From d97e486fb43db64a601b5cd3d0c7c17c2199a279 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Tue, 1 Jul 2008 21:02:36 +0000 Subject: [PATCH 0001/2031] Small modifications to place comments into the parse tree (Fairly inflexible at the moment) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10620 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 10 ++++++++++ Source/CParse/parser.y | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 2a0d341b5..140b7fedd 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -426,6 +426,14 @@ int yylook(void) { if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { scanner_locator(cmt); } + + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return DOXYGENSTRING; + } + + } break; case SWIG_TOKEN_ENDLINE: @@ -897,6 +905,8 @@ int yylex(void) { return (ID); case POUND: return yylex(); + case SWIG_TOKEN_COMMENT: + return yylex(); default: return (l); } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4fe8b47ed..6a835c7f3 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -55,6 +55,14 @@ static int max_class_levels = 0; static int class_level = 0; static Node **class_decl = NULL; +/* ----------------------------------------------------------------------------- + * Doxygen Comment Globals + * ----------------------------------------------------------------------------- */ + +int isComment = 0; /* boolean for parsing Doxygen Comments */ +String *currentComment = 0; /* Location of the stored Doxygen Comment */ +static String *sideDoxComments = 0; + /* ----------------------------------------------------------------------------- * Assist Functions * ----------------------------------------------------------------------------- */ @@ -71,6 +79,12 @@ static Node *new_node(const String_or_char *tag) { set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); + /* Sets Comment if a Comment is Availible */ + if(isComment){ + String *copyComment = Copy(currentComment); + Setattr(n,"comment",copyComment); + isComment = 0; + } return n; } @@ -1440,6 +1454,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { %token OPERATOR %token COPERATOR %token PARSETYPE PARSEPARM PARSEPARMS +%token DOXYGENSTRING %left CAST %left QUESTIONMARK @@ -1511,6 +1526,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { %type type_specifier primitive_type_list ; %type fname stringtype; %type featattr; +%type doxygen_comment; %% @@ -1568,6 +1584,7 @@ interface : interface declaration { declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } + | doxygen_comment { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; @@ -2811,6 +2828,7 @@ warn_directive : WARN string { } ; + /* ====================================================================== * C Parsing * ====================================================================== */ @@ -3132,6 +3150,20 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { } ; +/* ------------------------------------------------------------ + A Doxygen Comment (a string in Doxygen Format) + ------------------------------------------------------------ */ + +doxygen_comment : DOXYGENSTRING + { + currentComment = NewString($1); + isComment = 1; + $$ = 0; + } + ; + + + /* ====================================================================== * C++ Support * ====================================================================== */ @@ -5977,4 +6009,3 @@ ParmList *Swig_cparse_parms(String *s) { /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } - From 848e1b55fc8edb487e9b654b6cf7d3a55f1937ee Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Tue, 1 Jul 2008 22:06:28 +0000 Subject: [PATCH 0002/2031] Adding the Translator Module, which handles blobs of Doxygen Comments. Being heavily reworked at the moment. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10622 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/DoxygenEntity.cpp | 84 ++ Source/DoxygenTranslator/DoxygenEntity.h | 23 + .../DoxygenTranslator/DoxygenTranslator.cpp | 630 ++++++++++ Source/DoxygenTranslator/Skeleton | 1070 +++++++++++++++++ Source/DoxygenTranslator/example.i | 19 + 5 files changed, 1826 insertions(+) create mode 100644 Source/DoxygenTranslator/DoxygenEntity.cpp create mode 100644 Source/DoxygenTranslator/DoxygenEntity.h create mode 100644 Source/DoxygenTranslator/DoxygenTranslator.cpp create mode 100755 Source/DoxygenTranslator/Skeleton create mode 100644 Source/DoxygenTranslator/example.i diff --git a/Source/DoxygenTranslator/DoxygenEntity.cpp b/Source/DoxygenTranslator/DoxygenEntity.cpp new file mode 100644 index 000000000..9b02ade12 --- /dev/null +++ b/Source/DoxygenTranslator/DoxygenEntity.cpp @@ -0,0 +1,84 @@ +#include "DoxygenEntity.h" +#include + +/* Little data class for Doxygen Commands */ + + +/* Basic node for commands that have + * nothing after them + * example: \n + */ +string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; + +string findCommand(int commandNum){ + + int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); + if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ + return commandArray2[commandNum]; + } + + return "" ; +} + +DoxygenEntity::DoxygenEntity(int typeEnt){ + typeOfEntity = typeEnt; + data = ""; + isLeaf = 1; +} + +/* Basic node for commands that have + * only 1 thing after them + * example: \b word + * OR holding a string + */ +DoxygenEntity::DoxygenEntity(int typeEnt, string param1){ + typeOfEntity = typeEnt; + data = param1; + isLeaf = 1; +} + +/* Nonterminal node + * contains + */ +DoxygenEntity::DoxygenEntity(int typeEnt, list entList){ + typeOfEntity = typeEnt; + data = ""; + isLeaf = 0; + entityList = entList; +} + + +void DoxygenEntity::printEntity(){ + if (isLeaf) { + cout << "Node Command: " << findCommand(typeOfEntity); + if (data.compare("") != 0) cout << "Node Data: " << data; + cout << endl; + } + else{ + list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(); + p++; + } + } +} + +DoxygenEntity::~DoxygenEntity() +{ +} diff --git a/Source/DoxygenTranslator/DoxygenEntity.h b/Source/DoxygenTranslator/DoxygenEntity.h new file mode 100644 index 000000000..8330e4507 --- /dev/null +++ b/Source/DoxygenTranslator/DoxygenEntity.h @@ -0,0 +1,23 @@ + +#include +#include +#include +#include + +using namespace std; + +class DoxygenEntity{ + +public: + DoxygenEntity(int typeEnt); + DoxygenEntity(int typeEnt, string param1); + DoxygenEntity(int typeEnt, list entList); + virtual ~DoxygenEntity(); + void printEntity(); + int typeOfEntity; + list entityList; + string data; + int isLeaf; +}; + + diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp new file mode 100644 index 000000000..dadea41b5 --- /dev/null +++ b/Source/DoxygenTranslator/DoxygenTranslator.cpp @@ -0,0 +1,630 @@ +/* The main class for translating blobs of Doxygen for SWIG + * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program + * Currently the spacing/format on this is a bit goofy in places, due to shuffling code + * between 2 editors! Apologies for anyone combing through it :) + */ +//TODO DOH instead of STL? +//TODO Most commands are not fully implemented + +#include +#include +#include +#include +#include +#include "DoxygenEntity.h" + +using namespace std; + + +////////////////////////////////////////// +/*Set these to pick what internal functions +to test. */ + +//int testCommandParsingFunctions = 1;// not implemented + +int testCodeCrawlingFunctions = 1; +int demonstrateParsing = 0; + +////////////////////////////////////////// + + + +/* Globals*/ + + +// An array of all the commands and my generic description tag, plaindescription + +string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%", "plaindescription"}; + + +string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" }; + + + int startIndex = 0; + int endIndex = 0; + int isNewLine = 0; + + string doxygenString = ""; + int briefDescExists = 0; + + /* Entity list is the root list. + * it is arranged this way to help documentation modules, + * such as the javaDoc one, "sort" entities where they need to. + */ + + list rootList; + +/* General (untested) assist methods */ + + string StringToLower(string stringToConvert) + + {//change each element of the string to lower case + + for(unsigned int i=0;i= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description = ""; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping && endIndex < doxygenString.length()){ + if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } + + } + //endIndex = counter; + } + else if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + //cout << "2 "; + spareIndex = endIndex; + if (isSectionIndicator(getNextWord(spareIndex))) keepLooping = 0; + } + else if(endIndex < doxygenString.length() - 1 + && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ + //cout << "3 "; + keepLooping = 0; + } + if(keepLooping){ + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; + } + + /* This method is for a specific form of doxygen command + * that begins with a \command and ends in \endcommand + * such as \code and \endcode. The proper usage is + * progressTilEndCommand("endcode", index) + * currently this method does NOT process what is in between the two commands + */ + //TODO Make progressTilCommand return a formatted string + int progressTilEndCommand(string theCommand, int &startInd){ + endIndex = startInd; + while (endIndex < doxygenString.length()){ + if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; + if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ + startInd = endIndex + theCommand.length() + 1; + return 1; + } + } + endIndex++; + } + //End command not found + return 0; + } + + string getStringTilAnyCommand(string theCommand, int &startInd){ + endIndex = startInd; + startIndex = startInd; + int keepLooping = 1; + while (keepLooping && endIndex < doxygenString.length()){ + if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + startInd = endIndex; + keepLooping = 0; + } + endIndex++; + } + string description = ""; + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = endIndex; + return description; + return 0; + } + ///////////////TEST CLASSES AND MAIN BELOW///////////////// + + + /* Testing clearFluff(), a method to scan past all excess / * ! from beginning of + * a comment blob. Compartmentalised simply because this is a comment habit that + * differs wildly */ + + int testClearFluff(){ + + string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", + "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; + int testPassed = 1; + int casesSize = sizeof(cases)/sizeof(*cases); + for (int i = 0; i < casesSize; i++){ + doxygenString = cases[i]; + if(cases[i][clearFluff(0)] != 'W'){ + cout << "ClearFluff failed for string :" << doxygenString << "\t Displayed :" << cases[i][clearFluff(0)] << ": Instead." << endl; + testPassed = 0; + } + } + if(testPassed) cout << "+++ClearFluff passed for all tests+++\n" << endl; + else cout << "+++ClearFluff FAILED.+++" << endl; + return testPassed; + + }; + + int testGetNextWord(){ + string cases[] = {"/** WORD ", " * WORD ", "///!WORD ", " WORD ", "//! WORD ", " * WORD ", "*WORD "}; + int testPassed = 1; + string testWord = ""; + int placement = 0; + int casesSize = sizeof(cases)/sizeof(*cases); + for (int i = 0; i < casesSize; i++){ + doxygenString = cases[i]; + placement = 0; + testWord = getNextWord(placement); + if(testWord.compare("WORD") != 0){ + cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0; + } + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + } + placement = 0; + doxygenString = " * @WORD "; + testWord = getNextWord(placement); + if(testWord.compare("@WORD") != 0){ + cout << "GetNextWord failed for string :" + << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = " * "; + testWord.push_back(92); + testWord = testWord + "WORD "; + string commandWord = ""; + commandWord.push_back(92); + commandWord = commandWord + "WORD"; + doxygenString = testWord; + placement = 0; + testWord = getNextWord(placement); + if(testWord.compare(commandWord) != 0){ + cout << "GetNextWord failed for string :" << doxygenString + << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + doxygenString = "WORD ANOTHER WORD1 WORD2 \n"; + placement = 0; + testWord = getNextWord(placement); + if(testWord.compare("WORD") != 0){ + cout << "GetNextWord failed for string :" << doxygenString + << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = getNextWord(placement); + if(testWord.compare("ANOTHER") != 0){ + cout << "GetNextWord failed for string :" << doxygenString + << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = getNextWord(placement); + if(testWord.compare("WORD1") != 0){ + cout << "GetNextWord failed for string :" << doxygenString + << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = getNextWord(placement); + if(testWord.compare("WORD2") != 0){ + cout << "GetNextWord failed for string :" + << doxygenString << "\t Displayed :" << testWord + << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = getNextWord(placement); + if(testWord.compare("") != 0){ + cout << "GetNextWord failed for string :" << doxygenString + << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + testWord = getNextWord(placement); + if(testWord.compare("") != 0){ + cout << "GetNextWord failed for string :" << doxygenString << + "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0;} + //else cout << "GetNextWord passed for string :" << doxygenString << endl; + if(testPassed) cout << "+++NextWord passed for all tests+++\n" << endl; + else cout << "+++NextWord FAILED+++\n" << endl; + return testPassed; + } + + int testGetOneLine(){ + string cases[] = {" * Crop this sentence after this period.\n", + " * Crop this sentence after this period.\n", + "Crop this sentence after this period.\n", + "//! Crop this sentence after this period.\n", + " Crop this sentence after this period.\n" + }; + int testPassed = 1; + string testWord = ""; + int placement = 0; + int casesSize = sizeof(cases)/sizeof(*cases); + for (int i = 0; i < casesSize; i++){ + doxygenString = cases[i]; + placement = 0; + testWord = getOneLine(placement); + if(testWord.compare("Crop this sentence after this period.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0; + } + } + doxygenString = ("Get this line.\n * Now get this line."); + placement = 0; + testWord = getOneLine(placement); + if(testWord.compare("Get this line.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0; + } + testWord = getOneLine(placement); + if(testWord.compare("Now get this line.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0; + } + testWord = getOneLine(placement); + if(testWord.compare("") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; + testPassed = 0; + } + + if(testPassed) cout << "+++GetOneLine passed for all tests+++\n" << endl; + else cout << "+++GetOneLine FAILED+++\n" << endl; + return testPassed; + } +//TODO Flesh testGetStringTilEndOfParagraph out, fix weird spacing problems + int testGetStringTilEndOfParagraph(){ + int placement = 0; + int testPassed = 1; + string testParagraph; + doxygenString = ("/* This is a description,\n * thus it continues on\n * for several lines.\n\n This Shouldn't be included.\n\n **/"); + testParagraph = getStringTilEndOfParagraph(placement); + if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; + testPassed = 0; + } + //cout << "Curr Placement: " << placement<< endl; + testParagraph = getStringTilEndOfParagraph(placement); + //cout << "Curr Placement: " << placement<< endl; + if( testParagraph.compare(" This Shouldn't be included.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; + testPassed = 0; + } + + //cout << "Curr Placement: " << placement<< endl; + //cout << "String Length: " << doxygenString.length() << endl; + + doxygenString = "/* This is a description,\n * thus it continues on\n * for several lines.\n * \n * "; + doxygenString.push_back(92); + doxygenString += "author cheryl foil \n\n **/"; + placement = 0; + testParagraph = getStringTilEndOfParagraph(placement); + if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; + testPassed = 0; + } + + if(testPassed) cout << "+++GetDescription passed for all tests+++\n" << endl; + else cout << "+++GetDescription FAILED+++\n" << endl; + return testPassed; + } + + int testProgressTilEndCommand(){ + int placement = 0; + int testPassed = 1; + string testParagraph; + doxygenString = "Let's pretend this \n * is a bunch of code to be ended in "; + doxygenString.push_back(92); + doxygenString += "endcodeSTOP"; + progressTilEndCommand("endcode", placement); + //cout << "Placement : " << placement << endl; + if( doxygenString[placement] != 'S'){ + cout << "GetOneLine failed for string :" << doxygenString << "\n\t Displayed :" << testParagraph << ": Instead." << endl; + testPassed = 0; + } + if(testPassed) cout << "+++ProgressTilEndCommand passed for all tests+++\n" << endl; + else cout << "+++ProgressTilEndCommand FAILED+++\n" << endl; + return testPassed; + } + + int testCCF(){ + cout << "TESTING COMMAND PARSING FUNCTIONS" << endl; + cout << "Testing clearFluff" << endl; + testClearFluff(); + + cout << "Testing getNextWord" << endl; + testGetNextWord(); + cout << "Testing getOneLine"<< endl; + testGetOneLine(); + + cout << "Testing getStringTilEndOfParagraph" << endl; + testGetStringTilEndOfParagraph(); + + cout << "Testing progressTilEndCommand" << endl; + testProgressTilEndCommand(); + + return 1; + } + + /* prints the parse tree + * + */ + void printTree(){ + + list::iterator p = rootList.begin(); + while (p != rootList.end()){ + (*p).printEntity(); + p++; + } + + } + /* The actual "meat" of the doxygen parser. This is not yet fully implemented + * with my current design- however the skeletal outline is contained in + * the file Skeleton + */ + + int addCommand(int commentNum, int &startInd, list &doxyList){ + startIndex = startInd; + string name; + string nextWordInLine = ""; + string restOfLine = ""; + string restOfParagraph = ""; + string headerfile =""; + string headername = ""; + switch(commentNum){ + + + /* \b */ + case 108: + name = getNextWord(startIndex); + if (!name.empty()) doxyList.push_back( DoxygenEntity(108, name)); + else cout << "No word followed b command. Not added" << endl; + break; + /* \brief */ + case 109: + restOfParagraph = getStringTilEndOfParagraph(startIndex); + if(!restOfParagraph.empty()) doxyList.push_back( DoxygenEntity(109, restOfLine)); + else cout << "Nothing followed brief command. Not added" < entityList() ))); + + break; + + default: + cout << "Command " << commentNum << " not supported yet" << endl; + break; + } + startInd = startIndex; + } + + /* Returns the parse tree */ + +list parse(int startInd, int endInd, list &doxyList){ + string currWord = ""; + int startIndex = startInd; + int savedIndex; + int currCommand; + while (startIndex < endIndex){ + savedIndex = startIndex; + currWord = getNextWord(startIndex); + + if(currWord[0] == 92 || currWord[0] == '@'){ + currWord = doxygenString.substr(startIndex+1, currWord.length() - 1); + currCommand = findCommand(currWord); + if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} + //cout << "Command: " << currWord << " " << currCommand << endl; + addCommand(currCommand, startIndex, doxyList); + } + else{ + startIndex = savedIndex; + addCommand(238, startIndex, doxyList); + + } + } + + +} + + + int main(int argc, char *argv[]){ + if(testCodeCrawlingFunctions) testCCF(); + if (demonstrateParsing){ + int placement = 0; + clearFluff(0); + parse(0, doxygenString.length(), rootList); + printTree(); + } + return 1; + } diff --git a/Source/DoxygenTranslator/Skeleton b/Source/DoxygenTranslator/Skeleton new file mode 100755 index 000000000..099b94393 --- /dev/null +++ b/Source/DoxygenTranslator/Skeleton @@ -0,0 +1,1070 @@ +/** NOT A WORKING FILE- NOTES/SCRAPS + * A result of the initial implementation, + * stopped early because I changed my design. This is currently + * being reworked in the actual DoxygenTranslator class + */ + + + + +/* The Very Large and Unelegant Solution for dealing with Doxygen commands such as + * " \param". + * This is implemented this way because a LARGE number of potential Doxygen commands + * are not needed (such as PHP only or calling call graphs) and thus are simply + * thrown out. The more useful functions + * maybe be compartmentalised into their own method later on. + */ + +int addComment(int commentNum){ + + startIndex = endIndex; + string name; + string nextWordInLine = ""; + string restOfLine = ""; + string restOfParagraph = ""; + string headerfile =""; + string headername = ""; + switch(commentNum){ + + + /* \a */ + case 101: + nextWordInLine = getNextWord(); + if((nextWordInLine).empty()){ + cout << "Error: No word after tag a "<< endl; + } + else entityList.push_back( DoxygenEntity(101, "", nextWordInLine)); + startIndex = endIndex; + break; + + /* \addindex */ + case 102: + cout << "Add Index May not be Supported."<< endl; + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag a "<< endl; + } + else entityList.push_back( DoxygenEntity(102, "", restOfLine)); + startIndex = endIndex; + break; + + /* \addtogroup */ + case 103: + + + name = getNextWord(); + if (anythingLeftOnLine()){ + restOfLine = getOneLineSentence(); + entityList.push_back( DoxygenEntity(103, "", restOfLine)); + } + else cout << "AddtoGroup only supported for [(title)]. Command not added" << endl; + break; + + /* \anchor */ + case 104 : + getNextWord(); + cout << "Anchor is not supported. Command not added." << endl; + break; + + /* \arg */ + case 105: + + break; + + /* \attention */ + case 106: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(106, "", restOfLine)); + else cout << "Nothing followed attention command. Not added" < [] [] */ + case 115: + name = getNextWord(); + if (name.empty()) cout << "No word followed class command. Not added" <] */ + case 117: + cout << "cond is not supported. Command not added." << endl; + if (progressTilEndCommand("endcond") < 1) cout << "No endcode for command code found" << endl; + break; + + /* \copybrief */ + case 118: + getNextWord(); + cout << "copybrief is not yet implemented. Command not added." << endl; + break; + + /* \copydetails */ + case 119: + getNextWord(); + cout << "copydetails is not yet implemented. Command not added." << endl; + break; + + /* \copydoc */ + case 120: + getNextWord(); + cout << "copydoc is not yet implemented. Command not added." << endl; + break; + + /* \date { date description } */ + case 121: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(121, "", restOfLine)); + else cout << "Nothing followed date command. Not added" << endl; + break; + + /* \def */ + case 122: + name = getNextWord(); + if (!name.empty()) entityList.push_back( DoxygenEntity(122, name, "")); + else cout << "No word followed def command. Not added" << endl; + break; + + /* \defgroup (group title) */ + case 123: + name = getNextWord(); + if (name.empty())cout << "No word followed def command. Not added" << endl; + else { + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag a "<< endl; + } + else entityList.push_back( DoxygenEntity(123, name, restOfLine)); + } + break; + + /* \deprecated { description } */ + case 124: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(124, "", restOfLine)); + else cout << "Nothing followed deprecated command. Not added" << endl; + break; + + /* \details {detailed decription} */ + case 125: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(125, "", restOfLine)); + else cout << "Nothing followed details command. Not added" << endl; + break; + + /* \dir [] */ + case 126: + restOfLine = getOneLineSentence(); + entityList.push_back( DoxygenEntity(126, restOfLine , "")); + break; + + /* \dontinclude */ + case 127: + getNextWord(); + cout << "dontinclude is not implemented. Command not added." << endl; + break; + + /* \dot */ + case 128: + cout << "dot is not implemented. Command not added." << endl; + break; + + /* \dotfile ["caption"] */ + case 129: + getOneLineSentence(); + cout << "dotfile is not implemented. Command not added." << endl; + break; + + /* \e */ + case 130: + name = getNextWord(); + if (!name.empty()) entityList.push_back( DoxygenEntity(130, name, "")); + else cout << "No word followed e command. Not added" < */ + case 132: + getNextWord(); + cout << "elseif is not implemented. Command not added." << endl; + break; + + /* \em */ + /* Identical to e, so calls e */ + case 133: + addComment(130); + break; + + /* \endcode */ + case 134: + cout << "endcode is not implemented. Command not added." << endl; + break; + + /* \endcond */ + case 135: + cout << "endcond is not implemented. Command not added." << endl; + break; + + /* \enddot */ + case 136: + cout << "enddot is not implemented. Command not added." << endl; + break; + + /* \endhtmlonly */ + case 137: + cout << "endhtmlonly is not implemented. Command not added." << endl; + break; + + /* \endif */ + case 138: + cout << "endif is not implemented. Command not added." << endl; + break; + + /* \endlatexonly */ + case 139: + cout << "endlatexonly is not implemented. Command not added." << endl; + break; + + /* \endlink */ + case 140: + cout << "endlink is not implemented. Command not added." << endl; + break; + + /* \endmanonly */ + case 141: + cout << "endmanonly is not implemented. Command not added." << endl; + break; + + /* \endmsc */ + case 142: + cout << "endmsc is not implemented. Command not added." << endl; + break; + + /* \endverbatim */ + case 143: + cout << "endmsc is not implemented. Command not added." << endl; + break; + + /* \endxmlonly */ + case 144: + cout << "endxmlonly is not implemented. Command not added." << endl; + break; + + /* \enum */ + case 145: + name = getNextWord(); + if (!name.empty()) entityList.push_back( DoxygenEntity(145, name, "")); + else cout << "No word followed enum command. Not added" < */ + case 146: + name = getNextWord(); + if (!name.empty()) entityList.push_back( DoxygenEntity(146, name, "")); + else cout << "No word followed example command. Not added" < { exception description } */ + case 147: + name = getNextWord(); + if (name.empty()) cout << "No word followed exception command. Not added" < command. Not added" << endl; + } + break; + + /* \f$ */ + case 148: + cout << "f$ is not supported. Command not added." << endl; + if (progressTilEndCommand("f$") < 1) cout << "No endcode for command f$ found" << endl; + break; + + /* \f[ */ + case 149: + cout << "f$ is not supported. Command not added." << endl; + if (progressTilEndCommand("f]") < 1) cout << "No endcode for command f] found" << endl; + break; + + /* \f] */ + case 150: + cout << "f] is not implemented. Command not added." << endl; + break; + + /* \f{environment}{ */ + case 151: + cout << "f{environment}{ is not implemented. This may cause abnormal behaviour." << endl; + break; + + /* \f} */ + case 152: + cout << "f} is not implemented. This may cause abnormal behaviour." << endl; + break; + + /* \file [] */ + case 153: + name = getNextWord(); + if (!name.empty()) entityList.push_back( DoxygenEntity(153, name, "")); + else entityList.push_back( DoxygenEntity(153, "", "")); + break; + + /* \fn (function declaration) */ + case 154: + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag fn "<< endl; + } + else entityList.push_back( DoxygenEntity(154, restOfLine, "")); + break; + + /* \headerfile [] */ + case 155: + name = getNextWord(); + if (name.empty())cout << "No word followed headerfile command. Not added" << endl; + else { + restOfLine = getNextWord(); + entityList.push_back( DoxygenEntity(155, name, restOfLine)); + } + break; + + /* \hideinitializer */ + case 156: + cout << "hideinitializer is not implemented." << endl; + break; + + /* \htmlinclude */ + case 157: + name = getNextWord(); + if (name.empty())cout << "No word followed htmlinclude command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(157, name,"")); + } + break; + + /* \htmlonly */ + case 158: + cout << "htmlonly will be implemented later. For now the html is ignored." << endl; + if (progressTilEndCommand("endhtmlonly") < 1) cout << "No endcode for command code found" << endl; + break; + + /* \if */ + case 159: + cout << "if command is not implemented." << endl; + break; + + /* \ifnot */ + case 160: + cout << "ifnot command is not implemented." << endl; + break; + + /* \image ["caption"] [=] */ + case 161: + cout << "Image unsupported. Program may behave strangely if command is over one line." << endl; + getOneLineSentence(); + break; + + /* \include */ + case 162: + name = getNextWord(); + if (name.empty())cout << "No word followed include command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(162, name,"")); + } + break; + + /* \includelineno */ + case 163: + name = getNextWord(); + if (name.empty())cout << "No word followed includelineno command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(163, name,"")); + } + break; + + /* \ingroup ( [ ]) */ + case 164: + name = getNextWord(); + if (name.empty())cout << "No word followed ingroup command. Not added" << endl; + else { + string groupnames = getOneLineSentence(); + entityList.push_back( DoxygenEntity(164, name,groupnames)); + } + break; + + /* \internal */ + case 165: + entityList.push_back( DoxygenEntity(165, "","")); + break; + + /* \invariant { description of invariant } */ + case 166: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(166, restOfLine,"" )); + else cout << "Nothing followed invariant command. Not added" << endl; + break; + + /* \interface [] [] */ + case 167: + name = getNextWord(); + if (name.empty())cout << "No word followed ingroup command. Not added" << endl; + else { + string groupnames = getOneLineSentence(); + entityList.push_back( DoxygenEntity(167, name, groupnames)); + } + break; + + /* \latexonly */ + case 168: + cout << "latex only is not implemented" << endl; + if (progressTilEndCommand("endlatexonly") < 1) cout << "No endcode for command latexonly found" << endl; + break; + + /* \li { item-description } */ + //REDO + case 169: + addComment(105); + break; + + /* \line ( pattern ) */ + case 170: + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag line "<< endl; + } + else entityList.push_back( DoxygenEntity(170, restOfLine, "")); + break; + + /* \link */ + case 171: + name = getNextWord(); + if (name.empty())cout << "No word followed link command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(171, name,"")); + } + break; + + /* \mainpage [(title)] */ + case 172: + restOfLine = getOneLineSentence(); + entityList.push_back( DoxygenEntity(172, restOfLine, "")); + break; + + /* \manonly */ + case 173: + cout << "manonly is not implemented" << endl; + if (progressTilEndCommand("endmanonly") < 1) cout << "No endcode for command manonly found" << endl; + break; + + /* \msc */ + case 174: + cout << "msc is not implemented" << endl; + if (progressTilEndCommand("endmanonly") < 1) cout << "No endcode for command mscfound" << endl; + break; + + /* \n */ + case 175: + entityList.push_back( DoxygenEntity(175, "","")); + break; + + /* \name (header) */ + case 176: + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after header line "<< endl; + } + else entityList.push_back( DoxygenEntity(176, restOfLine, "")); + break; + + /* \namespace */ + case 177: + name = getNextWord(); + if (name.empty())cout << "No word followed namespace command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(177, name,"")); + } + break; + + /* \nosubgrouping */ + case 178: + cout << "Nosubgrouping not implemented "<< endl; + break; + + /* \note { text } */ + case 179: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(179, restOfLine,"" )); + else cout << "Nothing followed note command. Not added" << endl; + break; + + /* \overload [(function declaration)] */ + case 180: + restOfLine = getOneLineSentence(); + entityList.push_back( DoxygenEntity(172, restOfLine, "")); + break; + + /* \p */ + case 181: + name = getNextWord(); + if (name.empty())cout << "No word followed p command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(181, name,"")); + } + break; + + /* \package */ + case 182: + name = getNextWord(); + if (name.empty())cout << "No word followed package command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(182, name,"")); + } + break; + + /* \page (title) */ + case 183: + name = getNextWord(); + if (name.empty())cout << "No word followed page command. Not added" << endl; + else { + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag page "<< endl; + } + else entityList.push_back( DoxygenEntity(183, name, restOfLine)); + } + break; + + /* \par [(paragraph title)] { paragraph } */ + case 184: + name = getOneLineSentence(); + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(184, name, restOfParagraph )); + else cout << "Nothing followed par command. Not added" << endl; + break; + + /* \paragraph (paragraph title) */ + case 185: + name = getNextWord(); + if (name.empty())cout << "No word followed paragraph command. Not added" << endl; + else { + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after tag paragraph "<< endl; + } + else entityList.push_back( DoxygenEntity(185, name, restOfLine)); + } + break; + + /* \param { parameter description } */ + case 186: + name = getNextWord(); + if (name.empty())cout << "No word followed parameter command. Not added" << endl; + else { + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(186, name, restOfParagraph )); + else cout << "Nothing followed parameter command. Not added" << endl; + } + break; + + /* \post { description of the postcondition } */ + case 187: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(187, name, restOfParagraph )); + else cout << "Nothing followed post command. Not added" << endl; + break; + + /* \pre { description of the precondition } */ + case 188: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(187, name, restOfParagraph )); + else cout << "Nothing followed post command. Not added" << endl; + break; + + /* \private (PHP only) */ + case 189: + cout << "Private is a PHP Only Command." << endl; + break; + + /* \privatesection (PHP only) */ + case 190: + cout << "Privatesection is a PHP Only Command." << endl; + break; + + /* \property (qualified property name) */ + case 191: + restOfLine = getOneLineSentence(); + if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(191, restOfLine, "")); + else cout << "Nothing followed property command. Not added" << endl; + break; + + /* \protected (PHP only) */ + case 192: + cout << "Protected is a PHP Only Command." << endl; + break; + + /* \protectedsection (PHP only) */ + case 193: + cout << "Protectedsection is a PHP Only Command." << endl; + break; + + /* \protocol [] [] */ + case 194: + break; + + /* \public (PHP only) */ + case 195: + cout << "Public is a PHP Only Command." << endl; + break; + + /* \publicsection (PHP only) */ + case 196: + cout << "Public Section is a PHP Only Command." << endl; + break; + + /* \ref ["(text)"] */ + case 197: + name = getNextWord(); + getOneLineSentence(); + cout << "Ref is currently not supported." << endl; + break; + + /* \relates */ + case 198: + name = getNextWord(); + if (name.empty())cout << "No word followed relates command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(198, name,"")); + } + break; + + /* \relatesalso */ + case 199: + name = getNextWord(); + if (name.empty())cout << "No word followed relatesalso command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(199, name,"")); + } + break; + + /* \remarks { remark text } */ + case 200: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(200, restOfParagraph, "" )); + else cout << "Nothing followed remarks command. Not added" << endl; + break; + + /* \return { description of the return value } */ + case 201: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(200, restOfParagraph, "" )); + else cout << "Nothing followed return command. Not added" << endl; + break; + + /* \retval { description } */ + case 202: + name = getNextWord(); + if (name.empty())cout << "No word followed retval command. Not added" << endl; + else { + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(202, name, restOfParagraph )); + else cout << "Nothing followed retval command. Not added" << endl; + } + break; + + /* \sa { references } */ + case 203: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(203, restOfParagraph, "" )); + else cout << "Nothing followed sa command. Not added" << endl; + break; + + /* \section (section title) */ + case 204: + name = getNextWord(); + if (name.empty())cout << "No word followed section command. Not added" << endl; + else { + restOfLine = getOneLineSentence(); + if((restOfLine).empty()){ + cout << "Error: No word after section paragraph "<< endl; + } + else entityList.push_back( DoxygenEntity(204, name, restOfLine)); + } + break; + + /* \see { references } */ + case 205: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(205, restOfParagraph, "" )); + else cout << "Nothing followed see command. Not added" << endl; + break; + + /* \showinitializer */ + case 206: + cout << "Showerinitializer command unsupported"<< endl; + break; + + /* \since { text } */ + case 207: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(207, restOfParagraph, "" )); + else cout << "Nothing followed since command. Not added" << endl; + break; + + /* \skip ( pattern ) */ + case 208: + getOneLineSentence(); + cout << "Skip command unsupported"<< endl; + break; + + /* \skipline ( pattern ) */ + case 209: + getOneLineSentence(); + cout << "Skipline command unsupported"<< endl; + break; + + /* \struct [] [] */ + case 210: + name = getNextWord(); + if (name.empty())cout << "No word followed struct command. Not added" << endl; + else { + string groupnames = getOneLineSentence(); + entityList.push_back( DoxygenEntity(210, name, groupnames)); + } + break; + + /* \subpage ["(text)"] */ + case 211: + getOneLineSentence(); + cout << "subpag command unsupported"<< endl; + break; + + /* \subsection (subsection title) */ + case 212: + getOneLineSentence(); + cout << "subsection command unsupported"<< endl; + break; + + /* \subsubsection (subsubsection title) */ + case 213: + getOneLineSentence(); + cout << "subsubsection command unsupported"<< endl; + break; + + /* \test { paragraph describing a test case } */ + case 214: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(214, restOfParagraph, "" )); + else cout << "Nothing followed test command. Not added" << endl; + break; + + /* \throw { exception description } */ + case 215: + name = getNextWord(); + if (name.empty())cout << "No word followed throw command. Not added" << endl; + else { + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(215, name, restOfParagraph )); + else cout << "Nothing followed throw command. Not added" << endl; + } + break; + + /* \todo { paragraph describing what is to be done } */ + case 216: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(216, restOfParagraph, "" )); + else cout << "Nothing followed todo command. Not added" << endl; + break; + + /* \tparam { description } */ + case 217: + name = getNextWord(); + if (name.empty())cout << "No word followed tparam command. Not added" << endl; + else { + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(217, name, restOfParagraph )); + else cout << "Nothing followed tparam command. Not added" << endl; + } + break; + + /* \typedef (typedef declaration) */ + case 218: + restOfLine = getOneLineSentence(); + if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(218, restOfLine, "")); + else cout << "Nothing followed typedef command. Not added" << endl; + break; + + /* \union [] [] */ + case 219: + name = getNextWord(); + if (name.empty())cout << "No word followed union command. Not added" << endl; + else { + string groupnames = getOneLineSentence(); + entityList.push_back( DoxygenEntity(219, name, groupnames)); + } + break; + + /* \until ( pattern ) */ + case 220: + restOfLine = getOneLineSentence(); + if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(220, restOfLine, "")); + else cout << "Nothing followed until command. Not added" << endl; + break; + + /* \var (variable declaration) */ + case 221: + restOfLine = getOneLineSentence(); + if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(221, restOfLine, "")); + else cout << "Nothing followed var command. Not added" << endl; + break; + + /* \verbatim */ + case 222: + cout << "Verbatim is not supported. Command not added." << endl; + if (progressTilEndCommand("endverbatim") < 1) cout << "No endcode for command verbatim found" << endl; + break; + + /* \verbinclude */ + case 223: + name = getNextWord(); + if (name.empty())cout << "No word followed verbinclude command. Not added" << endl; + else { + entityList.push_back( DoxygenEntity(223, name,"")); + } + break; + + /* \version { version number } */ + case 224: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(224, restOfParagraph, "" )); + else cout << "Nothing followed version command. Not added" << endl; + break; + + /* \warning { warning message } */ + case 225: + restOfParagraph = stringTilEndOfParagraph(endIndex); + if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(225, restOfParagraph, "" )); + else cout << "Nothing followed warning command. Not added" << endl; + break; + + /* \weakgroup [(title)] */ + case 226: + name = getNextWord(); + if (name.empty())cout << "No word followed weakgroup command. Not added" << endl; + else { + string groupnames = getOneLineSentence(); + entityList.push_back( DoxygenEntity(226, name,groupnames)); + } + break; + + /* \xmlonly */ + case 227: + cout << "XML is not supported. Command not added." << endl; + if (progressTilEndCommand("endxmlonly") < 1) cout << "No endcode for command xmlonly found" << endl; + break; + + /* \xrefitem "(heading)" "(list title)" {text} */ + case 228: + //NEED TO IMPLEMENT + cout << "xrefitem is not supported yet. Command not added." << endl; + break; + + /* \$ */ + case 229: + entityList.push_back(229); + break; + + /* \@ */ + case 230: + entityList.push_back(230); + break; + + /* \\ */ + case 231: + entityList.push_back(231); + break; + + /* \& */ + case 232: + entityList.push_back(232); + break; + + /* \~[LanguageId] */ + case 233: + break; + + /* \< */ + case 234: + entityList.push_back(234); + break; + + /* \> */ + case 235: + entityList.push_back(235); + break; + + /* \# */ + case 236: + entityList.push_back(236); + break; + + /* \% */ + case 237: + entityList.push_back(237); + break; + + +} + + } + +int parse(string commentBlob){ + //NO error checking since this is only for my personal testing + // usage for now is "program -DocStyle filename + + /* + string java = "-java"; + + + if ((argc < 3)||(java.compare(StringToLower(argv[1])))!= 0 ) {cout << "Incorrect Usage. -Docstyle filename only." << endl; exit(1);} + string line; + ifstream doxCommentFile(argv[2], ios::in); + doxCommentFile >> doxygenString; + while(getline(doxCommentFile, line)){ + doxygenString += line + "\n";} + doxCommentFile.close(); + */ + doxygenString = commentBlob; + cout << doxygenString; + + +if(doxygenString.compare(0, 3, "/**")!= 0 && doxygenString.compare(0, 3, "/*!")!= 0 + && doxygenString.compare(0, 3, "///")!= 0 && doxygenString.compare(0, 3, "//!")!= 0 ){ + + cout << "String Is not in proper Doxygen format." << endl; + exit(1); + } + + +if(doxygenString[3] == '<'){ + cout << "Support for side comments not yet implemented"< 0){} + +while(endIndex < doxygenString.length() && startIndex < doxygenString.length()){ +currWord = getNextWord(); + +//while((currWord = nextWord()).compare("") == 0 ){ nextLine();} + +if(currWord[0] == 92 || currWord[0] == '@'){ + currWord = doxygenString.substr(startIndex+1, endIndex - startIndex - 1); + currCommand = findCommand(currWord); + if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} + cout << "Command: " << currWord << " " << currCommand << endl; + startIndex = endIndex; +} + +else if (briefDescriptions && !briefDescExists ){ + currComment = getOneLineSentence(); + if (!currComment.empty()){ + briefDescExists = 1; + cout << "Brief Description Found : " << currComment << endl << "-----" << endl; + entityList.push_back( DoxygenEntity(99, "", currComment)); + startIndex = endIndex; + } + else cout << "Error: Brief comment extends more than 1 line." << endl; +} + +else{ + currComment = getDescription(); + cout << "Long Description Found : " << currComment << endl << "-----" << endl; + entityList.push_back( DoxygenEntity(100, "", currComment)); + startIndex = endIndex; +} + +} + +cout << "Entity List : "<< endl; +list::iterator p = entityList.begin(); +while (p != entityList.end()){ + (*p).printEntity(); + p++; +} + + + return 0; +} + + +} + diff --git a/Source/DoxygenTranslator/example.i b/Source/DoxygenTranslator/example.i new file mode 100644 index 000000000..20f2488cb --- /dev/null +++ b/Source/DoxygenTranslator/example.i @@ -0,0 +1,19 @@ +/** File example. This is the Simple Test File! + */ + +%module example + +%inline %{ + +/** Function for Greater Common Divisor + * Compute the greatest common divisor of positive integers + * @param x an integer argument. + * @param y another integer argument. + * @return the GCD + */ +extern int gcd(int x, int y); + +/** Global Variable Foo. Foo is the value of Foo. + */ +extern double Foo; +%} From af125cd25151eaca3f96098c418326edf7a957c6 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 7 Jul 2008 02:59:22 +0000 Subject: [PATCH 0003/2031] Major overhaul to the basic structure of this parser, currently still sensitive and buggy. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10654 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/DoxygenEntity.cpp | 17 +- Source/DoxygenTranslator/DoxygenEntity.h | 10 +- .../DoxygenTranslator/DoxygenTranslator.cpp | 665 +++++++++++++++--- 3 files changed, 573 insertions(+), 119 deletions(-) diff --git a/Source/DoxygenTranslator/DoxygenEntity.cpp b/Source/DoxygenTranslator/DoxygenEntity.cpp index 9b02ade12..cd192601e 100644 --- a/Source/DoxygenTranslator/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/DoxygenEntity.cpp @@ -30,13 +30,13 @@ string findCommand(int commandNum){ int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ - return commandArray2[commandNum]; + return commandArray2[commandNum - 101]; } return "" ; } -DoxygenEntity::DoxygenEntity(int typeEnt){ +DoxygenEntity::DoxygenEntity(string typeEnt){ typeOfEntity = typeEnt; data = ""; isLeaf = 1; @@ -47,7 +47,7 @@ DoxygenEntity::DoxygenEntity(int typeEnt){ * example: \b word * OR holding a string */ -DoxygenEntity::DoxygenEntity(int typeEnt, string param1){ +DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ typeOfEntity = typeEnt; data = param1; isLeaf = 1; @@ -56,7 +56,7 @@ DoxygenEntity::DoxygenEntity(int typeEnt, string param1){ /* Nonterminal node * contains */ -DoxygenEntity::DoxygenEntity(int typeEnt, list entList){ +DoxygenEntity::DoxygenEntity(string typeEnt, list entList){ typeOfEntity = typeEnt; data = ""; isLeaf = 0; @@ -64,16 +64,19 @@ DoxygenEntity::DoxygenEntity(int typeEnt, list entList){ } -void DoxygenEntity::printEntity(){ +void DoxygenEntity::printEntity(int level){ if (isLeaf) { - cout << "Node Command: " << findCommand(typeOfEntity); + for (int i = 0; i < level; i++) {cout << "\t";} + cout << "Node Command: " << typeOfEntity << " "; if (data.compare("") != 0) cout << "Node Data: " << data; cout << endl; } else{ + cout << "Node Command : " << typeOfEntity << endl; list::iterator p = entityList.begin(); + level++; while (p != entityList.end()){ - (*p).printEntity(); + (*p).printEntity(level); p++; } } diff --git a/Source/DoxygenTranslator/DoxygenEntity.h b/Source/DoxygenTranslator/DoxygenEntity.h index 8330e4507..a0a99ed70 100644 --- a/Source/DoxygenTranslator/DoxygenEntity.h +++ b/Source/DoxygenTranslator/DoxygenEntity.h @@ -9,12 +9,12 @@ using namespace std; class DoxygenEntity{ public: - DoxygenEntity(int typeEnt); - DoxygenEntity(int typeEnt, string param1); - DoxygenEntity(int typeEnt, list entList); + DoxygenEntity(string typeEnt); + DoxygenEntity(string typeEnt, string param1); + DoxygenEntity(string typeEnt, list entList); virtual ~DoxygenEntity(); - void printEntity(); - int typeOfEntity; + void printEntity(int level); + string typeOfEntity; list entityList; string data; int isLeaf; diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp index dadea41b5..e2fdaef8a 100644 --- a/Source/DoxygenTranslator/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/DoxygenTranslator.cpp @@ -22,9 +22,10 @@ to test. */ //int testCommandParsingFunctions = 1;// not implemented -int testCodeCrawlingFunctions = 1; -int demonstrateParsing = 0; - +int testCodeCrawlingFunctions = 0; +int demonstrateParsing = 1; +int noisy = 1; // set this to 1 for extra chatter from the parsing stage. +int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); ////////////////////////////////////////// @@ -50,7 +51,7 @@ string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attent "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%", "plaindescription"}; + "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", @@ -58,12 +59,35 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", "version", "warning", "xrefitem" }; +/* All of the doxygen commands divided up by how they are parsed */ +string simpleCommands[] = {"n", "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; +string ignoredSimpleCommands[] = {"nothing at the moment"}; +string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; +string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; +string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; +string ignoreCommandLines[] = {"nothing at the moment"}; +string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"}; +string ignoreCommandParagraphs[] = {"nothing at the moment"}; +string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; +string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; +string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; +string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; +string commandOWords[] = {"dir", "file", "cond"}; +string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif"}; +string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li"}; int startIndex = 0; int endIndex = 0; int isNewLine = 0; - - string doxygenString = ""; + //string doxygenString = ""; int briefDescExists = 0; /* Entity list is the root list. @@ -99,6 +123,61 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d } return -1; } + + int commandBelongs(string theCommand){ + string smallString = StringToLower(theCommand ); + //cout << " Looking for command " << theCommand << endl; + int i = 0; + for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ + if(smallString.compare(simpleCommands[i]) == 0){return 1;} + } + for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ + if(smallString.compare(ignoredSimpleCommands[i]) == 0){return 2;} + } + for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ + if(smallString.compare( commandWords[i]) == 0){return 3;} + } + for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ + if(smallString.compare( ignoredCommandWords[i]) == 0){return 4;} + } + for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ + if(smallString.compare( commandLines[i]) == 0){return 5;} + } + for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ + if(smallString.compare( ignoreCommandLines[i]) == 0){return 6;} + } + for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ + if(smallString.compare( commandParagraph[i]) == 0){return 7;} + } + /* IgnoreCommandParagraph */ + for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ + if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return 8;} + } + for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ + if(smallString.compare( commandEndCommands[i]) == 0){return 9;} + } + for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ + if(smallString.compare( commandWordParagraphs[i]) == 0){return 10;} + } + for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ + if(smallString.compare( commandWordLines[i]) == 0){return 11;} + } + for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ + if(smallString.compare( commandWordOWordOWords[i]) == 0){return 12;} + } + for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ + if(smallString.compare( commandOWords[i]) == 0){return 13;} + } + for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ + if(smallString.compare( commandErrorThrowings[i]) == 0){return 14;} + } + for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ + if(smallString.compare( commandUniques[i]) == 0){return 15;} + } + + return 0; + + } /* isSectionIndicator returns a boolean if the command is a section indicator * This is a helper method for finding the end of a paragraph @@ -123,7 +202,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d /* Tiny method to compartmentalise the removal of all optional comment fluff such as /// * or **** that often occurs before commment blobs. */ - int clearFluff(int startInd){ + int clearFluff(int &startInd, string doxygenString){ int startIndex = startInd; int amountRemoved = 0; @@ -132,7 +211,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d startIndex++; amountRemoved++; } - + startInd = startIndex; return startIndex; } @@ -141,13 +220,13 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d * Updates the index it is given after completion. */ - string getNextWord(int &startInd){ + string getNextWord(int &startInd, string doxygenString){ int startIndex = startInd; string nextWord = ""; - while (doxygenString[startIndex] == '/'|| doxygenString[startIndex] == ' ' + while (startIndex < doxygenString.length() && (doxygenString[startIndex] == '/'|| doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '*' || doxygenString[startIndex]== '\n' - || doxygenString[startIndex] == '!'){ - if(doxygenString[startIndex]== '\n') return nextWord; + || doxygenString[startIndex] == '!')){ + if(doxygenString[startIndex]== '\n'){ startInd = startIndex; return nextWord;} startIndex++; //cout << "Start Index" << startIndex << endl; } @@ -168,7 +247,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d * and moved the index to the NEXT line * returns "" if nothing on the current line. */ - string getOneLine(int &startInd){ + string getOneLine(int &startInd, string doxygenString){ int startIndex = startInd; while (doxygenString[startIndex] == '/'|| doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '*' || doxygenString[startIndex]== '\n' @@ -187,13 +266,11 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d startInd = endIndex; return returnedLine; } - -/* Returns a Paragraph- defined in Doxygen to be a paragraph of text - * seperate by either a structural command or a blank line - * This method is VERY messy currently +/* Returns a properly formatted (all doxygen *, //! etc removed) + * up til ANY command or end of paragraph is encountered. Has all the same issues as + * getStringTilEndOfParagraph formatting wise. */ - //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters - string getStringTilEndOfParagraph(int &startInd){ +string getStringTilCommand(int &startInd, string doxygenString){ if (startInd >= doxygenString.length()) return ""; int startIndex = startInd; int endIndex = startInd; @@ -203,8 +280,89 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d int spareIndex = 0; int counter; int finalIndex; - while(keepLooping && endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == '\n'){ + while(keepLooping){ + if(endIndex >= doxygenString.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } + + } + //endIndex = counter; + } + else if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + finalIndex = endIndex; + keepLooping = 0; + } + else if(endIndex < doxygenString.length() -2 + && string("**/").compare(doxygenString.substr(endIndex , endIndex + 2)) == 0){ + finalIndex = endIndex; + //cout << "3 "; + keepLooping = 0; + } + if(keepLooping){ + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + //if(noisy) cout << "Final Index is: " << finalIndex << endl; + startInd = finalIndex; + return description; + } + + +/* Returns a Paragraph- defined in Doxygen to be a paragraph of text + * seperate by either a structural command or a blank line + * This method is VERY messy currently + */ + //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters + string getStringTilEndOfParagraph(int &startInd, string doxygenString){ + if (startInd >= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description = ""; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping){ + if(endIndex >= doxygenString.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ //cout << "1 "; counter = endIndex; if ( keepLooping && endIndex < doxygenString.length()-1) { @@ -226,7 +384,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d else if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ //cout << "2 "; spareIndex = endIndex; - if (isSectionIndicator(getNextWord(spareIndex))) keepLooping = 0; + if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) keepLooping = 0; } else if(endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ @@ -266,7 +424,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d * currently this method does NOT process what is in between the two commands */ //TODO Make progressTilCommand return a formatted string - int progressTilEndCommand(string theCommand, int &startInd){ + int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ endIndex = startInd; while (endIndex < doxygenString.length()){ if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ @@ -282,7 +440,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d return 0; } - string getStringTilAnyCommand(string theCommand, int &startInd){ + string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ endIndex = startInd; startIndex = startInd; int keepLooping = 1; @@ -319,15 +477,17 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d * differs wildly */ int testClearFluff(){ - + string doxygenString = ""; string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; int testPassed = 1; + int placement = 0; int casesSize = sizeof(cases)/sizeof(*cases); for (int i = 0; i < casesSize; i++){ + placement = 0; doxygenString = cases[i]; - if(cases[i][clearFluff(0)] != 'W'){ - cout << "ClearFluff failed for string :" << doxygenString << "\t Displayed :" << cases[i][clearFluff(0)] << ": Instead." << endl; + if(cases[i][clearFluff(placement, doxygenString)] != 'W'){ + cout << "ClearFluff failed for string :" << doxygenString << "\t Displayed :" << cases[i][clearFluff(placement = 0, doxygenString)] << ": Instead." << endl; testPassed = 0; } } @@ -338,6 +498,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d }; int testGetNextWord(){ + string doxygenString = ""; string cases[] = {"/** WORD ", " * WORD ", "///!WORD ", " WORD ", "//! WORD ", " * WORD ", "*WORD "}; int testPassed = 1; string testWord = ""; @@ -346,7 +507,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d for (int i = 0; i < casesSize; i++){ doxygenString = cases[i]; placement = 0; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("WORD") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0; @@ -355,7 +516,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d } placement = 0; doxygenString = " * @WORD "; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("@WORD") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; @@ -369,7 +530,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d commandWord = commandWord + "WORD"; doxygenString = testWord; placement = 0; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare(commandWord) != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; @@ -377,38 +538,38 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d //else cout << "GetNextWord passed for string :" << doxygenString << endl; doxygenString = "WORD ANOTHER WORD1 WORD2 \n"; placement = 0; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("WORD") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("ANOTHER") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("WORD1") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("WORD2") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement); + testWord = getNextWord(placement, doxygenString); if(testWord.compare("") != 0){ cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; @@ -420,6 +581,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d } int testGetOneLine(){ + string doxygenString = ""; string cases[] = {" * Crop this sentence after this period.\n", " * Crop this sentence after this period.\n", "Crop this sentence after this period.\n", @@ -433,7 +595,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d for (int i = 0; i < casesSize; i++){ doxygenString = cases[i]; placement = 0; - testWord = getOneLine(placement); + testWord = getOneLine(placement, doxygenString); if(testWord.compare("Crop this sentence after this period.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0; @@ -441,17 +603,17 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d } doxygenString = ("Get this line.\n * Now get this line."); placement = 0; - testWord = getOneLine(placement); + testWord = getOneLine(placement, doxygenString); if(testWord.compare("Get this line.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0; } - testWord = getOneLine(placement); + testWord = getOneLine(placement, doxygenString); if(testWord.compare("Now get this line.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0; } - testWord = getOneLine(placement); + testWord = getOneLine(placement, doxygenString); if(testWord.compare("") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; testPassed = 0; @@ -463,17 +625,18 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d } //TODO Flesh testGetStringTilEndOfParagraph out, fix weird spacing problems int testGetStringTilEndOfParagraph(){ + string doxygenString = ""; int placement = 0; int testPassed = 1; string testParagraph; doxygenString = ("/* This is a description,\n * thus it continues on\n * for several lines.\n\n This Shouldn't be included.\n\n **/"); - testParagraph = getStringTilEndOfParagraph(placement); + testParagraph = getStringTilEndOfParagraph(placement, doxygenString); if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; testPassed = 0; } //cout << "Curr Placement: " << placement<< endl; - testParagraph = getStringTilEndOfParagraph(placement); + testParagraph = getStringTilEndOfParagraph(placement, doxygenString); //cout << "Curr Placement: " << placement<< endl; if( testParagraph.compare(" This Shouldn't be included.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; @@ -487,25 +650,42 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d doxygenString.push_back(92); doxygenString += "author cheryl foil \n\n **/"; placement = 0; - testParagraph = getStringTilEndOfParagraph(placement); + testParagraph = getStringTilEndOfParagraph(placement, doxygenString); if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; testPassed = 0; } - if(testPassed) cout << "+++GetDescription passed for all tests+++\n" << endl; - else cout << "+++GetDescription FAILED+++\n" << endl; + if(testPassed) cout << "+++GetGetStringTilEndOfParagraph passed for all tests+++\n" << endl; + else cout << "+++GetGetStringTilEndOfParagraphFAILED+++\n" << endl; return testPassed; } + int testGetStringTilCommand(){ + string doxygenString = ""; + int placement = 0; + int testPassed = 1; + string testParagraph; + doxygenString = ("/* This is a description,\n * thus it continues on\n * for several @b lines.\n\n This Shouldn't be included.\n\n **/"); + testParagraph = getStringTilCommand(placement, doxygenString); + if( testParagraph.compare("This is a description, thus it continues on for several ") != 0){ + cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; + testPassed = 0; + } + if(testPassed) cout << "+++GetStringTilCommand passed for all tests+++\n" << endl; + else cout << "+++GetStringTilCommand FAILED+++\n" << endl; + return testPassed; + + } int testProgressTilEndCommand(){ + string doxygenString = ""; int placement = 0; int testPassed = 1; string testParagraph; doxygenString = "Let's pretend this \n * is a bunch of code to be ended in "; doxygenString.push_back(92); doxygenString += "endcodeSTOP"; - progressTilEndCommand("endcode", placement); + progressTilEndCommand("endcode", placement, doxygenString); //cout << "Placement : " << placement << endl; if( doxygenString[placement] != 'S'){ cout << "GetOneLine failed for string :" << doxygenString << "\n\t Displayed :" << testParagraph << ": Instead." << endl; @@ -532,6 +712,8 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d cout << "Testing progressTilEndCommand" << endl; testProgressTilEndCommand(); + cout << "Testing GetStringTilCommand" << endl; + testGetStringTilCommand(); return 1; } @@ -542,88 +724,357 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d list::iterator p = rootList.begin(); while (p != rootList.end()){ - (*p).printEntity(); + (*p).printEntity(0); p++; } } + + + + list parse(int startInd, string doxygenString){ + string currWord = ""; + int startIndex = startInd; + int savedIndex; + list aNewList; + endIndex = doxygenString.length(); + int currCommand; + while (startIndex < endIndex){ + savedIndex = startIndex; + currWord = getNextWord(startIndex, doxygenString); + if(noisy) cout << "Parsing for phrase starting in:" << currWord << endl; + if(currWord == ""){ + if (startIndex < endIndex) startIndex++; + } + else if(currWord[0] == 92 || currWord[0] == '@'){ + currWord = currWord.substr(1, currWord.length() - 1); + currCommand = findCommand(currWord); + if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} + //cout << "Command: " << currWord << " " << currCommand << endl; + addCommand(currWord, startIndex, aNewList, doxygenString); + } + else{ + startIndex = savedIndex; + addCommand(string("plainstring"), startIndex, aNewList, doxygenString); + + } + } + + return aNewList; + } + + /* Method for Adding a Simple Command + * Format: @command + * Plain commands, such as newline etc, they contain no other data + * \n \\ \@ \& \$ \# \< \> \% + */ + int addSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + + if (noisy) cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; + } + + /* NOT INCLUDED Simple Commands + * Format: @command + * Plain commands, such as newline etc, they contain no other data + */ + int ignoreSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + + if (noisy) cout << "Not Adding " << theCommand << endl; + return 1; + //doxyList.push_back(DoxygenEntity(108)); + } + + /* CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" + */ + int addCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()){ + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + else cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* NOT INCLUDED CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" + */ + int ignoreCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()){ + return 1; + } + else cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; + } + + /* CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" + */ + int addCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if(!line.empty()){ + int placement = 0; + list aNewList; + aNewList = parse(placement, line); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + + /* NOT INCLUDED CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if(!line.empty()){ + return 1; + } + else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; + } + + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single paragraph after then such as @return + * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" + */ + int addCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if(!restOfParagraph.empty()){ + int placement = 0; + list aNewList; + aNewList = parse(placement, restOfParagraph); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if(!restOfParagraph.empty()){ + return 1; + } + else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; + } + /* Command EndCommand + * Format: @command and ends at @endcommand + * Commands that take in a block of text such as @code + * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" + * Returns 1 if success, 0 if the endcommand is never encountered. + */ + + int ignoreCommandEndCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + return progressTilEndCommand( "end" + theCommand, startInd, doxygenString); + + } + + /* CommandWordParagraph + * Format: @command {paragraph} + * Commands such as param + * "param", "tparam", "throw", "retval", "exception" + */ + int addCommandWordParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if(!restOfParagraph.empty()){ + list aNewList; + aNewList = parse(placement, restOfParagraph); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No paragraph followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* CommandWordLine + * Format: @command (line) + * Commands such as param + * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" + */ + int addCommandWordLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if(!restOfLine.empty()){ + list aNewList; + aNewList = parse(placement, restOfLine); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + + /* Command Word Optional Word Optional Word + * Format: @command [] [] + * Commands such as class + * "category", "class", "protocol", "interface", "struct", "union" + */ + int addCommandWordOWordOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string headerfile = getNextWord(startInd, doxygenString); + string headername = getNextWord(startInd, doxygenString); + list aNewList; + aNewList.push_back(DoxygenEntity("plainstring", name)); + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + + /* Command Optional Word + * Format: @command [] + * Commands such as dir + * "dir", "file", "cond" + */ + int addCommandOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in * the file Skeleton */ - int addCommand(int commentNum, int &startInd, list &doxyList){ - startIndex = startInd; - string name; - string nextWordInLine = ""; - string restOfLine = ""; - string restOfParagraph = ""; - string headerfile =""; - string headername = ""; - switch(commentNum){ + int addCommand(string commandString, int &startInd, list &doxyList, string doxygenString){ + string theCommand = StringToLower(commandString); + string voidArray[] = {""}; + /* @command */ - /* \b */ - case 108: - name = getNextWord(startIndex); - if (!name.empty()) doxyList.push_back( DoxygenEntity(108, name)); - else cout << "No word followed b command. Not added" << endl; - break; - /* \brief */ - case 109: - restOfParagraph = getStringTilEndOfParagraph(startIndex); - if(!restOfParagraph.empty()) doxyList.push_back( DoxygenEntity(109, restOfLine)); - else cout << "Nothing followed brief command. Not added" < entityList() ))); - - break; - - default: - cout << "Command " << commentNum << " not supported yet" << endl; - break; + + if (theCommand.compare("plainstring") == 0){ + string nextPhrase = getStringTilCommand(startInd, doxygenString); + if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == 1){ + return addSimpleCommand(theCommand, startInd,doxyList, doxygenString); } - startInd = startIndex; + if (commandNumber == 2){ + return ignoreSimpleCommand(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 3){ + return addCommandWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 4){ + return ignoreCommandWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 5){ + return addCommandLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 6){ + return ignoreCommandLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 7){ + return addCommandParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 8){ + return ignoreCommandParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 9){ + return ignoreCommandEndCommand(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 10){ + return addCommandWordParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 11){ + return addCommandWordLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 12){ + return addCommandWordOWordOWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 13){ + return addCommandOWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == 14){ + return 0; + } + if (commandNumber == 15){ + return 0; + } + + return 0; + } + + int weirdTest(){ + string doxygenString = "this is a test."; + string restOfParagraph = ""; + int startIndex = 0; + restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); + cout << restOfParagraph<< " " << startIndex << endl; + + startIndex = 0; + restOfParagraph = getStringTilCommand(startIndex, doxygenString); + cout << restOfParagraph<< " " << startIndex << endl; } - /* Returns the parse tree */ + /* Returns a parse tree for a string */ -list parse(int startInd, int endInd, list &doxyList){ - string currWord = ""; - int startIndex = startInd; - int savedIndex; - int currCommand; - while (startIndex < endIndex){ - savedIndex = startIndex; - currWord = getNextWord(startIndex); - - if(currWord[0] == 92 || currWord[0] == '@'){ - currWord = doxygenString.substr(startIndex+1, currWord.length() - 1); - currCommand = findCommand(currWord); - if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} - //cout << "Command: " << currWord << " " << currCommand << endl; - addCommand(currCommand, startIndex, doxyList); - } - else{ - startIndex = savedIndex; - addCommand(238, startIndex, doxyList); - - } - } - - -} int main(int argc, char *argv[]){ + //weirdTest(); if(testCodeCrawlingFunctions) testCCF(); if (demonstrateParsing){ + string doxygenString = " This is a small sentence.\n *\n This is a line with a @b bold letter \n * \n @brief small @b description. **/"; + //string doxygenString = "This is a description.\n\n * @param x this is a parameter."; int placement = 0; - clearFluff(0); - parse(0, doxygenString.length(), rootList); + clearFluff(placement, doxygenString); + rootList = parse(placement, doxygenString); + cout << "---THE TREE---" << endl; printTree(); } return 1; From c727877cf9dd9f32cb47449a96c5012dfe45f10c Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Thu, 10 Jul 2008 04:18:22 +0000 Subject: [PATCH 0004/2031] Functionality fixes, small tweaks to make DoxygenTranslator more robust and the beginnings of a doxygen example collection git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10656 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/DoxygenEntity.cpp | 12 +- Source/DoxygenTranslator/DoxygenEntity.h | 2 +- .../DoxygenTranslator/DoxygenTranslator.cpp | 230 ++++++++++++------ Source/DoxygenTranslator/Examples/Example1 | 6 + Source/DoxygenTranslator/Examples/Example2 | 7 + Source/DoxygenTranslator/Examples/Example3 | 10 + Source/DoxygenTranslator/Examples/Example4 | 5 + 7 files changed, 186 insertions(+), 86 deletions(-) create mode 100644 Source/DoxygenTranslator/Examples/Example1 create mode 100644 Source/DoxygenTranslator/Examples/Example2 create mode 100644 Source/DoxygenTranslator/Examples/Example3 create mode 100644 Source/DoxygenTranslator/Examples/Example4 diff --git a/Source/DoxygenTranslator/DoxygenEntity.cpp b/Source/DoxygenTranslator/DoxygenEntity.cpp index cd192601e..6b8755592 100644 --- a/Source/DoxygenTranslator/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/DoxygenEntity.cpp @@ -24,7 +24,7 @@ string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "atten "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; + "$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; string findCommand(int commandNum){ @@ -56,7 +56,7 @@ DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ /* Nonterminal node * contains */ -DoxygenEntity::DoxygenEntity(string typeEnt, list entList){ +DoxygenEntity::DoxygenEntity(string typeEnt, list &entList ){ typeOfEntity = typeEnt; data = ""; isLeaf = 0; @@ -65,18 +65,20 @@ DoxygenEntity::DoxygenEntity(string typeEnt, list entList){ void DoxygenEntity::printEntity(int level){ + int thisLevel = level; if (isLeaf) { - for (int i = 0; i < level; i++) {cout << "\t";} + for (int i = 0; i < thisLevel; i++) {cout << "\t";} cout << "Node Command: " << typeOfEntity << " "; if (data.compare("") != 0) cout << "Node Data: " << data; cout << endl; } else{ + for (int i = 0; i < thisLevel; i++) {cout << "\t";} cout << "Node Command : " << typeOfEntity << endl; list::iterator p = entityList.begin(); - level++; + thisLevel++; while (p != entityList.end()){ - (*p).printEntity(level); + (*p).printEntity(thisLevel); p++; } } diff --git a/Source/DoxygenTranslator/DoxygenEntity.h b/Source/DoxygenTranslator/DoxygenEntity.h index a0a99ed70..734d09c8e 100644 --- a/Source/DoxygenTranslator/DoxygenEntity.h +++ b/Source/DoxygenTranslator/DoxygenEntity.h @@ -11,7 +11,7 @@ class DoxygenEntity{ public: DoxygenEntity(string typeEnt); DoxygenEntity(string typeEnt, string param1); - DoxygenEntity(string typeEnt, list entList); + DoxygenEntity(string typeEnt, list &entList ); virtual ~DoxygenEntity(); void printEntity(int level); string typeOfEntity; diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp index e2fdaef8a..13a3c56fe 100644 --- a/Source/DoxygenTranslator/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/DoxygenTranslator.cpp @@ -24,7 +24,8 @@ to test. */ int testCodeCrawlingFunctions = 0; int demonstrateParsing = 1; -int noisy = 1; // set this to 1 for extra chatter from the parsing stage. +int runExamples = 1; +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); ////////////////////////////////////////// @@ -51,7 +52,7 @@ string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attent "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; + "$", "@", "//","&", "~", "<", ">", "#", "%"}; string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", @@ -60,7 +61,7 @@ string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "d "version", "warning", "xrefitem" }; /* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = {"n", "$", "@", string(1, 92), string(1, '&'), "~", "<", ">", string(1, '#'), "%"}; +string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; string ignoredSimpleCommands[] = {"nothing at the moment"}; string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; @@ -84,10 +85,8 @@ string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "defin string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; - int startIndex = 0; - int endIndex = 0; + //int startIndex = 0; int isNewLine = 0; - //string doxygenString = ""; int briefDescExists = 0; /* Entity list is the root list. @@ -186,8 +185,8 @@ string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload int isSectionIndicator(string smallString){ smallString = StringToLower(smallString); - for (int i = 0; i < sizeof(commandArray)/sizeof(*commandArray); i++){ - if( smallString.compare(commandArray[i]) == 0){ + for (int i = 0; i < sizeof( sectionIndicators)/sizeof(* sectionIndicators); i++){ + if( smallString.compare( sectionIndicators[i]) == 0){ return 1; } } @@ -207,7 +206,7 @@ string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload int amountRemoved = 0; while(doxygenString[startIndex] == '/'|| doxygenString[startIndex] == '!' || doxygenString[startIndex] == '*' - || doxygenString[startIndex] == '\n' || doxygenString[startIndex] == ' '){ + || doxygenString[startIndex] == '\n' || doxygenString[startIndex] == ' '|| doxygenString[startIndex] == '\t'){ startIndex++; amountRemoved++; } @@ -222,9 +221,9 @@ string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload string getNextWord(int &startInd, string doxygenString){ int startIndex = startInd; - string nextWord = ""; + string nextWord; while (startIndex < doxygenString.length() && (doxygenString[startIndex] == '/'|| doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '*' || doxygenString[startIndex]== '\n' + || doxygenString[startIndex] == '*' || doxygenString[startIndex]== '\n' || doxygenString[startIndex] == '\t' || doxygenString[startIndex] == '!')){ if(doxygenString[startIndex]== '\n'){ startInd = startIndex; return nextWord;} startIndex++; @@ -233,7 +232,7 @@ string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload //cout << doxygenString[startIndex] << endl; int endIndex = startIndex; - while (doxygenString[endIndex]!= '\n' && doxygenString[endIndex]!= ' '){ + while (endIndex < doxygenString.length() && (doxygenString[endIndex]!= '\n' && doxygenString[endIndex]!= ' ')){ endIndex++; //cout << "End Index " << endIndex << endl; } @@ -251,7 +250,7 @@ string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload int startIndex = startInd; while (doxygenString[startIndex] == '/'|| doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '*' || doxygenString[startIndex]== '\n' - || doxygenString[startIndex] == '!'){ + || doxygenString[startIndex] == '!' || doxygenString[startIndex] == '\t'){ if(doxygenString[startIndex]== '\n') return ""; startIndex++; } @@ -274,7 +273,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ if (startInd >= doxygenString.length()) return ""; int startIndex = startInd; int endIndex = startInd; - string description = ""; + string description; /* Find the End of the description */ int keepLooping = 1; int spareIndex = 0; @@ -293,7 +292,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ //cout << "Counter :" << counter << endl; while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!') ){ + || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ if(doxygenString[counter] == '\n') { //cout << "Blank line found" << endl; keepLooping = 0; @@ -304,7 +303,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ } //endIndex = counter; } - else if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ finalIndex = endIndex; keepLooping = 0; } @@ -321,13 +320,13 @@ string getStringTilCommand(int &startInd, string doxygenString){ } //cout << "Done with EndIndex" << endl; while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; for (int i = startIndex; i < endIndex; i++){ if (doxygenString[i] == '\n') { - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t'|| doxygenString[i] == ' ' || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ i++; } @@ -351,7 +350,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ if (startInd >= doxygenString.length()) return ""; int startIndex = startInd; int endIndex = startInd; - string description = ""; + string description; /* Find the End of the description */ int keepLooping = 1; int spareIndex = 0; @@ -369,7 +368,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ counter++; //cout << "Counter :" << counter << endl; while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + doxygenString[counter] == '*'|| doxygenString[startIndex] == '\t' || doxygenString[counter] == '\n'|| doxygenString[counter] == '/' || doxygenString[counter] == '!') ){ if(doxygenString[counter] == '\n') { //cout << "Blank line found" << endl; @@ -381,30 +380,32 @@ string getStringTilCommand(int &startInd, string doxygenString){ } //endIndex = counter; } - else if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ - //cout << "2 "; - spareIndex = endIndex; - if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) keepLooping = 0; + //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap + else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + spareIndex = endIndex +1; + + if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { + keepLooping = 0; + finalIndex = endIndex;} } else if(endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - //cout << "3 "; keepLooping = 0; + finalIndex = endIndex; } if(keepLooping){ - //cout << "4 "; endIndex++; } } //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; for (int i = startIndex; i < endIndex; i++){ if (doxygenString[i] == '\n') { - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' ||doxygenString[startIndex] == '!' || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ i++; } @@ -425,9 +426,9 @@ string getStringTilCommand(int &startInd, string doxygenString){ */ //TODO Make progressTilCommand return a formatted string int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ - endIndex = startInd; + int endIndex = startInd; while (endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ + if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ startInd = endIndex + theCommand.length() + 1; @@ -440,34 +441,78 @@ string getStringTilCommand(int &startInd, string doxygenString){ return 0; } + /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered + */ + string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ - endIndex = startInd; - startIndex = startInd; - int keepLooping = 1; - while (keepLooping && endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == 92 || doxygenString[endIndex] == '@'){ - startInd = endIndex; - keepLooping = 0; - } - endIndex++; - } - string description = ""; - for (int i = startIndex; i < endIndex; i++){ + if (startInd >= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping){ + if(endIndex >= theCommand.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } - if (doxygenString[i] == '\n') { + } + //endIndex = counter; + } + else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + //cout << "2 "; + spareIndex = endIndex; + if (endIndex + theCommand.length() < theCommand.length() + && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) keepLooping = 0; + } + else if(endIndex < doxygenString.length() - 1 + && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ + //cout << "3 "; + keepLooping = 0; + } + if(keepLooping){ + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = endIndex; - return description; - return 0; + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; } ///////////////TEST CLASSES AND MAIN BELOW///////////////// @@ -477,7 +522,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ * differs wildly */ int testClearFluff(){ - string doxygenString = ""; + string doxygenString; string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; int testPassed = 1; @@ -498,10 +543,10 @@ string getStringTilCommand(int &startInd, string doxygenString){ }; int testGetNextWord(){ - string doxygenString = ""; + string doxygenString; string cases[] = {"/** WORD ", " * WORD ", "///!WORD ", " WORD ", "//! WORD ", " * WORD ", "*WORD "}; int testPassed = 1; - string testWord = ""; + string testWord; int placement = 0; int casesSize = sizeof(cases)/sizeof(*cases); for (int i = 0; i < casesSize; i++){ @@ -523,10 +568,10 @@ string getStringTilCommand(int &startInd, string doxygenString){ testPassed = 0;} //else cout << "GetNextWord passed for string :" << doxygenString << endl; testWord = " * "; - testWord.push_back(92); + testWord.push_back('\\'); testWord = testWord + "WORD "; - string commandWord = ""; - commandWord.push_back(92); + string commandWord; + commandWord.push_back('\\'); commandWord = commandWord + "WORD"; doxygenString = testWord; placement = 0; @@ -581,7 +626,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ } int testGetOneLine(){ - string doxygenString = ""; + string doxygenString; string cases[] = {" * Crop this sentence after this period.\n", " * Crop this sentence after this period.\n", "Crop this sentence after this period.\n", @@ -589,7 +634,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ " Crop this sentence after this period.\n" }; int testPassed = 1; - string testWord = ""; + string testWord; int placement = 0; int casesSize = sizeof(cases)/sizeof(*cases); for (int i = 0; i < casesSize; i++){ @@ -625,7 +670,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ } //TODO Flesh testGetStringTilEndOfParagraph out, fix weird spacing problems int testGetStringTilEndOfParagraph(){ - string doxygenString = ""; + string doxygenString; int placement = 0; int testPassed = 1; string testParagraph; @@ -647,7 +692,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ //cout << "String Length: " << doxygenString.length() << endl; doxygenString = "/* This is a description,\n * thus it continues on\n * for several lines.\n * \n * "; - doxygenString.push_back(92); + doxygenString.push_back('//'); doxygenString += "author cheryl foil \n\n **/"; placement = 0; testParagraph = getStringTilEndOfParagraph(placement, doxygenString); @@ -662,7 +707,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ } int testGetStringTilCommand(){ - string doxygenString = ""; + string doxygenString; int placement = 0; int testPassed = 1; string testParagraph; @@ -678,12 +723,12 @@ string getStringTilCommand(int &startInd, string doxygenString){ } int testProgressTilEndCommand(){ - string doxygenString = ""; + string doxygenString ; int placement = 0; int testPassed = 1; string testParagraph; doxygenString = "Let's pretend this \n * is a bunch of code to be ended in "; - doxygenString.push_back(92); + doxygenString.push_back('\\'); doxygenString += "endcodeSTOP"; progressTilEndCommand("endcode", placement, doxygenString); //cout << "Placement : " << placement << endl; @@ -733,11 +778,11 @@ string getStringTilCommand(int &startInd, string doxygenString){ list parse(int startInd, string doxygenString){ - string currWord = ""; + string currWord; int startIndex = startInd; int savedIndex; list aNewList; - endIndex = doxygenString.length(); + int endIndex = doxygenString.length(); int currCommand; while (startIndex < endIndex){ savedIndex = startIndex; @@ -746,12 +791,12 @@ string getStringTilCommand(int &startInd, string doxygenString){ if(currWord == ""){ if (startIndex < endIndex) startIndex++; } - else if(currWord[0] == 92 || currWord[0] == '@'){ + else if(currWord[0] == '\\' || currWord[0] == '@'){ currWord = currWord.substr(1, currWord.length() - 1); currCommand = findCommand(currWord); - if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} + if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currWord << endl;} //cout << "Command: " << currWord << " " << currCommand << endl; - addCommand(currWord, startIndex, aNewList, doxygenString); + else addCommand(currWord, startIndex, aNewList, doxygenString); } else{ startIndex = savedIndex; @@ -783,7 +828,6 @@ string getStringTilCommand(int &startInd, string doxygenString){ if (noisy) cout << "Not Adding " << theCommand << endl; return 1; - //doxyList.push_back(DoxygenEntity(108)); } /* CommandWord @@ -1051,7 +1095,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ int weirdTest(){ string doxygenString = "this is a test."; - string restOfParagraph = ""; + string restOfParagraph; int startIndex = 0; restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); cout << restOfParagraph<< " " << startIndex << endl; @@ -1061,16 +1105,42 @@ string getStringTilCommand(int &startInd, string doxygenString){ cout << restOfParagraph<< " " << startIndex << endl; } + + + int doRunExamples(){ + string line; + string filename; + string exampleNames[] = {"Examples/Example1","Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5"}; + int placement; + string doxygenString; + ifstream doxCommentFile; + for (int i = 0; i < 5; i++){ + doxCommentFile.open(exampleNames[i].c_str()); + doxCommentFile >> doxygenString; + while(getline(doxCommentFile, line)){ + doxygenString += line + "\n";} + doxCommentFile.close(); + placement = 0; + cout << "---RAW CODE---" << endl << doxygenString << endl< Date: Sun, 13 Jul 2008 04:51:51 +0000 Subject: [PATCH 0005/2031] Small tokenizer-related classes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10659 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/Token.cpp | 32 ++++++++ Source/DoxygenTranslator/Token.h | 21 +++++ Source/DoxygenTranslator/TokenList.cpp | 103 +++++++++++++++++++++++++ Source/DoxygenTranslator/TokenList.h | 24 ++++++ 4 files changed, 180 insertions(+) create mode 100644 Source/DoxygenTranslator/Token.cpp create mode 100644 Source/DoxygenTranslator/Token.h create mode 100644 Source/DoxygenTranslator/TokenList.cpp create mode 100644 Source/DoxygenTranslator/TokenList.h diff --git a/Source/DoxygenTranslator/Token.cpp b/Source/DoxygenTranslator/Token.cpp new file mode 100644 index 000000000..e85799546 --- /dev/null +++ b/Source/DoxygenTranslator/Token.cpp @@ -0,0 +1,32 @@ +#include "Token.h" +#include +#include +#include +#include +using namespace std; + + +Token::Token(int tType, string tString) +{ + tokenType = tType; + tokenString = tString; +} + +string Token::toString() +{ + if (tokenType == END_LINE){ + return "{END OF LINE}"; + } + if (tokenType == PARAGRAPH_END){ + return "{END OF PARAGRAPH}"; + } + if (tokenType == PLAINSTRING){ + return tokenString; + } + if (tokenType == COMMAND){ + return "{COMMAND : " + tokenString+ "}"; + } + return ""; +} + +Token:: ~Token(){} diff --git a/Source/DoxygenTranslator/Token.h b/Source/DoxygenTranslator/Token.h new file mode 100644 index 000000000..d569f5f7b --- /dev/null +++ b/Source/DoxygenTranslator/Token.h @@ -0,0 +1,21 @@ +#ifndef TOKEN_H_ +#define TOKEN_H_ +#include + +#define END_LINE 101 +#define PARAGRAPH_END 102 +#define PLAINSTRING 103 +#define COMMAND 104 +using namespace std; + +class Token +{ +public: + Token(int tType, string tString); + ~Token(); + int tokenType; + string tokenString; + string toString(); +}; + +#endif /*TOKEN_H_*/ diff --git a/Source/DoxygenTranslator/TokenList.cpp b/Source/DoxygenTranslator/TokenList.cpp new file mode 100644 index 000000000..6122328c4 --- /dev/null +++ b/Source/DoxygenTranslator/TokenList.cpp @@ -0,0 +1,103 @@ +#include "TokenList.h" +#include +#include +#include +#include +#include "Token.h" +#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list +#define END_LINE 101 +#define PARAGRAPH_END 102 //not used at the moment +#define PLAINSTRING 103 +#define COMMAND 104 +using namespace std; + + +list tokenList; +list::iterator tokenListIterator; +int noisy2 = 0; +/* The tokenizer*/ + +TokenList::TokenList(string doxygenString){ + int currentIndex = 0; + //Regex whitespace("[ \t]+"); + //Regex newLine("[\n]"); + //Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution + //Regex doxygenFluff("[/*!]+"); + int nextIndex = 0; + int isFluff = 0; + string currentWord; + while (currentIndex < doxygenString.length()){ + if(doxygenString[currentIndex] == '\n'){ + tokenList.push_back(Token(END_LINE, currentWord)); + currentIndex++; + } + while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' + || doxygenString[currentIndex]== '\t')) currentIndex ++; + if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached + else {nextIndex = currentIndex; + while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' + && doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; + currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); + if(noisy2) cout << "Current Word: " << currentWord << endl; + if (currentWord[0] == '@' || currentWord[0] == '\\'){ + currentWord = currentWord.substr(1, currentWord.length()-1); + tokenList.push_back(Token(COMMAND, currentWord)); + } + else if (currentWord[0] == '\n'){ + //if ((tokenList.back()).tokenType == END_LINE){} + tokenList.push_back(Token(END_LINE, currentWord)); + + } + else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ + if (currentWord.length() == 1) {isFluff = 1;} + else { isFluff = 1; + for(int i = 1; i < currentWord.length(); i++){ + if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0; + } + + } + if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); + } + + else tokenList.push_back(Token(PLAINSTRING, currentWord)); + currentIndex = nextIndex; + } + } + tokenListIterator = tokenList.begin(); +} + +Token TokenList::peek(){ + list::iterator p = tokenList.begin(); + if(p != tokenList.end()){ + p++; + Token returnedToken = (*p); + p--; + return returnedToken; + } + else + return Token(0, ""); +} + +Token TokenList::next(){ + list::iterator p = tokenList.begin(); + if(p != tokenList.end()){ + p++; + return (*p); + } + else + return Token(0, ""); +} + +void TokenList::printList(){ + list::iterator p = tokenList.begin(); + int i = 1; + int b = 0; + while (p != tokenList.end()){ + cout << (*p).toString() << " "; + b = i%TOKENSPERLINE; + if (b == 0) cout << endl; + p++; i++; + } +} + +TokenList:: ~TokenList(){} \ No newline at end of file diff --git a/Source/DoxygenTranslator/TokenList.h b/Source/DoxygenTranslator/TokenList.h new file mode 100644 index 000000000..153c69163 --- /dev/null +++ b/Source/DoxygenTranslator/TokenList.h @@ -0,0 +1,24 @@ +#ifndef TOKENLIST_H_ +#define TOKENLIST_H_ +#include +#include +#include +#include +#include "Token.h" +using namespace std; + +/* a small class used to represent the sequence of tokens + * that can be derived from a formatted doxygen string + */ + +class TokenList{ +public: + /* constructor takes a blob of Doxygen comment */ + TokenList(string doxygenString); + ~TokenList(); + Token peek(); /* returns next token without advancing */ + Token next(); /* returns next token and advances */ + void printList(); /* prints out the sequence of tokens */ +}; + +#endif /*TOKENLIST_H_*/ From cc6db6eab60d0226ea47bb3caa16e915ce84a6ca Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Wed, 16 Jul 2008 22:23:45 +0000 Subject: [PATCH 0006/2031] Reworking of DoxygenTranslator with the Tokenizer, more Doxygen commands implemented, beginning of the javaDoc convertor git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10670 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/DoxygenEntity.h | 5 +- .../DoxygenTranslator/DoxygenTranslator.cpp | 1470 +++++++---------- Source/DoxygenTranslator/JavaDocConverter.cpp | 104 ++ Source/DoxygenTranslator/JavaDocConverter.h | 17 + Source/DoxygenTranslator/Token.h | 4 +- Source/DoxygenTranslator/TokenList.cpp | 31 +- Source/DoxygenTranslator/TokenList.h | 7 +- 7 files changed, 716 insertions(+), 922 deletions(-) create mode 100644 Source/DoxygenTranslator/JavaDocConverter.cpp create mode 100644 Source/DoxygenTranslator/JavaDocConverter.h diff --git a/Source/DoxygenTranslator/DoxygenEntity.h b/Source/DoxygenTranslator/DoxygenEntity.h index 734d09c8e..0605b1cc9 100644 --- a/Source/DoxygenTranslator/DoxygenEntity.h +++ b/Source/DoxygenTranslator/DoxygenEntity.h @@ -1,3 +1,5 @@ +#ifndef DOXYGENENTITY_H_ +#define DOXYGENENTITY_H_ #include #include @@ -12,7 +14,7 @@ public: DoxygenEntity(string typeEnt); DoxygenEntity(string typeEnt, string param1); DoxygenEntity(string typeEnt, list &entList ); - virtual ~DoxygenEntity(); + ~DoxygenEntity(); void printEntity(int level); string typeOfEntity; list entityList; @@ -21,3 +23,4 @@ public: }; +#endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp index 13a3c56fe..d6129cda0 100644 --- a/Source/DoxygenTranslator/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/DoxygenTranslator.cpp @@ -1,106 +1,112 @@ -/* The main class for translating blobs of Doxygen for SWIG - * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - * Currently the spacing/format on this is a bit goofy in places, due to shuffling code - * between 2 editors! Apologies for anyone combing through it :) - */ -//TODO DOH instead of STL? -//TODO Most commands are not fully implemented -#include -#include -#include -#include -#include -#include "DoxygenEntity.h" + + //THE TOKENIZER REWORK -using namespace std; - - -////////////////////////////////////////// -/*Set these to pick what internal functions -to test. */ - -//int testCommandParsingFunctions = 1;// not implemented - -int testCodeCrawlingFunctions = 0; -int demonstrateParsing = 1; -int runExamples = 1; -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); -////////////////////////////////////////// - - - -/* Globals*/ - - -// An array of all the commands and my generic description tag, plaindescription - -string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "//","&", "~", "<", ">", "#", "%"}; - - -string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; - -/* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; -string ignoredSimpleCommands[] = {"nothing at the moment"}; -string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -string ignoreCommandLines[] = {"nothing at the moment"}; -string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"}; -string ignoreCommandParagraphs[] = {"nothing at the moment"}; -string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; -string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -string commandOWords[] = {"dir", "file", "cond"}; -string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; -string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; - - //int startIndex = 0; - int isNewLine = 0; - int briefDescExists = 0; - - /* Entity list is the root list. - * it is arranged this way to help documentation modules, - * such as the javaDoc one, "sort" entities where they need to. + /* The main class for translating blobs of Doxygen for SWIG + * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program + * Currently the spacing/format on this is a bit goofy in places, due to shuffling code + * between 2 editors! Apologies for anyone combing through it :) */ + //TODO DOH instead of STL? +//TODO work in Brief descriptions, detailed descriptions for autobrief - list rootList; + #include + #include + #include + #include + #include + #include "DoxygenEntity.h" + #include "TokenList.h" + #include "JavaDocConverter.h" + #define SIMPLECOMMAND 1 + #define IGNOREDSIMPLECOMMAND 2 + #define COMMANDWORD 3 + #define IGNOREDCOMMANDWORD 4 + #define COMMANDLINE 5 + #define IGNOREDCOMMANDLINE 6 + #define COMMANDPARAGRAPH 7 + #define IGNORECOMMANDPARAGRAPH 8 + #define COMMANDENDCOMMAND 9 + #define COMMANDWORDPARAGRAPH 10 + #define COMMANDWORDLINE 11 + #define COMMANDWORDOWORDWORD 12 + #define COMMANDOWORD 13 + #define COMMANDERRORTHROW 14 + #define COMMANDUNIQUE 15 +#define END_LINE 101 +#define PARAGRAPH_END 102 +#define PLAINSTRING 103 +#define COMMAND 104 + using namespace std; -/* General (untested) assist methods */ + ////////////////////////////////////////// + /*Set these to pick what internal functions + to test. */ + //int testCommandParsingFunctions = 1;// not implemented + + + int noisy = 0; // set this to 1 for extra chatter from the parsing stage. + int addCommand(string currCommand, TokenList &tokList, list &aNewList); + list parse(list::iterator endParsingIndex, TokenList &tokList); + + ////////////////////////////////////////// + + + string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "//","&", "~", "<", ">", "#", "%"}; + + + string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" }; + + /* All of the doxygen commands divided up by how they are parsed */ + string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; + string ignoredSimpleCommands[] = {"nothing at the moment"}; + string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; + string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; + string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; + string ignoreCommandLines[] = {"nothing at the moment"}; + string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; + string ignoreCommandParagraphs[] = {"nothing at the moment"}; + string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; + string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; + string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; + string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; + string commandOWords[] = {"dir", "file", "cond"}; + string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif"}; + string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li"}; + + + /* Changes a string to all lower case*/ string StringToLower(string stringToConvert) - {//change each element of the string to lower case + { for(unsigned int i=0;i= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } - - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - finalIndex = endIndex; - keepLooping = 0; - } - else if(endIndex < doxygenString.length() -2 - && string("**/").compare(doxygenString.substr(endIndex , endIndex + 2)) == 0){ - finalIndex = endIndex; - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; - - for (int i = startIndex; i < endIndex; i++){ - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t'|| doxygenString[i] == ' ' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - //if(noisy) cout << "Final Index is: " << finalIndex << endl; - startInd = finalIndex; - return description; - } - -/* Returns a Paragraph- defined in Doxygen to be a paragraph of text - * seperate by either a structural command or a blank line - * This method is VERY messy currently - */ - //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters - string getStringTilEndOfParagraph(int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[startIndex] == '\t' || doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } - - } - //endIndex = counter; - } - //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap - else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - spareIndex = endIndex +1; - - if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { - keepLooping = 0; - finalIndex = endIndex;} - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - keepLooping = 0; - finalIndex = endIndex; - } - if(keepLooping){ - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; - - for (int i = startIndex; i < endIndex; i++){ - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' ||doxygenString[startIndex] == '!' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } - - /* This method is for a specific form of doxygen command - * that begins with a \command and ends in \endcommand - * such as \code and \endcode. The proper usage is - * progressTilEndCommand("endcode", index) - * currently this method does NOT process what is in between the two commands - */ - //TODO Make progressTilCommand return a formatted string - int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ - int endIndex = startInd; - while (endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; - if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ - startInd = endIndex + theCommand.length() + 1; - return 1; - } - } - endIndex++; - } - //End command not found - return 0; - } - - /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered - */ - - string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= theCommand.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } - - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << "2 "; - spareIndex = endIndex; - if (endIndex + theCommand.length() < theCommand.length() - && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) keepLooping = 0; - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; - - for (int i = startIndex; i < endIndex; i++){ - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } - ///////////////TEST CLASSES AND MAIN BELOW///////////////// - - - /* Testing clearFluff(), a method to scan past all excess / * ! from beginning of - * a comment blob. Compartmentalised simply because this is a comment habit that - * differs wildly */ - - int testClearFluff(){ - string doxygenString; - string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", - "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; - int testPassed = 1; - int placement = 0; - int casesSize = sizeof(cases)/sizeof(*cases); - for (int i = 0; i < casesSize; i++){ - placement = 0; - doxygenString = cases[i]; - if(cases[i][clearFluff(placement, doxygenString)] != 'W'){ - cout << "ClearFluff failed for string :" << doxygenString << "\t Displayed :" << cases[i][clearFluff(placement = 0, doxygenString)] << ": Instead." << endl; - testPassed = 0; - } - } - if(testPassed) cout << "+++ClearFluff passed for all tests+++\n" << endl; - else cout << "+++ClearFluff FAILED.+++" << endl; - return testPassed; - - }; - - int testGetNextWord(){ - string doxygenString; - string cases[] = {"/** WORD ", " * WORD ", "///!WORD ", " WORD ", "//! WORD ", " * WORD ", "*WORD "}; - int testPassed = 1; - string testWord; - int placement = 0; - int casesSize = sizeof(cases)/sizeof(*cases); - for (int i = 0; i < casesSize; i++){ - doxygenString = cases[i]; - placement = 0; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("WORD") != 0){ - cout << "GetNextWord failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0; - } - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - } - placement = 0; - doxygenString = " * @WORD "; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("@WORD") != 0){ - cout << "GetNextWord failed for string :" - << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = " * "; - testWord.push_back('\\'); - testWord = testWord + "WORD "; - string commandWord; - commandWord.push_back('\\'); - commandWord = commandWord + "WORD"; - doxygenString = testWord; - placement = 0; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare(commandWord) != 0){ - cout << "GetNextWord failed for string :" << doxygenString - << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - doxygenString = "WORD ANOTHER WORD1 WORD2 \n"; - placement = 0; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("WORD") != 0){ - cout << "GetNextWord failed for string :" << doxygenString - << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("ANOTHER") != 0){ - cout << "GetNextWord failed for string :" << doxygenString - << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("WORD1") != 0){ - cout << "GetNextWord failed for string :" << doxygenString - << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("WORD2") != 0){ - cout << "GetNextWord failed for string :" - << doxygenString << "\t Displayed :" << testWord - << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("") != 0){ - cout << "GetNextWord failed for string :" << doxygenString - << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - testWord = getNextWord(placement, doxygenString); - if(testWord.compare("") != 0){ - cout << "GetNextWord failed for string :" << doxygenString << - "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0;} - //else cout << "GetNextWord passed for string :" << doxygenString << endl; - if(testPassed) cout << "+++NextWord passed for all tests+++\n" << endl; - else cout << "+++NextWord FAILED+++\n" << endl; - return testPassed; - } - - int testGetOneLine(){ - string doxygenString; - string cases[] = {" * Crop this sentence after this period.\n", - " * Crop this sentence after this period.\n", - "Crop this sentence after this period.\n", - "//! Crop this sentence after this period.\n", - " Crop this sentence after this period.\n" - }; - int testPassed = 1; - string testWord; - int placement = 0; - int casesSize = sizeof(cases)/sizeof(*cases); - for (int i = 0; i < casesSize; i++){ - doxygenString = cases[i]; - placement = 0; - testWord = getOneLine(placement, doxygenString); - if(testWord.compare("Crop this sentence after this period.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0; - } - } - doxygenString = ("Get this line.\n * Now get this line."); - placement = 0; - testWord = getOneLine(placement, doxygenString); - if(testWord.compare("Get this line.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0; - } - testWord = getOneLine(placement, doxygenString); - if(testWord.compare("Now get this line.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0; - } - testWord = getOneLine(placement, doxygenString); - if(testWord.compare("") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testWord << ": Instead." << endl; - testPassed = 0; - } - - if(testPassed) cout << "+++GetOneLine passed for all tests+++\n" << endl; - else cout << "+++GetOneLine FAILED+++\n" << endl; - return testPassed; - } -//TODO Flesh testGetStringTilEndOfParagraph out, fix weird spacing problems - int testGetStringTilEndOfParagraph(){ - string doxygenString; - int placement = 0; - int testPassed = 1; - string testParagraph; - doxygenString = ("/* This is a description,\n * thus it continues on\n * for several lines.\n\n This Shouldn't be included.\n\n **/"); - testParagraph = getStringTilEndOfParagraph(placement, doxygenString); - if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; - testPassed = 0; - } - //cout << "Curr Placement: " << placement<< endl; - testParagraph = getStringTilEndOfParagraph(placement, doxygenString); - //cout << "Curr Placement: " << placement<< endl; - if( testParagraph.compare(" This Shouldn't be included.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; - testPassed = 0; - } - - //cout << "Curr Placement: " << placement<< endl; - //cout << "String Length: " << doxygenString.length() << endl; - - doxygenString = "/* This is a description,\n * thus it continues on\n * for several lines.\n * \n * "; - doxygenString.push_back('//'); - doxygenString += "author cheryl foil \n\n **/"; - placement = 0; - testParagraph = getStringTilEndOfParagraph(placement, doxygenString); - if( testParagraph.compare("This is a description, thus it continues on for several lines.") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; - testPassed = 0; - } - - if(testPassed) cout << "+++GetGetStringTilEndOfParagraph passed for all tests+++\n" << endl; - else cout << "+++GetGetStringTilEndOfParagraphFAILED+++\n" << endl; - return testPassed; - } - - int testGetStringTilCommand(){ - string doxygenString; - int placement = 0; - int testPassed = 1; - string testParagraph; - doxygenString = ("/* This is a description,\n * thus it continues on\n * for several @b lines.\n\n This Shouldn't be included.\n\n **/"); - testParagraph = getStringTilCommand(placement, doxygenString); - if( testParagraph.compare("This is a description, thus it continues on for several ") != 0){ - cout << "GetOneLine failed for string :" << doxygenString << "\t Displayed :" << testParagraph << ": Instead." << endl; - testPassed = 0; - } - if(testPassed) cout << "+++GetStringTilCommand passed for all tests+++\n" << endl; - else cout << "+++GetStringTilCommand FAILED+++\n" << endl; - return testPassed; - - } - int testProgressTilEndCommand(){ - string doxygenString ; - int placement = 0; - int testPassed = 1; - string testParagraph; - doxygenString = "Let's pretend this \n * is a bunch of code to be ended in "; - doxygenString.push_back('\\'); - doxygenString += "endcodeSTOP"; - progressTilEndCommand("endcode", placement, doxygenString); - //cout << "Placement : " << placement << endl; - if( doxygenString[placement] != 'S'){ - cout << "GetOneLine failed for string :" << doxygenString << "\n\t Displayed :" << testParagraph << ": Instead." << endl; - testPassed = 0; - } - if(testPassed) cout << "+++ProgressTilEndCommand passed for all tests+++\n" << endl; - else cout << "+++ProgressTilEndCommand FAILED+++\n" << endl; - return testPassed; - } - - int testCCF(){ - cout << "TESTING COMMAND PARSING FUNCTIONS" << endl; - cout << "Testing clearFluff" << endl; - testClearFluff(); - - cout << "Testing getNextWord" << endl; - testGetNextWord(); - cout << "Testing getOneLine"<< endl; - testGetOneLine(); - - cout << "Testing getStringTilEndOfParagraph" << endl; - testGetStringTilEndOfParagraph(); - - cout << "Testing progressTilEndCommand" << endl; - testProgressTilEndCommand(); - - cout << "Testing GetStringTilCommand" << endl; - testGetStringTilCommand(); - return 1; - } - /* prints the parse tree * */ - void printTree(){ + void printTree( list &rootList){ list::iterator p = rootList.begin(); while (p != rootList.end()){ @@ -775,45 +160,217 @@ string getStringTilCommand(int &startInd, string doxygenString){ } - - - list parse(int startInd, string doxygenString){ - string currWord; - int startIndex = startInd; - int savedIndex; - list aNewList; - int endIndex = doxygenString.length(); - int currCommand; - while (startIndex < endIndex){ - savedIndex = startIndex; - currWord = getNextWord(startIndex, doxygenString); - if(noisy) cout << "Parsing for phrase starting in:" << currWord << endl; - if(currWord == ""){ - if (startIndex < endIndex) startIndex++; - } - else if(currWord[0] == '\\' || currWord[0] == '@'){ - currWord = currWord.substr(1, currWord.length() - 1); - currCommand = findCommand(currWord); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currWord << endl;} - //cout << "Command: " << currWord << " " << currCommand << endl; - else addCommand(currWord, startIndex, aNewList, doxygenString); - } - else{ - startIndex = savedIndex; - addCommand(string("plainstring"), startIndex, aNewList, doxygenString); + /* Determines how a command should be handled (what group it belongs to + * for parsing rules + */ + int commandBelongs(string theCommand){ + string smallString = StringToLower(theCommand ); + //cout << " Looking for command " << theCommand << endl; + int i = 0; + for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ + if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND ;} + } + for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ + if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} + } + for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ + if(smallString.compare( commandWords[i]) == 0){return COMMANDWORD;} + } + for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ + if(smallString.compare( ignoredCommandWords[i]) == 0){return IGNOREDCOMMANDWORD;} + } + for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ + if(smallString.compare( commandLines[i]) == 0){return COMMANDLINE;} + } + for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ + if(smallString.compare( ignoreCommandLines[i]) == 0){return IGNOREDCOMMANDLINE;} + } + for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ + if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} + } + /* IgnoreCommandParagraph */ + for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ + if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} + } + for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ + if(smallString.compare( commandEndCommands[i]) == 0){return COMMANDENDCOMMAND ;} + } + for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ + if(smallString.compare( commandWordParagraphs[i]) == 0){return COMMANDWORDPARAGRAPH;} + } + for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ + if(smallString.compare( commandWordLines[i]) == 0){return COMMANDWORDLINE ;} + } + for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ + if(smallString.compare( commandWordOWordOWords[i]) == 0){return COMMANDWORDOWORDWORD;} + } + for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ + if(smallString.compare( commandOWords[i]) == 0){return COMMANDOWORD;} + } + for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ + if(smallString.compare( commandErrorThrowings[i]) == 0){return COMMANDERRORTHROW;} + } + for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ + if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} + } + + return 0; + + } + /* Returns the next word ON THE CURRENT LINE ONLY + * if a new line is encountered, returns a blank string. + * Updates the index it is given if success. + */ + + string getNextWord(TokenList &tokList){ + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING ){ + nextToken = tokList.next(); + return nextToken.tokenString; + } + return ""; + } + + /* Returns the location of the end of the line as + * an iterator. + */ + list::iterator getOneLine(TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == END_LINE){ + return endOfParagraph; + } + endOfParagraph++; + } + return tokList.end(); + } + + + +/* Returns a properly formatted string + * up til ANY command or end of paragraph is encountered. + */ +string getStringTilCommand(TokenList &tokList){ + string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){ + Token currentToken = tokList.next(); + if(currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } + else if (tokList.peek().tokenType == END_LINE) break; + } + + return description; + } + +/* Returns a properly formatted string + * up til the command specified is encountered + */ +//TODO check that this behaves properly for formulas + +string getStringTilEndCommand(string theCommand, TokenList &tokList){ + string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenString.compare(theCommand) != 0 ){ + Token currentToken = tokList.next(); + description = description + currentToken.tokenString + " "; + + } + + return description; + } + +/* Returns the end of a Paragraph as an iterator- + * Paragraph is defined in Doxygen to be a paragraph of text + * seperate by either a structural command or a blank line + */ + +list::iterator getEndOfParagraph(TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == COMMAND){ + if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + return endOfParagraph; + } + } + + } + + return tokList.end(); + + } + +/* Returns the end of a section, defined as the first blank line OR first encounter of the same + * command. Example of this behaviour is \arg + */ + +list::iterator getEndOfSection(string theCommand, TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == COMMAND){ + if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + return endOfParagraph; + } + } + + } +} + /* This method is for returning the end of a specific form of doxygen command + * that begins with a \command and ends in \endcommand + * such as \code and \endcode. The proper usage is + * progressTilEndCommand("endcode", tokenList); + */ +list::iterator getEndCommand(string theCommand, TokenList &tokList){ + list::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand!= tokList.end()){ + if ((*endOfCommand).tokenType == COMMAND){ + if (theCommand.compare((* endOfCommand).tokenString) == 0){ + return endOfCommand; + } + endOfCommand++; } } - - return aNewList; + //End command not found + return tokList.end(); } + + /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered + */ + +list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ + list::iterator anIterator; + return anIterator; + } + + + /* Method for Adding a Simple Command * Format: @command * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ - int addSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addSimpleCommand(string theCommand, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); @@ -824,7 +381,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Format: @command * Plain commands, such as newline etc, they contain no other data */ - int ignoreSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int ignoreSimpleCommand(string theCommand, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; return 1; @@ -836,9 +393,9 @@ string getStringTilCommand(int &startInd, string doxygenString){ * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" */ - int addCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandWord(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); if (!name.empty()){ doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; @@ -851,9 +408,9 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ - int ignoreCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int ignoreCommandWord(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); if (!name.empty()){ return 1; } @@ -866,18 +423,14 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands with a single LINE after then such as @var * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" */ - int addCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandLine(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - int placement = 0; + list::iterator endOfLine = getOneLine(tokList); list aNewList; - aNewList = parse(placement, line); + aNewList = parse(endOfLine, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; + } /* NOT INCLUDED CommandLine @@ -885,14 +438,11 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands with a single LINE after then such as @var * */ - int ignoreCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int ignoreCommandLine(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; + list::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 1; } /* CommandParagraph @@ -901,32 +451,28 @@ string getStringTilCommand(int &startInd, string doxygenString){ * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" */ - int addCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - int placement = 0; - list aNewList; - aNewList = parse(placement, restOfParagraph); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + //if(!restOfParagraph.empty()){ + list aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + // } + //else cout << "No line followed " << theCommand << " command. Not added" << endl; } /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var * */ - int ignoreCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int ignoreCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + //else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 1; } /* Command EndCommand * Format: @command and ends at @endcommand @@ -936,10 +482,11 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Returns 1 if success, 0 if the endcommand is never encountered. */ - int ignoreCommandEndCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandEndCommand(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - return progressTilEndCommand( "end" + theCommand, startInd, doxygenString); - + string description = getStringTilEndCommand( "end" + theCommand, tokList); + doxyList.push_back(DoxygenEntity(theCommand, description)); + return 1; } /* CommandWordParagraph @@ -947,23 +494,19 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands such as param * "param", "tparam", "throw", "retval", "exception" */ - int addCommandWordParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandWordParagraph(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfParagraph.empty()){ + list::iterator endOfParagraph = getEndOfParagraph(tokList); + //if(!restOfParagraph.empty()){ list aNewList; - aNewList = parse(placement, restOfParagraph); + aNewList = parse(endOfParagraph, tokList); aNewList.push_front(DoxygenEntity("plainstring", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No paragraph followed " << theCommand << " command. Not added" << endl; return 0; } /* CommandWordLine @@ -971,40 +514,37 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ - int addCommandWordLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandWordLine(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfLine.empty()){ - list aNewList; - aNewList = parse(placement, restOfLine); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; + list::iterator endOfLine = getOneLine(tokList); + list aNewList; + aNewList = parse(endOfLine, tokList); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + + //else cout << "No line followed " << theCommand << " command. Not added" << endl; } - + /* Command Word Optional Word Optional Word * Format: @command [] [] * Commands such as class * "category", "class", "protocol", "interface", "struct", "union" */ - int addCommandWordOWordOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - string headerfile = getNextWord(startInd, doxygenString); - string headername = getNextWord(startInd, doxygenString); + string headerfile = getNextWord(tokList); + string headername = getNextWord(tokList); list aNewList; aNewList.push_back(DoxygenEntity("plainstring", name)); if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); @@ -1018,12 +558,138 @@ string getStringTilCommand(int &startInd, string doxygenString){ * Commands such as dir * "dir", "file", "cond" */ - int addCommandOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + int addCommandOWord(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); + string name = getNextWord(tokList); doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; } + + /* Commands that should not be encountered (such as PHP only) + */ + int addCommandErrorThrow(string theCommand, TokenList &tokList, list &doxyList){ + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } + + + int addCommandUnique(string theCommand, TokenList &tokList, list &doxyList){ + list aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ + list::iterator endOfSection = getEndOfSection(theCommand, tokList); + list aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + } + + // \xrefitem "(heading)" "(list title)" {text} + else if (theCommand.compare("xrefitem") == 0){ + //TODO Implement xrefitem + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; + } + // \ingroup ( [ ]) + else if (theCommand.compare("ingroup") == 0){ + string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \par [(paragraph title)] { paragraph } + else if (theCommand.compare("par") == 0){ + list::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + list aNewList2; + aNewList2 = parse(endOfLine, tokList); + aNewList.splice(aNewList.end(), aNewList2); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \headerfile [] + else if (theCommand.compare("headerfile") == 0){ + list aNewList; + string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \overload [(function declaration)] + else if (theCommand.compare("overload") == 0){ + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()){ + list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + else doxyList.push_back(DoxygenEntity(theCommand)); + } + // \weakgroup [(title)] + else if (theCommand.compare("weakgroup") == 0){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list aNewList; + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + // \ref ["(text)"] + else if (theCommand.compare("ref") == 0){ + //TODO Implement ref + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \subpage ["(text)"] + else if (theCommand.compare("subpage") == 0){ + //TODO implement subpage + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \dotfile ["caption"] + else if (theCommand.compare("dotfile") == 0){ + //TODO implement dotfile + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \image ["caption"] [=] + else if (theCommand.compare("image") == 0){ + //todo implement image + } + // \addtogroup [(title)] + else if (theCommand.compare("addtogroup") == 0){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list aNewList; + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + + } /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in @@ -1031,121 +697,111 @@ string getStringTilCommand(int &startInd, string doxygenString){ */ - int addCommand(string commandString, int &startInd, list &doxyList, string doxygenString){ + int addCommand(string commandString, TokenList &tokList,list &doxyList){ string theCommand = StringToLower(commandString); - string voidArray[] = {""}; - /* @command */ - - + if (theCommand.compare("plainstring") == 0){ - string nextPhrase = getStringTilCommand(startInd, doxygenString); + string nextPhrase = getStringTilCommand( tokList); if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); return 1; } int commandNumber = commandBelongs(theCommand); - if (commandNumber == 1){ - return addSimpleCommand(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == SIMPLECOMMAND){ + return addSimpleCommand(theCommand, doxyList); } - if (commandNumber == 2){ - return ignoreSimpleCommand(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == IGNOREDSIMPLECOMMAND){ + return ignoreSimpleCommand(theCommand, doxyList); } - if (commandNumber == 3){ - return addCommandWord(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDWORD){ + return addCommandWord(theCommand, tokList, doxyList); } - if (commandNumber == 4){ - return ignoreCommandWord(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == IGNOREDCOMMANDWORD){ + return ignoreCommandWord(theCommand, tokList, doxyList); } - if (commandNumber == 5){ - return addCommandLine(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDLINE ){ + return addCommandLine(theCommand, tokList, doxyList); } - if (commandNumber == 6){ - return ignoreCommandLine(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == IGNOREDCOMMANDLINE ){ + return ignoreCommandLine(theCommand, tokList, doxyList); } - if (commandNumber == 7){ - return addCommandParagraph(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDPARAGRAPH){ + return addCommandParagraph(theCommand, tokList, doxyList); } - if (commandNumber == 8){ - return ignoreCommandParagraph(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == IGNORECOMMANDPARAGRAPH){ + return ignoreCommandParagraph(theCommand, tokList, doxyList); } - if (commandNumber == 9){ - return ignoreCommandEndCommand(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDENDCOMMAND){ + return addCommandEndCommand(theCommand, tokList, doxyList); } - if (commandNumber == 10){ - return addCommandWordParagraph(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDWORDPARAGRAPH){ + return addCommandWordParagraph(theCommand, tokList, doxyList); } - if (commandNumber == 11){ - return addCommandWordLine(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDWORDLINE){ + return addCommandWordLine(theCommand, tokList, doxyList); } - if (commandNumber == 12){ - return addCommandWordOWordOWord(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDWORDOWORDWORD){ + return addCommandWordOWordOWord(theCommand, tokList, doxyList); } - if (commandNumber == 13){ - return addCommandOWord(theCommand, startInd,doxyList, doxygenString); + if (commandNumber == COMMANDOWORD){ + return addCommandOWord(theCommand, tokList, doxyList); } - if (commandNumber == 14){ - return 0; + if (commandNumber == COMMANDERRORTHROW){ + return addCommandErrorThrow(theCommand, tokList, doxyList); } - if (commandNumber == 15){ - return 0; + if (commandNumber == COMMANDUNIQUE){ + return addCommandUnique(theCommand, tokList, doxyList); } return 0; } - int weirdTest(){ - string doxygenString = "this is a test."; - string restOfParagraph; - int startIndex = 0; - restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - - startIndex = 0; - restOfParagraph = getStringTilCommand(startIndex, doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - } - + list parse(list::iterator endParsingIndex, TokenList &tokList){ + list aNewList; + int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); + if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(currToken.tokenType == END_LINE ){ + tokList.next(); + } + else if(currToken.tokenType == COMMAND){ + currCommand = findCommand(currToken.tokenString); + tokList.next(); + if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currToken.tokenString << endl;} + //cout << "Command: " << currWord << " " << currCommand << endl; + else addCommand(currToken.tokenString, tokList, aNewList); + } + else if (currToken.tokenType == PLAINSTRING){ + addCommand(string("plainstring"), tokList, aNewList); + } - int doRunExamples(){ - string line; - string filename; - string exampleNames[] = {"Examples/Example1","Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5"}; - int placement; - string doxygenString; - ifstream doxCommentFile; - for (int i = 0; i < 5; i++){ - doxCommentFile.open(exampleNames[i].c_str()); - doxCommentFile >> doxygenString; - while(getline(doxCommentFile, line)){ - doxygenString += line + "\n";} - doxCommentFile.close(); - placement = 0; - cout << "---RAW CODE---" << endl << doxygenString << endl< convert(string doxygenBlob){ + TokenList tokList = TokenList(doxygenBlob); + if(noisy) { + cout << "---TOKEN LIST---" << endl; + tokList.printList(); + } + list rootList; + rootList = parse( tokList.end(), tokList); + cout << "PARSED LIST" << endl; + printTree(rootList); + return rootList; + } + +int main(int argc, char *argv[]){ + string doxygenString1 = "//! A normal member taking two arguments and returning an integer value.\n/*!\n \\param a an \\b integer argument. \\param s a constant character pointer\n\n\n\n \\return The test results\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; + list rootList = convert(doxygenString1); + JavaDocConverter jDC = JavaDocConverter(); + jDC.convertToJavaDoc(rootList); + return 1; +} + + diff --git a/Source/DoxygenTranslator/JavaDocConverter.cpp b/Source/DoxygenTranslator/JavaDocConverter.cpp new file mode 100644 index 000000000..4e6fd93e6 --- /dev/null +++ b/Source/DoxygenTranslator/JavaDocConverter.cpp @@ -0,0 +1,104 @@ +#include "JavaDocConverter.h" +#include +#include +#include +#include + +int printTree = 1; +JavaDocConverter::JavaDocConverter() +{ +} + +JavaDocConverter::~JavaDocConverter() +{ +} + +/* Sorts entities by javaDoc standard order for commands + * NOTE: will not behave entirely properly until "First level" comments + * such as brief descriptions are TAGGED as such + */ +bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ + if(first.typeOfEntity.compare("plainstring") == 0) return true; + if(second.typeOfEntity.compare("plainstring") == 0) return false; + if(first.typeOfEntity.compare("param") == 0){ + if(second.typeOfEntity.compare("param")== 0) return true; + if(second.typeOfEntity.compare("return")== 0) return true; + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("return")== 0){ + if(second.typeOfEntity.compare("return")== 0) return true; + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + + } + if(first.typeOfEntity.compare("exception")== 0){ + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("author")== 0){ + if(first.typeOfEntity.compare("author")== 0) return true; + if(first.typeOfEntity.compare("version")== 0)return true; + if(first.typeOfEntity.compare("see")== 0)return true; + if(first.typeOfEntity.compare("since")== 0)return true; + if(first.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("version")== 0){ + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("see")== 0){ + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("since")== 0){ + if(second.typeOfEntity.compare("since")== 0) return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("deprecated")== 0){ + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + return true; +} + +string JavaDocConverter:: convertToJavaDoc(list entityList){ + + list::iterator entityIterator = entityList.begin(); + entityList.sort(compare_DoxygenEntities); + + cout << "---RESORTED LIST---" << endl; + if (printTree ){ + list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } + } + string javaDocString = "/**\n"; + + javaDocString += "*/\n"; + return javaDocString; +} diff --git a/Source/DoxygenTranslator/JavaDocConverter.h b/Source/DoxygenTranslator/JavaDocConverter.h new file mode 100644 index 000000000..b1c76ef17 --- /dev/null +++ b/Source/DoxygenTranslator/JavaDocConverter.h @@ -0,0 +1,17 @@ + #include + #include + #include "DoxygenEntity.h" + +#ifndef JAVADOCCONVERTER_H_ +#define JAVADOCCONVERTER_H_ + +class JavaDocConverter +{ +public: + + JavaDocConverter(); + string convertToJavaDoc(list entityList); + ~JavaDocConverter(); +}; + +#endif /*JAVADOCCONVERTER_H_*/ diff --git a/Source/DoxygenTranslator/Token.h b/Source/DoxygenTranslator/Token.h index d569f5f7b..e98686c14 100644 --- a/Source/DoxygenTranslator/Token.h +++ b/Source/DoxygenTranslator/Token.h @@ -13,8 +13,8 @@ class Token public: Token(int tType, string tString); ~Token(); - int tokenType; - string tokenString; + int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ + string tokenString; /* the data , such as param for @param*/ string toString(); }; diff --git a/Source/DoxygenTranslator/TokenList.cpp b/Source/DoxygenTranslator/TokenList.cpp index 6122328c4..0ace41c34 100644 --- a/Source/DoxygenTranslator/TokenList.cpp +++ b/Source/DoxygenTranslator/TokenList.cpp @@ -67,11 +67,8 @@ TokenList::TokenList(string doxygenString){ } Token TokenList::peek(){ - list::iterator p = tokenList.begin(); - if(p != tokenList.end()){ - p++; - Token returnedToken = (*p); - p--; + if(tokenListIterator!= tokenList.end()){ + Token returnedToken = (*tokenListIterator); return returnedToken; } else @@ -79,15 +76,22 @@ Token TokenList::peek(){ } Token TokenList::next(){ - list::iterator p = tokenList.begin(); - if(p != tokenList.end()){ - p++; - return (*p); + if(tokenListIterator != tokenList.end()){ + Token returnedToken = (*tokenListIterator); + tokenListIterator++; + return (returnedToken); } else return Token(0, ""); } +list::iterator TokenList::end(){ + return tokenList.end(); +} + +list::iterator TokenList::current(){ + return tokenListIterator; +} void TokenList::printList(){ list::iterator p = tokenList.begin(); int i = 1; @@ -100,4 +104,11 @@ void TokenList::printList(){ } } -TokenList:: ~TokenList(){} \ No newline at end of file +list::iterator TokenList::iteratorCopy(){ + list::iterator p = tokenListIterator; + return p; +} +void TokenList::setIterator(list::iterator newPosition){ + tokenListIterator = newPosition; +} +TokenList:: ~TokenList(){} diff --git a/Source/DoxygenTranslator/TokenList.h b/Source/DoxygenTranslator/TokenList.h index 153c69163..cc61f56e4 100644 --- a/Source/DoxygenTranslator/TokenList.h +++ b/Source/DoxygenTranslator/TokenList.h @@ -13,12 +13,15 @@ using namespace std; class TokenList{ public: - /* constructor takes a blob of Doxygen comment */ - TokenList(string doxygenString); + TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ ~TokenList(); Token peek(); /* returns next token without advancing */ Token next(); /* returns next token and advances */ + list::iterator end(); /* returns an end iterator */ + list::iterator current(); /* returns the current iterator */ void printList(); /* prints out the sequence of tokens */ + list::iterator iteratorCopy(); /* returns a copy of the current iterator */ + void setIterator(list::iterator newPosition); /*moves up the iterator*/ }; #endif /*TOKENLIST_H_*/ From 86b62e146bba6606fe39240faae3b7b15cd45d81 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Sun, 20 Jul 2008 05:20:17 +0000 Subject: [PATCH 0007/2031] javDocConvertor now functional for some simple commands such as author, param, returns, and b. Commands with a specific javaDoc order are sorted appropriately. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10686 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/DoxygenTranslator.cpp | 13 +- Source/DoxygenTranslator/JavaDocConverter.cpp | 140 +++++++++++++++--- Source/DoxygenTranslator/JavaDocConverter.h | 1 + 3 files changed, 132 insertions(+), 22 deletions(-) diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp index d6129cda0..96fe6b2c5 100644 --- a/Source/DoxygenTranslator/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/DoxygenTranslator.cpp @@ -69,7 +69,7 @@ "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "//","&", "~", "<", ">", "#", "%"}; + "$", "@", "\\","&", "~", "<", ">", "#", "%"}; string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", @@ -78,7 +78,7 @@ "version", "warning", "xrefitem" }; /* All of the doxygen commands divided up by how they are parsed */ - string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; + string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; string ignoredSimpleCommands[] = {"nothing at the moment"}; string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; @@ -791,13 +791,16 @@ list convert(string doxygenBlob){ } list rootList; rootList = parse( tokList.end(), tokList); - cout << "PARSED LIST" << endl; - printTree(rootList); + if(noisy) { + cout << "PARSED LIST" << endl; + printTree(rootList); + } return rootList; } int main(int argc, char *argv[]){ - string doxygenString1 = "//! A normal member taking two arguments and returning an integer value.\n/*!\n \\param a an \\b integer argument. \\param s a constant character pointer\n\n\n\n \\return The test results\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; + string doxygenString1 = "//! A normal member taking two arguments and returning an integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; + cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl; list rootList = convert(doxygenString1); JavaDocConverter jDC = JavaDocConverter(); jDC.convertToJavaDoc(rootList); diff --git a/Source/DoxygenTranslator/JavaDocConverter.cpp b/Source/DoxygenTranslator/JavaDocConverter.cpp index 4e6fd93e6..91f52662f 100644 --- a/Source/DoxygenTranslator/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/JavaDocConverter.cpp @@ -3,8 +3,10 @@ #include #include #include - -int printTree = 1; +#define APPROX_LINE_LENGTH 64//characters per line allowed +#define TAB_SIZE 8//characters per line allowed +int printSortedTree2 = 0; +//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag JavaDocConverter::JavaDocConverter() { } @@ -40,7 +42,7 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ if(second.typeOfEntity.compare("since")== 0)return true; if(second.typeOfEntity.compare("deprecated")== 0)return true; return false; - + } if(first.typeOfEntity.compare("exception")== 0){ if(second.typeOfEntity.compare("exception")== 0) return true; @@ -66,8 +68,9 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ if(second.typeOfEntity.compare("deprecated")== 0)return true; return false; } - if(first.typeOfEntity.compare("see")== 0){ + if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("sa")== 0)return true; if(second.typeOfEntity.compare("since")== 0)return true; if(second.typeOfEntity.compare("deprecated")== 0)return true; return false; @@ -84,21 +87,124 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ return true; } -string JavaDocConverter:: convertToJavaDoc(list entityList){ - - list::iterator entityIterator = entityList.begin(); - entityList.sort(compare_DoxygenEntities); +void JavaDocConverter::printSortedTree(list &entityList){ + list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } +} +string formatCommand(string unformattedLine, int indent){ + string formattedLines = "\n * "; + int lastPosition = 0; + int i = 0; + int isFirstLine = 1; + while (i != -1 && i < unformattedLine.length()){ + lastPosition = i; + if (isFirstLine){ + i+=APPROX_LINE_LENGTH; + } + else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); - cout << "---RESORTED LIST---" << endl; - if (printTree ){ - list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); + if (i > 0 && i + 1 < unformattedLine.length()){ + if (!isFirstLine) for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + else { + isFirstLine = 0; + } + formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); + formattedLines.append("\n *"); + + } + } + if (lastPosition < unformattedLine.length()){ + if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); + } + + return formattedLines; +} + +/* Contains the conversions for tags + * could probably be much more efficient... + */ +string javaDocFormat(DoxygenEntity &doxygenEntity){ + if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("brief") == 0){ + return doxygenEntity.data; + } + if (doxygenEntity.typeOfEntity.compare("detailed") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + return "" + doxygenEntity.data + ""; + } + return ""; +} + + +string translateSubtree( DoxygenEntity &doxygenEntity){ + string returnedString; + if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} + else { + returnedString += javaDocFormat(doxygenEntity); + list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ + returnedString+= translateSubtree(*p); p++; } } - string javaDocString = "/**\n"; - - javaDocString += "*/\n"; - return javaDocString; + return returnedString; } + +string translateEntity(DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) + return formatCommand(doxyEntity.data, 0) + "\n * "; + else if(doxyEntity.typeOfEntity.compare("see") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("return")== 0 + || doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("sa")== 0){ + return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); + } + + return ""; +} + +string JavaDocConverter:: convertToJavaDoc(list entityList){ + + + entityList.sort(compare_DoxygenEntities); + if(printSortedTree2){ + cout << "---RESORTED LIST---" << endl; + printSortedTree(entityList); + } + + string javaDocString = "/**"; + + list::iterator entityIterator = entityList.begin(); + while (entityIterator != entityList.end()){ + javaDocString += translateEntity(*entityIterator); + entityIterator++; + } + + javaDocString += "\n */\n"; + cout << "\n---RESULT IN JAVADOC---" << endl; + cout << javaDocString; + return javaDocString; +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/JavaDocConverter.h b/Source/DoxygenTranslator/JavaDocConverter.h index b1c76ef17..81122bc5f 100644 --- a/Source/DoxygenTranslator/JavaDocConverter.h +++ b/Source/DoxygenTranslator/JavaDocConverter.h @@ -12,6 +12,7 @@ public: JavaDocConverter(); string convertToJavaDoc(list entityList); ~JavaDocConverter(); + void printSortedTree(list &entityList); }; #endif /*JAVADOCCONVERTER_H_*/ From 32beba3cab2943988aad8642d4569a45a761e5ef Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Fri, 25 Jul 2008 06:15:32 +0000 Subject: [PATCH 0008/2031] Modifications to pick up Doxygen Comments and "post doxygen comments" and place them with appropriate attachments in the parse tree. Also a prototype for how to deal with comments describing structures marked with tags such as \class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10710 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 38 +++++++++------- Source/CParse/parser.y | 94 ++++++++++++++++++++++++++++++++++------ 2 files changed, 104 insertions(+), 28 deletions(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 140b7fedd..ff7d5343c 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -420,21 +420,29 @@ int yylook(void) { return HBLOCK; case SWIG_TOKEN_COMMENT: - { - String *cmt = Scanner_text(scan); - char *loc = Char(cmt); - if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { - scanner_locator(cmt); - } - - if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); - yylval.str = NewString(loc); - return DOXYGENSTRING; - } - - - } + { + String *cmt = Scanner_text(scan); + char *loc = Char(cmt); + if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { + scanner_locator(cmt); + } + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 3) == 0||strncmp(loc, "/*!<", 3) == 0||strncmp(loc, "//!<", 3) == 0) { + printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return DOXYGENPOSTSTRING; + } + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return DOXYGENSTRING; + } + /*DOES NOT WORK PROPERLY AT THE MINUTE + if (strncmp(loc, "//", 2)== 0) { + printf("C style Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return C_COMMENT_STRING; + }*/ + } break; case SWIG_TOKEN_ENDLINE: break; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 6a835c7f3..954b4a327 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -56,12 +56,36 @@ static int class_level = 0; static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- - * Doxygen Comment Globals + * Doxygen Comment Globals and Assist Functions * ----------------------------------------------------------------------------- */ +int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */ +String *currentComment; /* Location of the stored Doxygen Comment */ +String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ +String *currentCComment; /* Location of the stored C Comment */ +static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ -int isComment = 0; /* boolean for parsing Doxygen Comments */ -String *currentComment = 0; /* Location of the stored Doxygen Comment */ -static String *sideDoxComments = 0; +/* NOT a safe method at the moment */ +int isStructuralDoxygen(String *s){ + char *k = Char(s); + while (k[0] != '\0' && k[0] != '\\' && k[0] != '@'){ + k++; + } + if (k[0] == '\0') return 0; + k++; + if (strncmp(k, "addtogroup", 10) == 0 || strncmp(k, "callgraph", 9) == 0 || strncmp(k, "callergraph", 11) == 0 + || strncmp(k, "category", 8) == 0 || strncmp(k, "class", 5) == 0 || strncmp(k, "def", 3) == 0 + || strncmp(k, "defgroup", 8) == 0 || strncmp(k, "dir", 3) == 0 || strncmp(k, "enum", 4) == 0 + || strncmp(k, "example", 7) == 0 || strncmp(k, "file", 4) == 0 || strncmp(k, "fn", 2) == 0 + || strncmp(k, "headerfile", 9) == 0 || strncmp(k, "hideinitializer", 12) == 0 || strncmp(k, "ingroup", 7) == 0 + || strncmp(k, "interface", 9) == 0 || strncmp(k, "internal", 8) == 0 || strncmp(k, "mainpage", 8) == 0 + || strncmp(k, "name", 4) == 0 || strncmp(k, "namespace", 9) == 0 || strncmp(k, "nosubgrouping", 13) == 0 + || strncmp(k, "overload", 8) == 0 || strncmp(k, "package", 7) == 0 || strncmp(k, "page", 4) == 0 + || strncmp(k, "property", 8) == 0 || strncmp(k, "protocol", 8) == 0 || strncmp(k, "relates", 7) == 0 + || strncmp(k, "relatesalso", 5) == 0 || strncmp(k, "showinitializer", 5) == 0 || strncmp(k, "struct", 5) == 0 + || strncmp(k, "typedef", 7) == 0 || strncmp(k, "union", 5) == 0 || strncmp(k, "var", 3) == 0 + || strncmp(k, "weakgroup", 9) == 0){ return 1;} + return 0; +} /* ----------------------------------------------------------------------------- * Assist Functions @@ -79,12 +103,21 @@ static Node *new_node(const String_or_char *tag) { set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - /* Sets Comment if a Comment is Availible */ - if(isComment){ - String *copyComment = Copy(currentComment); - Setattr(n,"comment",copyComment); - isComment = 0; - } + if(parseComments){ + /* Sets any post comments to the previous node */ + if(previousNode != NULL && currentPostComment != 0){ + String *copyPostComment = Copy(currentComment); + Setattr(previousNode,"DoxygenPostComment",copyPostComment); + currentPostComment = 0; + } + /* Sets Doxygen Comment if a Comment is Availible */ + if(currentComment != 0){ + String *copyComment = Copy(currentComment); + Setattr(n,"DoxygenComment",copyComment); + currentComment = 0; + } + previousNode = n; + } return n; } @@ -1455,6 +1488,8 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { %token COPERATOR %token PARSETYPE PARSEPARM PARSEPARMS %token DOXYGENSTRING +%token DOXYGENPOSTSTRING +%token C_COMMENT_STRING %left CAST %left QUESTIONMARK @@ -1527,7 +1562,8 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { %type fname stringtype; %type featattr; %type doxygen_comment; - +%type c_style_comment; +%type doxygen_post_comment; %% /* ====================================================================== @@ -1585,6 +1621,8 @@ declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } | doxygen_comment { $$ = $1; } + | c_style_comment { $$ = $1; } + | doxygen_post_comment { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; @@ -3156,12 +3194,40 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { doxygen_comment : DOXYGENSTRING { - currentComment = NewString($1); - isComment = 1; + if(isStructuralDoxygen($1)){ + $$ = new_node("doxycomm"); + Setattr($$,"DoxygenComment",$1); + } + else { + if(currentComment != 0){ + Append(currentComment, $1); + } + else currentComment = $1; + $$ = 0; + } + } + ; + + +doxygen_post_comment : DOXYGENPOSTSTRING + { + if(currentPostComment != 0){ + Append(currentPostComment, $1); + } + else currentPostComment = $1; $$ = 0; } ; +c_style_comment : C_COMMENT_STRING + { + if(currentCComment != 0){ + Append(currentCComment, $1); + } + else currentCComment = $1; + $$ = 0; + } + ; /* ====================================================================== @@ -6009,3 +6075,5 @@ ParmList *Swig_cparse_parms(String *s) { /* Printf(stdout,"typeparse: '%s' ---> '%s'\n", s, top); */ return top; } + + From 4f2a579d6d7cf5f8208c0cb2f3af7de99795ba6d Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Fri, 15 Aug 2008 23:36:18 +0000 Subject: [PATCH 0009/2031] Now works end to end :) DoxygenTranslator restructured and placed into SWIG, Changes to java.cxx and lang.cxx to accomodate this git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10761 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 8 +- Source/CParse/parser.y | 44 +- Source/DoxygenTranslator/src/.deps/.dirstamp | 0 .../src/.deps/DoxygenEntity.Po | 380 +++++++ .../src/.deps/DoxygenParser.Po | 398 ++++++++ .../src/.deps/DoxygenTranslator.Po | 401 ++++++++ .../src/.deps/JavaDocConverter.Po | 385 ++++++++ Source/DoxygenTranslator/src/.deps/Token.Po | 379 +++++++ .../DoxygenTranslator/src/.deps/TokenList.Po | 382 ++++++++ Source/DoxygenTranslator/src/.dirstamp | 0 .../DoxygenTranslator/src/DoxygenEntity.cpp | 89 ++ Source/DoxygenTranslator/src/DoxygenEntity.h | 26 + .../DoxygenTranslator/src/DoxygenParser.cpp | 797 +++++++++++++++ Source/DoxygenTranslator/src/DoxygenParser.h | 19 + .../src/DoxygenTranslator.cpp | 41 + .../DoxygenTranslator/src/DoxygenTranslator.h | 10 + .../src/Examples/DoxygenTransWTokenizer.cpp | 924 ++++++++++++++++++ .../src/Examples/DoxygenTransWTokenizer.h | 11 + .../{ => src}/Examples/Example1 | 0 .../{ => src}/Examples/Example2 | 0 .../{ => src}/Examples/Example3 | 0 .../{ => src}/Examples/Example4 | 0 .../DoxygenTranslator/src/Examples/Example5 | 0 .../DoxygenTranslator/src/Examples/Example6 | 0 .../src/Examples/translator.h | 144 +++ .../src/JavaDocConverter.cpp | 210 ++++ .../DoxygenTranslator/src/JavaDocConverter.h | 18 + Source/DoxygenTranslator/src/Token.cpp | 32 + Source/DoxygenTranslator/src/Token.h | 21 + Source/DoxygenTranslator/src/TokenList.cpp | 116 +++ Source/DoxygenTranslator/src/TokenList.h | 27 + .../DoxygenTranslator/src/TranslatorTest.cpp | 68 ++ Source/DoxygenTranslator/src/TranslatorTest.h | 11 + Source/Makefile.am | 14 +- Source/Modules/java.cxx | 119 ++- Source/Modules/lang.cxx | 21 +- Source/Modules/swigmod.h | 6 + Tools/config/config.guess | 34 +- Tools/config/config.sub | 24 +- 39 files changed, 5101 insertions(+), 58 deletions(-) create mode 100644 Source/DoxygenTranslator/src/.deps/.dirstamp create mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po create mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenParser.Po create mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po create mode 100644 Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po create mode 100644 Source/DoxygenTranslator/src/.deps/Token.Po create mode 100644 Source/DoxygenTranslator/src/.deps/TokenList.Po create mode 100644 Source/DoxygenTranslator/src/.dirstamp create mode 100644 Source/DoxygenTranslator/src/DoxygenEntity.cpp create mode 100644 Source/DoxygenTranslator/src/DoxygenEntity.h create mode 100644 Source/DoxygenTranslator/src/DoxygenParser.cpp create mode 100644 Source/DoxygenTranslator/src/DoxygenParser.h create mode 100644 Source/DoxygenTranslator/src/DoxygenTranslator.cpp create mode 100644 Source/DoxygenTranslator/src/DoxygenTranslator.h create mode 100644 Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp create mode 100644 Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h rename Source/DoxygenTranslator/{ => src}/Examples/Example1 (100%) rename Source/DoxygenTranslator/{ => src}/Examples/Example2 (100%) rename Source/DoxygenTranslator/{ => src}/Examples/Example3 (100%) rename Source/DoxygenTranslator/{ => src}/Examples/Example4 (100%) create mode 100644 Source/DoxygenTranslator/src/Examples/Example5 create mode 100644 Source/DoxygenTranslator/src/Examples/Example6 create mode 100644 Source/DoxygenTranslator/src/Examples/translator.h create mode 100644 Source/DoxygenTranslator/src/JavaDocConverter.cpp create mode 100644 Source/DoxygenTranslator/src/JavaDocConverter.h create mode 100644 Source/DoxygenTranslator/src/Token.cpp create mode 100644 Source/DoxygenTranslator/src/Token.h create mode 100644 Source/DoxygenTranslator/src/TokenList.cpp create mode 100644 Source/DoxygenTranslator/src/TokenList.h create mode 100644 Source/DoxygenTranslator/src/TranslatorTest.cpp create mode 100644 Source/DoxygenTranslator/src/TranslatorTest.h diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index ff7d5343c..13e976b95 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -426,7 +426,7 @@ int yylook(void) { if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { scanner_locator(cmt); } - if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 3) == 0||strncmp(loc, "/*!<", 3) == 0||strncmp(loc, "//!<", 3) == 0) { + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); yylval.str = NewString(loc); return DOXYGENPOSTSTRING; @@ -436,12 +436,6 @@ int yylook(void) { yylval.str = NewString(loc); return DOXYGENSTRING; } - /*DOES NOT WORK PROPERLY AT THE MINUTE - if (strncmp(loc, "//", 2)== 0) { - printf("C style Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); - yylval.str = NewString(loc); - return C_COMMENT_STRING; - }*/ } break; case SWIG_TOKEN_ENDLINE: diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 954b4a327..eaf53449b 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -64,26 +64,25 @@ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ -/* NOT a safe method at the moment */ int isStructuralDoxygen(String *s){ - char *k = Char(s); - while (k[0] != '\0' && k[0] != '\\' && k[0] != '@'){ - k++; - } - if (k[0] == '\0') return 0; - k++; - if (strncmp(k, "addtogroup", 10) == 0 || strncmp(k, "callgraph", 9) == 0 || strncmp(k, "callergraph", 11) == 0 - || strncmp(k, "category", 8) == 0 || strncmp(k, "class", 5) == 0 || strncmp(k, "def", 3) == 0 - || strncmp(k, "defgroup", 8) == 0 || strncmp(k, "dir", 3) == 0 || strncmp(k, "enum", 4) == 0 - || strncmp(k, "example", 7) == 0 || strncmp(k, "file", 4) == 0 || strncmp(k, "fn", 2) == 0 - || strncmp(k, "headerfile", 9) == 0 || strncmp(k, "hideinitializer", 12) == 0 || strncmp(k, "ingroup", 7) == 0 - || strncmp(k, "interface", 9) == 0 || strncmp(k, "internal", 8) == 0 || strncmp(k, "mainpage", 8) == 0 - || strncmp(k, "name", 4) == 0 || strncmp(k, "namespace", 9) == 0 || strncmp(k, "nosubgrouping", 13) == 0 - || strncmp(k, "overload", 8) == 0 || strncmp(k, "package", 7) == 0 || strncmp(k, "page", 4) == 0 - || strncmp(k, "property", 8) == 0 || strncmp(k, "protocol", 8) == 0 || strncmp(k, "relates", 7) == 0 - || strncmp(k, "relatesalso", 5) == 0 || strncmp(k, "showinitializer", 5) == 0 || strncmp(k, "struct", 5) == 0 - || strncmp(k, "typedef", 7) == 0 || strncmp(k, "union", 5) == 0 || strncmp(k, "var", 3) == 0 - || strncmp(k, "weakgroup", 9) == 0){ return 1;} + char *slashPointer = Strchr(s, '\\'); + char *atPointer = Strchr(s,'@'); + if (slashPointer == NULL && atPointer == NULL) return 0; + else if( slashPointer == NULL) slashPointer = atPointer; + /* Perhaps a better solution exists... */ + slashPointer++; + if (strncmp(slashPointer, "addtogroup", 10) == 0 || strncmp(slashPointer, "callgraph", 9) == 0 || strncmp(slashPointer, "callergraph", 11) == 0 + || strncmp(slashPointer, "category", 8) == 0 || strncmp(slashPointer, "class", 5) == 0 || strncmp(slashPointer, "def", 3) == 0 + || strncmp(slashPointer, "defgroup", 8) == 0 || strncmp(slashPointer, "dir", 3) == 0 || strncmp(slashPointer, "enum", 4) == 0 + || strncmp(slashPointer, "example", 7) == 0 || strncmp(slashPointer, "file", 4) == 0 || strncmp(slashPointer, "fn", 2) == 0 + || strncmp(slashPointer, "headerfile", 9) == 0 || strncmp(slashPointer, "hideinitializer", 12) == 0 || strncmp(slashPointer, "ingroup", 7) == 0 + || strncmp(slashPointer, "interface", 9) == 0 || strncmp(slashPointer, "internal", 8) == 0 || strncmp(slashPointer, "mainpage", 8) == 0 + || strncmp(slashPointer, "name", 4) == 0 || strncmp(slashPointer, "namespace", 9) == 0 || strncmp(slashPointer, "nosubgrouping", 13) == 0 + || strncmp(slashPointer, "overload", 8) == 0 || strncmp(slashPointer, "package", 7) == 0 || strncmp(slashPointer, "page", 4) == 0 + || strncmp(slashPointer, "property", 8) == 0 || strncmp(slashPointer, "protocol", 8) == 0 || strncmp(slashPointer, "relates", 7) == 0 + || strncmp(slashPointer, "relatesalso", 5) == 0 || strncmp(slashPointer, "showinitializer", 5) == 0 || strncmp(slashPointer, "struct", 5) == 0 + || strncmp(slashPointer, "typedef", 7) == 0 || strncmp(slashPointer, "union", 5) == 0 || strncmp(slashPointer, "var", 3) == 0 + || strncmp(slashPointer, "weakgroup", 9) == 0){ return 1;} return 0; } @@ -4091,8 +4090,8 @@ cpp_members : cpp_member cpp_members { appendChild($$,$4); set_nextSibling($$,$6); } - | include_directive { $$ = $1; } - | empty { $$ = 0;} + | include_directive { $$ = $1; } + | empty { $$ = 0;} | error { int start_line = cparse_line; skip_decl(); @@ -4136,6 +4135,9 @@ cpp_member : c_declaration { $$ = $1; } | storage_class idcolon SEMI { $$ = 0; } | cpp_using_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } + | doxygen_comment{ $$ = $1; } + | c_style_comment{ $$ = $1; } + | doxygen_post_comment{ $$ = $1; } | cpp_catch_decl { $$ = 0; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } diff --git a/Source/DoxygenTranslator/src/.deps/.dirstamp b/Source/DoxygenTranslator/src/.deps/.dirstamp new file mode 100644 index 000000000..e69de29bb diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po b/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po new file mode 100644 index 000000000..7d2d2e0db --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po @@ -0,0 +1,380 @@ +DoxygenTranslator/src/DoxygenEntity.o \ + DoxygenTranslator/src/DoxygenEntity.o: \ + DoxygenTranslator/src/DoxygenEntity.cpp \ + DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/cstdlib \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/xlocale.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstring /usr/include/string.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/c++/4.2/clocale /usr/include/locale.h \ + /usr/include/bits/locale.h /usr/include/langinfo.h \ + /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ + /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/char_traits.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ + /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ + /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc + +DoxygenTranslator/src/DoxygenEntity.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/xlocale.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/string.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po b/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po new file mode 100644 index 000000000..3a023d6b9 --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po @@ -0,0 +1,398 @@ +DoxygenTranslator/src/DoxygenParser.o \ + DoxygenTranslator/src/DoxygenParser.o: \ + DoxygenTranslator/src/DoxygenParser.cpp \ + DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/cstdlib \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/xlocale.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstring /usr/include/string.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/c++/4.2/clocale /usr/include/locale.h \ + /usr/include/bits/locale.h /usr/include/langinfo.h \ + /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ + /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/char_traits.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ + /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ + /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/fstream \ + /usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h \ + /usr/include/c++/4.2/bits/fstream.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ + DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h + +DoxygenTranslator/src/DoxygenParser.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/xlocale.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/string.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: + +/usr/include/c++/4.2/fstream: + +/usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h: + +/usr/include/c++/4.2/bits/fstream.tcc: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +DoxygenTranslator/src/DoxygenEntity.h: + +DoxygenTranslator/src/TokenList.h: + +DoxygenTranslator/src/Token.h: + +DoxygenTranslator/src/JavaDocConverter.h: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po b/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po new file mode 100644 index 000000000..d71e23830 --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po @@ -0,0 +1,401 @@ +DoxygenTranslator/src/DoxygenTranslator.o \ + DoxygenTranslator/src/DoxygenTranslator.o: \ + DoxygenTranslator/src/DoxygenTranslator.cpp \ + DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/cstdlib \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/xlocale.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstring /usr/include/string.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/c++/4.2/clocale /usr/include/locale.h \ + /usr/include/bits/locale.h /usr/include/langinfo.h \ + /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ + /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/char_traits.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ + /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ + /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/fstream \ + /usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h \ + /usr/include/c++/4.2/bits/fstream.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ + DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h \ + DoxygenTranslator/src/DoxygenTranslator.h + +DoxygenTranslator/src/DoxygenParser.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/xlocale.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/string.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: + +/usr/include/c++/4.2/fstream: + +/usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h: + +/usr/include/c++/4.2/bits/fstream.tcc: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +DoxygenTranslator/src/DoxygenEntity.h: + +DoxygenTranslator/src/TokenList.h: + +DoxygenTranslator/src/Token.h: + +DoxygenTranslator/src/JavaDocConverter.h: + +DoxygenTranslator/src/DoxygenTranslator.h: diff --git a/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po b/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po new file mode 100644 index 000000000..79a3133a3 --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po @@ -0,0 +1,385 @@ +DoxygenTranslator/src/JavaDocConverter.o \ + DoxygenTranslator/src/JavaDocConverter.o: \ + DoxygenTranslator/src/JavaDocConverter.cpp \ + DoxygenTranslator/src/JavaDocConverter.h /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/exception_defines.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/cstring \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ + /usr/include/locale.h /usr/include/bits/locale.h \ + /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ + /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h \ + /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + /usr/include/c++/4.2/string /usr/include/c++/4.2/bits/char_traits.h \ + /usr/include/c++/4.2/memory \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/bits/locale_classes.h \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc + +DoxygenTranslator/src/JavaDocConverter.h: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +DoxygenTranslator/src/DoxygenEntity.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/Token.Po b/Source/DoxygenTranslator/src/.deps/Token.Po new file mode 100644 index 000000000..9a4bb90f5 --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/Token.Po @@ -0,0 +1,379 @@ +DoxygenTranslator/src/Token.o DoxygenTranslator/src/Token.o: \ + DoxygenTranslator/src/Token.cpp DoxygenTranslator/src/Token.h \ + /usr/include/c++/4.2/string \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ + /usr/include/locale.h /usr/include/bits/locale.h \ + /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ + /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/exception_defines.h \ + /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ + /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ + /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/bits/locale_classes.h \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc + +DoxygenTranslator/src/Token.h: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/TokenList.Po b/Source/DoxygenTranslator/src/.deps/TokenList.Po new file mode 100644 index 000000000..74d0e1c79 --- /dev/null +++ b/Source/DoxygenTranslator/src/.deps/TokenList.Po @@ -0,0 +1,382 @@ +DoxygenTranslator/src/TokenList.o DoxygenTranslator/src/TokenList.o: \ + DoxygenTranslator/src/TokenList.cpp DoxygenTranslator/src/TokenList.h \ + /usr/include/c++/4.2/cstdlib \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ + /usr/include/features.h /usr/include/sys/cdefs.h \ + /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ + /usr/include/gnu/stubs-32.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/cstddef \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/stdlib.h /usr/include/bits/waitflags.h \ + /usr/include/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/bits/endian.h /usr/include/xlocale.h \ + /usr/include/sys/types.h /usr/include/bits/types.h \ + /usr/include/bits/typesizes.h /usr/include/time.h \ + /usr/include/sys/select.h /usr/include/bits/select.h \ + /usr/include/bits/sigset.h /usr/include/bits/time.h \ + /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ + /usr/include/alloca.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/iosfwd \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ + /usr/include/c++/4.2/cstring /usr/include/string.h \ + /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ + /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ + /usr/include/c++/4.2/clocale /usr/include/locale.h \ + /usr/include/bits/locale.h /usr/include/langinfo.h \ + /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ + /usr/include/c++/4.2/cstdarg \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ + /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ + /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ + /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ + /usr/include/bits/confname.h /usr/include/getopt.h \ + /usr/include/c++/4.2/cctype /usr/include/ctype.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ + /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ + /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ + /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ + /usr/include/c++/4.2/bits/char_traits.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/bits/stl_pair.h \ + /usr/include/c++/4.2/bits/cpp_type_traits.h \ + /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ + /usr/include/c++/4.2/bits/stl_relops.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ + /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ + /usr/include/c++/4.2/bits/concept_check.h \ + /usr/include/c++/4.2/bits/stl_iterator.h \ + /usr/include/c++/4.2/debug/debug.h \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ + /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ + /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/bits/stl_construct.h \ + /usr/include/c++/4.2/bits/stl_uninitialized.h \ + /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ + /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ + /usr/include/c++/4.2/bits/stl_function.h \ + /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ + /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/stl_heap.h \ + /usr/include/c++/4.2/bits/stl_tempbuf.h \ + /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ + /usr/include/c++/4.2/bits/basic_ios.h \ + /usr/include/c++/4.2/bits/streambuf_iterator.h \ + /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ + /usr/include/wctype.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ + /usr/include/c++/4.2/bits/codecvt.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ + /usr/include/c++/4.2/bits/basic_ios.tcc \ + /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ + /usr/include/c++/4.2/bits/locale_facets.tcc \ + /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ + /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + DoxygenTranslator/src/Token.h + +DoxygenTranslator/src/TokenList.h: + +/usr/include/c++/4.2/cstdlib: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: + +/usr/include/features.h: + +/usr/include/sys/cdefs.h: + +/usr/include/bits/wordsize.h: + +/usr/include/gnu/stubs.h: + +/usr/include/gnu/stubs-32.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: + +/usr/include/c++/4.2/cstddef: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: + +/usr/include/stdlib.h: + +/usr/include/bits/waitflags.h: + +/usr/include/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/bits/endian.h: + +/usr/include/xlocale.h: + +/usr/include/sys/types.h: + +/usr/include/bits/types.h: + +/usr/include/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/sys/select.h: + +/usr/include/bits/select.h: + +/usr/include/bits/sigset.h: + +/usr/include/bits/time.h: + +/usr/include/sys/sysmacros.h: + +/usr/include/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/iosfwd: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: + +/usr/include/c++/4.2/cstring: + +/usr/include/string.h: + +/usr/include/c++/4.2/cstdio: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/bits/sys_errlist.h: + +/usr/include/c++/4.2/clocale: + +/usr/include/locale.h: + +/usr/include/bits/locale.h: + +/usr/include/langinfo.h: + +/usr/include/nl_types.h: + +/usr/include/iconv.h: + +/usr/include/libintl.h: + +/usr/include/c++/4.2/cstdarg: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: + +/usr/include/pthread.h: + +/usr/include/sched.h: + +/usr/include/bits/sched.h: + +/usr/include/signal.h: + +/usr/include/bits/setjmp.h: + +/usr/include/unistd.h: + +/usr/include/bits/posix_opt.h: + +/usr/include/bits/environments.h: + +/usr/include/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/c++/4.2/cctype: + +/usr/include/ctype.h: + +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/postypes.h: + +/usr/include/c++/4.2/cwchar: + +/usr/include/c++/4.2/ctime: + +/usr/include/bits/wchar.h: + +/usr/include/stdint.h: + +/usr/include/c++/4.2/bits/functexcept.h: + +/usr/include/c++/4.2/exception_defines.h: + +/usr/include/c++/4.2/exception: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/c++/4.2/bits/stl_pair.h: + +/usr/include/c++/4.2/bits/cpp_type_traits.h: + +/usr/include/c++/4.2/ext/type_traits.h: + +/usr/include/c++/4.2/utility: + +/usr/include/c++/4.2/bits/stl_relops.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_types.h: + +/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: + +/usr/include/c++/4.2/bits/concept_check.h: + +/usr/include/c++/4.2/bits/stl_iterator.h: + +/usr/include/c++/4.2/debug/debug.h: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + +/usr/include/c++/4.2/string: + +/usr/include/c++/4.2/memory: + +/usr/include/c++/4.2/bits/allocator.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: + +/usr/include/c++/4.2/ext/new_allocator.h: + +/usr/include/c++/4.2/new: + +/usr/include/c++/4.2/bits/stl_construct.h: + +/usr/include/c++/4.2/bits/stl_uninitialized.h: + +/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: + +/usr/include/c++/4.2/limits: + +/usr/include/c++/4.2/bits/ostream_insert.h: + +/usr/include/c++/4.2/bits/stl_function.h: + +/usr/include/c++/4.2/bits/basic_string.h: + +/usr/include/c++/4.2/algorithm: + +/usr/include/c++/4.2/bits/stl_algo.h: + +/usr/include/c++/4.2/bits/stl_heap.h: + +/usr/include/c++/4.2/bits/stl_tempbuf.h: + +/usr/include/c++/4.2/bits/basic_string.tcc: + +/usr/include/c++/4.2/streambuf: + +/usr/include/c++/4.2/bits/streambuf.tcc: + +/usr/include/c++/4.2/bits/basic_ios.h: + +/usr/include/c++/4.2/bits/streambuf_iterator.h: + +/usr/include/c++/4.2/bits/locale_facets.h: + +/usr/include/c++/4.2/cwctype: + +/usr/include/wctype.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: + +/usr/include/c++/4.2/bits/codecvt.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: + +/usr/include/c++/4.2/bits/basic_ios.tcc: + +/usr/include/c++/4.2/bits/ostream.tcc: + +/usr/include/c++/4.2/locale: + +/usr/include/c++/4.2/bits/locale_facets.tcc: + +/usr/include/c++/4.2/typeinfo: + +/usr/include/c++/4.2/istream: + +/usr/include/c++/4.2/bits/istream.tcc: + +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +DoxygenTranslator/src/Token.h: diff --git a/Source/DoxygenTranslator/src/.dirstamp b/Source/DoxygenTranslator/src/.dirstamp new file mode 100644 index 000000000..e69de29bb diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp new file mode 100644 index 000000000..6b8755592 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -0,0 +1,89 @@ +#include "DoxygenEntity.h" +#include + +/* Little data class for Doxygen Commands */ + + +/* Basic node for commands that have + * nothing after them + * example: \n + */ +string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; + +string findCommand(int commandNum){ + + int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); + if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ + return commandArray2[commandNum - 101]; + } + + return "" ; +} + +DoxygenEntity::DoxygenEntity(string typeEnt){ + typeOfEntity = typeEnt; + data = ""; + isLeaf = 1; +} + +/* Basic node for commands that have + * only 1 thing after them + * example: \b word + * OR holding a string + */ +DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ + typeOfEntity = typeEnt; + data = param1; + isLeaf = 1; +} + +/* Nonterminal node + * contains + */ +DoxygenEntity::DoxygenEntity(string typeEnt, list &entList ){ + typeOfEntity = typeEnt; + data = ""; + isLeaf = 0; + entityList = entList; +} + + +void DoxygenEntity::printEntity(int level){ + int thisLevel = level; + if (isLeaf) { + for (int i = 0; i < thisLevel; i++) {cout << "\t";} + cout << "Node Command: " << typeOfEntity << " "; + if (data.compare("") != 0) cout << "Node Data: " << data; + cout << endl; + } + else{ + for (int i = 0; i < thisLevel; i++) {cout << "\t";} + cout << "Node Command : " << typeOfEntity << endl; + list::iterator p = entityList.begin(); + thisLevel++; + while (p != entityList.end()){ + (*p).printEntity(thisLevel); + p++; + } + } +} + +DoxygenEntity::~DoxygenEntity() +{ +} diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h new file mode 100644 index 000000000..0605b1cc9 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -0,0 +1,26 @@ +#ifndef DOXYGENENTITY_H_ +#define DOXYGENENTITY_H_ + +#include +#include +#include +#include + +using namespace std; + +class DoxygenEntity{ + +public: + DoxygenEntity(string typeEnt); + DoxygenEntity(string typeEnt, string param1); + DoxygenEntity(string typeEnt, list &entList ); + ~DoxygenEntity(); + void printEntity(int level); + string typeOfEntity; + list entityList; + string data; + int isLeaf; +}; + + +#endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp new file mode 100644 index 000000000..226c60720 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -0,0 +1,797 @@ +#include "DoxygenParser.h" + +#include +#include +#include +#include +#include +#include "DoxygenEntity.h" +#include "TokenList.h" +#include "JavaDocConverter.h" +#define SIMPLECOMMAND 1 +#define IGNOREDSIMPLECOMMAND 2 +#define COMMANDWORD 3 +#define IGNOREDCOMMANDWORD 4 +#define COMMANDLINE 5 +#define IGNOREDCOMMANDLINE 6 +#define COMMANDPARAGRAPH 7 +#define IGNORECOMMANDPARAGRAPH 8 +#define COMMANDENDCOMMAND 9 +#define COMMANDWORDPARAGRAPH 10 +#define COMMANDWORDLINE 11 +#define COMMANDWORDOWORDWORD 12 +#define COMMANDOWORD 13 +#define COMMANDERRORTHROW 14 +#define COMMANDUNIQUE 15 +#define END_LINE 101 +#define PARAGRAPH_END 102 +#define PLAINSTRING 103 +#define COMMAND 104 +using namespace std; + +////////////////////////////////////////// +/*Set these to pick what internal functions +to test. */ + +//int testCommandParsingFunctions = 1;// not implemented + + +DoxygenParser::DoxygenParser() +{ +} + +DoxygenParser::~DoxygenParser() +{ +} + +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(string currCommand, TokenList &tokList, list &aNewList); +list parse(list::iterator endParsingIndex, TokenList &tokList); + +////////////////////////////////////////// + + +string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "\\","&", "~", "<", ">", "#", "%"}; + + +string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" }; + +/* All of the doxygen commands divided up by how they are parsed */ +string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; +string ignoredSimpleCommands[] = {"nothing at the moment"}; +string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; +string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; +string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; +string ignoreCommandLines[] = {"nothing at the moment"}; +string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; +string ignoreCommandParagraphs[] = {"nothing at the moment"}; +string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; +string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; +string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; +string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; +string commandOWords[] = {"dir", "file", "cond"}; +string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif"}; +string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li"}; + + +/* Changes a string to all lower case*/ +string StringToLower(string stringToConvert) + +{ + + for(unsigned int i=0;i &rootList){ + + list::iterator p = rootList.begin(); + while (p != rootList.end()){ + (*p).printEntity(0); + p++; + } + +} + +/* Determines how a command should be handled (what group it belongs to + * for parsing rules + */ + +int commandBelongs(string theCommand){ + string smallString = StringToLower(theCommand ); + //cout << " Looking for command " << theCommand << endl; + int i = 0; + for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ + if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND ;} + } + for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ + if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} + } + for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ + if(smallString.compare( commandWords[i]) == 0){return COMMANDWORD;} + } + for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ + if(smallString.compare( ignoredCommandWords[i]) == 0){return IGNOREDCOMMANDWORD;} + } + for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ + if(smallString.compare( commandLines[i]) == 0){return COMMANDLINE;} + } + for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ + if(smallString.compare( ignoreCommandLines[i]) == 0){return IGNOREDCOMMANDLINE;} + } + for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ + if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} + } + /* IgnoreCommandParagraph */ + for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ + if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} + } + for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ + if(smallString.compare( commandEndCommands[i]) == 0){return COMMANDENDCOMMAND ;} + } + for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ + if(smallString.compare( commandWordParagraphs[i]) == 0){return COMMANDWORDPARAGRAPH;} + } + for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ + if(smallString.compare( commandWordLines[i]) == 0){return COMMANDWORDLINE ;} + } + for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ + if(smallString.compare( commandWordOWordOWords[i]) == 0){return COMMANDWORDOWORDWORD;} + } + for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ + if(smallString.compare( commandOWords[i]) == 0){return COMMANDOWORD;} + } + for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ + if(smallString.compare( commandErrorThrowings[i]) == 0){return COMMANDERRORTHROW;} + } + for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ + if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} + } + + return 0; + +} +/* Returns the next word ON THE CURRENT LINE ONLY + * if a new line is encountered, returns a blank string. + * Updates the index it is given if success. + */ + +string getNextWord(TokenList &tokList){ + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING ){ + nextToken = tokList.next(); + return nextToken.tokenString; + } + return ""; +} + +/* Returns the location of the end of the line as + * an iterator. + */ +list::iterator getOneLine(TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == END_LINE){ + return endOfParagraph; + } + endOfParagraph++; + } + return tokList.end(); +} + + + +/* Returns a properly formatted string +* up til ANY command or end of paragraph is encountered. +*/ +string getStringTilCommand(TokenList &tokList){ + string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){ + Token currentToken = tokList.next(); + if(currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } + else if (tokList.peek().tokenType == END_LINE) break; + } + + return description; +} + +/* Returns a properly formatted string +* up til the command specified is encountered +*/ +//TODO check that this behaves properly for formulas + +string getStringTilEndCommand(string theCommand, TokenList &tokList){ + string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenString.compare(theCommand) != 0 ){ + Token currentToken = tokList.next(); + description = description + currentToken.tokenString + " "; + + } + + return description; +} + +/* Returns the end of a Paragraph as an iterator- +* Paragraph is defined in Doxygen to be a paragraph of text +* seperate by either a structural command or a blank line +*/ + +list::iterator getEndOfParagraph(TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == COMMAND){ + if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + return endOfParagraph; + } + } + + } + + return tokList.end(); + +} + +/* Returns the end of a section, defined as the first blank line OR first encounter of the same +* command. Example of this behaviour is \arg +*/ + +list::iterator getEndOfSection(string theCommand, TokenList &tokList){ + list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == COMMAND){ + if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + return endOfParagraph; + } + } + + } +} +/* This method is for returning the end of a specific form of doxygen command + * that begins with a \command and ends in \endcommand + * such as \code and \endcode. The proper usage is + * progressTilEndCommand("endcode", tokenList); + */ +list::iterator getEndCommand(string theCommand, TokenList &tokList){ + list::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand!= tokList.end()){ + if ((*endOfCommand).tokenType == COMMAND){ + if (theCommand.compare((* endOfCommand).tokenString) == 0){ + return endOfCommand; + } + endOfCommand++; + } + } + //End command not found + return tokList.end(); +} + +/* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered + */ + +list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ + list::iterator anIterator; + return anIterator; +} + + + + +/* Method for Adding a Simple Command + * Format: @command + * Plain commands, such as newline etc, they contain no other data + * \n \\ \@ \& \$ \# \< \> \% + */ + int addSimpleCommand(string theCommand, list &doxyList){ + + if (noisy) cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; +} + + /* NOT INCLUDED Simple Commands + * Format: @command + * Plain commands, such as newline etc, they contain no other data + */ + int ignoreSimpleCommand(string theCommand, list &doxyList){ + + if (noisy) cout << "Not Adding " << theCommand << endl; + return 1; +} + + /* CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" + */ + int addCommandWord(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (!name.empty()){ + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + else cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* NOT INCLUDED CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" + */ + int ignoreCommandWord(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string name = getNextWord(tokList); + if (!name.empty()){ + return 1; + } + else cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; +} + + /* CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" + */ + int addCommandLine(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + list::iterator endOfLine = getOneLine(tokList); + list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + +} + + /* NOT INCLUDED CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandLine(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 1; +} + + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single paragraph after then such as @return + * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" + */ + int addCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + //if(!restOfParagraph.empty()){ + list aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + // } + //else cout << "No line followed " << theCommand << " command. Not added" << endl; +} + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + //else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 1; +} + /* Command EndCommand + * Format: @command and ends at @endcommand + * Commands that take in a block of text such as @code + * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" + * Returns 1 if success, 0 if the endcommand is never encountered. + */ + + int addCommandEndCommand(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string description = getStringTilEndCommand( "end" + theCommand, tokList); + doxyList.push_back(DoxygenEntity(theCommand, description)); + return 1; + } + + /* CommandWordParagraph + * Format: @command {paragraph} + * Commands such as param + * "param", "tparam", "throw", "retval", "exception" + */ + int addCommandWordParagraph(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list::iterator endOfParagraph = getEndOfParagraph(tokList); + //if(!restOfParagraph.empty()){ + list aNewList; + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 0; + } + /* CommandWordLine + * Format: @command (line) + * Commands such as param + * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" + */ + int addCommandWordLine(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list::iterator endOfLine = getOneLine(tokList); + list aNewList; + aNewList = parse(endOfLine, tokList); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + + //else cout << "No line followed " << theCommand << " command. Not added" << endl; + } + + /* Command Word Optional Word Optional Word + * Format: @command [] [] + * Commands such as class + * "category", "class", "protocol", "interface", "struct", "union" + */ + int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string headerfile = getNextWord(tokList); + string headername = getNextWord(tokList); + list aNewList; + aNewList.push_back(DoxygenEntity("plainstring", name)); + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + + /* Command Optional Word + * Format: @command [] + * Commands such as dir + * "dir", "file", "cond" + */ + int addCommandOWord(string theCommand, TokenList &tokList, list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + + /* Commands that should not be encountered (such as PHP only) + */ + int addCommandErrorThrow(string theCommand, TokenList &tokList, list &doxyList){ + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } + + + int addCommandUnique(string theCommand, TokenList &tokList, list &doxyList){ + list aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ + list::iterator endOfSection = getEndOfSection(theCommand, tokList); + list aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + } + + // \xrefitem "(heading)" "(list title)" {text} + else if (theCommand.compare("xrefitem") == 0){ + //TODO Implement xrefitem + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; + } + // \ingroup ( [ ]) + else if (theCommand.compare("ingroup") == 0){ + string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \par [(paragraph title)] { paragraph } + else if (theCommand.compare("par") == 0){ + list::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + list aNewList2; + aNewList2 = parse(endOfLine, tokList); + aNewList.splice(aNewList.end(), aNewList2); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \headerfile [] + else if (theCommand.compare("headerfile") == 0){ + list aNewList; + string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstring", name)); + name = getNextWord(tokList); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \overload [(function declaration)] + else if (theCommand.compare("overload") == 0){ + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()){ + list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + else doxyList.push_back(DoxygenEntity(theCommand)); + } + // \weakgroup [(title)] + else if (theCommand.compare("weakgroup") == 0){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list aNewList; + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + // \ref ["(text)"] + else if (theCommand.compare("ref") == 0){ + //TODO Implement ref + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \subpage ["(text)"] + else if (theCommand.compare("subpage") == 0){ + //TODO implement subpage + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \dotfile ["caption"] + else if (theCommand.compare("dotfile") == 0){ + //TODO implement dotfile + if (noisy) cout << "Not Adding " << theCommand << endl; + list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \image ["caption"] [=] + else if (theCommand.compare("image") == 0){ + //todo implement image + } + // \addtogroup [(title)] + else if (theCommand.compare("addtogroup") == 0){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + list aNewList; + list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + + } + +/* The actual "meat" of the doxygen parser. This is not yet fully implemented + * with my current design- however the skeletal outline is contained in + * the file Skeleton + */ + + +int addCommand(string commandString, TokenList &tokList,list &doxyList){ + string theCommand = StringToLower(commandString); + + if (theCommand.compare("plainstring") == 0){ + string nextPhrase = getStringTilCommand( tokList); + if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND){ + return addSimpleCommand(theCommand, doxyList); + } + if (commandNumber == IGNOREDSIMPLECOMMAND){ + return ignoreSimpleCommand(theCommand, doxyList); + } + if (commandNumber == COMMANDWORD){ + return addCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDWORD){ + return ignoreCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDLINE ){ + return addCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDLINE ){ + return ignoreCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDPARAGRAPH){ + return addCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH){ + return ignoreCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDENDCOMMAND){ + return addCommandEndCommand(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDPARAGRAPH){ + return addCommandWordParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDLINE){ + return addCommandWordLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDOWORDWORD){ + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDOWORD){ + return addCommandOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDERRORTHROW){ + return addCommandErrorThrow(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDUNIQUE){ + return addCommandUnique(theCommand, tokList, doxyList); + } + + return 0; +} + +list parse(list::iterator endParsingIndex, TokenList &tokList){ + list aNewList; + int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); + if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(currToken.tokenType == END_LINE ){ + tokList.next(); + } + else if(currToken.tokenType == COMMAND){ + currCommand = findCommand(currToken.tokenString); + tokList.next(); + if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currToken.tokenString << endl;} + //cout << "Command: " << currWord << " " << currCommand << endl; + + else addCommand(currToken.tokenString, tokList, aNewList); + } + else if (currToken.tokenType == PLAINSTRING){ + addCommand(string("plainstring"), tokList, aNewList); + } + + + } + + return aNewList; +} + +list DoxygenParser::createTree(string doxygenBlob){ + TokenList tokList = TokenList(doxygenBlob); + if(noisy) { + cout << "---TOKEN LIST---" << endl; + tokList.printList(); + } + list rootList; + rootList = parse( tokList.end(), tokList); + if(noisy) { + cout << "PARSED LIST" << endl; + printTree(rootList); + } + return rootList; +} diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h new file mode 100644 index 000000000..776fcf123 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -0,0 +1,19 @@ +#ifndef DOXYGENPARSER_H_ +#define DOXYGENPARSER_H_ +#include +#include +#include +#include +#include +#include "DoxygenEntity.h" +#include "TokenList.h" +#include "JavaDocConverter.h" +class DoxygenParser +{ +public: + DoxygenParser(); + virtual ~DoxygenParser(); + list createTree(string doxygen); +}; + +#endif /*DOXYGENPARSER_H_*/ diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp new file mode 100644 index 000000000..191057ae7 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -0,0 +1,41 @@ + + +#include "DoxygenParser.h" +#include "DoxygenTranslator.h" +#include +#include +#include +#include +#include +#include "DoxygenEntity.h" +#include "TokenList.h" +#include "JavaDocConverter.h" + +DoxygenParser doxyParse; +JavaDocConverter jDC; + +DoxygenTranslator::DoxygenTranslator(){ + doxyParse = DoxygenParser(); + JavaDocConverter jDC = JavaDocConverter(); +} + +DoxygenTranslator::~DoxygenTranslator(){ + +} + + +char *DoxygenTranslator::convert(char* doxygenBlob, char* option){ + + list rootList = doxyParse.createTree(string(doxygenBlob)); + rootList = doxyParse.createTree(string(doxygenBlob)); + string returnedString; + if(strcmp(option, "JAVADOC") == 0){ + returnedString = jDC.convertToJavaDoc(rootList); + } + else cout << "Option not current supported.\n"; + char *nonConstString; + nonConstString = (char *)malloc(returnedString.length() + 1); + strcpy(nonConstString, returnedString.c_str()); + return nonConstString; +} + diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h new file mode 100644 index 000000000..e5fe7bcbb --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -0,0 +1,10 @@ +#ifndef DOXYGENTRANSLATOR_H_ +#define DOXYGENTRANSLATOR_H_ +class DoxygenTranslator +{ +public: + DoxygenTranslator(); + virtual ~DoxygenTranslator(); + char* convert(char* doxygenBlob, char* option); +}; +#endif /*DOXYGENTRANSLATOR_H_*/ diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp new file mode 100644 index 000000000..299f59216 --- /dev/null +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp @@ -0,0 +1,924 @@ +/* The main class for translating blobs of Doxygen for SWIG + * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program + * Currently the spacing/format on this is a bit goofy in places, due to shuffling code + * between 2 editors! Apologies for anyone combing through it :) + */ +//TODO DOH instead of STL? +//TODO Most commands are not fully implemented + +#include +#include +#include +#include +#include +#include "DoxygenEntity.h" +#include "TokenList.h" +#define SIMPLECOMMAND 1 +#define IGNOREDSIMPLECOMMAND 2 +#define COMMANDWORD 3 +#define IGNOREDCOMMANDWORD 4 +#define COMMANDLINE 5 +#define IGNOREDCOMMANDLINE 6 +#define COMMANDPARAGRAPH 7 +#define IGNORECOMMANDPARAGRAPH 8 +#define COMMANDENDCOMMAND 9 +#define COMMANDWORDPARAGRAPH 10 +#define COMMANDWORDLINE 11 +#define COMMANDWORDOWORDWORD 12 +#define COMMANDOWORD 13 +#define COMMANDERRORTHROW 14 +#define COMMANDUNIQUE 15 +using namespace std; + + +////////////////////////////////////////// +/*Set these to pick what internal functions +to test. */ + +//int testCommandParsingFunctions = 1;// not implemented + +int testCodeCrawlingFunctions = 0; +int demonstrateParsing = 0; +int runExamples = 0; +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); +////////////////////////////////////////// + + + +/* Globals*/ + + +// An array of all the commands and my generic description tag, plaindescription + +string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "//","&", "~", "<", ">", "#", "%"}; + + +string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" }; + +/* All of the doxygen commands divided up by how they are parsed */ +string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; +string ignoredSimpleCommands[] = {"nothing at the moment"}; +string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; +string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; +string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; +string ignoreCommandLines[] = {"nothing at the moment"}; +string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"}; +string ignoreCommandParagraphs[] = {"nothing at the moment"}; +string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; +string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; +string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; +string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; +string commandOWords[] = {"dir", "file", "cond"}; +string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif"}; +string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li"}; + + //int startIndex = 0; + int isNewLine = 0; + int briefDescExists = 0; + + /* Entity list is the root list. + * it is arranged this way to help documentation modules, + * such as the javaDoc one, "sort" entities where they need to. + */ + + list rootList; + +/* General (untested) assist methods */ + + string StringToLower(string stringToConvert) + + {//change each element of the string to lower case + + for(unsigned int i=0;i= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping){ + if(endIndex >= doxygenString.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } + + } + //endIndex = counter; + } + else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + finalIndex = endIndex; + keepLooping = 0; + } + else if(endIndex < doxygenString.length() -2 + && string("**/").compare(doxygenString.substr(endIndex , endIndex + 2)) == 0){ + finalIndex = endIndex; + //cout << "3 "; + keepLooping = 0; + } + if(keepLooping){ + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; + + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t'|| doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + //if(noisy) cout << "Final Index is: " << finalIndex << endl; + startInd = finalIndex; + return description; + } + + +/* Returns a Paragraph- defined in Doxygen to be a paragraph of text + * seperate by either a structural command or a blank line + * This method is VERY messy currently + */ + //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters + string getStringTilEndOfParagraph(int &startInd, string doxygenString){ + if (startInd >= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping){ + if(endIndex >= doxygenString.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[startIndex] == '\t' || doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } + + } + //endIndex = counter; + } + //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap + else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + spareIndex = endIndex +1; + + if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { + keepLooping = 0; + finalIndex = endIndex;} + } + else if(endIndex < doxygenString.length() - 1 + && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ + keepLooping = 0; + finalIndex = endIndex; + } + if(keepLooping){ + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' ||doxygenString[startIndex] == '!' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; + } + + /* This method is for a specific form of doxygen command + * that begins with a \command and ends in \endcommand + * such as \code and \endcode. The proper usage is + * progressTilEndCommand("endcode", index) + * currently this method does NOT process what is in between the two commands + */ + //TODO Make progressTilCommand return a formatted string + int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ + int endIndex = startInd; + while (endIndex < doxygenString.length()){ + if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; + if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ + startInd = endIndex + theCommand.length() + 1; + return 1; + } + } + endIndex++; + } + //End command not found + return 0; + } + + /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered + */ + + string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ + if (startInd >= doxygenString.length()) return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while(keepLooping){ + if(endIndex >= theCommand.length()){ + finalIndex = endIndex; + keepLooping = 0; + } + else if (doxygenString[endIndex] == '\n'){ + //cout << "1 "; + counter = endIndex; + if ( keepLooping && endIndex < doxygenString.length()-1) { + counter++; + //cout << "Counter :" << counter << endl; + while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' + || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ + if(doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter;} + else{ counter++;} + } + + } + //endIndex = counter; + } + else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ + //cout << "2 "; + spareIndex = endIndex; + if (endIndex + theCommand.length() < theCommand.length() + && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) keepLooping = 0; + } + else if(endIndex < doxygenString.length() - 1 + && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ + //cout << "3 "; + keepLooping = 0; + } + if(keepLooping){ + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; + + for (int i = startIndex; i < endIndex; i++){ + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; + } + + + /* prints the parse tree + * + */ + void printTree(){ + + list::iterator p = rootList.begin(); + while (p != rootList.end()){ + (*p).printEntity(0); + p++; + } + + } + + + + list parse(int startInd, string doxygenString){ + string currWord; + int startIndex = startInd; + int savedIndex; + list aNewList; + int endIndex = doxygenString.length(); + int currCommand; + while (startIndex < endIndex){ + savedIndex = startIndex; + currWord = getNextWord(startIndex, doxygenString); + if(noisy) cout << "Parsing for phrase starting in:" << currWord << endl; + if(currWord == ""){ + if (startIndex < endIndex) startIndex++; + } + else if(currWord[0] == '\\' || currWord[0] == '@'){ + currWord = currWord.substr(1, currWord.length() - 1); + currCommand = findCommand(currWord); + if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currWord << endl;} + //cout << "Command: " << currWord << " " << currCommand << endl; + else addCommand(currWord, startIndex, aNewList, doxygenString); + } + else{ + startIndex = savedIndex; + addCommand(string("plainstring"), startIndex, aNewList, doxygenString); + + } + } + + return aNewList; + } + + /* Method for Adding a Simple Command + * Format: @command + * Plain commands, such as newline etc, they contain no other data + * \n \\ \@ \& \$ \# \< \> \% + */ + int addSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + + if (noisy) cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; + } + + /* NOT INCLUDED Simple Commands + * Format: @command + * Plain commands, such as newline etc, they contain no other data + */ + int ignoreSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + + if (noisy) cout << "Not Adding " << theCommand << endl; + return 1; + } + + /* CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" + */ + int addCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()){ + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + else cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* NOT INCLUDED CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" + */ + int ignoreCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()){ + return 1; + } + else cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; + } + + /* CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" + */ + int addCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if(!line.empty()){ + int placement = 0; + list aNewList; + aNewList = parse(placement, line); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + + /* NOT INCLUDED CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if(!line.empty()){ + return 1; + } + else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; + } + + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single paragraph after then such as @return + * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" + */ + int addCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if(!restOfParagraph.empty()){ + int placement = 0; + list aNewList; + aNewList = parse(placement, restOfParagraph); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* CommandParagraph + * Format: @command {paragraph} + * Commands with a single LINE after then such as @var + * + */ + int ignoreCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if(!restOfParagraph.empty()){ + return 1; + } + else cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; + } + /* Command EndCommand + * Format: @command and ends at @endcommand + * Commands that take in a block of text such as @code + * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" + * Returns 1 if success, 0 if the endcommand is never encountered. + */ + + int ignoreCommandEndCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Not Adding " << theCommand << endl; + return progressTilEndCommand( "end" + theCommand, startInd, doxygenString); + + } + + /* CommandWordParagraph + * Format: @command {paragraph} + * Commands such as param + * "param", "tparam", "throw", "retval", "exception" + */ + int addCommandWordParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if(!restOfParagraph.empty()){ + list aNewList; + aNewList = parse(placement, restOfParagraph); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No paragraph followed " << theCommand << " command. Not added" << endl; + return 0; + } + /* CommandWordLine + * Format: @command (line) + * Commands such as param + * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" + */ + int addCommandWordLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if(!restOfLine.empty()){ + list aNewList; + aNewList = parse(placement, restOfLine); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + else cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; + } + + /* Command Word Optional Word Optional Word + * Format: @command [] [] + * Commands such as class + * "category", "class", "protocol", "interface", "struct", "union" + */ + int addCommandWordOWordOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + string headerfile = getNextWord(startInd, doxygenString); + string headername = getNextWord(startInd, doxygenString); + list aNewList; + aNewList.push_back(DoxygenEntity("plainstring", name)); + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + + /* Command Optional Word + * Format: @command [] + * Commands such as dir + * "dir", "file", "cond" + */ + int addCommandOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ + if (noisy) cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + + /* The actual "meat" of the doxygen parser. This is not yet fully implemented + * with my current design- however the skeletal outline is contained in + * the file Skeleton + */ + + + int addCommand(string commandString, int &startInd, list &doxyList, string doxygenString){ + string theCommand = StringToLower(commandString); + string voidArray[] = {""}; + /* @command */ + + + if (theCommand.compare("plainstring") == 0){ + string nextPhrase = getStringTilCommand(startInd, doxygenString); + if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND){ + return addSimpleCommand(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == IGNOREDSIMPLECOMMAND){ + return ignoreSimpleCommand(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDWORD){ + return addCommandWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDWORD){ + return ignoreCommandWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDLINE ){ + return addCommandLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDLINE ){ + return ignoreCommandLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDPARAGRAPH){ + return addCommandParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH){ + return ignoreCommandParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDENDCOMMAND){ + return ignoreCommandEndCommand(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDPARAGRAPH){ + return addCommandWordParagraph(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDLINE){ + return addCommandWordLine(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDOWORDWORD){ + return addCommandWordOWordOWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDOWORD){ + return addCommandOWord(theCommand, startInd,doxyList, doxygenString); + } + if (commandNumber == COMMANDERRORTHROW){ + return 0; + } + if (commandNumber == COMMANDUNIQUE){ + return 0; + } + + return 0; + } + + int weirdTest(){ + string doxygenString = "this is a test."; + string restOfParagraph; + int startIndex = 0; + restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); + cout << restOfParagraph<< " " << startIndex << endl; + + startIndex = 0; + restOfParagraph = getStringTilCommand(startIndex, doxygenString); + cout << restOfParagraph<< " " << startIndex << endl; + } + + + + int doRunExamples(){ + string line; + string filename; + string exampleNames[] = {"Examples/Example1","Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5"}; + int placement; + string doxygenString; + ifstream doxCommentFile; + for (int i = 0; i < 5; i++){ + doxCommentFile.open(exampleNames[i].c_str()); + doxCommentFile >> doxygenString; + while(getline(doxCommentFile, line)){ + doxygenString += line + "\n";} + doxCommentFile.close(); + placement = 0; + cout << "---RAW CODE---" << endl << doxygenString << endl< */ +#define POUND_COMMAND 236 /* \# */ +#define PERCENT_COMMAND 237 /* \% */ + +#endif /*TRANSLATOR_H_*/ diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp new file mode 100644 index 000000000..91f52662f --- /dev/null +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -0,0 +1,210 @@ +#include "JavaDocConverter.h" +#include +#include +#include +#include +#define APPROX_LINE_LENGTH 64//characters per line allowed +#define TAB_SIZE 8//characters per line allowed +int printSortedTree2 = 0; +//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag +JavaDocConverter::JavaDocConverter() +{ +} + +JavaDocConverter::~JavaDocConverter() +{ +} + +/* Sorts entities by javaDoc standard order for commands + * NOTE: will not behave entirely properly until "First level" comments + * such as brief descriptions are TAGGED as such + */ +bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ + if(first.typeOfEntity.compare("plainstring") == 0) return true; + if(second.typeOfEntity.compare("plainstring") == 0) return false; + if(first.typeOfEntity.compare("param") == 0){ + if(second.typeOfEntity.compare("param")== 0) return true; + if(second.typeOfEntity.compare("return")== 0) return true; + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("return")== 0){ + if(second.typeOfEntity.compare("return")== 0) return true; + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + + } + if(first.typeOfEntity.compare("exception")== 0){ + if(second.typeOfEntity.compare("exception")== 0) return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("author")== 0){ + if(first.typeOfEntity.compare("author")== 0) return true; + if(first.typeOfEntity.compare("version")== 0)return true; + if(first.typeOfEntity.compare("see")== 0)return true; + if(first.typeOfEntity.compare("since")== 0)return true; + if(first.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("version")== 0){ + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("sa")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("since")== 0){ + if(second.typeOfEntity.compare("since")== 0) return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + if(first.typeOfEntity.compare("deprecated")== 0){ + if(second.typeOfEntity.compare("deprecated")== 0)return true; + return false; + } + return true; +} + +void JavaDocConverter::printSortedTree(list &entityList){ + list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } +} +string formatCommand(string unformattedLine, int indent){ + string formattedLines = "\n * "; + int lastPosition = 0; + int i = 0; + int isFirstLine = 1; + while (i != -1 && i < unformattedLine.length()){ + lastPosition = i; + if (isFirstLine){ + i+=APPROX_LINE_LENGTH; + } + else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); + + if (i > 0 && i + 1 < unformattedLine.length()){ + if (!isFirstLine) for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + else { + isFirstLine = 0; + } + formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); + formattedLines.append("\n *"); + + } + } + if (lastPosition < unformattedLine.length()){ + if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); + } + + return formattedLines; +} + +/* Contains the conversions for tags + * could probably be much more efficient... + */ +string javaDocFormat(DoxygenEntity &doxygenEntity){ + if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("brief") == 0){ + return doxygenEntity.data; + } + if (doxygenEntity.typeOfEntity.compare("detailed") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + return "" + doxygenEntity.data + ""; + } + return ""; +} + + +string translateSubtree( DoxygenEntity &doxygenEntity){ + string returnedString; + if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} + else { + returnedString += javaDocFormat(doxygenEntity); + list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ + returnedString+= translateSubtree(*p); + p++; + } + } + return returnedString; +} + +string translateEntity(DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) + return formatCommand(doxyEntity.data, 0) + "\n * "; + else if(doxyEntity.typeOfEntity.compare("see") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("return")== 0 + || doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("sa")== 0){ + return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); + } + + return ""; +} + +string JavaDocConverter:: convertToJavaDoc(list entityList){ + + + entityList.sort(compare_DoxygenEntities); + if(printSortedTree2){ + cout << "---RESORTED LIST---" << endl; + printSortedTree(entityList); + } + + string javaDocString = "/**"; + + list::iterator entityIterator = entityList.begin(); + while (entityIterator != entityList.end()){ + javaDocString += translateEntity(*entityIterator); + entityIterator++; + } + + javaDocString += "\n */\n"; + cout << "\n---RESULT IN JAVADOC---" << endl; + cout << javaDocString; + return javaDocString; +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h new file mode 100644 index 000000000..81122bc5f --- /dev/null +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -0,0 +1,18 @@ + #include + #include + #include "DoxygenEntity.h" + +#ifndef JAVADOCCONVERTER_H_ +#define JAVADOCCONVERTER_H_ + +class JavaDocConverter +{ +public: + + JavaDocConverter(); + string convertToJavaDoc(list entityList); + ~JavaDocConverter(); + void printSortedTree(list &entityList); +}; + +#endif /*JAVADOCCONVERTER_H_*/ diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp new file mode 100644 index 000000000..e85799546 --- /dev/null +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -0,0 +1,32 @@ +#include "Token.h" +#include +#include +#include +#include +using namespace std; + + +Token::Token(int tType, string tString) +{ + tokenType = tType; + tokenString = tString; +} + +string Token::toString() +{ + if (tokenType == END_LINE){ + return "{END OF LINE}"; + } + if (tokenType == PARAGRAPH_END){ + return "{END OF PARAGRAPH}"; + } + if (tokenType == PLAINSTRING){ + return tokenString; + } + if (tokenType == COMMAND){ + return "{COMMAND : " + tokenString+ "}"; + } + return ""; +} + +Token:: ~Token(){} diff --git a/Source/DoxygenTranslator/src/Token.h b/Source/DoxygenTranslator/src/Token.h new file mode 100644 index 000000000..e98686c14 --- /dev/null +++ b/Source/DoxygenTranslator/src/Token.h @@ -0,0 +1,21 @@ +#ifndef TOKEN_H_ +#define TOKEN_H_ +#include + +#define END_LINE 101 +#define PARAGRAPH_END 102 +#define PLAINSTRING 103 +#define COMMAND 104 +using namespace std; + +class Token +{ +public: + Token(int tType, string tString); + ~Token(); + int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ + string tokenString; /* the data , such as param for @param*/ + string toString(); +}; + +#endif /*TOKEN_H_*/ diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp new file mode 100644 index 000000000..eeec6da46 --- /dev/null +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -0,0 +1,116 @@ +#include "TokenList.h" +#include +#include +#include +#include +#include "Token.h" +#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list +#define END_LINE 101 +#define PARAGRAPH_END 102 //not used at the moment +#define PLAINSTRING 103 +#define COMMAND 104 +using namespace std; + + +list tokenList; +list::iterator tokenListIterator; +int noisy2 = 0; +/* The tokenizer*/ + +TokenList::TokenList(string doxygenString){ + int currentIndex = 0; + //Regex whitespace("[ \t]+"); + //Regex newLine("[\n]"); + //Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution + //Regex doxygenFluff("[/*!]+"); + int nextIndex = 0; + int isFluff = 0; + string currentWord; + while (currentIndex < doxygenString.length()){ + if(doxygenString[currentIndex] == '\n'){ + tokenList.push_back(Token(END_LINE, currentWord)); + currentIndex++; + } + while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' + || doxygenString[currentIndex]== '\t')) currentIndex ++; + if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached + else {nextIndex = currentIndex; + while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' + && doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; + currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); + if(noisy2) cout << "Current Word: " << currentWord << endl; + if (currentWord[0] == '@' || currentWord[0] == '\\'){ + currentWord = currentWord.substr(1, currentWord.length()-1); + tokenList.push_back(Token(COMMAND, currentWord)); + } + else if (currentWord[0] == '\n'){ + //if ((tokenList.back()).tokenType == END_LINE){} + tokenList.push_back(Token(END_LINE, currentWord)); + + } + else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ + if (currentWord.length() == 1) {isFluff = 1;} + else { isFluff = 1; + for(int i = 1; i < currentWord.length(); i++){ + if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0; + } + + } + if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); + } + + else tokenList.push_back(Token(PLAINSTRING, currentWord)); + currentIndex = nextIndex; + } + } + tokenListIterator = tokenList.begin(); +} + +Token TokenList::peek(){ + if(tokenListIterator!= tokenList.end()){ + Token returnedToken = (*tokenListIterator); + return returnedToken; + } + else + return Token(0, ""); +} + +Token TokenList::next(){ + if(tokenListIterator != tokenList.end()){ + Token returnedToken = (*tokenListIterator); + tokenListIterator++; + return (returnedToken); + } + else + return Token(0, ""); +} + +list::iterator TokenList::end(){ + return tokenList.end(); +} + +list::iterator TokenList::current(){ + return tokenListIterator; +} +void TokenList::printList(){ + list::iterator p = tokenList.begin(); + int i = 1; + int b = 0; + while (p != tokenList.end()){ + cout << (*p).toString() << " "; + b = i%TOKENSPERLINE; + if (b == 0) cout << endl; + p++; i++; + } +} + +list::iterator TokenList::iteratorCopy(){ + list::iterator p = tokenListIterator; + return p; +} +void TokenList::setIterator(list::iterator newPosition){ + tokenListIterator = newPosition; +} +TokenList:: ~TokenList(){ + tokenList.clear(); +} diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h new file mode 100644 index 000000000..cc61f56e4 --- /dev/null +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -0,0 +1,27 @@ +#ifndef TOKENLIST_H_ +#define TOKENLIST_H_ +#include +#include +#include +#include +#include "Token.h" +using namespace std; + +/* a small class used to represent the sequence of tokens + * that can be derived from a formatted doxygen string + */ + +class TokenList{ +public: + TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ + ~TokenList(); + Token peek(); /* returns next token without advancing */ + Token next(); /* returns next token and advances */ + list::iterator end(); /* returns an end iterator */ + list::iterator current(); /* returns the current iterator */ + void printList(); /* prints out the sequence of tokens */ + list::iterator iteratorCopy(); /* returns a copy of the current iterator */ + void setIterator(list::iterator newPosition); /*moves up the iterator*/ +}; + +#endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/src/TranslatorTest.cpp b/Source/DoxygenTranslator/src/TranslatorTest.cpp new file mode 100644 index 000000000..f2bb48983 --- /dev/null +++ b/Source/DoxygenTranslator/src/TranslatorTest.cpp @@ -0,0 +1,68 @@ + +#include +#include +#include +#include +#include +using namespace std; + + +/* This classes primary function is to test the basic text processing abilities of + * the Doxygen parsing class + * It is currently a little messy */ + + +int testCommandParsingFunctions = 1; +int testCodeCrawlingFunctions = 1; + + +/* Testing clearFluff(), a method to scan past all excess / * ! from beginning of + * a comment blob. Compartmentalised simply because this is a comment habit that + * differs wildly */ + +int testClearFluff(){ + + string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", + "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; + + return 1; + + }; + +int testCCF(){ + + + + cout << "Testing getNextWord" << endl; + // Case 1: \command + string case1 = "\b word"; + string case2 = "\b word "; + string case3 = "\b word\n"; + string case4 = "\b word \n"; + string case5 = "\b word word"; + //Case 2: \command {paragraph} + + //Case 3: \command (text til end of line) + + + return 1; +} + +int testCPF(){ + // Case 1: \command + string case1 = "\b word"; + //Case 2: \command {paragraph} + + //Case 3: \command (text til end of line) + + return 1; + +} + +int main(int argc, char *argv[]){ + if(testCodeCrawlingFunctions) testCCF(); + if(testCommandParsingFunctions) testCPF(); + + + return 1; +} diff --git a/Source/DoxygenTranslator/src/TranslatorTest.h b/Source/DoxygenTranslator/src/TranslatorTest.h new file mode 100644 index 000000000..0014de718 --- /dev/null +++ b/Source/DoxygenTranslator/src/TranslatorTest.h @@ -0,0 +1,11 @@ +#ifndef TRANSLATORTEST_H_ +#define TRANSLATORTEST_H_ + +class TranslatorTest +{ +public: + TranslatorTest(); + virtual ~TranslatorTest(); +}; + +#endif /*TRANSLATORTEST_H_*/ diff --git a/Source/Makefile.am b/Source/Makefile.am index a72671305..1abe41cbd 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -88,7 +88,19 @@ eswig_SOURCES = CParse/cscanner.c \ Swig/typemap.c \ Swig/typesys.c \ Swig/warn.c \ - Swig/wrapfunc.c + Swig/wrapfunc.c \ + DoxygenTranslator/src/DoxygenEntity.h\ + DoxygenTranslator/src/DoxygenEntity.cpp\ + DoxygenTranslator/src/DoxygenParser.h\ + DoxygenTranslator/src/DoxygenParser.cpp\ + DoxygenTranslator/src/DoxygenTranslator.h\ + DoxygenTranslator/src/DoxygenTranslator.cpp\ + DoxygenTranslator/src/JavaDocConverter.h\ + DoxygenTranslator/src/JavaDocConverter.cpp\ + DoxygenTranslator/src/Token.h\ + DoxygenTranslator/src/Token.cpp\ + DoxygenTranslator/src/TokenList.h\ + DoxygenTranslator/src/TokenList.cpp bin_PROGRAMS = eswig eswig_LDADD = @SWIGLIBS@ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 5660b4885..23e233071 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -13,6 +13,7 @@ char cvsroot_java_cxx[] = "$Id$"; #include // for INT_MAX #include "cparse.h" #include +#include "../DoxygenTranslator/src/DoxygenTranslator.h" /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; @@ -43,7 +44,7 @@ class JAVA:public Language { bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool member_func_flag; // flag set when wrapping a member function - + String *imclass_name; // intermediary class name String *module_class_name; // module class name String *imclass_class_code; // intermediary class code @@ -70,7 +71,8 @@ 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 *structuralComments; + // Director method stuff: List *dmethods_seq; Hash *dmethods_table; @@ -87,6 +89,11 @@ class JAVA:public Language { Setline(p, Getline(n)); return p; } + /* DOXYGEN TO JAVADOC globals */ + bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc + //TODO make this bool a command line option + DoxygenTranslator doxyTranslator; + public: @@ -141,6 +148,7 @@ public: imclass_cppcasts_code(NULL), imclass_directors(NULL), destructor_call(NULL), + structuralComments(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), @@ -149,6 +157,7 @@ public: should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; + doxyTranslator = DoxygenTranslator(); } /* ----------------------------------------------------------------------------- @@ -202,6 +211,7 @@ public: virtual void main(int argc, char *argv[]) { + doxygen_javadoc_flag = true; SWIG_library_directory("java"); // Look for certain command line options @@ -355,6 +365,7 @@ public: imclass_imports = NewString(""); imclass_cppcasts_code = NewString(""); imclass_directors = NewString(""); + structuralComments = NewString(""); upcasts_code = NewString(""); dmethods_seq = NewList(); dmethods_table = NewHash(); @@ -432,6 +443,8 @@ public: // Start writing out the intermediary class file emitBanner(f_im); + + if (Len(package) > 0) Printf(f_im, "package %s;\n", package); @@ -482,13 +495,22 @@ public: // Start writing out the module class file emitBanner(f_module); - + //Add any structural comments to the top + if(doxygen_javadoc_flag && structuralComments){ + Printf(f_module, "%s", structuralComments); + } if (Len(package) > 0) Printf(f_module, "package %s;\n", package); if (module_imports) Printf(f_module, "%s\n", module_imports); - + + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(f_module, "/* This was generated from top() */"); + Printf(f_module, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } if (Len(module_class_modifiers) > 0) Printf(f_module, "%s ", module_class_modifiers); Printf(f_module, "%s ", module_class_name); @@ -921,7 +943,7 @@ public: Delete(c_param_type); Delete(arg); } - + Printv(f->code, nondir_args, NIL); Delete(nondir_args); @@ -1135,6 +1157,7 @@ public: return ret; } + /* ---------------------------------------------------------------------- * enumDeclaration() * @@ -1205,7 +1228,15 @@ public: // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); + Printv(proxy_class_constants_code, doxyTranslator.convert(Char((const String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + } + } + Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { // Global enums are defined in their own file @@ -1267,7 +1298,14 @@ public: tmpValue = NewString(name); // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); - + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); + Printf(enum_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } { EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); @@ -1326,6 +1364,21 @@ public: return SWIG_OK; } + /* ----------------------------------------------------------------------- + * doxygenComment() + * Simply translates the doxygen comment and places it into the appropriate + * file + * ------------------------------------------------------------------------ */ + virtual int doxygenComment(Node *n){ + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); + Printv(structuralComments, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + } + } + return SWIG_OK; + } + /* ----------------------------------------------------------------------- * constantWrapper() * Used for wrapping constants - #define or %constant. @@ -1344,7 +1397,14 @@ public: String *tm; String *return_type = NewString(""); String *constants_code = NewString(""); - + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); + Printf(constants_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } + if (!addSymbol(symname, n)) return SWIG_ERROR; @@ -1605,7 +1665,15 @@ public: // Pure Java interfaces const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE); - + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); + Printv(proxy_class_def, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + } + } + // Start writing the proxy class Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers @@ -1754,9 +1822,10 @@ public: // Start writing out the proxy class file emitBanner(f_proxy); - if (Len(package) > 0) + if (Len(package) > 0){ + Printf(f_proxy, "LETS TEST THIS NAO THX \n\n\n"); Printf(f_proxy, "package %s;\n", package); - + } Clear(proxy_class_def); Clear(proxy_class_code); @@ -1936,7 +2005,16 @@ public: // For wrapping member variables (Javabean setter) setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); } - + + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); + Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } + /* Start generating the proxy function */ const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); @@ -2158,7 +2236,15 @@ public: tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node Printf(im_return_type, "%s", tm); - + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(function_code, "/* This was generated from constructionhandler */\n" ); + Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } + Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); @@ -2419,6 +2505,14 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + if (Getattr(n,"DoxygenComment")){ + Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); + Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + } + } if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { @@ -2814,6 +2908,7 @@ public: const String *pure_baseclass = typemapLookup("javabase", type, WARN_NONE); const String *pure_interfaces = typemapLookup("javainterfaces", type, WARN_NONE); + // Emit the class Printv(swigtype, typemapLookup("javaimports", type, WARN_NONE), // Import statements "\n", typemapLookup("javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4a7bf8813..368dc2c85 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -132,6 +132,12 @@ int Dispatcher::emit_one(Node *n) { ret = namespaceDeclaration(n); } else if (strcmp(tag, "template") == 0) { ret = templateDeclaration(n); + } + /* =============================================================== + * Doxygen Comment + * =============================================================== */ + else if (strcmp(tag, "doxycomm") == 0) { + ret = doxygenComment(n); } /* =============================================================== @@ -296,7 +302,9 @@ int Dispatcher::usingDeclaration(Node *n) { int Dispatcher::namespaceDeclaration(Node *n) { return defaultHandler(n); } - +int Dispatcher::doxygenComment(Node *n){ + return defaultHandler(n); +} /* Allocators */ Language::Language(): @@ -2817,6 +2825,17 @@ int Language::usingDeclaration(Node *n) { /* Stubs. Language modules need to implement these */ +/* ---------------------------------------------------------------------- + * Language::doxygenComment() + * ---------------------------------------------------------------------- */ +int Language::doxygenComment(Node *n){ + + String *comment = Getattr(n, "comment"); + + return SWIG_OK; + +} + /* ---------------------------------------------------------------------- * Language::constantWrapper() * ---------------------------------------------------------------------- */ diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 5835c6362..03892e4f6 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -82,6 +82,9 @@ public: virtual int typemapcopyDirective(Node *n); virtual int typesDirective(Node *n); + /* Doxygen Comment */ + virtual int doxygenComment(Node *n); + /* C/C++ parsing */ virtual int cDeclaration(Node *n); @@ -159,6 +162,9 @@ public: virtual int namespaceDeclaration(Node *n); virtual int usingDeclaration(Node *n); + /* C/C++ parsing */ + virtual int doxygenComment(Node *n); + /* Function handlers */ virtual int functionHandler(Node *n); diff --git a/Tools/config/config.guess b/Tools/config/config.guess index 396482d6c..278f9e9e0 100755 --- a/Tools/config/config.guess +++ b/Tools/config/config.guess @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-07-02' +timestamp='2007-07-22' # 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 @@ -161,6 +161,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 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 @@ -329,7 +330,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; - i86pc:SunOS:5.*:*) + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) @@ -780,7 +781,7 @@ EOF i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; - i*:MINGW*:*) + *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) @@ -790,12 +791,15 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - x86:Interix*:[3456]*) - echo i586-pc-interix${UNAME_RELEASE} - exit ;; - EM64T:Interix*:[3456]*) - echo x86_64-unknown-interix${UNAME_RELEASE} - exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-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 ;; @@ -950,6 +954,9 @@ EOF x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; + xtensa:Linux:*:*) + echo xtensa-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 @@ -1208,6 +1215,15 @@ EOF 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 ;; diff --git a/Tools/config/config.sub b/Tools/config/config.sub index fab0aa355..1761d8bdf 100755 --- a/Tools/config/config.sub +++ b/Tools/config/config.sub @@ -4,7 +4,7 @@ # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. -timestamp='2006-09-20' +timestamp='2007-06-28' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -245,12 +245,12 @@ case $basic_machine in | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fr30 | frv \ + | 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 \ + | maxq | mb | microblaze | mcore | mep \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -324,7 +324,7 @@ case $basic_machine in | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ @@ -475,8 +475,8 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16c) - basic_machine=cr16c-unknown + cr16) + basic_machine=cr16-unknown os=-elf ;; crds | unos) @@ -683,6 +683,10 @@ case $basic_machine in basic_machine=i386-pc os=-mingw32 ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; miniframe) basic_machine=m68000-convergent ;; @@ -925,6 +929,9 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; + sh5el) + basic_machine=sh5le-unknown + ;; sh64) basic_machine=sh64-unknown ;; @@ -1219,7 +1226,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1414,6 +1421,9 @@ case $basic_machine in m68*-cisco) os=-aout ;; + mep-*) + os=-elf + ;; mips*-cisco) os=-elf ;; From 311ddbc2bf57311750ba4b6ea759e94900b90866 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Fri, 15 Aug 2008 23:54:53 +0000 Subject: [PATCH 0010/2031] Added a new Examples folder with modified Examples/java files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10763 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygencomments/java/callback/Makefile | 18 ++ .../doxygencomments/java/callback/example.cxx | 4 + .../doxygencomments/java/callback/example.h | 24 +++ .../doxygencomments/java/callback/example.i | 14 ++ .../doxygencomments/java/callback/index.html | 20 ++ .../doxygencomments/java/callback/main.java | 56 +++++ Examples/doxygencomments/java/check.list | 15 ++ Examples/doxygencomments/java/class/Makefile | 18 ++ .../doxygencomments/java/class/example.cxx | 28 +++ .../doxygencomments/java/class/example.dsp | 162 ++++++++++++++ Examples/doxygencomments/java/class/example.h | 45 ++++ Examples/doxygencomments/java/class/example.i | 10 + .../doxygencomments/java/class/index.html | 197 ++++++++++++++++++ Examples/doxygencomments/java/class/main.java | 70 +++++++ .../doxygencomments/java/constants/Makefile | 18 ++ .../doxygencomments/java/constants/example.i | 30 +++ .../doxygencomments/java/constants/index.html | 52 +++++ .../doxygencomments/java/constants/main.java | 44 ++++ Examples/doxygencomments/java/enum/Makefile | 18 ++ .../doxygencomments/java/enum/example.cxx | 37 ++++ Examples/doxygencomments/java/enum/example.h | 23 ++ Examples/doxygencomments/java/enum/example.i | 14 ++ Examples/doxygencomments/java/enum/index.html | 29 +++ Examples/doxygencomments/java/enum/main.java | 38 ++++ Examples/doxygencomments/java/extend/Makefile | 18 ++ .../doxygencomments/java/extend/example.cxx | 4 + .../doxygencomments/java/extend/example.h | 60 ++++++ .../doxygencomments/java/extend/example.i | 15 ++ .../doxygencomments/java/extend/index.html | 19 ++ .../doxygencomments/java/extend/main.java | 88 ++++++++ .../doxygencomments/java/funcptr/Makefile | 18 ++ .../doxygencomments/java/funcptr/example.c | 19 ++ .../doxygencomments/java/funcptr/example.h | 10 + .../doxygencomments/java/funcptr/example.i | 16 ++ .../doxygencomments/java/funcptr/index.html | 91 ++++++++ .../doxygencomments/java/funcptr/main.java | 33 +++ Examples/doxygencomments/java/index.html | 65 ++++++ .../doxygencomments/java/multimap/Makefile | 18 ++ .../doxygencomments/java/multimap/example.c | 53 +++++ .../doxygencomments/java/multimap/example.dsp | 158 ++++++++++++++ .../doxygencomments/java/multimap/example.i | 109 ++++++++++ .../doxygencomments/java/multimap/main.java | 40 ++++ Examples/doxygencomments/java/native/Makefile | 18 ++ .../doxygencomments/java/native/example.i | 56 +++++ .../doxygencomments/java/native/index.html | 33 +++ .../doxygencomments/java/native/main.java | 19 ++ .../doxygencomments/java/pointer/Makefile | 18 ++ .../doxygencomments/java/pointer/example.c | 16 ++ .../doxygencomments/java/pointer/example.i | 30 +++ .../doxygencomments/java/pointer/index.html | 165 +++++++++++++++ .../doxygencomments/java/pointer/main.java | 55 +++++ .../doxygencomments/java/reference/Makefile | 18 ++ .../java/reference/example.cxx | 46 ++++ .../doxygencomments/java/reference/example.h | 26 +++ .../doxygencomments/java/reference/example.i | 46 ++++ .../doxygencomments/java/reference/index.html | 147 +++++++++++++ .../doxygencomments/java/reference/main.java | 79 +++++++ Examples/doxygencomments/java/simple/Makefile | 18 ++ .../doxygencomments/java/simple/example.c | 18 ++ .../doxygencomments/java/simple/example.dsp | 158 ++++++++++++++ .../doxygencomments/java/simple/example.i | 7 + .../doxygencomments/java/simple/index.html | 108 ++++++++++ .../doxygencomments/java/simple/main.java | 32 +++ .../doxygencomments/java/template/Makefile | 18 ++ .../doxygencomments/java/template/example.h | 32 +++ .../doxygencomments/java/template/example.i | 17 ++ .../doxygencomments/java/template/index.html | 102 +++++++++ .../doxygencomments/java/template/main.java | 45 ++++ .../doxygencomments/java/typemap/Makefile | 18 ++ .../doxygencomments/java/typemap/example.i | 101 +++++++++ .../doxygencomments/java/typemap/index.html | 32 +++ .../doxygencomments/java/typemap/main.java | 26 +++ .../doxygencomments/java/variables/Makefile | 18 ++ .../doxygencomments/java/variables/example.c | 91 ++++++++ .../doxygencomments/java/variables/example.h | 6 + .../doxygencomments/java/variables/example.i | 49 +++++ .../doxygencomments/java/variables/index.html | 85 ++++++++ .../doxygencomments/java/variables/main.java | 97 +++++++++ 78 files changed, 3668 insertions(+) create mode 100644 Examples/doxygencomments/java/callback/Makefile create mode 100644 Examples/doxygencomments/java/callback/example.cxx create mode 100644 Examples/doxygencomments/java/callback/example.h create mode 100644 Examples/doxygencomments/java/callback/example.i create mode 100644 Examples/doxygencomments/java/callback/index.html create mode 100644 Examples/doxygencomments/java/callback/main.java create mode 100644 Examples/doxygencomments/java/check.list create mode 100644 Examples/doxygencomments/java/class/Makefile create mode 100644 Examples/doxygencomments/java/class/example.cxx create mode 100644 Examples/doxygencomments/java/class/example.dsp create mode 100644 Examples/doxygencomments/java/class/example.h create mode 100644 Examples/doxygencomments/java/class/example.i create mode 100644 Examples/doxygencomments/java/class/index.html create mode 100644 Examples/doxygencomments/java/class/main.java create mode 100644 Examples/doxygencomments/java/constants/Makefile create mode 100644 Examples/doxygencomments/java/constants/example.i create mode 100644 Examples/doxygencomments/java/constants/index.html create mode 100644 Examples/doxygencomments/java/constants/main.java create mode 100644 Examples/doxygencomments/java/enum/Makefile create mode 100644 Examples/doxygencomments/java/enum/example.cxx create mode 100644 Examples/doxygencomments/java/enum/example.h create mode 100644 Examples/doxygencomments/java/enum/example.i create mode 100644 Examples/doxygencomments/java/enum/index.html create mode 100644 Examples/doxygencomments/java/enum/main.java create mode 100644 Examples/doxygencomments/java/extend/Makefile create mode 100644 Examples/doxygencomments/java/extend/example.cxx create mode 100644 Examples/doxygencomments/java/extend/example.h create mode 100644 Examples/doxygencomments/java/extend/example.i create mode 100644 Examples/doxygencomments/java/extend/index.html create mode 100644 Examples/doxygencomments/java/extend/main.java create mode 100644 Examples/doxygencomments/java/funcptr/Makefile create mode 100644 Examples/doxygencomments/java/funcptr/example.c create mode 100644 Examples/doxygencomments/java/funcptr/example.h create mode 100644 Examples/doxygencomments/java/funcptr/example.i create mode 100644 Examples/doxygencomments/java/funcptr/index.html create mode 100644 Examples/doxygencomments/java/funcptr/main.java create mode 100644 Examples/doxygencomments/java/index.html create mode 100644 Examples/doxygencomments/java/multimap/Makefile create mode 100644 Examples/doxygencomments/java/multimap/example.c create mode 100644 Examples/doxygencomments/java/multimap/example.dsp create mode 100644 Examples/doxygencomments/java/multimap/example.i create mode 100644 Examples/doxygencomments/java/multimap/main.java create mode 100644 Examples/doxygencomments/java/native/Makefile create mode 100644 Examples/doxygencomments/java/native/example.i create mode 100644 Examples/doxygencomments/java/native/index.html create mode 100644 Examples/doxygencomments/java/native/main.java create mode 100644 Examples/doxygencomments/java/pointer/Makefile create mode 100644 Examples/doxygencomments/java/pointer/example.c create mode 100644 Examples/doxygencomments/java/pointer/example.i create mode 100644 Examples/doxygencomments/java/pointer/index.html create mode 100644 Examples/doxygencomments/java/pointer/main.java create mode 100644 Examples/doxygencomments/java/reference/Makefile create mode 100644 Examples/doxygencomments/java/reference/example.cxx create mode 100644 Examples/doxygencomments/java/reference/example.h create mode 100644 Examples/doxygencomments/java/reference/example.i create mode 100644 Examples/doxygencomments/java/reference/index.html create mode 100644 Examples/doxygencomments/java/reference/main.java create mode 100644 Examples/doxygencomments/java/simple/Makefile create mode 100644 Examples/doxygencomments/java/simple/example.c create mode 100644 Examples/doxygencomments/java/simple/example.dsp create mode 100644 Examples/doxygencomments/java/simple/example.i create mode 100644 Examples/doxygencomments/java/simple/index.html create mode 100644 Examples/doxygencomments/java/simple/main.java create mode 100644 Examples/doxygencomments/java/template/Makefile create mode 100644 Examples/doxygencomments/java/template/example.h create mode 100644 Examples/doxygencomments/java/template/example.i create mode 100644 Examples/doxygencomments/java/template/index.html create mode 100644 Examples/doxygencomments/java/template/main.java create mode 100644 Examples/doxygencomments/java/typemap/Makefile create mode 100644 Examples/doxygencomments/java/typemap/example.i create mode 100644 Examples/doxygencomments/java/typemap/index.html create mode 100644 Examples/doxygencomments/java/typemap/main.java create mode 100644 Examples/doxygencomments/java/variables/Makefile create mode 100644 Examples/doxygencomments/java/variables/example.c create mode 100644 Examples/doxygencomments/java/variables/example.h create mode 100644 Examples/doxygencomments/java/variables/example.i create mode 100644 Examples/doxygencomments/java/variables/index.html create mode 100644 Examples/doxygencomments/java/variables/main.java diff --git a/Examples/doxygencomments/java/callback/Makefile b/Examples/doxygencomments/java/callback/Makefile new file mode 100644 index 000000000..14c301703 --- /dev/null +++ b/Examples/doxygencomments/java/callback/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/callback/example.cxx b/Examples/doxygencomments/java/callback/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/doxygencomments/java/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/doxygencomments/java/callback/example.h b/Examples/doxygencomments/java/callback/example.h new file mode 100644 index 000000000..38ada8b84 --- /dev/null +++ b/Examples/doxygencomments/java/callback/example.h @@ -0,0 +1,24 @@ +/* File : example.h */ + +#include +#include + +/** Let's document class CALLBACK! */ +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + +/** Let's document class Caller! */ +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void call() { if (_callback) _callback->run(); } +}; + diff --git a/Examples/doxygencomments/java/callback/example.i b/Examples/doxygencomments/java/callback/example.i new file mode 100644 index 000000000..5dae4e7c1 --- /dev/null +++ b/Examples/doxygencomments/java/callback/example.i @@ -0,0 +1,14 @@ +/* File : example.i */ +/** Let's document module Example! */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%include "std_string.i" + +/* turn on director wrapping Callback */ +%feature("director") Callback; + +%include "example.h" + diff --git a/Examples/doxygencomments/java/callback/index.html b/Examples/doxygencomments/java/callback/index.html new file mode 100644 index 000000000..c25452018 --- /dev/null +++ b/Examples/doxygencomments/java/callback/index.html @@ -0,0 +1,20 @@ + + +SWIG:Examples:java:callback + + + + + +SWIG/Examples/python/extend/ +
+ +

Implementing C++ callbacks in Java

+ +

+This example illustrates how to use directors to implement C++ callbacks in Java. +

+ +
+ + diff --git a/Examples/doxygencomments/java/callback/main.java b/Examples/doxygencomments/java/callback/main.java new file mode 100644 index 000000000..4800f8cc9 --- /dev/null +++ b/Examples/doxygencomments/java/callback/main.java @@ -0,0 +1,56 @@ +public class main +{ + static { + try { + System.loadLibrary("example"); + } 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[] args) + { + System.out.println("Adding and calling a normal C++ callback"); + System.out.println("----------------------------------------"); + + Caller caller = new Caller(); + Callback callback = new Callback(); + + caller.setCallback(callback); + caller.call(); + caller.delCallback(); + + callback = new JavaCallback(); + + System.out.println(); + System.out.println("Adding and calling a Java callback"); + System.out.println("------------------------------------"); + + caller.setCallback(callback); + caller.call(); + caller.delCallback(); + + // Test that a double delete does not occur as the object has already been deleted from the C++ layer. + // Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize()) + // at any point after here. + callback.delete(); + + System.out.println(); + System.out.println("java exit"); + } +} + +class JavaCallback extends Callback +{ + public JavaCallback() + { + super(); + } + + public void run() + { + System.out.println("JavaCallback.run()"); + } +} + diff --git a/Examples/doxygencomments/java/check.list b/Examples/doxygencomments/java/check.list new file mode 100644 index 000000000..9728342f2 --- /dev/null +++ b/Examples/doxygencomments/java/check.list @@ -0,0 +1,15 @@ +# see top-level Makefile.in +callback +class +constants +enum +extend +funcptr +multimap +native +pointer +reference +simple +template +typemap +variables diff --git a/Examples/doxygencomments/java/class/Makefile b/Examples/doxygencomments/java/class/Makefile new file mode 100644 index 000000000..14c301703 --- /dev/null +++ b/Examples/doxygencomments/java/class/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/class/example.cxx b/Examples/doxygencomments/java/class/example.cxx new file mode 100644 index 000000000..1e8e203dd --- /dev/null +++ b/Examples/doxygencomments/java/class/example.cxx @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area(void) { + return M_PI*radius*radius; +} + +double Circle::perimeter(void) { + return 2*M_PI*radius; +} + +double Square::area(void) { + return width*width; +} + +double Square::perimeter(void) { + return 4*width; +} diff --git a/Examples/doxygencomments/java/class/example.dsp b/Examples/doxygencomments/java/class/example.dsp new file mode 100644 index 000000000..fbe87e7a4 --- /dev/null +++ b/Examples/doxygencomments/java/class/example.dsp @@ -0,0 +1,162 @@ +# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=example - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "example.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "example - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "example - Win32 Debug" +# Name "example - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\example.cxx +# End Source File +# Begin Source File + +SOURCE=.\example_wrap.cxx +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\example.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\example.i + +!IF "$(CFG)" == "example - Win32 Debug" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -c++ -java $(InputPath) + +# End Custom Build + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -c++ -java $(InputPath) + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/Examples/doxygencomments/java/class/example.h b/Examples/doxygencomments/java/class/example.h new file mode 100644 index 000000000..7e3e7d540 --- /dev/null +++ b/Examples/doxygencomments/java/class/example.h @@ -0,0 +1,45 @@ +/** \file example.h +comments on example.h */ + +/*! This is describing class Shape + \author Bob + */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + }; + double x, y; /*!< Important things */ + void move(double dx, double dy); + virtual double area(void) = 0; /*!< \return the area */ + virtual double perimeter(void) = 0; /*!< \return the perimeter */ + static int nshapes; +}; +/*! This is describing class Circle */ +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { }; + virtual double area(void); + virtual double perimeter(void); +}; + +/*! This is describing class square */ +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { }; + virtual double area(void); + virtual double perimeter(void); +}; + + + + + diff --git a/Examples/doxygencomments/java/class/example.i b/Examples/doxygencomments/java/class/example.i new file mode 100644 index 000000000..05c0ca2ab --- /dev/null +++ b/Examples/doxygencomments/java/class/example.i @@ -0,0 +1,10 @@ +/** File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/doxygencomments/java/class/index.html b/Examples/doxygencomments/java/class/index.html new file mode 100644 index 000000000..e9db7e94a --- /dev/null +++ b/Examples/doxygencomments/java/class/index.html @@ -0,0 +1,197 @@ + + +SWIG:Examples:java:class + + + + + +SWIG/Examples/java/class/ +
+ +

Wrapping a simple C++ class

+ +

+This example illustrates the high level form of C++ class wrapping performed +by SWIG. In this case, a C++ class has a proxy Java class, which +provides access to C++ class members. + +

The C++ Code

+ +Suppose you have some C++ classes described by the following (and admittedly lame) +header file: + +
+
+/* File : example.h */
+
+class Shape {
+public:
+  Shape() {
+    nshapes++;
+  }
+  virtual ~Shape() {
+    nshapes--;
+  };
+  double  x, y;   
+  void    move(double dx, double dy);
+  virtual double area() = 0;
+  virtual double perimeter() = 0;
+  static  int nshapes;
+};
+
+class Circle : public Shape {
+private:
+  double radius;
+public:
+  Circle(double r) : radius(r) { };
+  virtual double area();
+  virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+  double width;
+public:
+  Square(double w) : width(w) { };
+  virtual double area();
+  virtual double perimeter();
+};
+
+
+ +

The SWIG interface

+ +A simple SWIG interface for this can be built by simply grabbing the header file +like this: + +
+
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+
+ +Note: when creating a C++ extension, you must run SWIG with the -c++ option like this: +
+
+% swig -c++ -java example.i
+
+
+ +

A sample Java program

+ +Click here to see a Java program that calls the C++ functions from Java. + +

Key points

+ +
    +
  • To create a new object, you call a constructor like this: + +
    +
    +Circle c = new Circle(10);
    +
    +
    + +

    +

  • To access member data, a pair of accessor functions are used. +For example: + +
    +
    +c.setX(15);        // Set member data
    +x = c.getX();      // Get member data
    +
    +
    + +

    +

  • To invoke a member function, you simply do this + +
    +
    +System.out.println( "The area is " + c.area() );
    +
    +
    + +

    +

  • To invoke a destructor, simply do this + +
    +
    +c.delete();     // Deletes a shape
    +
    +
    + +

    +

  • Static member variables are wrapped with java static get and set access functions. For example: + +
    +
    +n = Shape.getNshapes();     // Get a static data member
    +Shape.setNshapes(13);       // Set a static data member
    +
    +
    + +
+ +

General Comments

+ +
    +
  • This high-level interface using proxy classes is not the only way to handle C++ code. +A low level interface using c functions to access member variables and member functions is the alternative SWIG +approach. This entails passing around the c pointer or c++ 'this' pointer and as such it is not difficult to crash the JVM. +The abstraction of the underlying pointer by the java proxy classes far better fits the java programming paradigm. + +

    +

  • SWIG *does* know how to properly perform upcasting of objects in an inheritance +hierarchy (including multiple inheritance). However Java classes can only derive from one base class so multiple inheritance +is not implemented. Java classes can implement more than one interface so there is scope for improvement in the future. + +

    +

  • A wide variety of C++ features are not currently supported by SWIG. Here is the +short and incomplete list: + +

    +

      +
    • Overloaded methods and functions. SWIG wrappers don't know how to resolve name +conflicts so you must give an alternative name to any overloaded method name using the +%name directive like this: + +
      +
      +void foo(int a);  
      +%name(foo2) void foo(double a, double b);
      +
      +
      + +

      +

    • Overloaded operators. Not supported at all. The only workaround for this is +to write a helper function. For example: + +
      +
      +%inline %{
      +    Vector *vector_add(Vector *a, Vector *b) {
      +          ... whatever ...
      +    }
      +%}
      +
      +
      + +

      +

    • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all). + +
    +
+ +
+ + diff --git a/Examples/doxygencomments/java/class/main.java b/Examples/doxygencomments/java/class/main.java new file mode 100644 index 000000000..8ef35db6d --- /dev/null +++ b/Examples/doxygencomments/java/class/main.java @@ -0,0 +1,70 @@ +// 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 main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + // ----- Object creation ----- + + System.out.println( "Creating some objects:" ); + Circle c = new Circle(10); + System.out.println( " Created circle " + c ); + Square s = new Square(10); + System.out.println( " Created square " + s ); + + // ----- Access a static member ----- + + System.out.println( "\nA total of " + Shape.getNshapes() + " shapes were created" ); + + // ----- Member data access ----- + + // Notice how we can do this using functions specific to + // the 'Circle' class. + c.setX(20); + c.setY(30); + + // Now use the same functions in the base class + Shape shape = s; + shape.setX(-10); + shape.setY(5); + + System.out.println( "\nHere is their current position:" ); + System.out.println( " Circle = (" + c.getX() + " " + c.getY() + ")" ); + System.out.println( " Square = (" + s.getX() + " " + s.getY() + ")" ); + + // ----- Call some methods ----- + + System.out.println( "\nHere are some properties of the shapes:" ); + Shape[] shapes = {c,s}; + for (int i=0; i + +SWIG:Examples:java:constants + + + + +SWIG/Examples/java/constants/ +
+ +

Wrapping C Constants

+ +

+When SWIG encounters C preprocessor macros and C declarations that look like constants, +it creates Java constant with an identical value. Click here +to see a SWIG interface with some constant declarations in it. + + +

Accessing Constants from Java

+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 +of the constants contained in the above file.

+

Key points

+
    +
  • The values of preprocessor macros are converted into Java constants. +
  • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float). +
  • Character constants such as 'x' are converted into Java strings. +
  • C string literals such as "Hello World" are converted into Java strings. +
  • Macros that are not fully defined are simply ignored. For example: +
    +
    +#define EXTERN extern
    +
    +
    +is ignored because SWIG has no idea what type of variable this would be. + +

    +

  • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored. + +
  • Certain C declarations involving 'const' are also turned into Java constants. +
  • The constants that appear in a SWIG interface file do not have to appear in any sort +of matching C source file since the creation of a constant does not require linkage +to a stored value (i.e., a value held in a C global variable or memory location). +
+ +
+ + + + diff --git a/Examples/doxygencomments/java/constants/main.java b/Examples/doxygencomments/java/constants/main.java new file mode 100644 index 000000000..7130c3d70 --- /dev/null +++ b/Examples/doxygencomments/java/constants/main.java @@ -0,0 +1,44 @@ +import java.lang.reflect.*; + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + System.out.println("ICONST = " + example.ICONST + " (should be 42)"); + System.out.println("FCONST = " + example.FCONST + " (should be 2.1828)"); + System.out.println("CCONST = " + example.CCONST + " (should be 'x')"); + System.out.println("CCONST2 = " + example.CCONST2 + " (this should be on a new line)"); + System.out.println("SCONST = " + example.SCONST + " (should be 'Hello World')"); + System.out.println("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')"); + System.out.println("EXPR = " + example.EXPR + " (should be 48.5484)"); + System.out.println("iconst = " + example.iconst + " (should be 37)"); + System.out.println("fconst = " + example.fconst + " (should be 3.14)"); + +// Use reflection to check if these variables are defined: + try + { + System.out.println("EXTERN = " + example.class.getField("EXTERN") + " (Arg! This shouldn't print anything)"); + } + catch (NoSuchFieldException e) + { + System.out.println("EXTERN isn't defined (good)"); + } + + try + { + System.out.println("FOO = " + example.class.getField("FOO") + " (Arg! This shouldn't print anything)"); + } + catch (NoSuchFieldException e) + { + System.out.println("FOO isn't defined (good)"); + } + } +} diff --git a/Examples/doxygencomments/java/enum/Makefile b/Examples/doxygencomments/java/enum/Makefile new file mode 100644 index 000000000..14c301703 --- /dev/null +++ b/Examples/doxygencomments/java/enum/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/enum/example.cxx b/Examples/doxygencomments/java/enum/example.cxx new file mode 100644 index 000000000..df7bb6328 --- /dev/null +++ b/Examples/doxygencomments/java/enum/example.cxx @@ -0,0 +1,37 @@ +/* File : example.cxx */ + +#include "example.h" +#include + +void Foo::enum_test(speed s) { + if (s == IMPULSE) { + printf("IMPULSE speed\n"); + } else if (s == WARP) { + printf("WARP speed\n"); + } else if (s == LUDICROUS) { + printf("LUDICROUS speed\n"); + } else { + printf("Unknown speed\n"); + } +} + +void enum_test(color c, Foo::speed s) { + if (c == RED) { + printf("color = RED, "); + } else if (c == BLUE) { + printf("color = BLUE, "); + } else if (c == GREEN) { + printf("color = GREEN, "); + } else { + printf("color = Unknown color!, "); + } + if (s == Foo::IMPULSE) { + printf("speed = IMPULSE speed\n"); + } else if (s == Foo::WARP) { + printf("speed = WARP speed\n"); + } else if (s == Foo::LUDICROUS) { + printf("speed = LUDICROUS speed\n"); + } else { + printf("speed = Unknown speed!\n"); + } +} diff --git a/Examples/doxygencomments/java/enum/example.h b/Examples/doxygencomments/java/enum/example.h new file mode 100644 index 000000000..2142d8240 --- /dev/null +++ b/Examples/doxygencomments/java/enum/example.h @@ -0,0 +1,23 @@ + + +/** This is a block describing enum + */ + +enum color { RED, BLUE, GREEN }; + +/*! This is describing class foo + */ + +class Foo { + public: + Foo() { } + enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; + void enum_test(speed s); +}; + +/*! This is describing enum test +//! \param c the color c +//! \param s the speed + */ + +void enum_test(color c, Foo::speed s); diff --git a/Examples/doxygencomments/java/enum/example.i b/Examples/doxygencomments/java/enum/example.i new file mode 100644 index 000000000..1f1f9d526 --- /dev/null +++ b/Examples/doxygencomments/java/enum/example.i @@ -0,0 +1,14 @@ +/** File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/** Force the generated Java code to use the C enum values rather than making a JNI call */ +%javaconst(1); + +/** Let's just grab the original header file here */ + +%include "example.h" + diff --git a/Examples/doxygencomments/java/enum/index.html b/Examples/doxygencomments/java/enum/index.html new file mode 100644 index 000000000..52c06c5d1 --- /dev/null +++ b/Examples/doxygencomments/java/enum/index.html @@ -0,0 +1,29 @@ + + +SWIG:Examples:java:enum + + + + + +SWIG/Examples/java/enum/ +
+ +

Wrapping enumerations

+ +

+This example tests SWIG's ability to wrap enumerations. +SWIG wraps enums in numerous different ways. The default approach is to wrap +each enum with the typesafe enum pattern. Enums are handled as integers in the JNI layer. +See the documentation for the other approaches for wrapping enums. + + +

+ +
+ + diff --git a/Examples/doxygencomments/java/enum/main.java b/Examples/doxygencomments/java/enum/main.java new file mode 100644 index 000000000..8646e0087 --- /dev/null +++ b/Examples/doxygencomments/java/enum/main.java @@ -0,0 +1,38 @@ + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + // Print out the value of some enums + System.out.println("*** color ***"); + System.out.println(" " + color.RED + " = " + color.RED.swigValue()); + System.out.println(" " + color.BLUE + " = " + color.BLUE.swigValue()); + System.out.println(" " + color.GREEN + " = " + color.GREEN.swigValue()); + + System.out.println("\n*** Foo::speed ***"); + System.out.println(" Foo::" + Foo.speed.IMPULSE + " = " + Foo.speed.IMPULSE.swigValue()); + System.out.println(" Foo::" + Foo.speed.WARP + " = " + Foo.speed.WARP.swigValue()); + System.out.println(" Foo::" + Foo.speed.LUDICROUS + " = " + Foo.speed.LUDICROUS.swigValue()); + + System.out.println("\nTesting use of enums with functions\n"); + + example.enum_test(color.RED, Foo.speed.IMPULSE); + example.enum_test(color.BLUE, Foo.speed.WARP); + example.enum_test(color.GREEN, Foo.speed.LUDICROUS); + + System.out.println( "\nTesting use of enum with class method" ); + Foo f = new Foo(); + + f.enum_test(Foo.speed.IMPULSE); + f.enum_test(Foo.speed.WARP); + f.enum_test(Foo.speed.LUDICROUS); + } +} diff --git a/Examples/doxygencomments/java/extend/Makefile b/Examples/doxygencomments/java/extend/Makefile new file mode 100644 index 000000000..14c301703 --- /dev/null +++ b/Examples/doxygencomments/java/extend/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/extend/example.cxx b/Examples/doxygencomments/java/extend/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/doxygencomments/java/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/doxygencomments/java/extend/example.h b/Examples/doxygencomments/java/extend/example.h new file mode 100644 index 000000000..db49ae747 --- /dev/null +++ b/Examples/doxygencomments/java/extend/example.h @@ -0,0 +1,60 @@ +/* File : example.h */ + +#include +#include +#include +#include +#include + +/**This is describiing class Employee */ +class Employee { +private: + std::string name; +public: + /** TEST */ + Employee(const char* n): name(n) {} +/**This is describing method getTitle */ + virtual std::string getTitle() { return getPosition() + " " + getName(); } + virtual std::string getName() { return name; } + virtual std::string getPosition() const { return "Employee"; } + virtual ~Employee() { printf("~Employee() @ %p\n", this); } +}; + +/**This is describing class Manager */ +class Manager: public Employee { +public: + Manager(const char* n): Employee(n) {} + virtual std::string getPosition() const { return "Manager"; } +}; + + +class EmployeeList { + std::vector list; +public: + EmployeeList() { + list.push_back(new Employee("Bob")); + list.push_back(new Employee("Jane")); + list.push_back(new Manager("Ted")); + } + void addEmployee(Employee *p) { + list.push_back(p); + std::cout << "New employee added. Current employees are:" << std::endl; + std::vector::iterator i; + for (i=list.begin(); i!=list.end(); i++) { + std::cout << " " << (*i)->getTitle() << std::endl; + } + } +/**This is describing class get item */ + const Employee *get_item(int i) { + return list[i]; + } + ~EmployeeList() { + std::vector::iterator i; + std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; + for (i=list.begin(); i!=list.end(); i++) { + delete *i; + } + std::cout << "~EmployeeList empty." << std::endl; + } +}; + diff --git a/Examples/doxygencomments/java/extend/example.i b/Examples/doxygencomments/java/extend/example.i new file mode 100644 index 000000000..c8ec32e09 --- /dev/null +++ b/Examples/doxygencomments/java/extend/example.i @@ -0,0 +1,15 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%include "std_vector.i" +%include "std_string.i" + +/* turn on director wrapping for Manager */ +%feature("director") Employee; +%feature("director") Manager; + +%include "example.h" + diff --git a/Examples/doxygencomments/java/extend/index.html b/Examples/doxygencomments/java/extend/index.html new file mode 100644 index 000000000..c7c2c127d --- /dev/null +++ b/Examples/doxygencomments/java/extend/index.html @@ -0,0 +1,19 @@ + + +SWIG:Examples:java:extend + + + + + +SWIG/Examples/java/extend/ +
+ +

Extending a simple C++ class in Java

+ +

+This example illustrates the extending of a C++ class with cross language polymorphism. + +


+ + diff --git a/Examples/doxygencomments/java/extend/main.java b/Examples/doxygencomments/java/extend/main.java new file mode 100644 index 000000000..ee3a94ed0 --- /dev/null +++ b/Examples/doxygencomments/java/extend/main.java @@ -0,0 +1,88 @@ +// This file illustrates the cross language polymorphism using directors. + + +// CEO class, which overrides Employee::getPosition(). + +class CEO extends Manager { + public CEO(String name) { + super(name); + } + public String getPosition() { + return "CEO"; + } + // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. + public void disownMemory() { + swigCMemOwn = false; + } +} + + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + + // Create an instance of CEO, a class derived from the Java proxy of the + // underlying C++ class. The calls to getName() and getPosition() are standard, + // the call to getTitle() uses the director wrappers to call CEO.getPosition(). + + CEO e = new CEO("Alice"); + System.out.println( e.getName() + " is a " + e.getPosition() ); + System.out.println( "Just call her \"" + e.getTitle() + "\"" ); + System.out.println( "----------------------" ); + + + // Create a new EmployeeList instance. This class does not have a C++ + // director wrapper, but can be used freely with other classes that do. + + EmployeeList list = new EmployeeList(); + + // EmployeeList owns its items, so we must surrender ownership of objects we add. + e.disownMemory(); + list.addEmployee(e); + System.out.println( "----------------------" ); + + // Now we access the first four items in list (three are C++ objects that + // EmployeeList's constructor adds, the last is our CEO). The virtual + // methods of all these instances are treated the same. For items 0, 1, and + // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls + // getPosition which resolves in Java. The call to getPosition is + // slightly different, however, because of the overidden getPosition() call, since + // now the object reference has been "laundered" by passing through + // EmployeeList as an Employee*. Previously, Java resolved the call + // immediately in CEO, but now Java thinks the object is an instance of + // class Employee. So the call passes through the + // Employee proxy class and on to the C wrappers and C++ director, + // eventually ending up back at the Java CEO implementation of getPosition(). + // The call to getTitle() for item 3 runs the C++ Employee::getTitle() + // method, which in turn calls getPosition(). This virtual method call + // passes down through the C++ director class to the Java implementation + // in CEO. All this routing takes place transparently. + + System.out.println( "(position, title) for items 0-3:" ); + + System.out.println( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" ); + System.out.println( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" ); + System.out.println( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" ); + System.out.println( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" ); + System.out.println( "----------------------" ); + + // Time to delete the EmployeeList, which will delete all the Employee* + // items it contains. The last item is our CEO, which gets destroyed as well. + list.delete(); + System.out.println( "----------------------" ); + + // All done. + + System.out.println( "java exit" ); + + } +} diff --git a/Examples/doxygencomments/java/funcptr/Makefile b/Examples/doxygencomments/java/funcptr/Makefile new file mode 100644 index 000000000..968c92c6c --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/funcptr/example.c b/Examples/doxygencomments/java/funcptr/example.c new file mode 100644 index 000000000..5c4a3dabf --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/example.c @@ -0,0 +1,19 @@ +/* File : example.c */ + +int do_op(int a, int b, int (*op)(int,int)) { + return (*op)(a,b); +} + +int add(int a, int b) { + return a+b; +} + +int sub(int a, int b) { + return a-b; +} + +int mul(int a, int b) { + return a*b; +} + +int (*funcvar)(int,int) = add; diff --git a/Examples/doxygencomments/java/funcptr/example.h b/Examples/doxygencomments/java/funcptr/example.h new file mode 100644 index 000000000..5285737a3 --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/example.h @@ -0,0 +1,10 @@ +/* file: example.h */ + +extern int do_op(int,int, int (*op)(int,int)); +/*! Describing function add */ +extern int add(int,int); +extern int sub(int,int); +extern int mul(int,int); + +extern int (*funcvar)(int,int); + diff --git a/Examples/doxygencomments/java/funcptr/example.i b/Examples/doxygencomments/java/funcptr/example.i new file mode 100644 index 000000000..82c3c2201 --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/example.i @@ -0,0 +1,16 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/** Wrap a function taking a pointer to a function */ +extern int do_op(int a, int b, int (*op)(int, int)); + +/** Now install a bunch of "ops" as constants */ +%constant int (*ADD)(int,int) = add; +%constant int (*SUB)(int,int) = sub; +%constant int (*MUL)(int,int) = mul; + +extern int (*funcvar)(int,int); + diff --git a/Examples/doxygencomments/java/funcptr/index.html b/Examples/doxygencomments/java/funcptr/index.html new file mode 100644 index 000000000..0ad2be1cf --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/index.html @@ -0,0 +1,91 @@ + + +SWIG:Examples:java:funcptr + + + + + +SWIG/Examples/java/funcptr/ +
+ +

Pointers to Functions

+ +

+Okay, just what in the heck does SWIG do with a declaration like this? + +

+
+int do_op(int a, int b, int (*op)(int, int));
+
+
+ +Well, it creates a wrapper as usual. Of course, that does raise some +questions about the third argument (the pointer to a function). + +

+In this case, SWIG will wrap the function pointer as it does for all other +pointers. However, in order to actually call this function from a Java program, +you will need to pass some kind of C function pointer object. In C, +this is easy, you just supply a function name as an argument like this: + +

+
+/* Some callback function */
+int add(int a, int b) {
+   return a+b;
+} 
+...
+int r = do_op(x,y,add);
+
+
+ +To make this work with SWIG, you will need to do a little extra work. Specifically, +you need to create some function pointer objects using the %constant directive like this: + +
+
+%constant(int (*)(int,int)) ADD = add;
+
+
+ +Now, in a Java program, you would do this: + +
+
+int r = do_op(x,y, example.ADD)
+
+
+where example is the module name. + +

An Example

+ +Here are some files that illustrate this with a simple example: + + + +

Notes

+ +
    +
  • The value of a function pointer must correspond to a function written in C or C++. +It is not possible to pass an arbitrary Java function in as a substitute for a C +function pointer. + +

    +

  • A Java function can be used as a C/C++ callback if you write some +clever typemaps and are very careful about how you create your extension. +This is an advanced topic not covered here. +
+ +
+ + + + + + diff --git a/Examples/doxygencomments/java/funcptr/main.java b/Examples/doxygencomments/java/funcptr/main.java new file mode 100644 index 000000000..cf81f92b4 --- /dev/null +++ b/Examples/doxygencomments/java/funcptr/main.java @@ -0,0 +1,33 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + + + int a = 37; + int b = 42; + + // Now call our C function with a bunch of callbacks + + System.out.println( "Trying some C callback functions" ); + System.out.println( " a = " + a ); + System.out.println( " b = " + b ); + System.out.println( " ADD(a,b) = " + example.do_op(a,b,example.ADD) ); + System.out.println( " SUB(a,b) = " + example.do_op(a,b,example.SUB) ); + System.out.println( " MUL(a,b) = " + example.do_op(a,b,example.MUL) ); + + System.out.println( "Here is what the C callback function classes are called in Java" ); + System.out.println( " ADD = " + example.ADD.getClass().getName() ); + System.out.println( " SUB = " + example.SUB.getClass().getName() ); + System.out.println( " MUL = " + example.MUL.getClass().getName() ); + } +} diff --git a/Examples/doxygencomments/java/index.html b/Examples/doxygencomments/java/index.html new file mode 100644 index 000000000..d98f9a393 --- /dev/null +++ b/Examples/doxygencomments/java/index.html @@ -0,0 +1,65 @@ + + +SWIG:Examples:java + + + +

SWIG Java Examples

+ +

+The following examples illustrate the use of SWIG with Java. + +

    +
  • simple. A minimal example showing how SWIG can +be used to wrap a C function, a global variable, and a constant. +
  • native. Comparing the manual and the SWIG approach to calling native code. +
  • typemap. Modifying the Java module's default behaviour by using typemaps. +
  • constants. This shows how preprocessor macros and +certain C declarations are turned into constants. +
  • variables. An example showing how to access C global variables. +
  • enum. Wrapping enumerations. +
  • class. How to wrap a simple C++ class. +
  • reference. C++ references. +
  • pointer. Simple pointer handling. +
  • template. C++ templates. +
  • funcptr. Pointers to functions. +
  • callback. C++ callbacks using directors. +
  • extend. Polymorphism using directors. +
+ +

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 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. +

+A Unix example: +

+
+$ make
+$ export LD_LIBRARY_PATH=. #ksh 
+$ java main
+
+
+

+ + + +

Compatibility

+ +The examples have been extensively tested on the following platforms: + +
    +
  • Solaris +
  • Linux +
  • Cygwin +
  • Windows +
+ +Your mileage may vary. If you experience a problem, please let us know by +contacting us on the mailing lists. + + + + diff --git a/Examples/doxygencomments/java/multimap/Makefile b/Examples/doxygencomments/java/multimap/Makefile new file mode 100644 index 000000000..968c92c6c --- /dev/null +++ b/Examples/doxygencomments/java/multimap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/multimap/example.c b/Examples/doxygencomments/java/multimap/example.c new file mode 100644 index 000000000..b8360fa8a --- /dev/null +++ b/Examples/doxygencomments/java/multimap/example.c @@ -0,0 +1,53 @@ +/* File : example.c */ +#include +#include +#include + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + +int gcdmain(int argc, char *argv[]) { + int x,y; + if (argc != 3) { + printf("usage: gcd x y\n"); + return -1; + } + x = atoi(argv[1]); + y = atoi(argv[2]); + printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); + return 0; +} + +int count(char *bytes, int len, char c) { + int i; + int count = 0; + for (i = 0; i < len; i++) { + if (bytes[i] == c) count++; + } + return count; +} + +void capitalize(char *str, int len) { + int i; + for (i = 0; i < len; i++) { + str[i] = (char)toupper(str[i]); + } +} + +void circle(double x, double y) { + double a = x*x + y*y; + if (a > 1.0) { + printf("Bad points %g, %g\n", x,y); + } else { + printf("Good points %g, %g\n", x,y); + } +} diff --git a/Examples/doxygencomments/java/multimap/example.dsp b/Examples/doxygencomments/java/multimap/example.dsp new file mode 100644 index 000000000..8e1f8415e --- /dev/null +++ b/Examples/doxygencomments/java/multimap/example.dsp @@ -0,0 +1,158 @@ +# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=example - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "example.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "example - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "example - Win32 Debug" +# Name "example - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\example.c +# End Source File +# Begin Source File + +SOURCE=.\example_wrap.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\example.i + +!IF "$(CFG)" == "example - Win32 Debug" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -java $(InputPath) + +# End Custom Build + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -java $(InputPath) + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/Examples/doxygencomments/java/multimap/example.i b/Examples/doxygencomments/java/multimap/example.i new file mode 100644 index 000000000..8d67282a5 --- /dev/null +++ b/Examples/doxygencomments/java/multimap/example.i @@ -0,0 +1,109 @@ +/* File : example.i */ +%module example + +%{ +extern int gcd(int x, int y); +extern int gcdmain(int argc, char *argv[]); +extern int count(char *bytes, int len, char c); +extern void capitalize (char *str, int len); +extern void circle (double cx, double cy); +extern int squareCubed (int n, int *OUTPUT); +%} + +extern int gcd(int x, int y); + +%typemap(jni) (int argc, char *argv[]) "jobjectArray" +%typemap(jtype) (int argc, char *argv[]) "String[]" +%typemap(jstype) (int argc, char *argv[]) "String[]" + +%typemap(javain) (int argc, char *argv[]) "$javainput" + +%typemap(in) (int argc, char *argv[]) (jstring *jsarray) { +int i; + + $1 = (*jenv)->GetArrayLength(jenv, $input); + if ($1 == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return $null; + } + $2 = (char **) malloc(($1+1)*sizeof(char *)); + jsarray = (jstring *) malloc($1*sizeof(jstring)); + for (i = 0; i < $1; i++) { + jsarray[i] = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, i); + $2[i] = (char *) (*jenv)->GetStringUTFChars(jenv, jsarray[i], 0); + } + $2[i] = 0; +} + +%typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */ + +%typemap(freearg) (int argc, char *argv[]) { +int i; + for (i = 0; i < $1; i++) { + (*jenv)->ReleaseStringUTFChars(jenv, jsarray$argnum[i], $2[i]); + } + free($2); +} + +extern int gcdmain(int argc, char *argv[]); + +%typemap(jni) (char *bytes, int len) "jstring" +%typemap(jtype) (char *bytes, int len) "String" +%typemap(jstype) (char *bytes, int len) "String" + +%typemap(javain) (char *bytes, int len) "$javainput" + +%typemap(in) (char *bytes, int len) { + $1 = ($1_type)(*jenv)->GetStringUTFChars(jenv, $input, 0); + $2 = (*jenv)->GetStringUTFLength(jenv, $input); +} + +%typemap(freearg) (char *bytes, int len) %{ + (*jenv)->ReleaseStringUTFChars(jenv, $input, $1); +%} + +extern int count(char *bytes, int len, char c); + +/* This example shows how to wrap a function that mutates a c string. A one + * element Java string array is used so that the string can be returned modified.*/ + +%typemap(jni) (char *str, int len) "jobjectArray" +%typemap(jtype) (char *str, int len) "String[]" +%typemap(jstype) (char *str, int len) "String[]" + +%typemap(javain) (char *str, int len) "$javainput" + +%typemap(in) (char *str, int len) (jstring js) { + int index = 0; + js = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, index); + $1 = (char *) (*jenv)->GetStringUTFChars(jenv, js, 0); + $2 = (*jenv)->GetStringUTFLength(jenv, js); +} + +/* Return the mutated string as a modified element in the array. */ +%typemap(argout) (char *str, int len) { + jstring newstring = (*jenv)->NewStringUTF(jenv, $1); + (*jenv)->SetObjectArrayElement(jenv, $input, 0, newstring); +} + +/* Release memory */ +%typemap(freearg) (char *str, int len) { + (*jenv)->ReleaseStringUTFChars(jenv, js$argnum, $1); +} + +extern void capitalize(char *str, int len); + +/* A multi-valued constraint. Force two arguments to lie + inside the unit circle */ + +%typemap(check) (double cx, double cy) { + double a = $1*$1 + $2*$2; + if (a > 1.0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "$1_name and $2_name must be in unit circle"); + return; + } +} + +extern void circle(double cx, double cy); + + diff --git a/Examples/doxygencomments/java/multimap/main.java b/Examples/doxygencomments/java/multimap/main.java new file mode 100644 index 000000000..331ac6b89 --- /dev/null +++ b/Examples/doxygencomments/java/multimap/main.java @@ -0,0 +1,40 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + + // Call our gcd() function + int x = 42; + int y = 105; + int g = example.gcd(x,y); + System.out.println("The gcd of " + x + " and " + y + " is " + g); + + // Call the gcdmain() function + String[] args = {"gcdmain","42","105"}; + example.gcdmain(args); + + // Call the count function + System.out.println(example.count("Hello World", 'l')); + + // Call the capitalize function + String[] capitalizeMe = {"hello world"}; + example.capitalize(capitalizeMe); + System.out.println(capitalizeMe[0]); + } +} + + + + + + + diff --git a/Examples/doxygencomments/java/native/Makefile b/Examples/doxygencomments/java/native/Makefile new file mode 100644 index 000000000..92afbd4d0 --- /dev/null +++ b/Examples/doxygencomments/java/native/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/native/example.i b/Examples/doxygencomments/java/native/example.i new file mode 100644 index 000000000..851b6fdc2 --- /dev/null +++ b/Examples/doxygencomments/java/native/example.i @@ -0,0 +1,56 @@ +/* File : example.i */ +%module example + +%{ +#include + +typedef struct point { + int x; + int y; +} Point; + + +Point *point_create(int x, int y) { + Point *p = (Point *) malloc(sizeof(Point)); + p->x = x; + p->y = y; + + return p; +} + +static char *point_toString(char *format, Point *p) { + static char buf[80]; + + sprintf(buf, format, p->x, p->y); + + return buf; +} + +/* this function will be wrapped by SWIG */ +char *point_toString1(Point *p) { + return point_toString("(%d,%d)", p); +} + +/* this one we wrapped manually*/ +JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) { + Point * p; + jstring result; + + (void)jcls; + + p = *(Point **)&jpoint; + + result = (*jenv)->NewStringUTF(jenv, point_toString("[%d,%d]", p)); + + return result; +} +%} + + +Point *point_create(int x, int y); +char *point_toString1(Point *p); + +/* give access to free() for memory cleanup of the malloc'd Point */ +extern void free(void *memblock); + +%native(point_toString2) char *point_toString2(Point *p); diff --git a/Examples/doxygencomments/java/native/index.html b/Examples/doxygencomments/java/native/index.html new file mode 100644 index 000000000..7ecf129ce --- /dev/null +++ b/Examples/doxygencomments/java/native/index.html @@ -0,0 +1,33 @@ + + +SWIG:Examples:java:native + + + + + +SWIG/Examples/java/native/ +
+ +

SWIG wrapped and manually wrapped functions in Java

+ +Click here for the relevant section in the SWIG and Java documentation. +

+This example compares wrapping a c global function using the manual way and the SWIG way. +

+ +
    +
  • example.i. Interface file comparing code wrapped by SWIG and wrapped manually. +
  • main.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. +
+ +

Notes

+ +
    +
  • SWIG writes all the awkward JNI code for you. You just have to tell SWIG which functions to wrap. +
  • If memory is allocated in c it needs to be free'd. A function, such as free(), can be provided with access from Java to free the memory. +
+ +
+ + diff --git a/Examples/doxygencomments/java/native/main.java b/Examples/doxygencomments/java/native/main.java new file mode 100644 index 000000000..f4760bb3d --- /dev/null +++ b/Examples/doxygencomments/java/native/main.java @@ -0,0 +1,19 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + SWIGTYPE_p_Point p = example.point_create(1, 2); + System.out.println("auto wrapped : " + example.point_toString1(p)); + System.out.println("manual wrapped: " + example.point_toString2(p)); + example.free(new SWIGTYPE_p_void(SWIGTYPE_p_Point.getCPtr(p), false)); //clean up c allocated memory + } +} diff --git a/Examples/doxygencomments/java/pointer/Makefile b/Examples/doxygencomments/java/pointer/Makefile new file mode 100644 index 000000000..968c92c6c --- /dev/null +++ b/Examples/doxygencomments/java/pointer/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/pointer/example.c b/Examples/doxygencomments/java/pointer/example.c new file mode 100644 index 000000000..b877d9a5b --- /dev/null +++ b/Examples/doxygencomments/java/pointer/example.c @@ -0,0 +1,16 @@ +/* File : example.c */ + +void add(int *x, int *y, int *result) { + *result = *x + *y; +} + +void sub(int *x, int *y, int *result) { + *result = *x - *y; +} + +int divide(int n, int d, int *r) { + int q; + q = n/d; + *r = n - q*d; + return q; +} diff --git a/Examples/doxygencomments/java/pointer/example.i b/Examples/doxygencomments/java/pointer/example.i new file mode 100644 index 000000000..a8ac79499 --- /dev/null +++ b/Examples/doxygencomments/java/pointer/example.i @@ -0,0 +1,30 @@ +/* File : example.i */ +%module example + +%{ +extern void add(int *, int *, int *); +extern void sub(int *, int *, int *); +extern int divide(int, int, int *); +%} + +/* This example illustrates a couple of different techniques + for manipulating C pointers */ + +/* First we'll use the pointer library */ +extern void add(int *x, int *y, int *result); +%include cpointer.i +%pointer_functions(int, intp); + +/* Next we'll use some typemaps */ + +%include typemaps.i +extern void sub(int *INPUT, int *INPUT, int *OUTPUT); + +/* Next we'll use typemaps and the %apply directive */ + +%apply int *OUTPUT { int *r }; +extern int divide(int n, int d, int *r); + + + + diff --git a/Examples/doxygencomments/java/pointer/index.html b/Examples/doxygencomments/java/pointer/index.html new file mode 100644 index 000000000..c30d549e6 --- /dev/null +++ b/Examples/doxygencomments/java/pointer/index.html @@ -0,0 +1,165 @@ + + +SWIG:Examples:java:pointer + + + + +SWIG/Examples/java/pointer/ +
+ +

Simple Pointer Handling

+ +

+This example illustrates a couple of techniques for handling +simple pointers in SWIG. The prototypical example is a C function +that operates on pointers such as this: + +

+
+void add(int *x, int *y, int *r) { 
+    *r = *x + *y;
+}
+
+
+ +By default, SWIG wraps this function exactly as specified and creates +an interface that expects pointer objects for arguments. +SWIG wraps a C pointer with a type wrapper class, for example, SWIGTYPE_p_int for an int*. +The only problem is how does one go about creating these objects from a Java program? +

+ + +

Possible Solutions

+ +
    +
  • Write some helper functions to explicitly create objects. For +example: + +
    +
    +int *new_int(int ivalue) {
    +  int *i = (int *) malloc(sizeof(ivalue));
    +  *i = ivalue;
    +  return i;
    +}
    +int get_int(int *i) {
    +  return *i;
    +}
    +
    +void delete_int(int *i) {
    +  free(i);
    +}
    +
    +
    + +

    +

  • The SWIG pointer library provides an easier way.
    +For example, in the interface file +you would do this: + +
    +
    +%include cpointer.i
    +%pointer_functions(int, intp);
    +
    +
    + +and from Java you would use pointers like this: + +
    +
    +SWIGTYPE_p_int a = example.new_intp();
    +SWIGTYPE_p_int b = example.new_intp();
    +SWIGTYPE_p_int c = example.new_intp();
    +example.intp_assign(a,37);
    +example.intp_assign(b,42);
    +
    +// Note that getCPtr() has package access by default
    +System.out.println("     a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a)));
    +System.out.println("     b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b)));
    +System.out.println("     c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c)));
    +
    +// Call the add() function with some pointers
    +example.add(a,b,c);
    +
    +// Now get the result
    +int res = example.intp_value(c);
    +System.out.println("     37 + 42 =" + res);
    +
    +// Clean up the pointers
    +example.delete_intp(a);
    +example.delete_intp(b);
    +example.delete_intp(c);
    +
    +
    + +

    +

  • Use the SWIG typemap library. This library allows you to completely +change the way arguments are processed by SWIG. For example: + +
    +
    +%include "typemaps.i"
    +void add(int *INPUT, int *INPUT, int *OUTPUT);
    +
    +
    + +And in a Java program: + +
    +
    +int[] r = {0};
    +example.sub(37,42,r);
    +System.out.println("Result =" + r[0]);
    +
    +
    +Needless to say, this is substantially easier although a bit unusual. + +

    +

  • A final alternative is to use the typemaps library in combination +with the %apply directive. This allows you to change the names of parameters +that behave as input or output parameters. For example: + +
    +
    +%include "typemaps.i"
    +%apply int *INPUT {int *x, int *y};
    +%apply int *OUTPUT {int *r};
    +
    +void add(int *x, int *y, int *r);
    +void sub(int *x, int *y, int *r);
    +void mul(int *x, int *y, int *r);
    +... etc ...
    +
    +
    + +
+ +

Example

+ +The following example illustrates the use of these features for pointer +extraction. + + + +

Notes

+ +
    +
  • Since pointers are used for so many different things (arrays, output values, +etc...) the complexity of pointer handling can be as complicated as you want to +make it. + +

    +

  • More documentation on the typemaps.i and cpointer.i library files can be +found in the SWIG user manual. The files also contain documentation. + +
+ +
+ + diff --git a/Examples/doxygencomments/java/pointer/main.java b/Examples/doxygencomments/java/pointer/main.java new file mode 100644 index 000000000..e96e02eaa --- /dev/null +++ b/Examples/doxygencomments/java/pointer/main.java @@ -0,0 +1,55 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + + // First create some objects using the pointer library. + System.out.println("Testing the pointer library"); + SWIGTYPE_p_int a = example.new_intp(); + SWIGTYPE_p_int b = example.new_intp(); + SWIGTYPE_p_int c = example.new_intp(); + example.intp_assign(a,37); + example.intp_assign(b,42); + + // Note that getCPtr() has package access by default + System.out.println(" a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a))); + System.out.println(" b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b))); + System.out.println(" c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c))); + + // Call the add() function with some pointers + example.add(a,b,c); + + // Now get the result + int res = example.intp_value(c); + System.out.println(" 37 + 42 =" + res); + + // Clean up the pointers + example.delete_intp(a); + example.delete_intp(b); + example.delete_intp(c); + + // Now try the typemap library + // Now it is no longer necessary to manufacture pointers. + // Instead we use a single element array which in Java is modifiable. + + System.out.println("Trying the typemap library"); + int[] r = {0}; + example.sub(37,42,r); + System.out.println(" 37 - 42 = " + r[0]); + + // Now try the version with return value + + System.out.println("Testing return value"); + int q = example.divide(42,37,r); + System.out.println(" 42/37 = " + q + " remainder " + r[0]); + } +} diff --git a/Examples/doxygencomments/java/reference/Makefile b/Examples/doxygencomments/java/reference/Makefile new file mode 100644 index 000000000..14c301703 --- /dev/null +++ b/Examples/doxygencomments/java/reference/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/reference/example.cxx b/Examples/doxygencomments/java/reference/example.cxx new file mode 100644 index 000000000..8a513bf49 --- /dev/null +++ b/Examples/doxygencomments/java/reference/example.cxx @@ -0,0 +1,46 @@ +/* File : example.cxx */ + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#include "example.h" +#include +#include + +Vector operator+(const Vector &a, const Vector &b) { + Vector r; + r.x = a.x + b.x; + r.y = a.y + b.y; + r.z = a.z + b.z; + return r; +} + +char *Vector::print() { + static char temp[512]; + sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); + return temp; +} + +VectorArray::VectorArray(int size) { + items = new Vector[size]; + maxsize = size; +} + +VectorArray::~VectorArray() { + delete [] items; +} + +Vector &VectorArray::operator[](int index) { + if ((index < 0) || (index >= maxsize)) { + printf("Panic! Array index out of bounds.\n"); + exit(1); + } + return items[index]; +} + +int VectorArray::size() { + return maxsize; +} + diff --git a/Examples/doxygencomments/java/reference/example.h b/Examples/doxygencomments/java/reference/example.h new file mode 100644 index 000000000..4915adb1b --- /dev/null +++ b/Examples/doxygencomments/java/reference/example.h @@ -0,0 +1,26 @@ +/* File : example.h */ + +class Vector { +private: + double x,y,z; +public: + Vector() : x(0), y(0), z(0) { }; + Vector(double x, double y, double z) : x(x), y(y), z(z) { }; + friend Vector operator+(const Vector &a, const Vector &b); + char *print(); +}; + +class VectorArray { +private: + Vector *items; + int maxsize; +public: + VectorArray(int maxsize); + ~VectorArray(); + Vector &operator[](int); + int size(); +}; + + + + diff --git a/Examples/doxygencomments/java/reference/example.i b/Examples/doxygencomments/java/reference/example.i new file mode 100644 index 000000000..6daa3b1f4 --- /dev/null +++ b/Examples/doxygencomments/java/reference/example.i @@ -0,0 +1,46 @@ +/* File : example.i */ + +/* This file has a few "typical" uses of C++ references. */ + +%module example + +%{ +#include "example.h" +%} + +class Vector { +public: + Vector(double x, double y, double z); + ~Vector(); + char *print(); +}; + +/* This helper function calls an overloaded operator */ +%inline %{ +Vector addv(Vector &a, Vector &b) { + return a+b; +} +%} + +/* Wrapper around an array of vectors class */ + +class VectorArray { +public: + VectorArray(int maxsize); + ~VectorArray(); + int size(); + + /* This wrapper provides an alternative to the [] operator */ + %extend { + Vector &get(int index) { + return (*$self)[index]; + } + void set(int index, Vector &a) { + (*$self)[index] = a; + } + } +}; + + + + diff --git a/Examples/doxygencomments/java/reference/index.html b/Examples/doxygencomments/java/reference/index.html new file mode 100644 index 000000000..64b129cbb --- /dev/null +++ b/Examples/doxygencomments/java/reference/index.html @@ -0,0 +1,147 @@ + + +SWIG:Examples:java:reference + + + + + +SWIG/Examples/java/reference/ +
+ +

C++ Reference Handling

+ +

+This example tests SWIG's handling of C++ references. Since C++ +references are closely related to pointers (as both refer to a +location in memory), SWIG simply collapses all references into +pointers when creating wrappers. + +

Some examples

+ +References are most commonly used as function parameter. For example, +you might have an operator like this: + +
+
+Vector operator+(const Vector &a, const Vector &b) {
+   Vector result;
+   result.x = a.x + b.x;
+   result.y = a.y + b.y;
+   result.z = a.z + b.z;
+   return result;
+}
+
+
+ +or a function: + +
+
+Vector addv(const Vector &a, const Vector &b) {
+   Vector result;
+   result.x = a.x + b.x;
+   result.y = a.y + b.y;
+   result.z = a.z + b.z;
+   return result;
+}
+
+
+ +In these cases, SWIG transforms everything into a pointer and creates a wrapper +that looks like this: + +
+
+Vector wrap_addv(Vector *a, Vector *b) {
+    return addv(*a,*b);
+}
+
+
+ +Occasionally, a reference is used as a return value of a function +when the return result is to be used as an lvalue in an expression. +The prototypical example is an operator like this: + +
+
+Vector &operator[](int index);
+
+
+ +or a method: + +
+
+Vector &get(int index);
+
+
+ +For functions returning references, a wrapper like this is created: + +
+
+Vector *wrap_Object_get(Object *self, int index) {
+    Vector &result = self->get(index);
+    return &result;
+}
+
+
+ +The following header file contains some class +definitions with some operators and use of references. + +

SWIG Interface

+ +SWIG does NOT support overloaded operators so it can not directly build +an interface to the classes in the above file. However, a number of workarounds +can be made. For example, an overloaded operator can be stuck behind a function +call such as the addv() function above. Array access can be handled +with a pair of set/get functions like this: + +
+
+class VectorArray {
+public:
+ ...
+   %addmethods {
+    Vector &get(int index) {
+      return (*self)[index];
+    }
+    void set(int index, Vector &a) {
+      (*self)[index] = a;
+    }
+   }
+   ...
+}
+
+
+ +Click here to see a SWIG interface file with these additions. + +

Sample Java program

+ +Click here to see a Java program that manipulates some C++ references. + +

Notes:

+ +
    +
  • C++ references primarily provide notational convenience for C++ +source code. However, Java only supports the 'x.a' +notation so it doesn't much matter. + +

    +

  • When a program returns a reference, a pointer is returned. +Unlike return by value, memory is not allocated to hold the +return result. + +

    +

  • SWIG has particular trouble handling various combinations of references +and pointers. This is side effect of an old parsing scheme and +type representation that will be replaced in future versions. + +
+ +
+ + diff --git a/Examples/doxygencomments/java/reference/main.java b/Examples/doxygencomments/java/reference/main.java new file mode 100644 index 000000000..4fd354761 --- /dev/null +++ b/Examples/doxygencomments/java/reference/main.java @@ -0,0 +1,79 @@ +// This example illustrates the manipulation of C++ references in Java. + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + System.out.println( "Creating some objects:" ); + Vector a = new Vector(3,4,5); + Vector b = new Vector(10,11,12); + + System.out.println( " Created " + a.print() ); + System.out.println( " Created " + b.print() ); + + // ----- Call an overloaded operator ----- + + // This calls the wrapper we placed around + // + // operator+(const Vector &a, const Vector &) + // + // It returns a new allocated object. + + System.out.println( "Adding a+b" ); + Vector c = example.addv(a,b); + System.out.println( " a+b = " + c.print() ); + + // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline + // is used as the proxy classes define finalizers which call the delete() method. When + // -noproxy is not specified the memory management is controlled by the garbage collector. + // You can still call delete(). It will free the c++ memory immediately, but not the + // Java memory! You then must be careful not to call any member functions as it will + // use a NULL c pointer on the underlying c++ object. We set the Java object to null + // which will then throw a Java exception should we attempt to use it again. + c.delete(); + c = null; + + // ----- Create a vector array ----- + + System.out.println( "Creating an array of vectors" ); + VectorArray va = new VectorArray(10); + System.out.println( " va = " + va.toString() ); + + // ----- Set some values in the array ----- + + // These operators copy the value of Vector a and Vector b to the vector array + va.set(0,a); + va.set(1,b); + + // This works, but it would cause a memory leak if -noproxy was used! + + va.set(2,example.addv(a,b)); + + + // Get some values from the array + + System.out.println( "Getting some array values" ); + for (int i=0; i<5; i++) + System.out.println( " va(" + i + ") = " + va.get(i).print() ); + + // Watch under resource meter to check on this + System.out.println( "Making sure we don't leak memory." ); + for (int i=0; i<1000000; i++) + c = va.get(i%10); + + // ----- Clean up ----- + // This could be omitted. The garbage collector would then clean up for us. + System.out.println( "Cleaning up" ); + va.delete(); + a.delete(); + b.delete(); + } +} diff --git a/Examples/doxygencomments/java/simple/Makefile b/Examples/doxygencomments/java/simple/Makefile new file mode 100644 index 000000000..968c92c6c --- /dev/null +++ b/Examples/doxygencomments/java/simple/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/simple/example.c b/Examples/doxygencomments/java/simple/example.c new file mode 100644 index 000000000..1c2af789c --- /dev/null +++ b/Examples/doxygencomments/java/simple/example.c @@ -0,0 +1,18 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + + diff --git a/Examples/doxygencomments/java/simple/example.dsp b/Examples/doxygencomments/java/simple/example.dsp new file mode 100644 index 000000000..8e1f8415e --- /dev/null +++ b/Examples/doxygencomments/java/simple/example.dsp @@ -0,0 +1,158 @@ +# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=example - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "example.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "example - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Desc=Java compile post-build step +PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "example - Win32 Debug" +# Name "example - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\example.c +# End Source File +# Begin Source File + +SOURCE=.\example_wrap.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\example.i + +!IF "$(CFG)" == "example - Win32 Debug" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -java $(InputPath) + +# End Custom Build + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo JAVA_INCLUDE: %JAVA_INCLUDE% + echo JAVA_BIN: %JAVA_BIN% + echo on + ..\..\..\swig.exe -java $(InputPath) + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/Examples/doxygencomments/java/simple/example.i b/Examples/doxygencomments/java/simple/example.i new file mode 100644 index 000000000..24093b9bf --- /dev/null +++ b/Examples/doxygencomments/java/simple/example.i @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} diff --git a/Examples/doxygencomments/java/simple/index.html b/Examples/doxygencomments/java/simple/index.html new file mode 100644 index 000000000..a363327fe --- /dev/null +++ b/Examples/doxygencomments/java/simple/index.html @@ -0,0 +1,108 @@ + + +SWIG:Examples:java:simple + + + + + +SWIG/Examples/java/simple/ +
+ +

Simple Java Example

+ +

+This example illustrates how you can hook Java to a very simple C program containing +a function and a global variable. + +

The C Code

+ +Suppose you have the following C code: + +
+
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+  int g;
+  g = y;
+  while (x > 0) {
+    g = x;
+    x = y % x;
+    y = g;
+  }
+  return g;
+}
+
+
+ +

The SWIG interface

+ +Here is a simple SWIG interface file: + +
+
+/* File: example.i */
+%module example
+
+extern int gcd(int x, int y);
+extern double Foo;
+
+
+ +

Compilation

+ +
    +
  1. swig -java example.i +

    +

  2. Compile example_wrap.c and example.c +to create the extension libexample.so (unix). +
+ +

Using the extension

+ +Click here to see a program that calls our C functions from Java. +

+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 main
+
+
+ +

Key points

+ +
    +
  • Use the loadLibrary statement from java to load and access the generated java classes. For example: +
    +
    +System.loadLibrary("example");
    +
    +
    + +
  • C functions work just like Java functions. For example: +
    +
    +int g = example.gcd(42,105);
    +
    +
    + +
  • C global variables are accessed through get and set functions in the module class. For example: +
    +
    +double a = example.get_Foo();
    +example.set_Foo(20.0);
    +
    +
    +
+ +
+ + diff --git a/Examples/doxygencomments/java/simple/main.java b/Examples/doxygencomments/java/simple/main.java new file mode 100644 index 000000000..6d224a4dc --- /dev/null +++ b/Examples/doxygencomments/java/simple/main.java @@ -0,0 +1,32 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + // Call our gcd() function + + int x = 42; + int y = 105; + int g = example.gcd(x,y); + System.out.println("The gcd of " + x + " and " + y + " is " + g); + + // Manipulate the Foo global variable + + // Output its current value + System.out.println("Foo = " + example.getFoo()); + + // Change its value + example.setFoo(3.1415926); + + // See if the change took effect + System.out.println("Foo = " + example.getFoo()); + } +} diff --git a/Examples/doxygencomments/java/template/Makefile b/Examples/doxygencomments/java/template/Makefile new file mode 100644 index 000000000..2b3d35c6a --- /dev/null +++ b/Examples/doxygencomments/java/template/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/template/example.h b/Examples/doxygencomments/java/template/example.h new file mode 100644 index 000000000..7401df650 --- /dev/null +++ b/Examples/doxygencomments/java/template/example.h @@ -0,0 +1,32 @@ +/* File : example.h */ + +// Some template definitions + +template T max(T a, T b) { return a>b ? a : b; } + +template class vector { + T *v; + int sz; + public: + vector(int _sz) { + v = new T[_sz]; + sz = _sz; + } + T &get(int index) { + return v[index]; + } + void set(int index, T &val) { + v[index] = val; + } +#ifdef SWIG + %extend { + T getitem(int index) { + return $self->get(index); + } + void setitem(int index, T val) { + $self->set(index,val); + } + } +#endif +}; + diff --git a/Examples/doxygencomments/java/template/example.i b/Examples/doxygencomments/java/template/example.i new file mode 100644 index 000000000..8f94c4da1 --- /dev/null +++ b/Examples/doxygencomments/java/template/example.i @@ -0,0 +1,17 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + +/* Now instantiate some specific template declarations */ + +%template(maxint) max; +%template(maxdouble) max; +%template(vecint) vector; +%template(vecdouble) vector; + diff --git a/Examples/doxygencomments/java/template/index.html b/Examples/doxygencomments/java/template/index.html new file mode 100644 index 000000000..1aebd4c2a --- /dev/null +++ b/Examples/doxygencomments/java/template/index.html @@ -0,0 +1,102 @@ + + +SWIG:Examples:java:template + + + + + +SWIG/Examples/java/template/ +
+ +

C++ template support

+ +

+This example illustrates how C++ templates can be used from Java using SWIG. + +

The C++ Code

+ +Lets take a templated function and a templated class as follows: + +
+
+/* File : example.h */
+
+// Some template definitions
+
+template T max(T a, T b) { return  a>b ? a : b; }
+
+template class vector {
+  T *v;
+  int sz;
+ public:
+  vector(int _sz) {
+    v = new T[_sz];
+    sz = _sz;
+  }
+  T &get(int index) {
+    return v[index];
+  }
+  void set(int index, T &val) {
+    v[index] = val;
+  }
+#ifdef SWIG
+  %addmethods {
+    T getitem(int index) {
+      return self->get(index);
+    }
+    void setitem(int index, T val) {
+      self->set(index,val);
+    }
+  }
+#endif
+};
+
+
+The %addmethods is used for a neater interface from Java as the functions get and set use C++ references to primitive types. These are tricky to use from Java as they end up as a pointer in Java (Java long). + +

The SWIG interface

+ +A simple SWIG interface for this can be built by simply grabbing the header file +like this: + +
+
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max;
+%template(maxdouble) max;
+%template(vecint) vector;
+%template(vecdouble) vector;
+
+
+ +Note that SWIG parses the templated function max and templated class vector and so knows about them. However to generate code for use from Java, SWIG has to be told which class/type to use as the template parameter. The SWIG directive %template is used for this. + +

A sample Java program

+ +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. + +
+
+vecdouble dv = new vecdouble(1000);
+dv.setitem(i, 12.34));
+
+
+ +
+ + diff --git a/Examples/doxygencomments/java/template/main.java b/Examples/doxygencomments/java/template/main.java new file mode 100644 index 000000000..9129fcf2a --- /dev/null +++ b/Examples/doxygencomments/java/template/main.java @@ -0,0 +1,45 @@ +// This example illustrates how C++ templates can be used from Java. + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) + { + // Call some templated functions + System.out.println(example.maxint(3,7)); + System.out.println(example.maxdouble(3.14,2.18)); + + // Create some class + + vecint iv = new vecint(100); + vecdouble dv = new vecdouble(1000); + + for (int i=0; i<100; i++) + iv.setitem(i,2*i); + + for (int i=0; i<1000; i++) + dv.setitem(i, 1.0/(i+1)); + + { + int sum = 0; + for (int i=0; i<100; i++) + sum = sum + iv.getitem(i); + + System.out.println(sum); + } + + { + double sum = 0.0; + for (int i=0; i<1000; i++) + sum = sum + dv.getitem(i); + System.out.println(sum); + } + } +} diff --git a/Examples/doxygencomments/java/typemap/Makefile b/Examples/doxygencomments/java/typemap/Makefile new file mode 100644 index 000000000..92afbd4d0 --- /dev/null +++ b/Examples/doxygencomments/java/typemap/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/typemap/example.i b/Examples/doxygencomments/java/typemap/example.i new file mode 100644 index 000000000..7c97e6673 --- /dev/null +++ b/Examples/doxygencomments/java/typemap/example.i @@ -0,0 +1,101 @@ +/* File : example.i */ +%module example +%{ +/* + example of a function that returns a value in the char * argument + normally used like: + + char buf[bigenough]; + f1(buf); +*/ + +void f1(char *s) { + if(s != NULL) { + sprintf(s, "hello world"); + } +} + +void f2(char *s) { + f1(s); +} + +void f3(char *s) { + f1(s); +} + +%} + +/* default behaviour is that of input arg, Java cannot return a value in a + * string argument, so any changes made by f1(char*) will not be seen in the Java + * string passed to the f1 function. +*/ +void f1(char *s); + +%include various.i + +/* use the BYTE argout typemap to get around this. Changes in the string by + * f2 can be seen in Java. */ +void f2(char *BYTE); + + + +/* Alternative approach uses a StringBuffer typemap for argout */ + +/* Define the types to use in the generated JNI C code and Java code */ +%typemap(jni) char *SBUF "jobject" +%typemap(jtype) char *SBUF "StringBuffer" +%typemap(jstype) char *SBUF "StringBuffer" + +/* How to convert Java(JNI) type to requested C type */ +%typemap(in) char *SBUF { + + $1 = NULL; + if($input != NULL) { + /* Get the String from the StringBuffer */ + jmethodID setLengthID; + jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); + jmethodID toStringID = (*jenv)->GetMethodID(jenv, sbufClass, "toString", "()Ljava/lang/String;"); + jstring js = (jstring) (*jenv)->CallObjectMethod(jenv, $input, toStringID); + + /* Convert the String to a C string */ + const char *pCharStr = (*jenv)->GetStringUTFChars(jenv, js, 0); + + /* Take a copy of the C string as the typemap is for a non const C string */ + jmethodID capacityID = (*jenv)->GetMethodID(jenv, sbufClass, "capacity", "()I"); + jint capacity = (*jenv)->CallIntMethod(jenv, $input, capacityID); + $1 = (char *) malloc(capacity+1); + strcpy($1, pCharStr); + + /* Release the UTF string we obtained with GetStringUTFChars */ + (*jenv)->ReleaseStringUTFChars(jenv, js, pCharStr); + + /* Zero the original StringBuffer, so we can replace it with the result */ + setLengthID = (*jenv)->GetMethodID(jenv, sbufClass, "setLength", "(I)V"); + (*jenv)->CallVoidMethod(jenv, $input, setLengthID, (jint) 0); + } +} + +/* How to convert the C type to the Java(JNI) type */ +%typemap(argout) char *SBUF { + + if($1 != NULL) { + /* Append the result to the empty StringBuffer */ + jstring newString = (*jenv)->NewStringUTF(jenv, $1); + jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); + jmethodID appendStringID = (*jenv)->GetMethodID(jenv, sbufClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); + (*jenv)->CallObjectMethod(jenv, $input, appendStringID, newString); + + /* Clean up the string object, no longer needed */ + free($1); + $1 = NULL; + } +} +/* Prevent the default freearg typemap from being used */ +%typemap(freearg) char *SBUF "" + +/* Convert the jstype to jtype typemap type */ +%typemap(javain) char *SBUF "$javainput" + +/* apply the new typemap to our function */ +void f3(char *SBUF); + diff --git a/Examples/doxygencomments/java/typemap/index.html b/Examples/doxygencomments/java/typemap/index.html new file mode 100644 index 000000000..486aa8e79 --- /dev/null +++ b/Examples/doxygencomments/java/typemap/index.html @@ -0,0 +1,32 @@ + + +SWIG:Examples:java:typemap + + + + + +SWIG/Examples/java/typemap/ +
+ +

Typemaps in Java

+ +

+This example shows how typemaps can be used to modify the default behaviour of the Java SWIG module. + +

+ +

Notes

+ +
    +
  • Shows how to pass strings to Java from c and visa versa. +
  • Typemaps can modify the default behaviour of the Java SWIG module. +
  • The default c to java mapping can be modified using typemaps. +
+ +
+ + diff --git a/Examples/doxygencomments/java/typemap/main.java b/Examples/doxygencomments/java/typemap/main.java new file mode 100644 index 000000000..bd9a4e1b6 --- /dev/null +++ b/Examples/doxygencomments/java/typemap/main.java @@ -0,0 +1,26 @@ + +public class main { + + static { + try { + System.loadLibrary("example"); + } 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[]) { + String s = "brave new world"; + example.f1(s); + System.out.println("f1(String): " + s); + + byte b[] = new byte[25]; + example.f2(b); + System.out.println("f2(byte[]): " + new String(b)); + + StringBuffer sb = new StringBuffer(20); + example.f3(sb); + System.out.println("f3(StringBuffer): " + sb); + } +} diff --git a/Examples/doxygencomments/java/variables/Makefile b/Examples/doxygencomments/java/variables/Makefile new file mode 100644 index 000000000..968c92c6c --- /dev/null +++ b/Examples/doxygencomments/java/variables/Makefile @@ -0,0 +1,18 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = + +all:: java + +java:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + javac *.java + +clean:: + $(MAKE) -f $(TOP)/Makefile java_clean + +check: all diff --git a/Examples/doxygencomments/java/variables/example.c b/Examples/doxygencomments/java/variables/example.c new file mode 100644 index 000000000..aa4ffe9b3 --- /dev/null +++ b/Examples/doxygencomments/java/variables/example.c @@ -0,0 +1,91 @@ +/* File : example.c */ + +/* I'm a file containing some C global variables */ + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#include +#include +#include "example.h" + +int ivar = 0; +short svar = 0; +long lvar = 0; +unsigned int uivar = 0; +unsigned short usvar = 0; +unsigned long ulvar = 0; +signed char scvar = 0; +unsigned char ucvar = 0; +char cvar = 0; +float fvar = 0; +double dvar = 0; +char *strvar = 0; +const char cstrvar[] = "Goodbye"; +int *iptrvar = 0; +char name[256] = "Dave"; +char path[256] = "/home/beazley"; + + +/* Global variables involving a structure */ +Point *ptptr = 0; +Point pt = { 10, 20 }; + +/* A variable that we will make read-only in the interface */ +int status = 1; + +/* A debugging function to print out their values */ + +void print_vars() { + printf("ivar = %d\n", ivar); + printf("svar = %d\n", svar); + printf("lvar = %ld\n", lvar); + printf("uivar = %u\n", uivar); + printf("usvar = %u\n", usvar); + printf("ulvar = %lu\n", ulvar); + printf("scvar = %d\n", scvar); + printf("ucvar = %u\n", ucvar); + printf("fvar = %g\n", fvar); + printf("dvar = %g\n", dvar); + printf("cvar = %c\n", cvar); + printf("strvar = %s\n", strvar ? strvar : "(null)"); + printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)"); + printf("iptrvar = %p\n", iptrvar); + printf("name = %s\n", name); + printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); + printf("pt = (%d, %d)\n", pt.x, pt.y); + printf("status = %d\n", status); +} + +/* A function to create an integer (to test iptrvar) */ + +int *new_int(int value) { + int *ip = (int *) malloc(sizeof(int)); + *ip = value; + return ip; +} + +/* A function to create a point */ + +Point *new_Point(int x, int y) { + Point *p = (Point *) malloc(sizeof(Point)); + p->x = x; + p->y = y; + return p; +} + +char * Point_print(Point *p) { + static char buffer[256]; + if (p) { + sprintf(buffer,"(%d,%d)", p->x,p->y); + } else { + sprintf(buffer,"null"); + } + return buffer; +} + +void pt_print() { + printf("(%d, %d)\n", pt.x, pt.y); +} diff --git a/Examples/doxygencomments/java/variables/example.h b/Examples/doxygencomments/java/variables/example.h new file mode 100644 index 000000000..0f7e89594 --- /dev/null +++ b/Examples/doxygencomments/java/variables/example.h @@ -0,0 +1,6 @@ +/* File: example.h */ + +typedef struct { + int x,y; +} Point; + diff --git a/Examples/doxygencomments/java/variables/example.i b/Examples/doxygencomments/java/variables/example.i new file mode 100644 index 000000000..591b871ed --- /dev/null +++ b/Examples/doxygencomments/java/variables/example.i @@ -0,0 +1,49 @@ +/* File : example.i */ +%module example +%{ +#include "example.h" +%} + +/* Some global variable declarations */ +%inline %{ +extern int ivar; +extern short svar; +extern long lvar; +extern unsigned int uivar; +extern unsigned short usvar; +extern unsigned long ulvar; +extern signed char scvar; +extern unsigned char ucvar; +extern char cvar; +extern float fvar; +extern double dvar; +extern char *strvar; +extern const char cstrvar[]; +extern int *iptrvar; +extern char name[256]; + +extern Point *ptptr; +extern Point pt; +%} + + +/* Some read-only variables */ + +%immutable; + +%inline %{ +extern int status; +extern char path[256]; +%} + +%mutable; + +/* Some helper functions to make it easier to test */ +%inline %{ +extern void print_vars(); +extern int *new_int(int value); +extern Point *new_Point(int x, int y); +extern char *Point_print(Point *p); +extern void pt_print(); +%} + diff --git a/Examples/doxygencomments/java/variables/index.html b/Examples/doxygencomments/java/variables/index.html new file mode 100644 index 000000000..05aaa2d6e --- /dev/null +++ b/Examples/doxygencomments/java/variables/index.html @@ -0,0 +1,85 @@ + + +SWIG:Examples:java:variables + + + + +SWIG/Examples/java/variables/ +
+ +

Wrapping C Global Variables

+ +

+When a C global variable appears in an interface file, SWIG tries to +wrap it using a technique known as "variable linking." The idea is +pretty simple---we try to create a Java variable that magically +retrieves or updates the value of the underlying C variable when it is +accessed. Click here to see a SWIG interface with some variable +declarations in it. + + +

Click here for the section on global variables in the SWIG and Java documentation.

+

Manipulating Variables from Java

+ +C variables are accessed through getters and setters from Java. Unfortunately this is the only way to get current values from variables because it is not possible to overload the dot operator in Java. All global variables are accessible from the module class. For example if the module class is called 'example', the global variable + +
+
+double foo;
+
+
+ +will be accessed in the Java module as +
+
+example.get_foo();
+example.set_foo(12.3);
+
+
+ +Click here to see the example program that updates and prints +out the values of the variables using this technique. + +

Key points

+ +
    +
  • When a global variable has the type "char *", SWIG manages it as a character +string. However, whenever the value of such a variable is set from Java, the old +value is destroyed using free() or delete (the choice of which depends +on whether or not SWIG was run with the -c++ option). +
  • signed char and unsigned char are handled as small 8-bit integers. +
  • String array variables such as 'char name[256]' are managed as Java strings, but +when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated. +
  • When structures and classes are used as global variables, they are mapped into pointers. +Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global. +
+ +

Creating read-only variables

+ +The %immutable and %mutable directives can be used to +specify a collection of read-only variables. For example: + +
+
+%immutable;
+int    status;
+double blah;
+...
+%mutable;
+
+
+ +The %immutable directive remains in effect until it is explicitly disabled +using the %mutable directive. + +

Comments

+
    +
  • Management of global variables is one of the most problematic aspects +of C/C++ wrapping because the Java interface and resulting memory management +is much trickier than simply creating a wrapper function. +
+ + + +
diff --git a/Examples/doxygencomments/java/variables/main.java b/Examples/doxygencomments/java/variables/main.java new file mode 100644 index 000000000..92745db99 --- /dev/null +++ b/Examples/doxygencomments/java/variables/main.java @@ -0,0 +1,97 @@ +// This example illustrates global variable access from Java. + +import java.lang.reflect.*; + +public class main { + static { + try { + System.loadLibrary("example"); + } 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[]) { + +// Try to set the values of some global variables + + example.setIvar(42); + example.setSvar((short)-31000); + example.setLvar(65537); + example.setUivar(123456); + example.setUsvar(61000); + example.setUlvar(654321); + example.setScvar((byte)-13); + example.setUcvar((short)251); + example.setCvar('S'); + example.setFvar((float)3.14159); + example.setDvar(2.1828); + example.setStrvar("Hello World"); + example.setIptrvar(example.new_int(37)); + example.setPtptr(example.new_Point(37,42)); + example.setName("Bill"); + + // Now print out the values of the variables + + System.out.println( "Variables (values printed from Java)" ); + + System.out.println( "ivar =" + example.getIvar() ); + System.out.println( "svar =" + example.getSvar() ); + System.out.println( "lvar =" + example.getLvar() ); + System.out.println( "uivar =" + example.getUivar() ); + System.out.println( "usvar =" + example.getUsvar() ); + System.out.println( "ulvar =" + example.getUlvar() ); + System.out.println( "scvar =" + example.getScvar() ); + System.out.println( "ucvar =" + example.getUcvar() ); + System.out.println( "fvar =" + example.getFvar() ); + System.out.println( "dvar =" + example.getDvar() ); + System.out.println( "cvar =" + (char)example.getCvar() ); + System.out.println( "strvar =" + example.getStrvar() ); + System.out.println( "cstrvar =" + example.getCstrvar() ); + System.out.println( "iptrvar =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(example.getIptrvar())) ); + System.out.println( "name =" + example.getName() ); + System.out.println( "ptptr =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPtptr())) + example.Point_print(example.getPtptr()) ); + System.out.println( "pt =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPt())) + example.Point_print(example.getPt()) ); + + System.out.println( "\nVariables (values printed from C)" ); + + example.print_vars(); + + System.out.println( "\nNow I'm going to try and modify some read only variables" ); + + System.out.println( " Trying to set 'path'" ); + try { + Method m = example.class.getDeclaredMethod("setPath", new Class[] {String.class}); + m.invoke(example.class, new Object[] {"Whoa!"} ); + System.out.println( "Hey, what's going on?!?! This shouldn't work" ); + } + catch (NoSuchMethodException e) { + System.out.println( "Good." ); + } + catch (Throwable t) { + System.out.println( "You shouldn't see this!" ); + } + + System.out.println( " Trying to set 'status'" ); + try { + Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class}); + m.invoke(example.class, new Object[] {new Integer(0)} ); + System.out.println( "Hey, what's going on?!?! This shouldn't work" ); + } + catch (NoSuchMethodException e) { + System.out.println( "Good." ); + } + catch (Throwable t) { + System.out.println( "You shouldn't see this!" ); + } + + System.out.println( "\nI'm going to try and update a structure variable.\n" ); + + example.setPt(example.getPtptr()); + + System.out.println( "The new value is" ); + example.pt_print(); + System.out.println( "You should see the value" + example.Point_print(example.getPtptr()) ); + } +} From e1a6b2ca3ba4467863b479419537d080435be186 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Sat, 16 Aug 2008 00:42:37 +0000 Subject: [PATCH 0011/2031] Cleaning up directories a bit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10764 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/DoxygenEntity.cpp | 89 -- Source/DoxygenTranslator/DoxygenEntity.h | 26 - .../DoxygenTranslator/DoxygenTranslator.cpp | 810 ------------------ Source/DoxygenTranslator/JavaDocConverter.cpp | 210 ----- Source/DoxygenTranslator/JavaDocConverter.h | 18 - Source/DoxygenTranslator/Token.cpp | 32 - Source/DoxygenTranslator/Token.h | 21 - Source/DoxygenTranslator/TokenList.cpp | 114 --- Source/DoxygenTranslator/TokenList.h | 27 - 9 files changed, 1347 deletions(-) delete mode 100644 Source/DoxygenTranslator/DoxygenEntity.cpp delete mode 100644 Source/DoxygenTranslator/DoxygenEntity.h delete mode 100644 Source/DoxygenTranslator/DoxygenTranslator.cpp delete mode 100644 Source/DoxygenTranslator/JavaDocConverter.cpp delete mode 100644 Source/DoxygenTranslator/JavaDocConverter.h delete mode 100644 Source/DoxygenTranslator/Token.cpp delete mode 100644 Source/DoxygenTranslator/Token.h delete mode 100644 Source/DoxygenTranslator/TokenList.cpp delete mode 100644 Source/DoxygenTranslator/TokenList.h diff --git a/Source/DoxygenTranslator/DoxygenEntity.cpp b/Source/DoxygenTranslator/DoxygenEntity.cpp deleted file mode 100644 index 6b8755592..000000000 --- a/Source/DoxygenTranslator/DoxygenEntity.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "DoxygenEntity.h" -#include - -/* Little data class for Doxygen Commands */ - - -/* Basic node for commands that have - * nothing after them - * example: \n - */ -string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; - -string findCommand(int commandNum){ - - int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); - if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ - return commandArray2[commandNum - 101]; - } - - return "" ; -} - -DoxygenEntity::DoxygenEntity(string typeEnt){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = 1; -} - -/* Basic node for commands that have - * only 1 thing after them - * example: \b word - * OR holding a string - */ -DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ - typeOfEntity = typeEnt; - data = param1; - isLeaf = 1; -} - -/* Nonterminal node - * contains - */ -DoxygenEntity::DoxygenEntity(string typeEnt, list &entList ){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = 0; - entityList = entList; -} - - -void DoxygenEntity::printEntity(int level){ - int thisLevel = level; - if (isLeaf) { - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command: " << typeOfEntity << " "; - if (data.compare("") != 0) cout << "Node Data: " << data; - cout << endl; - } - else{ - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command : " << typeOfEntity << endl; - list::iterator p = entityList.begin(); - thisLevel++; - while (p != entityList.end()){ - (*p).printEntity(thisLevel); - p++; - } - } -} - -DoxygenEntity::~DoxygenEntity() -{ -} diff --git a/Source/DoxygenTranslator/DoxygenEntity.h b/Source/DoxygenTranslator/DoxygenEntity.h deleted file mode 100644 index 0605b1cc9..000000000 --- a/Source/DoxygenTranslator/DoxygenEntity.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DOXYGENENTITY_H_ -#define DOXYGENENTITY_H_ - -#include -#include -#include -#include - -using namespace std; - -class DoxygenEntity{ - -public: - DoxygenEntity(string typeEnt); - DoxygenEntity(string typeEnt, string param1); - DoxygenEntity(string typeEnt, list &entList ); - ~DoxygenEntity(); - void printEntity(int level); - string typeOfEntity; - list entityList; - string data; - int isLeaf; -}; - - -#endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/DoxygenTranslator.cpp b/Source/DoxygenTranslator/DoxygenTranslator.cpp deleted file mode 100644 index 96fe6b2c5..000000000 --- a/Source/DoxygenTranslator/DoxygenTranslator.cpp +++ /dev/null @@ -1,810 +0,0 @@ - - - //THE TOKENIZER REWORK - - /* The main class for translating blobs of Doxygen for SWIG - * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - * Currently the spacing/format on this is a bit goofy in places, due to shuffling code - * between 2 editors! Apologies for anyone combing through it :) - */ - //TODO DOH instead of STL? -//TODO work in Brief descriptions, detailed descriptions for autobrief - - #include - #include - #include - #include - #include - #include "DoxygenEntity.h" - #include "TokenList.h" - #include "JavaDocConverter.h" - #define SIMPLECOMMAND 1 - #define IGNOREDSIMPLECOMMAND 2 - #define COMMANDWORD 3 - #define IGNOREDCOMMANDWORD 4 - #define COMMANDLINE 5 - #define IGNOREDCOMMANDLINE 6 - #define COMMANDPARAGRAPH 7 - #define IGNORECOMMANDPARAGRAPH 8 - #define COMMANDENDCOMMAND 9 - #define COMMANDWORDPARAGRAPH 10 - #define COMMANDWORDLINE 11 - #define COMMANDWORDOWORDWORD 12 - #define COMMANDOWORD 13 - #define COMMANDERRORTHROW 14 - #define COMMANDUNIQUE 15 -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 - using namespace std; - - ////////////////////////////////////////// - /*Set these to pick what internal functions - to test. */ - - //int testCommandParsingFunctions = 1;// not implemented - - - int noisy = 0; // set this to 1 for extra chatter from the parsing stage. - int addCommand(string currCommand, TokenList &tokList, list &aNewList); - list parse(list::iterator endParsingIndex, TokenList &tokList); - - ////////////////////////////////////////// - - - string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "\\","&", "~", "<", ">", "#", "%"}; - - - string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; - - /* All of the doxygen commands divided up by how they are parsed */ - string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; - string ignoredSimpleCommands[] = {"nothing at the moment"}; - string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; - string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; - string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; - string ignoreCommandLines[] = {"nothing at the moment"}; - string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; - string ignoreCommandParagraphs[] = {"nothing at the moment"}; - string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; - string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; - string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; - string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; - string commandOWords[] = {"dir", "file", "cond"}; - string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; - string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; - - - /* Changes a string to all lower case*/ - string StringToLower(string stringToConvert) - - { - - for(unsigned int i=0;i &rootList){ - - list::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; - } - - } - - /* Determines how a command should be handled (what group it belongs to - * for parsing rules - */ - - int commandBelongs(string theCommand){ - string smallString = StringToLower(theCommand ); - //cout << " Looking for command " << theCommand << endl; - int i = 0; - for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND ;} - } - for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ - if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} - } - for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ - if(smallString.compare( commandWords[i]) == 0){return COMMANDWORD;} - } - for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ - if(smallString.compare( ignoredCommandWords[i]) == 0){return IGNOREDCOMMANDWORD;} - } - for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ - if(smallString.compare( commandLines[i]) == 0){return COMMANDLINE;} - } - for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ - if(smallString.compare( ignoreCommandLines[i]) == 0){return IGNOREDCOMMANDLINE;} - } - for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ - if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} - } - /* IgnoreCommandParagraph */ - for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ - if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ - if(smallString.compare( commandEndCommands[i]) == 0){return COMMANDENDCOMMAND ;} - } - for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ - if(smallString.compare( commandWordParagraphs[i]) == 0){return COMMANDWORDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ - if(smallString.compare( commandWordLines[i]) == 0){return COMMANDWORDLINE ;} - } - for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ - if(smallString.compare( commandWordOWordOWords[i]) == 0){return COMMANDWORDOWORDWORD;} - } - for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ - if(smallString.compare( commandOWords[i]) == 0){return COMMANDOWORD;} - } - for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ - if(smallString.compare( commandErrorThrowings[i]) == 0){return COMMANDERRORTHROW;} - } - for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ - if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} - } - - return 0; - - } - /* Returns the next word ON THE CURRENT LINE ONLY - * if a new line is encountered, returns a blank string. - * Updates the index it is given if success. - */ - - string getNextWord(TokenList &tokList){ - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING ){ - nextToken = tokList.next(); - return nextToken.tokenString; - } - return ""; - } - - /* Returns the location of the end of the line as - * an iterator. - */ - list::iterator getOneLine(TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - return endOfParagraph; - } - endOfParagraph++; - } - return tokList.end(); - } - - - -/* Returns a properly formatted string - * up til ANY command or end of paragraph is encountered. - */ -string getStringTilCommand(TokenList &tokList){ - string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){ - Token currentToken = tokList.next(); - if(currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - else if (tokList.peek().tokenType == END_LINE) break; - } - - return description; - } - -/* Returns a properly formatted string - * up til the command specified is encountered - */ -//TODO check that this behaves properly for formulas - -string getStringTilEndCommand(string theCommand, TokenList &tokList){ - string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenString.compare(theCommand) != 0 ){ - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; - - } - - return description; - } - -/* Returns the end of a Paragraph as an iterator- - * Paragraph is defined in Doxygen to be a paragraph of text - * seperate by either a structural command or a blank line - */ - -list::iterator getEndOfParagraph(TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } - - } - - return tokList.end(); - - } - -/* Returns the end of a section, defined as the first blank line OR first encounter of the same - * command. Example of this behaviour is \arg - */ - -list::iterator getEndOfSection(string theCommand, TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } - - } -} - /* This method is for returning the end of a specific form of doxygen command - * that begins with a \command and ends in \endcommand - * such as \code and \endcode. The proper usage is - * progressTilEndCommand("endcode", tokenList); - */ -list::iterator getEndCommand(string theCommand, TokenList &tokList){ - list::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand!= tokList.end()){ - if ((*endOfCommand).tokenType == COMMAND){ - if (theCommand.compare((* endOfCommand).tokenString) == 0){ - return endOfCommand; - } - endOfCommand++; - } - } - //End command not found - return tokList.end(); - } - - /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered - */ - -list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ - list::iterator anIterator; - return anIterator; - } - - - - - /* Method for Adding a Simple Command - * Format: @command - * Plain commands, such as newline etc, they contain no other data - * \n \\ \@ \& \$ \# \< \> \% - */ - int addSimpleCommand(string theCommand, list &doxyList){ - - if (noisy) cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - - /* NOT INCLUDED Simple Commands - * Format: @command - * Plain commands, such as newline etc, they contain no other data - */ - int ignoreSimpleCommand(string theCommand, list &doxyList){ - - if (noisy) cout << "Not Adding " << theCommand << endl; - return 1; - } - - /* CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" - */ - int addCommandWord(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (!name.empty()){ - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - else cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - /* NOT INCLUDED CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" - */ - int ignoreCommandWord(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(tokList); - if (!name.empty()){ - return 1; - } - else cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; - } - - /* CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" - */ - int addCommandLine(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - list::iterator endOfLine = getOneLine(tokList); - list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - - } - - /* NOT INCLUDED CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandLine(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 1; - } - - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single paragraph after then such as @return - * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" - */ - int addCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ - list aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - // } - //else cout << "No line followed " << theCommand << " command. Not added" << endl; - } - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - //else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 1; - } - /* Command EndCommand - * Format: @command and ends at @endcommand - * Commands that take in a block of text such as @code - * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" - * Returns 1 if success, 0 if the endcommand is never encountered. - */ - - int addCommandEndCommand(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string description = getStringTilEndCommand( "end" + theCommand, tokList); - doxyList.push_back(DoxygenEntity(theCommand, description)); - return 1; - } - - /* CommandWordParagraph - * Format: @command {paragraph} - * Commands such as param - * "param", "tparam", "throw", "retval", "exception" - */ - int addCommandWordParagraph(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ - list aNewList; - aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 0; - } - /* CommandWordLine - * Format: @command (line) - * Commands such as param - * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" - */ - int addCommandWordLine(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list::iterator endOfLine = getOneLine(tokList); - list aNewList; - aNewList = parse(endOfLine, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - - //else cout << "No line followed " << theCommand << " command. Not added" << endl; - } - - /* Command Word Optional Word Optional Word - * Format: @command [] [] - * Commands such as class - * "category", "class", "protocol", "interface", "struct", "union" - */ - int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string headerfile = getNextWord(tokList); - string headername = getNextWord(tokList); - list aNewList; - aNewList.push_back(DoxygenEntity("plainstring", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - - /* Command Optional Word - * Format: @command [] - * Commands such as dir - * "dir", "file", "cond" - */ - int addCommandOWord(string theCommand, TokenList &tokList, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - - /* Commands that should not be encountered (such as PHP only) - */ - int addCommandErrorThrow(string theCommand, TokenList &tokList, list &doxyList){ - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } - - - int addCommandUnique(string theCommand, TokenList &tokList, list &doxyList){ - list aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - list::iterator endOfSection = getEndOfSection(theCommand, tokList); - list aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - } - - // \xrefitem "(heading)" "(list title)" {text} - else if (theCommand.compare("xrefitem") == 0){ - //TODO Implement xrefitem - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; - } - // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0){ - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0){ - list::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - list aNewList2; - aNewList2 = parse(endOfLine, tokList); - aNewList.splice(aNewList.end(), aNewList2); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \headerfile [] - else if (theCommand.compare("headerfile") == 0){ - list aNewList; - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0){ - list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()){ - list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - else doxyList.push_back(DoxygenEntity(theCommand)); - } - // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list aNewList; - list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - // \ref ["(text)"] - else if (theCommand.compare("ref") == 0){ - //TODO Implement ref - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0){ - //TODO implement subpage - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0){ - //TODO implement dotfile - if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \image ["caption"] [=] - else if (theCommand.compare("image") == 0){ - //todo implement image - } - // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - list aNewList; - list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - - } - - /* The actual "meat" of the doxygen parser. This is not yet fully implemented - * with my current design- however the skeletal outline is contained in - * the file Skeleton - */ - - - int addCommand(string commandString, TokenList &tokList,list &doxyList){ - string theCommand = StringToLower(commandString); - - if (theCommand.compare("plainstring") == 0){ - string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND){ - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW){ - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE){ - return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; - } - - list parse(list::iterator endParsingIndex, TokenList &tokList){ - list aNewList; - int currCommand; - while (tokList.current() != endParsingIndex){ - Token currToken = tokList.peek(); - if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ - tokList.next(); - } - else if(currToken.tokenType == COMMAND){ - currCommand = findCommand(currToken.tokenString); - tokList.next(); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currToken.tokenString << endl;} - //cout << "Command: " << currWord << " " << currCommand << endl; - - else addCommand(currToken.tokenString, tokList, aNewList); - } - else if (currToken.tokenType == PLAINSTRING){ - addCommand(string("plainstring"), tokList, aNewList); - } - - - } - - return aNewList; - } - -list convert(string doxygenBlob){ - TokenList tokList = TokenList(doxygenBlob); - if(noisy) { - cout << "---TOKEN LIST---" << endl; - tokList.printList(); - } - list rootList; - rootList = parse( tokList.end(), tokList); - if(noisy) { - cout << "PARSED LIST" << endl; - printTree(rootList); - } - return rootList; - } - -int main(int argc, char *argv[]){ - string doxygenString1 = "//! A normal member taking two arguments and returning an integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; - cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl; - list rootList = convert(doxygenString1); - JavaDocConverter jDC = JavaDocConverter(); - jDC.convertToJavaDoc(rootList); - return 1; -} - - diff --git a/Source/DoxygenTranslator/JavaDocConverter.cpp b/Source/DoxygenTranslator/JavaDocConverter.cpp deleted file mode 100644 index 91f52662f..000000000 --- a/Source/DoxygenTranslator/JavaDocConverter.cpp +++ /dev/null @@ -1,210 +0,0 @@ -#include "JavaDocConverter.h" -#include -#include -#include -#include -#define APPROX_LINE_LENGTH 64//characters per line allowed -#define TAB_SIZE 8//characters per line allowed -int printSortedTree2 = 0; -//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -JavaDocConverter::JavaDocConverter() -{ -} - -JavaDocConverter::~JavaDocConverter() -{ -} - -/* Sorts entities by javaDoc standard order for commands - * NOTE: will not behave entirely properly until "First level" comments - * such as brief descriptions are TAGGED as such - */ -bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ - if(first.typeOfEntity.compare("plainstring") == 0) return true; - if(second.typeOfEntity.compare("plainstring") == 0) return false; - if(first.typeOfEntity.compare("param") == 0){ - if(second.typeOfEntity.compare("param")== 0) return true; - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("return")== 0){ - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - - } - if(first.typeOfEntity.compare("exception")== 0){ - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("author")== 0){ - if(first.typeOfEntity.compare("author")== 0) return true; - if(first.typeOfEntity.compare("version")== 0)return true; - if(first.typeOfEntity.compare("see")== 0)return true; - if(first.typeOfEntity.compare("since")== 0)return true; - if(first.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("version")== 0){ - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("sa")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("since")== 0){ - if(second.typeOfEntity.compare("since")== 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("deprecated")== 0){ - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - return true; -} - -void JavaDocConverter::printSortedTree(list &entityList){ - list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } -} -string formatCommand(string unformattedLine, int indent){ - string formattedLines = "\n * "; - int lastPosition = 0; - int i = 0; - int isFirstLine = 1; - while (i != -1 && i < unformattedLine.length()){ - lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; - } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; - i = unformattedLine.find(" ", i); - - if (i > 0 && i + 1 < unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } - else { - isFirstLine = 0; - } - formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); - formattedLines.append("\n *"); - - } - } - if (lastPosition < unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} - formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); - } - - return formattedLines; -} - -/* Contains the conversions for tags - * could probably be much more efficient... - */ -string javaDocFormat(DoxygenEntity &doxygenEntity){ - if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("brief") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("detailed") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "" + doxygenEntity.data + ""; - } - return ""; -} - - -string translateSubtree( DoxygenEntity &doxygenEntity){ - string returnedString; - if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} - else { - returnedString += javaDocFormat(doxygenEntity); - list::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); - p++; - } - } - return returnedString; -} - -string translateEntity(DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; - else if(doxyEntity.typeOfEntity.compare("see") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("sa")== 0){ - return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); - } - - return ""; -} - -string JavaDocConverter:: convertToJavaDoc(list entityList){ - - - entityList.sort(compare_DoxygenEntities); - if(printSortedTree2){ - cout << "---RESORTED LIST---" << endl; - printSortedTree(entityList); - } - - string javaDocString = "/**"; - - list::iterator entityIterator = entityList.begin(); - while (entityIterator != entityList.end()){ - javaDocString += translateEntity(*entityIterator); - entityIterator++; - } - - javaDocString += "\n */\n"; - cout << "\n---RESULT IN JAVADOC---" << endl; - cout << javaDocString; - return javaDocString; -} \ No newline at end of file diff --git a/Source/DoxygenTranslator/JavaDocConverter.h b/Source/DoxygenTranslator/JavaDocConverter.h deleted file mode 100644 index 81122bc5f..000000000 --- a/Source/DoxygenTranslator/JavaDocConverter.h +++ /dev/null @@ -1,18 +0,0 @@ - #include - #include - #include "DoxygenEntity.h" - -#ifndef JAVADOCCONVERTER_H_ -#define JAVADOCCONVERTER_H_ - -class JavaDocConverter -{ -public: - - JavaDocConverter(); - string convertToJavaDoc(list entityList); - ~JavaDocConverter(); - void printSortedTree(list &entityList); -}; - -#endif /*JAVADOCCONVERTER_H_*/ diff --git a/Source/DoxygenTranslator/Token.cpp b/Source/DoxygenTranslator/Token.cpp deleted file mode 100644 index e85799546..000000000 --- a/Source/DoxygenTranslator/Token.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "Token.h" -#include -#include -#include -#include -using namespace std; - - -Token::Token(int tType, string tString) -{ - tokenType = tType; - tokenString = tString; -} - -string Token::toString() -{ - if (tokenType == END_LINE){ - return "{END OF LINE}"; - } - if (tokenType == PARAGRAPH_END){ - return "{END OF PARAGRAPH}"; - } - if (tokenType == PLAINSTRING){ - return tokenString; - } - if (tokenType == COMMAND){ - return "{COMMAND : " + tokenString+ "}"; - } - return ""; -} - -Token:: ~Token(){} diff --git a/Source/DoxygenTranslator/Token.h b/Source/DoxygenTranslator/Token.h deleted file mode 100644 index e98686c14..000000000 --- a/Source/DoxygenTranslator/Token.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef TOKEN_H_ -#define TOKEN_H_ -#include - -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 -using namespace std; - -class Token -{ -public: - Token(int tType, string tString); - ~Token(); - int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ - string tokenString; /* the data , such as param for @param*/ - string toString(); -}; - -#endif /*TOKEN_H_*/ diff --git a/Source/DoxygenTranslator/TokenList.cpp b/Source/DoxygenTranslator/TokenList.cpp deleted file mode 100644 index 0ace41c34..000000000 --- a/Source/DoxygenTranslator/TokenList.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "TokenList.h" -#include -#include -#include -#include -#include "Token.h" -#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list -#define END_LINE 101 -#define PARAGRAPH_END 102 //not used at the moment -#define PLAINSTRING 103 -#define COMMAND 104 -using namespace std; - - -list tokenList; -list::iterator tokenListIterator; -int noisy2 = 0; -/* The tokenizer*/ - -TokenList::TokenList(string doxygenString){ - int currentIndex = 0; - //Regex whitespace("[ \t]+"); - //Regex newLine("[\n]"); - //Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution - //Regex doxygenFluff("[/*!]+"); - int nextIndex = 0; - int isFluff = 0; - string currentWord; - while (currentIndex < doxygenString.length()){ - if(doxygenString[currentIndex] == '\n'){ - tokenList.push_back(Token(END_LINE, currentWord)); - currentIndex++; - } - while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' - || doxygenString[currentIndex]== '\t')) currentIndex ++; - if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached - else {nextIndex = currentIndex; - while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' - && doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; - currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); - if(noisy2) cout << "Current Word: " << currentWord << endl; - if (currentWord[0] == '@' || currentWord[0] == '\\'){ - currentWord = currentWord.substr(1, currentWord.length()-1); - tokenList.push_back(Token(COMMAND, currentWord)); - } - else if (currentWord[0] == '\n'){ - //if ((tokenList.back()).tokenType == END_LINE){} - tokenList.push_back(Token(END_LINE, currentWord)); - - } - else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ - if (currentWord.length() == 1) {isFluff = 1;} - else { isFluff = 1; - for(int i = 1; i < currentWord.length(); i++){ - if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0; - } - - } - if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); - } - - else tokenList.push_back(Token(PLAINSTRING, currentWord)); - currentIndex = nextIndex; - } - } - tokenListIterator = tokenList.begin(); -} - -Token TokenList::peek(){ - if(tokenListIterator!= tokenList.end()){ - Token returnedToken = (*tokenListIterator); - return returnedToken; - } - else - return Token(0, ""); -} - -Token TokenList::next(){ - if(tokenListIterator != tokenList.end()){ - Token returnedToken = (*tokenListIterator); - tokenListIterator++; - return (returnedToken); - } - else - return Token(0, ""); -} - -list::iterator TokenList::end(){ - return tokenList.end(); -} - -list::iterator TokenList::current(){ - return tokenListIterator; -} -void TokenList::printList(){ - list::iterator p = tokenList.begin(); - int i = 1; - int b = 0; - while (p != tokenList.end()){ - cout << (*p).toString() << " "; - b = i%TOKENSPERLINE; - if (b == 0) cout << endl; - p++; i++; - } -} - -list::iterator TokenList::iteratorCopy(){ - list::iterator p = tokenListIterator; - return p; -} -void TokenList::setIterator(list::iterator newPosition){ - tokenListIterator = newPosition; -} -TokenList:: ~TokenList(){} diff --git a/Source/DoxygenTranslator/TokenList.h b/Source/DoxygenTranslator/TokenList.h deleted file mode 100644 index cc61f56e4..000000000 --- a/Source/DoxygenTranslator/TokenList.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef TOKENLIST_H_ -#define TOKENLIST_H_ -#include -#include -#include -#include -#include "Token.h" -using namespace std; - -/* a small class used to represent the sequence of tokens - * that can be derived from a formatted doxygen string - */ - -class TokenList{ -public: - TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ - ~TokenList(); - Token peek(); /* returns next token without advancing */ - Token next(); /* returns next token and advances */ - list::iterator end(); /* returns an end iterator */ - list::iterator current(); /* returns the current iterator */ - void printList(); /* prints out the sequence of tokens */ - list::iterator iteratorCopy(); /* returns a copy of the current iterator */ - void setIterator(list::iterator newPosition); /*moves up the iterator*/ -}; - -#endif /*TOKENLIST_H_*/ From f7e758e59fc01c6fe7add7d208f6706d8f6e7398 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Sat, 16 Aug 2008 07:08:45 +0000 Subject: [PATCH 0012/2031] just removing 2 more useless things :) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10765 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/Skeleton | 1070 ---------------------------- Source/DoxygenTranslator/example.i | 19 - 2 files changed, 1089 deletions(-) delete mode 100755 Source/DoxygenTranslator/Skeleton delete mode 100644 Source/DoxygenTranslator/example.i diff --git a/Source/DoxygenTranslator/Skeleton b/Source/DoxygenTranslator/Skeleton deleted file mode 100755 index 099b94393..000000000 --- a/Source/DoxygenTranslator/Skeleton +++ /dev/null @@ -1,1070 +0,0 @@ -/** NOT A WORKING FILE- NOTES/SCRAPS - * A result of the initial implementation, - * stopped early because I changed my design. This is currently - * being reworked in the actual DoxygenTranslator class - */ - - - - -/* The Very Large and Unelegant Solution for dealing with Doxygen commands such as - * " \param". - * This is implemented this way because a LARGE number of potential Doxygen commands - * are not needed (such as PHP only or calling call graphs) and thus are simply - * thrown out. The more useful functions - * maybe be compartmentalised into their own method later on. - */ - -int addComment(int commentNum){ - - startIndex = endIndex; - string name; - string nextWordInLine = ""; - string restOfLine = ""; - string restOfParagraph = ""; - string headerfile =""; - string headername = ""; - switch(commentNum){ - - - /* \a */ - case 101: - nextWordInLine = getNextWord(); - if((nextWordInLine).empty()){ - cout << "Error: No word after tag a "<< endl; - } - else entityList.push_back( DoxygenEntity(101, "", nextWordInLine)); - startIndex = endIndex; - break; - - /* \addindex */ - case 102: - cout << "Add Index May not be Supported."<< endl; - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag a "<< endl; - } - else entityList.push_back( DoxygenEntity(102, "", restOfLine)); - startIndex = endIndex; - break; - - /* \addtogroup */ - case 103: - - - name = getNextWord(); - if (anythingLeftOnLine()){ - restOfLine = getOneLineSentence(); - entityList.push_back( DoxygenEntity(103, "", restOfLine)); - } - else cout << "AddtoGroup only supported for [(title)]. Command not added" << endl; - break; - - /* \anchor */ - case 104 : - getNextWord(); - cout << "Anchor is not supported. Command not added." << endl; - break; - - /* \arg */ - case 105: - - break; - - /* \attention */ - case 106: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(106, "", restOfLine)); - else cout << "Nothing followed attention command. Not added" < [] [] */ - case 115: - name = getNextWord(); - if (name.empty()) cout << "No word followed class command. Not added" <] */ - case 117: - cout << "cond is not supported. Command not added." << endl; - if (progressTilEndCommand("endcond") < 1) cout << "No endcode for command code found" << endl; - break; - - /* \copybrief */ - case 118: - getNextWord(); - cout << "copybrief is not yet implemented. Command not added." << endl; - break; - - /* \copydetails */ - case 119: - getNextWord(); - cout << "copydetails is not yet implemented. Command not added." << endl; - break; - - /* \copydoc */ - case 120: - getNextWord(); - cout << "copydoc is not yet implemented. Command not added." << endl; - break; - - /* \date { date description } */ - case 121: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(121, "", restOfLine)); - else cout << "Nothing followed date command. Not added" << endl; - break; - - /* \def */ - case 122: - name = getNextWord(); - if (!name.empty()) entityList.push_back( DoxygenEntity(122, name, "")); - else cout << "No word followed def command. Not added" << endl; - break; - - /* \defgroup (group title) */ - case 123: - name = getNextWord(); - if (name.empty())cout << "No word followed def command. Not added" << endl; - else { - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag a "<< endl; - } - else entityList.push_back( DoxygenEntity(123, name, restOfLine)); - } - break; - - /* \deprecated { description } */ - case 124: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(124, "", restOfLine)); - else cout << "Nothing followed deprecated command. Not added" << endl; - break; - - /* \details {detailed decription} */ - case 125: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(125, "", restOfLine)); - else cout << "Nothing followed details command. Not added" << endl; - break; - - /* \dir [] */ - case 126: - restOfLine = getOneLineSentence(); - entityList.push_back( DoxygenEntity(126, restOfLine , "")); - break; - - /* \dontinclude */ - case 127: - getNextWord(); - cout << "dontinclude is not implemented. Command not added." << endl; - break; - - /* \dot */ - case 128: - cout << "dot is not implemented. Command not added." << endl; - break; - - /* \dotfile ["caption"] */ - case 129: - getOneLineSentence(); - cout << "dotfile is not implemented. Command not added." << endl; - break; - - /* \e */ - case 130: - name = getNextWord(); - if (!name.empty()) entityList.push_back( DoxygenEntity(130, name, "")); - else cout << "No word followed e command. Not added" < */ - case 132: - getNextWord(); - cout << "elseif is not implemented. Command not added." << endl; - break; - - /* \em */ - /* Identical to e, so calls e */ - case 133: - addComment(130); - break; - - /* \endcode */ - case 134: - cout << "endcode is not implemented. Command not added." << endl; - break; - - /* \endcond */ - case 135: - cout << "endcond is not implemented. Command not added." << endl; - break; - - /* \enddot */ - case 136: - cout << "enddot is not implemented. Command not added." << endl; - break; - - /* \endhtmlonly */ - case 137: - cout << "endhtmlonly is not implemented. Command not added." << endl; - break; - - /* \endif */ - case 138: - cout << "endif is not implemented. Command not added." << endl; - break; - - /* \endlatexonly */ - case 139: - cout << "endlatexonly is not implemented. Command not added." << endl; - break; - - /* \endlink */ - case 140: - cout << "endlink is not implemented. Command not added." << endl; - break; - - /* \endmanonly */ - case 141: - cout << "endmanonly is not implemented. Command not added." << endl; - break; - - /* \endmsc */ - case 142: - cout << "endmsc is not implemented. Command not added." << endl; - break; - - /* \endverbatim */ - case 143: - cout << "endmsc is not implemented. Command not added." << endl; - break; - - /* \endxmlonly */ - case 144: - cout << "endxmlonly is not implemented. Command not added." << endl; - break; - - /* \enum */ - case 145: - name = getNextWord(); - if (!name.empty()) entityList.push_back( DoxygenEntity(145, name, "")); - else cout << "No word followed enum command. Not added" < */ - case 146: - name = getNextWord(); - if (!name.empty()) entityList.push_back( DoxygenEntity(146, name, "")); - else cout << "No word followed example command. Not added" < { exception description } */ - case 147: - name = getNextWord(); - if (name.empty()) cout << "No word followed exception command. Not added" < command. Not added" << endl; - } - break; - - /* \f$ */ - case 148: - cout << "f$ is not supported. Command not added." << endl; - if (progressTilEndCommand("f$") < 1) cout << "No endcode for command f$ found" << endl; - break; - - /* \f[ */ - case 149: - cout << "f$ is not supported. Command not added." << endl; - if (progressTilEndCommand("f]") < 1) cout << "No endcode for command f] found" << endl; - break; - - /* \f] */ - case 150: - cout << "f] is not implemented. Command not added." << endl; - break; - - /* \f{environment}{ */ - case 151: - cout << "f{environment}{ is not implemented. This may cause abnormal behaviour." << endl; - break; - - /* \f} */ - case 152: - cout << "f} is not implemented. This may cause abnormal behaviour." << endl; - break; - - /* \file [] */ - case 153: - name = getNextWord(); - if (!name.empty()) entityList.push_back( DoxygenEntity(153, name, "")); - else entityList.push_back( DoxygenEntity(153, "", "")); - break; - - /* \fn (function declaration) */ - case 154: - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag fn "<< endl; - } - else entityList.push_back( DoxygenEntity(154, restOfLine, "")); - break; - - /* \headerfile [] */ - case 155: - name = getNextWord(); - if (name.empty())cout << "No word followed headerfile command. Not added" << endl; - else { - restOfLine = getNextWord(); - entityList.push_back( DoxygenEntity(155, name, restOfLine)); - } - break; - - /* \hideinitializer */ - case 156: - cout << "hideinitializer is not implemented." << endl; - break; - - /* \htmlinclude */ - case 157: - name = getNextWord(); - if (name.empty())cout << "No word followed htmlinclude command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(157, name,"")); - } - break; - - /* \htmlonly */ - case 158: - cout << "htmlonly will be implemented later. For now the html is ignored." << endl; - if (progressTilEndCommand("endhtmlonly") < 1) cout << "No endcode for command code found" << endl; - break; - - /* \if */ - case 159: - cout << "if command is not implemented." << endl; - break; - - /* \ifnot */ - case 160: - cout << "ifnot command is not implemented." << endl; - break; - - /* \image ["caption"] [=] */ - case 161: - cout << "Image unsupported. Program may behave strangely if command is over one line." << endl; - getOneLineSentence(); - break; - - /* \include */ - case 162: - name = getNextWord(); - if (name.empty())cout << "No word followed include command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(162, name,"")); - } - break; - - /* \includelineno */ - case 163: - name = getNextWord(); - if (name.empty())cout << "No word followed includelineno command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(163, name,"")); - } - break; - - /* \ingroup ( [ ]) */ - case 164: - name = getNextWord(); - if (name.empty())cout << "No word followed ingroup command. Not added" << endl; - else { - string groupnames = getOneLineSentence(); - entityList.push_back( DoxygenEntity(164, name,groupnames)); - } - break; - - /* \internal */ - case 165: - entityList.push_back( DoxygenEntity(165, "","")); - break; - - /* \invariant { description of invariant } */ - case 166: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(166, restOfLine,"" )); - else cout << "Nothing followed invariant command. Not added" << endl; - break; - - /* \interface [] [] */ - case 167: - name = getNextWord(); - if (name.empty())cout << "No word followed ingroup command. Not added" << endl; - else { - string groupnames = getOneLineSentence(); - entityList.push_back( DoxygenEntity(167, name, groupnames)); - } - break; - - /* \latexonly */ - case 168: - cout << "latex only is not implemented" << endl; - if (progressTilEndCommand("endlatexonly") < 1) cout << "No endcode for command latexonly found" << endl; - break; - - /* \li { item-description } */ - //REDO - case 169: - addComment(105); - break; - - /* \line ( pattern ) */ - case 170: - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag line "<< endl; - } - else entityList.push_back( DoxygenEntity(170, restOfLine, "")); - break; - - /* \link */ - case 171: - name = getNextWord(); - if (name.empty())cout << "No word followed link command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(171, name,"")); - } - break; - - /* \mainpage [(title)] */ - case 172: - restOfLine = getOneLineSentence(); - entityList.push_back( DoxygenEntity(172, restOfLine, "")); - break; - - /* \manonly */ - case 173: - cout << "manonly is not implemented" << endl; - if (progressTilEndCommand("endmanonly") < 1) cout << "No endcode for command manonly found" << endl; - break; - - /* \msc */ - case 174: - cout << "msc is not implemented" << endl; - if (progressTilEndCommand("endmanonly") < 1) cout << "No endcode for command mscfound" << endl; - break; - - /* \n */ - case 175: - entityList.push_back( DoxygenEntity(175, "","")); - break; - - /* \name (header) */ - case 176: - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after header line "<< endl; - } - else entityList.push_back( DoxygenEntity(176, restOfLine, "")); - break; - - /* \namespace */ - case 177: - name = getNextWord(); - if (name.empty())cout << "No word followed namespace command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(177, name,"")); - } - break; - - /* \nosubgrouping */ - case 178: - cout << "Nosubgrouping not implemented "<< endl; - break; - - /* \note { text } */ - case 179: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(179, restOfLine,"" )); - else cout << "Nothing followed note command. Not added" << endl; - break; - - /* \overload [(function declaration)] */ - case 180: - restOfLine = getOneLineSentence(); - entityList.push_back( DoxygenEntity(172, restOfLine, "")); - break; - - /* \p */ - case 181: - name = getNextWord(); - if (name.empty())cout << "No word followed p command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(181, name,"")); - } - break; - - /* \package */ - case 182: - name = getNextWord(); - if (name.empty())cout << "No word followed package command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(182, name,"")); - } - break; - - /* \page (title) */ - case 183: - name = getNextWord(); - if (name.empty())cout << "No word followed page command. Not added" << endl; - else { - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag page "<< endl; - } - else entityList.push_back( DoxygenEntity(183, name, restOfLine)); - } - break; - - /* \par [(paragraph title)] { paragraph } */ - case 184: - name = getOneLineSentence(); - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(184, name, restOfParagraph )); - else cout << "Nothing followed par command. Not added" << endl; - break; - - /* \paragraph (paragraph title) */ - case 185: - name = getNextWord(); - if (name.empty())cout << "No word followed paragraph command. Not added" << endl; - else { - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after tag paragraph "<< endl; - } - else entityList.push_back( DoxygenEntity(185, name, restOfLine)); - } - break; - - /* \param { parameter description } */ - case 186: - name = getNextWord(); - if (name.empty())cout << "No word followed parameter command. Not added" << endl; - else { - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(186, name, restOfParagraph )); - else cout << "Nothing followed parameter command. Not added" << endl; - } - break; - - /* \post { description of the postcondition } */ - case 187: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(187, name, restOfParagraph )); - else cout << "Nothing followed post command. Not added" << endl; - break; - - /* \pre { description of the precondition } */ - case 188: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(187, name, restOfParagraph )); - else cout << "Nothing followed post command. Not added" << endl; - break; - - /* \private (PHP only) */ - case 189: - cout << "Private is a PHP Only Command." << endl; - break; - - /* \privatesection (PHP only) */ - case 190: - cout << "Privatesection is a PHP Only Command." << endl; - break; - - /* \property (qualified property name) */ - case 191: - restOfLine = getOneLineSentence(); - if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(191, restOfLine, "")); - else cout << "Nothing followed property command. Not added" << endl; - break; - - /* \protected (PHP only) */ - case 192: - cout << "Protected is a PHP Only Command." << endl; - break; - - /* \protectedsection (PHP only) */ - case 193: - cout << "Protectedsection is a PHP Only Command." << endl; - break; - - /* \protocol [] [] */ - case 194: - break; - - /* \public (PHP only) */ - case 195: - cout << "Public is a PHP Only Command." << endl; - break; - - /* \publicsection (PHP only) */ - case 196: - cout << "Public Section is a PHP Only Command." << endl; - break; - - /* \ref ["(text)"] */ - case 197: - name = getNextWord(); - getOneLineSentence(); - cout << "Ref is currently not supported." << endl; - break; - - /* \relates */ - case 198: - name = getNextWord(); - if (name.empty())cout << "No word followed relates command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(198, name,"")); - } - break; - - /* \relatesalso */ - case 199: - name = getNextWord(); - if (name.empty())cout << "No word followed relatesalso command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(199, name,"")); - } - break; - - /* \remarks { remark text } */ - case 200: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(200, restOfParagraph, "" )); - else cout << "Nothing followed remarks command. Not added" << endl; - break; - - /* \return { description of the return value } */ - case 201: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(200, restOfParagraph, "" )); - else cout << "Nothing followed return command. Not added" << endl; - break; - - /* \retval { description } */ - case 202: - name = getNextWord(); - if (name.empty())cout << "No word followed retval command. Not added" << endl; - else { - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(202, name, restOfParagraph )); - else cout << "Nothing followed retval command. Not added" << endl; - } - break; - - /* \sa { references } */ - case 203: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(203, restOfParagraph, "" )); - else cout << "Nothing followed sa command. Not added" << endl; - break; - - /* \section (section title) */ - case 204: - name = getNextWord(); - if (name.empty())cout << "No word followed section command. Not added" << endl; - else { - restOfLine = getOneLineSentence(); - if((restOfLine).empty()){ - cout << "Error: No word after section paragraph "<< endl; - } - else entityList.push_back( DoxygenEntity(204, name, restOfLine)); - } - break; - - /* \see { references } */ - case 205: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(205, restOfParagraph, "" )); - else cout << "Nothing followed see command. Not added" << endl; - break; - - /* \showinitializer */ - case 206: - cout << "Showerinitializer command unsupported"<< endl; - break; - - /* \since { text } */ - case 207: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(207, restOfParagraph, "" )); - else cout << "Nothing followed since command. Not added" << endl; - break; - - /* \skip ( pattern ) */ - case 208: - getOneLineSentence(); - cout << "Skip command unsupported"<< endl; - break; - - /* \skipline ( pattern ) */ - case 209: - getOneLineSentence(); - cout << "Skipline command unsupported"<< endl; - break; - - /* \struct [] [] */ - case 210: - name = getNextWord(); - if (name.empty())cout << "No word followed struct command. Not added" << endl; - else { - string groupnames = getOneLineSentence(); - entityList.push_back( DoxygenEntity(210, name, groupnames)); - } - break; - - /* \subpage ["(text)"] */ - case 211: - getOneLineSentence(); - cout << "subpag command unsupported"<< endl; - break; - - /* \subsection (subsection title) */ - case 212: - getOneLineSentence(); - cout << "subsection command unsupported"<< endl; - break; - - /* \subsubsection (subsubsection title) */ - case 213: - getOneLineSentence(); - cout << "subsubsection command unsupported"<< endl; - break; - - /* \test { paragraph describing a test case } */ - case 214: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(214, restOfParagraph, "" )); - else cout << "Nothing followed test command. Not added" << endl; - break; - - /* \throw { exception description } */ - case 215: - name = getNextWord(); - if (name.empty())cout << "No word followed throw command. Not added" << endl; - else { - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(215, name, restOfParagraph )); - else cout << "Nothing followed throw command. Not added" << endl; - } - break; - - /* \todo { paragraph describing what is to be done } */ - case 216: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(216, restOfParagraph, "" )); - else cout << "Nothing followed todo command. Not added" << endl; - break; - - /* \tparam { description } */ - case 217: - name = getNextWord(); - if (name.empty())cout << "No word followed tparam command. Not added" << endl; - else { - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(217, name, restOfParagraph )); - else cout << "Nothing followed tparam command. Not added" << endl; - } - break; - - /* \typedef (typedef declaration) */ - case 218: - restOfLine = getOneLineSentence(); - if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(218, restOfLine, "")); - else cout << "Nothing followed typedef command. Not added" << endl; - break; - - /* \union [] [] */ - case 219: - name = getNextWord(); - if (name.empty())cout << "No word followed union command. Not added" << endl; - else { - string groupnames = getOneLineSentence(); - entityList.push_back( DoxygenEntity(219, name, groupnames)); - } - break; - - /* \until ( pattern ) */ - case 220: - restOfLine = getOneLineSentence(); - if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(220, restOfLine, "")); - else cout << "Nothing followed until command. Not added" << endl; - break; - - /* \var (variable declaration) */ - case 221: - restOfLine = getOneLineSentence(); - if(!restOfLine.empty()) entityList.push_back( DoxygenEntity(221, restOfLine, "")); - else cout << "Nothing followed var command. Not added" << endl; - break; - - /* \verbatim */ - case 222: - cout << "Verbatim is not supported. Command not added." << endl; - if (progressTilEndCommand("endverbatim") < 1) cout << "No endcode for command verbatim found" << endl; - break; - - /* \verbinclude */ - case 223: - name = getNextWord(); - if (name.empty())cout << "No word followed verbinclude command. Not added" << endl; - else { - entityList.push_back( DoxygenEntity(223, name,"")); - } - break; - - /* \version { version number } */ - case 224: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(224, restOfParagraph, "" )); - else cout << "Nothing followed version command. Not added" << endl; - break; - - /* \warning { warning message } */ - case 225: - restOfParagraph = stringTilEndOfParagraph(endIndex); - if(!restOfParagraph.empty()) entityList.push_back( DoxygenEntity(225, restOfParagraph, "" )); - else cout << "Nothing followed warning command. Not added" << endl; - break; - - /* \weakgroup [(title)] */ - case 226: - name = getNextWord(); - if (name.empty())cout << "No word followed weakgroup command. Not added" << endl; - else { - string groupnames = getOneLineSentence(); - entityList.push_back( DoxygenEntity(226, name,groupnames)); - } - break; - - /* \xmlonly */ - case 227: - cout << "XML is not supported. Command not added." << endl; - if (progressTilEndCommand("endxmlonly") < 1) cout << "No endcode for command xmlonly found" << endl; - break; - - /* \xrefitem "(heading)" "(list title)" {text} */ - case 228: - //NEED TO IMPLEMENT - cout << "xrefitem is not supported yet. Command not added." << endl; - break; - - /* \$ */ - case 229: - entityList.push_back(229); - break; - - /* \@ */ - case 230: - entityList.push_back(230); - break; - - /* \\ */ - case 231: - entityList.push_back(231); - break; - - /* \& */ - case 232: - entityList.push_back(232); - break; - - /* \~[LanguageId] */ - case 233: - break; - - /* \< */ - case 234: - entityList.push_back(234); - break; - - /* \> */ - case 235: - entityList.push_back(235); - break; - - /* \# */ - case 236: - entityList.push_back(236); - break; - - /* \% */ - case 237: - entityList.push_back(237); - break; - - -} - - } - -int parse(string commentBlob){ - //NO error checking since this is only for my personal testing - // usage for now is "program -DocStyle filename - - /* - string java = "-java"; - - - if ((argc < 3)||(java.compare(StringToLower(argv[1])))!= 0 ) {cout << "Incorrect Usage. -Docstyle filename only." << endl; exit(1);} - string line; - ifstream doxCommentFile(argv[2], ios::in); - doxCommentFile >> doxygenString; - while(getline(doxCommentFile, line)){ - doxygenString += line + "\n";} - doxCommentFile.close(); - */ - doxygenString = commentBlob; - cout << doxygenString; - - -if(doxygenString.compare(0, 3, "/**")!= 0 && doxygenString.compare(0, 3, "/*!")!= 0 - && doxygenString.compare(0, 3, "///")!= 0 && doxygenString.compare(0, 3, "//!")!= 0 ){ - - cout << "String Is not in proper Doxygen format." << endl; - exit(1); - } - - -if(doxygenString[3] == '<'){ - cout << "Support for side comments not yet implemented"< 0){} - -while(endIndex < doxygenString.length() && startIndex < doxygenString.length()){ -currWord = getNextWord(); - -//while((currWord = nextWord()).compare("") == 0 ){ nextLine();} - -if(currWord[0] == 92 || currWord[0] == '@'){ - currWord = doxygenString.substr(startIndex+1, endIndex - startIndex - 1); - currCommand = findCommand(currWord); - if (currCommand < 0 ){ cout << "BAD COMMAND: " << currWord << endl; exit(1);} - cout << "Command: " << currWord << " " << currCommand << endl; - startIndex = endIndex; -} - -else if (briefDescriptions && !briefDescExists ){ - currComment = getOneLineSentence(); - if (!currComment.empty()){ - briefDescExists = 1; - cout << "Brief Description Found : " << currComment << endl << "-----" << endl; - entityList.push_back( DoxygenEntity(99, "", currComment)); - startIndex = endIndex; - } - else cout << "Error: Brief comment extends more than 1 line." << endl; -} - -else{ - currComment = getDescription(); - cout << "Long Description Found : " << currComment << endl << "-----" << endl; - entityList.push_back( DoxygenEntity(100, "", currComment)); - startIndex = endIndex; -} - -} - -cout << "Entity List : "<< endl; -list::iterator p = entityList.begin(); -while (p != entityList.end()){ - (*p).printEntity(); - p++; -} - - - return 0; -} - - -} - diff --git a/Source/DoxygenTranslator/example.i b/Source/DoxygenTranslator/example.i deleted file mode 100644 index 20f2488cb..000000000 --- a/Source/DoxygenTranslator/example.i +++ /dev/null @@ -1,19 +0,0 @@ -/** File example. This is the Simple Test File! - */ - -%module example - -%inline %{ - -/** Function for Greater Common Divisor - * Compute the greatest common divisor of positive integers - * @param x an integer argument. - * @param y another integer argument. - * @return the GCD - */ -extern int gcd(int x, int y); - -/** Global Variable Foo. Foo is the value of Foo. - */ -extern double Foo; -%} From 03fd3d6581dbe5411425a23d455476f4d0d22ef4 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Sat, 16 Aug 2008 07:11:00 +0000 Subject: [PATCH 0013/2031] more cleaning up git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10766 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/TranslatorTest.cpp | 68 ------------------- Source/DoxygenTranslator/src/TranslatorTest.h | 11 --- 2 files changed, 79 deletions(-) delete mode 100644 Source/DoxygenTranslator/src/TranslatorTest.cpp delete mode 100644 Source/DoxygenTranslator/src/TranslatorTest.h diff --git a/Source/DoxygenTranslator/src/TranslatorTest.cpp b/Source/DoxygenTranslator/src/TranslatorTest.cpp deleted file mode 100644 index f2bb48983..000000000 --- a/Source/DoxygenTranslator/src/TranslatorTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -#include -#include -#include -#include -#include -using namespace std; - - -/* This classes primary function is to test the basic text processing abilities of - * the Doxygen parsing class - * It is currently a little messy */ - - -int testCommandParsingFunctions = 1; -int testCodeCrawlingFunctions = 1; - - -/* Testing clearFluff(), a method to scan past all excess / * ! from beginning of - * a comment blob. Compartmentalised simply because this is a comment habit that - * differs wildly */ - -int testClearFluff(){ - - string cases[] = {"/** WORD", "/*! WORD", "/******* WORD", "///// WORD", "//! WORD", "//! WORD", "///WORD", - "/**\nWORD", "/**\n*WORD", "/** \n WORD"}; - - return 1; - - }; - -int testCCF(){ - - - - cout << "Testing getNextWord" << endl; - // Case 1: \command - string case1 = "\b word"; - string case2 = "\b word "; - string case3 = "\b word\n"; - string case4 = "\b word \n"; - string case5 = "\b word word"; - //Case 2: \command {paragraph} - - //Case 3: \command (text til end of line) - - - return 1; -} - -int testCPF(){ - // Case 1: \command - string case1 = "\b word"; - //Case 2: \command {paragraph} - - //Case 3: \command (text til end of line) - - return 1; - -} - -int main(int argc, char *argv[]){ - if(testCodeCrawlingFunctions) testCCF(); - if(testCommandParsingFunctions) testCPF(); - - - return 1; -} diff --git a/Source/DoxygenTranslator/src/TranslatorTest.h b/Source/DoxygenTranslator/src/TranslatorTest.h deleted file mode 100644 index 0014de718..000000000 --- a/Source/DoxygenTranslator/src/TranslatorTest.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef TRANSLATORTEST_H_ -#define TRANSLATORTEST_H_ - -class TranslatorTest -{ -public: - TranslatorTest(); - virtual ~TranslatorTest(); -}; - -#endif /*TRANSLATORTEST_H_*/ From 180171ddffc5f7c2e7d0a20816373c41e0fa6931 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Sat, 16 Aug 2008 07:31:05 +0000 Subject: [PATCH 0014/2031] Fixed post comment behaviour git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10767 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index eaf53449b..09aeb7381 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -105,8 +105,14 @@ static Node *new_node(const String_or_char *tag) { if(parseComments){ /* Sets any post comments to the previous node */ if(previousNode != NULL && currentPostComment != 0){ - String *copyPostComment = Copy(currentComment); - Setattr(previousNode,"DoxygenPostComment",copyPostComment); + String *copyPostComment = Copy(currentPostComment); + if (!Getattr(previousNode, "DoxygenComment")){ + Setattr(previousNode,"DoxygenComment",copyPostComment);} + else { + Append(copyPostComment, Getattr(previousNode, "DoxygenComment")); + Setattr(previousNode,"DoxygenComment",copyPostComment); + } + currentPostComment = 0; } /* Sets Doxygen Comment if a Comment is Availible */ From 88bd4e6331272a01e3fed7ec66f2b75b42b1424a Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 04:54:35 +0000 Subject: [PATCH 0015/2031] Removal of unneeded importants; debugging parser git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10777 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../src/.deps/DoxygenEntity.Po | 190 +++++------ .../src/.deps/DoxygenParser.Po | 211 ++++++------ .../src/.deps/DoxygenTranslator.Po | 204 ++++++------ Source/DoxygenTranslator/src/.deps/Token.Po | 78 +---- .../DoxygenTranslator/src/DoxygenEntity.cpp | 2 +- Source/DoxygenTranslator/src/DoxygenEntity.h | 3 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 306 +++++++++--------- Source/DoxygenTranslator/src/DoxygenParser.h | 5 - .../src/DoxygenTranslator.cpp | 32 +- .../src/JavaDocConverter.cpp | 33 +- Source/DoxygenTranslator/src/Token.cpp | 6 +- Source/DoxygenTranslator/src/TokenList.cpp | 2 +- 12 files changed, 498 insertions(+), 574 deletions(-) diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po b/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po index 7d2d2e0db..7a6dbd296 100644 --- a/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po +++ b/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po @@ -1,36 +1,42 @@ DoxygenTranslator/src/DoxygenEntity.o \ DoxygenTranslator/src/DoxygenEntity.o: \ DoxygenTranslator/src/DoxygenEntity.cpp \ - DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/cstdlib \ + DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/string \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ /usr/include/gnu/stubs-32.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ /usr/include/c++/4.2/cstddef \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ /usr/include/stdlib.h /usr/include/bits/waitflags.h \ /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/xlocale.h \ - /usr/include/sys/types.h /usr/include/bits/types.h \ - /usr/include/bits/typesizes.h /usr/include/time.h \ - /usr/include/sys/select.h /usr/include/bits/select.h \ - /usr/include/bits/sigset.h /usr/include/bits/time.h \ - /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ - /usr/include/alloca.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ /usr/include/c++/4.2/iosfwd \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstring /usr/include/string.h \ /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/wchar.h \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/c++/4.2/clocale /usr/include/locale.h \ - /usr/include/bits/locale.h /usr/include/langinfo.h \ - /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ - /usr/include/c++/4.2/cstdarg \ + /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ + /usr/include/locale.h /usr/include/bits/locale.h \ + /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ + /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ @@ -39,18 +45,10 @@ DoxygenTranslator/src/DoxygenEntity.o \ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ /usr/include/bits/confname.h /usr/include/getopt.h \ /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/char_traits.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/exception_defines.h \ /usr/include/c++/4.2/bits/stl_pair.h \ /usr/include/c++/4.2/bits/cpp_type_traits.h \ /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ @@ -59,25 +57,28 @@ DoxygenTranslator/src/DoxygenEntity.o \ /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ /usr/include/c++/4.2/bits/concept_check.h \ /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ + /usr/include/c++/4.2/bits/allocator.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/exception \ /usr/include/c++/4.2/bits/stl_construct.h \ /usr/include/c++/4.2/bits/stl_uninitialized.h \ /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ - /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/basic_string.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ /usr/include/c++/4.2/bits/stl_heap.h \ /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ + /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/bits/locale_classes.h \ /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ /usr/include/c++/4.2/bits/basic_ios.h \ /usr/include/c++/4.2/bits/streambuf_iterator.h \ @@ -92,12 +93,11 @@ DoxygenTranslator/src/DoxygenEntity.o \ /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ /usr/include/c++/4.2/bits/locale_facets.tcc \ /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc + /usr/include/c++/4.2/bits/istream.tcc DoxygenTranslator/src/DoxygenEntity.h: -/usr/include/c++/4.2/cstdlib: +/usr/include/c++/4.2/string: /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: @@ -115,10 +115,44 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/cstring: + /usr/include/c++/4.2/cstddef: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/c++/4.2/cstdlib: + /usr/include/stdlib.h: /usr/include/bits/waitflags.h: @@ -129,8 +163,6 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/bits/endian.h: -/usr/include/xlocale.h: - /usr/include/sys/types.h: /usr/include/bits/types.h: @@ -153,20 +185,10 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/alloca.h: -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - /usr/include/c++/4.2/iosfwd: /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: -/usr/include/c++/4.2/cstring: - -/usr/include/string.h: - /usr/include/c++/4.2/cstdio: /usr/include/stdio.h: @@ -179,8 +201,6 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: -/usr/include/bits/stdio_lim.h: - /usr/include/bits/sys_errlist.h: /usr/include/c++/4.2/clocale: @@ -229,8 +249,6 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/ctype.h: -/usr/include/c++/4.2/bits/stringfwd.h: - /usr/include/c++/4.2/bits/postypes.h: /usr/include/c++/4.2/cwchar: @@ -245,30 +263,6 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/exception_defines.h: -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - /usr/include/c++/4.2/bits/stl_pair.h: /usr/include/c++/4.2/bits/cpp_type_traits.h: @@ -289,18 +283,6 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/debug/debug.h: -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/string: - /usr/include/c++/4.2/memory: /usr/include/c++/4.2/bits/allocator.h: @@ -311,6 +293,8 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/new: +/usr/include/c++/4.2/exception: + /usr/include/c++/4.2/bits/stl_construct.h: /usr/include/c++/4.2/bits/stl_uninitialized.h: @@ -325,6 +309,10 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/bits/basic_string.h: +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + /usr/include/c++/4.2/algorithm: /usr/include/c++/4.2/bits/stl_algo.h: @@ -335,6 +323,24 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/bits/basic_string.tcc: +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + /usr/include/c++/4.2/streambuf: /usr/include/c++/4.2/bits/streambuf.tcc: @@ -372,9 +378,3 @@ DoxygenTranslator/src/DoxygenEntity.h: /usr/include/c++/4.2/istream: /usr/include/c++/4.2/bits/istream.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po b/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po index 3a023d6b9..8ec874c8c 100644 --- a/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po +++ b/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po @@ -1,36 +1,42 @@ DoxygenTranslator/src/DoxygenParser.o \ DoxygenTranslator/src/DoxygenParser.o: \ DoxygenTranslator/src/DoxygenParser.cpp \ - DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/cstdlib \ + DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/string \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ /usr/include/gnu/stubs-32.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ /usr/include/c++/4.2/cstddef \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ /usr/include/stdlib.h /usr/include/bits/waitflags.h \ /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/xlocale.h \ - /usr/include/sys/types.h /usr/include/bits/types.h \ - /usr/include/bits/typesizes.h /usr/include/time.h \ - /usr/include/sys/select.h /usr/include/bits/select.h \ - /usr/include/bits/sigset.h /usr/include/bits/time.h \ - /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ - /usr/include/alloca.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ /usr/include/c++/4.2/iosfwd \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstring /usr/include/string.h \ /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/wchar.h \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/c++/4.2/clocale /usr/include/locale.h \ - /usr/include/bits/locale.h /usr/include/langinfo.h \ - /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ - /usr/include/c++/4.2/cstdarg \ + /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ + /usr/include/locale.h /usr/include/bits/locale.h \ + /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ + /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ @@ -39,18 +45,10 @@ DoxygenTranslator/src/DoxygenParser.o \ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ /usr/include/bits/confname.h /usr/include/getopt.h \ /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/char_traits.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/exception_defines.h \ /usr/include/c++/4.2/bits/stl_pair.h \ /usr/include/c++/4.2/bits/cpp_type_traits.h \ /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ @@ -59,25 +57,29 @@ DoxygenTranslator/src/DoxygenParser.o \ /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ /usr/include/c++/4.2/bits/concept_check.h \ /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ + /usr/include/c++/4.2/bits/allocator.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/exception \ /usr/include/c++/4.2/bits/stl_construct.h \ /usr/include/c++/4.2/bits/stl_uninitialized.h \ /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ - /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/basic_string.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ /usr/include/c++/4.2/bits/stl_heap.h \ /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ + /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ + /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/bits/locale_classes.h \ /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ /usr/include/c++/4.2/bits/basic_ios.h \ /usr/include/c++/4.2/bits/streambuf_iterator.h \ @@ -92,16 +94,11 @@ DoxygenTranslator/src/DoxygenParser.o \ /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ /usr/include/c++/4.2/bits/locale_facets.tcc \ /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/fstream \ - /usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h \ - /usr/include/c++/4.2/bits/fstream.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ - DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h + /usr/include/c++/4.2/bits/istream.tcc DoxygenTranslator/src/Token.h DoxygenTranslator/src/DoxygenParser.h: -/usr/include/c++/4.2/cstdlib: +/usr/include/c++/4.2/string: /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: @@ -119,10 +116,44 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/cstring: + /usr/include/c++/4.2/cstddef: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/c++/4.2/cstdlib: + /usr/include/stdlib.h: /usr/include/bits/waitflags.h: @@ -133,8 +164,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/bits/endian.h: -/usr/include/xlocale.h: - /usr/include/sys/types.h: /usr/include/bits/types.h: @@ -157,20 +186,10 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/alloca.h: -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - /usr/include/c++/4.2/iosfwd: /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: -/usr/include/c++/4.2/cstring: - -/usr/include/string.h: - /usr/include/c++/4.2/cstdio: /usr/include/stdio.h: @@ -183,8 +202,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: -/usr/include/bits/stdio_lim.h: - /usr/include/bits/sys_errlist.h: /usr/include/c++/4.2/clocale: @@ -233,8 +250,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/ctype.h: -/usr/include/c++/4.2/bits/stringfwd.h: - /usr/include/c++/4.2/bits/postypes.h: /usr/include/c++/4.2/cwchar: @@ -249,30 +264,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/exception_defines.h: -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - /usr/include/c++/4.2/bits/stl_pair.h: /usr/include/c++/4.2/bits/cpp_type_traits.h: @@ -293,18 +284,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/debug/debug.h: -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/string: - /usr/include/c++/4.2/memory: /usr/include/c++/4.2/bits/allocator.h: @@ -315,6 +294,8 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/new: +/usr/include/c++/4.2/exception: + /usr/include/c++/4.2/bits/stl_construct.h: /usr/include/c++/4.2/bits/stl_uninitialized.h: @@ -329,6 +310,10 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/basic_string.h: +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + /usr/include/c++/4.2/algorithm: /usr/include/c++/4.2/bits/stl_algo.h: @@ -339,6 +324,28 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/basic_string.tcc: +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +DoxygenTranslator/src/DoxygenEntity.h: + +DoxygenTranslator/src/TokenList.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + /usr/include/c++/4.2/streambuf: /usr/include/c++/4.2/bits/streambuf.tcc: @@ -377,22 +384,4 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/istream.tcc: -/usr/include/c++/4.2/fstream: - -/usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h: - -/usr/include/c++/4.2/bits/fstream.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -DoxygenTranslator/src/DoxygenEntity.h: - -DoxygenTranslator/src/TokenList.h: - DoxygenTranslator/src/Token.h: - -DoxygenTranslator/src/JavaDocConverter.h: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po b/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po index d71e23830..4cec6c648 100644 --- a/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po +++ b/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po @@ -1,36 +1,42 @@ DoxygenTranslator/src/DoxygenTranslator.o \ DoxygenTranslator/src/DoxygenTranslator.o: \ DoxygenTranslator/src/DoxygenTranslator.cpp \ - DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/cstdlib \ + DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/string \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ /usr/include/gnu/stubs-32.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ + /usr/include/c++/4.2/bits/stringfwd.h \ + /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ /usr/include/c++/4.2/cstddef \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ + /usr/include/string.h /usr/include/xlocale.h \ + /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ + /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ + /usr/include/limits.h /usr/include/bits/posix1_lim.h \ + /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ + /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ /usr/include/stdlib.h /usr/include/bits/waitflags.h \ /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/xlocale.h \ - /usr/include/sys/types.h /usr/include/bits/types.h \ - /usr/include/bits/typesizes.h /usr/include/time.h \ - /usr/include/sys/select.h /usr/include/bits/select.h \ - /usr/include/bits/sigset.h /usr/include/bits/time.h \ - /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ - /usr/include/alloca.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/bits/endian.h /usr/include/sys/types.h \ + /usr/include/bits/types.h /usr/include/bits/typesizes.h \ + /usr/include/time.h /usr/include/sys/select.h \ + /usr/include/bits/select.h /usr/include/bits/sigset.h \ + /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ + /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ /usr/include/c++/4.2/iosfwd \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstring /usr/include/string.h \ /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ /usr/include/_G_config.h /usr/include/wchar.h \ /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/c++/4.2/clocale /usr/include/locale.h \ - /usr/include/bits/locale.h /usr/include/langinfo.h \ - /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ - /usr/include/c++/4.2/cstdarg \ + /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ + /usr/include/locale.h /usr/include/bits/locale.h \ + /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ + /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ @@ -39,18 +45,10 @@ DoxygenTranslator/src/DoxygenTranslator.o \ /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ /usr/include/bits/confname.h /usr/include/getopt.h \ /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/char_traits.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ + /usr/include/c++/4.2/exception_defines.h \ /usr/include/c++/4.2/bits/stl_pair.h \ /usr/include/c++/4.2/bits/cpp_type_traits.h \ /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ @@ -59,25 +57,30 @@ DoxygenTranslator/src/DoxygenTranslator.o \ /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ /usr/include/c++/4.2/bits/concept_check.h \ /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ + /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ + /usr/include/c++/4.2/bits/allocator.h \ /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ + /usr/include/c++/4.2/exception \ /usr/include/c++/4.2/bits/stl_construct.h \ /usr/include/c++/4.2/bits/stl_uninitialized.h \ /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ - /usr/include/c++/4.2/bits/stl_algo.h \ + /usr/include/c++/4.2/bits/basic_string.h \ + /usr/include/c++/4.2/ext/atomicity.h \ + /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ + /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ /usr/include/c++/4.2/bits/stl_heap.h \ /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ + /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ + /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ + DoxygenTranslator/src/DoxygenEntity.h \ + DoxygenTranslator/src/DoxygenTranslator.h /usr/include/c++/4.2/iostream \ + /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ + /usr/include/c++/4.2/bits/localefwd.h \ + /usr/include/c++/4.2/bits/ios_base.h \ + /usr/include/c++/4.2/bits/locale_classes.h \ /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ /usr/include/c++/4.2/bits/basic_ios.h \ /usr/include/c++/4.2/bits/streambuf_iterator.h \ @@ -94,15 +97,12 @@ DoxygenTranslator/src/DoxygenTranslator.o \ /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/fstream \ /usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h \ - /usr/include/c++/4.2/bits/fstream.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ - DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h \ - DoxygenTranslator/src/DoxygenTranslator.h + /usr/include/c++/4.2/bits/fstream.tcc DoxygenTranslator/src/TokenList.h \ + DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h DoxygenTranslator/src/DoxygenParser.h: -/usr/include/c++/4.2/cstdlib: +/usr/include/c++/4.2/string: /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: @@ -120,10 +120,44 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: +/usr/include/c++/4.2/bits/stringfwd.h: + +/usr/include/c++/4.2/bits/char_traits.h: + +/usr/include/c++/4.2/cstring: + /usr/include/c++/4.2/cstddef: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/c++/4.2/bits/stl_algobase.h: + +/usr/include/c++/4.2/climits: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: + +/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: + +/usr/include/limits.h: + +/usr/include/bits/posix1_lim.h: + +/usr/include/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/bits/posix2_lim.h: + +/usr/include/bits/xopen_lim.h: + +/usr/include/bits/stdio_lim.h: + +/usr/include/c++/4.2/cstdlib: + /usr/include/stdlib.h: /usr/include/bits/waitflags.h: @@ -134,8 +168,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/bits/endian.h: -/usr/include/xlocale.h: - /usr/include/sys/types.h: /usr/include/bits/types.h: @@ -158,20 +190,10 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/alloca.h: -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - /usr/include/c++/4.2/iosfwd: /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: -/usr/include/c++/4.2/cstring: - -/usr/include/string.h: - /usr/include/c++/4.2/cstdio: /usr/include/stdio.h: @@ -184,8 +206,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: -/usr/include/bits/stdio_lim.h: - /usr/include/bits/sys_errlist.h: /usr/include/c++/4.2/clocale: @@ -234,8 +254,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/ctype.h: -/usr/include/c++/4.2/bits/stringfwd.h: - /usr/include/c++/4.2/bits/postypes.h: /usr/include/c++/4.2/cwchar: @@ -250,30 +268,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/exception_defines.h: -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - /usr/include/c++/4.2/bits/stl_pair.h: /usr/include/c++/4.2/bits/cpp_type_traits.h: @@ -294,18 +288,6 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/debug/debug.h: -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/string: - /usr/include/c++/4.2/memory: /usr/include/c++/4.2/bits/allocator.h: @@ -316,6 +298,8 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/new: +/usr/include/c++/4.2/exception: + /usr/include/c++/4.2/bits/stl_construct.h: /usr/include/c++/4.2/bits/stl_uninitialized.h: @@ -330,6 +314,10 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/basic_string.h: +/usr/include/c++/4.2/ext/atomicity.h: + +/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: + /usr/include/c++/4.2/algorithm: /usr/include/c++/4.2/bits/stl_algo.h: @@ -340,6 +328,28 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/basic_string.tcc: +/usr/include/c++/4.2/list: + +/usr/include/c++/4.2/bits/stl_list.h: + +/usr/include/c++/4.2/bits/list.tcc: + +DoxygenTranslator/src/DoxygenEntity.h: + +DoxygenTranslator/src/DoxygenTranslator.h: + +/usr/include/c++/4.2/iostream: + +/usr/include/c++/4.2/ostream: + +/usr/include/c++/4.2/ios: + +/usr/include/c++/4.2/bits/localefwd.h: + +/usr/include/c++/4.2/bits/ios_base.h: + +/usr/include/c++/4.2/bits/locale_classes.h: + /usr/include/c++/4.2/streambuf: /usr/include/c++/4.2/bits/streambuf.tcc: @@ -384,18 +394,8 @@ DoxygenTranslator/src/DoxygenParser.h: /usr/include/c++/4.2/bits/fstream.tcc: -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -DoxygenTranslator/src/DoxygenEntity.h: - DoxygenTranslator/src/TokenList.h: DoxygenTranslator/src/Token.h: DoxygenTranslator/src/JavaDocConverter.h: - -DoxygenTranslator/src/DoxygenTranslator.h: diff --git a/Source/DoxygenTranslator/src/.deps/Token.Po b/Source/DoxygenTranslator/src/.deps/Token.Po index 9a4bb90f5..dbfe541b1 100644 --- a/Source/DoxygenTranslator/src/.deps/Token.Po +++ b/Source/DoxygenTranslator/src/.deps/Token.Po @@ -72,27 +72,7 @@ DoxygenTranslator/src/Token.o DoxygenTranslator/src/Token.o: \ /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ /usr/include/c++/4.2/bits/stl_heap.h \ /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ - /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ - /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/bits/locale_classes.h \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc + /usr/include/c++/4.2/bits/basic_string.tcc DoxygenTranslator/src/Token.h: @@ -321,59 +301,3 @@ DoxygenTranslator/src/Token.h: /usr/include/c++/4.2/bits/stl_tempbuf.h: /usr/include/c++/4.2/bits/basic_string.tcc: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index 6b8755592..a2faf67db 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -1,6 +1,6 @@ #include "DoxygenEntity.h" #include - +#include /* Little data class for Doxygen Commands */ diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 0605b1cc9..4313bfb2a 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -1,8 +1,7 @@ #ifndef DOXYGENENTITY_H_ #define DOXYGENENTITY_H_ -#include -#include + #include #include diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 226c60720..920b7c794 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -1,13 +1,5 @@ #include "DoxygenParser.h" - -#include -#include -#include -#include -#include -#include "DoxygenEntity.h" #include "TokenList.h" -#include "JavaDocConverter.h" #define SIMPLECOMMAND 1 #define IGNOREDSIMPLECOMMAND 2 #define COMMANDWORD 3 @@ -29,12 +21,6 @@ #define COMMAND 104 using namespace std; -////////////////////////////////////////// -/*Set these to pick what internal functions -to test. */ - -//int testCommandParsingFunctions = 1;// not implemented - DoxygenParser::DoxygenParser() { @@ -44,7 +30,8 @@ DoxygenParser::~DoxygenParser() { } -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +////////////////////////////////////////// +int noisy = 1; // set this to 1 for extra chatter from the parsing stage. int addCommand(string currCommand, TokenList &tokList, list &aNewList); list parse(list::iterator endParsingIndex, TokenList &tokList); @@ -101,32 +88,25 @@ string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "o "subpage", "dotfile", "image", "addtogroup", "li"}; -/* Changes a string to all lower case*/ -string StringToLower(string stringToConvert) - -{ - - for(unsigned int i=0;i &rootList){ - - list::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; + list::iterator p = rootList.begin(); + while (p != rootList.end()){ + (*p).printEntity(0); + p++; } - -} + } /* Determines how a command should be handled (what group it belongs to * for parsing rules */ - int commandBelongs(string theCommand){ - string smallString = StringToLower(theCommand ); + string smallString = StringToLower(theCommand); //cout << " Looking for command " << theCommand << endl; int i = 0; for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND ;} + if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND;} } for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} @@ -187,7 +161,6 @@ int commandBelongs(string theCommand){ for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} } - /* IgnoreCommandParagraph */ for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} } @@ -211,16 +184,14 @@ int commandBelongs(string theCommand){ } for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} - } - - return 0; - + } + return 0; } + /* Returns the next word ON THE CURRENT LINE ONLY * if a new line is encountered, returns a blank string. * Updates the index it is given if success. */ - string getNextWord(TokenList &tokList){ Token nextToken = tokList.peek(); if (nextToken.tokenType == PLAINSTRING ){ @@ -234,17 +205,17 @@ string getNextWord(TokenList &tokList){ * an iterator. */ list::iterator getOneLine(TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - return endOfParagraph; + list::iterator endOfLine = tokList.iteratorCopy(); + while(endOfLine!= tokList.end()){ + if ((* endOfLine).tokenType == END_LINE){ + endOfLine++; + return endOfLine; + } + endOfLine++; } - endOfParagraph++; - } + cout << "REACHED END" << endl; return tokList.end(); -} - - + } /* Returns a properly formatted string * up til ANY command or end of paragraph is encountered. @@ -256,12 +227,11 @@ string getStringTilCommand(TokenList &tokList){ Token currentToken = tokList.next(); if(currentToken.tokenType == PLAINSTRING) { description = description + currentToken.tokenString + " "; - } + } else if (tokList.peek().tokenType == END_LINE) break; - } - + } return description; -} + } /* Returns a properly formatted string * up til the command specified is encountered @@ -274,69 +244,67 @@ string getStringTilEndCommand(string theCommand, TokenList &tokList){ while(tokList.peek().tokenString.compare(theCommand) != 0 ){ Token currentToken = tokList.next(); description = description + currentToken.tokenString + " "; - - } - + } return description; -} + } /* Returns the end of a Paragraph as an iterator- * Paragraph is defined in Doxygen to be a paragraph of text * seperate by either a structural command or a blank line */ - list::iterator getEndOfParagraph(TokenList &tokList){ list::iterator endOfParagraph = tokList.iteratorCopy(); while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ + if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; + cout << "ENCOUNTERED END OF PARA" << endl; return endOfParagraph; + } } - } - + else if ((* endOfParagraph).tokenType == COMMAND){ + if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else return tokList.end(); + } + return tokList.end(); } - - return tokList.end(); - -} /* Returns the end of a section, defined as the first blank line OR first encounter of the same * command. Example of this behaviour is \arg +* if no end is encountered, returns the last token of the list. */ - list::iterator getEndOfSection(string theCommand, TokenList &tokList){ list::iterator endOfParagraph = tokList.iteratorCopy(); while(endOfParagraph != tokList.end()){ if ((* endOfParagraph).tokenType == COMMAND){ if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; else endOfParagraph++; - } + } else if((* endOfParagraph).tokenType == PLAINSTRING) { endOfParagraph++; - } + } else if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; return endOfParagraph; + } } - } - + } + return tokList.end(); } -} + /* This method is for returning the end of a specific form of doxygen command * that begins with a \command and ends in \endcommand * such as \code and \endcode. The proper usage is * progressTilEndCommand("endcode", tokenList); + * If the end is never encountered, it returns the end of the list. */ list::iterator getEndCommand(string theCommand, TokenList &tokList){ list::iterator endOfCommand = tokList.iteratorCopy(); @@ -354,11 +322,11 @@ list::iterator getEndCommand(string theCommand, TokenList &tokList){ /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ - +//TODO getTilAnyCommand list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ list::iterator anIterator; return anIterator; -} + } @@ -369,21 +337,19 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * \n \\ \@ \& \$ \# \< \> \% */ int addSimpleCommand(string theCommand, list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); return 1; -} + } /* NOT INCLUDED Simple Commands * Format: @command * Plain commands, such as newline etc, they contain no other data */ int ignoreSimpleCommand(string theCommand, list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; return 1; -} + } /* CommandWord * Format: @command @@ -397,10 +363,11 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ if (!name.empty()){ doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; - } + } else cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; -} + } + /* NOT INCLUDED CommandWord * Format: @command * Commands with a single WORD after then such as @b @@ -411,10 +378,10 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ string name = getNextWord(tokList); if (!name.empty()){ return 1; - } + } else cout << "WARNING: No word followed " << theCommand << " command." << endl; return 0; -} + } /* CommandLine * Format: @command (line) @@ -424,12 +391,11 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ int addCommandLine(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; list::iterator endOfLine = getOneLine(tokList); - list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - -} + list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; + } /* NOT INCLUDED CommandLine * Format: @command (line) @@ -452,14 +418,12 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ int addCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; list::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ list aNewList; aNewList = parse(endOfParagraph, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); return 1; - // } - //else cout << "No line followed " << theCommand << " command. Not added" << endl; -} + } + /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var @@ -469,9 +433,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ if (noisy) cout << "Not Adding " << theCommand << endl; list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); - //else cout << "WARNING: No line followed " << theCommand << " command." << endl; return 1; } + /* Command EndCommand * Format: @command and ends at @endcommand * Commands that take in a block of text such as @code @@ -479,13 +443,12 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ - int addCommandEndCommand(string theCommand, TokenList &tokList, list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; string description = getStringTilEndCommand( "end" + theCommand, tokList); doxyList.push_back(DoxygenEntity(theCommand, description)); return 1; - } + } /* CommandWordParagraph * Format: @command {paragraph} @@ -499,14 +462,14 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - list::iterator endOfParagraph = getEndOfParagraph(tokList); - //if(!restOfParagraph.empty()){ - list aNewList; - aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 0; - } + list::iterator endOfParagraph = getEndOfParagraph(tokList); + list aNewList; + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstring", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + /* CommandWordLine * Format: @command (line) * Commands such as param @@ -549,7 +512,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; - } + } /* Command Optional Word * Format: @command [] @@ -564,13 +527,17 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ } /* Commands that should not be encountered (such as PHP only) + * goes til the end of line then returns */ int addCommandErrorThrow(string theCommand, TokenList &tokList, list &doxyList){ cout << "Encountered :" << theCommand << endl; cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + list::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 0; } - +/* Adds the unique commands- different process for each unique command */ int addCommandUnique(string theCommand, TokenList &tokList, list &doxyList){ list aNewList; if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ @@ -578,8 +545,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ list aNewList; aNewList = parse(endOfSection, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - } - + } // \xrefitem "(heading)" "(list title)" {text} else if (theCommand.compare("xrefitem") == 0){ //TODO Implement xrefitem @@ -587,7 +553,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; - } + } // \ingroup ( [ ]) else if (theCommand.compare("ingroup") == 0){ string name = getNextWord(tokList); @@ -598,7 +564,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; - } + } // \par [(paragraph title)] { paragraph } else if (theCommand.compare("par") == 0){ list::iterator endOfLine = getOneLine(tokList); @@ -608,7 +574,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; - } + } // \headerfile [] else if (theCommand.compare("headerfile") == 0){ list aNewList; @@ -618,17 +584,18 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; - } + } // \overload [(function declaration)] else if (theCommand.compare("overload") == 0){ list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()){ - list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } + list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } else doxyList.push_back(DoxygenEntity(theCommand)); - } + return 1; + } // \weakgroup [(title)] else if (theCommand.compare("weakgroup") == 0){ if (noisy) cout << "Parsing " << theCommand << endl; @@ -641,35 +608,35 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { aNewList = parse(endOfLine, tokList); - } + } aNewList.push_front(DoxygenEntity("plainstring", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } + } // \ref ["(text)"] else if (theCommand.compare("ref") == 0){ //TODO Implement ref if (noisy) cout << "Not Adding " << theCommand << endl; list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); - } + } // \subpage ["(text)"] else if (theCommand.compare("subpage") == 0){ //TODO implement subpage if (noisy) cout << "Not Adding " << theCommand << endl; list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); - } + } // \dotfile ["caption"] else if (theCommand.compare("dotfile") == 0){ //TODO implement dotfile if (noisy) cout << "Not Adding " << theCommand << endl; list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); - } + } // \image ["caption"] [=] else if (theCommand.compare("image") == 0){ //todo implement image - } + } // \addtogroup [(title)] else if (theCommand.compare("addtogroup") == 0){ if (noisy) cout << "Parsing " << theCommand << endl; @@ -682,12 +649,12 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { aNewList = parse(endOfLine, tokList); - } + } aNewList.push_front(DoxygenEntity("plainstring", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + return 0; } - - } /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in @@ -697,13 +664,12 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ int addCommand(string commandString, TokenList &tokList,list &doxyList){ string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstring") == 0){ string nextPhrase = getStringTilCommand( tokList); if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); return 1; - } + } int commandNumber = commandBelongs(theCommand); if (commandNumber == SIMPLECOMMAND){ return addSimpleCommand(theCommand, doxyList); @@ -751,8 +717,8 @@ int addCommand(string commandString, TokenList &tokList,list &do return addCommandUnique(theCommand, tokList, doxyList); } - return 0; -} + return 0; + } list parse(list::iterator endParsingIndex, TokenList &tokList){ list aNewList; @@ -762,36 +728,64 @@ list parse(list::iterator endParsingIndex, TokenList &tokL if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; if(currToken.tokenType == END_LINE ){ tokList.next(); - } + } else if(currToken.tokenType == COMMAND){ currCommand = findCommand(currToken.tokenString); - tokList.next(); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currToken.tokenString << endl;} + if (currCommand < 0 ){ + if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; + tokList.next(); + addCommand(string("plainstring"), tokList, aNewList);} //cout << "Command: " << currWord << " " << currCommand << endl; - - else addCommand(currToken.tokenString, tokList, aNewList); - } + else { tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); + } + } else if (currToken.tokenType == PLAINSTRING){ addCommand(string("plainstring"), tokList, aNewList); + } + else break; } - - + return aNewList; } +list parseRoot(list::iterator endParsingIndex, TokenList &tokList){ + list aNewList; + int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); + if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(currToken.tokenType == END_LINE ){ + tokList.next(); + } + else if(currToken.tokenType == COMMAND){ + currCommand = findCommand(currToken.tokenString); + if (currCommand < 0 ){ + if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; + tokList.next(); + addCommand(string("details"), tokList, aNewList);} + //cout << "Command: " << currWord << " " << currCommand << endl; + else { tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); + } + } + else if (currToken.tokenType == PLAINSTRING){ + addCommand(string("details"), tokList, aNewList); + } + } return aNewList; -} + } list DoxygenParser::createTree(string doxygenBlob){ TokenList tokList = TokenList(doxygenBlob); if(noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); - } + } list rootList; - rootList = parse( tokList.end(), tokList); + rootList = parseRoot( tokList.end(), tokList); if(noisy) { cout << "PARSED LIST" << endl; printTree(rootList); - } + } return rootList; } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 776fcf123..638fdab72 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -1,13 +1,8 @@ #ifndef DOXYGENPARSER_H_ #define DOXYGENPARSER_H_ -#include -#include -#include #include #include #include "DoxygenEntity.h" -#include "TokenList.h" -#include "JavaDocConverter.h" class DoxygenParser { public: diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 191057ae7..a1789eb74 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -11,6 +11,7 @@ #include "TokenList.h" #include "JavaDocConverter.h" + DoxygenParser doxyParse; JavaDocConverter jDC; @@ -27,7 +28,7 @@ DoxygenTranslator::~DoxygenTranslator(){ char *DoxygenTranslator::convert(char* doxygenBlob, char* option){ list rootList = doxyParse.createTree(string(doxygenBlob)); - rootList = doxyParse.createTree(string(doxygenBlob)); + string returnedString; if(strcmp(option, "JAVADOC") == 0){ returnedString = jDC.convertToJavaDoc(rootList); @@ -39,3 +40,32 @@ char *DoxygenTranslator::convert(char* doxygenBlob, char* option){ return nonConstString; } +int testCommands(){ + string exampleArray[] = { + "/**\n * \n * Random Line \n * \\@ \n * Random Line After */", + "/**\n * \n * Random Line Before \n * \\b bold \n * Random Line After */", + "/**\n * \n * Random Line \n * \\copydoc bold \n * Random Line After */", + "/**\n * \n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */", + "/**\n * \n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */", + "/**\n * \n * Random Line \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */", + "/**\n * \n * Random Line \n * \\code this should continue \n * until here \\endcode \n * Random Line After */", + "/**\n * \n * Random Line \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */", + "/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */", + "/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */", + "/**\n * \n * Random Line \n * \\category singleword \n * but not this */", + "/**\n * \n * Random Line \n * \\category singleword oneword \n * but not this */", + "/**\n * \n * Random Line \n * \\category singleword oneword twoword \n * but not this */", + "/**\n * \n * Random Line \n * \\dir singleword \n * but not this */", + "/**\n * \n * Random Line \n * \\dir \n * but not this */", + "/**\n * \n * Random Line \n * \\fakecommand details \n * but not this */" + }; + //string exampleArrayUniques = {}; + DoxygenTranslator dT = DoxygenTranslator(); + for (int i = 0; i < 16; i ++ ){ + cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; + char *nonConstString = (char *)malloc(exampleArray[i].length()+1); + strcpy(nonConstString, exampleArray[i].c_str()); + dT.convert(nonConstString, "JAVADOC"); + } + return 1; +} diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 91f52662f..c1606cc77 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,8 +1,5 @@ #include "JavaDocConverter.h" -#include #include -#include -#include #define APPROX_LINE_LENGTH 64//characters per line allowed #define TAB_SIZE 8//characters per line allowed int printSortedTree2 = 0; @@ -20,6 +17,10 @@ JavaDocConverter::~JavaDocConverter() * such as brief descriptions are TAGGED as such */ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ + if(first.typeOfEntity.compare("brief") == 0) return true; + if(second.typeOfEntity.compare("brief") == 0) return false; + if(first.typeOfEntity.compare("details") == 0) return true; + if(second.typeOfEntity.compare("details") == 0) return false; if(first.typeOfEntity.compare("plainstring") == 0) return true; if(second.typeOfEntity.compare("plainstring") == 0) return false; if(first.typeOfEntity.compare("param") == 0){ @@ -54,11 +55,11 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ return false; } if(first.typeOfEntity.compare("author")== 0){ - if(first.typeOfEntity.compare("author")== 0) return true; - if(first.typeOfEntity.compare("version")== 0)return true; - if(first.typeOfEntity.compare("see")== 0)return true; - if(first.typeOfEntity.compare("since")== 0)return true; - if(first.typeOfEntity.compare("deprecated")== 0)return true; + if(second.typeOfEntity.compare("author")== 0) return true; + if(second.typeOfEntity.compare("version")== 0)return true; + if(second.typeOfEntity.compare("see")== 0)return true; + if(second.typeOfEntity.compare("since")== 0)return true; + if(second.typeOfEntity.compare("deprecated")== 0)return true; return false; } if(first.typeOfEntity.compare("version")== 0){ @@ -134,17 +135,11 @@ string javaDocFormat(DoxygenEntity &doxygenEntity){ if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ return doxygenEntity.data; } - else if (doxygenEntity.typeOfEntity.compare("brief") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("detailed") == 0){ - return doxygenEntity.data; - } else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "" + doxygenEntity.data + ""; + return "\b" + doxygenEntity.data + ""; } else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "" + doxygenEntity.data + ""; + return "\b" + doxygenEntity.data + ""; } return ""; } @@ -165,7 +160,9 @@ string translateSubtree( DoxygenEntity &doxygenEntity){ } string translateEntity(DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) + if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ + return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} + else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) return formatCommand(doxyEntity.data, 0) + "\n * "; else if(doxyEntity.typeOfEntity.compare("see") == 0){ return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); @@ -207,4 +204,4 @@ string JavaDocConverter:: convertToJavaDoc(list entityList){ cout << "\n---RESULT IN JAVADOC---" << endl; cout << javaDocString; return javaDocString; -} \ No newline at end of file +} diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp index e85799546..198b3e442 100644 --- a/Source/DoxygenTranslator/src/Token.cpp +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -1,8 +1,4 @@ #include "Token.h" -#include -#include -#include -#include using namespace std; @@ -21,7 +17,7 @@ string Token::toString() return "{END OF PARAGRAPH}"; } if (tokenType == PLAINSTRING){ - return tokenString; + return "{PLAINSTRING :" + tokenString + "}"; } if (tokenType == COMMAND){ return "{COMMAND : " + tokenString+ "}"; diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index eeec6da46..a05d2ceef 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -59,7 +59,7 @@ TokenList::TokenList(string doxygenString){ if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); } - else tokenList.push_back(Token(PLAINSTRING, currentWord)); + else if (!currentWord.empty())tokenList.push_back(Token(PLAINSTRING, currentWord)); currentIndex = nextIndex; } } From ac7887a940c40f39b45529b9535a6a4de54a4ac3 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 04:57:05 +0000 Subject: [PATCH 0016/2031] Cleaning up unneeded files git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10778 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/.deps/.dirstamp | 0 .../src/.deps/DoxygenEntity.Po | 380 ----------------- .../src/.deps/DoxygenParser.Po | 387 ----------------- .../src/.deps/DoxygenTranslator.Po | 401 ------------------ .../src/.deps/JavaDocConverter.Po | 385 ----------------- Source/DoxygenTranslator/src/.deps/Token.Po | 303 ------------- .../DoxygenTranslator/src/.deps/TokenList.Po | 382 ----------------- 7 files changed, 2238 deletions(-) delete mode 100644 Source/DoxygenTranslator/src/.deps/.dirstamp delete mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po delete mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenParser.Po delete mode 100644 Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po delete mode 100644 Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po delete mode 100644 Source/DoxygenTranslator/src/.deps/Token.Po delete mode 100644 Source/DoxygenTranslator/src/.deps/TokenList.Po diff --git a/Source/DoxygenTranslator/src/.deps/.dirstamp b/Source/DoxygenTranslator/src/.deps/.dirstamp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po b/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po deleted file mode 100644 index 7a6dbd296..000000000 --- a/Source/DoxygenTranslator/src/.deps/DoxygenEntity.Po +++ /dev/null @@ -1,380 +0,0 @@ -DoxygenTranslator/src/DoxygenEntity.o \ - DoxygenTranslator/src/DoxygenEntity.o: \ - DoxygenTranslator/src/DoxygenEntity.cpp \ - DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/string.h /usr/include/xlocale.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/types.h \ - /usr/include/bits/types.h /usr/include/bits/typesizes.h \ - /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ - /usr/include/locale.h /usr/include/bits/locale.h \ - /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ - /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h \ - /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ - /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ - /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/bits/locale_classes.h \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc - -DoxygenTranslator/src/DoxygenEntity.h: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/string.h: - -/usr/include/xlocale.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po b/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po deleted file mode 100644 index 8ec874c8c..000000000 --- a/Source/DoxygenTranslator/src/.deps/DoxygenParser.Po +++ /dev/null @@ -1,387 +0,0 @@ -DoxygenTranslator/src/DoxygenParser.o \ - DoxygenTranslator/src/DoxygenParser.o: \ - DoxygenTranslator/src/DoxygenParser.cpp \ - DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/string.h /usr/include/xlocale.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/types.h \ - /usr/include/bits/types.h /usr/include/bits/typesizes.h \ - /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ - /usr/include/locale.h /usr/include/bits/locale.h \ - /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ - /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h \ - /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ - /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - DoxygenTranslator/src/DoxygenEntity.h DoxygenTranslator/src/TokenList.h \ - /usr/include/c++/4.2/iostream /usr/include/c++/4.2/ostream \ - /usr/include/c++/4.2/ios /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/bits/locale_classes.h \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc DoxygenTranslator/src/Token.h - -DoxygenTranslator/src/DoxygenParser.h: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/string.h: - -/usr/include/xlocale.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -DoxygenTranslator/src/DoxygenEntity.h: - -DoxygenTranslator/src/TokenList.h: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: - -DoxygenTranslator/src/Token.h: diff --git a/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po b/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po deleted file mode 100644 index 4cec6c648..000000000 --- a/Source/DoxygenTranslator/src/.deps/DoxygenTranslator.Po +++ /dev/null @@ -1,401 +0,0 @@ -DoxygenTranslator/src/DoxygenTranslator.o \ - DoxygenTranslator/src/DoxygenTranslator.o: \ - DoxygenTranslator/src/DoxygenTranslator.cpp \ - DoxygenTranslator/src/DoxygenParser.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/string.h /usr/include/xlocale.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/types.h \ - /usr/include/bits/types.h /usr/include/bits/typesizes.h \ - /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ - /usr/include/locale.h /usr/include/bits/locale.h \ - /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ - /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h \ - /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ - /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - DoxygenTranslator/src/DoxygenEntity.h \ - DoxygenTranslator/src/DoxygenTranslator.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/bits/locale_classes.h \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/fstream \ - /usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h \ - /usr/include/c++/4.2/bits/fstream.tcc DoxygenTranslator/src/TokenList.h \ - DoxygenTranslator/src/Token.h DoxygenTranslator/src/JavaDocConverter.h - -DoxygenTranslator/src/DoxygenParser.h: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/string.h: - -/usr/include/xlocale.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -DoxygenTranslator/src/DoxygenEntity.h: - -DoxygenTranslator/src/DoxygenTranslator.h: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: - -/usr/include/c++/4.2/fstream: - -/usr/include/c++/4.2/i486-linux-gnu/bits/basic_file.h: - -/usr/include/c++/4.2/bits/fstream.tcc: - -DoxygenTranslator/src/TokenList.h: - -DoxygenTranslator/src/Token.h: - -DoxygenTranslator/src/JavaDocConverter.h: diff --git a/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po b/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po deleted file mode 100644 index 79a3133a3..000000000 --- a/Source/DoxygenTranslator/src/.deps/JavaDocConverter.Po +++ /dev/null @@ -1,385 +0,0 @@ -DoxygenTranslator/src/JavaDocConverter.o \ - DoxygenTranslator/src/JavaDocConverter.o: \ - DoxygenTranslator/src/JavaDocConverter.cpp \ - DoxygenTranslator/src/JavaDocConverter.h /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/exception_defines.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/cstring \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/string.h /usr/include/xlocale.h \ - /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/types.h \ - /usr/include/bits/types.h /usr/include/bits/typesizes.h \ - /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ - /usr/include/locale.h /usr/include/bits/locale.h \ - /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ - /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h \ - /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - /usr/include/c++/4.2/string /usr/include/c++/4.2/bits/char_traits.h \ - /usr/include/c++/4.2/memory \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ - DoxygenTranslator/src/DoxygenEntity.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/bits/locale_classes.h \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc - -DoxygenTranslator/src/JavaDocConverter.h: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/string.h: - -/usr/include/xlocale.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: - -DoxygenTranslator/src/DoxygenEntity.h: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/Token.Po b/Source/DoxygenTranslator/src/.deps/Token.Po deleted file mode 100644 index dbfe541b1..000000000 --- a/Source/DoxygenTranslator/src/.deps/Token.Po +++ /dev/null @@ -1,303 +0,0 @@ -DoxygenTranslator/src/Token.o DoxygenTranslator/src/Token.o: \ - DoxygenTranslator/src/Token.cpp DoxygenTranslator/src/Token.h \ - /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/char_traits.h /usr/include/c++/4.2/cstring \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/string.h /usr/include/xlocale.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/bits/stdio_lim.h /usr/include/c++/4.2/cstdlib \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/sys/types.h \ - /usr/include/bits/types.h /usr/include/bits/typesizes.h \ - /usr/include/time.h /usr/include/sys/select.h \ - /usr/include/bits/select.h /usr/include/bits/sigset.h \ - /usr/include/bits/time.h /usr/include/sys/sysmacros.h \ - /usr/include/bits/pthreadtypes.h /usr/include/alloca.h \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/sys_errlist.h /usr/include/c++/4.2/clocale \ - /usr/include/locale.h /usr/include/bits/locale.h \ - /usr/include/langinfo.h /usr/include/nl_types.h /usr/include/iconv.h \ - /usr/include/libintl.h /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h \ - /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h /usr/include/c++/4.2/memory \ - /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/algorithm /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc - -DoxygenTranslator/src/Token.h: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/string.h: - -/usr/include/xlocale.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: diff --git a/Source/DoxygenTranslator/src/.deps/TokenList.Po b/Source/DoxygenTranslator/src/.deps/TokenList.Po deleted file mode 100644 index 74d0e1c79..000000000 --- a/Source/DoxygenTranslator/src/.deps/TokenList.Po +++ /dev/null @@ -1,382 +0,0 @@ -DoxygenTranslator/src/TokenList.o DoxygenTranslator/src/TokenList.o: \ - DoxygenTranslator/src/TokenList.cpp DoxygenTranslator/src/TokenList.h \ - /usr/include/c++/4.2/cstdlib \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h \ - /usr/include/features.h /usr/include/sys/cdefs.h \ - /usr/include/bits/wordsize.h /usr/include/gnu/stubs.h \ - /usr/include/gnu/stubs-32.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h \ - /usr/include/c++/4.2/cstddef \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h \ - /usr/include/stdlib.h /usr/include/bits/waitflags.h \ - /usr/include/bits/waitstatus.h /usr/include/endian.h \ - /usr/include/bits/endian.h /usr/include/xlocale.h \ - /usr/include/sys/types.h /usr/include/bits/types.h \ - /usr/include/bits/typesizes.h /usr/include/time.h \ - /usr/include/sys/select.h /usr/include/bits/select.h \ - /usr/include/bits/sigset.h /usr/include/bits/time.h \ - /usr/include/sys/sysmacros.h /usr/include/bits/pthreadtypes.h \ - /usr/include/alloca.h /usr/include/c++/4.2/iostream \ - /usr/include/c++/4.2/ostream /usr/include/c++/4.2/ios \ - /usr/include/c++/4.2/iosfwd \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h \ - /usr/include/c++/4.2/cstring /usr/include/string.h \ - /usr/include/c++/4.2/cstdio /usr/include/stdio.h /usr/include/libio.h \ - /usr/include/_G_config.h /usr/include/wchar.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h \ - /usr/include/bits/stdio_lim.h /usr/include/bits/sys_errlist.h \ - /usr/include/c++/4.2/clocale /usr/include/locale.h \ - /usr/include/bits/locale.h /usr/include/langinfo.h \ - /usr/include/nl_types.h /usr/include/iconv.h /usr/include/libintl.h \ - /usr/include/c++/4.2/cstdarg \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h \ - /usr/include/pthread.h /usr/include/sched.h /usr/include/bits/sched.h \ - /usr/include/signal.h /usr/include/bits/setjmp.h /usr/include/unistd.h \ - /usr/include/bits/posix_opt.h /usr/include/bits/environments.h \ - /usr/include/bits/confname.h /usr/include/getopt.h \ - /usr/include/c++/4.2/cctype /usr/include/ctype.h \ - /usr/include/c++/4.2/bits/stringfwd.h \ - /usr/include/c++/4.2/bits/postypes.h /usr/include/c++/4.2/cwchar \ - /usr/include/c++/4.2/ctime /usr/include/bits/wchar.h \ - /usr/include/stdint.h /usr/include/c++/4.2/bits/functexcept.h \ - /usr/include/c++/4.2/exception_defines.h /usr/include/c++/4.2/exception \ - /usr/include/c++/4.2/bits/char_traits.h \ - /usr/include/c++/4.2/bits/stl_algobase.h /usr/include/c++/4.2/climits \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h \ - /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h \ - /usr/include/limits.h /usr/include/bits/posix1_lim.h \ - /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ - /usr/include/bits/posix2_lim.h /usr/include/bits/xopen_lim.h \ - /usr/include/c++/4.2/bits/stl_pair.h \ - /usr/include/c++/4.2/bits/cpp_type_traits.h \ - /usr/include/c++/4.2/ext/type_traits.h /usr/include/c++/4.2/utility \ - /usr/include/c++/4.2/bits/stl_relops.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_types.h \ - /usr/include/c++/4.2/bits/stl_iterator_base_funcs.h \ - /usr/include/c++/4.2/bits/concept_check.h \ - /usr/include/c++/4.2/bits/stl_iterator.h \ - /usr/include/c++/4.2/debug/debug.h \ - /usr/include/c++/4.2/bits/localefwd.h \ - /usr/include/c++/4.2/bits/ios_base.h \ - /usr/include/c++/4.2/ext/atomicity.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h \ - /usr/include/c++/4.2/bits/locale_classes.h /usr/include/c++/4.2/string \ - /usr/include/c++/4.2/memory /usr/include/c++/4.2/bits/allocator.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h \ - /usr/include/c++/4.2/ext/new_allocator.h /usr/include/c++/4.2/new \ - /usr/include/c++/4.2/bits/stl_construct.h \ - /usr/include/c++/4.2/bits/stl_uninitialized.h \ - /usr/include/c++/4.2/bits/stl_raw_storage_iter.h \ - /usr/include/c++/4.2/limits /usr/include/c++/4.2/bits/ostream_insert.h \ - /usr/include/c++/4.2/bits/stl_function.h \ - /usr/include/c++/4.2/bits/basic_string.h /usr/include/c++/4.2/algorithm \ - /usr/include/c++/4.2/bits/stl_algo.h \ - /usr/include/c++/4.2/bits/stl_heap.h \ - /usr/include/c++/4.2/bits/stl_tempbuf.h \ - /usr/include/c++/4.2/bits/basic_string.tcc \ - /usr/include/c++/4.2/streambuf /usr/include/c++/4.2/bits/streambuf.tcc \ - /usr/include/c++/4.2/bits/basic_ios.h \ - /usr/include/c++/4.2/bits/streambuf_iterator.h \ - /usr/include/c++/4.2/bits/locale_facets.h /usr/include/c++/4.2/cwctype \ - /usr/include/wctype.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h \ - /usr/include/c++/4.2/bits/codecvt.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h \ - /usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h \ - /usr/include/c++/4.2/bits/basic_ios.tcc \ - /usr/include/c++/4.2/bits/ostream.tcc /usr/include/c++/4.2/locale \ - /usr/include/c++/4.2/bits/locale_facets.tcc \ - /usr/include/c++/4.2/typeinfo /usr/include/c++/4.2/istream \ - /usr/include/c++/4.2/bits/istream.tcc /usr/include/c++/4.2/list \ - /usr/include/c++/4.2/bits/stl_list.h /usr/include/c++/4.2/bits/list.tcc \ - DoxygenTranslator/src/Token.h - -DoxygenTranslator/src/TokenList.h: - -/usr/include/c++/4.2/cstdlib: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++config.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/os_defines.h: - -/usr/include/features.h: - -/usr/include/sys/cdefs.h: - -/usr/include/bits/wordsize.h: - -/usr/include/gnu/stubs.h: - -/usr/include/gnu/stubs-32.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/cpu_defines.h: - -/usr/include/c++/4.2/cstddef: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stddef.h: - -/usr/include/stdlib.h: - -/usr/include/bits/waitflags.h: - -/usr/include/bits/waitstatus.h: - -/usr/include/endian.h: - -/usr/include/bits/endian.h: - -/usr/include/xlocale.h: - -/usr/include/sys/types.h: - -/usr/include/bits/types.h: - -/usr/include/bits/typesizes.h: - -/usr/include/time.h: - -/usr/include/sys/select.h: - -/usr/include/bits/select.h: - -/usr/include/bits/sigset.h: - -/usr/include/bits/time.h: - -/usr/include/sys/sysmacros.h: - -/usr/include/bits/pthreadtypes.h: - -/usr/include/alloca.h: - -/usr/include/c++/4.2/iostream: - -/usr/include/c++/4.2/ostream: - -/usr/include/c++/4.2/ios: - -/usr/include/c++/4.2/iosfwd: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++locale.h: - -/usr/include/c++/4.2/cstring: - -/usr/include/string.h: - -/usr/include/c++/4.2/cstdio: - -/usr/include/stdio.h: - -/usr/include/libio.h: - -/usr/include/_G_config.h: - -/usr/include/wchar.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/stdarg.h: - -/usr/include/bits/stdio_lim.h: - -/usr/include/bits/sys_errlist.h: - -/usr/include/c++/4.2/clocale: - -/usr/include/locale.h: - -/usr/include/bits/locale.h: - -/usr/include/langinfo.h: - -/usr/include/nl_types.h: - -/usr/include/iconv.h: - -/usr/include/libintl.h: - -/usr/include/c++/4.2/cstdarg: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++io.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/gthr-default.h: - -/usr/include/pthread.h: - -/usr/include/sched.h: - -/usr/include/bits/sched.h: - -/usr/include/signal.h: - -/usr/include/bits/setjmp.h: - -/usr/include/unistd.h: - -/usr/include/bits/posix_opt.h: - -/usr/include/bits/environments.h: - -/usr/include/bits/confname.h: - -/usr/include/getopt.h: - -/usr/include/c++/4.2/cctype: - -/usr/include/ctype.h: - -/usr/include/c++/4.2/bits/stringfwd.h: - -/usr/include/c++/4.2/bits/postypes.h: - -/usr/include/c++/4.2/cwchar: - -/usr/include/c++/4.2/ctime: - -/usr/include/bits/wchar.h: - -/usr/include/stdint.h: - -/usr/include/c++/4.2/bits/functexcept.h: - -/usr/include/c++/4.2/exception_defines.h: - -/usr/include/c++/4.2/exception: - -/usr/include/c++/4.2/bits/char_traits.h: - -/usr/include/c++/4.2/bits/stl_algobase.h: - -/usr/include/c++/4.2/climits: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h: - -/usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h: - -/usr/include/limits.h: - -/usr/include/bits/posix1_lim.h: - -/usr/include/bits/local_lim.h: - -/usr/include/linux/limits.h: - -/usr/include/bits/posix2_lim.h: - -/usr/include/bits/xopen_lim.h: - -/usr/include/c++/4.2/bits/stl_pair.h: - -/usr/include/c++/4.2/bits/cpp_type_traits.h: - -/usr/include/c++/4.2/ext/type_traits.h: - -/usr/include/c++/4.2/utility: - -/usr/include/c++/4.2/bits/stl_relops.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_types.h: - -/usr/include/c++/4.2/bits/stl_iterator_base_funcs.h: - -/usr/include/c++/4.2/bits/concept_check.h: - -/usr/include/c++/4.2/bits/stl_iterator.h: - -/usr/include/c++/4.2/debug/debug.h: - -/usr/include/c++/4.2/bits/localefwd.h: - -/usr/include/c++/4.2/bits/ios_base.h: - -/usr/include/c++/4.2/ext/atomicity.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/atomic_word.h: - -/usr/include/c++/4.2/bits/locale_classes.h: - -/usr/include/c++/4.2/string: - -/usr/include/c++/4.2/memory: - -/usr/include/c++/4.2/bits/allocator.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/c++allocator.h: - -/usr/include/c++/4.2/ext/new_allocator.h: - -/usr/include/c++/4.2/new: - -/usr/include/c++/4.2/bits/stl_construct.h: - -/usr/include/c++/4.2/bits/stl_uninitialized.h: - -/usr/include/c++/4.2/bits/stl_raw_storage_iter.h: - -/usr/include/c++/4.2/limits: - -/usr/include/c++/4.2/bits/ostream_insert.h: - -/usr/include/c++/4.2/bits/stl_function.h: - -/usr/include/c++/4.2/bits/basic_string.h: - -/usr/include/c++/4.2/algorithm: - -/usr/include/c++/4.2/bits/stl_algo.h: - -/usr/include/c++/4.2/bits/stl_heap.h: - -/usr/include/c++/4.2/bits/stl_tempbuf.h: - -/usr/include/c++/4.2/bits/basic_string.tcc: - -/usr/include/c++/4.2/streambuf: - -/usr/include/c++/4.2/bits/streambuf.tcc: - -/usr/include/c++/4.2/bits/basic_ios.h: - -/usr/include/c++/4.2/bits/streambuf_iterator.h: - -/usr/include/c++/4.2/bits/locale_facets.h: - -/usr/include/c++/4.2/cwctype: - -/usr/include/wctype.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_base.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/ctype_inline.h: - -/usr/include/c++/4.2/bits/codecvt.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/time_members.h: - -/usr/include/c++/4.2/i486-linux-gnu/bits/messages_members.h: - -/usr/include/c++/4.2/bits/basic_ios.tcc: - -/usr/include/c++/4.2/bits/ostream.tcc: - -/usr/include/c++/4.2/locale: - -/usr/include/c++/4.2/bits/locale_facets.tcc: - -/usr/include/c++/4.2/typeinfo: - -/usr/include/c++/4.2/istream: - -/usr/include/c++/4.2/bits/istream.tcc: - -/usr/include/c++/4.2/list: - -/usr/include/c++/4.2/bits/stl_list.h: - -/usr/include/c++/4.2/bits/list.tcc: - -DoxygenTranslator/src/Token.h: From 293747e8c529c635b324e38a94765ef4d611767a Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 05:08:01 +0000 Subject: [PATCH 0017/2031] Silencing of some diagnostic print statements for what method generated what javadoc git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10779 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 23e233071..ac8bfe13d 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -91,6 +91,7 @@ class JAVA:public Language { } /* DOXYGEN TO JAVADOC globals */ bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc + bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx //TODO make this bool a command line option DoxygenTranslator doxyTranslator; @@ -123,6 +124,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), + comment_creation_chatter(true), imclass_name(NULL), module_class_name(NULL), imclass_class_code(NULL), @@ -507,8 +509,8 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(f_module, "/* This was generated from top() */"); - Printf(f_module, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */"); + Printf(f_module, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } if (Len(module_class_modifiers) > 0) @@ -1231,9 +1233,9 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); - - Printv(proxy_class_constants_code, doxyTranslator.convert(Char((const String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + if(comment_creation_chatter) Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); + Printv(proxy_class_constants_code, + doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); } } @@ -1302,8 +1304,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); - Printf(enum_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); + Printf(enum_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } { @@ -1372,8 +1374,8 @@ public: virtual int doxygenComment(Node *n){ if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); - Printv(structuralComments, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + if(comment_creation_chatter) Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); + Printv(structuralComments, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); } } return SWIG_OK; @@ -1400,8 +1402,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); - Printf(constants_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); + Printf(constants_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } @@ -1669,8 +1671,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); - Printv(proxy_class_def, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + if(comment_creation_chatter) Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); + Printv(proxy_class_def, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); } } @@ -2010,8 +2012,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); - Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); + Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } @@ -2240,8 +2242,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(function_code, "/* This was generated from constructionhandler */\n" ); - Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler */\n" ); + Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } @@ -2509,8 +2511,8 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ - Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); - Printf(function_code, doxyTranslator.convert(Char((String *)Getattr(n,"DoxygenComment")),"JAVADOC")); + if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); + Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); } } From d08245c7f997646795cf1e1f85072140230ae79d Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 07:23:41 +0000 Subject: [PATCH 0018/2031] memory leak fix for a test method git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10781 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenTranslator.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index a1789eb74..77090573a 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -1,17 +1,11 @@ - - #include "DoxygenParser.h" #include "DoxygenTranslator.h" #include #include -#include #include -#include #include "DoxygenEntity.h" -#include "TokenList.h" #include "JavaDocConverter.h" - DoxygenParser doxyParse; JavaDocConverter jDC; @@ -65,7 +59,10 @@ int testCommands(){ cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; char *nonConstString = (char *)malloc(exampleArray[i].length()+1); strcpy(nonConstString, exampleArray[i].c_str()); - dT.convert(nonConstString, "JAVADOC"); + char * result = dT.convert(nonConstString, "JAVADOC"); + free(nonConstString); + free(result); } return 1; } + From 4af0c994992b29e264eb3f2cddd486872112fc92 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 07:34:27 +0000 Subject: [PATCH 0019/2031] Memory usage fix in java.cxx git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10782 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ac8bfe13d..025cfc1c8 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -124,7 +124,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), - comment_creation_chatter(true), + comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), imclass_class_code(NULL), @@ -510,7 +510,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */"); - Printf(f_module, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(f_module, convertedString); + free(convertedString); } } if (Len(module_class_modifiers) > 0) @@ -640,6 +642,8 @@ public: module_imports = NULL; Delete(module_class_modifiers); module_class_modifiers = NULL; + Delete(structuralComments); + structuralComments = NULL; Delete(imclass_imports); imclass_imports = NULL; Delete(imclass_cppcasts_code); @@ -1234,8 +1238,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); - Printv(proxy_class_constants_code, - doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printv(proxy_class_constants_code, convertedString, NIL); + free(convertedString); } } @@ -1305,7 +1310,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); - Printf(enum_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(enum_code, convertedString); + free(convertedString); } } { @@ -1375,7 +1382,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); - Printv(structuralComments, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printv(structuralComments, convertedString, NIL); + free(convertedString); } } return SWIG_OK; @@ -1403,7 +1412,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); - Printf(constants_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(constants_code, convertedString); + free(convertedString); } } @@ -1672,7 +1683,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); - Printv(proxy_class_def, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"), NIL); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printv(proxy_class_def, convertedString, NIL); + free(convertedString); } } @@ -2013,7 +2026,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); - Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(function_code, convertedString); + free(convertedString); } } @@ -2243,7 +2258,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler */\n" ); - Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(function_code, convertedString); + free(convertedString); } } @@ -2512,7 +2529,9 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); - Printf(function_code, doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC")); + char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + Printf(function_code, convertedString); + free(convertedString); } } From d621d21617759e346653a57db28c83c1d9c1da71 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 12:18:01 +0000 Subject: [PATCH 0020/2031] Documentation Page (draft) written. Not yet added to table of contents. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10783 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/DoxygenTranslation.html | 257 +++++++++++++++++++++++++++++ Doc/Manual/chapters | 2 +- 2 files changed, 258 insertions(+), 1 deletion(-) create mode 100644 Doc/Manual/DoxygenTranslation.html diff --git a/Doc/Manual/DoxygenTranslation.html b/Doc/Manual/DoxygenTranslation.html new file mode 100644 index 000000000..e3797b56f --- /dev/null +++ b/Doc/Manual/DoxygenTranslation.html @@ -0,0 +1,257 @@ + + + +SWIG and Doxygen Translation + + + +

SWIG and Doxgeyn Translation

+ + + + +

+This chapter describes SWIG's support for translating Doxygen comments found in interface and header files into a target language's normal documentation language. Currently only JavaDoc is supported. +

+ +

Doxygen Translation Overview

+ +

+The Doxygen Translation Module of SWIG is an ongoing effort from a Google Summer of Code proposal from Summer 2008. It adds an extra layer of functionality to SWIG, allowing automated translation of Doxygen formatted comments from interface files into a documentation language more suited for the target language. Currently this module only translates into JavaDoc for the SWIG Java Module, but other extensions are to be added in time. +

+ +

+Questions about running SWIG are best answered in the SWIG Basics chapter as well as the target language modules. (For now, only Java). The behaviour of this functionality is wildly unpredictable if the interface file is not proper to begin with! +

+ +

Preparations

+ + +

+To make use of the comment translation system, your documentation comments must be in properly formatted Doxygen. They can be present in your main interface file or any header file that it imports. It is advised that you are certain your comments compile properly with Doxygen before you try to translate them. Doxygen itself is a deeper tool and can provide you better feedback for correct any syntax errors that may be present. Please look at Doxygen's Documenting the code for proper specificatons for comment format. +

+ +
+/*! This is describing class Shape
+ \author Bob
+ */
+
+class Shape {
+
+ +

+Because this functionality is currently only extended to java, you must be able to run SWIG's Java Module in order to make use of this tool.

+

Enabling Doxygen Translation

+ + +

+NOT YET ADDED (current development branch has this feature automatically enabled). +

+ +

Additional Commandline Options

+ +

+ALSO TO BE ADDED (JavaDoc Autobrief?) +

+ +

Doxygen To JavaDoc

+ + +

+If translation is enabled, JavaDoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files.

+ +

Basic Example

+ +

Here is an example segment from an included header file

+
+/*! This is describing class Shape
+ \author Bob
+ */
+
+class Shape {
+public:
+  Shape() {
+    nshapes++;
+  }
+  virtual ~Shape() {
+    nshapes--;
+  };
+  double  x, y; /*!< Important Variables */
+  void    move(double dx, double dy); /*!< Moves the Shape */
+  virtual double area(void) = 0; /*!< \return the area */
+  virtual double perimeter(void) = 0; /*!< \return the perimeter */
+  static  int nshapes;
+};
+
+ +

Simply running SWIG should result in the following code being present in Shapes.java

+ +
+
+/**
+ * This is describing class Shape  
+ * 
+ * @author	Bob  
+ */
+
+public class Shape {
+
+...
+
+/**
+ * Important things  
+ * 
+ */
+  public void setX(double value) {
+    exampleJNI.Shape_x_set(swigCPtr, this, value);
+  }
+
+...
+
+/**
+ * @return	the area  
+ */
+  public double area() {
+    return exampleJNI.Shape_area(swigCPtr, this);
+  }
+
+/**
+ * @return	the perimeter  
+ */
+  public double perimeter() {
+    return exampleJNI.Shape_perimeter(swigCPtr, this);
+  }
+
+
+ + + +

+The code Java-wise should be identical to what would have been generated without this feature enabled. When the Doxygen Translator Module encounters a comment it finds nothing useful in or cannot parse, it should not effect the functionality of the SWIG generated code.

+ + +

JavaDoc Tags

+ + +

+Doxygen has a wealth of tags such as @latexonly that have no equivalent in JavaDoc. As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed. If you are interested in more if the specifics of JavaDoc, please visit How to Write Doc Comments for the Javadoc Tool.

+Doxygen and JavaDoc Equivalent Tags +
+* @param      
+* @return      
+* @exception   
+* @author      
+* @version     
+* @see         
+* @since       
+* @serial      
+* @deprecated  
+
+ +

Other Tags

+ + +

+Because there are no specific JavaDoc tag for some important information, some tags are given plain-english descriptions of their presence, such as @bug. This is a feature currently still being developed and it is likely that more information from the original Doxygen Comments will be reproduced as this module matures. +

+

Bad Behaviour

+ + +

+There are some tags that the Doxygen Translator Module currently does not expect to encounter. This includes the PHP-only Doxygen commands such as @publicsection: +

+ Completely Unsupported Tags +
+"annotatedclasslist", "classhierarchy", "define", "functionindex", 
+"header", "headerfilelist", "inherit", "l", "postheader", "private",
+ "privatesection", "protected", "protectedsection", "public", "publicsection"
+
+ +

+The parsing behaviour will be unpredictable if any of these are encountered for now. This should eventually be changed so that they are simply ignored. +

+

+In general parsing errors should not interfere with the operation of SWIG itself. Blank comments or lack of comments could be indication of either a parsing error or a lack of meaningful tags in a specific blob of doxygen. +

+ + +

Further Details

+ + +

+TO BE ADDED. +

+ + +

Developer Information

+ + +

+Currently a good deal of this Module still needs some reworking, particularly on the side of the parser and JavaDoc producer.

+ +

Module Design

+ + +

+If this functionality is turned on, SWIG places all comments found into the SWIG parse tree. Nodes contain an additional attribute called DoxygenComment when a comment is present. Individual nodes containing Doxygen with Structural Indicators, such as @file, as their first command, are also present in the parse tree. These indivudal "blobs" of Doxygen such as :

+
+/*! This is describing function Foo
+ \param x some random variable
+ \author Bob
+ \return Foo
+ */
+
+ +

+are passed on individually to the DoxygenTranslator Module. This module builds it's own private parse tree and hands it, similar to SWIG itself, to a seperate class to translate into the target documentation language. For example, JavaDocConverter is the JavaDoc module class. +

+ +

Extending to Other Languages

+ + +

+In general, extension to another language requires a fairly deep understanding of the target language module- such as Modules/python.cxx for python. Searching for "doxygen" in the java.cxx module can give you a good idea of the process for placing in documentation comments into the correct areas. The basic gist is that anywhere a comment may reside on a node, there needs to be a catch for it in front of where that function, class, or other object is written out to a target language file. The other half of extension is building a target documentation language comment generator that handles 1 blob at a time. However, this is relatively simple- nowhere near as complex as the wrapper generating modules in SWIG. See DoxygenTranslator/JavaDocConverter.cpp for a good example. The target language module hands DoxygenTranslator the blob to translate, and receives back a translated text. +

+ What is given to Doxygen Translator +
+/*! This is describing function Foo
+ \param x some random variable
+ \author Bob
+ \return Foo
+ */
+
+ What is received back by java.cxx +
+/** This is describing function Foo
+ *
+ * @param x some random variable
+ * @author Bob
+ * @return Foo
+ */
+
+

Development of the comment translator itself is simplified by the fact that the DoxygenTranslator module can easily include a main in DoxygenTranslator and thus be developed, compiled, and tested independantly of SWIG.

+ + diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 55a0aec13..2e5a16364 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -32,4 +32,4 @@ Ruby.html Tcl.html R.html Extending.html - +DoxygenTranslation.html From 719abc61cc26d208e5831043500b3d70014d282e Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 16:08:51 +0000 Subject: [PATCH 0021/2031] parsing fixes, helped behaviour of normal text descriptions in comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10788 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/doxygencomments/java/class/example.h | 22 +++++--- .../DoxygenTranslator/src/DoxygenParser.cpp | 21 ++++---- .../src/DoxygenTranslator.cpp | 52 +++++++++++++------ .../src/JavaDocConverter.cpp | 43 ++++++++++++--- .../DoxygenTranslator/src/JavaDocConverter.h | 1 - Source/Modules/java.cxx | 6 +-- 6 files changed, 100 insertions(+), 45 deletions(-) diff --git a/Examples/doxygencomments/java/class/example.h b/Examples/doxygencomments/java/class/example.h index 7e3e7d540..ce9af23d3 100644 --- a/Examples/doxygencomments/java/class/example.h +++ b/Examples/doxygencomments/java/class/example.h @@ -1,8 +1,10 @@ -/** \file example.h +/*! \file example.h comments on example.h */ /*! This is describing class Shape \author Bob + \exception some sort of exception + \see OtherShapes() */ class Shape { @@ -13,11 +15,12 @@ public: virtual ~Shape() { nshapes--; }; - double x, y; /*!< Important things */ + double x, y; /*!< Important variables */ void move(double dx, double dy); - virtual double area(void) = 0; /*!< \return the area */ - virtual double perimeter(void) = 0; /*!< \return the perimeter */ - static int nshapes; + virtual double area(void) = 0; /*!< \return the area \exception exception description */ + virtual double perimeter(void) = 0; /*!< \exception exception description + \return the perimeter */ + static int nshapes; /*!< Details about nshapes. */ }; /*! This is describing class Circle */ class Circle : public Shape { @@ -25,8 +28,9 @@ private: double radius; public: Circle(double r) : radius(r) { }; - virtual double area(void); - virtual double perimeter(void); + virtual double area(void); /*!< \return the area \exception exception description */ + virtual double perimeter(void); /*!< \exception exception description + \return the perimeter */ }; /*! This is describing class square */ @@ -34,7 +38,9 @@ class Square : public Shape { private: double width; public: - Square(double w) : width(w) { }; + Square(double w) : width(w) { }; /*!< Create square + /param w the width + /exception some description */ virtual double area(void); virtual double perimeter(void); }; diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 920b7c794..d953bc6d4 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -31,7 +31,7 @@ DoxygenParser::~DoxygenParser() } ////////////////////////////////////////// -int noisy = 1; // set this to 1 for extra chatter from the parsing stage. +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. int addCommand(string currCommand, TokenList &tokList, list &aNewList); list parse(list::iterator endParsingIndex, TokenList &tokList); @@ -70,7 +70,7 @@ string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example" string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; string ignoreCommandLines[] = {"nothing at the moment"}; -string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", +string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; string ignoreCommandParagraphs[] = {"nothing at the moment"}; string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", @@ -208,27 +208,28 @@ list::iterator getOneLine(TokenList &tokList){ list::iterator endOfLine = tokList.iteratorCopy(); while(endOfLine!= tokList.end()){ if ((* endOfLine).tokenType == END_LINE){ - endOfLine++; + //cout << "REACHED END" << endl; + //endOfLine++; return endOfLine; } + //cout << (* endOfLine).toString(); endOfLine++; } - cout << "REACHED END" << endl; + return tokList.end(); } /* Returns a properly formatted string -* up til ANY command or end of paragraph is encountered. +* up til ANY command or end of line is encountered. */ string getStringTilCommand(TokenList &tokList){ string description; if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING || tokList.peek().tokenType == END_LINE ){ + while(tokList.peek().tokenType == PLAINSTRING){ Token currentToken = tokList.next(); if(currentToken.tokenType == PLAINSTRING) { description = description + currentToken.tokenString + " "; } - else if (tokList.peek().tokenType == END_LINE) break; } return description; } @@ -259,7 +260,7 @@ list::iterator getEndOfParagraph(TokenList &tokList){ endOfParagraph++; if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; - cout << "ENCOUNTERED END OF PARA" << endl; + //cout << "ENCOUNTERED END OF PARA" << endl; return endOfParagraph; } } @@ -762,14 +763,14 @@ list parseRoot(list::iterator endParsingIndex, TokenList & if (currCommand < 0 ){ if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; tokList.next(); - addCommand(string("details"), tokList, aNewList);} + addCommand(string("partofdescription"), tokList, aNewList);} //cout << "Command: " << currWord << " " << currCommand << endl; else { tokList.next(); addCommand(currToken.tokenString, tokList, aNewList); } } else if (currToken.tokenType == PLAINSTRING){ - addCommand(string("details"), tokList, aNewList); + addCommand(string("partofdescription"), tokList, aNewList); } } return aNewList; diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 77090573a..d6f0ae152 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -36,27 +36,27 @@ char *DoxygenTranslator::convert(char* doxygenBlob, char* option){ int testCommands(){ string exampleArray[] = { - "/**\n * \n * Random Line \n * \\@ \n * Random Line After */", - "/**\n * \n * Random Line Before \n * \\b bold \n * Random Line After */", - "/**\n * \n * Random Line \n * \\copydoc bold \n * Random Line After */", - "/**\n * \n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */", - "/**\n * \n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */", - "/**\n * \n * Random Line \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */", - "/**\n * \n * Random Line \n * \\code this should continue \n * until here \\endcode \n * Random Line After */", - "/**\n * \n * Random Line \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */", - "/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */", - "/**\n * \n * Random Line \n * \\page singleword this should go til here \n * but not this */", - "/**\n * \n * Random Line \n * \\category singleword \n * but not this */", - "/**\n * \n * Random Line \n * \\category singleword oneword \n * but not this */", - "/**\n * \n * Random Line \n * \\category singleword oneword twoword \n * but not this */", - "/**\n * \n * Random Line \n * \\dir singleword \n * but not this */", - "/**\n * \n * Random Line \n * \\dir \n * but not this */", - "/**\n * \n * Random Line \n * \\fakecommand details \n * but not this */" + "/**\n * Random Line \n * \\@ \n * Random Line After */", + "/**\n * Random Line Before \n * \n * \\b bold \n * Random Line After */", + "/**\n * Random Line \n * \n *\\copydoc bold \n * Random Line After */", + "/**\n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */", + "/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */", + "/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */", + "/**\n * Random Line \n * \n * \\code this should continue \n * until here \\endcode \n * Random Line After */", + "/**\n * Random Line \n * \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */", + "/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */", + "/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */", + "/**\n * Random Line \n * \n * \\category singleword \n * but not this */", + "/**\n * Random Line \n * \n * \\category singleword oneword \n * but not this */", + "/**\n * Random Line \n * \n * \\category singleword oneword twoword \n * but not this */", + "/**\n * Random Line \n * \n * \\dir singleword \n * but not this */", + "/**\n * Random Line \n * \n * \\dir \n * but not this */", + "/**\n * Random Line \n * \n * \\fakecommand details \n * but not this */" }; //string exampleArrayUniques = {}; DoxygenTranslator dT = DoxygenTranslator(); for (int i = 0; i < 16; i ++ ){ - cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; + //cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; char *nonConstString = (char *)malloc(exampleArray[i].length()+1); strcpy(nonConstString, exampleArray[i].c_str()); char * result = dT.convert(nonConstString, "JAVADOC"); @@ -66,3 +66,21 @@ int testCommands(){ return 1; } +//int main(int argc, char *argv[]){ + //string doxygenString1 = "//! \\brief a brief description \n\n A normal member taking two arguments and returning an \\b integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; + //cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl; + //char *nonConstString = (char *)malloc(doxygenString1.length()+1); + //strcpy(nonConstString, doxygenString1.c_str()); + //DoxygenTranslator dT = DoxygenTranslator(); + //char *result = dT.convert("/**\n * \n * Random Line \n * \n * \\name An Entire Line \n * NOT This Line \n * \n * Random Line After */", "JAVADOC"); + //result = dT.convert(nonConstString, "JAVADOC"); + //cout << "End"; + //list rootList = doxyParse.createTree(doxygenString1); + //JavaDocConverter jDC = JavaDocConverter(); + //jDC.convertToJavaDoc(rootList); + //testCommands(); + //return 1; +//} + + + diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index c1606cc77..70c3bb731 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -21,6 +21,8 @@ bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ if(second.typeOfEntity.compare("brief") == 0) return false; if(first.typeOfEntity.compare("details") == 0) return true; if(second.typeOfEntity.compare("details") == 0) return false; + if(first.typeOfEntity.compare("partofdescription") == 0) return true; + if(first.typeOfEntity.compare("partofdescription") == 0) return false; if(first.typeOfEntity.compare("plainstring") == 0) return true; if(second.typeOfEntity.compare("plainstring") == 0) return false; if(first.typeOfEntity.compare("param") == 0){ @@ -132,14 +134,41 @@ string formatCommand(string unformattedLine, int indent){ * could probably be much more efficient... */ string javaDocFormat(DoxygenEntity &doxygenEntity){ + if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ + return doxygenEntity.data; + } if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ - return doxygenEntity.data; + return doxygenEntity.data; } else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "\b" + doxygenEntity.data + ""; + return "" + doxygenEntity.data + ""; } else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "\b" + doxygenEntity.data + ""; + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + return "@"; + } + else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + return "\\"; + } + else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + return "<"; + } + else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + return ">"; + } + else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + return "&"; + } + else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + return "#"; + } + else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + return "%"; + } + else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + return "~"; } return ""; } @@ -160,6 +189,7 @@ string translateSubtree( DoxygenEntity &doxygenEntity){ } string translateEntity(DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) @@ -179,7 +209,7 @@ string translateEntity(DoxygenEntity &doxyEntity){ else if(doxyEntity.typeOfEntity.compare("sa")== 0){ return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); } - + else return formatCommand(javaDocFormat(doxyEntity), 0 ); return ""; } @@ -201,7 +231,8 @@ string JavaDocConverter:: convertToJavaDoc(list entityList){ } javaDocString += "\n */\n"; + if(printSortedTree2){ cout << "\n---RESULT IN JAVADOC---" << endl; - cout << javaDocString; + cout << javaDocString; } return javaDocString; -} +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 81122bc5f..53a270ce4 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -1,7 +1,6 @@ #include #include #include "DoxygenEntity.h" - #ifndef JAVADOCCONVERTER_H_ #define JAVADOCCONVERTER_H_ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 025cfc1c8..a21e37bf4 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -44,6 +44,8 @@ class JAVA:public Language { bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool member_func_flag; // flag set when wrapping a member function + bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc + bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx String *imclass_name; // intermediary class name String *module_class_name; // module class name @@ -90,8 +92,6 @@ class JAVA:public Language { return p; } /* DOXYGEN TO JAVADOC globals */ - bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc - bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx //TODO make this bool a command line option DoxygenTranslator doxyTranslator; @@ -124,6 +124,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), + doxygen_javadoc_flag(true), comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), @@ -213,7 +214,6 @@ public: virtual void main(int argc, char *argv[]) { - doxygen_javadoc_flag = true; SWIG_library_directory("java"); // Look for certain command line options From ad0a3d9179a8650d145c3db0e9b1c1bdc8de79ee Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 18:30:21 +0000 Subject: [PATCH 0022/2031] Extra Examples git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10790 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygencomments/java/callback/example.h | 7 +++++-- Examples/doxygencomments/java/extend/example.h | 11 +++++++++-- Examples/doxygencomments/java/native/example.i | 11 +++++++++++ .../doxygencomments/java/pointer/example.i | 10 +++++++++- .../doxygencomments/java/reference/example.i | 18 +++++++++++++++--- Examples/doxygencomments/java/simple/example.i | 6 +++++- .../doxygencomments/java/template/example.h | 11 +++++++++-- Examples/java/pointer/example.i | 2 -- Examples/java/reference/example.i | 3 --- 9 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Examples/doxygencomments/java/callback/example.h b/Examples/doxygencomments/java/callback/example.h index 38ada8b84..a0c5fc4d2 100644 --- a/Examples/doxygencomments/java/callback/example.h +++ b/Examples/doxygencomments/java/callback/example.h @@ -3,9 +3,12 @@ #include #include -/** Let's document class CALLBACK! */ +/*! Let's document class CALLBACK! + /author Alfred + */ class Callback { public: + /** Information about Callback */ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } virtual void run() { std::cout << "Callback::run()" << std::endl; } }; @@ -16,7 +19,7 @@ private: Callback *_callback; public: Caller(): _callback(0) {} - ~Caller() { delCallback(); } + ~Caller() { delCallback(); }/**< Deletes Callback */ void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } void call() { if (_callback) _callback->run(); } diff --git a/Examples/doxygencomments/java/extend/example.h b/Examples/doxygencomments/java/extend/example.h index db49ae747..9b882fd59 100644 --- a/Examples/doxygencomments/java/extend/example.h +++ b/Examples/doxygencomments/java/extend/example.h @@ -6,12 +6,15 @@ #include #include -/**This is describiing class Employee */ +/**This is describiing class Employee + /author Bob */ class Employee { private: std::string name; public: - /** TEST */ + /** Employee + \param n name of Employee + \throws some exception */ Employee(const char* n): name(n) {} /**This is describing method getTitle */ virtual std::string getTitle() { return getPosition() + " " + getName(); } @@ -31,11 +34,15 @@ public: class EmployeeList { std::vector list; public: + /** Initialises Employee List */ EmployeeList() { list.push_back(new Employee("Bob")); list.push_back(new Employee("Jane")); list.push_back(new Manager("Ted")); } + /** Add employee + * \param p employee p + * \return void */ void addEmployee(Employee *p) { list.push_back(p); std::cout << "New employee added. Current employees are:" << std::endl; diff --git a/Examples/doxygencomments/java/native/example.i b/Examples/doxygencomments/java/native/example.i index 851b6fdc2..21bcf528c 100644 --- a/Examples/doxygencomments/java/native/example.i +++ b/Examples/doxygencomments/java/native/example.i @@ -4,11 +4,16 @@ %{ #include +/*! Structure Point */ typedef struct point { int x; int y; } Point; +/*! Point_create Description + /param x integer x + /param y some integer y + /return a point */ Point *point_create(int x, int y) { Point *p = (Point *) malloc(sizeof(Point)); @@ -18,6 +23,11 @@ Point *point_create(int x, int y) { return p; } +/*! Point_create Description + /param format the format + /param p some p + /return a character string of the point p */ + static char *point_toString(char *format, Point *p) { static char buf[80]; @@ -54,3 +64,4 @@ char *point_toString1(Point *p); extern void free(void *memblock); %native(point_toString2) char *point_toString2(Point *p); + diff --git a/Examples/doxygencomments/java/pointer/example.i b/Examples/doxygencomments/java/pointer/example.i index a8ac79499..7ac3b8cf8 100644 --- a/Examples/doxygencomments/java/pointer/example.i +++ b/Examples/doxygencomments/java/pointer/example.i @@ -7,10 +7,16 @@ extern void sub(int *, int *, int *); extern int divide(int, int, int *); %} -/* This example illustrates a couple of different techniques +/** This example illustrates a couple of different techniques for manipulating C pointers */ /* First we'll use the pointer library */ + +/*! function add + \param x some int x + \param y some int y + \param result some result + */ extern void add(int *x, int *y, int *result); %include cpointer.i %pointer_functions(int, intp); @@ -28,3 +34,5 @@ extern int divide(int n, int d, int *r); + + diff --git a/Examples/doxygencomments/java/reference/example.i b/Examples/doxygencomments/java/reference/example.i index 6daa3b1f4..8e4d05239 100644 --- a/Examples/doxygencomments/java/reference/example.i +++ b/Examples/doxygencomments/java/reference/example.i @@ -8,6 +8,12 @@ #include "example.h" %} +/*! Class vector description + \author Fred + \exception something random + \since 1.0 + \name ignoreme + \see something */ class Vector { public: Vector(double x, double y, double z); @@ -15,15 +21,18 @@ public: char *print(); }; -/* This helper function calls an overloaded operator */ +/** This helper function calls an overloaded operator */ %inline %{ Vector addv(Vector &a, Vector &b) { return a+b; } %} -/* Wrapper around an array of vectors class */ - +/*! Class Vector Array + \exception something random + \since 1.3 + \see something + \author Fred */ class VectorArray { public: VectorArray(int maxsize); @@ -44,3 +53,6 @@ public: + + + diff --git a/Examples/doxygencomments/java/simple/example.i b/Examples/doxygencomments/java/simple/example.i index 24093b9bf..c823bc8b6 100644 --- a/Examples/doxygencomments/java/simple/example.i +++ b/Examples/doxygencomments/java/simple/example.i @@ -2,6 +2,10 @@ %module example %inline %{ +/*! Function foo + \param x int x + \param y int y + \return the gcd */ extern int gcd(int x, int y); -extern double Foo; +extern double Foo; /*!< description of double foo %} diff --git a/Examples/doxygencomments/java/template/example.h b/Examples/doxygencomments/java/template/example.h index 7401df650..9ec711391 100644 --- a/Examples/doxygencomments/java/template/example.h +++ b/Examples/doxygencomments/java/template/example.h @@ -2,8 +2,15 @@ // Some template definitions +/*! Template class T + \author cmfoil + \sa something something */ + template T max(T a, T b) { return a>b ? a : b; } +/*! Template class Vector + \author cmfoil + \sa something something */ template class vector { T *v; int sz; @@ -17,12 +24,12 @@ template class vector { } void set(int index, T &val) { v[index] = val; - } + } /*!< Something about set */ #ifdef SWIG %extend { T getitem(int index) { return $self->get(index); - } + }/*!< Something about get item */ void setitem(int index, T val) { $self->set(index,val); } diff --git a/Examples/java/pointer/example.i b/Examples/java/pointer/example.i index a8ac79499..5b725cee6 100644 --- a/Examples/java/pointer/example.i +++ b/Examples/java/pointer/example.i @@ -26,5 +26,3 @@ extern void sub(int *INPUT, int *INPUT, int *OUTPUT); extern int divide(int n, int d, int *r); - - diff --git a/Examples/java/reference/example.i b/Examples/java/reference/example.i index 6daa3b1f4..fd80f9a94 100644 --- a/Examples/java/reference/example.i +++ b/Examples/java/reference/example.i @@ -41,6 +41,3 @@ public: } }; - - - From 6c646831c3400c74ff87affceb7be96604864566 Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 18:37:41 +0000 Subject: [PATCH 0023/2031] syntax error git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10791 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/doxygencomments/java/simple/example.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/doxygencomments/java/simple/example.i b/Examples/doxygencomments/java/simple/example.i index c823bc8b6..d10fe5e19 100644 --- a/Examples/doxygencomments/java/simple/example.i +++ b/Examples/doxygencomments/java/simple/example.i @@ -7,5 +7,5 @@ \param y int y \return the gcd */ extern int gcd(int x, int y); -extern double Foo; /*!< description of double foo +extern double Foo; /*!< description of double foo */ %} From 52dd40260d3925d50b9cd672da3d23de38b3792b Mon Sep 17 00:00:00 2001 From: Cheryl Foil Date: Mon, 18 Aug 2008 18:49:13 +0000 Subject: [PATCH 0024/2031] One more example, for variables git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10792 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygencomments/java/variables/example.h | 2 +- .../doxygencomments/java/variables/example.i | 44 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Examples/doxygencomments/java/variables/example.h b/Examples/doxygencomments/java/variables/example.h index 0f7e89594..2265a45f3 100644 --- a/Examples/doxygencomments/java/variables/example.h +++ b/Examples/doxygencomments/java/variables/example.h @@ -2,5 +2,5 @@ typedef struct { int x,y; -} Point; +} Point; /*!< Description of struct Point */ diff --git a/Examples/doxygencomments/java/variables/example.i b/Examples/doxygencomments/java/variables/example.i index 591b871ed..b9794f0cf 100644 --- a/Examples/doxygencomments/java/variables/example.i +++ b/Examples/doxygencomments/java/variables/example.i @@ -6,24 +6,24 @@ /* Some global variable declarations */ %inline %{ -extern int ivar; -extern short svar; -extern long lvar; -extern unsigned int uivar; -extern unsigned short usvar; -extern unsigned long ulvar; -extern signed char scvar; -extern unsigned char ucvar; -extern char cvar; -extern float fvar; -extern double dvar; -extern char *strvar; -extern const char cstrvar[]; -extern int *iptrvar; -extern char name[256]; +extern int ivar; /*!< Description of ivar */ +extern short svar; /*!< Description of svar */ +extern long lvar; /*!< Description of lvar */ +extern unsigned int uivar; /*!< Description of uivar */ +extern unsigned short usvar; /*!< Description of usvar */ +extern unsigned long ulvar; /*!< Description of ulvar */ +extern signed char scvar; /*!< Description of scvar */ +extern unsigned char ucvar; /*!< Description of ucvar */ +extern char cvar; /*!< Description of cvar */ +extern float fvar; /*!< Description of fvar */ +extern double dvar; /*!< Description of dvar */ +extern char *strvar; /*!< Description of strvar */ +extern const char cstrvar[]; /*!< Description of cstrvar */ +extern int *iptrvar; /*!< Description of iptrvar */ +extern char name[256]; /*!< Description of name */ -extern Point *ptptr; -extern Point pt; +extern Point *ptptr; /*!< Description of ptrptr */ +extern Point pt; /*!< Description of pt */ %} @@ -40,8 +40,16 @@ extern char path[256]; /* Some helper functions to make it easier to test */ %inline %{ +/*! this function prints variables + \author someone */ extern void print_vars(); -extern int *new_int(int value); +extern int *new_int(int value); /*!< Description of new_int + \param value the value + \return a new int */ +/*! Description of new_point + \param x the value x + \param y the value y + \return a new point */ extern Point *new_Point(int x, int y); extern char *Point_print(Point *p); extern void pt_print(); From 9f4726743120be21e1675c09d32c963d8b683f2f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Sep 2008 19:38:06 +0000 Subject: [PATCH 0025/2031] Few formatting changes and a couple of minor edits after review git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10817 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/DoxygenTranslation.html | 164 +++++++++++++++++++---------- 1 file changed, 111 insertions(+), 53 deletions(-) diff --git a/Doc/Manual/DoxygenTranslation.html b/Doc/Manual/DoxygenTranslation.html index e3797b56f..f53917e3a 100644 --- a/Doc/Manual/DoxygenTranslation.html +++ b/Doc/Manual/DoxygenTranslation.html @@ -5,53 +5,62 @@ -

SWIG and Doxgeyn Translation

+

35 SWIG and Doxgeyn Translation

+ +

-This chapter describes SWIG's support for translating Doxygen comments found in interface and header files into a target language's normal documentation language. Currently only JavaDoc is supported. +This chapter describes SWIG's support for translating Doxygen comments found in interface and header files into a target language's normal documentation language. +Currently only JavaDoc is supported.

-

Doxygen Translation Overview

+

35.1 Doxygen Translation Overview

+

-The Doxygen Translation Module of SWIG is an ongoing effort from a Google Summer of Code proposal from Summer 2008. It adds an extra layer of functionality to SWIG, allowing automated translation of Doxygen formatted comments from interface files into a documentation language more suited for the target language. Currently this module only translates into JavaDoc for the SWIG Java Module, but other extensions are to be added in time. +The Doxygen Translation Module of SWIG is an ongoing effort from a Google Summer of Code proposal from Summer 2008. +It adds an extra layer of functionality to SWIG, allowing automated translation of Doxygen formatted comments from input files into a documentation language more suited for the target language. +Currently this module only translates into JavaDoc for the SWIG Java Module, but other extensions are to be added in time.

-Questions about running SWIG are best answered in the SWIG Basics chapter as well as the target language modules. (For now, only Java). The behaviour of this functionality is wildly unpredictable if the interface file is not proper to begin with! +Questions about running SWIG are best answered in the SWIG Basics chapter as well as the target language modules. (For now, only Java). +The behaviour of this functionality is wildly unpredictable if the interface file is not proper to begin with!

-

Preparations

+

35.2 Preparations

-To make use of the comment translation system, your documentation comments must be in properly formatted Doxygen. They can be present in your main interface file or any header file that it imports. It is advised that you are certain your comments compile properly with Doxygen before you try to translate them. Doxygen itself is a deeper tool and can provide you better feedback for correct any syntax errors that may be present. Please look at Doxygen's Documenting the code for proper specificatons for comment format. +To make use of the comment translation system, your documentation comments must be in properly formatted Doxygen. They can be present in your main interface file or any header file that it imports. +It is advised that you are certain your comments compile properly with Doxygen before you try to translate them. +Doxygen itself is a deeper tool and can provide you better feedback for correct any syntax errors that may be present. +Please look at Doxygen's Documenting the code for proper specificatons for comment format.

@@ -63,29 +72,35 @@ class Shape {
 

-Because this functionality is currently only extended to java, you must be able to run SWIG's Java Module in order to make use of this tool.

-

Enabling Doxygen Translation

+Because this functionality is currently only extended to Java, you must be able to run SWIG's Java Module in order to make use of this tool. +

+

35.2.1 Enabling Doxygen Translation

NOT YET ADDED (current development branch has this feature automatically enabled).

-

Additional Commandline Options

+

35.2.2 Additional Commandline Options

+

ALSO TO BE ADDED (JavaDoc Autobrief?)

-

Doxygen To JavaDoc

+

35.3 Doxygen To JavaDoc

-If translation is enabled, JavaDoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files.

+If translation is enabled, JavaDoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files. +

-

Basic Example

+

35.3.1 Basic Example

-

Here is an example segment from an included header file

+ +

+Here is an example segment from an included header file +

 /*! This is describing class Shape
  \author Bob
@@ -99,15 +114,17 @@ public:
   virtual ~Shape() {
     nshapes--;
   };
-  double  x, y; /*!< Important Variables */
-  void    move(double dx, double dy); /*!< Moves the Shape */
-  virtual double area(void) = 0; /*!< \return the area */
-  virtual double perimeter(void) = 0; /*!< \return the perimeter */
+  double  x, y; /*!< Important Variables */
+  void    move(double dx, double dy); /*!< Moves the Shape */
+  virtual double area(void) = 0; /*!< \return the area */
+  virtual double perimeter(void) = 0; /*!< \return the perimeter */
   static  int nshapes;
 };
 
-

Simply running SWIG should result in the following code being present in Shapes.java

+

+Simply running SWIG should result in the following code being present in Shapes.java +

 
@@ -122,13 +139,20 @@ public class Shape {
 ...
 
 /**
- * Important things  
+ * Important Variables  
  * 
  */
   public void setX(double value) {
     exampleJNI.Shape_x_set(swigCPtr, this, value);
   }
 
+/**
+ * Important variables  
+ */
+  public double getX() {
+    return exampleJNI.Shape_x_get(swigCPtr, this);
+  }
+
 ...
 
 /**
@@ -150,15 +174,23 @@ public class Shape {
 
 
 

-The code Java-wise should be identical to what would have been generated without this feature enabled. When the Doxygen Translator Module encounters a comment it finds nothing useful in or cannot parse, it should not effect the functionality of the SWIG generated code.

+The code Java-wise should be identical to what would have been generated without this feature enabled. +When the Doxygen Translator Module encounters a comment it finds nothing useful in or cannot parse, it should not effect the functionality of the SWIG generated code. +

-

JavaDoc Tags

+

35.3.2 JavaDoc Tags

-Doxygen has a wealth of tags such as @latexonly that have no equivalent in JavaDoc. As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed. If you are interested in more if the specifics of JavaDoc, please visit How to Write Doc Comments for the Javadoc Tool.

+Doxygen has a wealth of tags such as @latexonly that have no equivalent in JavaDoc. +As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed. +If you are interested in more of the specifics of JavaDoc, please visit How to Write Doc Comments for the Javadoc Tool. +

+ +

Doxygen and JavaDoc Equivalent Tags +

 * @param      
 * @return      
@@ -171,19 +203,24 @@ Doxygen has a wealth of tags such as @latexonly that have no equivalent in JavaD
 * @deprecated  
 
-

Other Tags

+

35.3.3 Other Tags

-Because there are no specific JavaDoc tag for some important information, some tags are given plain-english descriptions of their presence, such as @bug. This is a feature currently still being developed and it is likely that more information from the original Doxygen Comments will be reproduced as this module matures. +Because there are no specific JavaDoc tags for some important information, some tags are given plain English descriptions of their presence, such as @bug. +This is a feature currently still being developed and it is likely that more information from the original Doxygen Comments will be reproduced as this module matures.

-

Bad Behaviour

+

35.3.4 Bad Behaviour

-There are some tags that the Doxygen Translator Module currently does not expect to encounter. This includes the PHP-only Doxygen commands such as @publicsection: +There are some tags that the Doxygen Translator Module currently does not expect to encounter. +This includes the PHP-only Doxygen commands such as @publicsection:

+ +

Completely Unsupported Tags +

 "annotatedclasslist", "classhierarchy", "define", "functionindex", 
 "header", "headerfilelist", "inherit", "l", "postheader", "private",
@@ -191,14 +228,16 @@ There are some tags that the Doxygen Translator Module currently does not expect
 

-The parsing behaviour will be unpredictable if any of these are encountered for now. This should eventually be changed so that they are simply ignored. +The parsing behaviour will be unpredictable if any of these are encountered for now. +This should eventually be changed so that they are simply ignored.

-In general parsing errors should not interfere with the operation of SWIG itself. Blank comments or lack of comments could be indication of either a parsing error or a lack of meaningful tags in a specific blob of doxygen. +In general parsing errors should not interfere with the operation of SWIG itself. +Blank comments or lack of comments could be an indication of either a parsing error or a lack of meaningful tags in a specific blob of doxygen.

-

Further Details

+

35.3.5 Further Details

@@ -206,17 +245,22 @@ TO BE ADDED.

-

Developer Information

+

35.4 Developer Information

-Currently a good deal of this Module still needs some reworking, particularly on the side of the parser and JavaDoc producer.

+Currently a good deal of this Module still needs some reworking, particularly on the side of the parser and JavaDoc producer. +

-

Module Design

+

35.4.1 Module Design

-If this functionality is turned on, SWIG places all comments found into the SWIG parse tree. Nodes contain an additional attribute called DoxygenComment when a comment is present. Individual nodes containing Doxygen with Structural Indicators, such as @file, as their first command, are also present in the parse tree. These indivudal "blobs" of Doxygen such as :

+If this functionality is turned on, SWIG places all comments found into the SWIG parse tree. +Nodes contain an additional attribute called DoxygenComment when a comment is present. +Individual nodes containing Doxygen with Structural Indicators, such as @file, as their first command, are also present in the parse tree. +These individual "blobs" of Doxygen such as : +

 /*! This is describing function Foo
  \param x some random variable
@@ -226,16 +270,26 @@ If this functionality is turned on, SWIG places all comments found into the SWIG
 

-are passed on individually to the DoxygenTranslator Module. This module builds it's own private parse tree and hands it, similar to SWIG itself, to a seperate class to translate into the target documentation language. For example, JavaDocConverter is the JavaDoc module class. +are passed on individually to the DoxygenTranslator Module. +This module builds its own private parse tree and hands it to a separate class for translation into the target documentation language. +For example, JavaDocConverter is the JavaDoc module class.

-

Extending to Other Languages

+

35.5 Extending to Other Languages

-In general, extension to another language requires a fairly deep understanding of the target language module- such as Modules/python.cxx for python. Searching for "doxygen" in the java.cxx module can give you a good idea of the process for placing in documentation comments into the correct areas. The basic gist is that anywhere a comment may reside on a node, there needs to be a catch for it in front of where that function, class, or other object is written out to a target language file. The other half of extension is building a target documentation language comment generator that handles 1 blob at a time. However, this is relatively simple- nowhere near as complex as the wrapper generating modules in SWIG. See DoxygenTranslator/JavaDocConverter.cpp for a good example. The target language module hands DoxygenTranslator the blob to translate, and receives back a translated text. +In general, an extension to another language requires a fairly deep understanding of the target language module, such as Modules/python.cxx for Python. +Searching for "doxygen" in the java.cxx module can give you a good idea of the process for placing documentation comments into the correct areas. +The basic gist is that anywhere a comment may reside on a node, there needs to be a catch for it in front of where that function, class, or other object is written out to a target language file. +The other half of extension is building a target documentation language comment generator that handles one blob at a time. +However, this is relatively simple and nowhere near as complex as the wrapper generating modules in SWIG. +See DoxygenTranslator/JavaDocConverter.cpp for a good example. +The target language module hands the DoxygenTranslator the blob to translate, and receives back a translated text. +

+

+ What is given to the Doxygen Translator

- What is given to Doxygen Translator
 /*! This is describing function Foo
  \param x some random variable
@@ -243,7 +297,9 @@ In general, extension to another language requires a fairly deep understanding o
  \return Foo
  */
 
+

What is received back by java.cxx +

 /** This is describing function Foo
  *
@@ -252,6 +308,8 @@ In general, extension to another language requires a fairly deep understanding o
  * @return Foo
  */
 
-

Development of the comment translator itself is simplified by the fact that the DoxygenTranslator module can easily include a main in DoxygenTranslator and thus be developed, compiled, and tested independantly of SWIG.

+

Development of the comment translator itself is simplified by the fact that the DoxygenTranslator module can easily include a main function and thus be developed, compiled, and tested independently of SWIG. +

+ From 8486cc9f4308688e590ba045f222eceafa720502 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Sep 2008 19:40:04 +0000 Subject: [PATCH 0026/2031] rename DoxygenTranslation.html to Doxygen.html git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10818 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 28 +++++++++++++++++++ .../{DoxygenTranslation.html => Doxygen.html} | 0 Doc/Manual/chapters | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) rename Doc/Manual/{DoxygenTranslation.html => Doxygen.html} (100%) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5c7a18eaf..9d6e4e66f 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1533,6 +1533,34 @@
+

35 SWIG and Doxgeyn Translation

+ + + + + diff --git a/Doc/Manual/DoxygenTranslation.html b/Doc/Manual/Doxygen.html similarity index 100% rename from Doc/Manual/DoxygenTranslation.html rename to Doc/Manual/Doxygen.html diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 2e5a16364..c9df298f0 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -32,4 +32,4 @@ Ruby.html Tcl.html R.html Extending.html -DoxygenTranslation.html +Doxygen.html From 721327573bb00785ff5d96ae0872e18534fa9aa1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Sep 2008 20:04:34 +0000 Subject: [PATCH 0027/2031] fix typo and main ref git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10823 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Doxygen.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index f53917e3a..27fc013eb 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

35 SWIG and Doxgeyn Translation

+

35 SWIG and Doxygen Translation

    From 825e67b2b0e7a356c678833ae3535b17708701ee Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 10:51:51 +0000 Subject: [PATCH 0028/2031] Merged revisions 10487,10498-10499,10503-10504,10506,10508,10511,10515-10516,10518-10519,10527,10530-10531,10536-10537,10539-10552,10558-10568,10574-10580,10582,10584,10588-10589,10594,10607-10610,10616,10621,10624-10629,10633-10641,10643,10647,10649-10650,10662,10672,10676-10677,10682-10683,10714,10726-10727,10738,10743,10747,10749,10794,10801-10809,10827-10831,10834 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/trunk ................ r10487 | wsfulton | 2008-05-21 23:15:52 +0100 (Wed, 21 May 2008) | 1 line Apply patch from Petr Viktorin to fix some recent regressions in CFFI/CLOS ................ r10498 | talby | 2008-05-26 21:09:56 +0100 (Mon, 26 May 2008) | 2 lines run test cases in the Perl set by the --with-perl5 configure option. ................ r10499 | talby | 2008-05-26 22:04:06 +0100 (Mon, 26 May 2008) | 3 lines The perl5 minherit runtime test will work better if the classes are actually built under SWIGPERL. ................ r10503 | wsfulton | 2008-05-28 10:44:37 +0100 (Wed, 28 May 2008) | 1 line Fix variable wrappers when using -proxy. Patch from Jan Jezabek ................ r10504 | bhy | 2008-05-28 18:27:48 +0100 (Wed, 28 May 2008) | 2 lines Fixed SF #1971977: typo in pycontainer.swg (related to -extranative option) ................ r10506 | wsfulton | 2008-05-29 01:45:28 +0100 (Thu, 29 May 2008) | 1 line Fix variable wrappers when using -noproxy ................ r10508 | bhy | 2008-05-30 14:53:33 +0100 (Fri, 30 May 2008) | 1 line Fixed SF #1976978, apply the macros for primitive types to std::wstring ................ r10511 | olly | 2008-05-30 17:11:27 +0100 (Fri, 30 May 2008) | 4 lines Fix typo in handling of /*@SWIG[...]*/ comments in the scanner. This just meant we were only actually looking for /*@SWI at the start of the comment, so was pretty harmless in practice. ................ r10515 | wsfulton | 2008-06-02 21:10:40 +0100 (Mon, 02 Jun 2008) | 1 line Fix samename testcase for c# and java ................ r10516 | wsfulton | 2008-06-02 21:15:39 +0100 (Mon, 02 Jun 2008) | 1 line Fix enums when using -noproxy ................ r10518 | bhy | 2008-06-07 12:20:07 +0100 (Sat, 07 Jun 2008) | 4 lines Added a test case for keyword renaming. Now it works for Python in SWIG's -c++ mode, but in C mode it doesn't work! (you can try with make keyword_rename.ctest) ................ r10519 | bhy | 2008-06-07 14:40:51 +0100 (Sat, 07 Jun 2008) | 1 line fixed keyword_rename.ctest tese case, caused by a mistake in Swig/naming.c ................ r10527 | mgossage | 2008-06-17 03:57:15 +0100 (Tue, 17 Jun 2008) | 1 line [lua] bugfix 1938142 (bool& and bool* support) ................ r10530 | wsfulton | 2008-06-19 21:02:13 +0100 (Thu, 19 Jun 2008) | 1 line Add R keyword support. Rename keywords for successful compilation of Java and C# code. More consistent keyword warnings across the different languages. ................ r10531 | wsfulton | 2008-06-19 22:15:48 +0100 (Thu, 19 Jun 2008) | 1 line add complete list of R reserved words ................ r10536 | wsfulton | 2008-06-21 12:35:33 +0100 (Sat, 21 Jun 2008) | 1 line better terminology for static types ................ r10537 | wsfulton | 2008-06-21 12:42:48 +0100 (Sat, 21 Jun 2008) | 1 line remove raise as keyword test- it conflicts with _raise in LIBCMT on windows ................ r10539 | wsfulton | 2008-06-21 16:21:29 +0100 (Sat, 21 Jun 2008) | 1 line Lua example warning removal fixes for vc++ ................ r10540 | wsfulton | 2008-06-21 16:23:02 +0100 (Sat, 21 Jun 2008) | 1 line Remove some vc++ /W4 warnings ................ r10541 | wsfulton | 2008-06-21 17:04:55 +0100 (Sat, 21 Jun 2008) | 1 line minor vc++ /W4 warning fixes ................ r10542 | wsfulton | 2008-06-21 20:07:51 +0100 (Sat, 21 Jun 2008) | 1 line 'byte' is already used in Ruby on windows, so use another keyword ................ r10543 | wsfulton | 2008-06-21 21:45:32 +0100 (Sat, 21 Jun 2008) | 1 line Fix crashing in the Ruby reject method in the STL wrappers ................ r10544 | wsfulton | 2008-06-21 21:48:28 +0100 (Sat, 21 Jun 2008) | 1 line Fix crashing in the Ruby reject method in the STL wrappers ................ r10545 | wsfulton | 2008-06-21 21:49:10 +0100 (Sat, 21 Jun 2008) | 1 line remove unnecessary variable int the char **STRING_ARRAY out typemap ................ r10546 | wsfulton | 2008-06-21 22:07:49 +0100 (Sat, 21 Jun 2008) | 1 line Fix Ruby C++ example dependencies in dsp files ................ r10547 | wsfulton | 2008-06-21 23:25:36 +0100 (Sat, 21 Jun 2008) | 1 line Fix unused parameter warnings in python when using gcc's -W -Wall options ................ r10548 | wsfulton | 2008-06-21 23:26:35 +0100 (Sat, 21 Jun 2008) | 1 line Fix virtual destructor ................ r10549 | wsfulton | 2008-06-22 00:25:20 +0100 (Sun, 22 Jun 2008) | 1 line various warning fixes ................ r10550 | wsfulton | 2008-06-22 01:09:11 +0100 (Sun, 22 Jun 2008) | 1 line Another fix for the JVM hanging on exit problem when using directors ................ r10551 | wsfulton | 2008-06-22 01:09:51 +0100 (Sun, 22 Jun 2008) | 1 line documentation sections update ................ r10552 | wsfulton | 2008-06-22 01:18:10 +0100 (Sun, 22 Jun 2008) | 1 line more docs on defining macros for the thread hanging problem ................ r10558 | wsfulton | 2008-06-22 22:30:20 +0100 (Sun, 22 Jun 2008) | 1 line fix unused parms in last commit for C code ................ r10559 | wsfulton | 2008-06-22 23:12:43 +0100 (Sun, 22 Jun 2008) | 1 line Suppress unused methods warning for VC++ ................ r10560 | wsfulton | 2008-06-23 21:26:07 +0100 (Mon, 23 Jun 2008) | 1 line fix partialcheck-test-suite and parallel make for r, chicken, tcl and php ................ r10561 | wsfulton | 2008-06-23 21:39:41 +0100 (Mon, 23 Jun 2008) | 1 line correct message display when running the partialcheck-test-suite make target ................ r10562 | wsfulton | 2008-06-23 22:14:53 +0100 (Mon, 23 Jun 2008) | 1 line fix typo ................ r10563 | olly | 2008-06-23 22:23:54 +0100 (Mon, 23 Jun 2008) | 3 lines Fix bad use of Python API (untested, since I can't even compile this code on x86-64!) ................ r10564 | olly | 2008-06-23 23:58:03 +0100 (Mon, 23 Jun 2008) | 3 lines [PHP] Fix segfault when wrapping a non-class function marked with %newobject (testcase char_strings). ................ r10565 | olly | 2008-06-24 01:27:34 +0100 (Tue, 24 Jun 2008) | 3 lines [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) (testcase ignore_parameter). ................ r10566 | olly | 2008-06-24 01:33:08 +0100 (Tue, 24 Jun 2008) | 2 lines [PHP] Fix typemap_namespace.i to not try to copy a non-existent typemap. ................ r10567 | olly | 2008-06-24 01:41:07 +0100 (Tue, 24 Jun 2008) | 3 lines Clean up dead and unused code in SwigToPhpType(), and rename to GetShadowReturnType(). ................ r10568 | olly | 2008-06-24 01:42:29 +0100 (Tue, 24 Jun 2008) | 2 lines Fix cosmetic typo in string constant. ................ r10574 | wsfulton | 2008-06-24 21:10:28 +0100 (Tue, 24 Jun 2008) | 1 line zap last entry ................ r10575 | wsfulton | 2008-06-24 21:11:46 +0100 (Tue, 24 Jun 2008) | 1 line variable name changes to remove php keywords ................ r10576 | wsfulton | 2008-06-24 21:12:08 +0100 (Tue, 24 Jun 2008) | 1 line variable name hiding fix ................ r10577 | wsfulton | 2008-06-24 21:12:43 +0100 (Tue, 24 Jun 2008) | 1 line More info about numobjects added ................ r10578 | wsfulton | 2008-06-24 21:13:41 +0100 (Tue, 24 Jun 2008) | 1 line update for 1.3.36 release ................ r10579 | wsfulton | 2008-06-24 22:48:46 +0100 (Tue, 24 Jun 2008) | 1 line remove deprecated -c commandline option (runtime library generation) ................ r10580 | wsfulton | 2008-06-24 22:53:12 +0100 (Tue, 24 Jun 2008) | 1 line correct comment about deprecated option ................ r10582 | wsfulton | 2008-06-25 00:00:27 +0100 (Wed, 25 Jun 2008) | 1 line use rsync and ssh to upload releases to SourceForge as ftp no longer works ................ r10584 | wsfulton | 2008-06-25 00:24:48 +0100 (Wed, 25 Jun 2008) | 1 line correction for 1.3.36 ................ r10588 | wsfulton | 2008-06-25 01:16:04 +0100 (Wed, 25 Jun 2008) | 1 line section update ................ r10589 | wsfulton | 2008-06-25 01:16:40 +0100 (Wed, 25 Jun 2008) | 1 line bump version to 1.3.37 ................ r10594 | wsfulton | 2008-06-26 19:33:06 +0100 (Thu, 26 Jun 2008) | 1 line correct typo in first entry about %fragment ................ r10607 | wsfulton | 2008-06-29 01:19:05 +0100 (Sun, 29 Jun 2008) | 1 line fix some potential null pointer usage as reported by CoveriCoverity Prevent ................ r10608 | wsfulton | 2008-06-29 01:50:27 +0100 (Sun, 29 Jun 2008) | 1 line fix potential null pointer usage as reported by Coverity Prevent ................ r10609 | wsfulton | 2008-06-29 10:57:41 +0100 (Sun, 29 Jun 2008) | 1 line make life easier for svn status updates as everyone has different autotool versions installed - use svn:ignore on config.sub and config.guess ................ r10610 | wsfulton | 2008-06-29 11:08:14 +0100 (Sun, 29 Jun 2008) | 1 line make life easier for svn status updates as everyone has different autotool versions installed - use svn:ignore on config.sub and config.guess ................ r10616 | talby | 2008-07-01 00:41:27 +0100 (Tue, 01 Jul 2008) | 2 lines Hopefully this provides more portable values for Infinity and NaN in Perl. ................ r10621 | wsfulton | 2008-07-01 23:02:14 +0100 (Tue, 01 Jul 2008) | 1 line update old commandline option ................ r10624 | olly | 2008-07-02 04:17:46 +0100 (Wed, 02 Jul 2008) | 5 lines [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. ................ r10625 | bhy | 2008-07-02 05:56:11 +0100 (Wed, 02 Jul 2008) | 1 line fix the relative import patch by try both relative and absolute import ................ r10626 | olly | 2008-07-02 06:55:18 +0100 (Wed, 02 Jul 2008) | 4 lines [PHP4] Support for PHP4 has been removed. The PHP developers are no longer making new PHP4 releases, and won't even be patching critical security issues after 2008-08-08. ................ r10627 | bhy | 2008-07-02 07:06:56 +0100 (Wed, 02 Jul 2008) | 1 line fix the previous commit -- new approach using imp module ................ r10628 | bhy | 2008-07-02 07:29:15 +0100 (Wed, 02 Jul 2008) | 1 line minor fix on relative import: close fp if exception occured during imp.find_module ................ r10629 | bhy | 2008-07-02 08:08:00 +0100 (Wed, 02 Jul 2008) | 1 line reconstruct the relative import, now the generated code looks better ................ r10633 | olly | 2008-07-03 01:09:56 +0100 (Thu, 03 Jul 2008) | 9 lines WARN_* constants are user visible, so keep existing WARN_PHP4_* for backward compatibility, but add preferred forms WARN_PHP_* and use these ourselves. Rename Lib/php4 to Lib/php, Source/Modules/php4.cxx to Source/Modules/php.cxx. Add typemaps for const reference so Examples/test-suite/apply_signed_char.i works. ................ r10634 | olly | 2008-07-03 01:12:58 +0100 (Thu, 03 Jul 2008) | 2 lines Remove file added in error. ................ r10635 | olly | 2008-07-03 01:37:38 +0100 (Thu, 03 Jul 2008) | 2 lines Rename php4*.swg to php*.swg. ................ r10636 | olly | 2008-07-03 02:13:51 +0100 (Thu, 03 Jul 2008) | 2 lines Update wrt PHP4. ................ r10637 | olly | 2008-07-03 03:32:11 +0100 (Thu, 03 Jul 2008) | 4 lines [PHP] The deprecated command line option "-phpfull" has been removed. We recommend building your extension as a dynamically loadable module. ................ r10638 | olly | 2008-07-03 03:32:41 +0100 (Thu, 03 Jul 2008) | 2 lines Fix version number ................ r10639 | olly | 2008-07-03 07:04:24 +0100 (Thu, 03 Jul 2008) | 2 lines Make t_output_helper() static. ................ r10640 | olly | 2008-07-03 07:05:34 +0100 (Thu, 03 Jul 2008) | 2 lines Make testcase li_typemaps work for PHP. ................ r10641 | olly | 2008-07-03 10:12:16 +0100 (Thu, 03 Jul 2008) | 2 lines Fix check::classname() to compare case-insensitively and not try to interpolate objects into strings. ................ r10643 | olly | 2008-07-03 23:00:01 +0100 (Thu, 03 Jul 2008) | 4 lines The operator& trick in allowexcept.i doesn't work for SWIG/PHP because the generated code takes the address of the variable in the code in the "vinit" section. So comment out the private operator& for PHP. ................ r10647 | olly | 2008-07-04 00:55:33 +0100 (Fri, 04 Jul 2008) | 2 lines [PHP] The SWIG cdata.i library module is now supported. ................ r10649 | olly | 2008-07-04 02:02:22 +0100 (Fri, 04 Jul 2008) | 4 lines [PHP] The deprecated command line option "-make" has been removed. Searches on Google codesearch suggest that nobody is using it now anyway. ................ r10650 | olly | 2008-07-04 02:22:11 +0100 (Fri, 04 Jul 2008) | 4 lines [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() since "empty" is a PHP reserved word. Based of patch from Mark Klein in SF#1943417. ................ r10662 | wsfulton | 2008-07-14 22:09:23 +0100 (Mon, 14 Jul 2008) | 1 line Fix director typemaps for pointers so that NULL pointers are correctly marshalled to C#/Java null in director methods ................ r10672 | olly | 2008-07-17 02:17:08 +0100 (Thu, 17 Jul 2008) | 2 lines Fix a typo; improve wording. ................ r10676 | wsfulton | 2008-07-17 22:05:49 +0100 (Thu, 17 Jul 2008) | 1 line SF #2019156 Configuring with --without-octave or --without-alllang did not disable octave. ................ r10677 | wsfulton | 2008-07-17 22:08:22 +0100 (Thu, 17 Jul 2008) | 1 line tidy output after detecting X11 headers ................ r10682 | wsfulton | 2008-07-19 19:08:06 +0100 (Sat, 19 Jul 2008) | 1 line a bit more on pgcpp ................ r10683 | wsfulton | 2008-07-19 23:45:54 +0100 (Sat, 19 Jul 2008) | 1 line Fix building of Tcl examples/test-suite on Mac OSX ................ r10714 | olly | 2008-07-27 13:51:16 +0100 (Sun, 27 Jul 2008) | 2 lines Fix "can can" typo in docs (SF#2026756) ................ r10726 | wuzzeb | 2008-08-02 09:28:02 +0100 (Sat, 02 Aug 2008) | 1 line Commit patch 2019314 ................ r10727 | wuzzeb | 2008-08-02 09:49:43 +0100 (Sat, 02 Aug 2008) | 1 line add assert.h to fix chicken build of external runtime (ext_test testsuite) ................ r10738 | talby | 2008-08-07 07:28:13 +0100 (Thu, 07 Aug 2008) | 2 lines hoist globals to local scope where trival. ................ r10743 | talby | 2008-08-08 04:10:55 +0100 (Fri, 08 Aug 2008) | 2 lines initial steps to clean up perl5 class methods (primarily constructors). ................ r10747 | talby | 2008-08-09 05:08:26 +0100 (Sat, 09 Aug 2008) | 2 lines moves perl space constructor fixups into wrapper code. ................ r10749 | talby | 2008-08-10 00:57:55 +0100 (Sun, 10 Aug 2008) | 2 lines usage_func() fix + CHANGES.current entry to explain my past few commits. ................ r10794 | talby | 2008-08-19 08:09:29 +0100 (Tue, 19 Aug 2008) | 3 lines rollback 10737:10749, this work is better left on a branch until it is in support a significant feature enhancement. ................ r10801 | drjoe | 2008-08-31 17:07:43 +0100 (Sun, 31 Aug 2008) | 2 lines change Rf_warning to warning. Looks like a typo ................ r10802 | wsfulton | 2008-09-01 20:59:23 +0100 (Mon, 01 Sep 2008) | 1 line Fix ruby detection problem breaking configure ................ r10803 | wsfulton | 2008-09-01 21:00:28 +0100 (Mon, 01 Sep 2008) | 1 line Fix another perl global namespace pollution ................ r10804 | wsfulton | 2008-09-01 21:32:53 +0100 (Mon, 01 Sep 2008) | 1 line Fix array bounds checking in C# std::vector wrappers ................ r10805 | wsfulton | 2008-09-01 21:34:49 +0100 (Mon, 01 Sep 2008) | 1 line fix runtime problem in Ruby std_vector example ................ r10806 | wsfulton | 2008-09-01 21:42:40 +0100 (Mon, 01 Sep 2008) | 1 line Fix portability problem using /dev/null ................ r10807 | wsfulton | 2008-09-01 22:46:41 +0100 (Mon, 01 Sep 2008) | 1 line patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM ................ r10808 | wsfulton | 2008-09-02 21:56:52 +0100 (Tue, 02 Sep 2008) | 1 line Add new terminator attribute for the csin typemap for C# ................ r10809 | wsfulton | 2008-09-03 00:01:37 +0100 (Wed, 03 Sep 2008) | 1 line Fix #1988296 - Multiple module director linking issue ................ r10827 | richardb | 2008-09-10 11:08:21 +0100 (Wed, 10 Sep 2008) | 6 lines [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). ................ r10828 | bhy | 2008-09-10 11:45:33 +0100 (Wed, 10 Sep 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-10827" from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ r10829 | bhy | 2008-09-10 12:04:09 +0100 (Wed, 10 Sep 2008) | 4 lines Removed merge tracking for "svnmerge" for https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy (Undo the init due to user error) ................ r10830 | bhy | 2008-09-10 12:08:16 +0100 (Wed, 10 Sep 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-10403" from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ r10831 | bhy | 2008-09-10 12:51:12 +0100 (Wed, 10 Sep 2008) | 11 lines (Still trying to set right properity to get svnmerge work...) Recorded merge of revisions 10404 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ........ r10404 | bhy | 2008-05-01 08:35:49 +0800 (Thu, 01 May 2008) | 5 lines Start of gsoc2008-bhy branch. This is a branch for Haoyu Bai's Python 3.0 backend project. Some file already modified since a little of work already done when starting the branch. ........ ................ r10834 | bhy | 2008-09-11 18:18:07 +0100 (Thu, 11 Sep 2008) | 8 lines Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken. This is the (incomplemete) log produced by svnmerge.py: Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10837 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +- CHANGES | 159 +- CHANGES.current | 148 +- Doc/Manual/CSharp.html | 58 +- Doc/Manual/Contents.html | 3 +- Doc/Manual/Extending.html | 3 +- Doc/Manual/Java.html | 27 +- Doc/Manual/Php.html | 184 +- Doc/Manual/Python.html | 253 ++- Doc/Manual/SWIG.html | 16 +- Doc/Manual/SWIGPlus.html | 5 +- Doc/Manual/Sections.html | 2 +- Doc/Manual/Typemaps.html | 15 +- Doc/Manual/Warnings.html | 2 +- Examples/GIFPlot/Python/full/Makefile | 3 +- Examples/GIFPlot/Python/shadow/Makefile | 3 +- Examples/GIFPlot/Python/simple/Makefile | 3 +- Examples/Makefile.in | 77 +- Examples/guile/multimap/example.i | 4 +- Examples/guile/multivalue/example.i | 6 + Examples/lua/arrays/example.c | 2 +- Examples/lua/embed2/embed2.c | 13 +- Examples/lua/embed3/embed3.cpp | 14 +- Examples/lua/owner/example.cxx | 4 +- Examples/perl5/import/base.h | 2 +- Examples/perl5/multiple_inheritance/example.h | 23 +- Examples/php4/reference/BUILD-proxy.sh | 5 - Examples/python/callback/Makefile | 1 + Examples/python/class/Makefile | 1 + Examples/python/constants/Makefile | 1 + Examples/python/contract/Makefile | 1 + Examples/python/docstrings/Makefile | 1 + Examples/python/enum/Makefile | 1 + Examples/python/exception/Makefile | 1 + Examples/python/exceptproxy/Makefile | 1 + Examples/python/extend/Makefile | 1 + Examples/python/funcptr/Makefile | 1 + Examples/python/funcptr2/Makefile | 1 + Examples/python/functor/Makefile | 1 + Examples/python/import/Makefile | 1 + Examples/python/import_template/Makefile | 1 + Examples/python/libffi/Makefile | 1 + Examples/python/multimap/Makefile | 1 + Examples/python/multimap/example.i | 32 +- Examples/python/operator/Makefile | 1 + Examples/python/pointer/Makefile | 1 + Examples/python/reference/Makefile | 1 + Examples/python/simple/Makefile | 1 + Examples/python/smartptr/Makefile | 1 + Examples/python/std_map/Makefile | 1 + Examples/python/std_vector/Makefile | 1 + Examples/python/swigrun/Makefile | 1 + Examples/python/template/Makefile | 1 + Examples/python/varargs/Makefile | 1 + Examples/python/variables/Makefile | 1 + Examples/python/weave/Makefile | 1 + Examples/ruby/class/example.dsp | 4 +- Examples/ruby/free_function/example.cxx | 2 +- Examples/ruby/free_function/example.dsp | 4 +- Examples/ruby/import/bar.dsp | 4 +- Examples/ruby/import/base.dsp | 4 +- Examples/ruby/import/foo.dsp | 4 +- Examples/ruby/import/spam.dsp | 4 +- Examples/ruby/mark_function/example.dsp | 4 +- Examples/ruby/std_vector/runme.rb | 8 +- Examples/tcl/import/base.h | 2 +- Examples/test-suite/abstract_virtual.i | 4 +- Examples/test-suite/allowexcept.i | 14 +- Examples/test-suite/apply_signed_char.i | 2 + Examples/test-suite/bools.i | 2 + Examples/test-suite/char_strings.i | 2 +- Examples/test-suite/chicken/Makefile.in | 12 +- Examples/test-suite/common.mk | 3 + Examples/test-suite/constant_pointers.i | 6 + Examples/test-suite/contract.i | 2 +- Examples/test-suite/cpp_basic.i | 2 + Examples/test-suite/csharp/Makefile.in | 4 +- .../test-suite/csharp/char_strings_runme.cs | 2 +- .../test-suite/csharp/director_basic_runme.cs | 74 + Examples/test-suite/csharp_prepost.i | 101 +- Examples/test-suite/default_constructor.i | 4 +- Examples/test-suite/director_basic.i | 6 +- Examples/test-suite/enum_thorough.i | 2 + Examples/test-suite/evil_diamond.i | 2 +- Examples/test-suite/evil_diamond_ns.i | 2 +- Examples/test-suite/evil_diamond_prop.i | 2 +- Examples/test-suite/fvirtual.i | 4 +- Examples/test-suite/guilescm/Makefile.in | 8 +- Examples/test-suite/java/Makefile.in | 4 +- .../test-suite/java/char_strings_runme.java | 2 +- .../test-suite/java/director_basic_runme.java | 57 +- Examples/test-suite/java_typemaps_proxy.i | 2 + Examples/test-suite/keyword_rename.i | 32 + Examples/test-suite/li_cstring.i | 8 +- Examples/test-suite/li_cwstring.i | 8 +- Examples/test-suite/li_std_string.i | 2 +- Examples/test-suite/lua/li_typemaps_runme.lua | 40 + Examples/test-suite/minherit.i | 2 +- Examples/test-suite/minherit2.i | 2 +- Examples/test-suite/multiple_inheritance.i | 4 +- Examples/test-suite/name_warnings.i | 3 +- Examples/test-suite/namespace_typemap.i | 2 +- Examples/test-suite/octave/fvirtual_runme.m | 2 +- .../test-suite/octave/li_std_string_runme.m | 2 +- Examples/test-suite/operbool.i | 10 + .../test-suite/perl5/li_std_string_runme.pl | 4 +- .../test-suite/perl5/li_typemaps_runme.pl | 39 +- Examples/test-suite/perl5/run-perl-test.pl | 2 +- Examples/test-suite/php4/Makefile.in | 6 +- Examples/test-suite/php4/tests.php4 | 2 +- Examples/test-suite/pure_virtual.i | 2 +- Examples/test-suite/python/Makefile.in | 67 +- Examples/test-suite/python/README | 6 +- Examples/test-suite/python/abstractbase.i | 18 + .../test-suite/python/abstractbase_runme3.py | 8 + .../test-suite/python/cpp_namespace_runme.py | 20 +- .../python/director_classic_runme.py | 68 +- .../python/director_exception_runme.py | 50 +- Examples/test-suite/python/file_test_runme.py | 3 +- Examples/test-suite/python/fvirtual_runme.py | 2 +- Examples/test-suite/python/hugemod.pl | 8 +- .../test-suite/python/keyword_rename_runme.py | 4 + .../test-suite/python/li_std_string_runme.py | 2 +- Examples/test-suite/python/operbool_runme.py | 4 + Examples/test-suite/python/pybuf.i | 34 + Examples/test-suite/python/pybuf_benchmark.i | 31 + .../python/pybuf_benchmark_runme.py | 16 + .../python/pybuf_benchmark_runme3.py | 16 + Examples/test-suite/python/pybuf_runme3.py | 15 + .../python/template_typedef_cplx2_runme.py | 13 +- .../python/template_typedef_cplx_runme.py | 13 +- Examples/test-suite/r/Makefile.in | 4 +- .../test-suite/ruby/li_std_string_runme.rb | 2 +- Examples/test-suite/samename.i | 13 +- .../test-suite/template_inherit_abstract.i | 2 +- Examples/test-suite/template_int_const.i | 8 +- Examples/test-suite/template_typedef_rec.i | 6 +- Examples/test-suite/typemap_namespace.i | 2 +- Examples/test-suite/using_composition.i | 6 +- Examples/test-suite/using_extend.i | 2 +- Examples/test-suite/using_namespace.i | 2 +- Lib/allegrocl/allegrocl.swg | 80 +- Lib/cdata.i | 9 +- Lib/cffi/cffi.swg | 7 +- Lib/chicken/chicken.swg | 1 + Lib/chicken/chickenkw.swg | 2 +- Lib/chicken/chickenrun.swg | 1 + Lib/csharp/csharp.swg | 3 +- Lib/csharp/csharphead.swg | 4 +- Lib/csharp/csharpkw.swg | 2 +- Lib/csharp/std_vector.i | 4 +- Lib/java/director.swg | 10 +- Lib/java/java.swg | 3 +- Lib/java/javakw.swg | 2 +- Lib/java/various.i | 2 +- Lib/lua/luatypemaps.swg | 4 +- Lib/lua/typemaps.i | 21 + Lib/ocaml/ocamlkw.swg | 2 +- Lib/perl5/noembed.h | 4 + Lib/perl5/perlkw.swg | 4 +- Lib/{php4 => php}/const.i | 0 Lib/{php4 => php}/globalvar.i | 0 Lib/{php4/php4.swg => php/php.swg} | 17 +- Lib/{php4/php4init.swg => php/phpinit.swg} | 0 Lib/{php4/php4kw.swg => php/phpkw.swg} | 14 +- Lib/{php4 => php}/phppointers.i | 0 Lib/{php4/php4run.swg => php/phprun.swg} | 4 +- Lib/{php4 => php}/std_common.i | 0 Lib/{php4 => php}/std_deque.i | 0 Lib/{php4 => php}/std_map.i | 4 + Lib/{php4 => php}/std_pair.i | 0 Lib/{php4 => php}/std_string.i | 0 Lib/{php4 => php}/std_vector.i | 2 + Lib/{php4 => php}/stl.i | 0 Lib/{php4 => php}/typemaps.i | 21 + Lib/{php4 => php}/utils.i | 4 +- Lib/pike/pikekw.swg | 2 +- Lib/python/director.swg | 9 +- Lib/python/file.i | 4 +- Lib/python/pyabc.i | 10 + Lib/python/pyapi.swg | 14 + Lib/python/pybuffer.i | 107 ++ Lib/python/pycontainer.swg | 65 +- Lib/python/pyerrors.swg | 6 +- Lib/python/pyhead.swg | 44 + Lib/python/pyinit.swg | 68 +- Lib/python/pyiterators.swg | 14 +- Lib/python/pyopers.swg | 6 + Lib/python/pyrun.swg | 113 +- Lib/python/pystrings.swg | 20 +- Lib/python/pythonkw.swg | 4 +- Lib/python/pywstrings.swg | 2 + Lib/python/std_map.i | 4 + Lib/r/r.swg | 4 +- Lib/r/rkw.swg | 32 + Lib/ruby/rubycontainer.swg | 6 +- Lib/ruby/rubykw.swg | 2 +- Lib/swiglabels.swg | 6 + Lib/typemaps/primtypes.swg | 1 + README | 9 +- Source/CParse/cscanner.c | 52 +- Source/CParse/parser.y | 37 +- Source/CParse/templ.c | 27 +- Source/DOH/hash.c | 31 +- Source/Include/swigwarn.h | 13 +- Source/Makefile.am | 2 +- Source/Modules/allegrocl.cxx | 61 +- Source/Modules/cffi.cxx | 6 +- Source/Modules/chicken.cxx | 13 +- Source/Modules/csharp.cxx | 92 +- Source/Modules/guile.cxx | 2 +- Source/Modules/java.cxx | 35 +- Source/Modules/lang.cxx | 61 +- Source/Modules/lua.cxx | 4 - Source/Modules/main.cxx | 10 +- Source/Modules/modula3.cxx | 4 +- Source/Modules/ocaml.cxx | 82 +- Source/Modules/{php4.cxx => php.cxx} | 944 ++-------- Source/Modules/python.cxx | 527 ++++-- Source/Modules/r.cxx | 17 +- Source/Modules/ruby.cxx | 10 +- Source/Modules/swigmain.cxx | 4 +- Source/Modules/uffi.cxx | 11 +- Source/Preprocessor/cpp.c | 5 +- Source/Swig/cwrap.c | 3 +- Source/Swig/include.c | 3 +- Source/Swig/misc.c | 23 +- Source/Swig/naming.c | 6 +- Source/Swig/scanner.c | 4 +- Source/Swig/typeobj.c | 3 +- Source/Swig/typesys.c | 17 +- TODO | 2 +- Tools/WAD/Python/type.c | 2 +- Tools/config/config.guess | 1516 --------------- Tools/config/config.sub | 1626 ----------------- Tools/mkrelease.py | 8 +- configure.in | 145 +- 237 files changed, 3218 insertions(+), 5059 deletions(-) delete mode 100755 Examples/php4/reference/BUILD-proxy.sh create mode 100644 Examples/test-suite/csharp/director_basic_runme.cs create mode 100644 Examples/test-suite/keyword_rename.i create mode 100644 Examples/test-suite/lua/li_typemaps_runme.lua create mode 100644 Examples/test-suite/operbool.i create mode 100644 Examples/test-suite/python/abstractbase.i create mode 100644 Examples/test-suite/python/abstractbase_runme3.py create mode 100644 Examples/test-suite/python/keyword_rename_runme.py create mode 100644 Examples/test-suite/python/operbool_runme.py create mode 100644 Examples/test-suite/python/pybuf.i create mode 100644 Examples/test-suite/python/pybuf_benchmark.i create mode 100644 Examples/test-suite/python/pybuf_benchmark_runme.py create mode 100644 Examples/test-suite/python/pybuf_benchmark_runme3.py create mode 100644 Examples/test-suite/python/pybuf_runme3.py rename Lib/{php4 => php}/const.i (100%) rename Lib/{php4 => php}/globalvar.i (100%) rename Lib/{php4/php4.swg => php/php.swg} (96%) rename Lib/{php4/php4init.swg => php/phpinit.swg} (100%) rename Lib/{php4/php4kw.swg => php/phpkw.swg} (93%) rename Lib/{php4 => php}/phppointers.i (100%) rename Lib/{php4/php4run.swg => php/phprun.swg} (99%) rename Lib/{php4 => php}/std_common.i (100%) rename Lib/{php4 => php}/std_deque.i (100%) rename Lib/{php4 => php}/std_map.i (97%) rename Lib/{php4 => php}/std_pair.i (100%) rename Lib/{php4 => php}/std_string.i (100%) rename Lib/{php4 => php}/std_vector.i (98%) rename Lib/{php4 => php}/stl.i (100%) rename Lib/{php4 => php}/typemaps.i (85%) rename Lib/{php4 => php}/utils.i (96%) create mode 100644 Lib/python/pyabc.i create mode 100644 Lib/python/pybuffer.i create mode 100644 Lib/r/rkw.swg rename Source/Modules/{php4.cxx => php.cxx} (64%) delete mode 100755 Tools/config/config.guess delete mode 100755 Tools/config/config.sub diff --git a/ANNOUNCE b/ANNOUNCE index 0fb688344..7c0e95e3f 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.35 (7 April 2008) *** +*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) *** http://www.swig.org -We're pleased to announce SWIG-1.3.35, the latest installment in the -SWIG development effort. SWIG-1.3.35 includes a number of bug fixes +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,11 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.35.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.35.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip Release numbers --------------- diff --git a/CHANGES b/CHANGES index fc3018a1d..782849c6f 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,162 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.36 (24 June 2008) +============================= + +06/24/2008: wsfulton + Remove deprecated -c commandline option (runtime library generation). + +06/24/2008: olly + [PHP] Fix assertion failure when handling %typemap(in,numinputs=0) + (testcase ignore_parameter). + +06/24/2008: olly + [PHP] Fix segfault when wrapping a non-class function marked with + %newobject (testcase char_strings). + +06/22/2008: wsfulton + [Java] Add a way to use AttachCurrentThreadAsDaemon instead of AttachCurrentThread + in director code. Define the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro, see + Lib/java/director.swg. + +06/21/2008: wsfulton + [Ruby] Fix crashing in the STL wrappers (reject! and delete_if methods) + +06/19/2008: wsfulton + [Java, C#] C# and Java keywords will be renamed instead of just issuing a warning + and then generating uncompileable code. Warning 314 gives the new name when a + keyword is found. + +06/19/2008: wsfulton + [R] Keyword handling added. R Keywords will be renamed as necessary. + Warning 314 gives the new name when a keyword is found. + +06/17/2008: mgossage + [Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase. + (Bug #1938142) + +06/07/2008: bhy + Added test case keyword_rename, then made the keyword renaming works properly + by fixing Swig_name_make() for a incomplete condition checking. + +06/02/2008: wsfulton + [Java, C#] Fix enum wrappers when using -noproxy. + +05/30/2008: bhy + Added std::wstring into Lib/typemaps/primtypes.swg, since it is also a primitive + type in SWIG - fixed SF #1976978. + +05/29/2008: wsfulton + [Java, C#] Fix variable wrappers when using -noproxy. + +05/29/2008: bhy + [Python] Fixed a typo of %#ifdef in Lib/python/pycontainer.swg, which is related + to -extranative SWIG option - SF #1971977. + +05/20/2008: wsfulton + New partialcheck makefile targets for partial testing of the test-suite. These + just invoke SWIG, ie no compilation and no runtime testing. It can be faster + when developing by just doing a directory diff of the files SWIG generates + against those from a previous run. Example usage from the top level directory: + + make partialcheck-test-suite + make partialcheck-java-test-suite + + This change also encompasses more flexibility in running the test-suite, eg + it is possible to prefix the command line which runs any target language test + with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk + file and makefiles in the test-suite directory. For example it is possible to + run the runtime tests through valgrind using: + + make check RUNTOOL="valgrind --leak-check=full" + + or invoke SWIG under valgrind using: + + make check SWIGTOOL="valgrind --tool=memcheck" + +05/19/2008: drjoe + [R] Fixed define that was breaking pre-2.7. Checked in + patch from Soren Sonnenburg that creates strings in + version independent way + +05/15/2008: wsfulton + [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. + +05/14/2008: wsfulton + Add an optimisation for functions that return objects by value, reducing + the number of copies of the object that are made. Implemented using an + optional attribute in the "out" typemap called "optimal". Details in + Typemaps.html. + +05/11/2008: olly + [PHP] Check for %feature("notabstract") when generating PHP5 class + wrapper. + +05/11/2008: wsfulton + Fix SF #1943608 - $self substitution in %contract, patch submitted by + Toon Verstraelen. + +05/09/2008: olly + [PHP] Fix char * typemaps to work when applied to signed char * and + unsigned char * (uncovered by testcase apply_strings). + +05/09/2008: wsfulton + Fix wrapping of char * member variables when using allprotected mode. + Bug reported by Warren Wang. + +05/09/2008: olly + [PHP] Fix bad PHP code generated when wrapping an enum in a + namespace (uncovered by testcase arrays_scope). + +05/09/2008: olly + [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 + is essentially obsolete now, so we care much more about solid PHP5 + support. + +05/07/2008: wsfulton + STL fixes when using %import rather than %include and the Solaris Workshop + compiler and the Roguewave STL. + +05/07/2008: wsfulton + Fix wrapping of overloaded protected methods when using allprotected mode. + Bug reported by Warren Wang. + +05/03/2008: wsfulton + Commit patch #1956607 to add -MT support from Richard Boulton. + This patch mirrors the gcc -MT option which allows one to change the default + Makefile target being generated when generating makefiles with the -M family + of options. For example: + + $ swig -java -MM -MT overiddenname -c++ example.i + overiddenname: \ + example.i \ + example.h + +04/30/2008: mgossage + [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) + which was unused and causing warning with g++ -Wall. + Removed other unused warning in typemaps.i and other places. + Added Examples/lua/embed3, and run tests a few test cases. + +04/24/2008: olly + [Python] Fix generated code for IBM's C++ compiler on AIX (patch + from Goeran Uddeborg in SF#1928048). + +04/24/2008: olly + Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to + avoid a clash with BSIZE defined by headers on AIX with Perl + (reported in SF#1928048). + +04/20/2008: wsfulton + Add the ability to wrap all protected members when using directors. + Previously only the virtual methods were available to the target language. + Now all protected members, (static and non-static variables, non-virtual methods + and static methods) are wrapped when using the allprotected mode. The allprotected + mode is turned on in the module declaration: + + %module(directors="1", allprotected="1") modulename + Version 1.3.35 (7 April 2008) ============================= @@ -12123,7 +12279,8 @@ Version 1.3.14 (August 12, 2002) with helper functions even if they aren't used. To fix this, a new fragment directive is available. For example: - %fragment("type_helper","header") %{ + (corrected typo in line below - 06/26/2008) + %fragment("type_header","header") %{ void some_helper_function() { ... } diff --git a/CHANGES.current b/CHANGES.current index 27e9925d2..6b552c994 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,106 +1,80 @@ -Version 1.3.36 (in progress) +Version 1.3.37 (in progress) ============================= -05/20/2008: wsfulton - New partialcheck makefile targets for partial testing of the test-suite. These - just invoke SWIG, ie no compilation and no runtime testing. It can be faster - when developing by just doing a directory diff of the files SWIG generates - against those from a previous run. Example usage from the top level directory: +2008-09-02: wsfulton + [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). - make partialcheck-test-suite - make partialcheck-java-test-suite +2008-09-02: wsfulton + [Python] Commit patch #1988296 GCItem multiple module linking issue when using + directors. - This change also encompasses more flexibility in running the test-suite, eg - it is possible to prefix the command line which runs any target language test - with a tool. See the RUNTOOL, COMPILETOOL and SWIGTOOL targets in the common.mk - file and makefiles in the test-suite directory. For example it is possible to - run the runtime tests through valgrind using: +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 - make check RUNTOOL="valgrind --leak-check=full" + %typemap(csin, + pre=" using (CDate temp$csinput = new CDate($csinput)) {", + terminator=" } // terminate temp$csinput using block", + ) const CDate & + "$csclassname.getCPtr(temp$csinput)" - or invoke SWIG under valgrind using: + See CSharp.html for more info. - make check SWIGTOOL="valgrind --tool=memcheck" +2008-09-01: wsfulton + [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into + no-eval context in DEFCENUM -05/19/2008: drjoe - [R] Fixed define that was breaking pre-2.7. Checked in - patch from Soren Sonnenburg that creates strings in - version independent way +2008-09-01: wsfulton + [C#] Correct array bounds checking in std::vector typemaps - Insert and InsertRange + methods. -05/15/2008: wsfulton - [Java] Fix variable name clash in directors - SF #1963316 reported by Tristan. +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 -05/14/2008: wsfulton - Add an optimisation for functions that return objects by value, reducing - the number of copies of the object that are made. Implemented using an - optional attribute in the "out" typemap called "optimal". Details in - Typemaps.html. +2008-07-19: wsfulton + Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. -05/11/2008: olly - [PHP] Check for %feature("notabstract") when generating PHP5 class - wrapper. +2008-07-17: wsfulton + Fix SF #2019156 Configuring with --without-octave or --without-alllang + did not disable octave. -05/11/2008: wsfulton - Fix SF #1943608 - $self substitution in %contract, patch submitted by - Toon Verstraelen. +2008-07-14: wsfultonn + [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly + marshalled to C#/Java null in director methods. -05/09/2008: olly - [PHP] Fix char * typemaps to work when applied to signed char * and - unsigned char * (uncovered by testcase apply_strings). +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. -05/09/2008: wsfulton - Fix wrapping of char * member variables when using allprotected mode. - Bug reported by Warren Wang. +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. -05/09/2008: olly - [PHP] Fix bad PHP code generated when wrapping an enum in a - namespace (uncovered by testcase arrays_scope). +2008-07-04: olly + [PHP] The SWIG cdata.i library module is now supported. -05/09/2008: olly - [PHP] SWIG now runs the PHP testsuite using PHP5, not PHP4. PHP4 - is essentially obsolete now, so we care much more about solid PHP5 - support. +2008-07-03: olly + [PHP] The deprecated command line option "-phpfull" has been + removed. We recommend building your extension as a dynamically + loadable module. -05/07/2008: wsfulton - STL fixes when using %import rather than %include and the Solaris Workshop - compiler and the Roguewave STL. +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. -05/07/2008: wsfulton - Fix wrapping of overloaded protected methods when using allprotected mode. - Bug reported by Warren Wang. - -05/03/2008: wsfulton - Commit patch #1956607 to add -MT support from Richard Boulton. - This patch mirrors the gcc -MT option which allows one to change the default - Makefile target being generated when generating makefiles with the -M family - of options. For example: - - $ swig -java -MM -MT overiddenname -c++ example.i - overiddenname: \ - example.i \ - example.h - -04/30/2008: mgossage - [Lua] Removed generation of _wrap_delete_XXXXX (wrappered destructor) - which was unused and causing warning with g++ -Wall. - Removed other unused warning in typemaps.i and other places. - Added Examples/lua/embed3, and run tests a few test cases. - -04/24/2008: olly - [Python] Fix generated code for IBM's C++ compiler on AIX (patch - from Goeran Uddeborg in SF#1928048). - -04/24/2008: olly - Rename BSIZE in Examples/test-suite/arrays_scope.i to BBSIZE to - avoid a clash with BSIZE defined by headers on AIX with Perl - (reported in SF#1928048). - -04/20/2008: wsfulton - Add the ability to wrap all protected members when using directors. - Previously only the virtual methods were available to the target language. - Now all protected members, (static and non-static variables, non-virtual methods - and static methods) are wrapped when using the allprotected mode. The allprotected - mode is turned on in the module declaration: - - %module(directors="1", allprotected="1") modulename +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. diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 97cb75409..a712f82f2 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1567,6 +1567,7 @@ 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();
    @@ -1649,8 +1650,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"
    @@ -1658,7 +1659,8 @@ 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)"
     
     
    @@ -1763,7 +1765,8 @@ 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)"
@@ -1788,6 +1791,50 @@ 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
+  }
+  ...
+}
+
+
+

17.5.4 A date example demonstrating marshalling of C# properties

@@ -1827,7 +1874,8 @@ 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 * %{ diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 9d6e4e66f..d385fec9f 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -380,7 +380,7 @@
  • Typemaps for multiple languages
  • Optimal code generation when returning by value -
  • Multi-argument typemaps +
  • Multi-argument typemaps
  • The run-time type checker
  • Accessing protected members
  • Common customization features diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 588912b68..5639663a1 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -448,7 +448,8 @@ 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 -dump_tree. +the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is +the stage being processed. 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. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 88963caf5..518426f5a 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -85,6 +85,7 @@

  • Director classes
  • Overhead and code bloat
  • Simple directors example +
  • Director threading issues
  • Accessing protected members
  • Common customization features @@ -2856,7 +2857,11 @@ 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 additional parameters do impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. +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. 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: @@ -3450,6 +3455,26 @@ DirectorDerived::upcall_method() invoked. +

    20.5.5 Director threading issues

    + + +

    +Depending on your operating system and version of Java and how you are using threads, you might find the JVM hangs on exit. +There are a couple of solutions to try out. The preferred solution requires jdk-1.4 and later and uses AttachCurrentThreadAsDaemon instead of AttachCurrentThread whenever a call into the JVM is required. This can be enabled by defining the SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON macro when compiling the C++ wrapper code. For older JVMs define SWIG_JAVA_NO_DETACH_CURRENT_THREAD instead, to avoid the DetachCurrentThread call but this will result in a memory leak instead. For further details inspect the source code in the java/director.swg library file. +

    + +

    +Macros can be defined on the commandline when compiling your C++ code, or alternatively added to the C++ wrapper file as shown below: +

    + +
    +
    +%insert("runtime") %{
    +#define SWIG_JAVA_NO_DETACH_CURRENT_THREAD
    +%}
    +
    +
    +

    20.6 Accessing protected members

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 6b654fde5..8adbc36b1 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -43,21 +43,24 @@ 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 although it is -significantly more functional, it still does not implement all the +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 features available in some of the other languages.

    -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 +In order to use this module, you will need to have a copy of the 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 @@ -88,7 +91,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 for PHP5, it will +in the interface file. If wrapping C++ code with PHP classes, it will also contain PHP5 class wrappers.

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

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

    @@ -110,17 +114,15 @@ 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, but if you really want to do this, the -phpfull -command line argument to swig may be of use - see below for details. +this approach, or provide explicit support for it.

    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 so variation between platforms - these commands should at +and there may be some variation between platforms - these commands should at least work for Linux though):

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

    -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

    -

    To test the extension from a PHP script, you need to load it first. You can load it for every script by adding this line the [PHP] section of @@ -717,20 +590,9 @@ variable, or assigning NULL to a variable.

    -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 +SWIG defaults to wrapping C++ structs and classes with PHP classes +unless "-noproxy" is specified. 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.

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

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

    @@ -854,9 +716,9 @@ the programmer can either reassign the variable or call
     
     
     

    -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 +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 wrapped using a class function with the same name, which returns the current value of the class variable. For example

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 62b72fabf..c0b71b52d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -46,7 +46,7 @@
  • Memory management
  • Python 2.2 and classic classes -
  • Cross language polymorphism +
  • Cross language polymorphism
  • Python Packages +
  • Python 3 Support +
  • @@ -113,9 +119,9 @@

    This chapter describes SWIG's support of Python. SWIG is compatible -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. +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.

    @@ -2544,7 +2550,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).

    -

    30.5 Cross language polymorphism

    +

    30.5 Cross language polymorphism

    @@ -4929,7 +4935,7 @@ with more than one line.

    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.

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

    +

    30.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. +

    + +

    30.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" : ...
    +
    + +

    +For details of usage of function annotation, see PEP 3107. +

    + +

    30.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. +

    + +
    + + +

    30.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/SWIG.html b/Doc/Manual/SWIG.html index c22d81c07..c1ffcff60 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 @@ -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 can +specific files is the same directory as the generated C/C++ file. This can be modified using the -outdir option. For example:

    @@ -2219,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

    @@ -2282,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

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index faf0b254c..ef7487ff8 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -1153,8 +1153,9 @@ public:

    -This is great for reducing the size of the wrappers, but the caveat is it does not work for the strongly typed languages -which don't have optional arguments in the language, such as C# and Java. +This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, +such as C# and Java, +which don't have optional arguments in the language, Another restriction of this feature is that it cannot handle default arguments that are not public. The following example illustrates this:

    diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index b7b4798e7..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.36 (in progress) +Last update : SWIG-1.3.37 (in progress)

    Sections

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index e07f9f87e..8f3035dc8 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -65,7 +65,7 @@
  • Typemaps for multiple languages
  • Optimal code generation when returning by value -
  • Multi-argument typemaps +
  • Multi-argument typemaps
  • The run-time type checker
    • Implementation @@ -702,7 +702,7 @@ variables (parms). The purpose of these variables will be explained shortly.

      code specifies the code used in the typemap. -Usually this is C/C++ code, but in the strongly typed target languages, such as Java and C#, this can contain target language code for certain typemaps. +Usually this is C/C++ code, but in the statically typed target languages, such as Java and C#, this can contain target language code for certain typemaps. It can take any one of the following forms:

      @@ -1933,7 +1933,7 @@ to implement customized conversions.

      In addition, the "in" typemap allows the number of converted arguments to be -specified. For example: +specified. The numinputs attributes facilitates this. For example:

      @@ -1946,7 +1946,12 @@ specified. For example:

      -At this time, only zero or one arguments may be converted. +At this time, only zero or one arguments may be converted. +When numinputs is set to 0, the argument is effectively ignored and cannot be supplied from the target language. +The argument is still required when making the C/C++ call and the above typemap +shows the value used is instead obtained from a locally declared variable called temp. +Usually numinputs is not specified, whereupon the default value is 1, that is, there is a one to one mapping of the number of arguments when used from the target language to the C/C++ call. +Multi-argument typemaps provide a similar concept where the number of arguments mapped from the target language to C/C++ can be changed for more tha multiple adjacent C/C++ arguments.

      @@ -2811,7 +2816,7 @@ optimal attribute usage in the out typemap at example.i:7. However, it doesn't always get it right, for example when $1 is within some commented out code.

      -

      10.9 Multi-argument typemaps

      +

      10.9 Multi-argument typemaps

      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 39d5d3f01..0b3cb37e9 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -373,7 +373,7 @@ example.i(4): Syntax error in input.

    • 117. Deprecated %new directive.
    • 118. Deprecated %typemap(except).
    • 119. Deprecated %typemap(ignore). -
    • 120. Deprecated command line option (-c). +
    • 120. Deprecated command line option (-runtime, -noruntime).
    • 121. Deprecated %name directive.
    diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile index ae927b72b..83a7c864b 100644 --- a/Examples/GIFPlot/Python/full/Makefile +++ b/Examples/GIFPlot/Python/full/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = -I../../Include SRCS = TARGET = gifplot @@ -23,3 +23,4 @@ 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 1f5014895..73fca9673 100644 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = -I../../Interface SRCS = TARGET = gifplot @@ -23,3 +23,4 @@ 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 5eb0344e8..9fc9a6c72 100644 --- a/Examples/GIFPlot/Python/simple/Makefile +++ b/Examples/GIFPlot/Python/simple/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = SRCS = TARGET = simple @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 0bf9f6767..f85075906 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -40,8 +40,9 @@ LIBCRYPT = @LIBCRYPT@ SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT) LIBPREFIX = -# RUNTOOL is for use as with runtime tools, eg set it to valgrind +# RUNTOOL is for use with runtime tools, eg set it to valgrind RUNTOOL = +# COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= # X11 options @@ -94,9 +95,9 @@ TK_OPTS = -ltk -ltcl @LIBS@ # Extra Tcl specific dynamic linking options TCL_DLNK = @TCLDYNAMICLINKING@ -TCL_LDSHARED = @TCL_LDSHARED@ -TCL_CXXSHARED = @TCL_CXXSHARED@ TCL_SO = @TCL_SO@ +TCLLDSHARED = @TCLLDSHARED@ +TCLCXXSHARED = @TCLCXXSHARED@ # ----------------------------------------------------------- # Build a new version of the tclsh shell @@ -135,7 +136,7 @@ wish_cpp: $(SRCS) tcl: $(SRCS) $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCL_LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ @@ -144,7 +145,7 @@ tcl: $(SRCS) tcl_cpp: $(SRCS) $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCL_CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------------- # Cleaning the Tcl examples @@ -222,19 +223,39 @@ perl5_clean: ################################################################## # Make sure these locate your Python installation -PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ -PYTHON_LIB = @PYLIB@ +ifeq (,$(PY3)) + PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ + PYTHON_LIB = @PYLIB@ + PYTHON = @PYTHON@ +else + PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ + PYTHON_LIB = @PY3LIB@ + PYTHON = @PYTHON3@ +endif -# Extra Python specific dynamic linking options -PYTHON_DLNK = @PYTHONDYNAMICLINKING@ +# Extra Python specific linking options +ifeq (,$(PY3)) + PYTHON_DLNK = @PYTHONDYNAMICLINKING@ + PYTHON_LINK = @PYLINK@ +else + PYTHON_DLNK = @PYTHON3DYNAMICLINKING@ + PYTHON_LINK = @PY3LINK@ +endif 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) - $(SWIG) -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -243,7 +264,7 @@ python: $(SRCS) # ----------------------------------------------------------------- python_cpp: $(SRCS) - $(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ $(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) @@ -256,18 +277,37 @@ python_cpp: $(SRCS) #TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11 TKINTER = -PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS) +PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCS) - $(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) - $(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ -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)) + SCRIPT = runme.py +else + SCRIPT = runme3.py +endif + +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + +python_run: $(SCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(SCRIPT) >/dev/null + +runme3.py: runme.py + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -277,6 +317,7 @@ python_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ + ################################################################## ##### OCTAVE ###### ################################################################## @@ -880,11 +921,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) chicken: $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) - $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) + $(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) $(INTERFACE) - $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) + $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) @@ -1078,11 +1119,11 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACE) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE) - +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: rm -f *_wrap* *~ .~* diff --git a/Examples/guile/multimap/example.i b/Examples/guile/multimap/example.i index a1cc0bb67..7337d1e9e 100644 --- a/Examples/guile/multimap/example.i +++ b/Examples/guile/multimap/example.i @@ -20,7 +20,7 @@ extern int gcd(int x, int y); SCM *v; if (!(SCM_NIMP($input) && SCM_VECTORP($input))) { SWIG_exception(SWIG_ValueError, "Expecting a vector"); - return; + return 0; } $1 = SCM_LENGTH($input); if ($1 == 0) { @@ -32,7 +32,7 @@ extern int gcd(int x, int y); if (!(SCM_NIMP(v[i]) && SCM_STRINGP(v[i]))) { free($2); SWIG_exception(SWIG_ValueError, "Vector items must be strings"); - return; + return 0; } $2[i] = SCM_CHARS(v[i]); } diff --git a/Examples/guile/multivalue/example.i b/Examples/guile/multivalue/example.i index abc2a6fbc..135389487 100644 --- a/Examples/guile/multivalue/example.i +++ b/Examples/guile/multivalue/example.i @@ -2,6 +2,12 @@ %module example; +%{ +void divide_l(int a, int b, int *quotient_p, int *remainder_p); +void divide_v(int a, int b, int *quotient_p, int *remainder_p); +void divide_mv(int a, int b, int *quotient_p, int *remainder_p); +%} + /* Multiple values as lists. By default, if more than one value is to be returned, a list of the values is created and returned; to switch back to this behavior, use: */ diff --git a/Examples/lua/arrays/example.c b/Examples/lua/arrays/example.c index 40ed12c79..56c7b19d9 100644 --- a/Examples/lua/arrays/example.c +++ b/Examples/lua/arrays/example.c @@ -16,7 +16,7 @@ void sort_int(int* arr, int len) // ditto doubles int compare_double(const void * a, const void * b) { - return ( *(double*)a - *(double*)b ); + return (int)( *(double*)a - *(double*)b ); } void sort_double(double* arr, int len) diff --git a/Examples/lua/embed2/embed2.c b/Examples/lua/embed2/embed2.c index 07b7a44d2..dac527eb4 100644 --- a/Examples/lua/embed2/embed2.c +++ b/Examples/lua/embed2/embed2.c @@ -11,6 +11,17 @@ We will be using the luaL_dostring()/lua_dostring() function to call into lua */ +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + #include #include @@ -108,7 +119,7 @@ int call_va (lua_State *L,const char *func, const char *sig, ...) { endwhile: /* do the call */ - nres = strlen(sig); /* number of expected results */ + nres = (int)strlen(sig); /* number of expected results */ if (lua_pcall(L, narg, nres, 0) != 0) /* do the call */ { printf("error running function `%s': %s\n",func, lua_tostring(L, -1)); diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index e42401cda..c2424f9af 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -5,6 +5,17 @@ passing C++ objects to this function. */ +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + #include #include #include @@ -70,9 +81,6 @@ int call_onEvent(lua_State *L, Event e) { int main(int argc, char* argv[]) { - int ok; - int res; - char str[80]; printf("[C++] Welcome to the simple embedded Lua example v3\n"); printf("[C++] We are in C++\n"); printf("[C++] opening a Lua state & loading the libraries\n"); diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx index 6e4091327..d6caeef15 100644 --- a/Examples/lua/owner/example.cxx +++ b/Examples/lua/owner/example.cxx @@ -54,14 +54,14 @@ void ShapeOwner::add(Shape* ptr) // this method takes ownership of the object Shape* ShapeOwner::get(int idx) // this pointer is still owned by the class (assessor) { - if (idx<0 || idx>=shapes.size()) + if (idx < 0 || idx >= static_cast(shapes.size())) return NULL; return shapes[idx]; } Shape* ShapeOwner::remove(int idx) // this method returns memory which must be deleted { - if (idx<0 || idx>=shapes.size()) + if (idx < 0 || idx >= static_cast(shapes.size())) return NULL; Shape* ptr=shapes[idx]; shapes.erase(shapes.begin()+idx); diff --git a/Examples/perl5/import/base.h b/Examples/perl5/import/base.h index be3cdef7d..5a266f68c 100644 --- a/Examples/perl5/import/base.h +++ b/Examples/perl5/import/base.h @@ -3,7 +3,7 @@ class Base { public: Base() { }; - ~Base() { }; + virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } diff --git a/Examples/perl5/multiple_inheritance/example.h b/Examples/perl5/multiple_inheritance/example.h index ce7dfe6a7..a8f544898 100644 --- a/Examples/perl5/multiple_inheritance/example.h +++ b/Examples/perl5/multiple_inheritance/example.h @@ -7,26 +7,25 @@ using namespace std; class Bar { public: - virtual void bar () - { - cout << "bar" << endl; - } + virtual void bar () { + cout << "bar" << endl; + } + virtual ~Bar() {} }; class Foo { public: - virtual void foo () - { - cout << "foo" << endl; - } + virtual void foo () { + cout << "foo" << endl; + } + virtual ~Foo() {} }; class Foo_Bar : public Foo, public Bar { public: - virtual void fooBar () - { - cout << "foobar" << endl; - } + virtual void fooBar () { + cout << "foobar" << endl; + } }; diff --git a/Examples/php4/reference/BUILD-proxy.sh b/Examples/php4/reference/BUILD-proxy.sh deleted file mode 100755 index b1c8c71a4..000000000 --- a/Examples/php4/reference/BUILD-proxy.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /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/python/callback/Makefile b/Examples/python/callback/Makefile index ad36d7d7e..a29276e58 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -19,3 +19,4 @@ 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 f331b8203..74625b992 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 01d0f943a..1420b4e0b 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -17,3 +17,4 @@ 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 c7b476995..77fe94b1a 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index 74ab112a1..f25450cac 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -21,3 +21,4 @@ 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 f331b8203..74625b992 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -18,3 +18,4 @@ 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 17c4f30b7..7dbdde944 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -18,3 +18,4 @@ 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 a4f334311..ba5c79827 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -19,3 +19,4 @@ 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 ad36d7d7e..a29276e58 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -19,3 +19,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -17,3 +17,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -17,3 +17,4 @@ 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 c45536529..fe389757a 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -19,3 +19,4 @@ 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 e00e81864..74d4f88cf 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -19,3 +19,4 @@ 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_template/Makefile b/Examples/python/import_template/Makefile index fa49f3145..ee47e994d 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -19,3 +19,4 @@ 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 8c7edfa65..fafb7de09 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -17,3 +17,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 163d7cc8e..3d5a09771 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -17,6 +17,7 @@ extern int gcd(int x, int y); %typemap(in,fragment="t_output_helper") (int argc, char *argv[]) { int i; + int l; if (!PyList_Check($input)) { SWIG_exception(SWIG_ValueError, "Expecting a list"); } @@ -27,11 +28,21 @@ 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 (!PyString_Check(s)) { +%#if PY_VERSION_HEX >= 0x03000000 + if (!PyUnicode_Check(s)) +%#else + if (!PyString_Check(s)) +%#endif + { free($2); SWIG_exception(SWIG_ValueError, "List items must be strings"); } +%#if PY_VERSION_HEX >= 0x03000000 + $2[i] = PyUnicode_AsStringAndSize(s, &l); +%#else $2[i] = PyString_AsString(s); +%#endif + } $2[i] = 0; } @@ -39,12 +50,21 @@ 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); @@ -56,9 +76,15 @@ 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 @@ -67,7 +93,11 @@ 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 c45536529..fe389757a 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -19,3 +19,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -17,3 +17,4 @@ 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 f331b8203..74625b992 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -18,3 +18,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index 58d139643..f73802a6b 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -19,3 +19,4 @@ 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 2d4c1b4a3..5d13da764 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -22,3 +22,4 @@ run: python runme.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -19,3 +19,4 @@ 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 53bf701c9..2142be5bb 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -22,3 +22,4 @@ clean:: check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -19,3 +19,4 @@ 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 01d0f943a..1420b4e0b 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -17,3 +17,4 @@ 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 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -17,3 +17,4 @@ 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 822779bd1..88f95c095 100644 --- a/Examples/python/weave/Makefile +++ b/Examples/python/weave/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/class/example.dsp +++ b/Examples/ruby/class/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/free_function/example.cxx b/Examples/ruby/free_function/example.cxx index 9e0d24b1a..402a947e9 100644 --- a/Examples/ruby/free_function/example.cxx +++ b/Examples/ruby/free_function/example.cxx @@ -23,7 +23,7 @@ Zoo::~Zoo() IterType iter = this->animals.begin(); IterType end = this->animals.end(); - for(iter; iter != end; ++iter) + for(; iter != end; ++iter) { Animal* animal = *iter; delete animal; diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/free_function/example.dsp +++ b/Examples/ruby/free_function/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp index e897f8d5c..dd09ca021 100644 --- a/Examples/ruby/import/bar.dsp +++ b/Examples/ruby/import/bar.dsp @@ -115,7 +115,7 @@ SOURCE=.\bar.i InputPath=.\bar.i InputName=bar -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=bar InputPath=.\bar.i InputName=bar -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp index 45d2fe2ea..2bd4fa243 100644 --- a/Examples/ruby/import/base.dsp +++ b/Examples/ruby/import/base.dsp @@ -115,7 +115,7 @@ SOURCE=.\base.i InputPath=.\base.i InputName=base -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=base InputPath=.\base.i InputName=base -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp index 2dfba9d60..2a764bbd7 100644 --- a/Examples/ruby/import/foo.dsp +++ b/Examples/ruby/import/foo.dsp @@ -115,7 +115,7 @@ SOURCE=.\foo.i InputPath=.\foo.i InputName=foo -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=foo InputPath=.\foo.i InputName=foo -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp index 0530b7303..d2d7158bb 100644 --- a/Examples/ruby/import/spam.dsp +++ b/Examples/ruby/import/spam.dsp @@ -115,7 +115,7 @@ SOURCE=.\spam.i InputPath=.\spam.i InputName=spam -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -130,7 +130,7 @@ InputName=spam InputPath=.\spam.i InputName=spam -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp index 49c480575..9a26322ec 100644 --- a/Examples/ruby/mark_function/example.dsp +++ b/Examples/ruby/mark_function/example.dsp @@ -123,7 +123,7 @@ SOURCE=.\example.i InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% @@ -138,7 +138,7 @@ InputName=example InputPath=.\example.i InputName=example -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" echo In order to function correctly, please ensure the following environment variables are correctly set: echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb index 1529d38c6..851190536 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.length-1) { |i| v[i] = i+1 } +0.upto(v.size-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.length-1) { |i| print w[i],"; " } +0.upto(w.size-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.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector in place Example::halve_in_place(v) -0.upto(v.length-1) { |i| print v[i],"; " } +0.upto(v.size-1) { |i| print v[i],"; " } puts diff --git a/Examples/tcl/import/base.h b/Examples/tcl/import/base.h index be3cdef7d..5a266f68c 100644 --- a/Examples/tcl/import/base.h +++ b/Examples/tcl/import/base.h @@ -3,7 +3,7 @@ class Base { public: Base() { }; - ~Base() { }; + virtual ~Base() { }; virtual void A() { printf("I'm Base::A\n"); } diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i index e2d8054bb..2e4d105b1 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_PHP4_MULTIPLE_INHERITANCE) D; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ %inline %{ #if defined(_MSC_VER) diff --git a/Examples/test-suite/allowexcept.i b/Examples/test-suite/allowexcept.i index 14b19b33d..37b01cd75 100644 --- a/Examples/test-suite/allowexcept.i +++ b/Examples/test-suite/allowexcept.i @@ -26,14 +26,26 @@ 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/apply_signed_char.i b/Examples/test-suite/apply_signed_char.i index ff1f1d83f..c0fa00cfe 100644 --- a/Examples/test-suite/apply_signed_char.i +++ b/Examples/test-suite/apply_signed_char.i @@ -31,5 +31,7 @@ const char memberconstchar; virtual ~DirectorTest() {} + private: + DirectorTest& operator=(const DirectorTest &); }; %} diff --git a/Examples/test-suite/bools.i b/Examples/test-suite/bools.i index 40e8989bd..7b94fcf88 100644 --- a/Examples/test-suite/bools.i +++ b/Examples/test-suite/bools.i @@ -57,6 +57,8 @@ struct BoolStructure { m_rbool(m_bool2), m_const_pbool(m_pbool), m_const_rbool(m_rbool) {} +private: + BoolStructure& operator=(const BoolStructure &); }; %} diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index a91afaded..b06eba773 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -10,7 +10,7 @@ below. %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. %{ -#define OTHERLAND_MSG "Little message from the the safe world." +#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." static char *global_str = NULL; const int UINT_DIGITS = 10; // max unsigned int is 4294967295 diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 0ac37d16a..ef6d7056c 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -40,7 +40,7 @@ SWIGOPT += -nounit $(setup) +$(swig_and_compile_c) $(run_testcase) - +if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \ $(MAKE) $*.cproxy; ) \ fi; @@ -54,7 +54,7 @@ SWIGOPT += -nounit %.externaltest: $(setup) - $(swig_and_compile_external) + +$(swig_and_compile_external) $(run_testcase) # Runs the testcase. A testcase is only run if @@ -69,21 +69,21 @@ run_testcase = \ %.cppproxy: SWIGOPT += -proxy %.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.cppproxy: - echo "Checking testcase $* (with run test) under chicken with -proxy" - $(swig_and_compile_cpp) + echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" + +$(swig_and_compile_cpp) $(run_testcase) %.cproxy: SWIGOPT += -proxy %.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.cproxy: - echo "Checking testcase $* (with run test) under chicken with -proxy" + echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" +$(swig_and_compile_c) $(run_testcase) %.multiproxy: SWIGOPT += -proxy -noclosuses %.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) %.multiproxy: - echo "Checking testcase $* (with run test) under chicken with -proxy" + echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" +$(swig_and_compile_multi_cpp) $(run_testcase) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3607a4253..57b57c271 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -202,6 +202,7 @@ CPP_TEST_CASES += \ inherit_target_language \ inherit_void_arg \ inline_initializer \ + keyword_rename \ kind \ langobj \ li_attribute \ @@ -236,6 +237,7 @@ CPP_TEST_CASES += \ null_pointer \ operator_overload \ operator_overload_break \ + operbool \ ordering \ overload_copy \ overload_extend \ @@ -422,6 +424,7 @@ C_TEST_CASES += \ immutable \ inctest \ integers \ + keyword_rename \ lextype \ li_carrays \ li_cdata \ diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 367baf49c..5bd2fd533 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -46,6 +46,8 @@ public: int* array_member1[ARRAY_SIZE]; ParametersTest* array_member2[ARRAY_SIZE]; MemberVariablesTest() : member3(NULL), member4(NULL) {} +private: + MemberVariablesTest& operator=(const MemberVariablesTest&); }; void foo(const int *const i) {} @@ -69,6 +71,8 @@ public: void ret6(int*& a) {} int*& ret7() {return GlobalIntPtr;} ReturnValuesTest() : int3(NULL) {} +private: + ReturnValuesTest& operator=(const ReturnValuesTest&); }; const int* globalRet1() {return &GlobalInt;} @@ -100,6 +104,8 @@ int* const globalRet2() {return &GlobalInt;} A* ap; const A* cap; Acptr acptr; + private: + B& operator=(const B&); }; const B* bar(const B* b) { diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index 6ee0a353c..a5732105b 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_PHP4_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */ #ifdef SWIGCSHARP %ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override diff --git a/Examples/test-suite/cpp_basic.i b/Examples/test-suite/cpp_basic.i index becf84708..a247dd268 100644 --- a/Examples/test-suite/cpp_basic.i +++ b/Examples/test-suite/cpp_basic.i @@ -55,6 +55,8 @@ class Bar { Foo *testFoo(int a, Foo *f) { return new Foo(2 * a + (f ? f->num : 0) + fval.num); } +private: + Bar& operator=(const Bar&); }; %} diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 44a1b3675..5fd576ed8 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -51,9 +51,9 @@ intermediary_classname.customtest: # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ diff --git a/Examples/test-suite/csharp/char_strings_runme.cs b/Examples/test-suite/csharp/char_strings_runme.cs index a1e878016..a8907fb16 100644 --- a/Examples/test-suite/csharp/char_strings_runme.cs +++ b/Examples/test-suite/csharp/char_strings_runme.cs @@ -5,7 +5,7 @@ using char_stringsNamespace; public class char_strings_runme { private static string CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; - private static string OTHERLAND_MSG = "Little message from the the safe world."; + private static string OTHERLAND_MSG = "Little message from the safe world."; public static void Main() { diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs new file mode 100644 index 000000000..b9916108c --- /dev/null +++ b/Examples/test-suite/csharp/director_basic_runme.cs @@ -0,0 +1,74 @@ +using System; + +namespace director_basicNamespace { + +public class runme +{ + static void Main() + { + runme r = new runme(); + r.run(); + } + + void run() + { + director_basic_MyFoo a = new director_basic_MyFoo(); + + if (a.ping() != "director_basic_MyFoo::ping()") { + throw new Exception ( "a.ping()" ); + } + + if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") { + throw new Exception ( "a.pong()" ); + } + + Foo b = new Foo(); + + if (b.ping() != "Foo::ping()") { + throw new Exception ( "b.ping()" ); + } + + if (b.pong() != "Foo::pong();Foo::ping()") { + throw new Exception ( "b.pong()" ); + } + + A1 a1 = new A1(1, false); + a1.Dispose(); + + { + MyOverriddenClass my = new MyOverriddenClass(); + + my.expectNull = true; + if (MyClass.call_pmethod(my, null) != null) + throw new Exception("null pointer marshalling problem"); + + Bar myBar = new Bar(); + my.expectNull = false; + Bar myNewBar = MyClass.call_pmethod(my, myBar); + if (myNewBar == null) + throw new Exception("non-null pointer marshalling problem"); + myNewBar.x = 10; + } + } +} + +class director_basic_MyFoo : Foo { + public director_basic_MyFoo() : base() { + } + + public override string ping() { + return "director_basic_MyFoo::ping()"; + } +} + +class MyOverriddenClass : MyClass { + public bool expectNull = false; + public bool nonNullReceived = false; + public override Bar pmethod(Bar b) { + if ( expectNull && (b != null) ) + throw new Exception("null not received as expected"); + return b; + } +} + +} diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i index 9c2cedc83..0c35c1833 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 and cshin attributes for csin typemaps +// Test the pre, post, terminate and cshin attributes for csin typemaps %include "std_vector.i" @@ -88,3 +88,102 @@ 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 71600e55a..ff22c7834 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_PHP4_MULTIPLE_INHERITANCE) EB; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) AD; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP 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 986a1706f..12cb0db65 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -112,12 +112,14 @@ 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/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 4aa0613f2..31e3e2105 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -81,6 +81,8 @@ struct SpeedClass { const colour myColour2; speedtd1 mySpeedtd1; SpeedClass() : myColour2(red), mySpeedtd1(slow) { } +private: + SpeedClass& operator=(const SpeedClass&); }; int speedTest0(int s) { return s; } diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i index 33353e32e..7b2e9152f 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_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i index 78a764ccc..515044007 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_PHP4_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ namespace Blah { diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i index e9fc24f4d..804ea66b4 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_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance %inline %{ diff --git a/Examples/test-suite/fvirtual.i b/Examples/test-suite/fvirtual.i index 074202bee..af189ed1f 100644 --- a/Examples/test-suite/fvirtual.i +++ b/Examples/test-suite/fvirtual.i @@ -10,11 +10,11 @@ virtual ~Node() {} }; - class Switch : public Node { + class NodeSwitch : public Node { public : virtual int addChild( Node *child ) { return 2; } // This was hidden with -fvirtual virtual int addChild( Node *child, bool value ) { return 3; } - virtual ~Switch() {} + virtual ~NodeSwitch() {} }; %} diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 285426ee8..04de236db 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -21,9 +21,9 @@ run_testcase = \ setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ fi; swig_and_compile_multi_cpp = \ @@ -43,9 +43,9 @@ swig_and_compile_multi_cpp = \ # Same as setup and run_testcase, but without the SCRIPTPREFIX (so the runme comes from the guilescm directory) local_setup = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE) (with SCM API)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ fi; local_run_testcase = \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 53816f6d0..ace8dee86 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -57,9 +57,9 @@ SWIGOPT += -package $* # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - echo "Checking testcase $* (with run test) under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \ else \ - echo "Checking testcase $* under $(LANGUAGE)" ; \ + echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ diff --git a/Examples/test-suite/java/char_strings_runme.java b/Examples/test-suite/java/char_strings_runme.java index 2e62080f5..2c71d3ea7 100644 --- a/Examples/test-suite/java/char_strings_runme.java +++ b/Examples/test-suite/java/char_strings_runme.java @@ -12,7 +12,7 @@ public class char_strings_runme { } private static String CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible."; - private static String OTHERLAND_MSG = "Little message from the the safe world."; + private static String OTHERLAND_MSG = "Little message from the safe world."; public static void main(String argv[]) { diff --git a/Examples/test-suite/java/director_basic_runme.java b/Examples/test-suite/java/director_basic_runme.java index eafe20bec..16a46aa35 100644 --- a/Examples/test-suite/java/director_basic_runme.java +++ b/Examples/test-suite/java/director_basic_runme.java @@ -14,28 +14,43 @@ 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(); + 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); + } } } @@ -45,3 +60,13 @@ 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_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i index 5a1e61bb2..e315a36b5 100644 --- a/Examples/test-suite/java_typemaps_proxy.i +++ b/Examples/test-suite/java_typemaps_proxy.i @@ -119,6 +119,8 @@ public: void const_member_method(const ConstWithout *p) const {} const ConstWithout * const_var; const ConstWithout * const var_const; +private: + ConstWithout& operator=(const ConstWithout &); }; const ConstWithout * global_constwithout = 0; void global_method_constwithout(const ConstWithout *p) {} diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i new file mode 100644 index 000000000..da9328868 --- /dev/null +++ b/Examples/test-suite/keyword_rename.i @@ -0,0 +1,32 @@ +/* + * Test reserved keyword renaming + */ + +%module keyword_rename + +#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD + +%inline %{ + +#define KW(x, y) int x (int y) { return y; } + +/* Python keywords */ +KW(in, except) +KW(except, in) +KW(pass, in) + +/* Perl keywords */ +KW(tie, die) +KW(use, next) + +/* Java keywords */ +KW(implements, native) +KW(synchronized, final) + +/* C# Keywords */ +KW(string, out) +struct sealed {int i;}; + +%} + + diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i index fd92ac7d3..28e8049e8 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 *in, int n); +%cstring_input_binary(char *str_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 *in, int n, char c) { +int count(char *str_in, int n, char c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i index dc9a1c4b9..769dcce12 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 *in, int n); +%cwstring_input_binary(wchar_t *str_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 *in, int n, wchar_t c) { +int count(wchar_t *str_in, int n, wchar_t c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i index 8c2f1b857..2d0b7503d 100644 --- a/Examples/test-suite/li_std_string.i +++ b/Examples/test-suite/li_std_string.i @@ -129,7 +129,7 @@ public: %} %inline %{ - std::string empty() { + std::string stdstring_empty() { return std::string(); } diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua new file mode 100644 index 000000000..77aeb54e4 --- /dev/null +++ b/Examples/test-suite/lua/li_typemaps_runme.lua @@ -0,0 +1,40 @@ +require("import") -- the import fn +import("li_typemaps") -- import code + +-- catch "undefined" global variables +setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) + +-- Check double INPUT typemaps +assert(li_typemaps.in_double(22.22) == 22.22) +assert(li_typemaps.inr_double(22.22) == 22.22) + +-- Check double OUTPUT typemaps +assert(li_typemaps.out_double(22.22) == 22.22) +assert(li_typemaps.outr_double(22.22) == 22.22) + +-- Check double INOUT typemaps +assert(li_typemaps.inout_double(22.22) == 22.22) +assert(li_typemaps.inoutr_double(22.22) == 22.22) + +-- check long long +assert(li_typemaps.in_ulonglong(20)==20) +assert(li_typemaps.inr_ulonglong(20)==20) +assert(li_typemaps.out_ulonglong(20)==20) +assert(li_typemaps.outr_ulonglong(20)==20) +assert(li_typemaps.inout_ulonglong(20)==20) +assert(li_typemaps.inoutr_ulonglong(20)==20) + +-- check bools +assert(li_typemaps.in_bool(true)==true) +assert(li_typemaps.inr_bool(false)==false) +assert(li_typemaps.out_bool(true)==true) +assert(li_typemaps.outr_bool(false)==false) +assert(li_typemaps.inout_bool(true)==true) +assert(li_typemaps.inoutr_bool(false)==false) + +-- the others +a,b=li_typemaps.inoutr_int2(1,2) +assert(a==1 and b==2) + +f,i=li_typemaps.out_foo(10) +assert(f.a==10 and i==20) diff --git a/Examples/test-suite/minherit.i b/Examples/test-suite/minherit.i index aba299387..24092b6c6 100644 --- a/Examples/test-suite/minherit.i +++ b/Examples/test-suite/minherit.i @@ -6,7 +6,7 @@ %module(ruby_minherit="1") minherit -#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) +#if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) %inline %{ diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i index f55131ff5..1bca4fc48 100644 --- a/Examples/test-suite/minherit2.i +++ b/Examples/test-suite/minherit2.i @@ -7,7 +7,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, SWIGWARN_RUBY_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) RemoteMpe; + SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe; #if defined(SWIGJAVA) || defined(SWIGCSHARP) diff --git a/Examples/test-suite/multiple_inheritance.i b/Examples/test-suite/multiple_inheritance.i index 1c4458114..1fc68eef9 100644 --- a/Examples/test-suite/multiple_inheritance.i +++ b/Examples/test-suite/multiple_inheritance.i @@ -5,11 +5,11 @@ It tests basic multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */ %inline %{ diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index a9cb35686..527dbcfaa 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -58,13 +58,12 @@ namespace std %template(max_i) max; - %inline { /* silently rename the parameter names in csharp/java */ #ifdef SWIGR double foo(double inparam, double out) { return 1.0; } #else - double foo(double in, double out) { return 1.0; } + double foo(double abstract, 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 e4e0af905..984b93a6f 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(PyString_AsString($input)); + $1 = new string_class(SWIG_Python_str_AsChar($input)); } %typemap(freearg) string_class * { delete $1; diff --git a/Examples/test-suite/octave/fvirtual_runme.m b/Examples/test-suite/octave/fvirtual_runme.m index 06c6e7ccb..e755a559a 100644 --- a/Examples/test-suite/octave/fvirtual_runme.m +++ b/Examples/test-suite/octave/fvirtual_runme.m @@ -1,6 +1,6 @@ fvirtual -sw = Switch(); +sw = NodeSwitch(); n = Node(); i = sw.addChild(n); diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m index 1c24ac344..fa0e260e0 100644 --- a/Examples/test-suite/octave/li_std_string_runme.m +++ b/Examples/test-suite/octave/li_std_string_runme.m @@ -148,7 +148,7 @@ if (s != "hellohello") endif -if (li_std_string.empty() != "") +if (li_std_string.stdstring_empty() != "") error endif diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i new file mode 100644 index 000000000..d6d7fc706 --- /dev/null +++ b/Examples/test-suite/operbool.i @@ -0,0 +1,10 @@ +%module operbool + +%inline %{ + class Test { + public: + operator bool() { + return false; + } + }; +%} diff --git a/Examples/test-suite/perl5/li_std_string_runme.pl b/Examples/test-suite/perl5/li_std_string_runme.pl index 0ee11bdc7..9ec7dd08c 100644 --- a/Examples/test-suite/perl5/li_std_string_runme.pl +++ b/Examples/test-suite/perl5/li_std_string_runme.pl @@ -98,7 +98,7 @@ SKIP: { is($gen1->testl("9234567890121111113"), "9234567890121111114", "ulonglong big number"); -is(li_std_string::empty(), "", "empty"); +is(li_std_string::stdstring_empty(), "", "stdstring_empty"); is(li_std_string::c_empty(), "", "c_empty"); @@ -110,4 +110,4 @@ is(li_std_string::get_null(li_std_string::c_null()), undef, "c_empty"); is(li_std_string::get_null(li_std_string::c_empty()), "non-null", "c_empty"); -is(li_std_string::get_null(li_std_string::empty()), "non-null", "c_empty"); +is(li_std_string::get_null(li_std_string::stdstring_empty()), "non-null", "stdstring_empty"); diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl index c149284ae..c182cdbb1 100644 --- a/Examples/test-suite/perl5/li_typemaps_runme.pl +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl @@ -37,24 +37,29 @@ batch('ulong', 0, 1, 12, 0xffffffff); batch('uchar', 0, 1, 12, 0xff); batch('schar', -0x80, 0, 1, 12, 0x7f); -# 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'); +{ + 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); } -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/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl index f0e1b0288..106bf002b 100755 --- a/Examples/test-suite/perl5/run-perl-test.pl +++ b/Examples/test-suite/perl5/run-perl-test.pl @@ -7,7 +7,7 @@ use strict; my $command = shift @ARGV; -my $output = `perl $command 2>&1`; +my $output = `$^X $command 2>&1`; die "SWIG Perl test failed: \n\n$output\n" if $?; diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php4/Makefile.in index dbd239964..2e14ef9a2 100644 --- a/Examples/test-suite/php4/Makefile.in +++ b/Examples/test-suite/php4/Makefile.in @@ -42,17 +42,17 @@ missingtests: missingcpptests missingctests %.cpptest: $(setup) +$(swig_and_compile_cpp) - $(run_testcase) + +$(run_testcase) %.ctest: $(setup) +$(swig_and_compile_c) - $(run_testcase) + +$(run_testcase) %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) - $(run_testcase) + +$(run_testcase) # Runs the testcase. A testcase is only run if # a file is found which has _runme.php4 appended after the testcase name. diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php4/tests.php4 index ae43398df..36e9f4163 100644 --- a/Examples/test-suite/php4/tests.php4 +++ b/Examples/test-suite/php4/tests.php4 @@ -67,7 +67,7 @@ class check { } function classname($string,$object) { - if ($string!=($classname=get_class($object))) return check::fail("Object: $object is of class %s not class %s",$classname,$string); + if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string); return TRUE; } diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index b41e48a89..aab9741a9 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -9,7 +9,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ %nodefaultctor C; %nodefaultdtor C; diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 7f11cd495..a3a027453 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -2,14 +2,41 @@ # Makefile for python test-suite ####################################################################### +ifeq (,$(PY3)) + PYBIN = @PYTHON@ +else + PYBIN = @PYTHON3@ +endif + LANGUAGE = python -PYTHON = @PYTHON@ -SCRIPTSUFFIX = _runme.py +ifneq (,$(USE_VALGRIND)) + PYTHON = valgrind --leak-check=full --suppressions=pyswig.supp $(PYBIN) +else + PYTHON = $(PYBIN) +endif + +#*_runme.py for Python 2.x, *_runme3.py for Python 3.x +PY2SCRIPTSUFFIX = _runme.py +PY3SCRIPTSUFFIX = _runme3.py + +ifeq (,$(PY3)) + SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) +else + SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) +endif + srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ + +#Use the tricky command because we want to disable the "import" fixer, +#but currently 2to3 has no option to let us do it +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + + CPP_TEST_CASES += \ + abstractbase \ argcargvtest \ autodoc \ callback \ @@ -77,12 +104,35 @@ VALGRIND_OPT += --suppressions=pythonswig.supp +$(swig_and_compile_multi_cpp) $(run_testcase) + +# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file +%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX) + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + + # Runs the testcase. A testcase is only run if -# a file is found which has _runme.py appended after the testcase name. +# 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) + +ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ + $(run_python);)\ fi; +else +py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) +py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) + +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: @@ -101,14 +151,15 @@ 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 + perl hugemod.pl $(hugemod_runme) $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest - time $(PYTHON) hugemod_runme.py - time $(PYTHON) hugemod_runme.py + sh -c "time $(PYTHON) $(hugemod_runme)" + sh -c "time $(PYTHON) $(hugemod_runme)" diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README index b86ec5289..71db759b5 100644 --- a/Examples/test-suite/python/README +++ b/Examples/test-suite/python/README @@ -1,4 +1,8 @@ See ../README for common README file. -Any testcases which have _runme.py appended after the testcase name will be detected and run. +Any testcases which have _runme.py (or _runme3.py for Python 3) 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/python/abstractbase.i b/Examples/test-suite/python/abstractbase.i new file mode 100644 index 000000000..530f21921 --- /dev/null +++ b/Examples/test-suite/python/abstractbase.i @@ -0,0 +1,18 @@ +%module 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/abstractbase_runme3.py b/Examples/test-suite/python/abstractbase_runme3.py new file mode 100644 index 000000000..13a87ee5e --- /dev/null +++ b/Examples/test-suite/python/abstractbase_runme3.py @@ -0,0 +1,8 @@ +from 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/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py index 3108b4f47..a454774f5 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 "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.cvar.Foo != 42: - raise "Bad variable value!" + raise RuntimeError("Bad variable value!") t = cpp_namespace.Test() if t.method() != "Test::method": - raise "Bad method return value!" + raise RuntimeError("Bad method return value!") if cpp_namespace.do_method(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method2(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("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 "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t2,40) != "Test2::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t3,40) != "Test3::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t4,40) != "Test4::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t5,40) != "Test5::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 878905679..7e18a9a61 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 ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(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 ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(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 ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(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 7c9e69250..ef7a044f1 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,5 +1,8 @@ from director_exception import * -from exceptions import * + +class MyException(Exception): + def __init__(self, a, b): + self.msg = a + b class MyFoo(Foo): def ping(self): @@ -7,39 +10,62 @@ class MyFoo(Foo): class MyFoo2(Foo): def ping(self): - return true + return True pass # error: should return a string -ok = 0 +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: - ok = 1 + if str(e) == "MyFoo::ping() EXCEPTION": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) except: pass - if not ok: raise RuntimeError -ok = 0 +# 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: - ok = 1 - - +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) 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/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index 64154c619..de4e2669e 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,8 @@ import sys import file_test -file_test.nfile(sys.stdout) +if sys.version_info < (3,0): + file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/fvirtual_runme.py b/Examples/test-suite/python/fvirtual_runme.py index e06ab5b4f..ada3313de 100644 --- a/Examples/test-suite/python/fvirtual_runme.py +++ b/Examples/test-suite/python/fvirtual_runme.py @@ -1,6 +1,6 @@ from fvirtual import * -sw = Switch() +sw = NodeSwitch() n = Node() i = sw.addChild(n); diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl index 15c4ce41b..5420926e4 100644 --- a/Examples/test-suite/python/hugemod.pl +++ b/Examples/test-suite/python/hugemod.pl @@ -2,8 +2,12 @@ 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, ">hugemod_runme.py" or die "error"; +open TEST, ">$runme" or die "error"; open I1, ">hugemod_a.i" or die "error"; open I2, ">hugemod_b.i" or die "error"; @@ -21,7 +25,7 @@ print I2 "\%inline \%{\n"; my $i; -for ($i = 0; $i < 6000; $i++) { +for ($i = 0; $i < $modsize; $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/python/keyword_rename_runme.py b/Examples/test-suite/python/keyword_rename_runme.py new file mode 100644 index 000000000..5646ce7d6 --- /dev/null +++ b/Examples/test-suite/python/keyword_rename_runme.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import keyword_rename +keyword_rename._in(1) +keyword_rename._except(1) diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_runme.py index ed79718d2..c0dae1e25 100644 --- a/Examples/test-suite/python/li_std_string_runme.py +++ b/Examples/test-suite/python/li_std_string_runme.py @@ -121,7 +121,7 @@ if s != "hellohello": raise RuntimeError -if li_std_string.empty() != "": +if li_std_string.stdstring_empty() != "": raise RuntimeError diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py new file mode 100644 index 000000000..4218b5dd4 --- /dev/null +++ b/Examples/test-suite/python/operbool_runme.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import operbool +assert not operbool.Test() + diff --git a/Examples/test-suite/python/pybuf.i b/Examples/test-suite/python/pybuf.i new file mode 100644 index 000000000..207b5b7e9 --- /dev/null +++ b/Examples/test-suite/python/pybuf.i @@ -0,0 +1,34 @@ +%module pybuf +%include + +%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 +%pybuffer_mutable_string(char *str1); +%cstring_mutable(char *str2); + +%inline %{ +void title(char *str) { + int outword = 0; + while(*str) { + if (isalnum(*str)) { + if (outword) { + outword = 1; + *str = toupper(*str); + } + } + else { + outword = 0; + } + str++; + } +} + +void title1(char *str1) { + title(str1); +} +void title2(char *str2) { + title(str2); +} +%} diff --git a/Examples/test-suite/python/pybuf_benchmark_runme.py b/Examples/test-suite/python/pybuf_benchmark_runme.py new file mode 100644 index 000000000..6676a910b --- /dev/null +++ b/Examples/test-suite/python/pybuf_benchmark_runme.py @@ -0,0 +1,16 @@ +import pybuf +import time +k=1000000 +n=7 + +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 diff --git a/Examples/test-suite/python/pybuf_benchmark_runme3.py b/Examples/test-suite/python/pybuf_benchmark_runme3.py new file mode 100644 index 000000000..e412d5993 --- /dev/null +++ b/Examples/test-suite/python/pybuf_benchmark_runme3.py @@ -0,0 +1,16 @@ +import pybuf +import time +k=1000000 +n=7 + +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) diff --git a/Examples/test-suite/python/pybuf_runme3.py b/Examples/test-suite/python/pybuf_runme3.py new file mode 100644 index 000000000..462736bf0 --- /dev/null +++ b/Examples/test-suite/python/pybuf_runme3.py @@ -0,0 +1,15 @@ +import pybuf +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 diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 030fe02d8..04c599329 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx2 import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,7 +82,7 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.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 99ffcb9aa..2cd9c8348 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,6 +82,6 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 0a1b3567e..70dd62ec5 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -42,7 +42,7 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ;) \ else \ - ($(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX);) \ + ($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX);) \ fi; run_multitestcase = \ @@ -51,7 +51,7 @@ run_multitestcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ;) \ else \ - ($(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \ + ($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \ fi; \ done # Clean diff --git a/Examples/test-suite/ruby/li_std_string_runme.rb b/Examples/test-suite/ruby/li_std_string_runme.rb index f572573bc..dc85b5dab 100644 --- a/Examples/test-suite/ruby/li_std_string_runme.rb +++ b/Examples/test-suite/ruby/li_std_string_runme.rb @@ -124,7 +124,7 @@ if (s != "hellohello") end -if (empty() != "") +if (stdstring_empty() != "") raise RuntimeError end diff --git a/Examples/test-suite/samename.i b/Examples/test-suite/samename.i index 1e9645e70..819cb4abd 100644 --- a/Examples/test-suite/samename.i +++ b/Examples/test-suite/samename.i @@ -1,6 +1,15 @@ %module samename -%inline { +#if !(defined(SWIGCSHARP) || defined(SWIGJAVA)) +class samename { + public: + void do_something() { + // ... + } +}; +#endif + +%{ class samename { public: @@ -9,5 +18,5 @@ class samename { } }; -} +%} diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index f676b3b3e..89d983de0 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_PHP4_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, Php4 multiple inheritance */ + SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP multiple inheritance */ %inline %{ diff --git a/Examples/test-suite/template_int_const.i b/Examples/test-suite/template_int_const.i index 37b1cf998..e69a53c4f 100644 --- a/Examples/test-suite/template_int_const.i +++ b/Examples/test-suite/template_int_const.i @@ -10,7 +10,7 @@ static const Polarization polarization = UnaryPolarization; }; template - struct Interface + struct Interface_ { }; @@ -26,16 +26,16 @@ }; %} -%template(Interface_UP) Interface; +%template(Interface_UP) Interface_; %template(Module_1) Module<1>; %inline %{ struct ExtInterface1 : - Interface // works + Interface_ // works { }; struct ExtInterface2 : - Interface // doesn't work + Interface_ // doesn't work { }; struct ExtModule1 : diff --git a/Examples/test-suite/template_typedef_rec.i b/Examples/test-suite/template_typedef_rec.i index 83fe2104a..abdf11382 100644 --- a/Examples/test-suite/template_typedef_rec.i +++ b/Examples/test-suite/template_typedef_rec.i @@ -16,7 +16,7 @@ public: template -class ArrayIterator +class ArrayIterator_ { public: typedef test_Array::intT intT; @@ -38,8 +38,8 @@ class ArrayPrimitiveT public: typedef T ValueT; typedef T valueT; - typedef ArrayIterator Iterator; - typedef ArrayIterator ConstIterator; + typedef ArrayIterator_ Iterator; + typedef ArrayIterator_ ConstIterator; typedef ArrayReverseIterator ReverseIterator; typedef ArrayReverseIterator ConstReverseIterator; }; diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index d30a4ddb1..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)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i index 7bb6add2a..bd0f712b5 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_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP 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 414ceedb4..e14cc28e8 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_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP 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 1989b6a0d..799c7cfb5 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_PHP4_MULTIPLE_INHERITANCE) Hi; // C#, Java, Php4 multiple inheritance + SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, Java, PHP multiple inheritance %inline %{ namespace hello diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 0ae8ed76c..8132e4628 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -296,15 +296,30 @@ $body)" sym)))) (cl::defun full-name (id type arity class) - (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)))) + ; 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::defun identifier-convert-null (id &key type class arity) (cl::if (cl::eq type :setter) @@ -312,6 +327,27 @@ $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) @@ -321,31 +357,7 @@ $body)" (cl::setq cname (full-name cname type arity class)) (cl::if (cl::eq type :constant) (cl::setf cname (cl::format nil "*~A*" 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)))) + (read-symbol-from-string (string-lispify cname))) (cl::defun id-convert-and-export (name &rest kwargs) (cl::multiple-value-bind (symbol package) diff --git a/Lib/cdata.i b/Lib/cdata.i index a9e74ed8a..67601f737 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -29,6 +29,11 @@ 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 @@ -76,7 +81,3 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); /* Memory move function */ void memmove(void *data, const void *indata, int inlen); - - - - diff --git a/Lib/cffi/cffi.swg b/Lib/cffi/cffi.swg index 63bd0b040..c832e00d2 100644 --- a/Lib/cffi/cffi.swg +++ b/Lib/cffi/cffi.swg @@ -86,7 +86,7 @@ short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, - float, double, long double, char *, void * + float, double, long double, char *, void *, enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE & "$result = $1;"; #ifdef __cplusplus @@ -125,8 +125,9 @@ int, signed int, unsigned int, long, signed long, unsigned long, enum SWIGTYPE "cl:integer"; -%typemap(lispclass) float "cl:single-float"; -%typemap(lispclass) double "cl:double-float"; +/* CLOS methods can't be specialized on single-float or double-float */ +%typemap(lispclass) float "cl:number"; +%typemap(lispclass) double "cl:number"; %typemap(lispclass) char * "cl:string"; diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index d8b71874e..a8d1b5a57 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -10,6 +10,7 @@ /* chicken.h has to appear first. */ %insert(runtime) %{ +#include #include %} diff --git a/Lib/chicken/chickenkw.swg b/Lib/chicken/chickenkw.swg index f01faf14f..d2c26c74c 100644 --- a/Lib/chicken/chickenkw.swg +++ b/Lib/chicken/chickenkw.swg @@ -3,7 +3,7 @@ /* Warnings for certain CHICKEN keywords. From Section 7.1.1 of Revised^5 Report on the Algorithmic Language Scheme */ -#define CHICKENKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x +#define CHICKENKW(x) %namewarn("314: '" #x "' is a R^5RS syntatic keyword") #x CHICKENKW(else); CHICKENKW(=>); diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index bd7242407..8703ea65a 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -7,6 +7,7 @@ * ----------------------------------------------------------------------------- */ #include +#include #include #include #include diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 35e5c26d7..e381ff9ae 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -428,7 +428,8 @@ 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::*), SWIGTYPE & "new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle" /* Default array handling */ diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 7938dee04..ffff70372 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -73,7 +73,7 @@ static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = { static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) { SWIG_CSharpExceptionCallback_t callback = SWIG_csharp_exceptions[SWIG_CSharpApplicationException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions)/sizeof(SWIG_CSharpException_t)) { callback = SWIG_csharp_exceptions[code].callback; } callback(msg); @@ -81,7 +81,7 @@ static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes static void SWIGUNUSED SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpExceptionArgumentCodes code, const char *msg, const char *param_name) { SWIG_CSharpExceptionArgumentCallback_t callback = SWIG_csharp_exceptions_argument[SWIG_CSharpArgumentException].callback; - if (code >=0 && (size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { + if ((size_t)code < sizeof(SWIG_csharp_exceptions_argument)/sizeof(SWIG_CSharpExceptionArgument_t)) { callback = SWIG_csharp_exceptions_argument[code].callback; } callback(msg, param_name); diff --git a/Lib/csharp/csharpkw.swg b/Lib/csharp/csharpkw.swg index c96042d2d..9a6d979f1 100644 --- a/Lib/csharp/csharpkw.swg +++ b/Lib/csharp/csharpkw.swg @@ -2,7 +2,7 @@ #define CSHARP_CSHARPKW_SWG_ /* Warnings for C# keywords */ -#define CSHARPKW(x) %namewarn("314:" #x " is a csharp keyword") #x +#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x` /* from diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index a04831f75..2e4d47c00 100755 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -231,14 +231,14 @@ return new std::vector(self->begin()+index, self->begin()+index+count); } void Insert(int index, const value_type& x) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, x); else throw std::out_of_range("index"); } // Takes a deep copy of the elements unlike ArrayList.InsertRange void InsertRange(int index, const std::vector& values) throw (std::out_of_range) { - if (index>=0 && index<(int)self->size()+1) + if (index>=0 && index<(int)self->size()) self->insert(self->begin()+index, values.begin(), values.end()); else throw std::out_of_range("index"); diff --git a/Lib/java/director.swg b/Lib/java/director.swg index bade80c9d..fa588671d 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -117,12 +117,18 @@ namespace Swig { JNIEnv *jenv_; public: JNIEnvWrapper(const Director *director) : director_(director), jenv_(0) { +#if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) + // Attach a daemon thread to the JVM. Useful when the JVM should not wait for + // the thread to exit upon shutdown. Only for jdk-1.4 and later. + director_->swig_jvm_->AttachCurrentThreadAsDaemon((void **) &jenv_, NULL); +#else director_->swig_jvm_->AttachCurrentThread((void **) &jenv_, NULL); +#endif } ~JNIEnvWrapper() { -// Some JVMs, eg JDK 1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. -// However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. #if !defined(SWIG_JAVA_NO_DETACH_CURRENT_THREAD) + // Some JVMs, eg jdk-1.4.2 and lower on Solaris have a bug and crash with the DetachCurrentThread call. + // However, without this call, the JVM hangs on exit when the thread was not created by the JVM and creates a memory leak. director_->swig_jvm_->DetachCurrentThread(); #endif } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index b7c5607c3..7d1808632 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -620,7 +620,8 @@ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} -%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $javaclassname($jniinput, false)" +%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)" +%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)" /* Default array handling */ diff --git a/Lib/java/javakw.swg b/Lib/java/javakw.swg index 9dcd97062..99cd54770 100644 --- a/Lib/java/javakw.swg +++ b/Lib/java/javakw.swg @@ -2,7 +2,7 @@ #define JAVA_JAVAKW_SWG_ /* Warnings for Java keywords */ -#define JAVAKW(x) %namewarn("314:" #x " is a java keyword") #x +#define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword, renaming to '_"`x`"'",rename="_%s") `x` /* from diff --git a/Lib/java/various.i b/Lib/java/various.i index c53f08aa2..733b8fa79 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -60,7 +60,7 @@ #endif } -%typemap(out) char **STRING_ARRAY (char *s) { +%typemap(out) char **STRING_ARRAY { int i; int len=0; jstring temp_string; diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 462d6a055..0941c9da1 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -73,7 +73,7 @@ %{$1 = (lua_toboolean(L, $input)!=0);%} %typemap(out) bool -%{ lua_pushboolean(L,(int)($1==true)); SWIG_arg++;%} +%{ lua_pushboolean(L,(int)($1!=0)); SWIG_arg++;%} // for const bool&, SWIG treats this as a const bool* so we must dereference it %typemap(in,checkfn="lua_isboolean") const bool& (bool temp) @@ -81,7 +81,7 @@ $1=&temp;%} %typemap(out) const bool& -%{ lua_pushboolean(L,(int)(*$1==true)); SWIG_arg++;%} +%{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%} // strings (char* and char[]) %typemap(in,checkfn="lua_isstring") const char*, char* diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index e0adcf192..fa0c0d0e5 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -80,6 +80,22 @@ SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NU // note we dont do char, as a char* is probably a string not a ptr to a single char +// similar for booleans +%typemap(in,checkfn="lua_isboolean") bool *INPUT(bool temp), bool &INPUT(bool temp) +%{ temp = (lua_toboolean(L,$input)!=0); + $1 = &temp; %} + +%typemap(in, numinputs=0) bool *OUTPUT (bool temp),bool &OUTPUT (bool temp) +%{ $1 = &temp; %} + +%typemap(argout) bool *OUTPUT,bool &OUTPUT +%{ lua_pushboolean(L, (int)((*$1)!=0)); SWIG_arg++;%} + +%typemap(in) bool *INOUT = bool *INPUT; +%typemap(argout) bool *INOUT = bool *OUTPUT; +%typemap(in) bool &INOUT = bool &INPUT; +%typemap(argout) bool &INOUT = bool &OUTPUT; + /* ----------------------------------------------------------------------------- * Basic Array typemaps * ----------------------------------------------------------------------------- */ @@ -320,6 +336,11 @@ for array handling %typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int); // TODO out variable arrays (is there a standard form for such things?) + +// referencing so that (int *INPUT,int) and (int INPUT[],int) are the same +%typemap(in) (TYPE INPUT[],int)=(TYPE *INPUT,int); +%typemap(freearg) (TYPE INPUT[],int)=(TYPE *INPUT,int); + %enddef // the following line of code diff --git a/Lib/ocaml/ocamlkw.swg b/Lib/ocaml/ocamlkw.swg index ba06f238e..9b9096e2b 100644 --- a/Lib/ocaml/ocamlkw.swg +++ b/Lib/ocaml/ocamlkw.swg @@ -2,7 +2,7 @@ #define OCAML_OCAMLKW_SWG_ /* Warnings for Ocaml keywords */ -#define OCAMLKW(x) %namewarn("314:" #x " is a ocaml keyword and it will properly renamed") #x +#define OCAMLKW(x) %namewarn("314: '" #x "' is a ocaml keyword and it will properly renamed") #x /* from diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h index a29de61f5..8d3dc7338 100644 --- a/Lib/perl5/noembed.h +++ b/Lib/perl5/noembed.h @@ -91,3 +91,7 @@ #ifdef open #undef open #endif +#ifdef readdir + #undef readdir +#endif + diff --git a/Lib/perl5/perlkw.swg b/Lib/perl5/perlkw.swg index 71a229c66..00648e0bf 100644 --- a/Lib/perl5/perlkw.swg +++ b/Lib/perl5/perlkw.swg @@ -1,6 +1,6 @@ /* Warnings for Perl keywords */ -#define PERLKW(x) %keywordwarn(`x` " is a perl keyword") `x` -#define PERLBN(x) %builtinwarn(`x` " conflicts with a built-in name in perl") "::" `x` +#define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x` +#define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x` /* diff --git a/Lib/php4/const.i b/Lib/php/const.i similarity index 100% rename from Lib/php4/const.i rename to Lib/php/const.i diff --git a/Lib/php4/globalvar.i b/Lib/php/globalvar.i similarity index 100% rename from Lib/php4/globalvar.i rename to Lib/php/globalvar.i diff --git a/Lib/php4/php4.swg b/Lib/php/php.swg similarity index 96% rename from Lib/php4/php4.swg rename to Lib/php/php.swg index feaee68f6..d30e0b2a9 100644 --- a/Lib/php4/php4.swg +++ b/Lib/php/php.swg @@ -2,15 +2,15 @@ * 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. * - * php4.swg + * php.swg * - * PHP4 configuration file + * PHP configuration file * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg" // Common C API type-checking code -%runtime "php4run.swg" // Php4 runtime functions +%runtime "phprun.swg" // PHP runtime functions -%include // Php4 initialization routine. +%include // PHP initialization routine. %include // Global variables. %include @@ -73,6 +73,13 @@ $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) { @@ -295,4 +302,4 @@ /* php keywords */ -%include +%include diff --git a/Lib/php4/php4init.swg b/Lib/php/phpinit.swg similarity index 100% rename from Lib/php4/php4init.swg rename to Lib/php/phpinit.swg diff --git a/Lib/php4/php4kw.swg b/Lib/php/phpkw.swg similarity index 93% rename from Lib/php4/php4kw.swg rename to Lib/php/phpkw.swg index 0d28994c5..3d1a62511 100644 --- a/Lib/php4/php4kw.swg +++ b/Lib/php/phpkw.swg @@ -2,21 +2,21 @@ * 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. * - * php4kw.swg + * phpkw.swg * * The 'keywords' in PHP are global, ie, the following names are fine * when used as class methods. * ----------------------------------------------------------------------------- */ -#define PHPKW(x) %keywordwarn(`x` " is a php keyword, renamed as c_"`x`,sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` +#define PHPKW(x) %keywordwarn("'" `x` "' is a php keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` %define PHPCN(x) -%keywordwarn(`x` " is a php reserved class name, class renamed as c_"`x`,%$isclass,rename="c_%s") `x`; -%keywordwarn(`x` " is a php reserved class name, constructor renamed as c_"`x`,%$isconstructor,rename="c_%s") `x`; +%keywordwarn("'" `x` "' is a php reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`; +%keywordwarn("'" `x` "' is a php reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`; %enddef -#define PHPBN1(x) %builtinwarn(`x` " conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x` -#define PHPBN2(x) %builtinwarn(`x` " conflicts with a built-in name in php") "::" `x` +#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x` +#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php") "::" `x` /* @@ -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/php4/phppointers.i b/Lib/php/phppointers.i similarity index 100% rename from Lib/php4/phppointers.i rename to Lib/php/phppointers.i diff --git a/Lib/php4/php4run.swg b/Lib/php/phprun.swg similarity index 99% rename from Lib/php4/php4run.swg rename to Lib/php/phprun.swg index d38452764..b4e4276f5 100644 --- a/Lib/php4/php4run.swg +++ b/Lib/php/phprun.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. * - * php4run.swg + * phprun.swg * - * PHP4 runtime library + * PHP runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus diff --git a/Lib/php4/std_common.i b/Lib/php/std_common.i similarity index 100% rename from Lib/php4/std_common.i rename to Lib/php/std_common.i diff --git a/Lib/php4/std_deque.i b/Lib/php/std_deque.i similarity index 100% rename from Lib/php4/std_deque.i rename to Lib/php/std_deque.i diff --git a/Lib/php4/std_map.i b/Lib/php/std_map.i similarity index 97% rename from Lib/php4/std_map.i rename to Lib/php/std_map.i index c35f21dc7..c6721806b 100644 --- a/Lib/php4/std_map.i +++ b/Lib/php/std_map.i @@ -30,6 +30,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -69,6 +70,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -105,6 +107,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -142,6 +145,7 @@ namespace std { map(const map &); unsigned int size() const; + %rename(is_empty) empty; bool empty() const; void clear(); %extend { diff --git a/Lib/php4/std_pair.i b/Lib/php/std_pair.i similarity index 100% rename from Lib/php4/std_pair.i rename to Lib/php/std_pair.i diff --git a/Lib/php4/std_string.i b/Lib/php/std_string.i similarity index 100% rename from Lib/php4/std_string.i rename to Lib/php/std_string.i diff --git a/Lib/php4/std_vector.i b/Lib/php/std_vector.i similarity index 98% rename from Lib/php4/std_vector.i rename to Lib/php/std_vector.i index fe084aca4..b54181618 100644 --- a/Lib/php4/std_vector.i +++ b/Lib/php/std_vector.i @@ -48,6 +48,7 @@ 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; @@ -86,6 +87,7 @@ 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/php4/stl.i b/Lib/php/stl.i similarity index 100% rename from Lib/php4/stl.i rename to Lib/php/stl.i diff --git a/Lib/php4/typemaps.i b/Lib/php/typemaps.i similarity index 85% rename from Lib/php4/typemaps.i rename to Lib/php/typemaps.i index c388fdf96..c5b749578 100644 --- a/Lib/php4/typemaps.i +++ b/Lib/php/typemaps.i @@ -107,6 +107,17 @@ int_typemap(unsigned char); %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *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) 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(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; @@ -117,6 +128,16 @@ int_typemap(unsigned char); %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *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) unsigned short &INOUT= unsigned short *OUTPUT; +%typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; +%typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; + %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ convert_to_string_ex($input); diff --git a/Lib/php4/utils.i b/Lib/php/utils.i similarity index 96% rename from Lib/php4/utils.i rename to Lib/php/utils.i index f7241187c..661a48777 100644 --- a/Lib/php4/utils.i +++ b/Lib/php/utils.i @@ -29,14 +29,14 @@ %enddef %define %pass_by_val( TYPE, CONVERT_IN ) -%typemap(in) TYPE +%typemap(in) TYPE, const TYPE & %{ CONVERT_IN($1,$1_ltype,$input); %} %enddef %fragment("t_output_helper","header") %{ -void +static void t_output_helper( zval **target, zval *o) { if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ diff --git a/Lib/pike/pikekw.swg b/Lib/pike/pikekw.swg index 85fd091a8..844b1f189 100644 --- a/Lib/pike/pikekw.swg +++ b/Lib/pike/pikekw.swg @@ -2,7 +2,7 @@ #define PIKE_PIKEKW_SWG_ /* Warnings for Pike keywords */ -#define PIKEKW(x) %namewarn("314:" #x " is a pike keyword") #x +#define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x /* from diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 176ee3336..836d107ce 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -107,7 +107,7 @@ namespace Swig { /* memory handler */ struct GCItem { - virtual ~GCItem() = 0; + virtual ~GCItem() {} virtual int get_own() const { @@ -115,10 +115,6 @@ namespace Swig { } }; - GCItem::~GCItem() - { - } - struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) @@ -212,10 +208,7 @@ 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 c0e7d5ea9..294ab9178 100644 --- a/Lib/python/file.i +++ b/Lib/python/file.i @@ -20,11 +20,13 @@ 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 new file mode 100644 index 000000000..3da06b5a9 --- /dev/null +++ b/Lib/python/pyabc.i @@ -0,0 +1,10 @@ +%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 1d5148dbf..d980f9263 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -27,6 +27,20 @@ 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 new file mode 100644 index 000000000..3dc4c2121 --- /dev/null +++ b/Lib/python/pybuffer.i @@ -0,0 +1,107 @@ +/* Impelementing 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 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(); + } SWIG_PYTHON_THREAD_END_BLOCK; return res; } @@ -597,6 +608,11 @@ namespace swig return !(self->empty()); } + /* Alias for Python 3 compatibility */ + bool __bool__() const { + return !(self->empty()); + } + size_type __len__() const { return self->size(); } @@ -618,6 +634,14 @@ 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); } @@ -634,6 +658,43 @@ 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 @@ -738,12 +799,12 @@ namespace swig { typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { -#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS +%#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } -#endif +%#endif size_type size = seq.size(); if (size <= (size_type)INT_MAX) { PyObject *obj = PyTuple_New((int)size); diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index e287e2fc8..01cf53e9b 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -58,12 +58,12 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + + PyErr_Format(type, "%s %s", + SWIG_Python_str_AsChar(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 7839511bc..d73d3d112 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -1,3 +1,47 @@ +/* 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 boht Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + str = PyUnicode_AsUTF8String(str); + return PyBytes_AsString(str); +#else + return PyString_AsString(str); +#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 diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index e6109b7bd..ab55765ad 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -33,18 +33,48 @@ 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; } @@ -52,7 +82,7 @@ SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", PyString_AsString(str)); + fprintf(fp,"%s\n", SWIG_Python_str_AsChar(str)); Py_DECREF(str); return 0; } @@ -110,8 +140,13 @@ 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) */ @@ -147,7 +182,10 @@ 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; @@ -272,13 +310,35 @@ SWIG_Python_FixMethods(PyMethodDef *methods, #ifdef __cplusplus extern "C" #endif -SWIGEXPORT void SWIG_init(void) { + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 + PyObject* +#else + void +#endif +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 + static struct PyModuleDef SWIG_module = { + PyModuleDef_HEAD_INIT, + (char *) SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; + + 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 e2dfbc3f5..62a7eaf70 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -38,18 +38,18 @@ namespace swig { virtual PySwigIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual PySwigIterator *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 PySwigIterator &x) const + virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } - virtual bool equal (const PySwigIterator &x) const + virtual bool equal (const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } @@ -66,6 +66,12 @@ namespace swig { return obj; } + /* Make an alias for Python 3.x */ + PyObject *__next__() + { + return next(); + } + PyObject *previous() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads @@ -335,6 +341,7 @@ namespace swig %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::next(); %catches(swig::stop_iteration) PySwigIterator::previous(); %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n); @@ -370,6 +377,7 @@ namespace swig virtual PySwigIterator *copy() const = 0; PyObject *next(); + PyObject *__next__(); PyObject *previous(); PySwigIterator *advance(ptrdiff_t n); diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index 76f1e6789..bd5c954f0 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -33,6 +33,12 @@ /* 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 */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 844a66bec..4f51d3a95 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -348,9 +348,13 @@ PySwigObject_format(const char* fmt, PySwigObject *v) PyObject *args = PyTuple_New(1); if (args) { if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); + PyObject *ofmt = SWIG_Python_str_FromChar(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); @@ -380,7 +384,7 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) { const char *name = SWIG_TypePrettyName(v->ty); PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); + PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS @@ -388,7 +392,14 @@ PySwigObject_repr(PySwigObject *v, PyObject *args) #else 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; } @@ -402,7 +413,7 @@ PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) PyObject *repr = PySwigObject_repr(v, NULL); #endif if (repr) { - fputs(PyString_AsString(repr), fp); + fputs(SWIG_Python_str_AsChar(repr), fp); Py_DECREF(repr); return 0; } else { @@ -415,7 +426,7 @@ PySwigObject_str(PySwigObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; + SWIG_Python_str_FromChar(result) : 0; } SWIGRUNTIME int @@ -426,6 +437,24 @@ PySwigObject_compare(PySwigObject *v, PySwigObject *w) return (i < j) ? -1 : ((i > j) ? 1 : 0); } +/* Added for Python 3.x, whould it also useful for Python 2.x? */ +SWIGRUNTIME PyObject* +PySwigObject_richcompare(PySwigObject *v, PySwigObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + if( (PySwigObject_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* @@ -436,8 +465,8 @@ PySwigObject_type(void) { SWIGRUNTIMEINLINE int PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); + return (Py_TYPE(op) == PySwigObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"PySwigObject") == 0); } SWIGRUNTIME PyObject * @@ -610,7 +639,10 @@ _PySwigObject_type(void) { (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*/ @@ -624,13 +656,19 @@ _PySwigObject_type(void) { 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif (unaryfunc)PySwigObject_long, /*nb_int*/ (unaryfunc)PySwigObject_long, /*nb_long*/ (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 (unaryfunc)PySwigObject_oct, /*nb_oct*/ (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ +#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 */ 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 */ @@ -644,8 +682,13 @@ _PySwigObject_type(void) { if (!type_init) { const PyTypeObject tmp = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ + /* 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 *)"PySwigObject", /* tp_name */ sizeof(PySwigObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -672,7 +715,7 @@ _PySwigObject_type(void) { swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + (richcmpfunc)PySwigObject_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ @@ -704,7 +747,10 @@ _PySwigObject_type(void) { #endif }; pyswigobject_type = tmp; + /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ +#if PY_VERSION_HEX < 0x03000000 pyswigobject_type.ob_type = &PyType_Type; +#endif type_init = 1; } return &pyswigobject_type; @@ -753,9 +799,9 @@ PySwigPacked_repr(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); + return SWIG_Python_str_FromFormat("", result, v->ty->name); } else { - return PyString_FromFormat("", v->ty->name); + return SWIG_Python_str_FromFormat("", v->ty->name); } } @@ -764,9 +810,9 @@ PySwigPacked_str(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); } else { - return PyString_FromString(v->ty->name); + return SWIG_Python_str_FromChar(v->ty->name); } } @@ -811,8 +857,13 @@ _PySwigPacked_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, /* ob_size */ + 0, /* ob_size */ +#endif (char *)"PySwigPacked", /* tp_name */ sizeof(PySwigPacked), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -867,7 +918,10 @@ _PySwigPacked_type(void) { #endif }; pyswigpacked_type = tmp; + /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ +#if PY_VERSION_HEX < 0x03000000 pyswigpacked_type.ob_type = &PyType_Type; +#endif type_init = 1; } return &pyswigpacked_type; @@ -912,7 +966,7 @@ PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { - return PyString_FromString("this"); + return SWIG_Python_str_FromChar("this"); } SWIGRUNTIME PyObject * @@ -924,6 +978,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 PySwigObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { @@ -1161,10 +1220,17 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) #endif } } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + Py_INCREF(data->newargs); + 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 @@ -1344,8 +1410,13 @@ 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); @@ -1365,7 +1436,7 @@ SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); + PyObject *key = SWIG_Python_str_FromChar(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { @@ -1403,9 +1474,9 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + PyErr_Format(type, "%s %s", mesg, SWIG_Python_str_AsChar(old_str)); } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); } Py_DECREF(old_str); } @@ -1454,7 +1525,7 @@ 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 ? PyString_AsString(str) : 0; + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index d4d60c42b..5a06792d7 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -5,10 +5,20 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { - if (PyString_Check(obj)) { +%#if PY_VERSION_HEX>=0x03000000 + if (PyUnicode_Check(obj)) +%#else + if (PyString_Check(obj)) +%#endif + { char *cstr; Py_ssize_t len; +%#if PY_VERSION_HEX>=0x03000000 + obj = PyUnicode_AsUTF8String(obj); + PyBytes_AsStringAndSize(obj, &cstr, &len); +%#else PyString_AsStringAndSize(obj, &cstr, &len); - if (cptr) { +%#endif + if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner @@ -33,7 +43,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) *alloc = SWIG_OLDOBJ; } } else { - *cptr = PyString_AsString(obj); + *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; @@ -64,7 +74,11 @@ 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/pythonkw.swg b/Lib/python/pythonkw.swg index f57d34ce4..2ee233516 100644 --- a/Lib/python/pythonkw.swg +++ b/Lib/python/pythonkw.swg @@ -2,8 +2,8 @@ Warnings for Python keywords, built-in names and bad names. */ -#define PYTHONKW(x) %keywordwarn(`x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x` -#define PYTHONBN(x) %builtinwarn(`x` " conflicts with a built-in name in python") "::"`x` +#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x` +#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") "::"`x` /* diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 8254bf8f7..4161dcb0f 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -8,12 +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) { int len = PyUnicode_GetSize(obj); if (cptr) { diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 12dc23ccf..b080731f0 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -22,6 +22,10 @@ int res = SWIG_ERROR; if (PyDict_Check(obj)) { PyObject_var 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 res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 3095529a0..0a4d0c36e 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -12,6 +12,8 @@ SWIGEXPORT void SWIG_init(void) { %} +%include + #define %Rruntime %insert("s") #define SWIG_Object SEXP @@ -77,7 +79,7 @@ SWIG_InitializeModule(0); %typemap(scheck) int %{ if(length($input) > 1) { - Rf_warning("using only the first element of $input") + warning("using only the first element of $input") } %} diff --git a/Lib/r/rkw.swg b/Lib/r/rkw.swg new file mode 100644 index 000000000..2c181faa0 --- /dev/null +++ b/Lib/r/rkw.swg @@ -0,0 +1,32 @@ +/* + Warnings for R keywords, built-in names and bad names. +*/ + +#define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x` + +/* + Warnings for R reserved words taken from + http://cran.r-project.org/doc/manuals/R-lang.html#Reserved-words +*/ + +RKW(if); +RKW(else); +RKW(repeat); +RKW(while); +RKW(function); +RKW(for); +RKW(in); +RKW(next); +RKW(break); +RKW(TRUE); +RKW(FALSE); +RKW(NULL); +RKW(Inf); +RKW(NaN); +RKW(NA); +RKW(NA_integer_); +RKW(NA_real_); +RKW(NA_complex_); +RKW(NA_character_); + +#undef RKW diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index e3cae5778..919695ec2 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -691,10 +691,12 @@ namespace swig for ( ; i != e; ) { VALUE r = swig::from< Sequence::value_type >(*i); - if ( RTEST( rb_yield(r) ) ) + if ( RTEST( rb_yield(r) ) ) { $self->erase(i++); - else + e = self->end(); + } else { ++i; + } } return self; diff --git a/Lib/ruby/rubykw.swg b/Lib/ruby/rubykw.swg index fec47baff..194687b95 100644 --- a/Lib/ruby/rubykw.swg +++ b/Lib/ruby/rubykw.swg @@ -2,7 +2,7 @@ #define RUBY_RUBYKW_SWG_ /* Warnings for Ruby keywords */ -#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s",fullname=1) `x` +#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x` /* diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg index 09de6c969..b943afb47 100644 --- a/Lib/swiglabels.swg +++ b/Lib/swiglabels.swg @@ -40,6 +40,12 @@ # endif #endif +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + #ifndef SWIGUNUSEDPARM # ifdef __cplusplus # define SWIGUNUSEDPARM(p) diff --git a/Lib/typemaps/primtypes.swg b/Lib/typemaps/primtypes.swg index c59aa1d1e..42728e5fe 100644 --- a/Lib/typemaps/primtypes.swg +++ b/Lib/typemaps/primtypes.swg @@ -283,6 +283,7 @@ _apply_macro(Macro, ptrdiff_t , Arg2); _apply_macro(Macro, std::size_t, Arg2); _apply_macro(Macro, std::ptrdiff_t, Arg2); _apply_macro(Macro, std::string, Arg2); +_apply_macro(Macro, std::wstring, Arg2); _apply_macro(Macro, std::complex, Arg2); _apply_macro(Macro, std::complex, Arg2); %enddef diff --git a/README b/README index 61550e558..2898130b0 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.35 (7 April 2008) +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,6 +91,13 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.36 summary: +- Enhancement to directors to wrap all protected members +- Optimisation feature for objects returned by value +- A few bugs fixes in the PHP, Java, Ruby, R, C#, Python, Lua and + Perl modules +- Other minor generic bug fixes + SWIG-1.3.35 summary: - Octave language module added - Bug fixes in Python, Lua, Java, C#, Perl modules diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 13e976b95..12556dcf6 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -420,23 +420,23 @@ int yylook(void) { return HBLOCK; case SWIG_TOKEN_COMMENT: - { - String *cmt = Scanner_text(scan); - char *loc = Char(cmt); - if ((strncmp(loc,"/*@SWIG@",6) == 0) && (loc[Len(cmt)-3] == '@')) { - scanner_locator(cmt); - } - if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { - printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); - yylval.str = NewString(loc); - return DOXYGENPOSTSTRING; - } - if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); - yylval.str = NewString(loc); - return DOXYGENSTRING; - } - } + { + String *cmt = Scanner_text(scan); + char *loc = Char(cmt); + if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { + scanner_locator(cmt); + } + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { + printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return DOXYGENPOSTSTRING; + } + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + yylval.str = NewString(loc); + return DOXYGENSTRING; + } + } break; case SWIG_TOKEN_ENDLINE: break; @@ -700,7 +700,15 @@ int yylex(void) { termtoken = SWIG_TOKEN_LPAREN; termvalue = "("; break; - } else if (nexttok == SWIG_TOKEN_SEMI) { + } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { + termtoken = SWIG_TOKEN_CODEBLOCK; + termvalue = Scanner_text(scan); + break; + } else if (nexttok == SWIG_TOKEN_LBRACE) { + termtoken = SWIG_TOKEN_LBRACE; + termvalue = "{"; + break; + } else if (nexttok == SWIG_TOKEN_SEMI) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; @@ -869,8 +877,14 @@ int yylex(void) { return (INLINE); if (strcmp(yytext, "%typemap") == 0) return (TYPEMAP); - if (strcmp(yytext, "%feature") == 0) + 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; 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 09aeb7381..d16a743e4 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -383,7 +383,9 @@ static void add_symbols(Node *n) { Delete(prefix); } - if (0 && !Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); + /* + if (!Getattr(n,"parentNode") && class_level) set_parentNode(n,class_decl[class_level - 1]); + */ Setattr(n,"ismember","1"); } } @@ -2348,21 +2350,25 @@ 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 */ @@ -2370,21 +2376,25 @@ 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(); } ; @@ -4215,10 +4225,11 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { /* Check for template names. If the class is a template and the constructor is missing the template part, we add it */ - if (Classprefix && (c = strchr(Char(Classprefix),'<'))) { - if (!Strchr($3,'<')) { - $3 = NewStringf("%s%s",$3,c); - } + if (Classprefix) { + c = strchr(Char(Classprefix),'<'); + if (c && !Strchr($3,'<')) { + $3 = NewStringf("%s%s",$3,c); + } } Setattr($$,"storage","virtual"); name = NewStringf("%s",$3); @@ -4534,12 +4545,8 @@ parms : rawparms { ; rawparms : parm ptail { - if (1) { - set_nextSibling($1,$2); - $$ = $1; - } else { - $$ = $2; - } + set_nextSibling($1,$2); + $$ = $1; } | empty { $$ = 0; } ; @@ -4592,12 +4599,8 @@ valparms : rawvalparms { ; rawvalparms : valparm valptail { - if (1) { - set_nextSibling($1,$2); - $$ = $1; - } else { - $$ = $2; - } + set_nextSibling($1,$2); + $$ = $1; } | empty { $$ = 0; } ; diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index a1f0c8e08..a3e992f83 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -167,18 +167,21 @@ 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 && strchr(Char(name), '<')) { - Append(patchlist, Getattr(n, "name")); - } else { - Append(name, templateargs); + if (name) { + if (strchr(Char(name), '<')) + Append(patchlist, Getattr(n, "name")); + else + Append(name, templateargs); } name = Getattr(n, "sym:name"); - if (name && strchr(Char(name), '<')) { - String *sn = Copy(tname); - Setattr(n, "sym:name", sn); - Delete(sn); - } else { - Replace(name, tname, rname, DOH_REPLACE_ANY); + 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); + } } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); @@ -281,13 +284,13 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab Delete(ptargs); } - if (0) { + /* Parm *p = tparms; while (p) { Printf(stdout, "tparm: '%s' '%s' '%s'\n", Getattr(p, "name"), Getattr(p, "type"), Getattr(p, "value")); p = nextSibling(p); } - } + */ /* Printf(stdout,"targs = '%s'\n", templateargs); Printf(stdout,"rname = '%s'\n", rname); diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index ccb94314a..62aef10f2 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -112,12 +112,11 @@ static void DelHash(DOH *ho) { int i; for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - next = n->next; - DelNode(n); - n = next; - } + n = h->hashtable[i]; + while (n) { + next = n->next; + DelNode(n); + n = next; } } DohFree(h->hashtable); @@ -138,12 +137,11 @@ static void Hash_clear(DOH *ho) { int i; for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - next = n->next; - DelNode(n); - n = next; - } + n = h->hashtable[i]; + while (n) { + next = n->next; + DelNode(n); + n = next; } h->hashtable[i] = 0; } @@ -454,11 +452,10 @@ static DOH *CopyHash(DOH *ho) { nho = DohObjMalloc(&DohHashType, nh); for (i = 0; i < h->hashsize; i++) { - if ((n = h->hashtable[i])) { - while (n) { - Hash_setattr(nho, n->key, n->object); - n = n->next; - } + n = h->hashtable[i]; + while (n) { + Hash_setattr(nho, n->key, n->object); + n = n->next; } } return nho; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 174e8b001..8c4678847 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -247,10 +247,17 @@ /* please leave 850-869 free for Modula 3 */ -#define WARN_PHP4_MULTIPLE_INHERITANCE 870 -#define WARN_PHP4_UNKNOWN_PRAGMA 871 +/* 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_PHP4_MULTIPLE_INHERITANCE 870 +#define WARN_PHP4_UNKNOWN_PRAGMA 871 -/* please leave 870-889 free for Php */ +#define WARN_PHP_MULTIPLE_INHERITANCE 870 +#define WARN_PHP_UNKNOWN_PRAGMA 871 + +/* please leave 870-889 free for PHP */ /* Feel free to claim any number in this space that's not currently being used. Just make sure you diff --git a/Source/Makefile.am b/Source/Makefile.am index 1abe41cbd..65b5c6f6f 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -57,7 +57,7 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/octave.cxx \ Modules/overload.cxx \ Modules/perl5.cxx \ - Modules/php4.cxx \ + Modules/php.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 561997276..217c89b1f 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1084,7 +1084,8 @@ void emit_synonym(Node *synonym) { of_ltype = lookup_defined_foreign_ltype(of_name); // Printf(f_clhead,";; from emit-synonym\n"); - Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); + if( of_ltype ) + 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); @@ -1521,6 +1522,8 @@ void ALLEGROCL::main(int argc, char *argv[]) { } + Preprocessor_define("SWIGALLEGROCL 1", 0); + allow_overloading(); } @@ -1531,7 +1534,7 @@ 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(), Swig_file_basename(Getattr(n,"infile"))); + Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); f_cl = NewFile(cl_filename, "w"); if (!f_cl) { @@ -2271,7 +2274,7 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) { return SWIG_OK; } -int ALLEGROCL::emit_defun(Node *n, File *f_cl) { +int ALLEGROCL::emit_defun(Node *n, File *fcl) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_defun: ENTER... "); #endif @@ -2307,27 +2310,27 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { if (Generate_Wrapper) { String *extra_parms = id_converter_arguments(n)->noname_str(); if (Getattr(n, "sym:overloaded")) - Printf(f_cl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); + Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); else - Printf(f_cl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); + Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms); Delete(extra_parms); } // Just C else { - Printf(f_cl, "(swig-defun (\"%s\" \"%s\")\n", funcname, Generate_Wrapper ? mangled_name : funcname); + Printf(fcl, "(swig-defun (\"%s\" \"%s\")\n", funcname, Generate_Wrapper ? mangled_name : funcname); } ////////////////////////////////////// // Lisp foreign call parameter list // ////////////////////////////////////// - Printf(f_cl, " ("); + Printf(fcl, " ("); /* Special cases */ if (ParmList_len(pl) == 0) { - Printf(f_cl, ":void"); + Printf(fcl, ":void"); /* } else if (any_varargs(pl)) { - Printf(f_cl, "#| varargs |#"); + Printf(fcl, "#| varargs |#"); varargs=1; */ } else { String *largs = NewString(""); @@ -2337,7 +2340,7 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype")); if (!first) { - Printf(f_cl, "\n "); + Printf(fcl, "\n "); } if (SwigType_isvarargs(argtype)) { @@ -2393,7 +2396,7 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { // if this parameter has been removed from the C/++ wrapper // it shouldn't be in the lisp wrapper either. if (!checkAttribute(p, "tmap:in:numinputs", "0")) { - Printf(f_cl, "(%s %s %s %s %s)", + Printf(fcl, "(%s %s %s %s %s)", // parms in the ff wrapper, but not in the lisp wrapper. (checkAttribute(p, "tmap:lin:numinputs", "0") ? ":p-" : ":p+"), argname, dispatchtype, ffitype, lisptype); @@ -2479,12 +2482,12 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { Replaceall(wrap->code, "$ldestructor", ldestructor); Delete(ldestructor); - Printf(f_cl, ")\n"); /* finish arg list */ + Printf(fcl, ")\n"); /* finish arg list */ ///////////////////////////////////////////////////// // Lisp foreign call return type and optimizations // ///////////////////////////////////////////////////// - Printf(f_cl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result")); + Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result")); for (Iterator option = First(n); option.item; option = Next(option)) { if (Strncmp("feature:ffargs:", option.key, 15)) @@ -2494,12 +2497,12 @@ int ALLEGROCL::emit_defun(Node *n, File *f_cl) { Replaceall(option_name, "_", "-"); // TODO: varargs vs call-direct ? - Printf(f_cl, "\n %s %s", option_name, option_val); + Printf(fcl, "\n %s %s", option_name, option_val); Delete(option_name); } - Printf(f_cl, ")\n %s)\n\n", wrap->code); + Printf(fcl, ")\n %s)\n\n", wrap->code); // Wrapper_print(wrap, stderr); Delete(result_type); @@ -2518,6 +2521,8 @@ int ALLEGROCL::functionWrapper(Node *n) { 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); @@ -2556,7 +2561,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", Getattr(n, "name"), Getattr(n, "sym:nextSibling")); + Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling")); if (!Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); @@ -2571,7 +2576,7 @@ int ALLEGROCL::functionWrapper(Node *n) { int gencomma = 0; #ifdef ALLEGROCL_DEBUG - Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), Getattr(n, "name")); + Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), name); #endif // Now walk the function parameter list and generate code to get arguments String *name_and_parms = NewStringf("%s (", mangled); @@ -2625,12 +2630,16 @@ int ALLEGROCL::functionWrapper(Node *n) { String *actioncode = emit_action(n); - 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); + String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + if (!is_void_return && 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); if (CPlusPlus) { Printf(f->code, " } catch (...) {\n"); @@ -2935,11 +2944,9 @@ int ALLEGROCL::classHandler(Node *n) { #endif if (Generate_Wrapper) - return cppClassHandler(n); + return cppClassHandler(n); else - return cClassHandler(n); - - return SWIG_OK; + return cClassHandler(n); } int ALLEGROCL::cClassHandler(Node *n) { diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index fb37392e8..4b3ddac70 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -444,7 +444,7 @@ int CFFI::functionWrapper(Node *n) { 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"); + if(!is_void_return) Printf(f->code, " return lresult;\n"); Delete(result_convert); emit_return_variable(n, Getattr(n, "type"), f); @@ -630,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); @@ -673,7 +673,7 @@ void CFFI::emit_class(Node *n) { Printf(supers, ")"); Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers); - Printf(f_clos, "\n ((ff :reader ff-pointer)))\n\n"); + Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n"); Parm *pattern = NewParm(Getattr(n, "name"), NULL); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index a76e09945..2298d2939 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -329,7 +329,6 @@ int CHICKEN::functionWrapper(Node *n) { Parm *p; int i; String *wname; - String *source; Wrapper *f; String *mangle = NewString(""); String *get_pointers; @@ -398,8 +397,6 @@ int CHICKEN::functionWrapper(Node *n) { SwigType *pt = Getattr(p, "type"); String *ln = Getattr(p, "lname"); - source = NewStringf("scm%d", i + 1); - Printf(f->def, ", C_word scm%d", i + 1); Printf(declfunc, ",C_word"); @@ -407,6 +404,7 @@ int CHICKEN::functionWrapper(Node *n) { if ((tm = Getattr(p, "tmap:in"))) { String *parse = Getattr(p, "tmap:in:parse"); if (!parse) { + String *source = NewStringf("scm%d", i + 1); Replaceall(tm, "$source", source); Replaceall(tm, "$target", ln); Replaceall(tm, "$input", source); @@ -445,20 +443,15 @@ int CHICKEN::functionWrapper(Node *n) { } } } - - } else { + Delete(source); } - p = Getattr(p, "tmap:in:next"); continue; } else { Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - - Delete(source); - p = nextSibling(p); } /* finish argument marshalling */ @@ -1510,7 +1503,7 @@ int CHICKEN::validIdentifier(String *s) { /* ------------------------------------------------------------ * closNameMapping() * Maps the identifier from C++ to the CLOS based on command - * line paramaters and such. + * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index df4677e26..431181355 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1073,7 +1073,9 @@ public: global_variable_flag = false; generate_property_declaration_flag = false; - Printf(module_class_code, "\n }\n\n"); + if (proxy_flag) { + Printf(module_class_code, "\n }\n\n"); + } return ret; } @@ -1885,6 +1887,7 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); + String *terminator_code = NewString(""); if (!proxy_flag) return; @@ -1924,7 +1927,7 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); if (setter_flag) @@ -1996,7 +1999,8 @@ public: if (!(variable_wrapper_flag && i == 0)) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); - last_parm = p; + if (setter_flag) + last_parm = p; /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { @@ -2032,6 +2036,14 @@ 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)); @@ -2057,7 +2069,8 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2069,6 +2082,9 @@ 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 }"); } @@ -2107,7 +2123,7 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // Properties if (generate_property_declaration_flag) { // Ensure the declaration is generated just once should the property contain both a set and get // Get the C# variable type - obtained differently depending on whether a setter is required. @@ -2168,6 +2184,7 @@ public: Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2188,6 +2205,7 @@ 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)); @@ -2283,6 +2301,14 @@ 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); @@ -2339,7 +2365,8 @@ public: bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); @@ -2351,6 +2378,9 @@ 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"); @@ -2369,6 +2399,7 @@ public: Delete(im_return_type); Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); @@ -2486,6 +2517,7 @@ 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) { @@ -2541,6 +2573,7 @@ public: num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2567,7 +2600,7 @@ public: if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in C# wrapper function (in proxy class) to type used in PInvoke function (in intermediary class) if ((tm = Getattr(p, "tmap:csin"))) { @@ -2589,6 +2622,14 @@ 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)); @@ -2613,7 +2654,8 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - if (is_pre_code || is_post_code) { + bool is_terminator_code = Len(terminator_code) > 0; + if (is_pre_code || is_post_code || is_terminator_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2625,6 +2667,9 @@ 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 }"); } @@ -2700,6 +2745,7 @@ public: Delete(pre_code); Delete(post_code); + Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2755,7 +2801,7 @@ public: value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a PINVOKE call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); @@ -2877,7 +2923,7 @@ public: * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2886,20 +2932,22 @@ public: String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that in C# properties, the input variable name is always called 'value' + Delete(arg); arg = NewString("value"); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 2390e8ad6..f5f080034 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1649,7 +1649,7 @@ public: /* ------------------------------------------------------------ * goopsNameMapping() * Maps the identifier from C++ to the GOOPS based * on command - * line paramaters and such. + * line parameters and such. * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index a21e37bf4..961f9098c 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2016,7 +2016,7 @@ public: Swig_warning(WARN_JAVA_TYPEMAP_JSTYPE_UNDEF, input_file, line_number, "No jstype typemap defined for %s\n", SwigType_str(t, 0)); } - if (proxy_flag && wrapping_member_flag && !enum_constant_flag) { + if (wrapping_member_flag && !enum_constant_flag) { // For wrapping member variables (Javabean setter) setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); } @@ -2578,6 +2578,7 @@ public: num_arguments = emit_num_arguments(l); num_required = emit_num_required(l); + bool global_or_member_variable = global_variable_flag || (wrapping_member_flag && !enum_constant_flag); int gencomma = 0; /* Output each parameter */ @@ -2602,7 +2603,7 @@ public: if (gencomma) Printf(imcall, ", "); - String *arg = makeParameterName(n, p, i, setter_flag); + String *arg = makeParameterName(n, p, i, global_or_member_variable); // Use typemaps to transform type used in Java wrapper function (in proxy class) to type used in JNI function (in intermediary class) if ((tm = Getattr(p, "tmap:javain"))) { @@ -2747,7 +2748,7 @@ public: value = Getattr(n, "enumvalue") ? Copy(Getattr(n, "enumvalue")) : Copy(Getattr(n, "enumvalueex")); } else { // Get the enumvalue from a JNI call - if (!getCurrentClass() || !cparse_cplusplus) { + if (!getCurrentClass() || !cparse_cplusplus || !proxy_flag) { // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); /* for wrapping of enums in a namespace when emit_action is used */ constantWrapper(n); @@ -2874,7 +2875,7 @@ public: * n - Node * p - parameter node * arg_num - parameter argument number - * setter - set this flag when wrapping member variables + * setter - set this flag when wrapping variables * Return: * arg - a unique parameter name * ----------------------------------------------------------------------------- */ @@ -2883,21 +2884,23 @@ public: String *arg = 0; String *pn = Getattr(p, "name"); - if (setter) { + + // Use C parameter name unless it is a duplicate or an empty parameter name + int count = 0; + ParmList *plist = Getattr(n, "parms"); + while (plist) { + if ((Cmp(pn, Getattr(plist, "name")) == 0)) + count++; + plist = nextSibling(plist); + } + String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; + arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + if (setter && Cmp(arg, "self") != 0) { // Note that for setters the parameter name is always set but sometimes includes C++ // scope resolution, so we need to strip off the scope resolution to make a valid name. + Delete(arg); arg = NewString("value"); //Swig_scopename_last(pn); - } else { - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - ParmList *plist = Getattr(n, "parms"); - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); } return arg; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 368dc2c85..e2fd93f7b 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1105,38 +1105,33 @@ int Language::globalfunctionHandler(Node *n) { String *name = Getattr(n, "name"); String *symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); - String *storage = Getattr(n, "storage"); ParmList *parms = Getattr(n, "parms"); - if (0 && (Cmp(storage, "static") == 0)) { - Swig_restore(n); - return SWIG_NOWRAP; /* Can't wrap static functions */ - } else { - /* Check for callback mode */ - String *cb = GetFlagAttr(n, "feature:callback"); - if (cb) { - String *cbname = Getattr(n, "feature:callback:name"); - if (!cbname) { - cbname = NewStringf(cb, symname); - Setattr(n, "feature:callback:name", cbname); - } - - callbackfunctionHandler(n); - if (Cmp(cbname, symname) == 0) { - Delete(cbname); - Swig_restore(n); - return SWIG_NOWRAP; - } - Delete(cbname); + /* Check for callback mode */ + String *cb = GetFlagAttr(n, "feature:callback"); + if (cb) { + String *cbname = Getattr(n, "feature:callback:name"); + if (!cbname) { + cbname = NewStringf(cb, symname); + Setattr(n, "feature:callback:name", cbname); } - Setattr(n, "parms", nonvoid_parms(parms)); - String *call = Swig_cfunction_call(name, parms); - String *cres = Swig_cresult(type, "result", call); - Setattr(n, "wrap:action", cres); - Delete(cres); - Delete(call); - functionWrapper(n); + + callbackfunctionHandler(n); + if (Cmp(cbname, symname) == 0) { + Delete(cbname); + Swig_restore(n); + return SWIG_NOWRAP; + } + Delete(cbname); } + Setattr(n, "parms", nonvoid_parms(parms)); + String *call = Swig_cfunction_call(name, parms); + String *cres = Swig_cresult(type, "result", call); + Setattr(n, "wrap:action", cres); + Delete(cres); + Delete(call); + functionWrapper(n); + Swig_restore(n); return SWIG_OK; } @@ -1384,9 +1379,6 @@ int Language::variableHandler(Node *n) { * ---------------------------------------------------------------------- */ int Language::globalvariableHandler(Node *n) { - String *storage = Getattr(n, "storage"); - if (0 && (Cmp(storage, "static") == 0)) - return SWIG_NOWRAP; variableWrapper(n); return SWIG_OK; } @@ -2116,8 +2108,8 @@ int Language::classDirector(Node *n) { String *using_protected_members_code = NewString(""); for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { Node *nodeType = Getattr(ni, "nodeType"); - bool cdecl = (Cmp(nodeType, "cdecl") == 0); - if (cdecl && !GetFlag(ni, "feature:ignore")) { + bool cdeclaration = (Cmp(nodeType, "cdecl") == 0); + if (cdeclaration && !GetFlag(ni, "feature:ignore")) { if (is_non_virtual_protected_access(ni)) { Node *overloaded = Getattr(ni, "sym:overloaded"); // emit the using base::member statement (but only once if the method is overloaded) @@ -3410,7 +3402,8 @@ int Language::is_assignable(Node *n) { SwigType *ftd = SwigType_typedef_resolve_all(type); SwigType *td = SwigType_strip_qualifiers(ftd); if (SwigType_type(td) == T_USER) { - if ((cn = Swig_symbol_clookup(td, 0))) { + cn = Swig_symbol_clookup(td, 0); + if (cn) { if ((Strcmp(nodeType(cn), "class") == 0)) { if (Getattr(cn, "allocate:noassign")) { SetFlag(n, "feature:immutable"); diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index f46c9e809..6113da960 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -490,8 +490,6 @@ public: Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - - p = nextSibling(p); } // add all argcheck code @@ -1101,7 +1099,6 @@ public: virtual int staticmemberfunctionHandler(Node *n) { current = STATIC_FUNC; return Language::staticmemberfunctionHandler(n); - current = NO_CPP; } /* ------------------------------------------------------------ @@ -1123,7 +1120,6 @@ public: // REPORT("staticmembervariableHandler",n); current = STATIC_VAR; return Language::staticmembervariableHandler(n); - current = NO_CPP; } /* --------------------------------------------------------------------- diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 3453f5de2..901ee812e 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -33,7 +33,7 @@ int GenerateDefault = 1; // Generate default constructors int Verbose = 0; int AddExtern = 0; int NoExcept = 0; -int SwigRuntime = 0; // 0 = no option, 1 = -c or -runtime, 2 = -noruntime +int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime /* Suppress warning messages for private inheritance, preprocessor evaluation etc... WARN_PP_EVALUATION 202 @@ -491,13 +491,13 @@ void SWIG_getoptions(int argc, char *argv[]) { Wrapper_compact_print_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-runtime") == 0) { + } else if (strcmp(argv[i], "-runtime") == 0) { // Used to also accept -c. removed in swig-1.3.36 Swig_mark_arg(i); - Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n"); + Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 1; - } else if ((strcmp(argv[i], "-c") == 0) || (strcmp(argv[i], "-noruntime") == 0)) { + } else if (strcmp(argv[i], "-noruntime") == 0) { Swig_mark_arg(i); - Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-c, -runtime, -noruntime command line options are deprecated.\n"); + Swig_warning(WARN_DEPRECATED_OPTC, "SWIG", 1, "-runtime, -noruntime command line options are deprecated.\n"); SwigRuntime = 2; } else if (strcmp(argv[i], "-external-runtime") == 0) { external_runtime = 1; diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 99d28e167..6cb24d39a 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -472,9 +472,9 @@ MODULA3(): cap = true; } else { if (cap) { - m3sym[i] = toupper(c); + m3sym[i] = (char)toupper(c); } else { - m3sym[i] = tolower(c); + m3sym[i] = (char)tolower(c); } cap = false; } diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 9f5677ba5..0d0f4c7f2 100755 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1292,56 +1292,50 @@ public: * which means looking up and registering by typedef and enum name. */ int enumDeclaration(Node *n) { String *name = Getattr(n, "name"); - 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("")); + 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("")); - /* 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), "::"); - } - } - - 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); + strip_position += 2; + oname = NewString(strip_position); + strip_position = strstr(Char(oname), "::"); } - Printf(f_enumtypes_type, "| `%s\n", oname); - Insert(fully_qualified_name, 0, "enum "); - Setattr(seen_enums, fully_qualified_name, n); + 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); + } } int ret = Language::enumDeclaration(n); diff --git a/Source/Modules/php4.cxx b/Source/Modules/php.cxx similarity index 64% rename from Source/Modules/php4.cxx rename to Source/Modules/php.cxx index cfe948e3f..9369c2489 100644 --- a/Source/Modules/php4.cxx +++ b/Source/Modules/php.cxx @@ -13,11 +13,9 @@ * Short term: * * Sort out auto-renaming of method and class names which are reserved - * words (e.g. empty, clone, exception, etc.) vs -php4/-php5 in some - * sane way. + * words (e.g. empty, clone, exception, etc.) * - * Sort out wrapping of static member variables in OO PHP5 (which first may - * mean we need to sort them out for PHP4!) + * Sort out wrapping of static member variables in OO PHP5. * * Medium term: * @@ -39,7 +37,7 @@ /* * TODO: Replace remaining stderr messages with Swig_error or Swig_warning - * (may need to add more WARN_PHP4_xxx codes...) + * (may need to add more WARN_PHP_xxx codes...) */ char cvsroot_php4_cxx[] = "$Id$"; @@ -50,16 +48,10 @@ char cvsroot_php4_cxx[] = "$Id$"; #include static const char *usage = (char *) "\ -PHP Options (available with -php4 or -php5)\n\ +PHP Options (available with -php5)\n\ -cppext - cpp file extension (default to .cpp)\n\ -noproxy - Don't generate proxy classes.\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 PHP4 store the pointer to the C++ class in @@ -76,16 +68,9 @@ 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 int gen_extra = 0; -static int gen_make = 0; - static File *f_runtime = 0; static File *f_h = 0; static File *f_phpcode = 0; @@ -116,9 +101,6 @@ 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; @@ -150,45 +132,44 @@ void SwigPHP_emit_resource_registrations() { ki = First(zend_types); if (ki.key) Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); - while (ki.key) - if (1 /* is pointer type */ ) { - DOH *key = ki.key; - Node *class_node = ki.item; - String *human_name = key; + while (ki.key) { + DOH *key = ki.key; + Node *class_node = ki.item; + String *human_name = key; - // Write out destructor function header - Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); + // Write out destructor function header + Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); - // write out body - if ((class_node != NOTCLASS)) { - String *destructor = Getattr(class_node, "destructor"); - human_name = Getattr(class_node, "sym:name"); - if (!human_name) - human_name = Getattr(class_node, "name"); - // Do we have a known destructor for this type? - if (destructor) { - Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); - } else { - Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); - } + // write out body + if ((class_node != NOTCLASS)) { + String *destructor = Getattr(class_node, "destructor"); + human_name = Getattr(class_node, "sym:name"); + if (!human_name) + human_name = Getattr(class_node, "name"); + // Do we have a known destructor for this type? + if (destructor) { + Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); } else { - Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); + Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); } - - // close function - Printf(s_wrappers, "}\n"); - - // declare le_swig_ to store php registration - Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); - - // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); - - // store php type in class struct - Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); - - ki = Next(ki); + } else { + Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); } + + // close function + Printf(s_wrappers, "}\n"); + + // declare le_swig_ to store php registration + Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); + + // register with php + Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); + + // store php type in class struct + Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); + + ki = Next(ki); + } } class PHP:public Language { @@ -217,327 +198,56 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - int i; - SWIG_library_directory("php4"); + SWIG_library_directory("php"); SWIG_config_cppext("cpp"); - for (i = 1; i < argc; i++) { - if (argv[i]) { - if (strcmp(argv[i], "-phpfull") == 0) { - gen_extra = 1; + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "-prefix") == 0) { + if (argv[i + 1]) { + prefix = NewString(argv[i + 1]); Swig_mark_arg(i); - } 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); - } else if (strcmp(argv[i], "-make") == 0) { - gen_make = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); + 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); + } 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((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); - } + Preprocessor_define("SWIGPHP 1", 0); + Preprocessor_define("SWIGPHP5 1", 0); SWIG_typemap_lang("php4"); - /* DB: Suggest using a language configuration file */ - SWIG_config_file("php4.swg"); + SWIG_config_file("php.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() * ------------------------------------------------------------ */ @@ -610,9 +320,8 @@ public: 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 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, " // 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, " if (!dl('%s.so')) return;\n", module); Printf(f_phpcode, " } else {\n"); Printf(f_phpcode, " if (!dl('%s.'.PHP_SHLIB_SUFFIX)) return;\n", module); @@ -728,9 +437,6 @@ 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"); @@ -741,10 +447,6 @@ 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 @@ -841,22 +543,12 @@ 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; @@ -873,8 +565,6 @@ 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(); @@ -891,13 +581,7 @@ public: Printf(f->code, "argc = ZEND_NUM_ARGS();\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"); - } + Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); Replaceall(dispatch, "$args", "self,args"); @@ -946,8 +630,6 @@ 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; @@ -972,19 +654,6 @@ 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; @@ -992,20 +661,11 @@ public: String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); - 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); + // 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); emit_parameter_variables(l, f); /* Attach standard typemaps */ @@ -1019,10 +679,8 @@ public: int num_required = emit_num_required(l); numopt = num_arguments - num_required; - 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); + if (num_arguments > 0) { + String *args = NewStringf("zval **args[%d]", num_arguments); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; @@ -1037,34 +695,17 @@ 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 (!mvr) { - int num = num_arguments - has_this_ptr; - if (num == 0) { + } else { + if (num_arguments == 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, num); + Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } @@ -1090,19 +731,7 @@ public: SwigType *pt = Getattr(p, "type"); - 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); - } - } + source = NewStringf("args[%d]", i); String *ln = Getattr(p, "lname"); @@ -1184,24 +813,6 @@ 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 = SwigToPhpType(n, true); - 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); } @@ -1229,16 +840,7 @@ public: Delete(tm); } - - if (mvr) { - if (!mvrset) { - Printf(f->code, "return _return_value;\n"); - } else { - Printf(f->code, "return SUCCESS;\n"); - } - } else { - Printf(f->code, "return;\n"); - } + Printf(f->code, "return;\n"); /* Error handling code */ Printf(f->code, "fail:\n"); @@ -1440,6 +1042,10 @@ public: if (wrapperType == memberfn) p = nextSibling(p); while (p) { + if (GetInt(p, "tmap:in:numinputs") == 0) { + p = nextSibling(p); + continue; + } assert(0 <= argno && argno < max_num_of_arguments); String *&pname = arg_names[argno]; const char *pname_cstr = GetChar(p, "name"); @@ -1635,8 +1241,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 and even later PHP4 - * versions apparently, but we want to be maximally portable). + * (it's deprecated and off by default in PHP5, but we want to be + * maximally portable). */ Setattr(seen, "r", seen); @@ -1750,7 +1356,8 @@ public: } Printf(output, "\n"); - if (wrapperType == memberfn || newobject) { + // 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. @@ -1984,7 +1591,7 @@ public: Printf(pragma_phpinfo, "%s\n", value); } } else { - Swig_warning(WARN_PHP4_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); + Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); } } } @@ -2014,52 +1621,7 @@ public: current_class = n; // String *use_class_name=SwigType_manglestr(SwigType_ltype(t)); - 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) { + if (shadow) { char *rename = GetChar(n, "sym:name"); if (!addSymbol(rename, n)) @@ -2086,7 +1648,7 @@ public: } 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, + Swig_warning(WARN_PHP_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); } @@ -2098,217 +1660,7 @@ public: Language::classHandler(n); classnode = 0; - 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) { + if (shadow) { DOH *key; List *baselist = Getattr(n, "bases"); Iterator ki, base; @@ -2430,21 +1782,10 @@ 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; } @@ -2453,7 +1794,6 @@ public: * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { - wrapperType = membervar; Language::membervariableHandler(n); wrapperType = standard; @@ -2466,7 +1806,6 @@ public: * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { - wrapperType = staticmembervar; Language::staticmembervariableHandler(n); wrapperType = standard; @@ -2488,12 +1827,13 @@ public: * 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); @@ -2538,37 +1878,16 @@ 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; } - - String * SwigToPhpType(Node *n, int shadow_flag) { - String *ptype = 0; + String * GetShadowReturnType(Node *n) { SwigType *t = Getattr(n, "type"); - if (shadow_flag) { - ptype = PhpTypeFromTypemap((char *) "pstype", n, (char *) ""); - } - if (!ptype) { - ptype = PhpTypeFromTypemap((char *) "ptype", n, (char *) ""); - } - - if (ptype) return ptype; - /* Map type here */ switch (SwigType_type(t)) { case T_CHAR: @@ -2589,7 +1908,7 @@ public: case T_POINTER: case T_REFERENCE: case T_USER: - if (shadow_flag && is_shadow(t)) { + if (is_shadow(t)) { return NewString(Char(is_shadow(t))); } break; @@ -2597,7 +1916,7 @@ public: /* TODO */ break; default: - Printf(stderr, "SwigToPhpType: unhandled data type: %s\n", SwigType_str(t, 0)); + Printf(stderr, "GetShadowReturnType: unhandled data type: %s\n", SwigType_str(t, 0)); break; } @@ -2612,54 +1931,20 @@ public: return NewStringf("%s", tms); } - 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); - } + int abstractConstructorHandler(Node *) { 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; } @@ -2770,9 +2055,14 @@ static Language *new_swig_php(int php_version) { } return maininstance; } + extern "C" Language *swig_php4(void) { - return new_swig_php(4); + 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. } + extern "C" Language *swig_php5(void) { return new_swig_php(5); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bfdec0d76..7a878b4f8 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -49,10 +49,11 @@ 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; @@ -96,7 +97,6 @@ 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\ @@ -148,6 +148,8 @@ 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,9 +261,6 @@ 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); @@ -284,7 +283,6 @@ 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) { @@ -390,7 +388,6 @@ public: proxydel = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0) { - apply = 0; classic = 0; modern = 1; modernargs = 1; @@ -408,7 +405,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - apply = 0; classic = 0; modern = 1; dirvtable = 1; @@ -429,8 +425,17 @@ 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) { @@ -689,13 +694,46 @@ public: mod_docstring = NULL; } - Printf(f_shadow, "\nimport %s\n", module); + 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, "try:\n", NULL); + Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); + Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); + Printv(f_shadow, tab8, "finally:\n", NULL); + Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL); + Printv(f_shadow, 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); - 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 */ { @@ -722,7 +760,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", @@ -730,11 +768,17 @@ 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", - " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", "del types\n", "\n\n", NIL); +// " _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); } } if (modern) { @@ -760,7 +804,11 @@ public: } - Printf(f_header, "#define SWIG_init init%s\n\n", module); + 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_name \"%s\"\n", module); Printf(f_wrappers, "#ifdef __cplusplus\n"); @@ -769,6 +817,9 @@ 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); @@ -787,6 +838,12 @@ 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"); @@ -794,10 +851,6 @@ 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); @@ -831,6 +884,19 @@ public: 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},", name, name); + Delete(name); + return 0; + } /* ------------------------------------------------------------ * importDirective() @@ -874,25 +940,19 @@ public: return Language::importDirective(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. + * funcCall() + * Emit shadow code to call a function in the extension + * module. Using proper argument and calling style for + * given node n. * ------------------------------------------------------------ */ + String *funcCall(String *name, String *parms) { + String *str = NewString(""); - 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); - } + Printv(str, module, ".", name, "(", parms, ")", NIL); return str; - } + } + /* ------------------------------------------------------------ * pythoncode() - Output python code into the shadow file @@ -1060,29 +1120,84 @@ 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) { + String *make_autodocParmList(Node *n, bool showTypes, bool calling=false, bool func_annotation=false) { + + 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; @@ -1099,12 +1214,14 @@ public: type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - } else { - pnext = nextSibling(p); - } + 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++; + if (Len(doc)) { // add a comma to the previous one if any @@ -1116,39 +1233,40 @@ 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) { - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - Printf(doc, "%s ", type); + if (showTypes) + Printf(doc, "%s ", type); + + + Append(doc, name); + if (pdoc) { + if (!pdocs) + pdocs = NewString("Parameters:\n"); + Printf(pdocs, " %s\n", pdoc); } - if (name) { - Append(doc, name); - if (pdoc) { - if (!pdocs) - pdocs = NewString("Parameters:\n"); - Printf(pdocs, " %s\n", pdoc); - } - } else { - Append(doc, "?"); - } + // Write the function annoation + if (func_annotation) + Printf(doc, " : '%s'", type); - 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"); + // Write default value + if (value && !calling) { + String* pv = pyvalue(value, Getattr(p, "type")); + if (pv) + value = pv; 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) @@ -1286,6 +1404,132 @@ 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() @@ -1351,6 +1595,40 @@ 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() @@ -1360,24 +1638,26 @@ public: * ------------------------------------------------------------ */ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { - if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { - /* If there is no addtofunc directive then just assign from the extension module */ - Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); + 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, 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 = ", funcCall(name, callParms), "\n", NIL); + Printv(f_dest, ctab4, pythonappend(n), "\n", NIL); + Printv(f_dest, ctab4, "return val\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); - } + Printv(f_dest, ctab4, "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) */ + Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); + } } @@ -1773,7 +2053,6 @@ public: Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); break; } - p = nextSibling(p); } /* finish argument marshalling */ @@ -2461,7 +2740,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::PyObject_var name = PyString_FromString(method_name);\n"); + Printf(f_directors_h, " swig::PyObject_var name = SWIG_Python_str_FromChar(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); @@ -2596,6 +2875,16 @@ 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)) { @@ -2604,6 +2893,9 @@ 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)) { @@ -2694,7 +2986,7 @@ 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); @@ -2807,13 +3099,15 @@ 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, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); - Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); + Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); + Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); } } else { - Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); + Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); @@ -2823,11 +3117,11 @@ public: } if (have_pythonappend(n)) { fproxy = 0; - Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\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 ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); } } } @@ -2860,17 +3154,19 @@ public: if (shadow) { if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; - Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); + String *parms = make_pyParmList(n, true, false, kw); + String *callParms = make_pyParmList(n, true, true, kw); + Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); if (have_pythonappend(n)) { - Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\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 ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); } Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL); @@ -2942,8 +3238,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)); @@ -2957,23 +3253,30 @@ public: String *classname = Swig_class_name(parent); String *rclassname = Swig_class_name(getCurrentClass()); assert(rclassname); - if (use_director) { + + 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, "); 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, "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(f_shadow, tab4, "def __init__(self, *args", (allow_kwargs ? ", **kwargs" : ""), "): \n", NIL); + Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) 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,", funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); } else { Printv(f_shadow, - tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", + tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n", tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) @@ -2993,13 +3296,15 @@ 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, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); + Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\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, tab4, pythonprepend(n), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif @@ -3578,15 +3883,15 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (use_parse || !modernargs) { 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::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + } else { + Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((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::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); } else { - Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + Printf(w->code, "swig::PyObject_var swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); } } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 989136a9d..49d3ecc89 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -57,11 +57,13 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { Insert(tmp, 0, retName); return tmp; + /* if(count) return(b); Delete(b); return(NewString("")); + */ } #if 0 @@ -104,7 +106,7 @@ static String * getRType(Node *n) { Now handles arrays, i.e. struct A[2] ****************/ -static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { +static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); char *retName = Char(SwigType_manglestr(resolved)); @@ -115,6 +117,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { } return tmp; +/* #if 1 List *l = SwigType_split(retType); int n = Len(l); @@ -160,6 +163,7 @@ static String *getRClassName(String *retType, int addRef = 1, int upRef=0) { #endif return tmp; +*/ } /********************* @@ -1841,6 +1845,9 @@ int R::functionWrapper(Node *n) { String *name = Getattr(p,"name"); String *lname = Getattr(p,"lname"); + // R keyword renaming + if (name && Swig_name_warning(p, 0, name, 0)) + name = 0; /* If we have a :: in the parameter name because we are accessing a static member of a class, say, then we need to remove that prefix. */ @@ -2027,14 +2034,18 @@ int R::functionWrapper(Node *n) { Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); } - if(0 && addCopyParam) { +#if 0 + if(addCopyParam) { Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); Printf(f->code, "}\n else {\n"); } +#endif Printf(f->code, "%s\n", tm); - if(0 && addCopyParam) +#if 0 + if(addCopyParam) Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ +#endif } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index a57571bb8..ad448d34e 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -448,7 +448,7 @@ private: parent_name = Copy( Getattr(mod, "name") ); if ( parent_name ) { - (Char(parent_name))[0] = toupper((Char(parent_name))[0]); + (Char(parent_name))[0] = (char)toupper((Char(parent_name))[0]); } } if ( parent_name ) @@ -1194,7 +1194,7 @@ public: while (m.item) { if (Len(m.item) > 0) { String *cap = NewString(m.item); - (Char(cap))[0] = toupper((Char(cap))[0]); + (Char(cap))[0] = (char)toupper((Char(cap))[0]); if (last != 0) { Append(module, "::"); } @@ -1206,7 +1206,7 @@ public: if (feature == 0) { feature = Copy(last); } - (Char(last))[0] = toupper((Char(last))[0]); + (Char(last))[0] = (char)toupper((Char(last))[0]); modvar = NewStringf("m%s", last); Delete(modules); } @@ -2219,7 +2219,7 @@ public: return name; if (islower(name[0])) { - name[0] = toupper(name[0]); + name[0] = (char)toupper(name[0]); Swig_warning(WARN_RUBY_WRONG_NAME, input_file, line_number, "Wrong %s name (corrected to `%s')\n", reason, name); return name; } @@ -2545,7 +2545,7 @@ public: String *name = Copy(symname); char *cname = Char(name); if (cname) - cname[0] = toupper(cname[0]); + cname[0] = (char)toupper(cname[0]); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", " $director_new \n", diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 3b60f2259..5b103e71e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -74,8 +74,8 @@ static swig_module modules[] = { {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, - {"-php", swig_php4, 0}, - {"-php4", swig_php4, "PHP4"}, + {"-php", swig_php5, 0}, + {"-php4", swig_php4, 0}, {"-php5", swig_php5, "PHP5"}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 7a94b77bb..5d4affb8c 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -26,7 +26,6 @@ public: }; static File *f_cl = 0; -static File *f_null = 0; static struct { int count; @@ -225,15 +224,7 @@ void UFFI::main(int argc, char *argv[]) { int UFFI::top(Node *n) { String *module = Getattr(n, "name"); String *output_filename = NewString(""); - String *devnull = NewString("/dev/null"); - - f_null = NewFile(devnull, "w+"); - if (!f_null) { - FileErrorDisplay(devnull); - SWIG_exit(EXIT_FAILURE); - } - Delete(devnull); - + File *f_null = NewString(""); Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 560d12998..c04f95f00 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -36,6 +36,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe /* Test a character to see if it valid in an identifier (after the first letter) */ #define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$')) +DOH *Preprocessor_replace(DOH *); /* Skip whitespace */ static void skip_whitespace(String *s, String *out) { @@ -698,7 +699,6 @@ static String *get_options(String *str) { static String *expand_macro(String *name, List *args) { String *ns; DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e; - DOH *Preprocessor_replace(DOH *); int i, l; int isvarargs = 0; @@ -935,7 +935,6 @@ static String *expand_macro(String *name, List *args) { List *evaluate_args(List *x) { Iterator i; - String *Preprocessor_replace(String *); List *nl = NewList(); for (i = First(x); i.item; i = Next(i)) { @@ -1795,7 +1794,7 @@ String *Preprocessor_parse(String *s) { for (i = 0; i < 6;) { c = Getc(s); Putc(c, value); - statement[i++] = c; + statement[i++] = (char)c; if (strncmp(statement, ed, i) && strncmp(statement, df, i)) break; } diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 2fc444290..18920ecc2 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -513,7 +513,8 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int pname = Swig_cparm_name(p, i); i++; } else { - if ((pname = Getattr(p, "value"))) + pname = Getattr(p, "value"); + if (pname) pname = Copy(pname); else pname = Copy(Getattr(p, "name")); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 25ea0683f..3f47be15b 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -352,7 +352,8 @@ char *Swig_file_filename(const String_or_char *filename) { char *c; strcpy(tmp, Char(filename)); - if ((c = strrchr(tmp, *delim))) + c = strrchr(tmp, *delim); + if (c) return c + 1; else return tmp; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 04691b595..d29250517 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -614,7 +614,8 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) { *rlast = Copy(s); } - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + if (co) { if (co == cc) { *rprefix = 0; *rlast = Copy(s); @@ -664,7 +665,9 @@ String *Swig_scopename_prefix(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + + if (co) { if (co == cc) { return 0; } else { @@ -715,7 +718,8 @@ String *Swig_scopename_last(String *s) { if (!strstr(c, "::")) return NewString(s); - if ((co = strstr(cc, "operator "))) { + co = strstr(cc, "operator "); + if (co) { return NewString(co); } @@ -756,7 +760,9 @@ String *Swig_scopename_first(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(c, "operator "))) { + + co = strstr(c, "operator "); + if (co) { if (co == c) { return 0; } @@ -804,7 +810,9 @@ String *Swig_scopename_suffix(String *s) { char *co = 0; if (!strstr(c, "::")) return 0; - if ((co = strstr(c, "operator "))) { + + co = strstr(c, "operator "); + if (co) { if (co == c) return 0; } @@ -842,8 +850,9 @@ String *Swig_scopename_suffix(String *s) { int Swig_scopename_check(String *s) { char *c = Char(s); - char *co = 0; - if ((co = strstr(c, "operator "))) { + char *co = strstr(c, "operator "); + + if (co) { if (co == c) return 0; } diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 519e5b59e..f34a24612 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -482,7 +482,8 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType Delete(t_name); } /* A template-based class lookup */ - if (0 && !rn && SwigType_istemplate(prefix)) { + /* + if (!rn && SwigType_istemplate(prefix)) { String *t_prefix = SwigType_templateprefix(prefix); if (Strcmp(t_prefix, prefix) != 0) { String *t_name = SwigType_templateprefix(name); @@ -491,6 +492,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType } Delete(t_prefix); } + */ } /* A wildcard-based class lookup */ if (!rn) { @@ -1477,7 +1479,7 @@ String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType } - if (rename_hash || rename_list) { + if (rename_hash || rename_list || namewarn_hash || namewarn_list) { Hash *rn = Swig_name_object_get(Swig_name_rename_hash(), prefix, name, decl); if (!rn || !Swig_name_match_nameobj(rn, n)) { rn = Swig_name_nameobj_lget(Swig_name_rename_list(), n, prefix, name, decl); diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index e8b1b5f46..06e78db37 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -200,7 +200,7 @@ static char nextchar(Scanner * s) { if ((nc == '\n') && (!s->freeze_line)) s->line++; Putc(nc,s->text); - return nc; + return (char)nc; } /* ----------------------------------------------------------------------------- @@ -349,7 +349,7 @@ static void get_escape(Scanner *s) { } else { char tmp[3]; tmp[0] = '\\'; - tmp[1] = c; + tmp[1] = (char)c; tmp[2] = 0; Delitem(s->text, DOH_END); Append(s->text, tmp); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index f234839fe..18d1b2304 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -937,7 +937,8 @@ String *SwigType_templateargs(const SwigType *t) { int SwigType_istemplate(const SwigType *t) { char *ct = Char(t); - if ((ct = strstr(ct, "<(")) && (strstr(ct + 2, ")>"))) + ct = strstr(ct, "<("); + if (ct && (strstr(ct + 2, ")>"))) return 1; return 0; } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index fdf37ece1..a9e2898bd 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -108,6 +108,8 @@ static Hash *typedef_resolve_cache = 0; static Hash *typedef_all_cache = 0; static Hash *typedef_qualified_cache = 0; +static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix); + /* common attribute keys, to avoid calling find_key all the times */ /* @@ -162,7 +164,6 @@ void SwigType_typesystem_init() { * ----------------------------------------------------------------------------- */ int SwigType_typedef(SwigType *type, String_or_char *name) { - Typetab *SwigType_find_scope(Typetab *, String *s); if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ @@ -409,7 +410,7 @@ void SwigType_print_scope(Typetab *t) { } } -Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) { +static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) { Typetab *ss; String *nnameprefix = 0; static int check_parent = 1; @@ -846,7 +847,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) { String *result; int i, len; - if (t && strncmp(Char(t), "::", 2) == 0) { + if (strncmp(Char(t), "::", 2) == 0) { return Copy(t); } @@ -1311,7 +1312,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) { SwigType *ftd = SwigType_typedef_resolve_all(t); td = SwigType_strip_qualifiers(ftd); Delete(ftd); - if ((n = Swig_symbol_clookup(td, 0))) { + n = Swig_symbol_clookup(td, 0); + if (n) { if (GetFlag(n, "feature:valuewrapper")) { use_wrapper = 1; } else { @@ -1334,7 +1336,8 @@ SwigType *SwigType_alttype(SwigType *t, int local_tmap) { Delete(ftd); if (SwigType_type(td) == T_USER) { use_wrapper = 1; - if ((n = Swig_symbol_clookup(td, 0))) { + n = Swig_symbol_clookup(td, 0); + if (n) { if ((Checkattr(n, "nodeType", "class") && !Getattr(n, "allocate:noassign") && (Getattr(n, "allocate:default_constructor"))) @@ -1795,13 +1798,15 @@ void SwigType_inherit_equiv(File *out) { String *lprefix = SwigType_lstr(prefix, 0); Hash *subhash = Getattr(sub, bk.key); String *convcode = Getattr(subhash, "convcode"); - Printf(out, "static void *%s(void *x, int *newmemory) {", convname); if (convcode) { + char *newmemoryused = Strstr(convcode, "newmemory"); /* see if newmemory parameter is used in order to avoid unused parameter warnings */ String *fn = Copy(convcode); Replaceall(fn, "$from", "x"); + Printf(out, "static void *%s(void *x, int *%s) {", convname, newmemoryused ? "newmemory" : "SWIGUNUSEDPARM(newmemory)"); Printf(out, "%s", fn); } else { String *cast = Getattr(subhash, "cast"); + Printf(out, "static void *%s(void *x, int *SWIGUNUSEDPARM(newmemory)) {", convname); Printf(out, "\n return (void *)((%s) ", lkey); if (cast) Printf(out, "%s", cast); diff --git a/TODO b/TODO index d764d1d20..103185d23 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ SWIG TO-DO -Release: SWIG-1.3.35 +Release: SWIG-1.3.36 ----------------------------------------------------------------------------- diff --git a/Tools/WAD/Python/type.c b/Tools/WAD/Python/type.c index 5236c1c64..7d8248e0b 100644 --- a/Tools/WAD/Python/type.c +++ b/Tools/WAD/Python/type.c @@ -62,7 +62,7 @@ new_wadobject(WadFrame *f, int count) { /* release a wad object */ static void wadobject_dealloc(wadobject *self) { - PyMem_DEL(self); + PyObject_Del(self); } static char message[65536]; diff --git a/Tools/config/config.guess b/Tools/config/config.guess deleted file mode 100755 index 278f9e9e0..000000000 --- a/Tools/config/config.guess +++ /dev/null @@ -1,1516 +0,0 @@ -#! /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 Free Software Foundation, -# Inc. - -timestamp='2007-07-22' - -# 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 -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.*:*) - echo i386-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:*:[45]) - 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) - echo x86_64-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:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - 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 ;; - 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 xtensa-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 ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - 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 ;; - 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 deleted file mode 100755 index 1761d8bdf..000000000 --- a/Tools/config/config.sub +++ /dev/null @@ -1,1626 +0,0 @@ -#! /bin/sh -# Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, -# Inc. - -timestamp='2007-06-28' - -# 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 -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 \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64vr | mips64vrel \ - | mips64orion | mips64orionel \ - | 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) - 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-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64orion-* | mips64orionel-* \ - | 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-* \ - | tron-* \ - | v850-* | v850e-* | vax-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ - | xstormy16-* | xtensa-* \ - | ymp-* \ - | z8k-*) - ;; - # 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 - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - 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 - ;; - 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 - ;; - 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 - ;; - 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 - ;; - 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 - ;; - 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* \ - | -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 - ;; - -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/mkrelease.py b/Tools/mkrelease.py index 574720dab..d7927f8e6 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -21,8 +21,8 @@ except: print "where version should be 1.3.x and username is your SF username" sys.exit(1) -print "Looking for wput" -os.system("which wput") and failed("wput not installed/found. Please install.") +print "Looking for rsync" +os.system("which rsync") and failed("rsync not installed/found. Please install.") print "Making source tarball" os.system("python ./mkdist.py " + version) and failed("") @@ -31,8 +31,8 @@ print "Build Windows package" os.system("./mkwindows.sh " + version) and failed("") print "Uploading to Sourceforge" -os.system("wput --verbose --binary swig-" + version + ".tar.gz ftp://anonymous:" + username + "@users.sourceforge.net@upload.sourceforge.net/incoming/") and failed("") -os.system("wput --verbose --binary swigwin-" + version + ".zip ftp://anonymous:" + username + "@users.sourceforge.net@upload.sourceforge.net/incoming/") and failed("") +os.system("rsync --archive --verbose -P --times -e ssh swig-" + version + ".tar.gz " + username + "@frs.sourceforge.net:uploads/") and failed("") +os.system("rsync --archive --verbose -P --times -e ssh swigwin-" + version + ".zip " + username + "@frs.sourceforge.net:uploads/") and failed("") os.system("svn copy -m \"rel-" + version + "\" https://swig.svn.sourceforge.net/svnroot/swig/trunk https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-" + version + "/") diff --git a/configure.in b/configure.in index 82d83a4f0..8a09cd6f7 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.36],[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]) @@ -254,18 +254,6 @@ case $host in *) MZSCHEME_SO=.so;; esac -AC_SUBST(TCL_LDSHARED) -case $host in - *-*-darwin*) TCL_LDSHARED="gcc -dynamiclib -flat_namespace -undefined suppress";; - *) TCL_LDSHARED=$LDSHARED;; -esac - -AC_SUBST(TCL_CXXSHARED) -case $host in - *-*-darwin*) TCL_CXXSHARED="g++ -dynamiclib -flat_namespace -undefined suppress";; - *) TCL_CXXSHARED=$TRYLINKINGWITHCXX;; -esac - AC_SUBST(LUA_SO) case $host in *-*-darwin*) LUA_SO=.so;; @@ -388,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 @@ -547,11 +535,25 @@ case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; *)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 @@ -571,7 +573,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 @@ -655,6 +657,103 @@ 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]) +else +PYTHON3="$PY3BIN" +fi + +# Check for Python 3.x development tools (header files, static library and python3-config) +AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config]) + +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 #---------------------------------------------------------------- @@ -743,13 +842,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= -fi +else # First figure out what the name of Octave is @@ -790,6 +889,8 @@ else AC_MSG_RESULT(could not figure out how to run octave) fi +fi + AC_SUBST(OCTAVE) AC_SUBST(OCTAVEEXT) AC_SUBST(OCTAVE_SO) @@ -1125,7 +1226,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 "$RUBYDIR" != ""; then + if test x"$RUBYDIR" != x""; then dirs="$RUBYDIR" RUBYINCLUDE=none for i in $dirs; do @@ -1852,11 +1953,17 @@ AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= -if test -z "$PYINCLUDE" || test -z "$PYLIB" ; then +if (test -z "$PYINCLUDE" || test -z "$PYLIB") && + (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; 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 From 0db7edfa6341841c9802bce8deb2b2f21af60688 Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:17:39 +0000 Subject: [PATCH 0029/2031] Progress towards a working pydoc implementation. - Nodes are now passed to the documentation translator so that type information can be looked up and used in parameter comments. - Class comments are now inserted as well as some method information, git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10838 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 9 +- Source/DoxygenTranslator/src/DoxygenEntity.h | 12 + .../src/DoxygenTranslator.cpp | 12 +- .../DoxygenTranslator/src/DoxygenTranslator.h | 5 +- .../src/JavaDocConverter.cpp | 2 +- .../DoxygenTranslator/src/JavaDocConverter.h | 10 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 205 ++++++++++++++++++ Source/DoxygenTranslator/src/PyDocConverter.h | 29 +++ Source/Makefile.am | 2 + Source/Modules/java.cxx | 18 +- Source/Modules/python.cxx | 33 ++- 11 files changed, 314 insertions(+), 23 deletions(-) create mode 100644 Source/DoxygenTranslator/src/PyDocConverter.cpp create mode 100644 Source/DoxygenTranslator/src/PyDocConverter.h diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index d16a743e4..95bd8701d 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -13,7 +13,7 @@ #define yylex yylex -char cvsroot_parser_y[] = "$Id$"; +char cvsroot_parser_y[] = "$Id: parser.y 10767 2008-08-16 07:31:05Z cherylfoil $"; #include "swig.h" #include "cparse.h" @@ -3209,15 +3209,18 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { doxygen_comment : DOXYGENSTRING { + while(Strchr($1,'/') == Char($1)) + Replace($1,"/","",DOH_REPLACE_FIRST); if(isStructuralDoxygen($1)){ $$ = new_node("doxycomm"); Setattr($$,"DoxygenComment",$1); } else { if(currentComment != 0){ - Append(currentComment, $1); + Append(currentComment,$1); } - else currentComment = $1; + else + currentComment = $1; $$ = 0; } } diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 4313bfb2a..779065bdf 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -21,5 +21,17 @@ public: int isLeaf; }; +struct find_entity { + find_entity(string typeString) { + typeOfEntity = typeString; + } + + bool operator()(DoxygenEntity& entity) { + return entity.typeOfEntity == typeOfEntity; + } + + string typeOfEntity; +}; + #endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index d6f0ae152..7fe2897c5 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -5,13 +5,16 @@ #include #include "DoxygenEntity.h" #include "JavaDocConverter.h" +#include "PyDocConverter.h" DoxygenParser doxyParse; JavaDocConverter jDC; +PyDocConverter pyDC; DoxygenTranslator::DoxygenTranslator(){ doxyParse = DoxygenParser(); JavaDocConverter jDC = JavaDocConverter(); + PyDocConverter pyDC = PyDocConverter(); } DoxygenTranslator::~DoxygenTranslator(){ @@ -19,13 +22,16 @@ DoxygenTranslator::~DoxygenTranslator(){ } -char *DoxygenTranslator::convert(char* doxygenBlob, char* option){ +char *DoxygenTranslator::convert(Node *n, char* doxygenBlob, char* option){ list rootList = doxyParse.createTree(string(doxygenBlob)); string returnedString; if(strcmp(option, "JAVADOC") == 0){ - returnedString = jDC.convertToJavaDoc(rootList); + returnedString = jDC.convertToJavaDoc(n, rootList); + } + else if(strcmp(option, "PYDOC") == 0){ + returnedString = pyDC.convertToPyDoc(n, rootList); } else cout << "Option not current supported.\n"; char *nonConstString; @@ -59,7 +65,7 @@ int testCommands(){ //cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; char *nonConstString = (char *)malloc(exampleArray[i].length()+1); strcpy(nonConstString, exampleArray[i].c_str()); - char * result = dT.convert(nonConstString, "JAVADOC"); + char * result = dT.convert(NULL, nonConstString, "JAVADOC"); free(nonConstString); free(result); } diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index e5fe7bcbb..3c26e3a25 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -1,10 +1,13 @@ #ifndef DOXYGENTRANSLATOR_H_ #define DOXYGENTRANSLATOR_H_ + +#include "swig.h" + class DoxygenTranslator { public: DoxygenTranslator(); virtual ~DoxygenTranslator(); - char* convert(char* doxygenBlob, char* option); + char* convert(Node *n, char* doxygenBlob, char* option); }; #endif /*DOXYGENTRANSLATOR_H_*/ diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 70c3bb731..b611cddf9 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -213,7 +213,7 @@ string translateEntity(DoxygenEntity &doxyEntity){ return ""; } -string JavaDocConverter:: convertToJavaDoc(list entityList){ +string JavaDocConverter:: convertToJavaDoc(Node *n, list entityList){ entityList.sort(compare_DoxygenEntities); diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 53a270ce4..39de3dd15 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -1,15 +1,17 @@ - #include - #include - #include "DoxygenEntity.h" #ifndef JAVADOCCONVERTER_H_ #define JAVADOCCONVERTER_H_ +#include +#include +#include "swig.h" +#include "DoxygenEntity.h" + class JavaDocConverter { public: JavaDocConverter(); - string convertToJavaDoc(list entityList); + string convertToJavaDoc(Node *n, list entityList); ~JavaDocConverter(); void printSortedTree(list &entityList); }; diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp new file mode 100644 index 000000000..ad675e273 --- /dev/null +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -0,0 +1,205 @@ +#include "PyDocConverter.h" +#include +#include + +#define APPROX_LINE_LENGTH 64//characters per line allowed +#define TAB_SIZE 8//characters per line allowed + +//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag +PyDocConverter::PyDocConverter() +{ + debug = 1; +} + +PyDocConverter::~PyDocConverter() +{ +} + +/* Sorts entities by pyDoc standard order for commands + * NOTE: will not behave entirely properly until "First level" comments + * such as brief descriptions are TAGGED as such + */ +bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second); + +void PyDocConverter::printSortedTree(list &entityList){ + list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } +} + +string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { + string result; + ParmList *plist = CopyParmList(Getattr(n, "parms")); + Parm *p = NULL; + + DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); + DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); + + for (p = plist; p;) { + if(Char(Getattr(p, "name")) == paramNameEntity.data) { + std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); + std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); + + std::ostringstream parameterDocString; + + parameterDocString << std::endl << name << " (" << type << "): "; + parameterDocString << paramDescriptionEntity.data; + + result = parameterDocString.str(); + break; + } + p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); + } + + Delete(plist); + return result; +} + +string PyDocConverter::formatCommand(string unformattedLine, int indent){ + string formattedLines = "\n"; + int lastPosition = 0; + int i = 0; + int isFirstLine = 1; + while (i != -1 && i < unformattedLine.length()){ + lastPosition = i; + if (isFirstLine){ + i+=APPROX_LINE_LENGTH; + } + else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); + + if (i > 0 && i + 1 < unformattedLine.length()){ + if (!isFirstLine) for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + else { + isFirstLine = 0; + } + formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); + formattedLines.append("\n"); + + } + } + if (lastPosition < unformattedLine.length()){ + if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); + } + + return formattedLines; +} + +/* Contains the conversions for tags + * could probably be much more efficient... + */ +string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){ + if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ + return doxygenEntity.data; + } + if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + return "@"; + } + else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + return "\\"; + } + else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + return "<"; + } + else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + return ">"; + } + else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + return "&"; + } + else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + return "#"; + } + else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + return "%"; + } + else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + return "~"; + } + return ""; +} + + +string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ + string returnedString; + if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";} + else { + returnedString += pyDocFormat(doxygenEntity); + list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ + returnedString+= translateSubtree(*p); + p++; + } + } + return returnedString; +} + +string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); + if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ + return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} + else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 + || doxyEntity.typeOfEntity.compare("deprecated")== 0 + || doxyEntity.typeOfEntity.compare("brief")== 0) + return formatCommand(doxyEntity.data, 0) + "\n * "; + else if(doxyEntity.typeOfEntity.compare("see") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("param") == 0) { + return formatParam(n, doxyEntity); + } + else if(doxyEntity.typeOfEntity.compare("return")== 0 + || doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("sa")== 0){ + return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); + } + else return formatCommand(pyDocFormat(doxyEntity), 0 ); + return ""; +} + +string PyDocConverter::convertToPyDoc(Node *n, list entityList){ + entityList.sort(compare_DoxygenEntities); + + if(debug){ + cout << "---RESORTED LIST---" << endl; + printSortedTree(entityList); + } + + string pyDocString = "\"\"\""; + + list::iterator entityIterator = entityList.begin(); + while (entityIterator != entityList.end()){ + pyDocString += translateEntity(n, *entityIterator); + entityIterator++; + } + + pyDocString += "\n\"\"\"\n"; + + if(debug){ + cout << "\n---RESULT IN PYDOC---" << endl; + cout << pyDocString; + } + + return pyDocString; +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h new file mode 100644 index 000000000..b9d813476 --- /dev/null +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -0,0 +1,29 @@ +#ifndef PYDOCCONVERTER_H_ +#define PYDOCCONVERTER_H_ + +#include +#include +#include "swig.h" +#include "DoxygenEntity.h" + +class PyDocConverter +{ +public: + + PyDocConverter(); + string convertToPyDoc(Node *n, list entityList); + ~PyDocConverter(); + void printSortedTree(list &entityList); + +protected: + std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); + std::string formatCommand(string unformattedLine, int indent); + std::string pyDocFormat(DoxygenEntity &doxygenEntity); + std::string translateSubtree( DoxygenEntity &doxygenEntity); + std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); + +private: + bool debug; +}; + +#endif /*PYDOCCONVERTER_H_*/ diff --git a/Source/Makefile.am b/Source/Makefile.am index 65b5c6f6f..bfa6b3413 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -97,6 +97,8 @@ eswig_SOURCES = CParse/cscanner.c \ DoxygenTranslator/src/DoxygenTranslator.cpp\ DoxygenTranslator/src/JavaDocConverter.h\ DoxygenTranslator/src/JavaDocConverter.cpp\ + DoxygenTranslator/src/PyDocConverter.h\ + DoxygenTranslator/src/PyDocConverter.cpp\ DoxygenTranslator/src/Token.h\ DoxygenTranslator/src/Token.cpp\ DoxygenTranslator/src/TokenList.h\ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 961f9098c..edb88ebbb 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -510,7 +510,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */"); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(f_module, convertedString); free(convertedString); } @@ -1238,7 +1238,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printv(proxy_class_constants_code, convertedString, NIL); free(convertedString); } @@ -1310,7 +1310,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(enum_code, convertedString); free(convertedString); } @@ -1382,7 +1382,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printv(structuralComments, convertedString, NIL); free(convertedString); } @@ -1412,7 +1412,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(constants_code, convertedString); free(convertedString); } @@ -1683,7 +1683,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printv(proxy_class_def, convertedString, NIL); free(convertedString); } @@ -2026,7 +2026,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(function_code, convertedString); free(convertedString); } @@ -2258,7 +2258,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler */\n" ); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(function_code, convertedString); free(convertedString); } @@ -2529,7 +2529,7 @@ public: if (doxygen_javadoc_flag){ if (Getattr(n,"DoxygenComment")){ if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); - char *convertedString = doxyTranslator.convert(Char(Getattr(n,"DoxygenComment")),"JAVADOC"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); Printf(function_code, convertedString); free(convertedString); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7a878b4f8..ba02eae2e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -7,7 +7,7 @@ * Python language module for SWIG. * ----------------------------------------------------------------------------- */ -char cvsroot_python_cxx[] = "$Id$"; +char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton $"; #include "swigmod.h" #define ctab2 " " @@ -18,6 +18,7 @@ char cvsroot_python_cxx[] = "$Id$"; static int treduce = SWIG_cparse_template_reduce(0); #include +#include "../DoxygenTranslator/src/DoxygenTranslator.h" #define PYSHADOW_MEMBER 0x2 @@ -70,6 +71,7 @@ static int buildnone = 0; static int nobuildnone = 0; static int safecstrings = 0; static int dirvtable = 0; +static int doxygen = 1; static int proxydel = 1; static int fastunpack = 0; static int fastproxy = 0; @@ -83,6 +85,8 @@ static int extranative = 0; static int outputtuple = 0; static int nortti = 0; +static DoxygenTranslator doxyTranslator; + /* flags for the make_autodoc function */ enum autodoc_t { AUTODOC_CLASS, @@ -103,6 +107,7 @@ Python Options (available with -python)\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ + -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ @@ -324,6 +329,9 @@ public: } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-doxygen") == 0) { + doxygen = 1; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-nodirvtable") == 0) { dirvtable = 0; Swig_mark_arg(i); @@ -2898,11 +2906,24 @@ public: } } Printf(f_shadow, ":\n"); - if (have_docstring(n)) { + + //translate and write pydoc comment if flagged + if (doxygen){ + if (Getattr(n,"DoxygenComment")){ + //if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC"); + Printf(f_shadow, Char(pythoncode(convertedString, shadow_indent))); + free(convertedString); + } + } + + // otherwise use default docstrings if requested + else if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str != NULL && Len(str)) Printv(f_shadow, tab4, str, "\n", NIL); } + if (!modern) { Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL); if (Len(base_class)) { @@ -3109,6 +3130,14 @@ public: } else { Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); + if (doxygen) { + if (Getattr(n,"DoxygenComment")){ + //if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */"); + char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC"); + Printf(f_shadow, Char(pythoncode(convertedString, tab8))); + free(convertedString); + } + } if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { From d12b8bc06ecf87f07a1961b976b077747501b423 Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:18:35 +0000 Subject: [PATCH 0030/2031] Remove "using std" clause and use namespaces properly. Minor refactoring as well. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10839 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenEntity.cpp | 176 +++++++-- Source/DoxygenTranslator/src/DoxygenEntity.h | 55 +-- .../DoxygenTranslator/src/DoxygenParser.cpp | 272 +++++++------- Source/DoxygenTranslator/src/DoxygenParser.h | 6 +- .../src/DoxygenTranslator.cpp | 77 +--- .../src/JavaDocConverter.cpp | 343 +++++++----------- .../DoxygenTranslator/src/JavaDocConverter.h | 9 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 336 +++++++++-------- Source/DoxygenTranslator/src/PyDocConverter.h | 21 +- 9 files changed, 638 insertions(+), 657 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index a2faf67db..dcca1d032 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -1,19 +1,24 @@ +/* ----------------------------------------------------------------------------- + * 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. + * + * python.cxx + * + * Part of the Doxygen comment translation module of SWIG. + * ----------------------------------------------------------------------------- */ + #include "DoxygenEntity.h" -#include #include -/* Little data class for Doxygen Commands */ - -/* Basic node for commands that have - * nothing after them - * example: \n +/* + * Basic node for commands that have nothing after them (eg: \n) */ -string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", +std::string DoxygenEntity::commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "std::endlatexonly", "std::endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", @@ -24,19 +29,9 @@ string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "atten "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; + "$", "@", std::string(1, 92), "&", "~", "<", ">", "#", "%"}; -string findCommand(int commandNum){ - - int arraySize = sizeof(commandArray2)/sizeof(*commandArray2); - if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){ - return commandArray2[commandNum - 101]; - } - - return "" ; -} - -DoxygenEntity::DoxygenEntity(string typeEnt){ +DoxygenEntity::DoxygenEntity(std::string typeEnt){ typeOfEntity = typeEnt; data = ""; isLeaf = 1; @@ -45,9 +40,9 @@ DoxygenEntity::DoxygenEntity(string typeEnt){ /* Basic node for commands that have * only 1 thing after them * example: \b word - * OR holding a string + * OR holding a std::string */ -DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ typeOfEntity = typeEnt; data = param1; isLeaf = 1; @@ -56,26 +51,25 @@ DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ /* Nonterminal node * contains */ -DoxygenEntity::DoxygenEntity(string typeEnt, list &entList ){ +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list &entList ){ typeOfEntity = typeEnt; data = ""; isLeaf = 0; entityList = entList; } - void DoxygenEntity::printEntity(int level){ int thisLevel = level; if (isLeaf) { - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command: " << typeOfEntity << " "; - if (data.compare("") != 0) cout << "Node Data: " << data; - cout << endl; + for (int i = 0; i < thisLevel; i++) {std::cout << "\t";} + std::cout << "Node Command: " << typeOfEntity << " "; + if (data.compare("") != 0) std::cout << "Node Data: " << data; + std::cout << std::endl; } else{ - for (int i = 0; i < thisLevel; i++) {cout << "\t";} - cout << "Node Command : " << typeOfEntity << endl; - list::iterator p = entityList.begin(); + for (int i = 0; i < thisLevel; i++) {std::cout << "\t";} + std::cout << "Node Command : " << typeOfEntity << std::endl; + std::list::iterator p = entityList.begin(); thisLevel++; while (p != entityList.end()){ (*p).printEntity(thisLevel); @@ -84,6 +78,122 @@ void DoxygenEntity::printEntity(int level){ } } -DoxygenEntity::~DoxygenEntity() -{ +bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ + if(first.typeOfEntity.compare("brief") == 0) + return true; + if(second.typeOfEntity.compare("brief") == 0) + return false; + if(first.typeOfEntity.compare("details") == 0) + return true; + if(second.typeOfEntity.compare("details") == 0) + return false; + if(first.typeOfEntity.compare("partofdescription") == 0) + return true; + if(first.typeOfEntity.compare("partofdescription") == 0) + return false; + if(first.typeOfEntity.compare("plainstd::string") == 0) + return true; + if(second.typeOfEntity.compare("plainstd::string") == 0) + return false; + if(first.typeOfEntity.compare("param") == 0){ + if(second.typeOfEntity.compare("param")== 0) + return true; + if(second.typeOfEntity.compare("return")== 0) + return true; + if(second.typeOfEntity.compare("exception")== 0) + return true; + if(second.typeOfEntity.compare("author")== 0) + return true; + if(second.typeOfEntity.compare("version")== 0) + return true; + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("return")== 0){ + if(second.typeOfEntity.compare("return")== 0) + return true; + if(second.typeOfEntity.compare("exception")== 0) + return true; + if(second.typeOfEntity.compare("author")== 0) + return true; + if(second.typeOfEntity.compare("version")== 0) + return true; + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0 + )return true; + return false; + } + if(first.typeOfEntity.compare("exception")== 0){ + if(second.typeOfEntity.compare("exception")== 0) + return true; + if(second.typeOfEntity.compare("author")== 0) + return true; + if(second.typeOfEntity.compare("version")== 0) + return true; + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("author")== 0){ + if(second.typeOfEntity.compare("author")== 0) + return true; + if(second.typeOfEntity.compare("version")== 0) + return true; + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("version")== 0){ + if(second.typeOfEntity.compare("version")== 0) + return true; + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ + if(second.typeOfEntity.compare("see")== 0) + return true; + if(second.typeOfEntity.compare("sa")== 0) + return true; + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("since")== 0){ + if(second.typeOfEntity.compare("since")== 0) + return true; + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + if(first.typeOfEntity.compare("deprecated")== 0){ + if(second.typeOfEntity.compare("deprecated")== 0) + return true; + return false; + } + return true; } + + diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 779065bdf..3bec0bb0c 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -1,37 +1,40 @@ +/* ----------------------------------------------------------------------------- + * 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. + * + * python.cxx + * + * Part of the Doxygen comment translation module of SWIG. + * ----------------------------------------------------------------------------- */ + #ifndef DOXYGENENTITY_H_ #define DOXYGENENTITY_H_ - #include #include -using namespace std; - -class DoxygenEntity{ - -public: - DoxygenEntity(string typeEnt); - DoxygenEntity(string typeEnt, string param1); - DoxygenEntity(string typeEnt, list &entList ); - ~DoxygenEntity(); - void printEntity(int level); - string typeOfEntity; - list entityList; - string data; - int isLeaf; +/* + * Structure to represent a doxygen comment entry + */ +struct DoxygenEntity{ + DoxygenEntity(std::string typeEnt); + DoxygenEntity(std::string typeEnt, std::string param1); + DoxygenEntity(std::string typeEnt, std::list &entList ); + void printEntity(int level); + std::string typeOfEntity; + std::list entityList; + std::string data; + int isLeaf; + static std::string commandArray[]; }; -struct find_entity { - find_entity(string typeString) { - typeOfEntity = typeString; - } - - bool operator()(DoxygenEntity& entity) { - return entity.typeOfEntity == typeOfEntity; - } - - string typeOfEntity; +/* + * Functor that sorts entities by javaDoc standard order for commands. + * NOTE: will not behave entirely properly until "First level" comments + * such as brief descriptions are TAGGED as such + */ +struct CompareDoxygenEntities { + bool operator()(DoxygenEntity& first, DoxygenEntity& second); }; - #endif /*TOKENLIST_H_*/ diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index d953bc6d4..ba624239a 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -19,8 +19,6 @@ #define PARAGRAPH_END 102 #define PLAINSTRING 103 #define COMMAND 104 -using namespace std; - DoxygenParser::DoxygenParser() { @@ -32,13 +30,13 @@ DoxygenParser::~DoxygenParser() ////////////////////////////////////////// int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(string currCommand, TokenList &tokList, list &aNewList); -list parse(list::iterator endParsingIndex, TokenList &tokList); +int addCommand(std::string currCommand, TokenList &tokList, std::list &aNewList); +std::list parse(std::list::iterator endParsingIndex, TokenList &tokList); ////////////////////////////////////////// -string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", +std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", @@ -57,49 +55,49 @@ string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attent "$", "@", "\\","&", "~", "<", ">", "#", "%"}; -string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", +std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", "version", "warning", "xrefitem" }; /* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; -string ignoredSimpleCommands[] = {"nothing at the moment"}; -string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", +std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; +std::string ignoredSimpleCommands[] = {"nothing at the moment"}; +std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -string ignoreCommandLines[] = {"nothing at the moment"}; -string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", +std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; +std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; +std::string ignoreCommandLines[] = {"nothing at the moment"}; +std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; -string ignoreCommandParagraphs[] = {"nothing at the moment"}; -string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", +std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; +std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; -string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -string commandOWords[] = {"dir", "file", "cond"}; -string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", +std::string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; +std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; +std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; +std::string commandOWords[] = {"dir", "file", "cond"}; +std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", + "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; -string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", +std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; -/* Changes a string to all lower case */ -string StringToLower(string stringToConvert){ +/* Changes a std::string to all lower case */ +std::string StringToLower(std::string stringToConvert){ for(unsigned int i=0;i &rootList){ - list::iterator p = rootList.begin(); +void printTree( std::list &rootList){ + std::list::iterator p = rootList.begin(); while (p != rootList.end()){ (*p).printEntity(0); p++; @@ -136,8 +134,8 @@ void printTree( list &rootList){ /* Determines how a command should be handled (what group it belongs to * for parsing rules */ -int commandBelongs(string theCommand){ - string smallString = StringToLower(theCommand); +int commandBelongs(std::string theCommand){ + std::string smallString = StringToLower(theCommand); //cout << " Looking for command " << theCommand << endl; int i = 0; for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ @@ -189,10 +187,10 @@ int commandBelongs(string theCommand){ } /* Returns the next word ON THE CURRENT LINE ONLY - * if a new line is encountered, returns a blank string. + * if a new line is encountered, returns a blank std::string. * Updates the index it is given if success. */ -string getNextWord(TokenList &tokList){ +std::string getNextWord(TokenList &tokList){ Token nextToken = tokList.peek(); if (nextToken.tokenType == PLAINSTRING ){ nextToken = tokList.next(); @@ -204,8 +202,8 @@ string getNextWord(TokenList &tokList){ /* Returns the location of the end of the line as * an iterator. */ -list::iterator getOneLine(TokenList &tokList){ - list::iterator endOfLine = tokList.iteratorCopy(); +std::list::iterator getOneLine(TokenList &tokList){ + std::list::iterator endOfLine = tokList.iteratorCopy(); while(endOfLine!= tokList.end()){ if ((* endOfLine).tokenType == END_LINE){ //cout << "REACHED END" << endl; @@ -219,11 +217,11 @@ list::iterator getOneLine(TokenList &tokList){ return tokList.end(); } -/* Returns a properly formatted string +/* Returns a properly formatted std::string * up til ANY command or end of line is encountered. */ -string getStringTilCommand(TokenList &tokList){ - string description; +std::string getStringTilCommand(TokenList &tokList){ + std::string description; if (tokList.peek().tokenType == 0) return ""; while(tokList.peek().tokenType == PLAINSTRING){ Token currentToken = tokList.next(); @@ -234,13 +232,13 @@ string getStringTilCommand(TokenList &tokList){ return description; } -/* Returns a properly formatted string +/* Returns a properly formatted std::string * up til the command specified is encountered */ //TODO check that this behaves properly for formulas -string getStringTilEndCommand(string theCommand, TokenList &tokList){ - string description; +std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){ + std::string description; if (tokList.peek().tokenType == 0) return ""; while(tokList.peek().tokenString.compare(theCommand) != 0 ){ Token currentToken = tokList.next(); @@ -253,8 +251,8 @@ string getStringTilEndCommand(string theCommand, TokenList &tokList){ * Paragraph is defined in Doxygen to be a paragraph of text * seperate by either a structural command or a blank line */ -list::iterator getEndOfParagraph(TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); +std::list::iterator getEndOfParagraph(TokenList &tokList){ + std::list::iterator endOfParagraph = tokList.iteratorCopy(); while(endOfParagraph != tokList.end()){ if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; @@ -278,10 +276,10 @@ list::iterator getEndOfParagraph(TokenList &tokList){ /* Returns the end of a section, defined as the first blank line OR first encounter of the same * command. Example of this behaviour is \arg -* if no end is encountered, returns the last token of the list. +* if no end is encountered, returns the last token of the std::list. */ -list::iterator getEndOfSection(string theCommand, TokenList &tokList){ - list::iterator endOfParagraph = tokList.iteratorCopy(); +std::list::iterator getEndOfSection(std::string theCommand, TokenList &tokList){ + std::list::iterator endOfParagraph = tokList.iteratorCopy(); while(endOfParagraph != tokList.end()){ if ((* endOfParagraph).tokenType == COMMAND){ if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; @@ -305,10 +303,10 @@ list::iterator getEndOfSection(string theCommand, TokenList &tokList){ * that begins with a \command and ends in \endcommand * such as \code and \endcode. The proper usage is * progressTilEndCommand("endcode", tokenList); - * If the end is never encountered, it returns the end of the list. + * If the end is never encountered, it returns the end of the std::list. */ -list::iterator getEndCommand(string theCommand, TokenList &tokList){ - list::iterator endOfCommand = tokList.iteratorCopy(); +std::list::iterator getEndCommand(std::string theCommand, TokenList &tokList){ + std::list::iterator endOfCommand = tokList.iteratorCopy(); while (endOfCommand!= tokList.end()){ if ((*endOfCommand).tokenType == COMMAND){ if (theCommand.compare((* endOfCommand).tokenString) == 0){ @@ -324,8 +322,8 @@ list::iterator getEndCommand(string theCommand, TokenList &tokList){ /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ //TODO getTilAnyCommand -list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ - list::iterator anIterator; +std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){ + std::list::iterator anIterator; return anIterator; } @@ -337,7 +335,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ - int addSimpleCommand(string theCommand, list &doxyList){ + int addSimpleCommand(std::string theCommand, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); return 1; @@ -347,7 +345,7 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Format: @command * Plain commands, such as newline etc, they contain no other data */ - int ignoreSimpleCommand(string theCommand, list &doxyList){ + int ignoreSimpleCommand(std::string theCommand, std::list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; return 1; } @@ -358,9 +356,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" */ - int addCommandWord(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (!name.empty()){ doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; @@ -374,9 +372,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ - int ignoreCommandWord(string theCommand, TokenList &tokList, list &doxyList){ + int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (!name.empty()){ return 1; } @@ -389,10 +387,10 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands with a single LINE after then such as @var * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" */ - int addCommandLine(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - list::iterator endOfLine = getOneLine(tokList); - list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); + std::list aNewList; aNewList = parse(endOfLine, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); return 1; @@ -403,9 +401,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands with a single LINE after then such as @var * */ - int ignoreCommandLine(string theCommand, TokenList &tokList, list &doxyList){ + int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfLine = getOneLine(tokList); + std::list::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 1; } @@ -416,10 +414,10 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" */ - int addCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); - list aNewList; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list aNewList; aNewList = parse(endOfParagraph, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); return 1; @@ -430,9 +428,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands with a single LINE after then such as @var * */ - int ignoreCommandParagraph(string theCommand, TokenList &tokList, list &doxyList){ + int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } @@ -444,9 +442,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ - int addCommandEndCommand(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Not Adding " << theCommand << endl; - string description = getStringTilEndCommand( "end" + theCommand, tokList); + std::string description = getStringTilEndCommand( "end" + theCommand, tokList); doxyList.push_back(DoxygenEntity(theCommand, description)); return 1; } @@ -456,17 +454,17 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands such as param * "param", "tparam", "throw", "retval", "exception" */ - int addCommandWordParagraph(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - list::iterator endOfParagraph = getEndOfParagraph(tokList); - list aNewList; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list aNewList; aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -476,17 +474,17 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ - int addCommandWordLine(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - list::iterator endOfLine = getOneLine(tokList); - list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); + std::list aNewList; aNewList = parse(endOfLine, tokList); - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -498,19 +496,19 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands such as class * "category", "class", "protocol", "interface", "struct", "union" */ - int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - string headerfile = getNextWord(tokList); - string headername = getNextWord(tokList); - list aNewList; - aNewList.push_back(DoxygenEntity("plainstring", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); + std::string headerfile = getNextWord(tokList); + std::string headername = getNextWord(tokList); + std::list aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -520,9 +518,9 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ * Commands such as dir * "dir", "file", "cond" */ - int addCommandOWord(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; } @@ -530,47 +528,47 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ /* Commands that should not be encountered (such as PHP only) * goes til the end of line then returns */ - int addCommandErrorThrow(string theCommand, TokenList &tokList, list &doxyList){ + int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list &doxyList){ cout << "Encountered :" << theCommand << endl; cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - list::iterator endOfLine = getOneLine(tokList); + std::list::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 0; } /* Adds the unique commands- different process for each unique command */ - int addCommandUnique(string theCommand, TokenList &tokList, list &doxyList){ - list aNewList; + int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ + std::list aNewList; if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - list::iterator endOfSection = getEndOfSection(theCommand, tokList); - list aNewList; + std::list::iterator endOfSection = getEndOfSection(theCommand, tokList); + std::list aNewList; aNewList = parse(endOfSection, tokList); doxyList.push_back( DoxygenEntity(theCommand, aNewList)); } - // \xrefitem "(heading)" "(list title)" {text} + // \xrefitem "(heading)" "(std::list title)" {text} else if (theCommand.compare("xrefitem") == 0){ //TODO Implement xrefitem if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } // \ingroup ( [ ]) else if (theCommand.compare("ingroup") == 0){ - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \par [(paragraph title)] { paragraph } else if (theCommand.compare("par") == 0){ - list::iterator endOfLine = getOneLine(tokList); + std::list::iterator endOfLine = getOneLine(tokList); aNewList = parse(endOfLine, tokList); - list aNewList2; + std::list aNewList2; aNewList2 = parse(endOfLine, tokList); aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); @@ -578,19 +576,19 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ } // \headerfile [] else if (theCommand.compare("headerfile") == 0){ - list aNewList; - string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstring", name)); + std::list aNewList; + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); + if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \overload [(function declaration)] else if (theCommand.compare("overload") == 0){ - list::iterator endOfLine = getOneLine(tokList); + std::list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()){ - list aNewList; + std::list aNewList; aNewList = parse(endOfLine, tokList); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } @@ -600,38 +598,38 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ // \weakgroup [(title)] else if (theCommand.compare("weakgroup") == 0){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - list aNewList; - list::iterator endOfLine = getOneLine(tokList); + std::list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { aNewList = parse(endOfLine, tokList); } - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \ref ["(text)"] else if (theCommand.compare("ref") == 0){ //TODO Implement ref if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \subpage ["(text)"] else if (theCommand.compare("subpage") == 0){ //TODO implement subpage if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \dotfile ["caption"] else if (theCommand.compare("dotfile") == 0){ //TODO implement dotfile if (noisy) cout << "Not Adding " << theCommand << endl; - list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \image ["caption"] [=] @@ -641,17 +639,17 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ // \addtogroup [(title)] else if (theCommand.compare("addtogroup") == 0){ if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(tokList); + std::string name = getNextWord(tokList); if (name.empty()){ cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - list aNewList; - list::iterator endOfLine = getOneLine(tokList); + std::list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { aNewList = parse(endOfLine, tokList); } - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } return 0; @@ -663,12 +661,12 @@ list::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ */ -int addCommand(string commandString, TokenList &tokList,list &doxyList){ - string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstring") == 0){ - string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); +int addCommand(std::string commandString, TokenList &tokList,std::list &doxyList){ + std::string theCommand = StringToLower(commandString); + if (theCommand.compare("plainstd::string") == 0){ + std::string nextPhrase = getStringTilCommand( tokList); + if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); return 1; } int commandNumber = commandBelongs(theCommand); @@ -721,8 +719,8 @@ int addCommand(string commandString, TokenList &tokList,list &do return 0; } -list parse(list::iterator endParsingIndex, TokenList &tokList){ - list aNewList; +std::list parse(std::list::iterator endParsingIndex, TokenList &tokList){ + std::list aNewList; int currCommand; while (tokList.current() != endParsingIndex){ Token currToken = tokList.peek(); @@ -735,22 +733,22 @@ list parse(list::iterator endParsingIndex, TokenList &tokL if (currCommand < 0 ){ if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; tokList.next(); - addCommand(string("plainstring"), tokList, aNewList);} + addCommand(std::string("plainstd::string"), tokList, aNewList);} //cout << "Command: " << currWord << " " << currCommand << endl; else { tokList.next(); addCommand(currToken.tokenString, tokList, aNewList); } } else if (currToken.tokenType == PLAINSTRING){ - addCommand(string("plainstring"), tokList, aNewList); + addCommand(std::string("plainstd::string"), tokList, aNewList); } else break; } return aNewList; } -list parseRoot(list::iterator endParsingIndex, TokenList &tokList){ - list aNewList; +std::list parseRoot(std::list::iterator endParsingIndex, TokenList &tokList){ + std::list aNewList; int currCommand; while (tokList.current() != endParsingIndex){ Token currToken = tokList.peek(); @@ -763,26 +761,26 @@ list parseRoot(list::iterator endParsingIndex, TokenList & if (currCommand < 0 ){ if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; tokList.next(); - addCommand(string("partofdescription"), tokList, aNewList);} + addCommand(std::string("partofdescription"), tokList, aNewList);} //cout << "Command: " << currWord << " " << currCommand << endl; else { tokList.next(); addCommand(currToken.tokenString, tokList, aNewList); } } else if (currToken.tokenType == PLAINSTRING){ - addCommand(string("partofdescription"), tokList, aNewList); + addCommand(std::string("partofdescription"), tokList, aNewList); } } return aNewList; } -list DoxygenParser::createTree(string doxygenBlob){ +std::list DoxygenParser::createTree(std::string doxygenBlob){ TokenList tokList = TokenList(doxygenBlob); if(noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); } - list rootList; + std::list rootList; rootList = parseRoot( tokList.end(), tokList); if(noisy) { cout << "PARSED LIST" << endl; diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 638fdab72..2269e6788 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -6,9 +6,9 @@ class DoxygenParser { public: - DoxygenParser(); - virtual ~DoxygenParser(); - list createTree(string doxygen); + DoxygenParser(); + virtual ~DoxygenParser(); + std::list createTree(std::string doxygen); }; #endif /*DOXYGENPARSER_H_*/ diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 7fe2897c5..fc74c5c20 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -24,69 +24,20 @@ DoxygenTranslator::~DoxygenTranslator(){ char *DoxygenTranslator::convert(Node *n, char* doxygenBlob, char* option){ - list rootList = doxyParse.createTree(string(doxygenBlob)); + std::list rootList = doxyParse.createTree(std::string(doxygenBlob)); + std::string returnedString; + + if(strcmp(option, "JAVADOC") == 0) + returnedString = jDC.convertToJavaDoc(n, rootList); + else if(strcmp(option, "PYDOC") == 0) + returnedString = pyDC.convertToPyDoc(n, rootList); + else + std::cout << "Option not current supported." << std::endl; - string returnedString; - if(strcmp(option, "JAVADOC") == 0){ - returnedString = jDC.convertToJavaDoc(n, rootList); - } - else if(strcmp(option, "PYDOC") == 0){ - returnedString = pyDC.convertToPyDoc(n, rootList); - } - else cout << "Option not current supported.\n"; - char *nonConstString; - nonConstString = (char *)malloc(returnedString.length() + 1); - strcpy(nonConstString, returnedString.c_str()); - return nonConstString; + char *nonConstString; + nonConstString = (char *)malloc(returnedString.length() + 1); + strcpy(nonConstString, returnedString.c_str()); + + return nonConstString; } -int testCommands(){ - string exampleArray[] = { - "/**\n * Random Line \n * \\@ \n * Random Line After */", - "/**\n * Random Line Before \n * \n * \\b bold \n * Random Line After */", - "/**\n * Random Line \n * \n *\\copydoc bold \n * Random Line After */", - "/**\n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */", - "/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */", - "/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */", - "/**\n * Random Line \n * \n * \\code this should continue \n * until here \\endcode \n * Random Line After */", - "/**\n * Random Line \n * \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */", - "/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */", - "/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */", - "/**\n * Random Line \n * \n * \\category singleword \n * but not this */", - "/**\n * Random Line \n * \n * \\category singleword oneword \n * but not this */", - "/**\n * Random Line \n * \n * \\category singleword oneword twoword \n * but not this */", - "/**\n * Random Line \n * \n * \\dir singleword \n * but not this */", - "/**\n * Random Line \n * \n * \\dir \n * but not this */", - "/**\n * Random Line \n * \n * \\fakecommand details \n * but not this */" - }; - //string exampleArrayUniques = {}; - DoxygenTranslator dT = DoxygenTranslator(); - for (int i = 0; i < 16; i ++ ){ - //cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl; - char *nonConstString = (char *)malloc(exampleArray[i].length()+1); - strcpy(nonConstString, exampleArray[i].c_str()); - char * result = dT.convert(NULL, nonConstString, "JAVADOC"); - free(nonConstString); - free(result); - } - return 1; -} - -//int main(int argc, char *argv[]){ - //string doxygenString1 = "//! \\brief a brief description \n\n A normal member taking two arguments and returning an \\b integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; - //cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl; - //char *nonConstString = (char *)malloc(doxygenString1.length()+1); - //strcpy(nonConstString, doxygenString1.c_str()); - //DoxygenTranslator dT = DoxygenTranslator(); - //char *result = dT.convert("/**\n * \n * Random Line \n * \n * \\name An Entire Line \n * NOT This Line \n * \n * Random Line After */", "JAVADOC"); - //result = dT.convert(nonConstString, "JAVADOC"); - //cout << "End"; - //list rootList = doxyParse.createTree(doxygenString1); - //JavaDocConverter jDC = JavaDocConverter(); - //jDC.convertToJavaDoc(rootList); - //testCommands(); - //return 1; -//} - - - diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index b611cddf9..dbf606bfd 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -12,227 +12,152 @@ JavaDocConverter::~JavaDocConverter() { } -/* Sorts entities by javaDoc standard order for commands - * NOTE: will not behave entirely properly until "First level" comments - * such as brief descriptions are TAGGED as such - */ -bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){ - if(first.typeOfEntity.compare("brief") == 0) return true; - if(second.typeOfEntity.compare("brief") == 0) return false; - if(first.typeOfEntity.compare("details") == 0) return true; - if(second.typeOfEntity.compare("details") == 0) return false; - if(first.typeOfEntity.compare("partofdescription") == 0) return true; - if(first.typeOfEntity.compare("partofdescription") == 0) return false; - if(first.typeOfEntity.compare("plainstring") == 0) return true; - if(second.typeOfEntity.compare("plainstring") == 0) return false; - if(first.typeOfEntity.compare("param") == 0){ - if(second.typeOfEntity.compare("param")== 0) return true; - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("return")== 0){ - if(second.typeOfEntity.compare("return")== 0) return true; - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - - } - if(first.typeOfEntity.compare("exception")== 0){ - if(second.typeOfEntity.compare("exception")== 0) return true; - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("author")== 0){ - if(second.typeOfEntity.compare("author")== 0) return true; - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("version")== 0){ - if(second.typeOfEntity.compare("version")== 0)return true; - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ - if(second.typeOfEntity.compare("see")== 0)return true; - if(second.typeOfEntity.compare("sa")== 0)return true; - if(second.typeOfEntity.compare("since")== 0)return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("since")== 0){ - if(second.typeOfEntity.compare("since")== 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - if(first.typeOfEntity.compare("deprecated")== 0){ - if(second.typeOfEntity.compare("deprecated")== 0)return true; - return false; - } - return true; +void JavaDocConverter::printSortedTree(std::list &entityList){ + std::list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } } -void JavaDocConverter::printSortedTree(list &entityList){ - list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } -} -string formatCommand(string unformattedLine, int indent){ - string formattedLines = "\n * "; - int lastPosition = 0; - int i = 0; - int isFirstLine = 1; - while (i != -1 && i < unformattedLine.length()){ - lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; - } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; - i = unformattedLine.find(" ", i); +std::string formatCommand(std::string unformattedLine, int indent){ + std::string formattedLines = "\n * "; + int lastPosition = 0; + int i = 0; + int isFirstLine = 1; + while (i != -1 && i < unformattedLine.length()){ + lastPosition = i; + if (isFirstLine){ + i+=APPROX_LINE_LENGTH; + } + else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } - else { - isFirstLine = 0; - } - formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); - formattedLines.append("\n *"); + if (i > 0 && i + 1 < unformattedLine.length()){ + if (!isFirstLine) for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + else { + isFirstLine = 0; + } + formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); + formattedLines.append("\n *"); - } - } - if (lastPosition < unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} - formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); - } + } + } + if (lastPosition < unformattedLine.length()){ + if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); + } - return formattedLines; + return formattedLines; } /* Contains the conversions for tags * could probably be much more efficient... */ -string javaDocFormat(DoxygenEntity &doxygenEntity){ - if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("@") == 0){ - return "@"; - } - else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ - return "\\"; - } - else if (doxygenEntity.typeOfEntity.compare("<") == 0){ - return "<"; - } - else if (doxygenEntity.typeOfEntity.compare(">") == 0){ - return ">"; - } - else if (doxygenEntity.typeOfEntity.compare("&") == 0){ - return "&"; - } - else if (doxygenEntity.typeOfEntity.compare("#") == 0){ - return "#"; - } - else if (doxygenEntity.typeOfEntity.compare("%") == 0){ - return "%"; - } - else if (doxygenEntity.typeOfEntity.compare("~") == 0){ - return "~"; - } - return ""; -} - - -string translateSubtree( DoxygenEntity &doxygenEntity){ - string returnedString; - if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} - else { - returnedString += javaDocFormat(doxygenEntity); - list::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); - p++; - } - } - return returnedString; -} - -string translateEntity(DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); - if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ - return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} - else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; - else if(doxyEntity.typeOfEntity.compare("see") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("sa")== 0){ - return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); - } - else return formatCommand(javaDocFormat(doxyEntity), 0 ); - return ""; -} - -string JavaDocConverter:: convertToJavaDoc(Node *n, list entityList){ - - - entityList.sort(compare_DoxygenEntities); - if(printSortedTree2){ - cout << "---RESORTED LIST---" << endl; - printSortedTree(entityList); +std::string javaDocFormat(DoxygenEntity &doxygenEntity){ + if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ + return doxygenEntity.data; } + if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + return "@"; + } + else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + return "\\"; + } + else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + return "<"; + } + else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + return ">"; + } + else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + return "&"; + } + else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + return "#"; + } + else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + return "%"; + } + else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + return "~"; + } + return ""; +} - string javaDocString = "/**"; - list::iterator entityIterator = entityList.begin(); - while (entityIterator != entityList.end()){ - javaDocString += translateEntity(*entityIterator); - entityIterator++; - } +std::string translateSubtree( DoxygenEntity &doxygenEntity){ + std::string returnedString; + if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} + else { + returnedString += javaDocFormat(doxygenEntity); + std::list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ + returnedString+= translateSubtree(*p); + p++; + } + } + return returnedString; +} - javaDocString += "\n */\n"; - if(printSortedTree2){ - cout << "\n---RESULT IN JAVADOC---" << endl; - cout << javaDocString; } - return javaDocString; +std::string translateEntity(DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(std::string(translateSubtree(doxyEntity)), 0); + if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ + return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} + else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) + return formatCommand(doxyEntity.data, 0) + "\n * "; + else if(doxyEntity.typeOfEntity.compare("see") == 0){ + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("return")== 0 + || doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + } + else if(doxyEntity.typeOfEntity.compare("sa")== 0){ + return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); + } + else return formatCommand(javaDocFormat(doxyEntity), 0 ); + return ""; +} + +std::string JavaDocConverter:: convertToJavaDoc(Node *n, std::list entityList){ + #pragma unused(n) + entityList.sort(CompareDoxygenEntities()); + + if(printSortedTree2){ + std::cout << "---RESORTED LIST---" << std::endl; + printSortedTree(entityList); + } + + std::string javaDocString = "/**"; + + for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ + javaDocString += translateEntity(*entityIterator); + entityIterator++; + } + + javaDocString += "\n */\n"; + + if(printSortedTree2){ + std::cout << "\n---RESULT IN JAVADOC---" << std::endl; + std::cout << javaDocString; + } + + return javaDocString; } \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 39de3dd15..0a329c27a 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -9,11 +9,10 @@ class JavaDocConverter { public: - - JavaDocConverter(); - string convertToJavaDoc(Node *n, list entityList); - ~JavaDocConverter(); - void printSortedTree(list &entityList); + JavaDocConverter(); + std::string convertToJavaDoc(Node *n, std::list entityList); + ~JavaDocConverter(); + void printSortedTree(std::list &entityList); }; #endif /*JAVADOCCONVERTER_H_*/ diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index ad675e273..1e4d6a73e 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -14,192 +14,188 @@ PyDocConverter::PyDocConverter() PyDocConverter::~PyDocConverter() { } - -/* Sorts entities by pyDoc standard order for commands - * NOTE: will not behave entirely properly until "First level" comments - * such as brief descriptions are TAGGED as such - */ -bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second); -void PyDocConverter::printSortedTree(list &entityList){ - list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } +void PyDocConverter::printSortedTree(std::list &entityList){ + std::list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } } -string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { - string result; - ParmList *plist = CopyParmList(Getattr(n, "parms")); - Parm *p = NULL; - - DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); - DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); - - for (p = plist; p;) { - if(Char(Getattr(p, "name")) == paramNameEntity.data) { - std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); - std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); - - std::ostringstream parameterDocString; - - parameterDocString << std::endl << name << " (" << type << "): "; - parameterDocString << paramDescriptionEntity.data; - - result = parameterDocString.str(); - break; - } - p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); - } +std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { + std::string result; + ParmList *plist = CopyParmList(Getattr(n, "parms")); + Parm *p = NULL; + + DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); + DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); + + for (p = plist; p;) { + if(Char(Getattr(p, "name")) == paramNameEntity.data) { + std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); + std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); + + std::ostringstream parameterDocString; + + parameterDocString << std::endl << name << " (" << type << ") -- "; + parameterDocString << paramDescriptionEntity.data; + + result = parameterDocString.str(); + break; + } + p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); + } - Delete(plist); - return result; + Delete(plist); + return result; } -string PyDocConverter::formatCommand(string unformattedLine, int indent){ - string formattedLines = "\n"; - int lastPosition = 0; - int i = 0; - int isFirstLine = 1; - while (i != -1 && i < unformattedLine.length()){ - lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; - } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; - i = unformattedLine.find(" ", i); +std::string PyDocConverter::formatCommand(std::string unformattedLine, int indent){ + std::string formattedLines = "\n"; + int lastPosition = 0; + signed int i = 0; + bool isFirstLine = true; + while (i != -1 && i < (int)unformattedLine.length()){ + lastPosition = i; + if (isFirstLine){ + i+=APPROX_LINE_LENGTH; + } + else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } - else { - isFirstLine = 0; - } - formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); - formattedLines.append("\n"); + if (i > 0 && i + 1 < (int)unformattedLine.length()){ + if (!isFirstLine) for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + else { + isFirstLine = false; + } + formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); + formattedLines.append("\n"); - } - } - if (lastPosition < unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} - formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); - } + } + } + if (lastPosition < (int)unformattedLine.length()){ + if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); + } - return formattedLines; + return formattedLines; } /* Contains the conversions for tags * could probably be much more efficient... */ -string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){ - if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("@") == 0){ - return "@"; - } - else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ - return "\\"; - } - else if (doxygenEntity.typeOfEntity.compare("<") == 0){ - return "<"; - } - else if (doxygenEntity.typeOfEntity.compare(">") == 0){ - return ">"; - } - else if (doxygenEntity.typeOfEntity.compare("&") == 0){ - return "&"; - } - else if (doxygenEntity.typeOfEntity.compare("#") == 0){ - return "#"; - } - else if (doxygenEntity.typeOfEntity.compare("%") == 0){ - return "%"; - } - else if (doxygenEntity.typeOfEntity.compare("~") == 0){ - return "~"; - } - return ""; -} - - -string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ - string returnedString; - if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";} - else { - returnedString += pyDocFormat(doxygenEntity); - list::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); - p++; - } - } - return returnedString; -} - -string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); - if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ - return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} - else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 - || doxyEntity.typeOfEntity.compare("deprecated")== 0 - || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; - else if(doxyEntity.typeOfEntity.compare("see") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("param") == 0) { - return formatParam(n, doxyEntity); - } - else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ - return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("sa")== 0){ - return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); - } - else return formatCommand(pyDocFormat(doxyEntity), 0 ); - return ""; -} - -string PyDocConverter::convertToPyDoc(Node *n, list entityList){ - entityList.sort(compare_DoxygenEntities); - - if(debug){ - cout << "---RESORTED LIST---" << endl; - printSortedTree(entityList); +std::string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){ + if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ + return doxygenEntity.data; } + if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ + return doxygenEntity.data; + } + else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + return "" + doxygenEntity.data + ""; + } + else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + return "@"; + } + else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + return "\\"; + } + else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + return "<"; + } + else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + return ">"; + } + else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + return "&"; + } + else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + return "#"; + } + else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + return "%"; + } + else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + return "~"; + } + return ""; +} - string pyDocString = "\"\"\""; - list::iterator entityIterator = entityList.begin(); - while (entityIterator != entityList.end()){ - pyDocString += translateEntity(n, *entityIterator); - entityIterator++; - } +std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ + std::string returnedString; + if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";} + else { + returnedString += pyDocFormat(doxygenEntity); + std::list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ + returnedString+= translateSubtree(*p); + p++; + } + } + return returnedString; +} - pyDocString += "\n\"\"\"\n"; - - if(debug){ - cout << "\n---RESULT IN PYDOC---" << endl; - cout << pyDocString; - } - - return pyDocString; +std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ + if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) + return formatCommand(std::string(translateSubtree(doxyEntity)), 0); + + if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ + return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} + + if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 + || doxyEntity.typeOfEntity.compare("deprecated")== 0 + || doxyEntity.typeOfEntity.compare("brief")== 0) + return formatCommand(doxyEntity.data, 0) + "\n * "; + + if(doxyEntity.typeOfEntity.compare("see") == 0) + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + + if(doxyEntity.typeOfEntity.compare("param") == 0) + return formatParam(n, doxyEntity); + + if(doxyEntity.typeOfEntity.compare("return")== 0 + || doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0) + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + + if(doxyEntity.typeOfEntity.compare("sa")== 0) + return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); + + return formatCommand(pyDocFormat(doxyEntity), 0); +} + +std::string PyDocConverter::convertToPyDoc(Node *n, std::list entityList){ + entityList.sort(CompareDoxygenEntities()); + + if(debug){ + std::cout << "---RESORTED LIST---" << std::endl; + printSortedTree(entityList); + } + + std::string pyDocString = "\"\"\""; + + for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ + pyDocString += translateEntity(n, *entityIterator); + entityIterator++; + } + + pyDocString += "\n\"\"\"\n"; + + if(debug){ + std::cout << "\n---RESULT IN PYDOC---" << std::endl; + std::cout << pyDocString; + } + + return pyDocString; } \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index b9d813476..27faaf6c3 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -9,21 +9,20 @@ class PyDocConverter { public: - - PyDocConverter(); - string convertToPyDoc(Node *n, list entityList); - ~PyDocConverter(); - void printSortedTree(list &entityList); + PyDocConverter(); + std::string convertToPyDoc(Node *n, std::list entityList); + ~PyDocConverter(); + void printSortedTree(std::list &entityList); protected: - std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); - std::string formatCommand(string unformattedLine, int indent); - std::string pyDocFormat(DoxygenEntity &doxygenEntity); - std::string translateSubtree( DoxygenEntity &doxygenEntity); - std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); + std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); + std::string formatCommand(std::string unformattedLine, int indent); + std::string pyDocFormat(DoxygenEntity &doxygenEntity); + std::string translateSubtree( DoxygenEntity &doxygenEntity); + std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); private: - bool debug; + bool debug; }; #endif /*PYDOCCONVERTER_H_*/ From eb38ea3a4330001f59b814491de3b2c34b9bef2d Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:19:07 +0000 Subject: [PATCH 0031/2031] Whitespace corrects. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10840 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenEntity.cpp | 21 - Source/DoxygenTranslator/src/DoxygenEntity.h | 1 - .../DoxygenTranslator/src/DoxygenParser.cpp | 1275 +++++++++-------- 3 files changed, 659 insertions(+), 638 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index dcca1d032..52fb60d90 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -10,27 +10,6 @@ #include "DoxygenEntity.h" #include -/* - * Basic node for commands that have nothing after them (eg: \n) - */ -std::string DoxygenEntity::commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "std::endlatexonly", "std::endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", std::string(1, 92), "&", "~", "<", ">", "#", "%"}; - DoxygenEntity::DoxygenEntity(std::string typeEnt){ typeOfEntity = typeEnt; data = ""; diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 3bec0bb0c..6a0b2e48c 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -25,7 +25,6 @@ struct DoxygenEntity{ std::list entityList; std::string data; int isLeaf; - static std::string commandArray[]; }; /* diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index ba624239a..cdc2d709f 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -37,75 +37,75 @@ std::list parse(std::list::iterator endParsingIndex, Toke std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "\\","&", "~", "<", ">", "#", "%"}; + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "\\","&", "~", "<", ">", "#", "%"}; std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" }; /* All of the doxygen commands divided up by how they are parsed */ std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; std::string ignoredSimpleCommands[] = {"nothing at the moment"}; std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; + "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; std::string ignoreCommandLines[] = {"nothing at the moment"}; std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; + "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; std::string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; std::string commandOWords[] = {"dir", "file", "cond"}; std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", - "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; + "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif"}; std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; +"subpage", "dotfile", "image", "addtogroup", "li"}; /* Changes a std::string to all lower case */ std::string StringToLower(std::string stringToConvert){ - for(unsigned int i=0;i &rootList){ - std::list::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; - } - } + std::list::iterator p = rootList.begin(); + while (p != rootList.end()){ + (*p).printEntity(0); + p++; + } +} /* Determines how a command should be handled (what group it belongs to * for parsing rules */ int commandBelongs(std::string theCommand){ - std::string smallString = StringToLower(theCommand); - //cout << " Looking for command " << theCommand << endl; - int i = 0; - for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0){return SIMPLECOMMAND;} - } - for ( i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ - if(smallString.compare(ignoredSimpleCommands[i]) == 0){return IGNOREDSIMPLECOMMAND;} - } - for ( i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ - if(smallString.compare( commandWords[i]) == 0){return COMMANDWORD;} - } - for ( i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ - if(smallString.compare( ignoredCommandWords[i]) == 0){return IGNOREDCOMMANDWORD;} - } - for ( i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ - if(smallString.compare( commandLines[i]) == 0){return COMMANDLINE;} - } - for ( i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ - if(smallString.compare( ignoreCommandLines[i]) == 0){return IGNOREDCOMMANDLINE;} - } - for ( i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ - if(smallString.compare( commandParagraph[i]) == 0){return COMMANDPARAGRAPH;} - } - for ( i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ - if(smallString.compare( ignoreCommandParagraphs[i]) == 0){return IGNORECOMMANDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ - if(smallString.compare( commandEndCommands[i]) == 0){return COMMANDENDCOMMAND ;} - } - for ( i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ - if(smallString.compare( commandWordParagraphs[i]) == 0){return COMMANDWORDPARAGRAPH;} - } - for ( i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ - if(smallString.compare( commandWordLines[i]) == 0){return COMMANDWORDLINE ;} - } - for ( i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ - if(smallString.compare( commandWordOWordOWords[i]) == 0){return COMMANDWORDOWORDWORD;} - } - for ( i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ - if(smallString.compare( commandOWords[i]) == 0){return COMMANDOWORD;} - } - for ( i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ - if(smallString.compare( commandErrorThrowings[i]) == 0){return COMMANDERRORTHROW;} - } - for ( i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ - if(smallString.compare( commandUniques[i]) == 0){return COMMANDUNIQUE;} - } - return 0; + std::string smallString = StringToLower(theCommand); + //cout << " Looking for command " << theCommand << endl; + unsigned i = 0; + for (i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ + if(smallString.compare(simpleCommands[i]) == 0) + return SIMPLECOMMAND; + } + for (i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ + if(smallString.compare(ignoredSimpleCommands[i]) == 0) + return IGNOREDSIMPLECOMMAND; + } + for (i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ + if(smallString.compare( commandWords[i]) == 0) + return COMMANDWORD; + } + for (i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ + if(smallString.compare( ignoredCommandWords[i]) == 0) + return IGNOREDCOMMANDWORD; + } + for (i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ + if(smallString.compare( commandLines[i]) == 0) + return COMMANDLINE; + } + for (i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ + if(smallString.compare( ignoreCommandLines[i]) == 0) + return IGNOREDCOMMANDLINE; + } + for (i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ + if(smallString.compare( commandParagraph[i]) == 0) + return COMMANDPARAGRAPH; + } + for (i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ + if(smallString.compare( ignoreCommandParagraphs[i]) == 0) + return IGNORECOMMANDPARAGRAPH; + } + for (i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ + if(smallString.compare( commandEndCommands[i]) == 0) + return COMMANDENDCOMMAND; + } + for (i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ + if(smallString.compare( commandWordParagraphs[i]) == 0) + return COMMANDWORDPARAGRAPH; + } + for (i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ + if(smallString.compare( commandWordLines[i]) == 0) + return COMMANDWORDLINE; + } + for (i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ + if(smallString.compare( commandWordOWordOWords[i]) == 0) + return COMMANDWORDOWORDWORD; + } + for (i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ + if(smallString.compare( commandOWords[i]) == 0) + return COMMANDOWORD; + } + for (i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ + if(smallString.compare( commandErrorThrowings[i]) == 0) + return COMMANDERRORTHROW; + } + for (i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ + if(smallString.compare( commandUniques[i]) == 0) + return COMMANDUNIQUE; + } + return 0; } /* Returns the next word ON THE CURRENT LINE ONLY @@ -191,46 +206,46 @@ int commandBelongs(std::string theCommand){ * Updates the index it is given if success. */ std::string getNextWord(TokenList &tokList){ - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING ){ - nextToken = tokList.next(); - return nextToken.tokenString; - } - return ""; + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING ){ + nextToken = tokList.next(); + return nextToken.tokenString; + } + return ""; } /* Returns the location of the end of the line as * an iterator. */ std::list::iterator getOneLine(TokenList &tokList){ - std::list::iterator endOfLine = tokList.iteratorCopy(); - while(endOfLine!= tokList.end()){ - if ((* endOfLine).tokenType == END_LINE){ - //cout << "REACHED END" << endl; - //endOfLine++; - return endOfLine; - } - //cout << (* endOfLine).toString(); - endOfLine++; - } - - return tokList.end(); - } + std::list::iterator endOfLine = tokList.iteratorCopy(); + while(endOfLine!= tokList.end()){ + if ((* endOfLine).tokenType == END_LINE){ + //cout << "REACHED END" << endl; + //endOfLine++; + return endOfLine; + } + //cout << (* endOfLine).toString(); + endOfLine++; + } + + return tokList.end(); + } /* Returns a properly formatted std::string * up til ANY command or end of line is encountered. */ std::string getStringTilCommand(TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING){ - Token currentToken = tokList.next(); - if(currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - } - return description; - } + std::string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenType == PLAINSTRING){ + Token currentToken = tokList.next(); + if(currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } + } + return description; + } /* Returns a properly formatted std::string * up til the command specified is encountered @@ -238,66 +253,66 @@ std::string getStringTilCommand(TokenList &tokList){ //TODO check that this behaves properly for formulas std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenString.compare(theCommand) != 0 ){ - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; - } - return description; - } + std::string description; + if (tokList.peek().tokenType == 0) return ""; + while(tokList.peek().tokenString.compare(theCommand) != 0 ){ + Token currentToken = tokList.next(); + description = description + currentToken.tokenString + " "; + } + return description; + } /* Returns the end of a Paragraph as an iterator- * Paragraph is defined in Doxygen to be a paragraph of text * seperate by either a structural command or a blank line */ std::list::iterator getEndOfParagraph(TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - //cout << "ENCOUNTERED END OF PARA" << endl; - return endOfParagraph; - } - } - else if ((* endOfParagraph).tokenType == COMMAND){ - if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else return tokList.end(); - } - return tokList.end(); - } + std::list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + //cout << "ENCOUNTERED END OF PARA" << endl; + return endOfParagraph; + } + } + else if ((* endOfParagraph).tokenType == COMMAND){ + if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else return tokList.end(); + } + return tokList.end(); + } /* Returns the end of a section, defined as the first blank line OR first encounter of the same * command. Example of this behaviour is \arg * if no end is encountered, returns the last token of the std::list. */ std::list::iterator getEndOfSection(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } - } - return tokList.end(); - } + std::list::iterator endOfParagraph = tokList.iteratorCopy(); + while(endOfParagraph != tokList.end()){ + if ((* endOfParagraph).tokenType == COMMAND){ + if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; + else endOfParagraph++; + } + else if((* endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } + else if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + if ((* endOfParagraph).tokenType == END_LINE){ + endOfParagraph++; + return endOfParagraph; + } + } + } + return tokList.end(); + } /* This method is for returning the end of a specific form of doxygen command * that begins with a \command and ends in \endcommand @@ -306,26 +321,27 @@ std::list::iterator getEndOfSection(std::string theCommand, TokenList &to * If the end is never encountered, it returns the end of the std::list. */ std::list::iterator getEndCommand(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand!= tokList.end()){ - if ((*endOfCommand).tokenType == COMMAND){ - if (theCommand.compare((* endOfCommand).tokenString) == 0){ - return endOfCommand; - } - endOfCommand++; - } - } - //End command not found - return tokList.end(); + std::list::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand!= tokList.end()){ + if ((*endOfCommand).tokenType == COMMAND){ + if (theCommand.compare((* endOfCommand).tokenString) == 0){ + return endOfCommand; + } + endOfCommand++; + } + } + //End command not found + return tokList.end(); } /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ //TODO getTilAnyCommand std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){ - std::list::iterator anIterator; - return anIterator; - } +#pragma unused(theCommand,tokList) + std::list::iterator anIterator; + return anIterator; +} @@ -335,325 +351,349 @@ std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &t * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ - int addSimpleCommand(std::string theCommand, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - - /* NOT INCLUDED Simple Commands - * Format: @command - * Plain commands, such as newline etc, they contain no other data - */ - int ignoreSimpleCommand(std::string theCommand, std::list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - return 1; - } - - /* CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" - */ - int addCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (!name.empty()){ - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - else cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - - /* NOT INCLUDED CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" - */ - int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - std::string name = getNextWord(tokList); - if (!name.empty()){ - return 1; - } - else cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; - } - - /* CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" - */ - int addCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - - /* NOT INCLUDED CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 1; +int addSimpleCommand(std::string theCommand, std::list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; } - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single paragraph after then such as @return - * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" - */ - int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single LINE after then such as @var - * - */ - int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; +/* NOT INCLUDED Simple Commands +* Format: @command +* Plain commands, such as newline etc, they contain no other data +*/ +int ignoreSimpleCommand(std::string theCommand, std::list &doxyList){ +#pragma unused(doxyList) + if (noisy) cout << "Not Adding " << theCommand << endl; + return 1; } - /* Command EndCommand - * Format: @command and ends at @endcommand - * Commands that take in a block of text such as @code - * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" - * Returns 1 if success, 0 if the endcommand is never encountered. - */ - int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Not Adding " << theCommand << endl; - std::string description = getStringTilEndCommand( "end" + theCommand, tokList); - doxyList.push_back(DoxygenEntity(theCommand, description)); - return 1; - } +/* CommandWord +* Format: @command +* Commands with a single WORD after then such as @b +* "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", +* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" +*/ +int addCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (!name.empty()){ + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } + else + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; +} - /* CommandWordParagraph - * Format: @command {paragraph} - * Commands such as param - * "param", "tparam", "throw", "retval", "exception" - */ - int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - - /* CommandWordLine - * Format: @command (line) - * Commands such as param - * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" - */ - int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList; - aNewList = parse(endOfLine, tokList); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - - //else cout << "No line followed " << theCommand << " command. Not added" << endl; - } +/* NOT INCLUDED CommandWord +* Format: @command +* Commands with a single WORD after then such as @b +* "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" +*/ +int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ +#pragma unused(doxyList) + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::string name = getNextWord(tokList); + if (!name.empty()) + return 1; + else + cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; +} - /* Command Word Optional Word Optional Word - * Format: @command [] [] - * Commands such as class - * "category", "class", "protocol", "interface", "struct", "union" - */ - int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::string headerfile = getNextWord(tokList); - std::string headername = getNextWord(tokList); - std::list aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } +/* CommandLine +* Format: @command (line) +* Commands with a single LINE after then such as @var +* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" +*/ +int addCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::list::iterator endOfLine = getOneLine(tokList); + std::list aNewList = parse(endOfLine, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; +} + +/* NOT INCLUDED CommandLine +* Format: @command (line) +* Commands with a single LINE after then such as @var +* +*/ +int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ +#pragma unused(doxyList) + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 1; +} + +/* CommandParagraph +* Format: @command {paragraph} +* Commands with a single paragraph after then such as @return +* "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", +* "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" +*/ +int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + return 1; +} - /* Command Optional Word - * Format: @command [] - * Commands such as dir - * "dir", "file", "cond" - */ - int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } +/* CommandParagraph +* Format: @command {paragraph} +* Commands with a single LINE after then such as @var +* +*/ +int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ +#pragma unused(doxyList) + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; +} + +/* Command EndCommand +* Format: @command and ends at @endcommand +* Commands that take in a block of text such as @code +* "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", +* "verbatim", "xmlonly", "cond", "if", "ifnot", "link" +* Returns 1 if success, 0 if the endcommand is never encountered. +*/ +int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::string description = getStringTilEndCommand( "end" + theCommand, tokList); + doxyList.push_back(DoxygenEntity(theCommand, description)); + return 1; +} + +/* CommandWordParagraph +* Format: @command {paragraph} +* Commands such as param +* "param", "tparam", "throw", "retval", "exception" +*/ +int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list aNewList; + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; +} + +/* CommandWordLine +* Format: @command (line) +* Commands such as param +* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" +*/ +int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list::iterator endOfLine = getOneLine(tokList); + std::list aNewList; + aNewList = parse(endOfLine, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + //else cout << "No line followed " << theCommand << " command. Not added" << endl; +} + +/* Command Word Optional Word Optional Word +* Format: @command [] [] +* Commands such as class +* "category", "class", "protocol", "interface", "struct", "union" +*/ +int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::string headerfile = getNextWord(tokList); + std::string headername = getNextWord(tokList); + std::list aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; +} + +/* Command Optional Word +* Format: @command [] +* Commands such as dir +* "dir", "file", "cond" +*/ +int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; +} /* Commands that should not be encountered (such as PHP only) * goes til the end of line then returns */ - int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list &doxyList){ - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - std::list::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 0; +int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list &doxyList){ +#pragma unused(doxyList) + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + std::list::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 0; } /* Adds the unique commands- different process for each unique command */ - int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ - std::list aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - std::list::iterator endOfSection = getEndOfSection(theCommand, tokList); - std::list aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - } - // \xrefitem "(heading)" "(std::list title)" {text} - else if (theCommand.compare("xrefitem") == 0){ - //TODO Implement xrefitem - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; - } - // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0){ - std::string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - std::list aNewList2; - aNewList2 = parse(endOfLine, tokList); - aNewList.splice(aNewList.end(), aNewList2); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \headerfile [] - else if (theCommand.compare("headerfile") == 0){ - std::list aNewList; - std::string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()){ - std::list aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - else doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - // \ref ["(text)"] - else if (theCommand.compare("ref") == 0){ - //TODO Implement ref - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0){ - //TODO implement subpage - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0){ - //TODO implement dotfile - if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \image ["caption"] [=] - else if (theCommand.compare("image") == 0){ - //todo implement image - } - // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - return 0; - } +int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ + std::list aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ + std::list::iterator endOfSection = getEndOfSection(theCommand, tokList); + std::list aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + } + // \xrefitem "(heading)" "(std::list title)" {text} + else if (theCommand.compare("xrefitem") == 0){ + //TODO Implement xrefitem + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; + } + // \ingroup ( [ ]) + else if (theCommand.compare("ingroup") == 0){ + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if(!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if(!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \par [(paragraph title)] { paragraph } + else if (theCommand.compare("par") == 0){ + std::list::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + std::list aNewList2; + aNewList2 = parse(endOfLine, tokList); + aNewList.splice(aNewList.end(), aNewList2); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \headerfile [] + else if (theCommand.compare("headerfile") == 0){ + std::list aNewList; + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if(!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \overload [(function declaration)] + else if (theCommand.compare("overload") == 0){ + std::list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()){ + std::list aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + else + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; + } + // \weakgroup [(title)] + else if (theCommand.compare("weakgroup") == 0){ + if (noisy) cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + // \ref ["(text)"] + else if (theCommand.compare("ref") == 0){ + //TODO Implement ref + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \subpage ["(text)"] + else if (theCommand.compare("subpage") == 0){ + //TODO implement subpage + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \dotfile ["caption"] + else if (theCommand.compare("dotfile") == 0){ + //TODO implement dotfile + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \image ["caption"] [=] + else if (theCommand.compare("image") == 0){ + //todo implement image + } + // \addtogroup [(title)] + else if (theCommand.compare("addtogroup") == 0){ + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()){ + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list aNewList; + std::list::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + return 0; +} /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in @@ -662,129 +702,132 @@ std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &t int addCommand(std::string commandString, TokenList &tokList,std::list &doxyList){ - std::string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstd::string") == 0){ - std::string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND){ - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW){ - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE){ - return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; - } + std::string theCommand = StringToLower(commandString); + if (theCommand.compare("plainstd::string") == 0){ + std::string nextPhrase = getStringTilCommand( tokList); + if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND){ + return addSimpleCommand(theCommand, doxyList); + } + if (commandNumber == IGNOREDSIMPLECOMMAND){ + return ignoreSimpleCommand(theCommand, doxyList); + } + if (commandNumber == COMMANDWORD){ + return addCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDWORD){ + return ignoreCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDLINE ){ + return addCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDLINE ){ + return ignoreCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDPARAGRAPH){ + return addCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH){ + return ignoreCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDENDCOMMAND){ + return addCommandEndCommand(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDPARAGRAPH){ + return addCommandWordParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDLINE){ + return addCommandWordLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDOWORDWORD){ + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDOWORD){ + return addCommandOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDERRORTHROW){ + return addCommandErrorThrow(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDUNIQUE){ + return addCommandUnique(theCommand, tokList, doxyList); + } + + return 0; + } std::list parse(std::list::iterator endParsingIndex, TokenList &tokList){ - std::list aNewList; - int currCommand; - while (tokList.current() != endParsingIndex){ - Token currToken = tokList.peek(); - if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ - tokList.next(); - } - else if(currToken.tokenType == COMMAND){ - currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; - tokList.next(); - addCommand(std::string("plainstd::string"), tokList, aNewList);} - //cout << "Command: " << currWord << " " << currCommand << endl; - else { tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } - else if (currToken.tokenType == PLAINSTRING){ - addCommand(std::string("plainstd::string"), tokList, aNewList); - } - else break; - } - return aNewList; - } + std::list aNewList; + int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); + if(noisy) + cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(currToken.tokenType == END_LINE ){ + tokList.next(); + } + else if(currToken.tokenType == COMMAND){ + currCommand = findCommand(currToken.tokenString); + if (currCommand < 0 ){ + if(noisy) + cout << "Unidentified Command " << currToken.tokenString << endl; + tokList.next(); + addCommand(std::string("plainstd::string"), tokList, aNewList); + } + else { tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); + } + } + else if (currToken.tokenType == PLAINSTRING){ + addCommand(std::string("plainstd::string"), tokList, aNewList); + } + break; + } + return aNewList; +} std::list parseRoot(std::list::iterator endParsingIndex, TokenList &tokList){ - std::list aNewList; - int currCommand; - while (tokList.current() != endParsingIndex){ - Token currToken = tokList.peek(); - if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ - tokList.next(); - } - else if(currToken.tokenType == COMMAND){ - currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; - tokList.next(); - addCommand(std::string("partofdescription"), tokList, aNewList);} - //cout << "Command: " << currWord << " " << currCommand << endl; - else { tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } - else if (currToken.tokenType == PLAINSTRING){ - addCommand(std::string("partofdescription"), tokList, aNewList); - } - } - return aNewList; - } + std::list aNewList; + int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); + if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(currToken.tokenType == END_LINE ){ + tokList.next(); + } + else if(currToken.tokenType == COMMAND){ + currCommand = findCommand(currToken.tokenString); + if (currCommand < 0 ){ + if(noisy) + cout << "Unidentified Command " << currToken.tokenString << endl; + tokList.next(); + addCommand(std::string("partofdescription"), tokList, aNewList);} + //cout << "Command: " << currWord << " " << currCommand << endl; + else { tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); + } + } + else if (currToken.tokenType == PLAINSTRING){ + addCommand(std::string("partofdescription"), tokList, aNewList); + } + } + return aNewList; +} std::list DoxygenParser::createTree(std::string doxygenBlob){ - TokenList tokList = TokenList(doxygenBlob); - if(noisy) { - cout << "---TOKEN LIST---" << endl; - tokList.printList(); - } - std::list rootList; - rootList = parseRoot( tokList.end(), tokList); - if(noisy) { - cout << "PARSED LIST" << endl; - printTree(rootList); - } - return rootList; + TokenList tokList = TokenList(doxygenBlob); + if(noisy) { + cout << "---TOKEN LIST---" << endl; + tokList.printList(); + } + std::list rootList; + rootList = parseRoot( tokList.end(), tokList); + if(noisy) { + cout << "PARSED LIST" << endl; + printTree(rootList); + } + return rootList; } From d7f2ceedd4246b9ad8f4ac6c7ee2a6bf593676d0 Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:19:32 +0000 Subject: [PATCH 0032/2031] Improve output so that the width of the docstrings can be controlled. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10841 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/PyDocConverter.cpp | 155 ++++++------------ Source/DoxygenTranslator/src/PyDocConverter.h | 8 +- 2 files changed, 56 insertions(+), 107 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 1e4d6a73e..5bbda8dc2 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -2,9 +2,6 @@ #include #include -#define APPROX_LINE_LENGTH 64//characters per line allowed -#define TAB_SIZE 8//characters per line allowed - //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag PyDocConverter::PyDocConverter() { @@ -15,7 +12,7 @@ PyDocConverter::~PyDocConverter() { } -void PyDocConverter::printSortedTree(std::list &entityList){ +void PyDocConverter::printTree(std::list &entityList){ std::list::iterator p = entityList.begin(); while (p != entityList.end()){ (*p).printEntity(0); @@ -24,24 +21,23 @@ void PyDocConverter::printSortedTree(std::list &entityList){ } std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { - std::string result; ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p = NULL; DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); + std::string result; + std::string paramDescription = formatCommand(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); + for (p = plist; p;) { if(Char(Getattr(p, "name")) == paramNameEntity.data) { std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); - std::ostringstream parameterDocString; - - parameterDocString << std::endl << name << " (" << type << ") -- "; - parameterDocString << paramDescriptionEntity.data; - - result = parameterDocString.str(); + result = name + " (" + type + ") "; + result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); + result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); break; } p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); @@ -51,88 +47,33 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { return result; } -std::string PyDocConverter::formatCommand(std::string unformattedLine, int indent){ - std::string formattedLines = "\n"; - int lastPosition = 0; - signed int i = 0; - bool isFirstLine = true; - while (i != -1 && i < (int)unformattedLine.length()){ - lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; - } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; - i = unformattedLine.find(" ", i); - - if (i > 0 && i + 1 < (int)unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } - else { - isFirstLine = false; - } - formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); - formattedLines.append("\n"); - +std::string PyDocConverter::formatCommand(std::string documentString, int indent, int maxWidth){ + std::ostringstream formattedString; + std::string currentLine; + + for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) + { + if(currentLine.length() == 0) + currentLine.resize(indent, ' '); + + currentLine += *stringPosition; + + if(*stringPosition == ' ' && (int)currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) + { + formattedString << currentLine << std::endl; + currentLine = ""; } } - if (lastPosition < (int)unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} - formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); - } - - return formattedLines; + + return formattedString.str(); } -/* Contains the conversions for tags - * could probably be much more efficient... - */ -std::string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){ - if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ - return doxygenEntity.data; - } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ - return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("@") == 0){ - return "@"; - } - else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ - return "\\"; - } - else if (doxygenEntity.typeOfEntity.compare("<") == 0){ - return "<"; - } - else if (doxygenEntity.typeOfEntity.compare(">") == 0){ - return ">"; - } - else if (doxygenEntity.typeOfEntity.compare("&") == 0){ - return "&"; - } - else if (doxygenEntity.typeOfEntity.compare("#") == 0){ - return "#"; - } - else if (doxygenEntity.typeOfEntity.compare("%") == 0){ - return "%"; - } - else if (doxygenEntity.typeOfEntity.compare("~") == 0){ - return "~"; - } - return ""; -} - - std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string returnedString; - if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";} + if (doxygenEntity.isLeaf) + return doxygenEntity.data + " "; else { - returnedString += pyDocFormat(doxygenEntity); + returnedString += doxygenEntity.data; std::list::iterator p = doxygenEntity.entityList.begin(); while (p != doxygenEntity.entityList.end()){ returnedString+= translateSubtree(*p); @@ -150,8 +91,8 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 - || doxyEntity.typeOfEntity.compare("deprecated")== 0 - || doxyEntity.typeOfEntity.compare("brief")== 0) + || doxyEntity.typeOfEntity.compare("deprecated")== 0 + || doxyEntity.typeOfEntity.compare("brief")== 0) return formatCommand(doxyEntity.data, 0) + "\n * "; if(doxyEntity.typeOfEntity.compare("see") == 0) @@ -159,33 +100,38 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ if(doxyEntity.typeOfEntity.compare("param") == 0) return formatParam(n, doxyEntity); + + if(doxyEntity.typeOfEntity.compare("return")== 0) + - if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0) + if(doxyEntity.typeOfEntity.compare("author")== 0 + || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("since")== 0 + || doxyEntity.typeOfEntity.compare("version")== 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0) return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); if(doxyEntity.typeOfEntity.compare("sa")== 0) return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); - return formatCommand(pyDocFormat(doxyEntity), 0); + return formatCommand(doxyEntity.data, 0); } std::string PyDocConverter::convertToPyDoc(Node *n, std::list entityList){ - entityList.sort(CompareDoxygenEntities()); + std::string pyDocString = "\"\"\"\n"; - if(debug){ - std::cout << "---RESORTED LIST---" << std::endl; - printSortedTree(entityList); - } - - std::string pyDocString = "\"\"\""; + bool inParamsSection = false; for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ + if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) + { + inParamsSection = true; + pyDocString += "\nArguments:\n"; + } + else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) + inParamsSection = false; + pyDocString += translateEntity(n, *entityIterator); entityIterator++; } @@ -194,7 +140,8 @@ std::string PyDocConverter::convertToPyDoc(Node *n, std::list ent if(debug){ std::cout << "\n---RESULT IN PYDOC---" << std::endl; - std::cout << pyDocString; + std::cout << pyDocString; + std::cout << std::endl; } return pyDocString; diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 27faaf6c3..4c7fdd4db 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -6,18 +6,20 @@ #include "swig.h" #include "DoxygenEntity.h" +#define DOC_STRING_LENGTH 64 // characters per line allowed +#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type + class PyDocConverter { public: PyDocConverter(); std::string convertToPyDoc(Node *n, std::list entityList); ~PyDocConverter(); - void printSortedTree(std::list &entityList); + void printTree(std::list &entityList); protected: std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); - std::string formatCommand(std::string unformattedLine, int indent); - std::string pyDocFormat(DoxygenEntity &doxygenEntity); + std::string formatCommand(std::string unformattedLine, int indent, int maxWidth = DOC_STRING_LENGTH); std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); From 0f41d25c0938566f4037fd117526f848009d3887 Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:19:53 +0000 Subject: [PATCH 0033/2031] Ensure doxygen comments are copied to overloaded function nodes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10842 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 95bd8701d..06b0685c6 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1363,6 +1363,10 @@ static void default_arguments(Node *n) { if (throws) Setattr(new_function,"throws",pl); Delete(pl); } + + /* copy doxygen comments if found */ + if(Getattr(function,"DoxygenComment")) + Setattr(new_function,"DoxygenComment",Getattr(function,"DoxygenComment")); /* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */ if (strcmp(cntype,"template") == 0) { From 01695a31285dc7101b07b09deae7465caeaad0f3 Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:20:58 +0000 Subject: [PATCH 0034/2031] Major refactoring: translation now takes a node and returns a translated comment if there is one. This is to allow for situations where you need to use several nodes to create a comment, for example where there are multiple overloads for the same function but the target language doesnt support overloading: in this case we want to combine comments to explain the possible overloads. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10843 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../src/DoxygenTranslator.cpp | 63 ++++---- .../DoxygenTranslator/src/DoxygenTranslator.h | 58 ++++++- .../src/JavaDocConverter.cpp | 51 +++--- .../DoxygenTranslator/src/JavaDocConverter.h | 34 ++-- .../DoxygenTranslator/src/PyDocConverter.cpp | 59 ++++--- Source/DoxygenTranslator/src/PyDocConverter.h | 43 +++++- Source/Modules/java.cxx | 145 +++++++++--------- Source/Modules/python.cxx | 58 ++++--- Source/Swig/misc.c | 11 ++ Source/Swig/swig.h | 3 +- 10 files changed, 324 insertions(+), 201 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index fc74c5c20..025670796 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -1,43 +1,32 @@ -#include "DoxygenParser.h" +/* ----------------------------------------------------------------------------- + * 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. + * + * DoxygenTranslator.cpp + * + * Module to return documentation for nodes formatted for various documentation + * systems. + * ----------------------------------------------------------------------------- */ + #include "DoxygenTranslator.h" -#include -#include -#include -#include "DoxygenEntity.h" #include "JavaDocConverter.h" #include "PyDocConverter.h" -DoxygenParser doxyParse; -JavaDocConverter jDC; -PyDocConverter pyDC; - -DoxygenTranslator::DoxygenTranslator(){ - doxyParse = DoxygenParser(); - JavaDocConverter jDC = JavaDocConverter(); - PyDocConverter pyDC = PyDocConverter(); -} - -DoxygenTranslator::~DoxygenTranslator(){ - -} - - -char *DoxygenTranslator::convert(Node *n, char* doxygenBlob, char* option){ - - std::list rootList = doxyParse.createTree(std::string(doxygenBlob)); - std::string returnedString; - - if(strcmp(option, "JAVADOC") == 0) - returnedString = jDC.convertToJavaDoc(n, rootList); - else if(strcmp(option, "PYDOC") == 0) - returnedString = pyDC.convertToPyDoc(n, rootList); - else - std::cout << "Option not current supported." << std::endl; - - char *nonConstString; - nonConstString = (char *)malloc(returnedString.length() + 1); - strcpy(nonConstString, returnedString.c_str()); - - return nonConstString; +bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){ + switch(format){ + case JavaDoc: + return JavaDocConverter().getDocumentation(node, documentation); + case PyDoc: + return PyDocConverter().getDocumentation(node, documentation); + default: + return false; + } } +void DoxygenTranslator::printTree(std::list &entityList){ + std::list::iterator p = entityList.begin(); + while (p != entityList.end()){ + (*p).printEntity(0); + p++; + } +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 3c26e3a25..4be1e97e3 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -1,13 +1,65 @@ +/* ----------------------------------------------------------------------------- + * 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. + * + * DoxygenTranslator.h + * + * Module to return documentation for nodes formatted for various documentation + * systems. + * ----------------------------------------------------------------------------- */ + #ifndef DOXYGENTRANSLATOR_H_ #define DOXYGENTRANSLATOR_H_ #include "swig.h" +#include "DoxygenEntity.h" +#include +/* + * Describes the availible documentation systems + * that can be translated to. + */ +enum DocumentationFormat { + JavaDoc = 1, + PyDoc = 2 +}; + +/* + * A class to translate doxygen comments attacted to parser nodes + * into alternative formats for use in code generated for target languages. + */ class DoxygenTranslator { public: - DoxygenTranslator(); - virtual ~DoxygenTranslator(); - char* convert(Node *n, char* doxygenBlob, char* option); + /* + * Virtual destructor. + */ + virtual ~DoxygenTranslator(){} + + /* + * Return the documentation for a given node formated for the correct + * documentation system. + * @param node The node to extract and translate documentation for. + * @param format The documentation format to output. + * @param documentation The returned documentation string. + * @return A bool to indicate if there was documentation to return for the node. + */ + static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation); + +protected: + /* + * Overridden in subclasses to return the documentation formatted for a given + * documentation system. + * @param node The node to extract and translate documentation for. + * @param documentation The returned documentation string. + * @return A bool to indicate if there was documentation to return for the node. + */ + virtual bool getDocumentation(Node *node, String *&documentation) = 0; + + /* + * Prints the details of a parsed entity list to stdout (for debugging). + */ + void printTree(std::list &entityList); }; + #endif /*DOXYGENTRANSLATOR_H_*/ diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index dbf606bfd..5081156bd 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,31 +1,17 @@ #include "JavaDocConverter.h" +#include "DoxygenParser.h" #include #define APPROX_LINE_LENGTH 64//characters per line allowed #define TAB_SIZE 8//characters per line allowed int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -JavaDocConverter::JavaDocConverter() -{ -} -JavaDocConverter::~JavaDocConverter() -{ -} - -void JavaDocConverter::printSortedTree(std::list &entityList){ - std::list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } -} - -std::string formatCommand(std::string unformattedLine, int indent){ +std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent){ std::string formattedLines = "\n * "; int lastPosition = 0; int i = 0; int isFirstLine = 1; - while (i != -1 && i < unformattedLine.length()){ + while (i != -1 && i < (int)unformattedLine.length()){ lastPosition = i; if (isFirstLine){ i+=APPROX_LINE_LENGTH; @@ -33,7 +19,7 @@ std::string formatCommand(std::string unformattedLine, int indent){ else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < unformattedLine.length()){ + if (i > 0 && i + 1 < (int)unformattedLine.length()){ if (!isFirstLine) for (int j = 0; j < indent; j++) { formattedLines.append("\t"); } @@ -45,7 +31,7 @@ std::string formatCommand(std::string unformattedLine, int indent){ } } - if (lastPosition < unformattedLine.length()){ + if (lastPosition < (int)unformattedLine.length()){ if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); } @@ -56,7 +42,7 @@ std::string formatCommand(std::string unformattedLine, int indent){ /* Contains the conversions for tags * could probably be much more efficient... */ -std::string javaDocFormat(DoxygenEntity &doxygenEntity){ +std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ return doxygenEntity.data; } @@ -97,7 +83,7 @@ std::string javaDocFormat(DoxygenEntity &doxygenEntity){ } -std::string translateSubtree( DoxygenEntity &doxygenEntity){ +std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string returnedString; if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} else { @@ -111,7 +97,7 @@ std::string translateSubtree( DoxygenEntity &doxygenEntity){ return returnedString; } -std::string translateEntity(DoxygenEntity &doxyEntity){ +std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(std::string(translateSubtree(doxyEntity)), 0); if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} @@ -136,13 +122,19 @@ std::string translateEntity(DoxygenEntity &doxyEntity){ return ""; } -std::string JavaDocConverter:: convertToJavaDoc(Node *n, std::list entityList){ - #pragma unused(n) +bool JavaDocConverter::getDocumentation(Node *n, String *&documentation){ + documentation = Getattr(n,"DoxygenComment"); + if(documentation == NULL) + return false; + + std::list entityList = DoxygenParser().createTree(Char(documentation)); + Delete(documentation); + entityList.sort(CompareDoxygenEntities()); - if(printSortedTree2){ + if(debug){ std::cout << "---RESORTED LIST---" << std::endl; - printSortedTree(entityList); + printTree(entityList); } std::string javaDocString = "/**"; @@ -154,10 +146,11 @@ std::string JavaDocConverter:: convertToJavaDoc(Node *n, std::list -#include -#include "swig.h" -#include "DoxygenEntity.h" +#include "DoxygenTranslator.h" -class JavaDocConverter +/* + * A class to translate doxygen comments into JavaDoc style comments. + */ +class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter(); - std::string convertToJavaDoc(Node *n, std::list entityList); - ~JavaDocConverter(); - void printSortedTree(std::list &entityList); + JavaDocConverter() : debug( true ){} + virtual bool getDocumentation(Node *node, String *&documentation); + +protected: + std::string formatCommand(std::string unformattedLine, int indent); + std::string translateEntity(DoxygenEntity &doxyEntity); + std::string javaDocFormat(DoxygenEntity &doxygenEntity); + std::string translateSubtree( DoxygenEntity &doxygenEntity); + +private: + bool debug; }; #endif /*JAVADOCCONVERTER_H_*/ diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 5bbda8dc2..2065b090e 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -1,4 +1,14 @@ +/* ----------------------------------------------------------------------------- + * 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. + * + * PyDocConverter.cpp + * + * Module to return documentation for nodes formatted for PyDoc + * ----------------------------------------------------------------------------- */ + #include "PyDocConverter.h" +#include "DoxygenParser.h" #include #include @@ -8,18 +18,6 @@ PyDocConverter::PyDocConverter() debug = 1; } -PyDocConverter::~PyDocConverter() -{ -} - -void PyDocConverter::printTree(std::list &entityList){ - std::list::iterator p = entityList.begin(); - while (p != entityList.end()){ - (*p).printEntity(0); - p++; - } -} - std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p = NULL; @@ -28,7 +26,7 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); std::string result; - std::string paramDescription = formatCommand(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); + std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); for (p = plist; p;) { if(Char(Getattr(p, "name")) == paramNameEntity.data) { @@ -47,7 +45,12 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { return result; } -std::string PyDocConverter::formatCommand(std::string documentString, int indent, int maxWidth){ +std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){ +#pragma unused(node) + return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity)); +} + +std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth){ std::ostringstream formattedString; std::string currentLine; @@ -85,24 +88,24 @@ std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) - return formatCommand(std::string(translateSubtree(doxyEntity)), 0); + return justifyString(std::string(translateSubtree(doxyEntity)), 0); if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ - return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} + return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; + return justifyString(doxyEntity.data, 0) + "\n * "; if(doxyEntity.typeOfEntity.compare("see") == 0) - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + return justifyString(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); if(doxyEntity.typeOfEntity.compare("param") == 0) return formatParam(n, doxyEntity); if(doxyEntity.typeOfEntity.compare("return")== 0) - + return formatReturnDescription(n, doxyEntity); if(doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("param")== 0 @@ -110,15 +113,22 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ || doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0) - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); + return justifyString(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); if(doxyEntity.typeOfEntity.compare("sa")== 0) - return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); + return justifyString(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); - return formatCommand(doxyEntity.data, 0); + return justifyString(doxyEntity.data); } -std::string PyDocConverter::convertToPyDoc(Node *n, std::list entityList){ +bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ + documentation = Getattr(n,"DoxygenComment"); + if(documentation == NULL) + return false; + + std::list entityList = DoxygenParser().createTree(Char(documentation)); + Delete(documentation); + std::string pyDocString = "\"\"\"\n"; bool inParamsSection = false; @@ -144,5 +154,6 @@ std::string PyDocConverter::convertToPyDoc(Node *n, std::list ent std::cout << std::endl; } - return pyDocString; + documentation = NewString(pyDocString.c_str()); + return true; } \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 4c7fdd4db..5da58e4ec 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -1,3 +1,12 @@ +/* ----------------------------------------------------------------------------- + * 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. + * + * PyDocConverter.h + * + * Module to return documentation for nodes formatted for PyDoc + * ----------------------------------------------------------------------------- */ + #ifndef PYDOCCONVERTER_H_ #define PYDOCCONVERTER_H_ @@ -5,21 +14,41 @@ #include #include "swig.h" #include "DoxygenEntity.h" +#include "DoxygenTranslator.h" #define DOC_STRING_LENGTH 64 // characters per line allowed #define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type -class PyDocConverter +class PyDocConverter : public DoxygenTranslator { public: PyDocConverter(); - std::string convertToPyDoc(Node *n, std::list entityList); - ~PyDocConverter(); - void printTree(std::list &entityList); - + bool getDocumentation(Node *node, String *&documentation); + protected: - std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); - std::string formatCommand(std::string unformattedLine, int indent, int maxWidth = DOC_STRING_LENGTH); + /* + * Format the doxygen comment relating to a function or method parameter + * @param node The parse tree node that the parameter relates to. + * @param doxygenEntity The doxygen entity relating to the parameter docstring. + */ + std::string formatParam(Node *node, DoxygenEntity &doxygenEntity); + + /* + * Format the doxygen comment relating to the return value for a method or function. + * @param node The parse tree node that the parameter relates to. + * @param doxygenEntity The doxygen entity relating to the parameter docstring. + */ + std::string formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity); + + /* + * Format a string so it is justified and split over several lines + * not exeeding a given length. + * @param unformattedLine The string to justify and split. + * @param indent An optional number of spaces to indent each line by. + * @param maxWidth The approximate maximum line width. + */ + std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); + std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index edb88ebbb..42ba5b396 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -91,10 +91,6 @@ class JAVA:public Language { Setline(p, Getline(n)); return p; } - /* DOXYGEN TO JAVADOC globals */ - //TODO make this bool a command line option - DoxygenTranslator doxyTranslator; - public: @@ -124,7 +120,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), - doxygen_javadoc_flag(true), + doxygen_javadoc_flag(true), comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), @@ -160,7 +156,6 @@ public: should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; - doxyTranslator = DoxygenTranslator(); } /* ----------------------------------------------------------------------------- @@ -508,12 +503,13 @@ public: Printf(f_module, "%s\n", module_imports); if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */"); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(f_module, convertedString); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ + if(comment_creation_chatter) + Printf(f_module, "/* This was generated from top() */"); + Printf(f_module, Char(doxygen_comments)); + Delete(doxygen_comments); + } } if (Len(module_class_modifiers) > 0) Printf(f_module, "%s ", module_class_modifiers); @@ -1234,15 +1230,17 @@ public: // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printv(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration */", NIL ); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printv(proxy_class_constants_code, convertedString, NIL); - free(convertedString); - } + + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ + if(comment_creation_chatter) + Printf(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(proxy_class_constants_code, Char(doxygen_comments)); + Delete(doxygen_comments); } + } Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { @@ -1308,12 +1306,13 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */" ); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(enum_code, convertedString); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ + if(comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(enum_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } } { EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); @@ -1379,15 +1378,16 @@ public: * file * ------------------------------------------------------------------------ */ virtual int doxygenComment(Node *n){ - if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printv(structuralComments, "/* This was generated from doxygenComment() */\n", NIL); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printv(structuralComments, convertedString, NIL); - free(convertedString); - } - } - return SWIG_OK; + if (doxygen_javadoc_flag){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(structuralComments, "/* This was generated from doxygenComment() */"); + Printf(structuralComments, Char(doxygen_comments)); + Delete(doxygen_comments); + } + } + return SWIG_OK; } /* ----------------------------------------------------------------------- @@ -1408,14 +1408,16 @@ public: String *tm; String *return_type = NewString(""); String *constants_code = NewString(""); + //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(constants_code, "/* This was generated from enumvalueDeclaration */\n"); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(constants_code, convertedString); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(constants_code, "/* This was generated from constantWrapper() */"); + Printf(constants_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } } if (!addSymbol(symname, n)) @@ -1681,12 +1683,13 @@ public: //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printv(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n", NIL ); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printv(proxy_class_def, convertedString, NIL); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */"); + Printf(proxy_class_def, Char(doxygen_comments)); + Delete(doxygen_comments); + } } // Start writing the proxy class @@ -2021,15 +2024,15 @@ public: setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(Swig_name_member(proxy_class_name, variable_name))) == 0); } - //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler */"); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(function_code, convertedString); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */"); + Printf(function_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } } /* Start generating the proxy function */ @@ -2254,15 +2257,16 @@ public: tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node Printf(im_return_type, "%s", tm); - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler */\n" ); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(function_code, convertedString); - free(convertedString); - } - } + //translate and write javadoc comment if flagged + if (doxygen_javadoc_flag){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from constructionhandler() */"); + Printf(function_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } + } Printf(function_code, " %s %s(", methodmods, proxy_class_name); Printf(helper_code, " static private %s SwigConstruct%s(", im_return_type, proxy_class_name); @@ -2525,14 +2529,15 @@ public: String *pre_code = NewString(""); String *post_code = NewString(""); - //translate and write javadoc comment if flagged + // translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ - if (Getattr(n,"DoxygenComment")){ - if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n" ); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")),"JAVADOC"); - Printf(function_code, convertedString); - free(convertedString); - } + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */"); + Printf(function_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } } if (l) { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ba02eae2e..94b3c1377 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -18,6 +18,7 @@ char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton static int treduce = SWIG_cparse_template_reduce(0); #include +#include #include "../DoxygenTranslator/src/DoxygenTranslator.h" #define PYSHADOW_MEMBER 0x2 @@ -85,8 +86,6 @@ static int extranative = 0; static int outputtuple = 0; static int nortti = 0; -static DoxygenTranslator doxyTranslator; - /* flags for the make_autodoc function */ enum autodoc_t { AUTODOC_CLASS, @@ -2906,19 +2905,18 @@ public: } } Printf(f_shadow, ":\n"); - - //translate and write pydoc comment if flagged - if (doxygen){ - if (Getattr(n,"DoxygenComment")){ - //if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */"); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC"); - Printf(f_shadow, Char(pythoncode(convertedString, shadow_indent))); - free(convertedString); - } + + // translate and write pydoc comment if flagged + if (doxygen){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ + Printf(f_shadow, Char(pythoncode(doxygen_comments, shadow_indent))); + Delete(doxygen_comments); } + } - // otherwise use default docstrings if requested - else if (have_docstring(n)) { + // otherwise use default docstrings if requested + else if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str != NULL && Len(str)) Printv(f_shadow, tab4, str, "\n", NIL); @@ -3130,15 +3128,33 @@ public: } else { Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); - if (doxygen) { - if (Getattr(n,"DoxygenComment")){ - //if(comment_creation_chatter) Printf(function_code, "/* This was generated from classHandler */"); - char *convertedString = doxyTranslator.convert(n, Char(Getattr(n,"DoxygenComment")), "PYDOC"); - Printf(f_shadow, Char(pythoncode(convertedString, tab8))); - free(convertedString); - } + if (doxygen) { + /*Node *documented_node = n; + if(Getattr(n, "sym:overloaded")){ + // If the function is overloaded then this funciton is called + // for the last one. Rewind to the first so the docstrings are + // in order. + while (Getattr(documented_node, "sym:previousSibling")) + documented_node = Getattr(documented_node, "sym:previousSibling"); + + int real_overload_count = 0; + std::ostringstream all_documentation; + + // for each real method (not a generated overload) append the documentation + while(documented_node){ + if(!is_generated_overload(documented_node) && Getattr(documented_node,"DoxygenComment")){ + all_documentation << "Overload " << ++real_overload_count << ":" << std::endl; + all_documentation << Char(Getattr(documented_node,"DoxygenComment")) << std::endl; + } + documented_node = Getattr(documented_node, "sym:nextSibling"); } - if (have_docstring(n)) + + char *convertedString = doxyTranslator.convert(n,const_cast< char *>(all_documentation.str().c_str()), "PYDOC"); + Printf(f_shadow, Char(pythoncode(convertedString, tab8))); + free(convertedString); + }*/ + } + else if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index d29250517..a9c64011e 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1032,6 +1032,17 @@ String *Swig_string_rxspencer(String *s) { } #endif +/* ------------------------------------------------------------ + * is_generated_overload() + * Check if the function is an automatically generated + * overload created because a method has default parameters. + * ------------------------------------------------------------ */ +int Swig_is_generated_overload(Node *n) +{ + Node *base_method = Getattr(n, "sym:overloaded"); + Node *default_args = Getattr(n, "defaultargs"); + return ((base_method != NULL) && (default_args != NULL) && (base_method == default_args)); +} /* ----------------------------------------------------------------------------- * Swig_init() diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 451de86c4..3f736bbd5 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -300,8 +300,9 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_init(void); extern void Swig_warn(const char *filename, int line, const char *msg); - + extern int Swig_value_wrapper_mode(int mode); + extern int Swig_is_generated_overload(Node *n); #define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg) From 83cef07b9025935338499a0b2b9fd70bb7d4706a Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:21:40 +0000 Subject: [PATCH 0035/2031] Multiple documentation sections are now concatted into one where there are various overloads for methods with the same name. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10844 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../src/JavaDocConverter.cpp | 2 - .../DoxygenTranslator/src/PyDocConverter.cpp | 101 +++++++++++++----- Source/DoxygenTranslator/src/PyDocConverter.h | 13 +++ Source/Modules/python.cxx | 29 +---- 4 files changed, 95 insertions(+), 50 deletions(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 5081156bd..0ba97fc60 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -128,8 +128,6 @@ bool JavaDocConverter::getDocumentation(Node *n, String *&documentation){ return false; std::list entityList = DoxygenParser().createTree(Char(documentation)); - Delete(documentation); - entityList.sort(CompareDoxygenEntities()); if(debug){ diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 2065b090e..dbee97233 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -9,8 +9,9 @@ #include "PyDocConverter.h" #include "DoxygenParser.h" -#include #include +#include +#include //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag PyDocConverter::PyDocConverter() @@ -121,39 +122,91 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ return justifyString(doxyEntity.data); } -bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ - documentation = Getattr(n,"DoxygenComment"); - if(documentation == NULL) - return false; - - std::list entityList = DoxygenParser().createTree(Char(documentation)); - Delete(documentation); - - std::string pyDocString = "\"\"\"\n"; - +std::string PyDocConverter::processEntityList(Node *n, std::list& entityList){ + std::string result; bool inParamsSection = false; for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ - if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) - { + if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){ inParamsSection = true; - pyDocString += "\nArguments:\n"; + result += "\nArguments:\n"; } else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) inParamsSection = false; - pyDocString += translateEntity(n, *entityIterator); + result += translateEntity(n, *entityIterator); entityIterator++; - } + } + + return result; +} - pyDocString += "\n\"\"\"\n"; +bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ + std::string pyDocString, result; - if(debug){ - std::cout << "\n---RESULT IN PYDOC---" << std::endl; - std::cout << pyDocString; - std::cout << std::endl; + // for overloaded functions we must concat documentation for underlying overloads + if(Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")){ + // rewind to the first overload + while (Getattr(n, "sym:previousSibling")) + n = Getattr(n, "sym:previousSibling"); + + std::vector allDocumentation; + + // for each real method (not a generated overload) append the documentation + while(n){ + documentation = Getattr(n,"DoxygenComment"); + if(!Swig_is_generated_overload(n) && documentation){ + std::list entityList = DoxygenParser().createTree(Char(documentation)); + allDocumentation.push_back(processEntityList(n, entityList)); + } + n = Getattr(n, "sym:nextSibling"); + } + + // construct final documentation string + if(allDocumentation.size() > 1){ + std::ostringstream concatDocString; + for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){ + concatDocString << generateDivider(); + concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; + concatDocString << generateDivider(); + concatDocString << allDocumentation[realOverloadCount] << std::endl; + } + pyDocString = concatDocString.str(); + } + else if (allDocumentation.size() == 1) { + pyDocString = *(allDocumentation.begin()); + } + } + // for other nodes just process as normal + else { + documentation = Getattr(n,"DoxygenComment"); + if(documentation != NULL){ + std::list entityList = DoxygenParser().createTree(Char(documentation)); + pyDocString = processEntityList(n, entityList); + } } - documentation = NewString(pyDocString.c_str()); - return true; -} \ No newline at end of file + // if we got something log the result and construct DOH string to return + if(pyDocString.length()) { + result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; + + if(debug){ + std::cout << "\n---RESULT IN PYDOC---" << std::endl; + std::cout << result; + std::cout << std::endl; + } + + documentation = NewString(result.c_str()); + return true; + } + + return false; +} + +std::string PyDocConverter::generateDivider(){ + std::ostringstream dividerString; + for(int i = 0; i < DOC_STRING_LENGTH; i++) + dividerString << '-'; + dividerString << std::endl; + return dividerString.str(); +} diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 5da58e4ec..500e39fe8 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -26,6 +26,14 @@ public: bool getDocumentation(Node *node, String *&documentation); protected: + + /* + * Process the contents of the entity list producing a documentation string. + * @param node The parse tree node that the entity list relates to. + * @param entityList The entity list to process + */ + std::string processEntityList(Node *node, std::list& entityList); + /* * Format the doxygen comment relating to a function or method parameter * @param node The parse tree node that the parameter relates to. @@ -51,6 +59,11 @@ protected: std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); + + /* + * Utility method to generate a diving line for a documentation string. + */ + std::string generateDivider(); private: bool debug; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 94b3c1377..8a3160ef3 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3129,30 +3129,11 @@ public: Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); if (doxygen) { - /*Node *documented_node = n; - if(Getattr(n, "sym:overloaded")){ - // If the function is overloaded then this funciton is called - // for the last one. Rewind to the first so the docstrings are - // in order. - while (Getattr(documented_node, "sym:previousSibling")) - documented_node = Getattr(documented_node, "sym:previousSibling"); - - int real_overload_count = 0; - std::ostringstream all_documentation; - - // for each real method (not a generated overload) append the documentation - while(documented_node){ - if(!is_generated_overload(documented_node) && Getattr(documented_node,"DoxygenComment")){ - all_documentation << "Overload " << ++real_overload_count << ":" << std::endl; - all_documentation << Char(Getattr(documented_node,"DoxygenComment")) << std::endl; - } - documented_node = Getattr(documented_node, "sym:nextSibling"); - } - - char *convertedString = doxyTranslator.convert(n,const_cast< char *>(all_documentation.str().c_str()), "PYDOC"); - Printf(f_shadow, Char(pythoncode(convertedString, tab8))); - free(convertedString); - }*/ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ + Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); + Delete(doxygen_comments); + } } else if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); From 8d28e0faadbfb6ce9a1d6695d11cc1f15fc8ccbb Mon Sep 17 00:00:00 2001 From: Jamie Kirkpatrick Date: Fri, 12 Sep 2008 11:22:04 +0000 Subject: [PATCH 0036/2031] Reformatting. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10845 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/PyDocConverter.cpp | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index dbee97233..bb36aa382 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -14,8 +14,7 @@ #include //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag -PyDocConverter::PyDocConverter() -{ +PyDocConverter::PyDocConverter(){ debug = 1; } @@ -88,36 +87,32 @@ std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ } std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) + if(doxyEntity.typeOfEntity.compare("partofdescription") == 0) return justifyString(std::string(translateSubtree(doxyEntity)), 0); - if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ - return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} + if ((doxyEntity.typeOfEntity.compare("brief") == 0) + ||(doxyEntity.typeOfEntity.compare("details") == 0)) + return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; - if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 - || doxyEntity.typeOfEntity.compare("deprecated")== 0 - || doxyEntity.typeOfEntity.compare("brief")== 0) - return justifyString(doxyEntity.data, 0) + "\n * "; - - if(doxyEntity.typeOfEntity.compare("see") == 0) - return justifyString(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + if(doxyEntity.typeOfEntity.compare("plainstring") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("brief") == 0) + return justifyString(doxyEntity.data, 0) + "\n"; if(doxyEntity.typeOfEntity.compare("param") == 0) return formatParam(n, doxyEntity); - if(doxyEntity.typeOfEntity.compare("return")== 0) + if(doxyEntity.typeOfEntity.compare("return") == 0) return formatReturnDescription(n, doxyEntity); - if(doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 + if(doxyEntity.typeOfEntity.compare("author") == 0 + || doxyEntity.typeOfEntity.compare("param") == 0 + || doxyEntity.typeOfEntity.compare("since") == 0 + || doxyEntity.typeOfEntity.compare("version") == 0 || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0) - return justifyString(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - - if(doxyEntity.typeOfEntity.compare("sa")== 0) - return justifyString(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("sa") == 0) + return ""; return justifyString(doxyEntity.data); } From 2cd2dac7e6dd91f17b634f373a28cc009e067d85 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Nov 2008 21:48:20 +0000 Subject: [PATCH 0037/2031] type fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10895 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Doxygen.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 27fc013eb..54161eeb3 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -59,7 +59,7 @@ The behaviour of this functionality is wildly unpredictable if the interface fil

    To make use of the comment translation system, your documentation comments must be in properly formatted Doxygen. They can be present in your main interface file or any header file that it imports. It is advised that you are certain your comments compile properly with Doxygen before you try to translate them. -Doxygen itself is a deeper tool and can provide you better feedback for correct any syntax errors that may be present. +Doxygen itself is a deeper tool and can provide you better feedback for correcting any syntax errors that may be present. Please look at Doxygen's Documenting the code for proper specificatons for comment format.

    From 45518cd0d1c413da083d85c140c3bd640f139303 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Oct 2009 21:27:09 +0000 Subject: [PATCH 0038/2031] apply doxygen-svndiff.patch from #2763155 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11697 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 4 +- Source/CParse/parser.y | 192 ++++++++++++++++-- .../DoxygenTranslator/src/DoxygenEntity.cpp | 31 ++- Source/DoxygenTranslator/src/DoxygenEntity.h | 35 +++- .../DoxygenTranslator/src/DoxygenParser.cpp | 72 +++---- .../src/Examples/DoxygenTransWTokenizer.cpp | 16 +- .../src/JavaDocConverter.cpp | 77 +++++-- .../DoxygenTranslator/src/JavaDocConverter.h | 2 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 2 +- Source/DoxygenTranslator/src/Token.cpp | 1 + Source/DoxygenTranslator/src/Token.h | 5 +- Source/DoxygenTranslator/src/TokenList.cpp | 155 +++++++++----- Source/DoxygenTranslator/src/TokenList.h | 19 +- Source/Modules/java.cxx | 17 +- Source/Modules/python.cxx | 9 +- 15 files changed, 467 insertions(+), 170 deletions(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 12556dcf6..68d50cd2d 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -427,12 +427,12 @@ int yylook(void) { scanner_locator(cmt); } if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { - printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ yylval.str = NewString(loc); return DOXYGENPOSTSTRING; } if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); + /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ yylval.str = NewString(loc); return DOXYGENSTRING; } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 06b0685c6..d28516206 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -13,7 +13,7 @@ #define yylex yylex -char cvsroot_parser_y[] = "$Id: parser.y 10767 2008-08-16 07:31:05Z cherylfoil $"; +char cvsroot_parser_y[] = "$Id$"; #include "swig.h" #include "cparse.h" @@ -1575,6 +1575,7 @@ static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { %type doxygen_comment; %type c_style_comment; %type doxygen_post_comment; +%type doxygen_post_comment_item; %% /* ====================================================================== @@ -3213,9 +3214,17 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { doxygen_comment : DOXYGENSTRING { - while(Strchr($1,'/') == Char($1)) - Replace($1,"/","",DOH_REPLACE_FIRST); - if(isStructuralDoxygen($1)){ + /* while(Strchr($1,'/') == Char($1)) + Replace($1,"/","",DOH_REPLACE_FIRST); */ + DohReplace($1, "/**", "", 0); + DohReplace($1, "/*!", "", 0); + DohReplace($1, "///", "", 0); + DohReplace($1, "*/", "", 0); + + /* isStructuralDoxygen() is disabled, since no comment + appears in such case. Need to fix. (most commands are + not translatable to javadoc anyway) */ + if(0 && isStructuralDoxygen($1)){ $$ = new_node("doxycomm"); Setattr($$,"DoxygenComment",$1); } @@ -3231,13 +3240,26 @@ doxygen_comment : DOXYGENSTRING ; -doxygen_post_comment : DOXYGENPOSTSTRING +doxygen_post_comment_item : DOXYGENPOSTSTRING { - if(currentPostComment != 0){ - Append(currentPostComment, $1); - } - else currentPostComment = $1; - $$ = 0; + DohReplace($1, "///<", "", 0); + DohReplace($1, "/**<", "", 0); + DohReplace($1, "/*!<", "", 0); + DohReplace($1, "//!<", "", 0); + DohReplace($1, "*/", "", 0); + + $$ = $1; + } + ; + +doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item + { + Append($1, $2); + $$ = $1; + } + | doxygen_post_comment_item + { + $$ = $1; } ; @@ -4541,13 +4563,38 @@ storage_class : EXTERN { $$ = "extern"; } ------------------------------------------------------------------------------ */ parms : rawparms { - Parm *p; + Parm *p, *nextSibling; $$ = $1; p = $1; - while (p) { + while (p) { + String *postComment = NULL; + nextSibling = nextSibling(p); + if (nextSibling != NULL) { + postComment = Getattr(nextSibling, "postComment"); + } else { + /* the last functino parameter has two attributes - + post comment of the previous params and its own post + comment. + */ + postComment = Getattr(p, "lastParamPostComment"); + } + if (postComment != NULL) { + String *param = NewString("\n@param "); + if (currentComment != 0) { + Append(currentComment, param); + Append(currentComment, Getattr(p, "name")); + Append(currentComment, postComment); + } + else { + currentComment = param; + Append(currentComment, Getattr(p, "name")); + Append(currentComment, postComment); + } + } + Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); - p = nextSibling(p); - } + p = nextSibling; + } } ; @@ -4562,6 +4609,34 @@ ptail : COMMA parm ptail { set_nextSibling($2,$3); $$ = $2; } + | COMMA doxygen_post_comment parm ptail { + set_nextSibling($3,$4); + $$ = $3; + + /** because function parameters are not nodes, + it must be the current function node, which + gets doxy comment set. + */ + + Setattr($3, "postComment", $2); + /* + currentPostComment = $2; + if (previousParmName != 0) { + String *param = NewString("\n@param "); + if (currentComment != 0) { + Append(currentComment, param); + Append(currentComment, previousParmName ); + Append(currentComment, currentPostComment); + } + else { + currentComment = param; + Append(currentComment, Getattr($3, "name") ); + Append(currentComment, currentPostComment); + } + } + currentPostComment = 0; + */ + } | empty { $$ = 0; } ; @@ -4575,6 +4650,36 @@ parm : rawtype parameter_declarator { Setattr($$,"value",$2.defarg); } } + | rawtype parameter_declarator doxygen_post_comment { + /** handles the last function parameter, which is not followed by comma */ + /* + String *param = NewString("@param "); + String *name = NewString($2.id); + + if (currentComment != 0) { + Append(currentComment, param); + } + else { + currentComment = param; + } + + Append(currentComment, name); + Append(currentComment, $3); + + if (currentPostComment != 0) { + } + currentPostComment = 0; + */ + + SwigType_push($1,$2.type); + $$ = NewParm($1,$2.id); + Setattr($$, "lastParamPostComment", $3); + Setfile($$,cparse_file); + Setline($$,cparse_line); + if ($2.defarg) { + Setattr($$,"value",$2.defarg); + } + } | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args { $$ = NewParm(NewStringf("template %s %s", $5,$6), 0); @@ -5462,6 +5567,65 @@ edecl : ID { } SetFlag($$,"feature:immutable"); } + + | doxygen_comment ID EQUAL etype { + $$ = new_node("enumitem"); + Setattr($$,"name",$2); + Setattr($$,"enumvalue", $4.val); + if ($4.type == T_CHAR) { + SwigType *type = NewSwigType(T_CHAR); + Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); + Setattr($$,"type",type); + Delete(type); + } else { + SwigType *type = NewSwigType(T_INT); + Setattr($$,"value",$2); + Setattr($$,"type",type); + Delete(type); + } + SetFlag($$,"feature:immutable"); + } + + | doxygen_post_comment ID EQUAL etype { + currentPostComment = $1; + $$ = new_node("enumitem"); + Setattr($$,"name",$2); + Setattr($$,"enumvalue", $4.val); + if ($4.type == T_CHAR) { + SwigType *type = NewSwigType(T_CHAR); + Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); + Setattr($$,"type",type); + Delete(type); + } else { + SwigType *type = NewSwigType(T_INT); + Setattr($$,"value",$2); + Setattr($$,"type",type); + Delete(type); + } + SetFlag($$,"feature:immutable"); + } + + | doxygen_comment ID { + SwigType *type = NewSwigType(T_INT); + $$ = new_node("enumitem"); + Setattr($$,"name",$2); + Setattr($$,"type",type); + SetFlag($$,"feature:immutable"); + Delete(type); + } + | doxygen_post_comment ID { + SwigType *type = NewSwigType(T_INT); + currentPostComment = $1; + $$ = new_node("enumitem"); + Setattr($$,"name",$2); + Setattr($$,"type",type); + SetFlag($$,"feature:immutable"); + Delete(type); + } + | doxygen_post_comment { + currentPostComment = $1; + $$ = $1; + } | empty { $$ = 0; } ; diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index 52fb60d90..b2b156b5d 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -13,7 +13,7 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){ typeOfEntity = typeEnt; data = ""; - isLeaf = 1; + isLeaf = true; } /* Basic node for commands that have @@ -24,7 +24,7 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ typeOfEntity = typeEnt; data = param1; - isLeaf = 1; + isLeaf = true; } /* Nonterminal node @@ -33,23 +33,35 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list &entList ){ typeOfEntity = typeEnt; data = ""; - isLeaf = 0; + isLeaf = false; entityList = entList; } void DoxygenEntity::printEntity(int level){ int thisLevel = level; if (isLeaf) { - for (int i = 0; i < thisLevel; i++) {std::cout << "\t";} + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; + } + std::cout << "Node Command: " << typeOfEntity << " "; - if (data.compare("") != 0) std::cout << "Node Data: " << data; + + if (data.compare("") != 0) { + std::cout << "Node Data: " << data; + } std::cout << std::endl; + + } else { + + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; } - else{ - for (int i = 0; i < thisLevel; i++) {std::cout << "\t";} + std::cout << "Node Command : " << typeOfEntity << std::endl; + std::list::iterator p = entityList.begin(); thisLevel++; + while (p != entityList.end()){ (*p).printEntity(thisLevel); p++; @@ -57,7 +69,10 @@ void DoxygenEntity::printEntity(int level){ } } +// not used, completely wrong - currently std lib reports 'invalid operator <' bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ + + // return first.typeOfEntity < second.typeOfEntity; if(first.typeOfEntity.compare("brief") == 0) return true; if(second.typeOfEntity.compare("brief") == 0) @@ -68,7 +83,7 @@ bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& sec return false; if(first.typeOfEntity.compare("partofdescription") == 0) return true; - if(first.typeOfEntity.compare("partofdescription") == 0) + if(second.typeOfEntity.compare("partofdescription") == 0) return false; if(first.typeOfEntity.compare("plainstd::string") == 0) return true; diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 6a0b2e48c..4c1ab7ff9 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -13,18 +13,43 @@ #include #include + +typedef enum { + SIMPLECOMMAND, + IGNOREDSIMPLECOMMAND, + COMMANDWORD, + IGNOREDCOMMANDWORD, + COMMANDLINE, + IGNOREDCOMMANDLINE, + COMMANDPARAGRAPH, + IGNORECOMMANDPARAGRAPH, + COMMANDENDCOMMAND, + COMMANDWORDPARAGRAPH, + COMMANDWORDLINE, + COMMANDWORDOWORDWORD, + COMMANDOWORD, + COMMANDERRORTHROW, + COMMANDUNIQUE, + END_LINE, + PARAGRAPH_END, + PLAINSTRING, + COMMAND +} DoxyCommandEnum; + /* * Structure to represent a doxygen comment entry */ struct DoxygenEntity{ - DoxygenEntity(std::string typeEnt); - DoxygenEntity(std::string typeEnt, std::string param1); - DoxygenEntity(std::string typeEnt, std::list &entList ); - void printEntity(int level); std::string typeOfEntity; std::list entityList; std::string data; - int isLeaf; + bool isLeaf; + + DoxygenEntity(std::string typeEnt); + DoxygenEntity(std::string typeEnt, std::string param1); + DoxygenEntity(std::string typeEnt, std::list &entList ); + + void printEntity(int level); }; /* diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index cdc2d709f..78072852d 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -1,24 +1,6 @@ #include "DoxygenParser.h" #include "TokenList.h" -#define SIMPLECOMMAND 1 -#define IGNOREDSIMPLECOMMAND 2 -#define COMMANDWORD 3 -#define IGNOREDCOMMANDWORD 4 -#define COMMANDLINE 5 -#define IGNOREDCOMMANDLINE 6 -#define COMMANDPARAGRAPH 7 -#define IGNORECOMMANDPARAGRAPH 8 -#define COMMANDENDCOMMAND 9 -#define COMMANDWORDPARAGRAPH 10 -#define COMMANDWORDLINE 11 -#define COMMANDWORDOWORDWORD 12 -#define COMMANDOWORD 13 -#define COMMANDERRORTHROW 14 -#define COMMANDUNIQUE 15 -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 + DoxygenParser::DoxygenParser() { @@ -50,14 +32,14 @@ std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "a "private", "privatesection", "property", "protected", "protectedsection", "protocol", "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\","&", "~", "<", ">", "#", "%"}; std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem" }; /* All of the doxygen commands divided up by how they are parsed */ @@ -73,7 +55,7 @@ std::string commandParagraph[] = {"partofdescription", "return", "remarks", "sin std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -std::string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; +std::string commandWordParagraphs[] = {"param", "tparam", "throw", "throws", "retval", "exception"}; std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; std::string commandOWords[] = {"dir", "file", "cond"}; @@ -264,28 +246,33 @@ std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){ /* Returns the end of a Paragraph as an iterator- * Paragraph is defined in Doxygen to be a paragraph of text -* seperate by either a structural command or a blank line + * separated by either a structural command or a blank line */ std::list::iterator getEndOfParagraph(TokenList &tokList){ std::list::iterator endOfParagraph = tokList.iteratorCopy(); while(endOfParagraph != tokList.end()){ if ((* endOfParagraph).tokenType == END_LINE){ endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ + if (endOfParagraph != tokList.end() && (* endOfParagraph).tokenType == END_LINE) { endOfParagraph++; //cout << "ENCOUNTERED END OF PARA" << endl; return endOfParagraph; } + + } else if ((*endOfParagraph).tokenType == COMMAND) { + + if (isSectionIndicator((* endOfParagraph).tokenString)) { + return endOfParagraph; } - else if ((* endOfParagraph).tokenType == COMMAND){ - if(isSectionIndicator((* endOfParagraph).tokenString)) return endOfParagraph; else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { + + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { endOfParagraph++; + } else { + return tokList.end(); } - else return tokList.end(); } + return tokList.end(); } @@ -478,7 +465,7 @@ int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list < /* CommandWordParagraph * Format: @command {paragraph} * Commands such as param -* "param", "tparam", "throw", "retval", "exception" + * "param", "tparam", "throw", "throws", "retval", "exception" */ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ if (noisy) @@ -560,8 +547,10 @@ int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ #pragma unused(doxyList) - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + if (noisy) { + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } std::list::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 0; @@ -699,8 +688,6 @@ int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ std::string theCommand = StringToLower(commandString); if (theCommand.compare("plainstd::string") == 0){ @@ -790,23 +777,30 @@ std::list parse(std::list::iterator endParsingIndex, Token } std::list parseRoot(std::list::iterator endParsingIndex, TokenList &tokList){ + std::list aNewList; int currCommand; + while (tokList.current() != endParsingIndex){ + Token currToken = tokList.peek(); - if(noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if(noisy) { + cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + } + if(currToken.tokenType == END_LINE ){ tokList.next(); } else if(currToken.tokenType == COMMAND){ currCommand = findCommand(currToken.tokenString); if (currCommand < 0 ){ - if(noisy) + if(noisy) { cout << "Unidentified Command " << currToken.tokenString << endl; + } + tokList.next(); + addCommand(std::string("partofdescription"), tokList, aNewList); + } else { tokList.next(); - addCommand(std::string("partofdescription"), tokList, aNewList);} - //cout << "Command: " << currWord << " " << currCommand << endl; - else { tokList.next(); addCommand(currToken.tokenString, tokList, aNewList); } } diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp index 299f59216..dacb31f77 100644 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp @@ -569,7 +569,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ } else{ startIndex = savedIndex; - addCommand(string("plainstring"), startIndex, aNewList, doxygenString); + addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); } } @@ -728,7 +728,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ if(!restOfParagraph.empty()){ list aNewList; aNewList = parse(placement, restOfParagraph); - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -752,7 +752,7 @@ string getStringTilCommand(int &startInd, string doxygenString){ if(!restOfLine.empty()){ list aNewList; aNewList = parse(placement, restOfLine); - aNewList.push_front(DoxygenEntity("plainstring", name)); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -775,9 +775,9 @@ string getStringTilCommand(int &startInd, string doxygenString){ string headerfile = getNextWord(startInd, doxygenString); string headername = getNextWord(startInd, doxygenString); list aNewList; - aNewList.push_back(DoxygenEntity("plainstring", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -806,10 +806,10 @@ string getStringTilCommand(int &startInd, string doxygenString){ /* @command */ - if (theCommand.compare("plainstring") == 0){ + if (theCommand.compare("plainstd::string") == 0){ string nextPhrase = getStringTilCommand(startInd, doxygenString); if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); return 1; } int commandNumber = commandBelongs(theCommand); diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 0ba97fc60..33a62ff77 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -15,15 +15,16 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind lastPosition = i; if (isFirstLine){ i+=APPROX_LINE_LENGTH; + } else { + i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; } - else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i = unformattedLine.find(" ", i); if (i > 0 && i + 1 < (int)unformattedLine.length()){ if (!isFirstLine) for (int j = 0; j < indent; j++) { formattedLines.append("\t"); - } - else { + } else { isFirstLine = 0; } formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); @@ -32,7 +33,11 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind } } if (lastPosition < (int)unformattedLine.length()){ - if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} + if (!isFirstLine) { + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } + } formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); } @@ -46,7 +51,7 @@ std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ return doxygenEntity.data; } - if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ + if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ return doxygenEntity.data; } else if (doxygenEntity.typeOfEntity.compare("b") == 0){ @@ -85,10 +90,12 @@ std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string returnedString; - if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} - else { + if (doxygenEntity.isLeaf) { + return javaDocFormat(doxygenEntity) + " "; + } else { returnedString += javaDocFormat(doxygenEntity); std::list::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()){ returnedString+= translateSubtree(*p); p++; @@ -97,38 +104,64 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ return returnedString; } + std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(std::string(translateSubtree(doxyEntity)), 0); - if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ - return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";} - else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) - return formatCommand(doxyEntity.data, 0) + "\n * "; - else if(doxyEntity.typeOfEntity.compare("see") == 0){ - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); + if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) { + return formatCommand(std::string(translateSubtree(doxyEntity)), 0); } - else if(doxyEntity.typeOfEntity.compare("return")== 0 + + if ((doxyEntity.typeOfEntity.compare("brief") == 0) || + (doxyEntity.typeOfEntity.compare("details") == 0)) { + return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * "; + + } else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 || + doxyEntity.typeOfEntity.compare("deprecated")== 0 || + doxyEntity.typeOfEntity.compare("brief")== 0) { + return formatCommand(doxyEntity.data, 0) + "\n * "; + + } else if(doxyEntity.typeOfEntity.compare("see") == 0) { + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + + translateSubtree(doxyEntity)), 2); + + } else if(doxyEntity.typeOfEntity.compare("return")== 0 || doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("param")== 0 + || doxyEntity.typeOfEntity.compare("throw")== 0 + || doxyEntity.typeOfEntity.compare("throws")== 0 || doxyEntity.typeOfEntity.compare("since")== 0 || doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + + // this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing + if (doxyEntity.typeOfEntity.compare("throw")== 0) { + doxyEntity.typeOfEntity = "throws"; + } return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } - else if(doxyEntity.typeOfEntity.compare("sa")== 0){ + + } else if(doxyEntity.typeOfEntity.compare("sa")== 0) { return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); + + } else { + return formatCommand(javaDocFormat(doxyEntity), 0 ); } - else return formatCommand(javaDocFormat(doxyEntity), 0 ); + return ""; } -bool JavaDocConverter::getDocumentation(Node *n, String *&documentation){ - documentation = Getattr(n,"DoxygenComment"); - if(documentation == NULL) + +bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) { + + documentation = Getattr(node, "DoxygenComment"); + + if (documentation == NULL) { return false; + } std::list entityList = DoxygenParser().createTree(Char(documentation)); - entityList.sort(CompareDoxygenEntities()); + + // entityList.sort(CompareDoxygenEntities()); sorting currently not used, + // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp if(debug){ std::cout << "---RESORTED LIST---" << std::endl; diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index e2a25d4ff..8651bb1cf 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -18,7 +18,7 @@ class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter() : debug( true ){} + JavaDocConverter() : debug( false ){} virtual bool getDocumentation(Node *node, String *&documentation); protected: diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index bb36aa382..6418ee73c 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -94,7 +94,7 @@ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ ||(doxyEntity.typeOfEntity.compare("details") == 0)) return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; - if(doxyEntity.typeOfEntity.compare("plainstring") == 0 + if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0 || doxyEntity.typeOfEntity.compare("deprecated") == 0 || doxyEntity.typeOfEntity.compare("brief") == 0) return justifyString(doxyEntity.data, 0) + "\n"; diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp index 198b3e442..2ac03afe5 100644 --- a/Source/DoxygenTranslator/src/Token.cpp +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -1,4 +1,5 @@ #include "Token.h" +#include "DoxygenEntity.h" using namespace std; diff --git a/Source/DoxygenTranslator/src/Token.h b/Source/DoxygenTranslator/src/Token.h index e98686c14..cf28c90b7 100644 --- a/Source/DoxygenTranslator/src/Token.h +++ b/Source/DoxygenTranslator/src/Token.h @@ -2,10 +2,6 @@ #define TOKEN_H_ #include -#define END_LINE 101 -#define PARAGRAPH_END 102 -#define PLAINSTRING 103 -#define COMMAND 104 using namespace std; class Token @@ -13,6 +9,7 @@ class Token public: Token(int tType, string tString); ~Token(); + int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ string tokenString; /* the data , such as param for @param*/ string toString(); diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index a05d2ceef..1a9ff0a7a 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -4,99 +4,162 @@ #include #include #include "Token.h" +#include "DoxygenEntity.h" #define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list -#define END_LINE 101 -#define PARAGRAPH_END 102 //not used at the moment -#define PLAINSTRING 103 -#define COMMAND 104 + using namespace std; - -list tokenList; -list::iterator tokenListIterator; int noisy2 = 0; /* The tokenizer*/ +TokenList::TokenList(const std::string &doxygenStringConst){ + size_t commentPos; + string doxygenString = doxygenStringConst; + + /* Comment start tokens are replaced in parser.y, see doxygen_comment and + doxygen_post_comment_item + do { + commentPos = doxygenString.find("///<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/**<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/*!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("//!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + break; + } while (true); */ + + size_t currentIndex = 0; + size_t nextIndex = 0; -TokenList::TokenList(string doxygenString){ - int currentIndex = 0; - //Regex whitespace("[ \t]+"); - //Regex newLine("[\n]"); - //Regex command("[@|\\]{1}[^ \t \n]+"); //the cheap solution - //Regex doxygenFluff("[/*!]+"); - int nextIndex = 0; - int isFluff = 0; string currentWord; + while (currentIndex < doxygenString.length()){ + if(doxygenString[currentIndex] == '\n'){ - tokenList.push_back(Token(END_LINE, currentWord)); + m_tokenList.push_back(Token(END_LINE, currentWord)); currentIndex++; } + + // skip WS, except \n while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex]== '\t')) currentIndex ++; - if (currentIndex == doxygenString.length()) {} //do nothing since end of string was reached - else {nextIndex = currentIndex; + + if (currentIndex < doxygenString.length()) { + + nextIndex = currentIndex; + + // skip non WS while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' - && doxygenString[nextIndex]!= '\t' && doxygenString[nextIndex]!= '\n')) nextIndex++; + && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n')) + nextIndex++; + + // now we have a token currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); - if(noisy2) cout << "Current Word: " << currentWord << endl; + + if(noisy2) + cout << "Current Word: " << currentWord << endl; + if (currentWord[0] == '@' || currentWord[0] == '\\'){ + // it is doxygen command currentWord = currentWord.substr(1, currentWord.length()-1); - tokenList.push_back(Token(COMMAND, currentWord)); - } - else if (currentWord[0] == '\n'){ - //if ((tokenList.back()).tokenType == END_LINE){} - tokenList.push_back(Token(END_LINE, currentWord)); + m_tokenList.push_back(Token(COMMAND, currentWord)); + + } else if (currentWord[0] == '\n'){ + + m_tokenList.push_back(Token(END_LINE, currentWord)); } else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ - if (currentWord.length() == 1) {isFluff = 1;} - else { isFluff = 1; - for(int i = 1; i < currentWord.length(); i++){ - if (currentWord[0] != '*' && currentWord[0] != '/' && currentWord[0] != '!') isFluff = 0; - } + bool isPlainString = false; + + if (currentWord.length() > 1) { + + for(size_t i = 1; i < currentWord.length(); i++){ + if (currentWord[i] != '*' && currentWord[i] != '/' && + currentWord[i] != '!') { + isPlainString = true; + break; + } } - if(!isFluff) tokenList.push_back(Token(PLAINSTRING, currentWord)); } - else if (!currentWord.empty())tokenList.push_back(Token(PLAINSTRING, currentWord)); + if(isPlainString) + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + + } else if (!currentWord.empty()) { + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + } currentIndex = nextIndex; } } - tokenListIterator = tokenList.begin(); + + m_tokenListIter = m_tokenList.begin(); +} + + +TokenList:: ~TokenList(){ } Token TokenList::peek(){ - if(tokenListIterator!= tokenList.end()){ - Token returnedToken = (*tokenListIterator); + if(m_tokenListIter!= m_tokenList.end()){ + Token returnedToken = (*m_tokenListIter); return returnedToken; } else return Token(0, ""); } + Token TokenList::next(){ - if(tokenListIterator != tokenList.end()){ - Token returnedToken = (*tokenListIterator); - tokenListIterator++; + if(m_tokenListIter != m_tokenList.end()){ + Token returnedToken = (*m_tokenListIter); + m_tokenListIter++; return (returnedToken); } else return Token(0, ""); } + list::iterator TokenList::end(){ return tokenList.end(); } + list::iterator TokenList::current(){ - return tokenListIterator; + return m_tokenListIter; } + + +list::iterator TokenList::iteratorCopy(){ + return m_tokenListIter; +} + + +void TokenList::setIterator(list::iterator newPosition){ + m_tokenListIter = newPosition; +} + + void TokenList::printList(){ - list::iterator p = tokenList.begin(); + list::iterator p = m_tokenList.begin(); int i = 1; int b = 0; - while (p != tokenList.end()){ + while (p != m_tokenList.end()){ cout << (*p).toString() << " "; b = i%TOKENSPERLINE; if (b == 0) cout << endl; @@ -104,13 +167,3 @@ void TokenList::printList(){ } } -list::iterator TokenList::iteratorCopy(){ - list::iterator p = tokenListIterator; - return p; -} -void TokenList::setIterator(list::iterator newPosition){ - tokenListIterator = newPosition; -} -TokenList:: ~TokenList(){ - tokenList.clear(); -} diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index cc61f56e4..0f5710e0f 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -5,23 +5,30 @@ #include #include #include "Token.h" -using namespace std; /* a small class used to represent the sequence of tokens * that can be derived from a formatted doxygen string */ class TokenList{ +private: + std::list m_tokenList; + std::list::iterator m_tokenListIter; + public: - TokenList(string doxygenString); /* constructor takes a blob of Doxygen comment */ + TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */ ~TokenList(); + Token peek(); /* returns next token without advancing */ Token next(); /* returns next token and advances */ - list::iterator end(); /* returns an end iterator */ - list::iterator current(); /* returns the current iterator */ - void printList(); /* prints out the sequence of tokens */ - list::iterator iteratorCopy(); /* returns a copy of the current iterator */ + + std::list::iterator end(); /* returns an end iterator */ + std::list::iterator current(); /* returns the current iterator */ + + std::list::iterator iteratorCopy(); /* returns a copy of the current iterator */ void setIterator(list::iterator newPosition); /*moves up the iterator*/ + + void printList(); /* prints out the sequence of tokens */ }; #endif /*TOKENLIST_H_*/ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 42ba5b396..532dfd305 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1304,6 +1304,15 @@ public: // Note that this is used in enumValue() amongst other places Setattr(n, "value", tmpValue); + { + EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); + + if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { + // Wrap (non-anonymous) C/C++ enum with a proper Java enum + // Emit the enum item. + if (!Getattr(n, "_last")) // Only the first enum item has this attribute set + Printf(enum_code, ",\n"); + //translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ String *doxygen_comments; @@ -1314,14 +1323,7 @@ public: Delete(doxygen_comments); } } - { - EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); - if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { - // Wrap (non-anonymous) C/C++ enum with a proper Java enum - // Emit the enum item. - if (!Getattr(n, "_last")) // Only the first enum item has this attribute set - Printf(enum_code, ",\n"); Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { String *value = enumValue(n); @@ -1841,7 +1843,6 @@ public: emitBanner(f_proxy); if (Len(package) > 0){ - Printf(f_proxy, "LETS TEST THIS NAO THX \n\n\n"); Printf(f_proxy, "package %s;\n", package); } Clear(proxy_class_def); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8a3160ef3..bfbada1da 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -7,7 +7,7 @@ * Python language module for SWIG. * ----------------------------------------------------------------------------- */ -char cvsroot_python_cxx[] = "$Id: python.cxx 10453 2008-05-15 21:18:44Z wsfulton $"; +char cvsroot_python_cxx[] = "$Id$"; #include "swigmod.h" #define ctab2 " " @@ -3124,6 +3124,13 @@ public: 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); + if (doxygen) { + String *doxygen_comments; + if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { + Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); + Delete(doxygen_comments); + } + } } } else { Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); From ad9eb0e0bb066100fc1c4ca84982c3c9dd96347d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Oct 2009 23:22:52 +0000 Subject: [PATCH 0039/2031] fix compile error introduced in last patch git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11698 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/TokenList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 1a9ff0a7a..9efd7e9ef 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -136,7 +136,7 @@ Token TokenList::next(){ list::iterator TokenList::end(){ - return tokenList.end(); + return m_tokenList.end(); } From 19d90026ef5c0c7f595b08495f8105063bced1ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Oct 2009 23:26:01 +0000 Subject: [PATCH 0040/2031] formatting fixes after running make beautify plus a few manual formatting fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11699 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenEntity.cpp | 204 ++- Source/DoxygenTranslator/src/DoxygenEntity.h | 12 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 862 +++++----- Source/DoxygenTranslator/src/DoxygenParser.h | 7 +- .../src/DoxygenTranslator.cpp | 24 +- .../DoxygenTranslator/src/DoxygenTranslator.h | 15 +- .../src/Examples/DoxygenTransWTokenizer.cpp | 1483 +++++++++-------- .../src/Examples/DoxygenTransWTokenizer.h | 9 +- .../src/Examples/translator.h | 252 +-- .../src/JavaDocConverter.cpp | 147 +- .../DoxygenTranslator/src/JavaDocConverter.h | 18 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 156 +- Source/DoxygenTranslator/src/PyDocConverter.h | 35 +- Source/DoxygenTranslator/src/Token.cpp | 39 +- Source/DoxygenTranslator/src/Token.h | 15 +- Source/DoxygenTranslator/src/TokenList.cpp | 230 ++- Source/DoxygenTranslator/src/TokenList.h | 26 +- 17 files changed, 1805 insertions(+), 1729 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index b2b156b5d..f770dc514 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -10,10 +10,10 @@ #include "DoxygenEntity.h" #include -DoxygenEntity::DoxygenEntity(std::string typeEnt){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = true; +DoxygenEntity::DoxygenEntity(std::string typeEnt) { + typeOfEntity = typeEnt; + data = ""; + isLeaf = true; } /* Basic node for commands that have @@ -21,173 +21,171 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){ * example: \b word * OR holding a std::string */ -DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ - typeOfEntity = typeEnt; - data = param1; - isLeaf = true; +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) { + typeOfEntity = typeEnt; + data = param1; + isLeaf = true; } /* Nonterminal node * contains */ -DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list &entList ){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = false; - entityList = entList; +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) { + typeOfEntity = typeEnt; + data = ""; + isLeaf = false; + entityList = entList; } -void DoxygenEntity::printEntity(int level){ - int thisLevel = level; - if (isLeaf) { - for (int i = 0; i < thisLevel; i++) { - std::cout << "\t"; - } - - std::cout << "Node Command: " << typeOfEntity << " "; - - if (data.compare("") != 0) { - std::cout << "Node Data: " << data; - } - std::cout << std::endl; +void DoxygenEntity::printEntity(int level) { + int thisLevel = level; + if (isLeaf) { + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; + } - } else { + std::cout << "Node Command: " << typeOfEntity << " "; - for (int i = 0; i < thisLevel; i++) { - std::cout << "\t"; - } + if (data.compare("") != 0) { + std::cout << "Node Data: " << data; + } + std::cout << std::endl; - std::cout << "Node Command : " << typeOfEntity << std::endl; + } else { - std::list::iterator p = entityList.begin(); - thisLevel++; + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; + } - while (p != entityList.end()){ - (*p).printEntity(thisLevel); - p++; - } - } + std::cout << "Node Command : " << typeOfEntity << std::endl; + + std::list < DoxygenEntity >::iterator p = entityList.begin(); + thisLevel++; + + while (p != entityList.end()) { + (*p).printEntity(thisLevel); + p++; + } + } } // not used, completely wrong - currently std lib reports 'invalid operator <' -bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ +bool CompareDoxygenEntities::operator() (DoxygenEntity & first, DoxygenEntity & second) { - // return first.typeOfEntity < second.typeOfEntity; - if(first.typeOfEntity.compare("brief") == 0) + // return first.typeOfEntity < second.typeOfEntity; + if (first.typeOfEntity.compare("brief") == 0) return true; - if(second.typeOfEntity.compare("brief") == 0) + if (second.typeOfEntity.compare("brief") == 0) return false; - if(first.typeOfEntity.compare("details") == 0) + if (first.typeOfEntity.compare("details") == 0) return true; - if(second.typeOfEntity.compare("details") == 0) + if (second.typeOfEntity.compare("details") == 0) return false; - if(first.typeOfEntity.compare("partofdescription") == 0) + if (first.typeOfEntity.compare("partofdescription") == 0) return true; - if(second.typeOfEntity.compare("partofdescription") == 0) + if (second.typeOfEntity.compare("partofdescription") == 0) return false; - if(first.typeOfEntity.compare("plainstd::string") == 0) + if (first.typeOfEntity.compare("plainstd::string") == 0) return true; - if(second.typeOfEntity.compare("plainstd::string") == 0) + if (second.typeOfEntity.compare("plainstd::string") == 0) return false; - if(first.typeOfEntity.compare("param") == 0){ - if(second.typeOfEntity.compare("param")== 0) + if (first.typeOfEntity.compare("param") == 0) { + if (second.typeOfEntity.compare("param") == 0) return true; - if(second.typeOfEntity.compare("return")== 0) + if (second.typeOfEntity.compare("return") == 0) return true; - if(second.typeOfEntity.compare("exception")== 0) + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("author")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("since") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("return")== 0){ - if(second.typeOfEntity.compare("return")== 0) + if (first.typeOfEntity.compare("return") == 0) { + if (second.typeOfEntity.compare("return") == 0) return true; - if(second.typeOfEntity.compare("exception")== 0) + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("author")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("since") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0 - )return true; - return false; - } - if(first.typeOfEntity.compare("exception")== 0){ - if(second.typeOfEntity.compare("exception")== 0) - return true; - if(second.typeOfEntity.compare("author")== 0) - return true; - if(second.typeOfEntity.compare("version")== 0) - return true; - if(second.typeOfEntity.compare("see")== 0) - return true; - if(second.typeOfEntity.compare("since")== 0) - return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("author")== 0){ - if(second.typeOfEntity.compare("author")== 0) + if (first.typeOfEntity.compare("exception") == 0) { + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("since") == 0) + return true; + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("version")== 0){ - if(second.typeOfEntity.compare("version")== 0) + if (first.typeOfEntity.compare("author") == 0) { + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("since") == 0) + return true; + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("see")== 0 || first.typeOfEntity.compare("sa")== 0){ - if(second.typeOfEntity.compare("see")== 0) + if (first.typeOfEntity.compare("version") == 0) { + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("sa")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("since") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("since")== 0){ - if(second.typeOfEntity.compare("since")== 0) + if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) { + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("sa") == 0) + return true; + if (second.typeOfEntity.compare("since") == 0) + return true; + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("deprecated")== 0){ - if(second.typeOfEntity.compare("deprecated")== 0) + if (first.typeOfEntity.compare("since") == 0) { + if (second.typeOfEntity.compare("since") == 0) + return true; + if (second.typeOfEntity.compare("deprecated") == 0) + return true; + return false; + } + if (first.typeOfEntity.compare("deprecated") == 0) { + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } return true; } - - diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 4c1ab7ff9..ca42393db 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -15,7 +15,7 @@ typedef enum { - SIMPLECOMMAND, + SIMPLECOMMAND, IGNOREDSIMPLECOMMAND, COMMANDWORD, IGNOREDCOMMANDWORD, @@ -39,15 +39,15 @@ typedef enum { /* * Structure to represent a doxygen comment entry */ -struct DoxygenEntity{ +struct DoxygenEntity { std::string typeOfEntity; - std::list entityList; + std::list < DoxygenEntity > entityList; std::string data; bool isLeaf; DoxygenEntity(std::string typeEnt); DoxygenEntity(std::string typeEnt, std::string param1); - DoxygenEntity(std::string typeEnt, std::list &entList ); + DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList); void printEntity(int level); }; @@ -58,7 +58,7 @@ struct DoxygenEntity{ * such as brief descriptions are TAGGED as such */ struct CompareDoxygenEntities { - bool operator()(DoxygenEntity& first, DoxygenEntity& second); + bool operator() (DoxygenEntity & first, DoxygenEntity & second); }; -#endif /*TOKENLIST_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 78072852d..f4bce5445 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -2,88 +2,110 @@ #include "TokenList.h" -DoxygenParser::DoxygenParser() -{ +DoxygenParser::DoxygenParser() { } -DoxygenParser::~DoxygenParser() -{ +DoxygenParser::~DoxygenParser() { } ////////////////////////////////////////// -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(std::string currCommand, TokenList &tokList, std::list &aNewList); -std::list parse(std::list::iterator endParsingIndex, TokenList &tokList); +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(std::string currCommand, TokenList & tokList, std::list < DoxygenEntity > &aNewList); +std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList); ////////////////////////////////////////// -std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "\\","&", "~", "<", ">", "#", "%"}; +std::string commandArray[] = { + "a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; -std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", - "version", "warning", "xrefitem" }; +std::string sectionIndicators[] = { + "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; /* All of the doxygen commands divided up by how they are parsed */ -std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; -std::string ignoredSimpleCommands[] = {"nothing at the moment"}; -std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -std::string ignoreCommandLines[] = {"nothing at the moment"}; -std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; -std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; -std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -std::string commandWordParagraphs[] = {"param", "tparam", "throw", "throws", "retval", "exception"}; -std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -std::string commandOWords[] = {"dir", "file", "cond"}; -std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", - "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; -std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", -"subpage", "dotfile", "image", "addtogroup", "li"}; +std::string simpleCommands[] = { + "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; + +std::string ignoredSimpleCommands[] = { + "nothing at the moment"}; + +std::string commandWords[] = { + "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; + +std::string ignoredCommandWords[] = { + "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; + +std::string commandLines[] = { + "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; + +std::string ignoreCommandLines[] = { + "nothing at the moment"}; + +std::string commandParagraph[] = { + "partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; + +std::string ignoreCommandParagraphs[] = { + "nothing at the moment"}; + +std::string commandEndCommands[] = { + "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; + +std::string commandWordParagraphs[] = { + "param", "tparam", "throw", "throws", "retval", "exception"}; + +std::string commandWordLines[] = { + "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; + +std::string commandWordOWordOWords[] = { + "category", "class", "protocol", "interface", "struct", "union"}; + +std::string commandOWords[] = { + "dir", "file", "cond"}; + +std::string commandErrorThrowings[] = { + "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", + "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; +std::string commandUniques[] = { + "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; /* Changes a std::string to all lower case */ -std::string StringToLower(std::string stringToConvert){ - for(unsigned int i=0;i &rootList){ - std::list::iterator p = rootList.begin(); - while (p != rootList.end()){ +void printTree(std::list < DoxygenEntity > &rootList) { + std::list < DoxygenEntity >::iterator p = rootList.begin(); + while (p != rootList.end()) { (*p).printEntity(0); p++; } @@ -116,190 +138,192 @@ void printTree( std::list &rootList){ /* Determines how a command should be handled (what group it belongs to * for parsing rules */ -int commandBelongs(std::string theCommand){ - std::string smallString = StringToLower(theCommand); - //cout << " Looking for command " << theCommand << endl; +int commandBelongs(std::string theCommand) { + std::string smallString = StringToLower(theCommand); + //cout << " Looking for command " << theCommand << endl; unsigned i = 0; - for (i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0) + for (i = 0; i < sizeof(simpleCommands) / sizeof(*simpleCommands); i++) { + if (smallString.compare(simpleCommands[i]) == 0) return SIMPLECOMMAND; } - for (i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ - if(smallString.compare(ignoredSimpleCommands[i]) == 0) + for (i = 0; i < sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); i++) { + if (smallString.compare(ignoredSimpleCommands[i]) == 0) return IGNOREDSIMPLECOMMAND; - } - for (i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ - if(smallString.compare( commandWords[i]) == 0) + } + for (i = 0; i < sizeof(commandWords) / sizeof(*commandWords); i++) { + if (smallString.compare(commandWords[i]) == 0) return COMMANDWORD; - } - for (i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ - if(smallString.compare( ignoredCommandWords[i]) == 0) + } + for (i = 0; i < sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); i++) { + if (smallString.compare(ignoredCommandWords[i]) == 0) return IGNOREDCOMMANDWORD; - } - for (i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ - if(smallString.compare( commandLines[i]) == 0) + } + for (i = 0; i < sizeof(commandLines) / sizeof(*commandLines); i++) { + if (smallString.compare(commandLines[i]) == 0) return COMMANDLINE; - } - for (i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ - if(smallString.compare( ignoreCommandLines[i]) == 0) + } + for (i = 0; i < sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); i++) { + if (smallString.compare(ignoreCommandLines[i]) == 0) return IGNOREDCOMMANDLINE; - } - for (i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ - if(smallString.compare( commandParagraph[i]) == 0) + } + for (i = 0; i < sizeof(commandParagraph) / sizeof(*commandParagraph); i++) { + if (smallString.compare(commandParagraph[i]) == 0) return COMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ - if(smallString.compare( ignoreCommandParagraphs[i]) == 0) + } + for (i = 0; i < sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); i++) { + if (smallString.compare(ignoreCommandParagraphs[i]) == 0) return IGNORECOMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ - if(smallString.compare( commandEndCommands[i]) == 0) + } + for (i = 0; i < sizeof(commandEndCommands) / sizeof(*commandEndCommands); i++) { + if (smallString.compare(commandEndCommands[i]) == 0) return COMMANDENDCOMMAND; - } - for (i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ - if(smallString.compare( commandWordParagraphs[i]) == 0) + } + for (i = 0; i < sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); i++) { + if (smallString.compare(commandWordParagraphs[i]) == 0) return COMMANDWORDPARAGRAPH; - } - for (i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ - if(smallString.compare( commandWordLines[i]) == 0) + } + for (i = 0; i < sizeof(commandWordLines) / sizeof(*commandWordLines); i++) { + if (smallString.compare(commandWordLines[i]) == 0) return COMMANDWORDLINE; - } - for (i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ - if(smallString.compare( commandWordOWordOWords[i]) == 0) + } + for (i = 0; i < sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); i++) { + if (smallString.compare(commandWordOWordOWords[i]) == 0) return COMMANDWORDOWORDWORD; - } - for (i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ - if(smallString.compare( commandOWords[i]) == 0) + } + for (i = 0; i < sizeof(commandOWords) / sizeof(*commandOWords); i++) { + if (smallString.compare(commandOWords[i]) == 0) return COMMANDOWORD; - } - for (i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ - if(smallString.compare( commandErrorThrowings[i]) == 0) + } + for (i = 0; i < sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); i++) { + if (smallString.compare(commandErrorThrowings[i]) == 0) return COMMANDERRORTHROW; - } - for (i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ - if(smallString.compare( commandUniques[i]) == 0) + } + for (i = 0; i < sizeof(commandUniques) / sizeof(*commandUniques); i++) { + if (smallString.compare(commandUniques[i]) == 0) return COMMANDUNIQUE; } - return 0; + return 0; } /* Returns the next word ON THE CURRENT LINE ONLY * if a new line is encountered, returns a blank std::string. * Updates the index it is given if success. */ -std::string getNextWord(TokenList &tokList){ - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING ){ - nextToken = tokList.next(); - return nextToken.tokenString; - } +std::string getNextWord(TokenList & tokList) { + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING) { + nextToken = tokList.next(); + return nextToken.tokenString; + } return ""; } /* Returns the location of the end of the line as * an iterator. */ -std::list::iterator getOneLine(TokenList &tokList){ - std::list::iterator endOfLine = tokList.iteratorCopy(); - while(endOfLine!= tokList.end()){ - if ((* endOfLine).tokenType == END_LINE){ - //cout << "REACHED END" << endl; - //endOfLine++; - return endOfLine; - } - //cout << (* endOfLine).toString(); - endOfLine++; - } - - return tokList.end(); +std::list < Token >::iterator getOneLine(TokenList & tokList) { + std::list < Token >::iterator endOfLine = tokList.iteratorCopy(); + while (endOfLine != tokList.end()) { + if ((*endOfLine).tokenType == END_LINE) { + //cout << "REACHED END" << endl; + //endOfLine++; + return endOfLine; + } + //cout << (* endOfLine).toString(); + endOfLine++; } + return tokList.end(); +} + /* Returns a properly formatted std::string * up til ANY command or end of line is encountered. */ -std::string getStringTilCommand(TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING){ - Token currentToken = tokList.next(); - if(currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - } - return description; +std::string getStringTilCommand(TokenList & tokList) { + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.peek().tokenType == PLAINSTRING) { + Token currentToken = tokList.next(); + if (currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } } + return description; +} /* Returns a properly formatted std::string * up til the command specified is encountered */ //TODO check that this behaves properly for formulas -std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenString.compare(theCommand) != 0 ){ - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; - } - return description; +std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList) { + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.peek().tokenString.compare(theCommand) != 0) { + Token currentToken = tokList.next(); + description = description + currentToken.tokenString + " "; } + return description; +} /* Returns the end of a Paragraph as an iterator- * Paragraph is defined in Doxygen to be a paragraph of text * separated by either a structural command or a blank line */ -std::list::iterator getEndOfParagraph(TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if (endOfParagraph != tokList.end() && (* endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - //cout << "ENCOUNTERED END OF PARA" << endl; - return endOfParagraph; - } +std::list < Token >::iterator getEndOfParagraph(TokenList & tokList) { + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if (endOfParagraph != tokList.end() && (*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + //cout << "ENCOUNTERED END OF PARA" << endl; + return endOfParagraph; + } - } else if ((*endOfParagraph).tokenType == COMMAND) { + } else if ((*endOfParagraph).tokenType == COMMAND) { - if (isSectionIndicator((* endOfParagraph).tokenString)) { - return endOfParagraph; - } - else endOfParagraph++; + if (isSectionIndicator((*endOfParagraph).tokenString)) { + return endOfParagraph; + } else + endOfParagraph++; - } else if ((*endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } else { - return tokList.end(); - } + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else { + return tokList.end(); } + } - return tokList.end(); - } + return tokList.end(); +} /* Returns the end of a section, defined as the first blank line OR first encounter of the same * command. Example of this behaviour is \arg * if no end is encountered, returns the last token of the std::list. */ -std::list::iterator getEndOfSection(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } +std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList & tokList) { + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == COMMAND) { + if (theCommand.compare((*endOfParagraph).tokenString) == 0) + return endOfParagraph; + else + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + return endOfParagraph; + } } - return tokList.end(); - } + } + return tokList.end(); +} /* This method is for returning the end of a specific form of doxygen command * that begins with a \command and ends in \endcommand @@ -307,12 +331,12 @@ std::list::iterator getEndOfSection(std::string theCommand, TokenList &to * progressTilEndCommand("endcode", tokenList); * If the end is never encountered, it returns the end of the std::list. */ -std::list::iterator getEndCommand(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand!= tokList.end()){ - if ((*endOfCommand).tokenType == COMMAND){ - if (theCommand.compare((* endOfCommand).tokenString) == 0){ - return endOfCommand; +std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & tokList) { + std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand != tokList.end()) { + if ((*endOfCommand).tokenType == COMMAND) { + if (theCommand.compare((*endOfCommand).tokenString) == 0) { + return endOfCommand; } endOfCommand++; } @@ -324,9 +348,9 @@ std::list::iterator getEndCommand(std::string theCommand, TokenList &tokL /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ //TODO getTilAnyCommand -std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){ +std::list < Token >::iterator getTilAnyCommand(std::string theCommand, TokenList & tokList) { #pragma unused(theCommand,tokList) - std::list::iterator anIterator; + std::list < Token >::iterator anIterator; return anIterator; } @@ -338,54 +362,56 @@ std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &t * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ -int addSimpleCommand(std::string theCommand, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; +int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); return 1; } - + /* NOT INCLUDED Simple Commands * Format: @command * Plain commands, such as newline etc, they contain no other data */ -int ignoreSimpleCommand(std::string theCommand, std::list &doxyList){ +int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) cout << "Not Adding " << theCommand << endl; + if (noisy) + cout << "Not Adding " << theCommand << endl; return 1; } - + /* CommandWord * Format: @command * Commands with a single WORD after then such as @b * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" */ -int addCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; +int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (!name.empty()){ + if (!name.empty()) { doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; - } - else - cout << "No word followed " << theCommand << " command. Not added" << endl; + } else + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - + /* NOT INCLUDED CommandWord * Format: @command * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ -int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; std::string name = getNextWord(tokList); if (!name.empty()) return 1; - else - cout << "WARNING: No word followed " << theCommand << " command." << endl; + else + cout << "WARNING: No word followed " << theCommand << " command." << endl; return 0; } @@ -394,12 +420,12 @@ int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -408,11 +434,11 @@ int addCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < Token >::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 1; } @@ -423,30 +449,30 @@ int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } - + /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var * */ -int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } - + /* Command EndCommand * Format: @command and ends at @endcommand * Commands that take in a block of text such as @code @@ -454,30 +480,30 @@ int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ -int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Not Adding " << theCommand << endl; - std::string description = getStringTilEndCommand( "end" + theCommand, tokList); + std::string description = getStringTilEndCommand("end" + theCommand, tokList); doxyList.push_back(DoxygenEntity(theCommand, description)); return 1; } - + /* CommandWordParagraph * Format: @command {paragraph} * Commands such as param * "param", "tparam", "throw", "throws", "retval", "exception" */ -int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; - } - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); + } + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -488,16 +514,17 @@ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::lis * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ -int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; +int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; - } - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList; - aNewList = parse(endOfLine, tokList); + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -509,21 +536,21 @@ int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } std::string headerfile = getNextWord(tokList); std::string headername = getNextWord(tokList); - std::list aNewList; + std::list < DoxygenEntity > aNewList; aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -534,241 +561,240 @@ int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::li * Commands such as dir * "dir", "file", "cond" */ -int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; + return 1; } /* Commands that should not be encountered (such as PHP only) * goes til the end of line then returns */ -int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) { - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } - std::list::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 0; - } + if (noisy) { + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 0; +} /* Adds the unique commands- different process for each unique command */ -int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ - std::list aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - std::list::iterator endOfSection = getEndOfSection(theCommand, tokList); - std::list aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); +int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + std::list < DoxygenEntity > aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { + std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \xrefitem "(heading)" "(std::list title)" {text} - else if (theCommand.compare("xrefitem") == 0){ + else if (theCommand.compare("xrefitem") == 0) { //TODO Implement xrefitem - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0){ + else if (theCommand.compare("ingroup") == 0) { std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - std::list aNewList2; + else if (theCommand.compare("par") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + std::list < DoxygenEntity > aNewList2; aNewList2 = parse(endOfLine, tokList); aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + return 1; } // \headerfile [] - else if (theCommand.compare("headerfile") == 0){ - std::list aNewList; + else if (theCommand.compare("headerfile") == 0) { + std::list < DoxygenEntity > aNewList; std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()){ - std::list aNewList; - aNewList = parse(endOfLine, tokList); + else if (theCommand.compare("overload") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - else + } else doxyList.push_back(DoxygenEntity(theCommand)); return 1; } // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + else if (theCommand.compare("weakgroup") == 0) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); + aNewList = parse(endOfLine, tokList); } aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \ref ["(text)"] - else if (theCommand.compare("ref") == 0){ + else if (theCommand.compare("ref") == 0) { //TODO Implement ref - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0){ + else if (theCommand.compare("subpage") == 0) { //TODO implement subpage - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0){ + else if (theCommand.compare("dotfile") == 0) { //TODO implement dotfile - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \image ["caption"] [=] - else if (theCommand.compare("image") == 0){ - //todo implement image - } + else if (theCommand.compare("image") == 0) { + //todo implement image + } // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0){ - if (noisy) + else if (theCommand.compare("addtogroup") == 0) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); + aNewList = parse(endOfLine, tokList); } aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } return 0; } - + /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in * the file Skeleton */ -int addCommand(std::string commandString, TokenList &tokList,std::list &doxyList){ - std::string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstd::string") == 0){ - std::string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND){ - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW){ - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE){ +int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + std::string theCommand = StringToLower(commandString); + if (theCommand.compare("plainstd::string") == 0) { + std::string nextPhrase = getStringTilCommand(tokList); + if (noisy) + cout << "Parsing plain std::string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND) { + return addSimpleCommand(theCommand, doxyList); + } + if (commandNumber == IGNOREDSIMPLECOMMAND) { + return ignoreSimpleCommand(theCommand, doxyList); + } + if (commandNumber == COMMANDWORD) { + return addCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDWORD) { + return ignoreCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDLINE) { + return addCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDLINE) { + return ignoreCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDPARAGRAPH) { + return addCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH) { + return ignoreCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDENDCOMMAND) { + return addCommandEndCommand(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDPARAGRAPH) { + return addCommandWordParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDLINE) { + return addCommandWordLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDOWORDWORD) { + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDOWORD) { + return addCommandOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDERRORTHROW) { + return addCommandErrorThrow(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDUNIQUE) { return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; - } + } -std::list parse(std::list::iterator endParsingIndex, TokenList &tokList){ - std::list aNewList; + return 0; +} + +std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { + std::list < DoxygenEntity > aNewList; int currCommand; - while (tokList.current() != endParsingIndex){ + while (tokList.current() != endParsingIndex) { Token currToken = tokList.peek(); - if(noisy) + if (noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ + if (currToken.tokenType == END_LINE) { tokList.next(); - } - else if(currToken.tokenType == COMMAND){ + } else if (currToken.tokenType == COMMAND) { currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) + if (currCommand < 0) { + if (noisy) cout << "Unidentified Command " << currToken.tokenString << endl; tokList.next(); addCommand(std::string("plainstd::string"), tokList, aNewList); + } else { + tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); } - else { tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } - else if (currToken.tokenType == PLAINSTRING){ + } else if (currToken.tokenType == PLAINSTRING) { addCommand(std::string("plainstd::string"), tokList, aNewList); } break; @@ -776,50 +802,48 @@ std::list parse(std::list::iterator endParsingIndex, Token return aNewList; } -std::list parseRoot(std::list::iterator endParsingIndex, TokenList &tokList){ +std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { - std::list aNewList; + std::list < DoxygenEntity > aNewList; int currCommand; - while (tokList.current() != endParsingIndex){ + while (tokList.current() != endParsingIndex) { Token currToken = tokList.peek(); - if(noisy) { + if (noisy) { cout << "Parsing for phrase starting in:" << currToken.toString() << endl; } - if(currToken.tokenType == END_LINE ){ + if (currToken.tokenType == END_LINE) { tokList.next(); - } - else if(currToken.tokenType == COMMAND){ + } else if (currToken.tokenType == COMMAND) { currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) { + if (currCommand < 0) { + if (noisy) { cout << "Unidentified Command " << currToken.tokenString << endl; } tokList.next(); addCommand(std::string("partofdescription"), tokList, aNewList); - } else { - tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); + } else { + tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); } - } - else if (currToken.tokenType == PLAINSTRING){ + } else if (currToken.tokenType == PLAINSTRING) { addCommand(std::string("partofdescription"), tokList, aNewList); } } return aNewList; } -std::list DoxygenParser::createTree(std::string doxygenBlob){ +std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob) { TokenList tokList = TokenList(doxygenBlob); - if(noisy) { + if (noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); } - std::list rootList; - rootList = parseRoot( tokList.end(), tokList); - if(noisy) { + std::list < DoxygenEntity > rootList; + rootList = parseRoot(tokList.end(), tokList); + if (noisy) { cout << "PARSED LIST" << endl; printTree(rootList); } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 2269e6788..c298a92f3 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -3,12 +3,11 @@ #include #include #include "DoxygenEntity.h" -class DoxygenParser -{ +class DoxygenParser { public: DoxygenParser(); virtual ~DoxygenParser(); - std::list createTree(std::string doxygen); + std::list < DoxygenEntity > createTree(std::string doxygen); }; -#endif /*DOXYGENPARSER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 025670796..6fe97d298 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -12,21 +12,21 @@ #include "JavaDocConverter.h" #include "PyDocConverter.h" -bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){ - switch(format){ - case JavaDoc: - return JavaDocConverter().getDocumentation(node, documentation); - case PyDoc: - return PyDocConverter().getDocumentation(node, documentation); - default: - return false; +bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) { + switch (format) { + case JavaDoc: + return JavaDocConverter().getDocumentation(node, documentation); + case PyDoc: + return PyDocConverter().getDocumentation(node, documentation); + default: + return false; } } -void DoxygenTranslator::printTree(std::list &entityList){ - std::list::iterator p = entityList.begin(); - while (p != entityList.end()){ +void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) { + std::list < DoxygenEntity >::iterator p = entityList.begin(); + while (p != entityList.end()) { (*p).printEntity(0); p++; } -} \ No newline at end of file +} diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 4be1e97e3..566b1551d 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -28,14 +28,13 @@ enum DocumentationFormat { * A class to translate doxygen comments attacted to parser nodes * into alternative formats for use in code generated for target languages. */ -class DoxygenTranslator -{ +class DoxygenTranslator { public: /* * Virtual destructor. */ - virtual ~DoxygenTranslator(){} - + virtual ~ DoxygenTranslator() { + } /* * Return the documentation for a given node formated for the correct * documentation system. @@ -45,7 +44,7 @@ public: * @return A bool to indicate if there was documentation to return for the node. */ static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation); - + protected: /* * Overridden in subclasses to return the documentation formatted for a given @@ -55,11 +54,11 @@ protected: * @return A bool to indicate if there was documentation to return for the node. */ virtual bool getDocumentation(Node *node, String *&documentation) = 0; - + /* * Prints the details of a parsed entity list to stdout (for debugging). */ - void printTree(std::list &entityList); + void printTree(std::list < DoxygenEntity > &entityList); }; -#endif /*DOXYGENTRANSLATOR_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp index dacb31f77..930141c97 100644 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp @@ -1,7 +1,5 @@ /* The main class for translating blobs of Doxygen for SWIG * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - * Currently the spacing/format on this is a bit goofy in places, due to shuffling code - * between 2 editors! Apologies for anyone combing through it :) */ //TODO DOH instead of STL? //TODO Most commands are not fully implemented @@ -40,8 +38,8 @@ to test. */ int testCodeCrawlingFunctions = 0; int demonstrateParsing = 0; int runExamples = 0; -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(string commandName, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString); ////////////////////////////////////////// @@ -51,162 +49,203 @@ int addCommand(string commandName, int &startInd, list &doxyList // An array of all the commands and my generic description tag, plaindescription -string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "//","&", "~", "<", ">", "#", "%"}; +string commandArray[] = { "a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "//", "&", "~", "<", ">", "#", "%" +}; string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" +}; /* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; -string ignoredSimpleCommands[] = {"nothing at the moment"}; -string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -string ignoreCommandLines[] = {"nothing at the moment"}; -string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"}; -string ignoreCommandParagraphs[] = {"nothing at the moment"}; -string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; -string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -string commandOWords[] = {"dir", "file", "cond"}; -string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; -string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; +string simpleCommands[] = { "n", "$", "@", "//", "&", "~", "<", ">", "#", "%" }; +string ignoredSimpleCommands[] = { "nothing at the moment" }; + +string commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno" +}; +string ignoredCommandWords[] = { "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" }; +string commandLines[] = { "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" }; +string ignoreCommandLines[] = { "nothing at the moment" }; + +string commandParagraph[] = { "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" +}; +string ignoreCommandParagraphs[] = { "nothing at the moment" }; + +string commandEndCommands[] = { "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link" +}; +string commandWordParagraphs[] = { "param", "tparam", "throw", "retval", "exception" }; +string commandWordLines[] = { "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" }; +string commandWordOWordOWords[] = { "category", "class", "protocol", "interface", "struct", "union" }; +string commandOWords[] = { "dir", "file", "cond" }; + +string commandErrorThrowings[] = { "annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif" +}; + +string commandUniques[] = { "xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li" +}; //int startIndex = 0; - int isNewLine = 0; - int briefDescExists = 0; +int isNewLine = 0; +int briefDescExists = 0; /* Entity list is the root list. * it is arranged this way to help documentation modules, * such as the javaDoc one, "sort" entities where they need to. */ - list rootList; +list < DoxygenEntity > rootList; /* General (untested) assist methods */ - string StringToLower(string stringToConvert) +string StringToLower(string stringToConvert) +{ + //change each element of the string to lower case - {//change each element of the string to lower case - - for(unsigned int i=0;i= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } +string getStringTilCommand(int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= doxygenString.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[counter] == '\n' + || doxygenString[counter] == '/' || doxygenString[counter] == '!' + || doxygenString[startIndex] == '\t')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - finalIndex = endIndex; - keepLooping = 0; - } - else if(endIndex < doxygenString.length() -2 - && string("**/").compare(doxygenString.substr(endIndex , endIndex + 2)) == 0){ - finalIndex = endIndex; - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; + } + //endIndex = counter; + } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + finalIndex = endIndex; + keepLooping = 0; + } else if (endIndex < doxygenString.length() - 2 && string("**/").compare(doxygenString.substr(endIndex, endIndex + 2)) == 0) { + finalIndex = endIndex; + //cout << "3 "; + keepLooping = 0; + } + if (keepLooping) { + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') + startIndex++; - for (int i = startIndex; i < endIndex; i++){ + for (int i = startIndex; i < endIndex; i++) { + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + //if(noisy) cout << "Final Index is: " << finalIndex << endl; + startInd = finalIndex; + return description; +} - if (doxygenString[i] == '\n') { - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t'|| doxygenString[i] == ' ' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - //if(noisy) cout << "Final Index is: " << finalIndex << endl; - startInd = finalIndex; - return description; - } - - /* Returns a Paragraph- defined in Doxygen to be a paragraph of text * seperate by either a structural command or a blank line * This method is VERY messy currently */ //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters - string getStringTilEndOfParagraph(int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[startIndex] == '\t' || doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } +string getStringTilEndOfParagraph(int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= doxygenString.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[startIndex] == '\t' + || doxygenString[counter] == '\n' || doxygenString[counter] == '/' + || doxygenString[counter] == '!')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - } - //endIndex = counter; - } - //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap - else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - spareIndex = endIndex +1; - - if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { - keepLooping = 0; - finalIndex = endIndex;} - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - keepLooping = 0; - finalIndex = endIndex; - } - if(keepLooping){ - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + } + //endIndex = counter; + } + //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap + else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + spareIndex = endIndex + 1; - for (int i = startIndex; i < endIndex; i++){ + if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { + keepLooping = 0; + finalIndex = endIndex; + } + } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { + keepLooping = 0; + finalIndex = endIndex; + } + if (keepLooping) { + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') + startIndex++; - if (doxygenString[i] == '\n') { + for (int i = startIndex; i < endIndex; i++) { - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' ||doxygenString[startIndex] == '!' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' || doxygenString[startIndex] == '!' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; +} /* This method is for a specific form of doxygen command * that begins with a \command and ends in \endcommand @@ -440,263 +488,280 @@ string getStringTilCommand(int &startInd, string doxygenString){ * currently this method does NOT process what is in between the two commands */ //TODO Make progressTilCommand return a formatted string - int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ - int endIndex = startInd; - while (endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; - if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ - startInd = endIndex + theCommand.length() + 1; - return 1; - } - } - endIndex++; - } - //End command not found - return 0; - } +int progressTilEndCommand(string theCommand, int &startInd, string doxygenString) { + int endIndex = startInd; + while (endIndex < doxygenString.length()) { + if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; + if (theCommand.compare(doxygenString.substr(endIndex + 1, theCommand.length())) == 0) { + startInd = endIndex + theCommand.length() + 1; + return 1; + } + } + endIndex++; + } + //End command not found + return 0; +} /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ - - string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= theCommand.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << "2 "; - spareIndex = endIndex; - if (endIndex + theCommand.length() < theCommand.length() - && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) keepLooping = 0; - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; +string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= theCommand.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[counter] == '\n' + || doxygenString[counter] == '/' || doxygenString[counter] == '!' + || doxygenString[startIndex] == '\t')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - for (int i = startIndex; i < endIndex; i++){ + } + //endIndex = counter; + } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + //cout << "2 "; + spareIndex = endIndex; + if (endIndex + theCommand.length() < theCommand.length() + && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) + keepLooping = 0; + } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { + //cout << "3 "; + keepLooping = 0; + } + if (keepLooping) { + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') + startIndex++; - if (doxygenString[i] == '\n') { + for (int i = startIndex; i < endIndex; i++) { - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; +} /* prints the parse tree * */ - void printTree(){ +void printTree() { - list::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; - } + list < DoxygenEntity >::iterator p = rootList.begin(); + while (p != rootList.end()) { + (*p).printEntity(0); + p++; + } - } - - - - list parse(int startInd, string doxygenString){ - string currWord; - int startIndex = startInd; - int savedIndex; - list aNewList; - int endIndex = doxygenString.length(); - int currCommand; - while (startIndex < endIndex){ - savedIndex = startIndex; - currWord = getNextWord(startIndex, doxygenString); - if(noisy) cout << "Parsing for phrase starting in:" << currWord << endl; - if(currWord == ""){ - if (startIndex < endIndex) startIndex++; - } - else if(currWord[0] == '\\' || currWord[0] == '@'){ - currWord = currWord.substr(1, currWord.length() - 1); - currCommand = findCommand(currWord); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currWord << endl;} - //cout << "Command: " << currWord << " " << currCommand << endl; - else addCommand(currWord, startIndex, aNewList, doxygenString); - } - else{ - startIndex = savedIndex; - addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); +} - } - } - return aNewList; - } - + +list < DoxygenEntity > parse(int startInd, string doxygenString) { + string currWord; + int startIndex = startInd; + int savedIndex; + list < DoxygenEntity > aNewList; + int endIndex = doxygenString.length(); + int currCommand; + while (startIndex < endIndex) { + savedIndex = startIndex; + currWord = getNextWord(startIndex, doxygenString); + if (noisy) + cout << "Parsing for phrase starting in:" << currWord << endl; + if (currWord == "") { + if (startIndex < endIndex) + startIndex++; + } else if (currWord[0] == '\\' || currWord[0] == '@') { + currWord = currWord.substr(1, currWord.length() - 1); + currCommand = findCommand(currWord); + if (currCommand < 0) { + if (noisy) + cout << "BAD COMMAND: " << currWord << endl; + } + //cout << "Command: " << currWord << " " << currCommand << endl; + else + addCommand(currWord, startIndex, aNewList, doxygenString); + } else { + startIndex = savedIndex; + addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); + + } + } + + return aNewList; +} + /* Method for Adding a Simple Command * Format: @command * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ - int addSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - - if (noisy) cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - +int addSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + + if (noisy) + cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; +} + /* NOT INCLUDED Simple Commands * Format: @command * Plain commands, such as newline etc, they contain no other data */ - int ignoreSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - - if (noisy) cout << "Not Adding " << theCommand << endl; - return 1; - } - +int ignoreSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + + if (noisy) + cout << "Not Adding " << theCommand << endl; + return 1; +} + /* CommandWord * Format: @command * Commands with a single WORD after then such as @b * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" */ - int addCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()){ - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - else cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } +int addCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()) { + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } else + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* NOT INCLUDED CommandWord * Format: @command * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ - int ignoreCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()){ - return 1; - } - else cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; - } - +int ignoreCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()) { + return 1; + } else + cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; +} + /* CommandLine * Format: @command (line) * Commands with a single LINE after then such as @var * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" */ - int addCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - int placement = 0; - list aNewList; - aNewList = parse(placement, line); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; - } - +int addCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if (!line.empty()) { + int placement = 0; + list < DoxygenEntity > aNewList; + aNewList = parse(placement, line); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* NOT INCLUDED CommandLine * Format: @command (line) * Commands with a single LINE after then such as @var * */ - int ignoreCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; - } - +int ignoreCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if (!line.empty()) { + return 1; + } else + cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; +} + /* CommandParagraph * Format: @command {paragraph} * Commands with a single paragraph after then such as @return * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" */ - int addCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - int placement = 0; - list aNewList; - aNewList = parse(placement, restOfParagraph); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; - } +int addCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if (!restOfParagraph.empty()) { + int placement = 0; + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfParagraph); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var * */ - int ignoreCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; - } +int ignoreCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if (!restOfParagraph.empty()) { + return 1; + } else + cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; +} + /* Command EndCommand * Format: @command and ends at @endcommand * Commands that take in a block of text such as @code @@ -704,221 +769,235 @@ string getStringTilCommand(int &startInd, string doxygenString){ * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ - - int ignoreCommandEndCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - return progressTilEndCommand( "end" + theCommand, startInd, doxygenString); - - } - + +int ignoreCommandEndCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + return progressTilEndCommand("end" + theCommand, startInd, doxygenString); + +} + /* CommandWordParagraph * Format: @command {paragraph} * Commands such as param * "param", "tparam", "throw", "retval", "exception" */ - int addCommandWordParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfParagraph.empty()){ - list aNewList; - aNewList = parse(placement, restOfParagraph); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No paragraph followed " << theCommand << " command. Not added" << endl; - return 0; +int addCommandWordParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if (!restOfParagraph.empty()) { + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfParagraph); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No paragraph followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* CommandWordLine * Format: @command (line) * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ - int addCommandWordLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfLine.empty()){ - list aNewList; - aNewList = parse(placement, restOfLine); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; +int addCommandWordLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } - + string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if (!restOfLine.empty()) { + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfLine); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* Command Word Optional Word Optional Word * Format: @command [] [] * Commands such as class * "category", "class", "protocol", "interface", "struct", "union" */ - int addCommandWordOWordOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string headerfile = getNextWord(startInd, doxygenString); - string headername = getNextWord(startInd, doxygenString); - list aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; +int addCommandWordOWordOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } - + string headerfile = getNextWord(startInd, doxygenString); + string headername = getNextWord(startInd, doxygenString); + list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; +} + /* Command Optional Word * Format: @command [] * Commands such as dir * "dir", "file", "cond" */ - int addCommandOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - +int addCommandOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; +} + /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in * the file Skeleton */ - int addCommand(string commandString, int &startInd, list &doxyList, string doxygenString){ - string theCommand = StringToLower(commandString); - string voidArray[] = {""}; - /* @command */ +int addCommand(string commandString, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + string theCommand = StringToLower(commandString); + string voidArray[] = { "" }; + /* @command */ - - if (theCommand.compare("plainstd::string") == 0){ - string nextPhrase = getStringTilCommand(startInd, doxygenString); - if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDENDCOMMAND){ - return ignoreCommandEndCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDERRORTHROW){ - return 0; - } - if (commandNumber == COMMANDUNIQUE){ - return 0; - } - - return 0; - } - - int weirdTest(){ - string doxygenString = "this is a test."; - string restOfParagraph; - int startIndex = 0; - restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - - startIndex = 0; - restOfParagraph = getStringTilCommand(startIndex, doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - } - + if (theCommand.compare("plainstd::string") == 0) { + string nextPhrase = getStringTilCommand(startInd, doxygenString); + if (noisy) + cout << "Parsing plain string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND) { + return addSimpleCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDSIMPLECOMMAND) { + return ignoreSimpleCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORD) { + return addCommandWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDWORD) { + return ignoreCommandWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDLINE) { + return addCommandLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDLINE) { + return ignoreCommandLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDPARAGRAPH) { + return addCommandParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH) { + return ignoreCommandParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDENDCOMMAND) { + return ignoreCommandEndCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDPARAGRAPH) { + return addCommandWordParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDLINE) { + return addCommandWordLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDOWORDWORD) { + return addCommandWordOWordOWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDOWORD) { + return addCommandOWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDERRORTHROW) { + return 0; + } + if (commandNumber == COMMANDUNIQUE) { + return 0; + } + + return 0; +} + +int weirdTest() { + string doxygenString = "this is a test."; + string restOfParagraph; + int startIndex = 0; + restOfParagraph = getStringTilEndOfParagraph(startIndex, doxygenString); + cout << restOfParagraph << " " << startIndex << endl; + + startIndex = 0; + restOfParagraph = getStringTilCommand(startIndex, doxygenString); + cout << restOfParagraph << " " << startIndex << endl; +} + + + +int doRunExamples() { + string line; + string filename; + string exampleNames[] = { "Examples/Example1", "Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5" }; + int placement; + string doxygenString; + ifstream doxCommentFile; + for (int i = 0; i < 5; i++) { + doxCommentFile.open(exampleNames[i].c_str()); + doxCommentFile >> doxygenString; + while (getline(doxCommentFile, line)) { + doxygenString += line + "\n"; + } + doxCommentFile.close(); + placement = 0; + cout << "---RAW CODE---" << endl << doxygenString << endl << endl; + //clearFluff(placement, doxygenString); + //rootList = parse(placement, doxygenString); + TokenList tokList = TokenList(doxygenString); + tokList.printList(); + cout << "---THE TREE---" << endl; + printTree(); + } + return 1; +} + - int doRunExamples(){ - string line; - string filename; - string exampleNames[] = {"Examples/Example1","Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5"}; - int placement; - string doxygenString; - ifstream doxCommentFile; - for (int i = 0; i < 5; i++){ - doxCommentFile.open(exampleNames[i].c_str()); - doxCommentFile >> doxygenString; - while(getline(doxCommentFile, line)){ - doxygenString += line + "\n";} - doxCommentFile.close(); - placement = 0; - cout << "---RAW CODE---" << endl << doxygenString << endl< */ -#define POUND_COMMAND 236 /* \# */ -#define PERCENT_COMMAND 237 /* \% */ +#define PROTOCOL 194 /* \protocol */ +#define PUBLIC 195 /* \public (PHP only) */ +#define PUBLICSECTION 196 /* \publicsection (PHP only) */ +#define REF 197 /* \ref */ +#define RELATES 198 /* \relates */ +#define RELATESALSO 199 /* \relatesalso */ +#define REMARKS 200 /* \remarks */ +#define RETURN_COMMAND 201 /* \return */ +#define RETVAL 202 /* \retval */ +#define SA 203 /* \sa */ +#define SECTION 204 /* \section */ +#define SEE 205 /* \see */ +#define SHOWINITIALIZER 206 /* \showinitializer */ +#define SINCE 207 /* \since */ +#define SKIP 208 /* \skip */ +#define SKIPLINE 209 /* \skipline */ +#define STRUCT 210 /* \struct */ +#define SUBPAGE 211 /* \subpage */ +#define SUBSECTION 212 /* \subsection */ +#define SUBSUBSECTION 213 /* \subsubsection */ +#define TEST 214 /* \test */ +#define THROW_COMMAND 215 /* \throw */ +#define TODO_COMMAND 216 /* \todo */ +#define TPARAM_COMMAND 217 /* \tparam */ +#define TYPEDEF_COMMAND 218 /* \typedef */ +#define UNION_COMMAND 219 /* \union */ +#define UNTIL_COMMAND 220 /* \until */ +#define VAR_COMMAND 221 /* \var */ +#define VERBATIM 222 /* \verbatim */ +#define VERBININCLUDE 223 /* \verbinclude */ +#define VERSION 224 /* \version */ +#define WARNING 225 /* \warning */ +#define WEAKGROUP 226 /* \weakgroup */ +#define XMLONLY 227 /* \xmlonly */ +#define XREFITEM 228 /* \xrefitem */ +#define DOLLAR_COMMAND 229 /* \$ */ +#define AT_COMMAND 230 /* \@ */ +#define SLASH_COMMAND 231 /* \\ */ +#define AND_COMMAND 232 /* \& */ +#define TILDE_COMMAND 233 /* \~ */ +#define LEFTANGLEBRACKET 234 /* \< */ +#define RIGHTANGLEBRACKET 235 /* \> */ +#define POUND_COMMAND 236 /* \# */ +#define PERCENT_COMMAND 237 /* \% */ -#endif /*TRANSLATOR_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 33a62ff77..9de2f99f3 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,42 +1,43 @@ #include "JavaDocConverter.h" #include "DoxygenParser.h" #include -#define APPROX_LINE_LENGTH 64//characters per line allowed -#define TAB_SIZE 8//characters per line allowed +#define APPROX_LINE_LENGTH 64 //characters per line allowed +#define TAB_SIZE 8 //characters per line allowed int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent){ +std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { std::string formattedLines = "\n * "; int lastPosition = 0; int i = 0; - int isFirstLine = 1; - while (i != -1 && i < (int)unformattedLine.length()){ + int isFirstLine = 1; + while (i != -1 && i < (int) unformattedLine.length()) { lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; + if (isFirstLine) { + i += APPROX_LINE_LENGTH; } else { - i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i += APPROX_LINE_LENGTH - indent * TAB_SIZE; } i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < (int)unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); + if (i > 0 && i + 1 < (int) unformattedLine.length()) { + if (!isFirstLine) + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); } else { - isFirstLine = 0; + isFirstLine = 0; } formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); formattedLines.append("\n *"); } } - if (lastPosition < (int)unformattedLine.length()){ + if (lastPosition < (int) unformattedLine.length()) { if (!isFirstLine) { - for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } } formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); } @@ -47,57 +48,47 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind /* Contains the conversions for tags * could probably be much more efficient... */ -std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ - if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ - return doxygenEntity.data; +std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) { + if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) { + return doxygenEntity.data; } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0) { + return doxygenEntity.data; + } else if (doxygenEntity.typeOfEntity.compare("b") == 0) { return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("c") == 0) { return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("@") == 0) { return "@"; - } - else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("\\") == 0) { return "\\"; - } - else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("<") == 0) { return "<"; - } - else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + } else if (doxygenEntity.typeOfEntity.compare(">") == 0) { return ">"; - } - else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("&") == 0) { return "&"; - } - else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("#") == 0) { return "#"; - } - else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("%") == 0) { return "%"; - } - else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("~") == 0) { return "~"; } return ""; } -std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ +std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { std::string returnedString; - if (doxygenEntity.isLeaf) { + if (doxygenEntity.isLeaf) { return javaDocFormat(doxygenEntity) + " "; } else { returnedString += javaDocFormat(doxygenEntity); - std::list::iterator p = doxygenEntity.entityList.begin(); + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); + while (p != doxygenEntity.entityList.end()) { + returnedString += translateSubtree(*p); p++; } } @@ -105,45 +96,43 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ } -std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ +std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) { if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) { return formatCommand(std::string(translateSubtree(doxyEntity)), 0); } - if ((doxyEntity.typeOfEntity.compare("brief") == 0) || - (doxyEntity.typeOfEntity.compare("details") == 0)) { + if ((doxyEntity.typeOfEntity.compare("brief") == 0) || (doxyEntity.typeOfEntity.compare("details") == 0)) { return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * "; - } else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 || - doxyEntity.typeOfEntity.compare("deprecated")== 0 || - doxyEntity.typeOfEntity.compare("brief")== 0) { + } else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 || + doxyEntity.typeOfEntity.compare("deprecated") == 0 || + doxyEntity.typeOfEntity.compare("brief") == 0) { return formatCommand(doxyEntity.data, 0) + "\n * "; - } else if(doxyEntity.typeOfEntity.compare("see") == 0) { - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + - translateSubtree(doxyEntity)), 2); + } else if (doxyEntity.typeOfEntity.compare("see") == 0) { + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("throw")== 0 - || doxyEntity.typeOfEntity.compare("throws")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + } else if (doxyEntity.typeOfEntity.compare("return") == 0 + || doxyEntity.typeOfEntity.compare("author") == 0 + || doxyEntity.typeOfEntity.compare("param") == 0 + || doxyEntity.typeOfEntity.compare("throw") == 0 + || doxyEntity.typeOfEntity.compare("throws") == 0 + || doxyEntity.typeOfEntity.compare("since") == 0 + || doxyEntity.typeOfEntity.compare("version") == 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0) { // this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing - if (doxyEntity.typeOfEntity.compare("throw")== 0) { + if (doxyEntity.typeOfEntity.compare("throw") == 0) { doxyEntity.typeOfEntity = "throws"; } return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - } else if(doxyEntity.typeOfEntity.compare("sa")== 0) { + } else if (doxyEntity.typeOfEntity.compare("sa") == 0) { return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); } else { - return formatCommand(javaDocFormat(doxyEntity), 0 ); + return formatCommand(javaDocFormat(doxyEntity), 0); } return ""; @@ -157,31 +146,31 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) { if (documentation == NULL) { return false; } - - std::list entityList = DoxygenParser().createTree(Char(documentation)); - // entityList.sort(CompareDoxygenEntities()); sorting currently not used, - // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp - - if(debug){ + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); + + // entityList.sort(CompareDoxygenEntities()); sorting currently not used, + // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp + + if (debug) { std::cout << "---RESORTED LIST---" << std::endl; printTree(entityList); } std::string javaDocString = "/**"; - - for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ + + for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { javaDocString += translateEntity(*entityIterator); entityIterator++; } javaDocString += "\n */\n"; - - if(debug){ + + if (debug) { std::cout << "\n---RESULT IN JAVADOC---" << std::endl; - std::cout << javaDocString; + std::cout << javaDocString; } - + documentation = NewString(javaDocString.c_str()); return true; } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 8651bb1cf..d898265ba 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -15,20 +15,20 @@ /* * A class to translate doxygen comments into JavaDoc style comments. */ -class JavaDocConverter : public DoxygenTranslator -{ +class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter() : debug( false ){} + JavaDocConverter() : debug(false) { + } virtual bool getDocumentation(Node *node, String *&documentation); - + protected: std::string formatCommand(std::string unformattedLine, int indent); - std::string translateEntity(DoxygenEntity &doxyEntity); - std::string javaDocFormat(DoxygenEntity &doxygenEntity); - std::string translateSubtree( DoxygenEntity &doxygenEntity); - + std::string translateEntity(DoxygenEntity & doxyEntity); + std::string javaDocFormat(DoxygenEntity & doxygenEntity); + std::string translateSubtree(DoxygenEntity & doxygenEntity); + private: bool debug; }; -#endif /*JAVADOCCONVERTER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 6418ee73c..44dec4cbf 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -14,25 +14,25 @@ #include //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag -PyDocConverter::PyDocConverter(){ - debug = 1; +PyDocConverter::PyDocConverter() { + debug = 1; } -std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { +std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p = NULL; - - DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); - DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); - + + DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin(); + DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); + std::string result; std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); - + for (p = plist; p;) { - if(Char(Getattr(p, "name")) == paramNameEntity.data) { + if (Char(Getattr(p, "name")) == paramNameEntity.data) { std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); - + result = name + " (" + type + ") "; result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); @@ -45,162 +45,158 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { return result; } -std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){ +std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) { #pragma unused(node) return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity)); } -std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth){ +std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth) { std::ostringstream formattedString; std::string currentLine; - - for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) - { - if(currentLine.length() == 0) + + for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) { + if (currentLine.length() == 0) currentLine.resize(indent, ' '); - + currentLine += *stringPosition; - - if(*stringPosition == ' ' && (int)currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) - { + + if (*stringPosition == ' ' && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) { formattedString << currentLine << std::endl; currentLine = ""; } } - + return formattedString.str(); } -std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ +std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { std::string returnedString; if (doxygenEntity.isLeaf) return doxygenEntity.data + " "; else { returnedString += doxygenEntity.data; - std::list::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()) { + returnedString += translateSubtree(*p); p++; } } return returnedString; } -std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription") == 0) +std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) { + if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) return justifyString(std::string(translateSubtree(doxyEntity)), 0); - + if ((doxyEntity.typeOfEntity.compare("brief") == 0) - ||(doxyEntity.typeOfEntity.compare("details") == 0)) + || (doxyEntity.typeOfEntity.compare("details") == 0)) return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; - - if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("brief") == 0) + + if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("brief") == 0) return justifyString(doxyEntity.data, 0) + "\n"; - - if(doxyEntity.typeOfEntity.compare("param") == 0) + + if (doxyEntity.typeOfEntity.compare("param") == 0) return formatParam(n, doxyEntity); - - if(doxyEntity.typeOfEntity.compare("return") == 0) + + if (doxyEntity.typeOfEntity.compare("return") == 0) return formatReturnDescription(n, doxyEntity); - if(doxyEntity.typeOfEntity.compare("author") == 0 - || doxyEntity.typeOfEntity.compare("param") == 0 - || doxyEntity.typeOfEntity.compare("since") == 0 - || doxyEntity.typeOfEntity.compare("version") == 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("sa") == 0) + if (doxyEntity.typeOfEntity.compare("author") == 0 + || doxyEntity.typeOfEntity.compare("param") == 0 + || doxyEntity.typeOfEntity.compare("since") == 0 + || doxyEntity.typeOfEntity.compare("version") == 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("sa") == 0) return ""; return justifyString(doxyEntity.data); } -std::string PyDocConverter::processEntityList(Node *n, std::list& entityList){ +std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity > &entityList) { std::string result; bool inParamsSection = false; - - for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ - if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){ + + for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { + if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) { inParamsSection = true; result += "\nArguments:\n"; - } - else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) + } else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) inParamsSection = false; - + result += translateEntity(n, *entityIterator); entityIterator++; - } - + } + return result; } -bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ +bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { std::string pyDocString, result; - + // for overloaded functions we must concat documentation for underlying overloads - if(Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")){ + if (Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")) { // rewind to the first overload while (Getattr(n, "sym:previousSibling")) n = Getattr(n, "sym:previousSibling"); - - std::vector allDocumentation; - + + std::vector < std::string > allDocumentation; + // for each real method (not a generated overload) append the documentation - while(n){ - documentation = Getattr(n,"DoxygenComment"); - if(!Swig_is_generated_overload(n) && documentation){ - std::list entityList = DoxygenParser().createTree(Char(documentation)); + while (n) { + documentation = Getattr(n, "DoxygenComment"); + if (!Swig_is_generated_overload(n) && documentation) { + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); allDocumentation.push_back(processEntityList(n, entityList)); } n = Getattr(n, "sym:nextSibling"); } - + // construct final documentation string - if(allDocumentation.size() > 1){ + if (allDocumentation.size() > 1) { std::ostringstream concatDocString; - for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){ + for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) { concatDocString << generateDivider(); concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; concatDocString << generateDivider(); concatDocString << allDocumentation[realOverloadCount] << std::endl; } pyDocString = concatDocString.str(); - } - else if (allDocumentation.size() == 1) { + } else if (allDocumentation.size() == 1) { pyDocString = *(allDocumentation.begin()); } - } + } // for other nodes just process as normal else { - documentation = Getattr(n,"DoxygenComment"); - if(documentation != NULL){ - std::list entityList = DoxygenParser().createTree(Char(documentation)); + documentation = Getattr(n, "DoxygenComment"); + if (documentation != NULL) { + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); pyDocString = processEntityList(n, entityList); } } - + // if we got something log the result and construct DOH string to return - if(pyDocString.length()) { + if (pyDocString.length()) { result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; - - if(debug){ + + if (debug) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; std::cout << result; std::cout << std::endl; } - + documentation = NewString(result.c_str()); return true; } - + return false; } -std::string PyDocConverter::generateDivider(){ +std::string PyDocConverter::generateDivider() { std::ostringstream dividerString; - for(int i = 0; i < DOC_STRING_LENGTH; i++) + for (int i = 0; i < DOC_STRING_LENGTH; i++) dividerString << '-'; dividerString << std::endl; return dividerString.str(); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 500e39fe8..5680480fc 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -16,38 +16,37 @@ #include "DoxygenEntity.h" #include "DoxygenTranslator.h" -#define DOC_STRING_LENGTH 64 // characters per line allowed -#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type +#define DOC_STRING_LENGTH 64 // characters per line allowed +#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type -class PyDocConverter : public DoxygenTranslator -{ +class PyDocConverter : public DoxygenTranslator { public: PyDocConverter(); bool getDocumentation(Node *node, String *&documentation); - + protected: - + /* * Process the contents of the entity list producing a documentation string. * @param node The parse tree node that the entity list relates to. * @param entityList The entity list to process */ - std::string processEntityList(Node *node, std::list& entityList); - + std::string processEntityList(Node *node, std::list < DoxygenEntity > &entityList); + /* * Format the doxygen comment relating to a function or method parameter * @param node The parse tree node that the parameter relates to. * @param doxygenEntity The doxygen entity relating to the parameter docstring. */ - std::string formatParam(Node *node, DoxygenEntity &doxygenEntity); - + std::string formatParam(Node *node, DoxygenEntity & doxygenEntity); + /* * Format the doxygen comment relating to the return value for a method or function. * @param node The parse tree node that the parameter relates to. * @param doxygenEntity The doxygen entity relating to the parameter docstring. */ - std::string formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity); - + std::string formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity); + /* * Format a string so it is justified and split over several lines * not exeeding a given length. @@ -56,17 +55,17 @@ protected: * @param maxWidth The approximate maximum line width. */ std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); - - std::string translateSubtree( DoxygenEntity &doxygenEntity); - std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); - + + std::string translateSubtree(DoxygenEntity & doxygenEntity); + std::string translateEntity(Node *n, DoxygenEntity & doxyEntity); + /* * Utility method to generate a diving line for a documentation string. */ std::string generateDivider(); - + private: bool debug; }; -#endif /*PYDOCCONVERTER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp index 2ac03afe5..f7c02b021 100644 --- a/Source/DoxygenTranslator/src/Token.cpp +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -3,27 +3,26 @@ using namespace std; -Token::Token(int tType, string tString) -{ - tokenType = tType; - tokenString = tString; +Token::Token(int tType, string tString) { + tokenType = tType; + tokenString = tString; } -string Token::toString() -{ - if (tokenType == END_LINE){ - return "{END OF LINE}"; - } - if (tokenType == PARAGRAPH_END){ - return "{END OF PARAGRAPH}"; - } - if (tokenType == PLAINSTRING){ - return "{PLAINSTRING :" + tokenString + "}"; - } - if (tokenType == COMMAND){ - return "{COMMAND : " + tokenString+ "}"; - } - return ""; +string Token::toString() { + if (tokenType == END_LINE) { + return "{END OF LINE}"; + } + if (tokenType == PARAGRAPH_END) { + return "{END OF PARAGRAPH}"; + } + if (tokenType == PLAINSTRING) { + return "{PLAINSTRING :" + tokenString + "}"; + } + if (tokenType == COMMAND) { + return "{COMMAND : " + tokenString + "}"; + } + return ""; } -Token:: ~Token(){} +Token::~Token() { +} diff --git a/Source/DoxygenTranslator/src/Token.h b/Source/DoxygenTranslator/src/Token.h index cf28c90b7..4ae44b65f 100644 --- a/Source/DoxygenTranslator/src/Token.h +++ b/Source/DoxygenTranslator/src/Token.h @@ -4,15 +4,14 @@ using namespace std; -class Token -{ +class Token { public: - Token(int tType, string tString); - ~Token(); + Token(int tType, string tString); + ~Token(); - int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ - string tokenString; /* the data , such as param for @param*/ - string toString(); + int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ + string tokenString; /* the data , such as param for @param */ + string toString(); }; -#endif /*TOKEN_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 9efd7e9ef..8eeef97b2 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -5,165 +5,161 @@ #include #include "Token.h" #include "DoxygenEntity.h" -#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list +#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list using namespace std; int noisy2 = 0; /* The tokenizer*/ -TokenList::TokenList(const std::string &doxygenStringConst){ - size_t commentPos; - string doxygenString = doxygenStringConst; +TokenList::TokenList(const std::string & doxygenStringConst) { + size_t commentPos; + string doxygenString = doxygenStringConst; - /* Comment start tokens are replaced in parser.y, see doxygen_comment and - doxygen_post_comment_item - do { - commentPos = doxygenString.find("///<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/**<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/*!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("//!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - break; - } while (true); */ + /* Comment start tokens are replaced in parser.y, see doxygen_comment and + doxygen_post_comment_item + do { + commentPos = doxygenString.find("///<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/**<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/*!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("//!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + break; + } while (true); + */ - size_t currentIndex = 0; - size_t nextIndex = 0; + size_t currentIndex = 0; + size_t nextIndex = 0; - string currentWord; + string currentWord; - while (currentIndex < doxygenString.length()){ + while (currentIndex < doxygenString.length()) { - if(doxygenString[currentIndex] == '\n'){ - m_tokenList.push_back(Token(END_LINE, currentWord)); - currentIndex++; - } + if (doxygenString[currentIndex] == '\n') { + m_tokenList.push_back(Token(END_LINE, currentWord)); + currentIndex++; + } + // skip WS, except \n + while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t')) + currentIndex++; - // skip WS, except \n - while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' - || doxygenString[currentIndex]== '\t')) currentIndex ++; + if (currentIndex < doxygenString.length()) { - if (currentIndex < doxygenString.length()) { + nextIndex = currentIndex; - nextIndex = currentIndex; + // skip non WS + while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex] != '\n')) + nextIndex++; - // skip non WS - while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' - && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n')) - nextIndex++; + // now we have a token + currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex); - // now we have a token - currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); + if (noisy2) + cout << "Current Word: " << currentWord << endl; - if(noisy2) - cout << "Current Word: " << currentWord << endl; + if (currentWord[0] == '@' || currentWord[0] == '\\') { + // it is doxygen command + currentWord = currentWord.substr(1, currentWord.length() - 1); + m_tokenList.push_back(Token(COMMAND, currentWord)); - if (currentWord[0] == '@' || currentWord[0] == '\\'){ - // it is doxygen command - currentWord = currentWord.substr(1, currentWord.length()-1); - m_tokenList.push_back(Token(COMMAND, currentWord)); + } else if (currentWord[0] == '\n') { - } else if (currentWord[0] == '\n'){ + m_tokenList.push_back(Token(END_LINE, currentWord)); - m_tokenList.push_back(Token(END_LINE, currentWord)); - - } - else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ - - bool isPlainString = false; + } else if (currentWord[0] == '*' || currentWord[0] == '/' || currentWord[0] == '!') { - if (currentWord.length() > 1) { + bool isPlainString = false; - for(size_t i = 1; i < currentWord.length(); i++){ - if (currentWord[i] != '*' && currentWord[i] != '/' && - currentWord[i] != '!') { - isPlainString = true; - break; - } - } - } - - if(isPlainString) - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + if (currentWord.length() > 1) { - } else if (!currentWord.empty()) { - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); - } - currentIndex = nextIndex; - } + for (size_t i = 1; i < currentWord.length(); i++) { + if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') { + isPlainString = true; + break; + } + } } - m_tokenListIter = m_tokenList.begin(); + if (isPlainString) + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + + } else if (!currentWord.empty()) { + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + } + currentIndex = nextIndex; + } + } + + m_tokenListIter = m_tokenList.begin(); } -TokenList:: ~TokenList(){ +TokenList::~TokenList() { } -Token TokenList::peek(){ - if(m_tokenListIter!= m_tokenList.end()){ - Token returnedToken = (*m_tokenListIter); - return returnedToken; - } - else - return Token(0, ""); -} - - -Token TokenList::next(){ - if(m_tokenListIter != m_tokenList.end()){ - Token returnedToken = (*m_tokenListIter); - m_tokenListIter++; - return (returnedToken); - } - else - return Token(0, ""); -} - - -list::iterator TokenList::end(){ - return m_tokenList.end(); +Token TokenList::peek() { + if (m_tokenListIter != m_tokenList.end()) { + Token returnedToken = (*m_tokenListIter); + return returnedToken; + } else + return Token(0, ""); } -list::iterator TokenList::current(){ +Token TokenList::next() { + if (m_tokenListIter != m_tokenList.end()) { + Token returnedToken = (*m_tokenListIter); + m_tokenListIter++; + return (returnedToken); + } else + return Token(0, ""); +} + + +list < Token >::iterator TokenList::end() { + return m_tokenList.end(); +} + + +list < Token >::iterator TokenList::current() { return m_tokenListIter; } -list::iterator TokenList::iteratorCopy(){ +list < Token >::iterator TokenList::iteratorCopy() { return m_tokenListIter; } -void TokenList::setIterator(list::iterator newPosition){ +void TokenList::setIterator(list < Token >::iterator newPosition) { m_tokenListIter = newPosition; } -void TokenList::printList(){ - list::iterator p = m_tokenList.begin(); - int i = 1; - int b = 0; - while (p != m_tokenList.end()){ - cout << (*p).toString() << " "; - b = i%TOKENSPERLINE; - if (b == 0) cout << endl; - p++; i++; - } +void TokenList::printList() { + list < Token >::iterator p = m_tokenList.begin(); + int i = 1; + int b = 0; + while (p != m_tokenList.end()) { + cout << (*p).toString() << " "; + b = i % TOKENSPERLINE; + if (b == 0) + cout << endl; + p++; + i++; + } } - diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index 0f5710e0f..841d66e1a 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -10,25 +10,25 @@ * that can be derived from a formatted doxygen string */ -class TokenList{ +class TokenList { private: - std::list m_tokenList; - std::list::iterator m_tokenListIter; + std::list < Token > m_tokenList; + std::list < Token >::iterator m_tokenListIter; public: - TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */ - ~TokenList(); + TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */ + ~TokenList(); - Token peek(); /* returns next token without advancing */ - Token next(); /* returns next token and advances */ + Token peek(); /* returns next token without advancing */ + Token next(); /* returns next token and advances */ - std::list::iterator end(); /* returns an end iterator */ - std::list::iterator current(); /* returns the current iterator */ + std::list < Token >::iterator end(); /* returns an end iterator */ + std::list < Token >::iterator current(); /* returns the current iterator */ - std::list::iterator iteratorCopy(); /* returns a copy of the current iterator */ - void setIterator(list::iterator newPosition); /*moves up the iterator*/ + std::list < Token >::iterator iteratorCopy(); /* returns a copy of the current iterator */ + void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */ - void printList(); /* prints out the sequence of tokens */ + void printList(); /* prints out the sequence of tokens */ }; -#endif /*TOKENLIST_H_*/ +#endif From 06269a50a5a1af69f856c41d0eecdb9e167f0bbe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 1 Nov 2009 22:05:01 +0000 Subject: [PATCH 0041/2031] Apply modified patch 2879724 from Marko Klopcic git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11716 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/PyDocConverter.cpp | 12 +++++++++++- Source/Modules/java.cxx | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 44dec4cbf..cbe81571b 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -19,6 +19,13 @@ PyDocConverter::PyDocConverter() { } std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { + + if (doxygenEntity.entityList.size() < 2) { + /* if 'paramDescriptionEntity' is not there, ignore param. Better than crash! + TODO: log error! */ + return ""; + } + ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p = NULL; @@ -34,7 +41,10 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); result = name + " (" + type + ") "; - result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); + if (result.size() < (DOC_PARAM_STRING_LENGTH - 3)) { + /* do not cut info away - it is better to have not so nice output than type information missing. */ + result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); + } result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); break; } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 532dfd305..0c5ad5401 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2533,10 +2533,10 @@ public: // translate and write javadoc comment if flagged if (doxygen_javadoc_flag){ String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)) { if(comment_creation_chatter) Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */"); - Printf(function_code, Char(doxygen_comments)); + Printv(function_code, doxygen_comments, NIL); Delete(doxygen_comments); } } From 2b1f0a14bcc9649be42f34cd7812ab09c6963f0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Mar 2010 23:43:39 +0000 Subject: [PATCH 0042/2031] merge revisions 11872:11876 from trunk to gsoc2008-cherylfoil branch - license changes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11900 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 12 +- COPYRIGHT | 63 + Doc/Manual/Sections.html | 2 +- Examples/GIFPlot/Chicken/check.list | 3 - Examples/GIFPlot/Chicken/full/Makefile | 28 - Examples/GIFPlot/Chicken/full/README | 6 - Examples/GIFPlot/Chicken/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Chicken/full/gifplot.i | 26 - .../GIFPlot/Chicken/full/test-gifplot.scm | 66 - Examples/GIFPlot/Chicken/simple/Makefile | 28 - Examples/GIFPlot/Chicken/simple/README | 5 - Examples/GIFPlot/Chicken/simple/simple.i | 34 - .../GIFPlot/Chicken/simple/test-simple.scm | 29 - Examples/GIFPlot/Common-Lisp/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Common-Lisp/full/gifplot.i | 21 - Examples/GIFPlot/Common-Lisp/full/runme.lisp | 59 - Examples/GIFPlot/Guile/check.list | 3 - Examples/GIFPlot/Guile/full/Makefile | 28 - Examples/GIFPlot/Guile/full/README | 8 - Examples/GIFPlot/Guile/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Guile/full/gifplot.i | 21 - Examples/GIFPlot/Guile/full/runme.scm | 66 - Examples/GIFPlot/Guile/simple/Makefile | 28 - Examples/GIFPlot/Guile/simple/README | 11 - Examples/GIFPlot/Guile/simple/runme.scm | 30 - Examples/GIFPlot/Guile/simple/simple.i | 34 - Examples/GIFPlot/Include/gifplot.h | 333 --- Examples/GIFPlot/Interface/gifplot.i | 264 -- Examples/GIFPlot/Java/check.list | 4 - Examples/GIFPlot/Java/full/Makefile | 20 - Examples/GIFPlot/Java/full/README | 8 - Examples/GIFPlot/Java/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Java/full/gifplot.i | 15 - Examples/GIFPlot/Java/full/main.java | 75 - Examples/GIFPlot/Java/shadow/Makefile | 20 - Examples/GIFPlot/Java/shadow/README | 5 - Examples/GIFPlot/Java/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Java/shadow/main.java | 76 - Examples/GIFPlot/Java/simple/Makefile | 21 - Examples/GIFPlot/Java/simple/README | 5 - Examples/GIFPlot/Java/simple/main.java | 41 - Examples/GIFPlot/Java/simple/simple.i | 38 - Examples/GIFPlot/Lib/Makefile.in | 22 - Examples/GIFPlot/Lib/color.c | 140 -- Examples/GIFPlot/Lib/font.c | 705 ------ Examples/GIFPlot/Lib/frame.c | 924 ------- Examples/GIFPlot/Lib/gif.c | 668 ----- Examples/GIFPlot/Lib/matrix.c | 343 --- Examples/GIFPlot/Lib/pixmap.c | 159 -- Examples/GIFPlot/Lib/plot2d.c | 445 ---- Examples/GIFPlot/Lib/plot3d.c | 2181 ----------------- Examples/GIFPlot/Makefile.in | 23 - Examples/GIFPlot/Ocaml/check.list | 3 - Examples/GIFPlot/Ocaml/full/Makefile | 33 - Examples/GIFPlot/Ocaml/full/README | 8 - Examples/GIFPlot/Ocaml/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ocaml/full/gifplot.i | 15 - Examples/GIFPlot/Ocaml/full/runme.ml | 87 - Examples/GIFPlot/Ocaml/simple/Makefile | 33 - Examples/GIFPlot/Ocaml/simple/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ocaml/simple/runme.ml | 35 - Examples/GIFPlot/Ocaml/simple/simple.i | 33 - Examples/GIFPlot/Perl5/check.list | 4 - Examples/GIFPlot/Perl5/full/Makefile | 24 - Examples/GIFPlot/Perl5/full/README | 8 - Examples/GIFPlot/Perl5/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Perl5/full/gifplot.i | 15 - Examples/GIFPlot/Perl5/full/runme.pl | 68 - Examples/GIFPlot/Perl5/shadow/Makefile | 24 - Examples/GIFPlot/Perl5/shadow/README | 2 - Examples/GIFPlot/Perl5/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Perl5/shadow/runme.pl | 68 - Examples/GIFPlot/Perl5/simple/Makefile | 24 - Examples/GIFPlot/Perl5/simple/README | 5 - Examples/GIFPlot/Perl5/simple/runme.pl | 28 - Examples/GIFPlot/Perl5/simple/simple.i | 38 - Examples/GIFPlot/Php4/check.list | 3 - Examples/GIFPlot/Php4/full/Makefile | 20 - Examples/GIFPlot/Php4/full/README | 4 - Examples/GIFPlot/Php4/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Php4/full/gifplot.i | 15 - Examples/GIFPlot/Php4/full/runme.php4 | 78 - Examples/GIFPlot/Php4/shadow/Makefile | 19 - Examples/GIFPlot/Php4/shadow/README | 2 - Examples/GIFPlot/Php4/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Php4/shadow/runme.php4 | 79 - Examples/GIFPlot/Php4/simple/Makefile | 20 - Examples/GIFPlot/Php4/simple/README | 5 - Examples/GIFPlot/Php4/simple/runme.php4 | 32 - Examples/GIFPlot/Php4/simple/simple.i | 38 - Examples/GIFPlot/Pike/check.list | 2 - Examples/GIFPlot/Pike/simple/Makefile | 24 - Examples/GIFPlot/Pike/simple/README | 5 - Examples/GIFPlot/Pike/simple/runme.pike | 30 - Examples/GIFPlot/Pike/simple/simple.i | 38 - Examples/GIFPlot/Python/check.list | 4 - Examples/GIFPlot/Python/full/Makefile | 26 - Examples/GIFPlot/Python/full/README | 8 - Examples/GIFPlot/Python/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Python/full/gifplot.i | 15 - Examples/GIFPlot/Python/full/runme.py | 64 - Examples/GIFPlot/Python/shadow/Makefile | 26 - Examples/GIFPlot/Python/shadow/README | 8 - Examples/GIFPlot/Python/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Python/shadow/runme.py | 62 - Examples/GIFPlot/Python/simple/Makefile | 26 - Examples/GIFPlot/Python/simple/README | 5 - Examples/GIFPlot/Python/simple/runme.py | 27 - Examples/GIFPlot/Python/simple/simple.i | 38 - Examples/GIFPlot/README | 59 - Examples/GIFPlot/Ruby/check.list | 4 - Examples/GIFPlot/Ruby/full/Makefile | 24 - Examples/GIFPlot/Ruby/full/README | 8 - Examples/GIFPlot/Ruby/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ruby/full/gifplot.i | 15 - Examples/GIFPlot/Ruby/full/runme.rb | 66 - Examples/GIFPlot/Ruby/shadow/Makefile | 24 - Examples/GIFPlot/Ruby/shadow/README | 5 - Examples/GIFPlot/Ruby/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ruby/shadow/runme.rb | 66 - Examples/GIFPlot/Ruby/simple/Makefile | 24 - Examples/GIFPlot/Ruby/simple/README | 5 - Examples/GIFPlot/Ruby/simple/runme.rb | 27 - Examples/GIFPlot/Ruby/simple/simple.i | 38 - Examples/GIFPlot/Tcl/check.list | 4 - Examples/GIFPlot/Tcl/full/Makefile | 24 - Examples/GIFPlot/Tcl/full/README | 8 - Examples/GIFPlot/Tcl/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Tcl/full/gifplot.i | 15 - Examples/GIFPlot/Tcl/full/runme.tcl | 67 - Examples/GIFPlot/Tcl/mandel/Makefile | 24 - Examples/GIFPlot/Tcl/mandel/README | 6 - Examples/GIFPlot/Tcl/mandel/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Tcl/mandel/display.tcl | 68 - Examples/GIFPlot/Tcl/mandel/mandel.i | 47 - Examples/GIFPlot/Tcl/mandel/mandel.tcl | 170 -- Examples/GIFPlot/Tcl/simple/Makefile | 24 - Examples/GIFPlot/Tcl/simple/README | 5 - Examples/GIFPlot/Tcl/simple/runme.tcl | 27 - Examples/GIFPlot/Tcl/simple/simple.i | 38 - Examples/chicken/zlib/Makefile | 28 - Examples/chicken/zlib/README.html | 1666 ------------- Examples/chicken/zlib/example.i | 76 - Examples/chicken/zlib/test-zlib.scm | 41 - Examples/guile/check.list | 1 - Examples/lua/lua.c | 1 - Examples/test-suite/li_std_set.i | 22 +- Examples/xml/example_gif.i | 329 --- LICENSE | 109 +- LICENSE-GPL | 674 +++++ LICENSE-UNIVERSITIES | 95 + Lib/allegrocl/allegrocl.swg | 2 - Lib/allegrocl/longlongs.i | 3 - Lib/allegrocl/std_list.i | 3 - Lib/allegrocl/std_string.i | 3 - Lib/attribute.i | 3 - Lib/carrays.i | 3 - Lib/cdata.i | 3 - Lib/chicken/chicken.swg | 3 - Lib/chicken/chickenrun.swg | 4 - Lib/chicken/multi-generic.scm | 2 +- Lib/chicken/std_string.i | 3 - Lib/chicken/typemaps.i | 3 - Lib/clisp/clisp.swg | 3 - Lib/cmalloc.i | 3 - Lib/constraints.i | 3 - Lib/cpointer.i | 3 - Lib/csharp/csharp.swg | 3 - Lib/csharp/csharphead.swg | 3 - Lib/csharp/director.swg | 3 - Lib/csharp/enums.swg | 3 - Lib/csharp/enumsimple.swg | 3 - Lib/csharp/enumtypesafe.swg | 3 - Lib/csharp/std_except.i | 3 - Lib/csharp/std_map.i | 3 - Lib/csharp/std_pair.i | 3 - Lib/csharp/std_string.i | 3 - Lib/csharp/std_vector.i | 3 - Lib/csharp/std_wstring.i | 3 - Lib/csharp/stl.i | 3 - Lib/csharp/typemaps.i | 3 - Lib/csharp/wchar.i | 3 - Lib/cstring.i | 3 - Lib/cwstring.i | 3 - Lib/exception.i | 3 - Lib/gcj/cni.swg | 3 - Lib/guile/common.scm | 6 - Lib/guile/cplusplus.i | 3 - Lib/guile/guile.i | 3 - Lib/guile/guile_gh.swg | 3 - Lib/guile/guile_gh_run.swg | 3 - Lib/guile/guile_scm.swg | 3 - Lib/guile/guile_scm_run.swg | 3 - Lib/guile/guilemain.i | 3 - Lib/guile/interpreter.i | 3 - Lib/guile/list-vector.i | 3 - Lib/guile/pointer-in-out.i | 3 - Lib/guile/ports.i | 3 - Lib/guile/std_common.i | 3 - Lib/guile/std_map.i | 3 - Lib/guile/std_pair.i | 3 - Lib/guile/std_string.i | 3 - Lib/guile/std_vector.i | 3 - Lib/guile/stl.i | 3 - Lib/guile/typemaps.i | 3 - Lib/inttypes.i | 3 - Lib/java/arrays_java.i | 3 - Lib/java/director.swg | 3 - Lib/java/enums.swg | 3 - Lib/java/enumsimple.swg | 3 - Lib/java/enumtypesafe.swg | 3 - Lib/java/enumtypeunsafe.swg | 3 - Lib/java/java.swg | 3 - Lib/java/javahead.swg | 3 - Lib/java/std_except.i | 3 - Lib/java/std_map.i | 3 - Lib/java/std_pair.i | 3 - Lib/java/std_string.i | 3 - Lib/java/std_vector.i | 3 - Lib/java/std_wstring.i | 3 - Lib/java/stl.i | 3 - Lib/java/typemaps.i | 3 - Lib/java/various.i | 3 - Lib/lua/_std_common.i | 3 - Lib/lua/lua.swg | 3 - Lib/lua/lua_fnptr.i | 3 - Lib/lua/luarun.swg | 3 - Lib/lua/luaruntime.swg | 3 - Lib/lua/luatypemaps.swg | 3 - Lib/lua/std_except.i | 3 - Lib/lua/std_map.i | 3 - Lib/lua/std_pair.i | 3 - Lib/lua/std_string.i | 3 - Lib/lua/std_vector.i | 3 - Lib/lua/stl.i | 3 - Lib/lua/typemaps.i | 3 - Lib/lua/wchar.i | 6 +- Lib/math.i | 3 - Lib/modula3/modula3.swg | 3 - Lib/modula3/modula3head.swg | 3 - Lib/modula3/typemaps.i | 3 - Lib/mzscheme/mzrun.swg | 3 - Lib/mzscheme/mzscheme.swg | 3 - Lib/mzscheme/std_common.i | 3 - Lib/mzscheme/std_map.i | 3 - Lib/mzscheme/std_pair.i | 3 - Lib/mzscheme/std_string.i | 3 - Lib/mzscheme/std_vector.i | 3 - Lib/mzscheme/stl.i | 3 - Lib/mzscheme/typemaps.i | 3 - Lib/ocaml/cstring.i | 3 - Lib/ocaml/director.swg | 3 - Lib/ocaml/ocaml.i | 3 - Lib/ocaml/ocamldec.swg | 3 - Lib/ocaml/std_common.i | 3 - Lib/ocaml/std_deque.i | 3 - Lib/ocaml/std_list.i | 3 - Lib/ocaml/std_map.i | 3 - Lib/ocaml/std_pair.i | 3 - Lib/ocaml/std_string.i | 3 - Lib/ocaml/std_vector.i | 3 - Lib/ocaml/stl.i | 3 - Lib/ocaml/typecheck.i | 3 - Lib/ocaml/typemaps.i | 3 - Lib/octave/octcontainer.swg | 3 - Lib/octave/octiterators.swg | 3 - Lib/perl5/perlmain.i | 3 - Lib/perl5/reference.i | 3 - Lib/perl5/std_common.i | 3 - Lib/perl5/std_list.i | 3 - Lib/perl5/std_map.i | 3 - Lib/perl5/std_pair.i | 3 - Lib/perl5/std_vector.i | 3 - Lib/perl5/stl.i | 3 - Lib/perl5/typemaps.i | 3 - Lib/php/const.i | 3 - Lib/php/globalvar.i | 3 - Lib/php/php.swg | 3 - Lib/php/phpkw.swg | 3 - Lib/php/phprun.swg | 3 - Lib/php/std_common.i | 3 - Lib/php/std_map.i | 3 - Lib/php/std_pair.i | 3 - Lib/php/std_string.i | 3 - Lib/php/std_vector.i | 3 - Lib/php/stl.i | 3 - Lib/php/typemaps.i | 3 - Lib/pike/pike.swg | 3 - Lib/pike/pikerun.swg | 3 - Lib/pike/std_string.i | 3 - Lib/pointer.i | 3 - Lib/python/ccomplex.i | 3 - Lib/python/director.swg | 3 - Lib/python/embed15.i | 3 - Lib/python/file.i | 4 - Lib/python/pycontainer.swg | 3 - Lib/python/pyiterators.swg | 3 - Lib/python/pyrun.swg | 3 - Lib/python/typemaps.i | 3 - Lib/ruby/director.swg | 3 - Lib/ruby/rubyautodoc.swg | 15 +- Lib/ruby/rubycontainer.swg | 3 - Lib/ruby/rubycontainer_extended.swg | 24 +- Lib/ruby/rubyiterators.swg | 3 - Lib/ruby/rubyprimtypes.swg | 4 - Lib/ruby/rubyrun.swg | 3 - Lib/ruby/rubystdautodoc.swg | 12 +- Lib/ruby/rubytracking.swg | 3 - Lib/ruby/rubywstrings.swg | 20 +- Lib/ruby/stl.i | 3 - Lib/ruby/typemaps.i | 3 - Lib/std/_std_deque.i | 3 - Lib/std_except.i | 3 - Lib/stdint.i | 3 - Lib/stl.i | 3 - Lib/swigarch.i | 3 - Lib/swigrun.i | 3 - Lib/tcl/mactclinit.c | 93 - Lib/tcl/mactkinit.c | 3 - Lib/tcl/std_common.i | 3 - Lib/tcl/std_pair.i | 3 - Lib/tcl/std_vector.i | 3 - Lib/tcl/stl.i | 3 - Lib/tcl/tcl8.swg | 3 - Lib/tcl/tclinterp.i | 3 - Lib/tcl/tclopers.swg | 3 - Lib/tcl/tclresult.i | 3 - Lib/tcl/tclrun.swg | 3 - Lib/tcl/tclsh.i | 3 - Lib/tcl/tclwstrings.swg | 3 - Lib/tcl/typemaps.i | 3 - Lib/tcl/wish.i | 3 - Lib/typemaps/attribute.swg | 3 - Lib/typemaps/carrays.swg | 3 - Lib/typemaps/cdata.swg | 3 - Lib/typemaps/cmalloc.swg | 3 - Lib/typemaps/cpointer.swg | 3 - Lib/typemaps/cstrings.swg | 3 - Lib/typemaps/exception.swg | 3 - Lib/typemaps/ptrtypes.swg | 3 - Lib/typemaps/swigtypemaps.swg | 3 - Lib/typemaps/typemaps.swg | 3 - Lib/uffi/uffi.swg | 2 - Lib/wchar.i | 3 - Lib/windows.i | 3 - Makefile.in | 56 +- README | 57 +- Source/CParse/cparse.h | 8 +- Source/CParse/cscanner.c | 8 +- Source/CParse/parser.y | 8 +- Source/CParse/templ.c | 8 +- Source/CParse/util.c | 8 +- Source/DOH/base.c | 12 +- Source/DOH/doh.h | 14 +- Source/DOH/dohint.h | 15 +- Source/DOH/file.c | 12 +- Source/DOH/fio.c | 12 +- Source/DOH/hash.c | 12 +- Source/DOH/list.c | 12 +- Source/DOH/memory.c | 12 +- Source/DOH/string.c | 12 +- Source/DOH/void.c | 12 +- Source/Include/swigwarn.h | 10 +- Source/Modules/allegrocl.cxx | 8 +- Source/Modules/allocate.cxx | 8 +- Source/Modules/browser.cxx | 8 +- Source/Modules/cffi.cxx | 8 +- Source/Modules/chicken.cxx | 8 +- Source/Modules/clisp.cxx | 8 +- Source/Modules/contract.cxx | 8 +- Source/Modules/csharp.cxx | 8 +- Source/Modules/directors.cxx | 8 +- Source/Modules/emit.cxx | 8 +- Source/Modules/guile.cxx | 8 +- Source/Modules/java.cxx | 8 +- Source/Modules/lang.cxx | 8 +- Source/Modules/lua.cxx | 8 +- Source/Modules/main.cxx | 8 +- Source/Modules/modula3.cxx | 8 +- Source/Modules/module.cxx | 8 +- Source/Modules/mzscheme.cxx | 8 +- Source/Modules/ocaml.cxx | 8 +- Source/Modules/octave.cxx | 8 +- Source/Modules/overload.cxx | 8 +- Source/Modules/perl5.cxx | 12 +- Source/Modules/php.cxx | 8 +- Source/Modules/pike.cxx | 8 +- Source/Modules/python.cxx | 8 +- Source/Modules/r.cxx | 8 +- Source/Modules/ruby.cxx | 8 +- Source/Modules/s-exp.cxx | 8 +- Source/Modules/swigmain.cxx | 12 +- Source/Modules/swigmod.h | 8 +- Source/Modules/tcl8.cxx | 8 +- Source/Modules/typepass.cxx | 8 +- Source/Modules/uffi.cxx | 8 +- Source/Modules/utils.cxx | 8 +- Source/Modules/xml.cxx | 8 +- Source/Preprocessor/cpp.c | 8 +- Source/Preprocessor/expr.c | 8 +- Source/Preprocessor/preprocessor.h | 8 +- Source/Swig/cwrap.c | 8 +- Source/Swig/deprecate.c | 8 +- Source/Swig/error.c | 8 +- Source/Swig/fragment.c | 8 +- Source/Swig/getopt.c | 8 +- Source/Swig/include.c | 8 +- Source/Swig/misc.c | 8 +- Source/Swig/naming.c | 8 +- Source/Swig/parms.c | 8 +- Source/Swig/scanner.c | 8 +- Source/Swig/stype.c | 8 +- Source/Swig/swig.h | 8 +- Source/Swig/swigfile.h | 8 +- Source/Swig/swigopt.h | 8 +- Source/Swig/swigparm.h | 8 +- Source/Swig/swigscan.h | 8 +- Source/Swig/swigtree.h | 8 +- Source/Swig/swigwrap.h | 8 +- Source/Swig/symbol.c | 8 +- Source/Swig/tree.c | 8 +- Source/Swig/typemap.c | 8 +- Source/Swig/typeobj.c | 8 +- Source/Swig/typesys.c | 8 +- Source/Swig/wrapfunc.c | 8 +- configure.in | 4 +- 426 files changed, 1379 insertions(+), 12512 deletions(-) create mode 100644 COPYRIGHT delete mode 100644 Examples/GIFPlot/Chicken/check.list delete mode 100644 Examples/GIFPlot/Chicken/full/Makefile delete mode 100644 Examples/GIFPlot/Chicken/full/README delete mode 100644 Examples/GIFPlot/Chicken/full/cmap delete mode 100644 Examples/GIFPlot/Chicken/full/gifplot.i delete mode 100644 Examples/GIFPlot/Chicken/full/test-gifplot.scm delete mode 100644 Examples/GIFPlot/Chicken/simple/Makefile delete mode 100644 Examples/GIFPlot/Chicken/simple/README delete mode 100644 Examples/GIFPlot/Chicken/simple/simple.i delete mode 100644 Examples/GIFPlot/Chicken/simple/test-simple.scm delete mode 100644 Examples/GIFPlot/Common-Lisp/full/cmap delete mode 100644 Examples/GIFPlot/Common-Lisp/full/gifplot.i delete mode 100644 Examples/GIFPlot/Common-Lisp/full/runme.lisp delete mode 100644 Examples/GIFPlot/Guile/check.list delete mode 100644 Examples/GIFPlot/Guile/full/Makefile delete mode 100644 Examples/GIFPlot/Guile/full/README delete mode 100644 Examples/GIFPlot/Guile/full/cmap delete mode 100644 Examples/GIFPlot/Guile/full/gifplot.i delete mode 100644 Examples/GIFPlot/Guile/full/runme.scm delete mode 100644 Examples/GIFPlot/Guile/simple/Makefile delete mode 100644 Examples/GIFPlot/Guile/simple/README delete mode 100644 Examples/GIFPlot/Guile/simple/runme.scm delete mode 100644 Examples/GIFPlot/Guile/simple/simple.i delete mode 100644 Examples/GIFPlot/Include/gifplot.h delete mode 100644 Examples/GIFPlot/Interface/gifplot.i delete mode 100644 Examples/GIFPlot/Java/check.list delete mode 100644 Examples/GIFPlot/Java/full/Makefile delete mode 100644 Examples/GIFPlot/Java/full/README delete mode 100644 Examples/GIFPlot/Java/full/cmap delete mode 100644 Examples/GIFPlot/Java/full/gifplot.i delete mode 100644 Examples/GIFPlot/Java/full/main.java delete mode 100644 Examples/GIFPlot/Java/shadow/Makefile delete mode 100644 Examples/GIFPlot/Java/shadow/README delete mode 100644 Examples/GIFPlot/Java/shadow/cmap delete mode 100644 Examples/GIFPlot/Java/shadow/main.java delete mode 100644 Examples/GIFPlot/Java/simple/Makefile delete mode 100644 Examples/GIFPlot/Java/simple/README delete mode 100644 Examples/GIFPlot/Java/simple/main.java delete mode 100644 Examples/GIFPlot/Java/simple/simple.i delete mode 100644 Examples/GIFPlot/Lib/Makefile.in delete mode 100644 Examples/GIFPlot/Lib/color.c delete mode 100644 Examples/GIFPlot/Lib/font.c delete mode 100644 Examples/GIFPlot/Lib/frame.c delete mode 100644 Examples/GIFPlot/Lib/gif.c delete mode 100644 Examples/GIFPlot/Lib/matrix.c delete mode 100644 Examples/GIFPlot/Lib/pixmap.c delete mode 100644 Examples/GIFPlot/Lib/plot2d.c delete mode 100644 Examples/GIFPlot/Lib/plot3d.c delete mode 100644 Examples/GIFPlot/Makefile.in delete mode 100644 Examples/GIFPlot/Ocaml/check.list delete mode 100644 Examples/GIFPlot/Ocaml/full/Makefile delete mode 100644 Examples/GIFPlot/Ocaml/full/README delete mode 100644 Examples/GIFPlot/Ocaml/full/cmap delete mode 100644 Examples/GIFPlot/Ocaml/full/gifplot.i delete mode 100644 Examples/GIFPlot/Ocaml/full/runme.ml delete mode 100644 Examples/GIFPlot/Ocaml/simple/Makefile delete mode 100644 Examples/GIFPlot/Ocaml/simple/cmap delete mode 100644 Examples/GIFPlot/Ocaml/simple/runme.ml delete mode 100644 Examples/GIFPlot/Ocaml/simple/simple.i delete mode 100644 Examples/GIFPlot/Perl5/check.list delete mode 100644 Examples/GIFPlot/Perl5/full/Makefile delete mode 100644 Examples/GIFPlot/Perl5/full/README delete mode 100644 Examples/GIFPlot/Perl5/full/cmap delete mode 100644 Examples/GIFPlot/Perl5/full/gifplot.i delete mode 100644 Examples/GIFPlot/Perl5/full/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/shadow/Makefile delete mode 100644 Examples/GIFPlot/Perl5/shadow/README delete mode 100644 Examples/GIFPlot/Perl5/shadow/cmap delete mode 100644 Examples/GIFPlot/Perl5/shadow/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/simple/Makefile delete mode 100644 Examples/GIFPlot/Perl5/simple/README delete mode 100644 Examples/GIFPlot/Perl5/simple/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/simple/simple.i delete mode 100644 Examples/GIFPlot/Php4/check.list delete mode 100644 Examples/GIFPlot/Php4/full/Makefile delete mode 100644 Examples/GIFPlot/Php4/full/README delete mode 100644 Examples/GIFPlot/Php4/full/cmap delete mode 100644 Examples/GIFPlot/Php4/full/gifplot.i delete mode 100644 Examples/GIFPlot/Php4/full/runme.php4 delete mode 100644 Examples/GIFPlot/Php4/shadow/Makefile delete mode 100644 Examples/GIFPlot/Php4/shadow/README delete mode 100644 Examples/GIFPlot/Php4/shadow/cmap delete mode 100644 Examples/GIFPlot/Php4/shadow/runme.php4 delete mode 100644 Examples/GIFPlot/Php4/simple/Makefile delete mode 100644 Examples/GIFPlot/Php4/simple/README delete mode 100644 Examples/GIFPlot/Php4/simple/runme.php4 delete mode 100644 Examples/GIFPlot/Php4/simple/simple.i delete mode 100644 Examples/GIFPlot/Pike/check.list delete mode 100644 Examples/GIFPlot/Pike/simple/Makefile delete mode 100644 Examples/GIFPlot/Pike/simple/README delete mode 100644 Examples/GIFPlot/Pike/simple/runme.pike delete mode 100644 Examples/GIFPlot/Pike/simple/simple.i delete mode 100644 Examples/GIFPlot/Python/check.list delete mode 100644 Examples/GIFPlot/Python/full/Makefile delete mode 100644 Examples/GIFPlot/Python/full/README delete mode 100644 Examples/GIFPlot/Python/full/cmap delete mode 100644 Examples/GIFPlot/Python/full/gifplot.i delete mode 100644 Examples/GIFPlot/Python/full/runme.py delete mode 100644 Examples/GIFPlot/Python/shadow/Makefile delete mode 100644 Examples/GIFPlot/Python/shadow/README delete mode 100644 Examples/GIFPlot/Python/shadow/cmap delete mode 100644 Examples/GIFPlot/Python/shadow/runme.py delete mode 100644 Examples/GIFPlot/Python/simple/Makefile delete mode 100644 Examples/GIFPlot/Python/simple/README delete mode 100644 Examples/GIFPlot/Python/simple/runme.py delete mode 100644 Examples/GIFPlot/Python/simple/simple.i delete mode 100644 Examples/GIFPlot/README delete mode 100644 Examples/GIFPlot/Ruby/check.list delete mode 100644 Examples/GIFPlot/Ruby/full/Makefile delete mode 100644 Examples/GIFPlot/Ruby/full/README delete mode 100644 Examples/GIFPlot/Ruby/full/cmap delete mode 100644 Examples/GIFPlot/Ruby/full/gifplot.i delete mode 100644 Examples/GIFPlot/Ruby/full/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/shadow/Makefile delete mode 100644 Examples/GIFPlot/Ruby/shadow/README delete mode 100644 Examples/GIFPlot/Ruby/shadow/cmap delete mode 100644 Examples/GIFPlot/Ruby/shadow/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/simple/Makefile delete mode 100644 Examples/GIFPlot/Ruby/simple/README delete mode 100644 Examples/GIFPlot/Ruby/simple/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/simple/simple.i delete mode 100644 Examples/GIFPlot/Tcl/check.list delete mode 100644 Examples/GIFPlot/Tcl/full/Makefile delete mode 100644 Examples/GIFPlot/Tcl/full/README delete mode 100644 Examples/GIFPlot/Tcl/full/cmap delete mode 100644 Examples/GIFPlot/Tcl/full/gifplot.i delete mode 100644 Examples/GIFPlot/Tcl/full/runme.tcl delete mode 100644 Examples/GIFPlot/Tcl/mandel/Makefile delete mode 100644 Examples/GIFPlot/Tcl/mandel/README delete mode 100644 Examples/GIFPlot/Tcl/mandel/cmap delete mode 100644 Examples/GIFPlot/Tcl/mandel/display.tcl delete mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.i delete mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.tcl delete mode 100644 Examples/GIFPlot/Tcl/simple/Makefile delete mode 100644 Examples/GIFPlot/Tcl/simple/README delete mode 100644 Examples/GIFPlot/Tcl/simple/runme.tcl delete mode 100644 Examples/GIFPlot/Tcl/simple/simple.i delete mode 100644 Examples/chicken/zlib/Makefile delete mode 100644 Examples/chicken/zlib/README.html delete mode 100644 Examples/chicken/zlib/example.i delete mode 100644 Examples/chicken/zlib/test-zlib.scm delete mode 100644 Examples/xml/example_gif.i create mode 100644 LICENSE-GPL create mode 100644 LICENSE-UNIVERSITIES delete mode 100644 Lib/tcl/mactclinit.c diff --git a/ANNOUNCE b/ANNOUNCE index 7c0e95e3f..5f19da9c0 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,11 +1,11 @@ -*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) *** +*** ANNOUNCE: SWIG 2.0.0 (in progress) *** http://www.swig.org -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. +We're pleased to announce SWIG-2.0.0, the latest installment in the +SWIG development effort. SWIG-2.0.0 includes a number of bug fixes +and enhancements. What is SWIG? ------------- @@ -24,11 +24,11 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.36.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.0.zip Release numbers --------------- diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 000000000..45f9d6b45 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,63 @@ +SWIG Copyright and Authors +-------------------------- + +Copyright (c) 1995-2010 The SWIG Developers +Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona). +Copyright (c) 1998-2005 University of Chicago. +Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California + +Portions also copyrighted by: + Network Applied Communication Laboratory, Inc + Information-technology Promotion Agency, Japan + +Active SWIG Developers: + William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin) + Olly Betts (olly@survex.com) (PHP) + Joseph Wang (joequant@gmail.com) (R) + Xavier Delacour (xavier.delacour@gmail.com) (Octave) + +Past SWIG developers and major contributors include: + Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) + Henning Thielemann (swig@henning-thielemann.de) (Modula3) + Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme) + Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping) + Mikel Bancroft (mikel@franz.com) (Allegro CL) + Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI) + Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby]) + Art Yerkes (ayerkes@speakeasy.net) (Ocaml) + Lyle Johnson (lyle@users.sourceforge.net) (Ruby) + Charlie Savage (cfis@interserv.com) (Ruby) + Thien-Thi Nguyen (ttn@glug.org) (build/test/misc) + Richard Palmer (richard@magicality.org) (PHP) + Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP) + Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP) + Kevin Ruland (PHP) + Shibukawa Yoshiki (Japanese Translation) + Jason Stewart (jason@openinformatics.com) (Perl5) + Loic Dachary (Perl5) + David Fletcher (Perl5) + Gary Holt (Perl5) + Masaki Fukushima (Ruby) + Scott Michel (scottm@cs.ucla.edu) (Java directors) + Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core) + Mark Rose (mrose@stm.lbl.gov) (Directors) + Jonah Beckford (beckford@usermail.com) (CHICKEN) + Ahmon Dancy (dancy@franz.com) (Allegro CL) + Dirk Gerrits (Allegro CL) + Neil Cawse (C#) + Harco de Hilster (Java) + Alexey Dyachenko (dyachenko@fromru.com) (Tcl) + Bob Techentin (Tcl) + Martin Froehlich (Guile) + Marcio Luis Teixeira (Guile) + Duncan Temple Lang (R) + Miklos Vajna (PHP directors) + Mark Gossage (mark@gossage.cjb.net) (Lua) + Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) + John Lenz (Guile, MzScheme updates, Chicken module, runtime system) + +Past contributors include: + James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran + Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn + (See CHANGES and CHANGES.current for a more complete list). + diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 5406f44ea..98f90bc1b 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.37 (in progress) +Last update : SWIG-2.0.0 (in progress)

    Sections

    diff --git a/Examples/GIFPlot/Chicken/check.list b/Examples/GIFPlot/Chicken/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Chicken/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Chicken/full/Makefile b/Examples/GIFPlot/Chicken/full/Makefile deleted file mode 100644 index 2ae4fd7ea..000000000 --- a/Examples/GIFPlot/Chicken/full/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = gifplot.i -SRCS = -CXXSRCS = -TARGET = gifplot -INCLUDE = -I. -I../../Include -SWIGOPT = -I../../Include -CFLAGS = -VARIANT = -LIBS = -L../.. -lgifplot -lm - -# comment the following two lines to build a dynamic so file -CHICKEN_MAIN = test-gifplot.scm -VARIANT = _static - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f gifplot.scm image.gif - rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/full/README b/Examples/GIFPlot/Chicken/full/README deleted file mode 100644 index e5ddd7af1..000000000 --- a/Examples/GIFPlot/Chicken/full/README +++ /dev/null @@ -1,6 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The Scheme program 'test-gifplot.scm' does something a -little more interesting. You'll have to go look at the header file to -get a complete listing of the functions. - -`make' will build a static binary. Run ./gifplot to test it. diff --git a/Examples/GIFPlot/Chicken/full/cmap b/Examples/GIFPlot/Chicken/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICexact (round (max (min cc 239) 0))))) - (gifplot:Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy) - z3 x (+ y dy) z4 - (gifplot:int->Pixel (+ c 16)))) - (y-loop (+ y dy) (+ j 1))))) - (x-loop (+ x dx) (+ i 1))))))) - -(display "Making a nice 3D plot...\n") -(drawsolid) - -(gifplot:FrameBuffer-writeGIF frame cmap "image.gif") -(display "Wrote image.gif\n") diff --git a/Examples/GIFPlot/Chicken/simple/Makefile b/Examples/GIFPlot/Chicken/simple/Makefile deleted file mode 100644 index 484e58390..000000000 --- a/Examples/GIFPlot/Chicken/simple/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = simple.i -SRCS = -CXXSRCS = -TARGET = simple -INCLUDE = -I. -I../../Include -SWIGOPT = -I../../Include -CFLAGS = -VARIANT = -LIBS = -L../.. -lgifplot -lm - -# comment the following two lines to build a dynamic so file -CHICKEN_MAIN = test-simple.scm -VARIANT = _static - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f simple.scm image.gif - rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/simple/README b/Examples/GIFPlot/Chicken/simple/README deleted file mode 100644 index 3b138f381..000000000 --- a/Examples/GIFPlot/Chicken/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. - -`make' will build an exe. Run ./simple to test it. diff --git a/Examples/GIFPlot/Chicken/simple/simple.i b/Examples/GIFPlot/Chicken/simple/simple.i deleted file mode 100644 index 23ac8a856..000000000 --- a/Examples/GIFPlot/Chicken/simple/simple.i +++ /dev/null @@ -1,34 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned int Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants, which we redefine (from gifplot.h) so - that SWIG sees them */ -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - diff --git a/Examples/GIFPlot/Chicken/simple/test-simple.scm b/Examples/GIFPlot/Chicken/simple/test-simple.scm deleted file mode 100644 index 43250d8e9..000000000 --- a/Examples/GIFPlot/Chicken/simple/test-simple.scm +++ /dev/null @@ -1,29 +0,0 @@ -;;; Draw some simple shapes - -(declare (uses simple)) - -(display "Drawing some basic shapes\n") - -(define cmap (simple:new-ColorMap #f)) -(define f (simple:new-FrameBuffer 400 400)) - -;; Clear the picture -(simple:FrameBuffer-clear f (simple:BLACK)) - -;; Make a red box -(simple:FrameBuffer-box f 40 40 200 200 (simple:RED)) - -;; Make a blue circle -(simple:FrameBuffer-circle f 200 200 40 (simple:BLUE)) - -;; Make green line -(simple:FrameBuffer-line f 10 390 390 200 (simple:GREEN)) - -;; Write an image out to disk - -(simple:FrameBuffer-writeGIF f cmap "image.gif") -(display "Wrote image.gif\n") - -(simple:delete-FrameBuffer f) -(simple:delete-ColorMap cmap) - diff --git a/Examples/GIFPlot/Common-Lisp/full/cmap b/Examples/GIFPlot/Common-Lisp/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC -#include -#include -#include -#include -#include - -#ifndef GIFPLOT_H - -#ifdef SWIG -%nodefault; -#endif - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - unsigned char *cmap; - char *name; -} ColorMap; - -extern ColorMap *new_ColorMap(char *filename); -extern void delete_ColorMap(ColorMap *c); -extern void ColorMap_default(ColorMap *c); -extern void ColorMap_assign(ColorMap *c, int index, int r, int g, int b); -extern int ColorMap_getitem(ColorMap *c, int index); -extern void ColorMap_setitem(ColorMap *c, int index, int value); -extern int ColorMap_write(ColorMap *c, char *filename); - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - Pixel **pixels; - Zvalue **zbuffer; - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; -} FrameBuffer; - -#define ZMIN 1e+36 - -/* FrameBuffer Methods */ - -extern FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -extern void delete_FrameBuffer(FrameBuffer *frame); -extern int FrameBuffer_resize(FrameBuffer *frame, int width, int height); -extern void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -extern void FrameBuffer_plot(FrameBuffer *frame, int x, int y, Pixel color); -extern void FrameBuffer_horizontal(FrameBuffer *frame, int xmin, int xmax, int y, Pixel color); -extern void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, Pixel c1, Pixel c2); -extern void FrameBuffer_vertical(FrameBuffer *frame, int ymin, int ymax, int x, Pixel color); -extern void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_solidbox(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_solidcircle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_setclip(FrameBuffer *frame, int xmin, int ymin, int xmax, int ymax); -extern void FrameBuffer_noclip(FrameBuffer *frame); -extern int FrameBuffer_makeGIF(FrameBuffer *frame, ColorMap *cmap, void *buffer, unsigned int maxsize); -extern int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); -extern void FrameBuffer_zresize(FrameBuffer *f, int width, int height); -extern void FrameBuffer_zclear(FrameBuffer *f); -extern void FrameBuffer_solidtriangle(FrameBuffer *f, int x1, int y1, int x2, int y2, int x3, int y3, Pixel c); -extern void FrameBuffer_interptriangle(FrameBuffer *f, int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, int tx3, int ty3, Pixel c3); - -#define HORIZONTAL 1 -#define VERTICAL 2 - -extern void FrameBuffer_drawchar(FrameBuffer *frame, int x, int y, int fgcolor, int bgcolor, char chr, int orientation); -extern void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - -/* ------------------------------------------------------------------------ - PixMap - - The equivalent of "bit-maps". - ------------------------------------------------------------------------ */ - -typedef struct PixMap { - int width; - int height; - int centerx; - int centery; - int *map; -} PixMap; - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); -extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor); - -#define GIFPLOT_TRANSPARENT 0 -#define GIFPLOT_FOREGROUND 1 -#define GIFPLOT_BACKGROUND 2 - -/* ------------------------------------------------------------------------ - Plot2D - - Definition and methods for 2D plots. - ------------------------------------------------------------------------ */ - -typedef struct Plot2D { - FrameBuffer *frame; /* what frame buffer are we using */ - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - double dx; /* Private scaling parameters */ - double dy; -} Plot2D; - -/* 2D Plot methods */ - -extern Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); -extern void delete_Plot2D(Plot2D *p2); -extern Plot2D *Plot2D_copy(Plot2D *p2); -extern void Plot2D_clear(Plot2D *p2, Pixel c); -extern void Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax); -extern void Plot2D_setscale(Plot2D *p2, int xscale, int yscale); -extern void Plot2D_plot(Plot2D *p2, double x, double y, Pixel color); -extern void Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color); -extern void Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_start(Plot2D *p2); -extern void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); -extern void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel c); -extern void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c); -extern void Plot2D_triangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - -#define LINEAR 10 -#define LOG 11 - -/* ----------------------------------------------------------------------- - Matrix - - Operations on 4x4 transformation matrices and vectors. - Matrices are represented as a double array of 16 elements - ----------------------------------------------------------------------- */ - -typedef double *Matrix; -typedef struct GL_Vector { - double x; - double y; - double z; - double w; -} GL_Vector; - -extern Matrix new_Matrix(); -extern void delete_Matrix(Matrix a); -extern Matrix Matrix_copy(Matrix a); -extern void Matrix_multiply(Matrix a, Matrix b, Matrix c); -extern void Matrix_identity(Matrix a); -extern void Matrix_zero(Matrix a); -extern void Matrix_transpose(Matrix a, Matrix result); -extern void Matrix_invert(Matrix a, Matrix inva); -extern void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t); -extern void Matrix_transform4(Matrix a, double rx, double ry, double rz, - double rw, GL_Vector *t); - -extern void Matrix_print(Matrix a); -extern void Matrix_translate(Matrix a, double tx, double ty, double tz); -extern void Matrix_rotatex(Matrix a, double deg); -extern void Matrix_rotatey(Matrix a, double deg); -extern void Matrix_rotatez(Matrix a, double deg); - -/* ----------------------------------------------------------------------- - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; /* Frame buffer being used */ - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - Matrix center_mat; /* Matrix used for centering the model */ - Matrix model_mat; /* Model rotation matrix */ - Matrix view_mat; /* Viewing matrix */ - Matrix fullmodel_mat; /* Full model matrix. Used by sphere plot */ - Matrix trans_mat; /* Total transformation matrix */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - double zoom; - int width; - int height; - int pers_mode; /* Perspective mode (private) */ - double ortho_left,ortho_right,ortho_bottom,ortho_top; -} Plot3D; - -extern Plot3D *new_Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax); -extern void delete_Plot3D(Plot3D *p3); -extern Plot3D *Plot3D_copy(Plot3D *p3); -extern void Plot3D_clear(Plot3D *p3, Pixel Color); -extern void Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar); -extern void Plot3D_ortho(Plot3D *p3, double left, double right, double top, double bottom); -extern void Plot3D_lookat(Plot3D *p3, double z); -extern void Plot3D_autoperspective(Plot3D *p3, double fovy); -extern void Plot3D_autoortho(Plot3D *p3); -extern void Plot3D_rotx(Plot3D *p3, double deg); -extern void Plot3D_roty(Plot3D *p3, double deg); -extern void Plot3D_rotz(Plot3D *p3, double deg); -extern void Plot3D_rotl(Plot3D *p3, double deg); -extern void Plot3D_rotr(Plot3D *p3, double deg); -extern void Plot3D_rotd(Plot3D *p3, double deg); -extern void Plot3D_rotu(Plot3D *p3, double deg); -extern void Plot3D_rotc(Plot3D *p3, double deg); -extern void Plot3D_zoom(Plot3D *p3, double percent); -extern void Plot3D_left(Plot3D *p3, double percent); -extern void Plot3D_right(Plot3D *p3, double percent); -extern void Plot3D_down(Plot3D *p3, double percent); -extern void Plot3D_up(Plot3D *p3, double percent); -extern void Plot3D_center(Plot3D *p3, double cx, double cy); - -extern void Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color); - -extern void Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot3D_start(Plot3D *p3); -extern void Plot3D_line(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); -extern void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); -extern void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - -extern void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - -extern void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - - -extern void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c); - -extern void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c, Pixel bc); - -extern PixMap PixMap_SQUARE; -extern PixMap PixMap_TRIANGLE; -extern PixMap PixMap_CROSS; - -#endif -#define GIFPLOT_H - - - diff --git a/Examples/GIFPlot/Interface/gifplot.i b/Examples/GIFPlot/Interface/gifplot.i deleted file mode 100644 index fdf661c5e..000000000 --- a/Examples/GIFPlot/Interface/gifplot.i +++ /dev/null @@ -1,264 +0,0 @@ -// -// Graphics module -// -%module gifplot -%{ -#include "gifplot.h" -%} - -#if defined(SWIGJAVA ) || defined(SWIGPHP) - %rename(make_default) ColorMap::default(); -#endif - -%rename(__getitem__) ColorMap::getitem(int index); -%rename(__setitem__) ColorMap::setitem(int index, int value); - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - char *name; - -// -// %extend adds some C methods to this structure to make it -// look like a C++ class in Python. -// These are really named things like ColorMap_default, ColorMap_assign, etc... - - %extend { - ColorMap(char *filename); - ~ColorMap(); - void default(); - void assign(int index,int r, int g, int b); - int getitem(int index); - void setitem(int index, int value); - int write(char *filename); - } -} ColorMap; - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; - %extend { - FrameBuffer(unsigned int width, unsigned int height); - ~FrameBuffer(); - void resize(int width, int height); - void clear(Pixel color); - void plot(int x, int y, Pixel color); - void horizontal(int xmin, int xmax, int y, Pixel color); - void horizontalinterp(int xmin, int xmax, int y, Pixel c1, Pixel c2); - void vertical(int ymin, int ymax, int x, Pixel color); - void box(int x1, int y1, int x2, int y2, Pixel color); - void solidbox(int x1, int y1, int x2, int y2, Pixel color); - void interpbox(int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); - void circle(int x1, int y1, int radius, Pixel color); - void solidcircle(int x1, int y1, int radius, Pixel color); - void line(int x1, int y1, int x2, int y2, Pixel color); - void setclip(int xmin, int ymin, int xmax, int ymax); - void noclip(); - int makeGIF(ColorMap *cmap, void *buffer, unsigned int maxsize); - void zresize(int width, int height); - void zclear(); - void drawchar(int x, int y, int fgcolor, int bgcolor, char chr, int orientation); - void drawstring(int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - void drawpixmap(PixMap *pm, int x, int y, int fgcolor, int bgcolor); - int writeGIF(ColorMap *cmap, char *filename); - } -} FrameBuffer; - -#define HORIZONTAL 1 -#define VERTICAL 2 - -/* -------------------------------------------------------------------------- - PixMap - - The equivalent of "bit-maps". - -------------------------------------------------------------------------- */ - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); - -#define GIFPLOT_TRANSPARENT 0 -#define GIFPLOT_FOREGROUND 1 -#define GIFPLOT_BACKGROUND 2 - -/* -------------------------------------------------------------------------- - Plot2D - - Definition and methods for 2D plots. - --------------------------------------------------------------------------- */ - -typedef struct Plot2D { - FrameBuffer *frame; - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - %extend { - Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); - ~Plot2D(); - Plot2D *copy(); - void clear(Pixel c); - void setview(int vxmin, int vymin, int vxmax, int vymax); - void setrange(double xmin, double ymin, double xmax, double ymax); - void setscale(int xscale, int yscale); - void plot(double x, double y, Pixel color); - void box(double x1, double y1, double x2, double y2, Pixel color); - void solidbox(double x1, double y1, double x2, double y2, Pixel color); - void interpbox(double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); - - void circle(double x, double y, double radius, Pixel color); - void solidcircle(double x, double y, double radius, Pixel color); - void line(double x1, double y1, double x2, double y2, Pixel color); - void start(); - void drawpixmap(PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); - void xaxis(double x, double y, double xtick, int ticklength, Pixel color); - void yaxis(double x, double y, double ytick, int ticklength, Pixel color); - void triangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); - - void solidtriangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); - - void interptriangle(double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - - } -} Plot2D; - -#define LINEAR 10 -#define LOG 11 - -/* ------------------------------------------------------------------------------ - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - %extend { - Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax); - ~Plot3D(); - Plot3D *copy(); - void clear(Pixel bgcolor); - void perspective( double fovy, double znear, double zfar); - void lookat( double z); - void autoperspective( double fovy); - void ortho(double left, double right, double bottom, double top); - void autoortho(); - void rotx( double deg); - void roty( double deg); - void rotz( double deg); - void rotl( double deg); - void rotr( double deg); - void rotd( double deg); - void rotu( double deg); - void rotc( double deg); - void zoom( double percent); - void left( double percent); - void right( double percent); - void down( double percent); - void up( double percent); - void center( double cx, double cy); - void plot( double x, double y, double z, Pixel Color); - void setview( int vxmin, int vymin, int vxmax, int vymax); - void start(); - void line( double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); - void triangle( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - void solidtriangle( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - void interptriangle(double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - void quad( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - void solidquad( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - void interpquad( double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - void solidsphere( double x, double y, double z, double radius,Pixel c); - void outlinesphere( double x, double y, double z, double radius,Pixel c, Pixel bc); - } -} Plot3D; - -#ifndef SWIGJAVA -/* These directives create constants of a specific type. They - do not correspond to any C variable or declared constant in the - header file */ -%constant PixMap * SQUARE = &PixMap_SQUARE; -%constant PixMap * TRIANGLE = &PixMap_TRIANGLE; -%constant PixMap * CROSS = &PixMap_CROSS; -#endif - - - - diff --git a/Examples/GIFPlot/Java/check.list b/Examples/GIFPlot/Java/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Java/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Java/full/Makefile b/Examples/GIFPlot/Java/full/Makefile deleted file mode 100644 index 8f167237d..000000000 --- a/Examples/GIFPlot/Java/full/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -noproxy -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README deleted file mode 100644 index f536864de..000000000 --- a/Examples/GIFPlot/Java/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -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 main.java files between this example and the -'full' example. This example does not use shadow classes. - diff --git a/Examples/GIFPlot/Java/full/cmap b/Examples/GIFPlot/Java/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; - gifplot.Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); - y = y + dy; - } - x = x + dx; - } - - gifplot.FrameBuffer_writeGIF(frame,cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - } - - // Here is the function to plot - public static double func(double x, double y) { - return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); - } -} diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile deleted file mode 100644 index e513b9b5a..000000000 --- a/Examples/GIFPlot/Java/shadow/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README deleted file mode 100644 index 4adbde306..000000000 --- a/Examples/GIFPlot/Java/shadow/README +++ /dev/null @@ -1,5 +0,0 @@ -This example uses the file in ../../Interface/gifplot.i to build -an interface with shadow classes. After doing a make, run the program main, ie: 'java main'. - -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/cmap b/Examples/GIFPlot/Java/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; - p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); - y = y + dy; - } - x = x + dx; - } - - frame.writeGIF(cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - } - - // Here is the function to plot - public static double func(double x, double y) { - return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); - } -} diff --git a/Examples/GIFPlot/Java/simple/Makefile b/Examples/GIFPlot/Java/simple/Makefile deleted file mode 100644 index d707fd458..000000000 --- a/Examples/GIFPlot/Java/simple/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -noproxy -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README deleted file mode 100644 index 1fb8453f0..000000000 --- a/Examples/GIFPlot/Java/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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 main'. - - diff --git a/Examples/GIFPlot/Java/simple/main.java b/Examples/GIFPlot/Java/simple/main.java deleted file mode 100644 index b165a4baa..000000000 --- a/Examples/GIFPlot/Java/simple/main.java +++ /dev/null @@ -1,41 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("simple"); - } 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[]) { - - // Draw some simple shapes - System.out.println( "Drawing some basic shapes" ); - - SWIGTYPE_p_ColorMap cmap = simple.new_ColorMap(null); - SWIGTYPE_p_FrameBuffer f = simple.new_FrameBuffer(400,400); - - // Clear the picture - simple.FrameBuffer_clear(f,(short)simple.BLACK); - - // Make a red box - simple.FrameBuffer_box(f,40,40,200,200,(short)simple.RED); - - // Make a blue circle - simple.FrameBuffer_circle(f,200,200,40,(short)simple.BLUE); - - // Make green line - simple.FrameBuffer_line(f,10,390,390,200, (short)simple.GREEN); - - // Write an image out to disk - - simple.FrameBuffer_writeGIF(f,cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - - simple.delete_FrameBuffer(f); - simple.delete_ColorMap(cmap); - } -} diff --git a/Examples/GIFPlot/Java/simple/simple.i b/Examples/GIFPlot/Java/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Java/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Lib/Makefile.in b/Examples/GIFPlot/Lib/Makefile.in deleted file mode 100644 index 9db828eb2..000000000 --- a/Examples/GIFPlot/Lib/Makefile.in +++ /dev/null @@ -1,22 +0,0 @@ -CC = @CC@ -CCSHARED= @CCSHARED@ -INCLUDES= -I../Include -CFLAGS = -O -SRCS = frame.c color.c plot2d.c plot3d.c font.c pixmap.c matrix.c gif.c -OBJS = $(SRCS:.c=.@OBJEXT@) -AR = @AR@ -RANLIB = @RANLIB@ -TARGET = ../libgifplot.a - -.c.@OBJEXT@: - $(CC) $(CCSHARED) $(INCLUDES) $(CFLAGS) -c -o $*.@OBJEXT@ $< - -all: $(OBJS) - @rm -f ../libgifplot.a - $(AR) cr $(TARGET) $(OBJS) - $(RANLIB) $(TARGET) - -clean: - rm -f *.@OBJEXT@ *~ $(TARGET) - -check: all diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c deleted file mode 100644 index a4eaf285e..000000000 --- a/Examples/GIFPlot/Lib/color.c +++ /dev/null @@ -1,140 +0,0 @@ -/* ----------------------------------------------------------------------------- - * color.c - * - * Colormaps - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define COLORMAP -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - ColorMap *new_ColorMap(char *filename) - - Read a colormap from a file. - ------------------------------------------------------------------------ */ - -ColorMap *new_ColorMap(char *filename) { - ColorMap *c; - FILE *cm; - void ColorMap_default(ColorMap *); - - if (!filename) { - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - c->name = 0; - ColorMap_default(c); - return c; - } - if (strlen(filename) == 0) { - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - ColorMap_default(c); - return c; - } - if ((cm = fopen(filename,"rb")) == NULL) { - return (ColorMap *) 0; - } - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - if (fread(c->cmap, 768, 1, cm) != 1) { - free((char *)c->cmap); - free((char *)c); - fclose(cm); - return (ColorMap *) 0; - } - fclose(cm); - c->name = (char *) malloc(strlen(filename)+1); - strcpy(c->name, filename); - ColorMap_default(c); - return c; -} - -/* -------------------------------------------------------------------------- - delete_ColorMap(ColorMap *cm) - - Destroy a ColorMap - -------------------------------------------------------------------------- */ - -void delete_ColorMap(ColorMap *cm) { - if (cm) { - free((char *)cm->cmap); - if (cm->name) - free((char *)cm->name); - free((char *)cm); - } -} - -/* -------------------------------------------------------------------------- - ColorMap_default(ColorMap *cm) - - This function fills in default values for the first 8 entries of the - colormap. These are *fixed* values---used internally. - -------------------------------------------------------------------------- */ - -void ColorMap_default(ColorMap *cm) { - unsigned char *r,*g,*b; - if (cm) { - r = cm->cmap; - g = cm->cmap+256; - b = cm->cmap+512; - - r[0] = 0; g[0] = 0; b[0] = 0; /* BLACK */ - r[1] = 255; g[1] = 255; b[1] = 255; /* WHITE */ - r[2] = 255; g[2] = 0; b[2] = 0; /* RED */ - r[3] = 0; g[3] = 255; b[3] = 0; /* GREEN */ - r[4] = 0; g[4] = 0; b[4] = 255; /* BLUE */ - r[5] = 255; g[5] = 255; b[5] = 0; /* YELLOW */ - r[6] = 0; g[6] = 255; b[6] = 255; /* CYAN */ - r[7] = 255; g[7] = 0; b[7] = 255; /* MAGENTA */ - } -} - -void ColorMap_assign(ColorMap *cm, int index, int r, int g, int b) { - unsigned char *rb,*gb,*bb; - - rb = cm->cmap; - gb = cm->cmap+256; - bb = cm->cmap+512; - - rb[index] = r; - gb[index] = g; - bb[index] = b; -} - -int ColorMap_getitem(ColorMap *cm, int index) { - if ((index < 0) && (index >= 768)) return -1; - return cm->cmap[index]; -} - -void ColorMap_setitem(ColorMap *cm, int index, int value) { - if ((index < 0) && (index >= 768)) return; - cm->cmap[index]=value; -} - -/* -------------------------------------------------------------------- - ColorMap_write(ColorMap *cm, char *filename) - - Write out a colormap to disk. - -------------------------------------------------------------------- */ - -int ColorMap_write(ColorMap *cm, char *filename) { - - FILE *f; - if (!cm) return -1; - if (!filename) return -1; - if (strlen(filename) == 0) return -1; - - f = fopen(filename,"w"); - - fwrite(cm->cmap,768,1,f); - fclose(f); - return 0; -} - -#undef COLORMAP diff --git a/Examples/GIFPlot/Lib/font.c b/Examples/GIFPlot/Lib/font.c deleted file mode 100644 index b30ee9b14..000000000 --- a/Examples/GIFPlot/Lib/font.c +++ /dev/null @@ -1,705 +0,0 @@ -/* ----------------------------------------------------------------------------- - * font.c - * - * Some basic fonts. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define FONT -#include "gifplot.h" - -static char Char_A[80] = "\ -...x....\ -...x....\ -..x.x...\ -..x.x...\ -.x...x..\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -........"; - -static char Char_B[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -........"; - -static char Char_C[80] = "\ -..xxxx..\ -.x....x.\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -.x....x.\ -..xxxx..\ -........"; - -static char Char_D[80] = "\ -xxxxx...\ -x....x..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x....x..\ -xxxxx...\ -........"; -static char Char_E[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxx...\ -x.......\ -x.......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_F[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxx...\ -x.......\ -x.......\ -x.......\ -x.......\ -........"; -static char Char_G[80] = "\ -.xxxxx..\ -x.....x.\ -x.......\ -x.......\ -x...xxx.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_H[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxxx.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -........"; -static char Char_I[80] = "\ -xxxxxxx.\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -xxxxxxx.\ -........"; -static char Char_J[80] = "\ -......x.\ -......x.\ -......x.\ -......x.\ -......x.\ -......x.\ -x.....x.\ -.x...x..\ -..xxx...\ -........"; -static char Char_K[80] = "\ -x.....x.\ -x....x..\ -x...x...\ -x..x....\ -xxx.....\ -x..x....\ -x...x...\ -x....x..\ -x.....x.\ -........"; -static char Char_L[80] = "\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_M[80] = "\ -x.....x.\ -xx...xx.\ -xx...xx.\ -x.x.x.x.\ -x.x.x.x.\ -x..x..x.\ -x..x..x.\ -x.....x.\ -x.....x.\ -........"; -static char Char_N[80] = "\ -x.....x.\ -xx....x.\ -x.x...x.\ -x.x...x.\ -x..x..x.\ -x...x.x.\ -x...x.x.\ -x....xx.\ -x.....x.\ -........"; -static char Char_O[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_P[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x.......\ -x.......\ -x.......\ -x.......\ -........"; -static char Char_Q[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x...x.x.\ -x....x..\ -.xxxx.x.\ -........"; -static char Char_R[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x..x....\ -x...x...\ -x....x..\ -x.....x.\ -........"; -static char Char_S[80] = "\ -.xxxxx..\ -x.....x.\ -x.......\ -x.......\ -.xxxxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_T[80] = "\ -xxxxxxx.\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_U[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_V[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -.x...x..\ -..x.x...\ -..x.x...\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_W[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x..x..x.\ -x..x..x.\ -x.x.x.x.\ -.x...x..\ -........"; -static char Char_X[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -..x.x...\ -...x....\ -..x.x...\ -.x...x..\ -x.....x.\ -x.....x.\ -........"; -static char Char_Y[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -..x.x...\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_Z[80] = "\ -xxxxxxx.\ -......x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_0[80] = "\ -.xxxxx..\ -x....xx.\ -x...x.x.\ -x..x..x.\ -x..x..x.\ -x.x...x.\ -x.x...x.\ -xx....x.\ -.xxxxx..\ -........"; -static char Char_1[80] = "\ -...x....\ -..xx....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -..xxx...\ -........"; -static char Char_2[80] = "\ -..xxxx..\ -.x....x.\ -x.....x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -xxxxxxx.\ -........"; -static char Char_3[80] = "\ -.xxxxx..\ -x.....x.\ -......x.\ -......x.\ -...xxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_4[80] = "\ -....xx..\ -...x.x..\ -..x..x..\ -.x...x..\ -xxxxxxx.\ -.....x..\ -.....x..\ -.....x..\ -.....x..\ -........"; -static char Char_5[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_6[80] = "\ -....xxx.\ -..xx....\ -.x......\ -x.......\ -x.xxx...\ -xx...x..\ -x.....x.\ -.x...x..\ -..xxx...\ -........"; -static char Char_7[80] = "\ -xxxxxxx.\ -x.....x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -x.......\ -........"; -static char Char_8[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_9[80] = "\ -..xxxx..\ -.x....x.\ -x.....x.\ -x....xx.\ -.xxxx.x.\ -......x.\ -......x.\ -....xx..\ -.xxx....\ -........"; -static char Char_MINUS[80] = "\ -........\ -........\ -........\ -........\ -.xxxxxx.\ -........\ -........\ -........\ -........\ -........"; -static char Char_PLUS[80] = "\ -........\ -........\ -...x....\ -...x....\ -.xxxxx..\ -...x....\ -...x....\ -........\ -........\ -........"; -static char Char_EQUAL[80] = "\ -........\ -........\ -........\ -.xxxxx..\ -........\ -.xxxxx..\ -........\ -........\ -........\ -........"; -static char Char_LPAREN[80] = "\ -....x...\ -...x....\ -..x.....\ -.x......\ -.x......\ -.x......\ -..x.....\ -...x....\ -....x...\ -........"; -static char Char_RPAREN[80] = "\ -...x....\ -....x...\ -.....x..\ -......x.\ -......x.\ -......x.\ -.....x..\ -....x...\ -...x....\ -........"; -static char Char_QUOTE[80] = "\ -..x.x...\ -..x.x...\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........"; -static char Char_COLON[80] = "\ -........\ -........\ -...xx...\ -...xx...\ -........\ -...xx...\ -...xx...\ -........\ -........\ -........"; -static char Char_PERIOD[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -...xx...\ -...xx...\ -........"; -static char Char_COMMA[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -...xx...\ -...xx...\ -....x...\ -...x...."; - -static char Char_SLASH[80] = "\ -........\ -......x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -........\ -........"; - -static char Char_SPACE[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........"; - -static char *GP_Font[128]; -static int InitGP_Font = 0; - -static void initGP_Fonts(void) { - - int i; - for (i = 0; i < 128; i++) - GP_Font[i] = (char *) 0; - - GP_Font['A'] = GP_Font['a'] = Char_A; - GP_Font['B'] = GP_Font['b'] = Char_B; - GP_Font['C'] = GP_Font['c'] = Char_C; - GP_Font['D'] = GP_Font['d'] = Char_D; - GP_Font['E'] = GP_Font['e'] = Char_E; - GP_Font['F'] = GP_Font['f'] = Char_F; - GP_Font['G'] = GP_Font['g'] = Char_G; - GP_Font['H'] = GP_Font['h'] = Char_H; - GP_Font['I'] = GP_Font['i'] = Char_I; - GP_Font['J'] = GP_Font['j'] = Char_J; - GP_Font['K'] = GP_Font['k'] = Char_K; - GP_Font['L'] = GP_Font['l'] = Char_L; - GP_Font['M'] = GP_Font['m'] = Char_M; - GP_Font['N'] = GP_Font['n'] = Char_N; - GP_Font['O'] = GP_Font['o'] = Char_O; - GP_Font['P'] = GP_Font['p'] = Char_P; - GP_Font['Q'] = GP_Font['q'] = Char_Q; - GP_Font['R'] = GP_Font['r'] = Char_R; - GP_Font['S'] = GP_Font['s'] = Char_S; - GP_Font['T'] = GP_Font['t'] = Char_T; - GP_Font['U'] = GP_Font['u'] = Char_U; - GP_Font['V'] = GP_Font['v'] = Char_V; - GP_Font['W'] = GP_Font['w'] = Char_W; - GP_Font['X'] = GP_Font['x'] = Char_X; - GP_Font['Y'] = GP_Font['y'] = Char_Y; - GP_Font['Z'] = GP_Font['z'] = Char_Z; - GP_Font['0'] = Char_0; - GP_Font['1'] = Char_1; - GP_Font['2'] = Char_2; - GP_Font['3'] = Char_3; - GP_Font['4'] = Char_4; - GP_Font['5'] = Char_5; - GP_Font['6'] = Char_6; - GP_Font['7'] = Char_7; - GP_Font['8'] = Char_8; - GP_Font['9'] = Char_9; - GP_Font['.'] = Char_PERIOD; - GP_Font[','] = Char_COMMA; - GP_Font['='] = Char_EQUAL; - GP_Font['-'] = Char_MINUS; - GP_Font['+'] = Char_PLUS; - GP_Font['\"'] = Char_QUOTE; - GP_Font['('] = Char_LPAREN; - GP_Font[')'] = Char_RPAREN; - GP_Font[':'] = Char_COLON; - GP_Font['/'] = Char_SLASH; - GP_Font[' '] = Char_SPACE; - InitGP_Font = 1; -} - -/* ----------------------------------------------------------------------- - void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, Pixel fgcolor, Pixel bgcolor, char chr, int orientation) - - Draws a character at location x, y with given color and orientation parameters. - Orientation can either be HORIZONTAL or VERTICAL - ----------------------------------------------------------------------- */ -void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, int fgcolor, - int bgcolor, char chr, int orientation) { - - Pixel c, bc,*p,*p1; - char *ch; - int i,j; - int xpixels,ypixels; - - if (!InitGP_Font) initGP_Fonts(); - - c = (Pixel) fgcolor; - bc = (Pixel) bgcolor; - xpixels = f->width; - ypixels = f->height; - - if (orientation == HORIZONTAL) { - if ((x < f->xmin) || (x > f->xmax-8) || - (y < f->ymin) || (y > f->ymax-10)) return; - - ch = GP_Font[(int) chr]; - if (!ch) return; - p = &f->pixels[y+9][x]; - for (i = 0; i < 10; i++) { - p1 = p; - for (j = 0; j< 8; j++) { - if (*(ch++) == 'x') *p= c; - else if (bgcolor >= 0) - *p = bc; - p++; - } - p = (p1 - xpixels); - } - } else { - if ((x < f->xmin+10) || (x >= f->xmax) || - (y < f->ymin) || (y > f->ymax-8)) return; - - ch = GP_Font[(int) chr]; - if (!ch) return; - p = &f->pixels[y][x-9]; - for (i = 0; i < 10; i++) { - p1 = p; - for (j = 0; j< 8; j++) { - if (*(ch++) == 'x') *p= c; - else if (bgcolor >= 0) - *p = bc; - p+=xpixels; - } - p = p1 + 1; - } - } -} - -/* ---------------------------------------------------------------------- - void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, - int bgcolor, char *text, int orientation) - - Draws an ASCII string on the framebuffer. Can be oriented either horizontally - or vertically. - ---------------------------------------------------------------------- */ - -void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation) { - - char *c; - int x1, y1; - int xpixels, ypixels; - - x1 = x; - y1 = y; - xpixels = f->width; - ypixels = f->height; - c = text; - while (*c) { - if (*c == '\n') { - if (orientation == HORIZONTAL) { - x1 = x; y1= y1- 10*xpixels; - } else { - y1 = y; x1= x1 + 10*ypixels; - } - } else { - FrameBuffer_drawchar(f, x1,y1,fgcolor, bgcolor,*c, orientation); - if (orientation == HORIZONTAL) { - x1+=8; - if (x1 >= (xpixels-8)) { - x1 = x; y1= y1- 10;} - if (y1 < 0) return; - } else { - y1 += 8; - if (y1 >= (ypixels-8)) { - y1 = y; x1 = x1 + 10;} - if (x1 > (xpixels-10)) return; - } - } - c++; - } -} - - - - - - - - diff --git a/Examples/GIFPlot/Lib/frame.c b/Examples/GIFPlot/Lib/frame.c deleted file mode 100644 index e006f0daf..000000000 --- a/Examples/GIFPlot/Lib/frame.c +++ /dev/null @@ -1,924 +0,0 @@ -/* ----------------------------------------------------------------------------- - * frame.c - * - * Frame buffer management - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define FRAME -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - FrameBuffer *new_FrameBuffer(int width, int height) - - Creates a new framebuffer for storing data. - ------------------------------------------------------------------------ */ - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height) { - - FrameBuffer *f; - int FrameBuffer_resize(FrameBuffer *f, int width, int height); - - /* Create a new frame buffer */ - - f = (FrameBuffer *) malloc(sizeof(FrameBuffer)); - f->pixels = (Pixel **) 0; - f->zbuffer = (Zvalue **) 0; - /* Set its size */ - - if (FrameBuffer_resize(f, width, height) == -1) { - free((char *) f); - return (FrameBuffer *) 0; - } - - f->xmin = 0; - f->ymin = 0; - f->xmax = width; - f->ymax = height; - return f; -} - -/* ------------------------------------------------------------------------ - void delete_FrameBuffer(FrameBuffer *f) - - Destroys the given framebuffer - ------------------------------------------------------------------------ */ - -void delete_FrameBuffer(FrameBuffer *f) { - - if (f) { - if (f->pixels) { - free((char *) f->pixels[0]); - free((char *) f->pixels); - } - if (f->zbuffer) { - free((char *) f->zbuffer[0]); - free((char *) f->zbuffer); - } - free((char *)f); - } -} - -/* ------------------------------------------------------------------------ - int *FrameBuffer_resize(FrameBuffer *f, int width, int height) - - Resize the given framebuffer. Returns 0 on success, -1 on failure. - ------------------------------------------------------------------------ */ - -int FrameBuffer_resize(FrameBuffer *f, int width, int height) { - int i; - if ((f) && (width > 0) && (height > 0)) { - if (f->pixels) { - free((char *)f->pixels[0]); - free((char *)f->pixels); - } - f->pixels = (Pixel **) malloc (height*sizeof(Pixel *)); - if (!f->pixels) return -1; - f->pixels[0] = (Pixel *) malloc(height*width*sizeof(Pixel)); - if (!f->pixels[0]) { - free((char *)f->pixels); - return -1; - } - for (i = 0; i < height; i++) - f->pixels[i] = f->pixels[0] + i*width; - f->width = width; - f->height = height; - if (f->zbuffer) { - FrameBuffer_zresize(f,width,height); - } - return 0; - } else { - return -1; - } -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_clear(FrameBuffer *f, Pixel color) - - Clears the current FrameBuffer - ------------------------------------------------------------------------ */ - -void FrameBuffer_clear(FrameBuffer *f, Pixel color) { - Pixel *p; - unsigned int i; - p = &f->pixels[0][0]; - - for (i = 0; i < f->width*f->height; i++, p++) - *p = color; -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) - - Plots a point and does a bounds check. - ------------------------------------------------------------------------ */ - -void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) { - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax)) - return; - f->pixels[y1][x1] = color; - -} - -/* ------------------------------------------------------------------------ - FrameBuffer_horizontal(Framebuffer *f, int xmin, int xmax, int y, Pixel color) - - Draw a horizontal line (clipped) - ------------------------------------------------------------------------ */ - -void FrameBuffer_horizontal(FrameBuffer *f, int xmin, int xmax, int y, Pixel color) { - - Pixel *p; - int i; - - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin < f->xmin) xmin = f->xmin; - if (xmax >= f->xmax) xmax = f->xmax - 1; - - p = &f->pixels[y][xmin]; - for (i = xmin; i <= xmax; i++, p++) - *p = color; - -} - -/* ------------------------------------------------------------------------ - FrameBuffer_horizontalinterp(Framebuffer *f, int xmin, int xmax, int y, - Pixel c1, Pixel c2) - - Draw a horizontal line (clipped) with color interpolation. - ------------------------------------------------------------------------ */ - -void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, - Pixel c1, Pixel c2) { - - Pixel *p; - int i; - double mc; - int x1; - if ((y < f->ymin) || (y >= f->ymax)) return; - - x1 = xmin; - if (xmin < f->xmin) xmin = f->xmin; - if (xmax >= f->xmax) xmax = f->xmax - 1; - if (xmax < f->xmin) return; - if (xmin >= f->xmax) return; - - if (xmin != xmax) - mc = (double)(c2 - c1)/(double) (xmax - xmin); - else - mc = 0.0; - - p = &f->pixels[y][xmin]; - for (i = xmin; i <= xmax; i++, p++) - *p = (Pixel) (mc*(i-x1) + c1); - -} - - -/* ------------------------------------------------------------------------ - FrameBuffer_vertical(Framebuffer *f, int xmin, int xmax, int y, Pixel color) - - Draw a Vertical line (clipped) - ------------------------------------------------------------------------ */ - -void FrameBuffer_vertical(FrameBuffer *f, int ymin, int ymax, int x, Pixel color) { - - Pixel *p; - int i; - - if ((x < f->xmin) || (x >= f->xmax)) return; - if (ymax < f->ymin) return; - if (ymin > f->ymax) return; - if (ymin < f->ymin) ymin = f->ymin; - if (ymax >= f->ymax) ymax = f->ymax - 1; - - p = &f->pixels[ymin][x]; - for (i = 0; i <= (ymax - ymin); i++, p+=f->width) - *p = color; - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) - - Makes an outline box. - ------------------------------------------------------------------------ */ - -void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { - - int xt, yt; - - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - } - - /* Draw lower edge */ - - FrameBuffer_horizontal(f,x1,x2,y1,color); - - /* Draw upper edge */ - - FrameBuffer_horizontal(f,x1,x2,y2,color); - - /* Draw left side */ - - FrameBuffer_vertical(f,y1,y2,x1,color); - - /* Draw right side */ - - FrameBuffer_vertical(f,y1,y2,x2,color); - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) - - Makes an solid box. - ------------------------------------------------------------------------ */ - -void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { - - int xt, yt; - - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - } - - /* Now perform some clipping */ - - if (y1 < f->ymin) y1 = f->ymin; - if (y2 >= f->ymax) y2 = f->ymax - 1; - - /* Fill it in using horizontal lines */ - - for (yt = y1; yt <= y2; yt++) - FrameBuffer_horizontal(f,x1,x2,yt,color); - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2 - Pixel c1, Pixel c2, Pixel c3, Pixel c4) - - Makes a box with interpolated color. Colors are assigned as follows : - (x1,y1) = c1 - (x1,y2) = c2 - (x2,y1) = c3 - (x2,y2) = c4 - ------------------------------------------------------------------------ */ - -void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) { - - int xt, yt; - Pixel ct; - double mc1,mc2; - int ystart; - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - ct = c1; - c1 = c3; - c3 = ct; - ct = c2; - c2 = c4; - c4 = ct; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - ct = c1; - c1 = c2; - c2 = ct; - ct = c3; - c3 = c4; - c4 = ct; - } - - /* Now perform some clipping */ - - ystart = y1; - mc1 = (double) (c2 - c1)/(double) (y2 - y1); - mc2 = (double) (c4 - c3)/(double) (y2 - y1); - if (y1 < f->ymin) y1 = f->ymin; - if (y2 >= f->ymax) y2 = f->ymax - 1; - - /* Fill it in using horizontal lines */ - - for (yt = y1; yt <= y2; yt++) - FrameBuffer_horizontalinterp(f,x1,x2,yt,(Pixel) ((mc1*(yt - ystart)) + c1), - (Pixel) ((mc2*(yt-ystart))+c3)); - -} - -/* --------------------------------------------------------------------------- - FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, color) - - Draws a line on the framebuffer using the Bresenham line algorithm. The - line is clipped to fit within the current view window. - ---------------------------------------------------------------------------- */ - -void FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c) { - - int dx,dy,dxneg,dyneg, inc1,inc2,di; - int x, y, xpixels, ypixels, xt, yt; - Pixel *p; - double m; - int end1 = 0, end2 = 0; - - /* Need to figure out where in the heck this line is */ - - dx = x2 - x1; - dy = y2 - y1; - - if (dx == 0) { - /* Draw a Vertical Line */ - if (y1 < y2) - FrameBuffer_vertical(f,y1,y2,x1,c); - else - FrameBuffer_vertical(f,y2,y1,x1,c); - return; - } - if (dy == 0) { - /* Draw a Horizontal Line */ - if (x1 < x2) - FrameBuffer_horizontal(f,x1,x2,y1,c); - else - FrameBuffer_horizontal(f,x2,x1,y1,c); - return; - } - - /* Figure out where in the heck these lines are using the - Cohen-Sutherland Line Clipping Scheme. */ - - end1 = ((x1 - f->xmin) < 0) | - (((f->xmax- 1 - x1) < 0) << 1) | - (((y1 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y1) < 0) << 3); - - end2 = ((x2 - f->xmin) < 0) | - (((f->xmax-1 - x2) < 0) << 1) | - (((y2 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y2) < 0) << 3); - - if (end1 & end2) return; /* Nope : Not visible */ - - /* Make sure points have a favorable orientation */ - - if (x1 > x2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - } - - /* Clip against the boundaries */ - m = (y2 - y1)/(double) (x2-x1); - if (x1 < f->xmin) { - y1 = (int) ((f->xmin - x1)*m + y1); - x1 = (int) f->xmin; - } - if (x2 >= f->xmax) { - y2 = (int) ((f->xmax -1 -x1)*m + y1); - x2 = (int) (f->xmax - 1); - } - - if (y1 > y2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - } - - m = 1/m; - if (y1 < f->ymin) { - x1 = (int) ((f->ymin - y1)*m + x1); - y1 = (int) f->ymin; - } - if (y2 >= f->ymax) { - x2 = (int) ((f->ymax-1-y1)*m + x1); - y2 = (int) (f->ymax-1); - } - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || - (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; - - dx = x2 - x1; - dy = y2 - y1; - xpixels = f->width; - ypixels = f->height; - - dxneg = (dx < 0) ? 1 : 0; - dyneg = (dy < 0) ? 1 : 0; - - dx = abs(dx); - dy = abs(dy); - if (dx >= dy) { - /* Slope between -1 and 1. */ - if (dxneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dyneg = !dyneg; - } - inc1 = 2*dy; - inc2 = 2*(dy-dx); - di = 2*dy-dx; - - /* Draw a line using x as independent variable */ - - p = &f->pixels[y1][x1]; - x = x1; - while (x <= x2) { - *(p++) = c; - if (di < 0) { - di = di + inc1; - } else { - if (dyneg) { - p = p - xpixels; - di = di + inc2; - } else { - p = p + xpixels; - di = di + inc2; - } - } - x++; - } - } else { - /* Slope < -1 or > 1 */ - if (dyneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dxneg = !dxneg; - } - inc1 = 2*dx; - inc2 = 2*(dx-dy); - di = 2*dx-dy; - - /* Draw a line using y as independent variable */ - - p = &f->pixels[y1][x1]; - y = y1; - while (y <= y2) { - *p = c; - p = p + xpixels; - if (di < 0) { - di = di + inc1; - } else { - if (dxneg) { - p = p - 1; - di = di + inc2; - } else { - p = p + 1; - di = di + inc2; - } - } - y++; - } - } -} - - -/* ------------------------------------------------------------------------- - FrameBuffer_circle(FrameBuffer f, int xc, int yc, int radius, Pixel c) - - Create an outline circle - ------------------------------------------------------------------------- */ - -#define plot_circle(x,y,c) \ - if ((x >= xmin) && (x < xmax) && \ - (y >= ymin) && (y < ymax)) \ - pixels[y][x] = c; - -void FrameBuffer_circle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { - - int xpixels, ypixels, x, y, p; - int xmin, ymin, xmax, ymax; - Pixel **pixels; - - if (radius <= 0) return; - xpixels = f->width; - ypixels = f->height; - pixels = f->pixels; - xmin = f->xmin; - ymin = f->ymin; - xmax = f->xmax; - ymax = f->ymax; - x = 0; - y = radius; - p = 3-2*radius; - while (x <= y) { - plot_circle(xc+x,yc+y,c); - plot_circle(xc-x,yc+y,c); - plot_circle(xc+x,yc-y,c); - plot_circle(xc-x,yc-y,c); - plot_circle(xc+y,yc+x,c); - plot_circle(xc-y,yc+x,c); - plot_circle(xc+y,yc-x,c); - plot_circle(xc-y,yc-x,c); - if (p < 0) p = p + 4*x + 6; - else { - p = p + 4*(x-y) + 10; - y = y -1; - } - x++; - } -} - - -/* ------------------------------------------------------------------------- - FrameBuffer_solidcircle(FrameBuffer f, int xc, int yc, int radius, Pixel c) - - Create an filled circle - ------------------------------------------------------------------------- */ - - -#define fill_circle(x,y,c) \ - x1 = xc - x; \ - x2 = xc + x; \ - FrameBuffer_horizontal(f,x1,x2,y,c); - -void FrameBuffer_solidcircle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { - - int xpixels, ypixels, x, y, p; - int x1,x2; - int xmin, ymin, xmax, ymax; - Pixel **pixels; - - if (radius <= 0) return; - xpixels = f->width; - ypixels = f->height; - pixels = f->pixels; - xmin = f->xmin; - ymin = f->ymin; - xmax = f->xmax; - ymax = f->ymax; - x = 0; - y = radius; - p = 3-2*radius; - while (x <= y) { - fill_circle(x,yc+y,c); - fill_circle(x,yc-y,c); - fill_circle(y,yc+x,c); - fill_circle(y,yc-x,c); - if (p < 0) p = p + 4*x + 6; - else { - p = p + 4*(x-y) + 10; - y = y -1; - } - x++; - } -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_setclip(f,xmin,ymin,xmax,ymax) - - Set clipping region for plotting - ------------------------------------------------------------------------ */ - -void FrameBuffer_setclip(FrameBuffer *f, int xmin, int ymin, int xmax, int ymax) { - - if (xmin >= xmax) return; - if (ymin >= ymax) return; - - if (xmin < 0) xmin = 0; - if (ymin < 0) ymin = 0; - if (xmax > (int) f->width) xmax = f->width; - if (ymax > (int) f->height) ymax = f->height; - - f->xmin = xmin; - f->ymin = ymin; - f->xmax = xmax; - f->ymax = ymax; -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_noclip(f) - - Disable clipping region - ------------------------------------------------------------------------ */ - -void FrameBuffer_noclip(FrameBuffer *f) { - f->xmin = 0; - f->ymin = 0; - f->xmax = f->width; - f->ymax = f->height; -} - - -/* ------------------------------------------------------------------------ - FrameBuffer_zresize(FrameBuffer *f, int width, int height) - - This function resizes the framebuffer's zbuffer. If none exist, it - creates a new one. - ------------------------------------------------------------------------ */ - -void FrameBuffer_zresize(FrameBuffer *f, int width, int height) { - int i; - - if (f->zbuffer) { - free((char *)f->zbuffer[0]); - free((char *)f->zbuffer); - } - f->zbuffer = (Zvalue **) malloc(height*sizeof(Zvalue *)); - f->zbuffer[0] = (Zvalue *) malloc(height*width*sizeof(Zvalue)); - for (i = 0; i < height; i++) - f->zbuffer[i] = f->zbuffer[0]+i*width; -} - -/* ------------------------------------------------------------------------ - FrameBuffer_zclear(FrameBuffer *f) - - Clears the z-buffer for a particular frame. Sets all of the z-values to - ZMIN. - ------------------------------------------------------------------------- */ - -void FrameBuffer_zclear(FrameBuffer *f) { - unsigned int i,j; - if (f) { - if (f->zbuffer) { - for (i = 0; i < f->width; i++) - for (j = 0; j < f->height; j++) - f->zbuffer[j][i] = ZMIN; - } - } -} - - - -/* ------------------------------------------------------------------------- - FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty2, - int tx2, int ty2, - int tx3, int ty3, Pixel color) - - This function draws a 2D filled triangle. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - -------------------------------------------------------------------------- */ - -void FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty1, - int tx2, int ty2, - int tx3, int ty3, Pixel color) { - int tempx, tempy; - double m1,m2,m3; - int y; - int ix1, ix2; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tx1 = tx2; - ty1 = ty2; - tx2 = tempx; - ty2 = tempy; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tx1 = tx3; - ty1 = ty3; - tx3 = tempx; - ty3 = tempy; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tx2 = tx3; - ty2 = ty3; - tx3 = tempx; - ty3 = tempy; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - FrameBuffer_line(f,tx1,ty1,tx2,ty2,color); - FrameBuffer_line(f,tx1,ty1,tx3,ty3,color); - FrameBuffer_line(f,tx2,ty2,tx3,ty3,color); - - } else { - - if (ty2 < ty1) { - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - if (ix1 > ix2) - FrameBuffer_horizontal(f,ix2,ix1,y,color); - else - FrameBuffer_horizontal(f,ix1,ix2,y,color); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - if (ix1 > ix2) - FrameBuffer_horizontal(f,ix2,ix1,y,color); - else - FrameBuffer_horizontal(f,ix1,ix2,y,color); - y--; - } - } - } -} - -/* ------------------------------------------------------------------------- - FrameBuffer_interptriangle(FrameBuffer *f, - int tx1, int ty2, Pixel c1, - int tx2, int ty2, Pixel c2, - int tx3, int ty3, Pixel c3) - - This function draws a filled triangle with color - interpolation. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - 5. Colors are interpolated between end points - -------------------------------------------------------------------------- */ - -void FrameBuffer_interptriangle(FrameBuffer *f, - int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, - int tx3, int ty3, Pixel c3) { - int tempx, tempy; - double m1,m2,m3; - double mc1,mc2,mc3; - Pixel ic1,ic2,tempc; - int y; - int ix1, ix2; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempc = c1; - tx1 = tx2; - ty1 = ty2; - c1 = c2; - tx2 = tempx; - ty2 = tempy; - c2 = tempc; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempc = c1; - tx1 = tx3; - ty1 = ty3; - c1 = c3; - tx3 = tempx; - ty3 = tempy; - c3 = tempc; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempc = c2; - tx2 = tx3; - ty2 = ty3; - c2 = c3; - tx3 = tempx; - ty3 = tempy; - c3 = tempc; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - if (tx2 > tx1) - FrameBuffer_horizontalinterp(f,tx1,tx2,ty1,c1,c2); - else - FrameBuffer_horizontalinterp(f,tx2,tx1,ty1,c2,c1); - if (tx3 > tx1) - FrameBuffer_horizontalinterp(f,tx1,tx3,ty1,c1,c3); - else - FrameBuffer_horizontalinterp(f,tx3,tx1,ty1,c3,c1); - if (tx3 > tx2) - FrameBuffer_horizontalinterp(f,tx2,tx3,ty2,c2,c3); - else - FrameBuffer_horizontalinterp(f,tx3,tx2,ty2,c3,c2); - - } else { - - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - if (ty2 < ty1) { - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mc1 = (c2 - c1)/(double) (ty2 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - ic1 = (int) (mc1*(y-ty1) + c1); - ic2 = (int) (mc2*(y-ty1) + c1); - if (ix1 > ix2) - FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); - else - FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mc3 = (c3 - c2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - ic1 = (int) (mc3*(y-ty2)+c2); - ic2 = (int) (mc2*(y-ty1)+c1); - if (ix1 > ix2) - FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); - else - FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); - y--; - } - } - } -} - - diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c deleted file mode 100644 index a0cfca1d5..000000000 --- a/Examples/GIFPlot/Lib/gif.c +++ /dev/null @@ -1,668 +0,0 @@ - -/********************************************************************** - * GIFPlot 0.0 - * - * Dave Beazley - * - * Department of Computer Science Theoretical Division (T-11) - * University of Utah Los Alamos National Laboratory - * Salt Lake City, Utah 84112 Los Alamos, New Mexico 87545 - * beazley@cs.utah.edu beazley@lanl.gov - * - * Copyright (c) 1996 - * The Regents of the University of California and the University of Utah - * All Rights Reserved - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that - * (1) The above copyright notice and the following two paragraphs - * appear in all copies of the source code and (2) redistributions - * including binaries reproduces these notices in the supporting - * documentation. Substantial modifications to this software may be - * copyrighted by their authors and need not follow the licensing terms - * described here, provided that the new terms are clearly indicated in - * all files where they apply. - * - * IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE - * UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL - * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, - * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH - * SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND - * THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, - * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - **************************************************************************/ - -/******************************************************************* - * Creates a GIF format file. - * - * Dave Beazley (T-11) - * August 11, 1995 - * - * Rather than writing directly to files, this module fills out - * output buffer. - * - * Note : To save memory, this routine uses approximately 50K of the - * output buffer as temporary storage (for hash tables and compression codes). - * The remainder of the output buffer is used to store the final image. - * This feature allows GIF images to be created with no additional - * memory overhead. - * - * -- Revision History - * $Log$ - * Revision 1.2 2003/09/01 16:23:31 beazley - * Restored the 'mojo'. - * - * Revision 1.2 1996/09/25 22:39:30 dmb - * Fixed prototypes and use of void pointers for compatibility with the Cray T3D - * - * Revision 1.1 1996/09/10 17:44:00 dmb - * Initial revision - * - * Revision 1.2 1995/08/31 14:46:07 beazley - * Minor changes to support comments and a few bug fixes. - * - * - ******************************************************************/ - - -/* - * xvgifwr.c - handles writing of GIF files. based on flgife.c and - * flgifc.c from the FBM Library, by Michael Maudlin - * - * Contains: - * WriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle, - * comment) - * - * Note: slightly brain-damaged, in that it'll only write non-interlaced - * GIF files (in the interests of speed, or something) - * - */ - - - -/***************************************************************** - * Portions of this code Copyright (C) 1989 by Michael Mauldin. - * Permission is granted to use this file in whole or in - * part for any purpose, educational, recreational or commercial, - * provided that this copyright notice is retained unchanged. - * This software is available to all free of charge by anonymous - * FTP and in the UUNET archives. - * - * - * Authors: Michael Mauldin (mlm@cs.cmu.edu) - * David Rowley (mgardi@watdcsu.waterloo.edu) - * - * Based on: compress.c - File compression ala IEEE Computer, June 1984. - * - * Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) - * Jim McKie (decvax!mcvax!jim) - * Steve Davies (decvax!vax135!petsd!peora!srd) - * Ken Turkowski (decvax!decwrl!turtlevax!ken) - * James A. Woods (decvax!ihnp4!ames!jaw) - * Joe Orost (decvax!vax135!petsd!joe) - *****************************************************************/ - -#include "gifplot.h" -#include -typedef long int count_int; -typedef unsigned char byte; - -static int gif_error; -static unsigned char *op; -static int Width, Height; -static int curx, cury; -static int Interlace; - -static void putgifword(int); -static void compress(int, byte **, int); -static void output_GIF(int); -static void cl_block(void); -static void cl_hash(count_int); -static void char_init(void); -static void char_out(int); -static void flush_char(void); -static void *OutBuffer; -static int OutBufSize; -static FrameBuffer *GIF_frame; - -static unsigned char pc2nc[256],r1[256],g1[256],b1[256]; - -/*************************************************************/ -int FrameBuffer_makeGIF(FrameBuffer *f, ColorMap *c, void *outbuffer, unsigned int outbufsize) -{ - int RWidth, RHeight; - int LeftOfs, TopOfs; - int ColorMapSize, InitCodeSize, Background, BitsPerPixel; - int i,j,nc; - char *rmap, *gmap, *bmap; - char *cmap; - int count; - - Interlace = 0; - Background = 0; - OutBuffer = outbuffer; - OutBufSize = outbufsize; - GIF_frame = f; - cmap = (char *) c->cmap; - - op = (unsigned char *) outbuffer; - gif_error = 0; - for (i=0; i<256; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } - - /* compute number of unique colors */ - nc = 0; - rmap = &cmap[0]; - gmap = &cmap[256]; - bmap = &cmap[512]; - - for (i=0; i<256; i++) { - /* see if color #i is already used */ - for (j=0; j= nc) break; - - BitsPerPixel = i; - - ColorMapSize = 1 << BitsPerPixel; - - RWidth = Width = f->width; - RHeight = Height = f->height; - LeftOfs = TopOfs = 0; - - if (BitsPerPixel <= 1) InitCodeSize = 2; - else InitCodeSize = BitsPerPixel; - - curx = 0; - cury = f->height - 1; - - strcpy((char *) op,"GIF89a"); /* Put in GIF magic number */ - op+=6; - putgifword(RWidth); /* screen descriptor */ - putgifword(RHeight); - - i = 0x80; /* Yes, there is a color map */ - i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */ - i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ - *(op++) = i; - *(op++) = Background; /* background color */ - *(op++) = 0; - for (i=0; ipixels, f->width*f->height); - - *(op++) = 0; - *(op++) = ';'; - - count = (op - (unsigned char *) OutBuffer); - if (gif_error) return -1; - else return count; -} - -/******************************/ -static void putgifword(w) -int w; -{ - /* writes a 16-bit integer in GIF order (LSB first) */ - *(op++) = w & 0xff; - *(op++) = (w>>8)&0xff; -} - -/***********************************************************************/ - - -static unsigned long cur_accum = 0; -static int cur_bits = 0; - - - - -#define GP_BITS 12 /* BITS was already defined on some systems */ - -#define HSIZE 5003 /* 80% occupancy */ - -typedef unsigned char char_type; - -static int n_bits; /* number of bits/code */ -static int maxbits = GP_BITS; /* user settable max # bits/code */ -static int maxcode; /* maximum code, given n_bits */ -static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ - -#define MAXCODE(n_bits) ( (1 << (n_bits)) - 1) - -static count_int *htab; -static unsigned short *codetab; -static GIFOutBufSize; - -/* static count_int htab [HSIZE]; -static unsigned short codetab [HSIZE]; */ - -#define HashTabOf(i) htab[i] -#define CodeTabOf(i) codetab[i] - -static int hsize = HSIZE; /* for dynamic table sizing */ - -/* - * To save much memory, we overlay the table used by compress() with those - * used by decompress(). The tab_prefix table is the same size and type - * as the codetab. The tab_suffix table needs 2**BITS characters. We - * get this from the beginning of htab. The output stack uses the rest - * of htab, and contains characters. There is plenty of room for any - * possible stack (stack used to be 8000 characters). - */ - -#define tab_prefixof(i) CodeTabOf(i) -#define tab_suffixof(i) ((char_type *)(htab))[i] -#define de_stack ((char_type *)&tab_suffixof(1<= GIF_frame->width) { - curx = 0; - cury--; - } - len--; - - hshift = 0; - for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L ) - hshift++; - hshift = 8 - hshift; /* set hash code range bound */ - - hsize_reg = hsize; - cl_hash( (count_int) hsize_reg); /* clear hash table */ - - output_GIF(ClearCode); - while (len) { - c = pc2nc[data[cury][curx]]; - curx++; - if (curx >= GIF_frame->width) { - curx = 0; - cury--; - } - len--; - - fcode = (long) ( ( (long) c << maxbits) + ent); - i = (((int) c << hshift) ^ ent); /* xor hashing */ - - if ( HashTabOf (i) == fcode ) { - ent = CodeTabOf (i); - continue; - } - - if ( (long)HashTabOf (i) < 0 ) /* empty slot */ - goto nomatch; - - disp = hsize_reg - i; /* secondary hash (after G. Knott) */ - if ( i == 0 ) - disp = 1; - -probe: - if ( (i -= disp) < 0 ) - i += hsize_reg; - - if ( HashTabOf (i) == fcode ) { - ent = CodeTabOf (i); - continue; - } - - if ( (long)HashTabOf (i) >= 0 ) - goto probe; - -nomatch: - output_GIF(ent); - out_count++; - ent = c; - - if ( free_ent < maxmaxcode ) { - CodeTabOf (i) = free_ent++; /* code -> hashtable */ - HashTabOf (i) = fcode; - } - else - cl_block(); - - } - /* Put out the final code */ - output_GIF(ent); - output_GIF(EOFCode); -} - - -/***************************************************************** - * TAG( output_GIF ) - * - * Output the given code. - * Inputs: - * code: A n_bits-bit integer. If == -1, then EOF. This assumes - * that n_bits =< (long)wordsize - 1. - * Outputs: - * Outputs code to the file. - * Assumptions: - * Chars are 8 bits long. - * Algorithm: - * Maintain a BITS character long buffer (so that 8 codes will - * fit in it exactly). Use the VAX insv instruction to insert each - * code in turn. When the buffer fills up empty it and start over. - */ - -static -unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, - 0x001F, 0x003F, 0x007F, 0x00FF, - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; - -static void output_GIF(code) -int code; -{ - cur_accum &= masks[cur_bits]; - - if (cur_bits > 0) - cur_accum |= ((long)code << cur_bits); - else - cur_accum = code; - - cur_bits += n_bits; - - while( cur_bits >= 8 ) { - char_out( (int) (cur_accum & 0xff) ); - cur_accum >>= 8; - cur_bits -= 8; - } - - /* - * If the next entry is going to be too big for the code size, - * then increase it, if possible. - */ - - if (free_ent > maxcode || clear_flg) { - - if( clear_flg ) { - maxcode = MAXCODE (n_bits = g_init_bits); - clear_flg = 0; - } - else { - n_bits++; - if ( n_bits == maxbits ) - maxcode = maxmaxcode; - else - maxcode = MAXCODE(n_bits); - } - } - - if( code == EOFCode ) { - /* At EOF, write the rest of the buffer */ - while( cur_bits > 0 ) { - char_out( (int)(cur_accum & 0xff) ); - cur_accum >>= 8; - cur_bits -= 8; - } - - flush_char(); - } -} - - -/********************************/ -static void cl_block () /* table clear for block compress */ -{ - /* Clear out the hash table */ - - cl_hash ( (count_int) hsize ); - free_ent = ClearCode + 2; - clear_flg = 1; - - output_GIF(ClearCode); -} - - -/********************************/ -static void cl_hash(hsize) /* reset code table */ -register count_int hsize; -{ - register count_int *htab_p = htab+hsize; - register long i; - register long m1 = -1; - - i = hsize - 16; - do { /* might use Sys V memset(3) here */ - *(htab_p-16) = m1; - *(htab_p-15) = m1; - *(htab_p-14) = m1; - *(htab_p-13) = m1; - *(htab_p-12) = m1; - *(htab_p-11) = m1; - *(htab_p-10) = m1; - *(htab_p-9) = m1; - *(htab_p-8) = m1; - *(htab_p-7) = m1; - *(htab_p-6) = m1; - *(htab_p-5) = m1; - *(htab_p-4) = m1; - *(htab_p-3) = m1; - *(htab_p-2) = m1; - *(htab_p-1) = m1; - htab_p -= 16; - } while ((i -= 16) >= 0); - - for ( i += 16; i > 0; i-- ) - *--htab_p = m1; -} - - -/****************************************************************************** - * - * GIF Specific routines - * - ******************************************************************************/ - -/* - * Number of characters so far in this 'packet' - */ -static int a_count; - -/* - * Set up the 'byte output' routine - */ -static void char_init() -{ - a_count = 0; -} - -/* - * Define the storage for the packet accumulator - */ -static char accum[ 256 ]; - -/* - * Add a character to the end of the current packet, and if it is 254 - * characters, flush the packet to disk. - */ -static void char_out(c) -int c; -{ - accum[ a_count++ ] = c; - if( a_count >= 254 ) - flush_char(); -} - -/* - * Flush the packet to disk, and reset the accumulator - */ -static void flush_char() -{ - if (gif_error) return; - if( a_count > 0 ) { - *(op++) = a_count; - memcpy(op,accum,a_count); - op+=a_count; - a_count = 0; - - if (op > (unsigned char *) ((char *) OutBuffer + (GIFOutBufSize - 2048))) { - gif_error = 1; - } - } -} - - -/* ---------------------------------------------------------------------- - int FrameBuffer_writeGIF(char *filename) - - Write a GIF file to filename - ----------------------------------------------------------------------- */ - -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { - - FILE *file; - void *buffer; - int nbytes; - int bufsize; - - file = fopen(filename,"wb"); - if (file == NULL) return -1; - - bufsize = (f->width*f->height*3)/2; - buffer = (void *) malloc(bufsize); - nbytes = FrameBuffer_makeGIF(f,c,buffer,bufsize); - if (nbytes == -1) { - free(buffer); - fclose(file); - return -1; - } - fwrite(buffer,nbytes,1,file); - fclose(file); - free(buffer); - return 0; -} - - - - - diff --git a/Examples/GIFPlot/Lib/matrix.c b/Examples/GIFPlot/Lib/matrix.c deleted file mode 100644 index ef0cf3aab..000000000 --- a/Examples/GIFPlot/Lib/matrix.c +++ /dev/null @@ -1,343 +0,0 @@ -/* ----------------------------------------------------------------------------- - * matrix.c - * - * Some 4x4 matrix operations - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define MATRIX -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - Matrix new_Matrix() - - Create a new 4x4 matrix. - ------------------------------------------------------------------------ */ -Matrix -new_Matrix() { - Matrix m; - m = (Matrix) malloc(16*sizeof(double)); - return m; -} - -/* ------------------------------------------------------------------------ - delete_Matrix(Matrix *m); - - Destroy a matrix - ------------------------------------------------------------------------ */ - -void -delete_Matrix(Matrix m) { - if (m) - free((char *) m); -} - -/* ------------------------------------------------------------------------ - Matrix Matrix_copy(Matrix a) - - Makes a copy of matrix a and returns it. - ------------------------------------------------------------------------ */ - -Matrix Matrix_copy(Matrix a) { - int i; - Matrix r = 0; - if (a) { - r = new_Matrix(); - if (r) { - for (i = 0; i < 16; i++) - r[i] = a[i]; - } - } - return r; -} - -/* ------------------------------------------------------------------------ - Matrix_multiply(Matrix a, Matrix b, Matrix c) - - Multiplies a*b = c - c may be one of the source matrices - ------------------------------------------------------------------------ */ -void -Matrix_multiply(Matrix a, Matrix b, Matrix c) { - double temp[16]; - int i,j,k; - - for (i =0; i < 4; i++) - for (j = 0; j < 4; j++) { - temp[i*4+j] = 0.0; - for (k = 0; k < 4; k++) - temp[i*4+j] += a[i*4+k]*b[k*4+j]; - } - for (i = 0; i < 16; i++) - c[i] = temp[i]; -} - -/* ------------------------------------------------------------------------ - Matrix_identity(Matrix a) - - Puts an identity matrix in matrix a - ------------------------------------------------------------------------ */ - -void -Matrix_identity(Matrix a) { - int i; - for (i = 0; i < 16; i++) a[i] = 0; - a[0] = 1; - a[5] = 1; - a[10] = 1; - a[15] = 1; -} - -/* ------------------------------------------------------------------------ - Matrix_zero(Matrix a) - - Puts a zero matrix in matrix a - ------------------------------------------------------------------------ */ -void -Matrix_zero(Matrix a) { - int i; - for (i = 0; i < 16; i++) a[i] = 0; -} - -/* ------------------------------------------------------------------------ - Matrix_transpose(Matrix a, Matrix result) - - Transposes matrix a and puts it in result. - ------------------------------------------------------------------------ */ -void -Matrix_transpose(Matrix a, Matrix result) { - double temp[16]; - int i,j; - - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - temp[4*i+j] = a[4*j+i]; - - for (i = 0; i < 16; i++) - result[i] = temp[i]; -} - - -/* ------------------------------------------------------------------------ - Matrix_gauss(Matrix a, Matrix b) - - Solves ax=b for x, using Gaussian elimination. Destroys a. - Really only used for calculating inverses of 4x4 transformation - matrices. - ------------------------------------------------------------------------ */ - -void Matrix_gauss(Matrix a, Matrix b) { - int ipiv[4], indxr[4], indxc[4]; - int i,j,k,l,ll; - int irow=0, icol=0; - double big, pivinv; - double dum; - for (j = 0; j < 4; j++) - ipiv[j] = 0; - for (i = 0; i < 4; i++) { - big = 0; - for (j = 0; j < 4; j++) { - if (ipiv[j] != 1) { - for (k = 0; k < 4; k++) { - if (ipiv[k] == 0) { - if (fabs(a[4*j+k]) >= big) { - big = fabs(a[4*j+k]); - irow = j; - icol = k; - } - } else if (ipiv[k] > 1) - return; /* Singular matrix */ - } - } - } - ipiv[icol] = ipiv[icol]+1; - if (irow != icol) { - for (l = 0; l < 4; l++) { - dum = a[4*irow+l]; - a[4*irow+l] = a[4*icol+l]; - a[4*icol+l] = dum; - } - for (l = 0; l < 4; l++) { - dum = b[4*irow+l]; - b[4*irow+l] = b[4*icol+l]; - b[4*icol+l] = dum; - } - } - indxr[i] = irow; - indxc[i] = icol; - if (a[4*icol+icol] == 0) return; - pivinv = 1.0/a[4*icol+icol]; - a[4*icol+icol] = 1.0; - for (l = 0; l < 4; l++) - a[4*icol+l] = a[4*icol+l]*pivinv; - for (l = 0; l < 4; l++) - b[4*icol+l] = b[4*icol+l]*pivinv; - for (ll = 0; ll < 4; ll++) { - if (ll != icol) { - dum = a[4*ll+icol]; - a[4*ll+icol] = 0; - for (l = 0; l < 4; l++) - a[4*ll+l] = a[4*ll+l] - a[4*icol+l]*dum; - for (l = 0; l < 4; l++) - b[4*ll+l] = b[4*ll+l] - b[4*icol+l]*dum; - } - } - } - for (l = 3; l >= 0; l--) { - if (indxr[l] != indxc[l]) { - for (k = 0; k < 4; k++) { - dum = a[4*k+indxr[l]]; - a[4*k+indxr[l]] = a[4*k+indxc[l]]; - a[4*k+indxc[l]] = dum; - } - } - } -} - -/* ------------------------------------------------------------------------ - Matrix_invert(Matrix a, Matrix inva) - - Inverts Matrix a and places the result in inva. - Relies on the Gaussian Elimination code above. (See Numerical recipes). - ------------------------------------------------------------------------ */ -void -Matrix_invert(Matrix a, Matrix inva) { - - double temp[16]; - int i; - - for (i = 0; i < 16; i++) - temp[i] = a[i]; - Matrix_identity(inva); - Matrix_gauss(temp,inva); -} - -/* ------------------------------------------------------------------------ - Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) - - Transform a vector. a*r ----> t - ------------------------------------------------------------------------ */ - -void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) { - - double rx, ry, rz, rw; - - rx = r->x; - ry = r->y; - rz = r->z; - rw = r->w; - t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; - t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; - t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; - t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; -} - -/* ------------------------------------------------------------------------ - Matrix_transform4(Matrix a, double x, double y, double z, double w, GL_Vector *t) - - Transform a vector from a point specified as 4 doubles - ------------------------------------------------------------------------ */ - -void Matrix_transform4(Matrix a, double rx, double ry, double rz, double rw, - GL_Vector *t) { - - t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; - t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; - t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; - t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; -} - -/* --------------------------------------------------------------------- - Matrix_translate(Matrix a, double tx, double ty, double tz) - - Put a translation matrix in Matrix a - ---------------------------------------------------------------------- */ - -void Matrix_translate(Matrix a, double tx, double ty, double tz) { - Matrix_identity(a); - a[3] = tx; - a[7] = ty; - a[11] = tz; - a[15] = 1; -} - -/* ----------------------------------------------------------------------- - Matrix_rotatex(Matrix a, double deg) - - Produce an x-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatex(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = 1.0; - a[5] = cos(r); - a[6] = -sin(r); - a[9] = sin(r); - a[10] = cos(r); - a[15] = 1.0; -} - -/* ----------------------------------------------------------------------- - Matrix_rotatey(Matrix a, double deg) - - Produce an y-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatey(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = cos(r); - a[2] = sin(r); - a[5] = 1.0; - a[8] = -sin(r); - a[10] = cos(r); - a[15] = 1; - -} -/* ----------------------------------------------------------------------- - Matrix_RotateZ(Matrix a, double deg) - - Produce an z-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatez(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = cos(r); - a[1] = -sin(r); - a[4] = sin(r); - a[5] = cos(r); - a[10] = 1.0; - a[15] = 1.0; -} - - -/* A debugging routine */ - -void Matrix_set(Matrix a, int i, int j, double val) { - a[4*j+i] = val; -} - -void Matrix_print(Matrix a) { - int i,j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - fprintf(stdout,"%10f ",a[4*i+j]); - } - fprintf(stdout,"\n"); - } - fprintf(stdout,"\n"); -} - diff --git a/Examples/GIFPlot/Lib/pixmap.c b/Examples/GIFPlot/Lib/pixmap.c deleted file mode 100644 index a55cf041f..000000000 --- a/Examples/GIFPlot/Lib/pixmap.c +++ /dev/null @@ -1,159 +0,0 @@ -/* ----------------------------------------------------------------------------- - * pixmap.c - * - * Pixel maps (i.e., bitmaps) - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PIXMAP -#include "gifplot.h" - -/* ----------------------------------------------------------------------- - PixMap *new_PixMap(int width, int height, int centerx, int centery) - - Create a new pixmap of given size - ----------------------------------------------------------------------- */ -PixMap *new_PixMap(int width, int height, int centerx, int centery) { - PixMap *pm; - if ((width > 0) && (height > 0)) { - pm = (PixMap *) malloc(sizeof(PixMap)); - pm->width = width; - pm->height = height; - pm->centerx = centerx; - pm->centery = centery; - pm->map = (int *) malloc(height*width*sizeof(int)); - return pm; - } - return (PixMap *) 0; -} - -/* -------------------------------------------------------------------------- - void delete_PixMap(PixMap *pm) - - Destroy a pixmap - -------------------------------------------------------------------------- */ - -void delete_PixMap(PixMap *pm) { - if (pm) { - free((char *) pm->map); - free((char *) pm); - } -} - -/* --------------------------------------------------------------------------- - void PixMap_set(PixMap *pm, int x, int y, int pix) - - Set a pixel in the bitmap - --------------------------------------------------------------------------- */ -void -PixMap_set(PixMap *pm, int x, int y, int pix) { - if ((x < 0) || (x>=pm->width)) return; - if ((y < 0) || (y>=pm->height)) return; - - pm->map[pm->width*y + x] = pix; -} - -/* ----------------------------------------------------------------------------- - void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) - - Draw a pixmap onto the framebuffer. This is somewhat optimized for speed. - ------------------------------------------------------------------------------ */ - -void -FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) { - - int startx, starty; /* Starting location on framebuffer */ - int startpixx = 0, startpixy = 0; /* Starting location in pixmap */ - int endx, endy; /* Ending location on framebuffer */ - int i,j, px, py; - int c; - - startx = x - pm->centerx; - starty = y + pm->centery; - endx = startx + pm->width; - endy = starty - pm->height; - - /* Figure out if we need to clip */ - - if (startx < f->xmin) { - startpixx = f->xmin - startx; - startx = f->xmin; - } - if (starty >= f->ymax) { - startpixy = starty - f->ymax; - starty = f->ymax-1; - } - if (endx >= f->xmax) { - endx = f->xmax-1; - } - if (endy < f->ymin) { - endy = f->ymin; - } - py = startpixy; - for (j = starty; j >= endy; j--) { - px = startpixx; - for (i = startx; i < endx; i++) { - c = pm->map[py*pm->width + px]; - switch (c) { - case GIFPLOT_FOREGROUND: - f->pixels[j][i] = fgcolor; - break; - case GIFPLOT_BACKGROUND: - f->pixels[j][i] = bgcolor; - break; - default: - break; - } - px++; - } - py++; - } -} - -/************************************************************************** - * Some common PixMaps (for plotting) - * - **************************************************************************/ - -int _SQUARE_MAP[] = { - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_SQUARE = { 8,8,4,4, _SQUARE_MAP}; - -int _TRIANGLE_MAP[] = { - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,1,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,1,1,1,0,0, - 1,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_TRIANGLE = { 8,8,4,4,_TRIANGLE_MAP}; - -int _CROSS_MAP[] = { - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 1,1,1,1,1,1,1,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_CROSS = { 8,8,4,4,_CROSS_MAP}; - - - diff --git a/Examples/GIFPlot/Lib/plot2d.c b/Examples/GIFPlot/Lib/plot2d.c deleted file mode 100644 index e78107bf1..000000000 --- a/Examples/GIFPlot/Lib/plot2d.c +++ /dev/null @@ -1,445 +0,0 @@ -/* ----------------------------------------------------------------------------- - * plot2d.c - * - * 2-Dimensional plotting - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PLOT2D - -#include "gifplot.h" - -/* ------------------------------------------------------------------------ - Plot2D *new_Plot2D(FrameBuffer *frame, xmin, ymin, xmax, ymax) - - Create a new 2D plot with given minimum and maximum coordinates. - ------------------------------------------------------------------------ */ -Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin,double xmax,double ymax) { - Plot2D *p2; - if (frame) { - if (xmax <= xmin) return (Plot2D *) 0; - if (ymax <= ymin) return (Plot2D *) 0; - p2 = (Plot2D *) malloc(sizeof(Plot2D)); - p2->frame = frame; - p2->xmin = xmin; - p2->ymin = ymin; - p2->xmax = xmax; - p2->ymax = ymax; - p2->view_xmin = 0; - p2->view_xmax = frame->width; - p2->view_ymin = 0; - p2->view_ymax = frame->height; - p2->xscale = LINEAR; - p2->yscale = LINEAR; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - return p2; - } - return (Plot2D *) 0; -} - -/* ---------------------------------------------------------------------------- - delete_Plot2D(Plot2D *p2) - - Delete a 2D plot - ---------------------------------------------------------------------------- */ -void -delete_Plot2D(Plot2D *p2) { - if (p2) - free((char *) p2); -} - -/* ----------------------------------------------------------------------------- - Plot2D *Plot2D_copy(Plot2D *p2) - - Makes a copy of the Plot2D data structure. - ----------------------------------------------------------------------------- */ - -Plot2D *Plot2D_copy(Plot2D *p2) { - Plot2D *c2; - if (p2) { - c2 = (Plot2D *) malloc(sizeof(Plot2D)); - if (c2) { - c2->frame = p2->frame; - c2->view_xmin = p2->view_xmin; - c2->view_ymin = p2->view_ymin; - c2->view_xmax = p2->view_xmax; - c2->view_ymax = p2->view_ymax; - c2->xmin = p2->xmin; - c2->ymin = p2->ymin; - c2->xmax = p2->xmax; - c2->ymax = p2->ymax; - c2->xscale = p2->xscale; - c2->yscale = p2->yscale; - c2->dx = p2->dx; - c2->dy = p2->dy; - } - return c2; - } else { - return (Plot2D *) 0; - } -} - -/* ----------------------------------------------------------------------------- - Plot2D_clear(Plot2D *p2, Pixel c) - - Clear the region assigned to this plot to the given color. - -------------------------------------------------------------------------- */ - -void Plot2D_clear(Plot2D *p2, Pixel c) { - int i,j; - for (i = p2->view_xmin; i < p2->view_xmax; i++) - for (j = p2->view_ymin; j < p2->view_ymax; j++) { - p2->frame->pixels[j][i] = c; - } -} - -/* ------------------------------------------------------------------------------ - Plot2D_setview - - Sets the plot region on the framebuffer - ------------------------------------------------------------------------------ */ - -void -Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax) { - if (p2) { - p2->view_xmin = vxmin; - p2->view_ymin = vymin; - p2->view_xmax = vxmax; - p2->view_ymax = vymax; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - FrameBuffer_setclip(p2->frame,vxmin,vymin,vxmax,vymax); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) - - Sets the plotting range. - ------------------------------------------------------------------------------- */ - -void -Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) { - if (p2) { - p2->xmin = xmin; - p2->ymin = ymin; - p2->xmax = xmax; - p2->ymax = ymax; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_setscale(Plot2D *p2, int xscale, int yscale) - - Sets the plotting scaling method - ------------------------------------------------------------------------------- */ - -void -Plot2D_setscale(Plot2D *p2, int xscale, int yscale) { - if (p2) { - p2->xscale = xscale; - p2->yscale = yscale; - } -} - -/* ---------------------------------------------------------------------------- - Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) - - Transforms x,y into screen coordinates px and py. Result is returned - in px and py. Rounds to the nearest pixel instead of truncating. - ----------------------------------------------------------------------------- */ - -void -Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) { - if (p2) { - *px = p2->view_xmin + (int) (p2->dx*(x-p2->xmin) + 0.5); - *py = p2->view_ymin + (int) (p2->dy*(y-p2->ymin) + 0.5); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) - - Plot a 2D Point of a given color - ------------------------------------------------------------------------------- */ -void -Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) { - int px, py; - - Plot2D_transform(p2,x,y,&px,&py); - FrameBuffer_plot(p2->frame, px, py, color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) - - Plot an outline box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_box(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_box(p2->frame,ix1,iy1,ix2,iy2,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_solidbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) - - Plot a solid box box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_solidbox(p2->frame,ix1,iy1,ix2,iy2,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) - - Plot a color-interpolated box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_interpbox(Plot2D *p2, double x1, double y1,double x2, double y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_interpbox(p2->frame,ix1,iy1,ix2,iy2,c1,c2,c3,c4); -} - -/* ------------------------------------------------------------------------------- - Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) - - Make an outline circle on the 2D plot. - ------------------------------------------------------------------------------- */ -void -Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) { - int ix, iy, ir; - - Plot2D_transform(p2,x,y,&ix,&iy); - ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ - if (ir > 1) - FrameBuffer_circle(p2->frame,ix,iy,ir,color); - else - FrameBuffer_plot(p2->frame,ix,iy,color); - -} - -/* ------------------------------------------------------------------------------- - Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) - - Make an solid circle on the 2D plot. - ------------------------------------------------------------------------------- */ -void -Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) { - int ix, iy, ir; - - Plot2D_transform(p2,x,y,&ix,&iy); - ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ - if (ir > 1) - FrameBuffer_solidcircle(p2->frame,ix,iy,ir,color); - else - FrameBuffer_plot(p2->frame,ix,iy,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) - - Draw a line - ------------------------------------------------------------------------------- */ - -void -Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) { - int ix1, ix2, iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_line(p2->frame,ix1,iy1,ix2,iy2,color); -} - - - -/* ------------------------------------------------------------------------------- - Plot2D_start(Plot2D *p2) - - This should be called before starting to make a 2D plot. It will change - the viewport coordinates for the framebuffer and do other stuff. - ------------------------------------------------------------------------------- */ - -void Plot2D_start(Plot2D *p2) { - if (p2) { - FrameBuffer_setclip(p2->frame, p2->view_xmin,p2->view_ymin,p2->view_xmax, p2->view_ymax); - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - } -} - -/* -------------------------------------------------------------------------- - void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) - - Draw a pixel map at the given coordinates. (Used for putting symbols on 2D - plots). - -------------------------------------------------------------------------- */ -void -Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) { - int ix, iy; - - Plot2D_transform(p2,x,y,&ix,&iy); - FrameBuffer_drawpixmap(p2->frame,pm,ix,iy,color,bgcolor); -} - -/* ---------------------------------------------------------------------------- - void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) - - Draw an X axis bar at location x,y with ticks spaced every xtick units. - Ticks are spaced starting at "x" - ----------------------------------------------------------------------------- */ - -void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) { - int ix, iy,iy2; - double xt; - - /* Draw a line fox the axis */ - - Plot2D_line(p2,p2->xmin,y,p2->xmax,y,color); - xt = x; - while (xt >= p2->xmin) { - Plot2D_transform(p2,xt,y,&ix,&iy); - iy2 = iy+ticklength; - iy = iy-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); - xt = xt - xtick; - } - xt = x + xtick; - while (xt < p2->xmax) { - Plot2D_transform(p2,xt,y,&ix,&iy); - iy2 = iy+ticklength; - iy = iy-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); - xt = xt + xtick; - } -} - - -/* ---------------------------------------------------------------------------- - void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c) - - Draw an Y axis bar at location x,y with ticks spaced every xtick units. - Ticks are spaced starting at "y" - ----------------------------------------------------------------------------- */ - -void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel color) { - int ix, iy, ix2; - double yt; - - /* Draw a line fox the axis */ - - Plot2D_line(p2,x,p2->ymin,x,p2->ymax,color); - yt = y; - while (yt >= p2->ymin) { - Plot2D_transform(p2,x,yt,&ix,&iy); - ix2 = ix+ticklength; - ix = ix-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); - yt = yt - ytick; - } - yt = y + ytick; - while (yt < p2->ymax) { - Plot2D_transform(p2,x,yt,&ix,&iy); - ix2 = ix+ticklength; - ix = ix-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); - yt = yt + ytick; - } -} - - -/* ------------------------------------------------------------------------- - Plot2D_triangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, - Pixel fillcolor) - - This function draws a 2D outline triangle. - -------------------------------------------------------------------------- */ - -void Plot2D_triangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, Pixel color) { - - Plot2D_line(p2,x1,y1,x2,y2,color); - Plot2D_line(p2,x2,y2,x3,y3,color); - Plot2D_line(p2,x3,y3,x1,y1,color); - -} - - -/* ------------------------------------------------------------------------- - Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, - Pixel color) - - This function draws a 2D filled triangle. Can be used to - draw other primitives such as quadralaterals, etc... - - -------------------------------------------------------------------------- */ - -void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, - - double x2, double y2, - double x3, double y3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - - /* Transform the three points into screen coordinates */ - - Plot2D_transform(p2,x1,y1,&tx1,&ty1); - Plot2D_transform(p2,x2,y2,&tx2,&ty2); - Plot2D_transform(p2,x3,y3,&tx3,&ty3); - - FrameBuffer_solidtriangle(p2->frame,tx1,ty1,tx2,ty2,tx3,ty3,color); - -} - -/* ------------------------------------------------------------------------- - Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - - This function draws a 2D filled triangle with color interpolation. - Can be used to draw other primitives such as quadralaterals, etc... - -------------------------------------------------------------------------- */ - -void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - - /* Transform the three points into screen coordinates */ - - Plot2D_transform(p2,x1,y1,&tx1,&ty1); - Plot2D_transform(p2,x2,y2,&tx2,&ty2); - Plot2D_transform(p2,x3,y3,&tx3,&ty3); - - FrameBuffer_interptriangle(p2->frame,tx1,ty1,c1,tx2,ty2,c2,tx3,ty3,c3); - -} - - - diff --git a/Examples/GIFPlot/Lib/plot3d.c b/Examples/GIFPlot/Lib/plot3d.c deleted file mode 100644 index 387e420e2..000000000 --- a/Examples/GIFPlot/Lib/plot3d.c +++ /dev/null @@ -1,2181 +0,0 @@ -/* ----------------------------------------------------------------------------- - * plot3d.c - * - * Three-dimensional plotting. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PLOT3D -#include "gifplot.h" -#include -#include - -#define ORTHO 1 -#define PERSPECTIVE 2 -/* ------------------------------------------------------------------------ - Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) - - Creates a new 3D plot. Min and max coordinates are primarily used to - pick some default parameters. Returns NULL on failure - ------------------------------------------------------------------------- */ - -Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) { - - Plot3D *p3; - void Plot3D_maketransform(Plot3D *p3); - - /* Check to make sure the framebuffer and min/max parameters are valid */ - - if (!f) return (Plot3D *) 0; - if ((xmin > xmax) || (ymin > ymax) || (zmin > zmax)) return (Plot3D *) 0; - - p3 = (Plot3D *) malloc(sizeof(Plot3D)); - p3->frame = f; - p3->xmin = xmin; - p3->ymin = ymin; - p3->zmin = zmin; - p3->xmax = xmax; - p3->ymax = ymax; - p3->zmax = zmax; - - /* Set view region to the entire size of the framebuffer */ - - p3->view_xmin = 0; - p3->view_ymin = 0; - p3->view_xmax = f->width; - p3->view_ymax = f->height; - p3->width = f->width; - p3->height = f->height; - - /* Calculate a center point based off the min and max coordinates given */ - - p3->xcenter = (xmax - xmin)/2.0 + xmin; - p3->ycenter = (ymax - ymin)/2.0 + ymin; - p3->zcenter = (zmax - zmin)/2.0 + zmin; - - /* Calculate the aspect ratio of the viewing region */ - - p3->aspect = (double) f->width/(double) f->height; - - /* Set default view parameters */ - p3->xshift = 1.0; - p3->yshift = 1.0; - p3->zoom = 0.5; - p3->fovy = 40.0; /* 40 degree field of view */ - - /* Create matrices */ - - p3->model_mat = new_Matrix(); - p3->view_mat = new_Matrix(); - p3->center_mat = new_Matrix(); - p3->fullmodel_mat = new_Matrix(); - p3->trans_mat = new_Matrix(); - p3->pers_mode = ORTHO; - - FrameBuffer_zresize(p3->frame,p3->width, p3->height); - Matrix_identity(p3->view_mat); - Matrix_identity(p3->model_mat); - Matrix_translate(p3->center_mat, -p3->xcenter,-p3->ycenter,-p3->zcenter); - Plot3D_maketransform(p3); - return p3; -} - -/* --------------------------------------------------------------------- - delete_Plot3D(Plot3D *p3) - - Deletes a 3D plot - --------------------------------------------------------------------- */ - -void delete_Plot3D(Plot3D *p3) { - if (p3) { - delete_Matrix(p3->view_mat); - delete_Matrix(p3->model_mat); - delete_Matrix(p3->trans_mat); - free((char *) p3); - } -} - -/* --------------------------------------------------------------------- - Plot3D *Plot3D_copy(Plot3D *p3) - - This makes a copy of the 3D plot structure and returns a pointer to it. - --------------------------------------------------------------------- */ - -Plot3D *Plot3D_copy(Plot3D *p3) { - Plot3D *c3; - if (p3) { - c3 = (Plot3D *) malloc(sizeof(Plot3D)); - if (c3) { - c3->frame = p3->frame; - c3->view_xmin = p3->view_xmin; - c3->view_ymin = p3->view_ymin; - c3->view_xmax = p3->view_xmax; - c3->view_ymax = p3->view_ymax; - c3->xmin = p3->xmin; - c3->ymin = p3->ymin; - c3->zmin = p3->zmin; - c3->xmax = p3->xmax; - c3->ymax = p3->ymax; - c3->zmax = p3->zmax; - c3->xcenter = p3->xcenter; - c3->ycenter = p3->ycenter; - c3->zcenter = p3->zcenter; - c3->fovy = p3->fovy; - c3->aspect = p3->aspect; - c3->znear = p3->znear; - c3->zfar = p3->zfar; - c3->center_mat = Matrix_copy(p3->center_mat); - c3->model_mat = Matrix_copy(p3->model_mat); - c3->view_mat = Matrix_copy(p3->view_mat); - c3->fullmodel_mat = Matrix_copy(p3->fullmodel_mat); - c3->trans_mat = Matrix_copy(p3->trans_mat); - c3->lookatz = p3->lookatz; - c3->xshift = p3->xshift; - c3->yshift = p3->yshift; - c3->zoom = p3->zoom; - c3->width = p3->width; - c3->height = p3->height; - c3->pers_mode = p3->pers_mode; - } - return c3; - } else { - return (Plot3D *) 0; - } -} - -/* ---------------------------------------------------------------------- - Plot3D_clear(Plot3D *p3, Pixel bgcolor) - - Clear the pixel and zbuffer only for the view region of this image. - ---------------------------------------------------------------------- */ -void -Plot3D_clear(Plot3D *p3, Pixel bgcolor) { - int i,j; - - for (i = p3->view_xmin; i < p3->view_xmax; i++) - for (j = p3->view_ymin; j < p3->view_ymax; j++) { - p3->frame->pixels[j][i] = bgcolor; - p3->frame->zbuffer[j][i] = ZMIN; - } -} - -/* --------------------------------------------------------------------- - Plot3D_maketransform(Plot3D *p3) - - This function builds the total 3D transformation matrix from a - collection of components. - - Trans = View * Rotation * Center - - Where View is the viewing transformation matrix, Rotation is the - model rotation matrix, Center is the translation matrix used to - center the Model at the origin. - --------------------------------------------------------------------- */ - -void -Plot3D_maketransform(Plot3D *p3) { - - Matrix_multiply(p3->model_mat,p3->center_mat, p3->fullmodel_mat); - Matrix_multiply(p3->view_mat,p3->fullmodel_mat, p3->trans_mat); -} - -/* --------------------------------------------------------------------- - Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) - - Sets up the perspective viewing transformation. Assumes "lookat" - has already been called. - --------------------------------------------------------------------- */ - -void -Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) { - double theta; - double mat[16]; - - p3->fovy = fovy; - p3->znear = znear; - p3->zfar = zfar; - - theta = 3.1415926*fovy/180.0; - - Matrix_identity(mat); - mat[0] = cos(theta/2.0)/(sin(theta/2.0)*p3->aspect); - mat[5] = cos(theta/2.0)/(sin(theta/2.0)); - mat[10] = -(zfar + znear)/(zfar-znear); - mat[14] = -1.0; - mat[11] = -(2*zfar*znear)/(zfar - znear); - mat[15] = 0.0; - - /* Update the view transformation matrix */ - - Matrix_multiply(mat,p3->view_mat,p3->view_mat); - - /* Update the global transformation matrix */ - - Plot3D_maketransform(p3); - p3->pers_mode = PERSPECTIVE; - -} - -/* --------------------------------------------------------------------- - Plot3D_lookat(Plot3D *p3, double z) - - A greatly simplified version of (lookat). Specifies the position - of the viewpoint. (can be used for moving image in or out). - - Destroys the current viewing transformation matrix, so it will have - to be recalculated. - --------------------------------------------------------------------- */ - -void -Plot3D_lookat(Plot3D *p3, double z) { - if (p3) { - Matrix_translate(p3->view_mat, 0,0,-z); - p3->lookatz = z; - Plot3D_maketransform(p3); - } -} - -/* ------------------------------------------------------------------------- - Plot3D_autoperspective(Plot3D *p3, double fovy) - - Automatically figures out a semi-decent viewpoint given the - min,max parameters currently set for this image - ------------------------------------------------------------------------- */ - -void -Plot3D_autoperspective(Plot3D *p3, double fovy) { - - /* Make a perspective transformation matrix for this system */ - - double zfar; - double znear; - double d, dmax; - double cx,cy,cz; - double xmin,xmax,ymin,ymax,zmin,zmax; - - xmin = p3->xmin; - ymin = p3->ymin; - zmin = p3->zmin; - xmax = p3->xmax; - ymax = p3->ymax; - zmax = p3->zmax; - cx = p3->xcenter; - cy = p3->ycenter; - cz = p3->zcenter; - - /* Calculate longest point from center point */ - - dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - - dmax = sqrt(dmax); - d = p3->lookatz; - - znear = d - dmax; - zfar = znear+1.5*dmax; - Plot3D_perspective(p3, fovy,znear,zfar); - -} - - -/* --------------------------------------------------------------------- - Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) - - Sets up an orthographic viewing transformation. - --------------------------------------------------------------------- */ - -void -Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) { - - - Matrix_identity(p3->view_mat); - p3->view_mat[0] = (2.0/(right - left))/p3->aspect; - p3->view_mat[5] = 2.0/(top - bottom); - p3->view_mat[10] = -1; - p3->view_mat[15] = 1.0; - p3->view_mat[3] = -(right+left)/(right-left); - p3->view_mat[7] = -(top+bottom)/(top-bottom); - - /* Update the global transformation matrix */ - - Plot3D_maketransform(p3); - p3->pers_mode = ORTHO; - p3->ortho_left = left; - p3->ortho_right = right; - p3->ortho_bottom = bottom; - p3->ortho_top = top; - -} - -/* --------------------------------------------------------------------- - Plot3D_autoortho(Plot3D *p3) - - Automatically pick an orthographic projection that's probably - pretty good. - --------------------------------------------------------------------- */ - -void -Plot3D_autoortho(Plot3D *p3) { - - /* Make a perspective transformation matrix for this system */ - - double d, dmax; - double cx,cy,cz; - double xmin,xmax,ymin,ymax,zmin,zmax; - - xmin = p3->xmin; - ymin = p3->ymin; - zmin = p3->zmin; - xmax = p3->xmax; - ymax = p3->ymax; - zmax = p3->zmax; - cx = p3->xcenter; - cy = p3->ycenter; - cz = p3->zcenter; - - /* Calculate longest point from center point */ - - dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - - dmax = sqrt(dmax); - - Plot3D_ortho(p3,-dmax,dmax,-dmax,dmax); - -} - - - -/* ------------------------------------------------------------------------- - Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) - - Sets the viewport for this 3D graph. Will recalculate all of the - local viewing transformation matrices accordingly. - ------------------------------------------------------------------------- */ -void -Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) { - if (p3) { - if ((vxmin > vxmax) || (vymin >vymax)) return; - p3->view_xmin = vxmin; - p3->view_ymin = vymin; - p3->view_xmax = vxmax; - p3->view_ymax = vymax; - p3->width = (vxmax - vxmin); - p3->height = (vymax - vymin); - p3->aspect = (double) p3->width/(double) p3->height; - - /* Fix up the viewing transformation matrix */ - - if (p3->pers_mode == PERSPECTIVE) { - Plot3D_lookat(p3,p3->lookatz); - Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); - } else { - Plot3D_ortho(p3,p3->ortho_left,p3->ortho_right,p3->ortho_bottom, p3->ortho_top); - } - FrameBuffer_setclip(p3->frame,vxmin,vymin,vxmax,vymax); - } -} - -/* --------------------------------------------------------------------------- - Plot2D_start(Plot2D *p3) - - Set up viewing region and other parameters for this image. - --------------------------------------------------------------------------- */ - -void -Plot3D_start(Plot3D *p3) { - if (p3) - FrameBuffer_setclip(p3->frame, p3->view_xmin,p3->view_ymin,p3->view_xmax, p3->view_ymax); - -} - -/* ------------------------------------------------------------------------- - Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color) - - Plot a 3D point - ------------------------------------------------------------------------- */ - -void -Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel color) { - - GL_Vector t; - int ix, iy; - double invw; - FrameBuffer *f; - - /* Perform a transformation */ - - Matrix_transform4(p3->trans_mat,x,y,z,1,&t); - - /* Scale the coordinates into unit cube */ - - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; -#ifdef GL_DEBUG - fprintf(stdout,"t.x = %g, t.y = %g, t.z = %g\n", t.x,t.y,t.z); -#endif - /* Calculate the x and y coordinates */ - - ix = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5); - iy = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5); - - if ((ix >= 0) && (ix < p3->width) && - (iy >= 0) && (ix < p3->height)) { - ix += p3->view_xmin; - iy += p3->view_ymin; - f = p3->frame; - if (t.z <= f->zbuffer[iy][ix]) { - f->pixels[iy][ix] = color; - f->zbuffer[iy][ix] = t.z; - } - } -} - -/* ---------------------------------------------------------------------- - Plot3D_rotx(Plot3D *p3, double deg) - - Rotate the model around its x axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_rotx(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - -/* ---------------------------------------------------------------------- - Plot3D_roty(Plot3D *p3, double deg) - - Rotate the model around its y axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_roty(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - -/* ---------------------------------------------------------------------- - Plot3D_rotz(Plot3D *p3, double deg) - - Rotate the model around its z axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_rotz(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatez(temp,deg); /* Construct a z rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotd(Plot3D *p3, double deg) - - Rotate the model down - ---------------------------------------------------------------------- */ - -void -Plot3D_rotd(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ - Matrix_multiply(temp, p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotu(Plot3D *p3, double deg) - - Rotate the model up - ---------------------------------------------------------------------- */ - -void -Plot3D_rotu(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,-deg); /* Construct a x rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotr(Plot3D *p3, double deg) - - Rotate the model down - ---------------------------------------------------------------------- */ - -void -Plot3D_rotr(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ - Matrix_multiply(temp, p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotl(Plot3D *p3, double deg) - - Rotate the model left - ---------------------------------------------------------------------- */ - -void -Plot3D_rotl(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,-deg); /* Construct a y rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotc(Plot3D *p3, double deg) - - Rotate the model around center point - ---------------------------------------------------------------------- */ - -void -Plot3D_rotc(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatez(temp,-deg); /* Construct a z rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); -} - -/* ------------------------------------------------------------------------- - Plot3D_zoom(Plot3D *p3, double percent) - - Zooms in or out the current image. percent defines a percentage of - zoom. - - Zooming is actually done by adjusting the perspective field of view - instead of scaling the model or moving in the viewpoint. This - seems to work the best. - ------------------------------------------------------------------------- */ - -void -Plot3D_zoom(Plot3D *p3, double percent) { - - double scale; - double dx; - if (percent <= 0) return; - scale = percent/100.0; - - dx = (1.0/scale - 1.0)/(2*p3->zoom); /* Don't even ask where this came from */ - p3->xshift += dx; - p3->yshift += dx; - p3->zoom = p3->zoom*scale; - -#ifdef OLD - p3->fovy = p3->fovy*scale; - if (p3->fovy > 170.0) p3->fovy = 170.0; - if (p3->fovy == 0) p3->fovy = 0.0001; - Plot3D_lookat(p3,p3->lookatz); - Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); -#endif -} - -/* -------------------------------------------------------------------------- - Plot3D_left(Plot3D *p3, double s) - - Shifts the image to the left by s units. This is a little funky. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_left(Plot3D *p3, double s) { - p3->xshift -= (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_right(Plot3D *p3, double s) - - Shifts the image to the right by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_right(Plot3D *p3, double s) { - p3->xshift += (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_up(Plot3D *p3, double s) - - Shifts the image up left by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_up(Plot3D *p3, double s) { - p3->yshift += (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_down(Plot3D *p3, double s) - - Shifts the image down by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_down(Plot3D *p3, double s) { - p3->yshift -= (s/100.0)/p3->zoom; -} - -/* ------------------------------------------------------------------------- - Plot3D_center(Plot3D *p3, double cx, double cy) - - Centers the image on a point in the range (0,0) - (100,100) - ------------------------------------------------------------------------- */ -void -Plot3D_center(Plot3D *p3, double cx, double cy) { - Plot3D_left(p3,cx-50); - Plot3D_down(p3,cy-50); -} - - - -/*************************************************************************** - * 3d Primitives * - ***************************************************************************/ - -/* ------------------------------------------------------------------------- - Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, double z1, double z2, Pixel color) - - Draws a "Horizontal" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. This function probably isn't - too useful by itself, but will be used by a number of other primitives. - -------------------------------------------------------------------------- */ - -void Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, Zvalue z1, Zvalue z2, Pixel color) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - int startx, endx; - - f = p3->frame; - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin > f->xmax) return; - if (xmin < f->xmin) startx = f->xmin; - else startx = xmin; - if (xmax < f->xmin) return; - if (xmax >= f->xmax) endx = f->xmax - 1; - else endx = xmax; - - /* Calculate z slope */ - - if (xmax != xmin) { - mz = (Zvalue) ((double) (z2 - z1)/(double) (xmax - xmin)); - } else { - mz = 0; - } - - /* Draw it */ - - p = &f->pixels[y][startx]; - zbuf = &f->zbuffer[y][startx]; - z = (Zvalue) (mz*(startx-xmin) + z1); - for (i = startx; i <= endx; i++, p++, zbuf++,z+=mz) { - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - - -/* ------------------------------------------------------------------------- - Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, double z1, double z2, Pixel color) - - Draws a "Vertical" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. This function probably isn't - too useful by itself, but will be used by a number of other primitives. - -------------------------------------------------------------------------- */ - -void Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, Zvalue z1, Zvalue z2, Pixel color) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - int starty, endy; - - f = p3->frame; - if ((x < f->xmin) || (x >= f->xmax)) return; - if (ymin >= f->ymax) return; - if (ymin < f->ymin) starty = f->ymin; - else starty = ymin; - if (ymax < f->ymin) return; - if (ymax >= f->ymax) endy = f->ymax - 1; - else endy = ymax; - - /* Calculate z slope */ - - mz = (double) (z2 - z1)/(double) (ymax - ymin); - - /* Draw it */ - - p = &f->pixels[starty][x]; - zbuf = &f->zbuffer[starty][x]; - for (i = starty; i <= endy; i++, p+=f->width, zbuf+=f->width) { - z = (Zvalue) (mz*(i-ymin) + z1); - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - -/* ------------------------------------------------------------------------------- - Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, - int x2, int y2, Zvalue z2, Pixel c) - - Draw a 3D line between points that have already been transformed into - 3D space. - - Uses a Bresenham line algorithm, but with linear interpolation between - Zvalues. - ------------------------------------------------------------------------------- */ - -void -Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, int x2, int y2, Zvalue z2, Pixel c) { - - int orig_x1, orig_y1, orig_x2,orig_y2; - Zvalue zt; - - /* Bresenham line drawing parameters */ - FrameBuffer *f; - int dx,dy,dxneg,dyneg, inc1,inc2,di; - int x, y, xpixels, ypixels, xt, yt; - Pixel *p; - double m; - int end1 = 0, end2 = 0; - Zvalue *zbuf,mz,z; - - f = p3->frame; - - /* Need to figure out where in the heck this line is */ - - dx = x2 - x1; - dy = y2 - y1; - - if ((dx == 0) && (dy == 0)) { - if ((x1 < f->xmin) || (x1 >= f->xmax) || - (y1 < f->ymin) || (y1 >= f->ymax)) return; - if (z1 <= f->zbuffer[y1][x1]) { - f->pixels[y1][x1] = c; - } - return; - } - if (dx == 0) { - /* Draw a Vertical Line */ - if (y1 < y2) - Plot3D_vertical(p3,y1,y2,x1,z1,z2,c); - else - Plot3D_vertical(p3,y2,y1,x1,z2,z1,c); - return; - } - if (dy == 0) { - /* Draw a Horizontal Line */ - if (x1 < x2) - Plot3D_horizontal(p3,x1,x2,y1,z1,z2,c); - else - Plot3D_horizontal(p3,x2,x1,y1,z2,z1,c); - return; - } - - /* Figure out where in the heck these lines are using the - Cohen-Sutherland Line Clipping Scheme. */ - - end1 = ((x1 - f->xmin) < 0) | - (((f->xmax- 1 - x1) < 0) << 1) | - (((y1 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y1) < 0) << 3); - - end2 = ((x2 - f->xmin) < 0) | - (((f->xmax-1 - x2) < 0) << 1) | - (((y2 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y2) < 0) << 3); - - if (end1 & end2) return; /* Nope : Not visible */ - - /* Make sure points have a favorable orientation */ - - if (x1 > x2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - zt = z1; - z1 = z2; - z2 = zt; - } - - /* Save original points before we clip them off */ - orig_x1 = x1; - orig_y1 = y1; - orig_x2 = x2; - orig_y2 = y2; - - /* Clip against the boundaries */ - m = (y2 - y1)/(double) (x2-x1); - if (x1 < f->xmin) { - y1 = (f->xmin - x1)*m + y1; - x1 = f->xmin; - } - if (x2 >= f->xmax) { - y2 = (f->xmax -1 -x1)*m + y1; - x2 = f->xmax - 1; - } - - if (y1 > y2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - zt = z1; - z1 = z2; - z2 = zt; - - /* Swap original points */ - - xt = orig_x1; - orig_x1 = orig_x2; - orig_x2 = xt; - yt = orig_y1; - orig_y1 = orig_y2; - orig_y2 = yt; - } - - m = 1/m; - if (y1 < f->ymin) { - x1 = (f->ymin - y1)*m + x1; - y1 = f->ymin; - } - if (y2 >= f->ymax) { - x2 = (f->ymax-1-y1)*m + x1; - y2 = f->ymax-1; - } - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || - (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; - - dx = x2 - x1; - dy = y2 - y1; - xpixels = f->width; - ypixels = f->height; - - dxneg = (dx < 0) ? 1 : 0; - dyneg = (dy < 0) ? 1 : 0; - - dx = abs(dx); - dy = abs(dy); - if (dx >= dy) { - /* Slope between -1 and 1. */ - mz = (z2 - z1)/(orig_x2 - orig_x1); /* Z interpolation slope */ - if (dxneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dyneg = !dyneg; - } - inc1 = 2*dy; - inc2 = 2*(dy-dx); - di = 2*dy-dx; - - /* Draw a line using x as independent variable */ - - p = &f->pixels[y1][x1]; - zbuf = &f->zbuffer[y1][x1]; - x = x1; - while (x <= x2) { - /* Do a z-buffer check */ - z = mz*(x-orig_x1)+z1; - if (z <= *zbuf){ - *p = c; - *zbuf = z; - } - p++; - zbuf++; - if (di < 0) { - di = di + inc1; - } else { - if (dyneg) { - p = p - xpixels; - zbuf = zbuf - xpixels; - di = di + inc2; - } else { - p = p + xpixels; - zbuf = zbuf + xpixels; - di = di + inc2; - } - } - x++; - } - } else { - /* Slope < -1 or > 1 */ - mz = (z2 - z1)/(double) (orig_y2 - orig_y1); - if (dyneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dxneg = !dxneg; - } - inc1 = 2*dx; - inc2 = 2*(dx-dy); - di = 2*dx-dy; - - /* Draw a line using y as independent variable */ - - p = &f->pixels[y1][x1]; - zbuf = &f->zbuffer[y1][x1]; - y = y1; - while (y <= y2) { - /* Do a z-buffer check */ - z = mz*(y-orig_y1)+z1; - if (z <= *zbuf) { - *p = c; - *zbuf = z; - } - p = p + xpixels; - zbuf = zbuf + xpixels; - if (di < 0) { - di = di + inc1; - } else { - if (dxneg) { - p = p - 1; - zbuf = zbuf - 1; - di = di + inc2; - } else { - p = p + 1; - zbuf = zbuf + 1; - di = di + inc2; - } - } - y++; - } - } -} - -/* --------------------------------------------------------------------------- - Plot3D_line(Plot3D *p3, double x1, double y1, double z1, double x2, double y2, double z2,int color) - - Draws a line in 3D space. This is done as follows (for lack of a better - method). - - 1. The points (x1,y1,z1) and (x2,y2,z2) are transformed into screen coordinates - 2. We draw the line using a modified Bresenham line algorithm. - 3. Zbuffer values are linearly interpolated between the two points. - ---------------------------------------------------------------------------- */ - -void -Plot3D_line(Plot3D *p3, double fx1, double fy1, double fz1, double fx2, double fy2, - double fz2, Pixel c) { - - /* 3D Transformation parameters */ - GL_Vector t; - double invw; - int x1,y1,x2,y2; - Zvalue z1,z2; - - /* Transform the two points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,fx1,fy1,fz1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - x1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - y1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - z1 = t.z; - - Matrix_transform4(p3->trans_mat,fx2,fy2,fz2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - x2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - y2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - z2 = t.z; - Plot3D_linetransform(p3,x1,y1,z1,x2,y2,z2,c); -} - - -/* ------------------------------------------------------------------------- - Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - Pixel fillcolor) - - This function draws a 3D z-buffered outline triangle. - -------------------------------------------------------------------------- */ - -void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - - Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); -} - - -/* ------------------------------------------------------------------------- - Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty2, Zvalue tz1, - int tx2, int ty2, Zvalue tz2, - int tx3, int ty3, Zvalue tz3, Pixel color) - - This function draws a 3D z-buffered filled triangle. Assumes three - points have already been transformed into screen coordinates. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - -------------------------------------------------------------------------- */ - -void Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty1, Zvalue tz1, - int tx2, int ty2, Zvalue tz2, - int tx3, int ty3, Zvalue tz3, Pixel color) { - int tempx, tempy; - Zvalue tempz; - double m1,m2,m3, mz1, mz2, mz3; - int y; - int ix1, ix2; - Zvalue zz1, zz2; - FrameBuffer *f; - register double fy1,fy2; - register Zvalue fz1,fz2; - - f = p3->frame; - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - if (tx2 < tx1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempz = tz1; - tx1 = tx2; - tz1 = tz2; - tx2 = tempx; - tz2 = tempz; - } - if (tx3 < tx1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempz = tz1; - tx1 = tx3; - tz1 = tz3; - tx3 = tempx; - tz3 = tempz; - } - if (tx3 < tx2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempz = tz2; - tx2 = tx3; - tz2 = tz3; - tx3 = tempx; - tz3 = tempz; - } - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - Plot3D_horizontal(p3,tx1,tx2,ty1,tz1,tz3,color); - - /* Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); - */ - - return; - } - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tx1 = tx2; - ty1 = ty2; - tz1 = tz2; - tx2 = tempx; - ty2 = tempy; - tz2 = tempz; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tx1 = tx3; - ty1 = ty3; - tz1 = tz3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempz = tz2; - tx2 = tx3; - ty2 = ty3; - tz2 = tz3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - if (ty2 < ty1) { - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz1 = (tz2 - tz1)/(double) (ty2 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - - y = ty1; - fy1 = m1*(y-ty1)+0.5 + tx1; - fy2 = m2*(y-ty1)+0.5 + tx1; - fz1 = mz1*(y-ty1) + tz1; - fz2 = mz2*(y-ty1) + tz1; - while (y >= ty2) { - /* Replace with bresenham scheme */ - /* Calculate x values from slope */ - ix1 = (int) fy1; - ix2 = (int) fy2; - zz1 = fz1; - zz2 = fz2; - fy1-= m1; - fy2-= m2; - fz1-= mz1; - fz2-= mz2; - if (ix1 > ix2) - Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); - else - Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mz3 = (tz3 - tz2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - zz1 = mz3*(y-ty2)+tz2; - zz2 = mz2*(y-ty1)+tz1; - if (ix1 > ix2) - Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); - else - Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); - y--; - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - Pixel color) - - This function draws a 3D z-buffered filled triangle. Can be used to - draw other primitives such as quadralaterals, etc... - - This function simply transforms the given points and calls - Plot3D_SolidTriangleTransform(). - -------------------------------------------------------------------------- */ - -void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - Matrix a; - register double xshift, yshift, zoom, width, height, view_xmin, view_ymin; - - a = p3->trans_mat; - xshift = p3->xshift; - yshift = p3->yshift; - zoom = p3->zoom; - height = p3->height; - width = p3->width; - view_xmin = p3->view_xmin; - view_ymin = p3->view_ymin; - - /* Transform the three points into screen coordinates */ - - t.w = a[12]*x1 + a[13]*y1 + a[14]*z1 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x1 + a[1]*y1 + a[2]*z1 + a[3])*invw; - t.y = (a[4]*x1 + a[5]*y1 + a[6]*z1 + a[7])*invw; - t.z = (a[8]*x1 + a[9]*y1 + a[10]*z1 + a[11])*invw; - - tx1 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty1 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz1 = (Zvalue) t.z; - - - t.w = a[12]*x2 + a[13]*y2 + a[14]*z2 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x2 + a[1]*y2 + a[2]*z2 + a[3])*invw; - t.y = (a[4]*x2 + a[5]*y2 + a[6]*z2 + a[7])*invw; - t.z = (a[8]*x2 + a[9]*y2 + a[10]*z2 + a[11])*invw; - tx2 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty2 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz2 = (Zvalue) t.z; - - t.w = a[12]*x3 + a[13]*y3 + a[14]*z3 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x3 + a[1]*y3 + a[2]*z3 + a[3])*invw; - t.y = (a[4]*x3 + a[5]*y3 + a[6]*z3 + a[7])*invw; - t.z = (a[8]*x3 + a[9]*y3 + a[10]*z3 + a[11])*invw; - tx3 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty3 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz3 = (Zvalue) t.z; - - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); - -} - - -/* ------------------------------------------------------------------------- - Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, - double z1, double z2, Pixel c1, Pixel c2) - - Draws a "Horizontal" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. Performs a color interpolation - between c1 and c2. This is primarily used by the SolidTriangleInterp() - function to give the illusion of smooth surfaces. - -------------------------------------------------------------------------- */ - -void Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, - Zvalue z1, Zvalue z2, Pixel c1, Pixel c2) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - double mc; - int startx, endx; - double invdx; - - f = p3->frame; - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin >= f->xmax) return; - if (xmin < f->xmin) startx = f->xmin; - else startx = xmin; - if (xmax < f->xmin) return; - if (xmax >= f->xmax) endx = f->xmax - 1; - else endx = xmax; - - /* Calculate z slope */ - if (xmax != xmin) { - invdx = 1.0/(double) (xmax-xmin); - } else { - invdx = 0; - } - - mz = (Zvalue) (z2 - z1)*invdx; - - /* Calculate c slope */ - - mc = (double) (c2 - c1)*invdx; - - /* Draw it */ - - p = &f->pixels[y][startx]; - zbuf = &f->zbuffer[y][startx]; - for (i = startx; i <= endx; i++, p++, zbuf++) { - z = (Zvalue) (mz*(i-xmin) + z1); - if (z <= *zbuf) { - *p = (Pixel) (mc*(i-xmin)+c1); - *zbuf = z; - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_interptriangletransform(Plot3D *p3, - int tx1, int ty2, Zvalue tz1, Pixel c1, - int tx2, int ty2, Zvalue tz2, Pixel c2, - int tx3, int ty3, Zvalue tz3, Pixel c3) - - This function draws a 3D z-buffered filled triangle with color - interpolation. Assumes three points have already been transformed - into screen coordinates. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - 5. Colors are interpolated between end points - -------------------------------------------------------------------------- */ - -void Plot3D_interptriangletransform(Plot3D *p3, - int tx1, int ty1, Zvalue tz1, Pixel c1, - int tx2, int ty2, Zvalue tz2, Pixel c2, - int tx3, int ty3, Zvalue tz3, Pixel c3) { - int tempx, tempy; - Zvalue tempz; - double m1,m2,m3, mz1, mz2, mz3; - double mc1,mc2,mc3; - Pixel ic1,ic2,tempc; - int y; - int ix1, ix2; - Zvalue zz1, zz2; - FrameBuffer *f; - - f = p3->frame; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tempc = c1; - tx1 = tx2; - ty1 = ty2; - tz1 = tz2; - c1 = c2; - tx2 = tempx; - ty2 = tempy; - tz2 = tempz; - c2 = tempc; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tempc = c1; - tx1 = tx3; - ty1 = ty3; - tz1 = tz3; - c1 = c3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - c3 = tempc; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempz = tz2; - tempc = c2; - tx2 = tx3; - ty2 = ty3; - tz2 = tz3; - c2 = c3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - c3 = tempc; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - if (tx2 > tx1) - Plot3D_horizontalinterp(p3,tx1,tx2,ty1,tz1,tz2,c1,c2); - else - Plot3D_horizontalinterp(p3,tx2,tx1,ty1,tz2,tz1,c2,c1); - if (tx3 > tx1) - Plot3D_horizontalinterp(p3,tx1,tx3,ty1,tz1,tz3,c1,c3); - else - Plot3D_horizontalinterp(p3,tx3,tx1,ty1,tz3,tz1,c3,c1); - if (tx3 > tx2) - Plot3D_horizontalinterp(p3,tx2,tx3,ty2,tz2,tz3,c2,c3); - else - Plot3D_horizontalinterp(p3,tx3,tx2,ty2,tz3,tz2,c3,c2); - - } else { - - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - if (ty2 < ty1) { - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz1 = (tz2 - tz1)/(double) (ty2 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mc1 = (c2 - c1)/(double) (ty2 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - zz1 = mz1*(y-ty1) + tz1; - zz2 = mz2*(y-ty1) + tz1; - ic1 = mc1*(y-ty1) + c1; - ic2 = mc2*(y-ty1) + c1; - if (ix1 > ix2) - Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); - else - Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mz3 = (tz3 - tz2)/(double) (ty3 - ty2); - mc3 = (c3 - c2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - zz1 = mz3*(y-ty2)+tz2; - zz2 = mz2*(y-ty1)+tz1; - ic1 = mc3*(y-ty2)+c2; - ic2 = mc2*(y-ty1)+c1; - if (ix1 > ix2) - Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); - else - Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); - y--; - } - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3) - - This function draws a 3D z-buffered filled triangle with color - interpolation. - - This function simply transforms the given points and calls - Plot3D_InterpTriangleTransform(). - -------------------------------------------------------------------------- */ - -void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); -} - -/* ------------------------------------------------------------------------- - Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel fillcolor) - - This function draws a 3D outlined Quadralateral. Used primarily for - drawing meshes and other things. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color) { - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx3,ty3,tz3,tx4,ty4,tz4,color); - Plot3D_linetransform(p3,tx4,ty4,tz4,tx1,ty1,tz1,color); - -} - - -/* ------------------------------------------------------------------------- - Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel fillcolor) - - This function draws a 3D solid Quadralateral. Uses the function - Plot3D_SolidTriangleTransform() to fill in the region. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color) { - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx4,ty4,tz4,tx3,ty3,tz3,color); -} - -/* ------------------------------------------------------------------------- - Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4) - - This function draws a 3D color-interpolated Quadralateral. Uses the function - Plot3D_InterpTriangleTransform() to fill in the region. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4) { - - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx4,ty4,tz4,c4,tx3,ty3,tz3,c3); - -} - -/* -------------------------------------------------------------------------- - Plot3D_solidsphere(Plot3 *p3, double x, double y, double z, double radius, - Pixel c) - - Makes a 3D sphere at x,y,z with given radius and color. - - Basic strategy : - 1. Transform point to screen coordinates - 2. Figure out what the radius is in screen coordinates - 3. Use bresenham algorithm for large spheres - 4. Use bitmaps for small spheres - -------------------------------------------------------------------------- */ - -/* This is used to fill in spheres */ -static int s_xmin; -static int s_ymin; -static int s_xmax; -static int s_ymax; -static Pixel **s_pixels; -static Zvalue **s_zbuffer; - -void Plot3D_spherehorizontal(int xmin, int xmax, int y, Zvalue z, Pixel color) { - int i; - int startx, endx; - Pixel *p; - Zvalue *zbuf; - - if ((y < s_ymin) || (y >= s_ymax)) return; - if (xmin < s_xmin) startx = s_xmin; - else startx = xmin; - if (xmax >= s_xmax) endx = s_xmax - 1; - else endx = xmax; - - /* Draw it */ - - p = &s_pixels[y][xmin]; - zbuf = &s_zbuffer[y][xmin]; - for (i = startx; i <= endx; i++, p++, zbuf++) { - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - -void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius, - Pixel c) { - - GL_Vector t,r; - double rad; - int tx,ty, irad; - Zvalue tz; - double invw; - int ix, iy, ix1,ix2,p; - FrameBuffer *f; - - /* First transform the point into model coordinates */ - - Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); - - /* Now transform two points in order to find proper sphere radius */ - - Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ - Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); - - invw = 1.0/t.w; - t.x = t.x*invw; - t.y = t.y*invw; - t.z = t.z*invw; - invw = 1.0/r.w; - r.x = r.x*invw; - r.y = r.y*invw; - r.z = r.z*invw; - invw = 1.0/r.w; - - rad = fabs(t.x - r.x); - - /* Transform everything into screen coordinates */ - - tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz = (Zvalue) t.z; - irad = (int) (p3->zoom*(rad*p3->width + 0.5)); - - /* This is only a temporary solution (maybe). */ - -#define fill_zcircle(x,y,c) \ - ix1 = tx - x; \ - ix2 = tx + x; \ - if (ix1 < s_xmin) ix1 = s_xmin; \ - if (ix2 >= s_xmax) ix2 = s_xmax; \ - Plot3D_spherehorizontal(ix1,ix2,y,tz,c); - - f = p3->frame; - s_xmin = f->xmin; - s_ymin = f->ymin; - s_xmax = f->xmax; - s_ymax = f->ymax; - s_pixels = f->pixels; - s_zbuffer = f->zbuffer; - if (irad <= 1) { - /* Plot a single pixel */ - if ((tx >= f->xmin) && (tx < f->xmax)) { - if ((ty >= f->ymin) && (ty ymax)) { - if (tz <= f->zbuffer[ty][tx]) { - f->pixels[ty][tx] = c; - f->zbuffer[ty][tx] = tz; - } - } - } - return; - } - ix = 0; - iy = irad; - p = 3-2*irad; - while (ix <= iy) { - fill_zcircle(ix,ty+iy,c); - fill_zcircle(ix,ty-iy,c); - fill_zcircle(iy,ty+ix,c); - fill_zcircle(iy,ty-ix,c); - if (p < 0) p = p + 4*ix + 6; - else { - p = p + 4*(ix-iy) + 10; - iy = iy -1; - } - ix++; - } -} - - -/* -------------------------------------------------------------------- - Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, - double radius, Pixel color, Pixel bc) - - Draws an outlined sphere. - -------------------------------------------------------------------- */ - -void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, - double radius, Pixel c, Pixel bc) -{ - GL_Vector t,r; - double rad; - int tx,ty, irad; - Zvalue tz; - double invw; - int ix, iy, ix1,ix2,p; - - FrameBuffer *f; - - /* First transform the point into model coordinates */ - - Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); - - /* Now transform two points in order to find proper sphere radius */ - - Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ - Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); - - invw = 1.0/t.w; - t.x = t.x*invw; - t.y = t.y*invw; - t.z = t.z*invw; - invw = 1.0/r.w; - r.x = r.x*invw; - r.y = r.y*invw; - r.z = r.z*invw; - invw = 1.0/r.w; - - rad = fabs(t.x - r.x); - - /* Transform everything into screen coordinates */ - - tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz = (Zvalue) t.z; - irad = (int) (p3->zoom*(rad*p3->width + 0.5)); - - /* This is only a temporary solution (maybe). */ -#define plot_zcircle(x,y,c) \ - if ((x >= s_xmin) && (x < s_xmax) && \ - (y >= s_ymin) && (y < s_ymax)) {\ - if (tz <= s_zbuffer[y][x]) { \ - s_pixels[y][x] = c; \ - s_zbuffer[y][x] = tz; } \ - } - - f = p3->frame; - s_xmin = f->xmin; - s_ymin = f->ymin; - s_xmax = f->xmax; - s_ymax = f->ymax; - s_pixels = f->pixels; - s_zbuffer = f->zbuffer; - - if (irad <= 1) { - /* Plot a single pixel */ - if ((tx >= f->xmin) && (tx < f->xmax)) { - if ((ty >= f->ymin) && (ty ymax)) { - if (tz <= f->zbuffer[ty][tx]) { - f->pixels[ty][tx] = c; - f->zbuffer[ty][tx] = tz; - } - } - } - return; - } - ix = 0; - iy = irad; - p = 3-2*irad; - while (ix <= iy) { - fill_zcircle(ix,ty+iy,c); - fill_zcircle(ix,ty-iy,c); - fill_zcircle(iy,ty+ix,c); - fill_zcircle(iy,ty-ix,c); - - plot_zcircle(tx+ix,ty+iy,bc); - plot_zcircle(tx-ix,ty+iy,bc); - plot_zcircle(tx+ix,ty-iy,bc); - plot_zcircle(tx-ix,ty-iy,bc); - plot_zcircle(tx+iy,ty+ix,bc); - plot_zcircle(tx-iy,ty+ix,bc); - plot_zcircle(tx+iy,ty-ix,bc); - plot_zcircle(tx-iy,ty-ix,bc); - if (p < 0) p = p + 4*ix + 6; - else { - p = p + 4*(ix-iy) + 10; - iy = iy -1; - } - ix++; - } -} - -/* QUAD Test - Test out quad functions for graphing */ - -double zf(double x, double y) { - return cos(sqrt(x*x + y*y)*10.0)/(sqrt(x*x+y*y)+1); -} - -void Quad_Test(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; - int c; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - za = 0.25*(z1+z2+z3+z4); - c = 16+((za + 1)*120); - if (c > 254) c = 254; - Plot3D_quad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); - } -} - - -void Quad_SolidTest(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; - int c; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - za = 0.25*(z1+z2+z3+z4); - c = 16+((za + 1)*120); - if (c > 254) c = 254; - Plot3D_solidquad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); - } -} - - - -void Quad_InterpTest(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4; - int c1,c2,c3,c4; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - c1 = 16+((z1 + 1)*120); - c2 = 16+((z2 + 1)*120); - c3 = 16+((z3 + 1)*120); - c4 = 16+((z4 + 1)*120); - if (c1 > 254) c1 = 254; - if (c2 > 254) c2 = 254; - if (c3 > 254) c3 = 254; - if (c4 > 254) c4 = 254; - Plot3D_interpquad(p3,x1,y1,z1,(Pixel) c1,x2,y2,z2,(Pixel) c2,x3,y3,z3,(Pixel) c3,x4,y4,z4,(Pixel) c4); - } -} - - - - - - - - - - - - diff --git a/Examples/GIFPlot/Makefile.in b/Examples/GIFPlot/Makefile.in deleted file mode 100644 index 4e51360c8..000000000 --- a/Examples/GIFPlot/Makefile.in +++ /dev/null @@ -1,23 +0,0 @@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -RANLIB = @RANLIB@ -OPT = - -INSTALL = ../install-sh -c -INSTALL_DATA = ${INSTALL} -m 644 -SHELL = /bin/sh - -all: - cd Lib && $(MAKE) OPT="$(OPT)" - -install: - $(INSTALL_DATA) Include/gifplot.h $(prefix)/include/gifplot.h - $(INSTALL_DATA) libgifplot.a $(exec_prefix)/lib/libgifplot.a - $(RANLIB) $(exec_prefix)/lib/libgifplot.a - -clean:: - rm -f *.@OBJEXT@ *~ libgifplot.a *_wrap* *_man* - cd Lib && $(MAKE) clean - rm -f config.log config.status config.cache - -check: all diff --git a/Examples/GIFPlot/Ocaml/check.list b/Examples/GIFPlot/Ocaml/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Ocaml/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Ocaml/full/Makefile b/Examples/GIFPlot/Ocaml/full/Makefile deleted file mode 100644 index 4f35c43f9..000000000 --- a/Examples/GIFPlot/Ocaml/full/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifcaml -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include -MLFILE = gifplot.ml -IOBJS = runme.cmo -PROGFILE = runme.ml - -all:: static - -static:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -dynamic:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_dynamic - -clean:: - $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ocaml/full/README b/Examples/GIFPlot/Ocaml/full/README deleted file mode 100644 index 4a2b400b5..000000000 --- a/Examples/GIFPlot/Ocaml/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The ocaml program 'runme.ml' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Ocaml/full/cmap b/Examples/GIFPlot/Ocaml/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC C_float x) - [ x ; y ; z1 ; - (x +. dx) ; y ; z2 ; - (x +. dx) ; (y +. dy) ; z3 ; - x ; (y +. dx) ; z4 ; - (float_of_int (c + 16)) ]))) ; - y_loop (y +. dy) (j + 1) - end in - begin - y_loop ymin 0 ; - x_loop (x +. dx) (i + 1) - end - end in - x_loop xmin 0 - end - -let _ = print_endline "Making a nice 3D plot..." -let _ = drawsolid () - -let _ = _FrameBuffer_writeGIF (C_list [ frame ; cmap ; C_string "image.gif" ]) -let _ = print_endline "Write image.gif" diff --git a/Examples/GIFPlot/Ocaml/simple/Makefile b/Examples/GIFPlot/Ocaml/simple/Makefile deleted file mode 100644 index 50492efc7..000000000 --- a/Examples/GIFPlot/Ocaml/simple/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifsimple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include -MLFILE = simple.ml -IOBJS = simple_wrap.o simple.cmo runme.cmo -PROGFILE = runme.ml - -all:: static - -static:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -dynamic:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -clean:: - $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ocaml/simple/cmap b/Examples/GIFPlot/Ocaml/simple/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } - Plot3D_solidquad($p3,$x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -FrameBuffer_writeGIF($frame,$cmap,"image.gif"); -print "Wrote image.gif\n"; - diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile deleted file mode 100644 index c5cb7aec4..000000000 --- a/Examples/GIFPlot/Perl5/shadow/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static - -clean:: - $(MAKE) -f $(TOP)/Makefile perl5_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Perl5/shadow/README b/Examples/GIFPlot/Perl5/shadow/README deleted file mode 100644 index ab12e344e..000000000 --- a/Examples/GIFPlot/Perl5/shadow/README +++ /dev/null @@ -1,2 +0,0 @@ -This example use the file in ../../Interface/gifplot.i to build -an interface with shadow classes. Run the script 'runme.pl'. diff --git a/Examples/GIFPlot/Perl5/shadow/cmap b/Examples/GIFPlot/Perl5/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear($BLACK); - -$p3 = new gifplot::Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); -$p3->lookat(2*($zmax-$zmin)); -$p3->autoperspective(40); -$p3->rotu(60); -$p3->rotr(30); -$p3->rotd(10); - -sub drawsolid { - $p3->clear($BLACK); - $p3->start(); - my $dx = 1.0*($xmax-$xmin)/$nxpoints; - my $dy = 1.0*($ymax-$ymin)/$nypoints; - my $cscale = 240.0/($zmax-$zmin); - my $x = $xmin; - for ($i = 0; $i < $nxpoints; $i++) { - my $y = $ymin; - for ($j = 0; $j < $nypoints; $j++) { - my $z1 = func($x,$y); - my $z2 = func($x+$dx,$y); - my $z3 = func($x+$dx,$y+$dy); - my $z4 = func($x,$y+$dy); - my $c1 = $cscale*($z1-$zmin); - my $c2 = $cscale*($z2-$zmin); - my $c3 = $cscale*($z3-$zmin); - my $c4 = $cscale*($z4-$zmin); - my $c = ($c1+$c2+$c3+$c4)/4; - if ($c < 0) { $c = 0; } - if ($c > 239) { $c = 239; } - $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -$frame->writeGIF($cmap,"image.gif"); -print "Wrote image.gif\n"; - diff --git a/Examples/GIFPlot/Perl5/simple/Makefile b/Examples/GIFPlot/Perl5/simple/Makefile deleted file mode 100644 index 36a8fa938..000000000 --- a/Examples/GIFPlot/Perl5/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static - -clean:: - $(MAKE) -f $(TOP)/Makefile perl5_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Perl5/simple/README b/Examples/GIFPlot/Perl5/simple/README deleted file mode 100644 index c2c799a70..000000000 --- a/Examples/GIFPlot/Perl5/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.pl' runs the example. - - diff --git a/Examples/GIFPlot/Perl5/simple/runme.pl b/Examples/GIFPlot/Perl5/simple/runme.pl deleted file mode 100644 index f28255e7c..000000000 --- a/Examples/GIFPlot/Perl5/simple/runme.pl +++ /dev/null @@ -1,28 +0,0 @@ -# Draw some simple shapes -print "Drawing some basic shapes\n"; - -use simple; - -$cmap = simple::new_ColorMap(); -$f = simple::new_FrameBuffer(400,400); - -# Clear the picture -simple::FrameBuffer_clear($f,$simple::BLACK); - -# Make a red box -simple::FrameBuffer_box($f,40,40,200,200,$simple::RED); - -# Make a blue circle -simple::FrameBuffer_circle($f,200,200,40,$simple::BLUE); - -# Make green line -simple::FrameBuffer_line($f,10,390,390,200, $simple::GREEN); - -# Write an image out to disk - -simple::FrameBuffer_writeGIF($f,$cmap,"image.gif"); -print "Wrote image.gif\n"; - -simple::delete_FrameBuffer($f); -simple::delete_ColorMap($cmap); - diff --git a/Examples/GIFPlot/Perl5/simple/simple.i b/Examples/GIFPlot/Perl5/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Perl5/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Php4/check.list b/Examples/GIFPlot/Php4/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Php4/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Php4/full/Makefile b/Examples/GIFPlot/Php4/full/Makefile deleted file mode 100644 index 3aa632b99..000000000 --- a/Examples/GIFPlot/Php4/full/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -noproxy -SRCS = -TARGET = php_gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 - -clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean - rm -f *.gif - rm -f php_gifplot.h - -check: all diff --git a/Examples/GIFPlot/Php4/full/README b/Examples/GIFPlot/Php4/full/README deleted file mode 100644 index f8d38d9af..000000000 --- a/Examples/GIFPlot/Php4/full/README +++ /dev/null @@ -1,4 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.php3' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. diff --git a/Examples/GIFPlot/Php4/full/cmap b/Examples/GIFPlot/Php4/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } - Plot3D_solidquad($p3, $x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -FrameBuffer_writeGIF($frame, $cmap,"image.gif"); -print "Wrote image.gif\n"; - -?> diff --git a/Examples/GIFPlot/Php4/shadow/Makefile b/Examples/GIFPlot/Php4/shadow/Makefile deleted file mode 100644 index 5627e53a0..000000000 --- a/Examples/GIFPlot/Php4/shadow/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = php_gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 - -clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Php4/shadow/README b/Examples/GIFPlot/Php4/shadow/README deleted file mode 100644 index 3e91f7d59..000000000 --- a/Examples/GIFPlot/Php4/shadow/README +++ /dev/null @@ -1,2 +0,0 @@ -This example use the file in ../../Interface/gifplot.i to build -an interface with shadow classes. Run the script 'runme.php3'. diff --git a/Examples/GIFPlot/Php4/shadow/cmap b/Examples/GIFPlot/Php4/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear(BLACK); - - -$p3 = new Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); -$p3->lookat(2*($zmax-$zmin)); -$p3->autoperspective(40); -$p3->rotu(60); -$p3->rotr(30); -$p3->rotd(10); - -function drawsolid() { - global $xmax; - global $xmin; - global $ymax; - global $ymin; - global $zmin; - global $zmax; - global $nxpoints; - global $nypoints; - global $p3; - - $p3->clear(BLACK); - $p3->start(); - $dx = 1.0*($xmax-$xmin)/$nxpoints; - $dy = 1.0*($ymax-$ymin)/$nypoints; - $cscale = 240.0/($zmax-$zmin); - $x = $xmin; - for ($i = 0; $i < $nxpoints; $i++) { - $y = $ymin; - for ($j = 0; $j < $nypoints; $j++) { - $z1 = func($x,$y); - $z2 = func($x+$dx,$y); - $z3 = func($x+$dx,$y+$dy); - $z4 = func($x,$y+$dy); - $c1 = $cscale*($z1-$zmin); - $c2 = $cscale*($z2-$zmin); - $c3 = $cscale*($z3-$zmin); - $c4 = $cscale*($z4-$zmin); - $c = ($c1+$c2+$c3+$c4)/4; - if ($c < 0) { $c = 0; } - if ($c > 239) { $c = 239; } - $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -$frame->writeGIF($cmap,"image.gif"); -print "Wrote image.gif\n"; - -?> diff --git a/Examples/GIFPlot/Php4/simple/Makefile b/Examples/GIFPlot/Php4/simple/Makefile deleted file mode 100644 index 6903bec0b..000000000 --- a/Examples/GIFPlot/Php4/simple/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -noproxy -SRCS = -TARGET = php_simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 - -clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean - rm -f *.gif - rm -f php_simple.h - -check: all diff --git a/Examples/GIFPlot/Php4/simple/README b/Examples/GIFPlot/Php4/simple/README deleted file mode 100644 index c2c799a70..000000000 --- a/Examples/GIFPlot/Php4/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.pl' runs the example. - - diff --git a/Examples/GIFPlot/Php4/simple/runme.php4 b/Examples/GIFPlot/Php4/simple/runme.php4 deleted file mode 100644 index cf21a0927..000000000 --- a/Examples/GIFPlot/Php4/simple/runme.php4 +++ /dev/null @@ -1,32 +0,0 @@ - - diff --git a/Examples/GIFPlot/Php4/simple/simple.i b/Examples/GIFPlot/Php4/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Php4/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Pike/check.list b/Examples/GIFPlot/Pike/check.list deleted file mode 100644 index d38998cab..000000000 --- a/Examples/GIFPlot/Pike/check.list +++ /dev/null @@ -1,2 +0,0 @@ -# see top-level Makefile.in -simple diff --git a/Examples/GIFPlot/Pike/simple/Makefile b/Examples/GIFPlot/Pike/simple/Makefile deleted file mode 100644 index d339e0333..000000000 --- a/Examples/GIFPlot/Pike/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static - -clean:: - $(MAKE) -f $(TOP)/Makefile pike_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Pike/simple/README b/Examples/GIFPlot/Pike/simple/README deleted file mode 100644 index 177b3633b..000000000 --- a/Examples/GIFPlot/Pike/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.pike' runs the example. - - diff --git a/Examples/GIFPlot/Pike/simple/runme.pike b/Examples/GIFPlot/Pike/simple/runme.pike deleted file mode 100644 index 0e70235f1..000000000 --- a/Examples/GIFPlot/Pike/simple/runme.pike +++ /dev/null @@ -1,30 +0,0 @@ -int main() -{ - // Draw some simple shapes - write("Drawing some basic shapes\n"); - - .simple.ColorMap cmap = .simple.new_ColorMap(); - .simple.FrameBuffer f = .simple.new_FrameBuffer(400, 400); - - // Clear the picture - .simple.FrameBuffer_clear(f, .simple.BLACK); - - // Make a red box - .simple.FrameBuffer_box(f, 40, 40, 200, 200, .simple.RED); - - // Make a blue circle - .simple.FrameBuffer_circle(f, 200, 200, 40, .simple.BLUE); - - // Make green line - .simple.FrameBuffer_line(f, 10, 390, 390, 200, .simple.GREEN); - - // Write an image out to disk - .simple.FrameBuffer_writeGIF(f, cmap, "image.gif"); - write("Wrote image.gif\n"); - - .simple.delete_FrameBuffer(f); - .simple.delete_ColorMap(cmap); - - return 0; -} - diff --git a/Examples/GIFPlot/Pike/simple/simple.i b/Examples/GIFPlot/Pike/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Pike/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Python/check.list b/Examples/GIFPlot/Python/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Python/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile deleted file mode 100644 index 83a7c864b..000000000 --- a/Examples/GIFPlot/Python/full/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/full/README b/Examples/GIFPlot/Python/full/README deleted file mode 100644 index 52971e40a..000000000 --- a/Examples/GIFPlot/Python/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.py' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Python/full/cmap b/Examples/GIFPlot/Python/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 - Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - x = x + dx - -print "Making a nice 3D plot..." -drawsolid() - -FrameBuffer_writeGIF(frame,cmap,"image.gif") -print "Wrote image.gif" - diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile deleted file mode 100644 index 73fca9673..000000000 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/README b/Examples/GIFPlot/Python/shadow/README deleted file mode 100644 index aa761e240..000000000 --- a/Examples/GIFPlot/Python/shadow/README +++ /dev/null @@ -1,8 +0,0 @@ -This example illustrates Python shadow classes. Take a look at -the file GIFPlot/Interface/gifplot.i - - - - - - diff --git a/Examples/GIFPlot/Python/shadow/cmap b/Examples/GIFPlot/Python/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 - p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - x = x + dx - -print "Making a nice 3D plot..." -drawsolid() - -frame.writeGIF(cmap,"image.gif") -print "Wrote image.gif" - diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile deleted file mode 100644 index 9fc9a6c72..000000000 --- a/Examples/GIFPlot/Python/simple/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/README b/Examples/GIFPlot/Python/simple/README deleted file mode 100644 index 22152c665..000000000 --- a/Examples/GIFPlot/Python/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.py' runs the example. - - diff --git a/Examples/GIFPlot/Python/simple/runme.py b/Examples/GIFPlot/Python/simple/runme.py deleted file mode 100644 index dade67767..000000000 --- a/Examples/GIFPlot/Python/simple/runme.py +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -print "Drawing some basic shapes" -import simple - -cmap = simple.new_ColorMap() -f = simple.new_FrameBuffer(400,400) - -# Clear the picture -simple.FrameBuffer_clear(f,simple.BLACK) - -# Make a red box -simple.FrameBuffer_box(f,40,40,200,200,simple.RED) - -# Make a blue circle -simple.FrameBuffer_circle(f,200,200,40,simple.BLUE) - -# Make green line -simple.FrameBuffer_line(f,10,390,390,200, simple.GREEN) - -# Write an image out to disk - -simple.FrameBuffer_writeGIF(f,cmap,"image.gif") -print "Wrote image.gif" - -simple.delete_FrameBuffer(f) -simple.delete_ColorMap(cmap) - diff --git a/Examples/GIFPlot/Python/simple/simple.i b/Examples/GIFPlot/Python/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Python/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/README b/Examples/GIFPlot/README deleted file mode 100644 index ac1025a42..000000000 --- a/Examples/GIFPlot/README +++ /dev/null @@ -1,59 +0,0 @@ -GIFPlot -======= - -To illustrate various SWIG features, the following examples involve -building an interface to a small, but somewhat useful graphics library -for creating 2D and 3D images in the form of GIF files. The Perl, -Python, Tcl, Java, Ruby etc. directories contain various examples specific to -those languages. - -This library was originally developed as part of the SPaSM molecular -dynamics project at Los Alamos National Laboratory. However, due to -patent enforcement issues related to LZW encoding and a general lack -of time on the part of the author, the library was never officially -released. On the plus side, a number of people have found it to be a -useful easter egg within the SWIG distribution :-). - - -DUE TO PATENT RESTRICTIONS ON THE LZW COMPRESSION ALGORITHM, THIS -LIBRARY ONLY PRODUCES UNCOMPRESSED GIF FILES. SO THERE. - - -Building the Library -==================== - -In order to run the examples, it is first necessary to build the GIFPlot -C library. To do this, simply run make: - - make - -Running the Examples -==================== - -Once the library has been built, go to your chosen language directory, -that is, Perl, Python, Tcl, Java, Ruby etc. Each example should have a -README file with a description. - -Each example can be compiled using the makefile in each example directory. This -makefile uses the top level makefile in the "Examples" directory of the distribution. -If the example doesn't compile, you will need to adjust the settings in this file. - -Documentation -============= - -Read the source Luke. The examples should be pretty much self-explanatory. -The header file Include/gifplot.h contains the full API. - -The original documentation for the library can be found online at: - - http://www.dabeaz.com/gifplot/index.html - - -Let me know what you think! -=========================== -If you found this example to be useful, confusing, or otherwise, I would like to know -about it. Suggestions for improvement are welcome. - --- Dave (dave@dabeaz.com) - - diff --git a/Examples/GIFPlot/Ruby/check.list b/Examples/GIFPlot/Ruby/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Ruby/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Ruby/full/Makefile b/Examples/GIFPlot/Ruby/full/Makefile deleted file mode 100644 index 5af8bc832..000000000 --- a/Examples/GIFPlot/Ruby/full/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/full/README b/Examples/GIFPlot/Ruby/full/README deleted file mode 100644 index 22af6cb06..000000000 --- a/Examples/GIFPlot/Ruby/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.rb' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Ruby/full/cmap b/Examples/GIFPlot/Ruby/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 - Plot3D_solidquad(P3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - end - x = x + dx - end -end - -puts "Making a nice 3D plot..." -drawsolid() - -FrameBuffer_writeGIF(frame,cmap,"image.gif") -puts "Wrote image.gif" diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile deleted file mode 100644 index ea382ea88..000000000 --- a/Examples/GIFPlot/Ruby/shadow/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/shadow/README b/Examples/GIFPlot/Ruby/shadow/README deleted file mode 100644 index 7a33e137f..000000000 --- a/Examples/GIFPlot/Ruby/shadow/README +++ /dev/null @@ -1,5 +0,0 @@ -This example illustrates Ruby shadow classes. Take a look at -the file GIFPlot/Interface/gifplot.i - -Actually Ruby module of SWIG needs no shadow class. But this example -is named "shadow" in order to be consistent with other languages. diff --git a/Examples/GIFPlot/Ruby/shadow/cmap b/Examples/GIFPlot/Ruby/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 - P3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - end - x = x + dx - end -end - -puts "Making a nice 3D plot..." -drawsolid() - -frame.writeGIF(cmap,"image.gif") -puts "Wrote image.gif" - diff --git a/Examples/GIFPlot/Ruby/simple/Makefile b/Examples/GIFPlot/Ruby/simple/Makefile deleted file mode 100644 index f7ca1a7d8..000000000 --- a/Examples/GIFPlot/Ruby/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/simple/README b/Examples/GIFPlot/Ruby/simple/README deleted file mode 100644 index 9b51038bf..000000000 --- a/Examples/GIFPlot/Ruby/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.rb' runs the example. - - diff --git a/Examples/GIFPlot/Ruby/simple/runme.rb b/Examples/GIFPlot/Ruby/simple/runme.rb deleted file mode 100644 index e8bf5a40f..000000000 --- a/Examples/GIFPlot/Ruby/simple/runme.rb +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -puts "Drawing some basic shapes" -require 'simple' - -cmap = Simple.new_ColorMap() -f = Simple.new_FrameBuffer(400,400) - -# Clear the picture -Simple.FrameBuffer_clear(f,Simple::BLACK) - -# Make a red box -Simple.FrameBuffer_box(f,40,40,200,200,Simple::RED) - -# Make a blue circle -Simple.FrameBuffer_circle(f,200,200,40,Simple::BLUE) - -# Make green line -Simple.FrameBuffer_line(f,10,390,390,200, Simple::GREEN) - -# Write an image out to disk - -Simple.FrameBuffer_writeGIF(f,cmap,"image.gif") -puts "Wrote image.gif" - -Simple.delete_FrameBuffer(f) -Simple.delete_ColorMap(cmap) - diff --git a/Examples/GIFPlot/Ruby/simple/simple.i b/Examples/GIFPlot/Ruby/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Ruby/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Tcl/check.list b/Examples/GIFPlot/Tcl/check.list deleted file mode 100644 index 2b6e3d28a..000000000 --- a/Examples/GIFPlot/Tcl/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -mandel -simple diff --git a/Examples/GIFPlot/Tcl/full/Makefile b/Examples/GIFPlot/Tcl/full/Makefile deleted file mode 100644 index 0c016e364..000000000 --- a/Examples/GIFPlot/Tcl/full/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/full/README b/Examples/GIFPlot/Tcl/full/README deleted file mode 100644 index bdba4e8b0..000000000 --- a/Examples/GIFPlot/Tcl/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.tcl' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Tcl/full/cmap b/Examples/GIFPlot/Tcl/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239} { set c 239 } - Plot3D_solidquad $p3 $x $y $z1 [expr {$x+$dx}] $y $z2 [expr {$x+$dx}] [expr {$y+$dy}] $z3 $x [expr {$y+$dy}] $z4 [expr {$c+16}] - set y [expr {$y + $dy}] - } - set x [expr {$x + $dx}] - } -} - -puts "Making a nice 3D plot..." -drawsolid - -FrameBuffer_writeGIF $frame $cmap "image.gif" -puts "Wrote image.gif" - diff --git a/Examples/GIFPlot/Tcl/mandel/Makefile b/Examples/GIFPlot/Tcl/mandel/Makefile deleted file mode 100644 index 9280d7bb2..000000000 --- a/Examples/GIFPlot/Tcl/mandel/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = mandel.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mywish' INTERFACE='$(INTERFACE)' wish - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/mandel/README b/Examples/GIFPlot/Tcl/mandel/README deleted file mode 100644 index a533d09b8..000000000 --- a/Examples/GIFPlot/Tcl/mandel/README +++ /dev/null @@ -1,6 +0,0 @@ -Kill lots of time exploring the Mandelbrot set. This example uses -the full SWIG interface file located in ../../Interface. To run -the program, type 'wish mandel.tcl'. - - - diff --git a/Examples/GIFPlot/Tcl/mandel/cmap b/Examples/GIFPlot/Tcl/mandel/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC {BoxBegin %W %x %y} - bind $c {BoxDrag %W %x %y} - bind $c "BoxFinish %W %x %y $p2 $mxmin $mymin $mxmax $mymax $func" -} - -proc BoxBegin {w x y} { - global box - set box(anchor) [list $x $y] - catch {unset box(last)} -} - -proc BoxDrag { w x y} { - global box - catch {$w delete $box(last)} - set box(last) [eval {$w create rect} $box(anchor) {$x $y -tag box -outline white}] -} - -proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { - global box - set start $box(anchor) - set x1 [lrange $start 0 0] - set y1 [lrange $start 1 1] - catch {$w delete $box(last)} -# Call the handler function - $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $x $y -} - -proc display_image {filename p2 handler} { - global __imageno __images - set i [image create photo -file $filename] - set tl .image$__imageno - toplevel $tl - frame $tl.img - frame $tl.button - - set width [image width $i] - set height [image height $i] - canvas $tl.img.c -width [expr {$width+0}] -height [expr {$height+0}] - pack $tl.img.c - $tl.img.c create image 0 0 -image $i -anchor nw - label $tl.button.label -text $filename - pack $tl.button.label -side left - button $tl.button.dismiss -text "Dismiss" -command "dismiss $tl $i" -width 10 - pack $tl.button.dismiss -side right - pack $tl.img $tl.button -side top -fill x - BoxInit $tl.img.c $p2 [$p2 cget -xmin] [$p2 cget -ymin] [$p2 cget -xmax] [$p2 cget -ymax] $handler - bind $tl "dismiss $tl $i" - bind $tl "dismiss $tl $i" - - # Bind some actions to the canvas - - incr __imageno 1 -} - -proc test {} { - puts "hello" -} - diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.i b/Examples/GIFPlot/Tcl/mandel/mandel.i deleted file mode 100644 index 0b19f4727..000000000 --- a/Examples/GIFPlot/Tcl/mandel/mandel.i +++ /dev/null @@ -1,47 +0,0 @@ -// Special module to run the mandlebrot set -%module gifplot -%include gifplot.i - -%inline %{ - -void mandel(Plot2D *p2, int tol) { - double scalingx; - double scalingy; - double zr,zi,ztr,zti,cr,ci; - double cscale; - int i,j,n; - FrameBuffer *f; - - f = p2->frame; - scalingx = (p2->xmax-p2->xmin)/f->width; - scalingy = (p2->ymax-p2->ymin)/f->height; - - cscale = 239.0/tol; - printf("working...\n"); - for (i = 0; i < f->width; i++) { - for (j = 0; j < f->height; j++) { - zr = scalingx*i + p2->xmin; - zi = scalingy*j + p2->ymin; - cr = zr; - ci = zi; - n = 0; - while (n < tol) { - ztr = zr*zr-zi*zi + cr; - zti = 2*zr*zi + ci; - zr = ztr; - zi = zti; - if (ztr*ztr + zti*zti > 20) break; - n = n + 1; - } - - if (n >= tol) FrameBuffer_plot(f,i,j,BLACK); - else FrameBuffer_plot(f,i,j,16+(int) (n*cscale)); - } - if ((i % 10) == 0) printf("%d\n",i); - } - -} - -%} - - diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.tcl b/Examples/GIFPlot/Tcl/mandel/mandel.tcl deleted file mode 100644 index 3e1600bc1..000000000 --- a/Examples/GIFPlot/Tcl/mandel/mandel.tcl +++ /dev/null @@ -1,170 +0,0 @@ -catch { load ./gifplot[info sharedlibextension] } -source display.tcl -set tcl_precision 17 -set f [FrameBuffer -args 400 400] -set cmap [ColorMap -args cmap] -set p2 [Plot2D -args $f -3 -2 1 2] - -set xmin -3 -set xmax 1 -set ymin -2.0 -set ymax 2.0 -set tolerance 240 -set filename mandel.gif - -# Make a plot from the above parms - -proc make_plot {} { - global p2 cmap tolerance - global xmin ymin xmax ymax filename - $p2 setrange $xmin $ymin $xmax $ymax - $p2 start - . config -cursor watch - update - mandel $p2 $tolerance - . config -cursor arrow - [$p2 cget -frame] writeGIF $cmap $filename - display_image $filename $p2 set_zoom -} - - -# Take some screen coordinates and set global min and max values - -proc set_zoom {p2 mxmin mymin mxmax mymax x1 y1 x2 y2} { - global xmin ymin xmax ymax - - set frame [$p2 cget -frame] - set width [$frame cget -width] - set height [$frame cget -height] - - if {$x1 < 0} {set x1 0} - if {$x1 > ($width)} {set x1 $width} - if {$x2 < 0} {set x2 0} - if {$x2 > ($width)} {set x2 $width} - if {$x1 < $x2} {set ixmin $x1; set ixmax $x2} {set ixmin $x2; set ixmax $x1} - - if {$y1 < 0} {set y1 0} - if {$y1 > ($height)} {set y1 $height} - if {$y2 < 0} {set y2 0} - if {$y2 > ($height)} {set y2 $height} - if {$y1 < $y2} {set iymin $y1; set iymax $y2} {set iymin $y2; set iymax $y1} - - # Now determine new min and max values based on screen location - - set xmin [expr {$mxmin + ($mxmax-$mxmin)*($ixmin)/($width)}] - set xmax [expr {$mxmin + ($mxmax-$mxmin)*($ixmax)/($width)}] - set ymin [expr {$mymin + ($mymax-$mymin)*(($height)-($iymax))/($height)}] - set ymax [expr {$mymin + ($mymax-$mymin)*(($height)-($iymin))/($height)}] - - catch {make_plot} -} - -# Box drag constrained to a square -proc BoxDrag { w x y} { - global box - catch {$w delete $box(last)} - set x1 [lrange $box(anchor) 0 0] - set y1 [lrange $box(anchor) 1 1] - set dx [expr {$x - $x1}] - set dy [expr {$y - $y1}] - if {abs($dy) > abs($dx)} {set dx $dy} - set newx [expr {$x1 + $dx}] - set newy [expr {$y1 + $dx}] - set box(last) [eval {$w create rect} $box(anchor) {$newx $newy -tag box -outline white}] -} - - -proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { - global box - set start $box(anchor) - set x1 [lrange $box(anchor) 0 0] - set y1 [lrange $box(anchor) 1 1] - set dx [expr {$x - $x1}] - set dy [expr {$y - $y1}] - if {($dx == 0) || ($dy == 0)} { - catch {$w delete $box(last)} - return - } - if {abs($dy) > abs($dx)} {set dx $dy} - set newx [expr {$x1 + $dx}] - set newy [expr {$y1 + $dx}] - $w config -cursor watch - update -# Call the handler function - $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $newx $newy - catch {$w delete $box(last)} - $w config -cursor arrow -} - - -# Create a few frames - -wm title . Mandelbrot -frame .title -relief groove -borderwidth 1 -label .title.name -text "Mandelbrot Set" -button .title.quit -text "Quit" -command "exit" -button .title.about -text "About" -command "about" -pack .title.name -side left -pack .title.quit .title.about -side right - -frame .func -relief groove -borderwidth 1 - -frame .func.xrange -label .func.xrange.xrlabel -text "X range" -width 12 -entry .func.xrange.xmin -textvar xmin -width 8 -label .func.xrange.xtolabel -text "to" -entry .func.xrange.xmax -textvar xmax -width 8 -pack .func.xrange.xrlabel .func.xrange.xmin .func.xrange.xtolabel .func.xrange.xmax -side left - -frame .func.yrange -label .func.yrange.yrlabel -text "Y range" -width 12 -entry .func.yrange.ymin -textvar ymin -width 8 -label .func.yrange.ytolabel -text "to" -entry .func.yrange.ymax -textvar ymax -width 8 -pack .func.yrange.yrlabel .func.yrange.ymin .func.yrange.ytolabel .func.yrange.ymax -side left - -frame .func.npoints -label .func.npoints.label -text "Tolerance " -width 12 -entry .func.npoints.npoints -textvar tolerance -width 8 -scale .func.npoints.scale -from 0 -to 2500 -variable tolerance -orient horizontal -showvalue false \ - -sliderlength 13 -bigincrement 10 -resolution 10 -pack .func.npoints.label .func.npoints.npoints .func.npoints.scale -side left - -pack .func.xrange .func.yrange .func.npoints -side top -fill x - -# Filename dialog - -frame .save -relief groove -borderwidth 1 - -frame .save.file -label .save.file.label -text "Save as" -width 12 -entry .save.file.filename -textvar filename -width 20 -pack .save.file.label .save.file.filename -side left -pack .save.file -side left -fill x -button .save.go -text "Plot" -command "make_plot" -pack .save.go -side right - -bind .save.file.filename {make_plot} - -pack .title .func .save -side top -fill both - -proc about { } { - toplevel .about -width 350 - - message .about.m -text "\ -Mandelbrot Set\n\n\ -Copyright (c) 1997\n\ -Dave Beazley\n\ -University of Utah\n\n\ -Creates a plot of the Mandelbrot set. Any displayed image can be zoomed by clicking and \ -dragging. Although the main calculation is written in C, it may take awhile for each \ -image to be calculated (be patient). Image quality can be improved at the expense of speed \ -by increasing the tolerance value.\n" - -button .about.okay -text "Ok" -command {destroy .about} - -pack .about.m .about.okay -side top -focus .about.okay -} - -make_plot diff --git a/Examples/GIFPlot/Tcl/simple/Makefile b/Examples/GIFPlot/Tcl/simple/Makefile deleted file mode 100644 index 752d79c10..000000000 --- a/Examples/GIFPlot/Tcl/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/simple/README b/Examples/GIFPlot/Tcl/simple/README deleted file mode 100644 index d6b291c92..000000000 --- a/Examples/GIFPlot/Tcl/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -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. The script 'runme.tcl' runs the example. - - diff --git a/Examples/GIFPlot/Tcl/simple/runme.tcl b/Examples/GIFPlot/Tcl/simple/runme.tcl deleted file mode 100644 index e3f41266c..000000000 --- a/Examples/GIFPlot/Tcl/simple/runme.tcl +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -puts "Drawing some basic shapes" - -catch { load ./simple[info sharedlibextension] simple} - -set cmap [new_ColorMap] -set f [new_FrameBuffer 400 400] - -# Clear the picture -FrameBuffer_clear $f $BLACK - -# Make a red box -FrameBuffer_box $f 40 40 200 200 $RED - -# Make a blue circle -FrameBuffer_circle $f 200 200 40 $BLUE - -# Make green line -FrameBuffer_line $f 10 390 390 200 $GREEN - -# Write an image out to disk -FrameBuffer_writeGIF $f $cmap image.gif -puts "Wrote image.gif" - -delete_FrameBuffer $f -delete_ColorMap $cmap - diff --git a/Examples/GIFPlot/Tcl/simple/simple.i b/Examples/GIFPlot/Tcl/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Tcl/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/chicken/zlib/Makefile b/Examples/chicken/zlib/Makefile deleted file mode 100644 index 720701444..000000000 --- a/Examples/chicken/zlib/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = -CXXSRCS = -TARGET = zlib -INCLUDE = -SWIGOPT = -I/usr/include -CFLAGS = -VARIANT = -LIBS = -lz -VARIANT = _direct - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f example.scm - rm -f $(TARGET) - -check:: - csi test-zlib.scm diff --git a/Examples/chicken/zlib/README.html b/Examples/chicken/zlib/README.html deleted file mode 100644 index b082a310c..000000000 --- a/Examples/chicken/zlib/README.html +++ /dev/null @@ -1,1666 +0,0 @@ - - - - zlib - Chicken - SWIG example - - -

    zlib - Chicken - SWIG

    - -

    Table of Contents

    - Building the example
    - zlib.h
    - How the zlib wrapper was developed
    - -

    Building the example

    - - zlib must be installed for this example to work.
    - - Just type make to build this example.
    - - If zlib is not installed in /usr/lib and /usr/include, then do - something similar to the following: - -
    -
    make SWIGOPT="-I/usr/local/include" LIBS="-L/usr/local/lib -lz"
    -
    - -

    zlib.h

    -
    -
    -001: /* zlib.h -- interface of the 'zlib' general purpose compression library
    -002:   version 1.1.4, March 11th, 2002
    -003: 
    -004:   Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler
    -005: 
    -006:   This software is provided 'as-is', without any express or implied
    -007:   warranty.  In no event will the authors be held liable for any damages
    -008:   arising from the use of this software.
    -009: 
    -010:   Permission is granted to anyone to use this software for any purpose,
    -011:   including commercial applications, and to alter it and redistribute it
    -012:   freely, subject to the following restrictions:
    -013: 
    -014:   1. The origin of this software must not be misrepresented; you must not
    -015:      claim that you wrote the original software. If you use this software
    -016:      in a product, an acknowledgment in the product documentation would be
    -017:      appreciated but is not required.
    -018:   2. Altered source versions must be plainly marked as such, and must not be
    -019:      misrepresented as being the original software.
    -020:   3. This notice may not be removed or altered from any source distribution.
    -021: 
    -022:   Jean-loup Gailly        Mark Adler
    -023:   jloup@gzip.org          madler@alumni.caltech.edu
    -024: 
    -025: 
    -026:   The data format used by the zlib library is described by RFCs (Request for
    -027:   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
    -028:   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
    -029: */
    -030: 
    -031: #ifndef _ZLIB_H
    -032: #define _ZLIB_H
    -033: 
    -034: #include "zconf.h"
    -035: 
    -036: #ifdef __cplusplus
    -037: extern "C" {
    -038: #endif
    -039: 
    -040: #define ZLIB_VERSION "1.1.4"
    -041: 
    -042: /* 
    -043:      The 'zlib' compression library provides in-memory compression and
    -044:   decompression functions, including integrity checks of the uncompressed
    -045:   data.  This version of the library supports only one compression method
    -046:   (deflation) but other algorithms will be added later and will have the same
    -047:   stream interface.
    -048: 
    -049:      Compression can be done in a single step if the buffers are large
    -050:   enough (for example if an input file is mmap'ed), or can be done by
    -051:   repeated calls of the compression function.  In the latter case, the
    -052:   application must provide more input and/or consume the output
    -053:   (providing more output space) before each call.
    -054: 
    -055:      The library also supports reading and writing files in gzip (.gz) format
    -056:   with an interface similar to that of stdio.
    -057: 
    -058:      The library does not install any signal handler. The decoder checks
    -059:   the consistency of the compressed data, so the library should never
    -060:   crash even in case of corrupted input.
    -061: */
    -062: 
    -063: typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
    -064: typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
    -065: 
    -066: struct internal_state;
    -067: 
    -068: typedef struct z_stream_s {
    -069:     Bytef    *next_in;  /* next input byte */
    -070:     uInt     avail_in;  /* number of bytes available at next_in */
    -071:     uLong    total_in;  /* total nb of input bytes read so far */
    -072: 
    -073:     Bytef    *next_out; /* next output byte should be put there */
    -074:     uInt     avail_out; /* remaining free space at next_out */
    -075:     uLong    total_out; /* total nb of bytes output so far */
    -076: 
    -077:     char     *msg;      /* last error message, NULL if no error */
    -078:     struct internal_state FAR *state; /* not visible by applications */
    -079: 
    -080:     alloc_func zalloc;  /* used to allocate the internal state */
    -081:     free_func  zfree;   /* used to free the internal state */
    -082:     voidpf     opaque;  /* private data object passed to zalloc and zfree */
    -083: 
    -084:     int     data_type;  /* best guess about the data type: ascii or binary */
    -085:     uLong   adler;      /* adler32 value of the uncompressed data */
    -086:     uLong   reserved;   /* reserved for future use */
    -087: } z_stream;
    -088: 
    -089: typedef z_stream FAR *z_streamp;
    -090: 
    -091: /*
    -092:    The application must update next_in and avail_in when avail_in has
    -093:    dropped to zero. It must update next_out and avail_out when avail_out
    -094:    has dropped to zero. The application must initialize zalloc, zfree and
    -095:    opaque before calling the init function. All other fields are set by the
    -096:    compression library and must not be updated by the application.
    -097: 
    -098:    The opaque value provided by the application will be passed as the first
    -099:    parameter for calls of zalloc and zfree. This can be useful for custom
    -100:    memory management. The compression library attaches no meaning to the
    -101:    opaque value.
    -102: 
    -103:    zalloc must return Z_NULL if there is not enough memory for the object.
    -104:    If zlib is used in a multi-threaded application, zalloc and zfree must be
    -105:    thread safe.
    -106: 
    -107:    On 16-bit systems, the functions zalloc and zfree must be able to allocate
    -108:    exactly 65536 bytes, but will not be required to allocate more than this
    -109:    if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
    -110:    pointers returned by zalloc for objects of exactly 65536 bytes *must*
    -111:    have their offset normalized to zero. The default allocation function
    -112:    provided by this library ensures this (see zutil.c). To reduce memory
    -113:    requirements and avoid any allocation of 64K objects, at the expense of
    -114:    compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
    -115: 
    -116:    The fields total_in and total_out can be used for statistics or
    -117:    progress reports. After compression, total_in holds the total size of
    -118:    the uncompressed data and may be saved for use in the decompressor
    -119:    (particularly if the decompressor wants to decompress everything in
    -120:    a single step).
    -121: */
    -122: 
    -123:                         /* constants */
    -124: 
    -125: #define Z_NO_FLUSH      0
    -126: #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
    -127: #define Z_SYNC_FLUSH    2
    -128: #define Z_FULL_FLUSH    3
    -129: #define Z_FINISH        4
    -130: /* Allowed flush values; see deflate() below for details */
    -131: 
    -132: #define Z_OK            0
    -133: #define Z_STREAM_END    1
    -134: #define Z_NEED_DICT     2
    -135: #define Z_ERRNO        (-1)
    -136: #define Z_STREAM_ERROR (-2)
    -137: #define Z_DATA_ERROR   (-3)
    -138: #define Z_MEM_ERROR    (-4)
    -139: #define Z_BUF_ERROR    (-5)
    -140: #define Z_VERSION_ERROR (-6)
    -141: /* Return codes for the compression/decompression functions. Negative
    -142:  * values are errors, positive values are used for special but normal events.
    -143:  */
    -144: 
    -145: #define Z_NO_COMPRESSION         0
    -146: #define Z_BEST_SPEED             1
    -147: #define Z_BEST_COMPRESSION       9
    -148: #define Z_DEFAULT_COMPRESSION  (-1)
    -149: /* compression levels */
    -150: 
    -151: #define Z_FILTERED            1
    -152: #define Z_HUFFMAN_ONLY        2
    -153: #define Z_DEFAULT_STRATEGY    0
    -154: /* compression strategy; see deflateInit2() below for details */
    -155: 
    -156: #define Z_BINARY   0
    -157: #define Z_ASCII    1
    -158: #define Z_UNKNOWN  2
    -159: /* Possible values of the data_type field */
    -160: 
    -161: #define Z_DEFLATED   8
    -162: /* The deflate compression method (the only one supported in this version) */
    -163: 
    -164: #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
    -165: 
    -166: #define zlib_version zlibVersion()
    -167: /* for compatibility with versions < 1.0.2 */
    -168: 
    -169:                         /* basic functions */
    -170: 
    -171: ZEXTERN const char * ZEXPORT zlibVersion OF((void));
    -172: /* The application can compare zlibVersion and ZLIB_VERSION for consistency.
    -173:    If the first character differs, the library code actually used is
    -174:    not compatible with the zlib.h header file used by the application.
    -175:    This check is automatically made by deflateInit and inflateInit.
    -176:  */
    -177: 
    -178: /* 
    -179: ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
    -180: 
    -181:      Initializes the internal stream state for compression. The fields
    -182:    zalloc, zfree and opaque must be initialized before by the caller.
    -183:    If zalloc and zfree are set to Z_NULL, deflateInit updates them to
    -184:    use default allocation functions.
    -185: 
    -186:      The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
    -187:    1 gives best speed, 9 gives best compression, 0 gives no compression at
    -188:    all (the input data is simply copied a block at a time).
    -189:    Z_DEFAULT_COMPRESSION requests a default compromise between speed and
    -190:    compression (currently equivalent to level 6).
    -191: 
    -192:      deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
    -193:    enough memory, Z_STREAM_ERROR if level is not a valid compression level,
    -194:    Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
    -195:    with the version assumed by the caller (ZLIB_VERSION).
    -196:    msg is set to null if there is no error message.  deflateInit does not
    -197:    perform any compression: this will be done by deflate().
    -198: */
    -199: 
    -200: 
    -201: ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
    -202: /*
    -203:     deflate compresses as much data as possible, and stops when the input
    -204:   buffer becomes empty or the output buffer becomes full. It may introduce some
    -205:   output latency (reading input without producing any output) except when
    -206:   forced to flush.
    -207: 
    -208:     The detailed semantics are as follows. deflate performs one or both of the
    -209:   following actions:
    -210: 
    -211:   - Compress more input starting at next_in and update next_in and avail_in
    -212:     accordingly. If not all input can be processed (because there is not
    -213:     enough room in the output buffer), next_in and avail_in are updated and
    -214:     processing will resume at this point for the next call of deflate().
    -215: 
    -216:   - Provide more output starting at next_out and update next_out and avail_out
    -217:     accordingly. This action is forced if the parameter flush is non zero.
    -218:     Forcing flush frequently degrades the compression ratio, so this parameter
    -219:     should be set only when necessary (in interactive applications).
    -220:     Some output may be provided even if flush is not set.
    -221: 
    -222:   Before the call of deflate(), the application should ensure that at least
    -223:   one of the actions is possible, by providing more input and/or consuming
    -224:   more output, and updating avail_in or avail_out accordingly; avail_out
    -225:   should never be zero before the call. The application can consume the
    -226:   compressed output when it wants, for example when the output buffer is full
    -227:   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
    -228:   and with zero avail_out, it must be called again after making room in the
    -229:   output buffer because there might be more output pending.
    -230: 
    -231:     If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
    -232:   flushed to the output buffer and the output is aligned on a byte boundary, so
    -233:   that the decompressor can get all input data available so far. (In particular
    -234:   avail_in is zero after the call if enough output space has been provided
    -235:   before the call.)  Flushing may degrade compression for some compression
    -236:   algorithms and so it should be used only when necessary.
    -237: 
    -238:     If flush is set to Z_FULL_FLUSH, all output is flushed as with
    -239:   Z_SYNC_FLUSH, and the compression state is reset so that decompression can
    -240:   restart from this point if previous compressed data has been damaged or if
    -241:   random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
    -242:   the compression.
    -243: 
    -244:     If deflate returns with avail_out == 0, this function must be called again
    -245:   with the same value of the flush parameter and more output space (updated
    -246:   avail_out), until the flush is complete (deflate returns with non-zero
    -247:   avail_out).
    -248: 
    -249:     If the parameter flush is set to Z_FINISH, pending input is processed,
    -250:   pending output is flushed and deflate returns with Z_STREAM_END if there
    -251:   was enough output space; if deflate returns with Z_OK, this function must be
    -252:   called again with Z_FINISH and more output space (updated avail_out) but no
    -253:   more input data, until it returns with Z_STREAM_END or an error. After
    -254:   deflate has returned Z_STREAM_END, the only possible operations on the
    -255:   stream are deflateReset or deflateEnd.
    -256:   
    -257:     Z_FINISH can be used immediately after deflateInit if all the compression
    -258:   is to be done in a single step. In this case, avail_out must be at least
    -259:   0.1% larger than avail_in plus 12 bytes.  If deflate does not return
    -260:   Z_STREAM_END, then it must be called again as described above.
    -261: 
    -262:     deflate() sets strm->adler to the adler32 checksum of all input read
    -263:   so far (that is, total_in bytes).
    -264: 
    -265:     deflate() may update data_type if it can make a good guess about
    -266:   the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered
    -267:   binary. This field is only for information purposes and does not affect
    -268:   the compression algorithm in any manner.
    -269: 
    -270:     deflate() returns Z_OK if some progress has been made (more input
    -271:   processed or more output produced), Z_STREAM_END if all input has been
    -272:   consumed and all output has been produced (only when flush is set to
    -273:   Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
    -274:   if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
    -275:   (for example avail_in or avail_out was zero).
    -276: */
    -277: 
    -278: 
    -279: ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
    -280: /*
    -281:      All dynamically allocated data structures for this stream are freed.
    -282:    This function discards any unprocessed input and does not flush any
    -283:    pending output.
    -284: 
    -285:      deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
    -286:    stream state was inconsistent, Z_DATA_ERROR if the stream was freed
    -287:    prematurely (some input or output was discarded). In the error case,
    -288:    msg may be set but then points to a static string (which must not be
    -289:    deallocated).
    -290: */
    -291: 
    -292: 
    -293: /* 
    -294: ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
    -295: 
    -296:      Initializes the internal stream state for decompression. The fields
    -297:    next_in, avail_in, zalloc, zfree and opaque must be initialized before by
    -298:    the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
    -299:    value depends on the compression method), inflateInit determines the
    -300:    compression method from the zlib header and allocates all data structures
    -301:    accordingly; otherwise the allocation will be deferred to the first call of
    -302:    inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
    -303:    use default allocation functions.
    -304: 
    -305:      inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
    -306:    memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
    -307:    version assumed by the caller.  msg is set to null if there is no error
    -308:    message. inflateInit does not perform any decompression apart from reading
    -309:    the zlib header if present: this will be done by inflate().  (So next_in and
    -310:    avail_in may be modified, but next_out and avail_out are unchanged.)
    -311: */
    -312: 
    -313: 
    -314: ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
    -315: /*
    -316:     inflate decompresses as much data as possible, and stops when the input
    -317:   buffer becomes empty or the output buffer becomes full. It may some
    -318:   introduce some output latency (reading input without producing any output)
    -319:   except when forced to flush.
    -320: 
    -321:   The detailed semantics are as follows. inflate performs one or both of the
    -322:   following actions:
    -323: 
    -324:   - Decompress more input starting at next_in and update next_in and avail_in
    -325:     accordingly. If not all input can be processed (because there is not
    -326:     enough room in the output buffer), next_in is updated and processing
    -327:     will resume at this point for the next call of inflate().
    -328: 
    -329:   - Provide more output starting at next_out and update next_out and avail_out
    -330:     accordingly.  inflate() provides as much output as possible, until there
    -331:     is no more input data or no more space in the output buffer (see below
    -332:     about the flush parameter).
    -333: 
    -334:   Before the call of inflate(), the application should ensure that at least
    -335:   one of the actions is possible, by providing more input and/or consuming
    -336:   more output, and updating the next_* and avail_* values accordingly.
    -337:   The application can consume the uncompressed output when it wants, for
    -338:   example when the output buffer is full (avail_out == 0), or after each
    -339:   call of inflate(). If inflate returns Z_OK and with zero avail_out, it
    -340:   must be called again after making room in the output buffer because there
    -341:   might be more output pending.
    -342: 
    -343:     If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much
    -344:   output as possible to the output buffer. The flushing behavior of inflate is
    -345:   not specified for values of the flush parameter other than Z_SYNC_FLUSH
    -346:   and Z_FINISH, but the current implementation actually flushes as much output
    -347:   as possible anyway.
    -348: 
    -349:     inflate() should normally be called until it returns Z_STREAM_END or an
    -350:   error. However if all decompression is to be performed in a single step
    -351:   (a single call of inflate), the parameter flush should be set to
    -352:   Z_FINISH. In this case all pending input is processed and all pending
    -353:   output is flushed; avail_out must be large enough to hold all the
    -354:   uncompressed data. (The size of the uncompressed data may have been saved
    -355:   by the compressor for this purpose.) The next operation on this stream must
    -356:   be inflateEnd to deallocate the decompression state. The use of Z_FINISH
    -357:   is never required, but can be used to inform inflate that a faster routine
    -358:   may be used for the single inflate() call.
    -359: 
    -360:      If a preset dictionary is needed at this point (see inflateSetDictionary
    -361:   below), inflate sets strm-adler to the adler32 checksum of the
    -362:   dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise 
    -363:   it sets strm->adler to the adler32 checksum of all output produced
    -364:   so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or
    -365:   an error code as described below. At the end of the stream, inflate()
    -366:   checks that its computed adler32 checksum is equal to that saved by the
    -367:   compressor and returns Z_STREAM_END only if the checksum is correct.
    -368: 
    -369:     inflate() returns Z_OK if some progress has been made (more input processed
    -370:   or more output produced), Z_STREAM_END if the end of the compressed data has
    -371:   been reached and all uncompressed output has been produced, Z_NEED_DICT if a
    -372:   preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
    -373:   corrupted (input stream not conforming to the zlib format or incorrect
    -374:   adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent
    -375:   (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not
    -376:   enough memory, Z_BUF_ERROR if no progress is possible or if there was not
    -377:   enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR
    -378:   case, the application may then call inflateSync to look for a good
    -379:   compression block.
    -380: */
    -381: 
    -382: 
    -383: ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
    -384: /*
    -385:      All dynamically allocated data structures for this stream are freed.
    -386:    This function discards any unprocessed input and does not flush any
    -387:    pending output.
    -388: 
    -389:      inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
    -390:    was inconsistent. In the error case, msg may be set but then points to a
    -391:    static string (which must not be deallocated).
    -392: */
    -393: 
    -394:                         /* Advanced functions */
    -395: 
    -396: /*
    -397:     The following functions are needed only in some special applications.
    -398: */
    -399: 
    -400: /*   
    -401: ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
    -402:                                      int  level,
    -403:                                      int  method,
    -404:                                      int  windowBits,
    -405:                                      int  memLevel,
    -406:                                      int  strategy));
    -407: 
    -408:      This is another version of deflateInit with more compression options. The
    -409:    fields next_in, zalloc, zfree and opaque must be initialized before by
    -410:    the caller.
    -411: 
    -412:      The method parameter is the compression method. It must be Z_DEFLATED in
    -413:    this version of the library.
    -414: 
    -415:      The windowBits parameter is the base two logarithm of the window size
    -416:    (the size of the history buffer).  It should be in the range 8..15 for this
    -417:    version of the library. Larger values of this parameter result in better
    -418:    compression at the expense of memory usage. The default value is 15 if
    -419:    deflateInit is used instead.
    -420: 
    -421:      The memLevel parameter specifies how much memory should be allocated
    -422:    for the internal compression state. memLevel=1 uses minimum memory but
    -423:    is slow and reduces compression ratio; memLevel=9 uses maximum memory
    -424:    for optimal speed. The default value is 8. See zconf.h for total memory
    -425:    usage as a function of windowBits and memLevel.
    -426: 
    -427:      The strategy parameter is used to tune the compression algorithm. Use the
    -428:    value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
    -429:    filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no
    -430:    string match).  Filtered data consists mostly of small values with a
    -431:    somewhat random distribution. In this case, the compression algorithm is
    -432:    tuned to compress them better. The effect of Z_FILTERED is to force more
    -433:    Huffman coding and less string matching; it is somewhat intermediate
    -434:    between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects
    -435:    the compression ratio but not the correctness of the compressed output even
    -436:    if it is not set appropriately.
    -437: 
    -438:       deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    -439:    memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
    -440:    method). msg is set to null if there is no error message.  deflateInit2 does
    -441:    not perform any compression: this will be done by deflate().
    -442: */
    -443:                             
    -444: ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
    -445:                                              const Bytef *dictionary,
    -446:                                              uInt  dictLength));
    -447: /*
    -448:      Initializes the compression dictionary from the given byte sequence
    -449:    without producing any compressed output. This function must be called
    -450:    immediately after deflateInit, deflateInit2 or deflateReset, before any
    -451:    call of deflate. The compressor and decompressor must use exactly the same
    -452:    dictionary (see inflateSetDictionary).
    -453: 
    -454:      The dictionary should consist of strings (byte sequences) that are likely
    -455:    to be encountered later in the data to be compressed, with the most commonly
    -456:    used strings preferably put towards the end of the dictionary. Using a
    -457:    dictionary is most useful when the data to be compressed is short and can be
    -458:    predicted with good accuracy; the data can then be compressed better than
    -459:    with the default empty dictionary.
    -460: 
    -461:      Depending on the size of the compression data structures selected by
    -462:    deflateInit or deflateInit2, a part of the dictionary may in effect be
    -463:    discarded, for example if the dictionary is larger than the window size in
    -464:    deflate or deflate2. Thus the strings most likely to be useful should be
    -465:    put at the end of the dictionary, not at the front.
    -466: 
    -467:      Upon return of this function, strm->adler is set to the Adler32 value
    -468:    of the dictionary; the decompressor may later use this value to determine
    -469:    which dictionary has been used by the compressor. (The Adler32 value
    -470:    applies to the whole dictionary even if only a subset of the dictionary is
    -471:    actually used by the compressor.)
    -472: 
    -473:      deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
    -474:    parameter is invalid (such as NULL dictionary) or the stream state is
    -475:    inconsistent (for example if deflate has already been called for this stream
    -476:    or if the compression method is bsort). deflateSetDictionary does not
    -477:    perform any compression: this will be done by deflate().
    -478: */
    -479: 
    -480: ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
    -481:                                     z_streamp source));
    -482: /*
    -483:      Sets the destination stream as a complete copy of the source stream.
    -484: 
    -485:      This function can be useful when several compression strategies will be
    -486:    tried, for example when there are several ways of pre-processing the input
    -487:    data with a filter. The streams that will be discarded should then be freed
    -488:    by calling deflateEnd.  Note that deflateCopy duplicates the internal
    -489:    compression state which can be quite large, so this strategy is slow and
    -490:    can consume lots of memory.
    -491: 
    -492:      deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
    -493:    enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
    -494:    (such as zalloc being NULL). msg is left unchanged in both source and
    -495:    destination.
    -496: */
    -497: 
    -498: ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
    -499: /*
    -500:      This function is equivalent to deflateEnd followed by deflateInit,
    -501:    but does not free and reallocate all the internal compression state.
    -502:    The stream will keep the same compression level and any other attributes
    -503:    that may have been set by deflateInit2.
    -504: 
    -505:       deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    -506:    stream state was inconsistent (such as zalloc or state being NULL).
    -507: */
    -508: 
    -509: ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
    -510: 				      int level,
    -511: 				      int strategy));
    -512: /*
    -513:      Dynamically update the compression level and compression strategy.  The
    -514:    interpretation of level and strategy is as in deflateInit2.  This can be
    -515:    used to switch between compression and straight copy of the input data, or
    -516:    to switch to a different kind of input data requiring a different
    -517:    strategy. If the compression level is changed, the input available so far
    -518:    is compressed with the old level (and may be flushed); the new level will
    -519:    take effect only at the next call of deflate().
    -520: 
    -521:      Before the call of deflateParams, the stream state must be set as for
    -522:    a call of deflate(), since the currently available input may have to
    -523:    be compressed and flushed. In particular, strm->avail_out must be non-zero.
    -524: 
    -525:      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
    -526:    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
    -527:    if strm->avail_out was zero.
    -528: */
    -529: 
    -530: /*   
    -531: ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
    -532:                                      int  windowBits));
    -533: 
    -534:      This is another version of inflateInit with an extra parameter. The
    -535:    fields next_in, avail_in, zalloc, zfree and opaque must be initialized
    -536:    before by the caller.
    -537: 
    -538:      The windowBits parameter is the base two logarithm of the maximum window
    -539:    size (the size of the history buffer).  It should be in the range 8..15 for
    -540:    this version of the library. The default value is 15 if inflateInit is used
    -541:    instead. If a compressed stream with a larger window size is given as
    -542:    input, inflate() will return with the error code Z_DATA_ERROR instead of
    -543:    trying to allocate a larger window.
    -544: 
    -545:       inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    -546:    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
    -547:    memLevel). msg is set to null if there is no error message.  inflateInit2
    -548:    does not perform any decompression apart from reading the zlib header if
    -549:    present: this will be done by inflate(). (So next_in and avail_in may be
    -550:    modified, but next_out and avail_out are unchanged.)
    -551: */
    -552: 
    -553: ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
    -554:                                              const Bytef *dictionary,
    -555:                                              uInt  dictLength));
    -556: /*
    -557:      Initializes the decompression dictionary from the given uncompressed byte
    -558:    sequence. This function must be called immediately after a call of inflate
    -559:    if this call returned Z_NEED_DICT. The dictionary chosen by the compressor
    -560:    can be determined from the Adler32 value returned by this call of
    -561:    inflate. The compressor and decompressor must use exactly the same
    -562:    dictionary (see deflateSetDictionary).
    -563: 
    -564:      inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
    -565:    parameter is invalid (such as NULL dictionary) or the stream state is
    -566:    inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
    -567:    expected one (incorrect Adler32 value). inflateSetDictionary does not
    -568:    perform any decompression: this will be done by subsequent calls of
    -569:    inflate().
    -570: */
    -571: 
    -572: ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
    -573: /* 
    -574:     Skips invalid compressed data until a full flush point (see above the
    -575:   description of deflate with Z_FULL_FLUSH) can be found, or until all
    -576:   available input is skipped. No output is provided.
    -577: 
    -578:     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
    -579:   if no more input was provided, Z_DATA_ERROR if no flush point has been found,
    -580:   or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
    -581:   case, the application may save the current current value of total_in which
    -582:   indicates where valid compressed data was found. In the error case, the
    -583:   application may repeatedly call inflateSync, providing more input each time,
    -584:   until success or end of the input data.
    -585: */
    -586: 
    -587: ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
    -588: /*
    -589:      This function is equivalent to inflateEnd followed by inflateInit,
    -590:    but does not free and reallocate all the internal decompression state.
    -591:    The stream will keep attributes that may have been set by inflateInit2.
    -592: 
    -593:       inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
    -594:    stream state was inconsistent (such as zalloc or state being NULL).
    -595: */
    -596: 
    -597: 
    -598:                         /* utility functions */
    -599: 
    -600: /*
    -601:      The following utility functions are implemented on top of the
    -602:    basic stream-oriented functions. To simplify the interface, some
    -603:    default options are assumed (compression level and memory usage,
    -604:    standard memory allocation functions). The source code of these
    -605:    utility functions can easily be modified if you need special options.
    -606: */
    -607: 
    -608: ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
    -609:                                  const Bytef *source, uLong sourceLen));
    -610: /*
    -611:      Compresses the source buffer into the destination buffer.  sourceLen is
    -612:    the byte length of the source buffer. Upon entry, destLen is the total
    -613:    size of the destination buffer, which must be at least 0.1% larger than
    -614:    sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the
    -615:    compressed buffer.
    -616:      This function can be used to compress a whole file at once if the
    -617:    input file is mmap'ed.
    -618:      compress returns Z_OK if success, Z_MEM_ERROR if there was not
    -619:    enough memory, Z_BUF_ERROR if there was not enough room in the output
    -620:    buffer.
    -621: */
    -622: 
    -623: ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
    -624:                                   const Bytef *source, uLong sourceLen,
    -625:                                   int level));
    -626: /*
    -627:      Compresses the source buffer into the destination buffer. The level
    -628:    parameter has the same meaning as in deflateInit.  sourceLen is the byte
    -629:    length of the source buffer. Upon entry, destLen is the total size of the
    -630:    destination buffer, which must be at least 0.1% larger than sourceLen plus
    -631:    12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
    -632: 
    -633:      compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    -634:    memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    -635:    Z_STREAM_ERROR if the level parameter is invalid.
    -636: */
    -637: 
    -638: ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
    -639:                                    const Bytef *source, uLong sourceLen));
    -640: /*
    -641:      Decompresses the source buffer into the destination buffer.  sourceLen is
    -642:    the byte length of the source buffer. Upon entry, destLen is the total
    -643:    size of the destination buffer, which must be large enough to hold the
    -644:    entire uncompressed data. (The size of the uncompressed data must have
    -645:    been saved previously by the compressor and transmitted to the decompressor
    -646:    by some mechanism outside the scope of this compression library.)
    -647:    Upon exit, destLen is the actual size of the compressed buffer.
    -648:      This function can be used to decompress a whole file at once if the
    -649:    input file is mmap'ed.
    -650: 
    -651:      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    -652:    enough memory, Z_BUF_ERROR if there was not enough room in the output
    -653:    buffer, or Z_DATA_ERROR if the input data was corrupted.
    -654: */
    -655: 
    -656: 
    -657: typedef voidp gzFile;
    -658: 
    -659: ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
    -660: /*
    -661:      Opens a gzip (.gz) file for reading or writing. The mode parameter
    -662:    is as in fopen ("rb" or "wb") but can also include a compression level
    -663:    ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
    -664:    Huffman only compression as in "wb1h". (See the description
    -665:    of deflateInit2 for more information about the strategy parameter.)
    -666: 
    -667:      gzopen can be used to read a file which is not in gzip format; in this
    -668:    case gzread will directly read from the file without decompression.
    -669: 
    -670:      gzopen returns NULL if the file could not be opened or if there was
    -671:    insufficient memory to allocate the (de)compression state; errno
    -672:    can be checked to distinguish the two cases (if errno is zero, the
    -673:    zlib error is Z_MEM_ERROR).  */
    -674: 
    -675: ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
    -676: /*
    -677:      gzdopen() associates a gzFile with the file descriptor fd.  File
    -678:    descriptors are obtained from calls like open, dup, creat, pipe or
    -679:    fileno (in the file has been previously opened with fopen).
    -680:    The mode parameter is as in gzopen.
    -681:      The next call of gzclose on the returned gzFile will also close the
    -682:    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
    -683:    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
    -684:      gzdopen returns NULL if there was insufficient memory to allocate
    -685:    the (de)compression state.
    -686: */
    -687: 
    -688: ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
    -689: /*
    -690:      Dynamically update the compression level or strategy. See the description
    -691:    of deflateInit2 for the meaning of these parameters.
    -692:      gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
    -693:    opened for writing.
    -694: */
    -695: 
    -696: ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
    -697: /*
    -698:      Reads the given number of uncompressed bytes from the compressed file.
    -699:    If the input file was not in gzip format, gzread copies the given number
    -700:    of bytes into the buffer.
    -701:      gzread returns the number of uncompressed bytes actually read (0 for
    -702:    end of file, -1 for error). */
    -703: 
    -704: ZEXTERN int ZEXPORT    gzwrite OF((gzFile file, 
    -705: 				   const voidp buf, unsigned len));
    -706: /*
    -707:      Writes the given number of uncompressed bytes into the compressed file.
    -708:    gzwrite returns the number of uncompressed bytes actually written
    -709:    (0 in case of error).
    -710: */
    -711: 
    -712: ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
    -713: /*
    -714:      Converts, formats, and writes the args to the compressed file under
    -715:    control of the format string, as in fprintf. gzprintf returns the number of
    -716:    uncompressed bytes actually written (0 in case of error).
    -717: */
    -718: 
    -719: ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
    -720: /*
    -721:       Writes the given null-terminated string to the compressed file, excluding
    -722:    the terminating null character.
    -723:       gzputs returns the number of characters written, or -1 in case of error.
    -724: */
    -725: 
    -726: ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
    -727: /*
    -728:       Reads bytes from the compressed file until len-1 characters are read, or
    -729:    a newline character is read and transferred to buf, or an end-of-file
    -730:    condition is encountered.  The string is then terminated with a null
    -731:    character.
    -732:       gzgets returns buf, or Z_NULL in case of error.
    -733: */
    -734: 
    -735: ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
    -736: /*
    -737:       Writes c, converted to an unsigned char, into the compressed file.
    -738:    gzputc returns the value that was written, or -1 in case of error.
    -739: */
    -740: 
    -741: ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
    -742: /*
    -743:       Reads one byte from the compressed file. gzgetc returns this byte
    -744:    or -1 in case of end of file or error.
    -745: */
    -746: 
    -747: ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
    -748: /*
    -749:      Flushes all pending output into the compressed file. The parameter
    -750:    flush is as in the deflate() function. The return value is the zlib
    -751:    error number (see function gzerror below). gzflush returns Z_OK if
    -752:    the flush parameter is Z_FINISH and all output could be flushed.
    -753:      gzflush should be called only when strictly necessary because it can
    -754:    degrade compression.
    -755: */
    -756: 
    -757: ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
    -758: 				      z_off_t offset, int whence));
    -759: /* 
    -760:       Sets the starting position for the next gzread or gzwrite on the
    -761:    given compressed file. The offset represents a number of bytes in the
    -762:    uncompressed data stream. The whence parameter is defined as in lseek(2);
    -763:    the value SEEK_END is not supported.
    -764:      If the file is opened for reading, this function is emulated but can be
    -765:    extremely slow. If the file is opened for writing, only forward seeks are
    -766:    supported; gzseek then compresses a sequence of zeroes up to the new
    -767:    starting position.
    -768: 
    -769:       gzseek returns the resulting offset location as measured in bytes from
    -770:    the beginning of the uncompressed stream, or -1 in case of error, in
    -771:    particular if the file is opened for writing and the new starting position
    -772:    would be before the current position.
    -773: */
    -774: 
    -775: ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
    -776: /*
    -777:      Rewinds the given file. This function is supported only for reading.
    -778: 
    -779:    gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
    -780: */
    -781: 
    -782: ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
    -783: /*
    -784:      Returns the starting position for the next gzread or gzwrite on the
    -785:    given compressed file. This position represents a number of bytes in the
    -786:    uncompressed data stream.
    -787: 
    -788:    gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
    -789: */
    -790: 
    -791: ZEXTERN int ZEXPORT gzeof OF((gzFile file));
    -792: /*
    -793:      Returns 1 when EOF has previously been detected reading the given
    -794:    input stream, otherwise zero.
    -795: */
    -796: 
    -797: ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
    -798: /*
    -799:      Flushes all pending output if necessary, closes the compressed file
    -800:    and deallocates all the (de)compression state. The return value is the zlib
    -801:    error number (see function gzerror below).
    -802: */
    -803: 
    -804: ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
    -805: /*
    -806:      Returns the error message for the last error which occurred on the
    -807:    given compressed file. errnum is set to zlib error number. If an
    -808:    error occurred in the file system and not in the compression library,
    -809:    errnum is set to Z_ERRNO and the application may consult errno
    -810:    to get the exact error code.
    -811: */
    -812: 
    -813:                         /* checksum functions */
    -814: 
    -815: /*
    -816:      These functions are not related to compression but are exported
    -817:    anyway because they might be useful in applications using the
    -818:    compression library.
    -819: */
    -820: 
    -821: ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
    -822: 
    -823: /*
    -824:      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
    -825:    return the updated checksum. If buf is NULL, this function returns
    -826:    the required initial value for the checksum.
    -827:    An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
    -828:    much faster. Usage example:
    -829: 
    -830:      uLong adler = adler32(0L, Z_NULL, 0);
    -831: 
    -832:      while (read_buffer(buffer, length) != EOF) {
    -833:        adler = adler32(adler, buffer, length);
    -834:      }
    -835:      if (adler != original_adler) error();
    -836: */
    -837: 
    -838: ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
    -839: /*
    -840:      Update a running crc with the bytes buf[0..len-1] and return the updated
    -841:    crc. If buf is NULL, this function returns the required initial value
    -842:    for the crc. Pre- and post-conditioning (one's complement) is performed
    -843:    within this function so it shouldn't be done by the application.
    -844:    Usage example:
    -845: 
    -846:      uLong crc = crc32(0L, Z_NULL, 0);
    -847: 
    -848:      while (read_buffer(buffer, length) != EOF) {
    -849:        crc = crc32(crc, buffer, length);
    -850:      }
    -851:      if (crc != original_crc) error();
    -852: */
    -853: 
    -854: 
    -855:                         /* various hacks, don't look :) */
    -856: 
    -857: /* deflateInit and inflateInit are macros to allow checking the zlib version
    -858:  * and the compiler's view of z_stream:
    -859:  */
    -860: ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
    -861:                                      const char *version, int stream_size));
    -862: ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
    -863:                                      const char *version, int stream_size));
    -864: ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
    -865:                                       int windowBits, int memLevel,
    -866:                                       int strategy, const char *version,
    -867:                                       int stream_size));
    -868: ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
    -869:                                       const char *version, int stream_size));
    -870: #define deflateInit(strm, level) \
    -871:         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
    -872: #define inflateInit(strm) \
    -873:         inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
    -874: #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
    -875:         deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
    -876:                       (strategy),           ZLIB_VERSION, sizeof(z_stream))
    -877: #define inflateInit2(strm, windowBits) \
    -878:         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
    -879: 
    -880: 
    -881: #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL)
    -882:     struct internal_state {int dummy;}; /* hack for buggy compilers */
    -883: #endif
    -884: 
    -885: ZEXTERN const char   * ZEXPORT zError           OF((int err));
    -886: ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
    -887: ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
    -888: 
    -889: #ifdef __cplusplus
    -890: }
    -891: #endif
    -892: 
    -893: #endif /* _ZLIB_H */
    -      
    -
    - -

    How the zlib wrapper was developed

    - -

    Attempt #1

    -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%include "zlib.h"
    -      
    -
    - - The result is: - -
    -
    -% swig -chicken -I/usr/include example.i
    -/usr/include/zlib.h:63: Syntax error in input.
    -/usr/include/zlib.h:78: Syntax error in input.
    -/usr/include/zlib.h:80: Syntax error in input.
    -      
    -
    - - The first problem we see is that the macro OF(...) is - not defined. - -

    Attempt #2

    - - We make sure to include zconf.h so that SWIG can see the - definition of OF(...). We try again. - -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%include "zconf.h"
    -%include "zlib.h"
    -      
    -
    - - The result is: - -
    -
    -% swig -chicken -I/usr/include example.i
    -      
    -
    - - This seems to work! But we should take a peek inside the generated - example_wrap.c to see what the names of the Scheme - procedures will be. - -
    -
    -% grep C_intern example_wrap.c
    -  C_word err = C_intern2 (&a, errorhook);
    -    sym = C_intern (&a, 21, "example:max-mem-level");
    -    sym = C_intern (&a, 17, "example:max-wbits");
    -    sym = C_intern (&a, 16, "example:seek-set");
    -    sym = C_intern (&a, 16, "example:seek-cur");
    -    sym = C_intern (&a, 16, "example:seek-end");
    -    sym = C_intern (&a, 20, "example:zlib-version");
    -    sym = C_intern (&a, 28, "example:z-stream-next-in-set");
    -    sym = C_intern (&a, 28, "example:z-stream-next-in-get");
    -    sym = C_intern (&a, 29, "example:z-stream-avail-in-set");
    -    sym = C_intern (&a, 29, "example:z-stream-avail-in-get");
    -    sym = C_intern (&a, 29, "example:z-stream-total-in-set");
    -    sym = C_intern (&a, 29, "example:z-stream-total-in-get");
    -    sym = C_intern (&a, 29, "example:z-stream-next-out-set");
    -    sym = C_intern (&a, 29, "example:z-stream-next-out-get");
    -    sym = C_intern (&a, 30, "example:z-stream-avail-out-set");
    -    sym = C_intern (&a, 30, "example:z-stream-avail-out-get");
    -    sym = C_intern (&a, 30, "example:z-stream-total-out-set");
    -    sym = C_intern (&a, 30, "example:z-stream-total-out-get");
    -    sym = C_intern (&a, 24, "example:z-stream-msg-set");
    -    sym = C_intern (&a, 24, "example:z-stream-msg-get");
    -    sym = C_intern (&a, 26, "example:z-stream-state-set");
    -    sym = C_intern (&a, 26, "example:z-stream-state-get");
    -    sym = C_intern (&a, 27, "example:z-stream-zalloc-set");
    -    sym = C_intern (&a, 27, "example:z-stream-zalloc-get");
    -    sym = C_intern (&a, 26, "example:z-stream-zfree-set");
    -    sym = C_intern (&a, 26, "example:z-stream-zfree-get");
    -    sym = C_intern (&a, 27, "example:z-stream-opaque-set");
    -    sym = C_intern (&a, 27, "example:z-stream-opaque-get");
    -    sym = C_intern (&a, 30, "example:z-stream-data-type-set");
    -    sym = C_intern (&a, 30, "example:z-stream-data-type-get");
    -    sym = C_intern (&a, 26, "example:z-stream-adler-set");
    -    sym = C_intern (&a, 26, "example:z-stream-adler-get");
    -    sym = C_intern (&a, 29, "example:z-stream-reserved-set");
    -    sym = C_intern (&a, 29, "example:z-stream-reserved-get");
    -    sym = C_intern (&a, 20, "example:new-z-stream");
    -    sym = C_intern (&a, 23, "example:delete-z-stream");
    -    sym = C_intern (&a, 18, "example:z-no-flush");
    -    sym = C_intern (&a, 23, "example:z-partial-flush");
    -    sym = C_intern (&a, 20, "example:z-sync-flush");
    -    sym = C_intern (&a, 20, "example:z-full-flush");
    -    sym = C_intern (&a, 16, "example:z-finish");
    -    sym = C_intern (&a, 12, "example:z-ok");
    -    sym = C_intern (&a, 20, "example:z-stream-end");
    -    sym = C_intern (&a, 19, "example:z-need-dict");
    -    sym = C_intern (&a, 15, "example:z-errno");
    -    sym = C_intern (&a, 22, "example:z-stream-error");
    -    sym = C_intern (&a, 20, "example:z-data-error");
    -    sym = C_intern (&a, 19, "example:z-mem-error");
    -    sym = C_intern (&a, 19, "example:z-buf-error");
    -    sym = C_intern (&a, 23, "example:z-version-error");
    -    sym = C_intern (&a, 24, "example:z-no-compression");
    -    sym = C_intern (&a, 20, "example:z-best-speed");
    -    sym = C_intern (&a, 26, "example:z-best-compression");
    -    sym = C_intern (&a, 29, "example:z-default-compression");
    -    sym = C_intern (&a, 18, "example:z-filtered");
    -    sym = C_intern (&a, 22, "example:z-huffman-only");
    -    sym = C_intern (&a, 26, "example:z-default-strategy");
    -    sym = C_intern (&a, 16, "example:z-binary");
    -    sym = C_intern (&a, 15, "example:z-ascii");
    -    sym = C_intern (&a, 17, "example:z-unknown");
    -    sym = C_intern (&a, 18, "example:z-deflated");
    -    sym = C_intern (&a, 14, "example:z-null");
    -    sym = C_intern (&a, 19, "example:zlibversion");
    -    sym = C_intern (&a, 15, "example:deflate");
    -    sym = C_intern (&a, 18, "example:deflateend");
    -    sym = C_intern (&a, 15, "example:inflate");
    -    sym = C_intern (&a, 18, "example:inflateend");
    -    sym = C_intern (&a, 28, "example:deflatesetdictionary");
    -    sym = C_intern (&a, 19, "example:deflatecopy");
    -    sym = C_intern (&a, 20, "example:deflatereset");
    -    sym = C_intern (&a, 21, "example:deflateparams");
    -    sym = C_intern (&a, 28, "example:inflatesetdictionary");
    -    sym = C_intern (&a, 19, "example:inflatesync");
    -    sym = C_intern (&a, 20, "example:inflatereset");
    -    sym = C_intern (&a, 16, "example:compress");
    -    sym = C_intern (&a, 17, "example:compress2");
    -    sym = C_intern (&a, 18, "example:uncompress");
    -    sym = C_intern (&a, 14, "example:gzopen");
    -    sym = C_intern (&a, 15, "example:gzdopen");
    -    sym = C_intern (&a, 19, "example:gzsetparams");
    -    sym = C_intern (&a, 14, "example:gzread");
    -    sym = C_intern (&a, 15, "example:gzwrite");
    -    sym = C_intern (&a, 16, "example:gzprintf");
    -    sym = C_intern (&a, 14, "example:gzputs");
    -    sym = C_intern (&a, 14, "example:gzgets");
    -    sym = C_intern (&a, 14, "example:gzputc");
    -    sym = C_intern (&a, 14, "example:gzgetc");
    -    sym = C_intern (&a, 15, "example:gzflush");
    -    sym = C_intern (&a, 14, "example:gzseek");
    -    sym = C_intern (&a, 16, "example:gzrewind");
    -    sym = C_intern (&a, 14, "example:gztell");
    -    sym = C_intern (&a, 13, "example:gzeof");
    -    sym = C_intern (&a, 15, "example:gzclose");
    -    sym = C_intern (&a, 15, "example:gzerror");
    -    sym = C_intern (&a, 15, "example:adler32");
    -    sym = C_intern (&a, 13, "example:crc32");
    -    sym = C_intern (&a, 20, "example:deflateinit-");
    -    sym = C_intern (&a, 20, "example:inflateinit-");
    -    sym = C_intern (&a, 21, "example:deflateinit2-");
    -    sym = C_intern (&a, 21, "example:inflateinit2-");
    -    sym = C_intern (&a, 32, "example:internal-state-dummy-set");
    -    sym = C_intern (&a, 32, "example:internal-state-dummy-get");
    -    sym = C_intern (&a, 26, "example:new-internal-state");
    -    sym = C_intern (&a, 29, "example:delete-internal-state");
    -    sym = C_intern (&a, 14, "example:zerror");
    -    sym = C_intern (&a, 24, "example:inflatesyncpoint");
    -    sym = C_intern (&a, 21, "example:get-crc-table");
    -      
    -
    - - In fact, we want the Scheme procedure names to begin with - zlib instead of example. For - example:zlib-version, we want - zlib-version. And we want dashes when the case - switches to/from upper/lowercase; ex. the function - deflateEnd() should be the Scheme procedure - zlib-deflate-end. - -

    Attempt #3

    - - We make sure to add -prefix zlib -mixed to the - swig command line, and we rename - ZLIB_VERSION to VERSION. We try again. - -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%rename(VERSION) ZLIB_VERSION;
    -
    -%include "zconf.h"
    -%include "zlib.h"
    -      
    -
    - - The result is: - -
    -
    -% swig -chicken -prefix zlib -mixed -I/usr/include example.i
    -% grep C_intern example_wrap.c
    -  C_word err = C_intern2 (&a, errorhook);
    -    sym = C_intern (&a, 18, "zlib:max-mem-level");
    -    sym = C_intern (&a, 14, "zlib:max-wbits");
    -    sym = C_intern (&a, 13, "zlib:seek-set");
    -    sym = C_intern (&a, 13, "zlib:seek-cur");
    -    sym = C_intern (&a, 13, "zlib:seek-end");
    -    sym = C_intern (&a, 12, "zlib:version");
    -    sym = C_intern (&a, 25, "zlib:z-stream-next-in-set");
    -    sym = C_intern (&a, 25, "zlib:z-stream-next-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-total-in-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-total-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-next-out-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-next-out-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-total-out-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-total-out-get");
    -    sym = C_intern (&a, 21, "zlib:z-stream-msg-set");
    -    sym = C_intern (&a, 21, "zlib:z-stream-msg-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-state-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-state-get");
    -    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-set");
    -    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-zfree-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-zfree-get");
    -    sym = C_intern (&a, 24, "zlib:z-stream-opaque-set");
    -    sym = C_intern (&a, 24, "zlib:z-stream-opaque-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-data-type-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-data-type-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-adler-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-adler-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-reserved-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-reserved-get");
    -    sym = C_intern (&a, 17, "zlib:new-z-stream");
    -    sym = C_intern (&a, 20, "zlib:delete-z-stream");
    -    sym = C_intern (&a, 15, "zlib:z-no-flush");
    -    sym = C_intern (&a, 20, "zlib:z-partial-flush");
    -    sym = C_intern (&a, 17, "zlib:z-sync-flush");
    -    sym = C_intern (&a, 17, "zlib:z-full-flush");
    -    sym = C_intern (&a, 13, "zlib:z-finish");
    -    sym = C_intern (&a, 9, "zlib:z-ok");
    -    sym = C_intern (&a, 17, "zlib:z-stream-end");
    -    sym = C_intern (&a, 16, "zlib:z-need-dict");
    -    sym = C_intern (&a, 12, "zlib:z-errno");
    -    sym = C_intern (&a, 19, "zlib:z-stream-error");
    -    sym = C_intern (&a, 17, "zlib:z-data-error");
    -    sym = C_intern (&a, 16, "zlib:z-mem-error");
    -    sym = C_intern (&a, 16, "zlib:z-buf-error");
    -    sym = C_intern (&a, 20, "zlib:z-version-error");
    -    sym = C_intern (&a, 21, "zlib:z-no-compression");
    -    sym = C_intern (&a, 17, "zlib:z-best-speed");
    -    sym = C_intern (&a, 23, "zlib:z-best-compression");
    -    sym = C_intern (&a, 26, "zlib:z-default-compression");
    -    sym = C_intern (&a, 15, "zlib:z-filtered");
    -    sym = C_intern (&a, 19, "zlib:z-huffman-only");
    -    sym = C_intern (&a, 23, "zlib:z-default-strategy");
    -    sym = C_intern (&a, 13, "zlib:z-binary");
    -    sym = C_intern (&a, 12, "zlib:z-ascii");
    -    sym = C_intern (&a, 14, "zlib:z-unknown");
    -    sym = C_intern (&a, 15, "zlib:z-deflated");
    -    sym = C_intern (&a, 11, "zlib:z-null");
    -    sym = C_intern (&a, 17, "zlib:zlib-version");
    -    sym = C_intern (&a, 12, "zlib:deflate");
    -    sym = C_intern (&a, 16, "zlib:deflate-end");
    -    sym = C_intern (&a, 12, "zlib:inflate");
    -    sym = C_intern (&a, 16, "zlib:inflate-end");
    -    sym = C_intern (&a, 27, "zlib:deflate-set-dictionary");
    -    sym = C_intern (&a, 17, "zlib:deflate-copy");
    -    sym = C_intern (&a, 18, "zlib:deflate-reset");
    -    sym = C_intern (&a, 19, "zlib:deflate-params");
    -    sym = C_intern (&a, 27, "zlib:inflate-set-dictionary");
    -    sym = C_intern (&a, 17, "zlib:inflate-sync");
    -    sym = C_intern (&a, 18, "zlib:inflate-reset");
    -    sym = C_intern (&a, 13, "zlib:compress");
    -    sym = C_intern (&a, 14, "zlib:compress2");
    -    sym = C_intern (&a, 15, "zlib:uncompress");
    -    sym = C_intern (&a, 11, "zlib:gzopen");
    -    sym = C_intern (&a, 12, "zlib:gzdopen");
    -    sym = C_intern (&a, 16, "zlib:gzsetparams");
    -    sym = C_intern (&a, 11, "zlib:gzread");
    -    sym = C_intern (&a, 12, "zlib:gzwrite");
    -    sym = C_intern (&a, 13, "zlib:gzprintf");
    -    sym = C_intern (&a, 11, "zlib:gzputs");
    -    sym = C_intern (&a, 11, "zlib:gzgets");
    -    sym = C_intern (&a, 11, "zlib:gzputc");
    -    sym = C_intern (&a, 11, "zlib:gzgetc");
    -    sym = C_intern (&a, 12, "zlib:gzflush");
    -    sym = C_intern (&a, 11, "zlib:gzseek");
    -    sym = C_intern (&a, 13, "zlib:gzrewind");
    -    sym = C_intern (&a, 11, "zlib:gztell");
    -    sym = C_intern (&a, 10, "zlib:gzeof");
    -    sym = C_intern (&a, 12, "zlib:gzclose");
    -    sym = C_intern (&a, 12, "zlib:gzerror");
    -    sym = C_intern (&a, 12, "zlib:adler32");
    -    sym = C_intern (&a, 10, "zlib:crc32");
    -    sym = C_intern (&a, 18, "zlib:deflate-init-");
    -    sym = C_intern (&a, 18, "zlib:inflate-init-");
    -    sym = C_intern (&a, 19, "zlib:deflate-init2-");
    -    sym = C_intern (&a, 19, "zlib:inflate-init2-");
    -    sym = C_intern (&a, 29, "zlib:internal-state-dummy-set");
    -    sym = C_intern (&a, 29, "zlib:internal-state-dummy-get");
    -    sym = C_intern (&a, 23, "zlib:new-internal-state");
    -    sym = C_intern (&a, 26, "zlib:delete-internal-state");
    -    sym = C_intern (&a, 12, "zlib:ze-rror");
    -    sym = C_intern (&a, 23, "zlib:inflate-sync-point");
    -    sym = C_intern (&a, 18, "zlib:get-crc-table");
    -      
    -
    - - Much better. The only problem is the identifier - zlib:ze-rror, and we are missing - zlib:deflate-init and zlib:inflate-init - because they are defined as macros (see macro definitions). - -

    Attempt #4

    - - We make sure to rename zError to - z_error, and we inline some helper functions for the - zlib:...-init macros. We try again. - -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%rename(VERSION) ZLIB_VERSION;
    -%rename(z_error) zError;
    -
    -%include "zconf.h"
    -%include "zlib.h"
    -
    -%inline %{
    -/* %inline blocks are seen by SWIG and are inserted into the header
    -   portion of example_wrap.c, so that they are also seen by the C
    -   compiler. */
    -int deflate_init(z_streamp strm, int level) {
    -  return deflateInit(strm,level); /* call macro */
    -}
    -int inflate_init(z_streamp strm) {
    -  return inflateInit(strm); /* call macro */
    -}
    -%}
    -
    -
    -      
    -
    - - The result is: - -
    -
    -% swig -chicken -prefix zlib -mixed -I/usr/include example.i
    -% grep C_intern example_wrap.c
    -  C_word err = C_intern2 (&a, errorhook);
    -    sym = C_intern (&a, 18, "zlib:max-mem-level");
    -    sym = C_intern (&a, 14, "zlib:max-wbits");
    -    sym = C_intern (&a, 13, "zlib:seek-set");
    -    sym = C_intern (&a, 13, "zlib:seek-cur");
    -    sym = C_intern (&a, 13, "zlib:seek-end");
    -    sym = C_intern (&a, 12, "zlib:version");
    -    sym = C_intern (&a, 25, "zlib:z-stream-next-in-set");
    -    sym = C_intern (&a, 25, "zlib:z-stream-next-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-avail-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-total-in-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-total-in-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-next-out-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-next-out-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-avail-out-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-total-out-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-total-out-get");
    -    sym = C_intern (&a, 21, "zlib:z-stream-msg-set");
    -    sym = C_intern (&a, 21, "zlib:z-stream-msg-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-state-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-state-get");
    -    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-set");
    -    sym = C_intern (&a, 24, "zlib:z-stream-zalloc-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-zfree-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-zfree-get");
    -    sym = C_intern (&a, 24, "zlib:z-stream-opaque-set");
    -    sym = C_intern (&a, 24, "zlib:z-stream-opaque-get");
    -    sym = C_intern (&a, 27, "zlib:z-stream-data-type-set");
    -    sym = C_intern (&a, 27, "zlib:z-stream-data-type-get");
    -    sym = C_intern (&a, 23, "zlib:z-stream-adler-set");
    -    sym = C_intern (&a, 23, "zlib:z-stream-adler-get");
    -    sym = C_intern (&a, 26, "zlib:z-stream-reserved-set");
    -    sym = C_intern (&a, 26, "zlib:z-stream-reserved-get");
    -    sym = C_intern (&a, 17, "zlib:new-z-stream");
    -    sym = C_intern (&a, 20, "zlib:delete-z-stream");
    -    sym = C_intern (&a, 15, "zlib:z-no-flush");
    -    sym = C_intern (&a, 20, "zlib:z-partial-flush");
    -    sym = C_intern (&a, 17, "zlib:z-sync-flush");
    -    sym = C_intern (&a, 17, "zlib:z-full-flush");
    -    sym = C_intern (&a, 13, "zlib:z-finish");
    -    sym = C_intern (&a, 9, "zlib:z-ok");
    -    sym = C_intern (&a, 17, "zlib:z-stream-end");
    -    sym = C_intern (&a, 16, "zlib:z-need-dict");
    -    sym = C_intern (&a, 12, "zlib:z-errno");
    -    sym = C_intern (&a, 19, "zlib:z-stream-error");
    -    sym = C_intern (&a, 17, "zlib:z-data-error");
    -    sym = C_intern (&a, 16, "zlib:z-mem-error");
    -    sym = C_intern (&a, 16, "zlib:z-buf-error");
    -    sym = C_intern (&a, 20, "zlib:z-version-error");
    -    sym = C_intern (&a, 21, "zlib:z-no-compression");
    -    sym = C_intern (&a, 17, "zlib:z-best-speed");
    -    sym = C_intern (&a, 23, "zlib:z-best-compression");
    -    sym = C_intern (&a, 26, "zlib:z-default-compression");
    -    sym = C_intern (&a, 15, "zlib:z-filtered");
    -    sym = C_intern (&a, 19, "zlib:z-huffman-only");
    -    sym = C_intern (&a, 23, "zlib:z-default-strategy");
    -    sym = C_intern (&a, 13, "zlib:z-binary");
    -    sym = C_intern (&a, 12, "zlib:z-ascii");
    -    sym = C_intern (&a, 14, "zlib:z-unknown");
    -    sym = C_intern (&a, 15, "zlib:z-deflated");
    -    sym = C_intern (&a, 11, "zlib:z-null");
    -    sym = C_intern (&a, 17, "zlib:zlib-version");
    -    sym = C_intern (&a, 12, "zlib:deflate");
    -    sym = C_intern (&a, 16, "zlib:deflate-end");
    -    sym = C_intern (&a, 12, "zlib:inflate");
    -    sym = C_intern (&a, 16, "zlib:inflate-end");
    -    sym = C_intern (&a, 27, "zlib:deflate-set-dictionary");
    -    sym = C_intern (&a, 17, "zlib:deflate-copy");
    -    sym = C_intern (&a, 18, "zlib:deflate-reset");
    -    sym = C_intern (&a, 19, "zlib:deflate-params");
    -    sym = C_intern (&a, 27, "zlib:inflate-set-dictionary");
    -    sym = C_intern (&a, 17, "zlib:inflate-sync");
    -    sym = C_intern (&a, 18, "zlib:inflate-reset");
    -    sym = C_intern (&a, 13, "zlib:compress");
    -    sym = C_intern (&a, 14, "zlib:compress2");
    -    sym = C_intern (&a, 15, "zlib:uncompress");
    -    sym = C_intern (&a, 11, "zlib:gzopen");
    -    sym = C_intern (&a, 12, "zlib:gzdopen");
    -    sym = C_intern (&a, 16, "zlib:gzsetparams");
    -    sym = C_intern (&a, 11, "zlib:gzread");
    -    sym = C_intern (&a, 12, "zlib:gzwrite");
    -    sym = C_intern (&a, 13, "zlib:gzprintf");
    -    sym = C_intern (&a, 11, "zlib:gzputs");
    -    sym = C_intern (&a, 11, "zlib:gzgets");
    -    sym = C_intern (&a, 11, "zlib:gzputc");
    -    sym = C_intern (&a, 11, "zlib:gzgetc");
    -    sym = C_intern (&a, 12, "zlib:gzflush");
    -    sym = C_intern (&a, 11, "zlib:gzseek");
    -    sym = C_intern (&a, 13, "zlib:gzrewind");
    -    sym = C_intern (&a, 11, "zlib:gztell");
    -    sym = C_intern (&a, 10, "zlib:gzeof");
    -    sym = C_intern (&a, 12, "zlib:gzclose");
    -    sym = C_intern (&a, 12, "zlib:gzerror");
    -    sym = C_intern (&a, 12, "zlib:adler32");
    -    sym = C_intern (&a, 10, "zlib:crc32");
    -    sym = C_intern (&a, 18, "zlib:deflate-init-");
    -    sym = C_intern (&a, 18, "zlib:inflate-init-");
    -    sym = C_intern (&a, 19, "zlib:deflate-init2-");
    -    sym = C_intern (&a, 19, "zlib:inflate-init2-");
    -    sym = C_intern (&a, 29, "zlib:internal-state-dummy-set");
    -    sym = C_intern (&a, 29, "zlib:internal-state-dummy-get");
    -    sym = C_intern (&a, 23, "zlib:new-internal-state");
    -    sym = C_intern (&a, 26, "zlib:delete-internal-state");
    -    sym = C_intern (&a, 12, "zlib:z-error");
    -    sym = C_intern (&a, 23, "zlib:inflate-sync-point");
    -    sym = C_intern (&a, 18, "zlib:get-crc-table");
    -    sym = C_intern (&a, 17, "zlib:deflate-init");
    -    sym = C_intern (&a, 17, "zlib:inflate-init");
    -      
    -
    - - Perfect! Now let's integrate this zlib extension into a - CHICKEN interpreter. To save some time, in this - Examples/chicken/zlib directory: -
      -
    1. Backup the original example.i.
    2. -
    3. Copy and paste the example.i text from above and - put it into the file called example.i
    4. -
    5. Run 'make' as per Building the - example.
    6. -
    7. Run the resultant executable zlib.
    8. -
    - - The interpreter interaction is as follows: - -
    -
    -% ./zlib
    -zlib
    -
    -  A SWIG example for the CHICKEN compiler
    -  Author: Jonah Beckford, February 2003
    -
    -Scheme Procedures:
    -
    -zlib:max-mem-level
    -zlib:max-wbits
    -zlib:seek-set
    -zlib:seek-cur
    -zlib:seek-end
    -zlib:version
    -zlib:z-stream-next-in-set
    -zlib:z-stream-next-in-get
    -zlib:z-stream-avail-in-set
    -...
    -zlib:get-crc-table
    -zlib:deflate-init
    -zlib:inflate-init
    -; This is the CHICKEN interpreter - Version 0, Build 1095 - windows-cygwin-x86
    -; (c)2000-2003 Felix L. Winkelmann
    ->>> (define s (zlib:new-z-stream))
    ->>> s
    -#<tagged pointer #<c++ "z_stream *">(#<pointer 6d9290>)>
    ->>> (zlib:z-stream-next-in-get s)
    -#f
    ->>> (zlib:z-stream-next-in-set s "some dummy stream data")
    -Error: Type error. Expected _p_Bytef: "bad argument type"
    ->>> (exit)
    -      
    -
    - - Apparently we cannot use Scheme strings as Bytef *. The SWIG - manual shows many ways how to handle strings and byte arrays, but - to be simplistic, let's just make the Bytef * look - like a char *, which is automatically handled as a - string by SWIG CHICKEN. - -

    Attempt #5

    - - We make sure to add an %apply construct so that Bytef - * is handled the same as char * to SWIG. We - try again. - -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%rename(VERSION) ZLIB_VERSION;
    -%rename(z_error) zError;
    -%apply char * { Bytef * };
    -
    -%include "zconf.h"
    -%include "zlib.h"
    -
    -%inline %{
    -/* %inline blocks are seen by SWIG and are inserted into the header
    -   portion of example_wrap.c, so that they are also seen by the C
    -   compiler. */
    -int deflate_init(z_streamp strm, int level) {
    -  return deflateInit(strm,level); /* call macro */
    -}
    -int inflate_init(z_streamp strm) {
    -  return inflateInit(strm); /* call macro */
    -}
    -%}
    -      
    -
    - - Build the example once more.
    - - The interpreter interaction is as follows: - -
    -
    -% ./zlib
    -zlib
    -
    -  A SWIG example for the CHICKEN compiler
    -  Author: Jonah Beckford, February 2003
    -
    -Scheme Procedures:
    -
    -zlib:max-mem-level
    -zlib:max-wbits
    -zlib:seek-set
    -zlib:seek-cur
    -zlib:seek-end
    -zlib:version
    -zlib:z-stream-next-in-set
    -zlib:z-stream-next-in-get
    -zlib:z-stream-avail-in-set
    -...
    -zlib:get-crc-table
    -zlib:deflate-init
    -zlib:inflate-init
    -; This is the CHICKEN interpreter - Version 0, Build 1095 - windows-cygwin-x86
    -; (c)2000-2003 Felix L. Winkelmann
    ->>> (define s (zlib:new-z-stream))
    -Init zstream
    ->>> (zlib:z-stream-zalloc-set s #f) 
    ->>> (zlib:z-stream-zfree-set s #f)
    ->>> (zlib:z-stream-opaque-set s #f)
    ->>> (zlib:deflate-init s (zlib:z-default-compression))
    -0
    -Deflate something small so we don't need to loop/stream data
    ->>> (define in "some dummy data")
    ->>> (define out (make-string 1000))
    ->>> (zlib:z-stream-next-in-set s in)
    ->>> (zlib:z-stream-avail-in-set s (string-length in))
    ->>> (zlib:z-stream-next-out-set s out)
    ->>> (zlib:z-stream-avail-out-set s (string-length out))
    ->>> (zlib:deflate s (zlib:z-finish))
    -1 ;; (zlib:z-stream-end) == 1, which is good
    ->>> (zlib:z-stream-total-out-get s)
    -23.
    ->>> out
    -"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        "
    -      
    -
    - - We see the problem ... the compression is occurring as it should, - but we cannot see any of the compressed output. This is because - when SWIG CHICKEN passes a Scheme string to a C function, it - duplicates the string before calling the C function. We want to - save the memory address that - zlib:z-stream-next-out-set is using, so we can - display this later. While we are at it, we can foresee that - compress, compress2 and - uncompress will all need some finessing to work with - mutating strings. - -

    Attempt #6

    - - When we have to finesse strings, we must use typemaps. As well, - we define some functions to save and restore the - next_out element. We try again. - -
    -
    -/* File : example.i */
    -%module example
    -%{
    -/* Put headers and other declarations here */
    -#include "zlib.h"
    -%}
    -
    -%include typemaps.i
    -
    -%rename(VERSION) ZLIB_VERSION;
    -%rename(z_error) zError;
    -%apply char * { Bytef * };
    -	
    -/* Allow the sourceLen to be automatically filled in from the length
    -   of the 'source' string */
    -%typemap(in) (const Bytef *source, uLong sourceLen)
    -%{  if (!C_swig_is_string ($input)) {
    -    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
    -  }
    -  $2 = (uLong) C_header_size ($input);
    -  $1 = C_c_string ($input);
    -%}
    -
    -/* Allocate space the size of which is determined by the Scheme
    -   integer argument, and make a temporary integer so we can set
    -   destLen. */
    -%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len)
    -%{  if (!C_swig_is_fixnum ($input)) {
    -    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer");
    -  }
    -  len = (uLong) C_unfix ($input);
    -  $2 = &len;
    -  $1 = (char *) malloc (*$2);
    -%}
    -
    -/* Return the mutated string as a new object. */
    -%typemap(argout) (Bytef *dest, uLongf *destLen) 
    -(C_word *scmstr) 
    -%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
    -  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
    -  free ($1);
    -%}
    -	
    -%include "zconf.h"
    -%include "zlib.h"
    -	
    -/* Ignore destLen as an input argument, and make a temporary integer so
    -   we can set destLen. */
    -%typemap(in, numinputs=0) uLongf *destLen (uLong len)
    -"$1 = &len;";
    -
    -/* Return a sized string as a new object. */
    -%typemap(argout)
    -(void *outstr, uLongf *destLen) (C_word *scmstr) 
    -%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
    -  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
    -%}
    -	
    -%inline %{
    -/* %inline blocks are seen by SWIG and are inserted into the header
    -   portion of example_wrap.c, so that they are also seen by the C
    -   compiler. */
    -int deflate_init(z_streamp strm, int level) {
    -  return deflateInit(strm,level); /* call macro */
    -}
    -int inflate_init(z_streamp strm) {
    -  return inflateInit(strm); /* call macro */
    -}
    -void* z_stream_save_next_out(z_streamp strm) {
    -  return (void*) strm->next_out;
    -}
    -void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) {
    -  *destLen = strm->next_out - (Bytef*)outstr;
    -}
    -%}
    -      
    -
    - - And that's it. Try building the entire example from the - Makefile. Run ./zlib test-zlib.scm to test it out. - - - diff --git a/Examples/chicken/zlib/example.i b/Examples/chicken/zlib/example.i deleted file mode 100644 index dd962ad56..000000000 --- a/Examples/chicken/zlib/example.i +++ /dev/null @@ -1,76 +0,0 @@ -/* File : example.i */ -%module example -%{ -/* Put headers and other declarations here */ -#include "zlib.h" -%} - -%include typemaps.i - -%rename(VERSION) ZLIB_VERSION; -%rename(z_error) zError; -%apply char * { Bytef * }; - -/* Allow the sourceLen to be automatically filled in from the length - of the 'source' string */ -%typemap(in) (const Bytef *source, uLong sourceLen) -%{ if (!C_swig_is_string ($input)) { - swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string"); - } - $2 = (uLong) C_header_size ($input); - $1 = C_c_string ($input); -%} - -/* Allocate space the size of which is determined by the Scheme - integer argument, and make a temporary integer so we can set - destLen. */ -%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len) -%{ if (!C_swig_is_fixnum ($input)) { - swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer"); - } - len = (uLong) C_unfix ($input); - $2 = &len; - $1 = (char *) malloc (*$2); -%} - -/* Return the mutated string as a new object. */ -%typemap(argout) (Bytef *dest, uLongf *destLen) -(C_word *scmstr) -%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); - SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); - free ($1); -%} - -%include "zconf.h" -%include "zlib.h" - -/* Ignore destLen as an input argument, and make a temporary integer so - we can set destLen. */ -%typemap(numinputs=0) uLongf *destLen (uLong len) -"$1 = &len;"; - -/* Return a sized string as a new object. */ -%typemap(argout) -(void *outstr, uLongf *destLen) (C_word *scmstr) -%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); - SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); -%} - -%inline %{ -/* %inline blocks are seen by SWIG and are inserted into the header - portion of example_wrap.c, so that they are also seen by the C - compiler. */ -int deflate_init(z_streamp strm, int level) { - return deflateInit(strm,level); /* call macro */ -} -int inflate_init(z_streamp strm) { - return inflateInit(strm); /* call macro */ -} -void* z_stream_save_next_out(z_streamp strm) { - return (void*) strm->next_out; -} -void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) { - *destLen = strm->next_out - (Bytef*)outstr; -} -%} - diff --git a/Examples/chicken/zlib/test-zlib.scm b/Examples/chicken/zlib/test-zlib.scm deleted file mode 100644 index a13d801b8..000000000 --- a/Examples/chicken/zlib/test-zlib.scm +++ /dev/null @@ -1,41 +0,0 @@ -(load-library 'example "./zlib.so") - -;; Init zstream -(define s (new-z-stream)) -(z-stream-zalloc-set s #f) -(z-stream-zfree-set s #f) -(z-stream-opaque-set s #f) -(deflate-init s (Z-DEFAULT-COMPRESSION)) - -;; Deflate something small so we don't need to loop/stream data -(define in "some pony et jumping et jack et flash et had a jack pony") -(define out (make-string 1000)) -(printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in)) -(z-stream-next-in-set s in) -(z-stream-avail-in-set s (string-length in)) -(z-stream-next-out-set s out) -(z-stream-avail-out-set s (string-length out)) -(let* - ((saved-out (z-stream-save-next-out s)) - (ret (deflate s (Z-FINISH)))) - (cond - ((= ret (Z-STREAM-END)) - (printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%" - (z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out))) - ((= ret (Z-OK)) - (display "only partial deflation ... not enough output space\n")) - (else - (printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s))))) - -;; Use simple compress routine, and set max output size to 100 -(newline) -(call-with-values (lambda () (compress 100 in)) - (lambda (ret compressed) - (cond - ((= ret (Z-OK)) - (printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%" - (string-length compressed) compressed)) - (else - (printf "compress error(~D): ~A ~%" ret (z-error ret)))))) - -(exit 0) diff --git a/Examples/guile/check.list b/Examples/guile/check.list index d35b2d693..7ccd0730a 100644 --- a/Examples/guile/check.list +++ b/Examples/guile/check.list @@ -1,6 +1,5 @@ # see top-level Makefile.in constants -matrix simple port multimap diff --git a/Examples/lua/lua.c b/Examples/lua/lua.c index e06e2c5fc..8cffaa503 100644 --- a/Examples/lua/lua.c +++ b/Examples/lua/lua.c @@ -1,5 +1,4 @@ /* -** $Id$ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index c2cdc2ebe..3c06ddc9a 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -1,18 +1,12 @@ -/** - * @file li_std_set.i - * @author gga - * @date Tue May 1 02:52:47 2007 - * - * @brief a test of set containers. - * Languages should define swig::LANGUAGE_OBJ to be - * an entity of their native pointer type which can be - * included in a STL container. +/* + * a test of set containers. + * Languages should define swig::LANGUAGE_OBJ to be + * an entity of their native pointer type which can be + * included in a STL container. * - * For example: - * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is PyObject_ptr in python - * - * + * For example: + * swig::LANGUAGE_OBJ is GC_VALUE in Ruby + * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python */ %module li_std_set diff --git a/Examples/xml/example_gif.i b/Examples/xml/example_gif.i deleted file mode 100644 index f0fb3b183..000000000 --- a/Examples/xml/example_gif.i +++ /dev/null @@ -1,329 +0,0 @@ -/* ----------------------------------------------------------------------------- - * gifplot.h - * - * Main header file for the GIFPlot library. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include - -#ifndef GIFPLOT_H - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - unsigned char *cmap; - char *name; -} ColorMap; - -extern ColorMap *new_ColorMap(char *filename); -extern void delete_ColorMap(ColorMap *c); -extern void ColorMap_default(ColorMap *c); -extern void ColorMap_assign(ColorMap *c, int index, int r, int g, int b); -extern int ColorMap_getitem(ColorMap *c, int index); -extern void ColorMap_setitem(ColorMap *c, int index, int value); -extern int ColorMap_write(ColorMap *c, char *filename); - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - Pixel **pixels; - Zvalue **zbuffer; - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; -} FrameBuffer; - -#define ZMIN 1e+36 - -/* FrameBuffer Methods */ - -extern FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -extern void delete_FrameBuffer(FrameBuffer *frame); -extern int FrameBuffer_resize(FrameBuffer *frame, int width, int height); -extern void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -extern void FrameBuffer_plot(FrameBuffer *frame, int x, int y, Pixel color); -extern void FrameBuffer_horizontal(FrameBuffer *frame, int xmin, int xmax, int y, Pixel color); -extern void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, Pixel c1, Pixel c2); -extern void FrameBuffer_vertical(FrameBuffer *frame, int ymin, int ymax, int x, Pixel color); -extern void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_solidbox(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_solidcircle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_setclip(FrameBuffer *frame, int xmin, int ymin, int xmax, int ymax); -extern void FrameBuffer_noclip(FrameBuffer *frame); -extern int FrameBuffer_makeGIF(FrameBuffer *frame, ColorMap *cmap, void *buffer, unsigned int maxsize); -extern int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); -extern void FrameBuffer_zresize(FrameBuffer *f, int width, int height); -extern void FrameBuffer_zclear(FrameBuffer *f); -extern void FrameBuffer_solidtriangle(FrameBuffer *f, int x1, int y1, int x2, int y2, int x3, int y3, Pixel c); -extern void FrameBuffer_interptriangle(FrameBuffer *f, int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, int tx3, int ty3, Pixel c3); - -#define HORIZONTAL 1 -#define VERTICAL 2 - -extern void FrameBuffer_drawchar(FrameBuffer *frame, int x, int y, int fgcolor, int bgcolor, char chr, int orientation); -extern void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - -/* ------------------------------------------------------------------------ - PixMap - - The equivalent of "bit-maps". - ------------------------------------------------------------------------ */ - -typedef struct PixMap { - int width; - int height; - int centerx; - int centery; - int *map; -} PixMap; - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); -extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor); - -#define TRANSPARENT 0 -#define FOREGROUND 1 -#define BACKGROUND 2 - -/* ------------------------------------------------------------------------ - Plot2D - - Definition and methods for 2D plots. - ------------------------------------------------------------------------ */ - -typedef struct Plot2D { - FrameBuffer *frame; /* what frame buffer are we using */ - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - double dx; /* Private scaling parameters */ - double dy; -} Plot2D; - -/* 2D Plot methods */ - -extern Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); -extern void delete_Plot2D(Plot2D *p2); -extern Plot2D *Plot2D_copy(Plot2D *p2); -extern void Plot2D_clear(Plot2D *p2, Pixel c); -extern void Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax); -extern void Plot2D_setscale(Plot2D *p2, int xscale, int yscale); -extern void Plot2D_plot(Plot2D *p2, double x, double y, Pixel color); -extern void Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color); -extern void Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_start(Plot2D *p2); -extern void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); -extern void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel c); -extern void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c); -extern void Plot2D_triangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - -#define LINEAR 10 -#define LOG 11 - -/* ----------------------------------------------------------------------- - Matrix - - Operations on 4x4 transformation matrices and vectors. - Matrices are represented as a double array of 16 elements - ----------------------------------------------------------------------- */ - -typedef double *Matrix; -typedef struct GL_Vector { - double x; - double y; - double z; - double w; -} GL_Vector; - -extern Matrix new_Matrix(); -extern void delete_Matrix(Matrix a); -extern Matrix Matrix_copy(Matrix a); -extern void Matrix_multiply(Matrix a, Matrix b, Matrix c); -extern void Matrix_identity(Matrix a); -extern void Matrix_zero(Matrix a); -extern void Matrix_transpose(Matrix a, Matrix result); -extern void Matrix_invert(Matrix a, Matrix inva); -extern void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t); -extern void Matrix_transform4(Matrix a, double rx, double ry, double rz, - double rw, GL_Vector *t); - -extern void Matrix_print(Matrix a); -extern void Matrix_translate(Matrix a, double tx, double ty, double tz); -extern void Matrix_rotatex(Matrix a, double deg); -extern void Matrix_rotatey(Matrix a, double deg); -extern void Matrix_rotatez(Matrix a, double deg); - -/* ----------------------------------------------------------------------- - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; /* Frame buffer being used */ - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - Matrix center_mat; /* Matrix used for centering the model */ - Matrix model_mat; /* Model rotation matrix */ - Matrix view_mat; /* Viewing matrix */ - Matrix fullmodel_mat; /* Full model matrix. Used by sphere plot */ - Matrix trans_mat; /* Total transformation matrix */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - double zoom; - int width; - int height; - int pers_mode; /* Perspective mode (private) */ - double ortho_left,ortho_right,ortho_bottom,ortho_top; -} Plot3D; - -extern Plot3D *new_Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax); -extern void delete_Plot3D(Plot3D *p3); -extern Plot3D *Plot3D_copy(Plot3D *p3); -extern void Plot3D_clear(Plot3D *p3, Pixel Color); -extern void Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar); -extern void Plot3D_ortho(Plot3D *p3, double left, double right, double top, double bottom); -extern void Plot3D_lookat(Plot3D *p3, double z); -extern void Plot3D_autoperspective(Plot3D *p3, double fovy); -extern void Plot3D_autoortho(Plot3D *p3); -extern void Plot3D_rotx(Plot3D *p3, double deg); -extern void Plot3D_roty(Plot3D *p3, double deg); -extern void Plot3D_rotz(Plot3D *p3, double deg); -extern void Plot3D_rotl(Plot3D *p3, double deg); -extern void Plot3D_rotr(Plot3D *p3, double deg); -extern void Plot3D_rotd(Plot3D *p3, double deg); -extern void Plot3D_rotu(Plot3D *p3, double deg); -extern void Plot3D_rotc(Plot3D *p3, double deg); -extern void Plot3D_zoom(Plot3D *p3, double percent); -extern void Plot3D_left(Plot3D *p3, double percent); -extern void Plot3D_right(Plot3D *p3, double percent); -extern void Plot3D_down(Plot3D *p3, double percent); -extern void Plot3D_up(Plot3D *p3, double percent); -extern void Plot3D_center(Plot3D *p3, double cx, double cy); - -extern void Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color); - -extern void Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot3D_start(Plot3D *p3); -extern void Plot3D_line(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); -extern void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); -extern void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - -extern void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - -extern void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - - -extern void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c); - -extern void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c, Pixel bc); - -extern PixMap PixMap_SQUARE; -extern PixMap PixMap_TRIANGLE; -extern PixMap PixMap_CROSS; - -#endif -#define GIFPLOT_H - - - diff --git a/LICENSE b/LICENSE index fdb73d916..d7a422fda 100644 --- a/LICENSE +++ b/LICENSE @@ -1,95 +1,22 @@ -SWIG is distributed under the following terms: +SWIG 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 3 of the License, or +(at your option) any later version. See the LICENSE-GPL file for +the full terms of the GNU General Public license version 3. -I. +Portions of SWIG are also licensed under the terms of the licenses +in the file LICENSE-UNIVERSITIES. You must observe the terms of +these licenses, as well as the terms of the GNU General Public License, +when you distribute SWIG. -Copyright (c) 1995-1998 -The University of Utah and the Regents of the University of California -All Rights Reserved +The SWIG library and examples, under the Lib and Examples top level +directories, are distributed under the following terms: -Permission is hereby granted, without written agreement and without -license or royalty fees, to use, copy, modify, and distribute this -software and its documentation for any purpose, provided that -(1) The above copyright notice and the following two paragraphs -appear in all copies of the source code and (2) redistributions -including binaries reproduces these notices in the supporting -documentation. Substantial modifications to this software may be -copyrighted by their authors and need not follow the licensing terms -described here, provided that the new terms are clearly indicated in -all files where they apply. - -IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE -UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY -PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. - -THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH -SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND -THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, -SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -II. - -This software includes contributions that are Copyright (c) 1998-2005 -University of Chicago. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. Neither the name of -the University of Chicago nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF -CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -III. - -This software includes contributions that are Copyright (c) 2005-2006 -Arizona Board of Regents (University of Arizona). -All Rights Reserved - -Permission is hereby granted, without written agreement and without -license or royalty fees, to use, copy, modify, and distribute this -software and its documentation for any purpose, provided that -(1) The above copyright notice and the following two paragraphs -appear in all copies of the source code and (2) redistributions -including binaries reproduces these notices in the supporting -documentation. Substantial modifications to this software may be -copyrighted by their authors and need not follow the licensing terms -described here, provided that the new terms are clearly indicated in -all files where they apply. - -THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF -ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + You may copy, modify, distribute, and make derivative works based on + this software, in source code or object code form, without + restriction. If you distribute the software to others, you may do + so according to the terms of your choice. This software is offered as + is, without warranty of any kind. +See the COPYRIGHT file for a list of contributors to SWIG and their +copyright notices. diff --git a/LICENSE-GPL b/LICENSE-GPL new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/LICENSE-GPL @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. 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 +them 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 prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. 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. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey 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; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + 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. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +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. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + 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 +state 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) + + 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 3 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program 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, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU 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 Lesser General +Public License instead of this License. But first, please read +. diff --git a/LICENSE-UNIVERSITIES b/LICENSE-UNIVERSITIES new file mode 100644 index 000000000..fdb73d916 --- /dev/null +++ b/LICENSE-UNIVERSITIES @@ -0,0 +1,95 @@ +SWIG is distributed under the following terms: + +I. + +Copyright (c) 1995-1998 +The University of Utah and the Regents of the University of California +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE +UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY +PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH +SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, +SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + + +II. + +This software includes contributions that are Copyright (c) 1998-2005 +University of Chicago. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions +in binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. Neither the name of +the University of Chicago nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +III. + +This software includes contributions that are Copyright (c) 2005-2006 +Arizona Board of Regents (University of Arizona). +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 8132e4628..eb4e87973 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -246,8 +246,6 @@ $body)" #endif %insert("lisphead") %{ -;; $Id$ - (eval-when (compile load eval) ;; avoid compiling ef-templates at runtime diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i index b887a8a0a..4aa54660b 100755 --- a/Lib/allegrocl/longlongs.i +++ b/Lib/allegrocl/longlongs.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * longlongs.i * * Typemap addition for support of 'long long' type and 'unsigned long long diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i index c8ab45649..4e260897f 100755 --- a/Lib/allegrocl/std_list.i +++ b/Lib/allegrocl/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/allegrocl/std_string.i b/Lib/allegrocl/std_string.i index 4da0148fe..becc322e9 100755 --- a/Lib/allegrocl/std_string.i +++ b/Lib/allegrocl/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/attribute.i b/Lib/attribute.i index 45c3c5b64..0cc3ff1a3 100644 --- a/Lib/attribute.i +++ b/Lib/attribute.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * attribute.i * * SWIG library file for implementing attributes. diff --git a/Lib/carrays.i b/Lib/carrays.i index 738b4577a..5fc78877c 100644 --- a/Lib/carrays.i +++ b/Lib/carrays.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * carrays.i * * SWIG library file containing macros that can be used to manipulate simple diff --git a/Lib/cdata.i b/Lib/cdata.i index 67601f737..41e8f86ce 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index a8d1b5a57..68f022570 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * chicken.swg * * CHICKEN configuration module. diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index 8703ea65a..f4e94d6f6 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -1,9 +1,5 @@ /* ----------------------------------------------------------------------------- - * 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. - * * chickenrun.swg - * * ----------------------------------------------------------------------------- */ #include diff --git a/Lib/chicken/multi-generic.scm b/Lib/chicken/multi-generic.scm index ae822f37b..9d2e31d34 100644 --- a/Lib/chicken/multi-generic.scm +++ b/Lib/chicken/multi-generic.scm @@ -21,7 +21,7 @@ ;; which functions are used when. ;; Comments, bugs, suggestions: send either to chicken-users@nongnu.org or to -;; Author: John Lenz , most code copied from TinyCLOS +;; Most code copied from TinyCLOS (define (make 'name "multi-generic" diff --git a/Lib/chicken/std_string.i b/Lib/chicken/std_string.i index 2955d0e2f..ce24cba32 100644 --- a/Lib/chicken/std_string.i +++ b/Lib/chicken/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/chicken/typemaps.i b/Lib/chicken/typemaps.i index d79e20184..56cd18a5d 100644 --- a/Lib/chicken/typemaps.i +++ b/Lib/chicken/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer handling diff --git a/Lib/clisp/clisp.swg b/Lib/clisp/clisp.swg index fb6cdbf2a..e1d330cb3 100644 --- a/Lib/clisp/clisp.swg +++ b/Lib/clisp/clisp.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * clisp.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/cmalloc.i b/Lib/cmalloc.i index 03a61351c..9f58bc03c 100644 --- a/Lib/cmalloc.i +++ b/Lib/cmalloc.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cmalloc.i * * SWIG library file containing macros that can be used to create objects using diff --git a/Lib/constraints.i b/Lib/constraints.i index 2deb1168a..8bc7f9159 100644 --- a/Lib/constraints.i +++ b/Lib/constraints.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * constraints.i * * SWIG constraints library. diff --git a/Lib/cpointer.i b/Lib/cpointer.i index 1a6e51741..6b15a8417 100644 --- a/Lib/cpointer.i +++ b/Lib/cpointer.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cpointer.i * * SWIG library file containing macros that can be used to manipulate simple diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index e381ff9ae..0cdc2ba05 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * csharp.swg * * C# typemaps diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index ffff70372..eec4a2f2c 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * csharphead.swg * * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined diff --git a/Lib/csharp/director.swg b/Lib/csharp/director.swg index 8957ecf42..7768d8c02 100644 --- a/Lib/csharp/director.swg +++ b/Lib/csharp/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * director.swg * * This file contains support for director classes so that C# proxy diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg index be2a6063b..6605da8c8 100644 --- a/Lib/csharp/enums.swg +++ b/Lib/csharp/enums.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper C# enums. diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg index f50849892..2b1cb182b 100644 --- a/Lib/csharp/enumsimple.swg +++ b/Lib/csharp/enumsimple.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg index 8ba7838ef..a6bf64b9a 100644 --- a/Lib/csharp/enumtypesafe.swg +++ b/Lib/csharp/enumtypesafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called diff --git a/Lib/csharp/std_except.i b/Lib/csharp/std_except.i index c86e97a54..27eb84bc2 100644 --- a/Lib/csharp/std_except.i +++ b/Lib/csharp/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index c35f21dc7..b19414597 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/csharp/std_pair.i b/Lib/csharp/std_pair.i index 78142ffa6..0712ad762 100644 --- a/Lib/csharp/std_pair.i +++ b/Lib/csharp/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/csharp/std_string.i b/Lib/csharp/std_string.i index d29692717..0d804518b 100644 --- a/Lib/csharp/std_string.i +++ b/Lib/csharp/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * Typemaps for std::string and const std::string& diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 2e4d47c00..11d57e43d 100755 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i index 938070e4b..9142d36a5 100755 --- a/Lib/csharp/std_wstring.i +++ b/Lib/csharp/std_wstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_wstring.i * * Typemaps for std::wstring and const std::wstring& diff --git a/Lib/csharp/stl.i b/Lib/csharp/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/csharp/stl.i +++ b/Lib/csharp/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i index ddfbd1b0c..ac8398021 100644 --- a/Lib/csharp/typemaps.i +++ b/Lib/csharp/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index be87560c3..f02c09a53 100755 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * wchar.i * * Typemaps for the wchar_t type diff --git a/Lib/cstring.i b/Lib/cstring.i index 4ebdf6857..6829f7597 100644 --- a/Lib/cstring.i +++ b/Lib/cstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cstring.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/cwstring.i b/Lib/cwstring.i index a6b08ae40..f0631d328 100644 --- a/Lib/cwstring.i +++ b/Lib/cwstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cwstring.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/exception.i b/Lib/exception.i index e30ac1a5d..7297a77f5 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * exception.i * * SWIG library file providing language independent exception handling diff --git a/Lib/gcj/cni.swg b/Lib/gcj/cni.swg index 247909a4a..4bd07df06 100644 --- a/Lib/gcj/cni.swg +++ b/Lib/gcj/cni.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cni.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/guile/common.scm b/Lib/guile/common.scm index a51d3a71d..17c9ab580 100644 --- a/Lib/guile/common.scm +++ b/Lib/guile/common.scm @@ -3,12 +3,6 @@ ;;;* ;;;* This file contains generic SWIG GOOPS classes for generated ;;;* GOOPS file support -;;;* -;;;* Copyright (C) 2003 John Lenz (jelenz@wisc.edu) -;;;* Copyright (C) 2004 Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de) -;;;* -;;;* This file may be freely redistributed without license or fee provided -;;;* this copyright message remains intact. ;;;************************************************************************ (define-module (Swig swigrun)) diff --git a/Lib/guile/cplusplus.i b/Lib/guile/cplusplus.i index cb4cf7434..0dfe71754 100644 --- a/Lib/guile/cplusplus.i +++ b/Lib/guile/cplusplus.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cplusplus.i * * SWIG typemaps for C++ diff --git a/Lib/guile/guile.i b/Lib/guile/guile.i index 1bf28d6f3..ef270d74b 100644 --- a/Lib/guile/guile.i +++ b/Lib/guile/guile.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guile.i * * SWIG Configuration File for Guile. diff --git a/Lib/guile/guile_gh.swg b/Lib/guile/guile_gh.swg index 6412a4c61..3b65af897 100644 --- a/Lib/guile/guile_gh.swg +++ b/Lib/guile/guile_gh.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guile_gh.swg * * This SWIG interface file is processed if the Guile module is run diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg index 5b1fca0aa..0eba1f97e 100644 --- a/Lib/guile/guile_gh_run.swg +++ b/Lib/guile/guile_gh_run.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guile_gh_run.swg * * Guile GH runtime file diff --git a/Lib/guile/guile_scm.swg b/Lib/guile/guile_scm.swg index caded728d..d12401451 100644 --- a/Lib/guile/guile_scm.swg +++ b/Lib/guile/guile_scm.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guile_scm.swg * * This SWIG interface file is processed if the Guile module is run diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 5da8558fc..91b74095d 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guile_scm_run.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/guile/guilemain.i b/Lib/guile/guilemain.i index 6f4e4d94d..925b81fee 100644 --- a/Lib/guile/guilemain.i +++ b/Lib/guile/guilemain.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * guilemain.i * * The main functions for a user augmented guile diff --git a/Lib/guile/interpreter.i b/Lib/guile/interpreter.i index 7e8f0777a..524e0694a 100644 --- a/Lib/guile/interpreter.i +++ b/Lib/guile/interpreter.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * interpreter.i * * SWIG file for a simple Guile interpreter diff --git a/Lib/guile/list-vector.i b/Lib/guile/list-vector.i index d98cae59a..c2cd1aea2 100644 --- a/Lib/guile/list-vector.i +++ b/Lib/guile/list-vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * list_vector.i * * Guile typemaps for converting between arrays and Scheme lists or vectors diff --git a/Lib/guile/pointer-in-out.i b/Lib/guile/pointer-in-out.i index bc6438759..d8a631ca9 100644 --- a/Lib/guile/pointer-in-out.i +++ b/Lib/guile/pointer-in-out.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pointer-in-out.i * * Guile typemaps for passing pointers indirectly diff --git a/Lib/guile/ports.i b/Lib/guile/ports.i index 0d0e142e1..5940b4d3b 100644 --- a/Lib/guile/ports.i +++ b/Lib/guile/ports.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * ports.i * * Guile typemaps for handling ports diff --git a/Lib/guile/std_common.i b/Lib/guile/std_common.i index ace5d65a8..a46c42c69 100644 --- a/Lib/guile/std_common.i +++ b/Lib/guile/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index cc53e1560..19c863096 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index f8c2ea688..35f0cfad5 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/guile/std_string.i b/Lib/guile/std_string.i index f80a65ca5..c10806e98 100644 --- a/Lib/guile/std_string.i +++ b/Lib/guile/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 145db945b..6801daee8 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/guile/stl.i b/Lib/guile/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/guile/stl.i +++ b/Lib/guile/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index d9f972850..4f306f7f8 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Guile-specific typemaps diff --git a/Lib/inttypes.i b/Lib/inttypes.i index 0cc81948e..8450cb840 100644 --- a/Lib/inttypes.i +++ b/Lib/inttypes.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * inttypes.i * * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index 95510c3f9..ddaf7408c 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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_java.i * * These typemaps give more natural support for arrays. The typemaps are not efficient diff --git a/Lib/java/director.swg b/Lib/java/director.swg index fa588671d..07e5a1af1 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/java/enums.swg b/Lib/java/enums.swg index 1a8f89b3a..edb67c417 100644 --- a/Lib/java/enums.swg +++ b/Lib/java/enums.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper Java enums. diff --git a/Lib/java/enumsimple.swg b/Lib/java/enumsimple.swg index f45774d0c..e08401869 100644 --- a/Lib/java/enumsimple.swg +++ b/Lib/java/enumsimple.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 diff --git a/Lib/java/enumtypesafe.swg b/Lib/java/enumtypesafe.swg index a49a9d134..d6c6e5190 100644 --- a/Lib/java/enumtypesafe.swg +++ b/Lib/java/enumtypesafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called diff --git a/Lib/java/enumtypeunsafe.swg b/Lib/java/enumtypeunsafe.swg index bda055113..d9a7c4d29 100644 --- a/Lib/java/enumtypeunsafe.swg +++ b/Lib/java/enumtypeunsafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * enumtypeunsafe.swg * * Include this file in order for C/C++ enums to be wrapped by integers values. diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 7d1808632..b5b1bc431 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * java.swg * * Java typemaps diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index 4aa0c84b5..f348b9d54 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * javahead.swg * * Java support code diff --git a/Lib/java/std_except.i b/Lib/java/std_except.i index 15be1deb8..9e23d50e6 100644 --- a/Lib/java/std_except.i +++ b/Lib/java/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 00967d3f9..a7020532c 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/java/std_pair.i b/Lib/java/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/java/std_pair.i +++ b/Lib/java/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/java/std_string.i b/Lib/java/std_string.i index 789e17a65..f0d837696 100644 --- a/Lib/java/std_string.i +++ b/Lib/java/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * Typemaps for std::string and const std::string& diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 92fa25ac2..e243eec1b 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/java/std_wstring.i b/Lib/java/std_wstring.i index 989176500..12d8fc14f 100644 --- a/Lib/java/std_wstring.i +++ b/Lib/java/std_wstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_wstring.i * * Typemaps for std::wstring and const std::wstring& diff --git a/Lib/java/stl.i b/Lib/java/stl.i index b8d7a654c..04f86014f 100644 --- a/Lib/java/stl.i +++ b/Lib/java/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index 59f7af99a..74ed99374 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/java/various.i b/Lib/java/various.i index 733b8fa79..7c396de3e 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * various.i * * SWIG Typemap library for Java. diff --git a/Lib/lua/_std_common.i b/Lib/lua/_std_common.i index 33cc513c3..e552d0c8f 100644 --- a/Lib/lua/_std_common.i +++ b/Lib/lua/_std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * _std_common.i * * std::helpers for LUA diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg index b6d888670..c3f5cecc5 100644 --- a/Lib/lua/lua.swg +++ b/Lib/lua/lua.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * lua.swg * * SWIG Configuration File for Lua. diff --git a/Lib/lua/lua_fnptr.i b/Lib/lua/lua_fnptr.i index c7df6f5a3..7e9facdf3 100644 --- a/Lib/lua/lua_fnptr.i +++ b/Lib/lua/lua_fnptr.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * lua_fnptr.i * * SWIG Library file containing the main typemap code to support Lua modules. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 32e1b1617..4c9aa5144 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * luarun.swg * * This file contains the runtime support for Lua modules diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index b82cd56d7..5823d4fcf 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * luaruntime.swg * * all the runtime code for . diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 0941c9da1..34db14a17 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * luatypemaps.swg * * basic typemaps for Lua. diff --git a/Lib/lua/std_except.i b/Lib/lua/std_except.i index ce148ef63..9c736b9ef 100644 --- a/Lib/lua/std_except.i +++ b/Lib/lua/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception * specification, such as: diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index dd22443d5..84b0c74ff 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/lua/std_pair.i b/Lib/lua/std_pair.i index 1b20f74e0..c76361554 100644 --- a/Lib/lua/std_pair.i +++ b/Lib/lua/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * std::pair typemaps for LUA diff --git a/Lib/lua/std_string.i b/Lib/lua/std_string.i index fa58f10bb..92f27d738 100644 --- a/Lib/lua/std_string.i +++ b/Lib/lua/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * std::string typemaps for LUA diff --git a/Lib/lua/std_vector.i b/Lib/lua/std_vector.i index c6778087f..f248f0340 100644 --- a/Lib/lua/std_vector.i +++ b/Lib/lua/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * std::vector typemaps for LUA diff --git a/Lib/lua/stl.i b/Lib/lua/stl.i index b8d7a654c..04f86014f 100644 --- a/Lib/lua/stl.i +++ b/Lib/lua/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index fa0c0d0e5..084726e58 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.swg * * SWIG Library file containing the main typemap code to support Lua modules. diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 5b206eb71..5021c1604 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -1,12 +1,8 @@ /* ----------------------------------------------------------------------------- - * 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. - * * wchar.i * * Typemaps for the wchar_t type * These are mapped to a Lua string and are passed around by value. - * * ----------------------------------------------------------------------------- */ // note: only support for pointer right now, not fixed length strings @@ -43,4 +39,4 @@ if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);go free($1); %} -%typemap(typecheck) wchar_t * = char *; \ No newline at end of file +%typemap(typecheck) wchar_t * = char *; diff --git a/Lib/math.i b/Lib/math.i index be931d71b..a37c92d19 100644 --- a/Lib/math.i +++ b/Lib/math.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * math.i * * SWIG library file for floating point operations. diff --git a/Lib/modula3/modula3.swg b/Lib/modula3/modula3.swg index 6a1b4d94d..599a12e5a 100644 --- a/Lib/modula3/modula3.swg +++ b/Lib/modula3/modula3.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * modula3.swg * * Modula3 typemaps diff --git a/Lib/modula3/modula3head.swg b/Lib/modula3/modula3head.swg index b2426be5f..af96a78d1 100644 --- a/Lib/modula3/modula3head.swg +++ b/Lib/modula3/modula3head.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * modula3head.swg * * Modula3 support code diff --git a/Lib/modula3/typemaps.i b/Lib/modula3/typemaps.i index 79ddfda0f..1d76ab5e0 100644 --- a/Lib/modula3/typemaps.i +++ b/Lib/modula3/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/mzscheme/mzrun.swg b/Lib/mzscheme/mzrun.swg index 3b05d2406..a5128da56 100644 --- a/Lib/mzscheme/mzrun.swg +++ b/Lib/mzscheme/mzrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * mzrun.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/mzscheme/mzscheme.swg b/Lib/mzscheme/mzscheme.swg index ed4b2ec9d..9ae242845 100644 --- a/Lib/mzscheme/mzscheme.swg +++ b/Lib/mzscheme/mzscheme.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * mzscheme.swg * * SWIG Configuration File for MzScheme. diff --git a/Lib/mzscheme/std_common.i b/Lib/mzscheme/std_common.i index 8732f811c..1f1ae1ab7 100644 --- a/Lib/mzscheme/std_common.i +++ b/Lib/mzscheme/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index aff720db6..b2c894509 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/mzscheme/std_pair.i b/Lib/mzscheme/std_pair.i index 2ac331e71..d5a65470d 100644 --- a/Lib/mzscheme/std_pair.i +++ b/Lib/mzscheme/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/mzscheme/std_string.i b/Lib/mzscheme/std_string.i index c9a82efe4..b8b99d9ad 100644 --- a/Lib/mzscheme/std_string.i +++ b/Lib/mzscheme/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string types diff --git a/Lib/mzscheme/std_vector.i b/Lib/mzscheme/std_vector.i index 90a52fc0a..22e1fa96b 100644 --- a/Lib/mzscheme/std_vector.i +++ b/Lib/mzscheme/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/mzscheme/stl.i b/Lib/mzscheme/stl.i index 946e4b7f0..b19eae58b 100644 --- a/Lib/mzscheme/stl.i +++ b/Lib/mzscheme/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index 334893242..b9f22440c 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/ocaml/cstring.i b/Lib/ocaml/cstring.i index e56258264..0d6aa4b69 100644 --- a/Lib/ocaml/cstring.i +++ b/Lib/ocaml/cstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cstring.i * * This file provides typemaps and macros for dealing with various forms diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index 87333168f..a21f62102 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i index a46e239d1..e099f7c10 100644 --- a/Lib/ocaml/ocaml.i +++ b/Lib/ocaml/ocaml.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * ocaml.i * * SWIG Configuration File for Ocaml diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index 3b5290fa1..8e452d3f9 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * ocamldec.swg * * Ocaml runtime code -- declarations diff --git a/Lib/ocaml/std_common.i b/Lib/ocaml/std_common.i index b2dff61d2..1c397050c 100644 --- a/Lib/ocaml/std_common.i +++ b/Lib/ocaml/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/ocaml/std_deque.i b/Lib/ocaml/std_deque.i index 44815ebda..a6c489597 100644 --- a/Lib/ocaml/std_deque.i +++ b/Lib/ocaml/std_deque.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_deque.i * * Default std_deque wrapper diff --git a/Lib/ocaml/std_list.i b/Lib/ocaml/std_list.i index 0aea90767..06181cca8 100644 --- a/Lib/ocaml/std_list.i +++ b/Lib/ocaml/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index f174f2872..f202e74ed 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/ocaml/std_pair.i b/Lib/ocaml/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/ocaml/std_pair.i +++ b/Lib/ocaml/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index 7add3a070..e75e95304 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index 91c335562..53d107447 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector types diff --git a/Lib/ocaml/stl.i b/Lib/ocaml/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/ocaml/stl.i +++ b/Lib/ocaml/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 51e66061b..4c3500690 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typecheck.i * * Typechecking rules diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 7f978bf7f..39544de94 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * The Ocaml module handles all types uniformly via typemaps. Here diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index bb1122a7b..d0e37112e 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * octcontainer.swg * * Octave cell <-> C++ container wrapper diff --git a/Lib/octave/octiterators.swg b/Lib/octave/octiterators.swg index 926361e10..0e3fe7033 100644 --- a/Lib/octave/octiterators.swg +++ b/Lib/octave/octiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * octiterators.swg * * Users can derive form the OctSwigIterator to implemet their diff --git a/Lib/perl5/perlmain.i b/Lib/perl5/perlmain.i index f224b9c75..18ecb7eb5 100644 --- a/Lib/perl5/perlmain.i +++ b/Lib/perl5/perlmain.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * perlmain.i * * Code to statically rebuild perl5. diff --git a/Lib/perl5/reference.i b/Lib/perl5/reference.i index d3d745cfc..06712bbd5 100644 --- a/Lib/perl5/reference.i +++ b/Lib/perl5/reference.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * reference.i * * Accept Perl references as pointers diff --git a/Lib/perl5/std_common.i b/Lib/perl5/std_common.i index bc25b353f..c36513912 100644 --- a/Lib/perl5/std_common.i +++ b/Lib/perl5/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index 633e40d9a..c6bca18f6 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index c35f21dc7..b19414597 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/perl5/std_pair.i b/Lib/perl5/std_pair.i index 78142ffa6..0712ad762 100644 --- a/Lib/perl5/std_pair.i +++ b/Lib/perl5/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index b1f722d4b..c6cacfe7e 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector types diff --git a/Lib/perl5/stl.i b/Lib/perl5/stl.i index 946e4b7f0..b19eae58b 100644 --- a/Lib/perl5/stl.i +++ b/Lib/perl5/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/perl5/typemaps.i b/Lib/perl5/typemaps.i index fc6d8f874..7d96f2ace 100644 --- a/Lib/perl5/typemaps.i +++ b/Lib/perl5/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * The SWIG typemap library provides a language independent mechanism for diff --git a/Lib/php/const.i b/Lib/php/const.i index 6ddd403d0..08096c98b 100644 --- a/Lib/php/const.i +++ b/Lib/php/const.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * const.i * * Typemaps for constants diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index a75b1a41e..3027ca84e 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * globalvar.i * * Global variables - add the variable to PHP diff --git a/Lib/php/php.swg b/Lib/php/php.swg index d30e0b2a9..903af5612 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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.swg * * PHP configuration file diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index 3d1a62511..e7d4f2fda 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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 * * The 'keywords' in PHP are global, ie, the following names are fine diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index b4e4276f5..c7976a3dc 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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 * * PHP runtime library diff --git a/Lib/php/std_common.i b/Lib/php/std_common.i index a779649dd..092bf012b 100644 --- a/Lib/php/std_common.i +++ b/Lib/php/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index c6721806b..ede5fbe30 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/php/std_pair.i b/Lib/php/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/php/std_pair.i +++ b/Lib/php/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 08a7cdac9..22c953bf5 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string types diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index b54181618..4cfc94f74 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * * SWIG typemaps for std::vector types diff --git a/Lib/php/stl.i b/Lib/php/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/php/stl.i +++ b/Lib/php/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index c5b749578..30235f278 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i. * * SWIG Typemap library for PHP4. diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg index e72da8fba..2ba27671e 100644 --- a/Lib/pike/pike.swg +++ b/Lib/pike/pike.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pike.swg * * Pike configuration module. diff --git a/Lib/pike/pikerun.swg b/Lib/pike/pikerun.swg index 875fcf4e2..451a4e092 100644 --- a/Lib/pike/pikerun.swg +++ b/Lib/pike/pikerun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pikerun.swg * * This file contains the runtime support for Pike modules diff --git a/Lib/pike/std_string.i b/Lib/pike/std_string.i index ca1fad822..0694035bf 100644 --- a/Lib/pike/std_string.i +++ b/Lib/pike/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/pointer.i b/Lib/pointer.i index 16e11b7d1..8015317d7 100644 --- a/Lib/pointer.i +++ b/Lib/pointer.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pointer.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index 30f797d74..28872b985 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * ccomplex.i * * C complex typemaps diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 836d107ce..090da0205 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/python/embed15.i b/Lib/python/embed15.i index f677d166e..4abfbba75 100644 --- a/Lib/python/embed15.i +++ b/Lib/python/embed15.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * embed15.i * * SWIG file embedding the Python interpreter in something else. diff --git a/Lib/python/file.i b/Lib/python/file.i index 294ab9178..359c34d2c 100644 --- a/Lib/python/file.i +++ b/Lib/python/file.i @@ -1,11 +1,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. - * * file.i * * Typemaps for FILE* - * From the ideas of Luigi Ballabio * ----------------------------------------------------------------------------- */ %types(FILE *); diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 58442ef76..006ab016f 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pycontainer.swg * * Python sequence <-> C++ container wrapper diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 62a7eaf70..9f85ffc4a 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pyiterators.swg * * Implement a python 'output' iterator for Python 2.2 or higher. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 4f51d3a95..1aae2d7aa 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * pyrun.swg * * This file contains the runtime support for Python modules diff --git a/Lib/python/typemaps.i b/Lib/python/typemaps.i index 1c87de61d..5d438ecab 100644 --- a/Lib/python/typemaps.i +++ b/Lib/python/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer handling diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 9a6371ad9..60c086f5b 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/ruby/rubyautodoc.swg b/Lib/ruby/rubyautodoc.swg index ade4bde1d..1e6b0d9dc 100644 --- a/Lib/ruby/rubyautodoc.swg +++ b/Lib/ruby/rubyautodoc.swg @@ -1,13 +1,8 @@ -/** - * @file rubyautodoc.swg - * @author gga - * @date Wed May 2 16:41:59 2007 - * - * @brief This file implements autodoc typemaps for some common - * ruby methods. - * - * - */ +/* ----------------------------------------------------------------------------- + * rubyautodoc.swg + * + * This file implements autodoc typemaps for some common ruby methods. + * ----------------------------------------------------------------------------- */ %define AUTODOC(func, str) %feature("autodoc", str) func; diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 919695ec2..c93094aeb 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * rubycontainer.swg * * Ruby sequence <-> C++ container wrapper diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index 360e399ce..09be64aee 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -1,17 +1,13 @@ -/** - * @file rubycontainer_extended.swg - * @author gga - * @date Sat May 5 05:36:01 2007 - * - * @brief This file contains additional functions that make containers - * behave closer to ruby primitive types. - * However, some of these functions place some restrictions on - * the underlying object inside of the container and the iterator - * (that it has to have an == comparison function, that it has to have - * an = assignment operator, etc). - * - */ - +/* ----------------------------------------------------------------------------- + * rubycontainer_extended.swg + * + * This file contains additional functions that make containers + * behave closer to ruby primitive types. + * However, some of these functions place some restrictions on + * the underlying object inside of the container and the iterator + * (that it has to have an == comparison function, that it has to have + * an = assignment operator, etc). + * ----------------------------------------------------------------------------- */ /** * Macro used to add extend functions that require operator== in object. diff --git a/Lib/ruby/rubyiterators.swg b/Lib/ruby/rubyiterators.swg index 466ae221b..aba156a2b 100644 --- a/Lib/ruby/rubyiterators.swg +++ b/Lib/ruby/rubyiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * rubyiterators.swg * * Implement a C++ 'output' iterator for Ruby. diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg index c2d577995..aff35dcf1 100644 --- a/Lib/ruby/rubyprimtypes.swg +++ b/Lib/ruby/rubyprimtypes.swg @@ -1,9 +1,5 @@ /* ----------------------------------------------------------------------------- - * 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. - * * rubyprimtypes.swg - * * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Primitive Types diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 24d861d5a..ccc997a71 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * rubyrun.swg * * This file contains the runtime support for Ruby modules diff --git a/Lib/ruby/rubystdautodoc.swg b/Lib/ruby/rubystdautodoc.swg index ad70f7f8b..e14f65902 100644 --- a/Lib/ruby/rubystdautodoc.swg +++ b/Lib/ruby/rubystdautodoc.swg @@ -1,12 +1,8 @@ -/** - * @file rubystdautodoc.swg - * @author gga - * @date Wed May 2 17:20:39 2007 +/* ----------------------------------------------------------------------------- + * rubystdautodoc.swg * - * @brief This file contains autodocs for standard STL functions. - * - * - */ + * This file contains autodocs for standard STL functions. + * ----------------------------------------------------------------------------- */ // // For STL autodocumentation diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 959d2087e..0a36f4a05 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * rubytracking.swg * * This file contains support for tracking mappings from diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg index 0cf9d7ed9..d1fe918ad 100644 --- a/Lib/ruby/rubywstrings.swg +++ b/Lib/ruby/rubywstrings.swg @@ -1,15 +1,11 @@ -/** - * @file rubywstrings.swg - * @author - * @date Fri May 4 17:49:40 2007 - * - * @brief Currently, Ruby does not support Unicode or WChar properly, so these - * are still treated as char arrays for now. - * There are other libraries available that add support to this in - * ruby including WString, FXString, etc. - * - * - */ +/* ----------------------------------------------------------------------------- + * rubywstrings.swg + * + * Currently, Ruby does not support Unicode or WChar properly, so these + * are still treated as char arrays for now. + * There are other libraries available that add support to this in + * ruby including WString, FXString, etc. + * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * utility methods for wchar_t strings diff --git a/Lib/ruby/stl.i b/Lib/ruby/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/ruby/stl.i +++ b/Lib/ruby/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/ruby/typemaps.i b/Lib/ruby/typemaps.i index 2492e2e03..c4db82161 100644 --- a/Lib/ruby/typemaps.i +++ b/Lib/ruby/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Pointer handling diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index 026f373d6..c30523c0d 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * _std_deque.i * * This file contains a generic definition of std::deque along with diff --git a/Lib/std_except.i b/Lib/std_except.i index af9803a62..769a68995 100644 --- a/Lib/std_except.i +++ b/Lib/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_except.i * * SWIG library file with typemaps to handle and throw STD exceptions in a diff --git a/Lib/stdint.i b/Lib/stdint.i index 7b48ca388..14fe6195e 100644 --- a/Lib/stdint.i +++ b/Lib/stdint.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stdint.i * * SWIG library file for ISO C99 types: 7.18 Integer types diff --git a/Lib/stl.i b/Lib/stl.i index c3ade01ea..0b236afda 100644 --- a/Lib/stl.i +++ b/Lib/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/swigarch.i b/Lib/swigarch.i index 260b60880..f5aea4678 100644 --- a/Lib/swigarch.i +++ b/Lib/swigarch.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * swigarch.i * * SWIG library file for 32bit/64bit code specialization and checking. diff --git a/Lib/swigrun.i b/Lib/swigrun.i index 17a140968..6026a9151 100644 --- a/Lib/swigrun.i +++ b/Lib/swigrun.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * swigrun.i * * Empty module (for now). Placeholder for runtime libs diff --git a/Lib/tcl/mactclinit.c b/Lib/tcl/mactclinit.c deleted file mode 100644 index 5dcf8e7f3..000000000 --- a/Lib/tcl/mactclinit.c +++ /dev/null @@ -1,93 +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. - * - * mactclinit.c - * ----------------------------------------------------------------------------- */ - -/* - * tclMacAppInit.c -- - * - * Provides a version of the Tcl_AppInit procedure for the example shell. - * - * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclMacAppInit.c 1.17 97/01/21 18:13:34 - */ - -#include "tcl.h" -#include "tclInt.h" -#include "tclMacInt.h" - -#if defined(THINK_C) -# include -#elif defined(__MWERKS__) -# include -short InstallConsole _ANSI_ARGS_((short fd)); -#endif - - - -/* - *---------------------------------------------------------------------- - * - * MacintoshInit -- - * - * This procedure calls initalization routines to set up a simple - * console on a Macintosh. This is necessary as the Mac doesn't - * have a stdout & stderr by default. - * - * Results: - * Returns TCL_OK if everything went fine. If it didn't the - * application should probably fail. - * - * Side effects: - * Inits the appropiate console package. - * - *---------------------------------------------------------------------- - */ - -#ifdef __cplusplus -extern "C" -#endif -extern int -MacintoshInit() -{ -#if defined(THINK_C) - - /* Set options for Think C console package */ - /* The console package calls the Mac init calls */ - console_options.pause_atexit = 0; - console_options.title = "\pTcl Interpreter"; - -#elif defined(__MWERKS__) - - /* Set options for CodeWarrior SIOUX package */ - SIOUXSettings.autocloseonquit = true; - SIOUXSettings.showstatusline = true; - SIOUXSettings.asktosaveonclose = false; - InstallConsole(0); - SIOUXSetTitle("\pTcl Interpreter"); - -#elif defined(applec) - - /* Init packages used by MPW SIOW package */ - InitGraf((Ptr)&qd.thePort); - InitFonts(); - InitWindows(); - InitMenus(); - TEInit(); - InitDialogs(nil); - InitCursor(); - -#endif - - TclMacSetEventProc((TclMacConvertEventPtr) SIOUXHandleOneEvent); - - /* No problems with initialization */ - return TCL_OK; -} diff --git a/Lib/tcl/mactkinit.c b/Lib/tcl/mactkinit.c index bfe74029c..78391d445 100644 --- a/Lib/tcl/mactkinit.c +++ b/Lib/tcl/mactkinit.c @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * mactkinit.c * * This is a support file needed to build a new version of Wish. diff --git a/Lib/tcl/std_common.i b/Lib/tcl/std_common.i index 3a6f47042..0718facb8 100644 --- a/Lib/tcl/std_common.i +++ b/Lib/tcl/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/tcl/std_pair.i b/Lib/tcl/std_pair.i index 52e96674f..1448d6524 100644 --- a/Lib/tcl/std_pair.i +++ b/Lib/tcl/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_pair.i * * Typemaps for std::pair diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index d913f00cc..3c8dd24b7 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * std_vector.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/stl.i b/Lib/tcl/stl.i index afd121341..40c7584ec 100644 --- a/Lib/tcl/stl.i +++ b/Lib/tcl/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/tcl8.swg b/Lib/tcl/tcl8.swg index c33cc7681..5da1bc07c 100644 --- a/Lib/tcl/tcl8.swg +++ b/Lib/tcl/tcl8.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tcl8.swg * * Tcl configuration module. diff --git a/Lib/tcl/tclinterp.i b/Lib/tcl/tclinterp.i index 48cdb6066..3b45b6d4b 100644 --- a/Lib/tcl/tclinterp.i +++ b/Lib/tcl/tclinterp.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclinterp.i * * Tcl_Interp *interp diff --git a/Lib/tcl/tclopers.swg b/Lib/tcl/tclopers.swg index 26b74203d..f113ccd19 100644 --- a/Lib/tcl/tclopers.swg +++ b/Lib/tcl/tclopers.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclopers.swg * * C++ overloaded operators. diff --git a/Lib/tcl/tclresult.i b/Lib/tcl/tclresult.i index ca0106432..c63b3ee19 100644 --- a/Lib/tcl/tclresult.i +++ b/Lib/tcl/tclresult.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclresult.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index 6387fb008..eb8bd253c 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclrun.swg * * This file contains the runtime support for Tcl modules and includes diff --git a/Lib/tcl/tclsh.i b/Lib/tcl/tclsh.i index 2e8ed3316..160ba8d8f 100644 --- a/Lib/tcl/tclsh.i +++ b/Lib/tcl/tclsh.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclsh.i * * SWIG File for building new tclsh program diff --git a/Lib/tcl/tclwstrings.swg b/Lib/tcl/tclwstrings.swg index 2d344c20f..b3b682e30 100644 --- a/Lib/tcl/tclwstrings.swg +++ b/Lib/tcl/tclwstrings.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * tclwstrings.wg * * Utility methods for wchar strings diff --git a/Lib/tcl/typemaps.i b/Lib/tcl/typemaps.i index 7c9e04a8b..8bee672cc 100644 --- a/Lib/tcl/typemaps.i +++ b/Lib/tcl/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.i * * Swig typemap library for Tcl8. This file contains various sorts diff --git a/Lib/tcl/wish.i b/Lib/tcl/wish.i index 077ded61f..260032a81 100644 --- a/Lib/tcl/wish.i +++ b/Lib/tcl/wish.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * wish.i * * SWIG File for making wish diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index f6335be82..19b22ed01 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * attribute.swg * * Attribute implementation diff --git a/Lib/typemaps/carrays.swg b/Lib/typemaps/carrays.swg index 27ca11779..cdeab36b7 100644 --- a/Lib/typemaps/carrays.swg +++ b/Lib/typemaps/carrays.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * carrays.swg * * This library file contains macros that can be used to manipulate simple diff --git a/Lib/typemaps/cdata.swg b/Lib/typemaps/cdata.swg index 32b3f5a77..5baf7904c 100644 --- a/Lib/typemaps/cdata.swg +++ b/Lib/typemaps/cdata.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cdata.swg * * This library file contains macros for manipulating raw C data as strings. diff --git a/Lib/typemaps/cmalloc.swg b/Lib/typemaps/cmalloc.swg index 15f962930..45a6ab990 100644 --- a/Lib/typemaps/cmalloc.swg +++ b/Lib/typemaps/cmalloc.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cmalloc.swg * * This library file contains macros that can be used to create objects using diff --git a/Lib/typemaps/cpointer.swg b/Lib/typemaps/cpointer.swg index ce1af169e..f797a6895 100644 --- a/Lib/typemaps/cpointer.swg +++ b/Lib/typemaps/cpointer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cpointer.swg * * This library file contains macros that can be used to manipulate simple diff --git a/Lib/typemaps/cstrings.swg b/Lib/typemaps/cstrings.swg index 9144da790..c60ef6496 100644 --- a/Lib/typemaps/cstrings.swg +++ b/Lib/typemaps/cstrings.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * cstrings.swg * * This file provides typemaps and macros for dealing with various forms diff --git a/Lib/typemaps/exception.swg b/Lib/typemaps/exception.swg index 17a819cd7..12c4ea658 100644 --- a/Lib/typemaps/exception.swg +++ b/Lib/typemaps/exception.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * exceptions.swg * * This SWIG library file provides language independent exception handling diff --git a/Lib/typemaps/ptrtypes.swg b/Lib/typemaps/ptrtypes.swg index 803377afe..e1bc476ed 100644 --- a/Lib/typemaps/ptrtypes.swg +++ b/Lib/typemaps/ptrtypes.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * ptrtypes.swg * * Value typemaps (Type, const Type&) for "Ptr" types, such as swig diff --git a/Lib/typemaps/swigtypemaps.swg b/Lib/typemaps/swigtypemaps.swg index 08abab028..0e39afe4c 100644 --- a/Lib/typemaps/swigtypemaps.swg +++ b/Lib/typemaps/swigtypemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * swigtypemaps.swg * * Unified Typemap Library frontend diff --git a/Lib/typemaps/typemaps.swg b/Lib/typemaps/typemaps.swg index 6e7505765..4629e8dfa 100644 --- a/Lib/typemaps/typemaps.swg +++ b/Lib/typemaps/typemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * typemaps.swg * * Tcl Pointer handling diff --git a/Lib/uffi/uffi.swg b/Lib/uffi/uffi.swg index 78bd23534..41b085998 100644 --- a/Lib/uffi/uffi.swg +++ b/Lib/uffi/uffi.swg @@ -27,8 +27,6 @@ typedef long size_t; %wrapper %{ -;; $Id$ - (eval-when (compile eval) ;;; You can define your own identifier converter if you want. diff --git a/Lib/wchar.i b/Lib/wchar.i index f106a3529..14de34634 100644 --- a/Lib/wchar.i +++ b/Lib/wchar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * wchar.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/windows.i b/Lib/windows.i index 08ddc2b22..2c093dacc 100644 --- a/Lib/windows.i +++ b/Lib/windows.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * 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. - * * windows.i * * SWIG library file to support types found in windows.h as well as Microsoft diff --git a/Makefile.in b/Makefile.in index ebfc03656..9760fdd9c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -162,50 +162,6 @@ java.actionexample: (cd Examples/$(LANGUAGE)/java && $(MAKE) -s $(chk-set-env) $(ACTION)) \ fi; \ -gifplot-library: - @echo $(ACTION)ing Examples/GIFPlot/Lib - @cd Examples/GIFPlot/Lib && $(MAKE) -k -s $(ACTION) - -check-gifplot: \ - check-tcl-gifplot \ - check-perl5-gifplot \ - check-python-gifplot \ - check-java-gifplot \ - check-guile-gifplot \ - check-mzscheme-gifplot \ - check-ruby-gifplot \ - check-ocaml-gifplot \ - check-octave-gifplot \ - check-php4-gifplot \ - check-pike-gifplot \ - check-chicken-gifplot \ -# check-lua-gifplot \ -# check-csharp-gifplot \ -# check-modula3-gifplot - -check-%-gifplot: gifplot-library - @if test -z "$(skip-$*)"; then \ - echo $* unknown; \ - exit 1; \ - fi - @passed=true; \ - up=`$(srcdir)/Tools/capitalize $*`; \ - dir="Examples/GIFPlot/$$up"; \ - if $(skip-$*); then \ - echo skipping $$up $(ACTION); \ - elif [ ! -f $$dir/check.list ]; then \ - echo skipping $$up $(ACTION) "(no $$dir/check.list)"; \ - else \ - all=`sed '/^#/d' $$dir/check.list`; \ - for a in $$all; do \ - echo $(ACTION)ing $$dir/$$a; \ - (cd $$dir/$$a && \ - $(MAKE) -k -s $(chk-set-env) $(ACTION)) \ - || passed=false; \ - done; \ - fi; \ - test $$passed = true - # Checks testcases in the test-suite excluding those which are known to be broken check-test-suite: \ check-tcl-test-suite \ @@ -255,7 +211,7 @@ partialcheck-test-suite: partialcheck-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck -check: check-aliveness check-examples check-gifplot check-test-suite +check: check-aliveness check-examples check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ @@ -315,7 +271,7 @@ broken-%-test-suite: # CLEAN ##################################################################### -clean: clean-objects clean-libfiles clean-examples clean-gifplot clean-test-suite clean-docs +clean: clean-objects clean-libfiles clean-examples clean-test-suite clean-docs clean-objects: clean-source @@ -330,9 +286,6 @@ clean-libfiles: clean-examples: @$(MAKE) -k -s check-examples ACTION=clean -clean-gifplot: - @$(MAKE) -k -s check-gifplot ACTION=clean - clean-test-suite: @$(MAKE) -k -s check-test-suite ACTION=clean @@ -342,9 +295,6 @@ clean-%-examples: clean-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=clean -clean-%-gifplot: - @$(MAKE) -k -s check-$*-gifplot ACTION=clean - clean-docs: @echo cleaning Docs @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) -s clean @@ -358,7 +308,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: distclean-objects clean-examples distclean-test-suite clean-docs distclean-dead distclean-objects: distclean-source diff --git a/README b/README index 2898130b0..d6174bda5 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.36 (24 June 2008) +Version: 2.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -13,61 +13,6 @@ the listed languages, or to extend C/C++ programs with a scripting language. This distribution represents the latest development release of SWIG. -The guilty parties working on this are: - -Active Developers: - William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin) - Olly Betts (olly@survex.com) (PHP) - John Lenz (Guile, MzScheme updates, Chicken module, runtime system) - Mark Gossage (mark@gossage.cjb.net) (Lua) - Joseph Wang (joe@gnacademy.org) (R) - Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) - Xavier Delacour (xavier.delacour@gmail.com) (Octave) - -Major contributors include: - Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) - Henning Thielemann (swig@henning-thielemann.de) (Modula3) - Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme) - Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping) - Mikel Bancroft (mikel@franz.com) (Allegro CL) - Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI) - Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby]) - Art Yerkes (ayerkes@speakeasy.net) (Ocaml) - Lyle Johnson (lyle@users.sourceforge.net) (Ruby) - Charlie Savage (cfis@interserv.com) (Ruby) - Thien-Thi Nguyen (ttn@glug.org) (build/test/misc) - Richard Palmer (richard@magicality.org) (PHP) - Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP) - Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP) - Kevin Ruland (PHP) - Shibukawa Yoshiki (Japanese Translation) - Jason Stewart (jason@openinformatics.com) (Perl5) - Loic Dachary (Perl5) - David Fletcher (Perl5) - Gary Holt (Perl5) - Masaki Fukushima (Ruby) - Scott Michel (scottm@cs.ucla.edu) (Java directors) - Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core) - Mark Rose (mrose@stm.lbl.gov) (Directors) - Jonah Beckford (beckford@usermail.com) (CHICKEN) - Ahmon Dancy (dancy@franz.com) (Allegro CL) - Dirk Gerrits (Allegro CL) - Neil Cawse (C#) - Harco de Hilster (Java) - Alexey Dyachenko (dyachenko@fromru.com) (Tcl) - Bob Techentin (Tcl) - Martin Froehlich (Guile) - Marcio Luis Teixeira (Guile) - Duncan Temple Lang (R) - -Past contributors include: - James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran - Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn - (See CHANGES for a more complete list). - -Portions also copyrighted by companies/corporations; - Network Applied Communication Laboratory, Inc - Information-technology Promotion Agency, Japan Up-to-date SWIG related information can be found at diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 06a901c0d..522ca778f 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cparse.h * diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 68d50cd2d..ea265bb56 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * scanner.c * diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index d28516206..1b055edd9 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * parser.y * diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index a3e992f83..120b75670 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * templ.c * diff --git a/Source/CParse/util.c b/Source/CParse/util.c index efae41051..fa934ffc0 100644 --- a/Source/CParse/util.c +++ b/Source/CParse/util.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * util.c * diff --git a/Source/DOH/base.c b/Source/DOH/base.c index dcb0140e0..7d19e6c3d 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * base.c * * This file contains the function entry points for dispatching methods on * DOH objects. A number of small utility functions are also included. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_base_c[] = "$Id$"; diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 7ab244fab..396a9cacf 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -1,14 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * doh.h * * This file describes of the externally visible functions in DOH. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. - * - * $Id$ * ----------------------------------------------------------------------------- */ #ifndef _DOH_H diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h index 1fc5eb7c9..661bed075 100644 --- a/Source/DOH/dohint.h +++ b/Source/DOH/dohint.h @@ -1,15 +1,14 @@ - /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * dohint.h * * This file describes internally managed objects. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. - * - * $Id$ * ----------------------------------------------------------------------------- */ #ifndef _DOHINT_H diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 8c53978ee..3d8d20284 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * file.c * * This file implements a file-like object that can be built around an * ordinary FILE * or integer file descriptor. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_file_c[] = "$Id$"; diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index f544cee64..2ef605c32 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * fio.c * * This file implements a number of standard I/O operations included * formatted output, readline, and splitting. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_fio_c[] = "$Id$"; diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 62aef10f2..ab90e725e 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -1,12 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * hash.c * * Implements a simple hash table object. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_hash_c[] = "$Id$"; diff --git a/Source/DOH/list.c b/Source/DOH/list.c index a45731de1..f3be4fba1 100644 --- a/Source/DOH/list.c +++ b/Source/DOH/list.c @@ -1,12 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * list.c * * Implements a simple list object. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_list_c[] = "$Id$"; diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index 1c6063ef3..fcacd6170 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * memory.c * * This file implements all of DOH's memory management including allocation * of objects and checking of objects. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_memory_c[] = "$Id$"; diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 1498d717a..ea6b46cb2 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * string.c * * Implements a string object that supports both sequence operations and * file semantics. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_string_c[] = "$Id$"; diff --git a/Source/DOH/void.c b/Source/DOH/void.c index 0be01561a..2d684b9cd 100644 --- a/Source/DOH/void.c +++ b/Source/DOH/void.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * void.c * * Implements a "void" object that is really just a DOH container around * an arbitrary C object represented as a void *. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_void_c[] = "$Id$"; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 8c4678847..d7a06c46c 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigwarn.h * @@ -16,8 +20,6 @@ * numbers in this file. * ----------------------------------------------------------------------------- */ -/* $Id$ */ - #ifndef SWIGWARN_H_ #define SWIGWARN_H_ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 217c89b1f..34ca51f8d 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * allegrocl.cxx * diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index e8397e6a6..31f27e1eb 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * allocate.cxx * diff --git a/Source/Modules/browser.cxx b/Source/Modules/browser.cxx index b1bc7349c..592e12783 100644 --- a/Source/Modules/browser.cxx +++ b/Source/Modules/browser.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * browser.cxx * diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 4b3ddac70..97859f090 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cffi.cxx * diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 2298d2939..ec77f1870 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * chicken.cxx * diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 823f22e2c..f0e57f3f0 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * clisp.cxx * diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index 9bf8decf6..e8687c90b 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * contract.cxx * diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 431181355..7992b260a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * csharp.cxx * diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 4363cd813..2050d953e 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * directors.cxx * diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index a4cf8cebc..fde3b2457 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * emit.cxx * diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index f5f080034..d64c87b49 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * guile.cxx * diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0c5ad5401..279eb530e 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * java.cxx * diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index e2fd93f7b..122270a9d 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * lang.cxx * diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 6113da960..e81974c9b 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * lua.cxx * diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 901ee812e..055af907f 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * main.cxx * diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 6cb24d39a..5ee3c6b5c 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * modula3.cxx * diff --git a/Source/Modules/module.cxx b/Source/Modules/module.cxx index 6a0d6bbb9..f4ab560dd 100644 --- a/Source/Modules/module.cxx +++ b/Source/Modules/module.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * module.cxx * diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 78d4a4b65..01e3b9c8c 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * mzscheme.cxx * diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 0d0f4c7f2..b8d932ffb 100755 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * ocaml.cxx * diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index d582e8a6c..4aa9c0ab8 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * octave.cxx * diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index d16913885..793511c57 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * overload.cxx * diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 6e706fc8d..8faff7d7f 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1,10 +1,10 @@ -/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=2:tabstop=8:smarttab: - */ - /* ---------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * perl5.cxx * diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 9369c2489..66ca6eff2 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * php4.cxx * diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 30f9b3d74..f4a6c13e6 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * pike.cxx * diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bfbada1da..c8d7e06ca 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * python.cxx * diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 49d3ecc89..9035f5e9e 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * r.cxx * diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index ad448d34e..ec0d3dee9 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * ruby.cxx * diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index b89b3097f..86213fcab 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * s-exp.cxx * diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 5b103e71e..7cd913e2a 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -1,11 +1,15 @@ /* ----------------------------------------------------------------------------- - * 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. - * - * Simplified Wrapper and Interface Generator (SWIG) + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigmain.cxx * + * Simplified Wrapper and Interface Generator (SWIG) + * * This file is the main entry point to SWIG. It collects the command * line options, registers built-in language modules, and instantiates * a module for code generation. If adding new language modules diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 03892e4f6..5dc6fd390 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigmod.h * diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 09bd266c3..7a86108bb 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * tcl8.cxx * diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index d663aed6e..e972cea05 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typepass.cxx * diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 5d4affb8c..c35ca2666 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * uffi.cxx * diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx index bf8211903..3fe7a2709 100644 --- a/Source/Modules/utils.cxx +++ b/Source/Modules/utils.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * utils.cxx * diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index c74b48d7c..bd595d526 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * xml.cxx * diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index c04f95f00..1e05af6ef 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cpp.c * diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index 4da24a774..3e3f39480 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * expr.c * diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index 4f7ff8804..199e5ae3c 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * preprocessor.h * diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 18920ecc2..714613d81 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cwrap.c * diff --git a/Source/Swig/deprecate.c b/Source/Swig/deprecate.c index 475d2c6cf..f25b9a650 100644 --- a/Source/Swig/deprecate.c +++ b/Source/Swig/deprecate.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * deprecate.c * diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 1eaba1f17..0ce53dd5b 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * error.c * diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 510a01875..896461b30 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * fragment.c * diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index 87b0f7c9d..b8389b476 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * getopt.c * diff --git a/Source/Swig/include.c b/Source/Swig/include.c index 3f47be15b..79b97b4d6 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * include.c * diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index a9c64011e..03dc28d2a 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * misc.c * diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index f34a24612..31cf116dc 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * naming.c * diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index baa1dfbf3..267852cf0 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * parms.c * diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 06e78db37..a082036a5 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * scanner.c * diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 5ffd28eec..30a80b4bd 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * stype.c * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 3f736bbd5..9501eaa55 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swig.h * diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index c945fb1ac..4f6869109 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigfile.h * diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h index 428d90dce..433ca07e5 100644 --- a/Source/Swig/swigopt.h +++ b/Source/Swig/swigopt.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigopt.h * diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 529438bae..6ea849424 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigparm.h * diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index 2486286a9..31b0c2705 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigscan.h * diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h index 2e5c4da36..d4221207c 100644 --- a/Source/Swig/swigtree.h +++ b/Source/Swig/swigtree.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigtree.h * diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h index 25eeb6f7f..bd1009d0e 100644 --- a/Source/Swig/swigwrap.h +++ b/Source/Swig/swigwrap.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigwrap.h * diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index c9691fa54..3d6eb508b 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * symbol.c * diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 61dca8353..b6cbca352 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * tree.c * diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 6cbeb67ea..5ee74b629 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typemap.c * diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 18d1b2304..2732e2fd5 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typeobj.c * diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index a9e2898bd..90df2ebd1 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typesys.c * diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c index 3778066ce..2e18474aa 100644 --- a/Source/Swig/wrapfunc.c +++ b/Source/Swig/wrapfunc.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * wrapfunc.c * diff --git a/configure.in b/configure.in index 8a09cd6f7..dada26c7f 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.37],[http://www.swig.org]) +AC_INIT([swig],[2.0.0],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) @@ -2135,8 +2135,6 @@ AC_CONFIG_FILES([ \ Examples/Makefile \ Examples/guile/Makefile \ Examples/xml/Makefile \ - Examples/GIFPlot/Makefile \ - Examples/GIFPlot/Lib/Makefile \ Examples/test-suite/chicken/Makefile \ Examples/test-suite/csharp/Makefile \ Examples/test-suite/guile/Makefile \ From 02fbe37ae6147b64e21c153b45a9a09313668438 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Mar 2010 11:47:21 +0000 Subject: [PATCH 0043/2031] Add new GPL license headers to source files added in this branch git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@11911 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenEntity.cpp | 12 ++++++++---- Source/DoxygenTranslator/src/DoxygenEntity.h | 10 +++++++--- Source/DoxygenTranslator/src/DoxygenParser.cpp | 11 +++++++++++ Source/DoxygenTranslator/src/DoxygenParser.h | 11 +++++++++++ .../DoxygenTranslator/src/DoxygenTranslator.cpp | 10 +++++++--- Source/DoxygenTranslator/src/DoxygenTranslator.h | 8 ++++++-- .../src/Examples/DoxygenTransWTokenizer.cpp | 16 +++++++++++++--- .../src/Examples/DoxygenTransWTokenizer.h | 11 +++++++++++ .../DoxygenTranslator/src/Examples/translator.h | 11 +++++++++++ .../DoxygenTranslator/src/JavaDocConverter.cpp | 11 +++++++++++ Source/DoxygenTranslator/src/JavaDocConverter.h | 8 ++++++-- Source/DoxygenTranslator/src/PyDocConverter.cpp | 10 +++++++--- Source/DoxygenTranslator/src/PyDocConverter.h | 8 ++++++-- Source/DoxygenTranslator/src/Token.cpp | 11 +++++++++++ Source/DoxygenTranslator/src/Token.h | 11 +++++++++++ Source/DoxygenTranslator/src/TokenList.cpp | 11 +++++++++++ Source/DoxygenTranslator/src/TokenList.h | 11 +++++++++++ Source/Swig/warn.c | 8 ++++++-- 18 files changed, 165 insertions(+), 24 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index f770dc514..dc49c803e 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -1,8 +1,12 @@ -/* ----------------------------------------------------------------------------- - * 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. +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * - * python.cxx + * DoxygenEntity.cpp * * Part of the Doxygen comment translation module of SWIG. * ----------------------------------------------------------------------------- */ diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index ca42393db..dcdba7644 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -1,8 +1,12 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * - * python.cxx + * DoxygenEntity.h * * Part of the Doxygen comment translation module of SWIG. * ----------------------------------------------------------------------------- */ diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index f4bce5445..030d8bee9 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * DoxygenParser.cpp + * ----------------------------------------------------------------------------- */ + #include "DoxygenParser.h" #include "TokenList.h" diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index c298a92f3..0c1f2d1cb 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * DoxygenParser.h + * ----------------------------------------------------------------------------- */ + #ifndef DOXYGENPARSER_H_ #define DOXYGENPARSER_H_ #include diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 6fe97d298..36ca95579 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -1,6 +1,10 @@ -/* ----------------------------------------------------------------------------- - * 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. +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * DoxygenTranslator.cpp * diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 566b1551d..1a14a4db2 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * DoxygenTranslator.h * diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp index 930141c97..dd803b75f 100644 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp @@ -1,6 +1,16 @@ -/* The main class for translating blobs of Doxygen for SWIG - * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - */ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * DoxygenTransWTokenizer.cpp + * + * The main class for translating blobs of Doxygen for SWIG + * ----------------------------------------------------------------------------- */ + //TODO DOH instead of STL? //TODO Most commands are not fully implemented diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h index fb3181d25..8a51b4d02 100644 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * DoxygenTransWTokenizer.h + * ----------------------------------------------------------------------------- */ + #ifndef DOXYGENTRANSWTOKENIZER_H_ #define DOXYGENTRANSWTOKENIZER_H_ diff --git a/Source/DoxygenTranslator/src/Examples/translator.h b/Source/DoxygenTranslator/src/Examples/translator.h index 0ae58f714..f9da98180 100644 --- a/Source/DoxygenTranslator/src/Examples/translator.h +++ b/Source/DoxygenTranslator/src/Examples/translator.h @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * translator.h + * ----------------------------------------------------------------------------- */ + #ifndef TRANSLATOR_H_ #define TRANSLATOR_H_ diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 9de2f99f3..8cca8b3a5 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * JavaDocConverter.cpp + * ----------------------------------------------------------------------------- */ + #include "JavaDocConverter.h" #include "DoxygenParser.h" #include diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index d898265ba..69fc8d75d 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * JavaDocConverter.h * diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index cbe81571b..3b305b9fd 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -1,6 +1,10 @@ -/* ----------------------------------------------------------------------------- - * 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. +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * PyDocConverter.cpp * diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 5680480fc..ecd033af5 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * PyDocConverter.h * diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp index f7c02b021..6ade97163 100644 --- a/Source/DoxygenTranslator/src/Token.cpp +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * Token.cpp + * ----------------------------------------------------------------------------- */ + #include "Token.h" #include "DoxygenEntity.h" using namespace std; diff --git a/Source/DoxygenTranslator/src/Token.h b/Source/DoxygenTranslator/src/Token.h index 4ae44b65f..6e10fd338 100644 --- a/Source/DoxygenTranslator/src/Token.h +++ b/Source/DoxygenTranslator/src/Token.h @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * Token.h + * ----------------------------------------------------------------------------- */ + #ifndef TOKEN_H_ #define TOKEN_H_ #include diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 8eeef97b2..5e13fe164 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * TokenList.cpp + * ----------------------------------------------------------------------------- */ + #include "TokenList.h" #include #include diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index 841d66e1a..057f67ed4 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -1,3 +1,14 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * TokenList.h + * ----------------------------------------------------------------------------- */ + #ifndef TOKENLIST_H_ #define TOKENLIST_H_ #include diff --git a/Source/Swig/warn.c b/Source/Swig/warn.c index a8dadc70b..b01815354 100644 --- a/Source/Swig/warn.c +++ b/Source/Swig/warn.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * 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. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * warn.c * From d590621eae215b6be8eb11d22dd59e74b69b3f38 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Tue, 8 May 2012 19:48:49 +0000 Subject: [PATCH 0044/2031] Added myself to the COPYRIGHT git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13050 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- COPYRIGHT | 1 + 1 file changed, 1 insertion(+) diff --git a/COPYRIGHT b/COPYRIGHT index 2fe0099b8..dc61d89b4 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -19,6 +19,7 @@ Active SWIG Developers: Past SWIG developers and major contributors include: Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) + Dmitry Kabak (userdima@gmail.com) (Doxygen) Henning Thielemann (swig@henning-thielemann.de) (Modula3) Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme) Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping) From ce39e74f28286e104ae0caff9d78d2cafb11e369 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 28 May 2012 19:47:03 +0000 Subject: [PATCH 0045/2031] Applied Christopher Mangiardi's patch that fixes incorrect comment placement in python single line functions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13133 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d3d652eb0..c47f695aa 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3979,7 +3979,7 @@ public: if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); - Printv(f_shadow, " return ", funcCall(fullname, callParms), "\n", NIL); + Printv(f_shadow, "\n", NIL); if (doxygen) { String *doxygen_comments; if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { @@ -3987,6 +3987,7 @@ public: Delete(doxygen_comments); } } + Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); From 744d59c9d000444606cf043947bf829d100f802f Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 3 Jun 2012 16:40:31 +0000 Subject: [PATCH 0046/2031] Small documentation fix in Doxygen.html git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13141 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Doxygen.html | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 54161eeb3..989fb0dc4 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -36,7 +36,7 @@

    This chapter describes SWIG's support for translating Doxygen comments found in interface and header files into a target language's normal documentation language. -Currently only JavaDoc is supported. +Currently only JavaDoc and PythonDoc is supported.

    35.1 Doxygen Translation Overview

    @@ -45,11 +45,11 @@ Currently only JavaDoc is supported.

    The Doxygen Translation Module of SWIG is an ongoing effort from a Google Summer of Code proposal from Summer 2008. It adds an extra layer of functionality to SWIG, allowing automated translation of Doxygen formatted comments from input files into a documentation language more suited for the target language. -Currently this module only translates into JavaDoc for the SWIG Java Module, but other extensions are to be added in time. +Currently this module only translates into JavaDoc and PythonDoc for the SWIG Java and Python Modules, but other extensions are to be added in time.

    -Questions about running SWIG are best answered in the SWIG Basics chapter as well as the target language modules. (For now, only Java). +Questions about running SWIG are best answered in the SWIG Basics chapter as well as the target language modules. (For now, only Java and Python). The behaviour of this functionality is wildly unpredictable if the interface file is not proper to begin with!

    @@ -72,7 +72,43 @@ class Shape {

    -Because this functionality is currently only extended to Java, you must be able to run SWIG's Java Module in order to make use of this tool. +Please note, as SWIG parses input file by itself with strict grammar, there is only a limited support for various cases of comment placement in the file. +Comments can be placed between two C expressions on separate lines: +

    + +
    +void someOtherFunction();
    +/**
    + * Some comment
    + */
    +void someFunction();
    +
    + +

    +and in some special cases, like function parameter comments: +

    + +
    +void someFunction(
    +         int a ///< Some parameter 
    +     );
    +
    + +

    +or enum element comments: +

    + +
    +enum E_NUMBERS
    +{
    +    EN_ZERO, ///< The first enum item, gets zero as it's value
    +    EN_ONE, ///< The second, EN_ONE=1
    +    EN_THREE
    +};
    +
    + +

    +Just remember, if SWIG shows syntax error parsing the file because of your comment, try to move it in some other, 'safer' place as desribed above.

    35.2.1 Enabling Doxygen Translation

    From ac6b51f13e02dc137f639c6465d227eee7442e08 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 4 Jun 2012 18:02:51 +0000 Subject: [PATCH 0047/2031] Fix to include comment for non-member functions in python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13149 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c47f695aa..f0f6d0671 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1780,6 +1780,13 @@ public: 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 (doxygen) { + String *doxygen_comments; + if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { + Printf(f_dest, Char(pythoncode(doxygen_comments, tab2))); + Delete(doxygen_comments); + } + } if (have_docstring(n)) Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); if (have_pythonprepend(n)) From e3f41f32a6096f8f8273fb4ba4ca610050f16961 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 4 Jun 2012 18:11:29 +0000 Subject: [PATCH 0048/2031] Added test case to check Doxygen comments parsing, including java and python runtime tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13150 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/doxygen_parsing.i | 84 +++++++++++++++++ Examples/test-suite/java/Makefile.in | 4 +- .../java/doxygen_parsing_runme.java | 89 +++++++++++++++++++ .../python/doxygen_parsing_runme.py | 19 ++++ 5 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/doxygen_parsing.i create mode 100644 Examples/test-suite/java/doxygen_parsing_runme.java create mode 100644 Examples/test-suite/python/doxygen_parsing_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7cc410e7a..ec47ffaa0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -187,6 +187,7 @@ CPP_TEST_CASES += \ director_using \ director_wombat \ disown \ + doxygen_parsing \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i new file mode 100644 index 000000000..20781cfa8 --- /dev/null +++ b/Examples/test-suite/doxygen_parsing.i @@ -0,0 +1,84 @@ +%module doxygen_parsing + +%inline %{ + +/** + * This is simple comment for a var + */ +int simpleVar=42; +/*! + * This is another type of comment for a var + */ +int simpleVarTwo=42; + +/// This is again another type of comment for a var +int simpleVarThree=42; +//! This is the last type of comment for a var +int simpleVarFour=42; + +/* + We assume that all this comment types are ok, + and later we only use the first-type comments. +*/ + + +/** + * This is simple comment for a function + */ +void simpleFunction(int arg) +{ +} + +/** + * This is simple comment for a class + */ +class CSimpleClass +{ +private: + /** Some member var */ + int simpleVar; + +public: + /** + * Simple method + */ + void simpleMethod(int asd) + { + } + /** + * Simple method with parameter + */ + void simpleMethodWithParameter( + int param /**< Some test param */ + ) + { + } +}; + +/** Test enumeration */ +enum E_TEST +{ + /** the first item */ + E_TEST_ONE, + E_TEST_TWO = 2, /**< the second */ + E_TEST_THREE = 2+1 +}; + +/** + * Comment for template class + */ +template +class CTemplateClass +{ +public: + /** + * Template method + */ + void templateMethod(T arg) + { + } +}; + +%} + +%template(CTemplateClassInt) CTemplateClass; \ No newline at end of file diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index ef3c981a4..813232620 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -79,8 +79,8 @@ setup = \ run_testcase = \ cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \ + $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_HOME)/lib/tools.jar:. -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath $(JAVA_HOME)/lib/tools.jar:. $*_runme; \ fi # Clean: remove testcase directories diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java new file mode 100644 index 000000000..c4264d003 --- /dev/null +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -0,0 +1,89 @@ + +import doxygen_parsing.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_runme { + static { + try { + System.loadLibrary("doxygen_parsing"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test", + "doxygen_parsing_runme", new String[]{"-quiet", "doxygen_parsing"}); + + wantedComments.put("simpleFunction", " This is simple comment for a function \n"); + + wantedComments.put("CSimpleClass", " This is simple comment for a class \n"); + wantedComments.put("simpleMethod", " Simple method \n"); + wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n @param\tparam Some test param \n"); + wantedComments.put("CTemplateClassInt", " Comment for template class \n"); + wantedComments.put("templateMethod", " Template method \n"); + + wantedComments.put("setSimpleVar", " This is simple comment for a var \n"); + wantedComments.put("getSimpleVar", " This is simple comment for a var \n"); + wantedComments.put("setSimpleVarTwo", " This is another type of comment for a var \n"); + wantedComments.put("getSimpleVarTwo", " This is another type of comment for a var \n"); + wantedComments.put("setSimpleVarThree", " This is again another type of comment for a var \n"); + wantedComments.put("getSimpleVarThree", " This is again another type of comment for a var \n"); + wantedComments.put("setSimpleVarFour", " This is the last type of comment for a var \n"); + wantedComments.put("getSimpleVarFour", " This is the last type of comment for a var \n"); + + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + System.exit(errorCount); + } +} diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py new file mode 100644 index 000000000..eef840818 --- /dev/null +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -0,0 +1,19 @@ +#!/usr/bin/python + +import doxygen_parsing +import sys +import re + +def check(got, expected): + if not re.match(str(expected), str(got)): + raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") + +check(doxygen_parsing.simpleFunction.__doc__, '\s+This is simple comment for a function\s+') +check(doxygen_parsing.CSimpleClass.__doc__, '\s+This is simple comment for a class\s+') +check(doxygen_parsing.CSimpleClass.simpleMethod.__doc__, '\s+Simple method\s+') +check(doxygen_parsing.CSimpleClass.simpleMethodWithParameter.__doc__, '' +'\s+Simple method with parameter' +'\s+Arguments:\s+param \(int\)\s+-- Some test param\s+' +) +check(doxygen_parsing.CTemplateClassInt.__doc__, '\s+Comment for template class\s+') +check(doxygen_parsing.CTemplateClassInt.templateMethod.__doc__, '\s+Template method\s+') \ No newline at end of file From b0f8e594c98d56abda1a461212466b72ace351e5 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 18 Jun 2012 18:30:18 +0000 Subject: [PATCH 0049/2031] Implement toggling comment parsing feature on and off git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13182 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cparse.h | 1 + Source/CParse/cscanner.c | 23 ++++++++++++++--------- Source/CParse/parser.y | 3 +-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 922bbfcdc..895118363 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -26,6 +26,7 @@ extern "C" { extern int cparse_line; extern int cparse_cplusplus; extern int cparse_start_line; + extern int scan_doxygen_comments; extern void Swig_cparse_cplusplus(int); extern void scanner_file(File *); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 66a570a95..44af1069b 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -46,6 +46,9 @@ static int last_brace = 0; static int last_id = 0; static int rename_active = 0; +/* Doxygen comments scanning */ +int scan_doxygen_comments = 1; + /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() * ----------------------------------------------------------------------------- */ @@ -337,15 +340,17 @@ static int yylook(void) { if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); } - if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { - /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENPOSTSTRING; - } - if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENSTRING; + if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/ + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { + /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENPOSTSTRING; + } + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENSTRING; + } } } break; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 39028cfe7..ffba04884 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -63,7 +63,6 @@ static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Doxygen Comment Globals and Assist Functions * ----------------------------------------------------------------------------- */ -int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */ String *currentComment; /* Location of the stored Doxygen Comment */ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ @@ -107,7 +106,7 @@ static Node *new_node(const_String_or_char_ptr tag) { set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - if(parseComments){ + if(scan_doxygen_comments){ /* Sets any post comments to the previous node */ if(previousNode != NULL && currentPostComment != 0){ String *copyPostComment = Copy(currentPostComment); From 72b23954fb58b89083045ae562420dcd59472c44 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 18 Jun 2012 18:33:30 +0000 Subject: [PATCH 0050/2031] Fix integration of doxygen with autodoc feature, fixed autodoc test and some code refactored git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13183 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/autodoc_runme.py | 6 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 2 +- Source/Modules/python.cxx | 67 ++++++++----------- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index dc843ae96..b0359f2e0 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -165,9 +165,9 @@ check(F.__init__.__doc__, "\n" check(B.funk.__doc__, "funk(B self, int c, int d) -> int") check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int") check(funkdefaults.__doc__, "\n" -" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" -" funkdefaults(A e, short arg2, int c, int d) -> int\n" -" " +" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" +" funkdefaults(A e, short arg2, int c, int d) -> int\n" +" " ) check(func_input.__doc__, "func_input(int * INPUT) -> int") diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 3b305b9fd..55c3ba61b 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -193,7 +193,7 @@ bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { // if we got something log the result and construct DOH string to return if (pyDocString.length()) { - result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; + result = pyDocString; if (debug) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f0f6d0671..07437715d 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -21,6 +21,7 @@ static int treduce = SWIG_cparse_template_reduce(0); #include #include #include "../DoxygenTranslator/src/DoxygenTranslator.h" +#include "../../../swig/bug.h" #define PYSHADOW_MEMBER 0x2 #define WARN_PYTHON_MULTIPLE_INH 405 @@ -120,7 +121,7 @@ Python Options (available with -python)\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ - -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ + -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes (default) \n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ @@ -139,6 +140,7 @@ static const char *usage2 = (char *) "\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ + -nodoxygen - Don't convert C++ doxygen comments to pydoc comments in proxy classes \n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ -nofastinit - Use traditional init mechanism for classes \n\ @@ -418,12 +420,17 @@ public: } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-doxygen") == 0) { - doxygen = 1; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-nodirvtable") == 0) { dirvtable = 0; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-doxygen") == 0) { + doxygen = 1; + scan_doxygen_comments = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nodoxygen") == 0) { + doxygen = 0; + scan_doxygen_comments = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastunpack") == 0) { fastunpack = 1; Swig_mark_arg(i); @@ -1194,7 +1201,10 @@ public: bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); - return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + return ((str && Len(str) > 0) + || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) + || (doxygen && Getattr(n, "DoxygenComment")) + ); } /* ------------------------------------------------------------ @@ -1206,8 +1216,10 @@ public: String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) { String *str = Getattr(n, "feature:docstring"); + String *doxygen_comment = 0; bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + bool have_doxygen = doxygen && DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comment); const char *triple_double = use_triple ? "\"\"\"" : ""; String *autodoc = NULL; String *doc = NULL; @@ -1224,6 +1236,9 @@ public: autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } + if (have_doxygen) { + have_doxygen = (doxygen_comment && Len(doxygen_comment) > 0); + } // If there is more than one line then make docstrings like this: // // """ @@ -1250,7 +1265,11 @@ public: doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), indent, triple_double, NIL); } - } else + } else if (have_doxygen) { // the lowest priority + doc = NewString(""); + Printv(doc, triple_double, "\n", pythoncode(doxygen_comment, indent), indent, triple_double, NIL); + } + else doc = NewString(""); // Save the generated strings in the parse tree in case they are used later @@ -1780,15 +1799,8 @@ public: 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 (doxygen) { - String *doxygen_comments; - if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { - Printf(f_dest, Char(pythoncode(doxygen_comments, tab2))); - Delete(doxygen_comments); - } - } if (have_docstring(n)) - Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab2), "\n", NIL); if (have_pythonprepend(n)) Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL); if (have_pythonappend(n)) { @@ -3700,16 +3712,7 @@ public: Printf(f_shadow, ":\n"); - // translate and write pydoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ - Printf(f_shadow, Char(pythoncode(doxygen_comments, shadow_indent))); - Delete(doxygen_comments); - } - } - - // otherwise use default docstrings if requested + // write docstrings if requested if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str && Len(str)) @@ -3987,26 +3990,12 @@ public: if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); - if (doxygen) { - String *doxygen_comments; - if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { - Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); - Delete(doxygen_comments); - } - } Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); - if (doxygen) { - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ - Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); - Delete(doxygen_comments); - } - } - else if (have_docstring(n)) + if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; From b88de2aa89f297b0c9bda42843836e3cab39f84b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 18 Jun 2012 19:13:23 +0000 Subject: [PATCH 0051/2031] Fixed enum comments generation, added testcases git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13184 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_parsing.i | 9 -- Examples/test-suite/doxygen_parsing_enums.i | 15 +++ .../test-suite/doxygen_parsing_enums_proper.i | 7 ++ .../test-suite/doxygen_parsing_enums_simple.i | 6 ++ .../doxygen_parsing_enums_typesafe.i | 8 ++ .../doxygen_parsing_enums_typeunsafe.i | 6 ++ Examples/test-suite/java/Makefile.in | 4 + .../doxygen_parsing_enums_proper_runme.java | 93 +++++++++++++++++++ .../doxygen_parsing_enums_simple_runme.java | 93 +++++++++++++++++++ .../doxygen_parsing_enums_typesafe_runme.java | 93 +++++++++++++++++++ ...oxygen_parsing_enums_typeunsafe_runme.java | 93 +++++++++++++++++++ .../java/doxygen_parsing_runme.java | 18 ++++ .../src/JavaDocConverter.cpp | 2 +- Source/Modules/java.cxx | 68 +++++++------- 14 files changed, 470 insertions(+), 45 deletions(-) create mode 100644 Examples/test-suite/doxygen_parsing_enums.i create mode 100644 Examples/test-suite/doxygen_parsing_enums_proper.i create mode 100644 Examples/test-suite/doxygen_parsing_enums_simple.i create mode 100644 Examples/test-suite/doxygen_parsing_enums_typesafe.i create mode 100644 Examples/test-suite/doxygen_parsing_enums_typeunsafe.i create mode 100644 Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java create mode 100644 Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java create mode 100644 Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java create mode 100644 Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index 20781cfa8..b61317bcd 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -55,15 +55,6 @@ public: } }; -/** Test enumeration */ -enum E_TEST -{ - /** the first item */ - E_TEST_ONE, - E_TEST_TWO = 2, /**< the second */ - E_TEST_THREE = 2+1 -}; - /** * Comment for template class */ diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i new file mode 100644 index 000000000..317abf384 --- /dev/null +++ b/Examples/test-suite/doxygen_parsing_enums.i @@ -0,0 +1,15 @@ +%module doxygen_parsing_enums + +%inline %{ + + +/** Test enumeration */ +enum E_TEST +{ + /** the first item */ + E_TEST_ONE, + E_TEST_TWO = 2, /**< the second */ + E_TEST_THREE = 2+1 +}; + +%} \ No newline at end of file diff --git a/Examples/test-suite/doxygen_parsing_enums_proper.i b/Examples/test-suite/doxygen_parsing_enums_proper.i new file mode 100644 index 000000000..1a69a84f1 --- /dev/null +++ b/Examples/test-suite/doxygen_parsing_enums_proper.i @@ -0,0 +1,7 @@ +%module "doxygen_parsing_enums_proper" + +// Test enum commenting using the proper enums in the target language +%include "enums.swg" + +%include "doxygen_parsing_enums.i" + diff --git a/Examples/test-suite/doxygen_parsing_enums_simple.i b/Examples/test-suite/doxygen_parsing_enums_simple.i new file mode 100644 index 000000000..823a27584 --- /dev/null +++ b/Examples/test-suite/doxygen_parsing_enums_simple.i @@ -0,0 +1,6 @@ +%module "doxygen_parsing_enums_simple" + +// Test enum commenting using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java) +%include "enumsimple.swg" + +%include "doxygen_parsing_enums.i" \ No newline at end of file diff --git a/Examples/test-suite/doxygen_parsing_enums_typesafe.i b/Examples/test-suite/doxygen_parsing_enums_typesafe.i new file mode 100644 index 000000000..25e355ee2 --- /dev/null +++ b/Examples/test-suite/doxygen_parsing_enums_typesafe.i @@ -0,0 +1,8 @@ +%module "doxygen_parsing_enums_typesafe" + +// Test enum commenting using the typesafe enum pattern in the target language +%include "enumtypesafe.swg" + +#define SWIG_TEST_NOCSCONST // For C# typesafe enums + +%include "doxygen_parsing_enums.i" \ No newline at end of file diff --git a/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i b/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i new file mode 100644 index 000000000..e001035df --- /dev/null +++ b/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i @@ -0,0 +1,6 @@ +%module "doxygen_parsing_enums_typeunsafe" + +// Test enum commenting using a type unsafe enum pattern (constant integers in a class for the enum type) +%include "enumtypeunsafe.swg" + +%include "doxygen_parsing_enums.i" \ No newline at end of file diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 813232620..3cb9d0c23 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -16,6 +16,10 @@ C_TEST_CASES = \ java_lib_various CPP_TEST_CASES = \ + doxygen_parsing_enums_simple \ + doxygen_parsing_enums_proper \ + doxygen_parsing_enums_typesafe \ + doxygen_parsing_enums_typeunsafe \ enum_thorough_proper \ enum_thorough_simple \ enum_thorough_typeunsafe \ diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java new file mode 100644 index 000000000..503e2c68e --- /dev/null +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_proper.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_proper_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_proper"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test", + "doxygen_parsing_enums_proper_runme", new String[]{"-quiet", "doxygen_parsing_enums_proper"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java new file mode 100644 index 000000000..ca640b3f0 --- /dev/null +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_simple.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_simple_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_simple"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test", + "doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java new file mode 100644 index 000000000..8d87c82d0 --- /dev/null +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_typesafe.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_typesafe_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_typesafe"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test", + "doxygen_parsing_enums_typesafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java new file mode 100644 index 000000000..a01007db1 --- /dev/null +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_typeunsafe.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_typeunsafe_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_typeunsafe"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test", + "doxygen_parsing_enums_typeunsafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index c4264d003..fe4b75fa5 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -33,6 +33,19 @@ public class doxygen_parsing_runme { parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } for (int j = 0; j < methods.length; j++) { MethodDoc m = methods[j]; if (m.getRawCommentText().length() > 0) @@ -84,6 +97,11 @@ public class doxygen_parsing_runme { } } + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + System.exit(errorCount); } } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 8cca8b3a5..23f8c6d3e 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -13,7 +13,7 @@ #include "DoxygenParser.h" #include #define APPROX_LINE_LENGTH 64 //characters per line allowed -#define TAB_SIZE 8 //characters per line allowed +#define TAB_SIZE 8 //current tab size in spaces int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index bfde4f19a..8455fbbf6 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -49,7 +49,7 @@ class JAVA:public Language { bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool member_func_flag; // flag set when wrapping a member function - bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc + bool doxygen; //flag for converting found doxygen to javadoc bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx String *imclass_name; // intermediary class name @@ -123,7 +123,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), - doxygen_javadoc_flag(true), + doxygen(true), comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), @@ -255,6 +255,14 @@ public: Printf(stderr, "Deprecated command line option: %s. Proxy classes are now generated by default.\n", argv[i]); Swig_mark_arg(i); proxy_flag = true; + } else if ((strcmp(argv[i], "-doxygen") == 0)) { + Swig_mark_arg(i); + doxygen = true; + scan_doxygen_comments = true; + } else if ((strcmp(argv[i], "-nodoxygen") == 0)) { + Swig_mark_arg(i); + doxygen = false; + scan_doxygen_comments = false; } else if ((strcmp(argv[i], "-noproxy") == 0)) { Swig_mark_arg(i); proxy_flag = false; @@ -528,7 +536,7 @@ public: // Start writing out the module class file emitBanner(f_module); //Add any structural comments to the top - if(doxygen_javadoc_flag && structuralComments){ + if(doxygen && structuralComments){ Printf(f_module, "%s", structuralComments); } if (package) @@ -537,7 +545,7 @@ public: if (module_imports) Printf(f_module, "%s\n", module_imports); - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ if(comment_creation_chatter) @@ -1292,17 +1300,6 @@ public: // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); - - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ - if(comment_creation_chatter) - Printf(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(proxy_class_constants_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } - } Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { @@ -1418,30 +1415,29 @@ public: } if (!addSymbol(name, n, scope)) return SWIG_ERROR; + + //translate and write javadoc comment if flagged + if (doxygen){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(enum_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } + } if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. - if (!GetFlag(n, "firstenumitem")) - Printf(enum_code, ",\n"); - - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ - if(comment_creation_chatter) - Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(enum_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } - } - + Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, "(%s)", value); Delete(value); } + Printf(enum_code, ",\n"); } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); @@ -1493,7 +1489,7 @@ public: * file * ------------------------------------------------------------------------ */ virtual int doxygenComment(Node *n){ - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -1527,7 +1523,7 @@ public: Swig_save("constantWrapper", n, "value", NIL); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -1825,7 +1821,7 @@ public: const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2231,7 +2227,7 @@ public: } //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2464,7 +2460,7 @@ public: Printf(im_return_type, "%s", tm); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2736,7 +2732,7 @@ public: String *post_code = NewString(""); // translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)) { if(comment_creation_chatter) @@ -4523,6 +4519,8 @@ extern "C" Language *swig_java(void) { const char *JAVA::usage = (char *) "\ Java Options (available with -java)\n\ + -doxygen - Convert C++ doxygen comments to JavaDoc comments in proxy classes (default)\n\ + -nodoxygen - Don't convert C++ doxygen comments to JavaDoc comments in proxy classes\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ -noproxy - Generate the low-level functional interface instead\n\ of proxy classes\n\ From 4141c9fd8712797401da42be00ad8e7c5bf498c0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 18 Jun 2012 19:31:35 +0000 Subject: [PATCH 0052/2031] Added doxygen switches doc git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13185 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Doxygen.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 989fb0dc4..d0e837756 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -114,7 +114,16 @@ Just remember, if SWIG shows syntax error parsing the file because of your comme

    -NOT YET ADDED (current development branch has this feature automatically enabled). +There are switches like '-doxygen' and '-nodoxygen' in every module that supports converting +documentation comments. The first one is default, so that swig by default produces correct +proxy files with comments. Some comments in some target languages can be manually overriden by specific +swig's features, like feature:docstring or feature:autodoc, in this cases doxygen comments +have lowest priority. +

    +

    +Switching off may be needed if swig cannot correctly parse your comments, for example showing Error: +Syntax error in input(1). message. Then it will just strip out every comment out of the code and +continue happily.

    35.2.2 Additional Commandline Options

    From 4289b8e27374bdab773a90b5ab9792f7e659ce45 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 25 Jun 2012 15:47:36 +0000 Subject: [PATCH 0053/2031] Refactored comment translator class, implemented result caching git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13191 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../src/DoxygenTranslator.cpp | 45 ++++-- .../DoxygenTranslator/src/DoxygenTranslator.h | 42 ++++-- .../src/JavaDocConverter.cpp | 11 +- .../DoxygenTranslator/src/JavaDocConverter.h | 2 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 23 ++-- Source/DoxygenTranslator/src/PyDocConverter.h | 2 +- Source/Modules/java.cxx | 128 +++++++++--------- Source/Modules/lang.cxx | 5 +- Source/Modules/python.cxx | 10 +- Source/Modules/swigmod.h | 3 + 10 files changed, 159 insertions(+), 112 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 36ca95579..a733fdbc7 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -13,18 +13,41 @@ * ----------------------------------------------------------------------------- */ #include "DoxygenTranslator.h" -#include "JavaDocConverter.h" -#include "PyDocConverter.h" -bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) { - switch (format) { - case JavaDoc: - return JavaDocConverter().getDocumentation(node, documentation); - case PyDoc: - return PyDocConverter().getDocumentation(node, documentation); - default: - return false; - } +DoxygenTranslator::DoxygenTranslator() { + // Init the cache + resultsCache = NewHash(); +} +DoxygenTranslator::~DoxygenTranslator() { + // Clean up the cache + Delete(resultsCache); +} + +bool DoxygenTranslator::hasDocumentation(Node *node) { + return getDoxygenComment(node); +} + +String *DoxygenTranslator::getDoxygenComment(Node *node) { + return Getattr(node, "DoxygenComment"); +} + + +String *DoxygenTranslator::getDocumentation(Node *node) { + + if (!hasDocumentation(node)) + return 0; + + // get from cache + String *resultedDocs = Getattr(resultsCache, getDoxygenComment(node)); + + if (resultedDocs) + return resultedDocs; + + // not found in cache, produce it + resultedDocs = makeDocumentation(node); + Setattr(resultsCache, getDoxygenComment(node), resultedDocs); + + return resultedDocs; } void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) { diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 1a14a4db2..023bdac89 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -17,16 +17,9 @@ #include "swig.h" #include "DoxygenEntity.h" +#include "DoxygenParser.h" #include -/* - * Describes the availible documentation systems - * that can be translated to. - */ -enum DocumentationFormat { - JavaDoc = 1, - PyDoc = 2 -}; /* * A class to translate doxygen comments attacted to parser nodes @@ -34,20 +27,31 @@ enum DocumentationFormat { */ class DoxygenTranslator { public: + /* + * Constructor + */ + DoxygenTranslator(); /* * Virtual destructor. */ - virtual ~ DoxygenTranslator() { - } + virtual ~ DoxygenTranslator(); /* * Return the documentation for a given node formated for the correct - * documentation system. + * documentation system. The result is cached and translated only once. * @param node The node to extract and translate documentation for. * @param format The documentation format to output. * @param documentation The returned documentation string. * @return A bool to indicate if there was documentation to return for the node. */ - static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation); + String *getDocumentation(Node *node); + /* + * Whether the specified node has comment or not + */ + bool hasDocumentation(Node *node); + /* + * Get original, Doxygen-format comment string + */ + String *getDoxygenComment(Node *node); protected: /* @@ -57,12 +61,22 @@ protected: * @param documentation The returned documentation string. * @return A bool to indicate if there was documentation to return for the node. */ - virtual bool getDocumentation(Node *node, String *&documentation) = 0; - + virtual String *makeDocumentation(Node *node) = 0; + /* * Prints the details of a parsed entity list to stdout (for debugging). */ void printTree(std::list < DoxygenEntity > &entityList); + + /* + * Doxygen parser object + */ + DoxygenParser parser; + + /* + * Cache of translated comments + */ + Hash *resultsCache; }; #endif diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 23f8c6d3e..812a6c34d 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -150,12 +150,12 @@ std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) { } -bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) { +String *JavaDocConverter::makeDocumentation(Node *node) { - documentation = Getattr(node, "DoxygenComment"); + String *documentation = getDoxygenComment(node); if (documentation == NULL) { - return false; + return NULL; } std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); @@ -181,7 +181,6 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) { std::cout << "\n---RESULT IN JAVADOC---" << std::endl; std::cout << javaDocString; } - - documentation = NewString(javaDocString.c_str()); - return true; + + return NewString(javaDocString.c_str()); } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 69fc8d75d..1d54e2514 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -23,7 +23,7 @@ class JavaDocConverter : public DoxygenTranslator { public: JavaDocConverter() : debug(false) { } - virtual bool getDocumentation(Node *node, String *&documentation); + String *makeDocumentation(Node *node); protected: std::string formatCommand(std::string unformattedLine, int indent); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 55c3ba61b..b1e94a062 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -19,7 +19,7 @@ //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag PyDocConverter::PyDocConverter() { - debug = 1; + debug = 0; } std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { @@ -40,6 +40,8 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); for (p = plist; p;) { + + //Swig_print(p, 1); if (Char(Getattr(p, "name")) == paramNameEntity.data) { std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); @@ -52,7 +54,12 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); break; } - p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); + /* + * doesn't seem to work always: in some cases (especially for 'self' parameters) + * tmap:in is present, but tmap:in:next is not and so this code skips all the parameters + */ + //p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); + p = nextSibling(p); } Delete(plist); @@ -147,7 +154,8 @@ std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity return result; } -bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { +String *PyDocConverter::makeDocumentation(Node *n) { + String *documentation; std::string pyDocString, result; // for overloaded functions we must concat documentation for underlying overloads @@ -160,7 +168,7 @@ bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { // for each real method (not a generated overload) append the documentation while (n) { - documentation = Getattr(n, "DoxygenComment"); + documentation = getDoxygenComment(n); if (!Swig_is_generated_overload(n) && documentation) { std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); allDocumentation.push_back(processEntityList(n, entityList)); @@ -184,7 +192,7 @@ bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { } // for other nodes just process as normal else { - documentation = Getattr(n, "DoxygenComment"); + documentation = getDoxygenComment(n); if (documentation != NULL) { std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); pyDocString = processEntityList(n, entityList); @@ -201,11 +209,10 @@ bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { std::cout << std::endl; } - documentation = NewString(result.c_str()); - return true; + return NewString(result.c_str()); } - return false; + return 0; } std::string PyDocConverter::generateDivider() { diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index ecd033af5..2d910c8f9 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -26,7 +26,7 @@ class PyDocConverter : public DoxygenTranslator { public: PyDocConverter(); - bool getDocumentation(Node *node, String *&documentation); + String *makeDocumentation(Node *node); protected: diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 8455fbbf6..2c6e1b08c 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -17,7 +17,7 @@ char cvsroot_java_cxx[] = "$Id$"; #include // for INT_MAX #include "cparse.h" #include -#include "../DoxygenTranslator/src/DoxygenTranslator.h" +#include "../DoxygenTranslator/src/JavaDocConverter.h" /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; @@ -158,11 +158,19 @@ public: dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), - n_directors(0) { + n_directors(0){ /* for now, multiple inheritance in directors is disabled, this should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; + + if (doxygen) + doxygenTranslator = new JavaDocConverter(); + } + + ~JAVA() { + if (doxygen) + delete doxygenTranslator; } /* ----------------------------------------------------------------------------- @@ -286,6 +294,9 @@ public: } } } + + if (doxygen) + doxygenTranslator = new JavaDocConverter(); // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGJAVA 1", 0); @@ -545,14 +556,12 @@ public: if (module_imports) Printf(f_module, "%s\n", module_imports); - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ - if(comment_creation_chatter) - Printf(f_module, "/* This was generated from top() */"); - Printf(f_module, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(f_module, "/* This was generated from top() */"); + Printf(f_module, Char(doxygen_comments)); + Delete(doxygen_comments); } if (Len(module_class_modifiers) > 0) Printf(f_module, "%s ", module_class_modifiers); @@ -1417,14 +1426,12 @@ public: return SWIG_ERROR; //translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(enum_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(enum_code, Char(doxygen_comments)); + Delete(doxygen_comments); } if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { @@ -1489,14 +1496,12 @@ public: * file * ------------------------------------------------------------------------ */ virtual int doxygenComment(Node *n){ - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(structuralComments, "/* This was generated from doxygenComment() */"); - Printf(structuralComments, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(structuralComments, "/* This was generated from doxygenComment() */"); + Printf(structuralComments, Char(doxygen_comments)); + Delete(doxygen_comments); } return SWIG_OK; } @@ -1523,14 +1528,12 @@ public: Swig_save("constantWrapper", n, "value", NIL); //translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(constants_code, "/* This was generated from constantWrapper() */"); - Printf(constants_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(constants_code, "/* This was generated from constantWrapper() */"); + Printf(constants_code, Char(doxygen_comments)); + Delete(doxygen_comments); } bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); @@ -1821,14 +1824,12 @@ public: const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); //translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */"); - Printf(proxy_class_def, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */"); + Printf(proxy_class_def, Char(doxygen_comments)); + Delete(doxygen_comments); } // Start writing the proxy class @@ -2227,14 +2228,12 @@ public: } //translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */"); - Printf(function_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */"); + Printf(function_code, Char(doxygen_comments)); + Delete(doxygen_comments); } /* Start generating the proxy function */ @@ -2460,14 +2459,12 @@ public: Printf(im_return_type, "%s", tm); //translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ - if(comment_creation_chatter) - Printf(function_code, "/* This was generated from constructionhandler() */"); - Printf(function_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from constructionhandler() */"); + Printf(function_code, Char(doxygen_comments)); + Delete(doxygen_comments); } Printf(function_code, " %s %s(", methodmods, proxy_class_name); @@ -2732,14 +2729,12 @@ public: String *post_code = NewString(""); // translate and write javadoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)) { - if(comment_creation_chatter) - Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */"); - Printv(function_code, doxygen_comments, NIL); - Delete(doxygen_comments); - } + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */"); + Printv(function_code, doxygen_comments, NIL); + Delete(doxygen_comments); } if (l) { @@ -4527,3 +4522,4 @@ Java Options (available with -java)\n\ -oldvarnames - Old intermediary method names for variable wrappers\n\ -package - Set name of the Java package to \n\ \n"; + diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index d89ef3e40..9e10e0f0b 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2869,9 +2869,10 @@ int Language::usingDeclaration(Node *n) { * ---------------------------------------------------------------------- */ int Language::doxygenComment(Node *n){ - String *comment = Getattr(n, "comment"); + String *comment = Getattr(n, "comment"); + Printf(stdout, "doxygenComment : %s\n", comment); - return SWIG_OK; + return SWIG_OK; } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 07437715d..40a50d45e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -20,7 +20,7 @@ static int treduce = SWIG_cparse_template_reduce(0); #include #include -#include "../DoxygenTranslator/src/DoxygenTranslator.h" +#include "../DoxygenTranslator/src/PyDocConverter.h" #include "../../../swig/bug.h" #define PYSHADOW_MEMBER 0x2 @@ -548,6 +548,9 @@ public: if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } + + if (doxygen) + doxygenTranslator = new PyDocConverter; if (!global_name) global_name = NewString("cvar"); @@ -1203,7 +1206,7 @@ public: String *str = Getattr(n, "feature:docstring"); return ((str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) - || (doxygen && Getattr(n, "DoxygenComment")) + || (doxygen && doxygenTranslator->hasDocumentation(n)) ); } @@ -1219,7 +1222,7 @@ public: String *doxygen_comment = 0; bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); - bool have_doxygen = doxygen && DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comment); + bool have_doxygen = doxygen && doxygenTranslator->hasDocumentation(n); const char *triple_double = use_triple ? "\"\"\"" : ""; String *autodoc = NULL; String *doc = NULL; @@ -1237,6 +1240,7 @@ public: have_auto = (autodoc && Len(autodoc) > 0); } if (have_doxygen) { + doxygen_comment = doxygenTranslator->getDocumentation(n); have_doxygen = (doxygen_comment && Len(doxygen_comment) > 0); } // If there is more than one line then make docstrings like this: diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 897aaa9ef..0acbc1fe7 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -17,6 +17,7 @@ #include "swig.h" #include "preprocessor.h" #include "swigwarn.h" +#include "../DoxygenTranslator/src/DoxygenTranslator.h" #if !defined(HAVE_BOOL) typedef int bool; @@ -315,6 +316,8 @@ protected: /* Director language module */ int director_language; + // Class instance to translate comments + DoxygenTranslator *doxygenTranslator; private: Hash *symtabs; /* symbol tables */ Hash *classtypes; From 304e232dbcf576c160edefb29abea66e28bc9a10 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 29 Jun 2012 19:28:21 +0000 Subject: [PATCH 0054/2031] Fixed enum comments generation in java git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13209 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygen_parsing_enums_simple_runme.java | 1 - Source/Modules/java.cxx | 21 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index ca640b3f0..ee422e2c4 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -64,7 +64,6 @@ public class doxygen_parsing_enums_simple_runme { com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test", "doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"}); - wantedComments.put("E_TEST", " Test enumeration \n"); wantedComments.put("E_TEST_ONE", " the first item \n"); wantedComments.put("E_TEST_TWO", " the second \n"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 2c6e1b08c..71de5380c 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1279,8 +1279,12 @@ public: Replaceall(enum_code, "$static ", ""); Delete(scope); } else { - // Wrap C++ enum with integers - just indicate start of enum with a comment, no comment for anonymous enums of any sort - if (symname && !Getattr(n, "unnamedinstance")) + //translate and write javadoc comment for the enum itself if flagged + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + Printf(stdout, "Warning: Not emitting comment for %s, not supported in simple enums mode.\n", + Getattr(n, "unnamedinstance") ? "unnamed enum" : symname); + } + else if (symname && !Getattr(n, "unnamedinstance")) Printf(constants_code, " // %s \n", symname); } @@ -1337,7 +1341,18 @@ public: } Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements - "\n", enum_code, "\n", NIL); + "\n\n", NIL); + + //translate and write javadoc comment if flagged + if (doxygen && doxygenTranslator->hasDocumentation(n)){ + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(f_enum, "/* This was generated from enumDeclaration() */"); + Printf(f_enum, Char(doxygen_comments)); + Delete(doxygen_comments); + } + + Printv(f_enum, enum_code, "\n", NIL); Printf(f_enum, "\n"); Close(f_enum); From 774cbc3ef216d9428620c0076dd569af61107da3 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 29 Jun 2012 19:37:42 +0000 Subject: [PATCH 0055/2031] Fixed comments parsing, but broken li_boost_shared_ptr_bits test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13210 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_parsing.i | 6 +- .../java/doxygen_parsing_runme.java | 6 +- .../python/doxygen_parsing_runme.py | 1 + Source/CParse/parser.y | 328 +++++++----------- 4 files changed, 138 insertions(+), 203 deletions(-) diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index b61317bcd..a83cd77ed 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -16,6 +16,9 @@ int simpleVarThree=42; //! This is the last type of comment for a var int simpleVarFour=42; +int simpleVarFive=42; +///< This is a post comment + /* We assume that all this comment types are ok, and later we only use the first-type comments. @@ -49,7 +52,8 @@ public: * Simple method with parameter */ void simpleMethodWithParameter( - int param /**< Some test param */ + int param, /**< Some test param */ + int argument /**< Some test argument */ ) { } diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index fe4b75fa5..909de9312 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -68,7 +68,9 @@ public class doxygen_parsing_runme { wantedComments.put("CSimpleClass", " This is simple comment for a class \n"); wantedComments.put("simpleMethod", " Simple method \n"); - wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n @param\tparam Some test param \n"); + wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n" + + " @param\tparam Some test param \n" + + " @param\targument Some test argument \n"); wantedComments.put("CTemplateClassInt", " Comment for template class \n"); wantedComments.put("templateMethod", " Template method \n"); @@ -80,6 +82,8 @@ public class doxygen_parsing_runme { wantedComments.put("getSimpleVarThree", " This is again another type of comment for a var \n"); wantedComments.put("setSimpleVarFour", " This is the last type of comment for a var \n"); wantedComments.put("getSimpleVarFour", " This is the last type of comment for a var \n"); + wantedComments.put("setSimpleVarFive", " This is a post comment \n"); + wantedComments.put("getSimpleVarFive", " This is a post comment \n"); int errorCount=0; diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index eef840818..097c18f8c 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -14,6 +14,7 @@ check(doxygen_parsing.CSimpleClass.simpleMethod.__doc__, '\s+Simple method\s+') check(doxygen_parsing.CSimpleClass.simpleMethodWithParameter.__doc__, '' '\s+Simple method with parameter' '\s+Arguments:\s+param \(int\)\s+-- Some test param\s+' +'argument \(int\)\s+-- Some test argument\s+' ) check(doxygen_parsing.CTemplateClassInt.__doc__, '\s+Comment for template class\s+') check(doxygen_parsing.CTemplateClassInt.templateMethod.__doc__, '\s+Template method\s+') \ No newline at end of file diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ffba04884..70f420411 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -24,6 +24,7 @@ char cvsroot_parser_y[] = "$Id$"; #include "preprocessor.h" #include + /* We do this for portability */ #undef alloca #define alloca malloc @@ -67,6 +68,7 @@ String *currentComment; /* Location of the stored Doxygen Comment */ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ +static Node *currentNode = NULL; /* Pointer to the current node (for post comments) */ int isStructuralDoxygen(String *s){ char *slashPointer = Strchr(s, '\\'); @@ -106,27 +108,9 @@ static Node *new_node(const_String_or_char_ptr tag) { set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - if(scan_doxygen_comments){ - /* Sets any post comments to the previous node */ - if(previousNode != NULL && currentPostComment != 0){ - String *copyPostComment = Copy(currentPostComment); - if (!Getattr(previousNode, "DoxygenComment")){ - Setattr(previousNode,"DoxygenComment",copyPostComment);} - else { - Append(copyPostComment, Getattr(previousNode, "DoxygenComment")); - Setattr(previousNode,"DoxygenComment",copyPostComment); - } - - currentPostComment = 0; - } - /* Sets Doxygen Comment if a Comment is Availible */ - if(currentComment != 0){ - String *copyComment = Copy(currentComment); - Setattr(n,"DoxygenComment",copyComment); - currentComment = 0; - } - previousNode = n; - } + /* Remember the previous node in case it will need a post-comment */ + previousNode = currentNode; + currentNode = n; return n; } @@ -205,6 +189,25 @@ static Node *copy_node(Node *n) { return nn; } +static void set_comment(Node *n, String *comment) { + Parm *p; + if (!n || !comment) + return; + + if (Getattr(n, "DoxygenComment")) + Append(Getattr(n, "DoxygenComment"), comment); + else { + Setattr(n, "DoxygenComment", comment); + /* This is the first comment, populate it with @params, if any */ + p = Getattr(n, "parms"); + while (p) { + if (Getattr(p, "DoxygenComment")) + Printv(comment, "\n@param ", Getattr(p, "name"), Getattr(p, "DoxygenComment"), NIL); + p=nextSibling(p); + } + } +} + /* ----------------------------------------------------------------------------- * Variables * ----------------------------------------------------------------------------- */ @@ -1496,6 +1499,7 @@ static void default_arguments(Node *n) { Node *function = n; if (function) { + ParmList *varargs = Getattr(function,"feature:varargs"); if (varargs) { /* Handles the %varargs directive by looking for "feature:varargs" and @@ -1793,6 +1797,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type fname stringtype; %type featattr; %type doxygen_comment; +%type doxygen_comment_item; %type c_style_comment; %type doxygen_post_comment; %type doxygen_post_comment_item; @@ -1852,9 +1857,7 @@ interface : interface declaration { declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } - | doxygen_comment { $$ = $1; } | c_style_comment { $$ = $1; } - | doxygen_post_comment { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; @@ -1878,6 +1881,14 @@ declaration : swig_directive { $$ = $1; } */ + | doxygen_comment declaration { + $$ = $2; + set_comment($2, $1); + } + | declaration doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } | error COPERATOR { $$ = 0; skip_decl(); @@ -3442,67 +3453,65 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { A Doxygen Comment (a string in Doxygen Format) ------------------------------------------------------------ */ -doxygen_comment : DOXYGENSTRING - { - /* while(Strchr($1,'/') == Char($1)) - Replace($1,"/","",DOH_REPLACE_FIRST); */ - DohReplace($1, "/**", "", 0); - DohReplace($1, "/*!", "", 0); - DohReplace($1, "///", "", 0); - DohReplace($1, "*/", "", 0); +doxygen_comment_item : DOXYGENSTRING { + DohReplace($1, "/**", "", 0); + DohReplace($1, "/*!", "", 0); + DohReplace($1, "///", "", 0); + DohReplace($1, "//!", "", 0); + DohReplace($1, "*/", "", 0); - /* isStructuralDoxygen() is disabled, since no comment - appears in such case. Need to fix. (most commands are - not translatable to javadoc anyway) */ - if(0 && isStructuralDoxygen($1)){ - $$ = new_node("doxycomm"); - Setattr($$,"DoxygenComment",$1); - } - else { - if(currentComment != 0){ - Append(currentComment,$1); - } - else - currentComment = $1; - $$ = 0; - } - } - ; - - -doxygen_post_comment_item : DOXYGENPOSTSTRING - { - DohReplace($1, "///<", "", 0); - DohReplace($1, "/**<", "", 0); - DohReplace($1, "/*!<", "", 0); - DohReplace($1, "//!<", "", 0); - DohReplace($1, "*/", "", 0); - - $$ = $1; - } - ; - -doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item - { - Append($1, $2); - $$ = $1; - } - | doxygen_post_comment_item - { - $$ = $1; - } - ; - -c_style_comment : C_COMMENT_STRING - { - if(currentCComment != 0){ - Append(currentCComment, $1); + /* isStructuralDoxygen() is disabled, since no comment + appears in such case. Need to fix. (most commands are + not translatable to javadoc anyway) */ + if(0 && isStructuralDoxygen($1)){ + $$ = new_node("doxycomm"); + Setattr($$,"DoxygenComment",$1); + } + else { + $$ = $1; } - else currentCComment = $1; - $$ = 0; - } - ; + } + ; + +doxygen_comment : doxygen_comment doxygen_comment_item { + Append($1, $2); + $$ = $1; + } + | doxygen_comment_item { + $$ = $1; + } + ; + + +doxygen_post_comment_item : DOXYGENPOSTSTRING { + DohReplace($1, "///<", "", 0); + DohReplace($1, "/**<", "", 0); + DohReplace($1, "/*!<", "", 0); + DohReplace($1, "//!<", "", 0); + DohReplace($1, "*/", "", 0); + + $$ = $1; + } + ; + +doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item { + Append($1, $2); + $$ = $1; + } + | doxygen_post_comment_item { + $$ = $1; + } + ; + +c_style_comment : C_COMMENT_STRING { + if(currentCComment != 0){ + Append(currentCComment, $1); + } + else currentCComment = $1; + $$ = 0; + } + ; /* ====================================================================== * C++ Support @@ -4480,9 +4489,7 @@ cpp_member : c_declaration { $$ = $1; } | storage_class idcolon SEMI { $$ = 0; } | cpp_using_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } - | doxygen_comment{ $$ = $1; } | c_style_comment{ $$ = $1; } - | doxygen_post_comment{ $$ = $1; } | cpp_catch_decl { $$ = 0; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } @@ -4490,6 +4497,14 @@ cpp_member : c_declaration { $$ = $1; } | fragment_directive {$$ = $1; } | types_directive {$$ = $1; } | SEMI { $$ = 0; } + | doxygen_comment cpp_member { + $$ = $2; + set_comment($2, $1); + } + | cpp_member doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } ; /* Possibly a constructor */ @@ -4890,41 +4905,18 @@ rawparms : parm ptail { set_nextSibling($1,$2); $$ = $1; } - | empty { $$ = 0; } + | empty { $$ = 0; previousNode = currentNode; currentNode=0; } ; ptail : COMMA parm ptail { set_nextSibling($2,$3); $$ = $2; - } - | COMMA doxygen_post_comment parm ptail { - set_nextSibling($3,$4); + } + | COMMA doxygen_post_comment parm ptail { + set_comment(previousNode, $2); + set_nextSibling($3,$4); $$ = $3; - - /** because function parameters are not nodes, - it must be the current function node, which - gets doxy comment set. - */ - - Setattr($3, "postComment", $2); - /* - currentPostComment = $2; - if (previousParmName != 0) { - String *param = NewString("\n@param "); - if (currentComment != 0) { - Append(currentComment, param); - Append(currentComment, previousParmName ); - Append(currentComment, currentPostComment); - } - else { - currentComment = param; - Append(currentComment, Getattr($3, "name") ); - Append(currentComment, currentPostComment); - } - } - currentPostComment = 0; - */ - } + } | empty { $$ = 0; } ; @@ -4932,45 +4924,18 @@ ptail : COMMA parm ptail { parm : rawtype parameter_declarator { SwigType_push($1,$2.type); $$ = NewParmWithoutFileLineInfo($1,$2.id); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); if ($2.defarg) { Setattr($$,"value",$2.defarg); } } - | rawtype parameter_declarator doxygen_post_comment { - /** handles the last function parameter, which is not followed by comma */ - /* - String *param = NewString("@param "); - String *name = NewString($2.id); - - if (currentComment != 0) { - Append(currentComment, param); - } - else { - currentComment = param; - } - - Append(currentComment, name); - Append(currentComment, $3); - - if (currentPostComment != 0) { - } - currentPostComment = 0; - */ - - SwigType_push($1,$2.type); - $$ = NewParmWithoutFileLineInfo($1,$2.id); - Setattr($$, "lastParamPostComment", $3); - Setfile($$,cparse_file); - Setline($$,cparse_line); - if ($2.defarg) { - Setattr($$,"value",$2.defarg); - } - } - | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args { $$ = NewParmWithoutFileLineInfo(NewStringf("template %s %s", $5,$6), 0); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); if ($7.val) { @@ -4980,9 +4945,19 @@ parm : rawtype parameter_declarator { | PERIOD PERIOD PERIOD { SwigType *t = NewString("v(...)"); $$ = NewParmWithoutFileLineInfo(t, 0); + previousNode = currentNode; + currentNode = $$; Setfile($$,cparse_file); Setline($$,cparse_line); } + | doxygen_comment parm { + $$ = $2; + set_comment($2, $1); + } + | parm doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } ; valparms : rawvalparms { @@ -5848,66 +5823,15 @@ edecl : ID { Setattr($$,"value",$1); Delete(type); } - - | doxygen_comment ID EQUAL etype { - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"enumvalue", $4.val); - if ($4.type == T_CHAR) { - SwigType *type = NewSwigType(T_CHAR); - Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); - Setattr($$,"type",type); - Delete(type); - } else { - SwigType *type = NewSwigType(T_INT); - Setattr($$,"value",$2); - Setattr($$,"type",type); - Delete(type); - } - SetFlag($$,"feature:immutable"); - } - - | doxygen_post_comment ID EQUAL etype { - currentPostComment = $1; - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"enumvalue", $4.val); - if ($4.type == T_CHAR) { - SwigType *type = NewSwigType(T_CHAR); - Setattr($$,"value",NewStringf("\'%(escape)s\'", $4.val)); - Setattr($$,"type",type); - Delete(type); - } else { - SwigType *type = NewSwigType(T_INT); - Setattr($$,"value",$2); - Setattr($$,"type",type); - Delete(type); - } - SetFlag($$,"feature:immutable"); - } - - | doxygen_comment ID { - SwigType *type = NewSwigType(T_INT); - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"type",type); - SetFlag($$,"feature:immutable"); - Delete(type); + | doxygen_comment edecl { + $$ = $2; + set_comment($2, $1); } - | doxygen_post_comment ID { - SwigType *type = NewSwigType(T_INT); - currentPostComment = $1; - $$ = new_node("enumitem"); - Setattr($$,"name",$2); - Setattr($$,"type",type); - SetFlag($$,"feature:immutable"); - Delete(type); + | doxygen_post_comment edecl { + $$ = $2; + set_comment(previousNode, $1); } - | doxygen_post_comment { - currentPostComment = $1; - $$ = $1; - } - | empty { $$ = 0; } + | empty { $$ = 0; previousNode = currentNode; currentNode = 0; } ; etype : expr { @@ -6557,3 +6481,5 @@ ParmList *Swig_cparse_parms(String *s, Node *file_line_node) { } + +struct S; From 46feb36cfb0f523161f02158c6727cce1a9861b3 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 1 Jul 2012 18:42:43 +0000 Subject: [PATCH 0056/2031] Another fix for enums_simple case, now emitting comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13216 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 71de5380c..49a5e9901 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1281,8 +1281,14 @@ public: } else { //translate and write javadoc comment for the enum itself if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)){ - Printf(stdout, "Warning: Not emitting comment for %s, not supported in simple enums mode.\n", - Getattr(n, "unnamedinstance") ? "unnamed enum" : symname); + String *doxygen_comments=doxygenTranslator->getDocumentation(n); + if(comment_creation_chatter) + Printf(constants_code, "/* This was generated from enumDeclaration() */"); + Printf(constants_code, "/* Comment for enum %s */\n", + Getattr(n, "unnamedinstance") ? "" : symname); + Printf(constants_code, Char(doxygen_comments)); + Printf(constants_code, "\n"); + Delete(doxygen_comments); } else if (symname && !Getattr(n, "unnamedinstance")) Printf(constants_code, " // %s \n", symname); From 4c215eb33756199f8505bb9d7a6bbd471d70444e Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 2 Jul 2012 20:29:49 +0000 Subject: [PATCH 0057/2031] Refactored most of comments translating code for java, preliminary version, lots of bugs right now git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13217 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/doxygen_basic_translate.i | 16 ++ .../java/doxygen_basic_translate_runme.java | 94 +++++++++ .../src/JavaDocConverter.cpp | 194 ++++++++++-------- .../DoxygenTranslator/src/JavaDocConverter.h | 37 +++- 5 files changed, 249 insertions(+), 93 deletions(-) create mode 100644 Examples/test-suite/doxygen_basic_translate.i create mode 100644 Examples/test-suite/java/doxygen_basic_translate_runme.java diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index ec47ffaa0..ed2d74cd9 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -188,6 +188,7 @@ CPP_TEST_CASES += \ director_wombat \ disown \ doxygen_parsing \ + doxygen_basic_translate \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i new file mode 100644 index 000000000..c961164d5 --- /dev/null +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -0,0 +1,16 @@ +%module doxygen_basic_translate + +%inline %{ + +/** + * \brief Brief description. + * The comment text + * \author Some author + * \return Some number + * \sa function2 + */ +int function() +{ +} + +%} \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java new file mode 100644 index 000000000..7aee4221b --- /dev/null +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -0,0 +1,94 @@ + +import doxygen_basic_translate.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_basic_translate_runme { + static { + try { + System.loadLibrary("doxygen_basic_translate"); + } 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); + } + } + + static HashMap parsedComments = new HashMap(); + static HashMap wantedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test", + "doxygen_basic_translate_runme", new String[]{"-quiet", "doxygen_basic_translate"}); + + wantedComments.put("function", " Brief description. \n The comment text \n" + + " @author\tSome author \n" + + " @return\tSome number \n" + + " @see\tfunction2 \n"); + + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 812a6c34d..0c332c3b9 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -14,9 +14,64 @@ #include #define APPROX_LINE_LENGTH 64 //characters per line allowed #define TAB_SIZE 8 //current tab size in spaces -int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag +// define static escape table, it is filled in JavaDocConverter's constructor +std::map JavaDocConverter::escapeTable; + +void JavaDocConverter::fillEscapeTable() { + if (escapeTable.size()) // fill only once + return; + + escapeTable["&"] = "&"; + escapeTable["\'"] = "&apos"; + escapeTable["\""] = """; + escapeTable["<"] = "<"; + escapeTable[">"] = ">"; +} + + +JavaDocConverter::JavaDocConverter() : debug(false) { + + fillEscapeTable(); + + // these commands insert HTML tags + tagHandlers["c"] = &handleTagC; + tagHandlers["b"] = &handleTagB; + // these commands insert just a single char, all of them need to be escaped + tagHandlers["$"] = &handleTagChar; + tagHandlers["@"] = &handleTagChar; + tagHandlers["\\"] = &handleTagChar; + tagHandlers["<"] = &handleTagChar; + tagHandlers[">"] = &handleTagChar; + tagHandlers["&"] = &handleTagChar; + tagHandlers["#"] = &handleTagChar; + tagHandlers["%"] = &handleTagChar; + tagHandlers["~"] = &handleTagChar; + tagHandlers["\""] = &handleTagChar; + tagHandlers["."] = &handleTagChar; + tagHandlers["::"] = &handleTagChar; + // these commands are stripped out + tagHandlers["brief"] = &handleTagStrip; + tagHandlers["details"] = &handleTagStrip; + tagHandlers["partofdescription"] = &handleTagStrip; + // these commands are kept as-is, they are supported by JavaDoc + tagHandlers["sa"] = &handleTagSeeAll; + tagHandlers["see"] = &handleTagSame; + tagHandlers["param"] = &handleTagSame; + tagHandlers["return"] = &handleTagSame; + tagHandlers["throws"] = &handleTagSame; + tagHandlers["throw"] = &handleTagThrow; + tagHandlers["author"] = &handleTagSame; + tagHandlers["since"] = &handleTagSame; + tagHandlers["version"] = &handleTagSame; + tagHandlers["exception"] = &handleTagSame; + tagHandlers["deprecated"] = &handleTagSame; + // this command just prints it's contents + // (it is internal command of swig's parser, contains plain text) + tagHandlers["plainstd::string"] = &handleTagData; +} + std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { std::string formattedLines = "\n * "; int lastPosition = 0; @@ -56,99 +111,58 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind return formattedLines; } -/* Contains the conversions for tags - * could probably be much more efficient... - */ -std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) { - if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) { - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0) { - return doxygenEntity.data; - } else if (doxygenEntity.typeOfEntity.compare("b") == 0) { - return "" + doxygenEntity.data + ""; - } else if (doxygenEntity.typeOfEntity.compare("c") == 0) { - return "" + doxygenEntity.data + ""; - } else if (doxygenEntity.typeOfEntity.compare("@") == 0) { - return "@"; - } else if (doxygenEntity.typeOfEntity.compare("\\") == 0) { - return "\\"; - } else if (doxygenEntity.typeOfEntity.compare("<") == 0) { - return "<"; - } else if (doxygenEntity.typeOfEntity.compare(">") == 0) { - return ">"; - } else if (doxygenEntity.typeOfEntity.compare("&") == 0) { - return "&"; - } else if (doxygenEntity.typeOfEntity.compare("#") == 0) { - return "#"; - } else if (doxygenEntity.typeOfEntity.compare("%") == 0) { - return "%"; - } else if (doxygenEntity.typeOfEntity.compare("~") == 0) { - return "~"; - } - return ""; -} - - std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { - std::string returnedString; - if (doxygenEntity.isLeaf) { - return javaDocFormat(doxygenEntity) + " "; - } else { - returnedString += javaDocFormat(doxygenEntity); - std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); - - while (p != doxygenEntity.entityList.end()) { - returnedString += translateSubtree(*p); - p++; - } + std::string translatedComment; + + if (doxygenEntity.isLeaf) + return translatedComment; + + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()) { + translateEntity(*p, translatedComment); + translateSubtree(*p); + p++; } - return returnedString; + + return translatedComment; } - -std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) { - if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) { - return formatCommand(std::string(translateSubtree(doxyEntity)), 0); - } - - if ((doxyEntity.typeOfEntity.compare("brief") == 0) || (doxyEntity.typeOfEntity.compare("details") == 0)) { - return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * "; - - } else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 || - doxyEntity.typeOfEntity.compare("deprecated") == 0 || - doxyEntity.typeOfEntity.compare("brief") == 0) { - return formatCommand(doxyEntity.data, 0) + "\n * "; - - } else if (doxyEntity.typeOfEntity.compare("see") == 0) { - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - - } else if (doxyEntity.typeOfEntity.compare("return") == 0 - || doxyEntity.typeOfEntity.compare("author") == 0 - || doxyEntity.typeOfEntity.compare("param") == 0 - || doxyEntity.typeOfEntity.compare("throw") == 0 - || doxyEntity.typeOfEntity.compare("throws") == 0 - || doxyEntity.typeOfEntity.compare("since") == 0 - || doxyEntity.typeOfEntity.compare("version") == 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0) { - - // this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing - if (doxyEntity.typeOfEntity.compare("throw") == 0) { - doxyEntity.typeOfEntity = "throws"; - } - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); - - } else if (doxyEntity.typeOfEntity.compare("sa") == 0) { - return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); - - } else { - return formatCommand(javaDocFormat(doxyEntity), 0); - } - - return ""; +void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translatedComment) { + // check if we have needed handler and call it + if (tagHandlers.find(tag.typeOfEntity)!=tagHandlers.end()) + tagHandlers[tag.typeOfEntity](this, tag, translatedComment); } +void JavaDocConverter::handleTagC(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + translatedComment += "" + tag.data + ""; +} +void JavaDocConverter::handleTagB(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + translatedComment += "" + tag.data + ""; +} +void JavaDocConverter::handleTagThrow(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + tag.typeOfEntity = "throws"; + handleTagSame(converter, tag, translatedComment); +} +void JavaDocConverter::handleTagSeeAll(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + tag.typeOfEntity = "see"; + handleTagSame(converter, tag, translatedComment); +} +void JavaDocConverter::handleTagChar(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + // escape it if we can, else just print + if (escapeTable.find(tag.typeOfEntity)!=escapeTable.end()) + translatedComment += escapeTable[tag.typeOfEntity]; + else + translatedComment += tag.typeOfEntity; +} +void JavaDocConverter::handleTagSame(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + translatedComment += converter->formatCommand(std::string("@" + tag.typeOfEntity + "\t" + converter->translateSubtree(tag)), 2); +} +void JavaDocConverter::handleTagStrip(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + translatedComment += converter->formatCommand(converter->translateSubtree(tag), 0); +} +void JavaDocConverter::handleTagData(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { + translatedComment += tag.data + " "; +} String *JavaDocConverter::makeDocumentation(Node *node) { @@ -158,7 +172,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { return NULL; } - std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation)); // entityList.sort(CompareDoxygenEntities()); sorting currently not used, // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp @@ -171,7 +185,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { std::string javaDocString = "/**"; for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { - javaDocString += translateEntity(*entityIterator); + translateEntity(*entityIterator, javaDocString); entityIterator++; } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 1d54e2514..408ec4bb2 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -15,24 +15,55 @@ #define JAVADOCCONVERTER_H_ #include "DoxygenTranslator.h" +#include /* * A class to translate doxygen comments into JavaDoc style comments. */ class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter() : debug(false) { - } + JavaDocConverter(); String *makeDocumentation(Node *node); protected: std::string formatCommand(std::string unformattedLine, int indent); - std::string translateEntity(DoxygenEntity & doxyEntity); std::string javaDocFormat(DoxygenEntity & doxygenEntity); std::string translateSubtree(DoxygenEntity & doxygenEntity); + void translateEntity(DoxygenEntity &tag, std::string &translatedComment); + + /* + * Typedef for the function that handles one tag + */ + typedef void (*tagHandler)(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + /* + * Here comes various tag handlers + */ + static void handleTagC(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + static void handleTagB(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + static void handleTagThrow(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + static void handleTagSeeAll(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + /* + * Print the name of tag to the output, used for escape-commands + */ + static void handleTagChar(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + /* + * Do not translate and print as-is + */ + static void handleTagSame(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + /* + * Print only the content and strip original tag + */ + static void handleTagStrip(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + /* + * Print only data part of code + */ + static void handleTagData(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); private: bool debug; + std::map tagHandlers; + static std::map escapeTable; + void fillEscapeTable(); }; #endif From 48e9052e223a41aad5a543b238a1bc2f58980ec0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 2 Jul 2012 21:43:15 +0000 Subject: [PATCH 0058/2031] Comment fixed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13247 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenTranslator.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 023bdac89..7ddaba9a8 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -39,9 +39,7 @@ public: * Return the documentation for a given node formated for the correct * documentation system. The result is cached and translated only once. * @param node The node to extract and translate documentation for. - * @param format The documentation format to output. - * @param documentation The returned documentation string. - * @return A bool to indicate if there was documentation to return for the node. + * @return The resulted documentation string. */ String *getDocumentation(Node *node); /* From 2004ff23b913d398998a51427113de9af6888b64 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 21:47:57 +0000 Subject: [PATCH 0059/2031] Removed the unwanted header git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13251 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 40a50d45e..5d9a97952 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -21,7 +21,6 @@ static int treduce = SWIG_cparse_template_reduce(0); #include #include #include "../DoxygenTranslator/src/PyDocConverter.h" -#include "../../../swig/bug.h" #define PYSHADOW_MEMBER 0x2 #define WARN_PYTHON_MULTIPLE_INH 405 From 75961bc7d1965b4edf5a4dcd50ae23ae2d3b59fc Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 22:04:52 +0000 Subject: [PATCH 0060/2031] Fixed double-search in map in JavaDocConverter.cpp git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13252 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 0c332c3b9..a3abf100a 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -129,8 +129,10 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translatedComment) { // check if we have needed handler and call it - if (tagHandlers.find(tag.typeOfEntity)!=tagHandlers.end()) - tagHandlers[tag.typeOfEntity](this, tag, translatedComment); + std::map::iterator it; + it = tagHandlers.find(tag.typeOfEntity); + if (it!=tagHandlers.end()) + (*it).second(this, tag, translatedComment); } void JavaDocConverter::handleTagC(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { From 13adf595ecd3c4481a14e68a9edaac4a49a0dc04 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 22:23:22 +0000 Subject: [PATCH 0061/2031] Refactored the code, got rid of global objects, got rid of tons of string comparisons git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13253 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenCommands.h | 95 ++++ .../DoxygenTranslator/src/DoxygenParser.cpp | 410 +++++------------- Source/DoxygenTranslator/src/DoxygenParser.h | 215 +++++++++ 3 files changed, 410 insertions(+), 310 deletions(-) create mode 100644 Source/DoxygenTranslator/src/DoxygenCommands.h diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h new file mode 100644 index 000000000..e1eba33f4 --- /dev/null +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -0,0 +1,95 @@ + +#ifndef DOXYGENCOMMANDS_H +#define DOXYGENCOMMANDS_H + +const char *commandArray[] = { + "a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; + + +const char *sectionIndicators[] = { + "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; +const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionIndicators); + +/* All of the doxygen commands divided up by how they are parsed */ +const char *simpleCommands[] = { + "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; +const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands); + +const char *ignoredSimpleCommands[] = { + "nothing at the moment"}; +const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); + +const char *commandWords[] = { + "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; +const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); + +const char *ignoredCommandWords[] = { + "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; +const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); + +const char *commandLines[] = { + "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; +const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines); + +const char *ignoreCommandLines[] = { + "nothing at the moment"}; +const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); + +const char *commandParagraph[] = { + "partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; +const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); + +const char *ignoreCommandParagraphs[] = { + "nothing at the moment"}; +const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); + +const char *commandEndCommands[] = { + "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; +const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); + +const char *commandWordParagraphs[] = { + "param", "tparam", "throw", "throws", "retval", "exception"}; +const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); + +const char *commandWordLines[] = { + "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; +const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines); + +const char *commandWordOWordOWords[] = { + "category", "class", "protocol", "interface", "struct", "union"}; +const int commandWordOWordOWordsSize = sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); + +const char *commandOWords[] = { + "dir", "file", "cond"}; +const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords); + +const char *commandErrorThrowings[] = { + "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", + "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; +const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); + +const char *commandUniques[] = { + "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; +const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); + +#endif \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 030d8bee9..fe4dc5ec0 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -10,135 +10,96 @@ * ----------------------------------------------------------------------------- */ #include "DoxygenParser.h" -#include "TokenList.h" +#include "DoxygenCommands.h" + +#include + +// Define static class members +std::map DoxygenParser::doxygenCommands; +std::set DoxygenParser::doxygenSectionIndicators; -DoxygenParser::DoxygenParser() { +DoxygenParser::DoxygenParser() : noisy(true) { + fillTables(); } DoxygenParser::~DoxygenParser() { } -////////////////////////////////////////// -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(std::string currCommand, TokenList & tokList, std::list < DoxygenEntity > &aNewList); -std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList); +void DoxygenParser::fillTables() { + // run it only once + if (doxygenCommands.size()) + return; + + // fill in tables with data from DxygenCommands.h + for (int i = 0; i < simpleCommandsSize; i++) + doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND; + for (int i = 0; i < ignoredSimpleCommandsSize; i++) + doxygenCommands[ignoredSimpleCommands[i]] = IGNOREDSIMPLECOMMAND; + + for (int i = 0; i < commandWordsSize; i++) + doxygenCommands[commandWords[i]] = COMMANDWORD; + for (int i = 0; i < ignoredCommandWordsSize; i++) + doxygenCommands[ignoredCommandWords[i]] = IGNOREDCOMMANDWORD; + + for (int i = 0; i < commandLinesSize; i++) + doxygenCommands[commandLines[i]] = COMMANDLINE; + for (int i = 0; i < ignoreCommandLinesSize; i++) + doxygenCommands[ignoreCommandLines[i]] = IGNOREDCOMMANDLINE; + + for (int i = 0; i < commandParagraphSize; i++) + doxygenCommands[commandParagraph[i]] = COMMANDPARAGRAPH; + for (int i = 0; i < ignoreCommandParagraphsSize; i++) + doxygenCommands[ignoreCommandParagraphs[i]] = IGNORECOMMANDPARAGRAPH; + + for (int i = 0; i < commandEndCommandsSize; i++) + doxygenCommands[commandEndCommands[i]] = COMMANDENDCOMMAND; + for (int i = 0; i < commandWordParagraphsSize; i++) + doxygenCommands[commandWordParagraphs[i]] = COMMANDWORDPARAGRAPH; + for (int i = 0; i < commandWordLinesSize; i++) + doxygenCommands[commandWordLines[i]] = COMMANDWORDLINE; + for (int i = 0; i < commandWordOWordOWordsSize; i++) + doxygenCommands[commandWordOWordOWords[i]] = COMMANDWORDOWORDWORD; + for (int i = 0; i < commandOWordsSize; i++) + doxygenCommands[commandOWords[i]] = COMMANDOWORD; + for (int i = 0; i < commandErrorThrowingsSize; i++) + doxygenCommands[commandErrorThrowings[i]] = COMMANDERRORTHROW; + for (int i = 0; i < commandUniquesSize; i++) + doxygenCommands[commandUniques[i]] = COMMANDUNIQUE; + + // fill section indicators command set + for (int i = 0; i < sectionIndicatorsSize; i++) + doxygenSectionIndicators.insert(sectionIndicators[i]); +} -////////////////////////////////////////// - - -std::string commandArray[] = { - "a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; - - -std::string sectionIndicators[] = { - "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; - -/* All of the doxygen commands divided up by how they are parsed */ -std::string simpleCommands[] = { - "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; - -std::string ignoredSimpleCommands[] = { - "nothing at the moment"}; - -std::string commandWords[] = { - "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; - -std::string ignoredCommandWords[] = { - "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; - -std::string commandLines[] = { - "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; - -std::string ignoreCommandLines[] = { - "nothing at the moment"}; - -std::string commandParagraph[] = { - "partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; - -std::string ignoreCommandParagraphs[] = { - "nothing at the moment"}; - -std::string commandEndCommands[] = { - "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; - -std::string commandWordParagraphs[] = { - "param", "tparam", "throw", "throws", "retval", "exception"}; - -std::string commandWordLines[] = { - "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; - -std::string commandWordOWordOWords[] = { - "category", "class", "protocol", "interface", "struct", "union"}; - -std::string commandOWords[] = { - "dir", "file", "cond"}; - -std::string commandErrorThrowings[] = { - "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", - "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; -std::string commandUniques[] = { - "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; - - -/* Changes a std::string to all lower case */ -std::string StringToLower(std::string stringToConvert) { +std::string DoxygenParser::StringToLower(std::string stringToConvert) { for (unsigned int i = 0; i < stringToConvert.length(); i++) { stringToConvert[i] = tolower(stringToConvert[i]); } return stringToConvert; //return the converted std::string } -/* finds out if a command exists (is a possible command) - * from the std::string array commandArray - * returns -1 if no match is found */ -int findCommand(std::string smallString) { +int DoxygenParser::findCommand(std::string smallString) { + std::map::iterator it; smallString = StringToLower(smallString); - int a; - for (unsigned i = 0; i < sizeof(commandArray) / sizeof(*commandArray); i++) { - if ((a = smallString.compare(commandArray[i])) == 0) { - return 101 + i; - } - } + // I'm not sure if we can really do so, because there are different commands + // in doxygenCommands and original commandArray + it = doxygenCommands.find(smallString); + if (it != doxygenCommands.end()) + return 1; return -1; } -/* isSectionIndicator returns a boolean if the command is a section indicator - * This is a helper method for finding the end of a paragraph - * by Doxygen's terms - */ -int isSectionIndicator(std::string smallString) { +int DoxygenParser::isSectionIndicator(std::string smallString) { smallString = StringToLower(smallString); - for (unsigned i = 0; i < sizeof(sectionIndicators) / sizeof(*sectionIndicators); i++) { - if (smallString.compare(sectionIndicators[i]) == 0) { - return 1; - } - } + std::set::iterator it; + it = doxygenSectionIndicators.find(smallString); + if (it != doxygenSectionIndicators.end()) + return 1; return 0; } -/* prints the parse tree */ -void printTree(std::list < DoxygenEntity > &rootList) { +void DoxygenParser::printTree(std::list < DoxygenEntity > &rootList) { std::list < DoxygenEntity >::iterator p = rootList.begin(); while (p != rootList.end()) { (*p).printEntity(0); @@ -146,81 +107,17 @@ void printTree(std::list < DoxygenEntity > &rootList) { } } -/* Determines how a command should be handled (what group it belongs to - * for parsing rules - */ -int commandBelongs(std::string theCommand) { +int DoxygenParser::commandBelongs(std::string theCommand) { std::string smallString = StringToLower(theCommand); //cout << " Looking for command " << theCommand << endl; - unsigned i = 0; - for (i = 0; i < sizeof(simpleCommands) / sizeof(*simpleCommands); i++) { - if (smallString.compare(simpleCommands[i]) == 0) - return SIMPLECOMMAND; - } - for (i = 0; i < sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); i++) { - if (smallString.compare(ignoredSimpleCommands[i]) == 0) - return IGNOREDSIMPLECOMMAND; - } - for (i = 0; i < sizeof(commandWords) / sizeof(*commandWords); i++) { - if (smallString.compare(commandWords[i]) == 0) - return COMMANDWORD; - } - for (i = 0; i < sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); i++) { - if (smallString.compare(ignoredCommandWords[i]) == 0) - return IGNOREDCOMMANDWORD; - } - for (i = 0; i < sizeof(commandLines) / sizeof(*commandLines); i++) { - if (smallString.compare(commandLines[i]) == 0) - return COMMANDLINE; - } - for (i = 0; i < sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); i++) { - if (smallString.compare(ignoreCommandLines[i]) == 0) - return IGNOREDCOMMANDLINE; - } - for (i = 0; i < sizeof(commandParagraph) / sizeof(*commandParagraph); i++) { - if (smallString.compare(commandParagraph[i]) == 0) - return COMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); i++) { - if (smallString.compare(ignoreCommandParagraphs[i]) == 0) - return IGNORECOMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(commandEndCommands) / sizeof(*commandEndCommands); i++) { - if (smallString.compare(commandEndCommands[i]) == 0) - return COMMANDENDCOMMAND; - } - for (i = 0; i < sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); i++) { - if (smallString.compare(commandWordParagraphs[i]) == 0) - return COMMANDWORDPARAGRAPH; - } - for (i = 0; i < sizeof(commandWordLines) / sizeof(*commandWordLines); i++) { - if (smallString.compare(commandWordLines[i]) == 0) - return COMMANDWORDLINE; - } - for (i = 0; i < sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); i++) { - if (smallString.compare(commandWordOWordOWords[i]) == 0) - return COMMANDWORDOWORDWORD; - } - for (i = 0; i < sizeof(commandOWords) / sizeof(*commandOWords); i++) { - if (smallString.compare(commandOWords[i]) == 0) - return COMMANDOWORD; - } - for (i = 0; i < sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); i++) { - if (smallString.compare(commandErrorThrowings[i]) == 0) - return COMMANDERRORTHROW; - } - for (i = 0; i < sizeof(commandUniques) / sizeof(*commandUniques); i++) { - if (smallString.compare(commandUniques[i]) == 0) - return COMMANDUNIQUE; - } + std::map::iterator it; + it = doxygenCommands.find(smallString); + if (it!=doxygenCommands.end()) + return it->second; return 0; } -/* Returns the next word ON THE CURRENT LINE ONLY - * if a new line is encountered, returns a blank std::string. - * Updates the index it is given if success. - */ -std::string getNextWord(TokenList & tokList) { +std::string DoxygenParser::getNextWord(TokenList & tokList) { Token nextToken = tokList.peek(); if (nextToken.tokenType == PLAINSTRING) { nextToken = tokList.next(); @@ -229,10 +126,7 @@ std::string getNextWord(TokenList & tokList) { return ""; } -/* Returns the location of the end of the line as - * an iterator. - */ -std::list < Token >::iterator getOneLine(TokenList & tokList) { +std::list < Token >::iterator DoxygenParser::getOneLine(TokenList & tokList) { std::list < Token >::iterator endOfLine = tokList.iteratorCopy(); while (endOfLine != tokList.end()) { if ((*endOfLine).tokenType == END_LINE) { @@ -247,10 +141,7 @@ std::list < Token >::iterator getOneLine(TokenList & tokList) { return tokList.end(); } -/* Returns a properly formatted std::string -* up til ANY command or end of line is encountered. -*/ -std::string getStringTilCommand(TokenList & tokList) { +std::string DoxygenParser::getStringTilCommand(TokenList & tokList) { std::string description; if (tokList.peek().tokenType == 0) return ""; @@ -263,12 +154,7 @@ std::string getStringTilCommand(TokenList & tokList) { return description; } -/* Returns a properly formatted std::string -* up til the command specified is encountered -*/ -//TODO check that this behaves properly for formulas - -std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList) { +std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenList & tokList) { std::string description; if (tokList.peek().tokenType == 0) return ""; @@ -279,11 +165,7 @@ std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList) return description; } -/* Returns the end of a Paragraph as an iterator- -* Paragraph is defined in Doxygen to be a paragraph of text - * separated by either a structural command or a blank line -*/ -std::list < Token >::iterator getEndOfParagraph(TokenList & tokList) { +std::list < Token >::iterator DoxygenParser::getEndOfParagraph(TokenList & tokList) { std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); while (endOfParagraph != tokList.end()) { if ((*endOfParagraph).tokenType == END_LINE) { @@ -311,11 +193,7 @@ std::list < Token >::iterator getEndOfParagraph(TokenList & tokList) { return tokList.end(); } -/* Returns the end of a section, defined as the first blank line OR first encounter of the same -* command. Example of this behaviour is \arg -* if no end is encountered, returns the last token of the std::list. -*/ -std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList & tokList) { +std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theCommand, TokenList & tokList) { std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); while (endOfParagraph != tokList.end()) { if ((*endOfParagraph).tokenType == COMMAND) { @@ -336,13 +214,7 @@ std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList return tokList.end(); } -/* This method is for returning the end of a specific form of doxygen command - * that begins with a \command and ends in \endcommand - * such as \code and \endcode. The proper usage is - * progressTilEndCommand("endcode", tokenList); - * If the end is never encountered, it returns the end of the std::list. - */ -std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & tokList) { +std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theCommand, TokenList & tokList) { std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); while (endOfCommand != tokList.end()) { if ((*endOfCommand).tokenType == COMMAND) { @@ -356,48 +228,27 @@ std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & return tokList.end(); } -/* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered - */ -//TODO getTilAnyCommand -std::list < Token >::iterator getTilAnyCommand(std::string theCommand, TokenList & tokList) { +std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string theCommand, TokenList & tokList) { #pragma unused(theCommand,tokList) std::list < Token >::iterator anIterator; return anIterator; } - - - -/* Method for Adding a Simple Command - * Format: @command - * Plain commands, such as newline etc, they contain no other data - * \n \\ \@ \& \$ \# \< \> \% - */ -int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); return 1; } -/* NOT INCLUDED Simple Commands -* Format: @command -* Plain commands, such as newline etc, they contain no other data -*/ -int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) if (noisy) cout << "Not Adding " << theCommand << endl; return 1; } -/* CommandWord -* Format: @command -* Commands with a single WORD after then such as @b -* "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", -* "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" -*/ -int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -409,12 +260,7 @@ int addCommandWord(std::string theCommand, TokenList & tokList, std::list < Doxy return 0; } -/* NOT INCLUDED CommandWord -* Format: @command -* Commands with a single WORD after then such as @b -* "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" -*/ -int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) if (noisy) cout << "Not Adding " << theCommand << endl; @@ -426,12 +272,7 @@ int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < D return 0; } -/* CommandLine -* Format: @command (line) -* Commands with a single LINE after then such as @var -* "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" -*/ -int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::list < Token >::iterator endOfLine = getOneLine(tokList); @@ -440,12 +281,7 @@ int addCommandLine(std::string theCommand, TokenList & tokList, std::list < Doxy return 1; } -/* NOT INCLUDED CommandLine -* Format: @command (line) -* Commands with a single LINE after then such as @var -* -*/ -int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) if (noisy) cout << "Not Adding " << theCommand << endl; @@ -454,13 +290,7 @@ int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < D return 1; } -/* CommandParagraph -* Format: @command {paragraph} -* Commands with a single paragraph after then such as @return -* "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", -* "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" -*/ -int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); @@ -470,12 +300,7 @@ int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < return 1; } -/* CommandParagraph -* Format: @command {paragraph} -* Commands with a single LINE after then such as @var -* -*/ -int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) if (noisy) cout << "Not Adding " << theCommand << endl; @@ -484,27 +309,15 @@ int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::lis return 1; } -/* Command EndCommand -* Format: @command and ends at @endcommand -* Commands that take in a block of text such as @code -* "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", -* "verbatim", "xmlonly", "cond", "if", "ifnot", "link" -* Returns 1 if success, 0 if the endcommand is never encountered. -*/ -int addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) - cout << "Not Adding " << theCommand << endl; + cout << "Parsing " << theCommand << endl; std::string description = getStringTilEndCommand("end" + theCommand, tokList); doxyList.push_back(DoxygenEntity(theCommand, description)); return 1; } -/* CommandWordParagraph -* Format: @command {paragraph} -* Commands such as param - * "param", "tparam", "throw", "throws", "retval", "exception" -*/ -int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -520,12 +333,7 @@ int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::li return 1; } -/* CommandWordLine -* Format: @command (line) -* Commands such as param -* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" -*/ -int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -542,12 +350,7 @@ int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < //else cout << "No line followed " << theCommand << " command. Not added" << endl; } -/* Command Word Optional Word Optional Word -* Format: @command [] [] -* Commands such as class -* "category", "class", "protocol", "interface", "struct", "union" -*/ -int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -567,12 +370,7 @@ int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::l return 1; } -/* Command Optional Word -* Format: @command [] -* Commands such as dir -* "dir", "file", "cond" -*/ -int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -580,10 +378,7 @@ int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < Dox return 1; } - /* Commands that should not be encountered (such as PHP only) - * goes til the end of line then returns - */ -int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) if (noisy) { cout << "Encountered :" << theCommand << endl; @@ -594,8 +389,7 @@ int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list return 0; } -/* Adds the unique commands- different process for each unique command */ -int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { std::list < DoxygenEntity > aNewList; if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); @@ -722,11 +516,7 @@ int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < Do return 0; } -/* The actual "meat" of the doxygen parser. This is not yet fully implemented - * with my current design- however the skeletal outline is contained in - * the file Skeleton - */ -int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { +int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { std::string theCommand = StringToLower(commandString); if (theCommand.compare("plainstd::string") == 0) { std::string nextPhrase = getStringTilCommand(tokList); @@ -785,7 +575,7 @@ int addCommand(std::string commandString, TokenList & tokList, std::list < Doxyg return 0; } -std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { +std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { std::list < DoxygenEntity > aNewList; int currCommand; while (tokList.current() != endParsingIndex) { @@ -813,7 +603,7 @@ std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, return aNewList; } -std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { +std::list < DoxygenEntity > DoxygenParser::parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { std::list < DoxygenEntity > aNewList; int currCommand; diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 0c1f2d1cb..e64644725 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -13,12 +13,227 @@ #define DOXYGENPARSER_H_ #include #include +#include +#include #include "DoxygenEntity.h" +#include "TokenList.h" class DoxygenParser { public: DoxygenParser(); virtual ~DoxygenParser(); std::list < DoxygenEntity > createTree(std::string doxygen); +private: + + /* + *Changes a std::string to all lower case + */ + std::string StringToLower(std::string stringToConvert); + + /* + * Finds out if a command exists (is a possible command) + * returns -1 if no match is found + */ + int findCommand(std::string smallString); + /* + * isSectionIndicator returns a boolean if the command is a section indicator + * This is a helper method for finding the end of a paragraph + * by Doxygen's terms + */ + int isSectionIndicator(std::string smallString); + /* + * Determines how a command should be handled (what group it belongs to + * for parsing rules + */ + int commandBelongs(std::string theCommand); + + /* + *prints the parse tree + */ + void printTree(std::list < DoxygenEntity > &rootList); + + /* + * Returns the next word ON THE CURRENT LINE ONLY + * if a new line is encountered, returns a blank std::string. + * Updates the index it is given if success. + */ + std::string getNextWord(TokenList & tokList); + + /* + * Returns the location of the end of the line as + * an iterator. + */ + std::list < Token >::iterator getOneLine(TokenList & tokList); + + /* + * Returns a properly formatted std::string + * up til ANY command or end of line is encountered. + */ + std::string getStringTilCommand(TokenList & tokList); + + /* + * Returns a properly formatted std::string + * up til the command specified is encountered + */ + //TODO check that this behaves properly for formulas + std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList); + + /* + * Returns the end of a Paragraph as an iterator- + * Paragraph is defined in Doxygen to be a paragraph of text + * separated by either a structural command or a blank line + */ + std::list < Token >::iterator getEndOfParagraph(TokenList & tokList); + + /* + * Returns the end of a section, defined as the first blank line OR first encounter of the same + * command. Example of this behaviour is \arg + * if no end is encountered, returns the last token of the std::list. + */ + std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList & tokList); + + /* + * This method is for returning the end of a specific form of doxygen command + * that begins with a \command and ends in \endcommand + * such as \code and \endcode. The proper usage is + * progressTilEndCommand("endcode", tokenList); + * If the end is never encountered, it returns the end of the std::list. + */ + std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & tokList); + /* + * A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered + */ + //TODO getTilAnyCommand + std::list < Token >::iterator getTilAnyCommand(std::string theCommand, TokenList & tokList); + + /* + * Method for Adding a Simple Command + * Format: @command + * Plain commands, such as newline etc, they contain no other data + * \n \\ \@ \& \$ \# \< \> \% + */ + int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList); + /* + * NOT INCLUDED Simple Commands + * Format: @command + * Plain commands, such as newline etc, they contain no other data + */ + int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList); + /* + * CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" + */ + int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * NOT INCLUDED CommandWord + * Format: @command + * Commands with a single WORD after then such as @b + * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" + */ + int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" + */ + int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * NOT INCLUDED CommandLine + * Format: @command (line) + * Commands with a single LINE after then such as @var + */ + int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * CommandParagraph + * Format: @command {paragraph} + * Commands with a single paragraph after then such as @return + * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" + */ + int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * CommandParagraph + * Format: @command {paragraph} + * Commands with a single LINE after then such as @var + */ + int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * Command EndCommand + * Format: @command and ends at @endcommand + * Commands that take in a block of text such as @code + * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" + * Returns 1 if success, 0 if the endcommand is never encountered. + */ + int addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * CommandWordParagraph + * Format: @command {paragraph} + * Commands such as param + * "param", "tparam", "throw", "throws", "retval", "exception" + */ + int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * CommandWordLine + * Format: @command (line) + * Commands such as param + * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" + */ + int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * Command Word Optional Word Optional Word + * Format: @command [] [] + * Commands such as class + * "category", "class", "protocol", "interface", "struct", "union" + */ + int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * Command Optional Word + * Format: @command [] + * Commands such as dir + * "dir", "file", "cond" + */ + int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * Commands that should not be encountered (such as PHP only) + * goes til the end of line then returns + */ + int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + *Adds the unique commands- different process for each unique command + */ + int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + /* + * The actual "meat" of the doxygen parser. This is not yet fully implemented + * with my current design- however the skeletal outline is contained in + * the file Skeleton + */ + int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList); + + std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList); + std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList); + + /* + * Fill static doxygenCommands and sectionIndicators containers + */ + void fillTables(); + + /* + * Whether to print lots of debug info during parsing + */ + bool noisy; + + /* + * Map of Doxygen commands to determine if a string is a + * command and how it needs to be parsed + */ + static std::map doxygenCommands; + + static std::set doxygenSectionIndicators; }; #endif + From 4398d1aee4a7237f514d3cc54e2befa5dbd65d99 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 22:28:41 +0000 Subject: [PATCH 0062/2031] Fixed a bug in parser with doxygen commands like code, dot, verbatim and so on git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13254 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index fe4dc5ec0..b760fcf42 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -158,10 +158,14 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL std::string description; if (tokList.peek().tokenType == 0) return ""; - while (tokList.peek().tokenString.compare(theCommand) != 0) { - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; + while (tokList.next().tokenString.compare(theCommand) != 0) { + //TODO: it won't output doxygen commands, need a way to fix it + if (tokList.peek().tokenType == PLAINSTRING) + description += tokList.peek().tokenString + " "; + if (tokList.peek().tokenType == END_LINE) + description += "\n"; } + tokList.next(); // eat the end command itself return description; } From f57b515ee7a813995b80913471769b8eb3666fee Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 22:54:37 +0000 Subject: [PATCH 0063/2031] Got rid of translated comments cache, seems very inefficient git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13255 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenTranslator.cpp | 16 +--------------- Source/DoxygenTranslator/src/DoxygenTranslator.h | 9 ++------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index a733fdbc7..18cf24c85 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -15,12 +15,8 @@ #include "DoxygenTranslator.h" DoxygenTranslator::DoxygenTranslator() { - // Init the cache - resultsCache = NewHash(); } DoxygenTranslator::~DoxygenTranslator() { - // Clean up the cache - Delete(resultsCache); } bool DoxygenTranslator::hasDocumentation(Node *node) { @@ -37,17 +33,7 @@ String *DoxygenTranslator::getDocumentation(Node *node) { if (!hasDocumentation(node)) return 0; - // get from cache - String *resultedDocs = Getattr(resultsCache, getDoxygenComment(node)); - - if (resultedDocs) - return resultedDocs; - - // not found in cache, produce it - resultedDocs = makeDocumentation(node); - Setattr(resultsCache, getDoxygenComment(node), resultedDocs); - - return resultedDocs; + return makeDocumentation(node); } void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) { diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 7ddaba9a8..637b30a9e 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -22,7 +22,7 @@ /* - * A class to translate doxygen comments attacted to parser nodes + * A class to translate doxygen comments attached to parser nodes * into alternative formats for use in code generated for target languages. */ class DoxygenTranslator { @@ -37,7 +37,7 @@ public: virtual ~ DoxygenTranslator(); /* * Return the documentation for a given node formated for the correct - * documentation system. The result is cached and translated only once. + * documentation system. * @param node The node to extract and translate documentation for. * @return The resulted documentation string. */ @@ -70,11 +70,6 @@ protected: * Doxygen parser object */ DoxygenParser parser; - - /* - * Cache of translated comments - */ - Hash *resultsCache; }; #endif From 501bb822e6be59b6407e1317c1e046a388aa22bf Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 4 Jul 2012 22:56:29 +0000 Subject: [PATCH 0064/2031] Oops, debug output should be left off by default git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13256 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index b760fcf42..07e61b590 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -19,7 +19,7 @@ std::map DoxygenParser::doxygenCommands; std::set DoxygenParser::doxygenSectionIndicators; -DoxygenParser::DoxygenParser() : noisy(true) { +DoxygenParser::DoxygenParser() : noisy(false) { fillTables(); } From 93a02cc728a5e5f2431445ae808c89d686f62aa5 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 13:40:41 +0000 Subject: [PATCH 0065/2031] Refactored doxygen tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13261 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_basic_translate.i | 6 +- Examples/test-suite/doxygen_parsing_enums.i | 4 +- Examples/test-suite/java/commentParser.java | 71 ++++++++++++++++ .../java/doxygen_basic_translate_runme.java | 82 +++---------------- .../doxygen_parsing_enums_proper_runme.java | 75 ++--------------- .../doxygen_parsing_enums_simple_runme.java | 75 ++--------------- .../doxygen_parsing_enums_typesafe_runme.java | 75 ++--------------- ...oxygen_parsing_enums_typeunsafe_runme.java | 75 ++--------------- .../java/doxygen_parsing_runme.java | 71 ++-------------- 9 files changed, 131 insertions(+), 403 deletions(-) create mode 100644 Examples/test-suite/java/commentParser.java diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index c961164d5..af449eb49 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -3,7 +3,9 @@ %inline %{ /** - * \brief Brief description. + * \brief + * Brief description. + * * The comment text * \author Some author * \return Some number @@ -13,4 +15,4 @@ int function() { } -%} \ No newline at end of file +%} diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i index 317abf384..222356510 100644 --- a/Examples/test-suite/doxygen_parsing_enums.i +++ b/Examples/test-suite/doxygen_parsing_enums.i @@ -9,7 +9,7 @@ enum E_TEST /** the first item */ E_TEST_ONE, E_TEST_TWO = 2, /**< the second */ - E_TEST_THREE = 2+1 + E_TEST_THREE = 2+1 /**< the last item */ }; -%} \ No newline at end of file +%} diff --git a/Examples/test-suite/java/commentParser.java b/Examples/test-suite/java/commentParser.java new file mode 100644 index 000000000..3877f5f4d --- /dev/null +++ b/Examples/test-suite/java/commentParser.java @@ -0,0 +1,71 @@ + +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class commentParser { + static HashMap parsedComments = new HashMap(); + + public static boolean start(RootDoc root) { + + /* + * This method is called by 'javadoc' and gets the whole parsed java + * file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), + classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static int check(HashMap wantedComments) { + int errorCount=0; + Iterator< Entry > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() < wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + return errorCount; + } +} \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index 7aee4221b..34270de56 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -2,8 +2,6 @@ import doxygen_basic_translate.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_basic_translate_runme { static { @@ -14,81 +12,25 @@ public class doxygen_basic_translate_runme { System.exit(1); } } - - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - + public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test", - "doxygen_basic_translate_runme", new String[]{"-quiet", "doxygen_basic_translate"}); + "commentParser", new String[]{"-quiet", "doxygen_basic_translate"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("function", " Brief description. \n The comment text \n" + - " @author\tSome author \n" + - " @return\tSome number \n" + - " @see\tfunction2 \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + " @author\tSome author \n" + + " @return\tSome number \n" + + " @see\tfunction2 \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } -} +} \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index 503e2c68e..d3993f201 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -2,8 +2,6 @@ import doxygen_parsing_enums_proper.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_parsing_enums_proper_runme { static { @@ -14,80 +12,25 @@ public class doxygen_parsing_enums_proper_runme { System.exit(1); } } - - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - + public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test", - "doxygen_parsing_enums_proper_runme", new String[]{"-quiet", "doxygen_parsing_enums_proper"}); + "commentParser", new String[]{"-quiet", "doxygen_parsing_enums_proper"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("E_TEST", " Test enumeration \n"); wantedComments.put("E_TEST_ONE", " the first item \n"); wantedComments.put("E_TEST_TWO", " the second \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + wantedComments.put("E_TEST_THREE", " the last item \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index ee422e2c4..1dffe4466 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -2,8 +2,6 @@ import doxygen_parsing_enums_simple.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_parsing_enums_simple_runme { static { @@ -14,79 +12,24 @@ public class doxygen_parsing_enums_simple_runme { System.exit(1); } } - - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - + public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test", - "doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"}); + "commentParser", new String[]{"-quiet", "doxygen_parsing_enums_simple"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("E_TEST_ONE", " the first item \n"); wantedComments.put("E_TEST_TWO", " the second \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + wantedComments.put("E_TEST_THREE", " the last item \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index 8d87c82d0..5aed9327e 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -2,8 +2,6 @@ import doxygen_parsing_enums_typesafe.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_parsing_enums_typesafe_runme { static { @@ -14,80 +12,25 @@ public class doxygen_parsing_enums_typesafe_runme { System.exit(1); } } - - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - + public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test", - "doxygen_parsing_enums_typesafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"}); + "commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("E_TEST", " Test enumeration \n"); wantedComments.put("E_TEST_ONE", " the first item \n"); wantedComments.put("E_TEST_TWO", " the second \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + wantedComments.put("E_TEST_THREE", " the last item \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index a01007db1..44405f837 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -2,8 +2,6 @@ import doxygen_parsing_enums_typeunsafe.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_parsing_enums_typeunsafe_runme { static { @@ -14,80 +12,25 @@ public class doxygen_parsing_enums_typeunsafe_runme { System.exit(1); } } - - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - + public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test", - "doxygen_parsing_enums_typeunsafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"}); + "commentParser", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("E_TEST", " Test enumeration \n"); wantedComments.put("E_TEST_ONE", " the first item \n"); wantedComments.put("E_TEST_TWO", " the second \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + wantedComments.put("E_TEST_THREE", " the last item \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index 909de9312..ae426da58 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -2,8 +2,6 @@ import doxygen_parsing.*; import com.sun.javadoc.*; import java.util.HashMap; -import java.util.Map.Entry; -import java.util.Iterator; public class doxygen_parsing_runme { static { @@ -15,55 +13,18 @@ public class doxygen_parsing_runme { } } - static HashMap parsedComments = new HashMap(); - static HashMap wantedComments = new HashMap(); - - public static boolean start(RootDoc root) { - - /* - This method is called by 'javadoc' and gets the whole parsed - java file, we get comments and store them - */ - - ClassDoc[] classes = root.classes(); - - for (int i = 0; i < classes.length; i++) { - - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; - if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); - } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; - if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); - } - } - return true; - } - public static void main(String argv[]) { /* Here we are using internal javadoc tool, it accepts the name of the class as paramterer, and calls the start() method of that class with parsed information. */ + commentParser parser = new commentParser(); com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test", - "doxygen_parsing_runme", new String[]{"-quiet", "doxygen_parsing"}); + "commentParser", new String[]{"-quiet", "doxygen_parsing"}); + HashMap wantedComments = new HashMap(); + wantedComments.put("simpleFunction", " This is simple comment for a function \n"); wantedComments.put("CSimpleClass", " This is simple comment for a class \n"); @@ -85,27 +46,7 @@ public class doxygen_parsing_runme { wantedComments.put("setSimpleVarFive", " This is a post comment \n"); wantedComments.put("getSimpleVarFive", " This is a post comment \n"); - - int errorCount=0; - Iterator< Entry > it = parsedComments.entrySet().iterator(); - - while (it.hasNext()) - { - Entry e = (Entry) it.next(); - - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { - System.out.println("Documentation comments for " + e.getKey() + " does not match: "); - System.out.println("\texpected:"+wantedComments.get(e.getKey())); - System.out.println("\tgot:\t"+e.getValue()); - errorCount++; - } - } - - if (parsedComments.size() != wantedComments.size()) { - System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); - errorCount++; - } - - System.exit(errorCount); + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); } } From 293c5cfc1fea4153660fc15776ce0ae71c7cb269 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 13:43:19 +0000 Subject: [PATCH 0066/2031] Added support for commenting the last enum item in parser.y git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13262 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 70f420411..4bf63b40f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5831,6 +5831,10 @@ edecl : ID { $$ = $2; set_comment(previousNode, $1); } + | edecl doxygen_post_comment { + $$ = $1; + set_comment($1, $2); + } | empty { $$ = 0; previousNode = currentNode; currentNode = 0; } ; From 509cbd72b0823381fbcc2ac9c9dab6b3bdbd5ede Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 13:47:35 +0000 Subject: [PATCH 0067/2031] Small JavaDoc converter and doxygen parser improvements, now basic tags working git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13263 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenParser.cpp | 1022 ++++++++--------- Source/DoxygenTranslator/src/DoxygenParser.h | 3 +- .../src/JavaDocConverter.cpp | 88 +- .../DoxygenTranslator/src/JavaDocConverter.h | 8 +- 4 files changed, 543 insertions(+), 578 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 07e61b590..e7104b9e0 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -12,645 +12,611 @@ #include "DoxygenParser.h" #include "DoxygenCommands.h" -#include - // Define static class members std::map DoxygenParser::doxygenCommands; std::set DoxygenParser::doxygenSectionIndicators; -DoxygenParser::DoxygenParser() : noisy(false) { - fillTables(); +DoxygenParser::DoxygenParser() : noisy(true) { + fillTables(); } DoxygenParser::~DoxygenParser() { } void DoxygenParser::fillTables() { - // run it only once - if (doxygenCommands.size()) - return; - - // fill in tables with data from DxygenCommands.h - for (int i = 0; i < simpleCommandsSize; i++) - doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND; - for (int i = 0; i < ignoredSimpleCommandsSize; i++) - doxygenCommands[ignoredSimpleCommands[i]] = IGNOREDSIMPLECOMMAND; - - for (int i = 0; i < commandWordsSize; i++) - doxygenCommands[commandWords[i]] = COMMANDWORD; - for (int i = 0; i < ignoredCommandWordsSize; i++) - doxygenCommands[ignoredCommandWords[i]] = IGNOREDCOMMANDWORD; - - for (int i = 0; i < commandLinesSize; i++) - doxygenCommands[commandLines[i]] = COMMANDLINE; - for (int i = 0; i < ignoreCommandLinesSize; i++) - doxygenCommands[ignoreCommandLines[i]] = IGNOREDCOMMANDLINE; - - for (int i = 0; i < commandParagraphSize; i++) - doxygenCommands[commandParagraph[i]] = COMMANDPARAGRAPH; - for (int i = 0; i < ignoreCommandParagraphsSize; i++) - doxygenCommands[ignoreCommandParagraphs[i]] = IGNORECOMMANDPARAGRAPH; - - for (int i = 0; i < commandEndCommandsSize; i++) - doxygenCommands[commandEndCommands[i]] = COMMANDENDCOMMAND; - for (int i = 0; i < commandWordParagraphsSize; i++) - doxygenCommands[commandWordParagraphs[i]] = COMMANDWORDPARAGRAPH; - for (int i = 0; i < commandWordLinesSize; i++) - doxygenCommands[commandWordLines[i]] = COMMANDWORDLINE; - for (int i = 0; i < commandWordOWordOWordsSize; i++) - doxygenCommands[commandWordOWordOWords[i]] = COMMANDWORDOWORDWORD; - for (int i = 0; i < commandOWordsSize; i++) - doxygenCommands[commandOWords[i]] = COMMANDOWORD; - for (int i = 0; i < commandErrorThrowingsSize; i++) - doxygenCommands[commandErrorThrowings[i]] = COMMANDERRORTHROW; - for (int i = 0; i < commandUniquesSize; i++) - doxygenCommands[commandUniques[i]] = COMMANDUNIQUE; - - // fill section indicators command set - for (int i = 0; i < sectionIndicatorsSize; i++) - doxygenSectionIndicators.insert(sectionIndicators[i]); + // run it only once + if (doxygenCommands.size()) + return; + + // fill in tables with data from DxygenCommands.h + for (int i = 0; i < simpleCommandsSize; i++) + doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND; + for (int i = 0; i < ignoredSimpleCommandsSize; i++) + doxygenCommands[ignoredSimpleCommands[i]] = IGNOREDSIMPLECOMMAND; + + for (int i = 0; i < commandWordsSize; i++) + doxygenCommands[commandWords[i]] = COMMANDWORD; + for (int i = 0; i < ignoredCommandWordsSize; i++) + doxygenCommands[ignoredCommandWords[i]] = IGNOREDCOMMANDWORD; + + for (int i = 0; i < commandLinesSize; i++) + doxygenCommands[commandLines[i]] = COMMANDLINE; + for (int i = 0; i < ignoreCommandLinesSize; i++) + doxygenCommands[ignoreCommandLines[i]] = IGNOREDCOMMANDLINE; + + for (int i = 0; i < commandParagraphSize; i++) + doxygenCommands[commandParagraph[i]] = COMMANDPARAGRAPH; + for (int i = 0; i < ignoreCommandParagraphsSize; i++) + doxygenCommands[ignoreCommandParagraphs[i]] = IGNORECOMMANDPARAGRAPH; + + for (int i = 0; i < commandEndCommandsSize; i++) + doxygenCommands[commandEndCommands[i]] = COMMANDENDCOMMAND; + for (int i = 0; i < commandWordParagraphsSize; i++) + doxygenCommands[commandWordParagraphs[i]] = COMMANDWORDPARAGRAPH; + for (int i = 0; i < commandWordLinesSize; i++) + doxygenCommands[commandWordLines[i]] = COMMANDWORDLINE; + for (int i = 0; i < commandWordOWordOWordsSize; i++) + doxygenCommands[commandWordOWordOWords[i]] = COMMANDWORDOWORDWORD; + for (int i = 0; i < commandOWordsSize; i++) + doxygenCommands[commandOWords[i]] = COMMANDOWORD; + for (int i = 0; i < commandErrorThrowingsSize; i++) + doxygenCommands[commandErrorThrowings[i]] = COMMANDERRORTHROW; + for (int i = 0; i < commandUniquesSize; i++) + doxygenCommands[commandUniques[i]] = COMMANDUNIQUE; + + // fill section indicators command set + for (int i = 0; i < sectionIndicatorsSize; i++) + doxygenSectionIndicators.insert(sectionIndicators[i]); } std::string DoxygenParser::StringToLower(std::string stringToConvert) { - for (unsigned int i = 0; i < stringToConvert.length(); i++) { - stringToConvert[i] = tolower(stringToConvert[i]); - } - return stringToConvert; //return the converted std::string + for (unsigned int i = 0; i < stringToConvert.length(); i++) { + stringToConvert[i] = tolower(stringToConvert[i]); + } + return stringToConvert; //return the converted std::string } int DoxygenParser::findCommand(std::string smallString) { - std::map::iterator it; - smallString = StringToLower(smallString); - // I'm not sure if we can really do so, because there are different commands - // in doxygenCommands and original commandArray - it = doxygenCommands.find(smallString); - if (it != doxygenCommands.end()) - return 1; - return -1; + std::map::iterator it; + smallString = StringToLower(smallString); + // I'm not sure if we can really do so, because there are different commands + // in doxygenCommands and original commandArray + it = doxygenCommands.find(smallString); + if (it != doxygenCommands.end()) + return 1; + return -1; } int DoxygenParser::isSectionIndicator(std::string smallString) { - smallString = StringToLower(smallString); - std::set::iterator it; - it = doxygenSectionIndicators.find(smallString); - if (it != doxygenSectionIndicators.end()) - return 1; - return 0; + smallString = StringToLower(smallString); + std::set::iterator it; + it = doxygenSectionIndicators.find(smallString); + if (it != doxygenSectionIndicators.end()) + return 1; + return 0; } void DoxygenParser::printTree(std::list < DoxygenEntity > &rootList) { - std::list < DoxygenEntity >::iterator p = rootList.begin(); - while (p != rootList.end()) { - (*p).printEntity(0); - p++; - } + std::list < DoxygenEntity >::iterator p = rootList.begin(); + while (p != rootList.end()) { + (*p).printEntity(0); + p++; + } } int DoxygenParser::commandBelongs(std::string theCommand) { - std::string smallString = StringToLower(theCommand); - //cout << " Looking for command " << theCommand << endl; - std::map::iterator it; - it = doxygenCommands.find(smallString); - if (it!=doxygenCommands.end()) - return it->second; - return 0; + std::string smallString = StringToLower(theCommand); + //cout << " Looking for command " << theCommand << endl; + std::map::iterator it; + it = doxygenCommands.find(smallString); + if (it!=doxygenCommands.end()) + return it->second; + return 0; } std::string DoxygenParser::getNextWord(TokenList & tokList) { - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING) { - nextToken = tokList.next(); - return nextToken.tokenString; - } - return ""; + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING) { + nextToken = tokList.next(); + return nextToken.tokenString; + } + return ""; } std::list < Token >::iterator DoxygenParser::getOneLine(TokenList & tokList) { - std::list < Token >::iterator endOfLine = tokList.iteratorCopy(); - while (endOfLine != tokList.end()) { - if ((*endOfLine).tokenType == END_LINE) { - //cout << "REACHED END" << endl; - //endOfLine++; - return endOfLine; - } - //cout << (* endOfLine).toString(); - endOfLine++; - } + std::list < Token >::iterator endOfLine = tokList.iteratorCopy(); + while (endOfLine != tokList.end()) { + if ((*endOfLine).tokenType == END_LINE) { + //cout << "REACHED END" << endl; + //endOfLine++; + return endOfLine; + } + //cout << (* endOfLine).toString(); + endOfLine++; + } - return tokList.end(); + return tokList.end(); } std::string DoxygenParser::getStringTilCommand(TokenList & tokList) { - std::string description; - if (tokList.peek().tokenType == 0) - return ""; - while (tokList.peek().tokenType == PLAINSTRING) { - Token currentToken = tokList.next(); - if (currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - } - return description; + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.peek().tokenType == PLAINSTRING) { + Token currentToken = tokList.next(); + if (currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } + } + return description; } std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenList & tokList) { - std::string description; - if (tokList.peek().tokenType == 0) - return ""; - while (tokList.next().tokenString.compare(theCommand) != 0) { - //TODO: it won't output doxygen commands, need a way to fix it - if (tokList.peek().tokenType == PLAINSTRING) - description += tokList.peek().tokenString + " "; - if (tokList.peek().tokenType == END_LINE) - description += "\n"; - } - tokList.next(); // eat the end command itself - return description; + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.next().tokenString.compare(theCommand) != 0) { + //TODO: it won't output doxygen commands, need a way to fix it + if (tokList.peek().tokenType == PLAINSTRING) + description += tokList.peek().tokenString + " "; + if (tokList.peek().tokenType == END_LINE) + description += "\n"; + } + tokList.next(); // eat the end command itself + return description; } std::list < Token >::iterator DoxygenParser::getEndOfParagraph(TokenList & tokList) { - std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); - while (endOfParagraph != tokList.end()) { - if ((*endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - if (endOfParagraph != tokList.end() && (*endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - //cout << "ENCOUNTERED END OF PARA" << endl; - return endOfParagraph; - } + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if (endOfParagraph != tokList.end() && (*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + //cout << "ENCOUNTERED END OF PARA" << endl; + return endOfParagraph; + } - } else if ((*endOfParagraph).tokenType == COMMAND) { + } else if ((*endOfParagraph).tokenType == COMMAND) { - if (isSectionIndicator((*endOfParagraph).tokenString)) { - return endOfParagraph; - } else - endOfParagraph++; + if (isSectionIndicator((*endOfParagraph).tokenString)) { + return endOfParagraph; + } else + endOfParagraph++; - } else if ((*endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } else { - return tokList.end(); - } - } + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else { + return tokList.end(); + } + } - return tokList.end(); + return tokList.end(); } std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theCommand, TokenList & tokList) { - std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); - while (endOfParagraph != tokList.end()) { - if ((*endOfParagraph).tokenType == COMMAND) { - if (theCommand.compare((*endOfParagraph).tokenString) == 0) - return endOfParagraph; - else - endOfParagraph++; - } else if ((*endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } else if ((*endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - if ((*endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - return endOfParagraph; - } - } - } - return tokList.end(); + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == COMMAND) { + if (theCommand.compare((*endOfParagraph).tokenString) == 0) + return endOfParagraph; + else + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + return endOfParagraph; + } + } + } + return tokList.end(); } std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theCommand, TokenList & tokList) { - std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand != tokList.end()) { - if ((*endOfCommand).tokenType == COMMAND) { - if (theCommand.compare((*endOfCommand).tokenString) == 0) { - return endOfCommand; - } - endOfCommand++; - } - } - //End command not found - return tokList.end(); + std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand != tokList.end()) { + if ((*endOfCommand).tokenType == COMMAND) { + if (theCommand.compare((*endOfCommand).tokenString) == 0) { + return endOfCommand; + } + endOfCommand++; + } + } + //End command not found + return tokList.end(); } std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string theCommand, TokenList & tokList) { #pragma unused(theCommand,tokList) - std::list < Token >::iterator anIterator; - return anIterator; + std::list < Token >::iterator anIterator; + return anIterator; } int DoxygenParser::addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; } int DoxygenParser::ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - return 1; + if (noisy) + cout << "Not Adding " << theCommand << endl; + return 1; } int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (!name.empty()) { - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } else - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (!name.empty()) { + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } else + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } int DoxygenParser::ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::string name = getNextWord(tokList); - if (!name.empty()) - return 1; - else - cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::string name = getNextWord(tokList); + if (!name.empty()) + return 1; + else + cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; } int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::list < Token >::iterator endOfLine = getOneLine(tokList); - std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; } int DoxygenParser::ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 1; + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 1; } int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list < DoxygenEntity > aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; } int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; } int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string description = getStringTilEndCommand("end" + theCommand, tokList); - doxyList.push_back(DoxygenEntity(theCommand, description)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string description = getStringTilEndCommand("end" + theCommand, tokList); + doxyList.push_back(DoxygenEntity(theCommand, description)); + return 1; } int DoxygenParser::addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list < DoxygenEntity > aNewList; - aNewList = parse(endOfParagraph, tokList); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; } int DoxygenParser::addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list < Token >::iterator endOfLine = getOneLine(tokList); - std::list < DoxygenEntity > aNewList; - aNewList = parse(endOfLine, tokList); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - //else cout << "No line followed " << theCommand << " command. Not added" << endl; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + //else cout << "No line followed " << theCommand << " command. Not added" << endl; } int DoxygenParser::addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::string headerfile = getNextWord(tokList); - std::string headername = getNextWord(tokList); - std::list < DoxygenEntity > aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::string headerfile = getNextWord(tokList); + std::string headername = getNextWord(tokList); + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; } int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; } int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) { - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } - std::list < Token >::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 0; + if (noisy) { + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 0; } int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - std::list < DoxygenEntity > aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { - std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); - std::list < DoxygenEntity > aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - // \xrefitem "(heading)" "(std::list title)" {text} - else if (theCommand.compare("xrefitem") == 0) { - //TODO Implement xrefitem - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; - } - // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0) { - std::string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if (!name.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if (!name.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0) { - std::list < Token >::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - std::list < DoxygenEntity > aNewList2; - aNewList2 = parse(endOfLine, tokList); - aNewList.splice(aNewList.end(), aNewList2); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \headerfile [] - else if (theCommand.compare("headerfile") == 0) { - std::list < DoxygenEntity > aNewList; - std::string name = getNextWord(tokList); - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - name = getNextWord(tokList); - if (!name.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0) { - std::list < Token >::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - std::list < DoxygenEntity > aNewList; - aNewList = parse(endOfLine, tokList); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } else - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list < DoxygenEntity > aNewList; - std::list < Token >::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - // \ref ["(text)"] - else if (theCommand.compare("ref") == 0) { - //TODO Implement ref - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0) { - //TODO implement subpage - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0) { - //TODO implement dotfile - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - } - // \image ["caption"] [=] - else if (theCommand.compare("image") == 0) { - //todo implement image - } - // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0) { - if (noisy) - cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - std::list < DoxygenEntity > aNewList; - std::list < Token >::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); - } - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - return 0; + std::list < DoxygenEntity > aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { + std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + // \xrefitem "(heading)" "(std::list title)" {text} + else if (theCommand.compare("xrefitem") == 0) { + //TODO Implement xrefitem + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + return 1; + } + // \ingroup ( [ ]) + else if (theCommand.compare("ingroup") == 0) { + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if (!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if (!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \par [(paragraph title)] { paragraph } + else if (theCommand.compare("par") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + std::list < DoxygenEntity > aNewList2; + aNewList2 = parse(endOfLine, tokList); + aNewList.splice(aNewList.end(), aNewList2); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \headerfile [] + else if (theCommand.compare("headerfile") == 0) { + std::list < DoxygenEntity > aNewList; + std::string name = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + name = getNextWord(tokList); + if (!name.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } + // \overload [(function declaration)] + else if (theCommand.compare("overload") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } else + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; + } + // \weakgroup [(title)] + else if (theCommand.compare("weakgroup") == 0) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + // \ref ["(text)"] + else if (theCommand.compare("ref") == 0) { + //TODO Implement ref + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \subpage ["(text)"] + else if (theCommand.compare("subpage") == 0) { + //TODO implement subpage + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \dotfile ["caption"] + else if (theCommand.compare("dotfile") == 0) { + //TODO implement dotfile + if (noisy) + cout << "Not Adding " << theCommand << endl; + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + tokList.setIterator(endOfParagraph); + } + // \image ["caption"] [=] + else if (theCommand.compare("image") == 0) { + //todo implement image + } + // \addtogroup [(title)] + else if (theCommand.compare("addtogroup") == 0) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + aNewList = parse(endOfLine, tokList); + } + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } + return 0; } int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - std::string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstd::string") == 0) { - std::string nextPhrase = getStringTilCommand(tokList); - if (noisy) - cout << "Parsing plain std::string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND) { - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND) { - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD) { - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD) { - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE) { - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE) { - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH) { - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH) { - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND) { - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH) { - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE) { - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD) { - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD) { - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW) { - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE) { - return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; -} - -std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { - std::list < DoxygenEntity > aNewList; - int currCommand; - while (tokList.current() != endParsingIndex) { - Token currToken = tokList.peek(); - if (noisy) - cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if (currToken.tokenType == END_LINE) { - tokList.next(); - } else if (currToken.tokenType == COMMAND) { - currCommand = findCommand(currToken.tokenString); - if (currCommand < 0) { - if (noisy) - cout << "Unidentified Command " << currToken.tokenString << endl; - tokList.next(); - addCommand(std::string("plainstd::string"), tokList, aNewList); - } else { - tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } else if (currToken.tokenType == PLAINSTRING) { - addCommand(std::string("plainstd::string"), tokList, aNewList); - } - break; - } - return aNewList; -} - -std::list < DoxygenEntity > DoxygenParser::parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { - - std::list < DoxygenEntity > aNewList; - int currCommand; - - while (tokList.current() != endParsingIndex) { - - Token currToken = tokList.peek(); - if (noisy) { - cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - } - - if (currToken.tokenType == END_LINE) { - tokList.next(); - } else if (currToken.tokenType == COMMAND) { - currCommand = findCommand(currToken.tokenString); - if (currCommand < 0) { - if (noisy) { - cout << "Unidentified Command " << currToken.tokenString << endl; + std::string theCommand = StringToLower(commandString); + if (theCommand.compare("plainstd::string") == 0) { + std::string nextPhrase = getStringTilCommand(tokList); + if (noisy) + cout << "Parsing plain std::string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); + return 1; } - tokList.next(); - addCommand(std::string("partofdescription"), tokList, aNewList); - } else { - tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } else if (currToken.tokenType == PLAINSTRING) { - addCommand(std::string("partofdescription"), tokList, aNewList); - } - } - return aNewList; + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND) { + return addSimpleCommand(theCommand, doxyList); + } + if (commandNumber == IGNOREDSIMPLECOMMAND) { + return ignoreSimpleCommand(theCommand, doxyList); + } + if (commandNumber == COMMANDWORD) { + return addCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDWORD) { + return ignoreCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDLINE) { + return addCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDLINE) { + return ignoreCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDPARAGRAPH) { + return addCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH) { + return ignoreCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDENDCOMMAND) { + return addCommandEndCommand(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDPARAGRAPH) { + return addCommandWordParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDLINE) { + return addCommandWordLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDOWORDWORD) { + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDOWORD) { + return addCommandOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDERRORTHROW) { + return addCommandErrorThrow(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDUNIQUE) { + return addCommandUnique(theCommand, tokList, doxyList); + } + + return 0; +} + +std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList, bool root) { + // if we are root, than any strings should be added as 'partofdescription', else as 'plainstd::string' + std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string"; + std::list < DoxygenEntity > aNewList; + int currCommand; + while (tokList.current() != endParsingIndex) { + Token currToken = tokList.peek(); + if (noisy) + cout << "Parsing for phrase starting in:" << currToken.toString() << endl; + if (currToken.tokenType == END_LINE) { + tokList.next(); + } else if (currToken.tokenType == COMMAND) { + currCommand = findCommand(currToken.tokenString); + if (currCommand < 0) { + if (noisy) + cout << "Unidentified Command " << currToken.tokenString << endl; + tokList.next(); + addCommand(currPlainstringCommandType, tokList, aNewList); + } else { + tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); + } + } else if (currToken.tokenType == PLAINSTRING) { + addCommand(currPlainstringCommandType, tokList, aNewList); + } + } + return aNewList; } std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob) { - TokenList tokList = TokenList(doxygenBlob); - if (noisy) { - cout << "---TOKEN LIST---" << endl; - tokList.printList(); - } - std::list < DoxygenEntity > rootList; - rootList = parseRoot(tokList.end(), tokList); - if (noisy) { - cout << "PARSED LIST" << endl; - printTree(rootList); - } - return rootList; + TokenList tokList = TokenList(doxygenBlob); + if (noisy) { + cout << "---TOKEN LIST---" << endl; + tokList.printList(); + } + std::list < DoxygenEntity > rootList; + rootList = parse(tokList.end(), tokList, true); + if (noisy) { + cout << "PARSED LIST" << endl; + printTree(rootList); + } + return rootList; } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index e64644725..8becdff02 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -213,8 +213,7 @@ private: */ int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList); - std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList); - std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList); + std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList, bool root=false); /* * Fill static doxygenCommands and sectionIndicators containers diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index a3abf100a..7bdda082e 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -16,10 +16,11 @@ #define TAB_SIZE 8 //current tab size in spaces //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -// define static escape table, it is filled in JavaDocConverter's constructor +// define static tables, they are filled in JavaDocConverter's constructor std::map JavaDocConverter::escapeTable; +std::map JavaDocConverter::tagHandlers; -void JavaDocConverter::fillEscapeTable() { +void JavaDocConverter::fillStaticTables() { if (escapeTable.size()) // fill only once return; @@ -28,48 +29,47 @@ void JavaDocConverter::fillEscapeTable() { escapeTable["\""] = """; escapeTable["<"] = "<"; escapeTable[">"] = ">"; + + // these commands insert HTML tags + tagHandlers["c"] = &handleTagC; + tagHandlers["b"] = &handleTagB; + // these commands insert just a single char, some of them need to be escaped + tagHandlers["$"] = &handleTagChar; + tagHandlers["@"] = &handleTagChar; + tagHandlers["\\"] = &handleTagChar; + tagHandlers["<"] = &handleTagChar; + tagHandlers[">"] = &handleTagChar; + tagHandlers["&"] = &handleTagChar; + tagHandlers["#"] = &handleTagChar; + tagHandlers["%"] = &handleTagChar; + tagHandlers["~"] = &handleTagChar; + tagHandlers["\""] = &handleTagChar; + tagHandlers["."] = &handleTagChar; + tagHandlers["::"] = &handleTagChar; + // these commands are stripped out + tagHandlers["brief"] = &handleParagraph; + tagHandlers["details"] = &handleParagraph; + tagHandlers["partofdescription"] = &handleParagraph; + // these commands are kept as-is, they are supported by JavaDoc + tagHandlers["sa"] = &handleTagSeeAll; + tagHandlers["see"] = &handleTagSame; + tagHandlers["param"] = &handleTagSame; + tagHandlers["return"] = &handleTagSame; + tagHandlers["throws"] = &handleTagSame; + tagHandlers["throw"] = &handleTagThrow; + tagHandlers["author"] = &handleTagSame; + tagHandlers["since"] = &handleTagSame; + tagHandlers["version"] = &handleTagSame; + tagHandlers["exception"] = &handleTagSame; + tagHandlers["deprecated"] = &handleTagSame; + // this command just prints it's contents + // (it is internal command of swig's parser, contains plain text) + tagHandlers["plainstd::string"] = &handlePlainString; } JavaDocConverter::JavaDocConverter() : debug(false) { - - fillEscapeTable(); - - // these commands insert HTML tags - tagHandlers["c"] = &handleTagC; - tagHandlers["b"] = &handleTagB; - // these commands insert just a single char, all of them need to be escaped - tagHandlers["$"] = &handleTagChar; - tagHandlers["@"] = &handleTagChar; - tagHandlers["\\"] = &handleTagChar; - tagHandlers["<"] = &handleTagChar; - tagHandlers[">"] = &handleTagChar; - tagHandlers["&"] = &handleTagChar; - tagHandlers["#"] = &handleTagChar; - tagHandlers["%"] = &handleTagChar; - tagHandlers["~"] = &handleTagChar; - tagHandlers["\""] = &handleTagChar; - tagHandlers["."] = &handleTagChar; - tagHandlers["::"] = &handleTagChar; - // these commands are stripped out - tagHandlers["brief"] = &handleTagStrip; - tagHandlers["details"] = &handleTagStrip; - tagHandlers["partofdescription"] = &handleTagStrip; - // these commands are kept as-is, they are supported by JavaDoc - tagHandlers["sa"] = &handleTagSeeAll; - tagHandlers["see"] = &handleTagSame; - tagHandlers["param"] = &handleTagSame; - tagHandlers["return"] = &handleTagSame; - tagHandlers["throws"] = &handleTagSame; - tagHandlers["throw"] = &handleTagThrow; - tagHandlers["author"] = &handleTagSame; - tagHandlers["since"] = &handleTagSame; - tagHandlers["version"] = &handleTagSame; - tagHandlers["exception"] = &handleTagSame; - tagHandlers["deprecated"] = &handleTagSame; - // this command just prints it's contents - // (it is internal command of swig's parser, contains plain text) - tagHandlers["plainstd::string"] = &handleTagData; + fillStaticTables(); } std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { @@ -136,10 +136,10 @@ void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translat } void JavaDocConverter::handleTagC(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += "" + tag.data + ""; + translatedComment += "" + tag.data + " "; } void JavaDocConverter::handleTagB(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += "" + tag.data + ""; + translatedComment += "" + tag.data + " "; } void JavaDocConverter::handleTagThrow(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { tag.typeOfEntity = "throws"; @@ -159,10 +159,10 @@ void JavaDocConverter::handleTagChar(JavaDocConverter* converter, DoxygenEntity& void JavaDocConverter::handleTagSame(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { translatedComment += converter->formatCommand(std::string("@" + tag.typeOfEntity + "\t" + converter->translateSubtree(tag)), 2); } -void JavaDocConverter::handleTagStrip(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { +void JavaDocConverter::handleParagraph(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { translatedComment += converter->formatCommand(converter->translateSubtree(tag), 0); } -void JavaDocConverter::handleTagData(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { +void JavaDocConverter::handlePlainString(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { translatedComment += tag.data + " "; } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 408ec4bb2..9776a17e0 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -53,17 +53,17 @@ protected: /* * Print only the content and strip original tag */ - static void handleTagStrip(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + static void handleParagraph(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); /* * Print only data part of code */ - static void handleTagData(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + static void handlePlainString(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); private: bool debug; - std::map tagHandlers; + static std::map tagHandlers; static std::map escapeTable; - void fillEscapeTable(); + void fillStaticTables(); }; #endif From 92112f69f159ca8ffc2caf21c6815d610a1f27b3 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 13:55:25 +0000 Subject: [PATCH 0068/2031] Refactored java commentParser class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13264 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/commentParser.java | 22 ++++++--------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Examples/test-suite/java/commentParser.java b/Examples/test-suite/java/commentParser.java index 3877f5f4d..1b167cfcd 100644 --- a/Examples/test-suite/java/commentParser.java +++ b/Examples/test-suite/java/commentParser.java @@ -14,30 +14,20 @@ public class commentParser { * file, we get comments and store them */ - ClassDoc[] classes = root.classes(); + for (ClassDoc classDoc : root.classes()) { - for (int i = 0; i < classes.length; i++) { + if (classDoc.getRawCommentText().length() > 0) + parsedComments.put(classDoc.name(), classDoc.getRawCommentText()); - if (classes[i].getRawCommentText().length() > 0) - parsedComments.put(classes[i].name(), - classes[i].getRawCommentText()); - - MethodDoc[] methods = classes[i].methods(); - FieldDoc[] fields = classes[i].fields(); - FieldDoc[] constants = classes[i].enumConstants(); - - for (int j = 0; j < constants.length; j++) { - FieldDoc f = constants[j]; + for (FieldDoc f : classDoc.enumConstants()) { if (f.getRawCommentText().length() > 0) parsedComments.put(f.name(), f.getRawCommentText()); } - for (int j = 0; j < fields.length; j++) { - FieldDoc f = fields[j]; + for (FieldDoc f : classDoc.fields()) { if (f.getRawCommentText().length() > 0) parsedComments.put(f.name(), f.getRawCommentText()); } - for (int j = 0; j < methods.length; j++) { - MethodDoc m = methods[j]; + for (MethodDoc m : classDoc.methods()) { if (m.getRawCommentText().length() > 0) parsedComments.put(m.name(), m.getRawCommentText()); } From 2d47ffc87d2900273b09e837ff24d48e38587f09 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 15:24:35 +0000 Subject: [PATCH 0069/2031] Fixed small bug in DoxygenParser.cpp, now it won't freeze if it doesn't find doxygen ending tag. Also turned debug output off git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13265 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index e7104b9e0..238a6c75b 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -17,7 +17,7 @@ std::map DoxygenParser::doxygenCommands; std::set DoxygenParser::doxygenSectionIndicators; -DoxygenParser::DoxygenParser() : noisy(true) { +DoxygenParser::DoxygenParser() : noisy(false) { fillTables(); } @@ -156,7 +156,8 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL std::string description; if (tokList.peek().tokenType == 0) return ""; - while (tokList.next().tokenString.compare(theCommand) != 0) { + while (tokList.current() != tokList.end() + && tokList.next().tokenString.compare(theCommand) != 0) { //TODO: it won't output doxygen commands, need a way to fix it if (tokList.peek().tokenType == PLAINSTRING) description += tokList.peek().tokenString + " "; From b3f53b98a079ee006a2a95c82d2b853fa413627d Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 7 Jul 2012 18:48:10 +0000 Subject: [PATCH 0070/2031] Added error reporting in case when there is no closing doxygen tag git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13266 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 238a6c75b..623d37658 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -156,13 +156,17 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL std::string description; if (tokList.peek().tokenType == 0) return ""; - while (tokList.current() != tokList.end() - && tokList.next().tokenString.compare(theCommand) != 0) { + while (tokList.next().tokenString.compare(theCommand) != 0) { //TODO: it won't output doxygen commands, need a way to fix it if (tokList.peek().tokenType == PLAINSTRING) description += tokList.peek().tokenString + " "; if (tokList.peek().tokenType == END_LINE) description += "\n"; + + if (tokList.current() == tokList.end()) { + cout << "Error, @" << theCommand << " command expected." << endl; + break; + } } tokList.next(); // eat the end command itself return description; From db3b39bc85dd50a2dff276dd368e0e966d12e22f Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 08:19:17 +0000 Subject: [PATCH 0071/2031] Added project plan to SVN git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13267 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 285 +++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 Doc/Devel/plan-gsoc-2012.txt diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt new file mode 100644 index 000000000..1796bcf78 --- /dev/null +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -0,0 +1,285 @@ + + + + +This document describes goals for the Google Summer of Code 2012, +SWIG code documentation project. + +Author: Marko Klopcic + + +Introduction +============ + +The goal of this project is _not_ to translate _any_ possible doxygen +formatted comment to JavaDoc or PyDoc, but to make it possible to +translate a subset of comment types in C/C++ code to +JavaDoc and PyDoc. Covering all the Doxygen functionality would be to +complex for the limited time. Hovewer, the code must be extendable so +that implementing missing features would not require redesign of the +comment handling code in SWIG. + +There will also be a possiblity to add untranslated comments to Java +and Python code (## comments, see Doxygen manual), if the user will +prefer to use Doxygen on the generated code. + +Abbreviations: + JD - JavaDoc + PD - PyDoc + + +Functionality +============= + + Types of comments + ----------------- + + Note: + See 'http://www.stack.nl/~dimitri/doxygen/docblocks.html' for + the detailed description of Doxygen syntax and terms used in this + section. + + 1. Only JavaDoc (/** */) and Qt (/*! */) styles of comment blocks + will be supported by SWIG translator. + + 2. The following doc after members will be supported: + + int var; ///< Detailed description after the member + //!< + + int var; //!< Brief description after the member + + int var; ///< Brief description after the member + + 3. Only comments before or after declaration/definition will be + supported. Comments with structural commands will be ignored + (warning will be written). (What about writing them to + 'package.info.java' for JD?) + + + Tags + ---- + + This section contains all doxygen tags taken from + http://www.stack.nl/~dimitri/doxygen/commands.html. If a tag is + marked as 'ignored', then the tag is ignored, but the text is copied + to the destination documentation. + + Supported: + + \a - translated to in JD, surrounded with _ in PD + \addindex - ignored + \addtogroup - ignored + \anchor - ignored, not supported by JD and PD + \arg - translated to @param in JD, special formatting in PD + \attention - ignored, content printed out + \authors, \author - translated to @author in JD, 'Author:' in PD + \b - in JD, surrounded with __ in PD + \brief - ignored, content printed out + \bug - ignored, content printed out + \c - translated to in JD, ignored in PD + \callgraph - ignored, not supported by JD and PD + \callergraph - ignored, not supported by JD and PD + \category - ignored, used only in Objective C + \cite - translated to in JD, single quotes in PD + \class - ignored (structural command) + \code - translated to in JD, ignored in PD + \cond - translated to 'Conditional comment: '. Later + SWIG may support definitions of conditions in config file. + \copybrief - ignored. Later SWIG may support this command by + performing copy + \copydetails - ignored. Later SWIG may support this command by + performing copy + \copydoc - ignored. Later SWIG may support this command by + performing copy + \copyright - replaced with text 'Copyright' in PD and PD + \date - ignored, content printed out + \def + \defgroup + \deprecated - translated to @deprecated in JD, 'Deprecated:' in PD + \details - ignored, content printed out + \dir - not supported + \dontinclude - not supported + \dot - not supported. Later SWIG may call dot and produce the graph image to include in JD and PD + \dotfile - see note for \dot + \e - translated to in JD + \else - see note for \cond + \elseif - see note for \cond + \em - translated to in JD + \endcode - see note for \code + \endcond - translated to 'End of conditional comment: '. Later + SWIG may support definitions of conditions in config file. + \enddot - see note for \dot + \endhtmlonly - not supported + \endif - see note for \cond + \endinternal - not supported + \endlatexonly - not supported + \endlink - see note for \link + \endmanonly - not supported + \endmsc - see note for \msc + \endrtfonly - not supported + \endverbatim - see note for \verbatim + \endxmlonly - not supported + \enum - ignored (structural command) + \example - translated to 'Example:' in JD and PD + \exception - equivalent to throws + \extends - not supported + \f$ + \f[ + \f] + \f{ + \f} + \file + \fn + \headerfile + \hideinitializer + \htmlinclude + \htmlonly + \if + \ifnot + \image + \implements + \include + \includelineno + \ingroup + \internal + \invariant + \interface + \latexonly + \li + \line + \link + \mainpage + \manonly + \memberof + \msc + \mscfile + \n + \name + \namespace + \nosubgrouping + \note + \overload + \p + \package + \page + \par + \paragraph + \param + \post + \pre + \private + \privatesection + \property + \protected + \protectedsection + \protocol + \public + \publicsection + \ref - ignored, not supported by JD and PD + \related + \relates + \relatedalso + \relatesalso + \remark + \remarks + \result + \return + \returns + \retval + \rtfonly + \sa + \section + \see + \short + \showinitializer + \since + \skip + \skipline + \snippet + \struct + \subpage + \subsection + \subsubsection + \tableofcontents + \test + \throw + \throws + \todo + \tparam + \typedef + \union + \until + \var + \verbatim + \verbinclude + \version + \warning + \weakgroup + \xmlonly + \xrefitem + \$ + \@ + \\ + \& + \~ + \< + \> + \# + \% + \" + \. + \:: + + +Tests +===== + +The following test cases will be implemented: + +- Class comments, JD and Qt style. +- Class comments, JD and Qt style. + +- Struct comments, JD and Qt style. +- Enum comments, JD and Qt style. + +- Class attributes, JD and Qt style, comment before and after declaration. +- Class methods, JD and Qt style, comment of parameters in function + comment. +- Class methods, JD and Qt style, comment of parameters + after parameter declaration. + +- Struct attributes, JD and Qt style, comment before and after declaration. +- Struct methods, JD and Qt style, comment of parameters in function + comment. +- Struct methods, JD and Qt style, comment of parameters + after parameter declaration. + +- Enum items JD and Qt style, comment before items +- Enum items JD and Qt style, comment after items + +- Class comment, JD and Qt style, with all supported tags. +- Class comment, JD and Qt style, with all doxygen tags, including + ignored ones. + + +Refactoring +=========== + +All the code in directory _DoxygenTranslator_ should be refactored: +- all methods should be class members +- most static methods should be normal members +- replace C arrays of strings and sequential searches with STL data + structures and algorithms. +- use singletons instead of class instantiaion for each comment found. + + +Documentation +============= + +SWIG documentation will contain: +- command line options +- list of implemented features (types and placements of comments) +- list of unimplemented features (types and placements of comments) +- list of tags and their translations (all Doxygen tags). + From 0e2f37bc544dd0fbaad632ef4101dc1d7e44cae0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 10:11:29 +0000 Subject: [PATCH 0072/2031] Extended project plan, now it is also the description of how are the doxygen tags translated git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13269 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 218 ++++++++++++++++++----------------- 1 file changed, 114 insertions(+), 104 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 1796bcf78..faf9359f9 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -64,19 +64,22 @@ Functionality http://www.stack.nl/~dimitri/doxygen/commands.html. If a tag is marked as 'ignored', then the tag is ignored, but the text is copied to the destination documentation. + Not all of the tags are currently implemented. The status of + implementation and time estimation for every tag may be seen in + plan-gsoc-2012-timings.txt - Supported: + Doxygen tags: \a - translated to in JD, surrounded with _ in PD \addindex - ignored \addtogroup - ignored \anchor - ignored, not supported by JD and PD \arg - translated to @param in JD, special formatting in PD - \attention - ignored, content printed out + \attention - ignored \authors, \author - translated to @author in JD, 'Author:' in PD \b - in JD, surrounded with __ in PD - \brief - ignored, content printed out - \bug - ignored, content printed out + \brief - ignored + \bug - ignored \c - translated to in JD, ignored in PD \callgraph - ignored, not supported by JD and PD \callergraph - ignored, not supported by JD and PD @@ -93,132 +96,139 @@ Functionality \copydoc - ignored. Later SWIG may support this command by performing copy \copyright - replaced with text 'Copyright' in PD and PD - \date - ignored, content printed out + \date - ignored \def \defgroup \deprecated - translated to @deprecated in JD, 'Deprecated:' in PD - \details - ignored, content printed out + \details - ignored \dir - not supported \dontinclude - not supported - \dot - not supported. Later SWIG may call dot and produce the graph image to include in JD and PD + \dot - not supported. Later SWIG may call dot and produce the graph image + to include in JD and PD \dotfile - see note for \dot - \e - translated to in JD + \e - equivalent \a \else - see note for \cond \elseif - see note for \cond - \em - translated to in JD + \em - equivalent to \a \endcode - see note for \code \endcond - translated to 'End of conditional comment: '. Later SWIG may support definitions of conditions in config file. \enddot - see note for \dot - \endhtmlonly - not supported + \endhtmlonly - ignored \endif - see note for \cond - \endinternal - not supported - \endlatexonly - not supported + \endinternal - ignored + \endlatexonly - ignored \endlink - see note for \link - \endmanonly - not supported + \endmanonly - ignored \endmsc - see note for \msc - \endrtfonly - not supported + \endrtfonly - ignored \endverbatim - see note for \verbatim - \endxmlonly - not supported + \endxmlonly - ignored \enum - ignored (structural command) \example - translated to 'Example:' in JD and PD - \exception - equivalent to throws + \exception - equivalent to throws, but translates to @exception in JD \extends - not supported \f$ \f[ \f] \f{ \f} - \file + \file \fn - \headerfile - \hideinitializer - \htmlinclude - \htmlonly - \if - \ifnot - \image - \implements - \include - \includelineno - \ingroup - \internal - \invariant - \interface - \latexonly - \li - \line - \link - \mainpage - \manonly - \memberof - \msc - \mscfile - \n - \name - \namespace - \nosubgrouping - \note - \overload - \p - \package - \page - \par - \paragraph - \param - \post - \pre - \private - \privatesection - \property - \protected - \protectedsection - \protocol - \public - \publicsection + \headerfile - not supported + \hideinitializer - not supported + \htmlinclude - not supported + \htmlonly - not supported + \if - see note for \cond + \ifnot - see note for \cond + \image - translated to in JD only when target=HTML, ignored in PD + \implements - not supported + \include - not supported + \includelineno - not supported + \ingroup - not supported. Later swig may print group names as plain text + in comments like 'Code group: something' in both JD and PD + \internal - ignored + \invariant - ignored + \interface - ignored (structural command) + \latexonly - ignored + \li - trabslated to
  • in JD, ignored in PD + \line - not supported + \link - translated to {@link ...} in JD, ignored in PD + \mainpage - ignored + \manonly - ignored + \memberof - not supported + \msc - not supported. Later SWIG may call dot and produce the graph image + to include in JD and PD + \mscfile - see note for \msc + \n - prints the new line + \name - ignored + \namespace - included in package-info.java if nspace feature is enabled, + otherwise ignored, ignored in PD + \nosubgrouping - ignored + \note - ignored in JD, translated to 'Note:' in PD + \overload - prints 'This is an overloaded member function, provided for + convenience. It differs from the above function only in what + argument(s) it accepts.' to the output in both JD and PD + \p - equivalent to \c + \package - is kept same in JD (it is already a JD tag), ignored in PD + \page - ignored + \par - translated to

    in JD, 'Title: ...' in PD + \paragraph - ignored + \param - equivalent to \arg + \post - ignored + \pre - ignored + \private - ignored + \privatesection - ignored + \property - ignored + \protected - ignored + \protectedsection - ignored + \protocol - ignored (Objective-C tag) + \public - ignored + \publicsection - ignored \ref - ignored, not supported by JD and PD - \related - \relates - \relatedalso - \relatesalso - \remark - \remarks - \result - \return - \returns - \retval - \rtfonly - \sa - \section - \see - \short - \showinitializer - \since - \skip - \skipline - \snippet - \struct - \subpage - \subsection - \subsubsection - \tableofcontents - \test - \throw - \throws - \todo - \tparam - \typedef - \union - \until - \var - \verbatim - \verbinclude - \version - \warning - \weakgroup - \xmlonly - \xrefitem - \$ + \related - ignored + \relates - ignored + \relatedalso - ignored + \relatesalso - ignored + \remark - translated to 'Remarks:' in both JD and PD + \remarks - equivalent to remark + \result - translated to @return in JD, 'Return:' in PD + \return - equivalent to result + \returns - equivalent to result + \retval - ignored + \rtfonly - ignored + \sa - translated to @see in JD, 'See also:' in PD + \section - not supported + \see - equivalent to \sa + \short - equivalent to \brief + \showinitializer - not supported + \since - translated to @since in JD, 'Since:' in PD + \skip - not supported + \skipline - not supported + \snippet - not supported + \struct - ignored (structural command) + \subpage - not supported + \subsection - not supported + \subsubsection - not supported + \tableofcontents - not supported + \test - ignored + \throw - translated to @throws in JD, 'Throws:' in PD + \throws - equivalent to \throw + \todo - translated to 'TODO:' in both JD and PD + \tparam - similar to \arg + \typedef - ignored (structural command) + \union - ignored (structural command) + \until - not supported + \var - ignored (structural command) + \verbatim - translated to {@literal ...} in JD, ignored in PD + \verbinclude - ignored + \version - translated to @version in JD, 'Version:' in PD + \warning - translated to 'Warning:' in both JD and PD + \weakgroup - not supported + \xmlonly - ignored + \xrefitem - ignored + \$ - this and all the others below: these commands insert single char, + it is escaped as HTML char in JD, kept as-is in PD \@ \\ \& From 32166f96f4b44d18d823a208ebf5b732f8e02041 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 11:08:56 +0000 Subject: [PATCH 0073/2031] New fixes for the project plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13273 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index faf9359f9..570457e1a 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -23,6 +23,10 @@ There will also be a possiblity to add untranslated comments to Java and Python code (## comments, see Doxygen manual), if the user will prefer to use Doxygen on the generated code. +Note: +time format below is HH:MM. '--Done' tick means that the item is +implemented, commited and working. + Abbreviations: JD - JavaDoc PD - PyDoc @@ -41,6 +45,7 @@ Functionality 1. Only JavaDoc (/** */) and Qt (/*! */) styles of comment blocks will be supported by SWIG translator. + --Done 2. The following doc after members will be supported: @@ -50,11 +55,14 @@ Functionality int var; //!< Brief description after the member int var; ///< Brief description after the member + + --Done 3. Only comments before or after declaration/definition will be supported. Comments with structural commands will be ignored (warning will be written). (What about writing them to 'package.info.java' for JD?) + --Done Tags @@ -63,10 +71,8 @@ Functionality This section contains all doxygen tags taken from http://www.stack.nl/~dimitri/doxygen/commands.html. If a tag is marked as 'ignored', then the tag is ignored, but the text is copied - to the destination documentation. - Not all of the tags are currently implemented. The status of - implementation and time estimation for every tag may be seen in - plan-gsoc-2012-timings.txt + to the destination documentation. 'Not implemented' means that the + tag with it's contents is stripped out of the output. Doxygen tags: @@ -97,8 +103,8 @@ Functionality performing copy \copyright - replaced with text 'Copyright' in PD and PD \date - ignored - \def - \defgroup + \def - ignored (structural command) + \defgroup - not supported \deprecated - translated to @deprecated in JD, 'Deprecated:' in PD \details - ignored \dir - not supported @@ -128,13 +134,14 @@ Functionality \example - translated to 'Example:' in JD and PD \exception - equivalent to throws, but translates to @exception in JD \extends - not supported - \f$ - \f[ - \f] - \f{ - \f} - \file - \fn + \f$ - not supported. Later swig may call LATeX to produce bitmaps with formulas + to include in JD and PD + \f[ - see note for \f$ + \f] - see note for \f$ + \f{ - see note for \f$ + \f} - see note for \f$ + \file - ignored (structural command) + \fn - ignored (structural command) \headerfile - not supported \hideinitializer - not supported \htmlinclude - not supported From 3a3c2b8063154316a51c4fa3f22bfd1382366ae4 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 13:56:45 +0000 Subject: [PATCH 0074/2031] Extended commentParser.java to the standalone java app to print parsed comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13274 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/commentParser.java | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Examples/test-suite/java/commentParser.java b/Examples/test-suite/java/commentParser.java index 1b167cfcd..93785669e 100644 --- a/Examples/test-suite/java/commentParser.java +++ b/Examples/test-suite/java/commentParser.java @@ -58,4 +58,28 @@ public class commentParser { return errorCount; } + + public static void printCommentListForJavaSource() { + Iterator< Entry > it = parsedComments.entrySet().iterator(); + while (it.hasNext()) + { + Entry e = (Entry) it.next(); + System.out.format("wantedComments.put(\"%s\", \"%s\");\n", e.getKey(), e.getValue()); + } + } + + public static void main(String argv[]) { + + if (argv.length<1) { + System.out.format("Usage:\n\tcommentParsing \n"); + System.exit(1); + } + + com.sun.tools.javadoc.Main.execute("The comment parser program", + "commentParser", new String[]{"-quiet", argv[0]}); + + // if we are run as standalone app, print the list of found comments as it would appear in java source + + printCommentListForJavaSource(); + } } \ No newline at end of file From dc432411301cd18f5591cebe70e4f660c496f649 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 14:02:23 +0000 Subject: [PATCH 0075/2031] Rewritten doxygen_parsing.cpptest according to the project plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13275 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_parsing.i | 152 +++++++++++------- Examples/test-suite/doxygen_parsing_enums.i | 36 ++++- .../doxygen_parsing_enums_proper_runme.java | 12 +- .../doxygen_parsing_enums_simple_runme.java | 9 +- .../doxygen_parsing_enums_typesafe_runme.java | 12 +- ...oxygen_parsing_enums_typeunsafe_runme.java | 12 +- .../java/doxygen_parsing_runme.java | 44 ++--- .../python/doxygen_parsing_runme.py | 37 +++-- 8 files changed, 207 insertions(+), 107 deletions(-) diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index a83cd77ed..b4579c886 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -3,77 +3,119 @@ %inline %{ /** - * This is simple comment for a var + * The class comment */ -int simpleVar=42; -/*! - * This is another type of comment for a var - */ -int simpleVarTwo=42; - -/// This is again another type of comment for a var -int simpleVarThree=42; -//! This is the last type of comment for a var -int simpleVarFour=42; - -int simpleVarFive=42; -///< This is a post comment - -/* - We assume that all this comment types are ok, - and later we only use the first-type comments. -*/ - +class SomeClass +{ +}; /** - * This is simple comment for a function + * The function comment */ -void simpleFunction(int arg) +void someFunction() { } /** - * This is simple comment for a class + * The enum comment */ -class CSimpleClass +enum SomeEnum { -private: - /** Some member var */ - int simpleVar; - -public: - /** - * Simple method - */ - void simpleMethod(int asd) - { - } - /** - * Simple method with parameter - */ - void simpleMethodWithParameter( - int param, /**< Some test param */ - int argument /**< Some test argument */ - ) - { - } + SOME_ENUM_ITEM }; /** - * Comment for template class + * The struct comment */ -template -class CTemplateClass +struct SomeStruct +{ +}; + +/** + * The var comment + */ +int someVar=42; + +class SomeAnotherClass { public: - /** - * Template method - */ - void templateMethod(T arg) - { - } + + /** + * The class attribute comment + */ + int classAttr; + + int classAttr2; ///< The class attribute post-comment + + int classAttr3; ///< The class attribute post-comment + //!< with details + + /** + * The class method comment + */ + void classMethod() + { + } + + /** + * The class method with parameter + */ + void classMethodExtended( + int a, ///< Parameter a + int b ///< Parameter b + ) + { + } + + /** + * The class method with parameter + * + * @param a Parameter a + * @param b Parameter b + */ + void classMethodExtended2(int a, int b) + { + } +}; + +struct SomeAnotherStruct +{ + /** + * The struct attribute comment + */ + int structAttr; + + int structAttr2; ///< The struct attribute post-comment + + int structAttr3; ///< The struct attribute post-comment + //!< with details + + /** + * The struct method comment + */ + void structMethod() + { + } + + /** + * The struct method with parameter + */ + void structMethodExtended( + int a, ///< Parameter a + int b ///< Parameter b + ) + { + } + + /** + * The struct method with parameter + * + * @param a Parameter a + * @param b Parameter b + */ + void structMethodExtended2(int a, int b) + { + } }; %} - -%template(CTemplateClassInt) CTemplateClass; \ No newline at end of file diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i index 222356510..5c48f4801 100644 --- a/Examples/test-suite/doxygen_parsing_enums.i +++ b/Examples/test-suite/doxygen_parsing_enums.i @@ -3,13 +3,33 @@ %inline %{ -/** Test enumeration */ -enum E_TEST -{ - /** the first item */ - E_TEST_ONE, - E_TEST_TWO = 2, /**< the second */ - E_TEST_THREE = 2+1 /**< the last item */ -}; + /** + * Testing comments before enum items + */ + enum SomeAnotherEnum + { + /** + * The comment for the first item + */ + SOME_ITEM_1, + /** + * The comment for the second item + */ + SOME_ITEM_2, + /** + * The comment for the third item + */ + SOME_ITEM_3 + }; + + /** + * Testing comments after enum items + */ + enum SomeAnotherEnum2 + { + SOME_ITEM_10, ///< Post comment for the first item + SOME_ITEM_20, ///< Post comment for the second item + SOME_ITEM_30 ///< Post comment for the third item + }; %} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index d3993f201..4531ada51 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -25,10 +25,14 @@ public class doxygen_parsing_enums_proper_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("E_TEST", " Test enumeration \n"); - wantedComments.put("E_TEST_ONE", " the first item \n"); - wantedComments.put("E_TEST_TWO", " the second \n"); - wantedComments.put("E_TEST_THREE", " the last item \n"); + wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); + wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); + wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); + wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); + wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); + wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); + wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); + wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index 1dffe4466..7fba76d5c 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -25,9 +25,12 @@ public class doxygen_parsing_enums_simple_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("E_TEST_ONE", " the first item \n"); - wantedComments.put("E_TEST_TWO", " the second \n"); - wantedComments.put("E_TEST_THREE", " the last item \n"); + wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); + wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); + wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); + wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); + wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); + wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index 5aed9327e..f853ffb3b 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -25,10 +25,14 @@ public class doxygen_parsing_enums_typesafe_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("E_TEST", " Test enumeration \n"); - wantedComments.put("E_TEST_ONE", " the first item \n"); - wantedComments.put("E_TEST_TWO", " the second \n"); - wantedComments.put("E_TEST_THREE", " the last item \n"); + wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); + wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); + wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); + wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); + wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); + wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); + wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); + wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index 44405f837..9788ae1d3 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -25,10 +25,14 @@ public class doxygen_parsing_enums_typeunsafe_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("E_TEST", " Test enumeration \n"); - wantedComments.put("E_TEST_ONE", " the first item \n"); - wantedComments.put("E_TEST_TWO", " the second \n"); - wantedComments.put("E_TEST_THREE", " the last item \n"); + wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); + wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); + wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); + wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); + wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); + wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); + wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); + wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index ae426da58..e0719c586 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -25,26 +25,30 @@ public class doxygen_parsing_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("simpleFunction", " This is simple comment for a function \n"); - - wantedComments.put("CSimpleClass", " This is simple comment for a class \n"); - wantedComments.put("simpleMethod", " Simple method \n"); - wantedComments.put("simpleMethodWithParameter", " Simple method with parameter \n" + - " @param\tparam Some test param \n" + - " @param\targument Some test argument \n"); - wantedComments.put("CTemplateClassInt", " Comment for template class \n"); - wantedComments.put("templateMethod", " Template method \n"); - - wantedComments.put("setSimpleVar", " This is simple comment for a var \n"); - wantedComments.put("getSimpleVar", " This is simple comment for a var \n"); - wantedComments.put("setSimpleVarTwo", " This is another type of comment for a var \n"); - wantedComments.put("getSimpleVarTwo", " This is another type of comment for a var \n"); - wantedComments.put("setSimpleVarThree", " This is again another type of comment for a var \n"); - wantedComments.put("getSimpleVarThree", " This is again another type of comment for a var \n"); - wantedComments.put("setSimpleVarFour", " This is the last type of comment for a var \n"); - wantedComments.put("getSimpleVarFour", " This is the last type of comment for a var \n"); - wantedComments.put("setSimpleVarFive", " This is a post comment \n"); - wantedComments.put("getSimpleVarFive", " This is a post comment \n"); + wantedComments.put("someFunction", " The function comment \n"); + wantedComments.put("SomeEnum", " The enum comment \n"); + wantedComments.put("setSomeVar", " The var comment \n"); + wantedComments.put("getSomeVar", " The var comment \n"); + wantedComments.put("SomeClass", " The class comment \n"); + wantedComments.put("setClassAttr", " The class attribute comment \n"); + wantedComments.put("getClassAttr", " The class attribute comment \n"); + wantedComments.put("setClassAttr2", " The class attribute post-comment \n"); + wantedComments.put("getClassAttr2", " The class attribute post-comment \n"); + wantedComments.put("setClassAttr3", " The class attribute post-comment with details \n"); + wantedComments.put("getClassAttr3", " The class attribute post-comment with details \n"); + wantedComments.put("classMethod", " The class method comment \n"); + wantedComments.put("classMethodExtended", " The class method with parameter \n @param a Parameter a \n @param b Parameter b \n"); + wantedComments.put("classMethodExtended2", " The class method with parameter \n @param a Parameter a \n @param b Parameter b \n"); + wantedComments.put("SomeStruct", " The struct comment \n"); + wantedComments.put("setStructAttr", " The struct attribute comment \n"); + wantedComments.put("getStructAttr", " The struct attribute comment \n"); + wantedComments.put("setStructAttr2", " The struct attribute post-comment \n"); + wantedComments.put("getStructAttr2", " The struct attribute post-comment \n"); + wantedComments.put("setStructAttr3", " The struct attribute post-comment with details \n"); + wantedComments.put("getStructAttr3", " The struct attribute post-comment with details \n"); + wantedComments.put("structMethod", " The struct method comment \n"); + wantedComments.put("structMethodExtended", " The struct method with parameter \n @param a Parameter a \n @param b Parameter b \n"); + wantedComments.put("structMethodExtended2", " The struct method with parameter \n @param a Parameter a \n @param b Parameter b \n"); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index 097c18f8c..b814a68ed 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -8,13 +8,32 @@ def check(got, expected): if not re.match(str(expected), str(got)): raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") -check(doxygen_parsing.simpleFunction.__doc__, '\s+This is simple comment for a function\s+') -check(doxygen_parsing.CSimpleClass.__doc__, '\s+This is simple comment for a class\s+') -check(doxygen_parsing.CSimpleClass.simpleMethod.__doc__, '\s+Simple method\s+') -check(doxygen_parsing.CSimpleClass.simpleMethodWithParameter.__doc__, '' -'\s+Simple method with parameter' -'\s+Arguments:\s+param \(int\)\s+-- Some test param\s+' -'argument \(int\)\s+-- Some test argument\s+' +check(doxygen_parsing.someFunction.__doc__, '\s+The function comment\s+') +check(doxygen_parsing.SomeClass.__doc__, '\s+The class comment\s+') +check(doxygen_parsing.SomeStruct.__doc__, '\s+The struct comment\s+') +check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__, '\s+The class method comment\s+') +check(doxygen_parsing.SomeAnotherClass.classMethodExtended.__doc__, '' +'\s+The class method with parameter' +'\s+Arguments:\s+' +'a \(int\)\s+-- Parameter a\s+' +'b \(int\)\s+-- Parameter b\s+' ) -check(doxygen_parsing.CTemplateClassInt.__doc__, '\s+Comment for template class\s+') -check(doxygen_parsing.CTemplateClassInt.templateMethod.__doc__, '\s+Template method\s+') \ No newline at end of file +check(doxygen_parsing.SomeAnotherClass.classMethodExtended2.__doc__, '' +'\s+The class method with parameter' +'\s+Arguments:\s+' +'a \(int\)\s+-- Parameter a\s+' +'b \(int\)\s+-- Parameter b\s+' +) +check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__, '\s+The struct method comment\s+') +check(doxygen_parsing.SomeAnotherStruct.structMethodExtended.__doc__, '' +'\s+The struct method with parameter' +'\s+Arguments:\s+' +'a \(int\)\s+-- Parameter a\s+' +'b \(int\)\s+-- Parameter b\s+' +) +check(doxygen_parsing.SomeAnotherStruct.structMethodExtended2.__doc__, '' +'\s+The struct method with parameter' +'\s+Arguments:\s+' +'a \(int\)\s+-- Parameter a\s+' +'b \(int\)\s+-- Parameter b\s+' +) \ No newline at end of file From 9404bb442cf333b11603c6409871c93cdf16a631 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 9 Jul 2012 21:30:11 +0000 Subject: [PATCH 0076/2031] Added optional functionality section to the project plan. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13309 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 61 +++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 570457e1a..f9b6849c5 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -24,8 +24,8 @@ and Python code (## comments, see Doxygen manual), if the user will prefer to use Doxygen on the generated code. Note: -time format below is HH:MM. '--Done' tick means that the item is -implemented, commited and working. +'--Done' tick below means that the item is implemented, commited and +working. Abbreviations: JD - JavaDoc @@ -248,35 +248,54 @@ Functionality \. \:: - +Optional functionality +====================== + +That section describes some complex cases where the current code +not behaves really well. Like a short to-do list of special cases. + +- When translating functions with default parameters in swig to +java, it creates overloaded functions with all the parameters +except the default ones. We need to copy the doxygen comment to +such functions and correct the list of @param tags. + +- In doxygen there is a special tags (and even a special option) +to create links to some code members from the current comment. +Sometimes it needs a type of parameters specified because of the +overloaded functions. And the same linking tags are supported in JD, +but it has a completely different typesystem, so we need to translate +the types of function parameters in comments also. For example: + + Tests ===== The following test cases will be implemented: -- Class comments, JD and Qt style. -- Class comments, JD and Qt style. +- Class comments. --Done -- Struct comments, JD and Qt style. -- Enum comments, JD and Qt style. +- Struct comments. --Done +- Enum comments. --Done +- Function comments. --Done +- Var comments. --Done -- Class attributes, JD and Qt style, comment before and after declaration. -- Class methods, JD and Qt style, comment of parameters in function - comment. -- Class methods, JD and Qt style, comment of parameters - after parameter declaration. +- Class attributes, comment before and after declaration. --Done +- Class methods, comment of parameters in function + comment. --Done +- Class methods, comment of parameters + after parameter declaration. --Done -- Struct attributes, JD and Qt style, comment before and after declaration. -- Struct methods, JD and Qt style, comment of parameters in function - comment. -- Struct methods, JD and Qt style, comment of parameters - after parameter declaration. +- Struct attributes, comment before and after declaration. --Done +- Struct methods, comment of parameters in function + comment. --Done +- Struct methods, comment of parameters + after parameter declaration. --Done -- Enum items JD and Qt style, comment before items -- Enum items JD and Qt style, comment after items +- Enum items JD and Qt style, comment before items --Done +- Enum items JD and Qt style, comment after items --Done -- Class comment, JD and Qt style, with all supported tags. -- Class comment, JD and Qt style, with all doxygen tags, including +- Class comment, with all supported tags. +- Class comment, with all doxygen tags, including ignored ones. From ed1bd4fbb98662886ccd493a58891dcb65a4428b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Tue, 10 Jul 2012 17:17:51 +0000 Subject: [PATCH 0077/2031] Implemented nice error output, with filename and line number information. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13313 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 4 ++ .../DoxygenTranslator/src/DoxygenParser.cpp | 37 +++++++++--------- Source/DoxygenTranslator/src/DoxygenParser.h | 2 +- .../src/JavaDocConverter.cpp | 6 ++- .../DoxygenTranslator/src/PyDocConverter.cpp | 4 +- Source/DoxygenTranslator/src/TokenList.cpp | 39 ++++++------------- Source/DoxygenTranslator/src/TokenList.h | 6 ++- 7 files changed, 46 insertions(+), 52 deletions(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 44af1069b..e15201b93 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -344,11 +344,15 @@ static int yylook(void) { if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ yylval.str = NewString(loc); + Setline(yylval.str, Scanner_start_line(scan)); + Setfile(yylval.str, Scanner_file(scan)); return DOXYGENPOSTSTRING; } if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ yylval.str = NewString(loc); + Setline(yylval.str, Scanner_start_line(scan)); + Setfile(yylval.str, Scanner_file(scan)); return DOXYGENSTRING; } } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 623d37658..4106cad44 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -156,19 +156,22 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL std::string description; if (tokList.peek().tokenType == 0) return ""; - while (tokList.next().tokenString.compare(theCommand) != 0) { + while (tokList.current() != tokList.end()) { + //TODO: it won't output doxygen commands, need a way to fix it if (tokList.peek().tokenType == PLAINSTRING) description += tokList.peek().tokenString + " "; if (tokList.peek().tokenType == END_LINE) description += "\n"; - if (tokList.current() == tokList.end()) { - cout << "Error, @" << theCommand << " command expected." << endl; - break; + if (tokList.peek().tokenString.compare(theCommand) == 0) { + tokList.next(); + return description; } + + tokList.next(); } - tokList.next(); // eat the end command itself + tokList.printListError(theCommand + " command expected"); return description; } @@ -263,7 +266,7 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; } else - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } @@ -275,7 +278,7 @@ int DoxygenParser::ignoreCommandWord(std::string theCommand, TokenList & tokList if (!name.empty()) return 1; else - cout << "WARNING: No word followed " << theCommand << " command." << endl; + tokList.printListError("No word followed " + theCommand + " command."); return 0; } @@ -329,7 +332,7 @@ int DoxygenParser::addCommandWordParagraph(std::string theCommand, TokenList & t cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); @@ -345,7 +348,7 @@ int DoxygenParser::addCommandWordLine(std::string theCommand, TokenList & tokLis cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } std::list < Token >::iterator endOfLine = getOneLine(tokList); @@ -362,7 +365,7 @@ int DoxygenParser::addCommandWordOWordOWord(std::string theCommand, TokenList & cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } std::string headerfile = getNextWord(tokList); @@ -387,10 +390,8 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) { - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } + tokList.printListError("Encountered: " + theCommand + + "\nThis command should not have been encountered. Behaviour past this may be unpredictable"); std::list < Token >::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 0; @@ -464,7 +465,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } std::list < DoxygenEntity > aNewList; @@ -509,7 +510,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; + tokList.printListError("No word followed " + theCommand + " command. Not added"); return 0; } std::list < DoxygenEntity > aNewList; @@ -611,8 +612,8 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e return aNewList; } -std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob) { - TokenList tokList = TokenList(doxygenBlob); +std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob, std::string fileName, int lineNumber) { + TokenList tokList(doxygenBlob, fileName, lineNumber); if (noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 8becdff02..c72ca6fed 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -21,7 +21,7 @@ class DoxygenParser { public: DoxygenParser(); virtual ~DoxygenParser(); - std::list < DoxygenEntity > createTree(std::string doxygen); + std::list < DoxygenEntity > createTree(std::string doxygen, std::string fileName, int lineNumber); private: /* diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 7bdda082e..2bc3165f4 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -163,7 +163,9 @@ void JavaDocConverter::handleParagraph(JavaDocConverter* converter, DoxygenEntit translatedComment += converter->formatCommand(converter->translateSubtree(tag), 0); } void JavaDocConverter::handlePlainString(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += tag.data + " "; + translatedComment += tag.data; + if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') + translatedComment += " "; } String *JavaDocConverter::makeDocumentation(Node *node) { @@ -174,7 +176,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { return NULL; } - std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation)); + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); // entityList.sort(CompareDoxygenEntities()); sorting currently not used, // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index b1e94a062..819c6bc6c 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -170,7 +170,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { while (n) { documentation = getDoxygenComment(n); if (!Swig_is_generated_overload(n) && documentation) { - std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); allDocumentation.push_back(processEntityList(n, entityList)); } n = Getattr(n, "sym:nextSibling"); @@ -194,7 +194,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { else { documentation = getDoxygenComment(n); if (documentation != NULL) { - std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); pyDocString = processEntityList(n, entityList); } } diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 5e13fe164..8624fb4a2 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -14,6 +14,7 @@ #include #include #include +#include "swig.h" #include "Token.h" #include "DoxygenEntity.h" #define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list @@ -22,37 +23,11 @@ using namespace std; int noisy2 = 0; /* The tokenizer*/ -TokenList::TokenList(const std::string & doxygenStringConst) { +TokenList::TokenList(const std::string & doxygenStringConst, const std::string fileName, int fileLine) + : fileName(fileName), fileLine(fileLine) { size_t commentPos; string doxygenString = doxygenStringConst; - /* Comment start tokens are replaced in parser.y, see doxygen_comment and - doxygen_post_comment_item - do { - commentPos = doxygenString.find("///<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/**<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/*!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("//!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - break; - } while (true); - */ - size_t currentIndex = 0; size_t nextIndex = 0; @@ -174,3 +149,11 @@ void TokenList::printList() { i++; } } + +void TokenList::printListError(std::string message) { + int curLine = fileLine; + for (list< Token >::iterator it = m_tokenList.begin(); it != current(); it++) + if (it->tokenType == END_LINE) + curLine++; + Swig_error(fileName.c_str(), curLine, "Doxygen parser error: %s. \n", message.c_str()); +} diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index 057f67ed4..d38fec792 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -25,9 +25,12 @@ class TokenList { private: std::list < Token > m_tokenList; std::list < Token >::iterator m_tokenListIter; + // location info for error output + std::string fileName; + int fileLine; public: - TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */ + TokenList(const std::string & doxygenString, const std::string fileName, int fileLine); /* constructor takes a blob of Doxygen comment */ ~TokenList(); Token peek(); /* returns next token without advancing */ @@ -40,6 +43,7 @@ public: void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */ void printList(); /* prints out the sequence of tokens */ + void printListError(std::string message); /* prints properly formatted error message */ }; #endif From be2116603477e83f708fd9151fac745eec6b41e0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 11 Jul 2012 22:24:36 +0000 Subject: [PATCH 0078/2031] Added parsing support for some new commands git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13314 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenCommands.h | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index e1eba33f4..93898193c 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -4,8 +4,8 @@ const char *commandArray[] = { "a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "author", "authors", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "cite", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "copyright", "date", "def", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", @@ -15,21 +15,21 @@ const char *commandArray[] = { "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "remark", "result", "return", "returns", "retval", "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; const char *sectionIndicators[] = { - "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "attention", "author", "authors", "brief", "bug", "cond", "date", "deprecated", "details", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; + "tparam", "post", "pre", "remarks", "remark", "result", "return", "returns", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionIndicators); /* All of the doxygen commands divided up by how they are parsed */ const char *simpleCommands[] = { - "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; + "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond"}; const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands); const char *ignoredSimpleCommands[] = { @@ -37,7 +37,8 @@ const char *ignoredSimpleCommands[] = { const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); const char *commandWords[] = { - "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; + "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", + "includelineno"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); const char *ignoredCommandWords[] = { @@ -53,8 +54,9 @@ const char *ignoreCommandLines[] = { const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); const char *commandParagraph[] = { - "partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; + "partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "cite", + "copyright"}; const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); const char *ignoreCommandParagraphs[] = { @@ -62,7 +64,7 @@ const char *ignoreCommandParagraphs[] = { const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); const char *commandEndCommands[] = { - "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; + "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "if", "ifnot", "link"}; const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const char *commandWordParagraphs[] = { @@ -85,11 +87,11 @@ const char *commandErrorThrowings[] = { "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif"}; const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); const char *commandUniques[] = { "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); -#endif \ No newline at end of file +#endif From c461f1110d9a4351913c37ee84e9d37a0c406118 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 11 Jul 2012 22:25:34 +0000 Subject: [PATCH 0079/2031] Small fixes to the project plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13315 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index f9b6849c5..a32878375 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -80,7 +80,7 @@ Functionality \addindex - ignored \addtogroup - ignored \anchor - ignored, not supported by JD and PD - \arg - translated to @param in JD, special formatting in PD + \arg - equivalent to \li \attention - ignored \authors, \author - translated to @author in JD, 'Author:' in PD \b - in JD, surrounded with __ in PD @@ -134,7 +134,7 @@ Functionality \example - translated to 'Example:' in JD and PD \exception - equivalent to throws, but translates to @exception in JD \extends - not supported - \f$ - not supported. Later swig may call LATeX to produce bitmaps with formulas + \f$ - ignored. Later swig may call LATeX to produce bitmaps with formulas to include in JD and PD \f[ - see note for \f$ \f] - see note for \f$ @@ -145,7 +145,7 @@ Functionality \headerfile - not supported \hideinitializer - not supported \htmlinclude - not supported - \htmlonly - not supported + \htmlonly - ignored \if - see note for \cond \ifnot - see note for \cond \image - translated to in JD only when target=HTML, ignored in PD @@ -181,7 +181,7 @@ Functionality \page - ignored \par - translated to

    in JD, 'Title: ...' in PD \paragraph - ignored - \param - equivalent to \arg + \param - translated to @param in JD, special formatting in PD \post - ignored \pre - ignored \private - ignored From 5500046b09468d7b86e43c7f9f284969b8d754dc Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 11 Jul 2012 22:27:34 +0000 Subject: [PATCH 0080/2031] Added testcase with a set of all supported doxygen tags git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13316 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_translate.i | 115 ++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Examples/test-suite/doxygen_translate.i diff --git a/Examples/test-suite/doxygen_translate.i b/Examples/test-suite/doxygen_translate.i new file mode 100644 index 000000000..5f3bd1b39 --- /dev/null +++ b/Examples/test-suite/doxygen_translate.i @@ -0,0 +1,115 @@ +%module doxygen_translate + +%inline %{ + +/** + * \a Hello + * + * \arg some list item + * + * \authors lots of them + * + * \author Zubr + * + * \b boldword + * + * \c codeword + * + * \cite citationword + * + * \code some test code \endcode + * + * \cond SOMECONDITION + * Some conditional comment + * \endcond + * + * \copyright some copyright + * + * \deprecated Now use another function + * + * \e italicword + * + * \if ANOTHERCONDITION + * First part of comment + * \else + * Second part of comment + * \endif + * + * \example someFile.txt + * Some details on using the example + * + * \exception SuperError + * + * \ifnot CONDITION + * Write something if not + * \endifnot + * + * \image html testImage.bmp + * + *
      + * + * \li Some unordered list + * \li With lots of items + * \li lots of lots of items + * + *
    + * + * \link someMember Some description follows \endlink + * + * \n \n \n + * + * \overload + * + * \p someword + * + * \package superPackage + * + * \par The paragraph title + * The paragraph text. + * Maybe even multiline + * + * \param a the first param + * + * \remark Some remark text + * + * \remarks Another remarks section + * + * \result Whatever + * + * \return it + * + * \returns may return + * + * \sa someOtherMethod + * + * \see function + * + * \since version 0.0.0.1 + * + * \throw superException + * + * \throws RuntimeError + * + * \todo Some very important task + * + * \tparam b B is mentioned again... + * + * \verbatim + * very long + * text with tags + * \endverbatim + * + * \version 0.0.0.2 + * + * \warning This is senseless! + * + * Here goes test of symbols: + * \$ \@ \\ \& \~ \< \> \# \% \" \. \:: + * + * And here goes simple text + */ +int function(int a, float b) +{ +} + +%} \ No newline at end of file From 6a54fe93ad625e0c41699837db7efe91ccf40949 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 12 Jul 2012 17:02:04 +0000 Subject: [PATCH 0081/2031] Added support for parsing of nested conditional comments and extended the test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13317 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_translate.i | 28 +++++-- .../DoxygenTranslator/src/DoxygenCommands.h | 7 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 84 +++++++++++++++---- 3 files changed, 91 insertions(+), 28 deletions(-) diff --git a/Examples/test-suite/doxygen_translate.i b/Examples/test-suite/doxygen_translate.i index 5f3bd1b39..04f70f014 100644 --- a/Examples/test-suite/doxygen_translate.i +++ b/Examples/test-suite/doxygen_translate.i @@ -29,20 +29,30 @@ * * \e italicword * - * \if ANOTHERCONDITION - * First part of comment - * \else - * Second part of comment - * \endif - * * \example someFile.txt * Some details on using the example * * \exception SuperError * - * \ifnot CONDITION - * Write something if not - * \endifnot + * \if ANOTHERCONDITION + * First part of comment + * \if SECONDCONDITION + * Nested condition text + * \elseif THIRDCONDITION + * The third condition text + * \else + * The last text block + * \endif + * \else + * Second part of comment + * \if CONDITION + * Second part extended + * \endif + * \endif + * + * \ifnot SOMECONDITION + * This is printed if not + * \endif * * \image html testImage.bmp * diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 93898193c..8b933878b 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -64,7 +64,7 @@ const char *ignoreCommandParagraphs[] = { const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); const char *commandEndCommands[] = { - "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "if", "ifnot", "link"}; + "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "link"}; const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const char *commandWordParagraphs[] = { @@ -87,11 +87,12 @@ const char *commandErrorThrowings[] = { "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif"}; + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else"}; const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); const char *commandUniques[] = { - "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; + "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li", + "if", "ifnot", "elseif", "else"}; const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); #endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 4106cad44..b47320268 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -164,7 +164,7 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL if (tokList.peek().tokenType == END_LINE) description += "\n"; - if (tokList.peek().tokenString.compare(theCommand) == 0) { + if (tokList.peek().tokenString == theCommand) { tokList.next(); return description; } @@ -207,7 +207,7 @@ std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theComm std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); while (endOfParagraph != tokList.end()) { if ((*endOfParagraph).tokenType == COMMAND) { - if (theCommand.compare((*endOfParagraph).tokenString) == 0) + if (theCommand == (*endOfParagraph).tokenString) return endOfParagraph; else endOfParagraph++; @@ -228,7 +228,7 @@ std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theComman std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); while (endOfCommand != tokList.end()) { if ((*endOfCommand).tokenType == COMMAND) { - if (theCommand.compare((*endOfCommand).tokenString) == 0) { + if (theCommand == (*endOfCommand).tokenString) { return endOfCommand; } endOfCommand++; @@ -399,14 +399,14 @@ int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokL int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { std::list < DoxygenEntity > aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { + if (theCommand == "arg" || theCommand == "li") { std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); std::list < DoxygenEntity > aNewList; aNewList = parse(endOfSection, tokList); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \xrefitem "(heading)" "(std::list title)" {text} - else if (theCommand.compare("xrefitem") == 0) { + else if (theCommand == "xrefitem") { //TODO Implement xrefitem if (noisy) cout << "Not Adding " << theCommand << endl; @@ -415,7 +415,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, return 1; } // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0) { + else if (theCommand == "ingroup") { std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); @@ -428,7 +428,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, return 1; } // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0) { + else if (theCommand == "par") { std::list < Token >::iterator endOfLine = getOneLine(tokList); aNewList = parse(endOfLine, tokList); std::list < DoxygenEntity > aNewList2; @@ -438,7 +438,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, return 1; } // \headerfile [] - else if (theCommand.compare("headerfile") == 0) { + else if (theCommand == "headerfile") { std::list < DoxygenEntity > aNewList; std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); @@ -449,7 +449,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, return 1; } // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0) { + else if (theCommand == "overload") { std::list < Token >::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { std::list < DoxygenEntity > aNewList; @@ -460,7 +460,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, return 1; } // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0) { + else if (theCommand == "weakgroup") { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -477,7 +477,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \ref ["(text)"] - else if (theCommand.compare("ref") == 0) { + else if (theCommand == "ref") { //TODO Implement ref if (noisy) cout << "Not Adding " << theCommand << endl; @@ -485,7 +485,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, tokList.setIterator(endOfParagraph); } // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0) { + else if (theCommand == "subpage") { //TODO implement subpage if (noisy) cout << "Not Adding " << theCommand << endl; @@ -493,7 +493,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, tokList.setIterator(endOfParagraph); } // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0) { + else if (theCommand == "dotfile") { //TODO implement dotfile if (noisy) cout << "Not Adding " << theCommand << endl; @@ -501,11 +501,11 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, tokList.setIterator(endOfParagraph); } // \image ["caption"] [=] - else if (theCommand.compare("image") == 0) { + else if (theCommand == "image") { //todo implement image } // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0) { + else if (theCommand == "addtogroup") { if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); @@ -521,12 +521,64 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } + // \if [\else ...] [\elseif ...] \endif + else if (theCommand == "if" || theCommand == "ifnot" || + theCommand == "else" || theCommand == "elseif") { + if (noisy) + cout << "Parsing " << theCommand << endl; + + std::string cond; + bool skipEndif = false; // if true then we skip endif after parsing block of code + bool needsCond = (theCommand == "if" || theCommand == "ifnot" || theCommand == "elseif"); + if (needsCond) { + cond = getNextWord(tokList); + if (cond.empty()) { + tokList.printListError("No word followed " + theCommand + " command. Not added"); + return 0; + } + } + + int nestedCounter = 1; + std::list < Token >::iterator endCommand = tokList.end(); + // go through the commands and find closing endif or else or elseif + std::list < Token >::iterator it=tokList.iteratorCopy(); + for (; it!=tokList.end(); it++) { + if (it->tokenType == COMMAND) { + if (it->tokenString == "if" || it->tokenString == "ifnot") + nestedCounter++; + else if (it->tokenString == "endif") + nestedCounter--; + if (nestedCounter == 1 && (it->tokenString == "else" || it->tokenString == "elseif")) { // else found + endCommand = it; + break; + } + if (nestedCounter == 0) { // endif found + endCommand = it; + skipEndif = true; + break; + } + } + } + + if (endCommand == tokList.end()) { + tokList.printListError("No corresponding endif found"); + return 0; + } + + std::list < DoxygenEntity > aNewList; + aNewList = parse(endCommand, tokList); + if (skipEndif) + tokList.next(); + if (needsCond) + aNewList.push_front(DoxygenEntity("plainstd::string", cond)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } return 0; } int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { std::string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstd::string") == 0) { + if (theCommand == "plainstd::string") { std::string nextPhrase = getStringTilCommand(tokList); if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; From 6a7fe334beee85e9d169d7c3330e1d9756e2d105 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 13 Jul 2012 10:46:59 +0000 Subject: [PATCH 0082/2031] Implemented parsing support for missing commands: \xrefitem, \ref, \subpage, \dotfile, \mscfile, \image, fixed \par git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13319 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenCommands.h | 8 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 98 +++++++++++++++---- 2 files changed, 84 insertions(+), 22 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 8b933878b..1b24eff33 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -12,7 +12,7 @@ const char *commandArray[] = { "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "line", "link", "mainpage", "manonly", "msc", "mscfile", "n", "name", "namespace", "nosubgrouping", "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", "private", "privatesection", "property", "protected", "protectedsection", "protocol", "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "remark", "result", "return", "returns", "retval", @@ -37,7 +37,7 @@ const char *ignoredSimpleCommands[] = { const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); const char *commandWords[] = { - "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", + "a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); @@ -68,7 +68,7 @@ const char *commandEndCommands[] = { const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const char *commandWordParagraphs[] = { - "param", "tparam", "throw", "throws", "retval", "exception"}; + "param", "tparam", "throw", "throws", "retval", "exception", "example"}; const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); const char *commandWordLines[] = { @@ -92,7 +92,7 @@ const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*co const char *commandUniques[] = { "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li", - "if", "ifnot", "elseif", "else"}; + "if", "ifnot", "elseif", "else", "mscfile"}; const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); #endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index b47320268..4fee595a6 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -407,11 +407,28 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } // \xrefitem "(heading)" "(std::list title)" {text} else if (theCommand == "xrefitem") { - //TODO Implement xrefitem if (noisy) - cout << "Not Adding " << theCommand << endl; + cout << "Parsing " << theCommand << endl; + std::string key = getNextWord(tokList); + if (key.empty()) { + tokList.printListError("No key followed " + theCommand + " command. Not added"); + return 0; + } + std::string heading = getNextWord(tokList); + if (key.empty()) { + tokList.printListError("No heading followed " + theCommand + " command. Not added"); + return 0; + } + std::string title = getNextWord(tokList); + if (title.empty()) { + tokList.printListError("No title followed " + theCommand + " command. Not added"); + return 0; + } std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + aNewList = parse(endOfParagraph, tokList); + aNewList.push_front(DoxygenEntity("plainstd::string", title)); + aNewList.push_front(DoxygenEntity("plainstd::string", heading)); + aNewList.push_front(DoxygenEntity("plainstd::string", key)); return 1; } // \ingroup ( [ ]) @@ -432,7 +449,8 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < Token >::iterator endOfLine = getOneLine(tokList); aNewList = parse(endOfLine, tokList); std::list < DoxygenEntity > aNewList2; - aNewList2 = parse(endOfLine, tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + aNewList2 = parse(endOfParagraph, tokList); aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -478,31 +496,75 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } // \ref ["(text)"] else if (theCommand == "ref") { - //TODO Implement ref if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + tokList.printListError("No key followed " + theCommand + " command. Not added"); + return 0; + } + std::string text = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!text.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", text)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \subpage ["(text)"] else if (theCommand == "subpage") { - //TODO implement subpage if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + tokList.printListError("No name followed " + theCommand + " command. Not added"); + return 0; + } + std::string text = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!text.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", text)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \dotfile ["caption"] - else if (theCommand == "dotfile") { - //TODO implement dotfile + // \mscfile ["caption"] + else if (theCommand == "dotfile" || theCommand == "mscfile") { if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); + cout << "Parsing " << theCommand << endl; + std::string file = getNextWord(tokList); + if (file.empty()) { + tokList.printListError("No file followed " + theCommand + " command. Not added"); + return 0; + } + std::string caption = getNextWord(tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", file)); + if (!caption.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", caption)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \image ["caption"] [=] else if (theCommand == "image") { - //todo implement image + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string format = getNextWord(tokList); + if (format.empty()) { + tokList.printListError("No format followed " + theCommand + " command. Not added"); + return 0; + } + std::string file = getNextWord(tokList); + if (file.empty()) { + tokList.printListError("No name followed " + theCommand + " command. Not added"); + return 0; + } + std::string caption = getNextWord(tokList); + std::string size = getNextWord(tokList); + + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", format)); + aNewList.push_back(DoxygenEntity("plainstd::string", file)); + if (!caption.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", caption)); + if (!size.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", size)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \addtogroup [(title)] else if (theCommand == "addtogroup") { From b99221e8af48dc9ece97a619934276bd64913a23 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 13 Jul 2012 14:08:37 +0000 Subject: [PATCH 0083/2031] Refactored TokenList class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13320 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenParser.cpp | 2 +- Source/DoxygenTranslator/src/TokenList.cpp | 116 +++++++----------- Source/DoxygenTranslator/src/TokenList.h | 8 +- 3 files changed, 55 insertions(+), 71 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 4fee595a6..6161d00b9 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -727,7 +727,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e } std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob, std::string fileName, int lineNumber) { - TokenList tokList(doxygenBlob, fileName, lineNumber); + TokenList tokList = TokenList::tokenizeDoxygenComment(doxygenBlob, fileName, lineNumber); if (noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 8624fb4a2..6bb6c8cd4 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -21,75 +21,53 @@ using namespace std; -int noisy2 = 0; -/* The tokenizer*/ -TokenList::TokenList(const std::string & doxygenStringConst, const std::string fileName, int fileLine) - : fileName(fileName), fileLine(fileLine) { - size_t commentPos; - string doxygenString = doxygenStringConst; - - size_t currentIndex = 0; - size_t nextIndex = 0; +TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, const std::string &fileName, int fileLine) { + TokenList tokList; + tokList.fileLine = fileLine; + tokList.fileName = fileName; + string::size_type pos, lastPos = 0; string currentWord; - - while (currentIndex < doxygenString.length()) { - - if (doxygenString[currentIndex] == '\n') { - m_tokenList.push_back(Token(END_LINE, currentWord)); - currentIndex++; - } - // skip WS, except \n - while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t')) - currentIndex++; - - if (currentIndex < doxygenString.length()) { - - nextIndex = currentIndex; - - // skip non WS - while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex] != '\n')) - nextIndex++; - - // now we have a token - currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex); - - if (noisy2) - cout << "Current Word: " << currentWord << endl; - - if (currentWord[0] == '@' || currentWord[0] == '\\') { - // it is doxygen command - currentWord = currentWord.substr(1, currentWord.length() - 1); - m_tokenList.push_back(Token(COMMAND, currentWord)); - - } else if (currentWord[0] == '\n') { - - m_tokenList.push_back(Token(END_LINE, currentWord)); - - } else if (currentWord[0] == '*' || currentWord[0] == '/' || currentWord[0] == '!') { - - bool isPlainString = false; - - if (currentWord.length() > 1) { - - for (size_t i = 1; i < currentWord.length(); i++) { - if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') { - isPlainString = true; - break; - } - } - } - - if (isPlainString) - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); - - } else if (!currentWord.empty()) { - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + while (true) { + pos = doxygenComment.find_first_of("\t\n ", lastPos); + if (pos == string::npos) + pos = doxygenComment.size(); + if (pos > lastPos) { + currentWord = doxygenComment.substr(lastPos, pos-lastPos); + if (currentWord[0] == '\\' || currentWord[0] == '@') { + // it's a doxygen command + currentWord = currentWord.substr(1, currentWord.length() - 1); + tokList.m_tokenList.push_back(Token(COMMAND, currentWord)); } - currentIndex = nextIndex; + else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') { + // check if it's one of the '!!!', '***', '///' of any length + char c = currentWord[0]; + bool isPlainString = false; + for (int i=0; i= doxygenComment.size()) + break; + + if (doxygenComment[pos] == '\n') + tokList.m_tokenList.push_back(Token(END_LINE, "\n")); + } + tokList.m_tokenListIter = tokList.m_tokenList.begin(); + return tokList; +} + +TokenList::TokenList() +: fileName(""), fileLine(0) { m_tokenListIter = m_tokenList.begin(); } @@ -151,9 +129,9 @@ void TokenList::printList() { } void TokenList::printListError(std::string message) { - int curLine = fileLine; - for (list< Token >::iterator it = m_tokenList.begin(); it != current(); it++) - if (it->tokenType == END_LINE) - curLine++; - Swig_error(fileName.c_str(), curLine, "Doxygen parser error: %s. \n", message.c_str()); + int curLine = fileLine; + for (list< Token >::iterator it = m_tokenList.begin(); it != current(); it++) + if (it->tokenType == END_LINE) + curLine++; + Swig_error(fileName.c_str(), curLine, "Doxygen parser error: %s. \n", message.c_str()); } diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index d38fec792..ce9d14c45 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -30,7 +30,7 @@ private: int fileLine; public: - TokenList(const std::string & doxygenString, const std::string fileName, int fileLine); /* constructor takes a blob of Doxygen comment */ + TokenList(); // construct an empty TokenList ~TokenList(); Token peek(); /* returns next token without advancing */ @@ -44,6 +44,12 @@ public: void printList(); /* prints out the sequence of tokens */ void printListError(std::string message); /* prints properly formatted error message */ + + /* + * Create TokenList and populate it with tokens from + * a blob of Doxygen comment + */ + static TokenList tokenizeDoxygenComment(const std::string &doxygenComment, const std::string &fileName, int fileLine); }; #endif From 34dc515a4041c079db4d4c5b3bc241efa6d96d34 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 13 Jul 2012 15:16:58 +0000 Subject: [PATCH 0084/2031] Fixed bug with quoted strings in doxygen comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13321 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/TokenList.cpp | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 6bb6c8cd4..1ade6375e 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -26,6 +26,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c tokList.fileLine = fileLine; tokList.fileName = fileName; + bool isPlainString = false; string::size_type pos, lastPos = 0; string currentWord; while (true) { @@ -42,17 +43,35 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') { // check if it's one of the '!!!', '***', '///' of any length char c = currentWord[0]; - bool isPlainString = false; + isPlainString = false; for (int i=0; i Date: Sat, 14 Jul 2012 22:41:41 +0000 Subject: [PATCH 0085/2031] Added support for parsing of missing doxygen commands. Now parser produces correct parse tree for every doxygen tag, at least for those included in the testcase. Also added the test with all the tags, even those that will be ignored later. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13322 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/doxygen_translate_all_tags.i | 338 ++++++++++++++++++ .../DoxygenTranslator/src/DoxygenCommands.h | 24 +- .../DoxygenTranslator/src/DoxygenParser.cpp | 51 ++- Source/DoxygenTranslator/src/TokenList.cpp | 5 +- 4 files changed, 401 insertions(+), 17 deletions(-) create mode 100644 Examples/test-suite/doxygen_translate_all_tags.i diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i new file mode 100644 index 000000000..ae66cc5de --- /dev/null +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -0,0 +1,338 @@ +%module doxygen_translate + +%inline %{ + +/** + * \a Hello + * + * \addindex SomeLatexIndex + * + * \addtogroup someGroup "Some title" + * + * \anchor theAnchor + * + * \arg some list item + * + * \attention This is attention! + * You were warned! + * + * \authors lots of them + * + * \author Zubr + * + * \b boldword + * + * \brief Some brief description, + * extended to many lines. + * + * \bug Not everything works right now... + * + * \c codeword + * + * \callgraph + * + * \callergraph + * + * \category someCategory headerFile.h headerName + * + * \cite citationword + * + * \class someClass headerFile.h headerName + * + * \code some test code \endcode + * + * \cond SOMECONDITION + * Some conditional comment + * \endcond + * + * \copybrief someClass::someMethod + * + * \copydetails someClass::someMethod2 + * + * \copydoc someClass::someMethod3 + * + * \copyright some copyright + * + * \date 1970 - 2012 + * + * \def someDefine + * + * \defgroup someGroup Some titles + * + * \deprecated Now use another function + * + * \details This is very large + * and detailed description of some thing + * + * \dir /somePath/someFolder + * + * \dontinclude someFile.h + * + * \dot + * digraph example { + * node [shape=record, fontname=Helvetica, fontsize=10]; + * b [ label="class B" URL="\ref B"]; + * c [ label="class C" URL="\ref C"]; + * b -> c [ arrowhead="open", style="dashed" ]; + * } + * \enddot + * + * \dotfile dotFile.dot "The caption" + * + * \e italicword + * + * \em emphazedWord + * + * \enum someEnum + * + * \example someFile.txt + * Some details on using the example + * + * \exception SuperError + * + * \extends someOtherFunction + * + * \f$ \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \f$ + * + * \f[ + * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} + * \f] + * + * \f{ + * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} + * \f} + * + * \file file.h + * + * \fn someFn + * + * \headerfile someHeader.h "Header name" + * + * \hideinitializer + * + * \htmlinclude htmlFile.htm + * + * \htmlonly + * This will only appear in hmtl + * \endhtmlonly + * + * \if ANOTHERCONDITION + * First part of comment + * \if SECONDCONDITION + * Nested condition text + * \elseif THIRDCONDITION + * The third condition text + * \else + * The last text block + * \endif + * \else + * Second part of comment + * \if CONDITION + * Second part extended + * \endif + * \endif + * + * \ifnot SOMECONDITION + * This is printed if not + * \endif + * + * \image html testImage.bmp "Hello, world!" asd=10qwe + * + * \implements someFunction + * + * \include header.h + * + * \includelineno header2.h + * + * \ingroup someGroup anotherGroup + * + * \internal + * + * \invariant Some text + * describing invariant. + * + * \interface someInterface someHeader.h "Header name" + * + * \latexonly + * This will only appear in LATeX + * \endlatexonly + * + *
      + * + * \li Some unordered list + * \li With lots of items + * \li lots of lots of items + * + *
    + * + * \line example + * + * \link someMember Some description follows \endlink + * + * \mainpage Some title + * + * \manonly + * This will only appear in man + * \endmanonly + * + * \memberof someThing + * + * \msc + * Sender,Receiver; + * Sender->Receiver [label="Command()", URL="\ref Receiver::Command()"]; + * Sender<-Receiver [label="Ack()", URL="\ref Ack()", ID="1"]; + * \endmsc + * + * \mscfile mscFile.msc "The caption" + * + * \n \n \n + * + * \name someHeader.h + * + * \namespace someNamespace + * + * \nosubgrouping + * + * \note Here + * is the note! + * + * \overload + * + * \p someword + * + * \package superPackage + * + * \page somePage The title + * + * \par The paragraph title + * The paragraph text. + * Maybe even multiline + * + * \paragraph someParagraph Paragraph title + * + * \param a the first param + * + * \post Some description + * + * \pre Some description + * + * \private + * + * \privatesection + * + * \property someVar + * + * \protected + * + * \protectedsection + * + * \protocol someProtocol header.h "Header name" + * + * \public + * + * \publicsection + * + * \ref someAnchor + * + * \related toSomething + * + * \relates toSomethingElse + * + * \relatedalso someName + * + * \relatesalso someName + * + * \remark Some remark text + * + * \remarks Another remarks section + * + * \result Whatever + * + * \return it + * + * \returns may return + * + * \retval someValue Some description + * + * \rtfonly + * This will only appear in RTF + * \endrtfonly + * + * \sa someOtherMethod + * + * \section someSection Some title + * + * \see function + * + * \short Same as + * brief description + * + * \showinitializer + * + * \since version 0.0.0.1 + * + * \skip somePattern + * + * \skipline someLine + * + * \snippet example.h Some snippet + * + * \struct someStruct + * + * \subpage someSubpage "Some description" + * + * \subsection someSubsection Some title + * + * \subsubsection someSubsection Some title + * + * \tableofcontents + * + * \test Some + * description of the + * test case + * + * \throw superException + * + * \throws RuntimeError + * + * \todo Some very important task + * + * \tparam b B is mentioned again... + * + * \typedef someTypedef + * + * \union someUnion + * + * \until somePattern + * + * \var someVar + * + * \verbatim + * very long + * text with tags + * \endverbatim + * + * \verbinclude someFile.h + * + * \version 0.0.0.2 + * + * \warning This is senseless! + * + * \weakgroup someGroup Some title + * + * \xmlonly + * This will only appear in XML + * \endxmlonly + * + * \xrefitem todo "Todo" "Todo List" + * + * Here goes test of symbols: + * \$ \@ \\ \& \~ \< \> \# \% \" \. \:: + * + * And here goes simple text + */ +int function(int a, float b) +{ +} + +%} diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 1b24eff33..27611cdcb 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -29,7 +29,10 @@ const int sectionIndicatorsSize = sizeof(sectionIndicators) / sizeof(*sectionInd /* All of the doxygen commands divided up by how they are parsed */ const char *simpleCommands[] = { - "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond"}; + "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%", "\"", ".", "::", "endcond", + "callgraph", "callergraph", "showinitializer", "hideinitializer", "internal", + "nosubgrouping", "public", "publicsection", "private", "privatesection", + "protected", "protectedsection", "tableofcontents"}; const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands); const char *ignoredSimpleCommands[] = { @@ -38,11 +41,12 @@ const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ig const char *commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", - "includelineno"}; + "includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related", + "relatedalso"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); const char *ignoredCommandWords[] = { - "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; + "nothing at the moment"}; const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); const char *commandLines[] = { @@ -56,7 +60,7 @@ const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCo const char *commandParagraph[] = { "partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant", "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "cite", - "copyright"}; + "copyright", "short"}; const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); const char *ignoreCommandParagraphs[] = { @@ -64,7 +68,7 @@ const char *ignoreCommandParagraphs[] = { const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); const char *commandEndCommands[] = { - "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "link"}; + "htmlonly", "latexonly", "manonly", "xmlonly", "link", "rtfonly"}; const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); const char *commandWordParagraphs[] = { @@ -72,7 +76,7 @@ const char *commandWordParagraphs[] = { const int commandWordParagraphsSize = sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); const char *commandWordLines[] = { - "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; + "page", "subsection", "subsubsection", "section", "paragraph", "defgroup", "snippet", "mainpage"}; const int commandWordLinesSize = sizeof(commandWordLines) / sizeof(*commandWordLines); const char *commandWordOWordOWords[] = { @@ -85,14 +89,14 @@ const int commandOWordsSize = sizeof(commandOWords) / sizeof(*commandOWords); const char *commandErrorThrowings[] = { "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", - "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else"}; + "headerfilestd::list", "inherit", "l", "postheader", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endif", "else", + "endrtfonly"}; const int commandErrorThrowingsSize = sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); const char *commandUniques[] = { "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li", - "if", "ifnot", "elseif", "else", "mscfile"}; + "if", "ifnot", "elseif", "else", "mscfile", "code", "verbatim", "f{", "f[", "f$", "dot", "msc"}; const int commandUniquesSize = sizeof(commandUniques) / sizeof(*commandUniques); #endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 6161d00b9..3e94bd538 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -227,11 +227,11 @@ std::list < Token >::iterator DoxygenParser::getEndOfSection(std::string theComm std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theCommand, TokenList & tokList) { std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); while (endOfCommand != tokList.end()) { + endOfCommand++; if ((*endOfCommand).tokenType == COMMAND) { if (theCommand == (*endOfCommand).tokenString) { return endOfCommand; } - endOfCommand++; } } //End command not found @@ -263,7 +263,9 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (!name.empty()) { - doxyList.push_back(DoxygenEntity(theCommand, name)); + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } else tokList.printListError("No word followed " + theCommand + " command. Not added"); @@ -322,8 +324,15 @@ int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & to int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; - std::string description = getStringTilEndCommand("end" + theCommand, tokList); - doxyList.push_back(DoxygenEntity(theCommand, description)); + std::list < Token >::iterator endCommand = getEndCommand("end" + theCommand, tokList); + if (endCommand == tokList.end()) { + tokList.printListError("Expected end" + theCommand); + return 0; + } + std::list < DoxygenEntity > aNewList; + aNewList = parse(endCommand, tokList); + tokList.next(); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -398,6 +407,7 @@ int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokL } int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + static std::map endCommands; std::list < DoxygenEntity > aNewList; if (theCommand == "arg" || theCommand == "li") { std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); @@ -524,6 +534,39 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, aNewList.push_back(DoxygenEntity("plainstd::string", text)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } + // \code ... \endcode + // \verbatim ... \endverbatim + // \dot dotcode \enddot + // \msc msccode \endmsc + // \f[ ... \f] + // \f{ ... \f} + // \f{env}{ ... \f} + // \f$ ... \f$ + else if (theCommand == "code" || theCommand == "verbatim" + || theCommand == "dot" || theCommand == "msc" + || theCommand == "f[" || theCommand == "f{" + || theCommand == "f$") { + if (!endCommands.size()) { + // fill in static table of end commands + endCommands["f["] = "f]"; + endCommands["f{"] = "f}"; + endCommands["f$"] = "f$"; + } + if (noisy) + cout << "Parsing " << theCommand << endl; + + std::string endCommand; + std::map ::iterator it; + it = endCommands.find(theCommand); + if (it != endCommands.end()) + endCommand = it->second; + else + endCommand = "end" + theCommand; + + std::string content = getStringTilEndCommand(endCommand, tokList); + aNewList.push_back(DoxygenEntity("plainstd::string", content)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + } // \dotfile ["caption"] // \mscfile ["caption"] else if (theCommand == "dotfile" || theCommand == "mscfile") { diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 1ade6375e..62dbdc997 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -30,6 +30,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c string::size_type pos, lastPos = 0; string currentWord; while (true) { + isPlainString = false; pos = doxygenComment.find_first_of("\t\n ", lastPos); if (pos == string::npos) pos = doxygenComment.size(); @@ -55,9 +56,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c if (isPlainString) { // handle quoted words - string::size_type qPos = currentWord.find('"', 0); - if (qPos != string::npos) { - lastPos += qPos; + if (currentWord[0] == '"') { pos = doxygenComment.find_first_of("\"\n", lastPos + 1); if (pos == string::npos) pos = doxygenComment.size(); From f0aa6b750179663ffe8dc8b72cb13a0b2fb5a437 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 16 Jul 2012 19:36:23 +0000 Subject: [PATCH 0086/2031] Fixed \cite doxygen command parsing git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13325 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenCommands.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 27611cdcb..96fde4a7c 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -42,7 +42,7 @@ const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ig const char *commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related", - "relatedalso"}; + "relatedalso", "cite"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); const char *ignoredCommandWords[] = { @@ -59,7 +59,7 @@ const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCo const char *commandParagraph[] = { "partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "cite", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "copyright", "short"}; const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); From 32154a91e4e3e32b80dde69bf112586e96534c21 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 16 Jul 2012 19:37:05 +0000 Subject: [PATCH 0087/2031] Normalized parameters handling, included newlines to the parsed tree git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13326 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 3e94bd538..a44b79abe 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -263,8 +263,8 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (!name.empty()) { - std::list < DoxygenEntity > aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } else @@ -393,7 +393,9 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - doxyList.push_back(DoxygenEntity(theCommand, name)); + std::list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -750,6 +752,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e if (noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; if (currToken.tokenType == END_LINE) { + aNewList.push_back(DoxygenEntity("plainstd::endl")); tokList.next(); } else if (currToken.tokenType == COMMAND) { currCommand = findCommand(currToken.tokenString); From db9659c286f57be807f181a72afde6f1b55e6dba Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 16 Jul 2012 19:42:30 +0000 Subject: [PATCH 0088/2031] Implemented most of non-ignored doxygen commands translating for java, fixed testcase. The output is not really nice right now, but almost all the commands mentioned in the project plan work ok git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13327 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 4 +- Examples/test-suite/common.mk | 2 +- Examples/test-suite/doxygen_translate.i | 7 +- .../src/JavaDocConverter.cpp | 229 ++++++++++++------ .../DoxygenTranslator/src/JavaDocConverter.h | 54 ++++- 5 files changed, 203 insertions(+), 93 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index a32878375..3750a27ca 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -92,7 +92,7 @@ Functionality \category - ignored, used only in Objective C \cite - translated to in JD, single quotes in PD \class - ignored (structural command) - \code - translated to in JD, ignored in PD + \code - translated to {@code ...} in JD, ignored in PD \cond - translated to 'Conditional comment: '. Later SWIG may support definitions of conditions in config file. \copybrief - ignored. Later SWIG may support this command by @@ -172,7 +172,7 @@ Functionality \namespace - included in package-info.java if nspace feature is enabled, otherwise ignored, ignored in PD \nosubgrouping - ignored - \note - ignored in JD, translated to 'Note:' in PD + \note - translated to 'Note:' in both JD and PD \overload - prints 'This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.' to the output in both JD and PD diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index ed2d74cd9..9f91cec8c 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -188,7 +188,7 @@ CPP_TEST_CASES += \ director_wombat \ disown \ doxygen_parsing \ - doxygen_basic_translate \ + doxygen_translate \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_translate.i b/Examples/test-suite/doxygen_translate.i index 04f70f014..8bfd3d250 100644 --- a/Examples/test-suite/doxygen_translate.i +++ b/Examples/test-suite/doxygen_translate.i @@ -54,7 +54,7 @@ * This is printed if not * \endif * - * \image html testImage.bmp + * \image html testImage.bmp "Hello, world!" asd=10qwe * *
      * @@ -68,6 +68,9 @@ * * \n \n \n * + * \note Here + * is the note! + * * \overload * * \p someword @@ -122,4 +125,4 @@ int function(int a, float b) { } -%} \ No newline at end of file +%} diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 2bc3165f4..42b5fcb80 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -17,54 +17,82 @@ //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag // define static tables, they are filled in JavaDocConverter's constructor -std::map JavaDocConverter::escapeTable; -std::map JavaDocConverter::tagHandlers; +std::map > JavaDocConverter::tagHandlers; void JavaDocConverter::fillStaticTables() { - if (escapeTable.size()) // fill only once - return; - - escapeTable["&"] = "&"; - escapeTable["\'"] = "&apos"; - escapeTable["\""] = """; - escapeTable["<"] = "<"; - escapeTable[">"] = ">"; + if (tagHandlers.size()) // fill only once // these commands insert HTML tags - tagHandlers["c"] = &handleTagC; - tagHandlers["b"] = &handleTagB; - // these commands insert just a single char, some of them need to be escaped - tagHandlers["$"] = &handleTagChar; - tagHandlers["@"] = &handleTagChar; - tagHandlers["\\"] = &handleTagChar; - tagHandlers["<"] = &handleTagChar; - tagHandlers[">"] = &handleTagChar; - tagHandlers["&"] = &handleTagChar; - tagHandlers["#"] = &handleTagChar; - tagHandlers["%"] = &handleTagChar; - tagHandlers["~"] = &handleTagChar; - tagHandlers["\""] = &handleTagChar; - tagHandlers["."] = &handleTagChar; - tagHandlers["::"] = &handleTagChar; - // these commands are stripped out - tagHandlers["brief"] = &handleParagraph; - tagHandlers["details"] = &handleParagraph; - tagHandlers["partofdescription"] = &handleParagraph; - // these commands are kept as-is, they are supported by JavaDoc - tagHandlers["sa"] = &handleTagSeeAll; - tagHandlers["see"] = &handleTagSame; - tagHandlers["param"] = &handleTagSame; - tagHandlers["return"] = &handleTagSame; - tagHandlers["throws"] = &handleTagSame; - tagHandlers["throw"] = &handleTagThrow; - tagHandlers["author"] = &handleTagSame; - tagHandlers["since"] = &handleTagSame; - tagHandlers["version"] = &handleTagSame; - tagHandlers["exception"] = &handleTagSame; - tagHandlers["deprecated"] = &handleTagSame; - // this command just prints it's contents - // (it is internal command of swig's parser, contains plain text) - tagHandlers["plainstd::string"] = &handlePlainString; + tagHandlers["a"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); + tagHandlers["arg"] = make_pair(&JavaDocConverter::handleTagHtml, "li"); + tagHandlers["b"] = make_pair(&JavaDocConverter::handleTagHtml, "b"); + tagHandlers["c"] = make_pair(&JavaDocConverter::handleTagHtml, "code"); + tagHandlers["cite"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); + tagHandlers["e"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); + tagHandlers["li"] = make_pair(&JavaDocConverter::handleTagHtml, "li"); + tagHandlers["p"] = make_pair(&JavaDocConverter::handleTagHtml, "code"); + // these commands insert just a single char, some of them need to be escaped + tagHandlers["$"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["@"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["\\"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["<"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers[">"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["&"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["#"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["%"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["~"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["\""] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["."] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["::"] = make_pair(&JavaDocConverter::handleTagChar, ""); + // these commands are stripped out + tagHandlers["attention"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["brief"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["date"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["details"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["partofdescription"] = make_pair(&JavaDocConverter::handleParagraph, ""); + // these commands are kept as-is, they are supported by JavaDoc + tagHandlers["author"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame, "author"); + tagHandlers["deprecated"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["exception"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["package"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["param"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["tparam"] = make_pair(&JavaDocConverter::handleTagSame, "param"); + tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return"); + tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, "return"); + tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see"); + tagHandlers["since"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["throws"] = make_pair(&JavaDocConverter::handleTagSame, ""); + tagHandlers["throw"] = make_pair(&JavaDocConverter::handleTagSame, "throws"); + tagHandlers["version"] = make_pair(&JavaDocConverter::handleTagSame, ""); + // these commands have special handlers + tagHandlers["code"] = make_pair(&JavaDocConverter::handleTagExtended, "code"); + tagHandlers["cond"] = make_pair(&JavaDocConverter::handleTagMessage, "Conditional comment: "); + tagHandlers["copyright"] = make_pair(&JavaDocConverter::handleTagMessage, "Copyright: "); + tagHandlers["else"] = make_pair(&JavaDocConverter::handleTagIf, "Else: "); + tagHandlers["elseif"] = make_pair(&JavaDocConverter::handleTagIf, "Else if: "); + tagHandlers["endcond"] = make_pair(&JavaDocConverter::handleTagMessage, "End of conditional comment."); + tagHandlers["if"] = make_pair(&JavaDocConverter::handleTagIf, "If: "); + tagHandlers["ifnot"] = make_pair(&JavaDocConverter::handleTagIf, "If not: "); + tagHandlers["image"] = make_pair(&JavaDocConverter::handleTagImage, ""); + tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagExtended, "link"); + tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage, "Note: "); + tagHandlers["overload"] = make_pair(&JavaDocConverter::handleTagMessage, "This is an overloaded member function, provided for" + " convenience. It differs from the above function only in what" + " argument(s) it accepts."); + tagHandlers["par"] = make_pair(&JavaDocConverter::handleTagPar, ""); + tagHandlers["remark"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: "); + tagHandlers["remarks"] = make_pair(&JavaDocConverter::handleTagMessage, "Remarks: "); + tagHandlers["todo"] = make_pair(&JavaDocConverter::handleTagMessage, "TODO: "); + tagHandlers["verbatim"] = make_pair(&JavaDocConverter::handleTagExtended, "literal"); + tagHandlers["warning"] = make_pair(&JavaDocConverter::handleTagMessage, "Warning: "); + // this command just prints it's contents + // (it is internal command of swig's parser, contains plain text) + tagHandlers["plainstd::string"] = make_pair(&JavaDocConverter::handlePlainString, ""); + tagHandlers["plainstd::endl"] = make_pair(&JavaDocConverter::handleNewLine, ""); + tagHandlers["n"] = make_pair(&JavaDocConverter::handleNewLine, ""); } @@ -73,7 +101,7 @@ JavaDocConverter::JavaDocConverter() : debug(false) { } std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { - std::string formattedLines = "\n * "; + std::string formattedLines; int lastPosition = 0; int i = 0; int isFirstLine = 1; @@ -89,11 +117,11 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind if (i > 0 && i + 1 < (int) unformattedLine.length()) { if (!isFirstLine) - for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } else { - isFirstLine = 0; - } + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } else { + isFirstLine = 0; + } formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); formattedLines.append("\n *"); @@ -102,7 +130,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind if (lastPosition < (int) unformattedLine.length()) { if (!isFirstLine) { for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); + formattedLines.append("\t"); } } formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); @@ -129,45 +157,96 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translatedComment) { // check if we have needed handler and call it - std::map::iterator it; - it = tagHandlers.find(tag.typeOfEntity); + std::map >::iterator it; + it = tagHandlers.find(tag.typeOfEntity); if (it!=tagHandlers.end()) - (*it).second(this, tag, translatedComment); + (this->*(it->second.first))(tag, translatedComment, it->second.second); } -void JavaDocConverter::handleTagC(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += "" + tag.data + " "; +void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + if (tag.entityList.size()) // do not include empty tags + translatedComment += "<" + arg + ">" + translateSubtree(tag) + ""; } -void JavaDocConverter::handleTagB(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += "" + tag.data + " "; +void JavaDocConverter::handleNewLine(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += "\n * "; } -void JavaDocConverter::handleTagThrow(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - tag.typeOfEntity = "throws"; - handleTagSame(converter, tag, translatedComment); -} -void JavaDocConverter::handleTagSeeAll(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - tag.typeOfEntity = "see"; - handleTagSame(converter, tag, translatedComment); -} -void JavaDocConverter::handleTagChar(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - // escape it if we can, else just print - if (escapeTable.find(tag.typeOfEntity)!=escapeTable.end()) - translatedComment += escapeTable[tag.typeOfEntity]; +void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + // escape it if we need to, else just print + if (arg.size()) + translatedComment += arg; else translatedComment += tag.typeOfEntity; + translatedComment += " "; } -void JavaDocConverter::handleTagSame(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += converter->formatCommand(std::string("@" + tag.typeOfEntity + "\t" + converter->translateSubtree(tag)), 2); +void JavaDocConverter::handleTagSame(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + if (arg.size()) + tag.typeOfEntity = arg; + translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2); } -void JavaDocConverter::handleParagraph(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { - translatedComment += converter->formatCommand(converter->translateSubtree(tag), 0); +void JavaDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += formatCommand(translateSubtree(tag), 0); } -void JavaDocConverter::handlePlainString(JavaDocConverter* converter, DoxygenEntity& tag, std::string& translatedComment) { +void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { translatedComment += tag.data; if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') translatedComment += " "; } +void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += "{@" + arg + " "; + handleParagraph(tag, translatedComment, dummy); + translatedComment += "}"; +} +void JavaDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += arg; + if (tag.entityList.size()) { + translatedComment += tag.entityList.begin()->data; + //handleNewLine(tag, translatedComment, dummy); + tag.entityList.pop_front(); + translatedComment += " {" + translateSubtree(tag) + "}"; + } +} +void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += formatCommand(arg, 0); + handleParagraph(tag, translatedComment, dummy); +} +void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + if (tag.entityList.size() < 2) + return; + + std::string file; + std::string title; + + std::list ::iterator it = tag.entityList.begin(); + if (it->data != "html") + return; + + it++; + file = it->data; + + it++; + if (it != tag.entityList.end()) + title = it->data; + + translatedComment += "\""data + "\""; + translatedComment += ">"; + tag.entityList.pop_front(); + handleParagraph(tag, translatedComment, dummy); + translatedComment += "

      "; +} + String *JavaDocConverter::makeDocumentation(Node *node) { String *documentation = getDoxygenComment(node); diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 9776a17e0..cb876ed6b 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -27,42 +27,70 @@ public: protected: std::string formatCommand(std::string unformattedLine, int indent); - std::string javaDocFormat(DoxygenEntity & doxygenEntity); std::string translateSubtree(DoxygenEntity & doxygenEntity); void translateEntity(DoxygenEntity &tag, std::string &translatedComment); /* * Typedef for the function that handles one tag + * arg - some string argument to easily pass it through lookup table */ - typedef void (*tagHandler)(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + typedef void (JavaDocConverter::*tagHandler)(DoxygenEntity &tag, + std::string &translatedComment, std::string &arg); /* - * Here comes various tag handlers + * Wrap the command data with the html tag + * arg - html tag, with no braces */ - static void handleTagC(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); - static void handleTagB(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); - static void handleTagThrow(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); - static void handleTagSeeAll(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + void handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Just prints new line + */ + void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Print the name of tag to the output, used for escape-commands + * arg - html-escaped variant, if not provided the command data is used */ - static void handleTagChar(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Do not translate and print as-is + * arg - the new tag name, if it needs to be renamed */ - static void handleTagSame(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + void handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Print only the content and strip original tag */ - static void handleParagraph(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Print only data part of code */ - static void handlePlainString(JavaDocConverter *converter, DoxygenEntity &tag, std::string &translatedComment); + void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print extended Javadoc command, like {@code ...} or {@literal ...} + * arg - command name + */ + void handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print the if-elseif-else-endif section + */ + void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Prints the specified message, than the contents of the tag + * arg - message + */ + void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert tag if the 'format' field is specified as 'html' + */ + void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert

      ...

      + */ + void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + private: bool debug; - static std::map tagHandlers; - static std::map escapeTable; + // this contains the handler pointer and one string argument + static std::map > tagHandlers; void fillStaticTables(); }; From ff0ec620b2d5a73ccbdfea6ed53b7b89e8215570 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 16 Jul 2012 19:51:43 +0000 Subject: [PATCH 0089/2031] Added runtime test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13328 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/doxygen_translate_runme.java | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Examples/test-suite/java/doxygen_translate_runme.java diff --git a/Examples/test-suite/java/doxygen_translate_runme.java b/Examples/test-suite/java/doxygen_translate_runme.java new file mode 100644 index 000000000..6eec790e2 --- /dev/null +++ b/Examples/test-suite/java/doxygen_translate_runme.java @@ -0,0 +1,149 @@ + +import doxygen_translate.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_translate_runme { + static { + try { + System.loadLibrary("doxygen_translate"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + commentParser parser = new commentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_translate runtime test", + "commentParser", new String[]{"-quiet", "doxygen_translate"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("function", " Hello \n" + + " \n" + + "
    • some list item \n" + + " \n" + + "
    • @author lots of them \n" + + " \n" + + " @author Zubr \n" + + " \n" + + " boldword \n" + + " \n" + + " codeword \n" + + " \n" + + " citationword \n" + + " \n" + + " {@code some test code }\n" + + " \n" + + " Conditional comment: SOMECONDITION \n" + + " Some conditional comment \n" + + " End of conditional comment.\n" + + " \n" + + " Copyright: some copyright \n" + + " \n" + + " @deprecated Now use another function \n" + + " \n" + + " italicword \n" + + " \n" + + " @exception SuperError \n" + + " \n" + + " If: ANOTHERCONDITION {\n" + + " First part of comment \n" + + " If: SECONDCONDITION {\n" + + " Nested condition text \n" + + " }Else if: THIRDCONDITION {\n" + + " The third condition text \n" + + " }Else: {The last text block \n" + + " }\n" + + " }Else: {Second part of comment \n" + + " If: CONDITION {\n" + + " Second part extended \n" + + " }\n" + + " }\n" + + " \n" + + " If not: SOMECONDITION {\n" + + " This is printed if not \n" + + " }\n" + + " \n" + + " \"Hello,\n" + + " \n" + + "
        \n" + + " \n" + + "
      • Some unordered list \n" + + "
      • With lots of items \n" + + "
      • lots of lots of items \n" + + " \n" + + "
      \n" + + " \n" + + " {@link someMember Some description follows }\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Note: Here \n" + + " is the note! \n" + + " \n" + + " This is an overloaded member function, provided for convenience. \n" + + " It differs from the above function only in what argument(s) it accepts.\n" + + " \n" + + " someword \n" + + " \n" + + " @package superPackage \n" + + " \n" + + "

      \n" + + " The paragraph text. \n" + + " Maybe even multiline \n" + + " \n" + + "

      @param a the first param \n" + + " \n" + + " Remarks: Some remark text \n" + + " \n" + + " Remarks: Another remarks section \n" + + " \n" + + " @return Whatever \n" + + " \n" + + " @return it \n" + + " \n" + + " @return may return \n" + + " \n" + + " @see someOtherMethod \n" + + " \n" + + " @see function \n" + + " \n" + + " @since version 0.0.0.1 \n" + + " \n" + + " @throws superException \n" + + " \n" + + " @throws RuntimeError \n" + + " \n" + + " TODO: Some very important task \n" + + " \n" + + " @param b B is mentioned again... \n" + + " \n" + + " {@literal \n" + + "very long \n" + + "text with tags \n" + + " }\n" + + " \n" + + " @version 0.0.0.2 \n" + + " \n" + + " Warning: This is senseless! \n" + + " \n" + + " Here goes test of symbols: \n" + + " $ @ \\ & ~ < > # % \" . :: \n" + + " \n" + + " And here goes simple text \n" + + " \n"); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} \ No newline at end of file From 9e1e514fbcc161765e0e69336a8d0ab96803b4d8 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 16 Jul 2012 19:57:28 +0000 Subject: [PATCH 0090/2031] Updated project plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13329 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 3750a27ca..6566598fe 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -24,7 +24,7 @@ and Python code (## comments, see Doxygen manual), if the user will prefer to use Doxygen on the generated code. Note: -'--Done' tick below means that the item is implemented, commited and +'-OK-' tick below means that the item is implemented, commited and working. Abbreviations: @@ -43,11 +43,10 @@ Functionality the detailed description of Doxygen syntax and terms used in this section. - 1. Only JavaDoc (/** */) and Qt (/*! */) styles of comment blocks + 1. -OK- Only JavaDoc (/** */) and Qt (/*! */) styles of comment blocks will be supported by SWIG translator. - --Done - 2. The following doc after members will be supported: + 2. -OK- The following doc after members will be supported: int var; ///< Detailed description after the member //!< @@ -56,13 +55,11 @@ Functionality int var; ///< Brief description after the member - --Done - 3. Only comments before or after declaration/definition will be + 3. -OK- Only comments before or after declaration/definition will be supported. Comments with structural commands will be ignored (warning will be written). (What about writing them to 'package.info.java' for JD?) - --Done Tags @@ -265,6 +262,9 @@ Sometimes it needs a type of parameters specified because of the overloaded functions. And the same linking tags are supported in JD, but it has a completely different typesystem, so we need to translate the types of function parameters in comments also. For example: +{@link MyClass#doSomething(const std::string &)} +does not make sense in Java, so the type should be converted. +{@link MyClass#doSomething(String)} Tests @@ -272,30 +272,30 @@ Tests The following test cases will be implemented: -- Class comments. --Done +-OK- Class comments. -- Struct comments. --Done -- Enum comments. --Done -- Function comments. --Done -- Var comments. --Done +-OK- Struct comments. +-OK- Enum comments. +-OK- Function comments. +-OK- Var comments. -- Class attributes, comment before and after declaration. --Done -- Class methods, comment of parameters in function - comment. --Done -- Class methods, comment of parameters - after parameter declaration. --Done +-OK- Class attributes, comment before and after declaration. +-OK- Class methods, comment of parameters in function + comment. +-OK- Class methods, comment of parameters + after parameter declaration. -- Struct attributes, comment before and after declaration. --Done -- Struct methods, comment of parameters in function - comment. --Done -- Struct methods, comment of parameters - after parameter declaration. --Done +-OK- Struct attributes, comment before and after declaration. +-OK- Struct methods, comment of parameters in function + comment. +-OK- Struct methods, comment of parameters + after parameter declaration. -- Enum items JD and Qt style, comment before items --Done -- Enum items JD and Qt style, comment after items --Done +-OK- Enum items JD and Qt style, comment before items +-OK- Enum items JD and Qt style, comment after items -- Class comment, with all supported tags. -- Class comment, with all doxygen tags, including +-OK- Class comment, with all supported tags. +-OK- Class comment, with all doxygen tags, including ignored ones. @@ -303,9 +303,9 @@ Refactoring =========== All the code in directory _DoxygenTranslator_ should be refactored: -- all methods should be class members -- most static methods should be normal members -- replace C arrays of strings and sequential searches with STL data +-OK- all methods should be class members +-OK- most static methods should be normal members +-OK- replace C arrays of strings and sequential searches with STL data structures and algorithms. - use singletons instead of class instantiaion for each comment found. From 3d5d66dbd31963debd9fa94674d89757f9a81b57 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Tue, 17 Jul 2012 23:17:17 +0000 Subject: [PATCH 0091/2031] Fixed a bug with freezing on commands like \code, \link and others git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13330 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index a44b79abe..80ded041a 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -331,7 +331,7 @@ int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokL } std::list < DoxygenEntity > aNewList; aNewList = parse(endCommand, tokList); - tokList.next(); + tokList.next(); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -768,6 +768,12 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e } else if (currToken.tokenType == PLAINSTRING) { addCommand(currPlainstringCommandType, tokList, aNewList); } + + if (endParsingIndex != tokList.end() && tokList.current() == tokList.end()) { + // this could happen if we cant reach the original endParsingIndex + tokList.printListError("Unexpected end of comment encountered"); + break; + } } return aNewList; } From d9e8d140e76d6eaf498230efd66a9c7bce0955d8 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 18 Jul 2012 22:05:19 +0000 Subject: [PATCH 0092/2031] Refactored PyDocConverter class, implemented some commands git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13331 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/PyDocConverter.cpp | 200 +++++++++++------- Source/DoxygenTranslator/src/PyDocConverter.h | 63 +++++- 2 files changed, 183 insertions(+), 80 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 819c6bc6c..3dd42677e 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -17,9 +17,74 @@ #include #include -//TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag -PyDocConverter::PyDocConverter() { - debug = 0; +// define static tables, they are filled in PyDocConverter's constructor +std::map > PyDocConverter::tagHandlers; +std::map PyDocConverter::sectionTitles; + +void PyDocConverter::fillStaticTables() { + if (tagHandlers.size()) // fill only once + return; + + sectionTitles["author"] = "Authors:"; + sectionTitles["authors"] = "Authors:"; + sectionTitles["copyright"] = "Copyright:"; + sectionTitles["deprecated"] = "Deprecated:"; + sectionTitles["param"] = "Arguments:"; + sectionTitles["tparam"] = "Arguments:"; + sectionTitles["note"] = "Notes:"; + sectionTitles["remark"] = "Remarks:"; + sectionTitles["remarks"] = "Remarks:"; + sectionTitles["warning"] = "Warning:"; + sectionTitles["result"] = "Return:"; + sectionTitles["return"] = "Return:"; + sectionTitles["returns"] = "Return:"; + + // these commands insert HTML tags + tagHandlers["a"] = make_pair(&PyDocConverter::handleTagWrap, "_"); + tagHandlers["b"] = make_pair(&PyDocConverter::handleTagWrap, "__"); + tagHandlers["cite"] = make_pair(&PyDocConverter::handleTagWrap, "'"); + tagHandlers["e"] = make_pair(&PyDocConverter::handleTagWrap, "_"); + // these commands insert just a single char, some of them need to be escaped + tagHandlers["$"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["@"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["\\"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["<"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers[">"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["&"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["#"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["%"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["~"] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["\""] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["."] = make_pair(&PyDocConverter::handleTagChar, ""); + tagHandlers["::"] = make_pair(&PyDocConverter::handleTagChar, ""); + // these commands are stripped out + tagHandlers["attention"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["author"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["authors"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["brief"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["c"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["code"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["copyright"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["date"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["deprecated"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["details"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["note"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["partofdescription"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["remark"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["remarks"] = make_pair(&PyDocConverter::handleParagraph, ""); + tagHandlers["warning"] = make_pair(&PyDocConverter::handleParagraph, ""); + // these commands have special handlers + tagHandlers["cond"] = make_pair(&PyDocConverter::handleTagMessage, "Conditional comment: "); + tagHandlers["endcond"] = make_pair(&PyDocConverter::handleTagMessage, "End of conditional comment."); + // this command just prints it's contents + // (it is internal command of swig's parser, contains plain text) + tagHandlers["plainstd::string"] = make_pair(&PyDocConverter::handlePlainString, ""); + tagHandlers["plainstd::endl"] = make_pair(&PyDocConverter::handleNewLine, ""); + tagHandlers["n"] = make_pair(&PyDocConverter::handleNewLine, ""); +} + +PyDocConverter::PyDocConverter() : debug(false) { + fillStaticTables(); } std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { @@ -27,6 +92,7 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) if (doxygenEntity.entityList.size() < 2) { /* if 'paramDescriptionEntity' is not there, ignore param. Better than crash! TODO: log error! */ + return ""; } @@ -91,67 +157,60 @@ std::string PyDocConverter::justifyString(std::string documentString, int indent } std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { - std::string returnedString; + std::string translatedComment; + if (doxygenEntity.isLeaf) - return doxygenEntity.data + " "; - else { - returnedString += doxygenEntity.data; - std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()) { - returnedString += translateSubtree(*p); - p++; + return translatedComment; + + std::string currentSection; + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()) { + std::map::iterator it; + it = sectionTitles.find(p->typeOfEntity); + if (it != sectionTitles.end()) { + if (it->second != currentSection) { + currentSection = it->second; + translatedComment += currentSection + "\n"; + } } - } - return returnedString; -} - -std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) { - if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) - return justifyString(std::string(translateSubtree(doxyEntity)), 0); - - if ((doxyEntity.typeOfEntity.compare("brief") == 0) - || (doxyEntity.typeOfEntity.compare("details") == 0)) - return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; - - if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("brief") == 0) - return justifyString(doxyEntity.data, 0) + "\n"; - - if (doxyEntity.typeOfEntity.compare("param") == 0) - return formatParam(n, doxyEntity); - - if (doxyEntity.typeOfEntity.compare("return") == 0) - return formatReturnDescription(n, doxyEntity); - - if (doxyEntity.typeOfEntity.compare("author") == 0 - || doxyEntity.typeOfEntity.compare("param") == 0 - || doxyEntity.typeOfEntity.compare("since") == 0 - || doxyEntity.typeOfEntity.compare("version") == 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("sa") == 0) - return ""; - - return justifyString(doxyEntity.data); -} - -std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity > &entityList) { - std::string result; - bool inParamsSection = false; - - for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { - if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) { - inParamsSection = true; - result += "\nArguments:\n"; - } else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) - inParamsSection = false; - - result += translateEntity(n, *entityIterator); - entityIterator++; + translateEntity(*p, translatedComment); + translateSubtree(*p); + p++; } - return result; + return translatedComment; +} + +void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment) { + // check if we have needed handler and call it + std::map >::iterator it; + it = tagHandlers.find(doxyEntity.typeOfEntity); + if (it!=tagHandlers.end()) + (this->*(it->second.first))(doxyEntity, translatedComment, it->second.second); +} + +void PyDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += translateSubtree(tag); +} +void PyDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += tag.data; + if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') + translatedComment += ""; +} +void PyDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += arg; + handleParagraph(tag, translatedComment, dummy); +} +void PyDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += tag.typeOfEntity; +} +void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + if (tag.entityList.size()) // do not include empty tags + translatedComment += arg + translateSubtree(tag) + arg; +} +void PyDocConverter::handleNewLine(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + translatedComment += "\n"; } String *PyDocConverter::makeDocumentation(Node *n) { @@ -171,7 +230,8 @@ String *PyDocConverter::makeDocumentation(Node *n) { documentation = getDoxygenComment(n); if (!Swig_is_generated_overload(n) && documentation) { std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); - allDocumentation.push_back(processEntityList(n, entityList)); + DoxygenEntity root("root", entityList); + allDocumentation.push_back(translateSubtree(root)); } n = Getattr(n, "sym:nextSibling"); } @@ -180,10 +240,10 @@ String *PyDocConverter::makeDocumentation(Node *n) { if (allDocumentation.size() > 1) { std::ostringstream concatDocString; for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) { - concatDocString << generateDivider(); - concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; - concatDocString << generateDivider(); - concatDocString << allDocumentation[realOverloadCount] << std::endl; + concatDocString << generateDivider(); + concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; + concatDocString << generateDivider(); + concatDocString << allDocumentation[realOverloadCount] << std::endl; } pyDocString = concatDocString.str(); } else if (allDocumentation.size() == 1) { @@ -195,7 +255,8 @@ String *PyDocConverter::makeDocumentation(Node *n) { documentation = getDoxygenComment(n); if (documentation != NULL) { std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); - pyDocString = processEntityList(n, entityList); + DoxygenEntity root("root", entityList); + pyDocString = translateSubtree(root); } } @@ -216,9 +277,6 @@ String *PyDocConverter::makeDocumentation(Node *n) { } std::string PyDocConverter::generateDivider() { - std::ostringstream dividerString; - for (int i = 0; i < DOC_STRING_LENGTH; i++) - dividerString << '-'; - dividerString << std::endl; - return dividerString.str(); + static string dividerString('-', DOC_STRING_LENGTH); + return dividerString; } diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 2d910c8f9..319f62875 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -29,14 +29,6 @@ public: String *makeDocumentation(Node *node); protected: - - /* - * Process the contents of the entity list producing a documentation string. - * @param node The parse tree node that the entity list relates to. - * @param entityList The entity list to process - */ - std::string processEntityList(Node *node, std::list < DoxygenEntity > &entityList); - /* * Format the doxygen comment relating to a function or method parameter * @param node The parse tree node that the parameter relates to. @@ -61,7 +53,53 @@ protected: std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); std::string translateSubtree(DoxygenEntity & doxygenEntity); - std::string translateEntity(Node *n, DoxygenEntity & doxyEntity); + void translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment); + + /* + * Typedef for the function that handles one tag + * arg - some string argument to easily pass it through lookup table + */ + typedef void (PyDocConverter::*tagHandler)(DoxygenEntity &tag, + std::string &translatedComment, std::string &arg); + + /* + * Wrap the command data with the some string + * arg - string to wrap with, like '_' or '*' + */ + void handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Just prints new line + */ + void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print the name of tag to the output, used for escape-commands + */ + void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print only the content and strip original tag + */ + void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print only data part of code + */ + void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Print the if-elseif-else-endif section + */ + void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Prints the specified message, than the contents of the tag + * arg - message + */ + void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert 'Image: ...' + */ + void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert 'Title: ...' + */ + void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Utility method to generate a diving line for a documentation string. @@ -70,6 +108,13 @@ protected: private: bool debug; + // temporary thing, should be refactored somehow + Node *currentNode; + // this contains the handler pointer and one string argument + static std::map > tagHandlers; + // this cointains the sectins titiles, like 'Arguments:' or 'Notes:', that are printed only once + static std::map sectionTitles; + void fillStaticTables(); }; #endif From b23cb40cf94ee6a5c1f2e818c30beb0ca9f3862b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 19 Jul 2012 16:05:46 +0000 Subject: [PATCH 0093/2031] Added some doxygen tests, currently with no runtime parts git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13333 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 + Examples/test-suite/doxygen_basic_translate.i | 51 +++++++++++++++++++ .../test-suite/doxygen_translate_all_tags.i | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9f91cec8c..eb8f7b03a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -188,7 +188,9 @@ CPP_TEST_CASES += \ director_wombat \ disown \ doxygen_parsing \ + doxygen_basic_translate \ doxygen_translate \ + doxygen_translate_all_tags \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index af449eb49..c06cbddc9 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -15,4 +15,55 @@ int function() { } +/** + * A test of a very very very very very very very very very very very very very very very very + * very very very very very long comment string. + */ +int function2() +{ +} + +/** + * A test for overloaded functions + * This is function \b one + */ +int function3(int a) +{ +} + +/** + * A test for overloaded functions + * This is function \b two + */ +int function3(int a, int b) +{ +} + +/** + * A test of some mixed tag usage + * \if CONDITION + * This \a code fragment shows us something \. + * \par Minuses: + * \arg it's senseless + * \arg it's stupid + * \arg it's null + * + * \warning This may not work as expected + * + * \code + * int main() { while(true); } + * \endcode + * \endif + */ +int function4() +{ +} + +/** + * Test for default args + */ +int function5(int a=42) +{ +} + %} diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i index ae66cc5de..cb3332179 100644 --- a/Examples/test-suite/doxygen_translate_all_tags.i +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -1,4 +1,4 @@ -%module doxygen_translate +%module doxygen_translate_all_tags %inline %{ From 2ae18d9a0fe1e5a37684a0338580dd6f7f59cc62 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 19 Jul 2012 16:06:48 +0000 Subject: [PATCH 0094/2031] Some test fixes to the java comment translator git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13334 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 42b5fcb80..62b9762f4 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -102,6 +102,7 @@ JavaDocConverter::JavaDocConverter() : debug(false) { std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { std::string formattedLines; + return unformattedLine; int lastPosition = 0; int i = 0; int isFirstLine = 1; @@ -203,7 +204,6 @@ void JavaDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedCo translatedComment += arg; if (tag.entityList.size()) { translatedComment += tag.entityList.begin()->data; - //handleNewLine(tag, translatedComment, dummy); tag.entityList.pop_front(); translatedComment += " {" + translateSubtree(tag) + "}"; } From c56d5fcf90a1ddbc6e27c0c0c8631b8208578da7 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 19 Jul 2012 16:08:11 +0000 Subject: [PATCH 0095/2031] Some code refactoring and all of the doxy commands are working for the python comment translator git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13335 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/PyDocConverter.cpp | 143 ++++++++++-------- Source/DoxygenTranslator/src/PyDocConverter.h | 39 ++--- 2 files changed, 103 insertions(+), 79 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 3dd42677e..5b6f39adf 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -25,10 +25,14 @@ void PyDocConverter::fillStaticTables() { if (tagHandlers.size()) // fill only once return; + // table of section titles, they are printed only once + // for each group of specified doxygen commands sectionTitles["author"] = "Authors:"; sectionTitles["authors"] = "Authors:"; sectionTitles["copyright"] = "Copyright:"; sectionTitles["deprecated"] = "Deprecated:"; + sectionTitles["example"] = "Example:"; + sectionTitles["exception"] = "Throws:"; sectionTitles["param"] = "Arguments:"; sectionTitles["tparam"] = "Arguments:"; sectionTitles["note"] = "Notes:"; @@ -38,6 +42,13 @@ void PyDocConverter::fillStaticTables() { sectionTitles["result"] = "Return:"; sectionTitles["return"] = "Return:"; sectionTitles["returns"] = "Return:"; + sectionTitles["sa"] = "See also:"; + sectionTitles["see"] = "See also:"; + sectionTitles["since"] = "Since:"; + sectionTitles["throw"] = "Throws:"; + sectionTitles["throws"] = "Throws:"; + sectionTitles["todo"] = "TODO:"; + sectionTitles["version"] = "Version:"; // these commands insert HTML tags tagHandlers["a"] = make_pair(&PyDocConverter::handleTagWrap, "_"); @@ -57,25 +68,22 @@ void PyDocConverter::fillStaticTables() { tagHandlers["\""] = make_pair(&PyDocConverter::handleTagChar, ""); tagHandlers["."] = make_pair(&PyDocConverter::handleTagChar, ""); tagHandlers["::"] = make_pair(&PyDocConverter::handleTagChar, ""); - // these commands are stripped out - tagHandlers["attention"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["author"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["authors"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["brief"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["c"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["code"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["copyright"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["date"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["deprecated"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["details"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["note"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["partofdescription"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["remark"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["remarks"] = make_pair(&PyDocConverter::handleParagraph, ""); - tagHandlers["warning"] = make_pair(&PyDocConverter::handleParagraph, ""); // these commands have special handlers + tagHandlers["arg"] = make_pair(&PyDocConverter::handleTagMessage, " -"); tagHandlers["cond"] = make_pair(&PyDocConverter::handleTagMessage, "Conditional comment: "); + tagHandlers["else"] = make_pair(&PyDocConverter::handleTagIf, "Else: "); + tagHandlers["elseif"] = make_pair(&PyDocConverter::handleTagIf, "Else if: "); tagHandlers["endcond"] = make_pair(&PyDocConverter::handleTagMessage, "End of conditional comment."); + tagHandlers["if"] = make_pair(&PyDocConverter::handleTagIf, "If: "); + tagHandlers["ifnot"] = make_pair(&PyDocConverter::handleTagIf, "If not: "); + tagHandlers["image"] = make_pair(&PyDocConverter::handleTagMessage, "Image: "); + tagHandlers["li"] = make_pair(&PyDocConverter::handleTagMessage, " -"); + tagHandlers["overload"] = make_pair(&PyDocConverter::handleTagMessage, "This is an overloaded member function, provided for" + " convenience.\nIt differs from the above function only in what" + " argument(s) it accepts."); + tagHandlers["par"] = make_pair(&PyDocConverter::handleTagPar, ""); + tagHandlers["param"] = make_pair(&PyDocConverter::handleTagParam, ""); + tagHandlers["tparam"] = make_pair(&PyDocConverter::handleTagParam, ""); // this command just prints it's contents // (it is internal command of swig's parser, contains plain text) tagHandlers["plainstd::string"] = make_pair(&PyDocConverter::handlePlainString, ""); @@ -87,38 +95,13 @@ PyDocConverter::PyDocConverter() : debug(false) { fillStaticTables(); } -std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { - - if (doxygenEntity.entityList.size() < 2) { - /* if 'paramDescriptionEntity' is not there, ignore param. Better than crash! - TODO: log error! */ - - return ""; - } - - ParmList *plist = CopyParmList(Getattr(n, "parms")); +std::string PyDocConverter::getParamType(std::string param) { + ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); Parm *p = NULL; - - DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin(); - DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); - - std::string result; - std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); - for (p = plist; p;) { - - //Swig_print(p, 1); - if (Char(Getattr(p, "name")) == paramNameEntity.data) { - std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); - std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); - - result = name + " (" + type + ") "; - if (result.size() < (DOC_PARAM_STRING_LENGTH - 3)) { - /* do not cut info away - it is better to have not so nice output than type information missing. */ - result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); - } - result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); - break; + if (Char(Getattr(p, "name")) == param) { + std::string type = Char(Swig_name_make(currentNode, 0, Getattr(p, "type"), 0, 0)); + return type; } /* * doesn't seem to work always: in some cases (especially for 'self' parameters) @@ -127,18 +110,12 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) //p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); p = nextSibling(p); } - Delete(plist); - return result; -} - -std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) { -#pragma unused(node) - return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity)); + return ""; } std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth) { - std::ostringstream formattedString; + std::string formattedString; std::string currentLine; for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) { @@ -147,13 +124,17 @@ std::string PyDocConverter::justifyString(std::string documentString, int indent currentLine += *stringPosition; - if (*stringPosition == ' ' && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) { - formattedString << currentLine << std::endl; + if (iswspace(*stringPosition) && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) { + formattedString += currentLine + "\n"; currentLine = ""; } } - return formattedString.str(); + // strip the last endl + if (formattedString.size()) + formattedString = formattedString.substr(0, formattedString.size() - 1); + + return formattedString; } std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { @@ -183,14 +164,17 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment) { // check if we have needed handler and call it + std::string dummy; std::map >::iterator it; it = tagHandlers.find(doxyEntity.typeOfEntity); if (it!=tagHandlers.end()) (this->*(it->second.first))(doxyEntity, translatedComment, it->second.second); + else + handleParagraph(doxyEntity, translatedComment, dummy); } void PyDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { - translatedComment += translateSubtree(tag); + translatedComment += justifyString(translateSubtree(tag), 0); } void PyDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { translatedComment += tag.data; @@ -205,6 +189,42 @@ void PyDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translate void PyDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { translatedComment += tag.typeOfEntity; } +void PyDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += arg; + if (tag.entityList.size()) { + translatedComment += tag.entityList.begin()->data; + tag.entityList.pop_front(); + translatedComment += " {" + translateSubtree(tag) + "}"; + } +} +void PyDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + translatedComment += "Title: "; + if (tag.entityList.size()) + translatedComment += tag.entityList.begin()->data; + tag.entityList.pop_front(); + handleParagraph(tag, translatedComment, dummy); +} +void PyDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { + std::string dummy; + if (tag.entityList.size() < 2) { + // TODO: log error + return; + } + DoxygenEntity paramNameEntity = *tag.entityList.begin(); + std::string paramDescription = "-- "; + + tag.entityList.pop_front(); + handleParagraph(tag, paramDescription, dummy); + paramDescription = justifyString(paramDescription, DOC_PARAM_STRING_LENGTH); + + std::string paramType = getParamType(paramNameEntity.data); + if (!paramType.size()) + paramType = "none"; + + translatedComment += paramNameEntity.data + " (" + paramType + ")" + paramDescription; +} void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { if (tag.entityList.size()) // do not include empty tags translatedComment += arg + translateSubtree(tag) + arg; @@ -217,6 +237,9 @@ String *PyDocConverter::makeDocumentation(Node *n) { String *documentation; std::string pyDocString, result; + // store the node, we may need it later + currentNode = n; + // for overloaded functions we must concat documentation for underlying overloads if (Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")) { // rewind to the first overload @@ -240,7 +263,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { if (allDocumentation.size() > 1) { std::ostringstream concatDocString; for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) { - concatDocString << generateDivider(); + concatDocString << generateDivider() << std::endl; concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; concatDocString << generateDivider(); concatDocString << allDocumentation[realOverloadCount] << std::endl; @@ -277,6 +300,6 @@ String *PyDocConverter::makeDocumentation(Node *n) { } std::string PyDocConverter::generateDivider() { - static string dividerString('-', DOC_STRING_LENGTH); + static string dividerString(DOC_STRING_LENGTH, '-'); return dividerString; } diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 319f62875..f14a130ac 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -29,20 +29,6 @@ public: String *makeDocumentation(Node *node); protected: - /* - * Format the doxygen comment relating to a function or method parameter - * @param node The parse tree node that the parameter relates to. - * @param doxygenEntity The doxygen entity relating to the parameter docstring. - */ - std::string formatParam(Node *node, DoxygenEntity & doxygenEntity); - - /* - * Format the doxygen comment relating to the return value for a method or function. - * @param node The parse tree node that the parameter relates to. - * @param doxygenEntity The doxygen entity relating to the parameter docstring. - */ - std::string formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity); - /* * Format a string so it is justified and split over several lines * not exeeding a given length. @@ -51,8 +37,16 @@ protected: * @param maxWidth The approximate maximum line width. */ std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); - + /* + * Translate every entity in a tree, also manages sections + * display. Prints title for every group of tags that have + * a section title associated with them + */ std::string translateSubtree(DoxygenEntity & doxygenEntity); + /* + * Translate one entity with the appropriate handler, acording + * to the tagHandlers + */ void translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment); /* @@ -92,20 +86,27 @@ protected: * arg - message */ void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); - /* - * Insert 'Image: ...' - */ - void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Insert 'Title: ...' */ void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Format nice param description with type information + */ + void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Utility method to generate a diving line for a documentation string. */ std::string generateDivider(); + /* + * Simple helper function that calculates correct parameter type + * of the node stored in 'currentNode' + * If param with specified name is not found, empty string is returned + */ + std::string getParamType(std::string name); + private: bool debug; // temporary thing, should be refactored somehow From 791ea1ba3a5a6f697fc873de7e9d1a15eb9cdab0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 10:52:59 +0000 Subject: [PATCH 0096/2031] Enhanced commentParser.java, improved string comparison (now ignoring whitespaces), improved comments text output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13342 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/commentParser.java | 30 ++++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/java/commentParser.java b/Examples/test-suite/java/commentParser.java index 93785669e..94beb8c2f 100644 --- a/Examples/test-suite/java/commentParser.java +++ b/Examples/test-suite/java/commentParser.java @@ -17,19 +17,19 @@ public class commentParser { for (ClassDoc classDoc : root.classes()) { if (classDoc.getRawCommentText().length() > 0) - parsedComments.put(classDoc.name(), classDoc.getRawCommentText()); + parsedComments.put(classDoc.qualifiedName(), classDoc.getRawCommentText()); for (FieldDoc f : classDoc.enumConstants()) { if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); + parsedComments.put(f.qualifiedName(), f.getRawCommentText()); } for (FieldDoc f : classDoc.fields()) { if (f.getRawCommentText().length() > 0) - parsedComments.put(f.name(), f.getRawCommentText()); + parsedComments.put(f.qualifiedName(), f.getRawCommentText()); } for (MethodDoc m : classDoc.methods()) { if (m.getRawCommentText().length() > 0) - parsedComments.put(m.name(), m.getRawCommentText()); + parsedComments.put(m.toString(), m.getRawCommentText()); } } return true; @@ -42,9 +42,21 @@ public class commentParser { while (it.hasNext()) { Entry e = (Entry) it.next(); + String actualStr = e.getValue(); + String wantedStr = wantedComments.get(e.getKey()); + // this may be weird, but I don't know any more effective solution + actualStr = actualStr.replace(" ", ""); + actualStr = actualStr.replace("\n", ""); + actualStr = actualStr.replace("\t", ""); + if (wantedStr != null) { + wantedStr = wantedStr.replace(" ", ""); + wantedStr = wantedStr.replace("\n", ""); + wantedStr = wantedStr.replace("\t", ""); + } - if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + if (!actualStr.equals(wantedStr)) { System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + // here we print original strings, for nicer output System.out.println("\texpected:"+wantedComments.get(e.getKey())); System.out.println("\tgot:\t"+e.getValue()); errorCount++; @@ -64,7 +76,11 @@ public class commentParser { while (it.hasNext()) { Entry e = (Entry) it.next(); - System.out.format("wantedComments.put(\"%s\", \"%s\");\n", e.getKey(), e.getValue()); + String commentText = e.getValue(); + commentText = commentText.replace("\\", "\\\\"); + commentText = commentText.replace("\"", "\\\""); + commentText = commentText.replace("\n", "\\n\" +\n\t\t\""); + System.out.format("wantedComments.put(\"%s\",\n\t\t\"%s\");\n", e.getKey(), commentText); } } @@ -82,4 +98,4 @@ public class commentParser { printCommentListForJavaSource(); } -} \ No newline at end of file +} From 07552d3b094daed26ec520399d94690abf850a20 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 11:17:42 +0000 Subject: [PATCH 0097/2031] Fixed ignored commands in JavaDocConverter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13343 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 62b9762f4..8f6725f5c 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -29,6 +29,7 @@ void JavaDocConverter::fillStaticTables() { tagHandlers["c"] = make_pair(&JavaDocConverter::handleTagHtml, "code"); tagHandlers["cite"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); tagHandlers["e"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); + tagHandlers["em"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); tagHandlers["li"] = make_pair(&JavaDocConverter::handleTagHtml, "li"); tagHandlers["p"] = make_pair(&JavaDocConverter::handleTagHtml, "code"); // these commands insert just a single char, some of them need to be escaped @@ -47,9 +48,17 @@ void JavaDocConverter::fillStaticTables() { // these commands are stripped out tagHandlers["attention"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["brief"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["bug"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["date"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["details"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["htmlonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["invariant"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["latexonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["manonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); tagHandlers["partofdescription"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["rtfonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["short"] = make_pair(&JavaDocConverter::handleParagraph, ""); + tagHandlers["xmlonly"] = make_pair(&JavaDocConverter::handleParagraph, ""); // these commands are kept as-is, they are supported by JavaDoc tagHandlers["author"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["authors"] = make_pair(&JavaDocConverter::handleTagSame, "author"); From 32ac8c0be4c89606a13c997eb3fdd7d9741ebe3b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 11:19:04 +0000 Subject: [PATCH 0098/2031] Added doxygen_basic_translate runtime test for java git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13344 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/doxygen_basic_translate_runme.java | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index 34270de56..50d6cedda 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -25,10 +25,52 @@ public class doxygen_basic_translate_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("function", " Brief description. \n The comment text \n" + - " @author\tSome author \n" + - " @return\tSome number \n" + - " @see\tfunction2 \n"); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function()", + " \n" + + " Brief description. \n" + + " \n" + + " The comment text \n" + + " @author Some author \n" + + " @return Some number \n" + + " @see function2 \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function2()", + " A test of a very very very very very very very very very very very very very very very very \n" + + " very very very very very long comment string. \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function4()", + " A test of some mixed tag usage \n" + + " If: CONDITION {\n" + + " This code fragment shows us something . \n" + + "

      \n" + + "

    • it's senseless \n" + + "
    • it's stupid \n" + + "
    • it's null \n" + + " \n" + + "
    • Warning: This may not work as expected \n" + + " \n" + + " {@code \n" + + "int main() { while(true); } \n" + + " }\n" + + " }\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function3(int)", + " A test for overloaded functions \n" + + " This is function one \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5(int)", + " Test for default args \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function3(int, int)", + " A test for overloaded functions \n" + + " This is function two \n" + + " \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); From 4c293c828282c6b95639797a17d4455b97cc2915 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 11:23:47 +0000 Subject: [PATCH 0099/2031] Enhanced and unified all java doxygen tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13345 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygen_parsing_enums_proper_runme.java | 37 ++++-- .../doxygen_parsing_enums_simple_runme.java | 27 +++- .../doxygen_parsing_enums_typesafe_runme.java | 38 ++++-- ...oxygen_parsing_enums_typeunsafe_runme.java | 37 ++++-- .../java/doxygen_parsing_runme.java | 124 ++++++++++++++---- .../doxygen_translate_all_tags_runme.java | 120 +++++++++++++++++ .../java/doxygen_translate_runme.java | 10 +- 7 files changed, 333 insertions(+), 60 deletions(-) create mode 100644 Examples/test-suite/java/doxygen_translate_all_tags_runme.java diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index 4531ada51..b96ee66ea 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -25,14 +25,35 @@ public class doxygen_parsing_enums_proper_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); - wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); - wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); - wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); - wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); - wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); - wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); - wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_10", + "Post comment for the first item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_1", + " The comment for the first item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum", + " Testing comments before enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_30", + "Post comment for the third item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2", + " Testing comments after enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_3", + " The comment for the third item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum.SOME_ITEM_2", + " The comment for the second item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_20", + "Post comment for the second item \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index 7fba76d5c..cd97c9a4f 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -25,12 +25,27 @@ public class doxygen_parsing_enums_simple_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); - wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); - wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); - wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); - wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); - wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_30", + "Post comment for the third item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_3", + " The comment for the third item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_2", + " The comment for the second item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_10", + "Post comment for the first item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_20", + "Post comment for the second item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_1", + " The comment for the first item \n" + + " \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index f853ffb3b..85ac15fe8 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -25,14 +25,36 @@ public class doxygen_parsing_enums_typesafe_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); - wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); - wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); - wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); - wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); - wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); - wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); - wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_1", + " The comment for the first item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2", + " Testing comments after enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_2", + " The comment for the second item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_20", + "Post comment for the second item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum", + " Testing comments before enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_10", + "Post comment for the first item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum.SOME_ITEM_3", + " The comment for the third item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_30", + "Post comment for the third item \n" + + ""); + // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index 9788ae1d3..6f453060d 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -25,14 +25,35 @@ public class doxygen_parsing_enums_typeunsafe_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("SomeAnotherEnum", " Testing comments before enum items \n"); - wantedComments.put("SOME_ITEM_1", " The comment for the first item \n"); - wantedComments.put("SOME_ITEM_2", " The comment for the second item \n"); - wantedComments.put("SOME_ITEM_3", " The comment for the third item \n"); - wantedComments.put("SomeAnotherEnum2", " Testing comments after enum items \n"); - wantedComments.put("SOME_ITEM_10", " Post comment for the first item \n"); - wantedComments.put("SOME_ITEM_20", " Post comment for the second item \n"); - wantedComments.put("SOME_ITEM_30", " Post comment for the third item \n"); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_2", + " The comment for the second item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_3", + " The comment for the third item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum.SOME_ITEM_1", + " The comment for the first item \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_20", + "Post comment for the second item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum", + " Testing comments before enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2", + " Testing comments after enum items \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_30", + "Post comment for the third item \n" + + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_10", + "Post comment for the first item \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index e0719c586..322a4e42c 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -25,31 +25,105 @@ public class doxygen_parsing_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("someFunction", " The function comment \n"); - wantedComments.put("SomeEnum", " The enum comment \n"); - wantedComments.put("setSomeVar", " The var comment \n"); - wantedComments.put("getSomeVar", " The var comment \n"); - wantedComments.put("SomeClass", " The class comment \n"); - wantedComments.put("setClassAttr", " The class attribute comment \n"); - wantedComments.put("getClassAttr", " The class attribute comment \n"); - wantedComments.put("setClassAttr2", " The class attribute post-comment \n"); - wantedComments.put("getClassAttr2", " The class attribute post-comment \n"); - wantedComments.put("setClassAttr3", " The class attribute post-comment with details \n"); - wantedComments.put("getClassAttr3", " The class attribute post-comment with details \n"); - wantedComments.put("classMethod", " The class method comment \n"); - wantedComments.put("classMethodExtended", " The class method with parameter \n @param a Parameter a \n @param b Parameter b \n"); - wantedComments.put("classMethodExtended2", " The class method with parameter \n @param a Parameter a \n @param b Parameter b \n"); - wantedComments.put("SomeStruct", " The struct comment \n"); - wantedComments.put("setStructAttr", " The struct attribute comment \n"); - wantedComments.put("getStructAttr", " The struct attribute comment \n"); - wantedComments.put("setStructAttr2", " The struct attribute post-comment \n"); - wantedComments.put("getStructAttr2", " The struct attribute post-comment \n"); - wantedComments.put("setStructAttr3", " The struct attribute post-comment with details \n"); - wantedComments.put("getStructAttr3", " The struct attribute post-comment with details \n"); - wantedComments.put("structMethod", " The struct method comment \n"); - wantedComments.put("structMethodExtended", " The struct method with parameter \n @param a Parameter a \n @param b Parameter b \n"); - wantedComments.put("structMethodExtended2", " The struct method with parameter \n @param a Parameter a \n @param b Parameter b \n"); - + wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr()", + " The class attribute comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr3(int)", + "The class attribute post-comment with details \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr3(int)", + "The struct attribute post-comment with details \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethodExtended2(int, int)", + " The class method with parameter \n" + + " \n" + + " @param a Parameter a \n" + + " @param b Parameter b \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeStruct", + " The struct comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.doxygen_parsing.setSomeVar(int)", + " The var comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethod()", + " The struct method comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.doxygen_parsing.someFunction()", + " The function comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethodExtended(int, int)", + " The class method with parameter \n" + + " \n" + + " @param a Parameter a \n" + + " @param b Parameter b \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr(int)", + " The class attribute comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethodExtended(int, int)", + " The struct method with parameter \n" + + " \n" + + " @param a Parameter a \n" + + " @param b Parameter b \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr()", + " The struct attribute comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeClass", + " The class comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr3()", + "The struct attribute post-comment with details \n" + + ""); + wantedComments.put("doxygen_parsing.doxygen_parsing.getSomeVar()", + " The var comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr2(int)", + "The struct attribute post-comment \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr2()", + "The class attribute post-comment \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.getStructAttr2()", + "The struct attribute post-comment \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.setStructAttr(int)", + " The struct attribute comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeEnum", + " The enum comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr3()", + "The class attribute post-comment with details \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.classMethod()", + " The class method comment \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherStruct.structMethodExtended2(int, int)", + " The struct method with parameter \n" + + " \n" + + " @param a Parameter a \n" + + " @param b Parameter b \n" + + " \n" + + ""); + wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr2(int)", + "The class attribute post-comment \n" + + ""); + // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java new file mode 100644 index 000000000..065dfa27e --- /dev/null +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -0,0 +1,120 @@ + +import doxygen_translate_all_tags.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_translate_all_tags_runme { + static { + try { + System.loadLibrary("doxygen_translate_all_tags"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + commentParser parser = new commentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_translate_all_tags runtime test", + "commentParser", new String[]{"-quiet", "doxygen_translate_all_tags"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.function(int, float)", + " Hello \n" + + "
    • some list item \n" + + "
    • This is attention! \n" + + " You were warned! \n" + + " @author lots of them \n" + + " @author Zubr \n" + + " boldword \n" + + " Some brief description, \n" + + " extended to many lines. \n" + + " Not everything works right now... \n" + + " codeword \n" + + " citationword \n" + + " {@code some test code }\n" + + " Conditional comment: SOMECONDITION \n" + + " Some conditional comment \n" + + " End of conditional comment.\n" + + " Copyright: some copyright \n" + + " 1970 - 2012 \n" + + " @deprecated Now use another function \n" + + " This is very large \n" + + " and detailed description of some thing \n" + + " italicword \n" + + " emphazedWord \n" + + " @exception SuperError \n" + + " This will only appear in hmtl \n" + + " If: ANOTHERCONDITION {\n" + + " First part of comment \n" + + " If: SECONDCONDITION {\n" + + " Nested condition text \n" + + " }Else if: THIRDCONDITION {\n" + + " The third condition text \n" + + " }Else: {The last text block \n" + + " }\n" + + " }Else: {Second part of comment \n" + + " If: CONDITION {\n" + + " Second part extended \n" + + " }\n" + + " }\n" + + " If not: SOMECONDITION {\n" + + " This is printed if not \n" + + " }\n" + + " \"Hello,\n" + + " Some text \n" + + " describing invariant. \n" + + " This will only appear in LATeX \n" + + "
        \n" + + "
      • Some unordered list \n" + + "
      • With lots of items \n" + + "
      • lots of lots of items \n" + + "
      \n" + + " {@link someMember Some description follows }\n" + + " This will only appear in man \n" + + " Note: Here \n" + + " is the note! \n" + + " This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.\n" + + " someword \n" + + " @package superPackage \n" + + "

      \n" + + " The paragraph text. \n" + + " Maybe even multiline \n" + + "

      \n" + + " @param a the first param \n" + + " Remarks: Some remark text \n" + + " Remarks: Another remarks section \n" + + " @return Whatever \n" + + " @return it \n" + + " @return may return \n" + + " This will only appear in RTF \n" + + " @see someOtherMethod \n" + + " @see function \n" + + " Same as \n" + + " brief description \n" + + " @since version 0.0.0.1 \n" + + " @throws superException \n" + + " @throws RuntimeError \n" + + " TODO: Some very important task \n" + + " @param b B is mentioned again... \n" + + " {@literal \n" + + "very long \n" + + "text with tags \n" + + " }\n" + + " @version 0.0.0.2 \n" + + " Warning: This is senseless! \n" + + " This will only appear in XML \n" + + " Here goes test of symbols: \n" + + " $ @ \\ & ~ < > # % \" . :: \n" + + " And here goes simple text \n" + + ""); + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_translate_runme.java b/Examples/test-suite/java/doxygen_translate_runme.java index 6eec790e2..cfd62d79c 100644 --- a/Examples/test-suite/java/doxygen_translate_runme.java +++ b/Examples/test-suite/java/doxygen_translate_runme.java @@ -25,7 +25,8 @@ public class doxygen_translate_runme { HashMap wantedComments = new HashMap(); - wantedComments.put("function", " Hello \n" + + wantedComments.put("doxygen_translate.doxygen_translate.function(int, float)", + " Hello \n" + " \n" + "
    • some list item \n" + " \n" + @@ -91,8 +92,7 @@ public class doxygen_translate_runme { " Note: Here \n" + " is the note! \n" + " \n" + - " This is an overloaded member function, provided for convenience. \n" + - " It differs from the above function only in what argument(s) it accepts.\n" + + " This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.\n" + " \n" + " someword \n" + " \n" + @@ -141,8 +141,8 @@ public class doxygen_translate_runme { " $ @ \\ & ~ < > # % \" . :: \n" + " \n" + " And here goes simple text \n" + - " \n"); - + " \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } From 8a683e42d0341388a46b964572d46ecf40a69796 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 23 Jul 2012 13:50:27 +0000 Subject: [PATCH 0100/2031] Fixed and updated all doxygen python tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13346 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../python/doxygen_basic_translate_runme.py | 62 ++++ .../python/doxygen_parsing_runme.py | 56 +-- .../doxygen_translate_all_tags_runme.py | 320 ++++++++++++++++++ .../python/doxygen_translate_runme.py | 148 ++++++++ 4 files changed, 562 insertions(+), 24 deletions(-) create mode 100644 Examples/test-suite/python/doxygen_basic_translate_runme.py create mode 100644 Examples/test-suite/python/doxygen_translate_all_tags_runme.py create mode 100644 Examples/test-suite/python/doxygen_translate_runme.py diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py new file mode 100644 index 000000000..95596c1f3 --- /dev/null +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -0,0 +1,62 @@ +#!/usr/bin/python + +import doxygen_basic_translate +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_basic_translate.function.__doc__, '' +' Brief description.\n' +' The comment text\n' +' Authors:\n' +' Some author\n' +' Return:\n' +' Some number\n' +' See also:\n' +' function2\n' +) +check(doxygen_basic_translate.function2.__doc__, '' +' A test of a very very very very very very very very very very very' +' very very very very very' +' very very very very very long comment' +' string.' +) +check(doxygen_basic_translate.function3.__doc__, '' +' ----------------------------------------------------------------\n' +' Overload 1:\n' +' ----------------------------------------------------------------\n' +' A test for overloaded functions\n' +' This is function __one__\n' +' ----------------------------------------------------------------\n' +' Overload 2:\n' +' ----------------------------------------------------------------\n' +' A test for overloaded functions\n' +' This is function __two__\n' +) +check(doxygen_basic_translate.function4.__doc__, '' +' A test of some mixed tag usage\n' +' If: CONDITION {\n' +' This _code_fragment shows us something .\n' +' Title: Minuses:\n' +' -it\'s senseless\n' +' -it\'s stupid\n' +' -it\'s null\n' +' Warning:\n' +' This may not work as expected\n' +' int main() { while(true); }\n' +' }' +) +check(doxygen_basic_translate.function5.__doc__, '' +' Test for default args' +) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index b814a68ed..cb22bb369 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -1,39 +1,47 @@ #!/usr/bin/python import doxygen_parsing +import string import sys -import re def check(got, expected): - if not re.match(str(expected), str(got)): - raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") -check(doxygen_parsing.someFunction.__doc__, '\s+The function comment\s+') -check(doxygen_parsing.SomeClass.__doc__, '\s+The class comment\s+') -check(doxygen_parsing.SomeStruct.__doc__, '\s+The struct comment\s+') -check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__, '\s+The class method comment\s+') +check(doxygen_parsing.someFunction.__doc__, 'The function comment') +check(doxygen_parsing.SomeClass.__doc__, 'The class comment') +check(doxygen_parsing.SomeStruct.__doc__, 'The struct comment') +check(doxygen_parsing.SomeAnotherClass.classMethod.__doc__, 'The class method comment') check(doxygen_parsing.SomeAnotherClass.classMethodExtended.__doc__, '' -'\s+The class method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The class method with parameter\n' +'Arguments:\n' +'a (int) -- Parameter a\n' +'b (int) -- Parameter b\n' ) check(doxygen_parsing.SomeAnotherClass.classMethodExtended2.__doc__, '' -'\s+The class method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The class method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) -check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__, '\s+The struct method comment\s+') +check(doxygen_parsing.SomeAnotherStruct.structMethod.__doc__, 'The struct method comment') check(doxygen_parsing.SomeAnotherStruct.structMethodExtended.__doc__, '' -'\s+The struct method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The struct method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) check(doxygen_parsing.SomeAnotherStruct.structMethodExtended2.__doc__, '' -'\s+The struct method with parameter' -'\s+Arguments:\s+' -'a \(int\)\s+-- Parameter a\s+' -'b \(int\)\s+-- Parameter b\s+' +'The struct method with parameter\n' +'Arguments:\n' +'a (int)-- Parameter a\n' +'b (int)-- Parameter b\n' ) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py new file mode 100644 index 000000000..768ccf1ba --- /dev/null +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -0,0 +1,320 @@ +#!/usr/bin/python + +import doxygen_translate_all_tags +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_translate_all_tags.function.__doc__, '' +' _Hello_' +'' +' SomeLatexIndex ' +'' +' someGroupSome title ' +'' +' theAnchor' +'' +' -some list item ' +'' +' This is attention! ' +' You were warned! ' +'' +' Authors:' +' lots of them ' +'' +' Zubr ' +'' +' __boldword__' +'' +' Some brief description, ' +' extended to many lines. ' +'' +' Not everything works right now... ' +'' +' codeword' +'' +' someCategoryheaderFile.hheaderName' +'' +' \'citationword\'' +'' +' someClassheaderFile.hheaderName' +'' +' some test code ' +'' +' Conditional comment: SOMECONDITION' +' Some conditional comment ' +' End of conditional comment.' +'' +' someClass::someMethod' +'' +' someClass::someMethod2' +'' +' someClass::someMethod3' +'' +' Copyright:' +' some copyright ' +'' +' 1970 - 2012 ' +'' +' someDefine' +'' +' someGroupSome titles ' +'' +' Deprecated:' +' Now use another function ' +'' +' This is very large ' +' and detailed description of some thing ' +'' +' /somePath/someFolder' +'' +' someFile.h' +'' +' digraph example { ' +' node [shape=record, fontname=Helvetica, fontsize=10]; ' +'' +' b [ label="class B" URL="\ref B"]; ' +' c [ label="class C" URL="\ref C"]; ' +' b -> c [ arrowhead="open", style="dashed" ]; ' +' } ' +'' +'' +' dotFile.dotThe caption' +'' +' _italicword_' +'' +' emphazedWord' +'' +' someEnum' +'' +' Example:' +' someFile.txt' +' Some details on using the example ' +'' +' Throws:' +' SuperError' +'' +' someOtherFunction' +'' +' file.h' +'' +' someFn ' +'' +' someHeader.hHeader name' +'' +' htmlFile.htm' +'' +' This will only appear in hmtl ' +'' +' If: ANOTHERCONDITION {' +' First part of comment ' +' If: SECONDCONDITION {' +' Nested condition text ' +' }Else if: THIRDCONDITION {' +' The third condition text ' +' }Else: {The last text block ' +' }' +' }Else: {Second part of comment ' +' If: CONDITION {' +' Second part extended ' +' }' +' }' +'' +' If not: SOMECONDITION {' +' This is printed if not ' +' }' +'' +' Image: htmltestImage.bmpHello, world!asd=10qwe' +'' +' someFunction' +'' +' header.h' +'' +' header2.h' +'' +' someGroupanotherGroup' +'' +' Some text ' +' describing invariant. ' +'' +' someInterfacesomeHeader.hHeader name' +'' +' This will only appear in LATeX ' +'' +'
        ' +'' +' -Some unordered list ' +' -With lots of items ' +' -lots of lots of items ' +'' +'
      ' +'' +' example ' +'' +' someMember Some description follows ' +'' +' Sometitle ' +'' +' This will only appear in man ' +'' +' someThing' +'' +' Sender,Receiver; ' +' Sender->Receiver [label="Command()", URL="\ref ' +' Receiver::Command()"]; ' +' Sender<-Receiver [label="Ack()", URL="\ref ' +' Ack()", ID="1"]; ' +'' +' mscFile.mscThe caption' +'' +' someHeader.h ' +'' +' someNamespace' +'' +' Notes:' +' Here ' +' is the note! ' +'' +' This is an overloaded member function, provided for convenience.' +' It differs from the above function only in what argument(s) it accepts.' +'' +' someword' +'' +' superPackage' +'' +' somePageThe title ' +'' +' Title: The paragraph title ' +' The paragraph text. ' +' Maybe even multiline ' +'' +' someParagraphParagraph title ' +'' +' Arguments:' +' a (int) -- the first param ' +'' +' Some description ' +'' +' Some description ' +'' +' someVar ' +'' +' someProtocolheader.hHeader name' +'' +' someAnchor' +'' +' toSomething' +'' +' toSomethingElse' +'' +' someName' +'' +' someName' +'' +' Remarks:' +' Some remark text ' +'' +' Another remarks section ' +'' +' Return:' +' Whatever ' +'' +' it ' +'' +' may return ' +'' +' someValueSome description ' +'' +'' +' This will only appear in RTF ' +'' +'' +' See also:' +' someOtherMethod ' +'' +' someSectionSome title ' +'' +' function ' +'' +' Same as ' +' brief description ' +'' +'' +'' +' Since:' +' version 0.0.0.1 ' +'' +' somePattern ' +'' +' someLine ' +'' +' example.hSome snippet ' +'' +' someStruct' +'' +' someSubpageSome description' +'' +' someSubsectionSome title ' +'' +' someSubsectionSome title ' +'' +'' +'' +' Some ' +' description of the ' +' test case ' +'' +' Throws:' +' superException' +'' +' RuntimeError' +'' +' TODO:' +' Some very important task ' +'' +' Arguments:' +' b (float) -- B is mentioned again... ' +'' +' someTypedef ' +'' +' someUnion' +'' +' somePattern ' +'' +' someVar ' +'' +'' +' very long ' +' text with tags ' +'' +'' +' someFile.h' +'' +' Version:' +' 0.0.0.2 ' +'' +' Warning:' +' This is senseless! ' +'' +' someGroupSome title ' +'' +'' +' This will only appear in XML ' +'' +'' +' Here goes test of symbols: ' +' $@\&~<>#%".::' +'' +' And here goes simple text ' +) \ No newline at end of file diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py new file mode 100644 index 000000000..61e5f5398 --- /dev/null +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -0,0 +1,148 @@ +#!/usr/bin/python + +import doxygen_translate +import string +import sys + +def check(got, expected): + #if got is Null + # raise RuntimeError('Expected comment string\n') + gotStr = string.replace(got, ' ', '') + gotStr = string.replace(gotStr, '\n', '') + gotStr = string.replace(gotStr, '\t', '') + expectedStr = string.replace(expected, ' ', '') + expectedStr = string.replace(expectedStr, '\n', '') + expectedStr = string.replace(expectedStr, '\t', '') + if not gotStr == expectedStr: + raise RuntimeError("Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]\n") + +check(doxygen_translate.function.__doc__, '' +' _Hello_' +'' +' -some list item ' +'' +' Authors:' +' lots of them ' +'' +' Zubr ' +'' +' __boldword__' +'' +' codeword' +'' +' \'citationword\'' +'' +' some test code ' +'' +' Conditional comment: SOMECONDITION' +' Some conditional comment ' +' End of conditional comment.' +'' +' Copyright:' +' some copyright ' +'' +' Deprecated:' +' Now use another function ' +'' +' _italicword_' +'' +' Example:' +' someFile.txt' +' Some details on using the example ' +'' +' Throws:' +' SuperError' +'' +' If: ANOTHERCONDITION {' +' First part of comment ' +' If: SECONDCONDITION {' +' Nested condition text ' +' }Else if: THIRDCONDITION {' +' The third condition text ' +' }Else: {The last text block ' +' }' +' }Else: {Second part of comment ' +' If: CONDITION {' +' Second part extended ' +' }' +' }' +'' +' If not: SOMECONDITION {' +' This is printed if not ' +' }' +'' +' Image: htmltestImage.bmpHello, world!asd=10qwe' +'' +'
        ' +'' +' -Some unordered list ' +' -With lots of items ' +' -lots of lots of items ' +'' +'
      ' +'' +' someMember Some description follows ' +'' +' Notes:' +' Here ' +' is the note! ' +'' +' This is an overloaded member function, provided for convenience.' +' It differs from the above function only in what argument(s) it accepts.' +'' +' someword' +'' +' superPackage' +'' +' Title: The paragraph title ' +' The paragraph text. ' +' Maybe even multiline ' +'' +' Arguments:' +' a (int) -- the first param ' +'' +' Remarks:' +' Some remark text ' +'' +' Another remarks section ' +'' +' Return:' +' Whatever ' +'' +' it ' +'' +' may return ' +'' +' See also:' +' someOtherMethod ' +'' +' function ' +'' +' Since:' +' version 0.0.0.1 ' +'' +' Throws:' +' superException' +'' +' RuntimeError' +'' +' TODO:' +' Some very important task ' +'' +' Arguments:' +' b (float) -- B is mentioned again... ' +'' +' very long ' +' text with tags ' +'' +' Version:' +' 0.0.0.2 ' +'' +' Warning:' +' This is senseless! ' +'' +' Here goes test of symbols: ' +' $@\&~<>#%".::' +'' +' And here goes simple text ' +) \ No newline at end of file From a7ae017d55078cf675d130c846ff05f78531d61c Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 25 Jul 2012 07:52:54 +0000 Subject: [PATCH 0101/2031] Fixed some spelling in project plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13396 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 6566598fe..6f012cd4b 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -2,29 +2,35 @@ + Project Plan + ============ + SWIG Code Comments + Google Summer of Code 2012 + + This document describes goals for the Google Summer of Code 2012, SWIG code documentation project. -Author: Marko Klopcic +Author: Marko Klopcic, Dmitry Kabak Introduction ============ -The goal of this project is _not_ to translate _any_ possible doxygen +The goal of this project is _not_ to translate _any_ possible Doxygen formatted comment to JavaDoc or PyDoc, but to make it possible to translate a subset of comment types in C/C++ code to JavaDoc and PyDoc. Covering all the Doxygen functionality would be to -complex for the limited time. Hovewer, the code must be extendable so +complex for the limited time. However, the code must be flexible so that implementing missing features would not require redesign of the comment handling code in SWIG. -There will also be a possiblity to add untranslated comments to Java +There will also be a possibility to add untranslated comments to Java and Python code (## comments, see Doxygen manual), if the user will prefer to use Doxygen on the generated code. Note: -'-OK-' tick below means that the item is implemented, commited and +'-OK-' tick below means that the item is implemented, committed and working. Abbreviations: @@ -249,7 +255,7 @@ Optional functionality ====================== That section describes some complex cases where the current code -not behaves really well. Like a short to-do list of special cases. +does not behave really well. Like a short to-do list of special cases. - When translating functions with default parameters in swig to java, it creates overloaded functions with all the parameters From 0b7d1ffc454522da7eb7b761cece8217ddf98b2d Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 25 Jul 2012 12:11:28 +0000 Subject: [PATCH 0102/2031] Small fix to correctly generate overloaded method comments in python git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13400 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/PyDocConverter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 5b6f39adf..3ae018cf9 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -252,6 +252,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { while (n) { documentation = getDoxygenComment(n); if (!Swig_is_generated_overload(n) && documentation) { + currentNode = n; std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); DoxygenEntity root("root", entityList); allDocumentation.push_back(translateSubtree(root)); From 4951d4a9007a0a64ed67b56e4d0d12a56097fe97 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 28 Jul 2012 09:19:23 +0000 Subject: [PATCH 0103/2031] Got rid of 81 reduce/reduce warnings in parser.y git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13424 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 48 ++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4bf63b40f..6aed8c3f9 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1798,7 +1798,6 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type featattr; %type doxygen_comment; %type doxygen_comment_item; -%type c_style_comment; %type doxygen_post_comment; %type doxygen_post_comment_item; %% @@ -1849,6 +1848,16 @@ interface : interface declaration { appendChild($1,$2); $$ = $1; } + | interface doxygen_comment declaration { + set_comment($3, $2); + appendChild($1, $3); + $$ = $1; + } + | interface declaration doxygen_post_comment { + set_comment($2, $3); + appendChild($1, $2); + $$ = $1; + } | empty { $$ = new_node("top"); } @@ -1857,7 +1866,6 @@ interface : interface declaration { declaration : swig_directive { $$ = $1; } | c_declaration { $$ = $1; } | cpp_declaration { $$ = $1; } - | c_style_comment { $$ = $1; } | SEMI { $$ = 0; } | error { $$ = 0; @@ -1880,15 +1888,6 @@ declaration : swig_directive { $$ = $1; } COPERATOR token---discarding the rest of the definition. Ugh. */ - - | doxygen_comment declaration { - $$ = $2; - set_comment($2, $1); - } - | declaration doxygen_post_comment { - $$ = $1; - set_comment($1, $2); - } | error COPERATOR { $$ = 0; skip_decl(); @@ -3470,15 +3469,14 @@ doxygen_comment_item : DOXYGENSTRING { else { $$ = $1; } - } - ; - -doxygen_comment : doxygen_comment doxygen_comment_item { + | doxygen_comment_item doxygen_comment_item { Append($1, $2); $$ = $1; } - | doxygen_comment_item { + ; + +doxygen_comment : doxygen_comment_item { $$ = $1; } ; @@ -3493,26 +3491,17 @@ doxygen_post_comment_item : DOXYGENPOSTSTRING { $$ = $1; } - ; - -doxygen_post_comment : doxygen_post_comment doxygen_post_comment_item { + | doxygen_post_comment_item doxygen_post_comment_item { Append($1, $2); $$ = $1; } - | doxygen_post_comment_item { + ; + +doxygen_post_comment : doxygen_post_comment_item { $$ = $1; } ; -c_style_comment : C_COMMENT_STRING { - if(currentCComment != 0){ - Append(currentCComment, $1); - } - else currentCComment = $1; - $$ = 0; - } - ; - /* ====================================================================== * C++ Support * ====================================================================== */ @@ -4489,7 +4478,6 @@ cpp_member : c_declaration { $$ = $1; } | storage_class idcolon SEMI { $$ = 0; } | cpp_using_decl { $$ = $1; } | cpp_template_decl { $$ = $1; } - | c_style_comment{ $$ = $1; } | cpp_catch_decl { $$ = 0; } | template_directive { $$ = $1; } | warn_directive { $$ = $1; } From 5fe88acdfb47b68e32e2323d004aefc115f998f0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 29 Jul 2012 11:37:38 +0000 Subject: [PATCH 0104/2031] Forgot to escape special HTML-chars in JavaDocConverter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13425 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/java/doxygen_translate_all_tags_runme.java | 4 ++-- Examples/test-suite/java/doxygen_translate_runme.java | 4 ++-- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index 065dfa27e..6db1f6686 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -111,10 +111,10 @@ public class doxygen_translate_all_tags_runme { " Warning: This is senseless! \n" + " This will only appear in XML \n" + " Here goes test of symbols: \n" + - " $ @ \\ & ~ < > # % \" . :: \n" + + " $ @ \\ & ~ < > # % " . :: \n" + " And here goes simple text \n" + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } -} \ No newline at end of file +} diff --git a/Examples/test-suite/java/doxygen_translate_runme.java b/Examples/test-suite/java/doxygen_translate_runme.java index cfd62d79c..8aa80a6ed 100644 --- a/Examples/test-suite/java/doxygen_translate_runme.java +++ b/Examples/test-suite/java/doxygen_translate_runme.java @@ -138,7 +138,7 @@ public class doxygen_translate_runme { " Warning: This is senseless! \n" + " \n" + " Here goes test of symbols: \n" + - " $ @ \\ & ~ < > # % \" . :: \n" + + " $ @ \\ & ~ < > # % " . :: \n" + " \n" + " And here goes simple text \n" + " \n" + @@ -146,4 +146,4 @@ public class doxygen_translate_runme { // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } -} \ No newline at end of file +} diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 8f6725f5c..636d49ebf 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -36,13 +36,13 @@ void JavaDocConverter::fillStaticTables() { tagHandlers["$"] = make_pair(&JavaDocConverter::handleTagChar, ""); tagHandlers["@"] = make_pair(&JavaDocConverter::handleTagChar, ""); tagHandlers["\\"] = make_pair(&JavaDocConverter::handleTagChar, ""); - tagHandlers["<"] = make_pair(&JavaDocConverter::handleTagChar, ""); - tagHandlers[">"] = make_pair(&JavaDocConverter::handleTagChar, ""); - tagHandlers["&"] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["<"] = make_pair(&JavaDocConverter::handleTagChar, "<"); + tagHandlers[">"] = make_pair(&JavaDocConverter::handleTagChar, ">"); + tagHandlers["&"] = make_pair(&JavaDocConverter::handleTagChar, "&"); tagHandlers["#"] = make_pair(&JavaDocConverter::handleTagChar, ""); tagHandlers["%"] = make_pair(&JavaDocConverter::handleTagChar, ""); tagHandlers["~"] = make_pair(&JavaDocConverter::handleTagChar, ""); - tagHandlers["\""] = make_pair(&JavaDocConverter::handleTagChar, ""); + tagHandlers["\""] = make_pair(&JavaDocConverter::handleTagChar, """); tagHandlers["."] = make_pair(&JavaDocConverter::handleTagChar, ""); tagHandlers["::"] = make_pair(&JavaDocConverter::handleTagChar, ""); // these commands are stripped out From 03da0be1fafce6b67e1d8fef033a1a0dd02a3687 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 29 Jul 2012 11:53:01 +0000 Subject: [PATCH 0105/2031] Fixed numerous 'unused argument' warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13426 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 10 +++++----- Source/DoxygenTranslator/src/PyDocConverter.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 636d49ebf..1f0ea9437 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -177,7 +177,7 @@ void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translated if (tag.entityList.size()) // do not include empty tags translatedComment += "<" + arg + ">" + translateSubtree(tag) + ""; } -void JavaDocConverter::handleNewLine(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void JavaDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) { translatedComment += "\n * "; } void JavaDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { @@ -193,10 +193,10 @@ void JavaDocConverter::handleTagSame(DoxygenEntity& tag, std::string& translated tag.typeOfEntity = arg; translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2); } -void JavaDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void JavaDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string&) { translatedComment += formatCommand(translateSubtree(tag), 0); } -void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void JavaDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string&) { translatedComment += tag.data; if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') translatedComment += " "; @@ -222,7 +222,7 @@ void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& transla translatedComment += formatCommand(arg, 0); handleParagraph(tag, translatedComment, dummy); } -void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translatedComment, std::string&) { if (tag.entityList.size() < 2) return; @@ -245,7 +245,7 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translate translatedComment += " alt=\"" + title +"\""; translatedComment += " />"; } -void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string&) { std::string dummy; translatedComment += "= maxWidth || (stringPosition + 1) == documentString.end()) { + if ((iswspace(*stringPosition) && (int) currentLine.size() >= maxWidth) || (stringPosition + 1) == documentString.end()) { formattedString += currentLine + "\n"; currentLine = ""; } @@ -173,10 +173,10 @@ void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity, std::string &tr handleParagraph(doxyEntity, translatedComment, dummy); } -void PyDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handleParagraph(DoxygenEntity& tag, std::string& translatedComment, std::string&) { translatedComment += justifyString(translateSubtree(tag), 0); } -void PyDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handlePlainString(DoxygenEntity& tag, std::string& translatedComment, std::string&) { translatedComment += tag.data; if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') translatedComment += ""; @@ -186,7 +186,7 @@ void PyDocConverter::handleTagMessage(DoxygenEntity& tag, std::string& translate translatedComment += arg; handleParagraph(tag, translatedComment, dummy); } -void PyDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handleTagChar(DoxygenEntity& tag, std::string& translatedComment, std::string&) { translatedComment += tag.typeOfEntity; } void PyDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { @@ -198,7 +198,7 @@ void PyDocConverter::handleTagIf(DoxygenEntity& tag, std::string& translatedComm translatedComment += " {" + translateSubtree(tag) + "}"; } } -void PyDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string&) { std::string dummy; translatedComment += "Title: "; if (tag.entityList.size()) @@ -206,7 +206,7 @@ void PyDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedCom tag.entityList.pop_front(); handleParagraph(tag, translatedComment, dummy); } -void PyDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string&) { std::string dummy; if (tag.entityList.size() < 2) { // TODO: log error @@ -229,7 +229,7 @@ void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedCo if (tag.entityList.size()) // do not include empty tags translatedComment += arg + translateSubtree(tag) + arg; } -void PyDocConverter::handleNewLine(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { +void PyDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) { translatedComment += "\n"; } From 3fbe45f0c619e33f482782af2af8e2955860c2d1 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 29 Jul 2012 13:48:03 +0000 Subject: [PATCH 0106/2031] Added nice doxygen debug switching (-debug-doxygen-parser and -debug-doxygen-translator) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13427 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 2 +- Source/DoxygenTranslator/src/DoxygenParser.h | 2 +- .../DoxygenTranslator/src/DoxygenTranslator.cpp | 3 ++- Source/DoxygenTranslator/src/DoxygenTranslator.h | 3 ++- .../DoxygenTranslator/src/JavaDocConverter.cpp | 4 +++- Source/DoxygenTranslator/src/JavaDocConverter.h | 3 +-- Source/DoxygenTranslator/src/PyDocConverter.cpp | 3 ++- Source/DoxygenTranslator/src/PyDocConverter.h | 3 +-- Source/Modules/java.cxx | 16 ++++++++++++---- Source/Modules/python.cxx | 13 ++++++++++++- 10 files changed, 37 insertions(+), 15 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 80ded041a..8ed186727 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -17,7 +17,7 @@ std::map DoxygenParser::doxygenCommands; std::set DoxygenParser::doxygenSectionIndicators; -DoxygenParser::DoxygenParser() : noisy(false) { +DoxygenParser::DoxygenParser(bool noisy) : noisy(noisy) { fillTables(); } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index c72ca6fed..5f6432d87 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -19,7 +19,7 @@ #include "TokenList.h" class DoxygenParser { public: - DoxygenParser(); + DoxygenParser(bool noisy = false); virtual ~DoxygenParser(); std::list < DoxygenEntity > createTree(std::string doxygen, std::string fileName, int lineNumber); private: diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 18cf24c85..10f6a4585 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -14,7 +14,8 @@ #include "DoxygenTranslator.h" -DoxygenTranslator::DoxygenTranslator() { +DoxygenTranslator::DoxygenTranslator(bool debugTranslator, bool debugParser) +: debug(debugTranslator), parser(debugParser) { } DoxygenTranslator::~DoxygenTranslator() { } diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 637b30a9e..97be4ee35 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -30,7 +30,7 @@ public: /* * Constructor */ - DoxygenTranslator(); + DoxygenTranslator(bool debugTranslator = false, bool debugParser = false); /* * Virtual destructor. */ @@ -52,6 +52,7 @@ public: String *getDoxygenComment(Node *node); protected: + bool debug; /* * Overridden in subclasses to return the documentation formatted for a given * documentation system. diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 1f0ea9437..165075708 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -21,6 +21,7 @@ std::map > Ja void JavaDocConverter::fillStaticTables() { if (tagHandlers.size()) // fill only once + return; // these commands insert HTML tags tagHandlers["a"] = make_pair(&JavaDocConverter::handleTagHtml, "i"); @@ -105,7 +106,8 @@ void JavaDocConverter::fillStaticTables() { } -JavaDocConverter::JavaDocConverter() : debug(false) { +JavaDocConverter::JavaDocConverter(bool debugTranslator, bool debugParser) +: DoxygenTranslator(debugTranslator, debugParser) { fillStaticTables(); } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index cb876ed6b..1d51a8d7b 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -22,7 +22,7 @@ */ class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter(); + JavaDocConverter(bool debugTranslator = false, bool debugParser = false); String *makeDocumentation(Node *node); protected: @@ -88,7 +88,6 @@ protected: private: - bool debug; // this contains the handler pointer and one string argument static std::map > tagHandlers; void fillStaticTables(); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 5dd622760..a873cfb16 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -91,7 +91,8 @@ void PyDocConverter::fillStaticTables() { tagHandlers["n"] = make_pair(&PyDocConverter::handleNewLine, ""); } -PyDocConverter::PyDocConverter() : debug(false) { +PyDocConverter::PyDocConverter(bool debugTranslator, bool debugParser) +: DoxygenTranslator(debugTranslator, debugParser) { fillStaticTables(); } diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index f14a130ac..9787891c8 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -25,7 +25,7 @@ class PyDocConverter : public DoxygenTranslator { public: - PyDocConverter(); + PyDocConverter(bool debugTranslator = false, bool debugParser = false); String *makeDocumentation(Node *node); protected: @@ -108,7 +108,6 @@ protected: std::string getParamType(std::string name); private: - bool debug; // temporary thing, should be refactored somehow Node *currentNode; // this contains the handler pointer and one string argument diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 49a5e9901..c7174d0fc 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -163,9 +163,6 @@ public: should be easy to implement though */ director_multiple_inheritance = 0; director_language = 1; - - if (doxygen) - doxygenTranslator = new JavaDocConverter(); } ~JAVA() { @@ -242,6 +239,9 @@ public: SWIG_library_directory("java"); + bool debug_doxygen_translator = false; + bool debug_doxygen_parser = false; + // Look for certain command line options for (int i = 1; i < argc; i++) { if (argv[i]) { @@ -271,6 +271,12 @@ public: Swig_mark_arg(i); doxygen = false; scan_doxygen_comments = false; + } else if ((strcmp(argv[i], "-debug-doxygen-translator") == 0)) { + Swig_mark_arg(i); + debug_doxygen_translator = true; + } else if ((strcmp(argv[i], "-debug-doxygen-parser") == 0)) { + Swig_mark_arg(i); + debug_doxygen_parser = true; } else if ((strcmp(argv[i], "-noproxy") == 0)) { Swig_mark_arg(i); proxy_flag = false; @@ -296,7 +302,7 @@ public: } if (doxygen) - doxygenTranslator = new JavaDocConverter(); + doxygenTranslator = new JavaDocConverter(debug_doxygen_translator, debug_doxygen_parser); // Add a symbol to the parser for conditional compilation Preprocessor_define("SWIGJAVA 1", 0); @@ -4537,6 +4543,8 @@ const char *JAVA::usage = (char *) "\ Java Options (available with -java)\n\ -doxygen - Convert C++ doxygen comments to JavaDoc comments in proxy classes (default)\n\ -nodoxygen - Don't convert C++ doxygen comments to JavaDoc comments in proxy classes\n\ + -debug-doxygen-parser - Display doxygen parser module debugging information\n\ + -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ -noproxy - Generate the low-level functional interface instead\n\ of proxy classes\n\ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5d9a97952..f7c9c00c1 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -121,6 +121,8 @@ Python Options (available with -python)\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes (default) \n\ + -debug-doxygen-parser - Display doxygen parser module debugging information\n\ + -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ @@ -332,6 +334,9 @@ public: SWIG_library_directory("python"); + bool debug_doxygen_parser = false; + bool debug_doxygen_translator = false; + for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-interface") == 0) { @@ -430,6 +435,12 @@ public: doxygen = 0; scan_doxygen_comments = 0; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-doxygen-translator") == 0) { + debug_doxygen_translator = true; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-doxygen-parser") == 0) { + debug_doxygen_parser = true; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastunpack") == 0) { fastunpack = 1; Swig_mark_arg(i); @@ -549,7 +560,7 @@ public: } if (doxygen) - doxygenTranslator = new PyDocConverter; + doxygenTranslator = new PyDocConverter(debug_doxygen_translator, debug_doxygen_parser); if (!global_name) global_name = NewString("cvar"); From 8260f4219f39abef61808211206db54b739664d4 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 29 Jul 2012 22:26:31 +0000 Subject: [PATCH 0107/2031] Expanded the Doxygen docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13428 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 4 +- Doc/Manual/Contents.html | 32 +- Doc/Manual/Doxygen.html | 554 ++++++++++++++++++++++++++++++----- 3 files changed, 489 insertions(+), 101 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 6f012cd4b..a3bf2ca39 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -320,8 +320,8 @@ Documentation ============= SWIG documentation will contain: -- command line options -- list of implemented features (types and placements of comments) +-OK- command line options +-OK- list of implemented features (types and placements of comments) - list of unimplemented features (types and placements of comments) - list of tags and their translations (all Doxygen tags). diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 7a05527c6..77518c268 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -524,32 +524,6 @@ -

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

      - - - - -

      17 SWIG and Allegro Common Lisp

      @@ -1717,7 +1691,7 @@ -

      35 SWIG and Doxgeyn Translation

      +

      39 SWIG and Doxygen Translation

    • Developer Information
    • Extending to Other Languages
    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index d0e837756..54fa1b6bf 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

    35 SWIG and Doxygen Translation

    +

    39 SWIG and Doxygen Translation

    @@ -39,7 +39,7 @@ This chapter describes SWIG's support for translating Doxygen comments found in Currently only JavaDoc and PythonDoc is supported.

    -

    35.1 Doxygen Translation Overview

    +

    39.1 Doxygen Translation Overview

    @@ -53,7 +53,7 @@ Questions about running SWIG are best answered in the S The behaviour of this functionality is wildly unpredictable if the interface file is not proper to begin with!

    -

    35.2 Preparations

    +

    39.2 Preparations

    @@ -61,6 +61,7 @@ To make use of the comment translation system, your documentation comments must It is advised that you are certain your comments compile properly with Doxygen before you try to translate them. Doxygen itself is a deeper tool and can provide you better feedback for correcting any syntax errors that may be present. Please look at Doxygen's Documenting the code for proper specificatons for comment format. +However, SWIG's Doxygen parser will still point you most of errors and warnings found in comments (like unterminated strings or missing ending tags).

    @@ -71,17 +72,63 @@ Please look at Doxygen's  Documenting the code)
    +Here they are:
    +
    +/**
    + * JavaDoc style comment, multiline
    + */
    +/*!
    + * QT-style comment, multiline
    + */
    +/**
    + Any of the above, but without intermediate *'s
    + */
    +/// Single-line comment
    +//! Another single-line comment
    +
    +

    + +

    +Also any of the above with '<' added after comment-starting symbol, like /**<, /*!<, ///<, or //!< +will be treated as post-comment and will be assigned to the node before the comment. +
    +Any number of '*' or '/' in doxygen comment is considered to be a separator and is not included in final comment, so you may safely use +comments like /*********/ or //////////. +

    +

    Please note, as SWIG parses input file by itself with strict grammar, there is only a limited support for various cases of comment placement in the file. -Comments can be placed between two C expressions on separate lines: +
    +Comments can be placed before C\C++ expressions on separate lines:

    +/**
    + * Some comment
    + */
     void someOtherFunction();
     /**
      * Some comment
      */
     void someFunction();
    +
    +class Shape {
    +  /*
    +   * Calculate the area in cm^2
    +   */
    +  int getArea();
    +}
    +
    + +

    +After C\C++ expressions at the end of the line: +

    + +
    +int someVariable = 9; ///< This is a var holding magic number 9
    +void doNothing(); ///< This does nothing, nop
     

    @@ -109,38 +156,37 @@ enum E_NUMBERS

    Just remember, if SWIG shows syntax error parsing the file because of your comment, try to move it in some other, 'safer' place as desribed above. +
    +Also, currently only the comments directly before or after the nodes are supported. Doxygen structural comments are stripped out and not assigned to anything.

    -

    35.2.1 Enabling Doxygen Translation

    +

    39.2.1 Enabling Doxygen Translation

    -There are switches like '-doxygen' and '-nodoxygen' in every module that supports converting -documentation comments. The first one is default, so that swig by default produces correct -proxy files with comments. Some comments in some target languages can be manually overriden by specific +There is a switch '-doxygen' in every module that supports converting +documentation comments. Some comments in some target languages can be manually overriden by specific swig's features, like feature:docstring or feature:autodoc, in this cases doxygen comments have lowest priority.

    -Switching off may be needed if swig cannot correctly parse your comments, for example showing Error: -Syntax error in input(1). message. Then it will just strip out every comment out of the code and -continue happily. +If doxygen parsing is switched off, then all the comments are stripped out in parser and all the resources used by comment parser and translator are freed.

    -

    35.2.2 Additional Commandline Options

    +

    39.2.2 Additional Commandline Options

    ALSO TO BE ADDED (JavaDoc Autobrief?)

    -

    35.3 Doxygen To JavaDoc

    +

    39.3 Doxygen To JavaDoc

    If translation is enabled, JavaDoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files.

    -

    35.3.1 Basic Example

    +

    39.3.1 Basic Example

    @@ -224,80 +270,436 @@ When the Doxygen Translator Module encounters a comment it finds nothing useful

    -

    35.3.2 JavaDoc Tags

    +

    39.3.2 JavaDoc Tags

    + + +

    +Here is the list of all doxygen tags and the description of how they are translated to JavaDoc +
    +Doxygen tags: +

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    \awraped with <i> html tag
    \argwrapped with <li> html tag
    \authortranslated to @author
    \authorstranslated to @author
    \bwrapped with <b> html tag
    \cwrapped with <code> html tag
    \citewrapped with <i> html tag
    \codetranslated to {@code ...}
    \condtranslated to 'Conditional comment: <condition>'
    \copyrightreplaced with 'Copyrigth:'
    \deprecatedtranslated to @deprecated
    \ewraped with <i> html tag
    \elsereplaced with '}Else:{'
    \elseifreplaced with '}Else if: <condition>{'
    \emwraped with <i> html tag
    \endcodesee note for \code
    \endcondreplaced with 'End of conditional comment.'
    \endifreplaced with '}'
    \endlinksee note for \link
    \endverbatimsee note for \verbatim
    \exceptiontranslated to @exception
    \ifreplaced with 'If: <condition> {'
    \ifnotreplaced with 'If not: <condition> {'
    \imagetranslated to <img/> html tag only if target=HTML
    \liwraped with <li> html tag
    \linktranslated to {@link ...}
    \nreplaced with new line char
    \notereplaced with 'Note:'
    \overloadprints 'This is an overloaded ...' according to Doxygen docs
    \pwraped with <code> html tag
    \parreplaced with <p alt='title'>...</p>
    \paramtranslated to @param
    \remarkreplaced with 'Remarks:'
    \remarksreplaced with 'Remarks:'
    \resulttranslated to @return
    \returntranslated to @return
    \returnstranslated to @return
    \satranslated to @see
    \seetranslated to @see
    \sincetranslated to @since
    \throwtranslated to @throws
    \throwstranslated to @thtows
    \todoreplaced with 'TODO:'
    \tparamtranslated to @param
    \verbatimtranslated to {@literal ...}
    \versiontranslated to @version
    \warningtranslated to 'Warning:'
    \$prints $ char
    \@prints @ char
    \\prints \ char
    \&prints & char
    \~prints ~ char
    \<prints < char
    \>prints > char
    \#prints # char
    \%prints % char
    \"prints " char
    \.prints . char
    \::prints ::
    +
    + +

    39.3.3 Unsupported tags

    Doxygen has a wealth of tags such as @latexonly that have no equivalent in JavaDoc. -As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed. +As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed with their content just printed out (if it has any sense, typically text content). If you are interested in more of the specifics of JavaDoc, please visit How to Write Doc Comments for the Javadoc Tool. -

    - -

    -Doxygen and JavaDoc Equivalent Tags +
    +Here is the list of these tags:

    -* @param      
    -* @return      
    -* @exception   
    -* @author      
    -* @version     
    -* @see         
    -* @since       
    -* @serial      
    -* @deprecated  
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    \addindex\addtogroup\anchor\attention
    \brief\bug\callgraph\callergraph
    \class\copybrief\copydetails\copydoc
    \date\def\defgroup\details
    \dir\dontinclude\dot\dotfile
    \enddot\endhtmlonly\endinternal\endlatexonly
    \endmanonly\endmsc\endrtfonly\endxmlonly
    \enum\example\extends\f$
    \f[\f]\f{\f}
    \file\fn\headerfile\hideinitializer
    \htmlinclude\htmlonly\implements\include
    \includelineno\ingroup\internal\invariant
    \interface\latexonly\line\mainpage
    \manonly\memberof\msc\mscfile
    \name\namespace\nosubgrouping\package
    \page\paragraph\post\pre
    \private\privatesection\property\protected
    \protectedsection\protocol\public\publicsection
    \ref\related\relates\relatedalso
    \relatesalso\retval\rtfonly\section
    \short\showinitializer\skip\skipline
    \snippet\struct\subpage\subsection
    \subsubsection\tableofcontents\test\typedef
    \union\until\var\verbinclude
    \weakgroup\xmlonly\xrefitem\category
    -

    35.3.3 Other Tags

    - - -

    -Because there are no specific JavaDoc tags for some important information, some tags are given plain English descriptions of their presence, such as @bug. -This is a feature currently still being developed and it is likely that more information from the original Doxygen Comments will be reproduced as this module matures. -

    -

    35.3.4 Bad Behaviour

    - - -

    -There are some tags that the Doxygen Translator Module currently does not expect to encounter. -This includes the PHP-only Doxygen commands such as @publicsection: -

    - -

    - Completely Unsupported Tags -

    -
    -"annotatedclasslist", "classhierarchy", "define", "functionindex", 
    -"header", "headerfilelist", "inherit", "l", "postheader", "private",
    - "privatesection", "protected", "protectedsection", "public", "publicsection"
    -
    - -

    -The parsing behaviour will be unpredictable if any of these are encountered for now. -This should eventually be changed so that they are simply ignored. -

    -

    -In general parsing errors should not interfere with the operation of SWIG itself. -Blank comments or lack of comments could be an indication of either a parsing error or a lack of meaningful tags in a specific blob of doxygen. -

    - - -

    35.3.5 Further Details

    +

    39.3.4 Further Details

    TO BE ADDED.

    - -

    35.4 Developer Information

    +

    39.4 Developer Information

    Currently a good deal of this Module still needs some reworking, particularly on the side of the parser and JavaDoc producer.

    -

    35.4.1 Module Design

    +

    39.4.1 Module Design

    @@ -320,7 +722,19 @@ This module builds its own private parse tree and hands it to a separate class f For example, JavaDocConverter is the JavaDoc module class.

    -

    35.5 Extending to Other Languages

    +

    39.4.2 Debugging commands

    + + +

    +There are two handy command line switches, that enable lots of detailed debug information printing. +

    + +
    +  -debug-doxygen-parser     - Display doxygen parser module debugging information
    +  -debug-doxygen-translator - Display doxygen translator module debugging information
    +
    + +

    39.5 Extending to Other Languages

    From 64b5efc5d7d69b36a3c3b1d448edfa702e43cad1 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 30 Jul 2012 08:07:15 +0000 Subject: [PATCH 0108/2031] Updated documentation, added description of PyDoc tags git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13429 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 4 +- Doc/Manual/Contents.html | 7 + Doc/Manual/Doxygen.html | 532 +++++++++++++++++++++++++++++++++-- 3 files changed, 519 insertions(+), 24 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index a3bf2ca39..43fc1adc3 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -322,6 +322,6 @@ Documentation SWIG documentation will contain: -OK- command line options -OK- list of implemented features (types and placements of comments) -- list of unimplemented features (types and placements of comments) -- list of tags and their translations (all Doxygen tags). +-OK- list of unimplemented features (types and placements of comments) +-OK- list of tags and their translations (all Doxygen tags). diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 77518c268..ca66d87cc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1709,6 +1709,13 @@

  • Unsupported tags
  • Further Details +
  • Doxygen To PythonDoc +
  • Developer Information
    • Module Design diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 54fa1b6bf..77c00b40e 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -22,6 +22,13 @@
    • Unsupported tags
    • Further Details
    +
  • Doxygen To PythonDoc +
  • Developer Information
    • Module Design @@ -220,9 +227,9 @@ Simply running SWIG should result in the following code being present in Shapes.
       
       /**
      - * This is describing class Shape  
      + * This is describing class Shape 
      + * @author Bob 
        * 
      - * @author	Bob  
        */
       
       public class Shape {
      @@ -230,35 +237,40 @@ public class Shape {
       ...
       
       /**
      - * Important Variables  
      - * 
      + * Important Variables 
        */
         public void setX(double value) {
      -    exampleJNI.Shape_x_set(swigCPtr, this, value);
      +    ShapesJNI.Shape_x_set(swigCPtr, this, value);
         }
       
       /**
      - * Important variables  
      + * Important Variables 
        */
         public double getX() {
      -    return exampleJNI.Shape_x_get(swigCPtr, this);
      +    return ShapesJNI.Shape_x_get(swigCPtr, this);
         }
       
      -...
      +/**
      + * Moves the Shape 
      + */
      +  public void move(double dx, double dy) {
      +    ShapesJNI.Shape_move(swigCPtr, this, dx, dy);
      +  }
       
       /**
      - * @return	the area  
      + * @return the area 
        */
         public double area() {
      -    return exampleJNI.Shape_area(swigCPtr, this);
      +    return ShapesJNI.Shape_area(swigCPtr, this);
         }
       
       /**
      - * @return	the perimeter  
      + * @return the perimeter 
        */
         public double perimeter() {
      -    return exampleJNI.Shape_perimeter(swigCPtr, this);
      +    return ShapesJNI.Shape_perimeter(swigCPtr, this);
         }
      +}
       
       
      @@ -282,7 +294,7 @@ Here is the list of all doxygen tags and the description of how they are transla - + @@ -327,7 +339,7 @@ Here is the list of all doxygen tags and the description of how they are transla - + @@ -339,7 +351,7 @@ Here is the list of all doxygen tags and the description of how they are transla - + @@ -379,7 +391,7 @@ Here is the list of all doxygen tags and the description of how they are transla - + @@ -399,7 +411,7 @@ Here is the list of all doxygen tags and the description of how they are transla - + @@ -692,14 +704,490 @@ Here is the list of these tags: TO BE ADDED.

      -

      39.4 Developer Information

      +

      39.4 Doxygen To PythonDoc

      -Currently a good deal of this Module still needs some reworking, particularly on the side of the parser and JavaDoc producer. +If translation is enabled, PyDoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files. +The problem is that PyDoc has no tag mechanism like Doxygen or JavaDoc, so most of Doxygen commands are translated as English plaintext pieces.

      -

      39.4.1 Module Design

      +

      39.4.1 Basic Example

      + + +

      +Here is an example segment from an included header file +

      +
      +/*! This is describing class Shape
      + \author Bob
      + */
      +
      +class Shape {
      +public:
      +  Shape() {
      +    nshapes++;
      +  }
      +  virtual ~Shape() {
      +    nshapes--;
      +  };
      +  double  x, y; /*!< Important Variables */
      +  void    move(double dx, double dy); /*!< Moves the Shape */
      +  virtual double area(void) = 0; /*!< \return the area */
      +  virtual double perimeter(void) = 0; /*!< \return the perimeter */
      +  static  int nshapes;
      +};
      +
      + +

      +Simply running SWIG should result in the following code being present in Shapes.py +

      + +
      +
      +...
      +
      +class Shape(_object):
      +    """
      +    This is describing class Shape 
      +    Authors:
      +    Bob 
      +
      +    """
      +    
      +    ...
      +    
      +    def move(self, *args):
      +        """
      +        Moves the Shape 
      +        """
      +        return _Shapes.Shape_move(self, *args)
      +
      +    def area(self):
      +        """
      +        Return:
      +        the area 
      +        """
      +        return _Shapes.Shape_area(self)
      +
      +    def perimeter(self):
      +        """
      +        Return:
      +        the perimeter 
      +        """
      +        return _Shapes.Shape_perimeter(self)
      +
      + +

      +Currently Doxygen comments assigned to vars are not present in proxy file, so they have no comment translated for them. +

      + +

      39.4.2 PyDoc translator

      + + +

      +Here is the list of all doxygen tags and the description of how they are translated to PyDoc +
      +Doxygen tags: +

      +
      +
      \awraped with <i> html tagwrapped with <i> html tag
      \arg
      \ewraped with <i> html tagwrapped with <i> html tag
      \else
      \emwraped with <i> html tagwrapped with <i> html tag
      \endcode
      \liwraped with <li> html tagwrapped with <li> html tag
      \link
      \pwraped with <code> html tagwrapped with <code> html tag
      \par
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      \awrapped with '_'
      \argprepended with ' --'
      \authorprints 'Author:'
      \authorsprints 'Author:'
      \bwrapped with '__'
      \citewrapped with single quotes
      \condtranslated to 'Conditional comment: <condition>'
      \copyrightprints'Copyrigth:'
      \deprecatedprints 'Deprecated:'
      \ewrapped with '_'
      \elsereplaced with '}Else:{'
      \elseifreplaced with '}Else if: <condition>{'
      \emwrapped with '_'
      \endcondreplaced with 'End of conditional comment.'
      \endifreplaced with '}'
      \exceptionreplaced with 'Throws:'
      \ifreplaced with 'If: <condition> {'
      \ifnotreplaced with 'If not: <condition> {'
      \liprepended with ' --'
      \nreplaced with new line char
      \notereplaced with 'Note:'
      \overloadprints 'This is an overloaded ...' according to Doxygen docs
      \parreplaced with 'Title: ...'
      \paramtranslated to 'Arguments:\n param(type) --description'
      \remarkreplaced with 'Remarks:'
      \remarksreplaced with 'Remarks:'
      \resultreplaced with 'Result:'
      \returnreplaced with 'Result:'
      \returnsreplaced with 'Result:'
      \sareplaced with 'See also:'
      \seereplaced with 'See also:'
      \sincereplaced with 'Since:'
      \throwreplaced with 'Throws:'
      \throwsreplaced wih 'Throws:'
      \todoreplaced with 'TODO:'
      \tparamtranslated to 'Arguments:\n param(type) --description'
      \versionreplaced with 'Version:'
      \warningtranslated to 'Warning:'
      \$prints $ char
      \@prints @ char
      \\prints \ char
      \&prints & char
      \~prints ~ char
      \<prints < char
      \>prints > char
      \#prints # char
      \%prints % char
      \"prints " char
      \.prints . char
      \::prints ::
      +
  • + +

    39.4.3 Unsupported tags

    + + +

    +Doxygen has a wealth of tags such as @latexonly that have no equivalent in PyDoc. +As a result several tags that have no translation (or particular use, such as some linking and section tags) are supressed with their content just printed out (if it has any sense, typically text content). +
    +Here is the list of these tags: +

    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    \addindex\addtogroup\anchor\attention
    \brief\bug\callgraph\callergraph
    \class\copybrief\copydetails\copydoc
    \date\def\defgroup\details
    \dir\dontinclude\dot\dotfile
    \code\endcode\endverbatim\endlink
    \enddot\endhtmlonly\endinternal\endlatexonly
    \endmanonly\endmsc\endrtfonly\endxmlonly
    \enum\example\extends\f$
    \f[\f]\f{\f}
    \file\fn\headerfile\hideinitializer
    \htmlinclude\htmlonly\implements\include
    \image\link\verbatim\p
    \includelineno\ingroup\internal\invariant
    \interface\latexonly\line\mainpage
    \manonly\memberof\msc\mscfile
    \name\namespace\nosubgrouping\package
    \page\paragraph\post\pre
    \private\privatesection\property\protected
    \protectedsection\protocol\public\publicsection
    \ref\related\relates\relatedalso
    \relatesalso\retval\rtfonly\section
    \short\showinitializer\skip\skipline
    \snippet\struct\subpage\subsection
    \subsubsection\tableofcontents\test\typedef
    \union\until\var\verbinclude
    \weakgroup\xmlonly\xrefitem\category
    \c
    +
    + +

    39.4.4 Further Details

    + + +

    +TO BE ADDED. +

    + +

    39.5 Developer Information

    + + +

    +

    + +

    39.5.1 Module Design

    @@ -722,7 +1210,7 @@ This module builds its own private parse tree and hands it to a separate class f For example, JavaDocConverter is the JavaDoc module class.

    -

    39.4.2 Debugging commands

    +

    39.5.2 Debugging commands

    @@ -734,7 +1222,7 @@ There are two handy command line switches, that enable lots of detailed debug in -debug-doxygen-translator - Display doxygen translator module debugging information

    -

    39.5 Extending to Other Languages

    +

    39.6 Extending to Other Languages

    From e764c9a73e738aabe0a0a8dbd3cdc5b357de636e Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 30 Jul 2012 08:09:14 +0000 Subject: [PATCH 0109/2031] Made JavaDoc output nicer git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13430 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 165075708..0856eabf1 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -276,7 +276,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { printTree(entityList); } - std::string javaDocString = "/**"; + std::string javaDocString = "/**\n * "; for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { translateEntity(*entityIterator, javaDocString); From fb3ee4fb78dd3be28fdd8308af33ae5818e031b6 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 2 Aug 2012 10:31:02 +0000 Subject: [PATCH 0110/2031] Implemented support for default args - overloaded functions, optional feature 1 in my project plan. Extended testcase. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13483 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_basic_translate.i | 1 + .../java/doxygen_basic_translate_runme.java | 5 +++ .../python/doxygen_basic_translate_runme.py | 4 +- Source/CParse/parser.y | 15 +++++-- .../src/JavaDocConverter.cpp | 44 ++++++++++++++++--- .../DoxygenTranslator/src/JavaDocConverter.h | 7 +++ 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index c06cbddc9..9cef037b1 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -61,6 +61,7 @@ int function4() /** * Test for default args + * @param a Some parameter, default is 42 */ int function5(int a=42) { diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index 50d6cedda..4e95b73a7 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -63,6 +63,11 @@ public class doxygen_basic_translate_runme { " \n" + ""); wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5(int)", + " Test for default args \n" + + " @param a Some parameter, default is 42" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5()", " Test for default args \n" + " \n" + ""); diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 95596c1f3..a952df8b0 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -58,5 +58,7 @@ check(doxygen_basic_translate.function4.__doc__, '' ' }' ) check(doxygen_basic_translate.function5.__doc__, '' -' Test for default args' +' Test for default args \n' +' Arguments: \n' +' a (int) -- Some parameter, default is 42\n' ) \ No newline at end of file diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 6aed8c3f9..e331752bf 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -190,6 +190,7 @@ static Node *copy_node(Node *n) { } static void set_comment(Node *n, String *comment) { + String *name; Parm *p; if (!n || !comment) return; @@ -206,6 +207,16 @@ static void set_comment(Node *n, String *comment) { p=nextSibling(p); } } + + /* Append same comment to every generated overload */ + name = Getattr(n, "name"); + if (!name) + return; + n = nextSibling(n); + while (n && Getattr(n, "name") && Strcmp(Getattr(n, "name"), name) == 0) { + Setattr(n, "DoxygenComment", comment); + n = nextSibling(n); + } } /* ----------------------------------------------------------------------------- @@ -1586,10 +1597,6 @@ static void default_arguments(Node *n) { if (throws) Setattr(new_function,"throws",pl); Delete(pl); } - - /* copy doxygen comments if found */ - if(Getattr(function,"DoxygenComment")) - Setattr(new_function,"DoxygenComment",Getattr(function,"DoxygenComment")); /* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */ if (strcmp(cntype,"template") == 0) { diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 0856eabf1..421134828 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -66,8 +66,8 @@ void JavaDocConverter::fillStaticTables() { tagHandlers["deprecated"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["exception"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["package"] = make_pair(&JavaDocConverter::handleTagSame, ""); - tagHandlers["param"] = make_pair(&JavaDocConverter::handleTagSame, ""); - tagHandlers["tparam"] = make_pair(&JavaDocConverter::handleTagSame, "param"); + tagHandlers["param"] = make_pair(&JavaDocConverter::handleTagParam, ""); + tagHandlers["tparam"] = make_pair(&JavaDocConverter::handleTagParam, ""); tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return"); tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, "return"); @@ -151,6 +151,23 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind return formattedLines; } +bool JavaDocConverter::paramExists(std::string param) { + ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); + Parm *p = NULL; + for (p = plist; p;) { + if (Char(Getattr(p, "name")) == param) + return true; + /* + * doesn't seem to work always: in some cases (especially for 'self' parameters) + * tmap:in is present, but tmap:in:next is not and so this code skips all the parameters + */ + //p = Getattr(p, "tmap:in") ? Getattr(p, "tmap:in:next") : nextSibling(p); + p = nextSibling(p); + } + Delete(plist); + return false; +} + std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { std::string translatedComment; @@ -250,12 +267,26 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag, std::string& translate void JavaDocConverter::handleTagPar(DoxygenEntity& tag, std::string& translatedComment, std::string&) { std::string dummy; translatedComment += "data + "\""; - translatedComment += ">"; + translatedComment += ">"; + tag.entityList.pop_front(); + handleParagraph(tag, translatedComment, dummy); + } + translatedComment += "

    "; +} + +void JavaDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedComment, std::string&) { + std::string dummy; + if (!tag.entityList.size()) + return; + if (!paramExists(tag.entityList.begin()->data)) + return; + + translatedComment += "@param "; + translatedComment += tag.entityList.begin()->data + " "; tag.entityList.pop_front(); handleParagraph(tag, translatedComment, dummy); - translatedComment += "

    "; } String *JavaDocConverter::makeDocumentation(Node *node) { @@ -278,6 +309,9 @@ String *JavaDocConverter::makeDocumentation(Node *node) { std::string javaDocString = "/**\n * "; + // store the current node + // (currently just to handle params) + currentNode = node; for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { translateEntity(*entityIterator, javaDocString); entityIterator++; diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 1d51a8d7b..f68a712b9 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -85,12 +85,19 @@ protected: * Insert

    ...

    */ void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert @param command, if it is really a function param + */ + void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); private: + Node *currentNode; // this contains the handler pointer and one string argument static std::map > tagHandlers; void fillStaticTables(); + + bool paramExists(std::string param); }; #endif From c72a56c6f1d5f1366e09bd99e8bef5b31b0c9598 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 2 Aug 2012 12:22:26 +0000 Subject: [PATCH 0111/2031] Small fix to display params type correctly in PyDocConverter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13484 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/PyDocConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index a873cfb16..df9466067 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -101,7 +101,7 @@ std::string PyDocConverter::getParamType(std::string param) { Parm *p = NULL; for (p = plist; p;) { if (Char(Getattr(p, "name")) == param) { - std::string type = Char(Swig_name_make(currentNode, 0, Getattr(p, "type"), 0, 0)); + std::string type = Char(SwigType_str(Getattr(p, "type"), "")); return type; } /* From 174e20318038b2311051938a88fa0233f744e50c Mon Sep 17 00:00:00 2001 From: Marko Klopcic Date: Thu, 2 Aug 2012 20:48:28 +0000 Subject: [PATCH 0112/2031] Fixed problem with doxygen comments at the end of a file or in a file without declarations. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13485 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_basic_translate.h | 5 +++++ Examples/test-suite/doxygen_basic_translate.i | 13 ++++++++++++- Source/CParse/parser.y | 19 ++++++++++++------- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/doxygen_basic_translate.h diff --git a/Examples/test-suite/doxygen_basic_translate.h b/Examples/test-suite/doxygen_basic_translate.h new file mode 100644 index 000000000..7b2b3f58a --- /dev/null +++ b/Examples/test-suite/doxygen_basic_translate.h @@ -0,0 +1,5 @@ + +/** + * This file contains only doxygen comment without a declaration - + * it should be ignored by SWIG and must not trigger syntax error. + */ diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index 9cef037b1..11c6a75ac 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -1,5 +1,7 @@ %module doxygen_basic_translate +%include "doxygen_basic_translate.h" + %inline %{ /** @@ -59,12 +61,21 @@ int function4() { } + +int function5(int a) +{ +} +/**< This is a post comment. */ + /** * Test for default args * @param a Some parameter, default is 42 */ -int function5(int a=42) +int function6(int a=42) { } +/** + * Comment at the end of file should be ignored. + */ %} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index e331752bf..41c94a5f3 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -66,7 +66,7 @@ static Node **class_decl = NULL; * ----------------------------------------------------------------------------- */ String *currentComment; /* Location of the stored Doxygen Comment */ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ -String *currentCComment; /* Location of the stored C Comment */ +static String *currentDeclComment = NULL; /* Comment of C/C++ declaration. */ static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ static Node *currentNode = NULL; /* Pointer to the current node (for post comments) */ @@ -1852,17 +1852,22 @@ program : interface { interface : interface declaration { /* add declaration to end of linked list (the declaration isn't always a single declaration, sometimes it is a linked list itself) */ + if (currentDeclComment != NULL) { + set_comment($2, currentDeclComment); + currentDeclComment = NULL; + } appendChild($1,$2); $$ = $1; } - | interface doxygen_comment declaration { - set_comment($3, $2); - appendChild($1, $3); + | interface doxygen_comment { + currentDeclComment = $2; $$ = $1; } - | interface declaration doxygen_post_comment { - set_comment($2, $3); - appendChild($1, $2); + | interface doxygen_post_comment { + Node *node = lastChild($1); + if (node) { + set_comment(node, $2); + } $$ = $1; } | empty { From 1881130f10cf70b6a0c398cd8c9ae89aa6e5e3f4 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 2 Aug 2012 22:01:54 +0000 Subject: [PATCH 0113/2031] Fixed doxygen_basic_translate java runtime test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13486 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/java/doxygen_basic_translate_runme.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index 4e95b73a7..946988c57 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -63,14 +63,22 @@ public class doxygen_basic_translate_runme { " \n" + ""); wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5(int)", + " This is a post comment. \n" + + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function6(int)", " Test for default args \n" + " @param a Some parameter, default is 42" + " \n" + ""); - wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function5()", + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function6()", " Test for default args \n" + " \n" + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function7(doxygen_basic_translate.SWIGTYPE_p_p_p_Shape)", + " Test for a parameter with difficult type \n" + + " (mostly for python) \n" + + " @param a Very strange param \n" + + ""); wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function3(int, int)", " A test for overloaded functions \n" + " This is function two \n" + From 9d3446d8030ec226a7aa1e43daae13d0f1a8143b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 3 Aug 2012 18:44:47 +0000 Subject: [PATCH 0114/2031] Fixed critical bug with doxygen comments, containing % symbol git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13487 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index c7174d0fc..3591b7363 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -566,7 +566,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(f_module, "/* This was generated from top() */"); - Printf(f_module, Char(doxygen_comments)); + Printv(f_module, Char(doxygen_comments), NIL); Delete(doxygen_comments); } if (Len(module_class_modifiers) > 0) @@ -1360,7 +1360,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(f_enum, "/* This was generated from enumDeclaration() */"); - Printf(f_enum, Char(doxygen_comments)); + Printv(f_enum, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1457,7 +1457,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(enum_code, Char(doxygen_comments)); + Printv(enum_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1527,7 +1527,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(structuralComments, "/* This was generated from doxygenComment() */"); - Printf(structuralComments, Char(doxygen_comments)); + Printv(structuralComments, Char(doxygen_comments), NIL); Delete(doxygen_comments); } return SWIG_OK; @@ -1559,7 +1559,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(constants_code, "/* This was generated from constantWrapper() */"); - Printf(constants_code, Char(doxygen_comments)); + Printv(constants_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1855,7 +1855,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */"); - Printf(proxy_class_def, Char(doxygen_comments)); + Printv(proxy_class_def, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -2259,7 +2259,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */"); - Printf(function_code, Char(doxygen_comments)); + Printv(function_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -2490,7 +2490,7 @@ public: String *doxygen_comments=doxygenTranslator->getDocumentation(n); if(comment_creation_chatter) Printf(function_code, "/* This was generated from constructionhandler() */"); - Printf(function_code, Char(doxygen_comments)); + Printv(function_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } From 3b280b6ffe51fed5bdbfad261b58fa369476bf77 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 3 Aug 2012 19:34:56 +0000 Subject: [PATCH 0115/2031] Fixed doxygen_basic_translate testcase. Why do I always have the tests messed up? git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13488 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_basic_translate.i | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index 11c6a75ac..e8c21f452 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -75,6 +75,21 @@ int function6(int a=42) { } +class Shape +{ +public: + typedef Shape* superType; +}; + +/** + * Test for a parameter with difficult type + * (mostly for python) + * @param a Very strange param + */ +void function7(Shape::superType *a[10]) +{ +} + /** * Comment at the end of file should be ignored. */ From d99fe121b8cd3fda73aa2b0822fbcdbf09b4abab Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 3 Aug 2012 19:43:35 +0000 Subject: [PATCH 0116/2031] Fixed python doxygen_basic_translate runtime test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13489 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/doxygen_basic_translate_runme.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index a952df8b0..4698e0f6c 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -58,7 +58,10 @@ check(doxygen_basic_translate.function4.__doc__, '' ' }' ) check(doxygen_basic_translate.function5.__doc__, '' +' This is a post comment. \n' +) +check(doxygen_basic_translate.function6.__doc__, '' ' Test for default args \n' ' Arguments: \n' ' a (int) -- Some parameter, default is 42\n' -) \ No newline at end of file +) From 380b71eb561f7c74848e16607c21d23ce509c5af Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 3 Aug 2012 21:43:02 +0000 Subject: [PATCH 0117/2031] Implemented automatic translation of links in doxygen comments, for example @see function(std::string) -> @see function(String) in java. Also included testcase for that git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13490 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/doxygen_translate_links.i | 67 ++++++++++ .../java/doxygen_translate_links_runme.java | 68 ++++++++++ .../src/JavaDocConverter.cpp | 123 +++++++++++++++++- .../DoxygenTranslator/src/JavaDocConverter.h | 15 +++ 4 files changed, 269 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/doxygen_translate_links.i create mode 100644 Examples/test-suite/java/doxygen_translate_links_runme.java diff --git a/Examples/test-suite/doxygen_translate_links.i b/Examples/test-suite/doxygen_translate_links.i new file mode 100644 index 000000000..5eee1d67f --- /dev/null +++ b/Examples/test-suite/doxygen_translate_links.i @@ -0,0 +1,67 @@ + + +%module doxygen_translate_links +%include "std_string.i" + +%inline %{ + +class Shape +{ +public: + typedef Shape* superType; +}; + +/** + * Testing typenames converting in \@ link + * + * \link superFunc(int,std::string) + * Test for std_string member + * \endlink + * + * \link superFunc(int,long,void*) + * Test for simple types + * \endlink + * + * \link superFunc(Shape::superType*) + * Test for custom types + * \endlink + * + * \link superFunc(int**[13]) + * Test for complex types + * \endlink + * + * same works for 'See also:' links: + * + * \sa superFunc(int,std::string) + * \sa superFunc(int,long,void*) + * \sa superFunc(Shape::superType*) + * \sa superFunc(int**[13]) + * + * some failing params: + * + * \sa superFunc() + * \sa superFunc() + * \sa superFunc() + * + */ +int function() +{ +} + +void superFunc(int, std::string) +{ +} + +void superFunc(int, long, void *) +{ +} + +void superFunc(Shape::superType *) +{ +} + +void superFunc(int **arr[13]) +{ +} + +%} diff --git a/Examples/test-suite/java/doxygen_translate_links_runme.java b/Examples/test-suite/java/doxygen_translate_links_runme.java new file mode 100644 index 000000000..080063430 --- /dev/null +++ b/Examples/test-suite/java/doxygen_translate_links_runme.java @@ -0,0 +1,68 @@ + +import doxygen_translate_links.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_translate_links_runme { + static { + try { + System.loadLibrary("doxygen_translate_links"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + commentParser parser = new commentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_translate_links runtime test", + "commentParser", new String[]{"-quiet", "doxygen_translate_links"}); + + HashMap wantedComments = new HashMap(); + + + wantedComments.put("doxygen_translate_links.doxygen_translate_links.function()", + " \n" + + " Testing typenames converting in @ link \n" + + " \n" + + " {@link superFunc(int,String) \n" + + " Test for std_string member \n" + + " }\n" + + " \n" + + " {@link superFunc(int,int,SWIGTYPE_p_void) \n" + + " Test for simple types \n" + + " }\n" + + " \n" + + " {@link superFunc(SWIGTYPE_p_p_Shape) \n" + + " Test for custom types \n" + + " }\n" + + " \n" + + " {@link superFunc(SWIGTYPE_p_p_p_int) \n" + + " Test for complex types \n" + + " }\n" + + " \n" + + " same works for 'See also:' links: \n" + + " \n" + + " @see superFunc(int,String)\n" + + " @see superFunc(int,int,SWIGTYPE_p_void)\n" + + " @see superFunc(SWIGTYPE_p_p_Shape)\n" + + " @see superFunc(SWIGTYPE_p_p_p_int)\n" + + " \n" + + " some failing params: \n" + + " \n" + + " @see superFunc() \n" + + " @see superFunc() \n" + + " @see superFunc() \n" + + " \n" + + " \n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} \ No newline at end of file diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 421134828..123eb040b 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -12,6 +12,8 @@ #include "JavaDocConverter.h" #include "DoxygenParser.h" #include +#include +#include "../../Modules/swigmod.h" #define APPROX_LINE_LENGTH 64 //characters per line allowed #define TAB_SIZE 8 //current tab size in spaces //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag @@ -71,8 +73,8 @@ void JavaDocConverter::fillStaticTables() { tagHandlers["result"] = make_pair(&JavaDocConverter::handleTagSame, "return"); tagHandlers["return"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["returns"] = make_pair(&JavaDocConverter::handleTagSame, "return"); - tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, ""); - tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see"); + //tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSame, ""); + //tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSame, "see"); tagHandlers["since"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["throws"] = make_pair(&JavaDocConverter::handleTagSame, ""); tagHandlers["throw"] = make_pair(&JavaDocConverter::handleTagSame, "throws"); @@ -87,7 +89,9 @@ void JavaDocConverter::fillStaticTables() { tagHandlers["if"] = make_pair(&JavaDocConverter::handleTagIf, "If: "); tagHandlers["ifnot"] = make_pair(&JavaDocConverter::handleTagIf, "If not: "); tagHandlers["image"] = make_pair(&JavaDocConverter::handleTagImage, ""); - tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagExtended, "link"); + tagHandlers["link"] = make_pair(&JavaDocConverter::handleTagLink, ""); + tagHandlers["see"] = make_pair(&JavaDocConverter::handleTagSee, ""); + tagHandlers["sa"] = make_pair(&JavaDocConverter::handleTagSee, ""); tagHandlers["note"] = make_pair(&JavaDocConverter::handleTagMessage, "Note: "); tagHandlers["overload"] = make_pair(&JavaDocConverter::handleTagMessage, "This is an overloaded member function, provided for" " convenience. It differs from the above function only in what" @@ -152,10 +156,12 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind } bool JavaDocConverter::paramExists(std::string param) { + if (GetFlag(currentNode, "feature:doxygen:nostripparams")) + return true; ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); Parm *p = NULL; for (p = plist; p;) { - if (Char(Getattr(p, "name")) == param) + if (Getattr(p, "name") && Char(Getattr(p, "name")) == param) return true; /* * doesn't seem to work always: in some cases (especially for 'self' parameters) @@ -289,6 +295,115 @@ void JavaDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translate handleParagraph(tag, translatedComment, dummy); } +string JavaDocConverter::convertLink(string linkObject) { + if (GetFlag(currentNode, "feature:doxygen:nolinktranslate")) + return linkObject; + // find the params in function in linkObject (if any) + size_t lbracePos = linkObject.find('(', 0); + size_t rbracePos = linkObject.find(')', 0); + if (lbracePos == string::npos && rbracePos == string::npos && lbracePos >= rbracePos) + return ""; + + string paramsStr = linkObject.substr(lbracePos + 1, rbracePos - lbracePos - 1); + // strip the params, to fill them later + linkObject = linkObject.substr(0, lbracePos); + + // find all the params + vector params; + size_t lastPos = 0, commaPos = 0; + while (true) { + commaPos = paramsStr.find(',', lastPos); + if (commaPos == string::npos) + commaPos = paramsStr.size(); + string param = paramsStr.substr(lastPos, commaPos - lastPos); + // if any param type is empty, we are failed + if (!param.size()) + return ""; + params.push_back(param); + lastPos = commaPos + 1; + if (lastPos >= paramsStr.size()) + break; + } + + linkObject += "("; + for (size_t i=0; i 'a(100).a(10).p.p.int' + // also converting arrays to pointers + string paramStr = params[i]; + String *swigType = NewString(""); + for (int j=(int)params[i].size() - 1; j>=0; j--) { + // skip all the [...] blocks, write 'p.' for every of it + if (paramStr[j] == ']') { + while (j>=0 && paramStr[j] != '[') + j--; + // no closing brace + if (!j) + return ""; + Append(swigType, "p."); + continue; + } + else if (paramStr[j] == '*') + Append(swigType, "p."); + else if (isalnum(paramStr[j])) { + Append(swigType, paramStr.substr(0, j + 1).c_str()); + break; + } + } + + // make dummy param list, to lookup typemaps for it + Parm *dummyParam = NewParm(swigType, "", 0); + Swig_typemap_attach_parms("jstype", dummyParam, NULL); + Language::instance()->replaceSpecialVariables(0, Getattr(dummyParam, "tmap:jstype"), dummyParam); + + //Swig_print(dummyParam, 1); + linkObject += Char(Getattr(dummyParam, "tmap:jstype")); + if (i != params.size() - 1) + linkObject += ","; + + Delete(dummyParam); + Delete(swigType); + } + linkObject += ")"; + + return linkObject; +} + +void JavaDocConverter::handleTagLink(DoxygenEntity& tag, std::string& translatedComment, std::string&) { + std::string dummy; + if (!tag.entityList.size()) + return; + + string linkObject = convertLink(tag.entityList.begin()->data); + if (!linkObject.size()) + linkObject = tag.entityList.begin()->data; + tag.entityList.pop_front(); + + translatedComment += "{@link "; + translatedComment += linkObject + " "; + handleParagraph(tag, translatedComment, dummy); + translatedComment += "}"; +} + +void JavaDocConverter::handleTagSee(DoxygenEntity& tag, std::string& translatedComment, std::string&) { + std::string dummy; + if (!tag.entityList.size()) + return; + + list::iterator it; + for (it = tag.entityList.begin(); it!=tag.entityList.end(); it++) { + if (it->typeOfEntity == "plainstd::endl") + handleNewLine(*it, translatedComment, dummy); + if (it->typeOfEntity != "plainstd::string") + continue; + translatedComment += "@see "; + string linkObject = convertLink(it->data); + if (!linkObject.size()) + linkObject = it->data; + translatedComment += linkObject; + } +} + String *JavaDocConverter::makeDocumentation(Node *node) { String *documentation = getDoxygenComment(node); diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index f68a712b9..a547a17f8 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -30,6 +30,11 @@ protected: std::string translateSubtree(DoxygenEntity & doxygenEntity); void translateEntity(DoxygenEntity &tag, std::string &translatedComment); + /* + * Convert params in link-objects and references + */ + std::string convertLink(std::string linkObject); + /* * Typedef for the function that handles one tag * arg - some string argument to easily pass it through lookup table @@ -89,6 +94,16 @@ protected: * Insert @param command, if it is really a function param */ void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert {@link...} command, and handle all the s correctly + * (like converting types of params, etc) + */ + void handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* + * Insert @see command, and handle all the s correctly + * (like converting types of params, etc) + */ + void handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); private: From e05d88b83cfbd1baef54988346911c3b1df8f5a7 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 3 Aug 2012 21:53:48 +0000 Subject: [PATCH 0118/2031] Removed some old unused code from parser.y git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13491 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 41c94a5f3..27957d9ab 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -64,8 +64,6 @@ static Node **class_decl = NULL; /* ----------------------------------------------------------------------------- * Doxygen Comment Globals and Assist Functions * ----------------------------------------------------------------------------- */ -String *currentComment; /* Location of the stored Doxygen Comment */ -String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ static String *currentDeclComment = NULL; /* Comment of C/C++ declaration. */ static Node *previousNode = NULL; /* Pointer to the previous node (for post comments) */ static Node *currentNode = NULL; /* Pointer to the current node (for post comments) */ @@ -4866,37 +4864,12 @@ storage_class : EXTERN { $$ = "extern"; } ------------------------------------------------------------------------------ */ parms : rawparms { - Parm *p, *nextSibling; + Parm *p; $$ = $1; p = $1; while (p) { - String *postComment = NULL; - nextSibling = nextSibling(p); - if (nextSibling != NULL) { - postComment = Getattr(nextSibling, "postComment"); - } else { - /* the last functino parameter has two attributes - - post comment of the previous params and its own post - comment. - */ - postComment = Getattr(p, "lastParamPostComment"); - } - if (postComment != NULL) { - String *param = NewString("\n@param "); - if (currentComment != 0) { - Append(currentComment, param); - Append(currentComment, Getattr(p, "name")); - Append(currentComment, postComment); - } - else { - currentComment = param; - Append(currentComment, Getattr(p, "name")); - Append(currentComment, postComment); - } - } - Replace(Getattr(p,"type"),"typename ", "", DOH_REPLACE_ANY); - p = nextSibling; + p = nextSibling(p); } } ; From 6365770c7fe90d449ccea50823146ff15736afb0 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 5 Aug 2012 13:31:19 +0000 Subject: [PATCH 0119/2031] Added missing test part to python testsuite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13516 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/doxygen_basic_translate_runme.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 4698e0f6c..4c1376f44 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -65,3 +65,9 @@ check(doxygen_basic_translate.function6.__doc__, '' ' Arguments: \n' ' a (int) -- Some parameter, default is 42\n' ) +check(doxygen_basic_translate.function7.__doc__, '' +' Test for a parameter with difficult type \n' +' (mostly for python) \n' +' Arguments: \n' +' a (Shape::superType *[10]) -- Very strange param \n' +) From 346fdfcab7d8532ec4a702d5edd0bf6575b29605 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 5 Aug 2012 14:16:57 +0000 Subject: [PATCH 0120/2031] Added doxygen:notranslate feature, to prevent running of automatic comment translation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13517 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 + .../test-suite/doxygen_basic_notranslate.i | 103 ++++++++++++++++++ .../src/JavaDocConverter.cpp | 10 ++ .../DoxygenTranslator/src/PyDocConverter.cpp | 30 ++++- 4 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/doxygen_basic_notranslate.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index eb8f7b03a..86e33037a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -189,8 +189,10 @@ CPP_TEST_CASES += \ disown \ doxygen_parsing \ doxygen_basic_translate \ + doxygen_basic_notranslate \ doxygen_translate \ doxygen_translate_all_tags \ + doxygen_translate_links \ dynamic_cast \ empty \ enum_rename \ diff --git a/Examples/test-suite/doxygen_basic_notranslate.i b/Examples/test-suite/doxygen_basic_notranslate.i new file mode 100644 index 000000000..8699e3289 --- /dev/null +++ b/Examples/test-suite/doxygen_basic_notranslate.i @@ -0,0 +1,103 @@ +%module doxygen_basic_notranslate + +%include "doxygen_basic_translate.h" +%feature("doxygen:notranslate") function; +%feature("doxygen:notranslate") function2; +%feature("doxygen:notranslate") function3; +%feature("doxygen:notranslate") function4; +%feature("doxygen:notranslate") function5; +%feature("doxygen:notranslate") function6; +%feature("doxygen:notranslate") function7; + +%inline %{ + +/** + * \brief + * Brief description. + * + * The comment text + * \author Some author + * \return Some number + * \sa function2 + */ +int function() +{ +} + +/** + * A test of a very very very very very very very very very very very very very very very very + * very very very very very long comment string. + */ +int function2() +{ +} + +/** + * A test for overloaded functions + * This is function \b one + */ +int function3(int a) +{ +} + +/** + * A test for overloaded functions + * This is function \b two + */ +int function3(int a, int b) +{ +} + +/** + * A test of some mixed tag usage + * \if CONDITION + * This \a code fragment shows us something \. + * \par Minuses: + * \arg it's senseless + * \arg it's stupid + * \arg it's null + * + * \warning This may not work as expected + * + * \code + * int main() { while(true); } + * \endcode + * \endif + */ +int function4() +{ +} + + +int function5(int a) +{ +} +/**< This is a post comment. */ + +/** + * Test for default args + * @param a Some parameter, default is 42 + */ +int function6(int a=42) +{ +} + +class Shape +{ +public: + typedef Shape* superType; +}; + +/** + * Test for a parameter with difficult type + * (mostly for python) + * @param a Very strange param + */ +void function7(Shape::superType *a[10]) +{ +} + +/** + * Comment at the end of file should be ignored. + */ +%} diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 123eb040b..b03556b47 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -412,6 +412,16 @@ String *JavaDocConverter::makeDocumentation(Node *node) { return NULL; } + if (GetFlag(node, "feature:doxygen:notranslate")) { + String *comment = NewString("/**\n"); + Append(comment, documentation); + // reformat the comment + Replaceall(comment, "\n *", "\n"); + Replaceall(comment, "\n", "\n * "); + Append(comment, "\n */\n"); + return comment; + } + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); // entityList.sort(CompareDoxygenEntities()); sorting currently not used, diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index df9466067..777a54201 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -254,9 +254,18 @@ String *PyDocConverter::makeDocumentation(Node *n) { documentation = getDoxygenComment(n); if (!Swig_is_generated_overload(n) && documentation) { currentNode = n; - std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); - DoxygenEntity root("root", entityList); - allDocumentation.push_back(translateSubtree(root)); + if (GetFlag(n, "feature:doxygen:notranslate")) { + String *comment = NewString(""); + Append(comment, documentation); + Replaceall(comment, "\n *", "\n"); + allDocumentation.push_back(Char(comment)); + Delete(comment); + } + else { + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); + DoxygenEntity root("root", entityList); + allDocumentation.push_back(translateSubtree(root)); + } } n = Getattr(n, "sym:nextSibling"); } @@ -279,9 +288,18 @@ String *PyDocConverter::makeDocumentation(Node *n) { else { documentation = getDoxygenComment(n); if (documentation != NULL) { - std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); - DoxygenEntity root("root", entityList); - pyDocString = translateSubtree(root); + if (GetFlag(n, "feature:doxygen:notranslate")) { + String *comment = NewString(""); + Append(comment, documentation); + Replaceall(comment, "\n *", "\n"); + pyDocString = Char(comment); + Delete(comment); + } + else { + std::list < DoxygenEntity > entityList = parser.createTree(Char(documentation), Char(Getfile(documentation)), Getline(documentation)); + DoxygenEntity root("root", entityList); + pyDocString = translateSubtree(root); + } } } From 0a3db948cca61b0976b68eed5a2bc777da0d38b2 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 5 Aug 2012 14:18:46 +0000 Subject: [PATCH 0121/2031] Fixed possible bug: as the return value of makeDocumentation is never checked, don't return null pointers, even in case of errors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13518 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 2 +- Source/DoxygenTranslator/src/PyDocConverter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index b03556b47..c7485ab4f 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -409,7 +409,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { String *documentation = getDoxygenComment(node); if (documentation == NULL) { - return NULL; + return NewString(""); } if (GetFlag(node, "feature:doxygen:notranslate")) { diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 777a54201..7937b5ba5 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -316,7 +316,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { return NewString(result.c_str()); } - return 0; + return NewString(""); } std::string PyDocConverter::generateDivider() { From 51e184f134cf1a7897aac7e5c4f1a3229c74c3db Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sun, 5 Aug 2012 16:22:48 +0000 Subject: [PATCH 0122/2031] Added special doxygen features description to docs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13523 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Doxygen.html | 90 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 77c00b40e..3178f70c2 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -101,7 +101,7 @@ Here they are: Also any of the above with '<' added after comment-starting symbol, like /**<, /*!<, ///<, or //!< will be treated as post-comment and will be assigned to the node before the comment.
    -Any number of '*' or '/' in doxygen comment is considered to be a separator and is not included in final comment, so you may safely use +Any number of '*' or '/' in Doxygen comment is considered to be a separator and is not included in final comment, so you may safely use comments like /*********/ or //////////.

    @@ -172,11 +172,11 @@ Also, currently only the comments directly before or after the nodes are support

    There is a switch '-doxygen' in every module that supports converting documentation comments. Some comments in some target languages can be manually overriden by specific -swig's features, like feature:docstring or feature:autodoc, in this cases doxygen comments +swig's features, like feature:docstring or feature:autodoc, in this cases Doxygen comments have lowest priority.

    -If doxygen parsing is switched off, then all the comments are stripped out in parser and all the resources used by comment parser and translator are freed. +If Doxygen parsing is switched off, then all the comments are stripped out in parser and all the resources used by comment parser and translator are freed.

    39.2.2 Additional Commandline Options

    @@ -274,19 +274,61 @@ public class Shape { - -

    The code Java-wise should be identical to what would have been generated without this feature enabled. When the Doxygen Translator Module encounters a comment it finds nothing useful in or cannot parse, it should not effect the functionality of the SWIG generated code.

    +

    +JavaDoc translator will handle most of the tags conversions (see the table below). It will also automatically translate link-objects +params, in \see and \link...\endlink commands. For example, 'someFunction(std::string)' will be converted to 'someFunction(String)'. +If this works not really good for you, or if you don't want such behaviour, you could turn this off by using 'doxygen:nolinktranslate' +feature. Also all '\param' and '\tparam' commands are stripped out, if specified parameter is not present in function. Use 'doxygen:nostripparams' +to avoid. +
    +If you intend to use resulting proxy files with Doxygen docs generator, rather than JavaDoc, you may want to turn off translator completely +(doxygen:notranslate feature). +Then SWIG will just copy the comments to the proxy file and reformat them if needed, but all the comment content will be left as is. +

    + +

    +JavaDoc translator features summary (see %feature directives): +
    + +

    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    doxygen:noranslate +Turn off the whole Doxygen translator. +The Doxygen comment will be attached to the right node, +but all the commands and text will be left as-is +
    doxygen:notlinkranslateTurn off automatic link-objects translation
    doxygen:nostripparams +Turn off stripping of @param and @tparam +Doxygen commands if such parameter is not found +
    +
    +

    39.3.2 JavaDoc Tags

    -Here is the list of all doxygen tags and the description of how they are translated to JavaDoc +Here is the list of all Doxygen tags and the description of how they are translated to JavaDoc
    Doxygen tags:

    @@ -782,11 +824,41 @@ class Shape(_object): Currently Doxygen comments assigned to vars are not present in proxy file, so they have no comment translated for them.

    +

    +Since all the overloaded functions in c++ are wrapped into one Python function, PyDoc translator will combine every comment of every +overloaded function and put it in the comment for wrapping function. +
    +If you intend to use resulting proxy files with Doxygen docs generator, rather than PyDoc, you may want to turn off translator completely +(doxygen:notranslate feature). +Then SWIG will just copy the comments to the proxy file and reformat them if needed, but all the comment content will be left as is. As Doxygen +don't support special commands in Python comments (see Doxygen docs), +you may want to use some tool like doxypy (http://code.foosel.org/doxypy) to do the work. +

    + +

    +PyDoc translator features summary (see %feature directives): +
    + +

    + +
    +
    +
    +
    +
    +
    +
    doxygen:noranslate +Turn off the whole Doxygen translator. +The Doxygen comment will be attached to the right node, +but all the commands and text will be left as-is +
    +
    +

    39.4.2 PyDoc translator

    -Here is the list of all doxygen tags and the description of how they are translated to PyDoc +Here is the list of all Doxygen tags and the description of how they are translated to PyDoc
    Doxygen tags:

    @@ -1218,8 +1290,8 @@ There are two handy command line switches, that enable lots of detailed debug in

    -  -debug-doxygen-parser     - Display doxygen parser module debugging information
    -  -debug-doxygen-translator - Display doxygen translator module debugging information
    +  -debug-doxygen-parser     - Display Doxygen parser module debugging information
    +  -debug-doxygen-translator - Display Doxygen translator module debugging information
     

    39.6 Extending to Other Languages

    From cecc793782e329b1f811b49960d84d5a89e4fc81 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Tue, 7 Aug 2012 20:04:23 +0000 Subject: [PATCH 0123/2031] Various small code fixes. Some unwanted code removed. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13551 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenCommands.h | 35 ----- Source/DoxygenTranslator/src/DoxygenEntity.h | 4 - .../DoxygenTranslator/src/DoxygenParser.cpp | 134 ++++-------------- Source/DoxygenTranslator/src/DoxygenParser.h | 31 +--- .../src/DoxygenTranslator.cpp | 2 +- .../DoxygenTranslator/src/DoxygenTranslator.h | 5 +- Source/DoxygenTranslator/src/TokenList.cpp | 2 +- 7 files changed, 36 insertions(+), 177 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 96fde4a7c..10ebca862 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -2,25 +2,6 @@ #ifndef DOXYGENCOMMANDS_H #define DOXYGENCOMMANDS_H -const char *commandArray[] = { - "a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "authors", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "cite", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "copyright", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "mscfile", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "remark", "result", "return", "returns", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; - - const char *sectionIndicators[] = { "attention", "author", "authors", "brief", "bug", "cond", "date", "deprecated", "details", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", @@ -35,38 +16,22 @@ const char *simpleCommands[] = { "protected", "protectedsection", "tableofcontents"}; const int simpleCommandsSize = sizeof(simpleCommands) / sizeof(*simpleCommands); -const char *ignoredSimpleCommands[] = { - "nothing at the moment"}; -const int ignoredSimpleCommandsSize = sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); - const char *commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno", "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude", "extends", "implements", "memberof", "related", "relatedalso", "cite"}; const int commandWordsSize = sizeof(commandWords) / sizeof(*commandWords); -const char *ignoredCommandWords[] = { - "nothing at the moment"}; -const int ignoredCommandWordsSize = sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); - const char *commandLines[] = { "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; const int commandLinesSize = sizeof(commandLines) / sizeof(*commandLines); -const char *ignoreCommandLines[] = { - "nothing at the moment"}; -const int ignoreCommandLinesSize = sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); - const char *commandParagraph[] = { "partofdescription", "result", "return", "returns", "remarks", "remark", "since", "test", "sa", "see", "pre", "post", "details", "invariant", "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author", "authors", "copyright", "short"}; const int commandParagraphSize = sizeof(commandParagraph) / sizeof(*commandParagraph); -const char *ignoreCommandParagraphs[] = { - "nothing at the moment"}; -const int ignoreCommandParagraphsSize = sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); - const char *commandEndCommands[] = { "htmlonly", "latexonly", "manonly", "xmlonly", "link", "rtfonly"}; const int commandEndCommandsSize = sizeof(commandEndCommands) / sizeof(*commandEndCommands); diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index dcdba7644..64b692ba0 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -20,13 +20,9 @@ typedef enum { SIMPLECOMMAND, - IGNOREDSIMPLECOMMAND, COMMANDWORD, - IGNOREDCOMMANDWORD, COMMANDLINE, - IGNOREDCOMMANDLINE, COMMANDPARAGRAPH, - IGNORECOMMANDPARAGRAPH, COMMANDENDCOMMAND, COMMANDWORDPARAGRAPH, COMMANDWORDLINE, diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 8ed186727..4df82b2d7 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -32,24 +32,12 @@ void DoxygenParser::fillTables() { // fill in tables with data from DxygenCommands.h for (int i = 0; i < simpleCommandsSize; i++) doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND; - for (int i = 0; i < ignoredSimpleCommandsSize; i++) - doxygenCommands[ignoredSimpleCommands[i]] = IGNOREDSIMPLECOMMAND; - for (int i = 0; i < commandWordsSize; i++) doxygenCommands[commandWords[i]] = COMMANDWORD; - for (int i = 0; i < ignoredCommandWordsSize; i++) - doxygenCommands[ignoredCommandWords[i]] = IGNOREDCOMMANDWORD; - for (int i = 0; i < commandLinesSize; i++) doxygenCommands[commandLines[i]] = COMMANDLINE; - for (int i = 0; i < ignoreCommandLinesSize; i++) - doxygenCommands[ignoreCommandLines[i]] = IGNOREDCOMMANDLINE; - for (int i = 0; i < commandParagraphSize; i++) doxygenCommands[commandParagraph[i]] = COMMANDPARAGRAPH; - for (int i = 0; i < ignoreCommandParagraphsSize; i++) - doxygenCommands[ignoreCommandParagraphs[i]] = IGNORECOMMANDPARAGRAPH; - for (int i = 0; i < commandEndCommandsSize; i++) doxygenCommands[commandEndCommands[i]] = COMMANDENDCOMMAND; for (int i = 0; i < commandWordParagraphsSize; i++) @@ -70,7 +58,7 @@ void DoxygenParser::fillTables() { doxygenSectionIndicators.insert(sectionIndicators[i]); } -std::string DoxygenParser::StringToLower(std::string stringToConvert) { +std::string DoxygenParser::stringToLower(std::string &stringToConvert) { for (unsigned int i = 0; i < stringToConvert.length(); i++) { stringToConvert[i] = tolower(stringToConvert[i]); } @@ -79,7 +67,7 @@ std::string DoxygenParser::StringToLower(std::string stringToConvert) { int DoxygenParser::findCommand(std::string smallString) { std::map::iterator it; - smallString = StringToLower(smallString); + smallString = stringToLower(smallString); // I'm not sure if we can really do so, because there are different commands // in doxygenCommands and original commandArray it = doxygenCommands.find(smallString); @@ -89,7 +77,7 @@ int DoxygenParser::findCommand(std::string smallString) { } int DoxygenParser::isSectionIndicator(std::string smallString) { - smallString = StringToLower(smallString); + smallString = stringToLower(smallString); std::set::iterator it; it = doxygenSectionIndicators.find(smallString); if (it != doxygenSectionIndicators.end()) @@ -106,7 +94,7 @@ void DoxygenParser::printTree(std::list < DoxygenEntity > &rootList) { } int DoxygenParser::commandBelongs(std::string theCommand) { - std::string smallString = StringToLower(theCommand); + std::string smallString = stringToLower(theCommand); //cout << " Looking for command " << theCommand << endl; std::map::iterator it; it = doxygenCommands.find(smallString); @@ -238,8 +226,7 @@ std::list < Token >::iterator DoxygenParser::getEndCommand(std::string theComman return tokList.end(); } -std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string theCommand, TokenList & tokList) { -#pragma unused(theCommand,tokList) +std::list < Token >::iterator DoxygenParser::getTilAnyCommand(std::string, TokenList &) { std::list < Token >::iterator anIterator; return anIterator; } @@ -251,13 +238,6 @@ int DoxygenParser::addSimpleCommand(std::string theCommand, std::list < DoxygenE return 1; } -int DoxygenParser::ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { -#pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - return 1; -} - int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; @@ -272,18 +252,6 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s return 0; } -int DoxygenParser::ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { -#pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::string name = getNextWord(tokList); - if (!name.empty()) - return 1; - else - tokList.printListError("No word followed " + theCommand + " command."); - return 0; -} - int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; @@ -293,15 +261,6 @@ int DoxygenParser::addCommandLine(std::string theCommand, TokenList & tokList, s return 1; } -int DoxygenParser::ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { -#pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 1; -} - int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; @@ -312,15 +271,6 @@ int DoxygenParser::addCommandParagraph(std::string theCommand, TokenList & tokLi return 1; } -int DoxygenParser::ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { -#pragma unused(doxyList) - if (noisy) - cout << "Not Adding " << theCommand << endl; - std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); - tokList.setIterator(endOfParagraph); - return 1; -} - int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { if (noisy) cout << "Parsing " << theCommand << endl; @@ -399,8 +349,7 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, return 1; } -int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { -#pragma unused(doxyList) +int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &) { tokList.printListError("Encountered: " + theCommand + "\nThis command should not have been encountered. Behaviour past this may be unpredictable"); std::list < Token >::iterator endOfLine = getOneLine(tokList); @@ -684,7 +633,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { - std::string theCommand = StringToLower(commandString); + std::string theCommand = stringToLower(commandString); if (theCommand == "plainstd::string") { std::string nextPhrase = getStringTilCommand(tokList); if (noisy) @@ -692,53 +641,30 @@ int DoxygenParser::addCommand(std::string commandString, TokenList & tokList, st doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); return 1; } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND) { - return addSimpleCommand(theCommand, doxyList); + switch (commandBelongs(theCommand)) { + case SIMPLECOMMAND: + return addSimpleCommand(theCommand, doxyList); + case COMMANDWORD: + return addCommandWord(theCommand, tokList, doxyList); + case COMMANDLINE: + return addCommandLine(theCommand, tokList, doxyList); + case COMMANDPARAGRAPH: + return addCommandParagraph(theCommand, tokList, doxyList); + case COMMANDENDCOMMAND: + return addCommandEndCommand(theCommand, tokList, doxyList); + case COMMANDWORDPARAGRAPH: + return addCommandWordParagraph(theCommand, tokList, doxyList); + case COMMANDWORDLINE: + return addCommandWordLine(theCommand, tokList, doxyList); + case COMMANDWORDOWORDWORD: + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + case COMMANDOWORD: + return addCommandOWord(theCommand, tokList, doxyList); + case COMMANDERRORTHROW: + return addCommandErrorThrow(theCommand, tokList, doxyList); + case COMMANDUNIQUE: + return addCommandUnique(theCommand, tokList, doxyList); } - if (commandNumber == IGNOREDSIMPLECOMMAND) { - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD) { - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD) { - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE) { - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE) { - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH) { - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH) { - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND) { - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH) { - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE) { - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD) { - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD) { - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW) { - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE) { - return addCommandUnique(theCommand, tokList, doxyList); - } - return 0; } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 5f6432d87..376676e08 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -27,7 +27,7 @@ private: /* *Changes a std::string to all lower case */ - std::string StringToLower(std::string stringToConvert); + std::string stringToLower(std::string &stringToConvert); /* * Finds out if a command exists (is a possible command) @@ -112,12 +112,6 @@ private: * \n \\ \@ \& \$ \# \< \> \% */ int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList); - /* - * NOT INCLUDED Simple Commands - * Format: @command - * Plain commands, such as newline etc, they contain no other data - */ - int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList); /* * CommandWord * Format: @command @@ -126,13 +120,6 @@ private: * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" */ int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); - /* - * NOT INCLUDED CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" - */ - int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); /* * CommandLine * Format: @command (line) @@ -140,12 +127,6 @@ private: * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" */ int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); - /* - * NOT INCLUDED CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - */ - int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); /* * CommandParagraph * Format: @command {paragraph} @@ -154,12 +135,6 @@ private: * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" */ int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); - /* - * CommandParagraph - * Format: @command {paragraph} - * Commands with a single LINE after then such as @var - */ - int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); /* * Command EndCommand * Format: @command and ends at @endcommand @@ -207,9 +182,7 @@ private: */ int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList); /* - * The actual "meat" of the doxygen parser. This is not yet fully implemented - * with my current design- however the skeletal outline is contained in - * the file Skeleton + * The actual "meat" of the doxygen parser. Calls the correct addCommand* function */ int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList); diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 10f6a4585..51df52f59 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -32,7 +32,7 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) { String *DoxygenTranslator::getDocumentation(Node *node) { if (!hasDocumentation(node)) - return 0; + return NewString(""); return makeDocumentation(node); } diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 97be4ee35..7d2e64542 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -39,7 +39,7 @@ public: * Return the documentation for a given node formated for the correct * documentation system. * @param node The node to extract and translate documentation for. - * @return The resulted documentation string. + * @return The resulted documentation string, or empty string in case of any errors. */ String *getDocumentation(Node *node); /* @@ -57,8 +57,7 @@ protected: * Overridden in subclasses to return the documentation formatted for a given * documentation system. * @param node The node to extract and translate documentation for. - * @param documentation The returned documentation string. - * @return A bool to indicate if there was documentation to return for the node. + * @return The resulted documentation string */ virtual String *makeDocumentation(Node *node) = 0; diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 62dbdc997..fd5850ffe 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -45,7 +45,7 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c // check if it's one of the '!!!', '***', '///' of any length char c = currentWord[0]; isPlainString = false; - for (int i=0; i Date: Wed, 8 Aug 2012 14:16:48 +0000 Subject: [PATCH 0124/2031] Changed quoted strings handling. Also not missing any doxygen commands now. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13563 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../doxygen_translate_all_tags_runme.py | 13 ++-- .../DoxygenTranslator/src/DoxygenParser.cpp | 20 +++++- Source/DoxygenTranslator/src/TokenList.cpp | 67 ++++++++----------- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 768ccf1ba..e1d7a33b7 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -21,7 +21,7 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' ' SomeLatexIndex ' '' -' someGroupSome title ' +' someGroup"Some title" ' '' ' theAnchor' '' @@ -84,8 +84,8 @@ check(doxygen_translate_all_tags.function.__doc__, '' ' digraph example { ' ' node [shape=record, fontname=Helvetica, fontsize=10]; ' '' -' b [ label="class B" URL="\ref B"]; ' -' c [ label="class C" URL="\ref C"]; ' +' b [ label="class B" URL=" B"]; ' +' c [ label="class C" URL=" C"]; ' ' b -> c [ arrowhead="open", style="dashed" ]; ' ' } ' '' @@ -171,9 +171,9 @@ check(doxygen_translate_all_tags.function.__doc__, '' ' someThing' '' ' Sender,Receiver; ' -' Sender->Receiver [label="Command()", URL="\ref ' +' Sender->Receiver [label="Command()", URL=" ' ' Receiver::Command()"]; ' -' Sender<-Receiver [label="Ack()", URL="\ref ' +' Sender<-Receiver [label="Ack()", URL=" ' ' Ack()", ID="1"]; ' '' ' mscFile.mscThe caption' @@ -312,9 +312,10 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' ' This will only appear in XML ' '' +' todo"Todo"Todo List' '' ' Here goes test of symbols: ' ' $@\&~<>#%".::' '' ' And here goes simple text ' -) \ No newline at end of file +) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 4df82b2d7..dd2e556eb 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -106,7 +106,23 @@ int DoxygenParser::commandBelongs(std::string theCommand) { std::string DoxygenParser::getNextWord(TokenList & tokList) { Token nextToken = tokList.peek(); if (nextToken.tokenType == PLAINSTRING) { - nextToken = tokList.next(); + // handle quoted strings as words + if (nextToken.tokenString[0] == '"' + && nextToken.tokenString[nextToken.tokenString.size() - 1] != '"') { + string word = nextToken.tokenString + " "; + nextToken = tokList.next(); + while (true) { + string nextWord = getNextWord(tokList); + if (!nextWord.size()) // maybe report unterminated string error + return word; + word += nextWord; + if (word[word.size() - 1] == '"') // strip quotes + return word.substr(1, word.size() - 2); + word += " "; + } + } + + tokList.next(); return nextToken.tokenString; } return ""; @@ -120,7 +136,6 @@ std::list < Token >::iterator DoxygenParser::getOneLine(TokenList & tokList) { //endOfLine++; return endOfLine; } - //cout << (* endOfLine).toString(); endOfLine++; } @@ -390,6 +405,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, aNewList.push_front(DoxygenEntity("plainstd::string", title)); aNewList.push_front(DoxygenEntity("plainstd::string", heading)); aNewList.push_front(DoxygenEntity("plainstd::string", key)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \ingroup ( [ ]) diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index fd5850ffe..d69721e9a 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -28,57 +28,44 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c bool isPlainString = false; string::size_type pos, lastPos = 0; + char prevChar = doxygenComment[lastPos]; string currentWord; while (true) { isPlainString = false; - pos = doxygenComment.find_first_of("\t\n ", lastPos); + pos = doxygenComment.find_first_of("\\@\t\n ", lastPos); if (pos == string::npos) pos = doxygenComment.size(); - if (pos > lastPos) { - currentWord = doxygenComment.substr(lastPos, pos-lastPos); - if (currentWord[0] == '\\' || currentWord[0] == '@') { - // it's a doxygen command - currentWord = currentWord.substr(1, currentWord.length() - 1); - tokList.m_tokenList.push_back(Token(COMMAND, currentWord)); - } - else if (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/') { - // check if it's one of the '!!!', '***', '///' of any length - char c = currentWord[0]; - isPlainString = false; - for (size_t i=0; i= doxygenComment.size()) break; - - if (doxygenComment[pos] == '\n') - tokList.m_tokenList.push_back(Token(END_LINE, "\n")); } tokList.m_tokenListIter = tokList.m_tokenList.begin(); return tokList; From 7178385d48763cae99421c948657cd05d1d8e59b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 9 Aug 2012 18:58:53 +0000 Subject: [PATCH 0125/2031] Made comment output nicer, now printing _someword_ instead of _someword _ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13576 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/JavaDocConverter.cpp | 18 ++++++++++++++++-- .../DoxygenTranslator/src/PyDocConverter.cpp | 11 +++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index c7485ab4f..fb13728ea 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -199,8 +199,15 @@ void JavaDocConverter::translateEntity(DoxygenEntity& tag, std::string& translat } void JavaDocConverter::handleTagHtml(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { - if (tag.entityList.size()) // do not include empty tags - translatedComment += "<" + arg + ">" + translateSubtree(tag) + ""; + if (tag.entityList.size()) { // do not include empty tags + std::string tagData = translateSubtree(tag); + // wrap the thing, ignoring whitespaces + size_t wsPos = tagData.find_last_not_of("\n\t "); + if (wsPos != std::string::npos) + translatedComment += "<" + arg + ">" + tagData.substr(0, wsPos + 1) + "" + tagData.substr(wsPos + 1); + else + translatedComment += "<" + arg + ">" + translateSubtree(tag) + " "; + } } void JavaDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) { translatedComment += "\n * "; @@ -434,6 +441,13 @@ String *JavaDocConverter::makeDocumentation(Node *node) { std::string javaDocString = "/**\n * "; + // strip endlines at the beginning + while (entityList.begin()->typeOfEntity == "plainstd::endl") + entityList.pop_front(); + // and at the end + while (entityList.rbegin()->typeOfEntity == "plainstd::endl") + entityList.pop_back(); + // store the current node // (currently just to handle params) currentNode = node; diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 7937b5ba5..0f1f32cbb 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -227,8 +227,15 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag, std::string& translatedC translatedComment += paramNameEntity.data + " (" + paramType + ")" + paramDescription; } void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedComment, std::string &arg) { - if (tag.entityList.size()) // do not include empty tags - translatedComment += arg + translateSubtree(tag) + arg; + if (tag.entityList.size()) { // do not include empty tags + std::string tagData = translateSubtree(tag); + // wrap the thing, ignoring whitespaces + int wsPos = tagData.find_last_not_of("\n\t "); + if (wsPos != std::string::npos) + translatedComment += arg + tagData.substr(0, wsPos + 1) + arg + tagData.substr(wsPos + 1); + else + translatedComment += arg + tagData + arg + " "; + } } void PyDocConverter::handleNewLine(DoxygenEntity&, std::string& translatedComment, std::string&) { translatedComment += "\n"; From 423915eef695b50790d4345441bba161b5a845e9 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 9 Aug 2012 19:06:58 +0000 Subject: [PATCH 0126/2031] Added some docs, updated project-plan git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13577 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/plan-gsoc-2012.txt | 20 +++++++++++++---- Doc/Manual/Contents.html | 3 ++- Doc/Manual/Doxygen.html | 42 ++++++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 43fc1adc3..7e8ecf541 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -77,7 +77,9 @@ Functionality to the destination documentation. 'Not implemented' means that the tag with it's contents is stripped out of the output. - Doxygen tags: + Doxygen tags: + + All tags: -OK- \a - translated to in JD, surrounded with _ in PD \addindex - ignored @@ -257,12 +259,12 @@ Optional functionality That section describes some complex cases where the current code does not behave really well. Like a short to-do list of special cases. -- When translating functions with default parameters in swig to +-OK- When translating functions with default parameters in swig to java, it creates overloaded functions with all the parameters except the default ones. We need to copy the doxygen comment to such functions and correct the list of @param tags. -- In doxygen there is a special tags (and even a special option) +-OK- In doxygen there is a special tags (and even a special option) to create links to some code members from the current comment. Sometimes it needs a type of parameters specified because of the overloaded functions. And the same linking tags are supported in JD, @@ -303,6 +305,15 @@ The following test cases will be implemented: -OK- Class comment, with all supported tags. -OK- Class comment, with all doxygen tags, including ignored ones. + +The list of all tests, in form of shell commands to make it simple +to test project by copying the text below into terminal program. +make doxygen_parsing.cpptest -s +make doxygen_translate.cpptest -s +make doxygen_translate_all_tags.cpptest -s +make doxygen_basic_translate.cpptest -s +make doxygen_basic_notranslate.cpptest -s +make doxygen_translate_links.cpptest -s Refactoring @@ -313,7 +324,7 @@ All the code in directory _DoxygenTranslator_ should be refactored: -OK- most static methods should be normal members -OK- replace C arrays of strings and sequential searches with STL data structures and algorithms. -- use singletons instead of class instantiaion for each comment found. +-OK- use singletons instead of class instantiaion for each comment found. Documentation @@ -324,4 +335,5 @@ SWIG documentation will contain: -OK- list of implemented features (types and placements of comments) -OK- list of unimplemented features (types and placements of comments) -OK- list of tags and their translations (all Doxygen tags). +-OK- some amount of debugging and development information diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ca66d87cc..137c746ab 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1719,7 +1719,8 @@
  • Developer Information
  • Extending to Other Languages diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 3178f70c2..cb79ef83c 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -32,7 +32,8 @@
  • Developer Information
  • Extending to Other Languages @@ -1282,7 +1283,7 @@ This module builds its own private parse tree and hands it to a separate class f For example, JavaDocConverter is the JavaDoc module class.

    -

    39.5.2 Debugging commands

    +

    39.5.2 Debugging Doxygen parser and translator

    @@ -1294,6 +1295,43 @@ There are two handy command line switches, that enable lots of detailed debug in -debug-doxygen-translator - Display Doxygen translator module debugging information +

    39.5.3 Tests

    + + +

    +This part of SWIG currently has 6 runtime tests in both Java and Python. +

    + +
    +  doxygen_parsing
    +  doxygen_translate
    +  doxygen_translate_all_tags
    +  doxygen_basic_translate
    +  doxygen_basic_notranslate
    +  doxygen_translate_links
    +
    + +

    +All this tests are included in common.mk and are build with the commands like 'make check-test-suite' +or 'make check-python-test-suite'. To run them individually, type 'make .cpptest -s' in the +language-specific subdir in Examples\test-suite. +
    +Runtime tests in Java are implemented using JavaDoc doclets. To make that work, you +should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME +environmental var defined and pointing to the JDK location. +
    +The Java's comment parsing code (the testing part) is located in commentParser.java. +You may see it to understand how the checking process works. There is also a possibility +to run that file as stand-alone program, with 'java commentParser ', +and it will print the list of comments found in the specified dir (in the format it's used +in runtime tests). So, when you want to create the new test of Doxygen comment translator, +just copy any existing one, and replace the actual comment content (section of entries in +form 'wantedComments.put(...)' with the output of the above command. +
    +Runtime tests in Python are just plain strings comparison with the use of __doc__ +properties. +

    +

    39.6 Extending to Other Languages

    From f7f3960d1126069aa2c7414b66dbf437879d3f5d Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 10 Aug 2012 12:27:40 +0000 Subject: [PATCH 0127/2031] Eliminate 'signed/unsigned comparison' compiler warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13582 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/PyDocConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 0f1f32cbb..1826bcab5 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -230,7 +230,7 @@ void PyDocConverter::handleTagWrap(DoxygenEntity& tag, std::string& translatedCo if (tag.entityList.size()) { // do not include empty tags std::string tagData = translateSubtree(tag); // wrap the thing, ignoring whitespaces - int wsPos = tagData.find_last_not_of("\n\t "); + size_t wsPos = tagData.find_last_not_of("\n\t "); if (wsPos != std::string::npos) translatedComment += arg + tagData.substr(0, wsPos + 1) + arg + tagData.substr(wsPos + 1); else From 9600bb310f675b1462dd35e3cb074dfe388e3253 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 10 Aug 2012 21:21:16 +0000 Subject: [PATCH 0128/2031] Improved unknown Doxygen commands handling git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13591 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/DoxygenParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index dd2e556eb..cffdd6b0d 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -701,7 +701,8 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e if (currCommand < 0) { if (noisy) cout << "Unidentified Command " << currToken.tokenString << endl; - tokList.next(); + tokList.printListError("Unsupported command: " + currToken.tokenString + ". Ignored"); + tokList.current()->tokenType = PLAINSTRING; // little hack to add the command as plaintext addCommand(currPlainstringCommandType, tokList, aNewList); } else { tokList.next(); From 771c61f9f18bc1a8feb74d24ccffa7cd296232ae Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 11 Aug 2012 14:34:48 +0000 Subject: [PATCH 0129/2031] Renamed DoxygenComment to doxygen to better comply swig's attribute namings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13597 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 14 +++++++------- Source/DoxygenTranslator/src/DoxygenTranslator.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 27957d9ab..ddcdc5477 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -193,15 +193,15 @@ static void set_comment(Node *n, String *comment) { if (!n || !comment) return; - if (Getattr(n, "DoxygenComment")) - Append(Getattr(n, "DoxygenComment"), comment); + if (Getattr(n, "doxygen")) + Append(Getattr(n, "doxygen"), comment); else { - Setattr(n, "DoxygenComment", comment); + Setattr(n, "doxygen", comment); /* This is the first comment, populate it with @params, if any */ p = Getattr(n, "parms"); while (p) { - if (Getattr(p, "DoxygenComment")) - Printv(comment, "\n@param ", Getattr(p, "name"), Getattr(p, "DoxygenComment"), NIL); + if (Getattr(p, "doxygen")) + Printv(comment, "\n@param ", Getattr(p, "name"), Getattr(p, "doxygen"), NIL); p=nextSibling(p); } } @@ -212,7 +212,7 @@ static void set_comment(Node *n, String *comment) { return; n = nextSibling(n); while (n && Getattr(n, "name") && Strcmp(Getattr(n, "name"), name) == 0) { - Setattr(n, "DoxygenComment", comment); + Setattr(n, "doxygen", comment); n = nextSibling(n); } } @@ -3474,7 +3474,7 @@ doxygen_comment_item : DOXYGENSTRING { not translatable to javadoc anyway) */ if(0 && isStructuralDoxygen($1)){ $$ = new_node("doxycomm"); - Setattr($$,"DoxygenComment",$1); + set_comment($$, $1); } else { $$ = $1; diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 51df52f59..d9bf5f059 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -25,7 +25,7 @@ bool DoxygenTranslator::hasDocumentation(Node *node) { } String *DoxygenTranslator::getDoxygenComment(Node *node) { - return Getattr(node, "DoxygenComment"); + return Getattr(node, "doxygen"); } From 3eed72b659b456613ba3b1c5e942833003a2247b Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Sat, 11 Aug 2012 15:23:18 +0000 Subject: [PATCH 0130/2031] Updated Doxygen warning system git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13598 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../DoxygenTranslator/src/DoxygenParser.cpp | 42 +++++++++---------- Source/DoxygenTranslator/src/TokenList.cpp | 8 ++-- Source/DoxygenTranslator/src/TokenList.h | 3 +- Source/Include/swigwarn.h | 8 ++++ 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index cffdd6b0d..8be8660d7 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -174,7 +174,7 @@ std::string DoxygenParser::getStringTilEndCommand(std::string theCommand, TokenL tokList.next(); } - tokList.printListError(theCommand + " command expected"); + tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, theCommand + " command expected"); return description; } @@ -263,7 +263,7 @@ int DoxygenParser::addCommandWord(std::string theCommand, TokenList & tokList, s doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } else - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } @@ -291,7 +291,7 @@ int DoxygenParser::addCommandEndCommand(std::string theCommand, TokenList & tokL cout << "Parsing " << theCommand << endl; std::list < Token >::iterator endCommand = getEndCommand("end" + theCommand, tokList); if (endCommand == tokList.end()) { - tokList.printListError("Expected end" + theCommand); + tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected end" + theCommand); return 0; } std::list < DoxygenEntity > aNewList; @@ -306,7 +306,7 @@ int DoxygenParser::addCommandWordParagraph(std::string theCommand, TokenList & t cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); @@ -322,7 +322,7 @@ int DoxygenParser::addCommandWordLine(std::string theCommand, TokenList & tokLis cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } std::list < Token >::iterator endOfLine = getOneLine(tokList); @@ -339,7 +339,7 @@ int DoxygenParser::addCommandWordOWordOWord(std::string theCommand, TokenList & cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } std::string headerfile = getNextWord(tokList); @@ -365,7 +365,7 @@ int DoxygenParser::addCommandOWord(std::string theCommand, TokenList & tokList, } int DoxygenParser::addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &) { - tokList.printListError("Encountered: " + theCommand + + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "Encountered: " + theCommand + "\nThis command should not have been encountered. Behaviour past this may be unpredictable"); std::list < Token >::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); @@ -387,17 +387,17 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string key = getNextWord(tokList); if (key.empty()) { - tokList.printListError("No key followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added"); return 0; } std::string heading = getNextWord(tokList); if (key.empty()) { - tokList.printListError("No heading followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No heading followed " + theCommand + " command. Not added"); return 0; } std::string title = getNextWord(tokList); if (title.empty()) { - tokList.printListError("No title followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No title followed " + theCommand + " command. Not added"); return 0; } std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); @@ -460,7 +460,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } std::list < DoxygenEntity > aNewList; @@ -477,7 +477,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No key followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added"); return 0; } std::string text = getNextWord(tokList); @@ -492,7 +492,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No name followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added"); return 0; } std::string text = getNextWord(tokList); @@ -541,7 +541,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string file = getNextWord(tokList); if (file.empty()) { - tokList.printListError("No file followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No file followed " + theCommand + " command. Not added"); return 0; } std::string caption = getNextWord(tokList); @@ -556,12 +556,12 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string format = getNextWord(tokList); if (format.empty()) { - tokList.printListError("No format followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No format followed " + theCommand + " command. Not added"); return 0; } std::string file = getNextWord(tokList); if (file.empty()) { - tokList.printListError("No name followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added"); return 0; } std::string caption = getNextWord(tokList); @@ -582,7 +582,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); if (name.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } std::list < DoxygenEntity > aNewList; @@ -605,7 +605,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, if (needsCond) { cond = getNextWord(tokList); if (cond.empty()) { - tokList.printListError("No word followed " + theCommand + " command. Not added"); + tokList.printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); return 0; } } @@ -633,7 +633,7 @@ int DoxygenParser::addCommandUnique(std::string theCommand, TokenList & tokList, } if (endCommand == tokList.end()) { - tokList.printListError("No corresponding endif found"); + tokList.printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "No corresponding endif found"); return 0; } @@ -701,7 +701,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e if (currCommand < 0) { if (noisy) cout << "Unidentified Command " << currToken.tokenString << endl; - tokList.printListError("Unsupported command: " + currToken.tokenString + ". Ignored"); + tokList.printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "Unsupported command: '" + currToken.tokenString + "'. Ignored"); tokList.current()->tokenType = PLAINSTRING; // little hack to add the command as plaintext addCommand(currPlainstringCommandType, tokList, aNewList); } else { @@ -714,7 +714,7 @@ std::list < DoxygenEntity > DoxygenParser::parse(std::list < Token >::iterator e if (endParsingIndex != tokList.end() && tokList.current() == tokList.end()) { // this could happen if we cant reach the original endParsingIndex - tokList.printListError("Unexpected end of comment encountered"); + tokList.printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of comment encountered"); break; } } diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index d69721e9a..037518263 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -42,8 +42,10 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c else if (prevChar == '\\' || prevChar == '@') { // it's a doxygen command // hack to get commands like \\ or \@ or @\ or @@ - if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\') + if (doxygenComment[pos] == '@' || doxygenComment[pos] == '\\') { currentWord += doxygenComment[pos]; + pos++; + } tokList.m_tokenList.push_back(Token(COMMAND, currentWord)); } else if (currentWord.size() && (currentWord[0] == '!' || currentWord[0] == '*' || currentWord[0] == '/')) { @@ -133,10 +135,10 @@ void TokenList::printList() { } } -void TokenList::printListError(std::string message) { +void TokenList::printListError(int warningType, std::string message) { int curLine = fileLine; for (list< Token >::iterator it = m_tokenList.begin(); it != current(); it++) if (it->tokenType == END_LINE) curLine++; - Swig_error(fileName.c_str(), curLine, "Doxygen parser error: %s. \n", message.c_str()); + Swig_warning(warningType, fileName.c_str(), curLine, "Doxygen parser warning: %s. \n", message.c_str()); } diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index ce9d14c45..69580f11c 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -16,6 +16,7 @@ #include #include #include "Token.h" +#include "swigwarn.h" /* a small class used to represent the sequence of tokens * that can be derived from a formatted doxygen string @@ -43,7 +44,7 @@ public: void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */ void printList(); /* prints out the sequence of tokens */ - void printListError(std::string message); /* prints properly formatted error message */ + void printListError(int warningType, std::string message); /* prints properly formatted error message */ /* * Create TokenList and populate it with tokens from diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 1aae86fdd..68f35e02f 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -221,6 +221,14 @@ /* please leave 700-719 free for D */ +#define WARN_DOXYGEN_UNKNOWN_COMMAND 720 +#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 721 +#define WARN_DOXYGEN_COMMAND_EXPECTED 722 +#define WARN_DOXYGEN_UNTERMINATED_STRING 723 +#define WARN_DOXYGEN_COMMAND_ERROR 724 + +/* please leave 720-729 free for Doxygen */ + #define WARN_RUBY_WRONG_NAME 801 #define WARN_RUBY_MULTIPLE_INHERITANCE 802 From c592e0db5126796221d83bd9b7e68fa68088cdef Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Mon, 13 Aug 2012 09:09:25 +0000 Subject: [PATCH 0131/2031] Made doxygen parsing switched off by default git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13602 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Source/CParse/cscanner.c | 2 +- Source/Modules/java.cxx | 9 ++------- Source/Modules/python.cxx | 9 ++------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 86e33037a..e7f757f0e 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -64,7 +64,7 @@ CXXSRCS = CSRCS = TARGETPREFIX = TARGETSUFFIX = -SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +SWIGOPT = -doxygen -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index e15201b93..fb5754856 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -47,7 +47,7 @@ static int last_id = 0; static int rename_active = 0; /* Doxygen comments scanning */ -int scan_doxygen_comments = 1; +int scan_doxygen_comments = 0; /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 3591b7363..910d481ab 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -123,7 +123,7 @@ public: global_variable_flag(false), old_variable_names(false), member_func_flag(false), - doxygen(true), + doxygen(false), comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), @@ -267,10 +267,6 @@ public: Swig_mark_arg(i); doxygen = true; scan_doxygen_comments = true; - } else if ((strcmp(argv[i], "-nodoxygen") == 0)) { - Swig_mark_arg(i); - doxygen = false; - scan_doxygen_comments = false; } else if ((strcmp(argv[i], "-debug-doxygen-translator") == 0)) { Swig_mark_arg(i); debug_doxygen_translator = true; @@ -4541,8 +4537,7 @@ extern "C" Language *swig_java(void) { const char *JAVA::usage = (char *) "\ Java Options (available with -java)\n\ - -doxygen - Convert C++ doxygen comments to JavaDoc comments in proxy classes (default)\n\ - -nodoxygen - Don't convert C++ doxygen comments to JavaDoc comments in proxy classes\n\ + -doxygen - Convert C++ doxygen comments to JavaDoc comments in proxy classes\n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f7c9c00c1..1d2096c81 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -85,7 +85,7 @@ static int buildnone = 0; static int nobuildnone = 0; static int safecstrings = 0; static int dirvtable = 0; -static int doxygen = 1; +static int doxygen = 0; static int proxydel = 1; static int fastunpack = 0; static int fastproxy = 0; @@ -120,7 +120,7 @@ Python Options (available with -python)\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ - -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes (default) \n\ + -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ @@ -141,7 +141,6 @@ static const char *usage2 = (char *) "\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ - -nodoxygen - Don't convert C++ doxygen comments to pydoc comments in proxy classes \n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ -nofastinit - Use traditional init mechanism for classes \n\ @@ -431,10 +430,6 @@ public: doxygen = 1; scan_doxygen_comments = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nodoxygen") == 0) { - doxygen = 0; - scan_doxygen_comments = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-debug-doxygen-translator") == 0) { debug_doxygen_translator = true; Swig_mark_arg(i); From a9cdb000bac276c5750fa785a8e230a757dd4d8a Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 16 Aug 2012 11:35:02 +0000 Subject: [PATCH 0132/2031] Made swig strip out all structural comments git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13622 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ddcdc5477..24c1842c0 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3469,19 +3469,18 @@ doxygen_comment_item : DOXYGENSTRING { DohReplace($1, "//!", "", 0); DohReplace($1, "*/", "", 0); - /* isStructuralDoxygen() is disabled, since no comment - appears in such case. Need to fix. (most commands are - not translatable to javadoc anyway) */ - if(0 && isStructuralDoxygen($1)){ - $$ = new_node("doxycomm"); - set_comment($$, $1); - } - else { - $$ = $1; + /* Throw out all structural comments */ + if (isStructuralDoxygen($1)) { + Delete($1); + $1 = 0; } + $$ = $1; } | doxygen_comment_item doxygen_comment_item { - Append($1, $2); + if ($1) + Append($1, $2); + else + $1 = $2; $$ = $1; } ; From 40ce1b412ad7d038e9e114ad94049ffe5faad7aa Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Thu, 16 Aug 2012 14:16:59 +0000 Subject: [PATCH 0133/2031] Now commands with no whitespace following them are also parsed git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13632 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DoxygenTranslator/src/TokenList.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 037518263..ceea0ba17 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -46,6 +46,14 @@ TokenList TokenList::tokenizeDoxygenComment(const std::string &doxygenComment, c currentWord += doxygenComment[pos]; pos++; } + // also strip the command till the first nonalpha char + for (int i=2; i Date: Thu, 16 Aug 2012 14:18:47 +0000 Subject: [PATCH 0134/2031] Fixed lots of PyDoc converter problems, see doxygen_tricky_constructs test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13633 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/doxygen_tricky_constructs.i | 106 +++++++++++++ .../doxygen_translate_all_tags_runme.py | 145 +----------------- .../python/doxygen_translate_runme.py | 6 +- .../DoxygenTranslator/src/PyDocConverter.cpp | 62 +++++++- Source/DoxygenTranslator/src/PyDocConverter.h | 4 + 5 files changed, 169 insertions(+), 154 deletions(-) create mode 100644 Examples/test-suite/doxygen_tricky_constructs.i diff --git a/Examples/test-suite/doxygen_tricky_constructs.i b/Examples/test-suite/doxygen_tricky_constructs.i new file mode 100644 index 000000000..96b1dfae3 --- /dev/null +++ b/Examples/test-suite/doxygen_tricky_constructs.i @@ -0,0 +1,106 @@ +# This file contains tests for situations, which do not normally +# appear in the code, but must neverthless be handled correctly. + +%module doxygen_tricky_constructs + +%inline %{ + + # Bug 1: Tag '@endink' is not recognized becuse it is not + # followed by whitespace. + + /** + * Tag endlink must be recognized also when followed by nonspace charater. + * + * @link Connection::getId() @endlink
    + */ + char g_counter; + + + /** + * Tag endlink must be recognized also when it is the last token + * in the commment. + * + * @link Connection::getId() @endlink
    + * @link debugIdeTraceProfilerCoverageSample.py Python example. @endlink + */ + int g_zipCode; + + + # Bug 2: Paramter 'isReportSize' is missing in comment of the overload, which + # has it. This bug disappears if @endlink is follwed by a space. + # + # Bug 3: Empty line before the link is missing, + # making the link text part of parameter description. This bug appears also + # when there is ordinary text in place of the link in case of overload + # with only 2 parameters. + /** + * Returns address of file line. + * + * @param fileName name of the file, where the source line is located + * @param line line number + * @param isGetSize if set, for every object location both address and size are returned + * + * @link Connection::getId() @endlink
    + */ + std::vector getAddress(const std::string &fileName, + int line, + bool isGetSize = false); + + # Bug 4: The first comment is attached to the second in Python (wrong), + # but not in Java (correct). + /** + * \defgroup icFacade isystem.connect Facade + * + * This page shows the core classes, which can be used to control + * all aspects of winIDEA, for example: debugging, analyzers, IO module, ... + */ + + /** + * This class contains information for connection to winIDEA. Its methods + * return reference to self, so we can use it like this: + *
    +     * CConnectionConfig config = new CConnectionConfig();
    +     * config.discoveryPort(5534).dllPath("C:\\myWinIDEA\\connect.dll").id("main");
    +     * 
    + * + * All parameters are optional. Set only what is required, default values are + * used for unspecified parameters. + *

    + * + * @link advancedWinIDEALaunching.py Python example. @endlink
    + */ + class CConnectionConfig + { + }; + + # Bug 5: Text after '\c' has no space following in Python. + # There are also to many empty lines in multiline comments in Python. + # Whitespaces are really a problem in Python (space and newlines), + # I like a parameter type added to each parameter description! + # """ + # Determines how long the isystem.connectshould wait for running + # + # instances to respond. Only one of lfWaitXXXflags from IConnect::ELaunchFlags + # + # may be specified. + # + # """ + + /** + * Determines how long the \c isystem.connect should wait for running + * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags + * may be specified. + */ + int waitTime(long waitTime); + + + # Bug 6: Text after tag \ingroup appears in Python comment (empty line in + # Java, which is acceptable): + /** \ingroup icFacade + * + * This class manages connection. + */ + int getConnection(); + + +%} diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index e1d7a33b7..f71cb7e11 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -19,12 +19,6 @@ def check(got, expected): check(doxygen_translate_all_tags.function.__doc__, '' ' _Hello_' '' -' SomeLatexIndex ' -'' -' someGroup"Some title" ' -'' -' theAnchor' -'' ' -some list item ' '' ' This is attention! ' @@ -44,60 +38,29 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' ' codeword' '' -' someCategoryheaderFile.hheaderName' -'' ' \'citationword\'' '' -' someClassheaderFile.hheaderName' -'' ' some test code ' '' ' Conditional comment: SOMECONDITION' ' Some conditional comment ' ' End of conditional comment.' '' -' someClass::someMethod' -'' -' someClass::someMethod2' -'' -' someClass::someMethod3' -'' ' Copyright:' ' some copyright ' '' ' 1970 - 2012 ' '' -' someDefine' -'' -' someGroupSome titles ' -'' ' Deprecated:' ' Now use another function ' '' ' This is very large ' ' and detailed description of some thing ' '' -' /somePath/someFolder' -'' -' someFile.h' -'' -' digraph example { ' -' node [shape=record, fontname=Helvetica, fontsize=10]; ' -'' -' b [ label="class B" URL=" B"]; ' -' c [ label="class C" URL=" C"]; ' -' b -> c [ arrowhead="open", style="dashed" ]; ' -' } ' -'' -'' -' dotFile.dotThe caption' -'' ' _italicword_' '' ' emphazedWord' '' -' someEnum' -'' ' Example:' ' someFile.txt' ' Some details on using the example ' @@ -105,16 +68,6 @@ check(doxygen_translate_all_tags.function.__doc__, '' ' Throws:' ' SuperError' '' -' someOtherFunction' -'' -' file.h' -'' -' someFn ' -'' -' someHeader.hHeader name' -'' -' htmlFile.htm' -'' ' This will only appear in hmtl ' '' ' If: ANOTHERCONDITION {' @@ -135,21 +88,11 @@ check(doxygen_translate_all_tags.function.__doc__, '' ' This is printed if not ' ' }' '' -' Image: htmltestImage.bmpHello, world!asd=10qwe' -'' -' someFunction' -'' -' header.h' -'' -' header2.h' -'' -' someGroupanotherGroup' +' Image: testImage.bmp(Hello, world!)' '' ' Some text ' ' describing invariant. ' '' -' someInterfacesomeHeader.hHeader name' -'' ' This will only appear in LATeX ' '' '

      ' @@ -160,28 +103,10 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' '
    ' '' -' example ' -'' ' someMember Some description follows ' '' -' Sometitle ' -'' ' This will only appear in man ' '' -' someThing' -'' -' Sender,Receiver; ' -' Sender->Receiver [label="Command()", URL=" ' -' Receiver::Command()"]; ' -' Sender<-Receiver [label="Ack()", URL=" ' -' Ack()", ID="1"]; ' -'' -' mscFile.mscThe caption' -'' -' someHeader.h ' -'' -' someNamespace' -'' ' Notes:' ' Here ' ' is the note! ' @@ -191,37 +116,13 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' ' someword' '' -' superPackage' -'' -' somePageThe title ' -'' ' Title: The paragraph title ' ' The paragraph text. ' ' Maybe even multiline ' '' -' someParagraphParagraph title ' -'' ' Arguments:' ' a (int) -- the first param ' '' -' Some description ' -'' -' Some description ' -'' -' someVar ' -'' -' someProtocolheader.hHeader name' -'' -' someAnchor' -'' -' toSomething' -'' -' toSomethingElse' -'' -' someName' -'' -' someName' -'' ' Remarks:' ' Some remark text ' '' @@ -234,47 +135,20 @@ check(doxygen_translate_all_tags.function.__doc__, '' '' ' may return ' '' -' someValueSome description ' -'' -'' ' This will only appear in RTF ' '' '' ' See also:' ' someOtherMethod ' '' -' someSectionSome title ' -'' ' function ' '' ' Same as ' ' brief description ' '' -'' -'' ' Since:' ' version 0.0.0.1 ' '' -' somePattern ' -'' -' someLine ' -'' -' example.hSome snippet ' -'' -' someStruct' -'' -' someSubpageSome description' -'' -' someSubsectionSome title ' -'' -' someSubsectionSome title ' -'' -'' -'' -' Some ' -' description of the ' -' test case ' -'' ' Throws:' ' superException' '' @@ -286,34 +160,17 @@ check(doxygen_translate_all_tags.function.__doc__, '' ' Arguments:' ' b (float) -- B is mentioned again... ' '' -' someTypedef ' -'' -' someUnion' -'' -' somePattern ' -'' -' someVar ' -'' -'' ' very long ' ' text with tags ' '' -'' -' someFile.h' -'' ' Version:' ' 0.0.0.2 ' '' ' Warning:' ' This is senseless! ' '' -' someGroupSome title ' -'' -'' ' This will only appear in XML ' '' -' todo"Todo"Todo List' -'' ' Here goes test of symbols: ' ' $@\&~<>#%".::' '' diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 61e5f5398..e7d819199 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -71,7 +71,7 @@ check(doxygen_translate.function.__doc__, '' ' This is printed if not ' ' }' '' -' Image: htmltestImage.bmpHello, world!asd=10qwe' +' Image: testImage.bmp(Hello, world!)' '' ' +
  • Support for Multithreaded Applications + diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index c0a7911d1..92488413e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2966,9 +2966,6 @@ class MyFoo(mymodule.Foo):

    36.5.2 Director classes

    - - -

    For each class that has directors enabled, SWIG generates a new class that derives from both the class in question and a special @@ -6737,6 +6734,7 @@ prohibiting it.

    36.13 Support for Multithreaded Applications

    +

    By default, SWIG does not enable support for multithreaded Python applications. More specifically, the Python wrappers generated by SWIG will not release the Python's interpreter's Global Interpreter Lock (GIL) when wrapped C/C++ code is @@ -6751,43 +6749,56 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai

    36.13.1 UI for Enabling Multithreading Support

    +

    The user interface is as follows:

      -
    1. Module thread support can be enabled in two ways: -
        -
      • - The -threads swig python option at the command line (or in setup.py): -
        $ swig -python -threads example.i
        -
      • -
      • - The threads module option in the *.i template file: -
        %feature("nothread") method;
        -
      • -
      -
    2. -
    3. You can disable thread support for a given method: -
      %module("threads"=1)
      or
      %nothread method;
      -
    4. -
    5. You can partially disable thread support for a given method: -
        -
      • To disable the C++/python thread protection: -
        %feature("nothreadblock") method;
        or
        %nothreadblock method;
        -
      • -
      • - To disable the python/C++ thread protection -
        %feature("nothreadallow") method;
        or
        %nothreadallow method;
        -
      • -
      -
    6. +
    7. Module thread support can be enabled in two ways:

      +
        +
      • +

        + The -threads swig python option at the command line (or in setup.py): +

        +
        $ swig -python -threads example.i
        +
      • +
      • +

        + The threads module option in the *.i template file: +

        +
        %feature("nothread") method;
        +
      • +
      +
    8. +
    9. You can disable thread support for a given method:

      +
      %module("threads"=1)
      + or +
      %nothread method;
      +
    10. +
    11. You can partially disable thread support for a given method:

      +
        +
      • To disable the C++/python thread protection:

        +
        %feature("nothreadblock") method;
        + or +
        %nothreadblock method;
        +
      • +
      • +

        To disable the python/C++ thread protection

        +
        %feature("nothreadallow") method;
        + or +
        %nothreadallow method;
        +
      • +
      +

    36.13.2 Multithread Performance

    + +

    For the curious about performance, here are some numbers for the profiletest.i test, which is used to check the speed of the wrapped code:

    - +
    From 7350e9fffa998e0b25ad43b7495f9284c10d4a6a Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 24 Mar 2017 14:22:53 +0100 Subject: [PATCH 0455/2031] Typo in Python.html --- Doc/Manual/Python.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 680d8d380..9b3afbdd9 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6827,7 +6827,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai
    Thread Mode Execution Time (sec)

    - Fullly threaded code decreases the wrapping performance by + Fully threaded code decreases the wrapping performance by around 60%. If that is important to your application, you can tune each method using the different 'nothread', 'nothreadblock' or 'nothreadallow' features as From ddf23498813ebe7e45a7b84365bdad33cf649929 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Mar 2017 19:39:05 +0000 Subject: [PATCH 0456/2031] Octave Travis install workaround tweak Workaround only needed for kwwette installs --- Tools/travis-linux-install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index bd18dfb3c..43bdb77bc 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -63,17 +63,17 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install ocaml ocaml-findlib ;; "octave") - # Travis adds external PPAs which contain newer versions of packages - # than in baseline trusty. These newer packages prevent some of the - # Octave packages in ppa:kwwette/octave, which rely on the older - # packages in trusty, from installing. To prevent these kind of - # interactions arising, clean out all external PPAs added by Travis - # before installing Octave - travis_retry sudo rm -rf /etc/apt/sources.list.d/* - travis_retry sudo apt-get -qq update if [[ -z "$VER" ]]; then travis_retry sudo apt-get -qq install liboctave-dev else + # Travis adds external PPAs which contain newer versions of packages + # than in baseline trusty. These newer packages prevent some of the + # Octave packages in ppa:kwwette/octave, which rely on the older + # packages in trusty, from installing. To prevent these kind of + # interactions arising, clean out all external PPAs added by Travis + # before installing Octave + sudo rm -rf /etc/apt/sources.list.d/* + travis_retry sudo apt-get -qq update travis_retry sudo add-apt-repository -y ppa:kwwette/octaves travis_retry sudo apt-get -qq update travis_retry sudo apt-get -qq install liboctave${VER}-dev From 8a0cd59dcb9cc5e58a0bbe3530e6b836641bb7ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Mar 2017 20:35:39 +0000 Subject: [PATCH 0457/2031] Add changes entry for #939 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 717ce2ee6..a7ae33faa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-03-24: tamuratak + [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks + on VALUE obj. + 2017-03-17: wsfulton [Go] Fix handling of typedef'd function pointers and typedef'd member function pointers such as: From b32854bc592c82d1401ed749f6ca7fff686180ef Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Wed, 29 Mar 2017 19:11:44 +0900 Subject: [PATCH 0458/2031] use forward declaration to treat the dependency of fragments --- Examples/test-suite/cpp11_shared_ptr_upcast.i | 6 ++--- Lib/ruby/rubystdcommon.swg | 5 ++-- Lib/ruby/rubystdcommon_forward.swg | 14 ++++++++++ Lib/ruby/std_shared_ptr.i | 26 ++++++++++++------- 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 Lib/ruby/rubystdcommon_forward.swg diff --git a/Examples/test-suite/cpp11_shared_ptr_upcast.i b/Examples/test-suite/cpp11_shared_ptr_upcast.i index 637563d53..22bc55594 100644 --- a/Examples/test-suite/cpp11_shared_ptr_upcast.i +++ b/Examples/test-suite/cpp11_shared_ptr_upcast.i @@ -9,9 +9,9 @@ #include %} -%include std_vector.i -%include std_map.i -%include std_shared_ptr.i +%include +%include +%include %{ diff --git a/Lib/ruby/rubystdcommon.swg b/Lib/ruby/rubystdcommon.swg index 2f7c03c0b..d1d366cf0 100644 --- a/Lib/ruby/rubystdcommon.swg +++ b/Lib/ruby/rubystdcommon.swg @@ -3,12 +3,11 @@ * The Ruby classes, for C++ * ------------------------------------------------------------ */ %include +%include -%fragment("StdTraits","header",fragment="StdTraitsCommon") +%fragment("StdTraits","header",fragment="StdTraitsCommon",fragment="StdTraitsForwardDeclaration") { -%#define SWIG_RUBYSTDCOMMON - namespace swig { /* Traits that provides the from method diff --git a/Lib/ruby/rubystdcommon_forward.swg b/Lib/ruby/rubystdcommon_forward.swg new file mode 100644 index 000000000..27bcb9960 --- /dev/null +++ b/Lib/ruby/rubystdcommon_forward.swg @@ -0,0 +1,14 @@ +%fragment("StdTraitsForwardDeclaration","header") +{ +namespace swig { + template struct traits_asptr; + template struct traits_asval; + struct pointer_category; + template struct traits_as; + template struct traits_from; + template struct noconst_traits; + template swig_type_info* type_info(); + template const char* type_name(); + template VALUE from(const Type& val); +} +} diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index 0610d590d..5d56b8750 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -1,16 +1,15 @@ #define SWIG_SHARED_PTR_NAMESPACE std %include +%include - /* - * We want to put the following code after the fragment "StdTraits" at rubystdcommon.swg. - * This code is needed if and only if the fragment and this std_shared_ptr.i are included at the same time. - * They don't always require each other. The order of including them is not predetermined either. - * So specifying the dependecy by using %fragment does not work. - */ -%wrapper %{ -#ifdef SWIG_RUBYSTDCOMMON +%fragment("StdSharedPtrTraits","header",fragment="StdTraitsForwardDeclaration") +{ namespace swig { + /* + template specialization for functions defined in rubystdcommon.swg. + here we should treat smart pointers in a way different from the way we treat raw pointers. + */ template struct traits_asptr > { static int asptr(VALUE obj, std::shared_ptr **val) { @@ -84,6 +83,11 @@ namespace swig { } }; + /* + we have to remove the const qualifier to work around a BUG + SWIG_TypeQuery("std::shared_ptr") == NULL, + which is caused by %template treating const qualifiers not properly. + */ template struct traits_from > { static VALUE from(const std::shared_ptr& val) { @@ -92,5 +96,7 @@ namespace swig { } }; } -#endif -%} +} + +//force the fragment. +%fragment("StdSharedPtrTraits"); From 8e70c588dfcba5542831ada45064508ba9970b70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Mar 2017 18:07:49 +0100 Subject: [PATCH 0459/2031] Add #917 to changes file --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a7ae33faa..93b3cc5c4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-02-29: tamuratak + [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing + for std::list, std::multiset, std::unordered_multiset and std::unordered_map. + 2017-03-24: tamuratak [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks on VALUE obj. From d56c8ef9ffcf96acbe7e9cc69eefd11e81488ada Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Mar 2017 07:32:04 +0100 Subject: [PATCH 0460/2031] Rename new Ruby assert functions used in test-suite --- Examples/test-suite/ruby/swig_assert.rb | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb index 2d5d1f406..5b3f9b5ce 100644 --- a/Examples/test-suite/ruby/swig_assert.rb +++ b/Examples/test-suite/ruby/swig_assert.rb @@ -1,12 +1,7 @@ #!/usr/bin/env ruby # -# A simple function to create useful asserts +# Useful assert functions # -# -# -# -# - # # Exception raised when some swig binding test fails @@ -16,15 +11,15 @@ end # -# simple assertions. strings are not needed as arguments. +# Simple assertions. Strings are not needed as arguments. # -def simple_assert_equal(a, b) +def swig_assert_equal_simple(a, b) unless a == b raise SwigRubyError.new("\n#{a} expected but was \n#{b}") end end -def simple_assert(a) +def swig_assert_simple(a) unless a raise SwigRubyError.new("assertion falied.") end From e66d8125aae043fc9a3b145116339ea5066ebf4c Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Fri, 31 Mar 2017 01:45:26 -0700 Subject: [PATCH 0461/2031] [Lua] Fix compiler warnings --- Lib/lua/luarun.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 660dbbf86..3510d04d7 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1860,7 +1860,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { switch(constants[i].type) { case SWIG_LUA_INT: lua_pushstring(L,constants[i].name); - lua_pushinteger(L,(lua_Number)constants[i].lvalue); + lua_pushinteger(L,(lua_Integer)constants[i].lvalue); lua_rawset(L,-3); break; case SWIG_LUA_FLOAT: @@ -1871,7 +1871,7 @@ SWIG_Lua_InstallConstants(lua_State *L, swig_lua_const_info constants[]) { case SWIG_LUA_CHAR: lua_pushstring(L,constants[i].name); { - char c = constants[i].lvalue; + char c = (char)constants[i].lvalue; lua_pushlstring(L,&c,1); } lua_rawset(L,-3); From 07d81cc1e9f912a4710b12d1ddb35f84e05710b0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Mar 2017 23:00:56 +0100 Subject: [PATCH 0462/2031] Use new unified Mono mcs compiler if available under Unix Do not prefer the old .NET 2 gmcs compiler, which was used even if the newer .NET 4 mcs was available. This is recommended by Mono project, see http://www.mono-project.com/docs/about-mono/languages/csharp/, and the .NET 1 original mcs is nowhere to be found nowadays. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4d9355cd0..7c0c916f3 100644 --- a/configure.ac +++ b/configure.ac @@ -2267,14 +2267,14 @@ else if test -z "$CSHARPCOMPILERBIN" ; then case $host in *-*-cygwin* | *-*-mingw*) - # prefer Mono gmcs (.NET 2.0) over mcs (.NET 1.1) - note mcs-1.2.3 has major pinvoke bug - AC_CHECK_PROGS(CSHARPCOMPILER, csc mono-csc gmcs mcs cscc) + # prefer unified Mono mcs compiler (not to be confused with the ancient .NET 1 mcs) over older/alternative names. + AC_CHECK_PROGS(CSHARPCOMPILER, csc mcs mono-csc gmcs cscc) if test -n "$CSHARPCOMPILER" && test "$CSHARPCOMPILER" = "csc" ; then AC_MSG_CHECKING(whether csc is the Microsoft CSharp compiler) csc 2>/dev/null | grep "C#" > /dev/null || CSHARPCOMPILER="" if test -z "$CSHARPCOMPILER" ; then AC_MSG_RESULT(no) - AC_CHECK_PROGS(CSHARPCOMPILER, mono-csc gmcs mcs cscc) + AC_CHECK_PROGS(CSHARPCOMPILER, mcs mono-csc gmcs cscc) else AC_MSG_RESULT(yes) fi From aa047c43f73d155f920871e23e7d9e909563e017 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Mar 2017 18:45:27 +0100 Subject: [PATCH 0463/2031] Add support for std::complex<> to C# Create Lib/csharp/complex.i with simplest possible typemaps mapping std::complex<> to System.Numerics.Complex. --- CHANGES.current | 3 ++ Examples/test-suite/csharp/Makefile.in | 2 + .../test-suite/csharp/complextest_runme.cs | 28 ++++++++++++ Lib/csharp/complex.i | 44 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 Examples/test-suite/csharp/complextest_runme.cs create mode 100644 Lib/csharp/complex.i diff --git a/CHANGES.current b/CHANGES.current index 93b3cc5c4..73740bf0c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -15,6 +15,9 @@ Version 3.0.13 (in progress) [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks on VALUE obj. +2017-03-17: vadz + [C#] Add support for std::complex + 2017-03-17: wsfulton [Go] Fix handling of typedef'd function pointers and typedef'd member function pointers such as: diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 0c799c7d9..292854a9f 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -13,6 +13,7 @@ top_srcdir = ../@top_srcdir@ top_builddir = ../@top_builddir@ CPP_TEST_CASES = \ + complextest \ csharp_attributes \ csharp_swig2_compatibility \ csharp_exceptions \ @@ -40,6 +41,7 @@ CSHARPFLAGSSPECIAL = # Custom tests - tests with additional commandline options intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname +complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP diff --git a/Examples/test-suite/csharp/complextest_runme.cs b/Examples/test-suite/csharp/complextest_runme.cs new file mode 100644 index 000000000..781909f25 --- /dev/null +++ b/Examples/test-suite/csharp/complextest_runme.cs @@ -0,0 +1,28 @@ +// This is the complex runtime testcase. It checks that the C++ std::complex type works. +// It requires .NET 4.0 as the previous versions didn't have System.Numerics.Complex type. + +using System; +using System.Numerics; + +using complextestNamespace; + +public class complextest_runme { + + public static void Main() { + var a = new Complex(-1, 2); + if ( complextest.Conj(a) != Complex.Conjugate(a) ) + throw new Exception("std::complex test failed"); + + if ( complextest.Conjf(a) != Complex.Conjugate(a) ) + throw new Exception("std::complex test failed"); + + var vec = new VectorStdCplx(); + vec.Add(new Complex(1, 2)); + vec.Add(new Complex(2, 3)); + vec.Add(new Complex(4, 3)); + vec.Add(new Complex(1, 0)); + + if ( complextest.Copy_h(vec).Count != 2 ) + throw new Exception("vector test failed"); + } +} diff --git a/Lib/csharp/complex.i b/Lib/csharp/complex.i new file mode 100644 index 000000000..045b65d43 --- /dev/null +++ b/Lib/csharp/complex.i @@ -0,0 +1,44 @@ +#ifndef __cplusplus +#error C# module only supports complex in C++ mode. +#endif + +%{ +#include +%} + +namespace std { + +// An extremely simplified subset of std::complex<> which contains just the +// methods we need. +template +class complex +{ +public: + complex(T re, T im); + + T real() const; + T imag() const; +}; + +} // namespace std + +%define swig_complex_typemaps(T) +%typemap(cstype) std::complex, const std::complex& "System.Numerics.Complex" + +// The casts in "pre" are needed in order to allow creating std::complex +// from System.Numerics.Complex, which always uses doubles. It relies on the +// fact that the name of the C++ and C# float/double types are the same. +%typemap(csin, + pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" + ) std::complex, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" + +%typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { + Complex_##T cppret = new Complex_##T($imcall, $owner);$excode + return new System.Numerics.Complex(cppret.real(), cppret.imag()); + } + +%template(Complex_##T) std::complex; +%enddef + +swig_complex_typemaps(double) +swig_complex_typemaps(float) From ec565f74cf64f1c916d47d7e8fdcb7197b1b26e7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 1 Apr 2017 23:48:33 +0200 Subject: [PATCH 0464/2031] Extend C# complex support to member variables of this type Define csvar{in,out} typemaps needed to support properties of complex type and apply the existing cstype and csin ones to them as well. Add unit test verifying that this works as expected in C# and, also, in Python, even though no changes were needed there. --- Examples/test-suite/complextest.i | 5 +++++ .../test-suite/csharp/complextest_runme.cs | 6 ++++++ .../test-suite/python/complextest_runme.py | 6 ++++++ Lib/csharp/complex.i | 18 ++++++++++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i index 64c751a82..6e82e8915 100644 --- a/Examples/test-suite/complextest.i +++ b/Examples/test-suite/complextest.i @@ -34,6 +34,11 @@ return b; } #endif + + struct ComplexPair + { + std::complex z1, z2; + }; } diff --git a/Examples/test-suite/csharp/complextest_runme.cs b/Examples/test-suite/csharp/complextest_runme.cs index 781909f25..2b7e4cc84 100644 --- a/Examples/test-suite/csharp/complextest_runme.cs +++ b/Examples/test-suite/csharp/complextest_runme.cs @@ -24,5 +24,11 @@ public class complextest_runme { if ( complextest.Copy_h(vec).Count != 2 ) throw new Exception("vector test failed"); + + var p = new ComplexPair(); + p.z1 = new Complex(0, 1); + p.z2 = new Complex(0, -1); + if ( Complex.Conjugate(p.z2) != p.z1 ) + throw new Exception("vector test failed"); } } diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py index 7dd7f5a3b..a55e6098b 100644 --- a/Examples/test-suite/python/complextest_runme.py +++ b/Examples/test-suite/python/complextest_runme.py @@ -15,3 +15,9 @@ try: complextest.Copy_h(v) except: pass + +p = complextest.ComplexPair() +p.z1 = complex(0, 1) +p.z2 = complex(0, -1) +if complextest.Conj(p.z2) != p.z1: + raise RuntimeError, "bad complex mapping" diff --git a/Lib/csharp/complex.i b/Lib/csharp/complex.i index 045b65d43..21c84adbb 100644 --- a/Lib/csharp/complex.i +++ b/Lib/csharp/complex.i @@ -23,20 +23,34 @@ public: } // namespace std %define swig_complex_typemaps(T) -%typemap(cstype) std::complex, const std::complex& "System.Numerics.Complex" +%typemap(cstype) std::complex, std::complex*, const std::complex& "System.Numerics.Complex" // The casts in "pre" are needed in order to allow creating std::complex // from System.Numerics.Complex, which always uses doubles. It relies on the // fact that the name of the C++ and C# float/double types are the same. %typemap(csin, pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" - ) std::complex, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" + ) std::complex, std::complex*, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" %typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { Complex_##T cppret = new Complex_##T($imcall, $owner);$excode return new System.Numerics.Complex(cppret.real(), cppret.imag()); } +%typemap(csvarin, excode=SWIGEXCODE2) std::complex* %{ + set { + var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); + $imcall;$excode + } + %} + +%typemap(csvarout, excode=SWIGEXCODE2) std::complex* %{ + get { + var cppret = new Complex_##T($imcall, $owner);$excode + return new System.Numerics.Complex(cppret.real(), cppret.imag()); + } + %} + %template(Complex_##T) std::complex; %enddef From bd233408e8ec192b342dc02e014906affab9e08f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Apr 2017 07:34:58 +0100 Subject: [PATCH 0465/2031] Add shared_ptr non-overloaded upcast tests --- Examples/test-suite/cpp11_shared_ptr_upcast.i | 75 +++++++++++++------ .../ruby/cpp11_shared_ptr_upcast_runme.rb | 11 +++ 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_upcast.i b/Examples/test-suite/cpp11_shared_ptr_upcast.i index 22bc55594..9f65eb7e1 100644 --- a/Examples/test-suite/cpp11_shared_ptr_upcast.i +++ b/Examples/test-suite/cpp11_shared_ptr_upcast.i @@ -31,33 +31,58 @@ public: int n; }; - typedef std::shared_ptr BasePtr; - typedef std::shared_ptr DerivedPtr; +typedef std::shared_ptr BasePtr; +typedef std::shared_ptr DerivedPtr; - int derived_num(DerivedPtr v) { - return (*v).get_n(); - } +// non-overloaded +int derived_num1(DerivedPtr v) { + return (*v).get_n(); +} - int derived_num(std::vector v) { - return (*v[0]).get_n(); - } +int derived_num2(std::vector v) { + return (*v[0]).get_n(); +} - int derived_num(std::map v) { - return (*v[0]).get_n(); - } +int derived_num3(std::map v) { + return (*v[0]).get_n(); +} - int base_num(BasePtr v) { - return (*v).get_m(); - } +int base_num1(BasePtr v) { + return (*v).get_m(); +} - int base_num(std::vector v) { - return (*v[0]).get_m(); - } +int base_num2(std::vector v) { + return (*v[0]).get_m(); +} - int base_num(std::map v) { - return (*v[0]).get_m(); - } +int base_num3(std::map v) { + return (*v[0]).get_m(); +} +// overloaded +int derived_num(DerivedPtr v) { + return derived_num1(v); +} + +int derived_num(std::vector v) { + return derived_num2(v); +} + +int derived_num(std::map v) { + return derived_num3(v); +} + +int base_num(BasePtr v) { + return base_num1(v); +} + +int base_num(std::vector v) { + return base_num2(v); +} + +int base_num(std::map v) { + return base_num3(v); +} %} @@ -88,10 +113,18 @@ public: typedef std::shared_ptr BasePtr; typedef std::shared_ptr DerivedPtr; +// non-overloaded +int derived_num1(DerivedPtr); +int derived_num2(std::vector > v); +int derived_num3(std::map v); +int base_num1(BasePtr); +int base_num2(std::vector > v); +int base_num3(std::map v); + +// overloaded int derived_num(DerivedPtr); int derived_num(std::vector > v); int derived_num(std::map v); int base_num(BasePtr); int base_num(std::vector > v); int base_num(std::map v); - diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb index 188f9ccbf..ef83ab367 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb @@ -4,9 +4,20 @@ require 'cpp11_shared_ptr_upcast' include Cpp11_shared_ptr_upcast +# non-overloaded +simple_assert_equal( 7, derived_num1(Derived.new(7)) ) +simple_assert_equal( 7, derived_num2([Derived.new(7)]) ) +simple_assert_equal( 7, derived_num3({0 => Derived.new(7)}) ) + +simple_assert_equal(-1, base_num1(Derived.new(7)) ) +simple_assert_equal(-1, base_num2([Derived.new(7)]) ) +simple_assert_equal(-1, base_num3({0 => Derived.new(7)}) ) + +# overloaded simple_assert_equal( 7, derived_num(Derived.new(7)) ) simple_assert_equal( 7, derived_num([Derived.new(7)]) ) simple_assert_equal( 7, derived_num({0 => Derived.new(7)}) ) + simple_assert_equal(-1, base_num(Derived.new(7)) ) simple_assert_equal(-1, base_num([Derived.new(7)]) ) simple_assert_equal(-1, base_num({0 => Derived.new(7)}) ) From c06c9b38538023482b5ac0670cb4db4bb1999070 Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Wed, 12 Apr 2017 13:54:42 +0200 Subject: [PATCH 0466/2031] [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) Signed-off-by: Simon Marchetto --- CHANGES.current | 6 +- Doc/Manual/Scilab.html | 15 +++- Source/Modules/scilab.cxx | 180 ++++++++++++++++++++------------------ 3 files changed, 114 insertions(+), 87 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 93b3cc5c4..2d5e841ea 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,11 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-04-12: smarchetto + [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation + With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) + 2017-02-29: tamuratak [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing for std::list, std::multiset, std::unordered_multiset and std::unordered_map. -2017-03-24: tamuratak +2017-03-24: tamuratak [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks on VALUE obj. diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 90bd8bb9a..14e03ff18 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -304,6 +304,11 @@ The following table lists the Scilab specific command line options in addition t Generate the gateway XML with the given <gateway_id> + +-targetversion +Generate for Scilab target (major) version + +

    @@ -331,13 +336,17 @@ There are a few exceptions, such as constants and enumerations, which can be wra

    -In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation should disappear from Scilab 6.0 onwards). -
    Thus long function or variable names may be truncated and this can cause ambiguities. +In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation disappears from Scilab 6.0 onwards). +
    By default, variable, member, and function names longer than 24 charaters are truncated, and a warning is produced for each truncation.

    -

    This happens especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names. +

    This can cause ambiguities, especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names. In these cases, the %rename directive can be used to choose a different Scilab name.

    +

    +Note: truncations can be disabled by specifying the target version 6 of Scilab in the targetversion argument (i.e. -targetversion 6). +

    +

    39.3.3 Functions

    diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 5997b5876..b3abc009e 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -18,13 +18,14 @@ static const int SCILAB_VARIABLE_NAME_CHAR_MAX = SCILAB_IDENTIFIER_NAME_CHAR_MAX static const char *usage = (char *) " \ Scilab options (available with -scilab)\n \ - -builder - Generate a Scilab builder script\n \ - -buildercflags - Add to the builder compiler flags\n \ - -builderflagscript - Set the Scilab script to use by builder to configure the build flags\n \ - -builderldflags - Add to the builder linker flags\n \ - -buildersources - Add the (comma separated) files to the builder sources\n \ - -builderverbositylevel - Set the builder verbosity level to (default 0: off, 2: high)\n \ - -gatewayxml - Generate gateway xml with the given \n \ + -builder - Generate a Scilab builder script\n \ + -buildercflags - Add to the builder compiler flags\n \ + -builderflagscript - Set the Scilab script to use by builder to configure the build flags\n \ + -builderldflags - Add to the builder linker flags\n \ + -buildersources - Add the (comma separated) files to the builder sources\n \ + -builderverbositylevel - Set the builder verbosity level to (default 0: off, 2: high)\n \ + -gatewayxml - Generate gateway xml with the given \n \ + -targetversion - Generate for Scilab target (major) version (default: 5)\n \ \n"; @@ -39,6 +40,8 @@ protected: String *variablesCode; + int targetVersion; + bool generateBuilder; File *builderFile; String *builderCode; @@ -71,6 +74,7 @@ public: * ----------------------------------------------------------------------*/ virtual void main(int argc, char *argv[]) { + targetVersion = 5; generateBuilder = false; sourceFileList = NewList(); @@ -95,48 +99,54 @@ public: /* Manage command line arguments */ for (int argIndex = 1; argIndex < argc; argIndex++) { if (argv[argIndex] != NULL) { - if (strcmp(argv[argIndex], "-help") == 0) { - Printf(stdout, "%s\n", usage); - } else if (strcmp(argv[argIndex], "-builder") == 0) { - Swig_mark_arg(argIndex); - generateBuilder = true; - createLoader = false; - } else if (strcmp(argv[argIndex], "-buildersources") == 0) { - if (argv[argIndex + 1] != NULL) { - Swig_mark_arg(argIndex); - char *sourceFile = strtok(argv[argIndex + 1], ","); - while (sourceFile != NULL) { - Insert(sourceFileList, Len(sourceFileList), sourceFile); - sourceFile = strtok(NULL, ","); - } - Swig_mark_arg(argIndex + 1); - } - } else if (strcmp(argv[argIndex], "-buildercflags") == 0) { - Swig_mark_arg(argIndex); - if (argv[argIndex + 1] != NULL) { - Insert(cflags, Len(cflags), argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); - } - } else if (strcmp(argv[argIndex], "-builderldflags") == 0) { - Swig_mark_arg(argIndex); - if (argv[argIndex + 1] != NULL) { - Insert(ldflags, Len(ldflags), argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); - } - } else if (strcmp(argv[argIndex], "-builderverbositylevel") == 0) { - Swig_mark_arg(argIndex); - verboseBuildLevel = NewString(argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); - } else if (strcmp(argv[argIndex], "-builderflagscript") == 0) { - Swig_mark_arg(argIndex); - buildFlagsScript = NewString(argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); - } else if (strcmp(argv[argIndex], "-gatewayxml") == 0) { - Swig_mark_arg(argIndex); - createGatewayXML = true; - gatewayID = NewString(argv[argIndex + 1]); - Swig_mark_arg(argIndex + 1); - } + if (strcmp(argv[argIndex], "-help") == 0) { + Printf(stdout, "%s\n", usage); + } else if (strcmp(argv[argIndex], "-builder") == 0) { + Swig_mark_arg(argIndex); + generateBuilder = true; + createLoader = false; + } else if (strcmp(argv[argIndex], "-buildersources") == 0) { + if (argv[argIndex + 1] != NULL) { + Swig_mark_arg(argIndex); + char *sourceFile = strtok(argv[argIndex + 1], ","); + while (sourceFile != NULL) { + Insert(sourceFileList, Len(sourceFileList), sourceFile); + sourceFile = strtok(NULL, ","); + } + Swig_mark_arg(argIndex + 1); + } + } else if (strcmp(argv[argIndex], "-buildercflags") == 0) { + Swig_mark_arg(argIndex); + if (argv[argIndex + 1] != NULL) { + Insert(cflags, Len(cflags), argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } + } else if (strcmp(argv[argIndex], "-builderldflags") == 0) { + Swig_mark_arg(argIndex); + if (argv[argIndex + 1] != NULL) { + Insert(ldflags, Len(ldflags), argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } + } else if (strcmp(argv[argIndex], "-builderverbositylevel") == 0) { + Swig_mark_arg(argIndex); + verboseBuildLevel = NewString(argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } else if (strcmp(argv[argIndex], "-builderflagscript") == 0) { + Swig_mark_arg(argIndex); + buildFlagsScript = NewString(argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } else if (strcmp(argv[argIndex], "-gatewayxml") == 0) { + Swig_mark_arg(argIndex); + createGatewayXML = true; + gatewayID = NewString(argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } else if (strcmp(argv[argIndex], "-targetversion") == 0) { + if (argv[argIndex + 1] != NULL) { + Swig_mark_arg(argIndex); + targetVersion = atoi(argv[argIndex + 1]); + Swig_mark_arg(argIndex + 1); + } + } } } @@ -784,57 +794,61 @@ public: /* ----------------------------------------------------------------------- * checkIdentifierName() - * Truncates (and displays a warning) for too long identifier names - * (applies on functions, variables, constants...) - * (Scilab identifiers names are limited to 24 chars max) + * If Scilab target version is lower than 6: + * truncates (and displays a warning) too long member identifier names + * (applies on members of structs, classes...) + * (Scilab 5 identifier names are limited to 24 chars max) * ----------------------------------------------------------------------- */ String *checkIdentifierName(String *name, int char_size_max) { String *scilabIdentifierName; - if (Len(name) > char_size_max) { - scilabIdentifierName = DohNewStringWithSize(name, char_size_max); - Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number, - "Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName); - } else + if (targetVersion <= 5) { + if (Len(name) > char_size_max) { + scilabIdentifierName = DohNewStringWithSize(name, char_size_max); + Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number, + "Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName); + } else scilabIdentifierName = name; - return scilabIdentifierName; + } else { + scilabIdentifierName = DohNewString(name); + } + return scilabIdentifierName; } /* ----------------------------------------------------------------------- * checkMemberIdentifierName() - * Truncates (and displays a warning) too long member identifier names - * (applies on members of structs, classes...) - * (Scilab identifiers names are limited to 24 chars max) + * If Scilab target version is lower than 6: + * truncates (and displays a warning) too long member identifier names + * (applies on members of structs, classes...) + * (Scilab 5 identifier names are limited to 24 chars max) * ----------------------------------------------------------------------- */ void checkMemberIdentifierName(Node *node, int char_size_max) { + if (targetVersion <= 5) { + String *memberName = Getattr(node, "sym:name"); + Node *containerNode = parentNode(node); + String *containerName = Getattr(containerNode, "sym:name"); + int lenContainerName = Len(containerName); + int lenMemberName = Len(memberName); - String *memberName = Getattr(node, "sym:name"); + if (lenContainerName + lenMemberName + 1 > char_size_max) { + int lenScilabMemberName = char_size_max - lenContainerName - 1; - Node *containerNode = parentNode(node); - String *containerName = Getattr(containerNode, "sym:name"); - - int lenContainerName = Len(containerName); - int lenMemberName = Len(memberName); - - if (lenContainerName + lenMemberName + 1 > char_size_max) { - int lenScilabMemberName = char_size_max - lenContainerName - 1; - - if (lenScilabMemberName > 0) { - String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName); - Setattr(node, "sym:name", scilabMemberName); - Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number, - "Wrapping functions names for member '%s.%s' will exceed 24 characters, " - "so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName); - } else - Swig_error(input_file, line_number, - "Wrapping functions names for member '%s.%s' will exceed 24 characters, " - "please rename the container of member '%s'.\n", containerName, memberName, containerName); + if (lenScilabMemberName > 0) { + String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName); + Setattr(node, "sym:name", scilabMemberName); + Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number, + "Wrapping functions names for member '%s.%s' will exceed 24 characters, " + "so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName); + } else { + Swig_error(input_file, line_number, + "Wrapping functions names for member '%s.%s' will exceed 24 characters, " + "please rename the container of member '%s'.\n", containerName, memberName, containerName); + } + } } } - - /* ----------------------------------------------------------------------- * addHelperFunctions() * ----------------------------------------------------------------------- */ From 83a389d3fbccbd588f3a649c4a736feeae617341 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 12 Apr 2017 19:08:23 +0100 Subject: [PATCH 0467/2031] Add support for pointers to shared_ptr and null shared_ptr in Ruby containers Upcasting of pointers to shared_ptr would need some more fundamental changes, but not done yet ... pointers to shared_ptr are not common. --- Examples/test-suite/cpp11_shared_ptr_upcast.i | 70 +++++++++++++-- .../ruby/cpp11_shared_ptr_upcast_runme.rb | 37 ++++++++ Lib/ruby/std_shared_ptr.i | 85 +++++++++++++------ 3 files changed, 160 insertions(+), 32 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_upcast.i b/Examples/test-suite/cpp11_shared_ptr_upcast.i index 9f65eb7e1..3427829d9 100644 --- a/Examples/test-suite/cpp11_shared_ptr_upcast.i +++ b/Examples/test-suite/cpp11_shared_ptr_upcast.i @@ -36,27 +36,27 @@ typedef std::shared_ptr DerivedPtr; // non-overloaded int derived_num1(DerivedPtr v) { - return (*v).get_n(); + return v == nullptr ? 999 : (*v).get_n(); } int derived_num2(std::vector v) { - return (*v[0]).get_n(); + return v[0] == nullptr ? 999 : (*v[0]).get_n(); } int derived_num3(std::map v) { - return (*v[0]).get_n(); + return v[0] == nullptr ? 999 : (*v[0]).get_n(); } int base_num1(BasePtr v) { - return (*v).get_m(); + return v == nullptr ? 999 : (*v).get_m(); } int base_num2(std::vector v) { - return (*v[0]).get_m(); + return v[0] == nullptr ? 999 : (*v[0]).get_m(); } int base_num3(std::map v) { - return (*v[0]).get_m(); + return v[0] == nullptr ? 999 : (*v[0]).get_m(); } // overloaded @@ -128,3 +128,61 @@ int derived_num(std::map v); int base_num(BasePtr); int base_num(std::vector > v); int base_num(std::map v); + +// ptr to shared_ptr +%shared_ptr(Base2); +%shared_ptr(Derived2) + +%inline %{ +class Base2 { +public: + Base2() : m(-1) {} + Base2(int i) : m(i) {} + int get_m() { return m; } + int m; +}; + + +class Derived2 : public Base2 { +public: + Derived2() : n(0) {} + Derived2(int i) : n(i) {} + int get_n_2() { return n; } + int n; +}; +%} + +%template(Base2List) std::vector * >; +%template(Base2Map) std::map * >; + +%template(Derived2List) std::vector * >; +%template(Derived2Map) std::map * >; + +%inline %{ +typedef std::shared_ptr * Derived2Ptr; +typedef std::shared_ptr * Base2Ptr; + +int base2_num1(Base2Ptr v) { + return v == nullptr ? 999 : *v == nullptr ? 888 : (*v)->get_m(); +} + +int base2_num2(std::vector v) { + return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_m(); +} + +int base2_num3(std::map v) { + return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_m(); +} + +int derived2_num1(Derived2Ptr v) { + return v == nullptr ? 999 : *v == nullptr ? 888 : (*v)->get_n_2(); +} + +int derived2_num2(std::vector v) { + return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_n_2(); +} + +int derived2_num3(std::map v) { + return v[0] == nullptr ? 999 : *v[0] == nullptr ? 888 : (*v[0])->get_n_2(); +} +%} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb index ef83ab367..864be1382 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb @@ -13,6 +13,14 @@ simple_assert_equal(-1, base_num1(Derived.new(7)) ) simple_assert_equal(-1, base_num2([Derived.new(7)]) ) simple_assert_equal(-1, base_num3({0 => Derived.new(7)}) ) +simple_assert_equal( 999, derived_num1(nil) ) +simple_assert_equal( 999, derived_num2([nil]) ) +simple_assert_equal( 999, derived_num3({0 => nil}) ) + +simple_assert_equal( 999, base_num1(nil) ) +simple_assert_equal( 999, base_num2([nil]) ) +simple_assert_equal( 999, base_num3({0 => nil}) ) + # overloaded simple_assert_equal( 7, derived_num(Derived.new(7)) ) simple_assert_equal( 7, derived_num([Derived.new(7)]) ) @@ -21,3 +29,32 @@ simple_assert_equal( 7, derived_num({0 => Derived.new(7)}) ) simple_assert_equal(-1, base_num(Derived.new(7)) ) simple_assert_equal(-1, base_num([Derived.new(7)]) ) simple_assert_equal(-1, base_num({0 => Derived.new(7)}) ) + +# ptr to shared_ptr +simple_assert_equal( 7, derived2_num1(Derived2.new(7)) ) +simple_assert_equal( 7, derived2_num2([Derived2.new(7)]) ) +simple_assert_equal( 7, derived2_num3({0 => Derived2.new(7)}) ) + +simple_assert_equal( -1, base2_num1(Derived2.new(7)) ) + +begin + # Upcast for pointers to shared_ptr in this generic framework has not been implemented + simple_assert_equal( -1, base2_num2([Derived2.new(7)]) ) + raise RuntimeError, "Failed to catch TypeError" +rescue TypeError +end +begin + # Upcast for pointers to shared_ptr in this generic framework has not been implemented + simple_assert_equal( -1, base2_num3({0 => Derived2.new(7)}) ) + raise RuntimeError, "Failed to catch TypeError" +rescue TypeError +end + +simple_assert_equal( 888, derived2_num1(nil) ) +simple_assert_equal( 999, derived2_num2([nil]) ) # although 888 would be more consistent +simple_assert_equal( 999, derived2_num3({0 => nil}) ) # although 888 would be more consistent + +simple_assert_equal( 888, base2_num1(nil) ) +simple_assert_equal( 999, base2_num2([nil]) ) # although 888 would be more consistent +simple_assert_equal( 999, base2_num3({0 => nil}) ) # although 888 would be more consistent + diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index 5d56b8750..4e0798d56 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -7,23 +7,32 @@ { namespace swig { /* - template specialization for functions defined in rubystdcommon.swg. - here we should treat smart pointers in a way different from the way we treat raw pointers. + Template specialization for functions defined in rubystdcommon.swg. Special handling for shared_ptr + is required as, shared_ptr * is used rather than the usual T *, see shared_ptr.i. */ template struct traits_asptr > { static int asptr(VALUE obj, std::shared_ptr **val) { - std::shared_ptr *p=0; + std::shared_ptr *p = 0; swig_type_info *descriptor = type_info >(); swig_ruby_owntype newmem = {0, 0}; int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR; - if (SWIG_IsOK(res) && p) { - if (val && *val) **val = *p; - if (newmem.own & SWIG_CAST_NEW_MEMORY) delete p; - return SWIG_OK; - } else { - return SWIG_ERROR; + if (SWIG_IsOK(res)) { + if (val) { + if (*val) { + **val = p ? *p : std::shared_ptr(); + } else { + *val = p; + if (newmem.own & SWIG_CAST_NEW_MEMORY) { + // Upcast for pointers to shared_ptr in this generic framework has not been implemented + res = SWIG_ERROR; + } + } + } + if (newmem.own & SWIG_CAST_NEW_MEMORY) + delete p; } + return res; } }; @@ -31,12 +40,13 @@ namespace swig { struct traits_asval > { static int asval(VALUE obj, std::shared_ptr *val) { if (val) { - std::shared_ptr ret; - std::shared_ptr *p=&ret; + std::shared_ptr ret; + std::shared_ptr *p = &ret; int res = traits_asptr >::asptr(obj, &p); - if (!SWIG_IsOK(res)) return res; - if (val) *val = ret; - return SWIG_OK; + if (!SWIG_IsOK(res)) + return res; + *val = ret; + return SWIG_OK; } else { return traits_asptr >::asptr(obj, (std::shared_ptr **)(0)); } @@ -44,17 +54,24 @@ namespace swig { }; template - struct traits_asval*> { + struct traits_asval *> { static int asval(VALUE obj, std::shared_ptr **val) { - if (val && *val) { - typedef typename noconst_traits >::noconst_type noconst_type; - noconst_type ret; - noconst_type *p = &ret; - int res = traits_asptr::asptr(obj, &p); - if (SWIG_IsOK(res)) { - **(const_cast(val)) = ret; + if (val) { + typedef typename noconst_traits >::noconst_type noconst_type; + if (*val) { + noconst_type ret; + noconst_type *p = &ret; + int res = traits_asptr::asptr(obj, &p); + if (SWIG_IsOK(res)) + **(const_cast(val)) = ret; + return res; + } else { + noconst_type *p = 0; + int res = traits_asptr::asptr(obj, &p); + if (SWIG_IsOK(res)) + *val = p; + return res; } - return res; } else { return traits_asptr >::asptr(obj, (std::shared_ptr **)(0)); } @@ -73,16 +90,32 @@ namespace swig { // Uninitialized return value, no Type() constructor required. if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); - if (lastErr == Qnil) { + if (lastErr == Qnil) SWIG_Error(SWIG_TypeError, swig::type_name >()); - } - static std::shared_ptr *v_def = (std::shared_ptr*) malloc(sizeof(std::shared_ptr)); + static std::shared_ptr *v_def = (std::shared_ptr *) malloc(sizeof(std::shared_ptr)); memset(v_def,0,sizeof(std::shared_ptr)); return *v_def; } } }; + template + struct traits_as *, pointer_category> { + static std::shared_ptr * as(VALUE obj, bool throw_error) { + std::shared_ptr *p = 0; + int res = traits_asptr >::asptr(obj, &p); + if (SWIG_IsOK(res)) { + return p; + } else { + if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); + if (lastErr == Qnil) + SWIG_Error(SWIG_TypeError, swig::type_name *>()); + return 0; + } + } + }; + /* we have to remove the const qualifier to work around a BUG SWIG_TypeQuery("std::shared_ptr") == NULL, From 1a6f8d1e4b350a8245bf3c355c76825bf7bfaaf8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Apr 2017 07:04:07 +0100 Subject: [PATCH 0468/2031] Ruby shared_ptr on error code improvement in traits_as::as --- Lib/ruby/std_shared_ptr.i | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index 4e0798d56..983ffde49 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -87,14 +87,11 @@ namespace swig { if (SWIG_IsOK(res)) { return ret; } else { - // Uninitialized return value, no Type() constructor required. if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) SWIG_Error(SWIG_TypeError, swig::type_name >()); - static std::shared_ptr *v_def = (std::shared_ptr *) malloc(sizeof(std::shared_ptr)); - memset(v_def,0,sizeof(std::shared_ptr)); - return *v_def; + return std::shared_ptr(); } } }; From f08d7a63a92a3ba89d97bdfcc206e1e1c4804c0f Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Thu, 13 Apr 2017 15:02:53 +0200 Subject: [PATCH 0469/2031] Add Node 7.x aka V8 5.2+ support * Use WeakCallbackInfo instead of WeakCallbackData * Use GetPrivate instead of GetHiddenValue * Adopted new signature for SetWeak to support destructor calling * SetAccessor deprecation fixed * Proper version checks where applicable --- Lib/javascript/v8/javascriptcode.swg | 27 +++++++++++++---- Lib/javascript/v8/javascripthelpers.swg | 29 ++++++++++++++++-- Lib/javascript/v8/javascriptinit.swg | 16 ++++++++-- Lib/javascript/v8/javascriptrun.swg | 40 +++++++++++++++++++++---- 4 files changed, 95 insertions(+), 17 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index fb7d55c2a..b8c508981 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -133,10 +133,13 @@ static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, v SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent *object, SWIGV8_Proxy *proxy) { -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); +#else + static void $jswrapper(const v8::WeakCallbackInfo &data) { + SWIGV8_Proxy *proxy = data.GetParameter(); #endif if(proxy->swigCMemOwn && proxy->swigCObject) { @@ -147,7 +150,9 @@ static void $jswrapper(const v8::WeakCallbackData &dat } delete proxy; +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) object.Clear(); +#endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) object.Dispose(); @@ -155,7 +160,7 @@ static void $jswrapper(const v8::WeakCallbackData &dat object.Dispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) object->Dispose(); #endif } @@ -177,10 +182,13 @@ static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, v SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) { -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); +#else +static void $jswrapper(const v8::WeakCallbackInfo &data) { + SWIGV8_Proxy *proxy = data.GetParameter(); #endif if(proxy->swigCMemOwn && proxy->swigCObject) { @@ -197,7 +205,7 @@ static void $jswrapper(const v8::WeakCallbackData &dat object->Dispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) object.Clear(); #endif } @@ -211,7 +219,11 @@ static void $jswrapper(const v8::WeakCallbackData &dat * ----------------------------------------------------------------------------- */ %fragment("js_getter", "templates") %{ +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo &info) { +#else +static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo &info) { +#endif SWIGV8_HANDLESCOPE(); v8::Handle jsresult; @@ -233,8 +245,11 @@ fail: * ----------------------------------------------------------------------------- */ %fragment("js_setter", "templates") %{ -static void $jswrapper(v8::Local property, v8::Local value, - const SwigV8PropertyCallbackInfoVoid &info) { +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +static void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid &info) { +#else +static void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid &info) { +#endif SWIGV8_HANDLESCOPE(); $jslocals diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 091467df4..74610793a 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -6,11 +6,16 @@ typedef v8::InvocationCallback SwigV8FunctionCallback; typedef v8::AccessorGetter SwigV8AccessorGetterCallback; typedef v8::AccessorSetter SwigV8AccessorSetterCallback; typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid; -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) typedef v8::FunctionCallback SwigV8FunctionCallback; typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback; typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback; typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid; +#else +typedef v8::FunctionCallback SwigV8FunctionCallback; +typedef v8::AccessorNameGetterCallback SwigV8AccessorGetterCallback; +typedef v8::AccessorNameSetterCallback SwigV8AccessorSetterCallback; +typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid; #endif /** @@ -65,18 +70,36 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle obj, const char */ SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); +#else + obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter); +#endif } -SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, - const SwigV8PropertyCallbackInfoVoid& info) +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) +#else +SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) +#endif { char buffer[256]; char msg[512]; int res; +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) property->WriteUtf8(buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); +#else + v8::Local sproperty; + if (property->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocal(&sproperty)) { + sproperty->WriteUtf8(buffer, 256); + res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); + } + else { + res = -1; + } +#endif if(res<0) { SWIG_exception(SWIG_ERROR, "Tried to write read-only variable."); diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg index 34befa7ce..86008d927 100644 --- a/Lib/javascript/v8/javascriptinit.swg +++ b/Lib/javascript/v8/javascriptinit.swg @@ -7,15 +7,27 @@ SWIG_V8_SetModule(void *, swig_module_info *swig_module) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); v8::Local mod = SWIGV8_EXTERNAL_NEW(swig_module); assert(!mod.IsEmpty()); +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) global_obj->SetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"), mod); +#else + v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data")); + global_obj->SetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey, mod); +#endif } SWIGRUNTIME swig_module_info * SWIG_V8_GetModule(void *) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) v8::Local moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data")); +#else + v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data")); + v8::Local moduleinfo; + if (!global_obj->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&moduleinfo)) + return 0; +#endif - if (moduleinfo.IsEmpty()) + if (moduleinfo.IsEmpty() || moduleinfo->IsNull() || moduleinfo->IsUndefined()) { // It's not yet loaded return 0; @@ -23,7 +35,7 @@ SWIG_V8_GetModule(void *) { v8::Local moduleinfo_extern = v8::Local::Cast(moduleinfo); - if (moduleinfo_extern.IsEmpty()) + if (moduleinfo_extern.IsEmpty() || moduleinfo_extern->IsNull() || moduleinfo_extern->IsUndefined()) { // Something's not right return 0; diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 5ac52a51d..30002c02a 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -193,8 +193,10 @@ public: void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy); -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) void (*dtor) (const v8::WeakCallbackData &data); +#else + void (*dtor) (const v8::WeakCallbackInfo &data); #endif }; @@ -241,9 +243,12 @@ SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Val SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) { -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData &data) { SWIGV8_Proxy *proxy = data.GetParameter(); +#else +SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackInfo &data) { + SWIGV8_Proxy *proxy = data.GetParameter(); #endif delete proxy; @@ -312,12 +317,18 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, sw } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } -#else +#elifif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor); } +#else + if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { + cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor, v8::WeakCallbackType::kParameter); + } else { + cdata->handle.SetWeak(cdata, SWIGV8_Proxy_DefaultDtor, v8::WeakCallbackType::kParameter); + } #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) @@ -470,7 +481,14 @@ int SwigV8Packed_Check(v8::Handle valRef) { v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return false; +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) v8::Handle flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__")); +#else + v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__")); + v8::Local flag; + if (!objRef->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&flag)) + return false; +#endif return (flag->IsBoolean() && flag->BooleanValue()); } @@ -519,10 +537,13 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persist SwigV8PackedData *cdata = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent *object, SwigV8PackedData *cdata) { -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SwigV8PackedData *cdata = data.GetParameter(); +#else +SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackInfo &data) { + SwigV8PackedData *cdata = data.GetParameter(); #endif delete cdata; @@ -537,7 +558,7 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackDataDispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) object.Clear(); #endif } @@ -550,7 +571,12 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf // v8::Handle obj = SWIGV8_OBJECT_NEW(); v8::Local obj = SWIGV8_OBJECT_NEW(); +#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true)); +#else + v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__")); + obj->SetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey, SWIGV8_BOOLEAN_NEW(true)); +#endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) obj->SetPointerInInternalField(0, cdata); @@ -573,9 +599,11 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); -#else +#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete); // v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete); +#else + cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete, v8::WeakCallbackType::kParameter); #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) From f768fd2b9d7f2816e431f7cd73f7c54c17742f03 Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Thu, 13 Apr 2017 17:31:00 +0200 Subject: [PATCH 0470/2031] Added check to prevent crash on illegal constructor call Constructors not called as part of object instantiation (using "new" or via inheritance) will not crash the VM anymore. --- Lib/javascript/v8/javascriptcode.swg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index fb7d55c2a..323a91cc5 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -10,9 +10,10 @@ %fragment("js_ctor", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - + v8::Handle self = args.Holder(); $jslocals + if(self->InternalFieldCount() < 1) SWIG_exception_fail(SWIG_ERROR, "Illegal call of constructor $jswrapper."); if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode @@ -77,9 +78,10 @@ fail: %fragment("js_overloaded_ctor", "templates") %{ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) { SWIGV8_HANDLESCOPE(); - + v8::Handle self = args.Holder(); $jslocals + if(self->InternalFieldCount() < 1) SWIG_exception_fail(SWIG_ERROR, "Illegal call of constructor $jswrapper."); if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode From 9ce8d7e7c99e75163318428aeff6e60d398fcdca Mon Sep 17 00:00:00 2001 From: Patrick Schneider Date: Thu, 13 Apr 2017 19:39:44 +0200 Subject: [PATCH 0471/2031] Remove warnings on Node 6.x aka V8 5.0 and 5.1 The proposed changes targetted at 5.2 (or 5.4 to be more precise, since there is no Node release with V8 5.2 or 5.3) work for lower versions as well and bust the deprecation warnings there. --- Lib/javascript/v8/javascriptcode.swg | 14 +++++++------- Lib/javascript/v8/javascripthelpers.swg | 8 ++++---- Lib/javascript/v8/javascriptinit.swg | 4 ++-- Lib/javascript/v8/javascriptrun.swg | 16 ++++++++-------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index b8c508981..c4aaf3db0 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -133,7 +133,7 @@ static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, v SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent *object, SWIGV8_Proxy *proxy) { -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); @@ -150,7 +150,7 @@ static void $jswrapper(const v8::WeakCallbackData &dat } delete proxy; -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 object.Clear(); #endif @@ -160,7 +160,7 @@ static void $jswrapper(const v8::WeakCallbackData &dat object.Dispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) object->Dispose(isolate); -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 object->Dispose(); #endif } @@ -182,7 +182,7 @@ static void $jswrapper(v8::Isolate *isolate, v8::Persistent object, v SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) { -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 static void $jswrapper(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SWIGV8_Proxy *proxy = data.GetParameter(); @@ -205,7 +205,7 @@ static void $jswrapper(const v8::WeakCallbackInfo &data) { object->Dispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 object.Clear(); #endif } @@ -219,7 +219,7 @@ static void $jswrapper(const v8::WeakCallbackInfo &data) { * ----------------------------------------------------------------------------- */ %fragment("js_getter", "templates") %{ -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo &info) { #else static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8PropertyCallbackInfo &info) { @@ -245,7 +245,7 @@ fail: * ----------------------------------------------------------------------------- */ %fragment("js_setter", "templates") %{ -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 static void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid &info) { #else static void $jswrapper(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid &info) { diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 74610793a..7b8a5ec23 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -6,7 +6,7 @@ typedef v8::InvocationCallback SwigV8FunctionCallback; typedef v8::AccessorGetter SwigV8AccessorGetterCallback; typedef v8::AccessorSetter SwigV8AccessorSetterCallback; typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid; -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 typedef v8::FunctionCallback SwigV8FunctionCallback; typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback; typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback; @@ -70,14 +70,14 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle obj, const char */ SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); #else obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter); #endif } -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) #else SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local value, const SwigV8PropertyCallbackInfoVoid& info) @@ -87,7 +87,7 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::LocalWriteUtf8(buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); #else diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg index 86008d927..e83f478d9 100644 --- a/Lib/javascript/v8/javascriptinit.swg +++ b/Lib/javascript/v8/javascriptinit.swg @@ -7,7 +7,7 @@ SWIG_V8_SetModule(void *, swig_module_info *swig_module) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); v8::Local mod = SWIGV8_EXTERNAL_NEW(swig_module); assert(!mod.IsEmpty()); -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 global_obj->SetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data"), mod); #else v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data")); @@ -18,7 +18,7 @@ SWIG_V8_SetModule(void *, swig_module_info *swig_module) { SWIGRUNTIME swig_module_info * SWIG_V8_GetModule(void *) { v8::Local global_obj = SWIGV8_CURRENT_CONTEXT()->Global(); -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 v8::Local moduleinfo = global_obj->GetHiddenValue(SWIGV8_STRING_NEW("swig_module_info_data")); #else v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("swig_module_info_data")); diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 30002c02a..0af9f4eb0 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -193,7 +193,7 @@ public: void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy); -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 void (*dtor) (const v8::WeakCallbackData &data); #else void (*dtor) (const v8::WeakCallbackInfo &data); @@ -243,7 +243,7 @@ SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Val SWIGV8_Proxy *proxy = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) { -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData &data) { SWIGV8_Proxy *proxy = data.GetParameter(); #else @@ -317,7 +317,7 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, sw } else { cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor); } -#elifif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) { cdata->handle.SetWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor); } else { @@ -481,7 +481,7 @@ int SwigV8Packed_Check(v8::Handle valRef) { v8::Handle objRef = valRef->ToObject(); if(objRef->InternalFieldCount() < 1) return false; -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 v8::Handle flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__")); #else v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__")); @@ -537,7 +537,7 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persist SwigV8PackedData *cdata = static_cast(parameter); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent *object, SwigV8PackedData *cdata) { -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData &data) { v8::Local object = data.GetValue(); SwigV8PackedData *cdata = data.GetParameter(); @@ -558,7 +558,7 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackInfoDispose(isolate); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) object->Dispose(); -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 object.Clear(); #endif } @@ -571,7 +571,7 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf // v8::Handle obj = SWIGV8_OBJECT_NEW(); v8::Local obj = SWIGV8_OBJECT_NEW(); -#if (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#if (V8_MAJOR_VERSION-0) < 5 obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true)); #else v8::Local privateKey = v8::Private::ForApi(v8::Isolate::GetCurrent(), SWIGV8_STRING_NEW("__swig__packed_data__")); @@ -599,7 +599,7 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION) cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete); -#elif (V8_MAJOR_VERSION-0) < 5 || (V8_MAJOR_VERSION == 5 && V8_MINOR_VERSION < 2) +#elif (V8_MAJOR_VERSION-0) < 5 cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete); // v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete); #else From 485efd511f52aa0a8446ad58f60455ceaf788966 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 14 Apr 2017 19:23:31 +0200 Subject: [PATCH 0472/2031] Add std_complex.i for C# too For consistency with the other modules (Python, Ruby and JS), allow including directly when using C# too instead of including which only works in C++ mode (i.e. when using std::complex) anyhow with C# for now. --- Lib/csharp/complex.i | 59 ++-------------------------------------- Lib/csharp/std_complex.i | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 56 deletions(-) create mode 100644 Lib/csharp/std_complex.i diff --git a/Lib/csharp/complex.i b/Lib/csharp/complex.i index 21c84adbb..4a6f91cdf 100644 --- a/Lib/csharp/complex.i +++ b/Lib/csharp/complex.i @@ -1,58 +1,5 @@ -#ifndef __cplusplus +#ifdef __cplusplus +%include +#else #error C# module only supports complex in C++ mode. #endif - -%{ -#include -%} - -namespace std { - -// An extremely simplified subset of std::complex<> which contains just the -// methods we need. -template -class complex -{ -public: - complex(T re, T im); - - T real() const; - T imag() const; -}; - -} // namespace std - -%define swig_complex_typemaps(T) -%typemap(cstype) std::complex, std::complex*, const std::complex& "System.Numerics.Complex" - -// The casts in "pre" are needed in order to allow creating std::complex -// from System.Numerics.Complex, which always uses doubles. It relies on the -// fact that the name of the C++ and C# float/double types are the same. -%typemap(csin, - pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" - ) std::complex, std::complex*, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" - -%typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { - Complex_##T cppret = new Complex_##T($imcall, $owner);$excode - return new System.Numerics.Complex(cppret.real(), cppret.imag()); - } - -%typemap(csvarin, excode=SWIGEXCODE2) std::complex* %{ - set { - var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); - $imcall;$excode - } - %} - -%typemap(csvarout, excode=SWIGEXCODE2) std::complex* %{ - get { - var cppret = new Complex_##T($imcall, $owner);$excode - return new System.Numerics.Complex(cppret.real(), cppret.imag()); - } - %} - -%template(Complex_##T) std::complex; -%enddef - -swig_complex_typemaps(double) -swig_complex_typemaps(float) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i new file mode 100644 index 000000000..d7cf7e6d3 --- /dev/null +++ b/Lib/csharp/std_complex.i @@ -0,0 +1,54 @@ +%{ +#include +%} + +namespace std { + +// An extremely simplified subset of std::complex<> which contains just the +// methods we need. +template +class complex +{ +public: + complex(T re, T im); + + T real() const; + T imag() const; +}; + +} // namespace std + +%define swig_complex_typemaps(T) +%typemap(cstype) std::complex, std::complex*, const std::complex& "System.Numerics.Complex" + +// The casts in "pre" are needed in order to allow creating std::complex +// from System.Numerics.Complex, which always uses doubles. It relies on the +// fact that the name of the C++ and C# float/double types are the same. +%typemap(csin, + pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" + ) std::complex, std::complex*, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" + +%typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { + Complex_##T cppret = new Complex_##T($imcall, $owner);$excode + return new System.Numerics.Complex(cppret.real(), cppret.imag()); + } + +%typemap(csvarin, excode=SWIGEXCODE2) std::complex* %{ + set { + var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); + $imcall;$excode + } + %} + +%typemap(csvarout, excode=SWIGEXCODE2) std::complex* %{ + get { + var cppret = new Complex_##T($imcall, $owner);$excode + return new System.Numerics.Complex(cppret.real(), cppret.imag()); + } + %} + +%template(Complex_##T) std::complex; +%enddef + +swig_complex_typemaps(double) +swig_complex_typemaps(float) From 95aa3d9389fd691b182921c0ebce88b8eb821b13 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Apr 2017 20:18:24 +0200 Subject: [PATCH 0473/2031] Also apply csvar{in,out} typemaps to std::complex references This is needed to handle the artificial complex-valued properties created using %naturalvar correctly. --- Lib/csharp/std_complex.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index d7cf7e6d3..4c627d72f 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -33,14 +33,14 @@ public: return new System.Numerics.Complex(cppret.real(), cppret.imag()); } -%typemap(csvarin, excode=SWIGEXCODE2) std::complex* %{ +%typemap(csvarin, excode=SWIGEXCODE2) std::complex*, const std::complex& %{ set { var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); $imcall;$excode } %} -%typemap(csvarout, excode=SWIGEXCODE2) std::complex* %{ +%typemap(csvarout, excode=SWIGEXCODE2) std::complex*, const std::complex& %{ get { var cppret = new Complex_##T($imcall, $owner);$excode return new System.Numerics.Complex(cppret.real(), cppret.imag()); From 03f229b3141703bbcec27e404c0c14f9391884e8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 15 Apr 2017 20:28:30 +0200 Subject: [PATCH 0474/2031] Allow avoiding generation of unwanted std::complex typemaps In many cases, only one of std::complex and std::complex is used, so while we continue to define typemaps for both by default, for compatibility with the other modules, add a possibility to avoid generating the code for the unwanted specialization by predefining the corresponding SWIG_NO_STD_COMPLEX_$TYPE before including this file. --- Lib/csharp/std_complex.i | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index 4c627d72f..b5bdec60d 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -50,5 +50,13 @@ public: %template(Complex_##T) std::complex; %enddef +// By default, typemaps for both std::complex and std::complex +// are defined, but one of them can be disabled by predefining the +// corresponding symbol before including this file. +#ifndef SWIG_NO_STD_COMPLEX_DOUBLE swig_complex_typemaps(double) +#endif + +#ifndef SWIG_NO_STD_COMPLEX_FLOAT swig_complex_typemaps(float) +#endif From 7a343a196bc74dad5acce107d2c709974b7535d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 07:33:15 +0100 Subject: [PATCH 0475/2031] Correct ordering of declarations in testcase --- Examples/test-suite/cpp11_shared_ptr_const.i | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_const.i b/Examples/test-suite/cpp11_shared_ptr_const.i index 1989e3261..0d1acdac0 100644 --- a/Examples/test-suite/cpp11_shared_ptr_const.i +++ b/Examples/test-suite/cpp11_shared_ptr_const.i @@ -43,11 +43,6 @@ std::vector > const_foo_vec(Foo v) { %template (FooVector) std::vector >; %template (FooConstVector) std::vector >; -std::shared_ptr foo(Foo v); -std::shared_ptr const_foo(Foo v); -std::vector > foo_vec(Foo v) const; -std::vector > const_foo_vec(Foo v) const; - class Foo { public: @@ -55,3 +50,8 @@ public: int get_m(); int m; }; +std::shared_ptr foo(Foo v); +std::shared_ptr const_foo(Foo v); +std::vector > foo_vec(Foo v) const; +std::vector > const_foo_vec(Foo v) const; + From 660147043da845998e9066d7116aaf3f525b56e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 07:49:03 +0100 Subject: [PATCH 0476/2031] Correct comment about const removal for shared_ptr --- Lib/ruby/std_shared_ptr.i | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index 983ffde49..f6c0a15ac 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -114,9 +114,8 @@ namespace swig { }; /* - we have to remove the const qualifier to work around a BUG - SWIG_TypeQuery("std::shared_ptr") == NULL, - which is caused by %template treating const qualifiers not properly. + The descriptors in the shared_ptr typemaps remove the const qualifier for the SWIG type system. + Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr") will return NULL. */ template struct traits_from > { @@ -128,5 +127,4 @@ namespace swig { } } -//force the fragment. %fragment("StdSharedPtrTraits"); From 6398614c9278db40d41dca630a672bcb39835276 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 07:57:48 +0100 Subject: [PATCH 0477/2031] Update ruby tests for change in swig_assert_equal_simple name --- .../ruby/cpp11_shared_ptr_const_runme.rb | 8 +-- .../ruby/cpp11_shared_ptr_upcast_runme.rb | 60 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb index db56252da..149aa0898 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb @@ -3,7 +3,7 @@ require "cpp11_shared_ptr_const" include Cpp11_shared_ptr_const -simple_assert_equal(1, foo( Foo.new(1) ).get_m ) -simple_assert_equal(7, const_foo( Foo.new(7) ).get_m ) -simple_assert_equal(7, foo_vec( Foo.new(7) )[0].get_m ) -simple_assert_equal(8, const_foo_vec( Foo.new(8) )[0].get_m ) +swig_assert_equal_simple(1, foo( Foo.new(1) ).get_m ) +swig_assert_equal_simple(7, const_foo( Foo.new(7) ).get_m ) +swig_assert_equal_simple(7, foo_vec( Foo.new(7) )[0].get_m ) +swig_assert_equal_simple(8, const_foo_vec( Foo.new(8) )[0].get_m ) diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb index 864be1382..000b9b6a9 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb @@ -5,56 +5,56 @@ require 'cpp11_shared_ptr_upcast' include Cpp11_shared_ptr_upcast # non-overloaded -simple_assert_equal( 7, derived_num1(Derived.new(7)) ) -simple_assert_equal( 7, derived_num2([Derived.new(7)]) ) -simple_assert_equal( 7, derived_num3({0 => Derived.new(7)}) ) +swig_assert_equal_simple( 7, derived_num1(Derived.new(7)) ) +swig_assert_equal_simple( 7, derived_num2([Derived.new(7)]) ) +swig_assert_equal_simple( 7, derived_num3({0 => Derived.new(7)}) ) -simple_assert_equal(-1, base_num1(Derived.new(7)) ) -simple_assert_equal(-1, base_num2([Derived.new(7)]) ) -simple_assert_equal(-1, base_num3({0 => Derived.new(7)}) ) +swig_assert_equal_simple(-1, base_num1(Derived.new(7)) ) +swig_assert_equal_simple(-1, base_num2([Derived.new(7)]) ) +swig_assert_equal_simple(-1, base_num3({0 => Derived.new(7)}) ) -simple_assert_equal( 999, derived_num1(nil) ) -simple_assert_equal( 999, derived_num2([nil]) ) -simple_assert_equal( 999, derived_num3({0 => nil}) ) +swig_assert_equal_simple( 999, derived_num1(nil) ) +swig_assert_equal_simple( 999, derived_num2([nil]) ) +swig_assert_equal_simple( 999, derived_num3({0 => nil}) ) -simple_assert_equal( 999, base_num1(nil) ) -simple_assert_equal( 999, base_num2([nil]) ) -simple_assert_equal( 999, base_num3({0 => nil}) ) +swig_assert_equal_simple( 999, base_num1(nil) ) +swig_assert_equal_simple( 999, base_num2([nil]) ) +swig_assert_equal_simple( 999, base_num3({0 => nil}) ) # overloaded -simple_assert_equal( 7, derived_num(Derived.new(7)) ) -simple_assert_equal( 7, derived_num([Derived.new(7)]) ) -simple_assert_equal( 7, derived_num({0 => Derived.new(7)}) ) +swig_assert_equal_simple( 7, derived_num(Derived.new(7)) ) +swig_assert_equal_simple( 7, derived_num([Derived.new(7)]) ) +swig_assert_equal_simple( 7, derived_num({0 => Derived.new(7)}) ) -simple_assert_equal(-1, base_num(Derived.new(7)) ) -simple_assert_equal(-1, base_num([Derived.new(7)]) ) -simple_assert_equal(-1, base_num({0 => Derived.new(7)}) ) +swig_assert_equal_simple(-1, base_num(Derived.new(7)) ) +swig_assert_equal_simple(-1, base_num([Derived.new(7)]) ) +swig_assert_equal_simple(-1, base_num({0 => Derived.new(7)}) ) # ptr to shared_ptr -simple_assert_equal( 7, derived2_num1(Derived2.new(7)) ) -simple_assert_equal( 7, derived2_num2([Derived2.new(7)]) ) -simple_assert_equal( 7, derived2_num3({0 => Derived2.new(7)}) ) +swig_assert_equal_simple( 7, derived2_num1(Derived2.new(7)) ) +swig_assert_equal_simple( 7, derived2_num2([Derived2.new(7)]) ) +swig_assert_equal_simple( 7, derived2_num3({0 => Derived2.new(7)}) ) -simple_assert_equal( -1, base2_num1(Derived2.new(7)) ) +swig_assert_equal_simple( -1, base2_num1(Derived2.new(7)) ) begin # Upcast for pointers to shared_ptr in this generic framework has not been implemented - simple_assert_equal( -1, base2_num2([Derived2.new(7)]) ) + swig_assert_equal_simple( -1, base2_num2([Derived2.new(7)]) ) raise RuntimeError, "Failed to catch TypeError" rescue TypeError end begin # Upcast for pointers to shared_ptr in this generic framework has not been implemented - simple_assert_equal( -1, base2_num3({0 => Derived2.new(7)}) ) + swig_assert_equal_simple( -1, base2_num3({0 => Derived2.new(7)}) ) raise RuntimeError, "Failed to catch TypeError" rescue TypeError end -simple_assert_equal( 888, derived2_num1(nil) ) -simple_assert_equal( 999, derived2_num2([nil]) ) # although 888 would be more consistent -simple_assert_equal( 999, derived2_num3({0 => nil}) ) # although 888 would be more consistent +swig_assert_equal_simple( 888, derived2_num1(nil) ) +swig_assert_equal_simple( 999, derived2_num2([nil]) ) # although 888 would be more consistent +swig_assert_equal_simple( 999, derived2_num3({0 => nil}) ) # although 888 would be more consistent -simple_assert_equal( 888, base2_num1(nil) ) -simple_assert_equal( 999, base2_num2([nil]) ) # although 888 would be more consistent -simple_assert_equal( 999, base2_num3({0 => nil}) ) # although 888 would be more consistent +swig_assert_equal_simple( 888, base2_num1(nil) ) +swig_assert_equal_simple( 999, base2_num2([nil]) ) # although 888 would be more consistent +swig_assert_equal_simple( 999, base2_num3({0 => nil}) ) # although 888 would be more consistent From 79620b10a993f3d735a29ff6f16552e43fb8f533 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 08:16:50 +0100 Subject: [PATCH 0478/2031] Add changes entry for enhanced Ruby shared_ptr in containers support --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2d5e841ea..9ea6662cc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-04-20: tamuratak + [Ruby] #930, #937 - Fix containers of std::shared_ptr. + Upcasting, const types (eg vector>) and NULL/nullptr support added. + 2017-04-12: smarchetto [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) From 661c3fc55472439803ff3b3742ad7c83228d2fb3 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Thu, 13 Apr 2017 15:43:25 +0900 Subject: [PATCH 0479/2031] [ruby] treat null shared_ptr in std containers properly. --- Lib/ruby/rubystdcommon_forward.swg | 3 ++- Lib/ruby/std_shared_ptr.i | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Lib/ruby/rubystdcommon_forward.swg b/Lib/ruby/rubystdcommon_forward.swg index 27bcb9960..4120b38e4 100644 --- a/Lib/ruby/rubystdcommon_forward.swg +++ b/Lib/ruby/rubystdcommon_forward.swg @@ -5,7 +5,8 @@ namespace swig { template struct traits_asval; struct pointer_category; template struct traits_as; - template struct traits_from; + template struct traits_from; + template struct traits_from_ptr; template struct noconst_traits; template swig_type_info* type_info(); template const char* type_name(); diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index f6c0a15ac..f2b05ef36 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -113,6 +113,17 @@ namespace swig { } }; + template + struct traits_from_ptr > { + static VALUE from(std::shared_ptr *val, int owner = 0) { + if (val && *val) { + return SWIG_NewPointerObj(val, type_info >(), owner); + } else { + return Qnil; + } + } + }; + /* The descriptors in the shared_ptr typemaps remove the const qualifier for the SWIG type system. Remove const likewise here, otherwise SWIG_TypeQuery("std::shared_ptr") will return NULL. From 0c3298073b0502dd0eda43b1a998937a0f00d057 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sun, 16 Apr 2017 16:35:15 +0900 Subject: [PATCH 0480/2031] [ruby] add a test for null shared_ptr in containers. --- .../cpp11_shared_ptr_nullptr_in_containers.i | 48 +++++++++++++++++++ ..._shared_ptr_nullptr_in_containers_runme.rb | 15 ++++++ 2 files changed, 63 insertions(+) create mode 100644 Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i create mode 100644 Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb diff --git a/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i new file mode 100644 index 000000000..3050add7e --- /dev/null +++ b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i @@ -0,0 +1,48 @@ +%module cpp11_shared_ptr_nullptr_in_containers + +%{ +#include +#include +%} + +%include +%include + +%shared_ptr(C) + +%inline %{ + +class C { +public: + C() : m(-1) {} + C(int i) : m(i) {} + int get_m() { return m; } + int m; +}; + +%} + +%template() std::vector >; + +%inline %{ + + std::vector > ret_vec_c_shared_ptr() { + std::vector > ret(3); + ret[0] = std::shared_ptr(new C(0)); + ret[2] = std::shared_ptr(new C(2)); + return ret; + } + + std::vector > ret_arg_vec(const std::vector >& v) { + return v; + } + + bool is_last_null(const std::vector >& v) { + if( *v.end() ) { + return false; + } else { + return true; + } + } + +%} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb new file mode 100644 index 000000000..46d499427 --- /dev/null +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb @@ -0,0 +1,15 @@ +require "cpp11_shared_ptr_nullptr_in_containers" + +include Cpp11_shared_ptr_nullptr_in_containers + +a = ret_vec_c_shared_ptr() +raise unless a[0].get_m == 0 +raise unless a[1] == nil +raise unless a[2].get_m == 2 + +a = ret_arg_vec([C.new(7), nil, C.new(9)]) +raise unless a[0].get_m == 7 +raise unless a[1] == nil +raise unless a[2].get_m == 9 + +raise unless is_last_null([C.new(7), C.new(8), nil]) From 042d8289fd2beb27a909b8f0f7787a353ad34fb3 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Mon, 17 Apr 2017 12:28:49 +0900 Subject: [PATCH 0481/2031] [ruby] enable a test for null shared_ptr in containers. --- Examples/test-suite/ruby/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 27e9f5e18..8ed73efb0 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -33,6 +33,7 @@ CPP_TEST_CASES = \ CPP11_TEST_CASES = \ cpp11_hash_tables \ cpp11_shared_ptr_upcast \ + cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_const C_TEST_CASES += \ From cc4e3aec52ecedb1240ae56f92fdf70b64e1380c Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Thu, 20 Apr 2017 13:59:44 +0900 Subject: [PATCH 0482/2031] [ruby] use std::vector::back() method. --- Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i index 3050add7e..46e2501d7 100644 --- a/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i +++ b/Examples/test-suite/cpp11_shared_ptr_nullptr_in_containers.i @@ -3,6 +3,8 @@ %{ #include #include + +class C; %} %include @@ -38,7 +40,7 @@ public: } bool is_last_null(const std::vector >& v) { - if( *v.end() ) { + if( v.back() ) { return false; } else { return true; From 34ba3b9ed96b864de0ddd8768394252e43aa7ead Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Thu, 20 Apr 2017 14:20:33 +0900 Subject: [PATCH 0483/2031] [ruby] add a test. --- .../ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb index 46d499427..9d8b3c050 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_nullptr_in_containers_runme.rb @@ -13,3 +13,4 @@ raise unless a[1] == nil raise unless a[2].get_m == 9 raise unless is_last_null([C.new(7), C.new(8), nil]) +raise if is_last_null([C.new(7), C.new(8)]) From 1c968b3695b234ec94cf7fbdb9902ecd519d2edf Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Mon, 10 Apr 2017 18:53:46 +0900 Subject: [PATCH 0484/2031] add a test for shared_ptr with director --- .../test-suite/cpp11_shared_ptr_director.i | 23 ++++++++++++++++++ .../ruby/cpp11_shared_ptr_director_runme.rb | 24 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Examples/test-suite/cpp11_shared_ptr_director.i create mode 100644 Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/cpp11_shared_ptr_director.i new file mode 100644 index 000000000..a8907de2c --- /dev/null +++ b/Examples/test-suite/cpp11_shared_ptr_director.i @@ -0,0 +1,23 @@ +%module(directors="1") "cpp11_shared_ptr_director" + +%{ +#include +%} + +%include "std_shared_ptr.i"; +%shared_ptr(Created); +%feature("director") Creator; + +%inline %{ +struct Created {}; + +struct Creator { + Creator() {}; + virtual std::shared_ptr create() = 0; + virtual ~Creator() {} +}; + +void crash(Creator* creator) { + std::shared_ptr ptr = creator->create(); +} +%} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb new file mode 100644 index 000000000..17e7512f3 --- /dev/null +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb @@ -0,0 +1,24 @@ +require 'cpp11_shared_ptr_director' + +include Cpp11_shared_ptr_director + +class Derived < Creator + + def initialize(flag) + @return_none = flag + super() + end + + def create + if @return_none + nil + else + Created.new + end + end + +end + +crash(Derived.new(false)) +crash(Derived.new(true)) + From b3c2b1c51ca703177082479874d3ac533d529de0 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Mon, 10 Apr 2017 23:26:18 +0900 Subject: [PATCH 0485/2031] [ruby] add %typemap(directorout) for shared_ptr. --- Examples/test-suite/cpp11_shared_ptr_director.i | 13 +++++++++++-- .../ruby/cpp11_shared_ptr_director_runme.rb | 4 ++-- Lib/ruby/boost_shared_ptr.i | 12 ++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/cpp11_shared_ptr_director.i index a8907de2c..23e649af3 100644 --- a/Examples/test-suite/cpp11_shared_ptr_director.i +++ b/Examples/test-suite/cpp11_shared_ptr_director.i @@ -9,7 +9,10 @@ %feature("director") Creator; %inline %{ -struct Created {}; +struct Created { + Created() {}; + int get_m() { return 1; }; +}; struct Creator { Creator() {}; @@ -17,7 +20,13 @@ struct Creator { virtual ~Creator() {} }; -void crash(Creator* creator) { +int crash(Creator* creator) { std::shared_ptr ptr = creator->create(); + if (ptr) { + return ptr->get_m(); + } else { + return -1; + } } + %} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb index 17e7512f3..208e72603 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb @@ -19,6 +19,6 @@ class Derived < Creator end -crash(Derived.new(false)) -crash(Derived.new(true)) +p crash(Derived.new(false)) +p crash(Derived.new(true)) diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index 938074d81..356e87452 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -197,6 +197,18 @@ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void * swig_argp, int swig_res = 0) { + if (NIL_P($input)) { + $result = $ltype(); + } else { + swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + $result = *(%reinterpret_cast(swig_argp, $<ype)); + } +} + %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { swig_ruby_owntype newmem = {0, 0}; void *argp = 0; From 17b4e0c66ec262381832950cc381e1a22ed6ffaa Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Tue, 11 Apr 2017 18:41:14 +0900 Subject: [PATCH 0486/2031] [ruby] add %typemap(directorin) and %typemap(directorout) for shared_ptr. --- .../test-suite/cpp11_shared_ptr_director.i | 48 ++++++++--- .../ruby/cpp11_shared_ptr_director_runme.rb | 34 ++++++-- Lib/ruby/boost_shared_ptr.i | 80 ++++++++++++++++--- 3 files changed, 133 insertions(+), 29 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/cpp11_shared_ptr_director.i index 23e649af3..bb23a1de7 100644 --- a/Examples/test-suite/cpp11_shared_ptr_director.i +++ b/Examples/test-suite/cpp11_shared_ptr_director.i @@ -5,23 +5,29 @@ %} %include "std_shared_ptr.i"; -%shared_ptr(Created); -%feature("director") Creator; +%shared_ptr(C); +%feature("director") Base; %inline %{ -struct Created { - Created() {}; - int get_m() { return 1; }; +struct C { + C() : m(1) {}; + C(int n) : m(n) {}; + int get_m() { return m; }; + int m; }; -struct Creator { - Creator() {}; - virtual std::shared_ptr create() = 0; - virtual ~Creator() {} +struct Base { + Base() {}; + virtual std::shared_ptr ret_c_shared_ptr() = 0; + virtual C ret_c_by_value() = 0; + virtual int take_c_by_value(C c) = 0; + virtual int take_c_shared_ptr_by_value(std::shared_ptr c) = 0; + virtual int take_c_shared_ptr_by_ref(std::shared_ptr& c) = 0; + virtual ~Base() {} }; -int crash(Creator* creator) { - std::shared_ptr ptr = creator->create(); +int call_ret_c_shared_ptr(Base* b) { + std::shared_ptr ptr = b->ret_c_shared_ptr(); if (ptr) { return ptr->get_m(); } else { @@ -29,4 +35,24 @@ int crash(Creator* creator) { } } +int call_ret_c_by_value(Base* b) { + C c = b->ret_c_by_value(); + return c.get_m(); +} + +int call_take_c_by_value(Base* b) { + C c(5); + return b->take_c_by_value(c); +} + +int call_take_c_shared_ptr_by_value(Base* b) { + std::shared_ptr ptr(new C(6)); + return b->take_c_shared_ptr_by_value(ptr); +} + +int call_take_c_shared_ptr_by_ref(Base* b) { + std::shared_ptr ptr(new C(7)); + return b->take_c_shared_ptr_by_ref(ptr); +} + %} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb index 208e72603..c2aefaa3d 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb @@ -2,23 +2,47 @@ require 'cpp11_shared_ptr_director' include Cpp11_shared_ptr_director -class Derived < Creator +class Derived < Base def initialize(flag) @return_none = flag super() end - def create + def ret_c_shared_ptr if @return_none nil else - Created.new + C.new end end + def ret_c_by_value + C.new + end + + def take_c_by_value(c) + c.get_m + end + + def take_c_shared_ptr_by_value(c) + c.get_m + end + + def take_c_shared_ptr_by_ref(c) + c.get_m + end + end -p crash(Derived.new(false)) -p crash(Derived.new(true)) +a = Derived.new(false) +b = Derived.new(true) + +raise unless call_ret_c_shared_ptr(a) == 1 +raise unless call_ret_c_shared_ptr(b) == -1 +raise unless call_ret_c_by_value(a) == 1 + +raise unless call_take_c_by_value(a) == 5 +raise unless call_take_c_shared_ptr_by_value(a) == 6 +raise unless call_take_c_shared_ptr_by_ref(a) == 7 diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index 356e87452..ef65fcb25 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -24,7 +24,9 @@ // Typemap customisations... +// // plain value +// %typemap(in) CONST TYPE (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -62,8 +64,28 @@ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorout,noblock=1) CONST TYPE (void *argp, int res = 0) { + swig_ruby_owntype newmem = {0, 0}; + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); + if (!SWIG_IsOK(res)) { + %dirout_fail(res, "$type"); + } + if (!argp) { + %dirout_nullref("$type"); + } else { + $result = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get()); + if (newmem.own & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); + } +} +%typemap(directorin,noblock=1) CONST TYPE { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); + $input = SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); +} + +// // plain pointer // Note: $disown not implemented by default 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) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); @@ -79,7 +101,6 @@ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } - %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); @@ -108,7 +129,16 @@ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorin,noblock=1) CONST TYPE * %{ +#error "directorin typemap for plain pointer not implemented" +%} +%typemap(directorout,noblock=1) CONST TYPE * %{ +#error "directorout typemap for plain pointer not implemented" +%} + +// // plain reference +// %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -153,8 +183,17 @@ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorin,noblock=1) CONST TYPE & %{ +#error "directorin typemap for plain reference not implemented" +%} +%typemap(directorout,noblock=1) CONST TYPE & %{ +#error "directorout typemap for plain reference not implemented" +%} + +// // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +// %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); @@ -182,7 +221,16 @@ #error "varout typemap not implemented" %} +%typemap(directorin,noblock=1) TYPE *CONST& %{ +#error "directorin typemap for plain pointer by reference not implemented" +%} +%typemap(directorout,noblock=1) TYPE *CONST& %{ +#error "directorout typemap for plain pointer by reference not implemented" +%} + +// // shared_ptr by value +// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -197,18 +245,6 @@ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } -%typemap(directorout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void * swig_argp, int swig_res = 0) { - if (NIL_P($input)) { - $result = $ltype(); - } else { - swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); - if (!SWIG_IsOK(swig_res)) { - %dirout_fail(swig_res,"$type"); - } - $result = *(%reinterpret_cast(swig_argp, $<ype)); - } -} - %typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { swig_ruby_owntype newmem = {0, 0}; void *argp = 0; @@ -224,7 +260,21 @@ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void * swig_argp, int swig_res = 0) { + if (NIL_P($input)) { + $result = $ltype(); + } else { + swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); + if (!SWIG_IsOK(swig_res)) { + %dirout_fail(swig_res,"$type"); + } + $result = *(%reinterpret_cast(swig_argp, $<ype)); + } +} + +// // shared_ptr by reference +// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -251,7 +301,9 @@ #error "varout typemap not implemented" %} +// // shared_ptr by pointer +// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -279,7 +331,9 @@ #error "varout typemap not implemented" %} +// // shared_ptr by pointer reference +// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); From 0f94b936e82201f56cc6d4a24cd3645640ddeaf9 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Tue, 11 Apr 2017 18:51:32 +0900 Subject: [PATCH 0487/2031] [ruby] enable a test, cpp11_shared_ptr_director. --- Examples/test-suite/ruby/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 27e9f5e18..33f42a7fc 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -33,7 +33,8 @@ CPP_TEST_CASES = \ CPP11_TEST_CASES = \ cpp11_hash_tables \ cpp11_shared_ptr_upcast \ - cpp11_shared_ptr_const + cpp11_shared_ptr_const \ + cpp11_shared_ptr_director C_TEST_CASES += \ li_cstring \ From 0020fc97b02d6ec7d58e211d1a652f68d6bc7f51 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Wed, 12 Apr 2017 12:20:05 +0900 Subject: [PATCH 0488/2031] [ruby] add %typemap(directorin) for shared_ptr. --- .../test-suite/cpp11_shared_ptr_director.i | 32 +++++++++++++++ .../ruby/cpp11_shared_ptr_director_runme.rb | 41 ++++++++++++++++--- Lib/ruby/boost_shared_ptr.i | 26 +++++++++++- 3 files changed, 93 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/cpp11_shared_ptr_director.i index bb23a1de7..0f0554134 100644 --- a/Examples/test-suite/cpp11_shared_ptr_director.i +++ b/Examples/test-suite/cpp11_shared_ptr_director.i @@ -23,6 +23,8 @@ struct Base { virtual int take_c_by_value(C c) = 0; virtual int take_c_shared_ptr_by_value(std::shared_ptr c) = 0; virtual int take_c_shared_ptr_by_ref(std::shared_ptr& c) = 0; + virtual int take_c_shared_ptr_by_pointer(std::shared_ptr* c) = 0; + virtual int take_c_shared_ptr_by_pointer_ref(std::shared_ptr*const&c) = 0; virtual ~Base() {} }; @@ -50,9 +52,39 @@ int call_take_c_shared_ptr_by_value(Base* b) { return b->take_c_shared_ptr_by_value(ptr); } +int call_take_c_shared_ptr_by_value_with_null(Base* b) { + std::shared_ptr ptr; + return b->take_c_shared_ptr_by_value(ptr); +} + int call_take_c_shared_ptr_by_ref(Base* b) { std::shared_ptr ptr(new C(7)); return b->take_c_shared_ptr_by_ref(ptr); } +int call_take_c_shared_ptr_by_ref_with_null(Base* b) { + std::shared_ptr ptr; + return b->take_c_shared_ptr_by_ref(ptr); +} + +int call_take_c_shared_ptr_by_pointer(Base* b) { + std::shared_ptr ptr(new C(8)); + return b->take_c_shared_ptr_by_pointer(&ptr); +} + +int call_take_c_shared_ptr_by_pointer_with_null(Base* b) { + std::shared_ptr ptr; + return b->take_c_shared_ptr_by_pointer(&ptr); +} + +int call_take_c_shared_ptr_by_pointer_ref(Base* b) { + auto ptr = new std::shared_ptr(new C(9)); + return b->take_c_shared_ptr_by_pointer_ref(ptr); +} + +int call_take_c_shared_ptr_by_pointer_ref_with_null(Base* b) { + auto ptr = new std::shared_ptr(); + return b->take_c_shared_ptr_by_pointer_ref(ptr); +} + %} diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb index c2aefaa3d..51b338aef 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb +++ b/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb @@ -26,11 +26,35 @@ class Derived < Base end def take_c_shared_ptr_by_value(c) - c.get_m + if c + c.get_m + else + -2 + end end def take_c_shared_ptr_by_ref(c) - c.get_m + if c + c.get_m + else + -3 + end + end + + def take_c_shared_ptr_by_pointer(c) + if c + c.get_m + else + -4 + end + end + + def take_c_shared_ptr_by_pointer_ref(c) + if c + c.get_m + else + -5 + end end end @@ -42,7 +66,14 @@ raise unless call_ret_c_shared_ptr(a) == 1 raise unless call_ret_c_shared_ptr(b) == -1 raise unless call_ret_c_by_value(a) == 1 -raise unless call_take_c_by_value(a) == 5 -raise unless call_take_c_shared_ptr_by_value(a) == 6 -raise unless call_take_c_shared_ptr_by_ref(a) == 7 +raise unless call_take_c_by_value(a) == 5 +raise unless call_take_c_shared_ptr_by_value(a) == 6 +raise unless call_take_c_shared_ptr_by_ref(a) == 7 +raise unless call_take_c_shared_ptr_by_pointer(a) == 8 +raise unless call_take_c_shared_ptr_by_pointer_ref(a) == 9 + +raise unless call_take_c_shared_ptr_by_value_with_null(a) == -2 +raise unless call_take_c_shared_ptr_by_ref_with_null(a) == -3 +raise unless call_take_c_shared_ptr_by_pointer_with_null(a) == -4 +raise unless call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -5 diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index ef65fcb25..0350f41d9 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -260,11 +260,19 @@ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN)); } +%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { + if ($1) { + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1); + $input = SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); + } else { + $input = Qnil; + } +} %typemap(directorout,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void * swig_argp, int swig_res = 0) { if (NIL_P($input)) { $result = $ltype(); } else { - swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags); + swig_res = SWIG_ConvertPtr($input, &swig_argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags); if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } @@ -301,6 +309,14 @@ #error "varout typemap not implemented" %} +%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & { + if ($1) { + $input = SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %newpointer_flags); + } else { + $input = Qnil; + } +} + // // shared_ptr by pointer // @@ -331,6 +347,14 @@ #error "varout typemap not implemented" %} +%typemap(directorin,noblock=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *const& { + if ($1 && *$1) { + $input = SWIG_NewPointerObj(%as_voidptr($1), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %newpointer_flags); + } else { + $input = Qnil; + } +} + // // shared_ptr by pointer reference // From b4377488f775464ddbb324128941c7182233f13c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 18:51:45 +0100 Subject: [PATCH 0489/2031] Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj. Closes #935 --- CHANGES.current | 3 +++ Lib/ruby/rubyrun.swg | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9ea6662cc..e31a71ab9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-04-20: wsfulton + [Ruby] #586, #935 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj. + 2017-04-20: tamuratak [Ruby] #930, #937 - Fix containers of std::shared_ptr. Upcasting, const types (eg vector>) and NULL/nullptr support added. diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 94618db4e..4628aedc3 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -171,10 +171,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) swig_class *sklass; VALUE klass; VALUE obj; - + if (!ptr) return Qnil; - + + assert(type); if (type->clientdata) { sklass = (swig_class *) type->clientdata; @@ -182,7 +183,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) track = sklass->trackObjects; if (track) { obj = SWIG_RubyInstanceFor(ptr); - + /* Check the object's type and make sure it has the correct type. It might not in cases where methods do things like downcast methods. */ @@ -214,7 +215,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) obj = Data_Wrap_Struct(klass, 0, 0, ptr); } rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name)); - + return obj; } From ab1e9f5bd9dba792f6fa197299f303f089663e79 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Apr 2017 19:20:35 +0100 Subject: [PATCH 0490/2031] Consistent whitespace amongst all the shared_ptr and intrusive_ptr typemaps [skip ci] --- Lib/csharp/boost_shared_ptr.i | 16 +++---- Lib/java/boost_intrusive_ptr.i | 80 +++++++++++++++++----------------- Lib/java/boost_shared_ptr.i | 18 ++++---- Lib/octave/boost_shared_ptr.i | 22 +++++----- Lib/python/boost_shared_ptr.i | 23 +++++----- Lib/r/boost_shared_ptr.i | 22 +++++----- Lib/scilab/boost_shared_ptr.i | 22 +++++----- 7 files changed, 101 insertions(+), 102 deletions(-) diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 2b65bf20d..8d65d7953 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -14,7 +14,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor mods -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -28,7 +28,7 @@ return $null; } $1 = *argp; %} -%typemap(out) CONST TYPE +%typemap(out) CONST TYPE %{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} // plain pointer @@ -66,7 +66,7 @@ %typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? ($1_ltype)$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & -%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} +%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) @@ -80,7 +80,7 @@ %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& -%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} +%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$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::*) %{ @@ -91,20 +91,20 @@ %} -%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (ctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "void *" -%typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (imtype, out="global::System.IntPtr") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "global::System.Runtime.InteropServices.HandleRef" -%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (cstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE)" -%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap(csin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(cstype, TYPE).getCPtr($csinput)" diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i index a484a3b6c..48e530c63 100644 --- a/Lib/java/boost_intrusive_ptr.i +++ b/Lib/java/boost_intrusive_ptr.i @@ -29,26 +29,26 @@ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); return $null; } - $1 = *argp; + $1 = *argp; %} -%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ +%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 >()); + *(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); + $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 >()); + *(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; } @@ -63,70 +63,70 @@ 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 & %{ +%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 >()); + *(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) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ +%typemap(in) TYPE *CONST& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain pointer by reference temp = ($*1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - $1 = &temp; + $1 = &temp; %} -%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ +%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") TYPE *CONST& %{ // 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 >()); + *(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) %{ +%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); + $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 > %{ +%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; + *(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; + 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(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) %{ +%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; + 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 { @@ -140,21 +140,21 @@ $1 = *temp; } %} -%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ +%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) %{ +%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; + smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - $1 = &temp; + $1 = &temp; } else { $1 = &tempnull; } @@ -163,17 +163,17 @@ 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 > * %{ +%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; + 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) %{ +%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) { @@ -185,14 +185,14 @@ %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 > *& %{ +%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::*) %{ @@ -208,7 +208,7 @@ 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 >, +%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 > *, @@ -341,7 +341,7 @@ return $null; } $1 = *argp; %} -%typemap(out) CONST TYPE +%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 @@ -371,11 +371,11 @@ %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; + 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(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 diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 5ed16aa32..33da61bf8 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -14,7 +14,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -28,7 +28,7 @@ return $null; } $1 = *argp; %} -%typemap(out) CONST TYPE +%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 @@ -58,7 +58,7 @@ // shared_ptr by value %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ($&1_type argp) -%{ argp = *($&1_ltype*)&$input; +%{ argp = *($&1_ltype*)&$input; if (argp) $1 = *argp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > %{ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; %} @@ -67,7 +67,7 @@ %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull) %{ $1 = $input ? *($&1_ltype)&$input : &tempnull; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & -%{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %} +%{ *($&1_ltype)&$result = *$1 ? new $*1_ltype(*$1) : 0; %} // shared_ptr by pointer %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull) @@ -81,7 +81,7 @@ %{ temp = $input ? *($1_ltype)&$input : &tempnull; $1 = &temp; %} %typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& -%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %} +%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$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::*) %{ @@ -92,20 +92,20 @@ %} -%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "jlong" -%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "long" -%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE)" -%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, +%typemap(javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& "$typemap(jstype, TYPE).getCPtr($javainput)" diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i index e91862057..4ef646831 100644 --- a/Lib/octave/boost_shared_ptr.i +++ b/Lib/octave/boost_shared_ptr.i @@ -8,7 +8,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -19,7 +19,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); @@ -58,7 +58,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -102,7 +102,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { @@ -148,7 +148,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -176,7 +176,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); @@ -206,7 +206,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -233,7 +233,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -261,7 +261,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); @@ -281,9 +281,9 @@ %} // Typecheck typemaps -// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index 40a1ae1ef..be5604cbe 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -18,7 +18,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -29,7 +29,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); @@ -68,7 +68,7 @@ int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -113,7 +113,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { @@ -159,7 +159,7 @@ int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -187,7 +187,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); @@ -217,7 +217,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -244,7 +244,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -272,7 +272,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); @@ -292,9 +292,9 @@ %} // Typecheck typemaps -// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, @@ -321,4 +321,3 @@ %enddef - diff --git a/Lib/r/boost_shared_ptr.i b/Lib/r/boost_shared_ptr.i index 8ef8d2ef2..4a56d7cba 100644 --- a/Lib/r/boost_shared_ptr.i +++ b/Lib/r/boost_shared_ptr.i @@ -8,7 +8,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -19,7 +19,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); @@ -56,7 +56,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -100,7 +100,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { @@ -146,7 +146,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -174,7 +174,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); @@ -204,7 +204,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -231,7 +231,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -259,7 +259,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); @@ -279,9 +279,9 @@ %} // Typecheck typemaps -// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, diff --git a/Lib/scilab/boost_shared_ptr.i b/Lib/scilab/boost_shared_ptr.i index b90422a66..d595b4861 100644 --- a/Lib/scilab/boost_shared_ptr.i +++ b/Lib/scilab/boost_shared_ptr.i @@ -14,7 +14,7 @@ %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; // destructor wrapper customisation -%feature("unref") TYPE +%feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" @@ -25,7 +25,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); @@ -64,7 +64,7 @@ int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -109,7 +109,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (!argp) { %argument_nullref("$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { @@ -155,7 +155,7 @@ int newmem = 0; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { - %argument_fail(res, "$type", $symname, $argnum); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *); @@ -183,7 +183,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) $1 = *(%reinterpret_cast(argp, $<ype)); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $<ype); @@ -213,7 +213,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -240,7 +240,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (newmem & SWIG_CAST_NEW_MEMORY) { if (argp) tempshared = *%reinterpret_cast(argp, $ltype); @@ -268,7 +268,7 @@ int newmem = 0; 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); + %argument_fail(res, "$type", $symname, $argnum); } if (argp) tempshared = *%reinterpret_cast(argp, $*ltype); if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype); @@ -288,9 +288,9 @@ %} // Typecheck typemaps -// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting +// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting // function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain. -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) TYPE CONST, TYPE CONST &, TYPE CONST *, From 6672338cc0d74c68c6738c53ba7de06a83b1efaa Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Fri, 21 Apr 2017 22:44:38 +0900 Subject: [PATCH 0491/2031] [ruby] delete unnecessary changes. --- Lib/ruby/boost_shared_ptr.i | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i index 0350f41d9..02e2f999f 100644 --- a/Lib/ruby/boost_shared_ptr.i +++ b/Lib/ruby/boost_shared_ptr.i @@ -24,9 +24,7 @@ // Typemap customisations... -// // plain value -// %typemap(in) CONST TYPE (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -82,10 +80,8 @@ $input = SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags); } -// // plain pointer // Note: $disown not implemented by default 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) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); @@ -101,6 +97,7 @@ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype); } } + %typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN)); @@ -136,9 +133,7 @@ #error "directorout typemap for plain pointer not implemented" %} -// // plain reference -// %typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -190,10 +185,8 @@ #error "directorout typemap for plain reference not implemented" %} -// // plain pointer by reference // Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance -// %typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); @@ -228,9 +221,7 @@ #error "directorout typemap for plain pointer by reference not implemented" %} -// // shared_ptr by value -// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -280,9 +271,7 @@ } } -// // shared_ptr by reference -// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -317,9 +306,7 @@ } } -// // shared_ptr by pointer -// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); @@ -355,9 +342,7 @@ } } -// // shared_ptr by pointer reference -// %typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) { swig_ruby_owntype newmem = {0, 0}; res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); From 31459d0cc070c294e6f7465ef68b262c634bbdbd Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Fri, 21 Apr 2017 22:56:13 +0900 Subject: [PATCH 0492/2031] [ruby] use boost/shared_ptr and boost_shared_ptr.i. not use auto. --- .../test-suite/cpp11_shared_ptr_director.i | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/cpp11_shared_ptr_director.i index 0f0554134..0a8a2494f 100644 --- a/Examples/test-suite/cpp11_shared_ptr_director.i +++ b/Examples/test-suite/cpp11_shared_ptr_director.i @@ -1,10 +1,10 @@ %module(directors="1") "cpp11_shared_ptr_director" %{ -#include +#include %} -%include "std_shared_ptr.i"; +%include "boost_shared_ptr.i"; %shared_ptr(C); %feature("director") Base; @@ -18,18 +18,18 @@ struct C { struct Base { Base() {}; - virtual std::shared_ptr ret_c_shared_ptr() = 0; + virtual boost::shared_ptr ret_c_shared_ptr() = 0; virtual C ret_c_by_value() = 0; virtual int take_c_by_value(C c) = 0; - virtual int take_c_shared_ptr_by_value(std::shared_ptr c) = 0; - virtual int take_c_shared_ptr_by_ref(std::shared_ptr& c) = 0; - virtual int take_c_shared_ptr_by_pointer(std::shared_ptr* c) = 0; - virtual int take_c_shared_ptr_by_pointer_ref(std::shared_ptr*const&c) = 0; + virtual int take_c_shared_ptr_by_value(boost::shared_ptr c) = 0; + virtual int take_c_shared_ptr_by_ref(boost::shared_ptr& c) = 0; + virtual int take_c_shared_ptr_by_pointer(boost::shared_ptr* c) = 0; + virtual int take_c_shared_ptr_by_pointer_ref(boost::shared_ptr*const&c) = 0; virtual ~Base() {} }; int call_ret_c_shared_ptr(Base* b) { - std::shared_ptr ptr = b->ret_c_shared_ptr(); + boost::shared_ptr ptr = b->ret_c_shared_ptr(); if (ptr) { return ptr->get_m(); } else { @@ -48,42 +48,42 @@ int call_take_c_by_value(Base* b) { } int call_take_c_shared_ptr_by_value(Base* b) { - std::shared_ptr ptr(new C(6)); + boost::shared_ptr ptr(new C(6)); return b->take_c_shared_ptr_by_value(ptr); } int call_take_c_shared_ptr_by_value_with_null(Base* b) { - std::shared_ptr ptr; + boost::shared_ptr ptr; return b->take_c_shared_ptr_by_value(ptr); } int call_take_c_shared_ptr_by_ref(Base* b) { - std::shared_ptr ptr(new C(7)); + boost::shared_ptr ptr(new C(7)); return b->take_c_shared_ptr_by_ref(ptr); } int call_take_c_shared_ptr_by_ref_with_null(Base* b) { - std::shared_ptr ptr; + boost::shared_ptr ptr; return b->take_c_shared_ptr_by_ref(ptr); } int call_take_c_shared_ptr_by_pointer(Base* b) { - std::shared_ptr ptr(new C(8)); + boost::shared_ptr ptr(new C(8)); return b->take_c_shared_ptr_by_pointer(&ptr); } int call_take_c_shared_ptr_by_pointer_with_null(Base* b) { - std::shared_ptr ptr; + boost::shared_ptr ptr; return b->take_c_shared_ptr_by_pointer(&ptr); } int call_take_c_shared_ptr_by_pointer_ref(Base* b) { - auto ptr = new std::shared_ptr(new C(9)); + boost::shared_ptr *ptr = new boost::shared_ptr(new C(9)); return b->take_c_shared_ptr_by_pointer_ref(ptr); } int call_take_c_shared_ptr_by_pointer_ref_with_null(Base* b) { - auto ptr = new std::shared_ptr(); + boost::shared_ptr *ptr = new boost::shared_ptr(); return b->take_c_shared_ptr_by_pointer_ref(ptr); } From 093cf8d60f0622f66bfbddca75167d9160801502 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Apr 2017 19:28:08 +0100 Subject: [PATCH 0493/2031] Rename shared_ptr testcase --- CHANGES.current | 3 +++ ...1_shared_ptr_director.i => li_boost_shared_ptr_director.i} | 2 +- Examples/test-suite/ruby/Makefile.in | 2 +- ...irector_runme.rb => li_boost_shared_ptr_director_runme.rb} | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) rename Examples/test-suite/{cpp11_shared_ptr_director.i => li_boost_shared_ptr_director.i} (97%) rename Examples/test-suite/ruby/{cpp11_shared_ptr_director_runme.rb => li_boost_shared_ptr_director_runme.rb} (94%) diff --git a/CHANGES.current b/CHANGES.current index 9ea6662cc..e859072bd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.13 (in progress) ============================ +2017-04-21: tamuratak + [Ruby] #964 - Add shared_ptr director typemaps. + 2017-04-20: tamuratak [Ruby] #930, #937 - Fix containers of std::shared_ptr. Upcasting, const types (eg vector>) and NULL/nullptr support added. diff --git a/Examples/test-suite/cpp11_shared_ptr_director.i b/Examples/test-suite/li_boost_shared_ptr_director.i similarity index 97% rename from Examples/test-suite/cpp11_shared_ptr_director.i rename to Examples/test-suite/li_boost_shared_ptr_director.i index 0a8a2494f..4acfa1a5d 100644 --- a/Examples/test-suite/cpp11_shared_ptr_director.i +++ b/Examples/test-suite/li_boost_shared_ptr_director.i @@ -1,4 +1,4 @@ -%module(directors="1") "cpp11_shared_ptr_director" +%module(directors="1") "li_boost_shared_ptr_director" %{ #include diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 33f42a7fc..cc2ba1ed2 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -11,6 +11,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES = \ + li_boost_shared_ptr_director \ li_cstring \ li_factory \ li_std_functors \ @@ -34,7 +35,6 @@ CPP11_TEST_CASES = \ cpp11_hash_tables \ cpp11_shared_ptr_upcast \ cpp11_shared_ptr_const \ - cpp11_shared_ptr_director C_TEST_CASES += \ li_cstring \ diff --git a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb b/Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb similarity index 94% rename from Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb rename to Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb index 51b338aef..0f7f14b46 100644 --- a/Examples/test-suite/ruby/cpp11_shared_ptr_director_runme.rb +++ b/Examples/test-suite/ruby/li_boost_shared_ptr_director_runme.rb @@ -1,6 +1,6 @@ -require 'cpp11_shared_ptr_director' +require 'li_boost_shared_ptr_director' -include Cpp11_shared_ptr_director +include Li_boost_shared_ptr_director class Derived < Base From 28f7d61986e6afb2a5d52fec6a8b79cee6237a25 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Apr 2017 19:36:09 +0100 Subject: [PATCH 0494/2031] Bump version to 4.0.0 --- ANNOUNCE | 8 ++++---- CHANGES.current | 4 ++-- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index e0bd4d0f9..109cf9216 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 3.0.13 (in progress) *** +*** ANNOUNCE: SWIG 4.0.0 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-3.0.13, the latest SWIG release. +We're pleased to announce SWIG-4.0.0, the latest SWIG release. What is SWIG? ============= @@ -27,11 +27,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-3.0.13.tar.gz + http://prdownloads.sourceforge.net/swig/swig-4.0.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-3.0.13.zip + http://prdownloads.sourceforge.net/swig/swigwin-4.0.0.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES.current b/CHANGES.current index 46b32f24a..f01a29b96 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,8 +4,8 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 3.0.13 (in progress) -============================ +Version 4.0.0 (in progress) +=========================== 2017-04-21: tamuratak [Ruby] #964 - Add shared_ptr director typemaps. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index bdf590ac9..739170745 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-3.0 Documentation

    -Last update : SWIG-3.0.13 (in progress) +Last update : SWIG-4.0.0 (in progress)

    Sections

    diff --git a/README b/README index 5510e0ec3..649602048 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 3.0.13 (in progress) +Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index 4d9355cd0..7234a1fd4 100644 --- a/configure.ac +++ b/configure.ac @@ -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],[3.0.13],[http://www.swig.org]) +AC_INIT([swig],[4.0.0],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed From 43c3ca37678ed421f13d93a0394c32e9ce741576 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sat, 18 Feb 2017 21:30:17 +0900 Subject: [PATCH 0495/2031] [ruby] clarify dependency of fragments for unordered_set containers. --- Lib/ruby/std_unordered_multiset.i | 2 +- Lib/ruby/std_unordered_set.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/ruby/std_unordered_multiset.i b/Lib/ruby/std_unordered_multiset.i index 29fa73a98..181aa212d 100644 --- a/Lib/ruby/std_unordered_multiset.i +++ b/Lib/ruby/std_unordered_multiset.i @@ -4,7 +4,7 @@ %include -%fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") +%fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits") %{ namespace swig { template diff --git a/Lib/ruby/std_unordered_set.i b/Lib/ruby/std_unordered_set.i index 5279bbed5..3d4494351 100644 --- a/Lib/ruby/std_unordered_set.i +++ b/Lib/ruby/std_unordered_set.i @@ -4,7 +4,7 @@ %include -%fragment("StdUnorderedSetTraits","header",fragment="",fragment="StdSequenceTraits") +%fragment("StdUnorderedSetTraits","header",fragment="",fragment="StdSetTraits") %{ namespace swig { template From 70740c51d0323c874e898f1cf438cacb0ab496ab Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sat, 22 Apr 2017 16:32:52 +0900 Subject: [PATCH 0496/2031] [ruby] add simple tests for std unordered containers. --- Examples/test-suite/cpp11_std_unordered_map.i | 5 +++++ Examples/test-suite/cpp11_std_unordered_multimap.i | 7 +++++++ Examples/test-suite/cpp11_std_unordered_multiset.i | 5 +++++ Examples/test-suite/cpp11_std_unordered_set.i | 5 +++++ Examples/test-suite/ruby/Makefile.in | 4 ++++ 5 files changed, 26 insertions(+) create mode 100644 Examples/test-suite/cpp11_std_unordered_map.i create mode 100644 Examples/test-suite/cpp11_std_unordered_multimap.i create mode 100644 Examples/test-suite/cpp11_std_unordered_multiset.i create mode 100644 Examples/test-suite/cpp11_std_unordered_set.i diff --git a/Examples/test-suite/cpp11_std_unordered_map.i b/Examples/test-suite/cpp11_std_unordered_map.i new file mode 100644 index 000000000..56c4a5248 --- /dev/null +++ b/Examples/test-suite/cpp11_std_unordered_map.i @@ -0,0 +1,5 @@ +%module cpp11_std_unordered_map + +%include + +%template(UnorderedMapIntInt) std::unordered_map; diff --git a/Examples/test-suite/cpp11_std_unordered_multimap.i b/Examples/test-suite/cpp11_std_unordered_multimap.i new file mode 100644 index 000000000..8556b26b5 --- /dev/null +++ b/Examples/test-suite/cpp11_std_unordered_multimap.i @@ -0,0 +1,7 @@ +%module cpp11_std_unordered_multimap + +%include +%include + +%template(PairIntInt) std::pair; +%template(UnorderedMultiMapIntInt) std::unordered_multimap; diff --git a/Examples/test-suite/cpp11_std_unordered_multiset.i b/Examples/test-suite/cpp11_std_unordered_multiset.i new file mode 100644 index 000000000..c9907425e --- /dev/null +++ b/Examples/test-suite/cpp11_std_unordered_multiset.i @@ -0,0 +1,5 @@ +%module cpp11_std_unordered_multiset + +%include + +%template(UnorderedMultiSetInt) std::unordered_multiset; diff --git a/Examples/test-suite/cpp11_std_unordered_set.i b/Examples/test-suite/cpp11_std_unordered_set.i new file mode 100644 index 000000000..f5652cb88 --- /dev/null +++ b/Examples/test-suite/cpp11_std_unordered_set.i @@ -0,0 +1,5 @@ +%module cpp11_std_unordered_set + +%include + +%template(UnorderedSetInt) std::unordered_set; diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index cc2ba1ed2..0a0e82fc0 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -35,6 +35,10 @@ CPP11_TEST_CASES = \ cpp11_hash_tables \ cpp11_shared_ptr_upcast \ cpp11_shared_ptr_const \ + cpp11_std_unordered_map \ + cpp11_std_unordered_multimap \ + cpp11_std_unordered_set \ + cpp11_std_unordered_multiset C_TEST_CASES += \ li_cstring \ From db11e82896753bc1c3c8ba78c6a402587c5f6921 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 Apr 2017 20:45:01 +0100 Subject: [PATCH 0497/2031] Makefile cosmetics --- Examples/test-suite/ruby/Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index f04e3a425..a34e55f71 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -27,9 +27,9 @@ CPP_TEST_CASES = \ ruby_naming \ ruby_track_objects \ ruby_track_objects_directors \ - std_containers -# ruby_li_std_speed -# stl_new + std_containers \ +# ruby_li_std_speed \ +# stl_new \ CPP11_TEST_CASES = \ cpp11_hash_tables \ From 7b9d94db2e0db0b3eb7c30edd17fea5bb1926c76 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Apr 2017 07:29:54 +0100 Subject: [PATCH 0498/2031] Fix Lua warning for missing (SWIGTYPE CLASS::*) typemaps for C wrappers --- Lib/lua/luatypemaps.swg | 2 -- 1 file changed, 2 deletions(-) diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index c2dfcae41..4c68d1d1d 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -235,7 +235,6 @@ $1=($1_ltype)&temp;%} // so the standard wrapping cannot be done // nor can you cast a member function pointer to a void* (obviously) // therefore a special wrapping functions SWIG_ConvertMember() & SWIG_NewMemberObj() were written -#ifdef __cplusplus %typemap(in,checkfn="lua_isuserdata") SWIGTYPE (CLASS::*) %{ if (!SWIG_IsOK(SWIG_ConvertMember(L,$input,(void*)(&$1),sizeof($type),$descriptor))) @@ -246,7 +245,6 @@ $1=($1_ltype)&temp;%} %{ SWIG_NewMemberObj(L,(void*)(&$1),sizeof($type),$descriptor); SWIG_arg++; %} -#endif // void (must be empty without the SWIG_arg++) From 34dee11d1d70e614b95eb19463a36d627d1b5c00 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Apr 2017 07:34:54 +0100 Subject: [PATCH 0499/2031] Add changes file entry for Lua warning fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f01a29b96..5f1a67771 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-04-25: jleveque + [Lua] #959 - Fix Visual Studio C4244 conversion warnings in Lua wrappers. + 2017-04-21: tamuratak [Ruby] #964 - Add shared_ptr director typemaps. From 7ad8ac92c0d6b9034303dedd1c2d0319dbd549d8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Apr 2017 18:06:57 +0100 Subject: [PATCH 0500/2031] Test c++11 unordered containers in Python --- Examples/test-suite/python/Makefile.in | 7 ++- .../python/cpp11_hash_tables_runme.py | 51 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/python/cpp11_hash_tables_runme.py diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 6d073a101..b6da00aa5 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -73,18 +73,21 @@ CPP_TEST_CASES += \ simutry \ std_containers \ swigobject \ - template_matrix + template_matrix \ # li_std_carray # director_profile # python_pybuf +CPP11_TEST_CASES = \ + cpp11_hash_tables \ + C_TEST_CASES += \ file_test \ li_cstring \ li_cwstring \ python_nondynamic \ - python_varargs_typemap + python_varargs_typemap \ # # This test only works with modern C compilers diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py new file mode 100644 index 000000000..39388fd20 --- /dev/null +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -0,0 +1,51 @@ +import cpp11_hash_tables + +def swig_assert_equal(a, b): + if a != b: + raise RuntimeError(str(a) + " != " + str(b)) + +for x in [cpp11_hash_tables.MapIntInt({1:7}), + cpp11_hash_tables.MultiMapIntInt({1:7}), + cpp11_hash_tables.UnorderedMapIntInt({1:7}), + cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: + + swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)]) + + swig_assert_equal(x[1], 7) + swig_assert_equal(2 in x, False) + x[2] = 9 + swig_assert_equal(x[2], 9) + del x[2] + swig_assert_equal(2 in x, False) + swig_assert_equal(x.empty(), False) + del x[1] + swig_assert_equal(x.empty(), True) + swig_assert_equal(1 in x, False) + +for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), + cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: + x[1] = 9 + swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) +# Is this broken?... +# swig_assert_equal(sorted([v for v in x[1]]), [7, 9]) + +for x in [cpp11_hash_tables.SetInt([1]), + cpp11_hash_tables.MultiSetInt([1]), + cpp11_hash_tables.UnorderedSetInt([1]), + cpp11_hash_tables.UnorderedMultiSetInt([1])]: + + swig_assert_equal([e for e in x], [1]) + + swig_assert_equal(1 in x, True) + swig_assert_equal(2 in x, False) + x.append(2) + swig_assert_equal(2 in x, True) + x.erase(2) + swig_assert_equal(x.empty(), False) + x.erase(1) + swig_assert_equal(x.empty(), True) + +for x in [cpp11_hash_tables.MultiSetInt([1]), + cpp11_hash_tables.UnorderedMultiSetInt([1])]: + x.append(1) + swig_assert_equal(x.count(1), 2) From 624ec3e1b7dd8908b37ee86bce6f60423c915bc5 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Tue, 25 Apr 2017 07:09:18 +0100 Subject: [PATCH 0501/2031] Fix bug with comments inline in macros - commit fixes #974 --- Source/Preprocessor/cpp.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 12d27c316..491eb8a96 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -607,6 +607,23 @@ static List *find_args(String *s, int ismacro, String *macro_name) { skip_tochar(s, '\'', str); c = Getc(s); continue; + } else if (c == '/') { + /* Ensure comments are ignored by eating up the characters */ + c = Getc(s); + if (c == '*') { + while ((c = Getc(s)) != EOF) { + if (c == '*') { + c = Getc(s); + if (c == '/' || c == EOF) + break; + } + } + c = Getc(s); + continue; + } + /* ensure char is available in the stream as this was not a comment*/ + Ungetc(c, s); + c = '/'; } if ((c == ',') && (level == 0)) break; From 956495dd47d3f1eec5da67befbf76b3ec79b5489 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 27 Apr 2017 19:45:19 +0100 Subject: [PATCH 0502/2031] Add testcase for macros with commas in comment --- CHANGES.current | 3 +++ Examples/test-suite/preproc.i | 17 +++++++++++++++++ Examples/test-suite/python/preproc_runme.py | 3 +++ 3 files changed, 23 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f01a29b96..1513eb33a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-04-27: redbrain + Issue #974, Patch #976 - Fix preprocessor handling of macros with commas in a comment. + 2017-04-21: tamuratak [Ruby] #964 - Add shared_ptr director typemaps. diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index f236bfdff..8ed8c1a09 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -370,3 +370,20 @@ int methodX(int x); int methodX(int x) { return x+100; } %} +// Comma in macro - Github issue #974 +%inline %{ +#define __attribute__(x) +#define TCX_PACKED(d) d __attribute__ ((__packed__)) + +TCX_PACKED (typedef struct tcxMessageTestImpl +{ + int mHeader; /**< comment */ +}) tcxMessageTest; + + +TCX_PACKED (typedef struct tcxMessageBugImpl +{ + int mBid; /**< Bid price and size, check PresentMap if available in message */ +}) tcxMessageBug; +%} + diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py index 99a6d0307..071362bc3 100644 --- a/Examples/test-suite/python/preproc_runme.py +++ b/Examples/test-suite/python/preproc_runme.py @@ -14,3 +14,6 @@ if 2 * preproc.one != preproc.two: if preproc.methodX(99) != 199: raise RuntimeError + +t1 = preproc.tcxMessageTest() +t2 = preproc.tcxMessageBug() From b4efa7b16e4a8cdb28a28ccecb9e77179673665e Mon Sep 17 00:00:00 2001 From: Christophe Duvernois Date: Thu, 27 Apr 2017 23:35:05 +0200 Subject: [PATCH 0503/2031] #526 : propagate c++11 noexcept to director classes test case --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_directors.i | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 Examples/test-suite/cpp11_directors.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index f9fe04383..18c00e750 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -543,6 +543,7 @@ CPP11_TEST_CASES += \ cpp11_default_delete \ cpp11_delegating_constructors \ cpp11_director_enums \ + cpp11_directors \ cpp11_explicit_conversion_operators \ cpp11_final_override \ cpp11_function_objects \ diff --git a/Examples/test-suite/cpp11_directors.i b/Examples/test-suite/cpp11_directors.i new file mode 100644 index 000000000..4462c1d52 --- /dev/null +++ b/Examples/test-suite/cpp11_directors.i @@ -0,0 +1,20 @@ +%module(directors="1") cpp11_directors +%feature("director"); + +%{ + +class Foo { + public: + virtual ~Foo() noexcept {} + virtual int ping() noexcept = 0; + virtual int pong() noexcept = 0; +}; + +%} + +class Foo { + public: + virtual ~Foo() noexcept {} + virtual int ping() noexcept = 0; + virtual int pong() noexcept = 0; +}; \ No newline at end of file From 4777a0ad3c28a11ce11141aa8ff83457d5e0caf8 Mon Sep 17 00:00:00 2001 From: Christophe Duvernois Date: Tue, 25 Apr 2017 15:53:25 +0200 Subject: [PATCH 0504/2031] #526 : propagate c++11 noexcept to director classes --- Source/Modules/csharp.cxx | 9 ++++++++- Source/Modules/d.cxx | 9 ++++++++- Source/Modules/java.cxx | 9 ++++++++- Source/Modules/octave.cxx | 4 ++++ Source/Modules/perl5.cxx | 9 ++++++++- Source/Modules/php.cxx | 4 ++++ Source/Modules/python.cxx | 5 ++++- Source/Modules/ruby.cxx | 4 ++++ 8 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 423c5a451..154fadac5 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4102,6 +4102,10 @@ public: Delete(target); // Add any exception specifications to the methods in the director class + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; @@ -4419,7 +4423,10 @@ public: String *dirclassname = directorClassName(current_class); Wrapper *w = NewWrapper(); - if (Getattr(n, "throw")) { + if (Getattr(n, "noexcept")) { + Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname); + Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname); + } else if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); } else { diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index de7afdab1..05ca6c636 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2217,6 +2217,10 @@ public: Delete(target); // Add any exception specifications to the methods in the director class + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = NULL; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; @@ -2483,7 +2487,10 @@ public: String *dirclassname = directorClassName(current_class); Wrapper *w = NewWrapper(); - if (Getattr(n, "throw")) { + if (Getattr(n, "noexcept")) { + Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname); + Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname); + } else if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); } else { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 946962447..b380565b5 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4293,6 +4293,10 @@ public: } } + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; @@ -4671,7 +4675,10 @@ public: String *dirClassName = directorClassName(current_class); Wrapper *w = NewWrapper(); - if (Getattr(n, "throw")) { + if (Getattr(n, "noexcept")) { + Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirClassName); + Printf(w->def, "%s::~%s() noexcept {\n", dirClassName, dirClassName); + } else if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", dirClassName); Printf(w->def, "%s::~%s() throw () {\n", dirClassName, dirClassName); } else { diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index b977609a8..0130cedd8 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1321,6 +1321,10 @@ public: Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 406568b16..a7c7fa9ff 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2090,6 +2090,10 @@ public: Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { @@ -2486,7 +2490,10 @@ public: Delete(mangle); Delete(ptype); - if (Getattr(n, "throw")) { + if (Getattr(n, "noexcept")) { + Printf(f_directors_h, " virtual ~%s() noexcept;\n", DirectorClassName); + Printf(f_directors, "%s::~%s() noexcept {%s}\n\n", DirectorClassName, DirectorClassName, body); + } else if (Getattr(n, "throw")) { Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName); Printf(f_directors, "%s::~%s() throw () {%s}\n\n", DirectorClassName, DirectorClassName, body); } else { diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 295039ba1..f0e3ae2df 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2530,6 +2530,10 @@ done: Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5e058e773..8dcabb578 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -5366,8 +5366,11 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; - if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { Parm *p; int gencomma = 0; diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index b9ac11546..07c5797f8 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3112,6 +3112,10 @@ public: Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { From e13eaaae2118309af479333ab97244e8c28b5fd0 Mon Sep 17 00:00:00 2001 From: Christophe Duvernois Date: Fri, 28 Apr 2017 11:45:02 +0200 Subject: [PATCH 0505/2031] java : noexcept method can't raise Swig::DirectorException --- Source/Modules/java.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b380565b5..b814c1576 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4375,9 +4375,11 @@ public: Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_method_ids[%s], %s);\n", methop, imclass_name, methid, jupcall_args); + if (!Getattr(n, "noexcept")) { // Generate code to handle any Java exception thrown by director delegation directorExceptHandler(n, catches_list ? catches_list : throw_parm_list, w); - + } + if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); From 9dcf10138e5053d50a37a7837dc86e58d6b96dae Mon Sep 17 00:00:00 2001 From: Christophe Duvernois Date: Fri, 28 Apr 2017 11:45:36 +0200 Subject: [PATCH 0506/2031] csharp : noexcept method can't raise Swig::DirectorPureVirtualException --- Source/Modules/csharp.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 154fadac5..a8792f7ea 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -403,6 +403,7 @@ public: if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); + Printf(f_runtime, "#include \n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); @@ -3935,7 +3936,12 @@ public: } Delete(super_call); } else { - Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + if (Getattr(n, "noexcept")) { + Printf(w->code, " //can't throw exception here\n"); + Printf(w->code, " assert(0 && \"swig DirectorPureVirtualException %s::%s\");", SwigType_namestr(c_classname), SwigType_namestr(name)); + } else { + Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + } } if (!ignored_method) From 3adf88e9ef236ff2795bd1b69b240b6fd35e895b Mon Sep 17 00:00:00 2001 From: Nihal Date: Sun, 7 May 2017 17:49:02 +0530 Subject: [PATCH 0507/2031] Refactor to generate init section before the code. Prerequisite to address issue #360, feature request of adding extension version. This change has been taken from Sources/Modules/php.cxx - PHP7 Backend. --- Source/Modules/php5.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index bf3ce4fa4..e31b81ecb 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -294,7 +294,7 @@ public: f_runtime = NewStringEmpty(); /* sections of the output file */ - s_init = NewString("/* init section */\n"); + s_init = NewStringEmpty(); r_init = NewString("/* rinit section */\n"); s_shutdown = NewString("/* shutdown section */\n"); r_shutdown = NewString("/* rshutdown section */\n"); @@ -528,7 +528,14 @@ public: Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n"); Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); + /* Emit all of the code */ + Language::top(n); + + SwigPHP_emit_resource_registrations(); + /* start the init section */ + String * s_init_old = s_init; + s_init = NewString("/* init section */\n"); Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n"); Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n"); Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n"); @@ -562,11 +569,9 @@ public: * things are being called in the wrong order */ Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module); + Printv(s_init, s_init_old, NIL); + Delete(s_init_old); - /* Emit all of the code */ - Language::top(n); - - SwigPHP_emit_resource_registrations(); // Printv(s_init,s_resourcetypes,NIL); /* We need this after all classes written out by ::top */ Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); From eb9e72f3b259b299c966f5f02bf724ea82a2c126 Mon Sep 17 00:00:00 2001 From: Nihal Date: Mon, 8 May 2017 11:43:38 +0530 Subject: [PATCH 0508/2031] Add new pragma to specify version to PHP5 and PHP7 extensions. See issue #360, feature request to have version in php5 and php7 extensions. --- Source/Modules/php.cxx | 12 +++++++++++- Source/Modules/php5.cxx | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 295039ba1..4bc0eecd3 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -96,6 +96,7 @@ static String *all_cs_entry; static String *pragma_incl; static String *pragma_code; static String *pragma_phpinfo; +static String *pragma_version; static String *s_oowrappers; static String *s_fakeoowrappers; static String *s_phpclasses; @@ -359,6 +360,7 @@ public: /* sub-sections of the php file */ pragma_code = NewStringEmpty(); pragma_incl = NewStringEmpty(); + pragma_version = NULL; /* Initialize the rest of the module */ @@ -515,7 +517,11 @@ public: } else { Printf(s_init, " NULL, /* No MINFO code */\n"); } - Printf(s_init, " NO_VERSION_YET,\n"); + if (Len(pragma_version) > 0) { + Printf(s_init, " \"%s\",\n", pragma_version); + } else { + Printf(s_init, " NO_VERSION_YET,\n"); + } Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); Printf(s_init, "};\n"); Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); @@ -2007,6 +2013,10 @@ done: if (value) { Printf(pragma_phpinfo, "%s\n", value); } + } else if (Strcmp(type, "version") == 0) { + if (value) { + pragma_version = value; + } } else { Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); } diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index e31b81ecb..7726a2f6c 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -96,6 +96,7 @@ static String *all_cs_entry; static String *pragma_incl; static String *pragma_code; static String *pragma_phpinfo; +static String *pragma_version; static String *s_oowrappers; static String *s_fakeoowrappers; static String *s_phpclasses; @@ -391,6 +392,7 @@ public: /* sub-sections of the php file */ pragma_code = NewStringEmpty(); pragma_incl = NewStringEmpty(); + pragma_version = NULL; /* Initialize the rest of the module */ @@ -549,7 +551,11 @@ public: Printf(s_init, " PHP_RINIT(%s),\n", module); Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module); Printf(s_init, " PHP_MINFO(%s),\n", module); - Printf(s_init, " NO_VERSION_YET,\n"); + if (Len(pragma_version) > 0) { + Printf(s_init, " \"%s\",\n", pragma_version); + } else { + Printf(s_init, " NO_VERSION_YET,\n"); + } Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); Printf(s_init, "};\n"); Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); @@ -1993,6 +1999,10 @@ done: if (value) { Printf(pragma_phpinfo, "%s\n", value); } + } else if (Strcmp(type, "version") == 0) { + if (value) { + pragma_version = value; + } } else { Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); } From 7f72398eb690a143fb928068cb61dfaa23c22d7a Mon Sep 17 00:00:00 2001 From: Nihal Date: Mon, 8 May 2017 12:02:18 +0530 Subject: [PATCH 0509/2031] Add tests for PHP pragma version to both PHP5 and PHP7. Pragma version to specify version of PHP5 and PHP7 extensions. See issue #360. --- Examples/test-suite/php/Makefile.in | 1 + Examples/test-suite/php/php_pragma_runme.php | 12 ++++++++++++ Examples/test-suite/php5/Makefile.in | 1 + Examples/test-suite/php5/php_pragma_runme.php | 12 ++++++++++++ Examples/test-suite/php_pragma.i | 6 ++++++ 5 files changed, 32 insertions(+) create mode 100644 Examples/test-suite/php/php_pragma_runme.php create mode 100644 Examples/test-suite/php5/php_pragma_runme.php create mode 100644 Examples/test-suite/php_pragma.i diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index c554e2b17..64f0d1f9d 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -14,6 +14,7 @@ CPP_TEST_CASES += \ li_factory \ php_iterator \ php_namewarn_rename \ + php_pragma \ include $(srcdir)/../common.mk diff --git a/Examples/test-suite/php/php_pragma_runme.php b/Examples/test-suite/php/php_pragma_runme.php new file mode 100644 index 000000000..ae92f6818 --- /dev/null +++ b/Examples/test-suite/php/php_pragma_runme.php @@ -0,0 +1,12 @@ +getVersion(),"1.5==version(php_pragma)"); + +check::done(); + +?> + diff --git a/Examples/test-suite/php5/Makefile.in b/Examples/test-suite/php5/Makefile.in index 391ca2c53..179ce59d6 100644 --- a/Examples/test-suite/php5/Makefile.in +++ b/Examples/test-suite/php5/Makefile.in @@ -14,6 +14,7 @@ CPP_TEST_CASES += \ li_factory \ php_iterator \ php_namewarn_rename \ + php_pragma \ include $(srcdir)/../common.mk diff --git a/Examples/test-suite/php5/php_pragma_runme.php b/Examples/test-suite/php5/php_pragma_runme.php new file mode 100644 index 000000000..ae92f6818 --- /dev/null +++ b/Examples/test-suite/php5/php_pragma_runme.php @@ -0,0 +1,12 @@ +getVersion(),"1.5==version(php_pragma)"); + +check::done(); + +?> + diff --git a/Examples/test-suite/php_pragma.i b/Examples/test-suite/php_pragma.i new file mode 100644 index 000000000..4d14f1357 --- /dev/null +++ b/Examples/test-suite/php_pragma.i @@ -0,0 +1,6 @@ +// Test pragma of php - pragma version. + +%module php_pragma + +%pragma(php) version= "1.5" + From 21108781a7d5ccdece63513bab1028e4c6034ef5 Mon Sep 17 00:00:00 2001 From: Nihal Date: Mon, 8 May 2017 12:02:53 +0530 Subject: [PATCH 0510/2031] Add documentation and examples for php version pragma. Pragma version to specify versions for PHP5 and PHP7 extensions. See issue #360. --- Doc/Manual/Php.html | 9 +++++++++ Examples/php/pragmas/example.i | 1 + Examples/php/pragmas/runme.php | 1 + Examples/php5/pragmas/example.i | 1 + Examples/php5/pragmas/runme.php | 1 + 5 files changed, 13 insertions(+) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 52bedf87f..7d3d33ac1 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -820,6 +820,15 @@ Results in the following in "example.php" echo "example.php execution\n"; +

    +The version pragma can be used to add version to generated PHP extension module. The version is inserted in the zend_module_entry block. +

    + +
    +%module example
    +%pragma(php) version="1.5"
    +
    +

    The include pragma is a short cut to add include statements to the example.php file. diff --git a/Examples/php/pragmas/example.i b/Examples/php/pragmas/example.i index c7e8bf303..f9307a663 100644 --- a/Examples/php/pragmas/example.i +++ b/Examples/php/pragmas/example.i @@ -27,5 +27,6 @@ # This code is inserted into example.php echo \"this was php code\\n\"; " +%pragma(php) version="1.5" %pragma(php) phpinfo="php_info_print_table_start();" diff --git a/Examples/php/pragmas/runme.php b/Examples/php/pragmas/runme.php index 538548b6f..b99cf37a4 100644 --- a/Examples/php/pragmas/runme.php +++ b/Examples/php/pragmas/runme.php @@ -2,4 +2,5 @@ require "example.php"; +echo "Version - " . ((new ReflectionExtension('example'))->getVersion()); ?> diff --git a/Examples/php5/pragmas/example.i b/Examples/php5/pragmas/example.i index c7e8bf303..f9307a663 100644 --- a/Examples/php5/pragmas/example.i +++ b/Examples/php5/pragmas/example.i @@ -27,5 +27,6 @@ # This code is inserted into example.php echo \"this was php code\\n\"; " +%pragma(php) version="1.5" %pragma(php) phpinfo="php_info_print_table_start();" diff --git a/Examples/php5/pragmas/runme.php b/Examples/php5/pragmas/runme.php index 538548b6f..b99cf37a4 100644 --- a/Examples/php5/pragmas/runme.php +++ b/Examples/php5/pragmas/runme.php @@ -2,4 +2,5 @@ require "example.php"; +echo "Version - " . ((new ReflectionExtension('example'))->getVersion()); ?> From e8e56f74ca5b12ca335c6db7319fbc1e0fc1b387 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 May 2017 07:41:40 +0100 Subject: [PATCH 0511/2031] Fix thread race in director_thread test --- Examples/test-suite/director_thread.i | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 2732eb907..fa55540a0 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -17,7 +17,7 @@ #include #endif -#include +#include class Foo; extern "C" { @@ -28,8 +28,17 @@ extern "C" { void* working(void* t); pthread_t thread; #endif + static int thread_terminate = 0; - + static SwigExamples::CriticalSection critical_section; + int get_thread_terminate() { + SwigExamples::Lock lock(critical_section); + return thread_terminate; + } + void set_thread_terminate(int value) { + SwigExamples::Lock lock(critical_section); + thread_terminate = value; + } } %} @@ -55,7 +64,7 @@ extern "C" { } void stop() { - thread_terminate = 1; + set_thread_terminate(1); %#ifdef _WIN32 /*TODO(bhy) what to do for win32? */ %#else @@ -87,7 +96,7 @@ extern "C" { #endif { Foo* f = static_cast(t); - while ( ! thread_terminate ) { + while (!get_thread_terminate()) { MilliSecondSleep(50); f->do_foo(); } From be5d046f7dc1c761e0308e1c75f6286cd76cdff4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 May 2017 08:20:01 +0100 Subject: [PATCH 0512/2031] director_thread testcase improvements - Add missing threading constructs to director_thread test for Windows - pthreads tidy up --- Examples/test-suite/director_thread.i | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index fa55540a0..699ccf5c4 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -11,6 +11,7 @@ #ifdef _WIN32 #include #include +#include #else #include #include @@ -22,11 +23,11 @@ class Foo; extern "C" { #ifdef _WIN32 - unsigned int __stdcall working(void* t); - unsigned int thread_id(0); + static unsigned int __stdcall working(void* t); + static HANDLE thread_handle = 0; #else void* working(void* t); - pthread_t thread; + static pthread_t thread; #endif static int thread_terminate = 0; @@ -66,7 +67,8 @@ extern "C" { void stop() { set_thread_terminate(1); %#ifdef _WIN32 - /*TODO(bhy) what to do for win32? */ + WaitForSingleObject(thread_handle, INFINITE); + CloseHandle(thread_handle); %#else pthread_join(thread, NULL); %#endif @@ -74,9 +76,18 @@ extern "C" { void run() { %#ifdef _WIN32 - _beginthreadex(NULL,0,working,this,0,&thread_id); + int thread_id = 0; + thread_handle = (HANDLE)_beginthreadex(NULL,0,working,this,0,&thread_id); + if (thread_handle == 0) { + fprintf(stderr, "_beginthreadex failed in run()\n"); + assert(0); + } %#else - pthread_create(&thread,NULL,working,this); + int create = pthread_create(&thread,NULL,working,this); + if (create != 0) { + fprintf(stderr, "pthread_create failed in run()\n"); + assert(0); + } %#endif MilliSecondSleep(500); } @@ -100,11 +111,6 @@ extern "C" { 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; } } From e05412088fd5e4b8dc2c7354abe0aa4f86665574 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 May 2017 19:41:31 +0100 Subject: [PATCH 0513/2031] director_thread testcase fix --- Examples/test-suite/director_thread.i | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 699ccf5c4..260bce774 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -18,7 +18,8 @@ #include #endif -#include +#include +#include "swig_examples_lock.h" class Foo; extern "C" { @@ -76,7 +77,7 @@ extern "C" { void run() { %#ifdef _WIN32 - int thread_id = 0; + unsigned int thread_id = 0; thread_handle = (HANDLE)_beginthreadex(NULL,0,working,this,0,&thread_id); if (thread_handle == 0) { fprintf(stderr, "_beginthreadex failed in run()\n"); From e429a891c9bff73f5d549b51b3f6fe81e6767040 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 16:16:17 +0100 Subject: [PATCH 0514/2031] Revert "csharp : noexcept method can't raise Swig::DirectorPureVirtualException" This reverts commit 9dcf10138e5053d50a37a7837dc86e58d6b96dae. --- Source/Modules/csharp.cxx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index a8792f7ea..154fadac5 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -403,7 +403,6 @@ public: if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); - Printf(f_runtime, "#include \n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); @@ -3936,12 +3935,7 @@ public: } Delete(super_call); } else { - if (Getattr(n, "noexcept")) { - Printf(w->code, " //can't throw exception here\n"); - Printf(w->code, " assert(0 && \"swig DirectorPureVirtualException %s::%s\");", SwigType_namestr(c_classname), SwigType_namestr(name)); - } else { - Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); - } + Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } if (!ignored_method) From cedfbfbee87cefe5b402ef2360719bd86accb99e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 16:16:29 +0100 Subject: [PATCH 0515/2031] Revert "java : noexcept method can't raise Swig::DirectorException" This reverts commit e13eaaae2118309af479333ab97244e8c28b5fd0. --- Source/Modules/java.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b814c1576..b380565b5 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4375,11 +4375,9 @@ public: Printf(w->code, "jenv->%s(Swig::jclass_%s, Swig::director_method_ids[%s], %s);\n", methop, imclass_name, methid, jupcall_args); - if (!Getattr(n, "noexcept")) { // Generate code to handle any Java exception thrown by director delegation directorExceptHandler(n, catches_list ? catches_list : throw_parm_list, w); - } - + if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); From 971404485f559bf8dcdcf12d74411f63e439d5b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 16:59:36 +0100 Subject: [PATCH 0516/2031] php5: propagate c++11 noexcept to director classes --- Source/Modules/php5.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index bf3ce4fa4..188f287d5 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -2525,6 +2525,10 @@ done: Delete(target); // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } ParmList *throw_parm_list = 0; if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { From 07ab80b49e0b51931a7e309b8c62b72a459efe64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 17:01:15 +0100 Subject: [PATCH 0517/2031] Add raise methods for throwing c++ exceptions in C#, Java, D The director c++ exceptions are thrown in a helper method instead of in the director overloaded method. This circumvents compiler warnings about throwing exceptions when the method has an exception specification or noexcept. If the exception is thrown, abort will still be called! In Java, the "director:noexcept" typemap can be used to do something else. This typemap should be ported to the other languages too. --- Doc/Manual/Java.html | 16 ++++++++++++++-- Lib/csharp/director.swg | 4 ++++ Lib/d/director.swg | 4 ++++ Lib/java/director.swg | 4 ++++ Source/Modules/csharp.cxx | 2 +- Source/Modules/d.cxx | 2 +- Source/Modules/java.cxx | 2 +- 7 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index bd259e60d..c77724bf2 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3923,12 +3923,24 @@ is used in the feature code. Consider the following, which also happens to be th if ($error) { jenv->ExceptionClear(); $directorthrowshandlers - throw Swig::DirectorException(jenv, $error); + Swig::DirectorException::raise(jenv, $error); } %} +

    +where Swig::DirectorException::raise is a helper method in the DirectorException class to throw a C++ exception (implemented in director.swg): +

    + +
    +
    +    static void raise(JNIEnv *jenv, jthrowable throwable) {
    +      throw DirectorException(jenv, throwable);
    +    }
    +
    +
    +

    The code generated using the director:except feature replaces the $directorthrowshandlers special variable with the code in the "directorthrows" typemaps, for each and every exception defined for the method. @@ -3963,7 +3975,7 @@ if (swigerror) { throw std::out_of_range(Swig::JavaExceptionMessage(jenv, swigerror).message()); } - throw Swig::DirectorException(jenv, swigerror); + Swig::DirectorException::raise(jenv, swigerror); } diff --git a/Lib/csharp/director.swg b/Lib/csharp/director.swg index 3438f2bf0..5d2ab5d9b 100644 --- a/Lib/csharp/director.swg +++ b/Lib/csharp/director.swg @@ -41,6 +41,10 @@ namespace Swig { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempt to invoke pure virtual method ") + msg) { } + + static void raise(const char *msg) { + throw DirectorPureVirtualException(msg); + } }; } diff --git a/Lib/d/director.swg b/Lib/d/director.swg index a7d9c7688..02da0e0ac 100644 --- a/Lib/d/director.swg +++ b/Lib/d/director.swg @@ -40,6 +40,10 @@ namespace Swig { public: DirectorPureVirtualException(const char *msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) { } + + static void raise(const char *msg) { + throw DirectorPureVirtualException(msg); + } }; } diff --git a/Lib/java/director.swg b/Lib/java/director.swg index 355e62d67..abde72286 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -356,6 +356,10 @@ namespace Swig { } } + static void raise(JNIEnv *jenv, jthrowable throwable) { + throw DirectorException(jenv, throwable); + } + private: static char *copypath(const char *srcmsg) { char *target = copystr(srcmsg); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 154fadac5..c41a212e4 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3935,7 +3935,7 @@ public: } Delete(super_call); } else { - Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } if (!ignored_method) diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 05ca6c636..36216b75e 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2077,7 +2077,7 @@ public: } Delete(super_call); } else { - Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } if (!ignored_method) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index b380565b5..e53cf1576 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4490,7 +4490,7 @@ public: Printf(directorexcept, "jthrowable $error = jenv->ExceptionOccurred();\n"); Printf(directorexcept, "if ($error) {\n"); Printf(directorexcept, " jenv->ExceptionClear();$directorthrowshandlers\n"); - Printf(directorexcept, " throw Swig::DirectorException(jenv, $error);\n"); + Printf(directorexcept, " Swig::DirectorException::raise(jenv, $error);\n"); Printf(directorexcept, "}\n"); } else { directorexcept = Copy(directorexcept); From 1416a158f04733cc638bfbba1b260a9a790e5942 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 17:33:07 +0100 Subject: [PATCH 0518/2031] changes file entry for noexcept on director methods --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 7e579f911..d6104c02c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-13: yag00 + Patch #975 - Add support for noexcept on director methods. + 2017-04-27: redbrain Issue #974, Patch #976 - Fix preprocessor handling of macros with commas in a comment. From 731f175d21c04aab3ec7ca074595280ca5a9529f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 17:46:01 +0100 Subject: [PATCH 0519/2031] propagate c++11 noexcept to director classes for Go --- Source/Modules/go.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 4927326f2..bcae168f0 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -5492,6 +5492,8 @@ private: *--------------------------------------------------------------------*/ String *buildThrow(Node *n) { + if (Getattr(n, "noexcept")) + return NewString("noexcept"); ParmList *throw_parm_list = Getattr(n, "throws"); if (!throw_parm_list && !Getattr(n, "throw")) return NULL; From ace88b45a0ba98248e77883e3d1045f9deb5e1cc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 18:15:55 +0100 Subject: [PATCH 0520/2031] Expand c++11 and c++14 Travis testing Add testing for Go, Perl, PHP, Tcl --- .travis.yml | 32 +++++++++++++++++++ .../test-suite/cpp11_raw_string_literals.i | 2 ++ 2 files changed, 34 insertions(+) diff --git a/.travis.yml b/.travis.yml index dce67cee7..d147114b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -224,10 +224,22 @@ matrix: env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=go SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=perl5 SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty + - os: linux + env: SWIGLANG=php VER=7.1 SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required @@ -236,14 +248,30 @@ matrix: env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=tcl SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=csharp SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=go SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=perl5 SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + sudo: required + dist: trusty + - os: linux + env: SWIGLANG=php VER=7.1 SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required @@ -252,6 +280,10 @@ matrix: env: SWIGLANG=ruby SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=tcl SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + sudo: required + dist: trusty - compiler: gcc os: osx env: SWIGLANG= diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i index 6fd13a0d0..1dea90e0c 100644 --- a/Examples/test-suite/cpp11_raw_string_literals.i +++ b/Examples/test-suite/cpp11_raw_string_literals.i @@ -17,7 +17,9 @@ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) hh; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ii; +#if defined(SWIGTCL) || defined(SWIGCSHARP) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGPYTHON) || defined(SWIGJAVA) %include +#endif %inline %{ #include From ebd37155a81fd0c9504522e43cbdaf38312a132c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 22:40:59 +0100 Subject: [PATCH 0521/2031] Fix potential use of uninitialized variables in directors --- Source/Modules/go.cxx | 14 +++++++++++++- Source/Modules/ocaml.cxx | 16 +++++++++++++--- Source/Modules/octave.cxx | 18 +++++++++++++----- Source/Modules/perl5.cxx | 18 ++++++++++++++---- Source/Modules/php.cxx | 12 ++++++++++-- Source/Modules/php5.cxx | 12 ++++++++++-- Source/Modules/python.cxx | 12 ++++++++++-- Source/Modules/ruby.cxx | 16 +++++++++++++--- 8 files changed, 96 insertions(+), 22 deletions(-) diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index bcae168f0..1512834f9 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -5058,7 +5058,19 @@ private: Printv(w->def, " {\n", NULL); if (SwigType_type(result) != T_VOID) { - Wrapper_add_local(w, "c_result", SwigType_lstr(result, "c_result")); + if (!SwigType_isclass(result)) { + if (!(SwigType_ispointer(result) || SwigType_isreference(result))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(result, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(result, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(result, "c_result"), "= 0", NIL); + } + } else { + String *cres = SwigType_lstr(result, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); + } } if (!is_ignored) { diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 73dd14f96..15a13f5ec 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1429,9 +1429,19 @@ public: * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { + String *cres = SwigType_lstr(returntype, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); } } diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 0130cedd8..e64a0779f 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1359,11 +1359,19 @@ public: // declare method return value // if the return value is a reference or const reference, a specialized typemap must // handle it, including declaration of c_result ($result). - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { - String *cres = SwigType_lstr(returntype, "c_result"); - Printf(w->code, "%s;\n", cres); - Delete(cres); + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { + String *cres = SwigType_lstr(returntype, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); } } diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index a7c7fa9ff..e46761028 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2130,10 +2130,20 @@ public: * handle it, including declaration of c_result ($result). */ if (!is_void) { - if (!(ignored_method && !pure_virtual)) { - String *cres = SwigType_lstr(returntype, "c_result"); - Printf(w->code, "%s;\n", cres); - Delete(cres); + if (!ignored_method || pure_virtual) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { + String *cres = SwigType_lstr(returntype, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); + } } if (!ignored_method) { String *pres = NewStringf("SV *%s", Swig_cresult_name()); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index f0e3ae2df..e6fbf47d7 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2569,8 +2569,16 @@ done: * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index 188f287d5..59d928c21 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -2566,8 +2566,16 @@ done: * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8dcabb578..2248ba920 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -5404,8 +5404,16 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { String *cres = SwigType_lstr(returntype, "c_result"); Printf(w->code, "%s;\n", cres); Delete(cres); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 07c5797f8..25988d6fb 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3154,9 +3154,19 @@ public: * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL); + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); + } else { + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); + } + } else { + String *cres = SwigType_lstr(returntype, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); } } From 320df846074e2ca24384d0e85b7f439eebc63cc0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 23:17:02 +0100 Subject: [PATCH 0522/2031] Add missing return for pure virtual director wrappers for D and C# --- Source/Modules/csharp.cxx | 6 +++++- Source/Modules/d.cxx | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index c41a212e4..89c47186e 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3826,7 +3826,7 @@ public: qualified_return = SwigType_rcaststr(returntype, "c_result"); - if (!is_void && !ignored_method) { + if (!is_void && (!ignored_method || pure_virtual)) { if (!SwigType_isclass(returntype)) { if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); @@ -3936,6 +3936,10 @@ public: Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + if (!is_void) + Printf(w->code, "return %s;", qualified_return); + else if (!ignored_method) + Printf(w->code, "return;\n"); } if (!ignored_method) diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 36216b75e..dd0fc371f 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -1975,7 +1975,7 @@ public: qualified_return = SwigType_rcaststr(returntype, "c_result"); - if (!is_void && !ignored_method) { + if (!is_void && (!ignored_method || pure_virtual)) { if (!SwigType_isclass(returntype)) { if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); @@ -2078,6 +2078,10 @@ public: Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); + if (!is_void) + Printf(w->code, "return %s;", qualified_return); + else if (!ignored_method) + Printf(w->code, "return;\n"); } if (!ignored_method) From d02302bd48927def5bb69de2645383968f849c46 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 May 2017 23:18:12 +0100 Subject: [PATCH 0523/2031] Remove php and perl5 C++11 and C++14 testing on Travis The language headers are not C++11 compatible --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index d147114b0..fd70c9160 100644 --- a/.travis.yml +++ b/.travis.yml @@ -232,14 +232,6 @@ matrix: env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty - - os: linux - env: SWIGLANG=perl5 SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 - sudo: required - dist: trusty - - os: linux - env: SWIGLANG=php VER=7.1 SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 - sudo: required - dist: trusty - os: linux env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required @@ -264,14 +256,6 @@ matrix: env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty - - os: linux - env: SWIGLANG=perl5 SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 - sudo: required - dist: trusty - - os: linux - env: SWIGLANG=php VER=7.1 SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 - sudo: required - dist: trusty - os: linux env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required From a271043555cdb94759ca12026ca530e782048f0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 14 May 2017 00:39:08 +0100 Subject: [PATCH 0524/2031] Fix warnings in Java OUTPUT and INOUT typemaps --- Examples/test-suite/java_director_typemaps.i | 2 +- Lib/java/typemaps.i | 36 +++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/java_director_typemaps.i b/Examples/test-suite/java_director_typemaps.i index 8d86c59a4..e7bc9a659 100644 --- a/Examples/test-suite/java_director_typemaps.i +++ b/Examples/test-suite/java_director_typemaps.i @@ -185,7 +185,7 @@ public: void etest() { bool boolarg_inout = false; - signed char signed_chararg_inout = 150; + signed char signed_chararg_inout = 111; unsigned char unsigned_chararg_inout = 150; short shortarg_inout = 150; diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index 4170915b3..1785d97ce 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -220,14 +220,14 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type { JNITYPE $1_jvalue; JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - $result = $1_jvalue; + $result = ($*1_ltype)$1_jvalue; } %typemap(directorargout, noblock=1) TYPE *OUTPUT { JNITYPE $1_jvalue; JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = $1_jvalue; + *$result = ($*1_ltype)$1_jvalue; } %typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; @@ -264,6 +264,21 @@ OUTPUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray); $1 = &temp; } +%typemap(directorargout, noblock=1) bool &OUTPUT +{ + jboolean $1_jvalue; + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + $result = $1_jvalue ? true : false; +} + +%typemap(directorargout, noblock=1) bool *OUTPUT +{ + jboolean $1_jvalue; + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = $1_jvalue ? true : false; +} + + /* Convert to BigInteger - byte array holds number in 2's complement big endian format */ /* Use first element in BigInteger array for output */ /* Overrides the typemap in the OUTPUT_TYPEMAP macro */ @@ -386,13 +401,13 @@ There are no char *INOUT typemaps, however you can apply the signed char * typem %typemap(directorargout, noblock=1) TYPE &INOUT { JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - $result = $1_jvalue; + $result = ($*1_ltype)$1_jvalue; } %typemap(directorargout, noblock=1) TYPE *INOUT { JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = $1_jvalue; + *$result = ($*1_ltype)$1_jvalue; } %typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; @@ -436,6 +451,19 @@ INOUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray); JCALL3(ReleaseBooleanArrayElements, jenv, $input , (jboolean *)jbtemp$argnum, 0); } +%typemap(directorargout, noblock=1) bool &INOUT +{ + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + $result = $1_jvalue ? true : false; +} + +%typemap(directorargout, noblock=1) bool *INOUT +{ + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = $1_jvalue ? true : false; +} + + /* Override the typemap in the INOUT_TYPEMAP macro for unsigned long long */ %typemap(in) unsigned long long *INOUT ($*1_ltype temp), unsigned long long &INOUT ($*1_ltype temp) { jobject bigint; From 6a3910690bef10fe45d780ad2ba22d393e55d425 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 14 May 2017 01:07:14 +0100 Subject: [PATCH 0525/2031] director_exception testcase warning fixes Fixes: 'function assumed not to throw an exception but does' --- Examples/test-suite/director_exception.i | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i index 0f87fb4ba..1ce14dedf 100644 --- a/Examples/test-suite/director_exception.i +++ b/Examples/test-suite/director_exception.i @@ -35,9 +35,9 @@ class DirectorMethodException: public Swig::DirectorException {}; #ifdef SWIGPHP %feature("director:except") { - if ($error == FAILURE) { - throw Swig::DirectorMethodException(); - } + if ($error == FAILURE) { + Swig::DirectorMethodException::raise("$symname"); + } } %exception { @@ -50,9 +50,9 @@ class DirectorMethodException: public Swig::DirectorException {}; #ifdef SWIGPYTHON %feature("director:except") { - if ($error != NULL) { - throw Swig::DirectorMethodException(); - } + if ($error != NULL) { + Swig::DirectorMethodException::raise("$symname"); + } } %exception { @@ -88,7 +88,7 @@ class DirectorMethodException: public Swig::DirectorException {}; #ifdef SWIGRUBY %feature("director:except") { - throw Swig::DirectorMethodException($error); + Swig::DirectorMethodException::raise($error); } %exception { From 37d90ca3ec5a6edd1c0a83fa9f7ccce66682a5a3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 May 2017 07:47:22 +0100 Subject: [PATCH 0526/2031] Appveyor testing- install python-devel package Needed for newer versions of cygwin on Appveyor in order to run Python tests --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ea01db0f8..74b1c045d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -79,7 +79,7 @@ install: - if "%OSVARIANT%"=="" bash -c "cl.exe /? 2>&1 | head -n 1" - if "%OSVARIANT%"=="" bash -c "which csc.exe" - if "%OSVARIANT%"=="" bash -c "csc.exe /? | head -n 1" -- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt" +- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt" - if "%OSVARIANT%"=="mingw" bash -c "pacman --noconfirm --sync mingw%MBITS%/mingw-w64-%MARCH%-pcre mingw%MBITS%/mingw-w64-%MARCH%-boost" - bash -c "which $CC" - bash -c "which $CXX" From 8f1ae7a8761a239b265ffae905e20f277f3b4283 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 16 May 2017 17:51:45 +1200 Subject: [PATCH 0527/2031] Add CHANGES.current entry for #970 --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index d6104c02c..aaa2e7c1f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-16: nihal95 + [PHP] Add %pragma version directive to allow the version of the + extension to be set. Patch #970, fixes #360. + 2017-05-13: yag00 Patch #975 - Add support for noexcept on director methods. From bb758d7810c833e18b95c7500753e0de2e7c8bfd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 May 2017 06:58:54 +0100 Subject: [PATCH 0528/2031] Use %naturalvar for C# std::complex wrappers --- Lib/csharp/std_complex.i | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index b5bdec60d..323b97a59 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -4,6 +4,8 @@ namespace std { +%naturalvar complex; + // An extremely simplified subset of std::complex<> which contains just the // methods we need. template @@ -19,28 +21,28 @@ public: } // namespace std %define swig_complex_typemaps(T) -%typemap(cstype) std::complex, std::complex*, const std::complex& "System.Numerics.Complex" +%typemap(cstype) std::complex, const std::complex& "System.Numerics.Complex" // The casts in "pre" are needed in order to allow creating std::complex // from System.Numerics.Complex, which always uses doubles. It relies on the // fact that the name of the C++ and C# float/double types are the same. %typemap(csin, pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" - ) std::complex, std::complex*, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" + ) std::complex, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" %typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { Complex_##T cppret = new Complex_##T($imcall, $owner);$excode return new System.Numerics.Complex(cppret.real(), cppret.imag()); } -%typemap(csvarin, excode=SWIGEXCODE2) std::complex*, const std::complex& %{ +%typemap(csvarin, excode=SWIGEXCODE2) const std::complex& %{ set { var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); $imcall;$excode } %} -%typemap(csvarout, excode=SWIGEXCODE2) std::complex*, const std::complex& %{ +%typemap(csvarout, excode=SWIGEXCODE2) const std::complex& %{ get { var cppret = new Complex_##T($imcall, $owner);$excode return new System.Numerics.Complex(cppret.real(), cppret.imag()); From 8c13ee2411aa8d3d822897f831b4c497cddc2cd7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 May 2017 07:10:43 +0100 Subject: [PATCH 0529/2031] C# std::complex wrappers SwigValueWrapper fix Fix std::complex constructor declaration to stop SwigValueWrapper from being generated --- Lib/csharp/std_complex.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index 323b97a59..ac30e1692 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -12,7 +12,7 @@ template class complex { public: - complex(T re, T im); + complex(T re = T(), T im = T()); T real() const; T imag() const; From e11e1c4cb8fc9be7f46160ba52cdad8acc433ea7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 May 2017 08:15:01 +0100 Subject: [PATCH 0530/2031] C# std::complex wrappers marshalling by value Change the wrapping to marshall directly to the .net System.Numerics.Complex type instead of using an intermediate std::complex .net type. --- Lib/csharp/std_complex.i | 57 ++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index ac30e1692..0f5b6b921 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -2,54 +2,67 @@ #include %} +%fragment("SwigSystemNumericsComplex", "header") { +// Identical to the layout of System.Numerics.Complex, but does assume that it is +// LayoutKind.Sequential on the managed side +struct SwigSystemNumericsComplex { + double real; + double imag; + SwigSystemNumericsComplex(double r = 0.0, double i = 0.0) : real(r), imag(i) {} +}; +} + namespace std { %naturalvar complex; -// An extremely simplified subset of std::complex<> which contains just the -// methods we need. template class complex { public: complex(T re = T(), T im = T()); - - T real() const; - T imag() const; }; -} // namespace std +} %define swig_complex_typemaps(T) -%typemap(cstype) std::complex, const std::complex& "System.Numerics.Complex" +%typemap(ctype, fragment="SwigSystemNumericsComplex") std::complex, const std::complex & "SwigSystemNumericsComplex" +%typemap(imtype) std::complex, const std::complex & "System.Numerics.Complex" +%typemap(cstype) std::complex, const std::complex & "System.Numerics.Complex" -// The casts in "pre" are needed in order to allow creating std::complex -// from System.Numerics.Complex, which always uses doubles. It relies on the -// fact that the name of the C++ and C# float/double types are the same. -%typemap(csin, - pre=" var cpp$csinput = new Complex_" #T "((" #T ")$csinput.Real, (" #T ")$csinput.Imaginary);" - ) std::complex, const std::complex& "Complex_" #T ".getCPtr(cpp$csinput)" +%typemap(in) std::complex($*1_ltype temp), const std::complex &($*1_ltype temp) +%{temp = std::complex< double >($input.real, $input.imag); + $1 = &temp;%} -%typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex& { - Complex_##T cppret = new Complex_##T($imcall, $owner);$excode - return new System.Numerics.Complex(cppret.real(), cppret.imag()); +%typemap(out) std::complex +%{$result = SwigSystemNumericsComplex($1.real(), $1.imag());%} + +%typemap(out) const std::complex & +%{$result = SwigSystemNumericsComplex($1->real(), $1->imag());%} + +%typemap(cstype) std::complex, const std::complex & "System.Numerics.Complex" + +%typemap(csin) std::complex, const std::complex & "$csinput" + +%typemap(csout, excode=SWIGEXCODE) std::complex, const std::complex & { + System.Numerics.Complex ret = $imcall;$excode + return ret; } -%typemap(csvarin, excode=SWIGEXCODE2) const std::complex& %{ +%typemap(csvarin, excode=SWIGEXCODE2) const std::complex & %{ set { - var cppvalue = new Complex_##T((T)value.Real, (T)value.Imaginary); $imcall;$excode } %} -%typemap(csvarout, excode=SWIGEXCODE2) const std::complex& %{ +%typemap(csvarout, excode=SWIGEXCODE2) const std::complex & %{ get { - var cppret = new Complex_##T($imcall, $owner);$excode - return new System.Numerics.Complex(cppret.real(), cppret.imag()); + System.Numerics.Complex ret = $imcall;$excode + return ret; } %} -%template(Complex_##T) std::complex; +%template() std::complex; %enddef // By default, typemaps for both std::complex and std::complex From 57ec5ec056b3e0b806a3e46d822354486cd94f78 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 May 2017 19:52:39 +0100 Subject: [PATCH 0531/2031] Fix linkage problems in C# std::complex wrappers Fix warnings and subsequent exception trying to use wrappers: Warning C4190: 'CSharp_complextestNamespace_VectorStdCplx_getitemcopy' has C-linkage specified, but returns UDT 'SwigSystemNumericsComplex' which is incompatible with C Rename swig_complex_typemaps macro to SWIG_COMPLEX_TYPEMAPS --- Lib/csharp/std_complex.i | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index 0f5b6b921..960a4b9b4 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -3,15 +3,23 @@ %} %fragment("SwigSystemNumericsComplex", "header") { +extern "C" { // Identical to the layout of System.Numerics.Complex, but does assume that it is // LayoutKind.Sequential on the managed side struct SwigSystemNumericsComplex { double real; double imag; - SwigSystemNumericsComplex(double r = 0.0, double i = 0.0) : real(r), imag(i) {} }; } +SWIGINTERN SwigSystemNumericsComplex SwigCreateSystemNumericsComplex(double real, double imag) { + SwigSystemNumericsComplex cpx; + cpx.real = real; + cpx.imag = imag; + return cpx; +} +} + namespace std { %naturalvar complex; @@ -25,7 +33,7 @@ public: } -%define swig_complex_typemaps(T) +%define SWIG_COMPLEX_TYPEMAPS(T) %typemap(ctype, fragment="SwigSystemNumericsComplex") std::complex, const std::complex & "SwigSystemNumericsComplex" %typemap(imtype) std::complex, const std::complex & "System.Numerics.Complex" %typemap(cstype) std::complex, const std::complex & "System.Numerics.Complex" @@ -34,11 +42,11 @@ public: %{temp = std::complex< double >($input.real, $input.imag); $1 = &temp;%} -%typemap(out) std::complex -%{$result = SwigSystemNumericsComplex($1.real(), $1.imag());%} +%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") std::complex +%{$result = SwigCreateSystemNumericsComplex($1.real(), $1.imag());%} -%typemap(out) const std::complex & -%{$result = SwigSystemNumericsComplex($1->real(), $1->imag());%} +%typemap(out, null="SwigCreateSystemNumericsComplex(0.0, 0.0)") const std::complex & +%{$result = SwigCreateSystemNumericsComplex($1->real(), $1->imag());%} %typemap(cstype) std::complex, const std::complex & "System.Numerics.Complex" @@ -69,9 +77,9 @@ public: // are defined, but one of them can be disabled by predefining the // corresponding symbol before including this file. #ifndef SWIG_NO_STD_COMPLEX_DOUBLE -swig_complex_typemaps(double) +SWIG_COMPLEX_TYPEMAPS(double) #endif #ifndef SWIG_NO_STD_COMPLEX_FLOAT -swig_complex_typemaps(float) +SWIG_COMPLEX_TYPEMAPS(float) #endif From fb941315c1247696b69b9188104d73afca285a08 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 May 2017 20:24:49 +0100 Subject: [PATCH 0532/2031] Add header to std_complex.i --- Lib/csharp/std_complex.i | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/csharp/std_complex.i b/Lib/csharp/std_complex.i index 960a4b9b4..e69d17067 100644 --- a/Lib/csharp/std_complex.i +++ b/Lib/csharp/std_complex.i @@ -1,3 +1,10 @@ +/* ----------------------------------------------------------------------------- + * std_complex.i + * + * Typemaps for handling std::complex and std::complex as a .NET + * System.Numerics.Complex type. Requires .NET 4 minimum. + * ----------------------------------------------------------------------------- */ + %{ #include %} From ed54cc904c4f85eaf1ceb18278c02049784218de Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Fri, 19 May 2017 17:16:08 +0200 Subject: [PATCH 0533/2031] Fix E731: do not assign a lambda expression https://www.python.org/dev/peps/pep-0008/#programming-recommendations --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 2248ba920..40a2d0f40 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -5033,7 +5033,7 @@ public: Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL); if (!have_pythonprepend(n) && !have_pythonappend(n)) { if (proxydel) { - Printv(f_shadow, tab4, "__del__ = lambda self: None\n", NIL); + Printv(f_shadow, tab4, "def __del__(self):\n", tab8, "return None\n", NIL); } return SWIG_OK; } From 10172161bfc6728ea5719f30657ddbfed0e06bfa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 May 2017 15:38:38 +0100 Subject: [PATCH 0534/2031] Update STL library documentation --- Doc/Manual/Library.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 4bad9a03e..a800c2d73 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1385,16 +1385,24 @@ The following table shows which C++ classes are supported and the equivalent SWI SWIG Interface library file + std::array (C++11) array std_array.i std::auto_ptr memory std_auto_ptr.i + std::complex complex std_complex.i std::deque deque std_deque.i std::list list std_list.i std::map map std_map.i + std::multimap (C++11) multimap std_multimap.i + std::multiset (C++11) multiset std_multiset.i std::pair utility std_pair.i std::set set std_set.i std::string string std_string.i + std::unordered_map (C++11) unordered_map std_unordered_map.i + std::unordered_multimap (C++11) unordered_multimap std_unordered_multimap.i + std::unordered_multiset (C++11) unordered_multiset std_unordered_multiset.i + std::unordered_set (C++11) unordered_set std_unordered_set.i std::vector vector std_vector.i - std::array array (C++11) std_array.i - std::shared_ptr shared_ptr (C++11) std_shared_ptr.i + std::wstring wstring std_wstring.i + std::shared_ptr (C++11) shared_ptr std_shared_ptr.i From 3e47ed56144c536a4cfc8b8d5be8185cb724e1c3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 May 2017 15:54:27 +0100 Subject: [PATCH 0535/2031] changes file update --- CHANGES.current | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 04dc7313f..c85c15335 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-20: jschueller + [Python] #991 Fix E731 PEP8 warning: do not assign a lambda expression + 2017-05-16: nihal95 [PHP] Add %pragma version directive to allow the version of the extension to be set. Patch #970, fixes #360. @@ -43,7 +46,7 @@ Version 4.0.0 (in progress) on VALUE obj. 2017-03-17: vadz - [C#] Add support for std::complex + [C#] #947 Add support for std::complex 2017-03-17: wsfulton [Go] Fix handling of typedef'd function pointers and typedef'd member function pointers From 81ba06e59eda4a14b29695f4d2ecbbd377b6f051 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 May 2017 23:57:15 +0100 Subject: [PATCH 0536/2031] Fix Python negative unsigned default values Closes #993 --- CHANGES.current | 4 ++++ Examples/test-suite/default_args.i | 3 +++ Examples/test-suite/python/default_args_runme.py | 2 ++ Source/Modules/python.cxx | 2 ++ 4 files changed, 11 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index c85c15335..8a3bb9ce7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-21: wsfulton + [Python] #993 Fix handling of default -ve unsigned values, such as: + void f(unsigned = -1U); + 2017-05-20: jschueller [Python] #991 Fix E731 PEP8 warning: do not assign a lambda expression diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 39b499cf4..8828bfe04 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -156,6 +156,9 @@ int double_if_handle_is_null(int n, MyHandle h = 0) { return h ? n : 2*n; } int double_if_dbl_ptr_is_null(int n, double* null_by_default) { return null_by_default ? n : 2*n; } + + void defaulted1(unsigned offset = -1U) {} // minus unsigned! + void defaulted2(int offset = -1U) {} // minus unsigned! }; int Foo::bar = 1; int Foo::spam = 2; diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index 9d275e4a1..b7c4cb508 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -32,6 +32,8 @@ def run(module_name): f.newname() f.newname(1) + f.defaulted1() + f.defaulted2() if f.double_if_void_ptr_is_null(2, None) != 4: raise RuntimeError diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 40a2d0f40..cf81827cb 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2115,6 +2115,8 @@ public: case 'u': case 'U': + if (value < 0) + fail = true; break; default: From b90a8d7444360abbc338875eb69b52cfb2972b5a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 May 2017 17:28:13 +0100 Subject: [PATCH 0537/2031] Remove unnecessary dynamic_cast in C#/D/Java directors Also revert the removal of dynamic_cast in the csdowncast feature. --- CHANGES.current | 4 ++++ Source/Modules/csharp.cxx | 10 +++------- Source/Modules/d.cxx | 6 ++---- Source/Modules/java.cxx | 14 +++++--------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 8a3bb9ce7..70439b221 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-21: Sghirate + [Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable + non-RTTI compilation. + 2017-05-21: wsfulton [Python] #993 Fix handling of default -ve unsigned values, such as: void f(unsigned = -1U); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index bbc1b8ac6..fc682365c 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -2225,7 +2225,7 @@ public: Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); - Printf(dcast_wrap->code, " if (obj) director = static_cast(obj);\n"); + Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); Printf(dcast_wrap->code, " return jresult;\n"); Printf(dcast_wrap->code, "}\n"); @@ -3735,15 +3735,12 @@ public: Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); - } - else { + } else { Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName); } - // TODO: if statement not needed?? - Java too - Printf(code_wrap->code, " if (director) {\n"); - Printf(code_wrap->code, " director->swig_connect_director("); + Printf(code_wrap->code, " director->swig_connect_director("); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); @@ -3760,7 +3757,6 @@ public: Printf(code_wrap->def, ") {\n"); Printf(code_wrap->code, ");\n"); Printf(imclass_class_code, ");\n"); - Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index dd0fc371f..9a64543c3 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3567,10 +3567,9 @@ private: Printf(code_wrap->def, "SWIGEXPORT void D_%s(void *objarg, void *dobj", connect_name); Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName); - Printf(code_wrap->code, " if (director) {\n"); - Printf(code_wrap->code, " director->swig_connect_director(dobj"); + Printf(code_wrap->code, " director->swig_connect_director(dobj"); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); @@ -3584,7 +3583,6 @@ private: Printf(code_wrap->def, ") {\n"); Printf(code_wrap->code, ");\n"); Printf(im_dmodule_code, ") %s;\n", connect_name); - Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index e53cf1576..75fe61c2b 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3760,18 +3760,16 @@ public: Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); + Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); } else { Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name); Printf(code_wrap->code, " (void)jcls;\n"); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName); } - Printf(code_wrap->code, " if (director) {\n"); - Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), " + Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), " "(jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));\n"); - Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); @@ -3791,11 +3789,9 @@ public: "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {\n", jnipackage, jni_imclass_name, changeown_jnimethod_name); Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name); - Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); + Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName); Printf(code_wrap->code, " (void)jcls;\n"); - Printf(code_wrap->code, " if (director) {\n"); - Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n"); - Printf(code_wrap->code, " }\n"); + Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); From 05badeb1a4f5f743aa525d2e262c670bd745f544 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 21 May 2017 17:38:38 +0100 Subject: [PATCH 0538/2031] Remove undocumented features used in directors The jsdowncast and csdowncast features are not documented and I think these are a relic of something that was never finished. --- Source/Modules/csharp.cxx | 31 ------------------------------- Source/Modules/java.cxx | 33 --------------------------------- 2 files changed, 64 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index fc682365c..7b1fca071 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -2207,37 +2207,6 @@ public: --nesting_depth; } - /* Output the downcast method, if necessary. Note: There's no other really - good place to put this code, since Abstract Base Classes (ABCs) can and should have - downcasts, making the constructorHandler() a bad place (because ABCs don't get to - have constructors emitted.) */ - if (GetFlag(n, "feature:csdowncast")) { - String *downcast_method = Swig_name_member(getNSpace(), proxy_class_name, "SWIGDowncast"); - String *wname = Swig_name_wrapper(downcast_method); - - String *norm_name = SwigType_namestr(Getattr(n, "name")); - - Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); - - Wrapper *dcast_wrap = NewWrapper(); - - Printf(dcast_wrap->def, "SWIGEXPORT jobject SWIGSTDCALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); - Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); - Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); - Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); - Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); - Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); - Printf(dcast_wrap->code, " return jresult;\n"); - Printf(dcast_wrap->code, "}\n"); - - Wrapper_print(dcast_wrap, f_wrappers); - DelWrapper(dcast_wrap); - - Delete(norm_name); - Delete(wname); - Delete(downcast_method); - } - if (f_interface) { Printv(f_interface, interface_class_code, "}\n", NIL); addCloseNamespace(nspace, f_interface); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 75fe61c2b..bd6e005d2 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2272,39 +2272,6 @@ public: --nesting_depth; } - /* Output the downcast method, if necessary. Note: There's no other really - good place to put this code, since Abstract Base Classes (ABCs) can and should have - downcasts, making the constructorHandler() a bad place (because ABCs don't get to - have constructors emitted.) */ - if (GetFlag(n, "feature:javadowncast")) { - String *downcast_method = Swig_name_member(getNSpace(), getClassPrefix(), "SWIGDowncast"); - String *jniname = makeValidJniName(downcast_method); - String *wname = Swig_name_wrapper(jniname); - - String *norm_name = SwigType_namestr(Getattr(n, "name")); - - Printf(imclass_class_code, " public final static native %s %s(long cPtrBase, boolean cMemoryOwn);\n", proxy_class_name, downcast_method); - - Wrapper *dcast_wrap = NewWrapper(); - - Printf(dcast_wrap->def, "SWIGEXPORT jobject JNICALL %s(JNIEnv *jenv, jclass jcls, jlong jCPtrBase, jboolean cMemoryOwn) {", wname); - Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); - Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); - Printf(dcast_wrap->code, " %s *obj = *((%s **)&jCPtrBase);\n", norm_name, norm_name); - Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); - Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); - Printf(dcast_wrap->code, " return jresult;\n"); - Printf(dcast_wrap->code, "}\n"); - - Wrapper_print(dcast_wrap, f_wrappers); - DelWrapper(dcast_wrap); - - Delete(norm_name); - Delete(wname); - Delete(jniname); - Delete(downcast_method); - } - if (f_interface) { Printv(f_interface, interface_class_code, "}\n", NIL); Delete(f_interface); From 98e67539ddbebc7461b2ece58149ac123e7a4835 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 May 2017 19:15:39 +0100 Subject: [PATCH 0539/2031] Director testcase cosmetic fixes --- .../test-suite/li_boost_shared_ptr_director.i | 8 ++--- Lib/java/boost_shared_ptr.i | 29 +++++++++++++++++++ Lib/java/java.swg | 2 +- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/li_boost_shared_ptr_director.i b/Examples/test-suite/li_boost_shared_ptr_director.i index 4acfa1a5d..8f36bf31c 100644 --- a/Examples/test-suite/li_boost_shared_ptr_director.i +++ b/Examples/test-suite/li_boost_shared_ptr_director.i @@ -10,14 +10,14 @@ %inline %{ struct C { - C() : m(1) {}; - C(int n) : m(n) {}; - int get_m() { return m; }; + C() : m(1) {} + C(int n) : m(n) {} + int get_m() { return m; } int m; }; struct Base { - Base() {}; + Base() {} virtual boost::shared_ptr ret_c_shared_ptr() = 0; virtual C ret_c_by_value() = 0; virtual int take_c_by_value(C c) = 0; diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 33da61bf8..699a8a0a0 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -156,6 +156,10 @@ CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } + + CPTR_VISIBILITY void swigSetCMemOwn(boolean own) { + swigCMemOwn = own; + } %} // Derived proxy classes @@ -172,6 +176,11 @@ CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } + + CPTR_VISIBILITY void swigSetCMemOwn(boolean own) { + swigCMemOwnDerived = own; + super.swigSetCMemOwn(own); + } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { @@ -195,6 +204,26 @@ super.delete(); } +%typemap(directordisconnect, methodname="swigDirectorDisconnect") TYPE %{ + protected void $methodname() { + swigSetCMemOwn(false); + $jnicall; + } +%} + +%typemap(directorowner_release, methodname="swigReleaseOwnership") TYPE %{ + public void $methodname() { + swigSetCMemOwn(false); + $jnicall; + } +%} + +%typemap(directorowner_take, methodname="swigTakeOwnership") TYPE %{ + public void $methodname() { + swigSetCMemOwn(true); + $jnicall; + } +%} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 2ca426675..60ab7b049 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1260,7 +1260,7 @@ SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) */ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) -%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { +%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, OWNERSHIP, WEAKREF);") TYPENAME { this($imcall, OWNERSHIP);$directorconnect } %enddef From 41db45beff36a8f1391f3fa4be0ae6337df04dea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 May 2017 19:33:20 +0100 Subject: [PATCH 0540/2031] director runtime test for java --- .../li_boost_shared_ptr_director_runme.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Examples/test-suite/java/li_boost_shared_ptr_director_runme.java diff --git a/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java new file mode 100644 index 000000000..904eab387 --- /dev/null +++ b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java @@ -0,0 +1,60 @@ +public class li_boost_shared_ptr_runme { + + static { + try { + System.loadLibrary("li_boost_shared_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); + } + } + + private static void check(String got, String expected) { + if (!got.equals(expected)) + throw new RuntimeException("Failed, got: " + got + " expected: " + expected); + } + + public static void main(String argv[]) { + li_boost_shared_ptr_director_Derived a = li_boost_shared_ptr_director_Derived.new(false); + li_boost_shared_ptr_director_Derived b = li_boost_shared_ptr_director_Derived.new(true); + + check(call_ret_c_shared_ptr(a) == 1); + check(call_ret_c_shared_ptr(b) == -1); + check(call_ret_c_by_value(a) == 1); + + check(call_take_c_by_value(a) == 5); + check(call_take_c_shared_ptr_by_value(a) == 6); + check(call_take_c_shared_ptr_by_ref(a) == 7); + check(call_take_c_shared_ptr_by_pointer(a) == 8); + check(call_take_c_shared_ptr_by_pointer_ref(a) == 9); + + check(call_take_c_shared_ptr_by_value_with_null(a) == -2); + check(call_take_c_shared_ptr_by_ref_with_null(a) == -3); + check(call_take_c_shared_ptr_by_pointer_with_null(a) == -4); + check(call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -5); + + } +} + +class li_boost_shared_ptr_director_Derived extends li_boost_shared_ptr_director.Base { + + @Override + public String ping() { + return "li_boost_shared_ptr_director_MyBarFoo.ping()"; + } + + @Override + public String pong() { + return "li_boost_shared_ptr_director_MyBarFoo.pong();" + ping(); + } + + @Override + public String upcall(li_boost_shared_ptr_director.FooBar fooBarPtr) { + return "override;" + fooBarPtr.FooBarDo(); + } + + @Override + public li_boost_shared_ptr_director.Foo makeFoo() { + return new li_boost_shared_ptr_director.Foo(); + } +} From 4bf607589f821092f45742ef85b58b4818b60ab4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 May 2017 20:56:15 +0100 Subject: [PATCH 0541/2031] Fix Java shared_ptr and directors for derived classes java compilation error. For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other methods for controlling memory ownership. Closes #230 Closes #759 --- CHANGES.current | 8 +++ Examples/test-suite/director_smartptr.i | 8 ++- .../java/director_smartptr_runme.java | 29 +++++++++ .../li_boost_shared_ptr_director_runme.java | 60 +++++++++++++++++++ .../test-suite/li_boost_shared_ptr_director.i | 8 +-- Lib/java/boost_shared_ptr.i | 29 +++++++++ Lib/java/java.swg | 2 +- 7 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/java/li_boost_shared_ptr_director_runme.java diff --git a/CHANGES.current b/CHANGES.current index 70439b221..cd91b3607 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-23: wsfulton + [Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation + error. + + For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying + the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other + methods for controlling memory ownership. + 2017-05-21: Sghirate [Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable non-RTTI compilation. diff --git a/Examples/test-suite/director_smartptr.i b/Examples/test-suite/director_smartptr.i index 9d0be80f0..d016af17e 100644 --- a/Examples/test-suite/director_smartptr.i +++ b/Examples/test-suite/director_smartptr.i @@ -44,7 +44,6 @@ public: %include %shared_ptr(Foo) - %feature("director") Foo; class FooBar { @@ -72,5 +71,12 @@ public: static Foo* get_self(Foo *self_); }; +%shared_ptr(FooDerived) +%feature("director") FooDerived; + +%inline %{ +struct FooDerived : Foo { +}; +%} #endif diff --git a/Examples/test-suite/java/director_smartptr_runme.java b/Examples/test-suite/java/director_smartptr_runme.java index 710ece710..ba2bfc8c4 100644 --- a/Examples/test-suite/java/director_smartptr_runme.java +++ b/Examples/test-suite/java/director_smartptr_runme.java @@ -33,6 +33,12 @@ public class director_smartptr_runme { director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo(); check(myFoo2.pong(), "Foo::pong();Foo::ping()"); check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()"); + + director_smartptr.FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived(); + check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()"); + check(director_smartptr.FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()"); + check(director_smartptr.FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()"); + } } @@ -58,3 +64,26 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo { return new director_smartptr.Foo(); } } + +class director_smartptr_MyBarFooDerived extends director_smartptr.FooDerived { + + @Override + public String ping() { + return "director_smartptr_MyBarFooDerived.ping()"; + } + + @Override + public String pong() { + return "director_smartptr_MyBarFooDerived.pong();" + ping(); + } + + @Override + public String upcall(director_smartptr.FooBar fooBarPtr) { + return "overrideDerived;" + fooBarPtr.FooBarDo(); + } + + @Override + public director_smartptr.Foo makeFoo() { + return new director_smartptr.Foo(); + } +} diff --git a/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java new file mode 100644 index 000000000..904eab387 --- /dev/null +++ b/Examples/test-suite/java/li_boost_shared_ptr_director_runme.java @@ -0,0 +1,60 @@ +public class li_boost_shared_ptr_runme { + + static { + try { + System.loadLibrary("li_boost_shared_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); + } + } + + private static void check(String got, String expected) { + if (!got.equals(expected)) + throw new RuntimeException("Failed, got: " + got + " expected: " + expected); + } + + public static void main(String argv[]) { + li_boost_shared_ptr_director_Derived a = li_boost_shared_ptr_director_Derived.new(false); + li_boost_shared_ptr_director_Derived b = li_boost_shared_ptr_director_Derived.new(true); + + check(call_ret_c_shared_ptr(a) == 1); + check(call_ret_c_shared_ptr(b) == -1); + check(call_ret_c_by_value(a) == 1); + + check(call_take_c_by_value(a) == 5); + check(call_take_c_shared_ptr_by_value(a) == 6); + check(call_take_c_shared_ptr_by_ref(a) == 7); + check(call_take_c_shared_ptr_by_pointer(a) == 8); + check(call_take_c_shared_ptr_by_pointer_ref(a) == 9); + + check(call_take_c_shared_ptr_by_value_with_null(a) == -2); + check(call_take_c_shared_ptr_by_ref_with_null(a) == -3); + check(call_take_c_shared_ptr_by_pointer_with_null(a) == -4); + check(call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -5); + + } +} + +class li_boost_shared_ptr_director_Derived extends li_boost_shared_ptr_director.Base { + + @Override + public String ping() { + return "li_boost_shared_ptr_director_MyBarFoo.ping()"; + } + + @Override + public String pong() { + return "li_boost_shared_ptr_director_MyBarFoo.pong();" + ping(); + } + + @Override + public String upcall(li_boost_shared_ptr_director.FooBar fooBarPtr) { + return "override;" + fooBarPtr.FooBarDo(); + } + + @Override + public li_boost_shared_ptr_director.Foo makeFoo() { + return new li_boost_shared_ptr_director.Foo(); + } +} diff --git a/Examples/test-suite/li_boost_shared_ptr_director.i b/Examples/test-suite/li_boost_shared_ptr_director.i index 4acfa1a5d..8f36bf31c 100644 --- a/Examples/test-suite/li_boost_shared_ptr_director.i +++ b/Examples/test-suite/li_boost_shared_ptr_director.i @@ -10,14 +10,14 @@ %inline %{ struct C { - C() : m(1) {}; - C(int n) : m(n) {}; - int get_m() { return m; }; + C() : m(1) {} + C(int n) : m(n) {} + int get_m() { return m; } int m; }; struct Base { - Base() {}; + Base() {} virtual boost::shared_ptr ret_c_shared_ptr() = 0; virtual C ret_c_by_value() = 0; virtual int take_c_by_value(C c) = 0; diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 33da61bf8..699a8a0a0 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -156,6 +156,10 @@ CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } + + CPTR_VISIBILITY void swigSetCMemOwn(boolean own) { + swigCMemOwn = own; + } %} // Derived proxy classes @@ -172,6 +176,11 @@ CPTR_VISIBILITY static long getCPtr($javaclassname obj) { return (obj == null) ? 0 : obj.swigCPtr; } + + CPTR_VISIBILITY void swigSetCMemOwn(boolean own) { + swigCMemOwnDerived = own; + super.swigSetCMemOwn(own); + } %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { @@ -195,6 +204,26 @@ super.delete(); } +%typemap(directordisconnect, methodname="swigDirectorDisconnect") TYPE %{ + protected void $methodname() { + swigSetCMemOwn(false); + $jnicall; + } +%} + +%typemap(directorowner_release, methodname="swigReleaseOwnership") TYPE %{ + public void $methodname() { + swigSetCMemOwn(false); + $jnicall; + } +%} + +%typemap(directorowner_take, methodname="swigTakeOwnership") TYPE %{ + public void $methodname() { + swigSetCMemOwn(true); + $jnicall; + } +%} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; %enddef diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 2ca426675..60ab7b049 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1260,7 +1260,7 @@ SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) */ %define SWIG_PROXY_CONSTRUCTOR(OWNERSHIP, WEAKREF, TYPENAME...) -%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, swigCMemOwn, WEAKREF);") TYPENAME { +%typemap(javaconstruct,directorconnect="\n $imclassname.$javaclazznamedirector_connect(this, swigCPtr, OWNERSHIP, WEAKREF);") TYPENAME { this($imcall, OWNERSHIP);$directorconnect } %enddef From 241460eddc2165cea0d30626ccca363b373ee115 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 May 2017 21:32:44 +0100 Subject: [PATCH 0542/2031] director_smartptr runtime tests enhancement Add same changes from previous commit to additional languages --- .../csharp/director_smartptr_runme.cs | 29 +++++++++++++++++++ .../python/director_smartptr_runme.py | 19 ++++++++++++ .../ruby/director_smartptr_runme.rb | 24 +++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/Examples/test-suite/csharp/director_smartptr_runme.cs b/Examples/test-suite/csharp/director_smartptr_runme.cs index 559dff7a0..33037a1da 100644 --- a/Examples/test-suite/csharp/director_smartptr_runme.cs +++ b/Examples/test-suite/csharp/director_smartptr_runme.cs @@ -26,6 +26,29 @@ public class runme } } + private class director_smartptr_MyBarFooDerived : FooDerived + { + public override string ping() + { + return "director_smartptr_MyBarFooDerived.ping()"; + } + + public override string pong() + { + return "director_smartptr_MyBarFooDerived.pong();" + ping(); + } + + public override string upcall(FooBar fooBarPtr) + { + return "overrideDerived;" + fooBarPtr.FooBarDo(); + } + + public override Foo makeFoo() + { + return new Foo(); + } + } + private static void check(string got, string expected) { if (got != expected) @@ -49,5 +72,11 @@ public class runme Foo myFoo2 = new Foo().makeFoo(); check(myFoo2.pong(), "Foo::pong();Foo::ping()"); check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()"); + + FooDerived myBarFooDerived = new director_smartptr_MyBarFooDerived(); + check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()"); + check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()"); + check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()"); + } } diff --git a/Examples/test-suite/python/director_smartptr_runme.py b/Examples/test-suite/python/director_smartptr_runme.py index c8bab9d7a..23e22d0fb 100644 --- a/Examples/test-suite/python/director_smartptr_runme.py +++ b/Examples/test-suite/python/director_smartptr_runme.py @@ -15,6 +15,20 @@ class director_smartptr_MyBarFoo(Foo): def makeFoo(self): return Foo() +class director_smartptr_MyBarFooDerived(FooDerived): + + def ping(self): + return "director_smartptr_MyBarFooDerived.ping()" + + def pong(self): + return "director_smartptr_MyBarFooDerived.pong();" + self.ping() + + def upcall(self, fooBarPtr): + return "overrideDerived;" + fooBarPtr.FooBarDo() + + def makeFoo(self): + return Foo() + def check(got, expected): if (got != expected): raise RuntimeError, "Failed, got: " + got + " expected: " + expected @@ -35,3 +49,8 @@ myFoo2 = Foo().makeFoo() check(myFoo2.pong(), "Foo::pong();Foo::ping()") check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()") check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()") + +myBarFooDerived = director_smartptr_MyBarFooDerived() +check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()") +check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()") +check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()") diff --git a/Examples/test-suite/ruby/director_smartptr_runme.rb b/Examples/test-suite/ruby/director_smartptr_runme.rb index 8b4bd3d6d..46ef8b1b5 100644 --- a/Examples/test-suite/ruby/director_smartptr_runme.rb +++ b/Examples/test-suite/ruby/director_smartptr_runme.rb @@ -30,6 +30,25 @@ class Director_smartptr_MyBarFoo < Foo end end +class Director_smartptr_MyBarFooDerived < FooDerived + + def ping() + return "director_smartptr_MyBarFooDerived.ping()" + end + + def pong() + return "director_smartptr_MyBarFooDerived.pong();" + ping() + end + + def upcall(fooBarPtr) + return "overrideDerived;" + fooBarPtr.FooBarDo() + end + + def makeFoo() + return Foo.new() + end +end + def check(got, expected) if (got != expected) raise RuntimeError, "Failed, got: #{got} expected: #{expected}" @@ -52,3 +71,8 @@ myFoo2 = Foo.new().makeFoo() check(myFoo2.pong(), "Foo::pong();Foo::ping()") check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()") check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()") + +myBarFooDerived = Director_smartptr_MyBarFooDerived.new() +check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()") +check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()") +check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()") From a4d01cddebf8568116bad93a2ffb783cd925c783 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 May 2017 20:35:18 +0100 Subject: [PATCH 0543/2031] Missing smart pointer handling in Java director extra methods - Add CHANGES file entry - Add testcase --- CHANGES.current | 4 ++++ Examples/test-suite/java/director_smartptr_runme.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index cd91b3607..78eb605a4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-25: asibross + [Java] #370 #417 Missing smart pointer handling in Java director extra methods + swigReleaseOwnership() and swigTakeOwnership(). + 2017-05-23: wsfulton [Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation error. diff --git a/Examples/test-suite/java/director_smartptr_runme.java b/Examples/test-suite/java/director_smartptr_runme.java index ba2bfc8c4..53d68f995 100644 --- a/Examples/test-suite/java/director_smartptr_runme.java +++ b/Examples/test-suite/java/director_smartptr_runme.java @@ -39,6 +39,13 @@ public class director_smartptr_runme { check(director_smartptr.FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()"); check(director_smartptr.FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()"); + director_smartptr.Foo myFoo3 = myBarFoo.makeFoo(); + myFoo3.swigReleaseOwnership(); + myFoo3.swigTakeOwnership(); + director_smartptr.FooDerived myBarFooDerived2 = new director_smartptr_MyBarFooDerived(); + myBarFooDerived2.swigReleaseOwnership(); + myBarFooDerived2.swigTakeOwnership(); + } } From 0bafadea5a2852fc88809ee2c5dbdfeb04eabbf1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 May 2017 18:55:52 +0100 Subject: [PATCH 0544/2031] Fix potential STL std::vector wrappers <: digraphs problems. --- Lib/java/std_vector.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index fee33f8c2..6d4f75010 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -31,9 +31,9 @@ int size_as_int(std::size_t sz) { %} %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE) -%typemap(javabase) std::vector "java.util.AbstractList<$typemap(jboxtype, CTYPE)>" -%typemap(javainterfaces) std::vector "java.util.RandomAccess" -%typemap(javacode) std::vector %{ +%typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>" +%typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess" +%typemap(javacode) std::vector< CTYPE > %{ public $javaclassname($typemap(jstype, CTYPE)[] initialElements) { this(); for ($typemap(jstype, CTYPE) element : initialElements) { From b51f32a915df51be552f9b906953d788af150906 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 May 2017 21:48:40 +0100 Subject: [PATCH 0545/2031] Java std::vector tweaks - Replace javacode typemap with %proxycode to make this typemap available to users - Make doSize private. --- Lib/java/std_vector.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 6d4f75010..9e0b2455d 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -33,7 +33,7 @@ int size_as_int(std::size_t sz) { %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE) %typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>" %typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess" -%typemap(javacode) std::vector< CTYPE > %{ +%proxycode %{ public $javaclassname($typemap(jstype, CTYPE)[] initialElements) { this(); for ($typemap(jstype, CTYPE) element : initialElements) { @@ -110,6 +110,7 @@ int size_as_int(std::size_t sz) { throw std::out_of_range("vector index out of range"); } } + value_type doRemove(int index) throw (std::out_of_range) { const int size = size_as_int(self->size()); if (0 <= index && index < size) { @@ -120,6 +121,7 @@ int size_as_int(std::size_t sz) { throw std::out_of_range("vector index out of range"); } } + CREF_TYPE doGet(int i) throw (std::out_of_range) { const int size = size_as_int(self->size()); if (i>=0 && isize()); if (i>=0 && isize()); if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { @@ -148,6 +152,7 @@ int size_as_int(std::size_t sz) { } %enddef +%javamethodmodifiers std::vector::doSize "private"; %javamethodmodifiers std::vector::doAdd "private"; %javamethodmodifiers std::vector::doGet "private"; %javamethodmodifiers std::vector::doSet "private"; From fdca8e9829d4c68e0747a09ee0b57f79fbb38e0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 May 2017 22:36:23 +0100 Subject: [PATCH 0546/2031] Better variable naming consistency in STL containers --- Lib/csharp/std_array.i | 6 +++--- Lib/csharp/std_map.i | 4 ++-- Lib/csharp/std_vector.i | 4 ++-- Lib/d/std_vector.i | 8 ++++---- Lib/java/std_array.i | 4 ++-- Lib/java/std_vector.i | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Lib/csharp/std_array.i b/Lib/csharp/std_array.i index 61bb510de..e7d392b85 100644 --- a/Lib/csharp/std_array.i +++ b/Lib/csharp/std_array.i @@ -174,7 +174,7 @@ bool empty() const; %rename(Fill) fill; - void fill(const value_type& val); + void fill(const value_type& value); %rename(Swap) swap; void swap(array& other); @@ -192,9 +192,9 @@ else throw std::out_of_range("index"); } - void setitem(int index, const_reference val) throw (std::out_of_range) { + void setitem(int index, const_reference value) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) - (*$self)[index] = val; + (*$self)[index] = value; else throw std::out_of_range("index"); } diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 90a865079..59b0a84f0 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -239,11 +239,11 @@ return iter != $self->end(); } - void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { + void Add(const key_type& key, const mapped_type& value) throw (std::out_of_range) { std::map< K, T, C >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); - $self->insert(std::pair< K, T >(key, val)); + $self->insert(std::pair< K, T >(key, value)); } bool Remove(const key_type& key) { diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index b0485eba6..52a865e67 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -231,9 +231,9 @@ else throw std::out_of_range("index"); } - void setitem(int index, CTYPE const& val) throw (std::out_of_range) { + void setitem(int index, CTYPE const& value) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) - (*$self)[index] = val; + (*$self)[index] = value; else throw std::out_of_range("index"); } diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i index 56f7188c7..c67057180 100644 --- a/Lib/d/std_vector.i +++ b/Lib/d/std_vector.i @@ -165,11 +165,11 @@ public void capacity(size_t value) { // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { - void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { + void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } - (*$self)[index] = val; + (*$self)[index] = value; } } @@ -517,11 +517,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { - void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { + void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } - (*$self)[index] = val; + (*$self)[index] = value; } } diff --git a/Lib/java/std_array.i b/Lib/java/std_array.i index cbacfe673..f75857e21 100644 --- a/Lib/java/std_array.i +++ b/Lib/java/std_array.i @@ -29,10 +29,10 @@ namespace std { else throw std::out_of_range("array index out of range"); } - void set(int i, const value_type& val) throw (std::out_of_range) { + void set(int i, const value_type& value) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && isize()); if (i>=0 && i Date: Tue, 30 May 2017 14:40:22 +0200 Subject: [PATCH 0547/2031] fix Scilab 6.0.0 linking issue --- Source/Modules/scilab.cxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index b3abc009e..4fea0ce36 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -1027,8 +1027,14 @@ public: Printf(gatewayHeader, "\n"); gatewayHeaderV6 = NewString(""); + Printf(gatewayHeaderV6, "#ifdef __cplusplus\n"); + Printf(gatewayHeaderV6, "extern \"C\" {\n"); + Printf(gatewayHeaderV6, "#endif\n"); Printf(gatewayHeaderV6, "#include \"c_gateway_prototype.h\"\n"); Printf(gatewayHeaderV6, "#include \"addfunction.h\"\n"); + Printf(gatewayHeaderV6, "#ifdef __cplusplus\n"); + Printf(gatewayHeaderV6, "}\n"); + Printf(gatewayHeaderV6, "#endif\n"); Printf(gatewayHeaderV6, "\n"); Printf(gatewayHeaderV6, "#define MODULE_NAME L\"%s\"\n", gatewayLibraryName); Printf(gatewayHeaderV6, "#ifdef __cplusplus\n"); From 84106490451daf19b0b5b3ac12daf627228321f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DAVID?= Date: Tue, 30 May 2017 15:30:59 +0200 Subject: [PATCH 0548/2031] update changes referencing issue --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 78eb605a4..7c82b8b89 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-05-30: davidcl + [Scilab] #994 Undefined symbol error when loading in Scilab 6 + 2017-05-25: asibross [Java] #370 #417 Missing smart pointer handling in Java director extra methods swigReleaseOwnership() and swigTakeOwnership(). From 32e7074d9b288f08e638afeea6b49c829d9cd200 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 May 2017 22:50:36 +0100 Subject: [PATCH 0549/2031] Whitespace fixes in STL wrappers --- Lib/csharp/std_map.i | 20 +++--- Lib/csharp/std_vector.i | 10 +-- Lib/d/std_map.i | 71 ++++++++++---------- Lib/java/std_map.i | 73 ++++++++++----------- Lib/java/std_vector.i | 140 ++++++++++++++++++++-------------------- 5 files changed, 154 insertions(+), 160 deletions(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 59b0a84f0..9d07bc830 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -4,14 +4,14 @@ * SWIG typemaps for std::map< K, T, C > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. - * + * * Using this wrapper is fairly simple. For example, to create a map from integers to doubles use: * * %include * %template(MapIntDouble) std::map * * Notes: - * 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with + * 1) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::map wrappers. * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! @@ -55,8 +55,8 @@ } public bool IsReadOnly { - get { - return false; + get { + return false; } } @@ -84,7 +84,7 @@ return vals; } } - + public void Add(global::System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { Add(item.Key, item.Value); } @@ -143,7 +143,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 : global::System.Collections.IEnumerator, + public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator, global::System.Collections.Generic.IEnumerator> { private $csclassname collectionRef; @@ -206,7 +206,7 @@ currentObject = null; } } - + %} public: @@ -251,7 +251,7 @@ if (iter != $self->end()) { $self->erase(iter); return true; - } + } return false; } @@ -285,12 +285,12 @@ %csmethodmodifiers std::map::destroy_iterator "private" // Default implementation -namespace std { +namespace std { template > class map { SWIG_STD_MAP_INTERNAL(K, T, C) }; } - + // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 52a865e67..0d1476f7f 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -5,9 +5,9 @@ * C# implementation * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection. * - * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with + * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with * C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality - * whenever we are confident that the required C++ operator== is available. This is the case for when + * whenever we are confident that the required C++ operator== is available. This is the case for when * T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED * macro to obtain this enhanced functionality, for example: * @@ -33,14 +33,14 @@ this.Add(element); } } - + public $csclassname(global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)> c) : this() { if (c == null) throw new global::System.ArgumentNullException("c"); foreach ($typemap(cstype, CTYPE) element in c) { this.Add(element); } - } + } public bool IsFixedSize { get { @@ -332,7 +332,7 @@ std::vector< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); if (it != $self->end()) { $self->erase(it); - return true; + return true; } return false; } diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i index 0e8574b8a..d2ba04118 100644 --- a/Lib/d/std_map.i +++ b/Lib/d/std_map.i @@ -16,44 +16,41 @@ #include %} -// exported class - namespace std { - template class map { - // add typemaps here - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef K key_type; - typedef T mapped_type; - map(); - map(const map &); + template class map { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map &); - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, const T& x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); } - }; + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map::iterator i = self->find(key); + return i != self->end(); + } + } + }; } diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index e7812f38a..2405571fa 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -16,47 +16,44 @@ #include %} -// exported class - namespace std { - template class map { - // add typemaps here - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef K key_type; - typedef T mapped_type; - map(); - map(const map &); - - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, const T& x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } + template class map { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + map(); + map(const map &); + + unsigned int size() const; + bool empty() const; + void clear(); + %extend { + const T& get(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + return i->second; + else + throw std::out_of_range("key not found"); } - }; + void set(const K& key, const T& x) { + (*self)[key] = x; + } + void del(const K& key) throw (std::out_of_range) { + std::map::iterator i = self->find(key); + if (i != self->end()) + self->erase(i); + else + throw std::out_of_range("key not found"); + } + bool has_key(const K& key) { + std::map::iterator i = self->find(key); + return i != self->end(); + } + } + }; // Legacy macros (deprecated) %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 3a76ec891..99fbd3e9a 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -20,11 +20,11 @@ // them, in order to achieve this. namespace { int size_as_int(std::size_t sz) { - if (sz > static_cast(INT_MAX)) { - throw std::out_of_range("vector size is too big to be representable as int"); - } + if (sz > static_cast(INT_MAX)) { + throw std::out_of_range("vector size is too big to be representable as int"); + } - return static_cast(sz); + return static_cast(sz); } } // anonymous namespace @@ -82,74 +82,74 @@ int size_as_int(std::size_t sz) { } %} - public: - typedef size_t size_type; - typedef CTYPE value_type; - typedef CREF_TYPE const_reference; - vector(); - vector(size_type n); - size_type capacity() const; - void reserve(size_type n); - %rename(isEmpty) empty; - bool empty() const; - void clear(); - %extend { - int doSize() const { - return size_as_int(self->size()); - } + public: + typedef size_t size_type; + typedef CTYPE value_type; + typedef CREF_TYPE const_reference; + vector(); + vector(size_type n); + size_type capacity() const; + void reserve(size_type n); + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %extend { + int doSize() const { + return size_as_int(self->size()); + } - void doAdd(const value_type& value) { - self->push_back(value); - } + void doAdd(const value_type& value) { + self->push_back(value); + } - void doAdd(int index, const value_type& value) throw (std::out_of_range) { - const int size = size_as_int(self->size()); - if (0 <= index && index <= size) { - self->insert(self->begin() + index, value); - } else { - throw std::out_of_range("vector index out of range"); - } - } - - value_type doRemove(int index) throw (std::out_of_range) { - const int size = size_as_int(self->size()); - if (0 <= index && index < size) { - CTYPE const old_value = (*self)[index]; - self->erase(self->begin() + index); - return old_value; - } else { - throw std::out_of_range("vector index out of range"); - } - } - - CREF_TYPE doGet(int i) throw (std::out_of_range) { - const int size = size_as_int(self->size()); - if (i>=0 && isize()); - if (i>=0 && isize()); - if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { - self->erase(self->begin() + fromIndex, self->begin() + toIndex); - } else { - throw std::out_of_range("vector index out of range"); - } - } + void doAdd(int index, const value_type& value) throw (std::out_of_range) { + const int size = size_as_int(self->size()); + if (0 <= index && index <= size) { + self->insert(self->begin() + index, value); + } else { + throw std::out_of_range("vector index out of range"); } + } + + value_type doRemove(int index) throw (std::out_of_range) { + const int size = size_as_int(self->size()); + if (0 <= index && index < size) { + CTYPE const old_value = (*self)[index]; + self->erase(self->begin() + index); + return old_value; + } else { + throw std::out_of_range("vector index out of range"); + } + } + + CREF_TYPE doGet(int i) throw (std::out_of_range) { + const int size = size_as_int(self->size()); + if (i>=0 && isize()); + if (i>=0 && isize()); + if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { + self->erase(self->begin() + fromIndex, self->begin() + toIndex); + } else { + throw std::out_of_range("vector index out of range"); + } + } + } %enddef %javamethodmodifiers std::vector::doSize "private"; @@ -160,7 +160,7 @@ int size_as_int(std::size_t sz) { %javamethodmodifiers std::vector::doRemoveRange "private"; namespace std { - + template class vector { SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const T&) }; From 9f55985a6cf86540d86799b174df607375e2c5c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 2 Jun 2017 18:39:02 +0100 Subject: [PATCH 0550/2031] Remove unused code --- Source/Modules/lang.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4dc39e069..69ca07772 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -81,7 +81,6 @@ extern int AddExtern; /* import modes */ #define IMPORT_MODE 1 -#define IMPORT_MODULE 2 /* ---------------------------------------------------------------------- * Dispatcher::emit_one() From 857a62425c7726d937ca4276a1c19e7280da3135 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Jun 2017 13:47:26 +0100 Subject: [PATCH 0551/2031] Formatting fixes in Lisp docs --- Doc/Manual/Lisp.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index ba42f735c..7bf8562c5 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -122,9 +122,12 @@ swig -cffi -help

    27.2.2 Generating CFFI bindings

    +

    + As we mentioned earlier the ideal way to use SWIG is to use interface files. To illustrate the use of it, let's assume that we have a file named test.h with the following C code: +

     #define y 5
    @@ -155,7 +158,10 @@ void lispsort_double (int n, double * array);
     enum color { RED, BLUE, GREEN};
     
    +

    Corresponding to this we will write a simple interface file: +

    +
     %module test
     
    @@ -163,7 +169,9 @@ Corresponding to this we will write a simple interface file:
     
     
    +

    The generated SWIG Code will be: +

     ;;;SWIG wrapper code starts here
    @@ -430,8 +438,10 @@ Also, while parsing the C++ file and generating C wrapper code SWIG
     %include "target/header.h"
     
     
    +

    Various features which were available for C headers can also be used here. The target header which we are going to use here is: +

     namespace OpenDemo {
       class Test
    @@ -478,8 +488,10 @@ namespace OpenDemo {
     %include "test.cpp"
     
    +

    SWIG generates 3 files, the first one is a C wrap which we don't show, the second is the plain CFFI wrapper which is as shown below: +

     (cffi:defcfun ("_wrap_Test_x_set" Test_x_set) :void
       (self :pointer)
    @@ -528,11 +540,13 @@ SWIG generates 3 files, the first one is a C wrap which we don't show,
     (cffi:defcfun ("_wrap_RandomUnitVectorOnXZPlane" RandomUnitVectorOnXZPlane) :pointer)
     
    +

    The output is pretty good but it fails in disambiguating overloaded functions such as the constructor, in this case. One way of resolving this problem is to make the interface use the rename directiv, but hopefully there are better solutions. In addition SWIG also generates, a CLOS file +

    
    From 57a89f987dd5736f9f55f23eb4b3708e07d0f676 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sat, 3 Jun 2017 16:18:41 +0100
    Subject: [PATCH 0552/2031] Fix %import and %fragment forced inclusion to not
     generate code.
    
    ---
     CHANGES.current                          | 22 ++++++
     Doc/Manual/Typemaps.html                 | 91 ++++++++++++++++++++++--
     Examples/test-suite/common.mk            |  1 +
     Examples/test-suite/import_fragments.i   | 18 +++++
     Examples/test-suite/import_fragments_a.i | 45 ++++++++++++
     Examples/test-suite/import_fragments_b.i |  9 +++
     Source/Modules/javascript.cxx            |  4 +-
     Source/Modules/lang.cxx                  |  3 +-
     8 files changed, 186 insertions(+), 7 deletions(-)
     create mode 100644 Examples/test-suite/import_fragments.i
     create mode 100644 Examples/test-suite/import_fragments_a.i
     create mode 100644 Examples/test-suite/import_fragments_b.i
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 65c32605d..f96beecbd 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,28 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.0 (in progress)
     ===========================
     
    +2017-06-03: wsfulton
    +            Fix %import on a file containing a file scope %fragment forced inclusion to not
    +            generate the fragment contents as %import should not result in code being generated.
    +            The behaviour is now the same as importing code insertion blocks.
    +            Wrapping FileC.i in the following example will result in no generated code, whereas
    +            previously "#include " was generated:
    +
    +              // FileA.i
    +              %fragment("", "header") %{
    +                #include 
    +              %}
    +
    +              %{
    +                #include 
    +              %}
    +              %fragment("");
    +
    +              // FileC.i
    +              %import "FileA.i"
    +
    +            *** POTENTIAL INCOMPATIBILITY ***
    +
     2017-05-26: Volker Diels-Grabsch, vadz
                 [Java] Implement java.util.List<> for std::vector. This notably allows to
                 iterate over wrapped vectors in a natural way.
    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
    index a3a3e09cb..f274c9293 100644
    --- a/Doc/Manual/Typemaps.html
    +++ b/Doc/Manual/Typemaps.html
    @@ -3904,9 +3904,9 @@ A fragment can use one or more additional fragments, for example:
     
     
    -%fragment("<limits.h>", "header") {
    -  %#include <limits.h>
    -}
    +%fragment("<limits.h>", "header") %{
    +  #include <limits.h>
    +%}
     
     
     %fragment("AsMyClass", "header", fragment="<limits.h>") {
    @@ -3989,8 +3989,91 @@ Finally, you can force the inclusion of a fragment at any point in the generated
     

    -which is very useful inside a template class, for example. +which, for example, is very useful inside a template class. +Another useful case is when using %extend inside a class +where the additional code in the %extend block depends on the contents of the fragment.

    + +
    +
    +%fragment("<limits.h>", "header") %{
    +  #include <limits.h>
    +%}
    +
    +struct X {
    +  ...
    +  %extend {
    +    %fragment("<limits.h>");
    +    bool check(short val) {
    +      if (val < SHRT_MIN /*defined in <limits.h>*/) {
    +        return true;
    +      } else {
    +        return false;
    +      }
    +    }
    +  }
    +};
    +
    +
    + + +

    +Forced inclusion of fragments can be used as a replacement for code insertion block, ensuring the +code block is only generated once. +Consider the contents of FileA.i below which first uses a code insertion block and then a forced fragment inclusion to generate code: +

    +

    +
    +// FileA.i
    +%{
    +  #include <stdio.h>
    +%}
    +%fragment("<limits.h>");
    +
    +
    + +

    +and another file including the above: +

    + +
    +
    +// FileB.i
    +%include "FileA.i"
    +
    +
    + +

    +The resulting code in the wrappers for FileB.i is: +

    + +
    +
    +  #include <stdio.h>
    +
    +  #include <limits.h>
    +
    +
    + +

    +A note of caution must be mentioned when using %fragment forced inclusion or code insertion blocks with %import. +If %import is used instead: +

    + +

    +
    +// FileC.i
    +%import "FileA.i"
    +
    +
    + +

    +then nothing is generated in the resulting code in the wrappers for FileC.i. +This is because %import is for collecting type information and does not result in any code +being generated, see File Imports. +

    + +

    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 18c00e750..f68451f87 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -246,6 +246,7 @@ CPP_TEST_CASES += \ global_vars \ grouping \ ignore_parameter \ + import_fragments \ import_nomodule \ inherit \ inherit_member \ diff --git a/Examples/test-suite/import_fragments.i b/Examples/test-suite/import_fragments.i new file mode 100644 index 000000000..26b87cdb2 --- /dev/null +++ b/Examples/test-suite/import_fragments.i @@ -0,0 +1,18 @@ +%module import_fragments + +// Check %fragments forced inclusion does not result in code generation when using %import +%import "import_fragments_a.i" + +%{ +template +struct TemplateA4 {}; +%} + +%template(TemplateA4Int) TemplateA4; + +%inline %{ +int getImport4() { + // Requires the ImportA4 fragment to be generated in order to compile + return ImportA4; +} +%} diff --git a/Examples/test-suite/import_fragments_a.i b/Examples/test-suite/import_fragments_a.i new file mode 100644 index 000000000..7478a1e86 --- /dev/null +++ b/Examples/test-suite/import_fragments_a.i @@ -0,0 +1,45 @@ +%module import_fragments_a + +%fragment("ImportA1", "header") %{ +ImportA1_this_will_not_compile; +%} +%fragment("ImportA2", "header") %{ +ImportA2_this_will_not_compile; +%} +%fragment("ImportA3", "header") %{ +ImportA3_this_will_not_compile; +%} +%fragment("ImportA4", "header") %{ +static int ImportA4 = 99; +%} +%fragment("ImportA5", "header") %{ +ImportA5_this_will_not_compile; +%} + +%fragment("ImportA1"); + +%{ +Import_will_not_compile; +%} + +struct StructA { + %fragment("ImportA2"); +}; + +template +struct TemplateA3 { + %fragment("ImportA3"); +}; + +template +struct TemplateA4 { + %fragment("ImportA4"); +}; + +template +struct TemplateA5 { + %fragment("ImportA5"); +}; +%template(TemplateA5Double) TemplateA5; + +%include "import_fragments_b.i" diff --git a/Examples/test-suite/import_fragments_b.i b/Examples/test-suite/import_fragments_b.i new file mode 100644 index 000000000..615db4796 --- /dev/null +++ b/Examples/test-suite/import_fragments_b.i @@ -0,0 +1,9 @@ +%module import_fragments_b + +%fragment("ImportB", "header") %{ +ImportB_this_will_not_compile; +%} + +%fragment("ImportB"); + + diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 4e7a7912f..490ee7fd3 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -462,10 +462,10 @@ int JAVASCRIPT::fragmentDirective(Node *n) { // and register them at the emitter. String *section = Getattr(n, "section"); - if (Equal(section, "templates")) { + if (Equal(section, "templates") && !ImportMode) { emitter->registerTemplate(Getattr(n, "value"), Getattr(n, "code")); } else { - Swig_fragment_register(n); + return Language::fragmentDirective(n); } return SWIG_OK; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 69ca07772..11874ef0a 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -624,7 +624,8 @@ int Language::constantDirective(Node *n) { * ---------------------------------------------------------------------- */ int Language::fragmentDirective(Node *n) { - Swig_fragment_register(n); + if (!(Getattr(n, "emitonly") && ImportMode)) + Swig_fragment_register(n); return SWIG_OK; } From be63f73e33fa0624e28652f117ee68c1648762cc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Jun 2017 17:15:44 +0100 Subject: [PATCH 0553/2031] Fix c++ compiler warnings in c++11 testcases --- .../test-suite/cpp11_alternate_function_syntax.i | 1 + Examples/test-suite/cpp11_constexpr.i | 10 ++++++++-- Examples/test-suite/cpp11_final_override.i | 1 + Examples/test-suite/cpp11_noexcept.i | 2 +- Examples/test-suite/cpp11_rvalue_reference2.i | 11 ++++++----- Examples/test-suite/cpp11_rvalue_reference3.i | 16 ++++++++++++++-- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Examples/test-suite/cpp11_alternate_function_syntax.i b/Examples/test-suite/cpp11_alternate_function_syntax.i index 3e47bbafe..b3ecabc8c 100644 --- a/Examples/test-suite/cpp11_alternate_function_syntax.i +++ b/Examples/test-suite/cpp11_alternate_function_syntax.i @@ -13,6 +13,7 @@ struct SomeStruct { auto addAlternateMemberPtrConstParm(int x, int (SomeStruct::*mp)(int, int) const) const -> int; virtual auto addFinal(int x, int y) const noexcept -> int final { return x + y; } + virtual ~SomeStruct() = default; }; int SomeStruct::addNormal(int x, int y) { return x + y; } diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i index d91107cc6..ef08a49c3 100644 --- a/Examples/test-suite/cpp11_constexpr.i +++ b/Examples/test-suite/cpp11_constexpr.i @@ -3,11 +3,17 @@ */ %module cpp11_constexpr + %inline %{ +#ifdef SWIG +#define CONST const +#else +#define CONST +#endif constexpr int AAA = 10; constexpr const int BBB = 20; constexpr int CCC() { return 30; } -constexpr const int DDD() { return 40; } +constexpr CONST int DDD() { return 40; } constexpr int XXX() { return 10; } constexpr int YYY = XXX() + 100; @@ -17,7 +23,7 @@ struct ConstExpressions { static constexpr int KKK = 200; static const int LLL = 300; constexpr int MMM() { return 400; } - constexpr const int NNN() { return 500; } + constexpr CONST int NNN() { return 500; } // Regression tests for support added in SWIG 3.0.4: static constexpr const int JJJ1 = 101; constexpr static int KKK1 = 201; diff --git a/Examples/test-suite/cpp11_final_override.i b/Examples/test-suite/cpp11_final_override.i index a5baeaa36..7abf50123 100644 --- a/Examples/test-suite/cpp11_final_override.i +++ b/Examples/test-suite/cpp11_final_override.i @@ -82,6 +82,7 @@ struct Destructors4 : Base { struct FinalOverrideMethods { virtual void final() {} virtual void override(int) {} + virtual ~FinalOverrideMethods() = default; }; struct FinalOverrideVariables { int final; diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i index 2fa6e8985..a77eb046f 100644 --- a/Examples/test-suite/cpp11_noexcept.i +++ b/Examples/test-suite/cpp11_noexcept.i @@ -18,7 +18,7 @@ struct NoExceptClass { NoExceptClass(const NoExceptClass&) noexcept {} NoExceptClass(NoExceptClass&&) noexcept {} NoExceptClass& operator=(const NoExceptClass&) noexcept { return *this; } - ~NoExceptClass() noexcept {} + virtual ~NoExceptClass() noexcept {} void noex0() noexcept {} void noex1() noexcept(sizeof(int) == 4) {} diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i index 6718a3941..d532e29f3 100644 --- a/Examples/test-suite/cpp11_rvalue_reference2.i +++ b/Examples/test-suite/cpp11_rvalue_reference2.i @@ -23,7 +23,7 @@ struct Thingy { int val; int &lvalref; int &&rvalref; - Thingy(int v) : val(v), lvalref(val), rvalref(22) {} + Thingy(int v, int &&rvalv) : val(v), lvalref(val), rvalref(std::move(rvalv)) {} void refIn(long &i) {} void rvalueIn(long &&i) {} short && rvalueInOut(short &&i) { return std::move(i); } @@ -32,7 +32,7 @@ struct Thingy { void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {} void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {} operator int &&() { return std::move(0); } - Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(copy_int(rhs.rvalref)) {} + Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(std::move(rhs.rvalref)) {} Thingy& operator=(const Thingy& rhs) { val = rhs.val; lvalref = rhs.lvalref; @@ -41,17 +41,18 @@ struct Thingy { } private: static const bool PrivateTrue; - int copy_int(int& i) { return i; } Thingy(); }; const bool Thingy::PrivateTrue = true; short && globalRvalueInOut(short &&i) { return std::move(i); } -Thingy &&globalrrval = Thingy(55); +int glob = 123; + +Thingy &&globalrrval = Thingy(55, std::move(glob)); short && func(short &&i) { return std::move(i); } -Thingy getit() { return Thingy(22); } +Thingy getit() { return Thingy(22, std::move(glob)); } void rvalrefFunction1(int &&v = (int &&)5) {} void rvalrefFunctionBYVAL(short (Thingy::*memFunc)(short)) {} diff --git a/Examples/test-suite/cpp11_rvalue_reference3.i b/Examples/test-suite/cpp11_rvalue_reference3.i index c65309945..6dfe4c098 100644 --- a/Examples/test-suite/cpp11_rvalue_reference3.i +++ b/Examples/test-suite/cpp11_rvalue_reference3.i @@ -31,7 +31,13 @@ struct Containing { Thing *const&& member_rvalue_ref_ptr3 = 0; Thing const*const &&member_rvalue_ref_ptr4 = 0; - Containing() : member_rvalue_ref(Thing()) {} + Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) : + member_rvalue_ref(std::move(r)), + member_rvalue_ref_ptr1(std::move(r1)), + member_rvalue_ref_ptr2(std::move(r2)), + member_rvalue_ref_ptr3(std::move(r3)), + member_rvalue_ref_ptr4(std::move(r4)) + {} }; %} @@ -62,6 +68,12 @@ struct IntContaining { int *const&& member_rvalue_ref_ptr3 = 0; int const*const &&member_rvalue_ref_ptr4 = 0; - IntContaining() : member_rvalue_ref(55) {} + IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) : + member_rvalue_ref(std::move(r)), + member_rvalue_ref_ptr1(std::move(r1)), + member_rvalue_ref_ptr2(std::move(r2)), + member_rvalue_ref_ptr3(std::move(r3)), + member_rvalue_ref_ptr4(std::move(r4)) + {} }; %} From 5eb9f735daee254b227b728da16e68e4d83b0843 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jun 2017 18:49:54 +0100 Subject: [PATCH 0554/2031] Add generic approach in fragments for converting size_t to Java int --- Lib/java/java.swg | 8 ++++++ Lib/java/std_vector.i | 65 ++++++++++++++++++------------------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 2ffb57196..e0ddcba02 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -54,6 +54,14 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { } } +%fragment("SWIG_JavaIntFromSize_t", "header") { +/* Check for overflow converting to Java int (always signed 32-bit) from (unsigned variable-bit) size_t */ +SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { + static const jint JINT_MAX = 0x7FFFFFFF; + return (size > (size_t)JINT_MAX) ? -1 : (jint)size; +} +} + /* Primitive types */ %typemap(jni) bool, const bool & "jboolean" %typemap(jni) char, const char & "jchar" diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 99fbd3e9a..4f5afe6db 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -7,29 +7,17 @@ %{ #include #include -#include - -// C++ allows to have up to 2^64-1 items in a vector on 64 bit machines and -// 2^32-1 even on 32 bit ones, but in Java size() must return a value of type -// "int" which is limited to signed 32 bit values, i.e. 2^31-1, and there -// doesn't seem to be any way to represent bigger vectors there. -// -// The only thing we can do is to at least detect such situation and throw an -// exception instead of silently returning the wrong size in this case and we -// use this helper to convert size_t values to int, instead of just casting -// them, in order to achieve this. -namespace { -int size_as_int(std::size_t sz) { - if (sz > static_cast(INT_MAX)) { - throw std::out_of_range("vector size is too big to be representable as int"); - } - - return static_cast(sz); -} -} // anonymous namespace - %} +%fragment("SWIG_VectorSize", "header", fragment="SWIG_JavaIntFromSize_t") { +SWIGINTERN jint SWIG_VectorSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) + throw std::out_of_range("vector size is too large to fit into a Java int"); + return sz; +} +} + %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE) %typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>" %typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess" @@ -94,16 +82,17 @@ int size_as_int(std::size_t sz) { bool empty() const; void clear(); %extend { - int doSize() const { - return size_as_int(self->size()); + %fragment("SWIG_VectorSize"); + jint doSize() const throw (std::out_of_range) { + return SWIG_VectorSize(self->size()); } void doAdd(const value_type& value) { self->push_back(value); } - void doAdd(int index, const value_type& value) throw (std::out_of_range) { - const int size = size_as_int(self->size()); + void doAdd(jint index, const value_type& value) throw (std::out_of_range) { + const jint size = SWIG_VectorSize(self->size()); if (0 <= index && index <= size) { self->insert(self->begin() + index, value); } else { @@ -111,8 +100,8 @@ int size_as_int(std::size_t sz) { } } - value_type doRemove(int index) throw (std::out_of_range) { - const int size = size_as_int(self->size()); + value_type doRemove(jint index) throw (std::out_of_range) { + const jint size = SWIG_VectorSize(self->size()); if (0 <= index && index < size) { CTYPE const old_value = (*self)[index]; self->erase(self->begin() + index); @@ -122,27 +111,27 @@ int size_as_int(std::size_t sz) { } } - CREF_TYPE doGet(int i) throw (std::out_of_range) { - const int size = size_as_int(self->size()); - if (i>=0 && isize()); + if (index >= 0 && index < size) + return (*self)[index]; else throw std::out_of_range("vector index out of range"); } - value_type doSet(int i, const value_type& value) throw (std::out_of_range) { - const int size = size_as_int(self->size()); - if (i>=0 && isize()); + if (index >= 0 && index < size) { + CTYPE const old_value = (*self)[index]; + (*self)[index] = value; return old_value; } else throw std::out_of_range("vector index out of range"); } - void doRemoveRange(int fromIndex, int toIndex) throw (std::out_of_range) { - const int size = size_as_int(self->size()); + void doRemoveRange(jint fromIndex, jint toIndex) throw (std::out_of_range) { + const jint size = SWIG_VectorSize(self->size()); if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { self->erase(self->begin() + fromIndex, self->begin() + toIndex); } else { From 30b7424f8ea663986aeed8694edabce6c2b41181 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jun 2017 19:15:32 +0100 Subject: [PATCH 0555/2031] Java std_vector runtime test From Volker Diels-Grabsch in SF patch https://sourceforge.net/p/swig/patches/278/ --- .../test-suite/java/li_std_vector_runme.java | 71 ++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index b422655a4..21f35c269 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -4,7 +4,7 @@ public class li_std_vector_runme { static { try { - System.loadLibrary("li_std_vector"); + System.loadLibrary("li_std_vector"); } 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); @@ -17,8 +17,30 @@ public class li_std_vector_runme { IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector()); IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector()); - v1.add(123); - if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); + if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed"); + if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed"); + if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed"); + if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed"); + if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed"); + if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed"); + if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed"); + if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed"); + + java.util.Iterator v1_iterator = v1.iterator(); + if (!v1_iterator.hasNext()) throw new RuntimeException("v1 test (9) failed"); + if (v1_iterator.next() != 456) throw new RuntimeException("v1 test (10) failed"); + if (v1_iterator.hasNext()) throw new RuntimeException("v1 test (11) failed"); + try { + v1_iterator.next(); + throw new RuntimeException("v1 test (12) failed"); + } catch (java.util.NoSuchElementException e) { + } + + if (v1.remove(new Integer(123))) throw new RuntimeException("v1 test (13) failed"); + if (!v1.remove(new Integer(456))) throw new RuntimeException("v1 test (14) failed"); + if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed"); + if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); + if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed"); StructVector v4 = li_std_vector.vecstruct(new StructVector()); StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector()); @@ -32,5 +54,48 @@ public class li_std_vector_runme { if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed"); if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed"); if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed"); + + StructVector v7 = li_std_vector.vecstruct(new StructVector()); + v7.add(new Struct(1)); + v7.add(new Struct(23)); + v7.add(new Struct(456)); + v7.add(new Struct(7890)); + if (v7.size() != 4) throw new RuntimeException("v7 test (1) failed"); + { + double[] a7 = {1, 23, 456, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (2) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (3) failed"); + } + if (v7.remove(2).getNum() != 456) throw new RuntimeException("v7 test (4) failed"); + { + double[] a7 = {1, 23, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (5) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (6) failed"); + } + v7.add(1, new Struct(123)); + { + double[] a7 = {1, 123, 23, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (7) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (8) failed"); + } + + BoolVector v8 = new BoolVector(); + if (!v8.add(true)) throw new RuntimeException("v8 test (1) failed");; + if (v8.get(0) != true) throw new RuntimeException("v8 test (2) failed");; + if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");; + if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");; + if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");; } } From bc7c80b8628a973d41aa8ebccd01773f76c75eb0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jun 2017 19:33:45 +0100 Subject: [PATCH 0556/2031] More Java vector runtime tests --- Examples/test-suite/java/li_std_vector_runme.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index 1a1e3614e..60776bbf1 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -110,5 +110,12 @@ public class li_std_vector_runme { if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");; if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");; if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");; + + java.util.ArrayList bl = new java.util.ArrayList(java.util.Arrays.asList(true, false, true, false)); + BoolVector bv = new BoolVector(java.util.Arrays.asList(true, false, true, false)); + BoolVector bv2 = new BoolVector(bl); + java.util.ArrayList bl2 = new java.util.ArrayList(bv); + boolean bbb1 = bv.get(0); + Boolean bbb2 = bv.get(0); } } From e1a667bd52dd938bbb0d8ac4633668ecd6ee214e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jun 2017 19:44:16 +0100 Subject: [PATCH 0557/2031] minor update to the changes file --- CHANGES.current | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f96beecbd..c0481b7af 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -30,8 +30,8 @@ Version 4.0.0 (in progress) *** POTENTIAL INCOMPATIBILITY *** 2017-05-26: Volker Diels-Grabsch, vadz - [Java] Implement java.util.List<> for std::vector. This notably allows to - iterate over wrapped vectors in a natural way. + [Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for + std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way. 2017-05-25: asibross [Java] #370 #417 Missing smart pointer handling in Java director extra methods @@ -83,10 +83,6 @@ Version 4.0.0 (in progress) [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) -2017-02-29: tamuratak - [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing - for std::list, std::multiset, std::unordered_multiset and std::unordered_map. - 2017-03-24: tamuratak [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks on VALUE obj. @@ -118,6 +114,10 @@ Version 4.0.0 (in progress) auto sum1(int x, int y) const -> int { return x + y; } auto sum2(int x, int y) noexcept -> int { return x + y; } +2017-02-29: tamuratak + [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing + for std::list, std::multiset, std::unordered_multiset and std::unordered_map. + 2017-02-27: assambar [C++11] Extend parser to support throw specifier in combination with override and/or final. From 10e73a5bfbaf696a751fc8f83bd79dddfec9cf0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 5 Jun 2017 20:47:49 +0100 Subject: [PATCH 0558/2031] Java jboxtype typemap documentation and tidy up --- Doc/Manual/Java.html | 11 +++++++++++ Lib/java/java.swg | 29 ++++++++++++++--------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c77724bf2..e0178465c 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5693,6 +5693,17 @@ The most important of these implement the mapping of C/C++ types to Java types: In other words the typemap provides the conversion from the native method call return type. + +jboxtype +Java boxed type. + These are Java code typemaps to provide the Java boxed type, such as, Integer for C type int. + As autoboxing is only relevant to the Java primitive types, these are only provided for the + C types that map to Java primitive types. + This typemap is usually only used by C++ STL container wrappers that are wrapped by Java generic + types as the boxed type must be used instead of the unboxed/primitive type when declaring a Java generic type. + + + javadirectorin Conversion from jtype to jstype for director methods. diff --git a/Lib/java/java.swg b/Lib/java/java.swg index e0ddcba02..b49826ba0 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -111,25 +111,24 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { %typemap(jstype) double, const double & "double" %typemap(jstype) void "void" -%typemap(jboxtype) bool "Boolean" -%typemap(jboxtype) char "Character" -%typemap(jboxtype) signed char "Byte" -%typemap(jboxtype) unsigned char "Short" -%typemap(jboxtype) short "Short" -%typemap(jboxtype) unsigned short "Integer" -%typemap(jboxtype) int "Integer" -%typemap(jboxtype) unsigned int "Long" -%typemap(jboxtype) long "Integer" -%typemap(jboxtype) unsigned long "Long" -%typemap(jboxtype) long long "Long" -%typemap(jboxtype) unsigned long long "java.math.BigInteger" -%typemap(jboxtype) float "Float" -%typemap(jboxtype) double "Double" +%typemap(jboxtype) bool, const bool & "Boolean" +%typemap(jboxtype) char, const char & "Character" +%typemap(jboxtype) signed char, const signed char & "Byte" +%typemap(jboxtype) unsigned char, const unsigned char & "Short" +%typemap(jboxtype) short, const short & "Short" +%typemap(jboxtype) unsigned short, const unsigned short & "Integer" +%typemap(jboxtype) int, const int & "Integer" +%typemap(jboxtype) unsigned int, const unsigned int & "Long" +%typemap(jboxtype) long, const long & "Integer" +%typemap(jboxtype) unsigned long, const unsigned long & "Long" +%typemap(jboxtype) long long, const long long & "Long" +%typemap(jboxtype) unsigned long long, const unsigned long long & "java.math.BigInteger" +%typemap(jboxtype) float, const float & "Float" +%typemap(jboxtype) double, const double & "Double" %typemap(jni) char *, char *&, char[ANY], char[] "jstring" %typemap(jtype) char *, char *&, char[ANY], char[] "String" %typemap(jstype) char *, char *&, char[ANY], char[] "String" -%typemap(jboxtype) char *, char *&, char[ANY], char[] "String" /* JNI types */ %typemap(jni) jboolean "jboolean" From 0083d451db637a625069ef340ff87f336585bf0b Mon Sep 17 00:00:00 2001 From: Alan Woodland Date: Mon, 5 Jun 2017 21:57:23 +0100 Subject: [PATCH 0559/2031] Switched from autobox to jboxtype per #842 --- Lib/java/autobox.i | 70 --------------------------------------------- Lib/java/std_list.i | 7 ++--- 2 files changed, 3 insertions(+), 74 deletions(-) delete mode 100644 Lib/java/autobox.i diff --git a/Lib/java/autobox.i b/Lib/java/autobox.i deleted file mode 100644 index 9fe6b995c..000000000 --- a/Lib/java/autobox.i +++ /dev/null @@ -1,70 +0,0 @@ -/* - Java typemaps for autoboxing in return types of generics. - - Java generics let you define interfaces, e.g. Collection which operate on any homogenous - collection of Objects, with compile time type checking. For example Collection can - only store String objects and the compiler helps enforce that. - - Unfortunately Java treats primitive types as a special case. They're not first class objects, - so in order to have a collection of ints we have to actually maintain a Collection. - For each primitive type in Java (boolean, byte, short, int, long, float, double) there - exists a corresponding "proper" Object type in java.lang.*. - - Although these proper Objects include a constructor and a xValue() method that allow for - explicit conversion between primitives and the corresponding Object type if programmers - were required to explicitly perform this conversion every time it would rapidly become - tedious for no real benefits. To address this the language designers introduced the - concepts of "autoboxing" and a corresponding unboxing which can happen implicitly. Thus it - becomes legal to write: - - Collection c = new ArrayList(); - double d1 = 0; - c.add(d1); // 1: void add(Double); - double d2 = c.iterator().next(); // 2: Double next(); - - The conversions required to allow lines commented 1: and 2: to compile are inserted - implicitly. - - When it comes to wrapping primitives from C or C++ code to Java SWIG by default take the path - most expected. This means that double in C++ is represented by double in Java etc. as expected. - Normally this behaviour is ideal, however when it comes to wrapping C++ templates which are - being mapped onto implementations of Java interfaces this behaviour is unhelpful because it - is a syntax error in Java to claim to implement Collection instead of - Collection. - - So to transparently allow a C++ template when wrapped to Java to accept template type - parameters of primitive, struct, enum etc. fluidly from the user perspective we need to support - the same mapping, outside of the normal default. - - This autobox typemap exists to solve exactly that problem. With it we can map primitives onto - the corresponding java.lang.* type, whilst mapping all other types onto type that they would - usually map onto. (That is to say it falls back to simply be the result of the jstype typemap - for all non-primitive types). - - So for example if a given container template in exists in C++: - - template - struct ExampleContainer { - typedef T value_type; - // ..... - }; - - When wrapped in Java we'd like it to implement the Collection interface correctly, even for - primitives. With these autobox typemaps we can now simply write the following for example: - - %typemap(javabase) ExampleContainer "Collection<$typemap(autobox,$1_basetype::value_type)>" - - Which does exactly the right thing for both primitive and non-primitive types. - -*/ -%define AUTOBOX(CTYPE, JTYPE) -%typemap(autobox) CTYPE, const CTYPE& "JTYPE" -%enddef -AUTOBOX(double, Double) -AUTOBOX(float, Float) -AUTOBOX(boolean, Boolean) -AUTOBOX(signed char, Byte) -AUTOBOX(short, Short) -AUTOBOX(int, Integer) -AUTOBOX(long, Long) -AUTOBOX(SWIGTYPE, $typemap(jstype,$1_basetype)) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index ac786910a..804223efd 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -1,5 +1,4 @@ %include -%include %{ #include @@ -61,7 +60,7 @@ namespace std { * interface and give "natural" semantics to Java users of the C++ iterator) */ //%typemap(javaclassmodifiers) iterator "public class" - //%typemap(javainterfaces) iterator "ListIterator<$typemap(autobox,$1_basetype::value_type)>" + //%typemap(javainterfaces) iterator "ListIterator<$typemap(jboxtype,$1_basetype::value_type)>" struct iterator { %extend { @@ -141,9 +140,9 @@ namespace std { import java.util.Collection; %} -%typemap(javabase) std::list "AbstractSequentialList<$typemap(autobox,$1_basetype::value_type)>" +%typemap(javabase) std::list "AbstractSequentialList<$typemap(jboxtype,$1_basetype::value_type)>" -#define JAVA_VALUE_TYPE $typemap(autobox,$1_basetype::value_type) +#define JAVA_VALUE_TYPE $typemap(jboxtype,$1_basetype::value_type) #define JAVA_ITERATOR_TYPE Iterator %typemap(javacode,noblock=1) std::list { From 0695cb72cb9727ea8ffbe7a41674f91a8f389a3c Mon Sep 17 00:00:00 2001 From: Alan Woodland Date: Mon, 5 Jun 2017 22:09:41 +0100 Subject: [PATCH 0560/2031] re-enabled li_std_list test --- Examples/test-suite/common.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index f68451f87..11b1446e0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -600,8 +600,8 @@ CPP_STD_TEST_CASES += \ smart_pointer_inherit \ template_typedef_fnc \ template_type_namespace \ - template_opaque -# li_std_list + template_opaque \ + li_std_list ifndef SKIP_CPP_STD_CASES From 00b0c5b8ea91493378bdc2e7c8fb6588c7d8e795 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Jun 2017 06:59:23 +0100 Subject: [PATCH 0561/2031] Testcase fix for name clash in tcl headers --- Examples/test-suite/cpp11_constexpr.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i index ef08a49c3..755efb0e0 100644 --- a/Examples/test-suite/cpp11_constexpr.i +++ b/Examples/test-suite/cpp11_constexpr.i @@ -6,14 +6,14 @@ %inline %{ #ifdef SWIG -#define CONST const +#define SWIGTESTCONST const #else -#define CONST +#define SWIGTESTCONST #endif constexpr int AAA = 10; constexpr const int BBB = 20; constexpr int CCC() { return 30; } -constexpr CONST int DDD() { return 40; } +constexpr SWIGTESTCONST int DDD() { return 40; } constexpr int XXX() { return 10; } constexpr int YYY = XXX() + 100; @@ -23,7 +23,7 @@ struct ConstExpressions { static constexpr int KKK = 200; static const int LLL = 300; constexpr int MMM() { return 400; } - constexpr CONST int NNN() { return 500; } + constexpr SWIGTESTCONST int NNN() { return 500; } // Regression tests for support added in SWIG 3.0.4: static constexpr const int JJJ1 = 101; constexpr static int KKK1 = 201; From b08d6ddbad85c1c38cbec8c53e1c5adb10be0f67 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Jun 2017 07:14:18 +0100 Subject: [PATCH 0562/2031] Temporarily disable failing tests --- Examples/test-suite/go/Makefile.in | 3 +++ Examples/test-suite/scilab/Makefile.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index b7be554d7..385f91002 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -38,6 +38,9 @@ CPP_TEST_CASES = \ MULTI_CPP_TEST_CASES = \ go_subdir_import +FAILING_CPP_TESTS = \ + import_fragments \ + include $(srcdir)/../common.mk INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in index 483ed2439..ee0c19f6a 100644 --- a/Examples/test-suite/scilab/Makefile.in +++ b/Examples/test-suite/scilab/Makefile.in @@ -27,6 +27,9 @@ CPP_STD_TEST_CASES += \ li_std_container_typemaps \ li_std_string_extra \ +FAILING_MULTI_CPP_TESTS = \ + import_stl \ + include $(srcdir)/../common.mk # Overriden variables From 5d5fd5b1224bfba952328e1b2dcd09bea269456b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Jun 2017 19:56:59 +0100 Subject: [PATCH 0563/2031] Fix scilab fragment dependency problem in STL headers import_stl test now working again --- Examples/test-suite/scilab/Makefile.in | 3 --- Lib/scilab/scicontainer.swg | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in index ee0c19f6a..483ed2439 100644 --- a/Examples/test-suite/scilab/Makefile.in +++ b/Examples/test-suite/scilab/Makefile.in @@ -27,9 +27,6 @@ CPP_STD_TEST_CASES += \ li_std_container_typemaps \ li_std_string_extra \ -FAILING_MULTI_CPP_TESTS = \ - import_stl \ - include $(srcdir)/../common.mk # Overriden variables diff --git a/Lib/scilab/scicontainer.swg b/Lib/scilab/scicontainer.swg index 2cc44b8e5..f6078690b 100644 --- a/Lib/scilab/scicontainer.swg +++ b/Lib/scilab/scicontainer.swg @@ -42,7 +42,9 @@ %fragment("SciSequence_Cont", "header", fragment="StdTraits", - fragment="SwigSciIterator_T") + fragment="SwigSciIterator_T", + fragment=SWIG_Traits_Sequence_frag(ptr), + fragment=SWIG_Traits_SequenceItem_frag(ptr)) { namespace swig { @@ -334,8 +336,7 @@ namespace swig %fragment("StdSequenceTraits","header", fragment="StdTraits", - fragment="SciSequence_Cont", - fragment=SWIG_Traits_SequenceItem_frag(ptr)) + fragment="SciSequence_Cont") { namespace swig { template From 8855ef2b482c09da9255079b0fac92d08c8308fb Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 13 Jun 2017 17:32:37 +1200 Subject: [PATCH 0564/2031] [Perl] Fix testsuite to work without . in @INC "." was removed from @INC in Perl 5.26 for security reasons, and has also been removed from older versions in some distros. Fixes https://github.com/swig/swig/issues/997 reported by lfam. --- CHANGES.current | 6 ++++++ Examples/Makefile.in | 2 +- Examples/test-suite/perl5/run-perl-test.pl | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ac620c96b..6b379a94b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-13: olly + [Perl] Fix testsuite to work without . in @INC - it was removed in + Perl 5.26 for security reasons, and has also been removed from + older versions in some distros. Fixes + https://github.com/swig/swig/issues/997 reported by lfam. + 2017-06-03: wsfulton Fix %import on a file containing a file scope %fragment forced inclusion to not generate the fragment contents as %import should not result in code being generated. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7682b565f..8a88fb5ea 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -282,7 +282,7 @@ perl5_static_cpp: $(SRCDIR_SRCS) # ----------------------------------------------------------------- perl5_run: - $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE) + $(RUNTOOL) $(PERL) -I. $(PERL5_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/test-suite/perl5/run-perl-test.pl b/Examples/test-suite/perl5/run-perl-test.pl index 106bf002b..5ea4e5115 100644 --- a/Examples/test-suite/perl5/run-perl-test.pl +++ b/Examples/test-suite/perl5/run-perl-test.pl @@ -7,7 +7,7 @@ use strict; my $command = shift @ARGV; -my $output = `$^X $command 2>&1`; +my $output = `$^X -I. $command 2>&1`; die "SWIG Perl test failed: \n\n$output\n" if $?; From 82969b07557bd7212b20373841406d4489dc5d78 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Jun 2017 19:02:59 +0100 Subject: [PATCH 0565/2031] Fix warning in generated code - traits_asptr. Visual Studio 2015 debug builds: error C4703: potentially uninitialized local pointer variable 'p' used --- Lib/octave/octstdcommon.swg | 2 +- Lib/python/pystdcommon.swg | 2 +- Lib/r/rstdcommon.swg | 2 +- Lib/ruby/rubystdcommon.swg | 2 +- Lib/scilab/scistdcommon.swg | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg index 799d369a7..b3b3d0048 100644 --- a/Lib/octave/octstdcommon.swg +++ b/Lib/octave/octstdcommon.swg @@ -41,7 +41,7 @@ namespace swig { template struct traits_asptr { static int asptr(const octave_value& obj, Type **val) { - Type *p; + Type *p = 0; swig_type_info *descriptor = type_info(); int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res)) { diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 8372426a0..93ee34bc7 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -45,7 +45,7 @@ namespace swig { template struct traits_asptr { static int asptr(PyObject *obj, Type **val) { - Type *p; + Type *p = 0; swig_type_info *descriptor = type_info(); int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res)) { diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg index e6c873a07..557dac71b 100644 --- a/Lib/r/rstdcommon.swg +++ b/Lib/r/rstdcommon.swg @@ -39,7 +39,7 @@ namespace swig { template struct traits_asptr { static int asptr(SWIG_Object obj, Type **val) { - Type *p; + Type *p = 0; swig_type_info *descriptor = type_info(); int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res)) { diff --git a/Lib/ruby/rubystdcommon.swg b/Lib/ruby/rubystdcommon.swg index 5cbdb430d..c34dacefb 100644 --- a/Lib/ruby/rubystdcommon.swg +++ b/Lib/ruby/rubystdcommon.swg @@ -53,7 +53,7 @@ namespace swig { template struct traits_asptr { static int asptr(VALUE obj, Type **val) { - Type *p; + Type *p = 0; swig_type_info *descriptor = type_info(); int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res)) { diff --git a/Lib/scilab/scistdcommon.swg b/Lib/scilab/scistdcommon.swg index 63f3ca164..975e93a7b 100644 --- a/Lib/scilab/scistdcommon.swg +++ b/Lib/scilab/scistdcommon.swg @@ -41,7 +41,7 @@ namespace swig { template struct traits_asptr { static int asptr(const SwigSciObject& obj, Type **val) { - Type *p; + Type *p = 0; swig_type_info *descriptor = type_info(); int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res)) { From 5b0611dbcd65399a5167db7aa1d2424220d072f6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Jun 2017 19:36:35 +0100 Subject: [PATCH 0566/2031] Fix compiler flags used during R testing CFLAGS and CXXFLAGS were not being passed properly when compiling wrappers. --- Examples/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 8a88fb5ea..e29a7608a 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1693,7 +1693,7 @@ r: $(SRCDIR_SRCS) ifneq ($(SRCDIR_SRCS),) $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(R_CFLAGS) $(SRCDIR_SRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) + +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" PKG_CFLAGS="$(CFLAGS)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) # ---------------------------------------------------------------- # Build a R dynamically loadable module (C++) @@ -1703,7 +1703,7 @@ r_cpp: $(SRCDIR_CXXSRCS) ifneq ($(SRCDIR_CXXSRCS),) $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(R_CFLAGS) $(SRCDIR_CXXSRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) + +( PKG_CPPFLAGS="$(CPPFLAGS) $(INCLUDES)" PKG_CXXFLAGS="$(CXXFLAGS)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) # ----------------------------------------------------------------- # Run R example From 6a7cd97fe9f3186b1105bd063fb2eb117dd3c87d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 07:02:07 +0100 Subject: [PATCH 0567/2031] Fix R function pointer wrappers containing lvalue and rvalue reference parameters --- CHANGES.current | 3 ++ Examples/test-suite/cpp11_rvalue_reference2.i | 9 +++--- Examples/test-suite/funcptr_cpp.i | 2 ++ Source/Modules/r.cxx | 31 ++++++++++++------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6b379a94b..7c879fb28 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-16: wsfulton + [R] Fix wrapping function pointers containing rvalue and lvalue reference parameters. + 2017-06-13: olly [Perl] Fix testsuite to work without . in @INC - it was removed in Perl 5.26 for security reasons, and has also been removed from diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i index d532e29f3..dd6c98d0b 100644 --- a/Examples/test-suite/cpp11_rvalue_reference2.i +++ b/Examples/test-suite/cpp11_rvalue_reference2.i @@ -55,10 +55,11 @@ short && func(short &&i) { return std::move(i); } Thingy getit() { return Thingy(22, std::move(glob)); } void rvalrefFunction1(int &&v = (int &&)5) {} -void rvalrefFunctionBYVAL(short (Thingy::*memFunc)(short)) {} -void rvalrefFunctionLVALUE(short &(Thingy::*memFunc)(short &)) {} -void rvalrefFunction2(short && (Thingy::*memFunc)(short &&)) {} -void rvalrefFunction3(short && (*memFunc)(short &&)) {} +void rvalrefFunctionBYVAL(short (Thingy::*fptr)(short)) {} +void rvalrefFunctionPTR(short * (*fptr)(short *)) {} +void rvalrefFunctionLVALUE(short & (Thingy::*fptr)(short &)) {} +void rvalrefFunction2(short && (Thingy::*fptr)(short &&)) {} +void rvalrefFunction3(short && (*fptr)(short &&)) {} template struct RemoveReference { typedef T type; diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i index b63749dc1..8e05d308d 100644 --- a/Examples/test-suite/funcptr_cpp.i +++ b/Examples/test-suite/funcptr_cpp.i @@ -15,6 +15,8 @@ int & addByReference(const int &a, int b) { static int val; val = a+b; return va int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); } int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); } int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } +int call4(int & (*d)(int &, int *), int a, int b) { return d(a, &b); } +int call5(int & (*d)(int &, int const * const), int a, int b) { return d(a, &b); } %} %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 74130aac3..1c8533064 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -573,7 +573,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *lname; if (!arg && Cmp(Getattr(p, "type"), "void")) { - lname = NewStringf("s_arg%d", i+1); + lname = NewStringf("arg%d", i+1); Setattr(p, "name", lname); } else lname = arg; @@ -616,19 +616,25 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { for(i = 0; p; i++) { SwigType *tt = Getattr(p, "type"); SwigType *name = Getattr(p, "name"); + SwigType *swig_parm_name = NewStringf("swigarg_%s", name); String *tm = Getattr(p, "tmap:out"); - Printf(f->def, "%s %s", SwigType_str(tt, 0), name); - if(tm) { - Replaceall(tm, "$1", name); - if (SwigType_isreference(tt)) { - String *tmp = NewString(""); - Append(tmp, "*"); - Append(tmp, name); - Replaceall(tm, tmp, name); + bool isVoidParm = Strcmp(tt, "void") == 0; + if (isVoidParm) + Printf(f->def, "%s", SwigType_str(tt, 0)); + else + Printf(f->def, "%s %s", SwigType_str(tt, 0), swig_parm_name); + if (tm) { + String *lstr = SwigType_lstr(tt, 0); + if (SwigType_isreference(tt) || SwigType_isrvalue_reference(tt)) { + Printf(f->code, "%s = (%s) &%s;\n", Getattr(p, "lname"), lstr, swig_parm_name); + } else if (!isVoidParm) { + Printf(f->code, "%s = (%s) %s;\n", Getattr(p, "lname"), lstr, swig_parm_name); } + Replaceall(tm, "$1", name); Replaceall(tm, "$result", "r_tmp"); replaceRClass(tm, Getattr(p,"type")); Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Delete(lstr); } Printf(setExprElements, "%s\n", tm); @@ -697,10 +703,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL); Printv(f->code, "\n", UnProtectWrapupCode, NIL); - if (SwigType_isreference(rettype)) { + if (SwigType_isreference(rettype)) { Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL); - } else if(!isVoidType) + } else if (SwigType_isrvalue_reference(rettype)) { + Printv(f->code, "return std::move(*", Swig_cresult_name(), ");\n", NIL); + } else if (!isVoidType) { Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL); + } Printv(f->code, "\n}\n", NIL); Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn"); From b2e494f018edb2b358f39eaee2e925620f61a81a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 07:38:26 +0100 Subject: [PATCH 0568/2031] Add R to c++11 and c++14 Travis testing --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index fd70c9160..5f09c87ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -236,6 +236,10 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=r SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required @@ -260,6 +264,10 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=r SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required From 67190cbb2e61e7d13d063e4fba81ee9ff13aa971 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 09:04:36 +0100 Subject: [PATCH 0569/2031] Add import_fragment test back in to Go test-suite --- Examples/test-suite/go/Makefile.in | 3 --- Examples/test-suite/import_fragments_a.i | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index 385f91002..b7be554d7 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -38,9 +38,6 @@ CPP_TEST_CASES = \ MULTI_CPP_TEST_CASES = \ go_subdir_import -FAILING_CPP_TESTS = \ - import_fragments \ - include $(srcdir)/../common.mk INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) diff --git a/Examples/test-suite/import_fragments_a.i b/Examples/test-suite/import_fragments_a.i index 7478a1e86..1babea95f 100644 --- a/Examples/test-suite/import_fragments_a.i +++ b/Examples/test-suite/import_fragments_a.i @@ -1,4 +1,7 @@ +#if !defined(SWIGGO) +// Prevent Go from generating a Go module import - this test is not set up as true multiple modules %module import_fragments_a +#endif %fragment("ImportA1", "header") %{ ImportA1_this_will_not_compile; From 95e8643d7077548392ce1bcccd9d1a4d961383ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 19:13:58 +0100 Subject: [PATCH 0570/2031] Rename func to funk in tests to avoid Go keyword problems --- Examples/test-suite/cpp11_default_delete.i | 8 ++++---- Examples/test-suite/cpp11_rvalue_reference2.i | 2 +- Examples/test-suite/cpp11_type_aliasing.i | 2 +- .../java/java_director_assumeoverride_runme.java | 2 +- Examples/test-suite/java_director_assumeoverride.i | 4 ++-- Examples/test-suite/javascript/null_pointer_runme.js | 2 +- Examples/test-suite/name_warnings.i | 4 +--- Examples/test-suite/null_pointer.i | 4 +--- Examples/test-suite/octave/null_pointer_runme.m | 2 +- Examples/test-suite/octave/octave_cell_deref_runme.m | 4 ++-- Examples/test-suite/octave_cell_deref.i | 2 +- Examples/test-suite/python/python_append_runme.py | 2 +- Examples/test-suite/python_append.i | 6 +++--- Examples/test-suite/scilab/null_pointer_runme.sci | 2 +- Examples/test-suite/simutry.i | 6 +++--- Examples/test-suite/tcl/null_pointer_runme.tcl | 2 +- 16 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i index 79c02cddc..b5e84ed51 100644 --- a/Examples/test-suite/cpp11_default_delete.i +++ b/Examples/test-suite/cpp11_default_delete.i @@ -17,20 +17,20 @@ public: }; struct A1 { - void func(int i) {} + void funk(int i) {} A1() = default; ~A1() = default; - void func(double i) = delete; /* Don't cast double to int. Compiler returns an error */ + void funk(double i) = delete; /* Don't cast double to int. Compiler returns an error */ private: A1(const A1&); }; A1::A1(const A1&) = default; struct A2 { - void func(int i) {} + void funk(int i) {} virtual void fff(int) = delete; virtual ~A2() = default; - template void func(T) = delete; + template void funk(T) = delete; }; struct trivial { diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i index dd6c98d0b..9aaf4accb 100644 --- a/Examples/test-suite/cpp11_rvalue_reference2.i +++ b/Examples/test-suite/cpp11_rvalue_reference2.i @@ -51,7 +51,7 @@ int glob = 123; Thingy &&globalrrval = Thingy(55, std::move(glob)); -short && func(short &&i) { return std::move(i); } +short && funk(short &&i) { return std::move(i); } Thingy getit() { return Thingy(22, std::move(glob)); } void rvalrefFunction1(int &&v = (int &&)5) {} diff --git a/Examples/test-suite/cpp11_type_aliasing.i b/Examples/test-suite/cpp11_type_aliasing.i index 2f6ea3aa7..abc1642c4 100644 --- a/Examples/test-suite/cpp11_type_aliasing.i +++ b/Examples/test-suite/cpp11_type_aliasing.i @@ -108,5 +108,5 @@ PairSubclass::data_t plus1(PairSubclass::const_ref_data_t x) { return x + 1; } using callback_t = int(*)(int); callback_t get_callback() { return mult2; } -int call(callback_t func, int param) { return func(param); } +int call(callback_t funk, int param) { return funk(param); } %} diff --git a/Examples/test-suite/java/java_director_assumeoverride_runme.java b/Examples/test-suite/java/java_director_assumeoverride_runme.java index e876a79c9..6c4d6918e 100644 --- a/Examples/test-suite/java/java_director_assumeoverride_runme.java +++ b/Examples/test-suite/java/java_director_assumeoverride_runme.java @@ -18,7 +18,7 @@ public class java_director_assumeoverride_runme { public static void main(String argv[]) { OverrideMe overrideMe = new MyOverrideMe(); - // MyOverrideMe doesn't actually override func(), but because assumeoverride + // MyOverrideMe doesn't actually override funk(), but because assumeoverride // was set to true, the C++ side will believe it was overridden. if (!java_director_assumeoverride.isFuncOverridden(overrideMe)) { throw new RuntimeException ( "isFuncOverridden()" ); diff --git a/Examples/test-suite/java_director_assumeoverride.i b/Examples/test-suite/java_director_assumeoverride.i index cddebb4d7..f0eb37049 100644 --- a/Examples/test-suite/java_director_assumeoverride.i +++ b/Examples/test-suite/java_director_assumeoverride.i @@ -4,7 +4,7 @@ class OverrideMe { public: virtual ~OverrideMe() {} - virtual void func() {}; + virtual void funk() {}; }; #include "java_director_assumeoverride_wrap.h" @@ -23,7 +23,7 @@ bool isFuncOverridden(OverrideMe* f) { class OverrideMe { public: virtual ~OverrideMe(); - virtual void func(); + virtual void funk(); }; bool isFuncOverridden(OverrideMe* f); diff --git a/Examples/test-suite/javascript/null_pointer_runme.js b/Examples/test-suite/javascript/null_pointer_runme.js index 7c0d61244..8a9b61186 100644 --- a/Examples/test-suite/javascript/null_pointer_runme.js +++ b/Examples/test-suite/javascript/null_pointer_runme.js @@ -1,6 +1,6 @@ var null_pointer = require("null_pointer"); -if (!null_pointer.func(null)) { +if (!null_pointer.funk(null)) { throw new Error("Javascript 'null' should be converted into NULL."); } diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index 3455c03bf..0b62ec5d7 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -40,9 +40,7 @@ namespace std #endif virtual ~A() {} -#ifndef SWIGGO // func is a keyword in Go. - virtual int func() = 0; -#endif + virtual int funk() = 0; private: typedef complex False; }; diff --git a/Examples/test-suite/null_pointer.i b/Examples/test-suite/null_pointer.i index 0da827f99..f40d6929f 100644 --- a/Examples/test-suite/null_pointer.i +++ b/Examples/test-suite/null_pointer.i @@ -1,11 +1,9 @@ %module null_pointer -%warnfilter(SWIGWARN_PARSE_KEYWORD) func; // 'func' is a Go keyword, renamed as 'Xfunc' - %inline { struct A {}; - bool func(A* a) { + bool funk(A* a) { return !a; } diff --git a/Examples/test-suite/octave/null_pointer_runme.m b/Examples/test-suite/octave/null_pointer_runme.m index 9d55d8be2..72362f451 100644 --- a/Examples/test-suite/octave/null_pointer_runme.m +++ b/Examples/test-suite/octave/null_pointer_runme.m @@ -5,4 +5,4 @@ endif null_pointer; -assert(func([])); +assert(funk([])); diff --git a/Examples/test-suite/octave/octave_cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m index d00d17282..0a45999d3 100644 --- a/Examples/test-suite/octave/octave_cell_deref_runme.m +++ b/Examples/test-suite/octave/octave_cell_deref_runme.m @@ -5,8 +5,8 @@ endif octave_cell_deref; -assert(func("hello")); -assert(func({"hello"})); +assert(funk("hello")); +assert(funk({"hello"})); c = func2(); assert(strcmp(c{1}, "hello")); diff --git a/Examples/test-suite/octave_cell_deref.i b/Examples/test-suite/octave_cell_deref.i index 2e92ec4de..272ba7c99 100644 --- a/Examples/test-suite/octave_cell_deref.i +++ b/Examples/test-suite/octave_cell_deref.i @@ -1,7 +1,7 @@ %module octave_cell_deref %inline { - bool func(const char* s) { + bool funk(const char* s) { return !strcmp("hello",s); } diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index 6675f3509..ce5514dff 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -9,7 +9,7 @@ if is_python_builtin(): exit(0) t = Test() -t.func() +t.funk() if is_new_style_class(Test): t.static_func() else: diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 2a71b5784..049494319 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -17,11 +17,11 @@ def clearstaticpath(): staticfuncpath = None %} -%pythonappend Test::func %{ +%pythonappend Test::funk %{ funcpath = os.path.dirname(funcpath) %} -%pythonprepend Test::func %{ +%pythonprepend Test::funk %{ global funcpath funcpath = mypath %} @@ -46,7 +46,7 @@ import os.path class Test { public: static void static_func() {}; - void func() {}; + void funk() {}; }; #ifdef SWIGPYTHON_BUILTIN diff --git a/Examples/test-suite/scilab/null_pointer_runme.sci b/Examples/test-suite/scilab/null_pointer_runme.sci index 2c693d259..dab59acf8 100644 --- a/Examples/test-suite/scilab/null_pointer_runme.sci +++ b/Examples/test-suite/scilab/null_pointer_runme.sci @@ -2,6 +2,6 @@ exec("swigtest.start", -1); p = getnull(); checkequal(SWIG_this(p), 0, "SWIG_this(p)"); -checkequal(func(p), %T, "func(p)"); +checkequal(funk(p), %T, "funk(p)"); exec("swigtest.quit", -1); diff --git a/Examples/test-suite/simutry.i b/Examples/test-suite/simutry.i index addea14db..ad45da425 100644 --- a/Examples/test-suite/simutry.i +++ b/Examples/test-suite/simutry.i @@ -23,7 +23,7 @@ namespace simuPOP { } - virtual int func() const + virtual int funk() const { return m_pop.m_a; } }; @@ -32,7 +32,7 @@ namespace simuPOP struct DerivedOperator: public Operator { DerivedOperator(int a):Operator(a){} - virtual int func() const + virtual int funk() const { return 2*this->m_pop.m_a; } }; @@ -90,7 +90,7 @@ namespace simuPOP void test( const std::vector< Operator*>& para) { for( size_t i =0; i < para.size(); ++i) - para[i]->func(); + para[i]->funk(); } } } diff --git a/Examples/test-suite/tcl/null_pointer_runme.tcl b/Examples/test-suite/tcl/null_pointer_runme.tcl index be99c7166..7ed87c153 100644 --- a/Examples/test-suite/tcl/null_pointer_runme.tcl +++ b/Examples/test-suite/tcl/null_pointer_runme.tcl @@ -3,7 +3,7 @@ if [ catch { load ./null_pointer[info sharedlibextension] null_pointer} err_msg } set a [A] -if {[func $a] != 0} { +if {[funk $a] != 0} { puts stderr "null_pointer test 1 failed" exit 1 } From 11aa71b93919213bf3952ecf08ff1a5496bb1f83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 19:20:50 +0100 Subject: [PATCH 0571/2031] Make sure warning and error messages are not split up They could be split up by other processes writing to stdout at the same time. --- CHANGES.current | 4 ++++ Source/Swig/error.c | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7c879fb28..65180f4e0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-16: wsfulton + Make sure warning and error messages are not split up by other processes writing to + stdout at the same time. + 2017-06-16: wsfulton [R] Fix wrapping function pointers containing rvalue and lvalue reference parameters. diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 2c93cfb21..1dde06652 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -106,13 +106,16 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c } if (warnall || wrn) { String *formatted_filename = format_filename(filename); + String *full_message = NewString(""); if (wnum) { - Printf(stderr, wrn_wnum_fmt, formatted_filename, line, wnum); + Printf(full_message, wrn_wnum_fmt, formatted_filename, line, wnum); } else { - Printf(stderr, wrn_nnum_fmt, formatted_filename, line); + Printf(full_message, wrn_nnum_fmt, formatted_filename, line); } - Printf(stderr, "%s", msg); + Printf(full_message, "%s", msg); + Printv(stderr, full_message, NIL); nwarning++; + Delete(full_message); Delete(formatted_filename); } Delete(out); @@ -128,6 +131,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { va_list ap; String *formatted_filename = NULL; + String *full_message = NULL; if (silence) return; @@ -136,14 +140,17 @@ void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, .. va_start(ap, fmt); formatted_filename = format_filename(filename); + full_message = NewString(""); if (line > 0) { - Printf(stderr, err_line_fmt, formatted_filename, line); + Printf(full_message, err_line_fmt, formatted_filename, line); } else { - Printf(stderr, err_eof_fmt, formatted_filename); + Printf(full_message, err_eof_fmt, formatted_filename); } - vPrintf(stderr, fmt, ap); + vPrintf(full_message, fmt, ap); + Printv(stderr, full_message, NIL); va_end(ap); nerrors++; + Delete(full_message); Delete(formatted_filename); } From 5679bce94fdc586c8a239ccc9368d3390c6d1444 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Jun 2017 20:36:52 +0100 Subject: [PATCH 0572/2031] Revert "Add R to c++11 and c++14 Travis testing" This reverts commit b2e494f018edb2b358f39eaee2e925620f61a81a. --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f09c87ec..fd70c9160 100644 --- a/.travis.yml +++ b/.travis.yml @@ -236,10 +236,6 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty - - os: linux - env: SWIGLANG=r SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 - sudo: required - dist: trusty - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required @@ -264,10 +260,6 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required dist: trusty - - os: linux - env: SWIGLANG=r SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 - sudo: required - dist: trusty - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required From 5386bf2a2484c0db5d8dcb9c050e480b30f2d28e Mon Sep 17 00:00:00 2001 From: Fabrice Benhamouda Date: Thu, 15 Jun 2017 17:18:52 -0400 Subject: [PATCH 0573/2031] fix swig/swig#600 and fix swig/swig#955 --- Examples/go/callback/gocallback.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/go/callback/gocallback.go b/Examples/go/callback/gocallback.go index 20fd0627a..881f505e0 100644 --- a/Examples/go/callback/gocallback.go +++ b/Examples/go/callback/gocallback.go @@ -36,6 +36,6 @@ func DeleteGoCallback(p GoCallback) { p.deleteCallback() } -func (p *goCallback) Run() { +func (p *overwrittenMethodsOnCallback) Run() { fmt.Println("GoCallback.Run") } From d5d4f180217d38897b44ecbcd892dafe4a129a93 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 17 Jun 2017 11:41:24 +1200 Subject: [PATCH 0574/2031] [Go] Fix Go callback example Fixes github #600, #955, #1000 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 65180f4e0..584fa6cb8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-17: fabrice102 + [Go] Fix Go callback example. Fixes github #600, #955, #1000. + 2017-06-16: wsfulton Make sure warning and error messages are not split up by other processes writing to stdout at the same time. From f12d14d1be51e21f39ff806175d6ff2eb7210f90 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 17 Jun 2017 10:32:26 +0100 Subject: [PATCH 0575/2031] Turn on C++11 Travis testing for R R tests use 'R CMD SHLIB' to compile the wrappers and there is no easy way to change the compiler this tool uses. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index fd70c9160..709bc4989 100644 --- a/.travis.yml +++ b/.travis.yml @@ -236,6 +236,10 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=r CPP11=1 # Note: making 'R CMD SHLIB' use a different compiler is non-trivial + sudo: required + dist: trusty - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required From 9d9acba737aa1dd2a35e725c57a52c5b667ce453 Mon Sep 17 00:00:00 2001 From: FUTATSUKI Yasuhito Date: Mon, 19 Jun 2017 15:37:29 +0900 Subject: [PATCH 0576/2031] Apply patch to configure with 2to3 rename for 3.0.12 --- Examples/Makefile.in | 2 +- Examples/test-suite/python/Makefile.in | 2 +- configure.ac | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index e29a7608a..6d4260d13 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -386,7 +386,7 @@ else PYSCRIPT = $(RUNME)3.py endif -PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` +PY2TO3 = @PY2TO3PROG@ `@PY2TO3PROG@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` python_run: $(PYSCRIPT) ifneq (,$(PEP8)) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index b6da00aa5..f62a31826 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -16,7 +16,7 @@ PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py PY3SCRIPTSUFFIX = _runme3.py -PY2TO3 = 2to3 -x import +PY2TO3 = @PY2TO3PROG@ -x import ifeq (,$(PY3)) SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) diff --git a/configure.ac b/configure.ac index 25ea0a243..130882c16 100644 --- a/configure.ac +++ b/configure.ac @@ -902,6 +902,11 @@ if test -n "$PYINCLUDE" || test -n "$PY3INCLUDE" ; then AC_MSG_RESULT($pep8_version) fi fi +AC_ARG_WITH(2to3, AS_HELP_STRING([--with-2to3], [alternate 2to3 executable]) +AS_HELP_STRING([--with-2to3=path], [Specify 2to3 utility path]),[ PY2TO3="$withval"], [PY2TO3="2to3"]) +if [ ! -z "$PYTHON3" ] ; then + AC_CHECK_PROGS(PY2TO3PROG, $PY2TO3) +fi #---------------------------------------------------------------- # Look for Perl5 From a706aa146c92298339d48100a1236909aecee265 Mon Sep 17 00:00:00 2001 From: FUTATSUKI YASUHITO Date: Mon, 19 Jun 2017 18:34:38 +0900 Subject: [PATCH 0577/2031] CCache: take care of program prefix/suffix on configure --- CCache/Makefile.in | 43 ++++++++++++++++++++++--------------------- CCache/ccache.h | 2 -- CCache/configure.ac | 14 ++++++++++++++ CCache/test.sh | 7 ++++++- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 67fd3f363..845b9c6ef 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -8,6 +8,7 @@ bindir=@bindir@ mandir=@mandir@ INSTALLCMD=@INSTALL@ PACKAGE_NAME=@PACKAGE_NAME@ +MYNAME=@MYNAME@ # Soft link test can be skipped on systems that don't support soft linking NOSOFTLINKSTEST= @@ -25,46 +26,46 @@ 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) +all: $(MYNAME)$(EXEEXT) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ./config.status $(SHELL) ./config.status # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile -docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html +docs: $(srcdir)/$(MYNAME).1 $(srcdir)/web/$(MYNAME)-man.html -$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) +$(MYNAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -$(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo - -yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo +$(srcdir)/$(MYNAME).1: $(srcdir)/ccache.yo + -yodl2man -o $(srcdir)/$(MYNAME).1 $(srcdir)/ccache.yo -$(srcdir)/web/ccache-man.html: $(srcdir)/ccache.yo - yodl2html -o $(srcdir)/web/ccache-man.html $(srcdir)/ccache.yo +$(srcdir)/web/$(MYNAME)-man.html: $(srcdir)/ccache.yo + yodl2html -o $(srcdir)/web/$(MYNMAE)-man.html $(srcdir)/ccache.yo -install: $(PACKAGE_NAME)$(EXEEXT) - @echo "Installing $(PACKAGE_NAME)" - @echo "Installing $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)" +install: $(MYNAME)$(EXEEXT) + @echo "Installing $(MYNAME)" + @echo "Installing $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} - ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) + ${INSTALLCMD} -m 755 $(MYNAME)$(EXEEXT) $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT) -install-docs: $(srcdir)/$(PACKAGE_NAME).1 - @echo "Installing $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1" +install-docs: $(srcdir)/$(MYNAME).1 + @echo "Installing $(DESTDIR)${mandir}/man1/$(MYNAME).1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 - ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 + ${INSTALLCMD} -m 644 $(srcdir)/$(MYNAME).1 $(DESTDIR)${mandir}/man1/$(MYNAME).1 -uninstall: $(PACKAGE_NAME)$(EXEEXT) - rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) +uninstall: $(MYNAME)$(EXEEXT) + rm -f $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT) -uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1 - rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 +uninstall-docs: $(srcdir)/$(MYNAME).1 + rm -f $(DESTDIR)${mandir}/man1/$(MYNAME).1 clean: - /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) + /bin/rm -f $(OBJS) *~ $(MYNAME)$(EXEEXT) test: test.sh - SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' $(srcdir)/test.sh + SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(MYNAME)' $(srcdir)/test.sh check: test @@ -73,7 +74,7 @@ distclean: clean /bin/rm -rf autom4te.cache maintainer-clean: distclean - /bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/ccache-man.html + /bin/rm -f $(srcdir)/$(MYNAME).1 $(srcdir)/web/$(MYNAME)-man.html # FIXME: To fix this, test.sh needs to be able to take ccache from the diff --git a/CCache/ccache.h b/CCache/ccache.h index a79d88322..99a63483b 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -51,8 +51,6 @@ #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 -#define MYNAME PACKAGE_NAME - #define LIMIT_MULTIPLE 0.8 /* default maximum cache size */ diff --git a/CCache/configure.ac b/CCache/configure.ac index dfbf86dbc..d5f0c38c2 100644 --- a/CCache/configure.ac +++ b/CCache/configure.ac @@ -14,6 +14,20 @@ AC_PROG_CPP AC_PROG_INSTALL AC_ARG_PROGRAM # for program_transform_name +AC_SUBST(MYNAME) +if test "x$program_prefix" != "xNONE" -a "x$program_prefix" != "x" +then + MYNAME="$program_prefix$PACKAGE_NAME" +else + MYNAME="$PACKAGE_NAME" +fi +if test "x$program_suffix" != "xNONE" -a "x$program_suffix" != "x" +then + MYNAME="$MYNAME$program_suffix" +fi + +AC_DEFINE_UNQUOTED(MYNAME, "$MYNAME", [Define my program name]) + AC_DEFINE([_GNU_SOURCE], 1, [Define _GNU_SOURCE so that we get all necessary prototypes]) diff --git a/CCache/test.sh b/CCache/test.sh index 438e782cd..7e69149ff 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -20,7 +20,12 @@ fi PATH="`echo $PATH | \ sed -e 's!:/usr\(/local\)*/lib\([0-9]\)*/ccache\(/\)*!!g'`" -CCACHE=../ccache-swig +if test -n "$CCACHE"; then + CCACHE="$CCACHE" +else + CCACHE=../ccache-swig +fi + TESTDIR=test.$$ test_failed() { From 93895f5a5101ba77e599f25ed241d60a85de290d Mon Sep 17 00:00:00 2001 From: FUTATSUKI YASUHITO Date: Tue, 20 Jun 2017 01:33:10 +0900 Subject: [PATCH 0578/2031] Add header file in CCache for _WIN32 environment --- CCache/Makefile.in | 2 +- CCache/ccache.h | 2 +- CCache/config_w32.h.in | 3 +++ CCache/configure.ac | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 CCache/config_w32.h.in diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 845b9c6ef..a718c8985 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -70,7 +70,7 @@ test: test.sh check: test distclean: clean - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h config_win32.h /bin/rm -rf autom4te.cache maintainer-clean: distclean diff --git a/CCache/ccache.h b/CCache/ccache.h index 99a63483b..f1c7f3eef 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -6,7 +6,7 @@ #include "config.h" #else #include -#define PACKAGE_NAME "ccache-swig.exe" +#include "config_w32.h" #endif #include diff --git a/CCache/config_w32.h.in b/CCache/config_w32.h.in new file mode 100644 index 000000000..35b1c5571 --- /dev/null +++ b/CCache/config_w32.h.in @@ -0,0 +1,3 @@ +#if !defined(MYNAME) +#define MYNAME "@MYNAME@@EXEEXT@" +#endif diff --git a/CCache/configure.ac b/CCache/configure.ac index d5f0c38c2..84d8fe835 100644 --- a/CCache/configure.ac +++ b/CCache/configure.ac @@ -7,6 +7,7 @@ AC_CONFIG_SRCDIR([ccache.h]) AC_MSG_NOTICE([Configuring ccache]) AC_CONFIG_HEADER(config.h) +AC_CONFIG_FILES([config_w32.h]) dnl Checks for programs. AC_PROG_CC From 529906f181249e5def19f7a9d0f6e48b7c3d101b Mon Sep 17 00:00:00 2001 From: FUTATSUKI YASUHITO Date: Tue, 20 Jun 2017 01:47:07 +0900 Subject: [PATCH 0579/2031] Embed fixed string '.exe' to CCache/config_win32.h even if EXEEXT is empty. --- CCache/config_w32.h.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCache/config_w32.h.in b/CCache/config_w32.h.in index 35b1c5571..74094b4bd 100644 --- a/CCache/config_w32.h.in +++ b/CCache/config_w32.h.in @@ -1,3 +1,3 @@ #if !defined(MYNAME) -#define MYNAME "@MYNAME@@EXEEXT@" +#define MYNAME "@MYNAME@.exe" #endif From 687cf9c9c1b886ef4a828b2c29610183e9fef26d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Jun 2017 19:12:23 +0100 Subject: [PATCH 0580/2031] Add missing %python:maybecall to operator overloads. This ensures NotImplemented is returned on error so that the Python interpreter will handle the operators correctly instead of throwing an exception. NotImplemented was not being returned for non-builtin wrappers when the operator overload did not have a function overload. See PEP 207 and https://docs.python.org/3/library/constants.html#NotImplemented Mentioned in SF patch #303 and SF bug #1208. --- CHANGES.current | 21 +++++++ Doc/Manual/Python.html | 8 +++ .../python/python_richcompare_runme.py | 56 +++++++++++++++++++ Source/Modules/python.cxx | 19 +++++-- 4 files changed, 98 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 584fa6cb8..f9177f1a6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,27 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-19: wsfulton + [Python] Fix handling of rich comparisons when wrapping overloaded operators: + + operator< operator<= operator> operator>= operator== operator!= + + Previously a TypeError was always thrown if the type was not correct. NotImplemented + is now returned from these wrapped functions if the type being compared with is + not correct. The subsequent behaviour varies between different versions of Python + and the comparison function being used, but is now consistent with normal Python + behaviour. For example, for the first 4 operator overloads above, a TypeError + 'unorderable types' is thrown in Python 3, but Python 2 will return True or False. + NotImplemented should be returned when the comparison cannot be done, see PEP 207 and + https://docs.python.org/3/library/constants.html#NotImplemented + + Note that the bug was only present when overloaded operators did not also have a + function overload. + + Fixes SF bug #1208 (3441262) and SF patch #303. + + *** POTENTIAL INCOMPATIBILITY *** + 2017-06-17: fabrice102 [Go] Fix Go callback example. Fixes github #600, #955, #1000. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 9b3afbdd9..1b73c08b7 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1894,6 +1894,14 @@ 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.

    +

    +Operator overloading is implemented in the pyopers.swg library file. +In particular overloaded operators are marked with the python:maybecall feature, also known as %pythonmaybecall. +This feature forces SWIG to generate code that return an instance of Python's NotImplemented +instead of raising an exception when the comparison fails, that is, on any kind of error. +This follows the guidelines in PEP 207 - Rich Comparisons and NotImplemented Python constant. +

    +

    36.3.12 C++ namespaces

    diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py index a68da2f98..f7c7a673b 100644 --- a/Examples/test-suite/python/python_richcompare_runme.py +++ b/Examples/test-suite/python/python_richcompare_runme.py @@ -1,4 +1,12 @@ import python_richcompare +import sys + +def check_unorderable_types(exception): + if str(exception).find("unorderable types") == -1: + raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2] + +def is_new_style_class(cls): + return hasattr(cls, "__class__") base1 = python_richcompare.BaseClass(1) base2 = python_richcompare.BaseClass(2) @@ -65,6 +73,18 @@ if (b1 == a1): raise RuntimeError( "Comparing equivalent instances of different subclasses, == returned True") +# Check comparison to other objects +#------------------------------------------------------------------------------- +if (base1 == 42) : + raise RuntimeError("Comparing class to incompatible type, == returned True") +if not (base1 != 42) : + raise RuntimeError("Comparing class to incompatible type, != returned False") + +if (a1 == 42) : + raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, == returned True") +if not (a1 != 42) : + raise RuntimeError("Comparing class (with overloaded operator ==) to incompatible type, != returned False") + # Check inequalities #------------------------------------------------------------------------- @@ -80,6 +100,42 @@ if not (a2 >= b2): if not (a2 <= b2): raise RuntimeError("operator<= failed") +# Check inequalities to other objects +#------------------------------------------------------------------------------- +if is_new_style_class(python_richcompare.BaseClass): + # Skip testing -classic option + if sys.version_info[0:2] < (3, 0): + if (base1 < 42): + raise RuntimeError("Comparing class to incompatible type, < returned True") + if (base1 <= 42): + raise RuntimeError("Comparing class to incompatible type, <= returned True") + if not (base1 > 42): + raise RuntimeError("Comparing class to incompatible type, > returned False") + if not (base1 >= 42): + raise RuntimeError("Comparing class to incompatible type, >= returned False") + else: + # Python 3 throws: TypeError: unorderable types + try: + res = base1 < 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 <= 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 > 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 >= 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + # Check inequalities used for ordering #------------------------------------------------------------------------- diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index cf81827cb..802c36cc7 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2573,8 +2573,8 @@ public: if (GetFlag(n, "feature:python:maybecall")) { Append(f->code, "fail:\n"); - Append(f->code, "Py_INCREF(Py_NotImplemented);\n"); - Append(f->code, "return Py_NotImplemented;\n"); + Append(f->code, " Py_INCREF(Py_NotImplemented);\n"); + Append(f->code, " return Py_NotImplemented;\n"); } else { Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) @@ -2586,7 +2586,7 @@ public: Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); - Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError," + Printf(f->code, " SWIG_SetErrorMsg(PyExc_NotImplementedError," "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Printf(f->code, "return %s;\n", builtin_ctor ? "-1" : "0"); Delete(protoTypes); @@ -3211,10 +3211,17 @@ public: if (need_cleanup) { Printv(f->code, cleanup, NIL); } - if (builtin_ctor) + if (builtin_ctor) { Printv(f->code, " return -1;\n", NIL); - else - Printv(f->code, " return NULL;\n", NIL); + } else { + if (GetFlag(n, "feature:python:maybecall")) { + Append(f->code, " PyErr_Clear();\n"); + Append(f->code, " Py_INCREF(Py_NotImplemented);\n"); + Append(f->code, " return Py_NotImplemented;\n"); + } else { + Printv(f->code, " return NULL;\n", NIL); + } + } if (funpack) { From 4ab2aff0a10aec829177f6db05b5ab09094aa596 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Jun 2017 19:43:51 +0100 Subject: [PATCH 0581/2031] Fix Python unordered_map and ordered_map compilation error when using -builtin --- Lib/python/std_unordered_map.i | 2 +- Lib/python/std_unordered_multimap.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 8ab4b1447..6bd34077b 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -53,7 +53,7 @@ static PyObject *from(const unordered_map_type& unordered_map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); + return SWIG_InternalNewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_map.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index f46a94b16..312b29e61 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -50,7 +50,7 @@ static PyObject *from(const unordered_multimap_type& unordered_multimap) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { - return SWIG_NewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); + return SWIG_InternalNewPointerObj(new unordered_multimap_type(unordered_multimap), desc, SWIG_POINTER_OWN); } else { size_type size = unordered_multimap.size(); Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; From b56d7c0539e398ec74d4e354f36beaaa2c758514 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Jun 2017 20:32:32 +0100 Subject: [PATCH 0582/2031] Python builtin C++11 STL fixes Compilation fixes for std::multimap, std::unordered_map and std::unordered_multimap. --- Lib/python/std_multimap.i | 10 ++++++++++ Lib/python/std_unordered_map.i | 10 ++++++++++ Lib/python/std_unordered_multimap.i | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 3209fb0f8..21c84b009 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -68,7 +68,17 @@ %define %swig_multimap_methods(Type...) %swig_map_common(Type); + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; +#endif + %extend { + // This will be called through the mp_ass_subscript slot to delete an entry. + void __setitem__(const key_type& key) { + self->erase(key); + } + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 6bd34077b..53f6aa283 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -226,7 +226,17 @@ %define %swig_unordered_map_methods(Map...) %swig_unordered_map_common(Map) + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; +#endif + %extend { + // This will be called through the mp_ass_subscript slot to delete an entry. + void __setitem__(const key_type& key) { + self->erase(key); + } + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index 312b29e61..4dbc2a4dd 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -75,7 +75,17 @@ %define %swig_unordered_multimap_methods(Type...) %swig_unordered_map_common(Type); + +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_ass_subscript", functype="objobjargproc") __setitem__; +#endif + %extend { + // This will be called through the mp_ass_subscript slot to delete an entry. + void __setitem__(const key_type& key) { + self->erase(key); + } + void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { self->insert(Type::value_type(key,x)); } From e0c0017839eddfac297458c5d5f3e547027b856e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Jun 2017 20:33:32 +0100 Subject: [PATCH 0583/2031] Remove failing runtime tests for now using Python 2 and -builtin --- Examples/test-suite/python/cpp11_hash_tables_runme.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index 39388fd20..d8c63208a 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -6,8 +6,10 @@ def swig_assert_equal(a, b): for x in [cpp11_hash_tables.MapIntInt({1:7}), cpp11_hash_tables.MultiMapIntInt({1:7}), - cpp11_hash_tables.UnorderedMapIntInt({1:7}), - cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: +# TODO: fix for -builtin +# cpp11_hash_tables.UnorderedMapIntInt({1:7}), +# cpp11_hash_tables.UnorderedMultiMapIntInt({1:7}) + ]: swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)]) @@ -25,7 +27,8 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}), for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: x[1] = 9 - swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) +# TODO: fix for -builtin +# swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) # Is this broken?... # swig_assert_equal(sorted([v for v in x[1]]), [7, 9]) From 057b1dc02884f408d6a6e9943d619aaead575a87 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Jun 2017 20:37:09 +0100 Subject: [PATCH 0584/2031] Add Travis Python 2, C++11 and -builtin testing --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 709bc4989..57f20eef6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -165,6 +165,10 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-builtin sudo: required dist: trusty + - os: linux + env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4 From 36b61dd0f27da90465b2b67ae5a136d2ff61274b Mon Sep 17 00:00:00 2001 From: FUTATSUKI YASUHITO Date: Tue, 20 Jun 2017 07:57:54 +0900 Subject: [PATCH 0585/2031] fix typo --- CCache/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index a718c8985..3e4609101 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -70,7 +70,7 @@ test: test.sh check: test distclean: clean - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h config_win32.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h config_w32.h /bin/rm -rf autom4te.cache maintainer-clean: distclean From 1d1d0de2d0ef53949fabcb68a7c42fd6d837e288 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Jun 2017 00:02:00 +0100 Subject: [PATCH 0586/2031] Fix python_richcompare test for Python 3.6 --- Examples/test-suite/python/python_richcompare_runme.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py index f7c7a673b..247660301 100644 --- a/Examples/test-suite/python/python_richcompare_runme.py +++ b/Examples/test-suite/python/python_richcompare_runme.py @@ -2,8 +2,9 @@ import python_richcompare import sys def check_unorderable_types(exception): - if str(exception).find("unorderable types") == -1: - raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2] +# if str(exception).find("unorderable types") == -1: +# raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2] + pass # Exception message seems to vary from one version of Python to another def is_new_style_class(cls): return hasattr(cls, "__class__") From ff53789dc90e61415b94fb82c9cd8bb9a08ac078 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Jun 2017 07:00:22 +0100 Subject: [PATCH 0587/2031] Suppress warning in testcase --- Examples/test-suite/default_args.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 8828bfe04..7959caa33 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -5,6 +5,7 @@ %{ #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) + #pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned #endif #if __GNUC__ >= 7 #pragma GCC diagnostic push From 339b62516027a98ff97749c27440a6f9f3927173 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Jun 2017 00:05:56 +0100 Subject: [PATCH 0588/2031] Add changes file entry for Ruby std::wstring support --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f9177f1a6..65cf8d127 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-21: tamuratak + [Ruby] #911 - Add std::wstring support. + 2017-06-19: wsfulton [Python] Fix handling of rich comparisons when wrapping overloaded operators: From 7be53b769237bf8f818b3f426b03655c2d3b1a1f Mon Sep 17 00:00:00 2001 From: FUTATSUKI YASUHITO Date: Wed, 21 Jun 2017 08:07:08 +0900 Subject: [PATCH 0589/2031] Apply changes requested for this pull request --- CCache/Makefile.in | 46 ++++++++++++++++++++-------------------- CCache/ccache.h | 4 +++- CCache/config_w32.h.in | 3 --- CCache/config_win32.h.in | 3 +++ CCache/configure.ac | 12 +++++------ 5 files changed, 35 insertions(+), 33 deletions(-) delete mode 100644 CCache/config_w32.h.in create mode 100644 CCache/config_win32.h.in diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 3e4609101..1a6feb40f 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -8,7 +8,7 @@ bindir=@bindir@ mandir=@mandir@ INSTALLCMD=@INSTALL@ PACKAGE_NAME=@PACKAGE_NAME@ -MYNAME=@MYNAME@ +PROGRAM_NAME=@PROGRAM_NAME@ # Soft link test can be skipped on systems that don't support soft linking NOSOFTLINKSTEST= @@ -26,55 +26,55 @@ 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: $(MYNAME)$(EXEEXT) +all: $(PROGRAM_NAME)$(EXEEXT) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ./config.status $(SHELL) ./config.status # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile -docs: $(srcdir)/$(MYNAME).1 $(srcdir)/web/$(MYNAME)-man.html +docs: $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/web/$(PROGRAM_NAME)-man.html -$(MYNAME)$(EXEEXT): $(OBJS) $(HEADERS) +$(PROGRAM_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -$(srcdir)/$(MYNAME).1: $(srcdir)/ccache.yo - -yodl2man -o $(srcdir)/$(MYNAME).1 $(srcdir)/ccache.yo +$(srcdir)/$(PROGRAM_NAME).1: $(srcdir)/ccache.yo + -yodl2man -o $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/ccache.yo -$(srcdir)/web/$(MYNAME)-man.html: $(srcdir)/ccache.yo - yodl2html -o $(srcdir)/web/$(MYNMAE)-man.html $(srcdir)/ccache.yo +$(srcdir)/web/$(PROGRAM_NAME)-man.html: $(srcdir)/ccache.yo + yodl2html -o $(srcdir)/web/$(PROGRAM_NAME)-man.html $(srcdir)/ccache.yo -install: $(MYNAME)$(EXEEXT) - @echo "Installing $(MYNAME)" - @echo "Installing $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT)" +install: $(PROGRAM_NAME)$(EXEEXT) + @echo "Installing $(PROGRAM_NAME)" + @echo "Installing $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} - ${INSTALLCMD} -m 755 $(MYNAME)$(EXEEXT) $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT) + ${INSTALLCMD} -m 755 $(PROGRAM_NAME)$(EXEEXT) $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) -install-docs: $(srcdir)/$(MYNAME).1 - @echo "Installing $(DESTDIR)${mandir}/man1/$(MYNAME).1" +install-docs: $(srcdir)/$(PROGRAM_NAME).1 + @echo "Installing $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 - ${INSTALLCMD} -m 644 $(srcdir)/$(MYNAME).1 $(DESTDIR)${mandir}/man1/$(MYNAME).1 + ${INSTALLCMD} -m 644 $(srcdir)/$(PROGRAM_NAME).1 $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 -uninstall: $(MYNAME)$(EXEEXT) - rm -f $(DESTDIR)${bindir}/$(MYNAME)$(EXEEXT) +uninstall: $(PROGRAM_NAME)$(EXEEXT) + rm -f $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) -uninstall-docs: $(srcdir)/$(MYNAME).1 - rm -f $(DESTDIR)${mandir}/man1/$(MYNAME).1 +uninstall-docs: $(srcdir)/$(PROGRAM_NAME).1 + rm -f $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 clean: - /bin/rm -f $(OBJS) *~ $(MYNAME)$(EXEEXT) + /bin/rm -f $(OBJS) *~ $(PROGRAM_NAME)$(EXEEXT) test: test.sh - SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(MYNAME)' $(srcdir)/test.sh + SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(PROGRAM_NAME)' $(srcdir)/test.sh check: test distclean: clean - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h config_w32.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status ccache_swig_config.h config_win32.h /bin/rm -rf autom4te.cache maintainer-clean: distclean - /bin/rm -f $(srcdir)/$(MYNAME).1 $(srcdir)/web/$(MYNAME)-man.html + /bin/rm -f $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/web/$(PROGRAM_NAME)-man.html # FIXME: To fix this, test.sh needs to be able to take ccache from the diff --git a/CCache/ccache.h b/CCache/ccache.h index f1c7f3eef..25e786496 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -6,7 +6,7 @@ #include "config.h" #else #include -#include "config_w32.h" +#include "config_win32.h" #endif #include @@ -51,6 +51,8 @@ #define STATUS_FATAL 4 #define STATUS_NOCACHE 5 +#define MYNAME PROGRAM_NAME + #define LIMIT_MULTIPLE 0.8 /* default maximum cache size */ diff --git a/CCache/config_w32.h.in b/CCache/config_w32.h.in deleted file mode 100644 index 74094b4bd..000000000 --- a/CCache/config_w32.h.in +++ /dev/null @@ -1,3 +0,0 @@ -#if !defined(MYNAME) -#define MYNAME "@MYNAME@.exe" -#endif diff --git a/CCache/config_win32.h.in b/CCache/config_win32.h.in new file mode 100644 index 000000000..2d5ab97e3 --- /dev/null +++ b/CCache/config_win32.h.in @@ -0,0 +1,3 @@ +#if !defined(PROGRAM_NAME) +#define PROGRAM_NAME "@PROGRAM_NAME@.exe" +#endif diff --git a/CCache/configure.ac b/CCache/configure.ac index 84d8fe835..e1c761860 100644 --- a/CCache/configure.ac +++ b/CCache/configure.ac @@ -7,7 +7,7 @@ AC_CONFIG_SRCDIR([ccache.h]) AC_MSG_NOTICE([Configuring ccache]) AC_CONFIG_HEADER(config.h) -AC_CONFIG_FILES([config_w32.h]) +AC_CONFIG_FILES([config_win32.h]) dnl Checks for programs. AC_PROG_CC @@ -15,19 +15,19 @@ AC_PROG_CPP AC_PROG_INSTALL AC_ARG_PROGRAM # for program_transform_name -AC_SUBST(MYNAME) +AC_SUBST(PROGRAM_NAME) if test "x$program_prefix" != "xNONE" -a "x$program_prefix" != "x" then - MYNAME="$program_prefix$PACKAGE_NAME" + PROGRAM_NAME="$program_prefix$PACKAGE_NAME" else - MYNAME="$PACKAGE_NAME" + PROGRAM_NAME="$PACKAGE_NAME" fi if test "x$program_suffix" != "xNONE" -a "x$program_suffix" != "x" then - MYNAME="$MYNAME$program_suffix" + PROGRAM_NAME="$PROGRAM_NAME$program_suffix" fi -AC_DEFINE_UNQUOTED(MYNAME, "$MYNAME", [Define my program name]) +AC_DEFINE_UNQUOTED(PROGRAM_NAME, "$PROGRAM_NAME", [Define my program name]) AC_DEFINE([_GNU_SOURCE], 1, [Define _GNU_SOURCE so that we get all necessary prototypes]) From 2a47918a3f8d4a50acea604b2f6355d79104496b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Jun 2017 15:35:35 +0100 Subject: [PATCH 0590/2031] Add changes entry for ccache-swig configure fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 65cf8d127..d06fba638 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-21: futatuki + #1004 - Fix ccache-swig executable name to respect configure's --program-prefix and + --program-suffix values if used. + 2017-06-21: tamuratak [Ruby] #911 - Add std::wstring support. From fa416e4d4092331d6d77129adfe9c5d202903f2f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Jun 2017 15:51:52 +0100 Subject: [PATCH 0591/2031] li_std_list testcase not working for most languages --- Examples/test-suite/common.mk | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 11b1446e0..146ada2c6 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -99,7 +99,7 @@ CPP_TEST_BROKEN += \ # Broken C test cases. (Can be run individually using: make testcase.ctest) C_TEST_BROKEN += \ - tag_no_clash_with_variable + tag_no_clash_with_variable \ # C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_CASES += \ @@ -533,7 +533,7 @@ CPP_TEST_CASES += \ virtual_vs_nonvirtual_base \ voidtest \ wallkw \ - wrapmacro + wrapmacro \ # C++11 test cases. CPP11_TEST_CASES += \ @@ -601,8 +601,6 @@ CPP_STD_TEST_CASES += \ template_typedef_fnc \ template_type_namespace \ template_opaque \ - li_std_list - ifndef SKIP_CPP_STD_CASES CPP_TEST_CASES += ${CPP_STD_TEST_CASES} @@ -666,7 +664,7 @@ C_TEST_CASES += \ typedef_struct \ typemap_subst \ union_parameter \ - unions + unions \ # Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) @@ -677,7 +675,7 @@ MULTI_CPP_TEST_CASES += \ packageoption \ mod \ template_typedef_import \ - multi_import + multi_import \ # Custom tests - tests with additional commandline options wallkw.cpptest: SWIGOPT += -Wallkw From dd25f5b722499aa1ec9220ce5b70142c869d6b26 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Jun 2017 11:47:56 +0100 Subject: [PATCH 0592/2031] Java std::list rework to be consistent with std::vector wrappers --- Lib/java/std_list.i | 274 +++++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 146 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 804223efd..70bb6e20a 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -2,56 +2,134 @@ %{ #include -#include +#include %} +%fragment("SWIG_ListSize", "header", fragment="SWIG_JavaIntFromSize_t") { +SWIGINTERN jint SWIG_ListSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) + throw std::out_of_range("list size is too large to fit into a Java int"); + return sz; +} +} + %javamethodmodifiers std::list::begin "private"; %javamethodmodifiers std::list::insert "private"; %javamethodmodifiers std::list::set "private"; -%javamethodmodifiers std::list::previous_index "private"; -%javamethodmodifiers std::list::next_index "private"; %javamethodmodifiers std::list::previous "private"; %javamethodmodifiers std::list::next "private"; %javamethodmodifiers std::list::deref "private"; %javamethodmodifiers std::list::advance "private"; -%javamethodmodifiers std::list::has_next "private"; - -/* - To conform to Java Collection interface we must return int from size(). - Unfortunately that loses precision from the integer types commonly used in - C++ implementations. Since we can't overload on return values the best - workaround here is to expose the real C++ size() return value to Java as a - long and use the javaout typemap to validate. We can then at least fails - gracefully in the case where we have a collection with > 2^31-1 items rather - than failing mysteriously. - - The use of SWIG_list_size_type here allows us to selectively %apply this to - only the cases where we have to conform to the Java interface requirement, - without interfering with other size_type usage. The intention is that - SWIG_list_size_type is both reserved and unique. (Perhaps it could live in - std_common.i later on?) -*/ -%typemap(jstype) SWIG_list_size_type "int"; -%typemap(javaout) SWIG_list_size_type { - final long result = $jnicall; - if (result > Integer.MAX_VALUE) { - throw new IndexOutOfBoundsException("Size of Collection is not representable as int"); - } - return (int)result; -} +%javamethodmodifiers std::list::doSize "private"; +%javamethodmodifiers std::list::doPreviousIndex "private"; +%javamethodmodifiers std::list::doNextIndex "private"; +%javamethodmodifiers std::list::doHasNext "private"; // Match Java style better: %rename(Iterator) std::list::iterator; %nodefaultctor std::list::iterator; +%typemap(javaimports) std::list %{ + import java.util.AbstractSequentialList; + import java.util.ListIterator; + import java.util.NoSuchElementException; + import java.util.Collection; +%} + +%typemap(javabase) std::list "AbstractSequentialList<$typemap(jboxtype, $1_basetype::value_type)>" + namespace std { template class list { + +%proxycode %{ + public $javaclassname(Collection c) { + this(); + ListIterator<$typemap(jboxtype, T)> it = listIterator(0); + // Special case the "copy constructor" here to avoid lots of cross-language calls + for (Object o : c) { + it.add(($typemap(jboxtype, T))o); + } + } + + public int size() { + return doSize(); + } + + public ListIterator<$typemap(jboxtype, T)> listIterator(int index) { + return new ListIterator<$typemap(jboxtype, T)>() { + private Iterator pos; + private Iterator last; + + private ListIterator<$typemap(jboxtype, T)> init(int index) { + pos = $javaclassname.this.begin(); + pos = pos.advance_unchecked(index); + return this; + } + + public void add($typemap(jboxtype, T) v) { + // Technically we can invalidate last here, but this makes more sense + last = $javaclassname.this.insert(pos, v); + } + + public void set($typemap(jboxtype, T) v) { + if (null == last) { + throw new IllegalStateException(); + } + last.set_unchecked(v); + } + + public void remove() { + if (null == last) { + throw new IllegalStateException(); + } + $javaclassname.this.remove(last); + last = null; + } + + public int previousIndex() { + return $javaclassname.this.doPreviousIndex(pos); + } + + public int nextIndex() { + return $javaclassname.this.doNextIndex(pos); + } + + public $typemap(jboxtype, T) previous() { + if (previousIndex() < 0) { + throw new NoSuchElementException(); + } + last = pos; + pos = pos.previous_unchecked(); + return last.deref_unchecked(); + } + + public $typemap(jboxtype, T) next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + last = pos; + pos = pos.next_unchecked(); + return last.deref_unchecked(); + } + + public boolean hasPrevious() { + // This call to previousIndex() will be much slower than the hasNext() implementation, but it's simpler like this with C++ forward iterators + return previousIndex() != -1; + } + + public boolean hasNext() { + return $javaclassname.this.doHasNext(pos); + } + }.init(index); + } +%} + public: typedef size_t size_type; typedef T value_type; - typedef T& reference; - %apply SWIG_list_size_type { size_type next_index, size_type previous_index, size_type size }; + typedef T &reference; /* * We'd actually be better off having the nested class *not* be static in the wrapper @@ -60,22 +138,22 @@ namespace std { * interface and give "natural" semantics to Java users of the C++ iterator) */ //%typemap(javaclassmodifiers) iterator "public class" - //%typemap(javainterfaces) iterator "ListIterator<$typemap(jboxtype,$1_basetype::value_type)>" + //%typemap(javainterfaces) iterator "ListIterator<$typemap(jboxtype, $1_basetype::value_type)>" struct iterator { %extend { - void set_unchecked(const value_type& v) { + void set_unchecked(const value_type &v) { **$self = v; } iterator next_unchecked() const { - std::list::iterator ret=*$self; + std::list::iterator ret = *$self; ++ret; return ret; } iterator previous_unchecked() const { - std::list::iterator ret=*$self; + std::list::iterator ret = *$self; --ret; return ret; } @@ -85,141 +163,45 @@ namespace std { } iterator advance_unchecked(const size_type index) const { - std::list::iterator ret=*$self; + std::list::iterator ret = *$self; std::advance(ret, index); return ret; } } }; - void assign(size_type n, const value_type &val); - - bool empty() const; - - list(size_type n, const value_type &value=value_type()); - list(const list &o); list(); + list(size_type n, const value_type &value = value_type()); + list(const list &o); ~list(); - - size_type max_size () const; - + void assign(size_type n, const value_type &val); + bool empty() const; + size_type max_size() const; void pop_back(); void pop_front(); void push_back(const value_type &x); void push_front(const value_type &x); - - size_type size() const; - - // Although sort() is nice it makes operator<() mandatory which it probably shouldn't be - //void sort(); - iterator begin(); iterator end(); iterator insert(iterator pos, const value_type &v); %extend { - size_type previous_index(const iterator& pos) const { - return pos == self->begin() ? -1 : std::distance(self->begin(), static_cast::const_iterator>(pos)); + %fragment("SWIG_ListSize"); + jint doSize() const throw (std::out_of_range) { + return SWIG_ListSize(self->size()); } - size_type next_index(const iterator& pos) const { - return pos == self->end() ? self->size() : std::distance(self->begin(), static_cast::const_iterator>(pos)); + jint doPreviousIndex(const iterator &pos) const { + return pos == self->begin() ? -1 : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); } - bool has_next(const iterator& pos) const { + jint doNextIndex(const iterator &pos) const { + return pos == self->end() ? self->size() : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); + } + + bool doHasNext(const iterator &pos) const { return pos != $self->end(); } } }; } - -%typemap(javaimports) std::list %{ - import java.util.AbstractSequentialList; - import java.util.ListIterator; - import java.util.NoSuchElementException; - import java.util.Collection; -%} - -%typemap(javabase) std::list "AbstractSequentialList<$typemap(jboxtype,$1_basetype::value_type)>" - -#define JAVA_VALUE_TYPE $typemap(jboxtype,$1_basetype::value_type) -#define JAVA_ITERATOR_TYPE Iterator - -%typemap(javacode,noblock=1) std::list { - public $javaclassname(Collection c) { - this(); - ListIterator it = listIterator(0); - // We should special case the "copy constructor" here to avoid lots of cross-language calls - for (Object o: c) { - it.add((JAVA_VALUE_TYPE)o); - } - } - - public ListIterator listIterator(int index) { - return new ListIterator() { - private JAVA_ITERATOR_TYPE pos; - private JAVA_ITERATOR_TYPE last; - - private ListIterator init(int index) { - pos = $javaclassname.this.begin(); - pos = pos.advance_unchecked(index); - return this; - } - - public void add(JAVA_VALUE_TYPE v) { - // Technically we can invalidate last here, but this makes more sense - last=$javaclassname.this.insert(pos, v); - } - - public void set(JAVA_VALUE_TYPE v) { - if (null==last) { - throw new IllegalStateException(); - } - last.set_unchecked(v); - } - - public void remove() { - if (null==last) { - throw new IllegalStateException(); - } - $javaclassname.this.remove(last); - last=null; - } - - public int previousIndex() { - return $javaclassname.this.previous_index(pos); - } - - public int nextIndex() { - return $javaclassname.this.next_index(pos); - } - - public JAVA_VALUE_TYPE previous() { - if (previousIndex() < 0) { - throw new NoSuchElementException(); - } - last = pos; - pos = pos.previous_unchecked(); - return last.deref_unchecked(); - } - - public JAVA_VALUE_TYPE next() { - if (!hasNext()) { - throw new NoSuchElementException(); - } - last = pos; - pos = pos.next_unchecked(); - return last.deref_unchecked(); - } - - public boolean hasPrevious() { - // This call to previousIndex() will be much slower than the hasNext() implementation, but it's simpler like this with C++ forward iterators - return previousIndex() != -1; - } - - public boolean hasNext() { - return $javaclassname.this.has_next(pos); - } - }.init(index); - } -} From 02a00db9f5a765daeb7e663a783340edbe2bf51e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Jun 2017 20:30:11 +0100 Subject: [PATCH 0593/2031] Remove redundant code --- Lib/java/std_list.i | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 70bb6e20a..070f6a606 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -16,11 +16,6 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { %javamethodmodifiers std::list::begin "private"; %javamethodmodifiers std::list::insert "private"; -%javamethodmodifiers std::list::set "private"; -%javamethodmodifiers std::list::previous "private"; -%javamethodmodifiers std::list::next "private"; -%javamethodmodifiers std::list::deref "private"; -%javamethodmodifiers std::list::advance "private"; %javamethodmodifiers std::list::doSize "private"; %javamethodmodifiers std::list::doPreviousIndex "private"; %javamethodmodifiers std::list::doNextIndex "private"; From 7b7f921ccb9e1e4de193f073d07af87445ecb393 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Jun 2017 20:38:19 +0100 Subject: [PATCH 0594/2031] cosmetics --- Lib/java/std_list.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 070f6a606..f9986b11e 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -157,7 +157,7 @@ namespace std { return **$self; } - iterator advance_unchecked(const size_type index) const { + iterator advance_unchecked(size_type index) const { std::list::iterator ret = *$self; std::advance(ret, index); return ret; From 430376e1159eb578537de7c88b1dc9264d4128a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Jun 2017 21:49:58 +0100 Subject: [PATCH 0595/2031] Java std::list - fully qualifiy Java class name to avoid potential name ambiguity --- Lib/java/std_list.i | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index f9986b11e..c6f074417 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -26,22 +26,15 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { %nodefaultctor std::list::iterator; -%typemap(javaimports) std::list %{ - import java.util.AbstractSequentialList; - import java.util.ListIterator; - import java.util.NoSuchElementException; - import java.util.Collection; -%} - -%typemap(javabase) std::list "AbstractSequentialList<$typemap(jboxtype, $1_basetype::value_type)>" +%typemap(javabase) std::list "java.util.AbstractSequentialList<$typemap(jboxtype, $1_basetype::value_type)>" namespace std { template class list { %proxycode %{ - public $javaclassname(Collection c) { + public $javaclassname(java.util.Collection c) { this(); - ListIterator<$typemap(jboxtype, T)> it = listIterator(0); + java.util.ListIterator<$typemap(jboxtype, T)> it = listIterator(0); // Special case the "copy constructor" here to avoid lots of cross-language calls for (Object o : c) { it.add(($typemap(jboxtype, T))o); @@ -52,12 +45,12 @@ namespace std { return doSize(); } - public ListIterator<$typemap(jboxtype, T)> listIterator(int index) { - return new ListIterator<$typemap(jboxtype, T)>() { + public java.util.ListIterator<$typemap(jboxtype, T)> listIterator(int index) { + return new java.util.ListIterator<$typemap(jboxtype, T)>() { private Iterator pos; private Iterator last; - private ListIterator<$typemap(jboxtype, T)> init(int index) { + private java.util.ListIterator<$typemap(jboxtype, T)> init(int index) { pos = $javaclassname.this.begin(); pos = pos.advance_unchecked(index); return this; @@ -93,7 +86,7 @@ namespace std { public $typemap(jboxtype, T) previous() { if (previousIndex() < 0) { - throw new NoSuchElementException(); + throw new java.util.NoSuchElementException(); } last = pos; pos = pos.previous_unchecked(); @@ -102,7 +95,7 @@ namespace std { public $typemap(jboxtype, T) next() { if (!hasNext()) { - throw new NoSuchElementException(); + throw new java.util.NoSuchElementException(); } last = pos; pos = pos.next_unchecked(); @@ -133,7 +126,7 @@ namespace std { * interface and give "natural" semantics to Java users of the C++ iterator) */ //%typemap(javaclassmodifiers) iterator "public class" - //%typemap(javainterfaces) iterator "ListIterator<$typemap(jboxtype, $1_basetype::value_type)>" + //%typemap(javainterfaces) iterator "java.util.ListIterator<$typemap(jboxtype, $1_basetype::value_type)>" struct iterator { %extend { From 109a60add684e1991285c35b024b53a076f45737 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Jun 2017 22:17:59 +0100 Subject: [PATCH 0596/2031] javabase typemap improvement for std::list --- Lib/java/std_list.i | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index c6f074417..38742632e 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -26,11 +26,10 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { %nodefaultctor std::list::iterator; -%typemap(javabase) std::list "java.util.AbstractSequentialList<$typemap(jboxtype, $1_basetype::value_type)>" - namespace std { template class list { +%typemap(javabase) std::list< T > "java.util.AbstractSequentialList<$typemap(jboxtype, T)>" %proxycode %{ public $javaclassname(java.util.Collection c) { this(); From 80ffb169c173537c08355e75d4ade4462b38c015 Mon Sep 17 00:00:00 2001 From: Michael Thon Date: Tue, 7 Jun 2016 02:12:12 +0200 Subject: [PATCH 0597/2031] [Python] fix and improve default argument handling 1. Fix negative octals. Currently not handled correctly by `-py3` (unusual case, but incorrect). 2. Fix arguments of type "octal + something" (e.g. `0640 | 04`). Currently drops everything after the first octal. Nasty! 3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always "False" (unusual case, but incorrect). 4. Remove special handling of "TRUE" and "FALSE" from `convertValue` since there's no reason these have to match "true" and "false". 5. Remove the Python 2 vs. Python 3 distinction based on the `-py3` flag. Now the same python code is produced for default arguments for Python 2 and Python 3. For this, octal default arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This is required, as Python 2 and Python 3 have incompatible syntax for octal literals. Fixes #707 --- CHANGES.current | 21 +++ Examples/test-suite/default_args.i | 14 +- .../test-suite/python/default_args_runme.py | 36 +++- Source/Modules/python.cxx | 163 ++++++++---------- 4 files changed, 129 insertions(+), 105 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f9177f1a6..d3c025363 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,27 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-23: m7thon + [Python] fix and improve default argument handling: + + 1. Fix negative octals. Currently not handled correctly by `-py3` + (unusual case, but incorrect). + 2. Fix arguments of type "octal + something" (e.g. `0640 | 04`). + Currently drops everything after the first octal. Nasty! + 3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always + "False" (unusual case, but incorrect). + 4. Remove special handling of "TRUE" and "FALSE" from + `convertValue` since there's no reason these have to match + "true" and "false". + 5. Remove the Python 2 vs. Python 3 distinction based on the + `-py3` flag. Now the same python code is produced for default + arguments for Python 2 and Python 3. For this, octal default + arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This + is required, as Python 2 and Python 3 have incompatible syntax + for octal literals. + + Fixes #707 + 2017-06-19: wsfulton [Python] Fix handling of rich comparisons when wrapping overloaded operators: diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 8828bfe04..28e64d40e 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -18,14 +18,20 @@ #include // All kinds of numbers: hex, octal (which pose special problems to Python), negative... - void trickyvalue1(int first, int pos = -1) {} - void trickyvalue2(int first, unsigned rgb = 0xabcdef) {} - void trickyvalue3(int first, int mode = 0644) {} + + class TrickyInPython { + public: + int value_m1(int first, int pos = -1) { return pos; } + unsigned value_0xabcdef(int first, unsigned rgb = 0xabcdef) { return rgb; } + int value_0644(int first, int mode = 0644) { return mode; } + int value_perm(int first, int mode = 0640 | 0004) { return mode; } + int value_m01(int first, int val = -01) { return val; } + bool booltest2(bool x = 0 | 1) { return x; } + }; void doublevalue1(int first, double num = 0.0e-1) {} void doublevalue2(int first, double num = -0.0E2) {} - // Long long arguments are not handled at Python level currently but still work. void seek(long long offset = 0LL) {} void seek2(unsigned long long offset = 0ULL) {} void seek3(long offset = 0L) {} diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index b7c4cb508..ddaf2cd4f 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -115,15 +115,39 @@ def run(module_name): if Klass_inc().val != 0: raise RuntimeError("Klass::inc failed") - default_args.trickyvalue1(10) - default_args.trickyvalue1(10, 10) - default_args.trickyvalue2(10) - default_args.trickyvalue2(10, 10) - default_args.trickyvalue3(10) - default_args.trickyvalue3(10, 10) + tricky_failure = False + tricky = default_args.TrickyInPython() + if tricky.value_m1(10) != -1: + print "trickyvalue_m1 failed" + tricky_failure = True + if tricky.value_m1(10, 10) != 10: + print "trickyvalue_m1 failed" + tricky_failure = True + if tricky.value_0xabcdef(10) != 0xabcdef: + print "trickyvalue_0xabcdef failed" + tricky_failure = True + if tricky.value_0644(10) != 420: + print "trickyvalue_0644 failed" + tricky_failure = True + if tricky.value_perm(10) != 420: + print "trickyvalue_perm failed" + tricky_failure = True + if tricky.value_m01(10) != -1: + print "trickyvalue_m01 failed" + tricky_failure = True + if not tricky.booltest2(): + print "booltest2 failed" + tricky_failure = True + + if tricky_failure: + raise RuntimeError + default_args.seek() default_args.seek(10) + if not default_args.booltest(): + raise RuntimeError("booltest failed") + if default_args.slightly_off_square(10) != 102: raise RuntimeError diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 802c36cc7..a55c8ab09 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2030,6 +2030,66 @@ public: return doc; } + /* ------------------------------------------------------------ + * convertIntegerValue() + * + * Check if string v is an integer and can be represented in + * Python. If so, return an appropriate Python representation, + * otherwise (or if we are unsure), return NIL. + * ------------------------------------------------------------ */ + String *convertIntegerValue(String *v, SwigType *resolved_type) { + const char *const s = Char(v); + char *end; + String *result = NIL; + + // Check if this is an integer number in any base. + long value = strtol(s, &end, 0); + if (errno == ERANGE || end == s) + return NIL; + if (*end != '\0') { + // If there is a suffix after the number, we can safely ignore any + // combination of "l" and "u", but not anything else. + for (char *p = end; *p != '\0'; ++p) { + switch (*p) { + case 'l': + case 'L': + case 'u': + case 'U': + break; + default: + return NIL; + } + } + } + // So now we are certain that we are indeed dealing with an integer + // that has a representation as long given by value. + + if (Cmp(resolved_type, "bool") == 0) + // Allow integers as the default value for a bool parameter. + return NewString(value ? "True" : "False"); + + if (value == 0) + return NewString(SwigType_ispointer(resolved_type) ? "None" : "0"); + + // v may still be octal or hexadecimal: + const char *p = s; + if (*p == '+' || *p == '-') + ++p; + if (*p == '0' && *(p+1) != 'x' && *(p+1) != 'X') { + // This must have been an octal number. This is the only case we + // cannot use in Python directly, since Python 2 and 3 use non- + // compatible representations. + result = NewString(*s == '-' ? "int('-" : "int('"); + String *octal_string = NewStringWithSize(p, (int) (end - p)); + Append(result, octal_string); + Append(result, "', 8)"); + Delete(octal_string); + return result; + } + result = *end == '\0' ? v : NewStringWithSize(s, (int) (end - s)); + return result; + } + /* ------------------------------------------------------------ * convertDoubleValue() * @@ -2078,111 +2138,24 @@ public: * convertValue() * * Check if string v can be a Python value literal or a - * constant. Return NIL if it isn't. + * constant. Return an equivalent Python representation, + * or NIL if it isn't, or we are unsure. * ------------------------------------------------------------ */ String *convertValue(String *v, SwigType *type) { const char *const s = Char(v); - char *end; String *result = NIL; - bool fail = false; - SwigType *resolved_type = 0; + SwigType *resolved_type = SwigType_typedef_resolve_all(type); - // Check if this is a number in any base. - long value = strtol(s, &end, 0); - (void) value; - if (end != s) { - if (errno == ERANGE) { - // There was an overflow, we could try representing the value as Python - // long integer literal, but for now don't bother with it. - fail = true; - } else { - if (*end != '\0') { - // If there is a suffix after the number, we can safely ignore any - // combination of "l" and "u", but not anything else (again, stuff like - // "LL" could be handled, but we don't bother to do it currently). - bool seen_long = false; - for (char * p = end; *p != '\0'; ++p) { - switch (*p) { - case 'l': - case 'L': - // Bail out on "LL". - if (seen_long) { - fail = true; - break; - } - seen_long = true; - break; - - case 'u': - case 'U': - if (value < 0) - fail = true; - break; - - default: - // Except that our suffix could actually be the fractional part of - // a floating point number, so we still have to check for this. - result = convertDoubleValue(v); - } - } - } - - if (!fail) { - // Allow integers as the default value for a bool parameter. - resolved_type = SwigType_typedef_resolve_all(type); - if (Cmp(resolved_type, "bool") == 0) { - result = NewString(value ? "True" : "False"); - } else { - // Deal with the values starting with 0 first as they can be octal or - // hexadecimal numbers or even pointers. - if (s[0] == '0') { - if (Len(v) == 1) { - // This is just a lone 0, but it needs to be represented differently - // in Python depending on whether it's a zero or a null pointer. - if (SwigType_ispointer(resolved_type)) - result = NewString("None"); - else - result = v; - } else if (s[1] == 'x' || s[1] == 'X') { - // This must have been a hex number, we can use it directly in Python, - // so nothing to do here. - } else { - // This must have been an octal number, we have to change its prefix - // to be "0o" in Python 3 only (and as long as we still support Python - // 2.5, this can't be done unconditionally). - if (py3) { - if (end - s > 1) { - result = NewString("0o"); - Append(result, NewStringWithSize(s + 1, (int)(end - s - 1))); - } - } - } - } - - // Avoid unnecessary string allocation in the common case when we don't - // need to remove any suffix. - if (!result) - result = *end == '\0' ? v : NewStringWithSize(s, (int)(end - s)); - } - } - } - } - - // Check if this is a floating point number (notice that it wasn't - // necessarily parsed as a long above, consider e.g. ".123"). - if (!fail && !result) { + result = convertIntegerValue(v, resolved_type); + if (!result) { result = convertDoubleValue(v); if (!result) { - if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0) + if (Strcmp(v, "true") == 0) result = NewString("True"); - else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0) + else if (Strcmp(v, "false") == 0) result = NewString("False"); - else if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) { - if (!resolved_type) - resolved_type = SwigType_typedef_resolve_all(type); + else if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0) result = SwigType_ispointer(resolved_type) ? NewString("None") : NewString("0"); - } - // This could also be an enum type, default value of which could be // representable in Python if it doesn't include any scope (which could, // but currently is not, translated). From 2425c8d6d896dfb4eacb1b5877a5fa6274fde8d8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 23 Jun 2017 14:54:50 +1200 Subject: [PATCH 0598/2031] Don't handle cases like -1U as Python constants --- Source/Modules/python.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a55c8ab09..73706f240 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2047,14 +2047,18 @@ public: if (errno == ERANGE || end == s) return NIL; if (*end != '\0') { - // If there is a suffix after the number, we can safely ignore any - // combination of "l" and "u", but not anything else. + // If there is a suffix after the number, we can safely ignore "l" + // and (provided the number is unsigned) "u", and also combinations of + // these, but not anything else. for (char *p = end; *p != '\0'; ++p) { switch (*p) { case 'l': case 'L': + break; case 'u': case 'U': + if (value < 0) + return NIL; break; default: return NIL; From a2267a815288076e31e27e4397d78e6f2c1b0627 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 14:19:12 +0100 Subject: [PATCH 0599/2031] Memory leak fixes in Python default argument handling --- Source/Modules/python.cxx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 73706f240..581064046 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1874,6 +1874,7 @@ public: String *new_value = convertValue(value, Getattr(p, "type")); if (new_value) Printf(doc, "=%s", new_value); + Delete(new_value); } Delete(type_str); Delete(made_name); @@ -2090,7 +2091,7 @@ public: Delete(octal_string); return result; } - result = *end == '\0' ? v : NewStringWithSize(s, (int) (end - s)); + result = *end == '\0' ? Copy(v) : NewStringWithSize(s, (int) (end - s)); return result; } @@ -2132,7 +2133,7 @@ public: // Avoid unnecessary string allocation in the common case when we don't // need to remove any suffix. - return *end == '\0' ? v : NewStringWithSize(s, (int)(end - s)); + return *end == '\0' ? Copy(v) : NewStringWithSize(s, (int)(end - s)); } return NIL; @@ -2167,7 +2168,7 @@ public: Node *lookup = Swig_symbol_clookup(v, 0); if (lookup) { if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0) - result = Getattr(lookup, "sym:name"); + result = Copy(Getattr(lookup, "sym:name")); } } } @@ -2214,10 +2215,12 @@ public: if (Getattr(p, "tmap:default")) return false; - if (String *value = Getattr(p, "value")) { - String *type = Getattr(p, "type"); - if (!convertValue(value, type)) + String *value = Getattr(p, "value"); + if (value) { + String *convertedValue = convertValue(value, Getattr(p, "type")); + if (!convertedValue) return false; + Delete(convertedValue); } } From 005ff93dbdabb9ce0708d74588c36b04aff1e658 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 14:38:26 +0100 Subject: [PATCH 0600/2031] Fix construction from dict for std::multimap std::unordered_multimap (Python 3) --- Lib/python/std_multimap.i | 6 +++++- Lib/python/std_unordered_multimap.i | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 21c84b009..f78a5277c 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -23,7 +23,11 @@ int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); - return traits_asptr_stdseq, std::pair >::asptr(items, val); +%#if PY_VERSION_HEX >= 0x03000000 + /* In Python 3.x the ".items()" method returns a dict_items object */ + items = PySequence_Fast(items, ".items() didn't return a sequence!"); +%#endif + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; swig_type_info *descriptor = swig::type_info(); diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index 4dbc2a4dd..6d7def900 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -30,7 +30,11 @@ int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); - return traits_asptr_stdseq, std::pair >::asptr(items, val); +%#if PY_VERSION_HEX >= 0x03000000 + /* In Python 3.x the ".items()" method returns a dict_items object */ + items = PySequence_Fast(items, ".items() didn't return a sequence!"); +%#endif + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_multimap_type *p; swig_type_info *descriptor = swig::type_info(); From c6bff3731e59cb820bfaddae4d205a689bcde343 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 14:51:25 +0100 Subject: [PATCH 0601/2031] Add Python 3 C++11 Travis testing --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 57f20eef6..e2a47e6f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -169,6 +169,10 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 PY3=3 VER=3.5 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4 From 990c5973657bbf25d50d65fc3d40d8bf3b4df0a9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 15:26:53 +0100 Subject: [PATCH 0602/2031] Wrap std::list::empty as isEmpty in Java --- Examples/test-suite/java/li_std_list_runme.java | 7 ++++++- Lib/java/std_list.i | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index de53a9fa6..c3c666c51 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -16,7 +16,12 @@ public class li_std_list_runme { IntList v1 = new IntList(); DoubleList v2 = new DoubleList(); - v1.add(123); + if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed"); + if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed"); + if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed"); + if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed"); + if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed"); + if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); StructList v4 = new StructList(); diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 38742632e..8714be0f4 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -162,6 +162,7 @@ namespace std { list(const list &o); ~list(); void assign(size_type n, const value_type &val); + %rename(isEmpty) empty; bool empty() const; size_type max_size() const; void pop_back(); From 428b332e6845093abc68a1f704db714beaa86cf8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 15:35:10 +0100 Subject: [PATCH 0603/2031] Improve Java std::list std::vector runtime tests and wrap std::list::clear --- .../test-suite/java/li_std_list_runme.java | 13 +++++++++++ .../test-suite/java/li_std_vector_runme.java | 22 +++++++++++++------ Lib/java/std_list.i | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index c3c666c51..05be034ff 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -22,7 +22,20 @@ public class li_std_list_runme { if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed"); if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed"); + int sum = 0; + for (int n : v1) { + if (n != 123) throw new RuntimeException("v1 loop test failed"); + sum += n; + } + if (sum != 123) throw new RuntimeException("v1 sum test failed"); if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); + v1.clear(); + if (!v1.isEmpty()) throw new RuntimeException("v1 test clear failed"); + v1.add(123); + + if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed"); + if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed"); + if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed"); StructList v4 = new StructList(); StructPtrList v5 = new StructPtrList(); diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index 60776bbf1..56a2e4359 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -17,15 +17,23 @@ public class li_std_vector_runme { IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector()); IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector()); - for (int n : v1) { - if (n != 123) throw new RuntimeException("v1 loop test failed"); - } - if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed"); if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed"); if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed"); if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed"); if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed"); + + int sum = 0; + for (int n : v1) { + if (n != 123) throw new RuntimeException("v1 loop test failed"); + sum += n; + } + if (sum != 123) throw new RuntimeException("v1 sum test failed"); + if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); + v1.clear(); + if (!v1.isEmpty()) throw new RuntimeException("v1 test clear failed"); + v1.add(123); + if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed"); if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed"); if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed"); @@ -59,13 +67,13 @@ public class li_std_vector_runme { if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed"); for (Struct s : v4) { - if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed"); + if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed"); } for (Struct s : v5) { - if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed"); + if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed"); } for (Struct s : v6) { - if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed"); + if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed"); } StructVector v7 = li_std_vector.vecstruct(new StructVector()); diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 8714be0f4..ab824e512 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -164,6 +164,7 @@ namespace std { void assign(size_type n, const value_type &val); %rename(isEmpty) empty; bool empty() const; + void clear(); size_type max_size() const; void pop_back(); void pop_front(); From 2d99027935a95d6b02bb6904bdbea1eff52c6f4d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 16:17:00 +0100 Subject: [PATCH 0604/2031] Fix removing elements from std::list Java wrapper Add missing remove method on Java side (without it elements aren't removed). --- Examples/test-suite/java/li_std_list_runme.java | 16 ++++++++++++++++ Lib/java/std_list.i | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index 05be034ff..ca40db2f2 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -37,6 +37,22 @@ public class li_std_list_runme { if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed"); if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed"); + java.util.Iterator v1_iterator = v1.iterator(); + if (!v1_iterator.hasNext()) throw new RuntimeException("v1 test (9) failed"); + if (v1_iterator.next() != 456) throw new RuntimeException("v1 test (10) failed"); + if (v1_iterator.hasNext()) throw new RuntimeException("v1 test (11) failed"); + try { + v1_iterator.next(); + throw new RuntimeException("v1 test (12) failed"); + } catch (java.util.NoSuchElementException e) { + } + + if (v1.remove(new Integer(123))) throw new RuntimeException("v1 test (13) failed"); + if (!v1.remove(new Integer(456))) throw new RuntimeException("v1 test (14) failed"); + if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed"); + if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); + if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed"); + StructList v4 = new StructList(); StructPtrList v5 = new StructPtrList(); StructConstPtrList v6 = new StructConstPtrList(); diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index ab824e512..0eca5a970 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -165,6 +165,8 @@ namespace std { %rename(isEmpty) empty; bool empty() const; void clear(); + %rename(remove) erase; + iterator erase(iterator pos); size_type max_size() const; void pop_back(); void pop_front(); From b40b9aee83f25796aa64a2288a351ed55302e1ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Jun 2017 20:10:26 +0100 Subject: [PATCH 0605/2031] Modify std::list declarations to match the C++ standard --- Lib/java/std_list.i | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 0eca5a970..0ce26ad0f 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -125,11 +125,11 @@ namespace std { * interface and give "natural" semantics to Java users of the C++ iterator) */ //%typemap(javaclassmodifiers) iterator "public class" - //%typemap(javainterfaces) iterator "java.util.ListIterator<$typemap(jboxtype, $1_basetype::value_type)>" + //%typemap(javainterfaces) iterator "java.util.ListIterator<$typemap(jboxtype, T)>" struct iterator { %extend { - void set_unchecked(const value_type &v) { + void set_unchecked(const T &v) { **$self = v; } @@ -145,7 +145,7 @@ namespace std { return ret; } - value_type deref_unchecked() const { + T deref_unchecked() const { return **$self; } @@ -158,10 +158,10 @@ namespace std { }; list(); - list(size_type n, const value_type &value = value_type()); - list(const list &o); + list(size_type n, const T &value = T()); + list(const list &other); ~list(); - void assign(size_type n, const value_type &val); + void assign(size_type n, const T &value); %rename(isEmpty) empty; bool empty() const; void clear(); @@ -170,11 +170,11 @@ namespace std { size_type max_size() const; void pop_back(); void pop_front(); - void push_back(const value_type &x); - void push_front(const value_type &x); + void push_back(const T &value); + void push_front(const T &value); iterator begin(); iterator end(); - iterator insert(iterator pos, const value_type &v); + iterator insert(iterator pos, const T &value); %extend { %fragment("SWIG_ListSize"); From c2f622c73c27fa370c6d643512b6d8591f0929f2 Mon Sep 17 00:00:00 2001 From: FUTATSUKI Yasuhito Date: Sat, 24 Jun 2017 21:41:59 +0900 Subject: [PATCH 0606/2031] Fix make *clean issue in CCache subdir --- CCache/Makefile.in | 36 ++++++++++++++++++------------------ CCache/test.sh | 4 ++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 1a6feb40f..f3b25a5f5 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -26,46 +26,46 @@ 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: $(PROGRAM_NAME)$(EXEEXT) +all: $(PACKAGE_NAME)$(EXEEXT) # Regenerate Makefile if Makefile.in or config.status have changed. Makefile: $(srcdir)/Makefile.in ./config.status $(SHELL) ./config.status # Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile -docs: $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/web/$(PROGRAM_NAME)-man.html +docs: $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/$(PACKAGE_NAME)-man.html -$(PROGRAM_NAME)$(EXEEXT): $(OBJS) $(HEADERS) +$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) -$(srcdir)/$(PROGRAM_NAME).1: $(srcdir)/ccache.yo - -yodl2man -o $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/ccache.yo +$(srcdir)/$(PACKAGE_NAME).1: $(srcdir)/ccache.yo + -yodl2man -o $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/ccache.yo -$(srcdir)/web/$(PROGRAM_NAME)-man.html: $(srcdir)/ccache.yo - yodl2html -o $(srcdir)/web/$(PROGRAM_NAME)-man.html $(srcdir)/ccache.yo +$(srcdir)/web/$(PACKAGE_NAME)-man.html: $(srcdir)/ccache.yo + yodl2html -o $(srcdir)/web/$(PACKAGE_NAME)-man.html $(srcdir)/ccache.yo -install: $(PROGRAM_NAME)$(EXEEXT) - @echo "Installing $(PROGRAM_NAME)" +install: $(PACKAGE_NAME)$(EXEEXT) + @echo "Installing $(PACKAGE_NAME)" @echo "Installing $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT)" ${INSTALLCMD} -d $(DESTDIR)${bindir} - ${INSTALLCMD} -m 755 $(PROGRAM_NAME)$(EXEEXT) $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) + ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) -install-docs: $(srcdir)/$(PROGRAM_NAME).1 +install-docs: $(srcdir)/$(PACKAGE_NAME).1 @echo "Installing $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1" ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 - ${INSTALLCMD} -m 644 $(srcdir)/$(PROGRAM_NAME).1 $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 + ${INSTALLCMD} -m 644 $(srcdir)/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 -uninstall: $(PROGRAM_NAME)$(EXEEXT) +uninstall: $(PACKAGE_NAME)$(EXEEXT) rm -f $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) -uninstall-docs: $(srcdir)/$(PROGRAM_NAME).1 - rm -f $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 +uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1 + rm -f $(DESTDIR)${mandir}/man1/$(PACKAGE_NAME).1 clean: - /bin/rm -f $(OBJS) *~ $(PROGRAM_NAME)$(EXEEXT) + /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) test: test.sh - SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(PROGRAM_NAME)' $(srcdir)/test.sh + SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(PACKAGE_NAME)' CCACHE_PROG=$(PROGRAM_NAME) $(srcdir)/test.sh check: test @@ -74,7 +74,7 @@ distclean: clean /bin/rm -rf autom4te.cache maintainer-clean: distclean - /bin/rm -f $(srcdir)/$(PROGRAM_NAME).1 $(srcdir)/web/$(PROGRAM_NAME)-man.html + /bin/rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/$(PACKAGE_NAME)-man.html # FIXME: To fix this, test.sh needs to be able to take ccache from the diff --git a/CCache/test.sh b/CCache/test.sh index 7e69149ff..5b6f92a35 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -411,6 +411,10 @@ swigtests() { # main program rm -rf $TESTDIR mkdir $TESTDIR +if test -n "$CCACHE_PROG"; then + ln -s $CCACHE $TESTDIR/$CCACHE_PROG + CCACHE=./$CCACHE_PROG +fi cd $TESTDIR || exit 1 unset CCACHE_DIR From ea55c5bba0596676668b23877e256a510a60807a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Jun 2017 14:21:34 +0100 Subject: [PATCH 0607/2031] Java std::vector std::list enhancements - Add missing vector copy constructor - Add constructor to initialize the containers. Note that Java's equivalent constructor for ArrayList just sets the capacity, whereas the wrappers behave like the C++ constructor and set the size. I've done this mainly because there has been a vector(size_type) constructor in the Java wrappers for many years, so best to keep this unchanged. --- .../test-suite/java/li_std_list_runme.java | 67 ++++++++++++++++++- .../test-suite/java/li_std_vector_runme.java | 6 ++ Examples/test-suite/li_std_list.i | 24 ++++--- Lib/java/std_list.i | 15 ++++- Lib/java/std_vector.i | 14 +++- 5 files changed, 114 insertions(+), 12 deletions(-) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index ca40db2f2..f0e48804b 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -53,6 +53,12 @@ public class li_std_list_runme { if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed"); + if (new IntList(3).size() != 3) throw new RuntimeException("constructor initial size test failed"); + for (int n : new IntList(10, 999)) + if (n != 999) throw new RuntimeException("constructor initialization with value failed"); + for (int n : new IntList(new IntList(10, 999))) + if (n != 999) throw new RuntimeException("copy constructor initialization with value failed"); + StructList v4 = new StructList(); StructPtrList v5 = new StructPtrList(); StructConstPtrList v6 = new StructConstPtrList(); @@ -61,9 +67,68 @@ public class li_std_list_runme { v5.add(new Struct(34)); v6.add(new Struct(56)); - Struct s = null; if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed"); if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed"); if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed"); + + for (Struct s : v4) { + if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed"); + } + for (Struct s : v5) { + if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed"); + } + for (Struct s : v6) { + if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed"); + } + + StructList v7 = li_std_list.CopyContainerStruct(new StructList()); + v7.add(new Struct(1)); + v7.add(new Struct(23)); + v7.add(new Struct(456)); + v7.add(new Struct(7890)); + if (v7.size() != 4) throw new RuntimeException("v7 test (1) failed"); + { + double[] a7 = {1, 23, 456, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (2) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (3) failed"); + } + if (v7.remove(2).getNum() != 456) throw new RuntimeException("v7 test (4) failed"); + { + double[] a7 = {1, 23, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (5) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (6) failed"); + } + v7.add(1, new Struct(123)); + { + double[] a7 = {1, 123, 23, 7890}; + int i7 = 0; + for (Struct s7 : v7) { + if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (7) failed"); + i7++; + } + if (i7 != a7.length) throw new RuntimeException("v7 test (8) failed"); + } + + BoolList v8 = new BoolList(); + if (!v8.add(true)) throw new RuntimeException("v8 test (1) failed");; + if (v8.get(0) != true) throw new RuntimeException("v8 test (2) failed");; + if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");; + if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");; + if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");; + + java.util.ArrayList bl = new java.util.ArrayList(java.util.Arrays.asList(true, false, true, false)); + BoolList bv = new BoolList(java.util.Arrays.asList(true, false, true, false)); + BoolList bv2 = new BoolList(bl); + java.util.ArrayList bl2 = new java.util.ArrayList(bv); + boolean bbb1 = bv.get(0); + Boolean bbb2 = bv.get(0); } } diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index 56a2e4359..b63df0210 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -54,6 +54,12 @@ public class li_std_vector_runme { if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed"); + if (new IntVector(3).size() != 3) throw new RuntimeException("constructor initial size test failed"); + for (int n : new IntVector(10, 999)) + if (n != 999) throw new RuntimeException("constructor initialization with value failed"); + for (int n : new IntVector(new IntVector(10, 999))) + if (n != 999) throw new RuntimeException("copy constructor initialization with value failed"); + StructVector v4 = li_std_vector.vecstruct(new StructVector()); StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector()); StructConstPtrVector v6 = li_std_vector.vecstructconstptr(new StructConstPtrVector()); diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i index 3a2d761ff..d1ec4e7e4 100644 --- a/Examples/test-suite/li_std_list.i +++ b/Examples/test-suite/li_std_list.i @@ -1,6 +1,7 @@ %module li_std_list %include "std_list.i" +%include "std_string.i" %{ #include @@ -8,15 +9,18 @@ #include %} -namespace std { - %template(IntList) list; -} - +%template(BoolList) std::list; +%template(CharList) std::list; +%template(ShortList) std::list; +%template(IntList) std::list; +%template(LongList) std::list; +%template(UCharList) std::list; +%template(UIntList) std::list; +%template(UShortList) std::list; +%template(ULongList) std::list; +%template(FloatList) std::list; %template(DoubleList) std::list; - -namespace std { - %template(RealList) list; -} +%template(StringList) std::list; %inline %{ @@ -37,6 +41,10 @@ struct Struct { // bool operator==(const Struct &other) { return (num == other.num); } }; +const std::list & CopyContainerStruct(const std::list & container) { return container; } +const std::list & CopyContainerStructPtr(const std::list & container) { return container; } +const std::list & CopyContainerStructConstPtr(const std::list & container) { return container; } + enum Fruit { APPLE, BANANNA, diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 0ce26ad0f..619afbb1d 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -29,7 +29,7 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { namespace std { template class list { -%typemap(javabase) std::list< T > "java.util.AbstractSequentialList<$typemap(jboxtype, T)>" +%typemap(javabase) std::list "java.util.AbstractSequentialList<$typemap(jboxtype, T)>" %proxycode %{ public $javaclassname(java.util.Collection c) { this(); @@ -158,7 +158,6 @@ namespace std { }; list(); - list(size_type n, const T &value = T()); list(const list &other); ~list(); void assign(size_type n, const T &value); @@ -178,6 +177,18 @@ namespace std { %extend { %fragment("SWIG_ListSize"); + list(jint count) { + if (count < 0) + throw std::out_of_range("list count must be positive"); + return new std::list(static_cast::size_type>(count)); + } + + list(jint count, const T &value) { + if (count < 0) + throw std::out_of_range("list count must be positive"); + return new std::list(static_cast::size_type>(count), value); + } + jint doSize() const throw (std::out_of_range) { return SWIG_ListSize(self->size()); } diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 4f5afe6db..2f6f07096 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -75,7 +75,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { typedef CTYPE value_type; typedef CREF_TYPE const_reference; vector(); - vector(size_type n); + vector(const vector &other); size_type capacity() const; void reserve(size_type n); %rename(isEmpty) empty; @@ -83,6 +83,18 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { void clear(); %extend { %fragment("SWIG_VectorSize"); + vector(jint count) { + if (count < 0) + throw std::out_of_range("vector count must be positive"); + return new std::vector< CTYPE >(static_cast::size_type>(count)); + } + + vector(jint count, const CTYPE &value) { + if (count < 0) + throw std::out_of_range("vector count must be positive"); + return new std::vector< CTYPE >(static_cast::size_type>(count), value); + } + jint doSize() const throw (std::out_of_range) { return SWIG_VectorSize(self->size()); } From b4b193d7de84a7bab5e45c1f6a16b941a5b44178 Mon Sep 17 00:00:00 2001 From: FUTATSUKI Yasuhito Date: Sat, 24 Jun 2017 22:32:27 +0900 Subject: [PATCH 0608/2031] Add explicit dependency on header files generated by configure script --- CCache/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index f3b25a5f5..d36e7d0ac 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -24,7 +24,7 @@ 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 +HEADERS = ccache.h mdfour.h config.h config_win32.h all: $(PACKAGE_NAME)$(EXEEXT) From a8e948e96de007cb4c7b8f69242dd5cb2310c1bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Jun 2017 22:53:11 +0100 Subject: [PATCH 0609/2031] Java std::vector std::list: add missing exception handling --- Lib/java/std_list.i | 8 ++++---- Lib/java/std_vector.i | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 619afbb1d..05c5683fa 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -177,13 +177,13 @@ namespace std { %extend { %fragment("SWIG_ListSize"); - list(jint count) { + list(jint count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("list count must be positive"); return new std::list(static_cast::size_type>(count)); } - list(jint count, const T &value) { + list(jint count, const T &value) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("list count must be positive"); return new std::list(static_cast::size_type>(count), value); @@ -193,11 +193,11 @@ namespace std { return SWIG_ListSize(self->size()); } - jint doPreviousIndex(const iterator &pos) const { + jint doPreviousIndex(const iterator &pos) const throw (std::out_of_range) { return pos == self->begin() ? -1 : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); } - jint doNextIndex(const iterator &pos) const { + jint doNextIndex(const iterator &pos) const throw (std::out_of_range) { return pos == self->end() ? self->size() : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); } diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 2f6f07096..774b6c911 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -83,13 +83,13 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { void clear(); %extend { %fragment("SWIG_VectorSize"); - vector(jint count) { + vector(jint count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("vector count must be positive"); return new std::vector< CTYPE >(static_cast::size_type>(count)); } - vector(jint count, const CTYPE &value) { + vector(jint count, const CTYPE &value) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("vector count must be positive"); return new std::vector< CTYPE >(static_cast::size_type>(count), value); From c686045f552f3b157b20fe86fc3c4b5611c6becb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Jun 2017 23:33:31 +0100 Subject: [PATCH 0610/2031] More efficient add implementation for Java std::list The default implementation in AbstractSequentialList calls add(size(), e) and size() might be expensive. --- Examples/test-suite/java/li_std_list_runme.java | 8 ++++++++ Examples/test-suite/java/li_std_vector_runme.java | 8 ++++++++ Lib/java/std_list.i | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index f0e48804b..0af9fbc48 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -130,5 +130,13 @@ public class li_std_list_runme { java.util.ArrayList bl2 = new java.util.ArrayList(bv); boolean bbb1 = bv.get(0); Boolean bbb2 = bv.get(0); + + IntList v9 = new IntList(java.util.Arrays.asList(10, 20, 30, 40)); + v9.add(50); + v9.add(60); + v9.add(70); + if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed"); + if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed"); + if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed"); } } diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index b63df0210..4d28b30de 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -131,5 +131,13 @@ public class li_std_vector_runme { java.util.ArrayList bl2 = new java.util.ArrayList(bv); boolean bbb1 = bv.get(0); Boolean bbb2 = bv.get(0); + + IntVector v9 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40)); + v9.add(50); + v9.add(60); + v9.add(70); + if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed"); + if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed"); + if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed"); } } diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 05c5683fa..d98fde731 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -14,6 +14,7 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { } } +%javamethodmodifiers std::list::push_back "private"; %javamethodmodifiers std::list::begin "private"; %javamethodmodifiers std::list::insert "private"; %javamethodmodifiers std::list::doSize "private"; @@ -44,6 +45,11 @@ namespace std { return doSize(); } + public boolean add($typemap(jboxtype, T) value) { + push_back(value); + return true; + } + public java.util.ListIterator<$typemap(jboxtype, T)> listIterator(int index) { return new java.util.ListIterator<$typemap(jboxtype, T)>() { private Iterator pos; From ecebbdd0df3748e376c4e160346d9429493b669b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 Jun 2017 00:10:06 +0100 Subject: [PATCH 0611/2031] Additional add/remove methods added to Java std::list wrappers Add functions similar to java.util.LinkedList: addFirst addLast removeFirst removeLast --- Examples/test-suite/java/li_std_list_runme.java | 10 ++++++++++ Lib/java/std_list.i | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index 0af9fbc48..e0d97b893 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -138,5 +138,15 @@ public class li_std_list_runme { if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed"); if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed"); if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed"); + v9.addFirst(-10); + v9.addLast(80); + if (v9.size() != 8) throw new RuntimeException("v9 test (4) failed"); + if (v9.get(0) != -10) throw new RuntimeException("v9 test (5) failed");; + if (v9.get(v9.size()-1) != 80) throw new RuntimeException("v9 test (6) failed");; + v9.removeFirst(); + if (v9.get(0) != 10) throw new RuntimeException("v9 test (7) failed");; + v9.removeLast(); + if (v9.size() != 6) throw new RuntimeException("v9 test (8) failed"); + if (v9.get(v9.size()-1) != 70) throw new RuntimeException("v9 test (9) failed");; } } diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index d98fde731..86024a903 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -14,7 +14,6 @@ SWIGINTERN jint SWIG_ListSize(size_t size) { } } -%javamethodmodifiers std::list::push_back "private"; %javamethodmodifiers std::list::begin "private"; %javamethodmodifiers std::list::insert "private"; %javamethodmodifiers std::list::doSize "private"; @@ -46,7 +45,7 @@ namespace std { } public boolean add($typemap(jboxtype, T) value) { - push_back(value); + addLast(value); return true; } @@ -173,9 +172,13 @@ namespace std { %rename(remove) erase; iterator erase(iterator pos); size_type max_size() const; + %rename(removeLast) pop_back; void pop_back(); + %rename(removeFirst) pop_front; void pop_front(); + %rename(addLast) push_back; void push_back(const T &value); + %rename(addFirst) push_front; void push_front(const T &value); iterator begin(); iterator end(); From 74fa7d00e27abeeedd86f1292456eca5fbb04f86 Mon Sep 17 00:00:00 2001 From: Nihal Date: Sat, 24 Jun 2017 13:43:55 +0530 Subject: [PATCH 0612/2031] Fix indentation in PHP7 and PHP5 variables example --- Examples/php/variables/runme.php | 4 ++-- Examples/php5/variables/runme.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/php/variables/runme.php b/Examples/php/variables/runme.php index bbfeb610b..14f27f389 100644 --- a/Examples/php/variables/runme.php +++ b/Examples/php/variables/runme.php @@ -26,10 +26,10 @@ echo "pt = ".pt_get(), point_print(pt_get()) , "\n"; /* Try to set the values of some global variables */ -$a = "42.14"; + $a = "42.14"; ivar_set($a); -echo "a = $a\n"; + echo "a = $a\n"; svar_set(-31000); lvar_set(65537); uivar_set(123456); diff --git a/Examples/php5/variables/runme.php b/Examples/php5/variables/runme.php index bbfeb610b..14f27f389 100644 --- a/Examples/php5/variables/runme.php +++ b/Examples/php5/variables/runme.php @@ -26,10 +26,10 @@ echo "pt = ".pt_get(), point_print(pt_get()) , "\n"; /* Try to set the values of some global variables */ -$a = "42.14"; + $a = "42.14"; ivar_set($a); -echo "a = $a\n"; + echo "a = $a\n"; svar_set(-31000); lvar_set(65537); uivar_set(123456); From 6daed2cea10d51c41e363d734921f944e75028b1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 12:28:02 +0100 Subject: [PATCH 0613/2031] Remove Java std::list::assign This doesn't exist in equivalent Java containers. If we put it back, the full set of overloaded assign wrappers ought to be added. --- Lib/java/std_list.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 86024a903..a634de382 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -165,7 +165,6 @@ namespace std { list(); list(const list &other); ~list(); - void assign(size_type n, const T &value); %rename(isEmpty) empty; bool empty() const; void clear(); From 3af40e74231b5c7f79f00b7e01e9f906dc60e2ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 12:46:22 +0100 Subject: [PATCH 0614/2031] Handle length_error exceptions in Java std::vector::reserve --- Lib/java/std_vector.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 774b6c911..d22896390 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -77,7 +77,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { vector(); vector(const vector &other); size_type capacity() const; - void reserve(size_type n); + void reserve(size_type n) throw (std::length_error); %rename(isEmpty) empty; bool empty() const; void clear(); From 90d2ba884c92ce799c8e8c7b4684e778f7b77ec2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 13:42:19 +0100 Subject: [PATCH 0615/2031] Java std::list std::vector - test addAll and subList --- Examples/test-suite/java/li_std_list_runme.java | 10 ++++++++++ Examples/test-suite/java/li_std_vector_runme.java | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index e0d97b893..ea2227faf 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -148,5 +148,15 @@ public class li_std_list_runme { v9.removeLast(); if (v9.size() != 6) throw new RuntimeException("v9 test (8) failed"); if (v9.get(v9.size()-1) != 70) throw new RuntimeException("v9 test (9) failed");; + + IntList v10 = new IntList(java.util.Arrays.asList(10, 20, 30, 40, 50)); + v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3) + if (v10.size() != 2) throw new RuntimeException("v10 test (1) failed"); + if (v10.get(0) != 10) throw new RuntimeException("v10 test (2) failed"); + if (v10.get(1) != 50) throw new RuntimeException("v10 test (3) failed"); + v10.addAll(1, java.util.Arrays.asList(22, 33)); + if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed"); + if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed"); + if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed"); } } diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index 4d28b30de..5371a2ba2 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -139,5 +139,15 @@ public class li_std_vector_runme { if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed"); if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed"); if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed"); + + IntVector v10 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40, 50)); + v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3) + if (v10.size() != 2) throw new RuntimeException("v10 test (1) failed"); + if (v10.get(0) != 10) throw new RuntimeException("v10 test (2) failed"); + if (v10.get(1) != 50) throw new RuntimeException("v10 test (3) failed"); + v10.addAll(1, java.util.Arrays.asList(22, 33)); + if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed"); + if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed"); + if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed"); } } From d92faa7f7fc94067155ecab4d2ce4610ddc3fa0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 13:43:57 +0100 Subject: [PATCH 0616/2031] Remove Java std::list::max_size Not in any Java equivalent containers nor std::vector wrapper. --- Lib/java/std_list.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index a634de382..d937bcfe3 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -170,7 +170,6 @@ namespace std { void clear(); %rename(remove) erase; iterator erase(iterator pos); - size_type max_size() const; %rename(removeLast) pop_back; void pop_back(); %rename(removeFirst) pop_front; From d04eb8874251f029a50699736dc2889f777c526e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 13:53:49 +0100 Subject: [PATCH 0617/2031] Consistent destructor declarations --- Lib/java/std_list.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index d937bcfe3..766fb184c 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -164,7 +164,6 @@ namespace std { list(); list(const list &other); - ~list(); %rename(isEmpty) empty; bool empty() const; void clear(); From f4aa8b33218beab0ea4022a1aa77cac4e73b9c16 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 26 Jun 2017 15:28:43 +0100 Subject: [PATCH 0618/2031] Add missing typedefs to Java std::vector --- Lib/java/std_vector.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index d22896390..c7fd73b37 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -72,8 +72,13 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef CTYPE value_type; + typedef CTYPE &reference; typedef CREF_TYPE const_reference; + typedef CTYPE *pointer; + typedef CTYPE const *const_pointer; + vector(); vector(const vector &other); size_type capacity() const; From 717ef91b902323e9e6aefbade4b7c967dff140f4 Mon Sep 17 00:00:00 2001 From: Nihal Date: Mon, 26 Jun 2017 11:21:52 +0530 Subject: [PATCH 0619/2031] Remove -noproxy support in the Examples of PHP7 --- Examples/php/enum/Makefile | 2 +- Examples/php/enum/runme.php | 20 ++++++++++---------- Examples/php/value/Makefile | 2 +- Examples/php/value/runme.php | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Examples/php/enum/Makefile b/Examples/php/enum/Makefile index 4483f781e..063a0645f 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php/enum/Makefile @@ -5,7 +5,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -SWIGOPT = -noproxy +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run diff --git a/Examples/php/enum/runme.php b/Examples/php/enum/runme.php index 55b0bc4c3..813476645 100644 --- a/Examples/php/enum/runme.php +++ b/Examples/php/enum/runme.php @@ -11,22 +11,22 @@ print " BLUE =" . BLUE; print " GREEN =" . GREEN; print "\n*** Foo::speed ***"; -print " Foo_IMPULSE =" . Foo_IMPULSE; -print " Foo_WARP =" . Foo_WARP; -print " Foo_LUDICROUS =" . Foo_LUDICROUS; +print " Foo::IMPULSE =" . Foo::IMPULSE; +print " Foo::WARP =" . Foo::WARP; +print " Foo::LUDICROUS =" . Foo::LUDICROUS; print "\nTesting use of enums with functions\n"; -enum_test(RED, Foo_IMPULSE); -enum_test(BLUE, Foo_WARP); -enum_test(GREEN, Foo_LUDICROUS); +enum_test(RED, Foo::IMPULSE); +enum_test(BLUE, Foo::WARP); +enum_test(GREEN, Foo::LUDICROUS); enum_test(1234,5678); print "\nTesting use of enum with class method\n"; -$f = new_Foo(); +$f = new Foo(); -Foo_enum_test($f,Foo_IMPULSE); -Foo_enum_test($f,Foo_WARP); -Foo_enum_test($f,Foo_LUDICROUS); +$f->enum_test(Foo::IMPULSE); +$f->enum_test(Foo::WARP); +$f->enum_test(Foo::LUDICROUS); ?> diff --git a/Examples/php/value/Makefile b/Examples/php/value/Makefile index 28fc3a127..47e5ed9f9 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php/value/Makefile @@ -5,7 +5,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i LIBS = -SWIGOPT = -noproxy +SWIGOPT = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run diff --git a/Examples/php/value/runme.php b/Examples/php/value/runme.php index 49115376c..569c87cf5 100644 --- a/Examples/php/value/runme.php +++ b/Examples/php/value/runme.php @@ -3,15 +3,15 @@ require "example.php"; - $v = new_vector(); - vector_x_set($v,1.0); - vector_y_set($v,2.0); - vector_z_set($v,3.0); + $v = new Vector(); + $v->x = 1.0; + $v->y = 2.0; + $v->z = 3.0; - $w = new_vector(); - vector_x_set($w,10.0); - vector_y_set($w,11.0); - vector_z_set($w,12.0); + $w = new Vector(); + $w->x = 10.0; + $w->y = 11.0; + $w->z = 12.0; echo "I just created the following vector\n"; vector_print($v); @@ -25,7 +25,7 @@ echo "\nNow I'm going to add the vectors together\n"; - $r = new_vector(); + $r = new Vector(); vector_add($v, $w, $r); vector_print($r); From 52f9ef7bfce7e42fa6764382da6bf4e24fdf4c72 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 27 Jun 2017 16:37:18 +1200 Subject: [PATCH 0620/2031] Add entry for previous commit --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b07e3eb7b..7373f7c97 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-27: nihaln + [PHP] Update the enum and value examples to use the OO wrappers + rather than the flat functions produced with -noproxy. There's + not been a good reason to use -noproxy for since PHP5 OO wrapping + was fixed back in 2005. + 2017-06-23: m7thon [Python] fix and improve default argument handling: From 251d25346dada6fe14cc0dd0aaa45e8fa653ded0 Mon Sep 17 00:00:00 2001 From: Nihal Date: Tue, 27 Jun 2017 10:37:07 +0530 Subject: [PATCH 0621/2031] Fix OUTPUT Typemap not having return statement bug in PHP wrapper. --- CHANGES.current | 4 ++++ Source/Modules/php.cxx | 2 +- Source/Modules/php5.cxx | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7373f7c97..9662acb28 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-06-27: nihaln + [PHP] Update the OUTPUT Typemap to add return statement to the + PHP Wrapper. + 2017-06-27: nihaln [PHP] Update the enum and value examples to use the OO wrappers rather than the flat functions produced with -noproxy. There's diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0ab792863..061dc0c22 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1841,7 +1841,7 @@ public: Delete(wrapobj); } } else { - if (non_void_return) { + if (non_void_return || hasargout) { Printf(output, "\t\treturn %s;\n", invoke); } else if (Cmp(invoke, "$r") != 0) { Printf(output, "\t\t%s;\n", invoke); diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index bf5664c3c..2fa76493e 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -1827,7 +1827,7 @@ public: Delete(wrapobj); } } else { - if (non_void_return) { + if (non_void_return || hasargout) { Printf(output, "\t\treturn %s;\n", invoke); } else if (Cmp(invoke, "$r") != 0) { Printf(output, "\t\t%s;\n", invoke); From fccf5c29b481bc55766daebc0b79a2c0e2b1ff42 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jun 2017 15:34:05 +0100 Subject: [PATCH 0622/2031] Minor correction in C# std::list doNextIndex --- Lib/java/std_list.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 766fb184c..e511ea006 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -204,7 +204,7 @@ namespace std { } jint doNextIndex(const iterator &pos) const throw (std::out_of_range) { - return pos == self->end() ? self->size() : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); + return pos == self->end() ? SWIG_ListSize(self->size()) : SWIG_ListSize(std::distance(self->begin(), static_cast::const_iterator>(pos))); } bool doHasNext(const iterator &pos) const { From 44cd658a53e457c363a72b11aba6ec52677f4f82 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jun 2017 19:32:34 +0100 Subject: [PATCH 0623/2031] Add in missing Java std::list listIterator index range checking --- .../test-suite/java/li_std_list_runme.java | 18 ++++++++++++++++++ .../test-suite/java/li_std_vector_runme.java | 18 ++++++++++++++++++ Lib/java/std_list.i | 2 ++ 3 files changed, 38 insertions(+) diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index ea2227faf..e45b8968b 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -158,5 +158,23 @@ public class li_std_list_runme { if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed"); if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed"); if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed"); + + v10.add(v10.size(), 55); + if (v10.size() != 5) throw new RuntimeException("v10 test (7) failed"); + if (v10.get(4) != 55) throw new RuntimeException("v10 test (8) failed"); + + IntList v11 = new IntList(java.util.Arrays.asList(11, 22, 33, 44)); + v11.listIterator(0); + v11.listIterator(v11.size()); + try { + v11.listIterator(v11.size() + 1); + throw new RuntimeException("v11 test (1) failed"); + } catch (IndexOutOfBoundsException e) { + } + try { + v11.listIterator(-1); + throw new RuntimeException("v11 test (2) failed"); + } catch (IndexOutOfBoundsException e) { + } } } diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index 5371a2ba2..d23bbe7cd 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -149,5 +149,23 @@ public class li_std_vector_runme { if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed"); if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed"); if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed"); + + v10.add(v10.size(), 55); + if (v10.size() != 5) throw new RuntimeException("v10 test (7) failed"); + if (v10.get(4) != 55) throw new RuntimeException("v10 test (8) failed"); + + IntVector v11 = new IntVector(java.util.Arrays.asList(11, 22, 33, 44)); + v11.listIterator(0); + v11.listIterator(v11.size()); + try { + v11.listIterator(v11.size() + 1); + throw new RuntimeException("v11 test (1) failed"); + } catch (IndexOutOfBoundsException e) { + } + try { + v11.listIterator(-1); + throw new RuntimeException("v11 test (2) failed"); + } catch (IndexOutOfBoundsException e) { + } } } diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index e511ea006..af6ac075f 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -55,6 +55,8 @@ namespace std { private Iterator last; private java.util.ListIterator<$typemap(jboxtype, T)> init(int index) { + if (index < 0 || index > $javaclassname.this.size()) + throw new IndexOutOfBoundsException("Index: " + index); pos = $javaclassname.this.begin(); pos = pos.advance_unchecked(index); return this; From 0b390a5473eb36b931046c19c677c3a3545920d6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jun 2017 19:59:19 +0100 Subject: [PATCH 0624/2031] Fix Java container tests for change in vector constructor declaration --- Examples/test-suite/constructor_copy.i | 8 +++++++- Examples/test-suite/ignore_template_constructor.i | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i index 7dcd05e8b..222c12f32 100644 --- a/Examples/test-suite/constructor_copy.i +++ b/Examples/test-suite/constructor_copy.i @@ -73,12 +73,18 @@ public: %include "std_vector.i" -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB) +#if defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB) #define SWIG_GOOD_VECTOR %ignore std::vector::vector(size_type); %ignore std::vector::resize(size_type); #endif +#if defined(SWIGJAVA) +#define SWIG_GOOD_VECTOR +%ignore std::vector::vector(jint); +%ignore std::vector::resize(jint); +#endif + #if defined(SWIGTCL) || defined(SWIGPERL) #define SWIG_GOOD_VECTOR /* here, for languages with bad declaration */ diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i index 31a5505fb..bdffbec3e 100644 --- a/Examples/test-suite/ignore_template_constructor.i +++ b/Examples/test-suite/ignore_template_constructor.i @@ -1,12 +1,18 @@ %module ignore_template_constructor %include std_vector.i -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGPERL) || defined(SWIGRUBY) +#if defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGPERL) || defined(SWIGRUBY) #define SWIG_GOOD_VECTOR %ignore std::vector::vector(size_type); %ignore std::vector::resize(size_type); #endif +#if defined(SWIGJAVA) +#define SWIG_GOOD_VECTOR +%ignore std::vector::vector(jint); +%ignore std::vector::resize(jint); +#endif + #if defined(SWIGTCL) || defined(SWIGPERL) #define SWIG_GOOD_VECTOR /* here, for languages with bad declaration */ From abe53e39a9f3602a65a9b6b5dea0c74a12d7e1c9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 29 Jun 2017 20:19:59 +0100 Subject: [PATCH 0625/2031] Java std::vector minor improvement --- Lib/java/std_vector.i | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index c7fd73b37..f35376965 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -109,7 +109,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } void doAdd(jint index, const value_type& value) throw (std::out_of_range) { - const jint size = SWIG_VectorSize(self->size()); + const jint size = static_cast::size_type>(self->size()); if (0 <= index && index <= size) { self->insert(self->begin() + index, value); } else { @@ -118,7 +118,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } value_type doRemove(jint index) throw (std::out_of_range) { - const jint size = SWIG_VectorSize(self->size()); + const jint size = static_cast::size_type>(self->size()); if (0 <= index && index < size) { CTYPE const old_value = (*self)[index]; self->erase(self->begin() + index); @@ -129,7 +129,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } CREF_TYPE doGet(jint index) throw (std::out_of_range) { - const jint size = SWIG_VectorSize(self->size()); + const jint size = static_cast::size_type>(self->size()); if (index >= 0 && index < size) return (*self)[index]; else @@ -137,7 +137,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } value_type doSet(jint index, const value_type& value) throw (std::out_of_range) { - const jint size = SWIG_VectorSize(self->size()); + const jint size = static_cast::size_type>(self->size()); if (index >= 0 && index < size) { CTYPE const old_value = (*self)[index]; (*self)[index] = value; @@ -148,7 +148,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } void doRemoveRange(jint fromIndex, jint toIndex) throw (std::out_of_range) { - const jint size = SWIG_VectorSize(self->size()); + const jint size = static_cast::size_type>(self->size()); if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { self->erase(self->begin() + fromIndex, self->begin() + toIndex); } else { From 74345c92e47938a75817eff5ba48dc9d3ce2a281 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Sat, 1 Jul 2017 17:38:48 -0600 Subject: [PATCH 0626/2031] supress clang warning about vtable ptr overwrite. Use calloc to zero memory just once. Document memory leak. --- Lib/python/pystdcommon.swg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 93ee34bc7..45f27375e 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -135,12 +135,11 @@ namespace swig { } } else { // Uninitialized return value, no Type() constructor required. - static Type *v_def = (Type*) malloc(sizeof(Type)); + static Type *v_def = (Type*) calloc(1, sizeof(Type)); // memory leak? if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); - memset(v_def,0,sizeof(Type)); return *v_def; } } From 6c0885ff677139a0c3c9719dd9fae7eac4f0167f Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Sat, 1 Jul 2017 17:58:59 -0600 Subject: [PATCH 0627/2031] Use the Type() ctor and avoid: - clang warning about memset overwrite of vtable - memory leak - Undefined behavior in Type copy/move operations and dtor. --- Lib/python/pystdcommon.swg | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 45f27375e..70746a58e 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -134,13 +134,12 @@ namespace swig { return *v; } } else { - // Uninitialized return value, no Type() constructor required. - static Type *v_def = (Type*) calloc(1, sizeof(Type)); // memory leak? + static Type v_def; if (!PyErr_Occurred()) { %type_error(swig::type_name()); } if (throw_error) throw std::invalid_argument("bad type"); - return *v_def; + return v_def; } } }; From bfaafde020dc7e38d3a147b0fdbd79adaf68df96 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Mon, 3 Jul 2017 12:25:04 -0600 Subject: [PATCH 0628/2031] traits_as::as() ignores throw_error and always throws. --- Lib/python/pystdcommon.swg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 70746a58e..c8ce2c8e6 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -122,7 +122,7 @@ namespace swig { template struct traits_as { - static Type as(PyObject *obj, bool throw_error) { + static Type as(PyObject *obj, bool /* throw_error */) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { @@ -134,12 +134,10 @@ namespace swig { return *v; } } else { - static Type v_def; if (!PyErr_Occurred()) { %type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); - return v_def; + throw std::invalid_argument("bad type"); } } }; From b229d92f9bfbefb6d11c3b92d590ead1ce93dc4a Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Mon, 3 Jul 2017 12:49:30 -0600 Subject: [PATCH 0629/2031] remove bool from as() (it now always throws). catch std::invalid_argument (what is expected) instread of std::exception. --- Lib/python/pycontainer.swg | 4 ++-- Lib/python/pystdcommon.swg | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 1687aca42..36557d75e 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -434,8 +434,8 @@ namespace swig { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); try { - return swig::as(item, true); - } catch (std::exception& e) { + return swig::as(item); + } catch (const std::invalid_argument& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", (int)_index); if (!PyErr_Occurred()) { diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index c8ce2c8e6..0242e4d35 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -107,14 +107,14 @@ namespace swig { template struct traits_as { - static Type as(PyObject *obj, bool throw_error) { + static Type as(PyObject *obj) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { if (!PyErr_Occurred()) { ::%type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); + throw std::invalid_argument("bad type"); } return v; } @@ -122,7 +122,7 @@ namespace swig { template struct traits_as { - static Type as(PyObject *obj, bool /* throw_error */) { + static Type as(PyObject *obj) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { @@ -144,7 +144,7 @@ namespace swig { template struct traits_as { - static Type* as(PyObject *obj, bool throw_error) { + static Type* as(PyObject *obj) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res)) { @@ -153,15 +153,14 @@ namespace swig { if (!PyErr_Occurred()) { %type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); - return 0; + throw std::invalid_argument("bad type"); } } }; template - inline Type as(PyObject *obj, bool te = false) { - return traits_as::category>::as(obj, te); + inline Type as(PyObject *obj) { + return traits_as::category>::as(obj); } template From dd26e8a01423e9e6c7e3660558df34f22b4a0506 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Mon, 3 Jul 2017 15:35:24 -0600 Subject: [PATCH 0630/2031] as() now always throws and never creates an invalid object with memset() --- Lib/ruby/rubycontainer.swg | 12 ++++++------ Lib/ruby/rubystdcommon.swg | 21 ++++++++------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 4f1c6f55e..4d0163f51 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -183,8 +183,8 @@ namespace swig { VALUE item = rb_ary_entry(_seq, _index ); try { - return swig::as(item, true); - } catch (std::exception& e) { + return swig::as(item); + } catch (const std::invalid_argument& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); VALUE lastErr = rb_gv_get("$!"); @@ -926,7 +926,7 @@ namespace swig VALUE elem = argv[0]; int idx = 0; try { - Sequence::value_type val = swig::as( elem, true ); + Sequence::value_type val = swig::as( elem ); if ( i >= len ) { $self->resize(i-1, val); return $self; @@ -943,7 +943,7 @@ namespace swig } } - catch( std::invalid_argument ) + catch( const std::invalid_argument & ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", @@ -967,10 +967,10 @@ namespace swig Sequence::iterator start = $self->begin(); VALUE elem = argv[idx]; try { - Sequence::value_type val = swig::as( elem, true ); + Sequence::value_type val = swig::as( elem ); $self->insert( start, val ); } - catch( std::invalid_argument ) + catch( const std::invalid_argument & ) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", diff --git a/Lib/ruby/rubystdcommon.swg b/Lib/ruby/rubystdcommon.swg index c34dacefb..99dd7f81e 100644 --- a/Lib/ruby/rubystdcommon.swg +++ b/Lib/ruby/rubystdcommon.swg @@ -115,15 +115,15 @@ namespace swig { template struct traits_as { - static Type as(VALUE obj, bool throw_error) { + static Type as(VALUE obj) { Type v; int res = asval(obj, &v); if (!SWIG_IsOK(res)) { - if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } + throw std::invalid_argument("bad type"); } return v; } @@ -131,7 +131,7 @@ namespace swig { template struct traits_as { - static Type as(VALUE obj, bool throw_error) { + static Type as(VALUE obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { @@ -143,40 +143,35 @@ namespace swig { return *v; } } else { - // Uninitialized return value, no Type() constructor required. - if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } - static Type *v_def = (Type*) malloc(sizeof(Type)); - memset(v_def,0,sizeof(Type)); - return *v_def; + throw std::invalid_argument("bad type"); } } }; template struct traits_as { - static Type* as(VALUE obj, bool throw_error) { + static Type* as(VALUE obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { - if (throw_error) throw std::invalid_argument("bad type"); VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { %type_error(swig::type_name()); } - return 0; + throw std::invalid_argument("bad type"); } } }; template - inline Type as(VALUE obj, bool te = false) { - return traits_as< Type, typename traits< Type >::category >::as(obj, te); + inline Type as(VALUE obj) { + return traits_as< Type, typename traits< Type >::category >::as(obj); } template From a67eff0ae908a81dfea913d51265833f039abba5 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Mon, 3 Jul 2017 20:55:40 -0600 Subject: [PATCH 0631/2031] remove bool from shared_ptr as well. --- Lib/ruby/std_shared_ptr.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i index f2b05ef36..9742230cc 100644 --- a/Lib/ruby/std_shared_ptr.i +++ b/Lib/ruby/std_shared_ptr.i @@ -80,35 +80,35 @@ namespace swig { template struct traits_as, pointer_category> { - static std::shared_ptr as(VALUE obj, bool throw_error) { + static std::shared_ptr as(VALUE obj) { std::shared_ptr ret; std::shared_ptr *v = &ret; int res = traits_asptr >::asptr(obj, &v); if (SWIG_IsOK(res)) { return ret; } else { - if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) SWIG_Error(SWIG_TypeError, swig::type_name >()); - return std::shared_ptr(); + throw std::invalid_argument("bad type"); } } }; template struct traits_as *, pointer_category> { - static std::shared_ptr * as(VALUE obj, bool throw_error) { + static std::shared_ptr * as(VALUE obj) { std::shared_ptr *p = 0; int res = traits_asptr >::asptr(obj, &p); if (SWIG_IsOK(res)) { return p; } else { - if (throw_error) throw std::invalid_argument("bad type"); + VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) SWIG_Error(SWIG_TypeError, swig::type_name *>()); - return 0; + throw std::invalid_argument("bad type"); } } }; From 0eba02f37a61e05bcb0c8833bd5ecb8f4cde4fcc Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 21 Mar 2017 20:45:10 +0000 Subject: [PATCH 0632/2031] Experimental fix for delimiter leakage in raw strings. --- Source/Swig/scanner.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index f62ddda01..4901ff1ca 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -749,6 +749,9 @@ static int look(Scanner *s) { } if (Strcmp( str_delimiter, end_delimiter )==0) { + int len = Len(s->text); + Delslice(s->text, len - 2 - Len(str_delimiter), len); /* Delete ending )XXXX" */ + Delslice(s->text, 0, Len(str_delimiter) + 1); /* Delete starting XXXX( */ Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */ Delete( str_delimiter ); str_delimiter = 0; From 7be6c10d4ab474b7ba952fbf0490cfec10e8519c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jul 2017 19:35:44 +0100 Subject: [PATCH 0633/2031] Fix display of documented template types when using the autodoc feature for Python. --- CHANGES.current | 17 +++++++++++++++++ Examples/test-suite/autodoc.i | 9 ++++++++- Examples/test-suite/python/autodoc_runme.py | 6 ++++++ Source/Modules/python.cxx | 8 ++++---- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9662acb28..0232208b7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,23 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-07-07: wsfulton + [Python] Fix display of documented template types when using the autodoc + feature. For example when wrapping: + + %feature("autodoc"); + template struct T {}; + %template(TInteger) T; + + the generated documentation contains: + """Proxy of C++ T< int > class.""" + instead of: + """Proxy of C++ T<(int)> class.""" + and + """__init__(TInteger self) -> TInteger""" + instead of + """__init__(T<(int)> self) -> TInteger""" + 2017-06-27: nihaln [PHP] Update the OUTPUT Typemap to add return statement to the PHP Wrapper. diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index a2d9f5b4e..97c05d791 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -133,6 +133,14 @@ typedef int Integer; void banana(S *a, const struct tagS *b, int c, Integer d) {} %} +// Check docs for a template type +%inline %{ +template struct T { + T inout(T t) { return t; } +}; +%} +%template(TInteger) T; + %inline %{ #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } @@ -140,4 +148,3 @@ bool is_python_builtin() { return true; } bool is_python_builtin() { return false; } #endif %} - diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index af04c8c0e..bf2fa621d 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -365,3 +365,9 @@ check(func_output.__doc__, "func_output() -> int") check(func_inout.__doc__, "func_inout(int * INOUT) -> int") check(func_cb.__doc__, "func_cb(int c, int d) -> int") check(banana.__doc__, "banana(S a, S b, int c, Integer d)") + +check(TInteger.__doc__, "Proxy of C++ T< int > class.", "::T< int >") +check(TInteger.__init__.__doc__, "__init__(TInteger self) -> TInteger", None, skip) +check(TInteger.inout.__doc__, + "inout(TInteger self, TInteger t) -> TInteger", + "inout(TInteger t) -> TInteger") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 581064046..64905bc21 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1960,9 +1960,9 @@ public: Delete(rname); } else { if (CPlusPlus) { - Printf(doc, "Proxy of C++ %s class.", real_classname); + Printf(doc, "Proxy of C++ %s class.", SwigType_namestr(real_classname)); } else { - Printf(doc, "Proxy of C %s struct.", real_classname); + Printf(doc, "Proxy of C %s struct.", SwigType_namestr(real_classname)); } } } @@ -1973,7 +1973,7 @@ public: String *paramList = make_autodocParmList(n, showTypes); Printf(doc, "__init__("); if (showTypes) - Printf(doc, "%s ", getClassName()); + Printf(doc, "%s ", class_name); if (Len(paramList)) Printf(doc, "self, %s) -> %s", paramList, class_name); else @@ -1984,7 +1984,7 @@ public: case AUTODOC_DTOR: if (showTypes) - Printf(doc, "__del__(%s self)", getClassName()); + Printf(doc, "__del__(%s self)", class_name); else Printf(doc, "__del__(self)"); break; From 20b72b78b4c96b521f41bf7c4d7fda7d632c1f29 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Jul 2017 13:17:50 +0100 Subject: [PATCH 0634/2031] Fix CCache documentation build and uninstall --- .gitignore | 3 +++ CCache/Makefile.in | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e94087e29..d2e6b841f 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ CCache/ccache_swig_config.h CCache/config.h CCache/config.log CCache/config.status +CCache/config_win32.h Examples/Makefile Examples/d/example.mk Examples/guile/Makefile @@ -85,6 +86,8 @@ swig.spec # Build Artifacts .dirstamp CCache/ccache-swig +CCache/ccache-swig.1 +CCache/web/ccache-swig-man.html Lib/swigwarn.swg Source/CParse/parser.c Source/CParse/parser.h diff --git a/CCache/Makefile.in b/CCache/Makefile.in index d36e7d0ac..d1bb8c526 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -18,9 +18,6 @@ SWIG=swig SWIG_LIB=../$(srcdir)/../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 @@ -59,11 +56,14 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) rm -f $(DESTDIR)${bindir}/$(PROGRAM_NAME)$(EXEEXT) uninstall-docs: $(srcdir)/$(PACKAGE_NAME).1 - rm -f $(DESTDIR)${mandir}/man1/$(PACKAGE_NAME).1 + rm -f $(DESTDIR)${mandir}/man1/$(PROGRAM_NAME).1 -clean: +clean: clean-docs /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) +clean-docs: + rm -f $(srcdir)/$(PACKAGE_NAME).1 $(srcdir)/web/$(PACKAGE_NAME)-man.html + test: test.sh SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' CCACHE='../$(PACKAGE_NAME)' CCACHE_PROG=$(PROGRAM_NAME) $(srcdir)/test.sh From 06c275935bffeaec91ebf37e17f7ce3dbe6ccf6c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Jul 2017 07:17:03 +0100 Subject: [PATCH 0635/2031] Add readme info for Java container wrappers --- CHANGES.current | 5 +++++ Lib/java/std_list.i | 8 ++++++++ Lib/java/std_vector.i | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0232208b7..531295c1e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-07-17: fflexo + [Java] #674 Add std_list.i to add support for std::list containers. The Java proxy + extends java.util.AbstractSequentialList and makes the C++ std::list container look + and feel much like a java.util.LinkedList from Java. + 2017-07-07: wsfulton [Python] Fix display of documented template types when using the autodoc feature. For example when wrapping: diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index af6ac075f..595db8919 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -1,3 +1,11 @@ +/* ----------------------------------------------------------------------------- + * std_list.i + * + * SWIG typemaps for std::list. + * The Java proxy class extends java.util.AbstractSequentialList. The std::list + * container looks and feels much like a java.util.LinkedList from Java. + * ----------------------------------------------------------------------------- */ + %include %{ diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index f35376965..57368c81a 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -1,5 +1,10 @@ /* ----------------------------------------------------------------------------- * std_vector.i + * + * SWIG typemaps for std::vector. + * The Java proxy class extends java.util.AbstractList and implements + * java.util.RandomAccess. The std::vector container looks and feels much like a + * java.util.ArrayList from Java. * ----------------------------------------------------------------------------- */ %include From a2e3cc0709364630dfde7fe65ca13752aa35ce70 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Thu, 20 Jul 2017 13:07:59 -0600 Subject: [PATCH 0636/2031] as() no longer uses memset and always throws. --- Lib/r/rstdcommon.swg | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg index 557dac71b..5f41fd144 100644 --- a/Lib/r/rstdcommon.swg +++ b/Lib/r/rstdcommon.swg @@ -101,12 +101,11 @@ namespace swig { template struct traits_as { - static Type as(SWIG_Object obj, bool throw_error) { + static Type as(SWIG_Object obj) { Type v; int res = asval(obj, &v); if (!obj || !SWIG_IsOK(res)) { - if (throw_error) - throw std::invalid_argument("bad type"); + throw std::invalid_argument("bad type"); } return v; } @@ -114,7 +113,7 @@ namespace swig { template struct traits_as { - static Type as(SWIG_Object obj, bool throw_error) { + static Type as(SWIG_Object obj) { Type *v = 0; int res = (obj ? traits_asptr::asptr(obj, &v) : SWIG_ERROR); if (SWIG_IsOK(res) && v) { @@ -126,12 +125,7 @@ namespace swig { return *v; } } else { - // Uninitialized return value, no Type() constructor required. - static Type *v_def = (Type*) malloc(sizeof(Type)); - if (throw_error) throw std::invalid_argument("bad type"); - memset(v_def,0,sizeof(Type)); - return *v_def; } } }; @@ -152,8 +146,8 @@ namespace swig { }; template - inline Type as(SWIG_Object obj, bool te = false) { - return traits_as::category>::as(obj, te); + inline Type as(SWIG_Object obj) { + return traits_as::category>::as(obj); } template From b27a58b5b85698db763452bd7cb14f07338e13f6 Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Thu, 20 Jul 2017 14:28:02 -0600 Subject: [PATCH 0637/2031] as() no longer memsets and always throws. --- Lib/octave/octcontainer.swg | 4 ++-- Lib/octave/octstdcommon.swg | 21 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 771edbde0..9b6520739 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -202,8 +202,8 @@ namespace swig // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index); octave_value item; // * todo try { - return swig::as(item, true); - } catch (std::exception& e) { + return swig::as(item); + } catch (const std::exception& e) { char msg[1024]; sprintf(msg, "in sequence element %d ", _index); if (!Octave_Error_Occurred()) { diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg index b3b3d0048..80b2154d9 100644 --- a/Lib/octave/octstdcommon.swg +++ b/Lib/octave/octstdcommon.swg @@ -103,14 +103,14 @@ namespace swig { template struct traits_as { - static Type as(const octave_value& obj, bool throw_error) { + static Type as(const octave_value& obj) { Type v; int res = asval(obj, &v); if (!obj.is_defined() || !SWIG_IsOK(res)) { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); + throw std::invalid_argument("bad type"); } return v; } @@ -118,7 +118,7 @@ namespace swig { template struct traits_as { - static Type as(const octave_value& obj, bool throw_error) { + static Type as(const octave_value& obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { @@ -130,21 +130,17 @@ namespace swig { return *v; } } else { - // Uninitialized return value, no Type() constructor required. - static Type *v_def = (Type*) malloc(sizeof(Type)); if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); - memset(v_def,0,sizeof(Type)); - return *v_def; + throw std::invalid_argument("bad type"); } } }; template struct traits_as { - static Type* as(const octave_value& obj, bool throw_error) { + static Type* as(const octave_value& obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { @@ -153,15 +149,14 @@ namespace swig { if (!Octave_Error_Occurred()) { %type_error(swig::type_name()); } - if (throw_error) throw std::invalid_argument("bad type"); - return 0; + throw std::invalid_argument("bad type"); } } }; template - inline Type as(const octave_value& obj, bool te = false) { - return traits_as::category>::as(obj, te); + inline Type as(const octave_value& obj) { + return traits_as::category>::as(obj); } template From c3ba9506bfb041f6f153f079cb8f0192b2aa6d6d Mon Sep 17 00:00:00 2001 From: Mike Romberg Date: Thu, 20 Jul 2017 14:48:51 -0600 Subject: [PATCH 0638/2031] as() no longer uses memset and always throws. --- Lib/scilab/scistdcommon.swg | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/Lib/scilab/scistdcommon.swg b/Lib/scilab/scistdcommon.swg index 975e93a7b..b08fc0307 100644 --- a/Lib/scilab/scistdcommon.swg +++ b/Lib/scilab/scistdcommon.swg @@ -104,23 +104,21 @@ namespace swig { template struct traits_as { - static Type as(const SwigSciObject& obj, bool throw_error) { + static Type as(const SwigSciObject& obj) { Type v; int res = asval(obj, &v); if (SWIG_IsOK(res)) { return v; } else { - %type_error(swig::type_name()); - if (throw_error) - throw std::invalid_argument("bad type"); - return res; + %type_error(swig::type_name()); + throw std::invalid_argument("bad type"); } } }; template struct traits_as { - static Type as(const SwigSciObject& obj, bool throw_error) { + static Type as(const SwigSciObject& obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res) && v) { @@ -132,36 +130,29 @@ namespace swig { return *v; } } else { - // Uninitialized return value, no Type() constructor required. - static Type *v_def = (Type*) malloc(sizeof(Type)); - %type_error(swig::type_name()); - if (throw_error) - throw std::invalid_argument("bad type"); - memset(v_def,0,sizeof(Type)); - return *v_def; + %type_error(swig::type_name()); + throw std::invalid_argument("bad type"); } } }; template struct traits_as { - static Type* as(const SwigSciObject& obj, bool throw_error) { + static Type* as(const SwigSciObject& obj) { Type *v = 0; int res = traits_asptr::asptr(obj, &v); if (SWIG_IsOK(res)) { return v; } else { - %type_error(swig::type_name()); - if (throw_error) - throw std::invalid_argument("bad type"); - return SWIG_OK; + %type_error(swig::type_name()); + throw std::invalid_argument("bad type"); } } }; template - inline Type as(const SwigSciObject& obj, bool te = false) { - return traits_as::category>::as(obj, te); + inline Type as(const SwigSciObject& obj) { + return traits_as::category>::as(obj); } template From 36b3c56a062b700f1a13f98fe52419f3f5fd498c Mon Sep 17 00:00:00 2001 From: Andrew Galante Date: Wed, 26 Jul 2017 13:59:08 -0700 Subject: [PATCH 0639/2031] Prevent writeback of a const char* array through a director when using the byte[] %typemap. --- Lib/java/java.swg | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index b49826ba0..56516439d 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1366,12 +1366,12 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) } /* String & length */ -%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray" -%typemap(jtype) (char *STRING, size_t LENGTH) "byte[]" -%typemap(jstype) (char *STRING, size_t LENGTH) "byte[]" -%typemap(javain) (char *STRING, size_t LENGTH) "$javainput" -%typemap(freearg) (char *STRING, size_t LENGTH) "" -%typemap(in) (char *STRING, size_t LENGTH) { +%typemap(jni) (const char *STRING, size_t LENGTH) "jbyteArray" +%typemap(jtype) (const char *STRING, size_t LENGTH) "byte[]" +%typemap(jstype) (const char *STRING, size_t LENGTH) "byte[]" +%typemap(javain) (const char *STRING, size_t LENGTH) "$javainput" +%typemap(freearg) (const char *STRING, size_t LENGTH) "" +%typemap(in) (const char *STRING, size_t LENGTH) { if ($input) { $1 = ($1_ltype) JCALL2(GetByteArrayElements, jenv, $input, 0); $2 = ($2_type) JCALL1(GetArrayLength, jenv, $input); @@ -1380,10 +1380,10 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) $2 = 0; } } -%typemap(argout) (char *STRING, size_t LENGTH) { +%typemap(argout) (const char *STRING, size_t LENGTH) { if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); } -%typemap(directorin, descriptor="[B", noblock=1) (char *STRING, size_t LENGTH) { +%typemap(directorin, descriptor="[B", noblock=1) (const char *STRING, size_t LENGTH) { $input = 0; if ($1) { $input = JCALL1(NewByteArray, jenv, (jsize)$2); @@ -1392,9 +1392,10 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } Swig::LocalRefGuard $1_refguard(jenv, $input); } +%typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput" +%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) } %typemap(directorargout, noblock=1) (char *STRING, size_t LENGTH) { if ($input && $1) JCALL4(GetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1); } -%typemap(javadirectorin, descriptor="[B") (char *STRING, size_t LENGTH) "$jniinput" %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } /* java keywords */ From 46f7217c507f5599777041e346b23a3c3475d015 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 28 Jul 2017 09:37:41 +1200 Subject: [PATCH 0640/2031] Remove random statement glued onto comment line And also copy-and-paste duplicate. --- Examples/octave/extend/runme.m | 2 +- Examples/python/extend/runme.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/octave/extend/runme.m b/Examples/octave/extend/runme.m index bc73184a8..c88a7c151 100644 --- a/Examples/octave/extend/runme.m +++ b/Examples/octave/extend/runme.m @@ -14,7 +14,7 @@ CEO=@(name) subclass(swigexample.Manager(name),'getPosition',@(self) "CEO"); # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses -# the director wrappers to call CEO.getPosition. e = CEO("Alice") +# the director wrappers to call CEO.getPosition. e = CEO("Alice"); printf("%s is a %s\n",e.getName(),e.getPosition()); diff --git a/Examples/python/extend/runme.py b/Examples/python/extend/runme.py index 2bb38fadc..e97358b99 100644 --- a/Examples/python/extend/runme.py +++ b/Examples/python/extend/runme.py @@ -18,7 +18,7 @@ class CEO(example.Manager): # Create an instance of our employee extension class, CEO. The calls to # getName() and getPosition() are standard, the call to getTitle() uses -# the director wrappers to call CEO.getPosition. e = CEO("Alice") +# the director wrappers to call CEO.getPosition. e = CEO("Alice") print e.getName(), "is a", e.getPosition() From a92137a708baa1e3378364c1f5cbc0e031e97bed Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Aug 2017 14:09:30 +1200 Subject: [PATCH 0641/2031] [C++11] Allow static_assert at the top level And disallow it right after template). Fixes https://github.com/swig/swig/issues/1031 reported by Artem V L. --- CHANGES.current | 5 +++++ Doc/Manual/CPlusPlus11.html | 3 ++- Examples/test-suite/cpp11_static_assert.i | 14 ++++++++++++-- Source/CParse/parser.y | 10 +++++----- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 531295c1e..c957a6e6c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-08-05: olly + [C++11] Allow static_assert at the top level (and disallow it right + after template). Fixes https://github.com/swig/swig/issues/1031 + reported by Artem V L. + 2017-07-17: fflexo [Java] #674 Add std_list.i to add support for std::list containers. The Java proxy extends java.util.AbstractSequentialList and makes the C++ std::list container look diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index d3494455b..e4dff6543 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -877,7 +877,8 @@ so in this case it is entirely possible to pass an int instead of a double to -SWIG correctly parses the new static_assert declarations. +SWIG correctly parses the new static_assert declarations (though 3.0.12 and earlier +had a bug which meant this wasn't accepted at file scope). This is a C++ compile time directive so there isn't anything useful that SWIG can do with it.

    diff --git a/Examples/test-suite/cpp11_static_assert.i b/Examples/test-suite/cpp11_static_assert.i index 8d616f96c..1533d4210 100644 --- a/Examples/test-suite/cpp11_static_assert.i +++ b/Examples/test-suite/cpp11_static_assert.i @@ -1,12 +1,22 @@ -/* This test case checks whether SWIG correctly parses and ignores the - keywords "static_assert()" inside the class or struct. +/* This test case checks whether SWIG correctly parses and ignores + "static_assert()" in various places. */ %module cpp11_static_assert %inline %{ +static_assert(sizeof(int) >= 2, "What? int size is invalid!"); + +namespace dummy { +// C++17 allows the message to be omitted, so check that works too. +static_assert(sizeof(int) >= sizeof(short)); +} + template struct Check1 { static_assert(sizeof(int) <= sizeof(T), "not big enough"); + Check1() { + static_assert(true); + } }; template diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 69dce5534..db5ff9f97 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2991,6 +2991,9 @@ c_declaration : c_decl { SetFlag($$,"aliastemplate"); add_symbols($$); } + | cpp_static_assert { + $$ = $1; + } ; /* ------------------------------------------------------------ @@ -4209,9 +4212,6 @@ cpp_temp_possible: c_decl { | cpp_constructor_decl { $$ = $1; } - | cpp_static_assert { - $$ = $1; - } | cpp_template_decl { $$ = 0; } @@ -4469,7 +4469,6 @@ cpp_member : c_declaration { $$ = $1; } default_arguments($$); } | cpp_destructor_decl { $$ = $1; } - | cpp_static_assert { $$ = $1; } | cpp_protection_decl { $$ = $1; } | cpp_swig_directive { $$ = $1; } | cpp_conversion_operator { $$ = $1; } @@ -4673,7 +4672,8 @@ cpp_catch_decl : CATCH LPAREN parms RPAREN LBRACE { } ; -/* static_assert(bool, const char*); */ +/* static_assert(bool, const char*); (C++11) + * static_assert(bool); (C++17) */ cpp_static_assert : STATIC_ASSERT LPAREN { skip_balanced('(',')'); $$ = 0; From 6303a099aa91d37d3d023b55f6cbc2500aa64b22 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Aug 2017 17:01:35 +1200 Subject: [PATCH 0642/2031] Fix previous commit to compile with older compilers Not all "C++11" compilers will also support C++17. --- Examples/test-suite/cpp11_static_assert.i | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Examples/test-suite/cpp11_static_assert.i b/Examples/test-suite/cpp11_static_assert.i index 1533d4210..7ca452d85 100644 --- a/Examples/test-suite/cpp11_static_assert.i +++ b/Examples/test-suite/cpp11_static_assert.i @@ -8,14 +8,24 @@ static_assert(sizeof(int) >= 2, "What? int size is invalid!"); namespace dummy { // C++17 allows the message to be omitted, so check that works too. +// But only show the C++17 version to SWIG, as the compiler may +// lack C++17 support. +#ifdef SWIG static_assert(sizeof(int) >= sizeof(short)); +#else +static_assert(sizeof(int) >= sizeof(short), "blah"); +#endif } template struct Check1 { static_assert(sizeof(int) <= sizeof(T), "not big enough"); Check1() { +#ifdef SWIG static_assert(true); +#else + static_assert(true, "true"); +#endif } }; From 74a4cc878629781bf63899ee4a5eff04b03b0027 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 9 Aug 2017 11:37:03 +1200 Subject: [PATCH 0643/2031] [php] Fix reported descriptor in typemap error message The affected typemap is %typemap(in) SWIGTYPE *DISOWN, where the error message was referring to $&1_descriptor but the descriptor actually used by the typemap is $1_descriptor. --- Lib/php/php.swg | 2 +- Lib/php5/php.swg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 0ac46e006..83f76217a 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -134,7 +134,7 @@ %typemap(in) SWIGTYPE *DISOWN %{ if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } %} diff --git a/Lib/php5/php.swg b/Lib/php5/php.swg index 40854ea61..6f8470ff9 100644 --- a/Lib/php5/php.swg +++ b/Lib/php5/php.swg @@ -134,7 +134,7 @@ %typemap(in) SWIGTYPE *DISOWN { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } } From 90f9117e10172722c03dcfde74b35ddd93d6072d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 13 Aug 2017 18:04:33 +1200 Subject: [PATCH 0644/2031] Fix various comment and documentation typos --- CHANGES | 2 +- Doc/Manual/Allegrocl.html | 2 +- Doc/Manual/Android.html | 2 +- Doc/Manual/CCache.html | 2 +- Doc/Manual/CSharp.html | 2 +- Doc/Manual/D.html | 2 +- Doc/Manual/Extending.html | 4 ++-- Doc/Manual/Java.html | 2 +- Doc/Manual/Php.html | 2 +- Doc/Manual/Python.html | 2 +- Doc/Manual/SWIGPlus.html | 2 +- Doc/Manual/Scilab.html | 8 ++++---- Examples/javascript/enum/runme.js | 2 +- Examples/test-suite/README | 2 +- Examples/test-suite/csharp/li_std_map_runme.cs | 2 +- Examples/test-suite/director_extend.i | 2 +- Examples/test-suite/perl5/README | 2 +- Lib/d/dswigtype.swg | 2 +- Lib/lua/luarun.swg | 4 ++-- Lib/perl5/perlrun.swg | 2 +- Lib/python/pyrun.swg | 4 ++-- Lib/r/rrun.swg | 2 +- Lib/r/srun.swg | 2 +- Lib/ruby/rubyrun.swg | 2 +- Lib/scilab/scitypemaps.swg | 2 +- Lib/tcl/tclrun.swg | 2 +- Source/Modules/go.cxx | 2 +- Source/Modules/lang.cxx | 6 +++--- Source/Modules/lua.cxx | 4 ++-- Source/Modules/r.cxx | 2 +- Source/Modules/utils.cxx | 2 +- Source/Swig/cwrap.c | 2 +- Source/Swig/symbol.c | 2 +- configure.ac | 2 +- 34 files changed, 43 insertions(+), 43 deletions(-) diff --git a/CHANGES b/CHANGES index 836bf4b9c..8376c0b36 100644 --- a/CHANGES +++ b/CHANGES @@ -21116,7 +21116,7 @@ Version 1.3.7 (September 3, 2001) typedef __name vector; %enddef - An a specific instantiation is created in exactly the same way: + A specific instantiation is created in exactly the same way: %template(intvec) vector; diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index ddb6fba55..c4d898130 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -155,7 +155,7 @@ SWIG directives. SWIG can be furnished with a header file, but an interface can also be generated without library headers by supplying a simple text file--called the interface file, which is typically named with a .i extension--containing any foreign declarations of -identifiers you wish to use. The most common approach is to use a an +identifiers you wish to use. The most common approach is to use an interface file with directives to parse the needed headers. A straight parse of library headers will result in usable code, but SWIG directives provides much freedom in how a user might tailor the diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index b295b5e04..726314228 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -409,7 +409,7 @@ All the steps required to compile and use a simple hierarchy of classes for shap

    First create an Android project called SwigClass in a subdirectory called class. -The steps below create and build a the JNI C++ app. +The steps below create and build the JNI C++ app. Adjust the --target id as mentioned earlier in the Examples introduction.

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index d23b0cb2f..521184ff0 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -411,7 +411,7 @@ following conditions need to be met:

    -ccache was inspired by the compilercache shell script script written +ccache was inspired by the compilercache shell script written by Erik Thiele and I would like to thank him for an excellent piece of work. See http://www.erikyyy.de/compilercache/ diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 5be63a340..4eb855022 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1772,7 +1772,7 @@ should pass the call on to CSharpDefaults.DefaultMethod(int)using the C

    -When using multiple modules it is is possible to compile each SWIG generated wrapper +When using multiple modules it is possible to compile each SWIG generated wrapper into a different assembly. However, by default the generated code may not compile if generated classes in one assembly use generated classes in another assembly. diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 45b57e18b..1a317a005 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -280,7 +280,7 @@ class SomeClass : AnInterface, AnotherInterface { ... }

    -

    For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.

    +

    For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but if it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.

    The $importtype macro helps you to elegantly solve this problem:

     %typemap(dimports) RemoteMpe %{
    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
    index bf70b69ac..358d02706 100644
    --- a/Doc/Manual/Extending.html
    +++ b/Doc/Manual/Extending.html
    @@ -1576,7 +1576,7 @@ return the node for the first class member.
     
     
    Returns the last child node. You might use this if you wanted to append a new -node to the of a class. +node to the children of a class.

    @@ -3164,7 +3164,7 @@ these kinds of problems.

    Examples/Makefile.in -
    Nothing special here; see comments at top the of this file +
    Nothing special here; see comments at the top of this file and look to the existing languages for examples.
    Examples/qux99/check.list diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index e0178465c..fad2fc3d4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -4105,7 +4105,7 @@ the exception specification or %catches feature.

    Note that the "directorthrows" typemaps are important -only if it is important for the the exceptions passed through the C++ +only if it is important for the exceptions passed through the C++ layer to be mapped to distinct C++ exceptions. If director methods are being called by C++ code that is itself wrapped in a SWIG generated Java wrapper and access is always through this wrapper, diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 7d3d33ac1..4e17db316 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -163,7 +163,7 @@ If the module is in PHP's default extension directory, you can omit the path.

    For some SAPIs (for example, the CLI SAPI) you can instead use the dl() function to load -an extension at run time, by adding a like like this to the start of each +an extension at run time, by adding a line like this to the start of each PHP script which uses your extension:

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1b73c08b7..9b9e51455 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6046,7 +6046,7 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

    When SWIG creates wrappers from an interface file, say foo.i, two Python modules are -created. There is a pure Python module module (foo.py) and C/C++ code which is +created. There is a pure Python module (foo.py) and C/C++ code which is built and linked into a dynamically (or statically) loaded low-level module _foo (see the Preliminaries section for details). So, the interface file really defines two Python modules. How these two modules are loaded is diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 3e7860b9b..0667623bc 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2779,7 +2779,7 @@ into two methods such that additional logic can be packed into the operations; C this[type key] { get { ... } set { ... }}, Python uses __getitem__ and __setitem__, etc. In C++ if the return type of operator[] is a reference and the method is const, it is often indicative of the setter, -and and the getter is usually a const function return an object by value. +and the getter is usually a const function return an object by value. In the absence of any hard and fast rules and the fact that there may be multiple index operators, it is up to the user to choose the getter and setter to use by using %rename as shown earlier.

    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 14e03ff18..44c570b9b 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -1136,7 +1136,7 @@ But we can use either use the get_perimeter() function of the parent cl As explained in 6.15 SWIG provides support for overloaded functions and constructors.

    -

    As SWIG knows pointer types, the overloading works also with pointer types, here is is an example with a function magnify overloaded for the previous classes Shape and Circle: +

    As SWIG knows pointer types, the overloading works also with pointer types, here is an example with a function magnify overloaded for the previous classes Shape and Circle:

    @@ -1620,11 +1620,11 @@ void printArray(int values[], int len) {
     
     
     

    -There are no specific typemaps for pointer-to-pointers, they are are mapped as pointers in Scilab. +There are no specific typemaps for pointer-to-pointers, they are mapped as pointers in Scilab.

    -Pointer-to-pointers are sometimes used to implement matrices in C. The following is a an example of this: +Pointer-to-pointers are sometimes used to implement matrices in C. The following is an example of this:

    @@ -2062,7 +2062,7 @@ In this mode, the following SWIG options may be used to setup the build: Let's give an example how to build a module example, composed of two sources, and using a library dependency:

      -
    • the sources are baa1.c and baa2.c (and are stored in in the current directory)
    • +
    • the sources are baa1.c and baa2.c (and are stored in the current directory)
    • the library is libfoo in /opt/foo (headers stored in /opt/foo/include, and shared library in /opt/foo/lib)
    diff --git a/Examples/javascript/enum/runme.js b/Examples/javascript/enum/runme.js index 851d43c4b..f3264889c 100644 --- a/Examples/javascript/enum/runme.js +++ b/Examples/javascript/enum/runme.js @@ -30,5 +30,5 @@ f.enum_test(example.Foo.LUDICROUS); // enum value BLUE of enum color is accessed as property of cconst console.log("example.BLUE= " + example.BLUE); -// enum value LUDICROUS of enum Foo::speed is accessed as as property of cconst +// enum value LUDICROUS of enum Foo::speed is accessed as property of cconst console.log("example.speed.LUDICROUS= " + example.Foo.LUDICROUS); diff --git a/Examples/test-suite/README b/Examples/test-suite/README index aac7636c6..3b7cea477 100644 --- a/Examples/test-suite/README +++ b/Examples/test-suite/README @@ -47,6 +47,6 @@ testdir/README file. Further Documentation --------------------- -There is documentation about the test-suite and how to use use it in +There is documentation about the test-suite and how to use it in the SWIG documentation - Doc/Manual/Extending.html#Extending_test_suite. diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index 0fe1ab5cd..b21c81e4e 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -18,7 +18,7 @@ public class li_std_map_runme { public static void Main() { - // Set up an int int map + // Set up an string to int map StringIntMap simap = new StringIntMap(); for (int i = 0; i < collectionSize; i++) { diff --git a/Examples/test-suite/director_extend.i b/Examples/test-suite/director_extend.i index cec930a42..60a9d4cf0 100644 --- a/Examples/test-suite/director_extend.i +++ b/Examples/test-suite/director_extend.i @@ -25,7 +25,7 @@ namespace Swig { size_t ExceptionMethod() { // Check positioning of director code in wrapper file -// Below is what we really want to test, but director exceptions vary too much across across all languages +// Below is what we really want to test, but director exceptions vary too much across all languages // throw Swig::DirectorException("DirectorException was not in scope!!"); // Instead check definition of Director class as that is defined in the same place as DirectorException (director.swg) size_t size = sizeof(Swig::Director); diff --git a/Examples/test-suite/perl5/README b/Examples/test-suite/perl5/README index 804dec8e8..f15c07849 100644 --- a/Examples/test-suite/perl5/README +++ b/Examples/test-suite/perl5/README @@ -6,7 +6,7 @@ Test::More Support == Test::More is a standard perl test harness tool. -Support was added for for using Test::More in 1.3.28. +Support was added for using Test::More in 1.3.28. If adding a new test to this suite, please use Test::More. There are a few legacy test cases which do not use Test::More and these ought to be converted: diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg index f91d6dfe6..5043741d5 100644 --- a/Lib/d/dswigtype.swg +++ b/Lib/d/dswigtype.swg @@ -162,7 +162,7 @@ return ret; } -// Treat references to arrays like like references to a single element. +// Treat references to arrays like references to a single element. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 3510d04d7..514336029 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -180,7 +180,7 @@ typedef struct swig_elua_entry { * -------------------------------------------------------------------------- */ /* Push the string STR on the Lua stack, like lua_pushstring, but - prefixed with the the location of the innermost Lua call-point + prefixed with the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pusherrstring (lua_State *L, const char *str) @@ -191,7 +191,7 @@ SWIG_Lua_pusherrstring (lua_State *L, const char *str) } /* Push a formatted string generated from FMT and following args on - the Lua stack, like lua_pushfstring, but prefixed with the the + the Lua stack, like lua_pushfstring, but prefixed with the location of the innermost Lua call-point (as formated by luaL_where). */ SWIGRUNTIME void SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...) diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index d1865de0a..cc4ba446a 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -392,7 +392,7 @@ SWIG_Perl_NewPackedObj(SWIG_MAYBE_PERL_OBJECT void *ptr, int sz, swig_type_info return result; } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 939a69204..efc476613 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -538,7 +538,7 @@ SwigPyObject_dealloc(PyObject *v) PyObject *res; /* PyObject_CallFunction() has the potential to silently drop - the active active exception. In cases of unnamed temporary + the active exception. In cases of unnamed temporary variable or where we just finished iterating over a generator StopIteration will be active right now, and this needs to remain true upon return from SwigPyObject_dealloc. So save @@ -1308,7 +1308,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { } } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index 81f6461d2..63b7ecc70 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -350,7 +350,7 @@ SWIG_R_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { return ptr ? RSwigPacked_New((void *) ptr, sz, type) : R_NilValue; } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_R_ConvertPacked(SEXP obj, void *ptr, size_t sz, swig_type_info *ty) { diff --git a/Lib/r/srun.swg b/Lib/r/srun.swg index 2045ab94e..d07218a77 100644 --- a/Lib/r/srun.swg +++ b/Lib/r/srun.swg @@ -7,7 +7,7 @@ # This could be provided as a separate run-time library but this -# approach allows the code to to be included directly into the +# approach allows the code to be included directly into the # generated bindings and so removes the need to have and install an # additional library. We may however end up with multiple copies of # this and some confusion at run-time as to which class to use. This diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 4628aedc3..1afc5c1d0 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -363,7 +363,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) { return rb_str_new2(result); } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg index 4cf0da3f1..682d18c44 100644 --- a/Lib/scilab/scitypemaps.swg +++ b/Lib/scilab/scitypemaps.swg @@ -7,7 +7,7 @@ #define SWIG_Object int #define %append_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR -#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the the function name +#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the function name #define %raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc) #define %set_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR #define %set_varoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index f671ba240..408ddac3d 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -199,7 +199,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) { return c; } -/* Convert a packed value value */ +/* Convert a packed pointer value */ SWIGRUNTIME int SWIG_Tcl_ConvertPacked(Tcl_Interp *SWIGUNUSEDPARM(interp) , Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty) { swig_cast_info *tc; diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 1512834f9..916030437 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -990,7 +990,7 @@ private: * overname: The overload string for overloaded function. * wname: The SWIG wrapped name--the name of the C function. * base: A list of the names of base classes, in the case where this - * is is a vritual method not defined in the current class. + * is a virtual method not defined in the current class. * parms: The parameters. * result: The result type. * is_static: Whether this is a static method or member. diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 11874ef0a..1e4a6bdb6 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1949,7 +1949,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_ generation of 'empty' director classes. But this has to be done outside the previous 'for' - an the recursive loop!. + and the recursive loop!. */ if (n == parent) { int len = Len(vm); @@ -2078,7 +2078,7 @@ int Language::classDirectorConstructors(Node *n) { needed, since there is a public constructor already defined. (scottm) This code is needed here to make the director_abstract + - test generate compilable code (Example2 in director_abastract.i). + test generate compilable code (Example2 in director_abstract.i). (mmatus) This is very strange, since swig compiled with gcc3.2.3 doesn't need it here.... @@ -3308,7 +3308,7 @@ Node *Language::classLookup(const SwigType *s) const { } if (n) { /* Found a match. Look at the prefix. We only allow - the cases where where we want a proxy class for the particular type */ + the cases where we want a proxy class for the particular type */ bool acceptable_prefix = (Len(prefix) == 0) || // simple type (pass by value) (Strcmp(prefix, "p.") == 0) || // pointer diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 80ea47f3f..08de34976 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -1755,7 +1755,7 @@ public: * * This is to convert the string of Lua code into a proper string, which can then be * emitted into the C/C++ code. - * Basically is is a lot of search & replacing of odd sequences + * Basically it is a lot of search & replacing of odd sequences * ---------------------------------------------------------------------------- */ void escapeCode(String *str) { @@ -1770,7 +1770,7 @@ public: /* ----------------------------------------------------------------------------- * rawGetCArraysHash(String *name) * - * A small helper to hide impelementation of how CArrays hashes are stored + * A small helper to hide implementation of how CArrays hashes are stored * ---------------------------------------------------------------------------- */ Hash *rawGetCArraysHash(const_String_or_char_ptr name) { diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 1c8533064..6a326206f 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -718,7 +718,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { function that handles the scoerceout. We need to check if any of the argument types have an entry in that map. If none do, the ignore and call the function straight. - Otherwise, generate the a marshalling function. + Otherwise, generate a marshalling function. Need to be able to find it in S. Or use an entirely generic one that evaluates the expressions. Handle errors in the evaluation of the function by restoring diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx index a91ebe098..2964ed3a6 100644 --- a/Source/Modules/utils.cxx +++ b/Source/Modules/utils.cxx @@ -59,7 +59,7 @@ int is_non_virtual_protected_access(Node *n) { // When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done. // However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded() // which calls is_non_virtual_protected_access. So commented out below. - // Moving the director vtable creation into into Typepass should solve this problem. + // Moving the director vtable creation into Typepass should solve this problem. if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/) result = 1; } diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 9da4e0829..4c3135e3a 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -277,7 +277,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) { SwigType_del_rvalue_reference(tvalue); tycode = SwigType_type(tvalue); if (tycode != T_USER) { - /* plain primitive type, we copy the the def value */ + /* plain primitive type, we copy the def value */ String *lstr = SwigType_lstr(tvalue, defname); defvalue = NewStringf("%s = %s", lstr, qvalue); Delete(lstr); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index c548a0670..965a84472 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -599,7 +599,7 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { Setattr(ccurrent, name, n); } - /* Multiple entries in the C symbol table. We append to to the symbol table */ + /* Multiple entries in the C symbol table. We append to the symbol table */ if (append) { Node *fn, *pn = 0; cn = Getattr(ccurrent, name); diff --git a/configure.ac b/configure.ac index 25ea0a243..ddf7a7dd7 100644 --- a/configure.ac +++ b/configure.ac @@ -280,7 +280,7 @@ fi AC_MSG_RESULT($RPATH) # LINKFORSHARED are the flags passed to the $(CC) command that links -# the a few executables -- this is only needed for a few systems +# a few executables -- this is only needed for a few systems AC_MSG_CHECKING(LINKFORSHARED) if test -z "$LINKFORSHARED" From 2165f27f5d77d38399f7f83e6a7fb41a12c77690 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Aug 2017 22:55:23 +0100 Subject: [PATCH 0645/2031] Fix incorrectly shown warning for empty template instantiation used as a base class. --- CHANGES.current | 8 ++++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/template_empty_inherit.i | 30 ++++++++++++++++++++ Source/Modules/typepass.cxx | 12 +++++--- 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/template_empty_inherit.i diff --git a/CHANGES.current b/CHANGES.current index c957a6e6c..808bd1798 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -12,6 +12,14 @@ Version 4.0.0 (in progress) after template). Fixes https://github.com/swig/swig/issues/1031 reported by Artem V L. +2017-08-02: wsfulton + Fix incorrectly shown warning when an empty template instantiation was used on a + class used as a base class and that base class was explicitly ignored with %ignore. + Example of the warning which will no longer appear: + + Warning 401: Base class 'Functor< int,int >' has no name as it is an empty + template instantiated with '%template()'. Ignored. + 2017-07-17: fflexo [Java] #674 Add std_list.i to add support for std::list containers. The Java proxy extends java.util.AbstractSequentialList and makes the C++ std::list container look diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 146ada2c6..b7ea38f10 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -418,6 +418,7 @@ CPP_TEST_CASES += \ template_default_inherit \ template_default_qualify \ template_default_vw \ + template_empty_inherit \ template_enum \ template_enum_ns_inherit \ template_enum_typedef \ diff --git a/Examples/test-suite/template_empty_inherit.i b/Examples/test-suite/template_empty_inherit.i new file mode 100644 index 000000000..3032f8171 --- /dev/null +++ b/Examples/test-suite/template_empty_inherit.i @@ -0,0 +1,30 @@ +%module template_empty_inherit + +%inline %{ +template struct Functor { + virtual Result operator()(Arg x) const = 0; +}; +%} + +// Bug fix - %ignore was resulting in this warning: +// Warning 401: Base class 'Functor< int,int >' has no name as it is an empty template instantiated with '%template()'. Ignored. +%ignore Functor; +%template() Functor; + +%inline %{ +#include +struct SquareFunctor : Functor { + int operator()(int v) const { return v*v; } +}; +%} + +%include +%template(VectorInt) std::vector; + +%inline %{ +std::vector squares(const std::vector& vi) { + std::vector result; + std::transform(vi.begin(), vi.end(), std::back_inserter(result), SquareFunctor()); + return result; +} +%} diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index bf8028c29..281c96ad0 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -187,8 +187,10 @@ class TypePass:private Dispatcher { ilist = alist = NewList(); Append(ilist, bcls); } else { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); + if (!GetFlag(bcls, "feature:ignore")) { + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); + } } } break; @@ -209,8 +211,10 @@ class TypePass:private Dispatcher { ilist = alist = NewList(); Append(ilist, bcls); } else { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); + if (!GetFlag(bcls, "feature:ignore")) { + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname)); + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname)); + } } } else { Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname)); From aedc3c3eafe416c58467abcc68c498d6b7fd1d27 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 9 Aug 2017 21:15:23 +0100 Subject: [PATCH 0646/2031] Replace assert in Python import examples with code that always runs. --- Examples/python/import_packages/namespace_pkg/nonpkg.py | 3 ++- Examples/python/import_packages/namespace_pkg/normal.py | 3 ++- Examples/python/import_packages/namespace_pkg/split.py | 3 ++- Examples/python/import_packages/namespace_pkg/zipsplit.py | 3 ++- Examples/python/import_packages/split_modules/vanilla/runme.py | 3 ++- .../import_packages/split_modules/vanilla_split/runme.py | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py index acf0aedbd..dc910b846 100644 --- a/Examples/python/import_packages/namespace_pkg/nonpkg.py +++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py @@ -2,4 +2,5 @@ import robin -assert(robin.run() == "AWAY!") +if not(robin.run() == "AWAY!"): + raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py index fc26c0216..231d4cccd 100644 --- a/Examples/python/import_packages/namespace_pkg/normal.py +++ b/Examples/python/import_packages/namespace_pkg/normal.py @@ -4,4 +4,5 @@ sys.path.insert(0, 'path1') from brave import robin -assert(robin.run() == "AWAY!") +if not(robin.run() == "AWAY!"): + raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py index 1b66c2d49..88d17d5fe 100644 --- a/Examples/python/import_packages/namespace_pkg/split.py +++ b/Examples/python/import_packages/namespace_pkg/split.py @@ -6,4 +6,5 @@ sys.path.insert(0, 'path3') from brave import robin -assert(robin.run() == "AWAY!") +if not(robin.run() == "AWAY!"): + raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py index 9e35559e3..b027b11c1 100644 --- a/Examples/python/import_packages/namespace_pkg/zipsplit.py +++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py @@ -6,4 +6,5 @@ sys.path.insert(0, 'path3') from brave import robin -assert(robin.run() == "AWAY!") +if not(robin.run() == "AWAY!"): + raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py index a188364f1..4c46ef200 100644 --- a/Examples/python/import_packages/split_modules/vanilla/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla/runme.py @@ -7,4 +7,5 @@ import pkg1.foo print " Finished importing pkg1.foo" -assert(pkg1.foo.count() == 3) +if not(pkg1.foo.count() == 3): + raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py index a188364f1..4c46ef200 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py @@ -7,4 +7,5 @@ import pkg1.foo print " Finished importing pkg1.foo" -assert(pkg1.foo.count() == 3) +if not(pkg1.foo.count() == 3): + raise RuntimeError("test failed") From b2660e7100b0f499635a58206e0b1a9152f3ffb2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Aug 2017 07:46:56 +0100 Subject: [PATCH 0647/2031] Fix template_empty_inherit testcase - To be standards compliant - Wrap operator() for all target languages --- Examples/test-suite/template_empty_inherit.i | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/test-suite/template_empty_inherit.i b/Examples/test-suite/template_empty_inherit.i index 3032f8171..308a01fda 100644 --- a/Examples/test-suite/template_empty_inherit.i +++ b/Examples/test-suite/template_empty_inherit.i @@ -1,5 +1,7 @@ %module template_empty_inherit +%rename(FunctorOperator) operator(); + %inline %{ template struct Functor { virtual Result operator()(Arg x) const = 0; @@ -13,6 +15,7 @@ template struct Functor { %inline %{ #include +#include struct SquareFunctor : Functor { int operator()(int v) const { return v*v; } }; From aa2932f4090022ee9989d092bc05487622ba212d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Jul 2017 07:23:23 +0100 Subject: [PATCH 0648/2031] Typemap change for templates For templates only, the template parameters are fully resolved when handling typemaps. Without this, it is too hard to have decent rules to apply typemaps when parameter types are typedef'd and template parameters have default values. Fixes %clear for typedefs in templates, eg: %typemap("in") XXX::Long "..." template typename struct XXX { typedef long Long; }; %clear XXX::Long; as the typemap was previously incorrectly stored as a typemap for long instead of XXX::Long. --- .../python/typemap_template_typedef_runme.py | 32 +++++++++ .../test-suite/typemap_template_typedef.i | 66 +++++++++++++++++++ Source/Swig/typemap.c | 36 +++++++++- 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/python/typemap_template_typedef_runme.py create mode 100644 Examples/test-suite/typemap_template_typedef.i diff --git a/Examples/test-suite/python/typemap_template_typedef_runme.py b/Examples/test-suite/python/typemap_template_typedef_runme.py new file mode 100644 index 000000000..a2458367e --- /dev/null +++ b/Examples/test-suite/python/typemap_template_typedef_runme.py @@ -0,0 +1,32 @@ +from typemap_template_typedef import * + +def check(got, expected): + if got != expected: + raise RuntimeError("got: " + str(got) + " expected: " + str(expected)) + +x = XXXInt() + +check(x.aa1(0), 0) +check(x.aa2(0), 55) +check(x.aa3(0), 0) +check(aa1(0), 0) +check(aa2(0), 0) + +check(x.bb1(0), 0) +check(x.bb2(0), 66) +check(x.bb3(0), 0) +check(bb1(0), 0) +check(bb2(0), 0) + +check(x.cc1(0), 0) +check(x.cc2(0), 77) +check(x.cc3(0), 77) +check(cc1(0), 0) +check(cc2(0), 0) + +check(x.dd1(0), 0) +check(x.dd2(0), 88) +check(x.dd3(0), 0) +check(dd1(0), 0) +check(dd2(0), 0) + diff --git a/Examples/test-suite/typemap_template_typedef.i b/Examples/test-suite/typemap_template_typedef.i new file mode 100644 index 000000000..c84416ef9 --- /dev/null +++ b/Examples/test-suite/typemap_template_typedef.i @@ -0,0 +1,66 @@ +%module typemap_template_typedef +//%module("templatereduce") typemap_template_typedef + +%typemap(in) int TMAP55 %{ $1 = 55; /* int TMAP55 typemap */ %} +%typemap(in) int TMAP66 %{ $1 = 66; /* int TMAP66 typemap */ %} +%typemap(in) int TMAP77 %{ $1 = 77; /* int TMAP77 typemap */ %} +%typemap(in) int TMAP88 %{ $1 = 88; /* int TMAP88 typemap */ %} + +%apply int TMAP77 { XXX::Long cc } + +%inline %{ +typedef int Integer; + +template struct XXX { +#ifdef SWIG +// In swig-3.0.12 'Long aa' was actually stored as 'long aa' in typemap table instead of 'XXX::Long aa' +%apply int TMAP55 { Long aa } +%apply int TMAP66 { XXX::Long bb } +%apply int TMAP88 { XXX::Long dd } +#endif + typedef long Long; + long aa1(long aa) { return aa; } + long aa2(Long aa) { return aa; } + long bb1(long bb) { return bb; } + long bb2(Long bb) { return bb; } + long cc1(long cc) { return cc; } + long cc2(Long cc) { return cc; } + long dd1(long dd) { return dd; } + long dd2(Long dd) { return dd; } +#ifdef SWIG +%clear Long aa; +%clear XXX::Long bb; +%clear XXX::Long dd; +#endif + long aa3(Long aa) { return aa; } + long bb3(Long bb) { return bb; } + long cc3(Long cc) { return cc; } + long dd3(Long dd) { return dd; } +}; +%} + +%template(XXXInt) XXX; + +%clear XXX::Long cc; + +%inline %{ + long aa1(XXX::Long aa) { return aa; } + long aa2(long aa) { return aa; } + long bb1(XXX::Long bb) { return bb; } + long bb2(long bb) { return bb; } + long cc1(XXX::Long cc) { return cc; } + long cc2(long cc) { return cc; } + long dd1(XXX::Long dd) { return dd; } + long dd2(long dd) { return dd; } +%} + +%inline %{ +typedef Integer INTEGER; +template struct YYY { + void meff(T1 t1, T2 t2) {} +}; +%} +%template(YYYIntInt) YYY; +%inline %{ + void whyohwhy(YYY yy) {} +%} diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 8970c719d..c0f5397c1 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -61,13 +61,44 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper static Hash *typemaps; +/* ----------------------------------------------------------------------------- + * typemap_identifier_fix() + * + * Create a type that can be used as a hash key lookup independent of the various + * ways a template parameter list can be defined. This is achieved by fully + * resolving the template parameters. + * + * This is a copy and modification of feature_identifier_fix in parser.y. + * ----------------------------------------------------------------------------- */ + +static SwigType *typemap_identifier_fix(const SwigType *s) { + String *tp = SwigType_istemplate_templateprefix(s); + if (tp) { + String *ts, *ta, *tq, *tr; + ts = SwigType_templatesuffix(s); + ta = SwigType_templateargs(s); + tq = Swig_symbol_type_qualify(ta, 0); + tr = SwigType_typedef_resolve_all(ta); + Append(tp,tr); + Append(tp,ts); + Delete(ts); + Delete(ta); + Delete(tq); + Delete(tr); + return tp; + } else { + return NewString(s); + } +} + static Hash *get_typemap(const SwigType *type) { Hash *tm = 0; SwigType *dtype = 0; SwigType *hashtype; if (SwigType_istemplate(type)) { - String *ty = Swig_symbol_template_deftype(type, 0); + SwigType *rty = typemap_identifier_fix(type); + String *ty = Swig_symbol_template_deftype(rty, 0); dtype = Swig_symbol_type_qualify(ty, 0); type = dtype; Delete(ty); @@ -88,7 +119,7 @@ static void set_typemap(const SwigType *type, Hash **tmhash) { Hash *new_tm = 0; assert(*tmhash == 0); if (SwigType_istemplate(type)) { - SwigType *rty = SwigType_typedef_resolve_all(type); + SwigType *rty = typemap_identifier_fix(type); String *ty = Swig_symbol_template_deftype(rty, 0); String *tyq = Swig_symbol_type_qualify(ty, 0); hashtype = SwigType_remove_global_scope_prefix(tyq); @@ -733,6 +764,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type SwigType *oldctype = ctype; ctype = SwigType_typedef_resolve(ctype_unstripped); Delete(oldctype); + Delete(ctype_unstripped); ctype_unstripped = Copy(ctype); } } From 26e14c4f189c0f269047c9a40d137293ecf9a983 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Jul 2017 13:17:23 +0100 Subject: [PATCH 0649/2031] Fix scope lookup for template parameters containing unary scope operators Fixes cases like: namespace Alloc { template struct Rebind { typedef int Integer; }; } %template(RebindBucket) Alloc::Rebind< Bucket >; OR %template(RebindBucket) Alloc::Rebind< ::Bucket >; Alloc::Rebind< Bucket >::Integer Bucket1() { return 1; } Alloc::Rebind< ::Bucket >::Integer Bucket2() { return 2; } Alloc::Rebind<::template TemplateBucket>::Integer Bucket3() { return 3; }; --- Examples/test-suite/common.mk | 1 + .../java/cpp11_template_typedefs_runme.java | 19 +++ ...emplate_parameters_global_scope_runme.java | 75 ++++++++++ .../template_parameters_global_scope.i | 133 ++++++++++++++++++ Source/Swig/typesys.c | 38 ++++- 5 files changed, 260 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/java/cpp11_template_typedefs_runme.java create mode 100644 Examples/test-suite/java/template_parameters_global_scope_runme.java create mode 100644 Examples/test-suite/template_parameters_global_scope.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 146ada2c6..ab341e7a1 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -444,6 +444,7 @@ CPP_TEST_CASES += \ template_ns_enum2 \ template_ns_inherit \ template_ns_scope \ + template_parameters_global_scope \ template_partial_arg \ template_partial_specialization \ template_partial_specialization_typedef \ diff --git a/Examples/test-suite/java/cpp11_template_typedefs_runme.java b/Examples/test-suite/java/cpp11_template_typedefs_runme.java new file mode 100644 index 000000000..473e7cf07 --- /dev/null +++ b/Examples/test-suite/java/cpp11_template_typedefs_runme.java @@ -0,0 +1,19 @@ +import cpp11_template_typedefs.*; + +public class cpp11_template_typedefs_runme { + + static { + try { + System.loadLibrary("cpp11_template_typedefs"); + } 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[]) { + int alloc1 = cpp11_template_typedefs.get_bucket_allocator1(); + int alloc2 = cpp11_template_typedefs.get_bucket_allocator2(); + } +} + diff --git a/Examples/test-suite/java/template_parameters_global_scope_runme.java b/Examples/test-suite/java/template_parameters_global_scope_runme.java new file mode 100644 index 000000000..a536fe476 --- /dev/null +++ b/Examples/test-suite/java/template_parameters_global_scope_runme.java @@ -0,0 +1,75 @@ +import template_parameters_global_scope.*; + +public class template_parameters_global_scope_runme { + + static { + try { + System.loadLibrary("template_parameters_global_scope"); + } 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[]) { + + int alloc = 0; + + // Check 1 + alloc = template_parameters_global_scope.Bucket1(); + alloc = template_parameters_global_scope.Bucket2(); + alloc = template_parameters_global_scope.Bucket3(); + alloc = template_parameters_global_scope.Bucket4(); + alloc = template_parameters_global_scope.Bucket5(); + alloc = template_parameters_global_scope.Bucket6(); + + // Check 2 + alloc = template_parameters_global_scope.Spade1(); + alloc = template_parameters_global_scope.Spade2(); + alloc = template_parameters_global_scope.Spade3(); + alloc = template_parameters_global_scope.Spade4(); + alloc = template_parameters_global_scope.Spade5(); + alloc = template_parameters_global_scope.Spade6(); + + // Check 3 + alloc = template_parameters_global_scope.Ball1(); + alloc = template_parameters_global_scope.Ball2(); + alloc = template_parameters_global_scope.Ball3(); + alloc = template_parameters_global_scope.Ball4(); + alloc = template_parameters_global_scope.Ball5(); + alloc = template_parameters_global_scope.Ball6(); + + // Check 4 + alloc = template_parameters_global_scope.Bat1(); + alloc = template_parameters_global_scope.Bat2(); + alloc = template_parameters_global_scope.Bat3(); + alloc = template_parameters_global_scope.Bat4(); + alloc = template_parameters_global_scope.Bat5(); + alloc = template_parameters_global_scope.Bat6(); + + // Check 5 + alloc = template_parameters_global_scope.Chair1(); + alloc = template_parameters_global_scope.Chair2(); + alloc = template_parameters_global_scope.Chair3(); + alloc = template_parameters_global_scope.Chair4(); + alloc = template_parameters_global_scope.Chair5(); + alloc = template_parameters_global_scope.Chair6(); + + // Check 6 + alloc = template_parameters_global_scope.Table1(); + alloc = template_parameters_global_scope.Table2(); + alloc = template_parameters_global_scope.Table3(); + alloc = template_parameters_global_scope.Table4(); + alloc = template_parameters_global_scope.Table5(); + alloc = template_parameters_global_scope.Table6(); + + /* + alloc = template_parameters_global_scope.rejig1(); + alloc = template_parameters_global_scope.rejig2(); + alloc = template_parameters_global_scope.rejig3(); + alloc = template_parameters_global_scope.rejig4(); + alloc = template_parameters_global_scope.rejig5(); + alloc = template_parameters_global_scope.rejig6(); + */ + } +} diff --git a/Examples/test-suite/template_parameters_global_scope.i b/Examples/test-suite/template_parameters_global_scope.i new file mode 100644 index 000000000..4c14ba4a3 --- /dev/null +++ b/Examples/test-suite/template_parameters_global_scope.i @@ -0,0 +1,133 @@ +%module template_parameters_global_scope + +%inline %{ +namespace Alloc { + template struct Rebind { + typedef int Integer; + }; +} +%} + +%inline %{ +struct Bucket {}; +typedef Bucket TDBucket; +typedef ::Bucket TDGlobalBucket; +%} + +// Check 1: %template no unary scope operator +%template(RebindBucket) Alloc::Rebind< Bucket >; + +%inline %{ +Alloc::Rebind< Bucket >::Integer Bucket1() { return 1; } +Alloc::Rebind< ::Bucket >::Integer Bucket2() { return 2; } +Alloc::Rebind< TDBucket >::Integer Bucket3() { return 3; } +Alloc::Rebind< ::TDBucket >::Integer Bucket4() { return 4; } +Alloc::Rebind< TDGlobalBucket >::Integer Bucket5() { return 5; } +Alloc::Rebind< ::TDGlobalBucket >::Integer Bucket6() { return 6; } +%} + +// Check 2: %template with unary scope operator +%inline %{ +struct Spade {}; +typedef Spade TDSpade; +typedef ::Spade TDGlobalSpade; +%} +%template(RebindSpade) Alloc::Rebind< ::Spade >; + +%inline %{ +Alloc::Rebind< Spade >::Integer Spade1() { return 1; } +Alloc::Rebind< ::Spade >::Integer Spade2() { return 2; } +Alloc::Rebind< TDSpade >::Integer Spade3() { return 3; } +Alloc::Rebind< ::TDSpade >::Integer Spade4() { return 4; } +Alloc::Rebind< TDGlobalSpade >::Integer Spade5() { return 5; } +Alloc::Rebind< ::TDGlobalSpade >::Integer Spade6() { return 6; } +%} + +// Check 3: %template typedef no unary scope operator +%inline %{ +struct Ball {}; +typedef Ball TDBall; +typedef ::Ball TDGlobalBall; +%} +%template(RebindBall) Alloc::Rebind< TDBall >; + +%inline %{ +Alloc::Rebind< Ball >::Integer Ball1() { return 1; } +Alloc::Rebind< ::Ball >::Integer Ball2() { return 2; } +Alloc::Rebind< TDBall >::Integer Ball3() { return 3; } +Alloc::Rebind< ::TDBall >::Integer Ball4() { return 4; } +Alloc::Rebind< TDGlobalBall >::Integer Ball5() { return 5; } +Alloc::Rebind< ::TDGlobalBall >::Integer Ball6() { return 6; } +%} + +// Check 4: %template typedef with unary scope operator +%inline %{ +struct Bat {}; +typedef Bat TDBat; +typedef ::Bat TDGlobalBat; +%} +%template(RebindBat) Alloc::Rebind< ::TDBat >; + +%inline %{ +Alloc::Rebind< Bat >::Integer Bat1() { return 1; } +Alloc::Rebind< ::Bat >::Integer Bat2() { return 2; } +Alloc::Rebind< TDBat >::Integer Bat3() { return 3; } +Alloc::Rebind< ::TDBat >::Integer Bat4() { return 4; } +Alloc::Rebind< TDGlobalBat >::Integer Bat5() { return 5; } +Alloc::Rebind< ::TDGlobalBat >::Integer Bat6() { return 6; } +%} + +// Check 5: %template double typedef no unary scope operator +%inline %{ +struct Chair {}; +typedef Chair TDChair; +typedef ::Chair TDGlobalChair; +%} +%template(RebindChair) Alloc::Rebind< TDGlobalChair >; + +%inline %{ +Alloc::Rebind< Chair >::Integer Chair1() { return 1; } +Alloc::Rebind< ::Chair >::Integer Chair2() { return 2; } +Alloc::Rebind< TDChair >::Integer Chair3() { return 3; } +Alloc::Rebind< ::TDChair >::Integer Chair4() { return 4; } +Alloc::Rebind< TDGlobalChair >::Integer Chair5() { return 5; } +Alloc::Rebind< ::TDGlobalChair >::Integer Chair6() { return 6; } +%} + +// Check 6: %template double typedef with unary scope operator +%inline %{ +struct Table {}; +typedef Table TDTable; +typedef ::Table TDGlobalTable; +%} +%template(RebindTable) Alloc::Rebind< ::TDGlobalTable >; + +%inline %{ +Alloc::Rebind< Table >::Integer Table1() { return 1; } +Alloc::Rebind< ::Table >::Integer Table2() { return 2; } +Alloc::Rebind< TDTable >::Integer Table3() { return 3; } +Alloc::Rebind< ::TDTable >::Integer Table4() { return 4; } +Alloc::Rebind< TDGlobalTable >::Integer Table5() { return 5; } +Alloc::Rebind< ::TDGlobalTable >::Integer Table6() { return 6; } +%} + +#if 0 +%inline %{ +namespace Alloc { + template struct Rejig { + typedef int Integer; + }; +} +%} + +%template(RejigSpade) Alloc::Rejig<::Spade>; + +%inline %{ +Alloc::Rejig<>::Integer rejig1() { return 1; } +Alloc::Rejig< ::Spade >::Integer rejig2() { return 2; } +Alloc::Rejig< ::TDSpade >::Integer rejig3() { return 3; } +Alloc::Rejig< ::TDSpade >::Integer rejig4() { return 4; } +Alloc::Rejig< TDGlobalSpade >::Integer rejig5() { return 5; } +Alloc::Rejig< ::TDGlobalSpade >::Integer rejig6() { return 6; } +%} +#endif diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index e11fc781a..40155591c 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -248,10 +248,26 @@ void SwigType_new_scope(const_String_or_char_ptr name) { ttab = NewHash(); Setattr(s, "typetab", ttab); - /* Build fully qualified name and */ + /* Build fully qualified name */ qname = SwigType_scope_name(s); +#if 1 + { + /* TODO: only do with templates? What happens with non-templates with code below? */ + String *stripped_qname; + stripped_qname = SwigType_remove_global_scope_prefix(qname); + /* Use fully qualified name for hash key without unary scope prefix, qname may contain unary scope */ + Setattr(scopes, stripped_qname, s); + Setattr(s, "qname", qname); + /* + Printf(stdout, "SwigType_new_scope stripped %s %s\n", qname, stripped_qname); + */ + Delete(stripped_qname); + } +#else + Printf(stdout, "SwigType_new_scope %s\n", qname); Setattr(scopes, qname, s); Setattr(s, "qname", qname); +#endif Delete(qname); current_scope = s; @@ -418,12 +434,14 @@ static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) { Typetab *s_orig = s; String *nnameprefix = 0; static int check_parent = 1; + int is_template = 0; if (Getmark(s)) return 0; Setmark(s, 1); - if (SwigType_istemplate(nameprefix)) { + is_template = SwigType_istemplate(nameprefix); + if (is_template) { nnameprefix = SwigType_typedef_resolve_all(nameprefix); nameprefix = nnameprefix; } @@ -437,10 +455,12 @@ static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) { } else { full = NewString(nameprefix); } - if (Getattr(scopes, full)) { - s = Getattr(scopes, full); - } else { - s = 0; + s = Getattr(scopes, full); + if (!s && is_template) { + /* try look up scope with all the unary scope operators within the template parameter list removed */ + SwigType *full_stripped = SwigType_remove_global_scope_prefix(full); + s = Getattr(scopes, full_stripped); + Delete(full_stripped); } Delete(full); if (s) { @@ -911,6 +931,9 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) { return Copy(r); } +#ifdef SWIG_DEBUG + Printf(stdout, "SwigType_typedef_resolve_all start ... %s\n", t); +#endif /* Recursively resolve the typedef */ r = NewString(t); while ((n = SwigType_typedef_resolve(r))) { @@ -931,6 +954,9 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) { Delete(key); Delete(rr); } +#ifdef SWIG_DEBUG + Printf(stdout, "SwigType_typedef_resolve_all end === %s => %s\n", t, r); +#endif return r; } From 8bf3a342c2293d7c621076d26a6245bf5bbbbcb6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Jul 2017 18:54:54 +0100 Subject: [PATCH 0650/2031] Minor code optimisation in template_parameters_resolve --- Source/Swig/typesys.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 40155591c..3bb776a2c 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -594,14 +594,15 @@ static String *template_parameters_resolve(const String *base) { if ((i + 1) < sz) Append(type, ","); } - Append(type, ")>"); - Append(type, suffix); - Delete(suffix); - Delete(tparms); - if (!rep) { + if (rep) { + Append(type, ")>"); + Append(type, suffix); + } else { Delete(type); type = 0; } + Delete(suffix); + Delete(tparms); return type; } From 2681bbad366b8dfc1ed9aa599dcb14ed8684733d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 26 Jul 2017 19:48:46 +0100 Subject: [PATCH 0651/2031] Improve description of template_parameters_resolve --- Source/Swig/typesys.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 3bb776a2c..2fb514d5e 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -561,8 +561,11 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) { /* ----------------------------------------------------------------------------- * template_parameters_resolve() * - * For use with templates only. The template parameters are resolved. If none - * of the parameters can be resolved, zero is returned. + * For use with templates only. Attempts to resolve one template parameter. + * + * If one of the template parameters can be resolved, the type is returned with + * just the one parameter resolved and the remaining parameters left as is. + * If none of the template parameters can be resolved, zero is returned. * ----------------------------------------------------------------------------- */ static String *template_parameters_resolve(const String *base) { From 8753f9652ccc91f0aa080efff15207a4fa33c8ec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 13:09:02 +0100 Subject: [PATCH 0652/2031] Namespace documentation minor corrections --- Doc/Manual/SWIGPlus.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 3e7860b9b..b22f1c279 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3915,6 +3915,8 @@ then SWIG simply creates three wrapper functions bar(), spam(), and blah() in the target language. SWIG does not prepend the names with a namespace prefix nor are the functions packaged in any kind of nested scope. +Note that the default handling of flattening all the namespace scopes in the target language +can be changed via the nspace feature.

    @@ -4203,9 +4205,7 @@ namespace foo {

    Note: The flattening of namespaces is only intended to serve as a basic namespace implementation. -None of the target language modules are currently programmed -with any namespace awareness. In the future, language modules may or may not provide -more advanced namespace support. +More advanced handling of namespaces is discussed next.

    6.19.1 The nspace feature for namespaces

    From 7ee76f93f99e01c9fb5de0bd91ab16178519f18c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 13:41:45 +0100 Subject: [PATCH 0653/2031] More consistent formatting of examples in documentation --- Doc/Manual/Java.html | 4 +-- Doc/Manual/Lua.html | 18 ++++++------ Doc/Manual/Perl5.html | 6 ++-- Doc/Manual/Php.html | 6 ++-- Doc/Manual/Python.html | 37 ++++++++++++------------ Doc/Manual/SWIG.html | 20 ++++++------- Doc/Manual/SWIGPlus.html | 62 ++++++++++++++++++++-------------------- Doc/Manual/Scilab.html | 26 ++++++++--------- Doc/Manual/Tcl.html | 16 +++++------ 9 files changed, 96 insertions(+), 99 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index e0178465c..e21440ee9 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5278,7 +5278,7 @@ void * operator new(size_t t) { throw bad_alloc(); pJalloc->ref = 0; return static_cast<void *>( - static_cast<char *>(static_cast<void *>(pJalloc)) + sizeof(Jalloc)); + static_cast<char *>(static_cast<void *>(pJalloc)) + sizeof(Jalloc)); } } @@ -7240,7 +7240,7 @@ public class runme { example.print_args(animals); String args[] = example.get_args(); for (int i=0; i<args.length; i++) - System.out.println(i + ":" + args[i]); + System.out.println(i + ":" + args[i]); } }
    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index c94fe31dc..c5c944225 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -1008,11 +1008,10 @@ The following operators cannot be overloaded (mainly because they are not suppor

    SWIG also accepts the __str__() member function which converts an object to a string. This function should return a const char*, preferably to static memory. This will be used for the print() and tostring() functions in Lua. Assuming the complex class has a function

    -
    const char* __str__()
    -{
    -        static char buffer[255];
    -        sprintf(buffer, "Complex(%g, %g)", this->re(), this->im());
    -        return buffer;
    +
    const char* __str__() {
    +  static char buffer[255];
    +  sprintf(buffer, "Complex(%g, %g)", this->re(), this->im());
    +  return buffer;
     }
     

    @@ -1031,11 +1030,10 @@ Complex(10, 12)

    It is also possible to overload the operator[], but currently this cannot be automatically performed. To overload the operator[] you need to provide two functions, __getitem__() and __setitem__()

    -
    class Complex
    -{
    -        //....
    -        double __getitem__(int i)const; // i is the index, returns the data
    -        void __setitem__(int i, double d); // i is the index, d is the data
    +
    class Complex {
    +  //....
    +  double __getitem__(int i)const; // i is the index, returns the data
    +  void __setitem__(int i, double d); // i is the index, d is the data
     };
     

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 96e9f7517..03f2c7048 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -3279,9 +3279,9 @@ suffice in most cases:

     %feature("director:except") {
    -    if ($error != NULL) {
    -        throw Swig::DirectorMethodException();
    -    }
    +  if ($error != NULL) {
    +    throw Swig::DirectorMethodException();
    +  }
     }
     
    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 7d3d33ac1..c4ba2e3f8 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -1175,9 +1175,9 @@ should suffice in most cases:
     %feature("director:except") {
    -    if ($error == FAILURE) {
    -        throw Swig::DirectorMethodException();
    -    }
    +  if ($error == FAILURE) {
    +    throw Swig::DirectorMethodException();
    +  }
     }
     
    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1b73c08b7..169151d47 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -226,16 +226,15 @@ resulting C file should be built as a python extension, inserting the module #include "example.h" int fact(int n) { - if (n < 0){ /* This should probably return an error, but this is simpler */ - return 0; - } - if (n == 0) { - return 1; - } - else { - /* testing for overflow would be a good idea here */ - return n * fact(n-1); - } + if (n < 0) { /* This should probably return an error, but this is simpler */ + return 0; + } + if (n == 0) { + return 1; + } else { + /* testing for overflow would be a good idea here */ + return n * fact(n-1); + } }
    @@ -3133,9 +3132,9 @@ suffice in most cases:
     %feature("director:except") {
    -    if ($error != NULL) {
    -        throw Swig::DirectorMethodException();
    -    }
    +  if ($error != NULL) {
    +    throw Swig::DirectorMethodException();
    +  }
     }
     
    @@ -4142,11 +4141,11 @@ Sometimes a C function expects an array to be passed as a pointer. For example,
     int sumitems(int *first, int nitems) {
    -    int i, sum = 0;
    -    for (i = 0; i < nitems; i++) {
    -        sum += first[i];
    -    }
    -    return sum;
    +  int i, sum = 0;
    +  for (i = 0; i < nitems; i++) {
    +    sum += first[i];
    +  }
    +  return sum;
     }
     
    @@ -6526,7 +6525,7 @@ string that cannot be completely decoded as UTF-8: %inline %{ const char* non_utf8_c_str(void) { - return "h\xe9llo w\xc3\xb6rld"; + return "h\xe9llo w\xc3\xb6rld"; } %} diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index e5b441fbb..b1cb1b4dd 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1266,12 +1266,12 @@ pointers. As a result, SWIG creates a wrapper like this:
     Vector *wrap_cross_product(Vector *v1, Vector *v2) {
    -        Vector x = *v1;
    -        Vector y = *v2;
    -        Vector *result;
    -        result = (Vector *) malloc(sizeof(Vector));
    -        *(result) = cross(x, y);
    -        return result;
    +  Vector x = *v1;
    +  Vector y = *v2;
    +  Vector *result;
    +  result = (Vector *) malloc(sizeof(Vector));
    +  *(result) = cross(x, y);
    +  return result;
     }
     
    @@ -1280,10 +1280,10 @@ or if SWIG was run with the -c++ option:

     Vector *wrap_cross(Vector *v1, Vector *v2) {
    -        Vector x = *v1;
    -        Vector y = *v2;
    -        Vector *result = new Vector(cross(x, y)); // Uses default copy constructor
    -        return result;
    +  Vector x = *v1;
    +  Vector y = *v2;
    +  Vector *result = new Vector(cross(x, y)); // Uses default copy constructor
    +  return result;
     }
     
    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index b22f1c279..5841c7d43 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2958,29 +2958,29 @@ To illustrate, consider the following template definition:
     template<class T> class List {
     private:
    -    T *data;
    -    int nitems;
    -    int maxitems;
    +  T *data;
    +  int nitems;
    +  int maxitems;
     public:
    -    List(int max) {
    -      data = new T [max];
    -      nitems = 0;
    -      maxitems = max;
    -    }
    -    ~List() {
    -      delete [] data;
    -    };
    -    void append(T obj) {
    -      if (nitems < maxitems) {
    -        data[nitems++] = obj;
    -      }
    -    }
    -    int length() {
    -      return nitems;
    -    }
    -    T get(int n) {
    -      return data[n];
    +  List(int max) {
    +    data = new T [max];
    +    nitems = 0;
    +    maxitems = max;
    +  }
    +  ~List() {
    +    delete [] data;
    +  };
    +  void append(T obj) {
    +    if (nitems < maxitems) {
    +      data[nitems++] = obj;
         }
    +  }
    +  int length() {
    +    return nitems;
    +  }
    +  T get(int n) {
    +    return data[n];
    +  }
     };
     
    @@ -3704,10 +3704,10 @@ template <class T> class OuterTemplateClass {}; // Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and // OuterClass::InnerClass if the target language doesn't support nested classes. class OuterClass { - public: - // Forward declarations: - struct InnerStruct; - class InnerClass; + public: + // Forward declarations: + struct InnerStruct; + class InnerClass; }; struct OuterClass::InnerStruct {}; @@ -4533,13 +4533,13 @@ around some other class. For example:
     // Smart-pointer class
     template<class T> class SmartPtr {
    -    T *pointee;
    +  T *pointee;
     public:
    -    SmartPtr(T *p) : pointee(p) { ... }
    -    T *operator->() {
    -        return pointee;
    -    }
    -    ...
    +  SmartPtr(T *p) : pointee(p) { ... }
    +  T *operator->() {
    +    return pointee;
    +  }
    +  ...
     };
     
     // Ordinary class
    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
    index 14e03ff18..aef06e302 100644
    --- a/Doc/Manual/Scilab.html
    +++ b/Doc/Manual/Scilab.html
    @@ -121,15 +121,15 @@ In this example we bind from C a function and a global variable into Scilab. The
     double Foo = 3.0;
     
     int fact(int n) {
    -    if (n < 0) {
    -        return 0;
    -    }
    -    else if (n == 0) {
    -        return 1;
    -    }
    -    else {
    -        return n * fact(n-1);
    -    }
    +  if (n < 0) {
    +    return 0;
    +  }
    +  else if (n == 0) {
    +    return 1;
    +  }
    +  else {
    +    return n * fact(n-1);
    +  }
     }
     %}
     
    @@ -896,8 +896,8 @@ Let's see it on an example of a struct with two members: %inline %{ typedef struct { - int x; - int arr[4]; + int x; + int arr[4]; } Foo; %} @@ -1143,11 +1143,11 @@ As explained in 6.15 SWI %module example void magnify(Square *square, double factor) { - square->size *= factor; + square->size *= factor; }; void magnify(Circle *circle, double factor) { - square->radius *= factor; + square->radius *= factor; };
    diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 38d4103e0..31408b312 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -3215,28 +3215,28 @@ helper functions to access arrays : %inline %{ double *new_double(int size) { - return (double *) malloc(size*sizeof(double)); + return (double *) malloc(size*sizeof(double)); } void delete_double(double *a) { - free(a); + free(a); } double get_double(double *a, int index) { - return a[index]; + return a[index]; } void set_double(double *a, int index, double val) { - a[index] = val; + a[index] = val; } int *new_int(int size) { - return (int *) malloc(size*sizeof(int)); + return (int *) malloc(size*sizeof(int)); } void delete_int(int *a) { - free(a); + free(a); } int get_int(int *a, int index) { - return a[index]; + return a[index]; } int set_int(int *a, int index, int val) { - a[index] = val; + a[index] = val; } %} From 8052211ac586e691c75bde7814803add8fe1b32f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 13:56:47 +0100 Subject: [PATCH 0654/2031] More consistent formatting of examples in documentation --- Doc/Manual/CSharp.html | 40 ++++++++++++------------ Doc/Manual/Customization.html | 2 +- Doc/Manual/Extending.html | 58 +++++++++++++++++------------------ Doc/Manual/Java.html | 22 ++++++------- Doc/Manual/Perl5.html | 5 ++- Doc/Manual/SWIGPlus.html | 26 ++++++++-------- 6 files changed, 76 insertions(+), 77 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 5be63a340..d618f5a08 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -997,9 +997,9 @@ When the following C# code is executed:
     public class runme {
    -    static void Main() {
    -      example.positivesonly(-1);
    -    }
    +  static void Main() {
    +    example.positivesonly(-1);
    +  }
     }
     
    @@ -1846,12 +1846,12 @@ and the following usage from C# after running the code through SWIG:
    -      Wheel wheel = new Bike(10).getWheel();
    -      Console.WriteLine("wheel size: " + wheel.size);
    -      // Simulate a garbage collection
    -      global::System.GC.Collect();
    -      global::System.GC.WaitForPendingFinalizers();
    -      global::System.Console.WriteLine("wheel size: " + wheel.size);
    +  Wheel wheel = new Bike(10).getWheel();
    +  Console.WriteLine("wheel size: " + wheel.size);
    +  // Simulate a garbage collection
    +  global::System.GC.Collect();
    +  global::System.GC.WaitForPendingFinalizers();
    +  global::System.Console.WriteLine("wheel size: " + wheel.size);
     
    @@ -1980,9 +1980,9 @@ and more or less equivalent usage from C#
    -      Container container = new Container();
    -      Element element = new Element(20);
    -      container.setElement(element);
    +  Container container = new Container();
    +  Element element = new Element(20);
    +  container.setElement(element);
     
    @@ -1993,14 +1993,14 @@ In order to understand why, consider a garbage collection occuring...
    -      Container container = new Container();
    -      Element element = new Element(20);
    -      container.setElement(element);
    -      Console.WriteLine("element.value: " + container.getElement().value);
    -      // Simulate a garbage collection
    -      global::System.GC.Collect();
    -      global::System.GC.WaitForPendingFinalizers();
    -      global::System.Console.WriteLine("element.value: " + container.getElement().value);
    +  Container container = new Container();
    +  Element element = new Element(20);
    +  container.setElement(element);
    +  Console.WriteLine("element.value: " + container.getElement().value);
    +  // Simulate a garbage collection
    +  global::System.GC.Collect();
    +  global::System.GC.WaitForPendingFinalizers();
    +  global::System.Console.WriteLine("element.value: " + container.getElement().value);
     
    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 0e5fb2869..e5040fc9b 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -516,7 +516,7 @@ The special variables are often used in situations where method calls are logged $action } catch (MemoryError) { - croak("Out of memory in $decl"); + croak("Out of memory in $decl"); } } void log(const char *message); diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index bf70b69ac..c225d9554 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -2592,36 +2592,36 @@ command line options, simply use code similar to this:
     void Language::main(int argc, char *argv[]) {
       for (int i = 1; i < argc; i++) {
    -      if (argv[i]) {
    -          if (strcmp(argv[i], "-interface") == 0) {
    -            if (argv[i+1]) {
    -              interface = NewString(argv[i+1]);
    -              Swig_mark_arg(i);
    -              Swig_mark_arg(i+1);
    -              i++;
    -            } else {
    -              Swig_arg_error();
    -            }
    -          } else if (strcmp(argv[i], "-globals") == 0) {
    -            if (argv[i+1]) {
    -              global_name = NewString(argv[i+1]);
    -              Swig_mark_arg(i);
    -              Swig_mark_arg(i+1);
    -              i++;
    -            } else {
    -              Swig_arg_error();
    -            }
    -          } else if ((strcmp(argv[i], "-proxy") == 0)) {
    -            proxy_flag = 1;
    -            Swig_mark_arg(i);
    -          } else if (strcmp(argv[i], "-keyword") == 0) {
    -            use_kw = 1;
    -            Swig_mark_arg(i);
    -          } else if (strcmp(argv[i], "-help") == 0) {
    -            fputs(usage, stderr);
    -          }
    -          ...
    +    if (argv[i]) {
    +      if (strcmp(argv[i], "-interface") == 0) {
    +        if (argv[i+1]) {
    +          interface = NewString(argv[i+1]);
    +          Swig_mark_arg(i);
    +          Swig_mark_arg(i+1);
    +          i++;
    +        } else {
    +          Swig_arg_error();
    +        }
    +      } else if (strcmp(argv[i], "-globals") == 0) {
    +        if (argv[i+1]) {
    +          global_name = NewString(argv[i+1]);
    +          Swig_mark_arg(i);
    +          Swig_mark_arg(i+1);
    +          i++;
    +        } else {
    +          Swig_arg_error();
    +        }
    +      } else if ((strcmp(argv[i], "-proxy") == 0)) {
    +        proxy_flag = 1;
    +        Swig_mark_arg(i);
    +      } else if (strcmp(argv[i], "-keyword") == 0) {
    +        use_kw = 1;
    +        Swig_mark_arg(i);
    +      } else if (strcmp(argv[i], "-help") == 0) {
    +        fputs(usage, stderr);
           }
    +      ...
    +    }
       }
     }
     
    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index e21440ee9..928adce67 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3935,9 +3935,9 @@ where Swig::DirectorException::raise is a helper method in the Director
    -    static void raise(JNIEnv *jenv, jthrowable throwable) {
    -      throw DirectorException(jenv, throwable);
    -    }
    +  static void raise(JNIEnv *jenv, jthrowable throwable) {
    +    throw DirectorException(jenv, throwable);
    +  }
     
    @@ -4335,16 +4335,16 @@ struct Vector { %extend Vector { char *toString() { - static char tmp[1024]; - sprintf(tmp, "Vector(%g, %g, %g)", $self->x, $self->y, $self->z); - return tmp; + static char tmp[1024]; + sprintf(tmp, "Vector(%g, %g, %g)", $self->x, $self->y, $self->z); + return tmp; } Vector(double x, double y, double z) { - Vector *v = (Vector *) malloc(sizeof(Vector)); - v->x = x; - v->y = y; - v->z = z; - return v; + Vector *v = (Vector *) malloc(sizeof(Vector)); + v->x = x; + v->y = y; + v->z = z; + return v; } };
    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 03f2c7048..5e9a9e33e 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -1633,9 +1633,8 @@ class DoubleArray { void setitem(int i, double val) { if ((i >= 0) && (i < n)) ptr[i] = val; - else { + else throw RangeError(); - } } };
    @@ -2985,7 +2984,7 @@ sub set_transform for (my $j = 0; $j < 4, $j++) { mat44_set($a, $i, $j, $x->[i][j]) - } + } } example.set_transform($im, $a); free_mat44($a); diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 5841c7d43..3d8263e37 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -346,8 +346,8 @@ public: class Spam { public: - Foo *value; - ... + Foo *value; + ... }; @@ -726,7 +726,7 @@ public: class Grok : public Bar { public: - Grok(); // Not wrapped. No implementation of abstract spam(). + Grok(); // Not wrapped. No implementation of abstract spam(). }; @@ -4915,19 +4915,19 @@ base classes. For example:
     class Foo {
     public:
    -      int  blah(int x);
    +  int  blah(int x);
     };
     
     class Bar {
     public:
    -      double blah(double x);
    +  double blah(double x);
     };
     
     class FooBar : public Foo, public Bar {
     public:
    -      using Foo::blah;  
    -      using Bar::blah;
    -      char *blah(const char *x);
    +  using Foo::blah;
    +  using Bar::blah;
    +  char *blah(const char *x);
     };
     
    @@ -5008,14 +5008,14 @@ correctly, you can always change the interface to the following: class FooBar : public Foo, public Bar { public: #ifndef SWIG - using Foo::blah; - using Bar::blah; + using Foo::blah; + using Bar::blah; #else - int blah(int x); // explicitly tell SWIG about other declarations - double blah(double x); + int blah(int x); // explicitly tell SWIG about other declarations + double blah(double x); #endif - char *blah(const char *x); + char *blah(const char *x); }; From ba45861b462e91e266456f510036768c2aa55be5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 16:49:21 +0100 Subject: [PATCH 0655/2031] More consistent formatting of examples in documentation --- Doc/Manual/Go.html | 4 +- Doc/Manual/SWIG.html | 16 ++--- Doc/Manual/SWIGPlus.html | 148 +++++++++++++++++++-------------------- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index f25e9850b..820921bd5 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -639,12 +639,12 @@ public: virtual ~FooBarAbstract() {}; std::string FooBar() { - return this->Foo() + ", " + this->Bar(); + return this->Foo() + ", " + this->Bar(); }; protected: virtual std::string Foo() { - return "Foo"; + return "Foo"; }; virtual std::string Bar() = 0; diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index b1cb1b4dd..cff4e7dc2 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1043,14 +1043,14 @@ expect :

     # Copy a file 
     def filecopy(source, target):
    -  f1 = fopen(source, "r")
    -  f2 = fopen(target, "w")
    -  buffer = malloc(8192)
    -  nbytes = fread(buffer, 8192, 1, f1)
    -  while (nbytes > 0):
    -    fwrite(buffer, 8192, 1, f2)
    -          nbytes = fread(buffer, 8192, 1, f1)
    -  free(buffer)
    +    f1 = fopen(source, "r")
    +    f2 = fopen(target, "w")
    +    buffer = malloc(8192)
    +    nbytes = fread(buffer, 8192, 1, f1)
    +    while (nbytes > 0):
    +        fwrite(buffer, 8192, 1, f2)
    +            nbytes = fread(buffer, 8192, 1, f1)
    +    free(buffer)
     

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 3d8263e37..87fe30fa8 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -777,9 +777,9 @@ the normal constructor function. For example, if you have this:

     class List {
     public:
    -    List();    
    -    List(const List &);      // Copy constructor
    -    ...
    +  List();    
    +  List(const List &);      // Copy constructor
    +  ...
     };
     
    @@ -803,7 +803,7 @@ through a special function like this:
     List *copy_List(List *f) {
    -    return new List(*f);
    +  return new List(*f);
     }
     
    @@ -832,7 +832,7 @@ However, copy constructor wrappers can be generated if using the copyctor
    @@ -851,9 +851,9 @@ could be wrapped, but they had to be renamed. For example:
     class Foo {
     public:
    -    Foo();
    +  Foo();
       %name(CopyFoo) Foo(const Foo &);
    -    ...
    +  ...
     };
     
    @@ -969,8 +969,8 @@ not primitive types, such as classes. For instance, if you had another class lik
     class Foo {
     public:
    -    List items;
    -    ...
    +  List items;
    +  ...
     
    @@ -982,10 +982,10 @@ For example:
     List *Foo_items_get(Foo *self) {
    -    return &self->items;
    +  return &self->items;
     }
     void Foo_items_set(Foo *self, List *value) {
    -    self->items = *value;
    +  self->items = *value;
     }
     
    @@ -1007,10 +1007,10 @@ It is the naturalvar feature and can be used to effectively change the way acces
     const List &Foo_items_get(Foo *self) {
    -    return self->items;
    +  return self->items;
     }
     void Foo_items_set(Foo *self, const List &value) {
    -    self->items = value;
    +  self->items = value;
     }
     
    @@ -1105,7 +1105,7 @@ SWIG will wrap all types of functions that have default arguments. For example m
     class Foo {
     public:
    -    void bar(int x, int y = 3, int z = 4);
    +  void bar(int x, int y = 3, int z = 4);
     };
     
    @@ -1120,9 +1120,9 @@ Thus for the example above, it is as if we had instead given the following to SW
     class Foo {
     public:
    -    void bar(int x, int y, int z);
    -    void bar(int x, int y);
    -    void bar(int x);
    +  void bar(int x, int y, int z);
    +  void bar(int x, int y);
    +  void bar(int x);
     };
     
    @@ -1158,7 +1158,7 @@ can be re-activated by using the compactdefaultargs %feature("compactdefaultargs") Foo::bar; class Foo { public: - void bar(int x, int y = 3, int z = 4); + void bar(int x, int y = 3, int z = 4); }; @@ -1485,8 +1485,8 @@ class A; %feature("valuewrapper") B; struct B { - B(); - // .... + B(); + // .... }; @@ -3000,15 +3000,15 @@ provide an expanded version of the class directly like this: %rename(intList) List<int>; // Rename to a suitable identifier class List<int> { private: - int *data; - int nitems; - int maxitems; + int *data; + int nitems; + int maxitems; public: - List(int max); - ~List(); - void append(int obj); - int length(); - int get(int n); + List(int max); + ~List(); + void append(int obj); + int length(); + int get(int n); }; @@ -3244,15 +3244,15 @@ a class like this,
     template<> class List<int> {
     private:
    -    int *data;
    -    int nitems;
    -    int maxitems;
    +  int *data;
    +  int nitems;
    +  int maxitems;
     public:
    -    List(int max);
    -    ~List();
    -    void append(int obj);
    -    int length();
    -    int get(int n);
    +  List(int max);
    +  ~List();
    +  void append(int obj);
    +  int length();
    +  int get(int n);
     };
     
    @@ -3275,15 +3275,15 @@ code defines a template that is applied when the template argument is a pointer.
     template<class T> class List<T*> {
     private:
    -    T *data;
    -    int nitems;
    -    int maxitems;
    +  T *data;
    +  int nitems;
    +  int maxitems;
     public:
    -    List(int max);
    -    ~List();
    -    void append(int obj);
    -    int length();
    -    T get(int n);
    +  List(int max);
    +  ~List();
    +  void append(int obj);
    +  int length();
    +  T get(int n);
     };
     
    @@ -3587,11 +3587,11 @@ It is also possible to separate these declarations from the template class. For ... template<class T> class List { - ... - public: - List() { } - T get(int index); - ... + ... + public: + List() { } + T get(int index); + ... }; @@ -3609,9 +3609,9 @@ additional methods to a specific instantiation. For example: %template(intList) List<int>; %extend List<int> { - void blah() { - printf("Hey, I'm an List<int>!\n"); - } + void blah() { + printf("Hey, I'm an List<int>!\n"); + } }; @@ -3698,7 +3698,7 @@ template <class T> class OuterTemplateClass {}; // OuterTemplateClass<OuterClass::InnerStruct> and thus the template needs // to be expanded with %template before the OuterClass declaration. %template(OuterTemplateClass_OuterClass__InnerStruct) - OuterTemplateClass<OuterClass::InnerStruct> + OuterTemplateClass<OuterClass::InnerStruct> // Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and @@ -3736,7 +3736,7 @@ introduced a new class name. This name could then be used with other directives
     %template(vectori) vector<int>;
     %extend vectori {
    -    void somemethod() { }
    +  void somemethod() { }
     };
     
    @@ -3750,7 +3750,7 @@ as the class name. For example:
     %template(vectori) vector<int>;
     %extend vector<int> {
    -    void somemethod() { }
    +  void somemethod() { }
     };
     
    @@ -4011,7 +4011,7 @@ in a different namespace. For example:
     namespace foo {
    -    template<typename T> T max(T a, T b) { return a > b ? a : b; }
    +  template<typename T> T max(T a, T b) { return a > b ? a : b; }
     }
     
     using foo::max;
    @@ -4020,8 +4020,8 @@ using foo::max;
     %template(maxfloat) foo::max<float>;    // Okay (qualified name).
     
     namespace bar {
    -    using namespace foo;
    -    %template(maxdouble)  max<double>;    // Okay.
    +  using namespace foo;
    +  %template(maxdouble)  max<double>;    // Okay.
     }
     
    @@ -4445,10 +4445,10 @@ struct Error4 : EBase { }; class Foo { public: - ... - void bar(); - void blah() throw(Error1, Error2, Error3, Error4); - ... + ... + void bar(); + void blah() throw(Error1, Error2, Error3, Error4); + ... }; @@ -4545,8 +4545,8 @@ public: // Ordinary class class Foo_Impl { public: - int x; - virtual void bar(); + int x; + virtual void bar(); ... }; @@ -4555,13 +4555,13 @@ typedef SmartPtr<Foo_Impl> Foo; // Create smart pointer Foo Foo make_Foo() { - return SmartPtr<Foo_Impl>(new Foo_Impl()); + return SmartPtr<Foo_Impl>(new Foo_Impl()); } // Do something with smart pointer Foo void do_something(Foo f) { - printf("x = %d\n", f->x); - f->bar(); + printf("x = %d\n", f->x); + f->bar(); } // Call the wrapped smart pointer proxy class in the target language 'Foo' @@ -4660,13 +4660,13 @@ example, if you have this code

     class Foo {
     public:
    -    int x;
    +  int x;
     };
     
     class Bar {
     public:
    -    int x;       
    -    Foo *operator->();
    +  int x;       
    +  Foo *operator->();
     };
     
    @@ -4970,14 +4970,14 @@ you wrap this code in Python, the module works just like you would expect:
     class Foo {
     protected:
    -    int x;
    -    int blah(int x);
    +  int x;
    +  int blah(int x);
     };
     
     class Bar : public Foo {
     public:
    -    using Foo::x;       // Make x public
    -    using Foo::blah;    // Make blah public
    +  using Foo::x;       // Make x public
    +  using Foo::blah;    // Make blah public
     };
     
    From c454f2ce2f91e0f458121033ffa349c283eeeb30 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 17:02:47 +0100 Subject: [PATCH 0656/2031] Documentation corrections to use targetlang formatting --- Doc/Manual/Library.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index a800c2d73..f41799bf0 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -411,7 +411,7 @@ void print_array(double x[10]); Now, in a scripting language, you might write this:

    -
    +
     a = new_doubleArray(10)             # Create an array
     for i in range(0, 10):
    @@ -475,7 +475,7 @@ void print_array(double x[10]);
     Allows you to do this:
     

    -
    +
     import example
     c = example.doubleArray(10)  # Create double[10]
    @@ -801,7 +801,7 @@ target language.  In other words, if you were using a language like Tcl,
     and you wrote this,
     

    -
    +
     % foo Hello
     
    @@ -852,7 +852,7 @@ size_t parity(char *str, size_t len, size_t initial); Now, in the target language, you can use binary string data like this:

    -
    +
     >>> s = "H\x00\x15eg\x09\x20"
     >>> parity(s, 0)
    
    From 04131a988f49286fde74fb9d74c5c4bd1ade8454 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Sun, 30 Jul 2017 17:18:55 +0100
    Subject: [PATCH 0657/2031] More consistent formatting of examples in
     documentation
    
    ---
     Doc/Manual/CSharp.html   |   2 +-
     Doc/Manual/Perl5.html    | 114 ++++++++++++++++++-------------------
     Doc/Manual/Php.html      |  18 +++---
     Doc/Manual/Pike.html     |   4 +-
     Doc/Manual/Python.html   | 119 ++++++++++++++++++++-------------------
     Doc/Manual/SWIG.html     |  16 +++---
     Doc/Manual/SWIGPlus.html |   2 +-
     Doc/Manual/Tcl.html      |  46 +++++++--------
     8 files changed, 161 insertions(+), 160 deletions(-)
    
    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
    index d618f5a08..bb3524ac5 100644
    --- a/Doc/Manual/CSharp.html
    +++ b/Doc/Manual/CSharp.html
    @@ -677,7 +677,7 @@ 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);
    +  examplePINVOKE.myArrayCopy(sourceArray, targetArray, nitems);
     }
     
    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 5e9a9e33e..8ea43ad6b 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -949,7 +949,7 @@ Foo *BarToFoo(Bar *b) { } Foo *IncrFoo(Foo *f, int i) { - return f+i; + return f+i; } %}
    @@ -1057,7 +1057,7 @@ produces a single accessor function like this:
     int *Foo_x_get(Foo *self) {
    -    return self->x;
    +  return self->x;
     };
     
    @@ -1092,11 +1092,11 @@ generates accessor functions such as this:
     Foo *Bar_f_get(Bar *b) {
    -    return &b->f;
    +  return &b->f;
     }
     
     void Bar_f_set(Bar *b, Foo *val) {
    -    b->f = *val;
    +  b->f = *val;
     }
     
    @@ -1887,9 +1887,9 @@ like this:
     %typemap(out) int {
    -    $result = sv_newmortal();
    -    set_setiv($result, (IV) $1);
    -    argvi++;
    +  $result = sv_newmortal();
    +  set_setiv($result, (IV) $1);
    +  argvi++;
     }
     
    @@ -2312,8 +2312,8 @@ Consider the following data structure:
     #define SIZE  8
     typedef struct {
    -    int   values[SIZE];
    -    ...
    +  int   values[SIZE];
    +  ...
     } Foo;
     
     
    @@ -2327,10 +2327,10 @@ To make the member writable, a "memberin" typemap can be used.
     %typemap(memberin) int [SIZE] {
    -    int i;
    -    for (i = 0; i < SIZE; i++) {
    -        $1[i] = $input[i];
    -    }
    +  int i;
    +  for (i = 0; i < SIZE; i++) {
    +    $1[i] = $input[i];
    +  }
     }
     
     
    @@ -2599,48 +2599,48 @@ package example::Vector; %BLESSEDMEMBERS = (); sub new () { - my $self = shift; - my @args = @_; - $self = vectorc::new_Vector(@args); - return undef if (!defined($self)); - bless $self, "example::Vector"; - $OWNER{$self} = 1; - my %retval; - tie %retval, "example::Vector", $self; - return bless \%retval, "Vector"; + my $self = shift; + my @args = @_; + $self = vectorc::new_Vector(@args); + return undef if (!defined($self)); + bless $self, "example::Vector"; + $OWNER{$self} = 1; + my %retval; + tie %retval, "example::Vector", $self; + return bless \%retval, "Vector"; } sub DESTROY { - return unless $_[0]->isa('HASH'); - my $self = tied(%{$_[0]}); - delete $ITERATORS{$self}; - if (exists $OWNER{$self}) { - examplec::delete_Vector($self)); - delete $OWNER{$self}; - } + return unless $_[0]->isa('HASH'); + my $self = tied(%{$_[0]}); + delete $ITERATORS{$self}; + if (exists $OWNER{$self}) { + examplec::delete_Vector($self)); + delete $OWNER{$self}; + } } sub FETCH { - my ($self, $field) = @_; - my $member_func = "vectorc::Vector_${field}_get"; - my $val = &$member_func($self); - if (exists $BLESSEDMEMBERS{$field}) { - return undef if (!defined($val)); - my %retval; - tie %retval, $BLESSEDMEMBERS{$field}, $val; - return bless \%retval, $BLESSEDMEMBERS{$field}; - } - return $val; + my ($self, $field) = @_; + my $member_func = "vectorc::Vector_${field}_get"; + my $val = &$member_func($self); + if (exists $BLESSEDMEMBERS{$field}) { + return undef if (!defined($val)); + my %retval; + tie %retval, $BLESSEDMEMBERS{$field}, $val; + return bless \%retval, $BLESSEDMEMBERS{$field}; + } + return $val; } sub STORE { - my ($self, $field, $newval) = @_; - my $member_func = "vectorc::Vector_${field}_set"; - if (exists $BLESSEDMEMBERS{$field}) { - &$member_func($self, tied(%{$newval})); - } else { - &$member_func($self, $newval); - } + my ($self, $field, $newval) = @_; + my $member_func = "vectorc::Vector_${field}_set"; + if (exists $BLESSEDMEMBERS{$field}) { + &$member_func($self, tied(%{$newval})); + } else { + &$member_func($self, $newval); + } }
    @@ -2841,11 +2841,11 @@ this:
     sub dot_product {
    -    my @args = @_;
    -    $args[0] = tied(%{$args[0]});         # Get the real pointer values
    -    $args[1] = tied(%{$args[1]});
    -    my $result = vectorc::dot_product(@args);
    -    return $result;
    +  my @args = @_;
    +  $args[0] = tied(%{$args[0]});         # Get the real pointer values
    +  $args[1] = tied(%{$args[1]});
    +  my $result = vectorc::dot_product(@args);
    +  return $result;
     }
     
    @@ -3103,14 +3103,14 @@ the methods one() and two() (but not three()): %feature("director") Foo; class Foo { public: - Foo(int foo); - virtual void one(); - virtual void two(); + Foo(int foo); + virtual void one(); + virtual void two(); }; class Bar: public Foo { public: - virtual void three(); + virtual void three(); };
    @@ -3304,8 +3304,8 @@ suitable exception handler:
     %exception {
    -    try { $action }
    -    catch (Swig::DirectorException &e) { SWIG_fail; }
    +  try { $action }
    +  catch (Swig::DirectorException &e) { SWIG_fail; }
     }
     
    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index c4ba2e3f8..4fda4cc69 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -986,14 +986,14 @@ the methods one() and two() (but not three()): %feature("director") Foo; class Foo { public: - Foo(int foo); - virtual void one(); - virtual void two(); + Foo(int foo); + virtual void one(); + virtual void two(); }; class Bar: public Foo { public: - virtual void three(); + virtual void three(); };
    @@ -1125,12 +1125,12 @@ Here is an example:
     class Foo {
     public:
    -    ...
    +  ...
     };
     class FooContainer {
     public:
    -    void addFoo(Foo *);
    -    ...
    +  void addFoo(Foo *);
    +  ...
     };
     
    @@ -1204,8 +1204,8 @@ suitable exception handler:
     %exception {
    -    try { $action }
    -    catch (Swig::DirectorException &e) { SWIG_fail; }
    +  try { $action }
    +  catch (Swig::DirectorException &e) { SWIG_fail; }
     }
     
    diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html index 22ab4e2a2..a8bc0d415 100644 --- a/Doc/Manual/Pike.html +++ b/Doc/Manual/Pike.html @@ -230,8 +230,8 @@ For example, given this C++ class declaration: class Shape { public: - static void print(); - static int nshapes; + static void print(); + static int nshapes; }; diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 169151d47..e294db86d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1275,7 +1275,7 @@ Foo *BarToFoo(Bar *b) { } Foo *IncrFoo(Foo *f, int i) { - return f+i; + return f+i; } %} @@ -1385,7 +1385,7 @@ example, consider this:
     struct Bar {
    -    int  x[16];
    +  int  x[16];
     };
     
    @@ -1715,9 +1715,9 @@ Similarly, if you have a class like this,
     class Foo {
     public:
    -    Foo();
    -    Foo(const Foo &);
    -    ...
    +  Foo();
    +  Foo(const Foo &);
    +  ...
     };
     
    @@ -1950,11 +1950,11 @@ For example: %rename(Bar_spam) Bar::spam; namespace Foo { - int spam(); + int spam(); } namespace Bar { - int spam(); + int spam(); } @@ -2165,9 +2165,9 @@ have a class like this
     class Foo {
     public:
    -    int x;
    -    int spam(int);
    -    ...
    +  int x;
    +  int spam(int);
    +  ...
     
    @@ -2178,19 +2178,19 @@ then SWIG transforms it into a set of low-level procedural wrappers. For example
     Foo *new_Foo() {
    -    return new Foo();
    +  return new Foo();
     }
     void delete_Foo(Foo *f) {
    -    delete f;
    +  delete f;
     }
     int Foo_x_get(Foo *f) {
    -    return f->x;
    +  return f->x;
     }
     void Foo_x_set(Foo *f, int value) {
    -    f->x = value;
    +  f->x = value;
     }
     int Foo_spam(Foo *f, int arg1) {
    -    return f->spam(arg1);
    +  return f->spam(arg1);
     }
     
    @@ -2309,10 +2309,10 @@ please refer to the python documentation:

     typedef struct {
    -    PyObject_HEAD
    -    PyObject *dict;
    -    PyObject *args;
    -    PyObject *message;
    +  PyObject_HEAD
    +  PyObject *dict;
    +  PyObject *args;
    +  PyObject *message;
     } PyBaseExceptionObject;
     
    @@ -2322,12 +2322,12 @@ typedef struct {
     typedef struct {
    -    PyObject_HEAD
    -    void *ptr;
    -    swig_type_info *ty;
    -    int own;
    -    PyObject *next;
    -    PyObject *dict;
    +  PyObject_HEAD
    +  void *ptr;
    +  swig_type_info *ty;
    +  int own;
    +  PyObject *next;
    +  PyObject *dict;
     } SwigPyObject;
     
    @@ -2338,13 +2338,13 @@ typedef struct {
     class MyException {
     public:
    -    MyException (const char *msg_);
    -    ~MyException ();
    +  MyException (const char *msg_);
    +  ~MyException ();
     
    -    const char *what () const;
    +  const char *what () const;
     
     private:
    -    char *msg;
    +  char *msg;
     };
     
    @@ -2371,9 +2371,9 @@ strings, you can define an 'operator+ (const char*)' method :

     class MyString {
     public:
    -    MyString (const char *init);
    -    MyString operator+ (const char *other) const;
    -    ...
    +  MyString (const char *init);
    +  MyString operator+ (const char *other) const;
    +  ...
     };
     
    @@ -2472,11 +2472,12 @@ slot entries. For example, suppose you have this class:
     class Twit {
     public:
    -    Twit operator+ (const Twit& twit) const;
    +  Twit operator+ (const Twit& twit) const;
     
    -    // Forward to operator+
    -    Twit add (const Twit& twit) const
    -    { return *this + twit; }
    +  // Forward to operator+
    +  Twit add (const Twit& twit) const {
    +    return *this + twit;
    +  }
     };
     
    @@ -2635,8 +2636,8 @@ ownership of the result. For example:
     class Foo {
     public:
    -    Foo();
    -    Foo bar();
    +  Foo();
    +  Foo bar();
     };
     
    @@ -2665,9 +2666,9 @@ they came from. Therefore, the ownership is set to zero. For example:
     class Foo {
     public:
    -    ...
    -    Foo *spam();
    -    ...
    +  ...
    +  Foo *spam();
    +  ...
     };
     
    @@ -2706,8 +2707,8 @@ or global variable. For example, consider this interface: %module example struct Foo { - int value; - Foo *next; + int value; + Foo *next; }; Foo *head = 0; @@ -2938,15 +2939,15 @@ the methods one() and two() (but not three()): %feature("director") Foo; class Foo { public: - Foo(int foo); - virtual ~Foo(); - virtual void one(); - virtual void two(); + Foo(int foo); + virtual ~Foo(); + virtual void one(); + virtual void two(); }; class Bar: public Foo { public: - virtual void three(); + virtual void three(); }; @@ -3090,8 +3091,8 @@ public: }; class FooContainer { public: - void addFoo(Foo *); - ... + void addFoo(Foo *); + ... }; @@ -3161,8 +3162,8 @@ suitable exception handler:
     %exception {
    -    try { $action }
    -    catch (Swig::DirectorException &e) { SWIG_fail; }
    +  try { $action }
    +  catch (Swig::DirectorException &e) { SWIG_fail; }
     }
     
    @@ -3239,7 +3240,7 @@ references, such as
     class Foo {
     …
    -    virtual const int& bar();
    +  virtual const int& bar();
     …
     };
     
    @@ -3257,7 +3258,7 @@ types, wherever possible, for example
     class Foo {
     …
    -    virtual int bar();
    +  virtual int bar();
     …
     };
     
    @@ -3510,7 +3511,7 @@ def bar(*args): class Foo { public: - int bar(int x); + int bar(int x); }; @@ -3547,7 +3548,7 @@ proxy, just before the return statement. class Foo { public: - int bar(int x); + int bar(int x); }; @@ -3576,7 +3577,7 @@ SWIG version 1.3.28 you can use the directive forms class Foo { public: - int bar(int x); + int bar(int x); }; @@ -3605,8 +3606,8 @@ as it will then get attached to all the overloaded C++ methods. For example: class Foo { public: - int bar(int x); - int bar(); + int bar(int x); + int bar(); }; diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index cff4e7dc2..a43ff94b5 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1236,9 +1236,9 @@ creating a wrapper equivalent to the following:
     double wrap_dot_product(Vector *a, Vector *b) {
    -    Vector x = *a;
    -    Vector y = *b;
    -    return dot_product(x, y);
    +  Vector x = *a;
    +  Vector y = *b;
    +  return dot_product(x, y);
     }
     
    @@ -2368,10 +2368,10 @@ defined in the interface. For example:
     struct Vector *new_Vector() {
    -    return (Vector *) calloc(1, sizeof(struct Vector));
    +  return (Vector *) calloc(1, sizeof(struct Vector));
     }
     void delete_Vector(struct Vector *obj) {
    -    free(obj);
    +  free(obj);
     }
     
    @@ -2602,10 +2602,10 @@ like this:
     WORD Foo_w_get(Foo *f) {
    -    return f->w;
    +  return f->w;
     }
     void Foo_w_set(FOO *f, WORD value) {
    -    f->w = value;
    +  f->w = value;
     }
     
    @@ -2896,7 +2896,7 @@ instead of a method. To do this, you might write some code like this:
     // Add a new attribute to Vector
     %extend Vector {
    -    const double magnitude;
    +  const double magnitude;
     }
     // Now supply the implementation of the Vector_magnitude_get function
     %{
    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
    index 87fe30fa8..da4f54603 100644
    --- a/Doc/Manual/SWIGPlus.html
    +++ b/Doc/Manual/SWIGPlus.html
    @@ -4042,7 +4042,7 @@ namespace foo {
       typedef int Integer;
       class bar {
         public:
    -      ...
    +    ...
       };
     }
     
    diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
    index 31408b312..41cb78661 100644
    --- a/Doc/Manual/Tcl.html
    +++ b/Doc/Manual/Tcl.html
    @@ -958,7 +958,7 @@ Foo *BarToFoo(Bar *b) {
     }
     
     Foo *IncrFoo(Foo *f, int i) {
    -    return f+i;
    +  return f+i;
     }
     %}
     
    @@ -1054,7 +1054,7 @@ example, consider this:
     struct Bar {
    -    int  x[16];
    +  int  x[16];
     };
     
    @@ -1456,9 +1456,9 @@ Similarly, if you have a class like this,
     class Foo {
     public:
    -    Foo();
    -    Foo(const Foo &);
    -    ...
    +  Foo();
    +  Foo(const Foo &);
    +  ...
     };
     
    @@ -1693,11 +1693,11 @@ For example: %rename(Bar_spam) Bar::spam; namespace Foo { - int spam(); + int spam(); } namespace Bar { - int spam(); + int spam(); } @@ -1886,19 +1886,19 @@ then SWIG transforms it into a set of low-level procedural wrappers. For example
     Foo *new_Foo() {
    -    return new Foo();
    +  return new Foo();
     }
     void delete_Foo(Foo *f) {
    -    delete f;
    +  delete f;
     }
     int Foo_x_get(Foo *f) {
    -    return f->x;
    +  return f->x;
     }
     void Foo_x_set(Foo *f, int value) {
    -    f->x = value;
    +  f->x = value;
     }
     int Foo_spam(Foo *f, int arg1) {
    -    return f->spam(arg1);
    +  return f->spam(arg1);
     }
     
    @@ -1945,8 +1945,8 @@ ownership of the result. For example:
     class Foo {
     public:
    -    Foo();
    -    Foo bar();
    +  Foo();
    +  Foo bar();
     };
     
    @@ -1975,9 +1975,9 @@ they came from. Therefore, the ownership is set to zero. For example:
     class Foo {
     public:
    -    ...
    -    Foo *spam();
    -    ...
    +  ...
    +  Foo *spam();
    +  ...
     };
     
    @@ -2011,8 +2011,8 @@ or global variable. For example, consider this interface: %module example struct Foo { - int value; - Foo *next; + int value; + Foo *next; }; Foo *head = 0; @@ -2465,9 +2465,9 @@ you might define a typemap like this: %module example %typemap(in) int { - if (Tcl_GetIntFromObj(interp, $input, &$1) == TCL_ERROR) - return TCL_ERROR; - printf("Received an integer : %d\n", $1); + if (Tcl_GetIntFromObj(interp, $input, &$1) == TCL_ERROR) + return TCL_ERROR; + printf("Received an integer : %d\n", $1); } %inline %{ extern int fact(int n); @@ -2585,7 +2585,7 @@ like this:
     %typemap(out) int {
    -    Tcl_SetObjResult(interp, Tcl_NewIntObj($1));
    +  Tcl_SetObjResult(interp, Tcl_NewIntObj($1));
     }
     
    From 5779aa8d7966ae4ce983a822a0dc56014e3c295a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Jul 2017 17:22:40 +0100 Subject: [PATCH 0658/2031] More consistent formatting of examples in documentation --- Doc/Manual/Python.html | 8 ++++---- Doc/Manual/SWIG.html | 2 +- Doc/Manual/SWIGPlus.html | 12 ++++++------ Doc/Manual/Varargs.html | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index e294db86d..b43ca1949 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2565,9 +2565,9 @@ the function callback in the tp_hash slot for the builtin type for MyClass
     static PyHeapTypeObject SwigPyBuiltin__MyClass_type = {
    -    ...
    -    (hashfunc) myHashFunc,       /* tp_hash */
    -    ...
    +  ...
    +  (hashfunc) myHashFunc,       /* tp_hash */
    +  ...
     
    @@ -3087,7 +3087,7 @@ references. Here is an example:
     class Foo {
     public:
    -    ...
    +  ...
     };
     class FooContainer {
     public:
    diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
    index a43ff94b5..c05ed456c 100644
    --- a/Doc/Manual/SWIG.html
    +++ b/Doc/Manual/SWIG.html
    @@ -389,7 +389,7 @@ For example
     /* bar not wrapped unless foo has been defined and 
        the declaration of bar within foo has already been parsed */
     int foo::bar(int) {
    -    ... whatever ...
    +  ... whatever ...
     }
     
    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index da4f54603..d0a8f2c9c 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -706,7 +706,7 @@ class Foo { protected: Foo(); // Not wrapped. public: - ... + ... }; @@ -1278,7 +1278,7 @@ equivalent to one generated for the following declaration
     class Foo {
     public:
    -    ...
    +  ...
     };
     
     void blah(Foo *f);    
    @@ -4381,9 +4381,9 @@ class Error { };
     
     class Foo {
     public:
    -    ...
    -    void blah() throw(Error);
    -    ...
    +  ...
    +  void blah() throw(Error);
    +  ...
     };
     
    @@ -4547,7 +4547,7 @@ class Foo_Impl { public: int x; virtual void bar(); - ... + ... }; // Smart-pointer wrapper diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index fb58ee39a..eba816382 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -423,8 +423,8 @@ Variable length arguments may be used in typemap specifications. For example:
     %typemap(in) (...) {
    -    // Get variable length arguments (somehow)
    -    ...
    +  // Get variable length arguments (somehow)
    +  ...
     }
     
     %typemap(in) (const char *fmt, ...) {
    
    From 97ae9d66bc7b8cd1fe78680c1253a222c5864c55 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 8 Aug 2017 19:40:39 +0100
    Subject: [PATCH 0659/2031] Template documentation tweaks
    
    Add subsections to the template documentation
    Rewrite some of the template introduction
    ---
     Doc/Manual/Contents.html |   9 ++
     Doc/Manual/SWIGPlus.html | 227 +++++++++++++++++++++++----------------
     2 files changed, 146 insertions(+), 90 deletions(-)
    
    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
    index 56afca857..67f0c3965 100644
    --- a/Doc/Manual/Contents.html
    +++ b/Doc/Manual/Contents.html
    @@ -246,6 +246,15 @@
     
  • Wrapping overloaded operators
  • Class extension
  • Templates +
  • Namespaces
    • The nspace feature for namespaces diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index d0a8f2c9c..7cc0d5387 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -49,6 +49,15 @@
    • Wrapping overloaded operators
    • Class extension
    • Templates +
    • Namespaces
      • The nspace feature for namespaces @@ -2936,23 +2945,24 @@ as vector<int>. The wrapper for foo() will accept either variant.

        +

        6.18.1 The %template directive

        + +

        -Starting with SWIG-1.3.7, simple C++ template declarations can also be -wrapped. SWIG-1.3.12 greatly expands upon the earlier implementation. Before discussing this any further, there are a few things -you need to know about template wrapping. First, a bare C++ template +There are a couple of important points about template wrapping. +First, a bare C++ template does not define any sort of runnable object-code for which SWIG can normally create a wrapper. Therefore, in order to wrap a template, you need to give SWIG information about a particular template -instantiation (e.g., vector<int>, +instantiation (e.g., vector<int>, array<double>, etc.). Second, an instantiation name such as vector<int> is generally not a valid identifier name in most target languages. Thus, you will need to give the -template instantiation a more suitable name such as intvector -when creating a wrapper. +template instantiation a more suitable name such as intvector.

        -To illustrate, consider the following template definition: +To illustrate, consider the following class template definition:

        @@ -2985,14 +2995,26 @@ public:
         

        -By itself, this template declaration is useless--SWIG simply ignores it -because it doesn't know how to generate any code until unless a definition of +By itself, this class template is useless--SWIG simply ignores it +because it doesn't know how to generate any code unless a definition of T is provided. +The %template directive is required to instantiate the template for use in a target language. +The directive requires an identifier name for use in the target language plus the template for instantiation. +The example below instantiates List<int> for use as a class named intList:

        +
        +
        +%template(intList) List<int>;
        +
        +
        +

        -One way to create wrappers for a specific template instantiation is to simply -provide an expanded version of the class directly like this: +The instantiation expands the template code as a C++ compiler would do and then makes it available +under the given identifier name. +Essentially it is the same as wrapping the following concept code where +the class template definition has T expanded to int +(note that this is not entirely valid syntax):

        @@ -3014,28 +3036,6 @@ public:
        -

        -The %rename directive is needed to give the template class an appropriate identifier -name in the target language (most languages would not recognize C++ template syntax as a valid -class name). The rest of the code is the same as what would appear in a normal -class definition. -

        - -

        -Since manual expansion of templates gets old in a hurry, the %template directive can -be used to create instantiations of a template class. Semantically, %template is -simply a shortcut---it expands template code in exactly the same way as shown above. Here -are some examples: -

        - -
        -
        -/* Instantiate a few different versions of the template */
        -%template(intList) List<int>;
        -%template(doubleList) List<double>;
        -
        -
        -

        The argument to %template() is the name of the instantiation in the target language. The name you choose should not conflict with @@ -3053,7 +3053,67 @@ typedef List<int> intList; // OK

  • -SWIG can also generate wrappers for function templates using a similar technique. +The %template directive +must always appear after the definition of the template to be expanded, so the following will work: +

    + +
    +
    +template<class T> class List { ... };
    +%template(intList) List<int>;
    +
    +
    + +

    +but if %template is used before the template definition, such as: +

    + +
    +
    +%template(intList) List<int>;
    +template<class T> class List { ... };
    +
    +
    + +

    +SWIG will generate an error: +

    + +
    +
    +example.i:3: Error: Template 'List' undefined.
    +
    +
    + +

    +Since the type system knows how to handle typedef, it is +generally not necessary to instantiate different versions of a template +for typenames that are equivalent. For instance, consider this code: +

    + +
    +
    +%template(intList) List<int>;
    +typedef int Integer;
    +...
    +void foo(List<Integer> *x);
    +
    +
    + +

    +In this case, List<Integer> is exactly the same type as +List<int>. Any use of List<Integer> is mapped back to the +instantiation of List<int> created earlier. Therefore, it is +not necessary to instantiate a new class for the type Integer (doing so is +redundant and will simply result in code bloat). +

    + +

    6.18.2 Function templates

    + + +

    +SWIG can also generate wrappers for function templates using a similar technique +to that shown above for class templates. For example:

    @@ -3073,6 +3133,28 @@ In this case, maxint and maxdouble become unique names for spe instantiations of the function.

    +

    +SWIG even supports overloaded templated functions. As usual the %template directive +is used to wrap templated functions. For example: +

    + +
    +
    +template<class T> void foo(T x) { };
    +template<class T> void foo(T x, T y) { };
    +
    +%template(foo) foo<int>;
    +
    +
    + +

    +This will generate two overloaded wrapper methods, the first will take a single integer as an argument +and the second will take two integer arguments. +

    + +

    6.18.3 Default template arguments

    + +

    The number of arguments supplied to %template should match that in the original template definition. Template default arguments are supported. For example: @@ -3110,28 +3192,8 @@ instantiation only once in order to reduce the potential for code bloat.

    -

    -Since the type system knows how to handle typedef, it is -generally not necessary to instantiate different versions of a template -for typenames that are equivalent. For instance, consider this code: -

    +

    6.18.4 Template base classes

    -
    -
    -%template(intList) vector<int>;
    -typedef int Integer;
    -...
    -void foo(vector<Integer> *x);
    -
    -
    - -

    -In this case, vector<Integer> is exactly the same type as -vector<int>. Any use of Vector<Integer> is mapped back to the -instantiation of vector<int> created earlier. Therefore, it is -not necessary to instantiate a new class for the type Integer (doing so is -redundant and will simply result in code bloat). -

    When a template is instantiated using %template, information @@ -3158,13 +3220,13 @@ nothing is known about List<int>, you will get a warning message

    -example.h:42: Warning 401. Nothing known about class 'List<int >'. Ignored. 
    -example.h:42: Warning 401. Maybe you forgot to instantiate 'List<int >' using %template. 
    +example.h:42: Warning 401. Nothing known about class 'List< int >'. Ignored. 
    +example.h:42: Warning 401. Maybe you forgot to instantiate 'List< int >' using %template. 
     

    -If a template class inherits from another template class, you need to +If a class template inherits from another class template, you need to make sure that base classes are instantiated before derived classes. For example:

    @@ -3235,6 +3297,9 @@ TEMPLATE_WRAP(PairStringInt, std::pair<string, int>) Note the use of a vararg macro for the type T. If this wasn't used, the comma in the templated type in the last example would not be possible.

    +

    6.18.5 Template specialization

    + +

    The SWIG template mechanism does support specialization. For instance, if you define a class like this, @@ -3281,7 +3346,7 @@ private: public: List(int max); ~List(); - void append(int obj); + void append(T obj); int length(); T get(int n); }; @@ -3322,10 +3387,13 @@ SWIG implements template argument deduction so that the following partial specia +

    6.18.6 Member templates

    + +

    -Member function templates are supported. The underlying principle is the same +Member templates are supported. The underlying principle is the same as for normal templates--SWIG can't create a wrapper unless you provide -more information about types. For example, a class with a member template might +more information about types. For example, a class with a member function template might look like this:

    @@ -3399,11 +3467,6 @@ methods to the Foo class.

    -

    -Note: because of the way that templates are handled, the %template directive -must always appear after the definition of the template to be expanded. -

    -

    Now, if your target language supports overloading, you can even try

    @@ -3424,7 +3487,7 @@ depending on the argument type.

    When used with members, the %template directive may be placed in another -template class. Here is a slightly perverse example: +class template. Here is a slightly perverse example:

    @@ -3475,7 +3538,7 @@ template<class T1, class T2> struct pair {

    This declaration is perfectly acceptable to SWIG, but the constructor template will be ignored unless you explicitly expand it. To do that, you could expand a few versions of the constructor -in the template class itself. For example: +in the class template itself. For example:

    @@ -3536,6 +3599,9 @@ constructor, that will dispatch the proper call depending on the argument type.

    +

    6.18.7 More on templates

    + +

    If all of this isn't quite enough and you really want to make someone's head explode, SWIG directives such as @@ -3568,7 +3634,7 @@ instantiation.

    -It is also possible to separate these declarations from the template class. For example: +It is also possible to separate these declarations from the class template. For example:

    @@ -3616,25 +3682,6 @@ additional methods to a specific instantiation. For example:
    -

    -SWIG even supports overloaded templated functions. As usual the %template directive -is used to wrap templated functions. For example: -

    - -
    -
    -template<class T> void foo(T x) { };
    -template<class T> void foo(T x, T y) { };
    -
    -%template(foo) foo<int>;
    -
    -
    - -

    -This will generate two overloaded wrapper methods, the first will take a single integer as an argument -and the second will take two integer arguments. -

    -

    It is even possible to extend a class via %extend with template methods, for example:

    @@ -3694,7 +3741,7 @@ For example:
     template <class T> class OuterTemplateClass {};
     
    -// The nested class OuterClass::InnerClass inherits from the template class
    +// The nested class OuterClass::InnerClass inherits from the class template
     // OuterTemplateClass<OuterClass::InnerStruct> and thus the template needs
     // to be expanded with %template before the OuterClass declaration.
     %template(OuterTemplateClass_OuterClass__InnerStruct)
    @@ -4524,7 +4571,7 @@ for member pointers.
     

    In some C++ programs, objects are often encapsulated by smart-pointers or proxy classes. This is sometimes done to implement automatic memory management (reference counting) or -persistence. Typically a smart-pointer is defined by a template class where +persistence. Typically a smart-pointer is defined by a class template where the -> operator has been overloaded. This class is then wrapped around some other class. For example:

    From 959e6272082e416303d80d7326430d1fd0b4c432 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 9 Aug 2017 00:06:24 +0100 Subject: [PATCH 0660/2031] %template scope enforcement and class definition fixes The scoping rules around %template have been specified and enforced. The %template directive for a class template is the equivalent to an explicit instantiation of a C++ class template. The scope for a valid %template instantiation is now the same as the scope required for a valid explicit instantiation of a C++ template. A definition of the template for the explicit instantiation must be in scope where the instantiation is declared and must not be enclosed within a different namespace. For example, a few %template and explicit instantiations of std::vector are shown below: // valid namespace std { %template(vin) vector; template class vector; } // valid using namespace std; %template(vin) vector; template class vector; // valid using std::vector; %template(vin) vector; template class vector; // ill-formed namespace unrelated { using std::vector; %template(vin) vector; template class vector; } // ill-formed namespace unrelated { using namespace std; %template(vin) vector; template class vector; } // ill-formed namespace unrelated { namespace std { %template(vin) vector; template class vector; } } // ill-formed namespace unrelated { %template(vin) std::vector; template class std::vector; } When the scope is incorrect, an error now occurs such as: cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'. Previously SWIG accepted the ill-formed examples above but this led to numerous subtle template scope problems especially in the presence of using declarations and using directives as well as with %feature and %typemap. Actually, a valid instantiation is one which conforms to the C++03 standard as C++11 made a change to disallow using declarations and using directives to find a template. // valid C++03, ill-formed C++11 using std::vector; template class vector; Similar fixes for defining classes using forward class references have also been put in place. For example: namespace Space1 { struct A; } namespace Space2 { struct Space1::A { void x(); } } will now error out with: cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'. --- Doc/Manual/Contents.html | 1 + Doc/Manual/SWIGPlus.html | 108 ++++++++++- Examples/test-suite/class_scope_namespace.i | 153 ++++++++++++++++ Examples/test-suite/common.mk | 1 + .../test-suite/errors/cpp_class_definition.i | 26 +++ .../errors/cpp_class_definition.stderr | 1 + .../errors/cpp_namespace_template_bad.i | 40 +++++ .../errors/cpp_namespace_template_bad.stderr | 9 + .../errors/cpp_nested_template.stderr | 2 + .../test-suite/errors/cpp_template_scope.i | 57 ++++++ .../errors/cpp_template_scope.stderr | 11 ++ .../java/class_scope_namespace_runme.java | 59 ++++++ .../java/namespace_template_runme.java | 32 ++++ Examples/test-suite/namespace_template.i | 40 ++--- .../test-suite/smart_pointer_namespace2.i | 13 +- .../test-suite/template_nested_typemaps.i | 33 ++-- .../template_partial_specialization.i | 4 +- .../template_partial_specialization_typedef.i | 4 +- Source/CParse/parser.y | 170 ++++++++++++------ Source/Swig/misc.c | 38 +++- Source/Swig/swig.h | 1 + 21 files changed, 689 insertions(+), 114 deletions(-) create mode 100644 Examples/test-suite/class_scope_namespace.i create mode 100644 Examples/test-suite/errors/cpp_class_definition.i create mode 100644 Examples/test-suite/errors/cpp_class_definition.stderr create mode 100644 Examples/test-suite/errors/cpp_namespace_template_bad.i create mode 100644 Examples/test-suite/errors/cpp_namespace_template_bad.stderr create mode 100644 Examples/test-suite/errors/cpp_template_scope.i create mode 100644 Examples/test-suite/errors/cpp_template_scope.stderr create mode 100644 Examples/test-suite/java/class_scope_namespace_runme.java create mode 100644 Examples/test-suite/java/namespace_template_runme.java diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 67f0c3965..3d9f6fd3b 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -253,6 +253,7 @@
  • Template base classes
  • Template specialization
  • Member templates +
  • Scoping and templates
  • More on templates
  • Namespaces diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 7cc0d5387..13c81588d 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -56,6 +56,7 @@
  • Template base classes
  • Template specialization
  • Member templates +
  • Scoping and templates
  • More on templates
  • Namespaces @@ -3599,7 +3600,108 @@ constructor, that will dispatch the proper call depending on the argument type.

    -

    6.18.7 More on templates

    +

    6.18.7 Scoping and templates

    + + +

    +The %template directive for a class template is the equivalent to an explicit instantiation +of a C++ class template. The scope for a valid %template instantiation is the same +as the scope required for a valid explicit instantiation of a C++ template. +A definition of the template for the explicit instantiation must be in scope +where the instantiation is declared and must not be enclosed within a different namespace. +

    + +

    +For example, a few %template instantiations and C++ explicit instantiations are shown below: +

    + +
    +
    +namespace N {
    +  template<typename T> class C {};
    +}
    +
    +// valid
    +%template(cin) N::C<int>;
    +template class N::C<int>;
    +
    +// valid
    +namespace N {
    +  %template(cin) C<int>;
    +  template class C<int>;
    +}
    +
    +// valid
    +using namespace N;
    +%template(cin) C<int>;
    +template class C<int>;
    +
    +// valid
    +using N::C;
    +%template(cin) C<int>;
    +template class C<int>;
    +
    +// ill-formed
    +namespace unrelated {
    +  using N::C;
    +  %template(cin) C<int>;
    +  template class C<int>;
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  using namespace N;
    +  %template(cin) C<int>;
    +  template class C<int>;
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  namespace N {
    +    %template(cin) C<int>;
    +    template class C<int>;
    +  }
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  %template(cin) N::C<int>;
    +  template class N::C<int>;
    +}
    +
    +
    + +

    +When the scope is incorrect, such as for the ill-formed examples above, an error occurs: +

    + +
    +
    +cpp_template_scope.i:34: Error: 'C' resolves to 'N::C' and was incorrectly instantiated
    +in scope 'unrelated' instead of within scope 'N'.
    +
    +
    + +

    +A note for the C++ standard geeks out there; a valid instantiation is one which conforms to +the C++03 standard as C++11 made a change to disallow using declarations and using directives to find a template. +

    + +
    +
    +// valid C++03, ill-formed C++11
    +using N::C;
    +template class C<int>;
    +
    +
    + +

    +Compatibility Note: Versions prior to SWIG-4.0.0 did not error out with incorrectly scoped +%template declarations, but this led to numerous subtle template scope problems. +

    + + +

    6.18.8 More on templates

    @@ -4348,9 +4450,9 @@ In the example below, the generic template type is used to rename to bbb

    -%rename(bbb) Space::ABC::aaa(T t);                  // will match but with lower precedence than ccc
    +%rename(bbb) Space::ABC::aaa(T t);                     // will match but with lower precedence than ccc
     %rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence
    -                                                             // than bbb
    +                                                       // than bbb
     
     namespace Space {
       class XYZ {};
    diff --git a/Examples/test-suite/class_scope_namespace.i b/Examples/test-suite/class_scope_namespace.i
    new file mode 100644
    index 000000000..08a9f01dc
    --- /dev/null
    +++ b/Examples/test-suite/class_scope_namespace.i
    @@ -0,0 +1,153 @@
    +// Test a mix of forward class declarations, class definitions, using declarations and using directives.
    +
    +%module class_scope_namespace
    +
    +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) H::HH;
    +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Space8::I::II;
    +
    +%inline %{
    +struct A;
    +namespace Space1 {
    +  namespace SubSpace1 {
    +    struct A {
    +      void aa(Space1::SubSpace1::A, SubSpace1::A, A) {}
    +    };
    +    void aaa(Space1::SubSpace1::A, SubSpace1::A, A) {}
    +  }
    +}
    +
    +namespace Space2 {
    +  struct B;
    +}
    +using Space2::B;
    +struct B {
    +  void bb(Space2::B, B) {}
    +};
    +void bbb(Space2::B, B) {}
    +
    +namespace Space3 {
    +  namespace SubSpace3 {
    +    struct C;
    +    struct D;
    +  }
    +}
    +struct C;
    +struct D;
    +namespace Space3 {
    +  struct C;
    +  struct SubSpace3::C {
    +    void cc(Space3::SubSpace3::C, SubSpace3::C) {}
    +  };
    +  using SubSpace3::D;
    +  struct SubSpace3::D {
    +    void dd(Space3::SubSpace3::D, SubSpace3::D, D) {}
    +  };
    +  void ccc(Space3::SubSpace3::C, SubSpace3::C) {}
    +  void ddd(Space3::SubSpace3::D, SubSpace3::D, D) {}
    +}
    +
    +namespace Space4 {
    +  namespace SubSpace4 {
    +    struct E;
    +  }
    +}
    +using namespace Space4;
    +using SubSpace4::E;
    +// Was added to incorrect namespace in swig-3.0.12
    +struct SubSpace4::E {
    +  void ee(Space4::SubSpace4::E, SubSpace4::E, E) {}
    +};
    +void eee(Space4::SubSpace4::E, SubSpace4::E, E) {}
    +
    +namespace Space5 {
    +  namespace SubSpace5 {
    +    namespace SubSubSpace5 {
    +      struct F;
    +    }
    +  }
    +}
    +namespace Space5 {
    +  using namespace SubSpace5;
    +  using SubSubSpace5::F;
    +  // Was added to incorrect namespace in swig-3.0.12
    +  struct SubSubSpace5::F {
    +    void ff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {}
    +  };
    +// needs fixing
    +  void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, /*SubSubSpace5::F,*/ F) {}
    +}
    +
    +namespace Space6 {
    +  struct G;
    +  namespace SubSpace6 {
    +    struct G;
    +  }
    +}
    +namespace Space6 {
    +  struct SubSpace6::G {
    +    void gg(Space6::SubSpace6::G, SubSpace6::G) {}
    +  };
    +  void ggg(Space6::SubSpace6::G, SubSpace6::G) {}
    +}
    +
    +struct HH;
    +struct H {
    +  struct HH {
    +    void hh(H::HH) {}
    +  };
    +};
    +void hhh(H::HH) {}
    +
    +namespace Space8 {
    +  struct II;
    +  struct I {
    +    struct II {
    +      void ii(Space8::I::II, I::II) {}
    +    };
    +  };
    +  void iii(Space8::I::II, I::II) {}
    +}
    +
    +struct J;
    +namespace Space9 {
    +  namespace SubSpace9 {
    +    struct J {
    +      void jj(Space9::SubSpace9::J, SubSpace9::J, J) {}
    +    };
    +    void jjj(Space9::SubSpace9::J, SubSpace9::J, J) {}
    +  }
    +}
    +
    +namespace Space10 {
    +  struct K;
    +}
    +namespace Space10 {
    +  namespace SubSpace10 {
    +    struct K {
    +      void kk(Space10::SubSpace10::K, SubSpace10::K, K) {}
    +    };
    +    void kkk(Space10::SubSpace10::K, SubSpace10::K, K) {}
    +  }
    +}
    +
    +namespace OtherSpace {
    +  struct L;
    +  struct M;
    +}
    +using OtherSpace::L;
    +namespace Space11 {
    +  using OtherSpace::M;
    +  namespace SubSpace11 {
    +    struct L {
    +      void ll(Space11::SubSpace11::L, SubSpace11::L, L) {}
    +    };
    +    void lll(Space11::SubSpace11::L, SubSpace11::L, L) {}
    +    struct M {
    +      void mm(Space11::SubSpace11::M, SubSpace11::M, M) {}
    +    };
    +    void mmm(Space11::SubSpace11::M, SubSpace11::M, M) {}
    +  }
    +}
    +
    +%}
    +
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index ab341e7a1..0c896825f 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -136,6 +136,7 @@ CPP_TEST_CASES += \
     	char_binary \
     	char_strings \
     	chartest \
    +	class_scope_namespace \
     	class_forward \
     	class_ignore \
     	class_scope_weird \
    diff --git a/Examples/test-suite/errors/cpp_class_definition.i b/Examples/test-suite/errors/cpp_class_definition.i
    new file mode 100644
    index 000000000..8381e75cc
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_class_definition.i
    @@ -0,0 +1,26 @@
    +%module xxx
    +
    +// This should error but doesn't
    +#if 0
    +namespace OtherSpace {
    +  struct L;
    +}
    +namespace Space11 {
    +  namespace SubSpace11 {
    +    using OtherSpace::L;
    +    struct L {
    +      void ll();
    +    };
    +  }
    +}
    +#endif
    +
    +namespace Space1 {
    +  struct A;
    +}
    +namespace Space2 {
    +  struct Space1::A {
    +    void x();
    +  };
    +}
    +
    diff --git a/Examples/test-suite/errors/cpp_class_definition.stderr b/Examples/test-suite/errors/cpp_class_definition.stderr
    new file mode 100644
    index 000000000..2c4102842
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_class_definition.stderr
    @@ -0,0 +1 @@
    +cpp_class_definition.i:22: Error: 'Space1::A' resolves to 'Space1::A' and was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
    diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.i b/Examples/test-suite/errors/cpp_namespace_template_bad.i
    new file mode 100644
    index 000000000..5c42d6dcb
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_namespace_template_bad.i
    @@ -0,0 +1,40 @@
    +%module namespace_template
    +
    +namespace test {
    +  template T max(T a, T b) { return (a > b) ? a : b; }
    +  template class vector { 
    +  public:
    +    vector() { }
    +    ~vector() { }
    +  }; 
    +}
    +
    +namespace test2 {
    +  using namespace test;
    +  %template(maxshort) max;
    +  %template(vectorshort) vector;
    +}
    +
    +namespace test3 {
    +  using test::max;
    +  using test::vector;
    +  %template(maxlong) max;
    +  %template(vectorlong) vector;
    +}
    +
    +namespace test4 {
    +  using namespace test;
    +  typedef int Integer;
    +}
    +
    +namespace test4 {
    +  %template(maxInteger) max;
    +  %template(vectorInteger) vector;
    +}
    +
    +using namespace test;
    +namespace test5 {
    +  %template(maxdouble) max;
    +  %template(vectordouble) vector;
    +}
    +
    diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.stderr b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
    new file mode 100644
    index 000000000..5965d529c
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_namespace_template_bad.stderr
    @@ -0,0 +1,9 @@
    +cpp_namespace_template_bad.i:14: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:15: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test2' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:21: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:22: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test3' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:31: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:32: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test4' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:37: Error: 'max' resolves to 'test::max' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
    +cpp_namespace_template_bad.i:37: Error: Template 'max' undefined.
    +cpp_namespace_template_bad.i:38: Error: 'vector' resolves to 'test::vector' and was incorrectly instantiated in scope 'test5' instead of within scope 'test'.
    diff --git a/Examples/test-suite/errors/cpp_nested_template.stderr b/Examples/test-suite/errors/cpp_nested_template.stderr
    index 9e46cff74..363a260f6 100644
    --- a/Examples/test-suite/errors/cpp_nested_template.stderr
    +++ b/Examples/test-suite/errors/cpp_nested_template.stderr
    @@ -1,2 +1,4 @@
    +cpp_nested_template.i:9: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'A' instead of within scope ''.
     cpp_nested_template.i:9: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
    +cpp_nested_template.i:18: Error: 'Temply' resolves to '::Temply' and was incorrectly instantiated in scope 'B' instead of within scope ''.
     cpp_nested_template.i:18: Warning 324: Named nested template instantiations not supported. Processing as if no name was given to %template().
    diff --git a/Examples/test-suite/errors/cpp_template_scope.i b/Examples/test-suite/errors/cpp_template_scope.i
    new file mode 100644
    index 000000000..ec0f0a577
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_template_scope.i
    @@ -0,0 +1,57 @@
    +%module xxx
    +
    +namespace std {
    +  template class vector {};
    +}
    +
    +struct S1 {};
    +struct S2 {};
    +struct S3 {};
    +struct S4 {};
    +struct S5 {};
    +struct S6 {};
    +struct S7 {};
    +
    +// valid
    +namespace std {
    +  %template(vi1) vector;
    +  template class vector;
    +}
    +
    +// valid
    +using namespace std;
    +%template(vi2) vector;
    +template class vector;
    +
    +// valid
    +using std::vector;
    +%template(vi3) vector;
    +template class vector;
    +
    +// ill-formed
    +namespace unrelated {
    +  using std::vector;
    +  %template(vi4) vector;
    +  template class vector;
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  using namespace std;
    +  %template(vi5) vector;
    +  template class vector;
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  namespace std {
    +    %template(vi6) vector;
    +    template class vector;
    +  }
    +}
    +
    +// ill-formed
    +namespace unrelated {
    +  %template(vi7) std::vector;
    +  template class std::vector;
    +}
    diff --git a/Examples/test-suite/errors/cpp_template_scope.stderr b/Examples/test-suite/errors/cpp_template_scope.stderr
    new file mode 100644
    index 000000000..e47630268
    --- /dev/null
    +++ b/Examples/test-suite/errors/cpp_template_scope.stderr
    @@ -0,0 +1,11 @@
    +cpp_template_scope.i:18: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:24: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:29: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
    +cpp_template_scope.i:35: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:41: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
    +cpp_template_scope.i:42: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:48: Error: 'vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated::std' instead of within scope 'std'.
    +cpp_template_scope.i:49: Warning 320: Explicit template instantiation ignored.
    +cpp_template_scope.i:55: Error: 'std::vector' resolves to 'std::vector' and was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
    +cpp_template_scope.i:56: Warning 320: Explicit template instantiation ignored.
    diff --git a/Examples/test-suite/java/class_scope_namespace_runme.java b/Examples/test-suite/java/class_scope_namespace_runme.java
    new file mode 100644
    index 000000000..e80779413
    --- /dev/null
    +++ b/Examples/test-suite/java/class_scope_namespace_runme.java
    @@ -0,0 +1,59 @@
    +
    +import class_scope_namespace.*;
    +
    +public class class_scope_namespace_runme {
    +
    +  static {
    +    try {
    +      System.loadLibrary("class_scope_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[]) 
    +  {
    +    A a = new A();
    +    B b = new B();
    +    C c = new C();
    +    D d = new D();
    +    E e = new E();
    +    F f = new F();
    +    G g = new G();
    +    H.HH h = new H.HH();
    +    I.II i = new I.II();
    +    J j = new J();
    +    K k = new K();
    +    L l = new L();
    +    M m = new M();
    +
    +    a.aa(a, a, a);
    +    b.bb(b, b);
    +    c.cc(c, c);
    +    d.dd(d, d, d);
    +    e.ee(e, e, e);
    +    f.ff(f, f, f, f);
    +    g.gg(g, g);
    +    h.hh(h);
    +    i.ii(i, i);
    +    j.jj(j, j, j);
    +    k.kk(k, k, k);
    +    l.ll(l, l, l);
    +    m.mm(m, m, m);
    +
    +    class_scope_namespace.aaa(a, a, a);
    +    class_scope_namespace.bbb(b, b);
    +    class_scope_namespace.ccc(c, c);
    +    class_scope_namespace.ddd(d, d, d);
    +    class_scope_namespace.eee(e, e, e);
    +    class_scope_namespace.fff(f, f, f);
    +    class_scope_namespace.ggg(g, g);
    +    class_scope_namespace.hhh(h);
    +    class_scope_namespace.iii(i, i);
    +    class_scope_namespace.jjj(j, j, j);
    +    class_scope_namespace.kkk(k, k, k);
    +    class_scope_namespace.lll(l, l, l);
    +    class_scope_namespace.mmm(m, m, m);
    +  }
    +}
    diff --git a/Examples/test-suite/java/namespace_template_runme.java b/Examples/test-suite/java/namespace_template_runme.java
    new file mode 100644
    index 000000000..c0c7ba135
    --- /dev/null
    +++ b/Examples/test-suite/java/namespace_template_runme.java
    @@ -0,0 +1,32 @@
    +
    +import namespace_template.*;
    +
    +public class namespace_template_runme {
    +
    +  static {
    +    try {
    +      System.loadLibrary("namespace_template");
    +    } 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[]) {
    +    vectorchar vc = new vectorchar();
    +    vectorshort vs = new vectorshort();
    +    vectorint vi = new vectorint();
    +    vectorlong vl = new vectorlong();
    +
    +    vc.blah((char)10);
    +    vs.blah((short)10);
    +    vi.blah(10);
    +    vl.blah(10);
    +
    +    vc.vectoruse(vc, vc);
    +    vs.vectoruse(vs, vs);
    +    vi.vectoruse(vi, vi);
    +    vl.vectoruse(vl, vl);
    +  }
    +}
    +
    diff --git a/Examples/test-suite/namespace_template.i b/Examples/test-suite/namespace_template.i
    index a36abb19b..8a4b6dca9 100644
    --- a/Examples/test-suite/namespace_template.i
    +++ b/Examples/test-suite/namespace_template.i
    @@ -2,10 +2,10 @@
     
     %module namespace_template
     
    -%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector;            /* Ruby, wrong class name */
    -%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test2::vector;   /* Ruby, wrong class name */
    -%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test3::vector;    /* Ruby, wrong class name */
    -%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
    +%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector;        /* Ruby, wrong class name */
    +%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector;      /* Ruby, wrong class name */
    +%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector;       /* Ruby, wrong class name */
    +%warnfilter(SWIGWARN_RUBY_WRONG_NAME) test::vector; /* Ruby, wrong class name */
     
     %{
     #ifdef max
    @@ -23,20 +23,9 @@ namespace test {
                char * blah(T x) {
                   return (char *) "vector::blah";
                }
    +           void vectoruse(vector a, test::vector b) {}
        }; 
     }
    -
    -namespace test2 {
    -   using namespace test;
    -}
    -
    -namespace test3 {
    -   using test::max;
    -   using test::vector;
    -}
    -
    -using namespace test2;
    -namespace T4 = test;
     %}
     
     namespace test {
    @@ -48,6 +37,7 @@ namespace test {
                char * blah(T x) {
                   return (char *) "vector::blah";
                }
    +           void vectoruse(vector a, test::vector b) {}
        }; 
     }
     
    @@ -55,30 +45,26 @@ using namespace test;
     %template(maxint) max;
     %template(vectorint) vector;
     
    -namespace test2 {
    -   using namespace test;
    +namespace test {
        %template(maxshort) max;
        %template(vectorshort) vector;
     }
     
    -namespace test3 {
    -   using test::max;
    -   using test::vector;
    +namespace test {
        %template(maxlong) max;
        %template(vectorlong) vector;
     }
     
     %inline %{
     
    -namespace test4 {
    -   using namespace test;
    -   typedef int Integer;
    +namespace test {
    +   typedef char Char;
     }
     
     %}
     
    -namespace test4 {
    -   %template(maxInteger) max;
    -   %template(vectorInteger) vector;
    +namespace test {
    +   %template(maxchar) max;
    +   %template(vectorchar) vector;
     }
     
    diff --git a/Examples/test-suite/smart_pointer_namespace2.i b/Examples/test-suite/smart_pointer_namespace2.i
    index 882799862..e78364c25 100644
    --- a/Examples/test-suite/smart_pointer_namespace2.i
    +++ b/Examples/test-suite/smart_pointer_namespace2.i
    @@ -49,11 +49,6 @@ namespace one
         };
     }
     
    -%define PTR_DEF(o)
    -typedef one::Ptr o ## _ptr;
    -%template(o ## _ptr) one::Ptr;
    -%enddef
    -
     namespace one
     {
         class Obj1
    @@ -63,7 +58,8 @@ namespace one
             void donothing() {}
         };
     
    -    PTR_DEF(Obj1)
    +    typedef one::Ptr Obj1_ptr;
    +    %template(Obj1_ptr) one::Ptr;
     }
     
     namespace two
    @@ -75,6 +71,9 @@ namespace two
             void donothing() {}
         };
     
    -    PTR_DEF(Obj2)
    +    typedef one::Ptr Obj2_ptr;
     }
     
    +using two::Obj2;
    +%template(Obj2_ptr) one::Ptr;
    +
    diff --git a/Examples/test-suite/template_nested_typemaps.i b/Examples/test-suite/template_nested_typemaps.i
    index 54f5bc503..577a88e14 100644
    --- a/Examples/test-suite/template_nested_typemaps.i
    +++ b/Examples/test-suite/template_nested_typemaps.i
    @@ -1,25 +1,30 @@
    -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE
    -
     %module template_nested_typemaps
     
    -// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
    +#pragma SWIG nowarn=SWIGWARN_PARSE_NAMED_NESTED_CLASS
     
    -template  struct Typemap {
    -  %typemap(in) T {
    -    $1 = -99;
    -  }
    -};
    -template <> struct Typemap { // Note explicit specialization
    -  %typemap(in) short {
    -    $1 = -77;
    -  }
    -};
    +// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods
    +// Only for languages that support nested classes
     
     %inline %{
     int globalInt1(int s) { return s; }
     short globalShort1(short s) { return s; }
     
     template  struct Breeze {
    +  template  struct Typemap {
    +#ifdef SWIG
    +    %typemap(in) TMT {
    +      $1 = -99;
    +    }
    +#endif
    +  };
    +  template  struct TypemapShort {
    +#ifdef SWIG
    +    %typemap(in) short {
    +      $1 = -77;
    +    }
    +#endif
    +  };
    +
       int methodInt1(int s) { return s; }
     #if defined(SWIG)
       %template() Typemap;
    @@ -29,7 +34,7 @@ template  struct Breeze {
     
       short methodShort1(short s) { return s; }
     #if defined(SWIG)
    -  %template(TypemapShort) Typemap; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE
    +  %template() TypemapShort;
     #endif
       short methodShort2(short s) { return s; } // should pick up the typemap within Typemap
     };
    diff --git a/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i
    index 8781fbbda..a7afd3000 100644
    --- a/Examples/test-suite/template_partial_specialization.i
    +++ b/Examples/test-suite/template_partial_specialization.i
    @@ -32,7 +32,7 @@ namespace One {
     %template(H) One::OneParm;
     
     // %template scope explicit specializations
    -namespace ONE {
    +namespace One {
       %template(I) One::OneParm;
       %template(J) ::One::OneParm;
     }
    @@ -42,7 +42,7 @@ namespace One {
     }
     
     // %template scope partial specializations
    -namespace ONE {
    +namespace One {
       %template(BB) One::OneParm;
       %template(BBB) ::One::OneParm;
     }
    diff --git a/Examples/test-suite/template_partial_specialization_typedef.i b/Examples/test-suite/template_partial_specialization_typedef.i
    index 6fdbf99aa..9c00efc98 100644
    --- a/Examples/test-suite/template_partial_specialization_typedef.i
    +++ b/Examples/test-suite/template_partial_specialization_typedef.i
    @@ -59,7 +59,7 @@ namespace One {
     %template(H) One::OneParm;
     
     // %template scope explicit specializations
    -namespace ONE {
    +namespace One {
       %template(I) One::OneParm;
       %template(J) ::One::OneParm;
     }
    @@ -69,7 +69,7 @@ namespace One {
     }
     
     // %template scope partial specializations
    -namespace ONE {
    +namespace One {
       %template(BB) One::OneParm;
       %template(BBB) ::One::OneParm;
     }
    diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
    index 69dce5534..30408e73b 100644
    --- a/Source/CParse/parser.y
    +++ b/Source/CParse/parser.y
    @@ -209,7 +209,7 @@ static String *yyrename = 0;
     
     /* Forward renaming operator */
     
    -static String *resolve_create_node_scope(String *cname);
    +static String *resolve_create_node_scope(String *cname, int is_class_definition);
     
     
     Hash *Swig_cparse_features(void) {
    @@ -815,32 +815,53 @@ static String *remove_block(Node *kw, const String *inputcode) {
       return modified_code;
     }
     
    -
    +/*
    +#define RESOLVE_DEBUG 1
    +*/
     static Node *nscope = 0;
     static Node *nscope_inner = 0;
     
     /* Remove the scope prefix from cname and return the base name without the prefix.
      * The scopes required for the symbol name are resolved and/or created, if required.
      * For example AA::BB::CC as input returns CC and creates the namespace AA then inner 
    - * namespace BB in the current scope. If cname is found to already exist as a weak symbol
    - * (forward reference) then the scope might be changed to match, such as when a symbol match 
    - * is made via a using reference. */
    -static String *resolve_create_node_scope(String *cname) {
    + * namespace BB in the current scope. */
    +static String *resolve_create_node_scope(String *cname, int is_class_definition) {
       Symtab *gscope = 0;
       Node *cname_node = 0;
    -  int skip_lookup = 0;
    +  String *last = Swig_scopename_last(cname);
       nscope = 0;
       nscope_inner = 0;  
     
    -  if (Strncmp(cname,"::",2) == 0)
    -    skip_lookup = 1;
    -
    -  cname_node = skip_lookup ? 0 : Swig_symbol_clookup_no_inherit(cname, 0);
    +  if (Strncmp(cname,"::" ,2) != 0) {
    +    if (is_class_definition) {
    +      /* Only lookup symbols which are in scope via a using declaration but not via a using directive.
    +         For example find y via 'using x::y' but not y via a 'using namespace x'. */
    +      cname_node = Swig_symbol_clookup_no_inherit(cname, 0);
    +      if (!cname_node) {
    +	Node *full_lookup_node = Swig_symbol_clookup(cname, 0);
    +	if (full_lookup_node) {
    +	 /* This finds a symbol brought into scope via both a using directive and a using declaration. */
    +	  Node *last_node = Swig_symbol_clookup_no_inherit(last, 0);
    +	  if (last_node == full_lookup_node)
    +	    cname_node = last_node;
    +	}
    +      }
    +    } else {
    +      /* For %template, the template needs to be in scope via any means. */
    +      cname_node = Swig_symbol_clookup(cname, 0);
    +    }
    +  }
    +#if RESOLVE_DEBUG
    +  if (!cname_node)
    +    Printf(stdout, "symbol does not yet exist (%d): [%s]\n", is_class_definition, cname);
    +  else
    +    Printf(stdout, "symbol does exist (%d): [%s]\n", is_class_definition, cname);
    +#endif
     
       if (cname_node) {
         /* The symbol has been defined already or is in another scope.
    -       If it is a weak symbol, it needs replacing and if it was brought into the current scope
    -       via a using declaration, the scope needs adjusting appropriately for the new symbol.
    +       If it is a weak symbol, it needs replacing and if it was brought into the current scope,
    +       the scope needs adjusting appropriately for the new symbol.
            Similarly for defined templates. */
         Symtab *symtab = Getattr(cname_node, "sym:symtab");
         Node *sym_weak = Getattr(cname_node, "sym:weak");
    @@ -848,48 +869,92 @@ static String *resolve_create_node_scope(String *cname) {
           /* Check if the scope is the current scope */
           String *current_scopename = Swig_symbol_qualifiedscopename(0);
           String *found_scopename = Swig_symbol_qualifiedscopename(symtab);
    -      int len;
           if (!current_scopename)
     	current_scopename = NewString("");
           if (!found_scopename)
     	found_scopename = NewString("");
    -      len = Len(current_scopename);
    -      if ((len > 0) && (Strncmp(current_scopename, found_scopename, len) == 0)) {
    -	if (Len(found_scopename) > len + 2) {
    -	  /* A matching weak symbol was found in non-global scope, some scope adjustment may be required */
    -	  String *new_cname = NewString(Char(found_scopename) + len + 2); /* skip over "::" prefix */
    -	  String *base = Swig_scopename_last(cname);
    -	  Printf(new_cname, "::%s", base);
    -	  cname = new_cname;
    -	  Delete(base);
    -	} else {
    -	  /* A matching weak symbol was found in the same non-global local scope, no scope adjustment required */
    -	  assert(len == Len(found_scopename));
    +
    +      {
    +	int fail = 1;
    +	List *current_scopes = Swig_scopename_tolist(current_scopename);
    +	List *found_scopes = Swig_scopename_tolist(found_scopename);
    +        Iterator cit = First(current_scopes);
    +	Iterator fit = First(found_scopes);
    +#if RESOLVE_DEBUG
    +Printf(stdout, "comparing current: [%s] found: [%s]\n", current_scopename, found_scopename);
    +#endif
    +	for (; fit.item && cit.item; fit = Next(fit), cit = Next(cit)) {
    +	  String *current = cit.item;
    +	  String *found = fit.item;
    +#if RESOLVE_DEBUG
    +	  Printf(stdout, "  looping %s %s\n", current, found);
    +#endif
    +	  if (Strcmp(current, found) != 0)
    +	    break;
     	}
    -      } else {
    -	String *base = Swig_scopename_last(cname);
    -	if (Len(found_scopename) > 0) {
    -	  /* A matching weak symbol was found in a different scope to the local scope - probably via a using declaration */
    -	  cname = NewStringf("%s::%s", found_scopename, base);
    +
    +	if (!cit.item) {
    +	  String *subscope = NewString("");
    +	  for (; fit.item; fit = Next(fit)) {
    +	    if (Len(subscope) > 0)
    +	      Append(subscope, "::");
    +	    Append(subscope, fit.item);
    +	  }
    +	  if (Len(subscope) > 0)
    +	    cname = NewStringf("%s::%s", subscope, last);
    +	  else
    +	    cname = Copy(last);
    +#if RESOLVE_DEBUG
    +	  Printf(stdout, "subscope to create: [%s] cname: [%s]\n", subscope, cname);
    +#endif
    +	  fail = 0;
    +	  Delete(subscope);
     	} else {
    -	  /* Either:
    -	      1) A matching weak symbol was found in a different scope to the local scope - this is actually a
    -	      symbol with the same name in a different scope which we don't want, so no adjustment required.
    -	      2) A matching weak symbol was found in the global scope - no adjustment required.
    -	  */
    -	  cname = Copy(base);
    +	  if (is_class_definition) {
    +	    if (!fit.item) {
    +	      /* It is valid to define a new class with the same name as one forward declared in a parent scope */
    +	      fail = 0;
    +	    } else if (Swig_scopename_check(cname)) {
    +	      /* Classes defined with scope qualifiers must have a matching forward declaration in matching scope */
    +	      fail = 1;
    +	    } else {
    +	      /* This may let through some invalid cases */
    +	      fail = 0;
    +	    }
    +#if RESOLVE_DEBUG
    +	    Printf(stdout, "scope for class definition, fail: %d\n", fail);
    +#endif
    +	  } else {
    +#if RESOLVE_DEBUG
    +	    Printf(stdout, "no matching base scope for template\n");
    +#endif
    +	    fail = 1;
    +	  }
    +	}
    +
    +	Delete(found_scopes);
    +	Delete(current_scopes);
    +
    +	if (fail) {
    +	  String *cname_resolved = NewStringf("%s::%s", found_scopename, last);
    +	  Swig_error(cparse_file, cparse_line, "'%s' resolves to '%s' and was incorrectly instantiated in scope '%s' instead of within scope '%s'.\n", cname, cname_resolved, current_scopename, found_scopename);
    +	  cname = Copy(last);
    +	  Delete(cname_resolved);
     	}
    -	Delete(base);
           }
    +
           Delete(current_scopename);
           Delete(found_scopename);
         }
    +  } else if (!is_class_definition) {
    +    /* A template instantiation requires a template to be found in scope... fail here too?
    +    Swig_error(cparse_file, cparse_line, "No template found to instantiate '%s' with %%template.\n", cname);
    +     */
       }
     
       if (Swig_scopename_check(cname)) {
         Node   *ns;
         String *prefix = Swig_scopename_prefix(cname);
    -    String *base = Swig_scopename_last(cname);
         if (prefix && (Strncmp(prefix,"::",2) == 0)) {
     /* I don't think we can use :: global scope to declare classes and hence neither %template. - consider reporting error instead - wsfulton. */
           /* Use the global scope */
    @@ -899,6 +964,7 @@ static String *resolve_create_node_scope(String *cname) {
           gscope = set_scope_to_global();
         }
         if (Len(prefix) == 0) {
    +      String *base = Copy(last);
           /* Use the global scope, but we need to add a 'global' namespace.  */
           if (!gscope) gscope = set_scope_to_global();
           /* note that this namespace is not the "unnamed" one,
    @@ -907,6 +973,7 @@ static String *resolve_create_node_scope(String *cname) {
           nscope = new_node("namespace");
           Setattr(nscope,"symtab", gscope);;
           nscope_inner = nscope;
    +      Delete(last);
           return base;
         }
         /* Try to locate the scope */
    @@ -924,7 +991,7 @@ static String *resolve_create_node_scope(String *cname) {
     	String *nname = Swig_symbol_qualifiedscopename(nstab);
     	if (tname && (Strcmp(tname,nname) == 0)) {
     	  ns = 0;
    -	  cname = base;
    +	  cname = Copy(last);
     	}
     	Delete(tname);
     	Delete(nname);
    @@ -932,19 +999,10 @@ static String *resolve_create_node_scope(String *cname) {
           if (ns) {
     	/* we will try to create a new node using the namespaces we
     	   can find in the scope name */
    -	List *scopes;
    +	List *scopes = Swig_scopename_tolist(prefix);
     	String *sname;
     	Iterator si;
    -	String *name = NewString(prefix);
    -	scopes = NewList();
    -	while (name) {
    -	  String *base = Swig_scopename_last(name);
    -	  String *tprefix = Swig_scopename_prefix(name);
    -	  Insert(scopes,0,base);
    -	  Delete(base);
    -	  Delete(name);
    -	  name = tprefix;
    -	}
    +
     	for (si = First(scopes); si.item; si = Next(si)) {
     	  Node *ns1,*ns2;
     	  sname = si.item;
    @@ -990,12 +1048,13 @@ static String *resolve_create_node_scope(String *cname) {
     	  nscope_inner = ns2;
     	  if (!nscope) nscope = ns2;
     	}
    -	cname = base;
    +	cname = Copy(last);
     	Delete(scopes);
           }
         }
         Delete(prefix);
       }
    +  Delete(last);
     
       return cname;
     }
    @@ -2631,9 +2690,8 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
     		  tscope = Swig_symbol_current();          /* Get the current scope */
     
     		  /* If the class name is qualified, we need to create or lookup namespace entries */
    -		  if (!inclass) {
    -		    $5 = resolve_create_node_scope($5);
    -		  }
    +		  $5 = resolve_create_node_scope($5, 0);
    +
     		  if (nscope_inner && Strcmp(nodeType(nscope_inner), "class") == 0) {
     		    outer_class	= nscope_inner;
     		  }
    @@ -3520,7 +3578,7 @@ cpp_class_decl  : storage_class cpptype idcolon inherit LBRACE {
     		   Setattr($$,"prev_symtab",Swig_symbol_current());
     		  
     		   /* If the class name is qualified.  We need to create or lookup namespace/scope entries */
    -		   scope = resolve_create_node_scope($3);
    +		   scope = resolve_create_node_scope($3, 1);
     		   /* save nscope_inner to the class - it may be overwritten in nested classes*/
     		   Setattr($$, "nested:innerscope", nscope_inner);
     		   Setattr($$, "nested:nscope", nscope);
    diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
    index cfa0c68b3..f80fb678f 100644
    --- a/Source/Swig/misc.c
    +++ b/Source/Swig/misc.c
    @@ -823,10 +823,11 @@ String *Swig_string_emangle(String *s) {
     
     
     /* -----------------------------------------------------------------------------
    - * Swig_scopename_prefix()
    + * Swig_scopename_split()
      *
    - * Take a qualified name like "A::B::C" and return the scope name.
    - * In this case, "A::B".   Returns NULL if there is no base.
    + * Take a qualified name like "A::B::C" and splits off the last name.
    + * In this case, returns "C" as last and "A::B" as prefix.
    + * Always returns non NULL for last, but prefix may be NULL if there is no prefix.
      * ----------------------------------------------------------------------------- */
     
     void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
    @@ -882,6 +883,12 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
       }
     }
     
    +/* -----------------------------------------------------------------------------
    + * Swig_scopename_prefix()
    + *
    + * Take a qualified name like "A::B::C" and return the scope name.
    + * In this case, "A::B".   Returns NULL if there is no base.
    + * ----------------------------------------------------------------------------- */
     
     String *Swig_scopename_prefix(const String *s) {
       char *tmp = Char(s);
    @@ -1067,6 +1074,31 @@ String *Swig_scopename_suffix(const String *s) {
       }
     }
     
    +/* -----------------------------------------------------------------------------
    + * Swig_scopename_tolist()
    + *
    + * Take a qualified scope name like "A::B::C" and convert it to a list.
    + * In this case, return a list of 3 elements "A", "B", "C".
    + * Returns an empty list if the input is empty.
    + * ----------------------------------------------------------------------------- */
    +
    +List *Swig_scopename_tolist(const String *s) {
    +  List *scopes = NewList();
    +  String *name = Len(s) == 0 ? 0 : NewString(s);
    +
    +  while (name) {
    +    String *last = 0;
    +    String *prefix = 0;
    +    Swig_scopename_split(name, &prefix, &last);
    +    Insert(scopes, 0, last);
    +    Delete(last);
    +    Delete(name);
    +    name = prefix;
    +  }
    +  Delete(name);
    +  return scopes;
    +}
    +
     /* -----------------------------------------------------------------------------
      * Swig_scopename_check()
      *
    diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
    index f25f0993e..0bcd53a66 100644
    --- a/Source/Swig/swig.h
    +++ b/Source/Swig/swig.h
    @@ -326,6 +326,7 @@ extern int        ParmList_is_compactdefargs(ParmList *p);
       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 List *Swig_scopename_tolist(const String *s);
       extern int Swig_scopename_check(const String *s);
       extern String *Swig_string_lower(String *s);
       extern String *Swig_string_upper(String *s);
    
    From 1434449041eee60fb13dfe9a0ddea6be88fc88df Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Wed, 9 Aug 2017 09:15:50 +0100
    Subject: [PATCH 0661/2031] Testcase fix for nameclash in php
    
    ---
     .../test-suite/template_parameters_global_scope.i    | 12 ++++++------
     1 file changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/Examples/test-suite/template_parameters_global_scope.i b/Examples/test-suite/template_parameters_global_scope.i
    index 4c14ba4a3..a828187b5 100644
    --- a/Examples/test-suite/template_parameters_global_scope.i
    +++ b/Examples/test-suite/template_parameters_global_scope.i
    @@ -9,17 +9,17 @@ namespace Alloc {
     %}
     
     %inline %{
    -struct Bucket {};
    -typedef Bucket TDBucket;
    -typedef ::Bucket TDGlobalBucket;
    +struct Bucket_ {};
    +typedef Bucket_ TDBucket;
    +typedef ::Bucket_ TDGlobalBucket;
     %}
     
     // Check 1: %template no unary scope operator
    -%template(RebindBucket) Alloc::Rebind< Bucket >;
    +%template(RebindBucket) Alloc::Rebind< Bucket_ >;
     
     %inline %{
    -Alloc::Rebind< Bucket >::Integer Bucket1() { return 1; }
    -Alloc::Rebind< ::Bucket >::Integer Bucket2() { return 2; }
    +Alloc::Rebind< Bucket_ >::Integer Bucket1() { return 1; }
    +Alloc::Rebind< ::Bucket_ >::Integer Bucket2() { return 2; }
     Alloc::Rebind< TDBucket >::Integer Bucket3() { return 3; }
     Alloc::Rebind< ::TDBucket >::Integer Bucket4() { return 4; }
     Alloc::Rebind< TDGlobalBucket >::Integer Bucket5() { return 5; }
    
    From 8bf81b8718ba413f66a9dc41e06a50f113e68edd Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Wed, 9 Aug 2017 20:54:32 +0100
    Subject: [PATCH 0662/2031] More docs on %template
    
    ---
     Doc/Manual/SWIGPlus.html | 14 ++++++++++++++
     1 file changed, 14 insertions(+)
    
    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
    index 13c81588d..28e0e839f 100644
    --- a/Doc/Manual/SWIGPlus.html
    +++ b/Doc/Manual/SWIGPlus.html
    @@ -3109,6 +3109,20 @@ not necessary to instantiate a new class for the type Integer (doing so
     redundant and will simply result in code bloat).
     

    +

    +The template provide to %template for instantiation must be the actual template and not a typedef to a template. +

    + +
    +
    +typedef List<int> ListOfInt;
    +
    +%template(intList) List<int>; // ok
    +%template(intList) ListOfInt; // illegal - Syntax error
    +
    +
    + +

    6.18.2 Function templates

    From bf98c5304faed50fa0c1f09228c55f21fcb06691 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Aug 2017 10:11:38 +0100 Subject: [PATCH 0663/2031] Fix type lookup in the presence of using directives and using declarations Fix some cases of type lookup failure via a combination of both using directives and using declarations resulting in C++ code that did not compile as the generated type was not fully qualified for use in the global namespace. Example below: namespace Space5 { namespace SubSpace5 { namespace SubSubSpace5 { struct F {}; } } using namespace SubSpace5; using SubSubSpace5::F; void func(SubSubSpace5::F f); } --- Examples/test-suite/class_scope_namespace.i | 3 +- Examples/test-suite/common.mk | 1 + .../java/class_scope_namespace_runme.java | 2 +- .../java/namespace_chase_runme.java | 26 +++++ Examples/test-suite/namespace_chase.i | 36 +++++++ Source/Swig/typesys.c | 101 +++++++++++++----- 6 files changed, 139 insertions(+), 30 deletions(-) create mode 100644 Examples/test-suite/java/namespace_chase_runme.java create mode 100644 Examples/test-suite/namespace_chase.i diff --git a/Examples/test-suite/class_scope_namespace.i b/Examples/test-suite/class_scope_namespace.i index 08a9f01dc..372727f3c 100644 --- a/Examples/test-suite/class_scope_namespace.i +++ b/Examples/test-suite/class_scope_namespace.i @@ -73,8 +73,7 @@ namespace Space5 { struct SubSubSpace5::F { void ff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {} }; -// needs fixing - void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, /*SubSubSpace5::F,*/ F) {} + void fff(Space5::SubSpace5::SubSubSpace5::F, SubSpace5::SubSubSpace5::F, SubSubSpace5::F, F) {} } namespace Space6 { diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 0c896825f..ce6544279 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -292,6 +292,7 @@ CPP_TEST_CASES += \ multiple_inheritance_shared_ptr \ name_cxx \ name_warnings \ + namespace_chase \ namespace_class \ namespace_enum \ namespace_extend \ diff --git a/Examples/test-suite/java/class_scope_namespace_runme.java b/Examples/test-suite/java/class_scope_namespace_runme.java index e80779413..9d74a6ca6 100644 --- a/Examples/test-suite/java/class_scope_namespace_runme.java +++ b/Examples/test-suite/java/class_scope_namespace_runme.java @@ -47,7 +47,7 @@ public class class_scope_namespace_runme { class_scope_namespace.ccc(c, c); class_scope_namespace.ddd(d, d, d); class_scope_namespace.eee(e, e, e); - class_scope_namespace.fff(f, f, f); + class_scope_namespace.fff(f, f, f, f); class_scope_namespace.ggg(g, g); class_scope_namespace.hhh(h); class_scope_namespace.iii(i, i); diff --git a/Examples/test-suite/java/namespace_chase_runme.java b/Examples/test-suite/java/namespace_chase_runme.java new file mode 100644 index 000000000..9b4898bd0 --- /dev/null +++ b/Examples/test-suite/java/namespace_chase_runme.java @@ -0,0 +1,26 @@ + +import namespace_chase.*; + +public class namespace_chase_runme { + + static { + try { + System.loadLibrary("namespace_chase"); + } 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[]) + { + Struct1A s1a = new Struct1A(); + Struct1B s1b = new Struct1B(); + Struct1C s1c = new Struct1C(); + + namespace_chase.sss3a(s1a, s1b, s1c); + namespace_chase.sss3b(s1a, s1b, s1c); + // needs fixing +// namespace_chase.sss3c(s1a, s1b, s1c); + } +} diff --git a/Examples/test-suite/namespace_chase.i b/Examples/test-suite/namespace_chase.i new file mode 100644 index 000000000..5e3921d0d --- /dev/null +++ b/Examples/test-suite/namespace_chase.i @@ -0,0 +1,36 @@ +%module namespace_chase + +%inline %{ + namespace Space1A { + struct Struct1A {}; + namespace Space1B { + struct Struct1B {}; + namespace Space1C { + struct Struct1C {}; + } + } + } + namespace Space2A { + using namespace Space1A; + namespace Space2B { + using namespace Space1B; + namespace Space2C { + using namespace Space1C; + } + } + } + namespace Space3 { + using namespace Space2A; + void sss3a(Space1A::Struct1A, Space1A::Space1B::Struct1B, Space1A::Space1B::Space1C::Struct1C) {} + void sss3b(Struct1A, Space1B::Struct1B, Space1B::Space1C::Struct1C) {} + // To fix: the last two parameters below fail and result in SWIGTYPE_ types instead of proxy classes + void sss3c(Space2A::Struct1A, Space2A::Space1B::Struct1B, Space2A::Space1B::Space1C::Struct1C) {} + } + namespace Space4 { + using namespace Space2A; + using namespace Space2A::Space2B; + using namespace Space2A::Space2B::Space2C; + void sss4a(Struct1A, Struct1B, Space2C::Struct1C) {} + void sss4b(Struct1A, Struct1B, Struct1C) {} + } +%} diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 2fb514d5e..e460b422a 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -53,8 +53,7 @@ * typedef A B; * typedef B *C; * - * typetab is built as follows: - * + * typetab in scope '' contains: * "A" : "int" * "B" : "A" * "C" : "p.B" @@ -67,31 +66,76 @@ * ---> a(40).p.p.A (B --> A) * ---> a(40).p.p.int (A --> int) * + * + * Using declarations are stored in the "typetab" hash table. For example, + * + * namespace NN { + * struct SS {}; + * } + * namespace N { + * struct S {}; + * using NN::SS; + * } + * using N::S; + * + * typetab in scope '' contains: + * "S" : "N::S" + * + * and typetab in scope 'N' contains: + * "SS" : "NN::SS" + * "S" : "S" + * + * * For inheritance, SWIG tries to resolve types back to the base class. For instance, if * you have this: * - * class Foo { - * public: - * typedef int Integer; - * }; + * class Foo { + * public: + * typedef int Integer; + * }; + * struct Bar : public Foo { + * void blah(Integer x); + * }; * - * class Bar : public Foo { - * void blah(Integer x); - * }; + * In this case typetab in scope '' contains: + * "Foo" : "Foo" + * "Bar" : "Bar" + * and scope 'Foo' contains: + * "Integer" : "int" + * and scope 'Bar' inherits from 'Foo' but is empty (observe that blah is not a scope or typedef) * * The argument type of Bar::blah will be set to Foo::Integer. * + * + * The scope-inheritance mechanism is used to manage C++ using directives. + * + * namespace XX { + * class CC {}; + * } + * namespace X { + * class C {}; + * using namespace XX; + * } + * using namespace X; + * + * typetab in scope '' inherits from 'X' + * typetab in scope 'X' inherits from 'XX' and contains: + * "C" : "C" + * typetab in scope 'XX' contains: + * "CC" : "CC" + * + * * The scope-inheritance mechanism is used to manage C++ namespace aliases. * For example, if you have this: * - * namespace Foo { - * typedef int Integer; - * } + * namespace Foo { + * typedef int Integer; + * } * - * namespace F = Foo; + * namespace F = Foo; * - * In this case, "F::" is defined as a scope that "inherits" from Foo. Internally, - * "F::" will merely be an empty scope that refers to Foo. SWIG will never + * In this case, F is defined as a scope that "inherits" from Foo. Internally, + * F will merely be an empty scope that points to Foo. SWIG will never * place new type information into a namespace alias---attempts to do so * will generate a warning message (in the parser) and will place information into * Foo instead. @@ -968,8 +1012,17 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) { /* ----------------------------------------------------------------------------- * SwigType_typedef_qualified() * - * Given a type declaration, this function tries to fully qualify it according to - * typedef scope rules. + * Given a type declaration, this function tries to fully qualify it so that the + * resulting type can be used in the global scope. The type name is resolved in + * the current scope. + * + * It provides a fully qualified name, not necessarily a fully expanded name. + * When a using declaration or using directive is found the type may not be fully + * expanded, but it will be resolved and fully qualified for use in the global scope. + * + * This function is for looking up scopes to qualify a type. It does not resolve + * C typedefs, it just qualifies them. See SwigType_typedef_resolve for resolving. + * * If the unary scope operator (::) is used as a prefix to the type to denote global * scope, it is left in place. * ----------------------------------------------------------------------------- */ @@ -1030,20 +1083,14 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) { out of the current scope */ Typetab *cs = current_scope; - while (cs) { - String *qs = SwigType_scope_name(cs); - if (Len(qs)) { - Append(qs, "::"); - } - Append(qs, e); - if (Getattr(scopes, qs)) { + if (cs) { + Typetab *found_scope = SwigType_find_scope(cs, e); + if (found_scope) { + String *qs = SwigType_scope_name(found_scope); Clear(e); Append(e, qs); Delete(qs); - break; } - Delete(qs); - cs = Getattr(cs, "parent"); } } } From 96e99416d76c3e0201a7b60417a0c24f845ba5b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Aug 2017 22:38:03 +0100 Subject: [PATCH 0664/2031] Add using declarations to templates into typedef table. Fixes #1051. Using declarations to templates were missing in SWIG's internal typedef tables. This led to a few problems, such as, templates that did not instantiate and generated C++ code that did not compile as SWIG did not know what scope the template was in. This happened mostly when a using declaration was used on a template type in a completely unrelated namespace. --- Examples/test-suite/common.mk | 1 + ...rective_and_declaration_forward_runme.java | 10 ++--- ...emplate_using_directive_typedef_runme.java | 31 +++++++++++++ .../template_using_directive_typedef_runme.py | 15 +++++++ Source/Modules/typepass.cxx | 3 -- Source/Swig/typesys.c | 45 +++++++++++++++---- 6 files changed, 89 insertions(+), 16 deletions(-) create mode 100644 Examples/test-suite/java/template_using_directive_typedef_runme.java create mode 100644 Examples/test-suite/python/template_using_directive_typedef_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index ce6544279..e5e60a330 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -436,6 +436,7 @@ CPP_TEST_CASES += \ template_methods \ template_namespace_forward_declaration \ template_using_directive_and_declaration_forward \ + template_using_directive_typedef \ template_nested \ template_nested_typemaps \ template_ns \ diff --git a/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java b/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java index 080945e02..3aab5fa8f 100644 --- a/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java +++ b/Examples/test-suite/java/template_using_directive_and_declaration_forward_runme.java @@ -19,32 +19,32 @@ public class template_using_directive_and_declaration_forward_runme { template_using_directive_and_declaration_forward.useit1b(new Thing1Int()); template_using_directive_and_declaration_forward.useit1c(new Thing1Int()); -//BROKEN template_using_directive_and_declaration_forward.useit2(new Thing2Int()); + template_using_directive_and_declaration_forward.useit2(new Thing2Int()); template_using_directive_and_declaration_forward.useit2a(new Thing2Int()); template_using_directive_and_declaration_forward.useit2b(new Thing2Int()); template_using_directive_and_declaration_forward.useit2c(new Thing2Int()); template_using_directive_and_declaration_forward.useit2d(new Thing2Int()); -//BROKEN template_using_directive_and_declaration_forward.useit3(new Thing3Int()); + template_using_directive_and_declaration_forward.useit3(new Thing3Int()); template_using_directive_and_declaration_forward.useit3a(new Thing3Int()); template_using_directive_and_declaration_forward.useit3b(new Thing3Int()); template_using_directive_and_declaration_forward.useit3c(new Thing3Int()); template_using_directive_and_declaration_forward.useit3d(new Thing3Int()); -//BROKEN template_using_directive_and_declaration_forward.useit4(new Thing4Int()); + template_using_directive_and_declaration_forward.useit4(new Thing4Int()); template_using_directive_and_declaration_forward.useit4a(new Thing4Int()); template_using_directive_and_declaration_forward.useit4b(new Thing4Int()); template_using_directive_and_declaration_forward.useit4c(new Thing4Int()); template_using_directive_and_declaration_forward.useit4d(new Thing4Int()); -//BROKEN template_using_directive_and_declaration_forward.useit5(new Thing5Int()); + template_using_directive_and_declaration_forward.useit5(new Thing5Int()); template_using_directive_and_declaration_forward.useit5a(new Thing5Int()); template_using_directive_and_declaration_forward.useit5b(new Thing5Int()); template_using_directive_and_declaration_forward.useit5c(new Thing5Int()); template_using_directive_and_declaration_forward.useit5d(new Thing5Int()); -//BROKEN template_using_directive_and_declaration_forward.useit7(new Thing7Int()); + template_using_directive_and_declaration_forward.useit7(new Thing7Int()); template_using_directive_and_declaration_forward.useit7a(new Thing7Int()); template_using_directive_and_declaration_forward.useit7b(new Thing7Int()); template_using_directive_and_declaration_forward.useit7c(new Thing7Int()); diff --git a/Examples/test-suite/java/template_using_directive_typedef_runme.java b/Examples/test-suite/java/template_using_directive_typedef_runme.java new file mode 100644 index 000000000..bec077399 --- /dev/null +++ b/Examples/test-suite/java/template_using_directive_typedef_runme.java @@ -0,0 +1,31 @@ + +import template_using_directive_typedef.*; + +public class template_using_directive_typedef_runme { + + static { + try { + System.loadLibrary("template_using_directive_typedef"); + } 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[]) { + Vector_Obj vo = new Vector_Obj(); + + Holder h = new Holder(); + h.holder_use1(vo, vo, vo); + h.holder_use2(vo, vo, vo); + h.holder_use3(vo, vo, vo); + + template_using_directive_typedef.tns_holder_use(vo, vo); + template_using_directive_typedef.tns_use(vo, vo, vo); + template_using_directive_typedef.global_holder_use(vo); + template_using_directive_typedef.global_use(vo, vo, vo); + template_using_directive_typedef.ns1_holder_use(vo); + template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo); + } +} + diff --git a/Examples/test-suite/python/template_using_directive_typedef_runme.py b/Examples/test-suite/python/template_using_directive_typedef_runme.py new file mode 100644 index 000000000..363a3b754 --- /dev/null +++ b/Examples/test-suite/python/template_using_directive_typedef_runme.py @@ -0,0 +1,15 @@ +import template_using_directive_typedef + +vo = template_using_directive_typedef.Vector_Obj(); + +h = template_using_directive_typedef.Holder(); +h.holder_use1(vo, vo, vo); +h.holder_use2(vo, vo, vo); +h.holder_use3(vo, vo, vo); + +template_using_directive_typedef.tns_holder_use(vo, vo); +template_using_directive_typedef.tns_use(vo, vo, vo); +template_using_directive_typedef.global_holder_use(vo); +template_using_directive_typedef.global_use(vo, vo, vo); +template_using_directive_typedef.ns1_holder_use(vo); +template_using_directive_typedef.ns2_holder_use(vo, vo, vo, vo); diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index bf8028c29..43ada4d4b 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -1199,10 +1199,7 @@ class TypePass:private Dispatcher { } else if (Strcmp(ntype, "enum") == 0) { SwigType_typedef_using(Getattr(n, "uname")); } else if (Strcmp(ntype, "template") == 0) { - /* - Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname")); SwigType_typedef_using(Getattr(n, "uname")); - */ } } } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index e460b422a..409e28f35 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -42,10 +42,15 @@ * "name" - Scope name * "qname" - Fully qualified typename * "typetab" - Type table containing typenames and typedef information + * For a given key in the typetab table, the value is a fully + * qualified name if not pointing to itself. * "symtab" - Hash table of symbols defined in a scope * "inherit" - List of inherited scopes * "parent" - Parent scope * + * The contents of these tables can be viewed for debugging using the -debug-typedef + * option which calls SwigType_print_scope(). + * * Typedef information is stored in the "typetab" hash table. For example, * if you have these declarations: * @@ -210,6 +215,7 @@ void SwigType_typesystem_init() { * ----------------------------------------------------------------------------- */ int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) { + /* Printf(stdout, "typedef %s %s\n", type, name); */ if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ @@ -660,6 +666,17 @@ static SwigType *typedef_resolve(Typetab *s, String *base) { /* ----------------------------------------------------------------------------- * SwigType_typedef_resolve() + * + * Given a type declaration, this function looks to reduce/resolve the type via a + * typedef (including via C++ using declarations). + * + * If it is able to find a typedef, the resolved type is returned. If no typedef + * is found NULL is returned. The type name is resolved in the current scope. + * The type returned is not always fully qualified for the global scope, it is + * valid for use in the current scope. If the current scope is global scope, a + * fully qualified type should be returned. + * + * Some additional notes are in Doc/Manual/Extending.html. * ----------------------------------------------------------------------------- */ /* #define SWIG_DEBUG */ @@ -786,6 +803,25 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { } } + if (!type && SwigType_istemplate(base)) { + String *tprefix = SwigType_templateprefix(base); + String *rtprefix = SwigType_typedef_resolve(tprefix); + /* We're looking for a using declaration on the template prefix to resolve the template prefix + * in another scope. Using declaration do not have template parameters. */ + if (rtprefix && !SwigType_istemplate(rtprefix)) { + String *tsuffix = SwigType_templatesuffix(base); + String *targs = SwigType_templateargs(base); + type = NewString(rtprefix); + newtype = 1; + Append(type, targs); + Append(type, tsuffix); + Delete(targs); + Delete(tsuffix); + Delete(rtprefix); + } + Delete(tprefix); + } + if (type && (Equal(base, type))) { if (newtype) Delete(type); @@ -1106,10 +1142,6 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) { Parm *p; List *parms; ty = Swig_symbol_template_deftype(e, current_symtab); - /* - String *dt = Swig_symbol_template_deftype(e, current_symtab); - ty = Swig_symbol_type_qualify(dt, 0); - */ e = ty; parms = SwigType_parmlist(e); tprefix = SwigType_templateprefix(e); @@ -1176,9 +1208,6 @@ SwigType *SwigType_typedef_qualified(const SwigType *t) { Delete(tprefix); Delete(qprefix); Delete(parms); - /* - Delete(dt); - */ } Append(result, e); Delete(ty); @@ -1258,7 +1287,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) { String *defined_name = 0; - /* Printf(stdout,"using %s\n", name); */ + /* Printf(stdout, "using %s\n", name); */ if (!Swig_scopename_check(name)) return -1; /* Not properly qualified */ From 09af283371edab461a4ddd0df147ce86e8547c04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Aug 2017 23:12:55 +0100 Subject: [PATCH 0665/2031] Test a few %template errors --- Examples/test-suite/errors/cpp_invalid_template.i | 9 +++++++++ Examples/test-suite/errors/cpp_invalid_template.stderr | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 Examples/test-suite/errors/cpp_invalid_template.i create mode 100644 Examples/test-suite/errors/cpp_invalid_template.stderr diff --git a/Examples/test-suite/errors/cpp_invalid_template.i b/Examples/test-suite/errors/cpp_invalid_template.i new file mode 100644 index 000000000..ea0d7beac --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_template.i @@ -0,0 +1,9 @@ +%module cpp_invalid_scope + +%template(abc) SSS::AAA; + +namespace UUU { + struct JJJ; +} + +%template(xxx) UUU::JJJ; diff --git a/Examples/test-suite/errors/cpp_invalid_template.stderr b/Examples/test-suite/errors/cpp_invalid_template.stderr new file mode 100644 index 000000000..f6bfaaf7d --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_template.stderr @@ -0,0 +1,3 @@ +cpp_invalid_template.i:3: Error: Undefined scope 'SSS' +cpp_invalid_template.i:3: Error: Template 'SSS::AAA' undefined. +cpp_invalid_template.i:9: Error: 'JJJ' is not defined as a template. (classforward) From 902a141540a14c96f19c448dd0d18fb79413d47d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2017 07:56:28 +0100 Subject: [PATCH 0666/2031] Fix testcase failure on Node Javascript --- Examples/test-suite/preproc.i | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 8ed8c1a09..8d9c5176f 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -372,8 +372,9 @@ int methodX(int x) { return x+100; } // Comma in macro - Github issue #974 %inline %{ -#define __attribute__(x) -#define TCX_PACKED(d) d __attribute__ ((__packed__)) +#define swig__attribute__(x) +#define TCX_PACKED(d) d swig__attribute__ ((__packed__)) + TCX_PACKED (typedef struct tcxMessageTestImpl { From 8813343920e8d92e287377485848aad132eae880 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2017 07:57:30 +0100 Subject: [PATCH 0667/2031] Remove stray blank line print in php test --- Examples/test-suite/php5/php_pragma_runme.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/php5/php_pragma_runme.php b/Examples/test-suite/php5/php_pragma_runme.php index ae92f6818..c76cfc9b5 100644 --- a/Examples/test-suite/php5/php_pragma_runme.php +++ b/Examples/test-suite/php5/php_pragma_runme.php @@ -9,4 +9,3 @@ check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==v check::done(); ?> - From 1132bc334b399e20f420b4abdd00eb2c20463887 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2017 22:05:26 +0100 Subject: [PATCH 0668/2031] Add recent template and scope fixes into changes file --- CHANGES.current | 155 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 808bd1798..4e3aebafd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,161 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-08-16: wsfulton + Fix #1051. Add using declarations to templates into typedef table. + + Using declarations to templates were missing in SWIG's internal typedef tables. + This led to a few problems, such as, templates that did not instantiate and generated + C++ code that did not compile as SWIG did not know what scope the template was + in. This happened mostly when a using declaration was used on a template type in a + completely unrelated namespace. + +2017-08-16: wsfulton + Fix type lookup in the presence of using directives and using declarations. + + Fix some cases of type lookup failure via a combination of both using directives and + using declarations resulting in C++ code that did not compile as the generated type was + not fully qualified for use in the global namespace. Example below: + + namespace Space5 { + namespace SubSpace5 { + namespace SubSubSpace5 { + struct F {}; + } + } + using namespace SubSpace5; + using SubSubSpace5::F; + void func(SubSubSpace5::F f); + } + +2017-08-16: wsfulton + %template scope enforcement and class definition fixes. + + The scoping rules around %template have been specified and enforced. + The %template directive for a class template is the equivalent to an + explicit instantiation of a C++ class template. The scope for a valid + %template instantiation is now the same as the scope required for a + valid explicit instantiation of a C++ template. A definition of the + template for the explicit instantiation must be in scope where the + instantiation is declared and must not be enclosed within a different + namespace. + + For example, a few %template and C++ explicit instantiations of std::vector + are shown below: + + // valid + namespace std { + %template(vin) vector; + template class vector; + } + + // valid + using namespace std; + %template(vin) vector; + template class vector; + + // valid + using std::vector; + %template(vin) vector; + template class vector; + + // ill-formed + namespace unrelated { + using std::vector; + %template(vin) vector; + template class vector; + } + + // ill-formed + namespace unrelated { + using namespace std; + %template(vin) vector; + template class vector; + } + + // ill-formed + namespace unrelated { + namespace std { + %template(vin) vector; + template class vector; + } + } + + // ill-formed + namespace unrelated { + %template(vin) std::vector; + template class std::vector; + } + + When the scope is incorrect, an error now occurs such as: + + cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and + was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'. + + Previously SWIG accepted the ill-formed examples above but this led to + numerous subtle template scope problems especially in the presence of + using declarations and using directives as well as with %feature and %typemap. + + Actually, a valid instantiation is one which conforms to the C++03 + standard as C++11 made a change to disallow using declarations and + using directives to find a template. + + // valid C++03, ill-formed C++11 + using std::vector; + template class vector; + + Similar fixes for defining classes using forward class references have + also been put in place. For example: + + namespace Space1 { + struct A; + } + namespace Space2 { + struct Space1::A { + void x(); + } + } + + will now error out with: + + cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and + was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'. + +2017-08-16: wsfulton + Fix scope lookup for template parameters containing unary scope operators. + + Fixes cases like: + + namespace Alloc { + template struct Rebind { + typedef int Integer; + }; + } + %template(RebindBucket) Alloc::Rebind< Bucket >; + OR + %template(RebindBucket) Alloc::Rebind< ::Bucket >; + + Alloc::Rebind< Bucket >::Integer Bucket1(); + Alloc::Rebind< ::Bucket >::Integer Bucket2(); + Alloc::Rebind<::template TemplateBucket>::Integer Bucket3(); + +2017-08-16: wsfulton + For templates only, the template parameters are fully resolved when + handling typemaps. Without this, it is too hard to have decent rules + to apply typemaps when parameter types are typedef'd and template + parameters have default values. + + Fixes %clear for typedefs in templates, eg: + + %typemap("in") XXX::Long "..." + template typename struct XXX { + typedef long Long; + }; + %clear XXX::Long; + + as the typemap was previously incorrectly stored as a typemap for long + instead of XXX::Long. + 2017-08-05: olly [C++11] Allow static_assert at the top level (and disallow it right after template). Fixes https://github.com/swig/swig/issues/1031 From 9f454234b1e15e421c51c20b42cb1d78a66800ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2017 22:15:17 +0100 Subject: [PATCH 0669/2031] Add missing template_using_directive_typedef.i test file --- .../template_using_directive_typedef.i | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Examples/test-suite/template_using_directive_typedef.i diff --git a/Examples/test-suite/template_using_directive_typedef.i b/Examples/test-suite/template_using_directive_typedef.i new file mode 100644 index 000000000..1c8bcb9dd --- /dev/null +++ b/Examples/test-suite/template_using_directive_typedef.i @@ -0,0 +1,44 @@ +%module template_using_directive_typedef + +%inline %{ +namespace space { + template class Vector {}; + class VectorClass {}; +} +struct Obj {}; +%} + +%template(Vector_Obj) space::Vector; + +%inline %{ +namespace tns { + using space::Vector; // template using directives were not being added into the typedef table + using space::VectorClass; + typedef Vector NSVec; +} +%} + +%inline %{ +namespace tns { + struct Holder { +// using Vec = Vector; + typedef Vector Vec; + typedef VectorClass VecClass; + Vec items; + void holder_use1(space::Vector, tns::NSVec, tns::Vector) {} + void holder_use2(space::Vector, NSVec, Vector) {} + void holder_use3(tns::Holder::Vec, Holder::Vec, Vec) {} + }; + void tns_holder_use(tns::Holder::Vec, Holder::Vec) {} + void tns_use(space::Vector, NSVec, tns::NSVec) {} +} +void global_holder_use(tns::Holder::Vec) {} +void global_use(space::Vector, tns::NSVec, tns::Vector) {} +namespace ns1 { + void ns1_holder_use(tns::Holder::Vec) {} +} +namespace ns2 { + using namespace tns; + void ns2_holder_use(tns::Holder::Vec, Holder::Vec, NSVec, Vector) {} +} +%} From 11d105080399f5089dbf24f4acc61d388c5f90a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Aug 2017 22:18:29 +0100 Subject: [PATCH 0670/2031] Correct issue numbers in changes file --- CHANGES.current | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4e3aebafd..0629dfbb6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,7 +8,7 @@ Version 4.0.0 (in progress) =========================== 2017-08-16: wsfulton - Fix #1051. Add using declarations to templates into typedef table. + Fix #1063. Add using declarations to templates into typedef table. Using declarations to templates were missing in SWIG's internal typedef tables. This led to a few problems, such as, templates that did not instantiate and generated @@ -35,7 +35,7 @@ Version 4.0.0 (in progress) } 2017-08-16: wsfulton - %template scope enforcement and class definition fixes. + Issue #1051. %template scope enforcement and class definition fixes. The scoping rules around %template have been specified and enforced. The %template directive for a class template is the equivalent to an From dd3d04a2f2f2a05d5fc3bedac0a177e7caf6d1bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Aug 2017 10:28:41 +0100 Subject: [PATCH 0671/2031] Fix testcase for clang --- Examples/test-suite/class_scope_namespace.i | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Examples/test-suite/class_scope_namespace.i b/Examples/test-suite/class_scope_namespace.i index 372727f3c..730c076aa 100644 --- a/Examples/test-suite/class_scope_namespace.i +++ b/Examples/test-suite/class_scope_namespace.i @@ -20,9 +20,17 @@ namespace Space2 { struct B; } using Space2::B; +#ifdef __clang__ +namespace Space2 { + struct B { + void bb(Space2::B, B) {} + }; +} +#else struct B { void bb(Space2::B, B) {} }; +#endif void bbb(Space2::B, B) {} namespace Space3 { From 9e19fe7868d6d901c45329873ba02f09a7942542 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Aug 2017 01:02:34 +0100 Subject: [PATCH 0672/2031] C++11 ref-qualifier support added Fixes #1059 Methods with rvalue ref-qualifiers are ignored by default as it is not possible to have an rvalue temporary from the target language (which is needed to call the rvalue ref-qualified method). A warning 405 is shown mentioning the ignored rvalue ref-qualifier method which can be seen with the -Wextra option. cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&. Usually rvalue and lvalue ref-qualifier overloaded methods are written - the lvalue method will then be wrapped. --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_ref_qualifiers.i | 16 ++++ Examples/test-suite/errors/cpp_refqualifier.i | 18 +++++ .../test-suite/errors/cpp_refqualifier.stderr | 6 ++ .../java/cpp11_ref_qualifiers_runme.java | 22 ++++++ .../python/cpp11_ref_qualifiers_runme.py | 6 ++ Source/CParse/parser.y | 74 ++++++++++++++++--- Source/Include/swigwarn.h | 1 + Source/Modules/main.cxx | 15 ++-- Source/Swig/naming.c | 4 + 10 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 Examples/test-suite/cpp11_ref_qualifiers.i create mode 100644 Examples/test-suite/errors/cpp_refqualifier.i create mode 100644 Examples/test-suite/errors/cpp_refqualifier.stderr create mode 100644 Examples/test-suite/java/cpp11_ref_qualifiers_runme.java create mode 100644 Examples/test-suite/python/cpp11_ref_qualifiers_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e3448dcbc..b47b6e33b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -561,6 +561,7 @@ CPP11_TEST_CASES += \ cpp11_noexcept \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ + cpp11_ref_qualifiers \ cpp11_result_of \ cpp11_rvalue_reference \ cpp11_rvalue_reference2 \ diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i new file mode 100644 index 000000000..fa1d68d0e --- /dev/null +++ b/Examples/test-suite/cpp11_ref_qualifiers.i @@ -0,0 +1,16 @@ +%module cpp11_ref_qualifiers + +%inline %{ +class Host { +public: + void h1() & {} + void h2() const & {} + void h3() && {} + void h4() const && {} + + void h() & {} + void h() const & {} + void h() && {} + void h() const && {} +}; +%} diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i new file mode 100644 index 000000000..1cbcd936d --- /dev/null +++ b/Examples/test-suite/errors/cpp_refqualifier.i @@ -0,0 +1,18 @@ +%module cpp_refqualifier + +%ignore Host::h_ignored; + +class Host { +public: + void h1() &; + void h2() const &; + void h3() &&; + void h4() const &&; + + void h() &; + void h() const &; + void h() &&; + void h() const &&; + + void h_ignored() &&; +}; diff --git a/Examples/test-suite/errors/cpp_refqualifier.stderr b/Examples/test-suite/errors/cpp_refqualifier.stderr new file mode 100644 index 000000000..866d9b530 --- /dev/null +++ b/Examples/test-suite/errors/cpp_refqualifier.stderr @@ -0,0 +1,6 @@ +cpp_refqualifier.i:9: Warning 405: Method with rvalue ref-qualifier ignored h3() &&. +cpp_refqualifier.i:10: Warning 405: Method with rvalue ref-qualifier ignored h4() const &&. +cpp_refqualifier.i:14: Warning 405: Method with rvalue ref-qualifier ignored h() &&. +cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&. +cpp_refqualifier.i:13: Warning 512: Overloaded method Host::h() const & ignored, +cpp_refqualifier.i:12: Warning 512: using non-const method Host::h() & instead. diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java new file mode 100644 index 000000000..49afe8039 --- /dev/null +++ b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java @@ -0,0 +1,22 @@ + +import cpp11_ref_qualifiers.*; + +public class cpp11_ref_qualifiers_runme { + + static { + try { + System.loadLibrary("cpp11_ref_qualifiers"); + } 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[]) { + Host h = new Host(); + h.h1(); + h.h2(); + h.h(); + } +} + diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py new file mode 100644 index 000000000..24ce1d2bf --- /dev/null +++ b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py @@ -0,0 +1,6 @@ +import cpp11_ref_qualifiers + +h = cpp11_ref_qualifiers.Host() +h.h1() +h.h2() +h.h() diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index a4167b12d..9a101b1d2 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -485,6 +485,16 @@ static void add_symbols(Node *n) { SetFlag(n,"deleted"); SetFlag(n,"feature:ignore"); } + { + String *refqualifier = Getattr(n, "refqualifier"); + if (Equal(refqualifier, "&&") && strncmp(Char(symname), "$ignore", 7) != 0) { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED, Getfile(n), Getline(n), + "Method with rvalue ref-qualifier ignored %s.\n", Swig_name_decl(n)); + SWIG_WARN_NODE_END(n); + SetFlag(n, "feature:ignore"); + } + } } if (only_csymbol || GetFlag(n,"feature:ignore") || strncmp(Char(symname),"$ignore",7) == 0) { /* Only add to C symbol table and continue */ @@ -1451,6 +1461,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) String *rawval; int type; String *qualifier; + String *refqualifier; String *bitfield; Parm *throws; String *throwf; @@ -1560,7 +1571,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) /* Misc */ %type identifier; -%type initializer cpp_const exception_specification; +%type initializer cpp_const exception_specification cv_ref_qualifier; %type storage_class extern_string; %type parms ptail rawparms varargs_parms ; %type templateparameters templateparameterstail; @@ -1576,7 +1587,8 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) %type expr exprnum exprcompound valexpr; %type ename ; %type less_valparms_greater; -%type type_qualifier ; +%type type_qualifier; +%type ref_qualifier; %type type_qualifier_raw; %type idstring idstringopt; %type pragma_lang; @@ -3063,6 +3075,7 @@ c_decl : storage_class type declarator initializer c_decl_tail { $$ = new_node("cdecl"); if ($4.qualifier) decl = add_qualifier_to_declarator($3.type, $4.qualifier); + Setattr($$,"refqualifier",$4.refqualifier); Setattr($$,"type",$2); Setattr($$,"storage",$1); Setattr($$,"name",$3.id); @@ -3136,6 +3149,7 @@ c_decl : storage_class type declarator initializer c_decl_tail { | storage_class AUTO declarator cpp_const ARROW cpp_alternate_rettype initializer c_decl_tail { $$ = new_node("cdecl"); if ($4.qualifier) SwigType_push($3.type, $4.qualifier); + Setattr($$,"refqualifier",$4.refqualifier); Setattr($$,"type",$6); Setattr($$,"storage",$1); Setattr($$,"name",$3.id); @@ -3198,6 +3212,7 @@ c_decl_tail : SEMI { | COMMA declarator initializer c_decl_tail { $$ = new_node("cdecl"); if ($3.qualifier) SwigType_push($2.type,$3.qualifier); + Setattr($$,"refqualifier",$3.refqualifier); Setattr($$,"name",$2.id); Setattr($$,"decl",$2.type); Setattr($$,"parms",$2.parms); @@ -3236,13 +3251,15 @@ c_decl_tail : SEMI { initializer : def_args { $$ = $1; $$.qualifier = 0; + $$.refqualifier = 0; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; } - | type_qualifier def_args { + | cv_ref_qualifier def_args { $$ = $2; - $$.qualifier = $1; + $$.qualifier = $1.qualifier; + $$.refqualifier = $1.refqualifier; $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; @@ -3250,13 +3267,15 @@ initializer : def_args { | exception_specification def_args { $$ = $2; $$.qualifier = 0; + $$.refqualifier = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; } - | type_qualifier exception_specification def_args { + | cv_ref_qualifier exception_specification def_args { $$ = $3; - $$.qualifier = $1; + $$.qualifier = $1.qualifier; + $$.refqualifier = $1.refqualifier; $$.throws = $2.throws; $$.throwf = $2.throwf; $$.nexcept = $2.nexcept; @@ -4809,6 +4828,7 @@ cpp_vend : cpp_const SEMI { Clear(scanner_ccode); $$.val = 0; $$.qualifier = $1.qualifier; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; @@ -4818,6 +4838,7 @@ cpp_vend : cpp_const SEMI { Clear(scanner_ccode); $$.val = $3.val; $$.qualifier = $1.qualifier; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; @@ -4827,6 +4848,7 @@ cpp_vend : cpp_const SEMI { skip_balanced('{','}'); $$.val = 0; $$.qualifier = $1.qualifier; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; @@ -5828,6 +5850,29 @@ pointer : STAR type_qualifier pointer { } ; +/* cv-qualifier plus C++11 ref-qualifier for non-static member functions */ +cv_ref_qualifier : type_qualifier { + $$.qualifier = $1; + $$.refqualifier = 0; + } + | type_qualifier ref_qualifier { + $$.qualifier = $1; + $$.refqualifier = $2; + } + | ref_qualifier { + $$.qualifier = 0; + $$.refqualifier = $1; + } + ; + +ref_qualifier : AND { + $$ = NewString("&"); + } + | LAND { + $$ = NewString("&&"); + } + ; + type_qualifier : type_qualifier_raw { $$ = NewStringEmpty(); if ($1) SwigType_add_qualifier($$,$1); @@ -6049,6 +6094,7 @@ definetype : { /* scanner_check_typedef(); */ } expr { $$.rawval = NewStringf("%s", $$.val); } $$.qualifier = 0; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; @@ -6074,6 +6120,7 @@ deleted_definition : DELETE_KW { $$.rawval = 0; $$.type = T_STRING; $$.qualifier = 0; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; @@ -6087,6 +6134,7 @@ explicit_default : DEFAULT { $$.rawval = 0; $$.type = T_STRING; $$.qualifier = 0; + $$.refqualifier = 0; $$.bitfield = 0; $$.throws = 0; $$.throwf = 0; @@ -6616,25 +6664,29 @@ exception_specification : THROW LPAREN parms RPAREN { } ; -cpp_const : type_qualifier { +cpp_const : cv_ref_qualifier { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; - $$.qualifier = $1; + $$.qualifier = $1.qualifier; + $$.refqualifier = $1.refqualifier; } | exception_specification { $$ = $1; $$.qualifier = 0; + $$.refqualifier = 0; } - | type_qualifier exception_specification { + | cv_ref_qualifier exception_specification { $$ = $2; - $$.qualifier = $1; + $$.qualifier = $1.qualifier; + $$.refqualifier = $1.refqualifier; } | empty { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; - $$.qualifier = 0; + $$.qualifier = 0; + $$.refqualifier = 0; } ; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 0b4c7eeb5..dd32aef3a 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -153,6 +153,7 @@ #define WARN_TYPE_INCOMPLETE 402 #define WARN_TYPE_ABSTRACT 403 #define WARN_TYPE_REDEFINED 404 +#define WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405 #define WARN_TYPEMAP_SOURCETARGET 450 #define WARN_TYPEMAP_CHARLEAK 451 diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 12b83b2e4..9822b6af7 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -38,14 +38,15 @@ int NoExcept = 0; int SwigRuntime = 0; // 0 = no option, 1 = -runtime, 2 = -noruntime /* Suppress warning messages for private inheritance, preprocessor evaluation etc... - WARN_PP_EVALUATION 202 - WARN_PARSE_PRIVATE_INHERIT 309 - WARN_TYPE_ABSTRACT 403 - WARN_LANG_OVERLOAD_CONST 512 - WARN_PARSE_BUILTIN_NAME 321 - WARN_PARSE_REDUNDANT 322 + WARN_PP_EVALUATION 202 + WARN_PARSE_PRIVATE_INHERIT 309 + WARN_PARSE_BUILTIN_NAME 321 + WARN_PARSE_REDUNDANT 322 + WARN_TYPE_ABSTRACT 403 + WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405 + WARN_LANG_OVERLOAD_CONST 512 */ -#define EXTRA_WARNINGS "202,309,403,512,321,322" +#define EXTRA_WARNINGS "202,309,403,405,512,321,322" extern "C" { extern String *ModuleName; diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index ce1dbe806..69b9e2190 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1681,6 +1681,7 @@ String *Swig_name_str(Node *n) { * "MyNameSpace::MyTemplate::~MyTemplate()" * "MyNameSpace::ABC::ABC(int,double)" * "MyNameSpace::ABC::constmethod(int) const" + * "MyNameSpace::ABC::refqualifiermethod(int) const &" * "MyNameSpace::ABC::variablename" * * ----------------------------------------------------------------------------- */ @@ -1688,6 +1689,7 @@ String *Swig_name_str(Node *n) { String *Swig_name_decl(Node *n) { String *qname; String *decl; + String *refqualifier = Getattr(n, "refqualifier"); qname = Swig_name_str(n); @@ -1695,6 +1697,8 @@ String *Swig_name_decl(Node *n) { decl = NewStringf("%s", qname); else decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : ""); + if (refqualifier) + Printv(decl, " ", refqualifier, NIL); Delete(qname); From 685ee6cdc46bd4833851e0a55f535e9cfd18a978 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Aug 2017 09:38:19 +0100 Subject: [PATCH 0673/2031] Use normal SWIG encodings for ref-qualifiers --- Source/CParse/parser.y | 8 +++++--- Source/Swig/naming.c | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 9a101b1d2..80ec8611e 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -487,7 +487,7 @@ static void add_symbols(Node *n) { } { String *refqualifier = Getattr(n, "refqualifier"); - if (Equal(refqualifier, "&&") && strncmp(Char(symname), "$ignore", 7) != 0) { + if (SwigType_isrvalue_reference(refqualifier) && strncmp(Char(symname), "$ignore", 7) != 0) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED, Getfile(n), Getline(n), "Method with rvalue ref-qualifier ignored %s.\n", Swig_name_decl(n)); @@ -5866,10 +5866,12 @@ cv_ref_qualifier : type_qualifier { ; ref_qualifier : AND { - $$ = NewString("&"); + $$ = NewStringEmpty(); + SwigType_add_reference($$); } | LAND { - $$ = NewString("&&"); + $$ = NewStringEmpty(); + SwigType_add_rvalue_reference($$); } ; diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 69b9e2190..4fa32538f 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1697,8 +1697,11 @@ String *Swig_name_decl(Node *n) { decl = NewStringf("%s", qname); else decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : ""); - if (refqualifier) - Printv(decl, " ", refqualifier, NIL); + if (refqualifier) { + String *rq = SwigType_str(refqualifier, 0); + Printv(decl, " ", rq, NIL); + Delete(rq); + } Delete(qname); From 665b09ffc99109d2c0939a2965d460508e55ec13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Aug 2017 18:34:51 +0100 Subject: [PATCH 0674/2031] Fix seg fault with %interface and using declarations --- Source/Modules/interface.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Modules/interface.cxx b/Source/Modules/interface.cxx index f6d4c955b..fee6cd7da 100644 --- a/Source/Modules/interface.cxx +++ b/Source/Modules/interface.cxx @@ -151,12 +151,14 @@ void Swig_interface_propagate_methods(Node *n) { for (Node *child = firstChild(n); child; child = nextSibling(child)) { if (Getattr(child, "interface:owner")) break; // at the end of the list are newly appended methods - if (checkAttribute(child, "name", name)) { - String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl")); - identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0; - Delete(decl); - if (identically_overloaded_method) - break; + if (Cmp(nodeType(child), "cdecl") == 0) { + if (checkAttribute(child, "name", name)) { + String *decl = SwigType_typedef_resolve_all(Getattr(child, "decl")); + identically_overloaded_method = Strcmp(decl, this_decl_resolved) == 0; + Delete(decl); + if (identically_overloaded_method) + break; + } } } } From fbada9959c8412fd13ca858bca1918e3d5c33359 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 27 Aug 2017 11:11:32 +0100 Subject: [PATCH 0675/2031] Fix types when calling PyTuple_New Replace int with Py_ssize_t to fix warnings on Windows when using -O and/or -builtin. --- Lib/python/builtin.swg | 4 ++-- Source/Modules/python.cxx | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 4fd19471a..99903a9b5 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -393,10 +393,10 @@ SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) { SWIGINTERN void SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { - int base_count = 0; + Py_ssize_t base_count = 0; PyTypeObject **b; PyObject *tuple; - int i; + Py_ssize_t i; if (!bases[0]) { bases[0] = SwigPyObject_type(); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 64905bc21..9039f07ca 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2927,9 +2927,9 @@ public: Clear(f->def); if (overname) { if (noargs) { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL); + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **SWIGUNUSEDPARM(swig_obj)) {", NIL); } else { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL); + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL); } Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments); } else { @@ -3238,7 +3238,8 @@ public: DelWrapper(f); f = NewWrapper(); if (funpack) { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", int nobjs, PyObject **swig_obj) {", NIL); + // Note: funpack is currently always false for varargs + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); } From 175ab4e720266727f371e7f33381f2c6fecc5297 Mon Sep 17 00:00:00 2001 From: Jesse Rusak Date: Tue, 29 Aug 2017 11:00:23 -0400 Subject: [PATCH 0676/2031] Avoid possible GC issues in Java example code This prevents the previously-set element value from being collected before or during the call to setElement. Since C++ could still have a reference to during that time, it could lead to misbehavior. --- Doc/Manual/Java.html | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 85757d1cb..fd57fda25 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -8165,13 +8165,10 @@ public class Container { // Ensure that the GC doesn't collect any Element set from Java // as the underlying C++ class stores a shallow copy private Element elementReference; - private long getCPtrAndAddReference(Element element) { - elementReference = element; - return Element.getCPtr(element); - } public void setElement(Element e) { - exampleJNI.Container_setElement(swigCPtr, this, getCPtrAndAddReference(e), e); + exampleJNI.Container_setElement(swigCPtr, this, Element.getCPtr(e), e); + elementReference = e; } }
    @@ -8179,22 +8176,20 @@ public class Container {

    The following typemaps will generate the desired code. -The 'javain' typemap matches the input parameter type for the setElement method. +The 'javain' typemap matches the input parameter type for the setElement method and allows adding code after the call. The 'javacode' typemap simply adds in the specified code into the Java proxy class.

    -%typemap(javain) Element *e "getCPtrAndAddReference($javainput)"
    +%typemap(javain, 
    +         post="elementReference = $javainput;\n"
    +         ) Element *e "Element.getCPtr($javainput)"
     
     %typemap(javacode) Container %{
       // Ensure that the GC doesn't collect any element set from Java
       // as the underlying C++ class stores a shallow copy
       private Element elementReference;
    -  private long getCPtrAndAddReference(Element element) {
    -    elementReference = element;
    -    return Element.getCPtr(element);
    -  }
     %}
     
    From eeab1529016f34e6f2f8e6e95f8cb465d73d4d6a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Aug 2017 23:09:04 +0100 Subject: [PATCH 0677/2031] Fix support for member const function pointer variables Was not generating code that compiled when the variable was not a simple member pointer, for example, a const reference member pointer: short (Funcs::* const& cc7)(bool) const = cc1; --- Examples/test-suite/member_funcptr_galore.i | 22 +++++++++++- Source/CParse/parser.y | 39 +++++++++++++++------ Source/Swig/stype.c | 6 +++- Source/Swig/typeobj.c | 2 +- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i index 27d7a386a..01857ff1a 100644 --- a/Examples/test-suite/member_funcptr_galore.i +++ b/Examples/test-suite/member_funcptr_galore.i @@ -6,6 +6,12 @@ %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp3; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pp5; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra2; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra3; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc2; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc3; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc5; + %{ #if defined(__SUNPRO_CC) #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */ @@ -191,7 +197,7 @@ int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool)) const { return 0; } int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool)) const { return 0; } int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool)) const { return 0; } -// member function pointer variables +// member non-const function pointer variables short (Funcs::* pp1)(bool) = &Funcs::FF; short (Funcs::* const * extra2)(bool) = &pp1; @@ -204,4 +210,18 @@ short (Funcs::* *const& pp4)(bool) = extra4; short (Funcs::* & pp5)(bool) = pp1; short (Funcs::* const pp6)(bool) = &Funcs::FF; short (Funcs::* const& pp7)(bool) = pp1; + +// member const function pointer variables +short (Funcs::* cc1)(bool) const = &Funcs::CC; + +short (Funcs::* const * ccextra2)(bool) const = &cc1; +short (Funcs::* * ccextra3)(bool) const = &cc1; +short (Funcs::* *const ccextra4)(bool) const = &cc1; + +short (Funcs::* const *& cc2)(bool) const = ccextra2; +short (Funcs::* *& cc3)(bool) const = ccextra3; +short (Funcs::* *const& cc4)(bool) const = ccextra4; +short (Funcs::* & cc5)(bool) const = cc1; +short (Funcs::* const cc6)(bool) const = &Funcs::CC; +short (Funcs::* const& cc7)(bool) const = cc1; %} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 80ec8611e..bc12997be 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1432,22 +1432,39 @@ static void mark_nodes_as_extend(Node *n) { static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) { int is_pointer_to_member_function = 0; String *decl = Copy(type); + String *poppedtype = NewString(""); assert(qualifier); - if (SwigType_ismemberpointer(decl)) { - String *memberptr = SwigType_pop(decl); - if (SwigType_isfunction(decl)) { - assert(!SwigType_isqualifier(decl)); - SwigType_push(decl, qualifier); - SwigType_push(decl, memberptr); - is_pointer_to_member_function = 1; + + while (decl) { + if (SwigType_ismemberpointer(decl)) { + String *memberptr = SwigType_pop(decl); + if (SwigType_isfunction(decl)) { + is_pointer_to_member_function = 1; + SwigType_push(decl, qualifier); + SwigType_push(decl, memberptr); + Insert(decl, 0, poppedtype); + Delete(memberptr); + break; + } else { + Append(poppedtype, memberptr); + } + Delete(memberptr); } else { - Delete(decl); - decl = Copy(type); + String *popped = SwigType_pop(decl); + if (!popped) + break; + Append(poppedtype, popped); + Delete(popped); } - Delete(memberptr); } - if (!is_pointer_to_member_function) + + if (!is_pointer_to_member_function) { + Delete(decl); + decl = Copy(type); SwigType_push(decl, qualifier); + } + + Delete(poppedtype); return decl; } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 829005cd9..5cfa3e890 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -670,6 +670,7 @@ SwigType *SwigType_ltype(const SwigType *s) { int nelements, i; int firstarray = 1; int notypeconv = 0; + int memberpointer = 0; result = NewStringEmpty(); tc = Copy(s); @@ -707,13 +708,16 @@ SwigType *SwigType_ltype(const SwigType *s) { notypeconv = 1; } if (SwigType_isqualifier(element)) { - /* Do nothing. Ignore */ + if (memberpointer) + Append(result, element); + /* otherwise ignore */ } else if (SwigType_ispointer(element)) { Append(result, element); firstarray = 0; } else if (SwigType_ismemberpointer(element)) { Append(result, element); firstarray = 0; + memberpointer = 1; } else if (SwigType_isreference(element)) { if (notypeconv) { Append(result, element); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index b2832b6a9..5240927ef 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -48,7 +48,7 @@ * 'a(n).' = Array of size n [n] * 'f(..,..).' = Function with arguments (args) * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) - * 'm(qual).' = Pointer to member (qual::*) + * 'm(cls).' = Pointer to member (cls::*) * * The complete type representation for varargs is: * 'v(...)' From 1cf599bccb100f3bcda42f5f507ea32f99cd5f89 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 23 Aug 2017 09:07:12 +0100 Subject: [PATCH 0678/2031] Improve ref-qualifier implementation Internally, handle function ref-qualifiers in the function decl type string. Needed for a whole host of things to work like %feature and %rename. Add %feature %rename and %ignore testing for ref-qualifiers. --- Examples/test-suite/cpp11_ref_qualifiers.i | 82 ++++++++++++++++--- Examples/test-suite/errors/cpp_refqualifier.i | 4 + .../test-suite/errors/cpp_refqualifier.stderr | 12 +-- .../java/cpp11_ref_qualifiers_runme.java | 25 ++++++ .../python/cpp11_ref_qualifiers_runme.py | 31 +++++++ Source/CParse/parser.y | 20 +++-- Source/Modules/overload.cxx | 18 +++- Source/Swig/naming.c | 23 ++++-- Source/Swig/stype.c | 20 +++-- Source/Swig/swig.h | 1 + Source/Swig/typeobj.c | 81 ++++++++++++++++-- 11 files changed, 265 insertions(+), 52 deletions(-) diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i index fa1d68d0e..2115843a3 100644 --- a/Examples/test-suite/cpp11_ref_qualifiers.i +++ b/Examples/test-suite/cpp11_ref_qualifiers.i @@ -1,16 +1,76 @@ %module cpp11_ref_qualifiers -%inline %{ -class Host { -public: - void h1() & {} - void h2() const & {} - void h3() && {} - void h4() const && {} +%include - void h() & {} - void h() const & {} - void h() && {} - void h() const && {} +%ignore Host::h() const &; + +// Basic testing +%inline %{ +using std::string; +class Host { + string s; +public: + string h1() & { return string(); } + string h2() const & { return string(); } + string h3() && { return std::move(string()); } + string h4() const && { return std::move(string()); } + string h5() const { return string(); } + string h6() volatile const & { return string(); } + string h7() const volatile & { return string(); } + string h8() volatile const && { return std::move(string()); } + string h9() const volatile && { return std::move(string()); } + + string h() & { return string(); } + string h() const & { return string(); } + string h() && { return std::move(string()); } + string h() const && { return std::move(string()); } +}; +%} + +// %feature testing +%feature("except") F1() & %{ result = "F1"; %} +%feature("except") F2 %{ result = "F2"; %} +%feature("except") F3 %{ result = "F3"; %} +%feature("except") F3() %{ _should_not_be_used_ %} + +%feature("except") C1(int i) const & %{ result = "C1"; %} +%feature("except") C2 %{ result = "C2"; %} +%feature("except") C3 %{ result = "C3"; %} +%feature("except") C3(int i) %{ _should_not_be_used_ %} + +%inline %{ +struct Features { + string F1() & { return string(); } + string F2() & { return string(); } + string F3() & { return string(); } + + string C1(int i) const & { return string(); } + string C2(int i) const & { return string(); } + string C3(int i) const & { return string(); } +}; +%} + +// %rename testing +%rename(RR1) R1; +%rename(RR2) R2() &; +%rename(RR3) R3; +%rename(RR3Bad) R3(); + +%rename(SS1) S1; +%rename(SS2) S2(int i) const &; +%rename(SS3) S3; +%rename(SS3Bad) S3(int i); +%rename(SS3BadConst) S3(int i) const; +%rename(SS3BadLValue) S3(int i) &; + +%inline %{ +struct Renames { + string R1() & { return string(); } + string R2() & { return string(); } + string R3() & { return string(); } + + string S1(int i) const & { return string(); } + string S2(int i) const & { return string(); } + string S3(int i) const & { return string(); } }; %} diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i index 1cbcd936d..438aacd93 100644 --- a/Examples/test-suite/errors/cpp_refqualifier.i +++ b/Examples/test-suite/errors/cpp_refqualifier.i @@ -1,6 +1,8 @@ %module cpp_refqualifier %ignore Host::h_ignored; +%ignore Host::i_ignored() &&; +%ignore Host::j_ignored() const &&; class Host { public: @@ -15,4 +17,6 @@ public: void h() const &&; void h_ignored() &&; + void i_ignored() &&; + void j_ignored() const &&; }; diff --git a/Examples/test-suite/errors/cpp_refqualifier.stderr b/Examples/test-suite/errors/cpp_refqualifier.stderr index 866d9b530..ea2cd220a 100644 --- a/Examples/test-suite/errors/cpp_refqualifier.stderr +++ b/Examples/test-suite/errors/cpp_refqualifier.stderr @@ -1,6 +1,6 @@ -cpp_refqualifier.i:9: Warning 405: Method with rvalue ref-qualifier ignored h3() &&. -cpp_refqualifier.i:10: Warning 405: Method with rvalue ref-qualifier ignored h4() const &&. -cpp_refqualifier.i:14: Warning 405: Method with rvalue ref-qualifier ignored h() &&. -cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&. -cpp_refqualifier.i:13: Warning 512: Overloaded method Host::h() const & ignored, -cpp_refqualifier.i:12: Warning 512: using non-const method Host::h() & instead. +cpp_refqualifier.i:11: Warning 405: Method with rvalue ref-qualifier h3() && ignored. +cpp_refqualifier.i:12: Warning 405: Method with rvalue ref-qualifier h4() const && ignored. +cpp_refqualifier.i:16: Warning 405: Method with rvalue ref-qualifier h() && ignored. +cpp_refqualifier.i:17: Warning 405: Method with rvalue ref-qualifier h() const && ignored. +cpp_refqualifier.i:15: Warning 512: Overloaded method Host::h() const & ignored, +cpp_refqualifier.i:14: Warning 512: using non-const method Host::h() & instead. diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java index 49afe8039..bbe6be8e3 100644 --- a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java +++ b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java @@ -14,9 +14,34 @@ public class cpp11_ref_qualifiers_runme { public static void main(String argv[]) { Host h = new Host(); + + // Basic testing h.h1(); h.h2(); + h.h6(); + h.h7(); + h.h(); + + // %feature testing + Features f = new Features(); + if (!f.F1().equals("F1")) throw new RuntimeException("Fail"); + if (!f.F2().equals("F2")) throw new RuntimeException("Fail"); + if (!f.F3().equals("F3")) throw new RuntimeException("Fail"); + + if (!f.C1(0).equals("C1")) throw new RuntimeException("Fail"); + if (!f.C2(0).equals("C2")) throw new RuntimeException("Fail"); + if (!f.C3(0).equals("C3")) throw new RuntimeException("Fail"); + + // %rename testing + Renames r = new Renames(); + r.RR1(); + r.RR2(); + r.RR3(); + + r.SS1(0); + r.SS2(0); + r.SS3(0); } } diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py index 24ce1d2bf..47c474218 100644 --- a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py +++ b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py @@ -1,6 +1,37 @@ import cpp11_ref_qualifiers h = cpp11_ref_qualifiers.Host() + +# Basic testing h.h1() h.h2() +h.h6() +h.h7() + h.h() + +# %feature testing +f = cpp11_ref_qualifiers.Features() +if f.F1() != "F1": + raise RuntimeException("Fail") +if f.F2() != "F2": + raise RuntimeException("Fail") +if f.F3() != "F3": + raise RuntimeException("Fail") + +if f.C1(0) != "C1": + raise RuntimeException("Fail") +if f.C2(0) != "C2": + raise RuntimeException("Fail") +if f.C3(0) != "C3": + raise RuntimeException("Fail") + +# %rename testing +r = cpp11_ref_qualifiers.Renames() +r.RR1() +r.RR2() +r.RR3() + +r.SS1(0) +r.SS2(0) +r.SS3(0) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index bc12997be..ccb09e3eb 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -487,16 +487,16 @@ static void add_symbols(Node *n) { } { String *refqualifier = Getattr(n, "refqualifier"); - if (SwigType_isrvalue_reference(refqualifier) && strncmp(Char(symname), "$ignore", 7) != 0) { + if (SwigType_isrvalue_reference(refqualifier) && Strcmp(symname, "$ignore") != 0) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED, Getfile(n), Getline(n), - "Method with rvalue ref-qualifier ignored %s.\n", Swig_name_decl(n)); + "Method with rvalue ref-qualifier %s ignored.\n", Swig_name_decl(n)); SWIG_WARN_NODE_END(n); SetFlag(n, "feature:ignore"); } } } - if (only_csymbol || GetFlag(n,"feature:ignore") || strncmp(Char(symname),"$ignore",7) == 0) { + if (only_csymbol || GetFlag(n, "feature:ignore") || Strncmp(symname, "$ignore", 7) == 0) { /* Only add to C symbol table and continue */ Swig_symbol_add(0, n); if (!only_csymbol && !GetFlag(n, "feature:ignore")) { @@ -1421,10 +1421,12 @@ static void mark_nodes_as_extend(Node *n) { } /* ----------------------------------------------------------------------------- - * add_qualifier_to_declarator + * add_qualifier_to_declarator() * + * Normally the qualifier is pushed on to the front of the type. * Adding a qualifier to a pointer to member function is a special case. * For example : typedef double (Cls::*pmf)(void) const; + * The qualifier is : q(const). * The declarator is : m(Cls).f(void). * We need : m(Cls).q(const).f(void). * ----------------------------------------------------------------------------- */ @@ -5870,15 +5872,17 @@ pointer : STAR type_qualifier pointer { /* cv-qualifier plus C++11 ref-qualifier for non-static member functions */ cv_ref_qualifier : type_qualifier { $$.qualifier = $1; - $$.refqualifier = 0; + $$.refqualifier = 0; } | type_qualifier ref_qualifier { $$.qualifier = $1; - $$.refqualifier = $2; + $$.refqualifier = $2; + SwigType_push($$.qualifier, $2); } | ref_qualifier { - $$.qualifier = 0; - $$.refqualifier = $1; + $$.qualifier = NewStringEmpty(); + $$.refqualifier = $1; + SwigType_push($$.qualifier, $1); } ; diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 330294efd..81d1bb000 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -231,9 +231,21 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { } if (!differ) { /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n, "decl"); - String *d2 = Getattr(nodes[j].n, "decl"); - if (d1 && d2) { + String *decl1 = Getattr(nodes[i].n, "decl"); + String *decl2 = Getattr(nodes[j].n, "decl"); + if (decl1 && decl2) { + /* Remove ref-qualifiers. Note that rvalue ref-qualifiers are already ignored and + * it is illegal to overload a function with and without ref-qualifiers. So with + * all the combinations of ref-qualifiers and cv-qualifiers, we just detect + * the cv-qualifier (const) overloading. */ + String *d1 = Copy(decl1); + String *d2 = Copy(decl2); + if (SwigType_isreference(d1) || SwigType_isrvalue_reference(d1)) { + Delete(SwigType_pop(d1)); + } + if (SwigType_isreference(d2) || SwigType_isrvalue_reference(d2)) { + Delete(SwigType_pop(d2)); + } String *dq1 = Copy(d1); String *dq2 = Copy(d2); if (SwigType_isconst(d1)) { diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 4fa32538f..d12770125 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1689,18 +1689,23 @@ String *Swig_name_str(Node *n) { String *Swig_name_decl(Node *n) { String *qname; String *decl; - String *refqualifier = Getattr(n, "refqualifier"); qname = Swig_name_str(n); + decl = NewStringf("%s", qname); - if (checkAttribute(n, "kind", "variable")) - decl = NewStringf("%s", qname); - else - decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : ""); - if (refqualifier) { - String *rq = SwigType_str(refqualifier, 0); - Printv(decl, " ", rq, NIL); - Delete(rq); + if (!checkAttribute(n, "kind", "variable")) { + String *d = Getattr(n, "decl"); + Printv(decl, "(", ParmList_errorstr(Getattr(n, "parms")), ")", NIL); + if (SwigType_isfunction(d)) { + SwigType *decl_temp = Copy(d); + SwigType *qualifiers = SwigType_pop_function_qualifiers(decl_temp); + if (qualifiers) { + String *qualifiers_string = SwigType_str(qualifiers, 0); + Printv(decl, " ", qualifiers_string, NIL); + Delete(qualifiers_string); + } + Delete(decl_temp); + } } Delete(qname); diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 5cfa3e890..4b745b335 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -44,7 +44,7 @@ * 'z.' = Rvalue reference (&&) * 'a(n).' = Array of size n [n] * 'f(..,..).' = Function with arguments (args) - * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) + * 'q(str).' = Qualifier, such as const or volatile (cv-qualifier) * 'm(cls).' = Pointer to member (cls::*) * * The encoding follows the order that you might describe a type in words. @@ -64,11 +64,19 @@ * * More examples: * - * String Encoding C++ Example - * --------------- ----------- - * p.f(bool).q(const).long const long (*)(bool) - * m(Funcs).q(const).f(bool).long long (Funcs::*)(bool) const - * r.q(const).m(Funcs).f(int).long long (Funcs::*const &)(int) + * String Encoding C++ Example + * --------------- ----------- + * p.f(bool).r.q(const).long const long & (*)(bool) + * m(Funcs).q(const).f(bool).long long (Funcs::*)(bool) const + * r.q(const).m(Funcs).f(int).long long (Funcs::*const &)(int) + * m(Funcs).z.q(const).f(bool).long long (Funcs::*)(bool) const && + * + * Function decl examples: + * + * f(bool). long a(bool); + * r.f(bool). long b(bool) &; + * z.f(bool). long c(bool) &&; + * z.q(const).f(bool). long d(bool) const &&; * * For the most part, this module tries to minimize the use of special * characters (*, [, <, etc...) in its type encoding. One reason for this diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 0bcd53a66..7452c374c 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -136,6 +136,7 @@ extern "C" { extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms); extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms); extern SwigType *SwigType_pop_function(SwigType *t); + extern SwigType *SwigType_pop_function_qualifiers(SwigType *t); extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node); extern List *SwigType_split(const SwigType *t); extern String *SwigType_pop(SwigType *t); diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 5240927ef..7a0626c29 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -43,11 +43,11 @@ * All type constructors are denoted by a trailing '.': * * 'p.' = Pointer (*) - * 'r.' = Reference (&) - * 'z.' = Rvalue reference (&&) + * 'r.' = Reference or ref-qualifier (&) + * 'z.' = Rvalue reference or ref-qualifier (&&) * 'a(n).' = Array of size n [n] * 'f(..,..).' = Function with arguments (args) - * 'q(str).' = Qualifier (such as const or volatile) (const, volatile) + * 'q(str).' = Qualifier, such as const or volatile (cv-qualifier) * 'm(cls).' = Pointer to member (cls::*) * * The complete type representation for varargs is: @@ -183,9 +183,10 @@ SwigType *SwigType_del_element(SwigType *t) { * SwigType_pop() * * Pop one type element off the type. - * Example: t in: q(const).p.Integer - * t out: p.Integer - * result: q(const). + * For example: + * t in: q(const).p.Integer + * t out: p.Integer + * result: q(const). * ----------------------------------------------------------------------------- */ SwigType *SwigType_pop(SwigType *t) { @@ -771,7 +772,6 @@ SwigType *SwigType_array_type(const SwigType *ty) { * Functions * * SwigType_add_function() - * SwigType_del_function() * SwigType_isfunction() * SwigType_pop_function() * @@ -795,14 +795,36 @@ SwigType *SwigType_add_function(SwigType *t, ParmList *parms) { return t; } +/* ----------------------------------------------------------------------------- + * SwigType_pop_function() + * + * Pop and return the function from the input type leaving the function's return + * type, if any. + * For example: + * t in: q(const).f().p. + * t out: p. + * result: q(const).f(). + * ----------------------------------------------------------------------------- */ + SwigType *SwigType_pop_function(SwigType *t) { SwigType *f = 0; SwigType *g = 0; char *c = Char(t); - if (strncmp(c, "q(", 2) == 0) { + if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) { + /* Remove ref-qualifier */ f = SwigType_pop(t); c = Char(t); } + if (strncmp(c, "q(", 2) == 0) { + /* Remove cv-qualifier */ + String *qual = SwigType_pop(t); + if (f) { + SwigType_push(qual, f); + Delete(f); + } + f = qual; + c = Char(t); + } if (strncmp(c, "f(", 2)) { printf("Fatal error. SwigType_pop_function applied to non-function.\n"); abort(); @@ -814,14 +836,55 @@ SwigType *SwigType_pop_function(SwigType *t) { return g; } +/* ----------------------------------------------------------------------------- + * SwigType_pop_function_qualifiers() + * + * Pop and return the function qualifiers from the input type leaving the rest of + * function declaration. Returns NULL if no qualifiers. + * For example: + * t in: r.q(const).f().p. + * t out: f().p. + * result: r.q(const) + * ----------------------------------------------------------------------------- */ + +SwigType *SwigType_pop_function_qualifiers(SwigType *t) { + SwigType *qualifiers = 0; + char *c = Char(t); + if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) { + /* Remove ref-qualifier */ + String *qual = SwigType_pop(t); + qualifiers = qual; + c = Char(t); + } + if (strncmp(c, "q(", 2) == 0) { + /* Remove cv-qualifier */ + String *qual = SwigType_pop(t); + if (qualifiers) { + SwigType_push(qual, qualifiers); + Delete(qualifiers); + } + qualifiers = qual; + c = Char(t); + } + assert(strncmp(c, "f(", 2) == 0); + + return qualifiers; +} + int SwigType_isfunction(const SwigType *t) { char *c; if (!t) { return 0; } c = Char(t); + if (strncmp(c, "r.", 2) == 0 || strncmp(c, "z.", 2) == 0) { + /* Might be a function with a ref-qualifier, skip over */ + c += 2; + if (!*c) + return 0; + } if (strncmp(c, "q(", 2) == 0) { - /* Might be a 'const' function. Try to skip over the 'const' */ + /* Might be a function with a cv-qualifier, skip over */ c = strchr(c, '.'); if (c) c++; From 8a40327aa8f75af9d5c68bfee1125be4544f2865 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Aug 2017 19:08:09 +0100 Subject: [PATCH 0679/2031] Add unignore for rvalue ref-qualifiers Use std::move on this pointer as the default approach to supporting rvalue ref-qualifiers if a user really wants to wrap. std::move requires headers so add swigfragments.swg for all languages to use common fragments. Just header file fragments for now. --- Examples/test-suite/common.mk | 1 + .../cpp11_ref_qualifiers_rvalue_unignore.i | 15 ++++ Examples/test-suite/errors/cpp_refqualifier.i | 8 +- ..._ref_qualifiers_rvalue_unignore_runme.java | 20 +++++ ...11_ref_qualifiers_rvalue_unignore_runme.py | 4 + Lib/swig.swg | 4 +- Lib/swigfragments.swg | 86 +++++++++++++++++++ Lib/typemaps/fragments.swg | 69 --------------- Source/CParse/parser.y | 7 +- Source/Swig/cwrap.c | 9 ++ 10 files changed, 149 insertions(+), 74 deletions(-) create mode 100644 Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i create mode 100644 Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java create mode 100644 Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py create mode 100644 Lib/swigfragments.swg diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index b47b6e33b..0d0a32c8c 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -562,6 +562,7 @@ CPP11_TEST_CASES += \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ cpp11_ref_qualifiers \ + cpp11_ref_qualifiers_rvalue_unignore \ cpp11_result_of \ cpp11_rvalue_reference \ cpp11_rvalue_reference2 \ diff --git a/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i b/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i new file mode 100644 index 000000000..2f5fadfc6 --- /dev/null +++ b/Examples/test-suite/cpp11_ref_qualifiers_rvalue_unignore.i @@ -0,0 +1,15 @@ +%module cpp11_ref_qualifiers_rvalue_unignore + +// This is a minimal test that does not include any C++ headers to make sure the required +// header is generated from a fragment for the generated std::move call + +// m1 and m2 are ignored by default, unignore them +%feature("ignore", "0") RefQualifier::m1() &&; +%feature("ignore", "0") RefQualifier::m2() const &&; + +%inline %{ +struct RefQualifier { + void m1() && {} + void m2() const && {} +}; +%} diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i index 438aacd93..afd6632fc 100644 --- a/Examples/test-suite/errors/cpp_refqualifier.i +++ b/Examples/test-suite/errors/cpp_refqualifier.i @@ -18,5 +18,11 @@ public: void h_ignored() &&; void i_ignored() &&; - void j_ignored() const &&; + void i_ignored() &&; +}; + +%feature("ignore", "0") Unignore::k_unignored() const &&; + +struct Unignore { + void k_unignored() const &&; }; diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java new file mode 100644 index 000000000..bbbe6f788 --- /dev/null +++ b/Examples/test-suite/java/cpp11_ref_qualifiers_rvalue_unignore_runme.java @@ -0,0 +1,20 @@ + +import cpp11_ref_qualifiers_rvalue_unignore.*; + +public class cpp11_ref_qualifiers_rvalue_unignore_runme { + + static { + try { + System.loadLibrary("cpp11_ref_qualifiers_rvalue_unignore"); + } 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[]) { + new RefQualifier().m1(); + new RefQualifier().m2(); + } +} + diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py new file mode 100644 index 000000000..6352c79c2 --- /dev/null +++ b/Examples/test-suite/python/cpp11_ref_qualifiers_rvalue_unignore_runme.py @@ -0,0 +1,4 @@ +import cpp11_ref_qualifiers_rvalue_unignore + +cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m1() +cpp11_ref_qualifiers_rvalue_unignore.RefQualifier().m2() diff --git a/Lib/swig.swg b/Lib/swig.swg index 6f48f0d20..6dc215dcf 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -309,11 +309,13 @@ static int NAME(TYPE x) { %define %$classname %$ismember,"match$parentNode$name" %enddef %define %$isnested "match$nested"="1" %enddef + /* ----------------------------------------------------------------------------- - * Include all the warnings labels and macros + * Common includes for warning labels, macros, fragments etc * ----------------------------------------------------------------------------- */ %include +%include /* ----------------------------------------------------------------------------- * Overloading support diff --git a/Lib/swigfragments.swg b/Lib/swigfragments.swg new file mode 100644 index 000000000..63bb6c8f4 --- /dev/null +++ b/Lib/swigfragments.swg @@ -0,0 +1,86 @@ +/* ----------------------------------------------------------------------------- + * swigfragments.swg + * + * Common fragments + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Fragments for C header files + * ----------------------------------------------------------------------------- */ + +%fragment("", "header") %{ +#include +%} + +/* Default compiler options for gcc allow long_long but not LLONG_MAX. + * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */ +%fragment("", "header") %{ +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif +%} + +%fragment("", "header") %{ +#include +%} + +%fragment("", "header") %{ +#include +%} + +%fragment("", "header") %{ +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif +%} + +%fragment("", "header") %{ +#include +#ifdef _MSC_VER +# ifndef strtoull +# define strtoull _strtoui64 +# endif +# ifndef strtoll +# define strtoll _strtoi64 +# endif +#endif +%} + +%fragment("", "header") %{ +#include +#include +#ifndef WCHAR_MIN +# define WCHAR_MIN 0 +#endif +#ifndef WCHAR_MAX +# define WCHAR_MAX 65535 +#endif +%} + +/* ----------------------------------------------------------------------------- + * Fragments for C++ header files + * ----------------------------------------------------------------------------- */ + +%fragment("", "header") %{ +#include +%} + +%fragment("", "header") %{ +#include +%} + +%fragment("", "header") %{ +#include +%} + +%fragment("", "header") %{ +#include +%} diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 3f33ca98d..aaf948c05 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -96,75 +96,6 @@ * common fragments * ------------------------------------------------------------ */ -/* Default compiler options for gcc allow long_long but not LLONG_MAX. - * Define SWIG_NO_LLONG_MAX if this added limits support is not wanted. */ -%fragment("","header") %{ -#include -#if !defined(SWIG_NO_LLONG_MAX) -# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) -# define LLONG_MAX __LONG_LONG_MAX__ -# define LLONG_MIN (-LLONG_MAX - 1LL) -# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) -# endif -#endif -%} - -%fragment("","header") %{ -#include -%} - -%fragment("","header") %{ -#include -#include -#ifndef WCHAR_MIN -# define WCHAR_MIN 0 -#endif -#ifndef WCHAR_MAX -# define WCHAR_MAX 65535 -#endif -%} - -%fragment("","header") %{ -#include -%} - -%fragment("","header") %{ -#include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# ifndef snprintf -# define snprintf _snprintf -# endif -#endif -%} - -%fragment("","header") %{ -#include -#ifdef _MSC_VER -# ifndef strtoull -# define strtoull _strtoui64 -# endif -# ifndef strtoll -# define strtoll _strtoi64 -# endif -#endif -%} - -%fragment("", "header") %{ -#include -%} - -%fragment("", "header") %{ -#include -%} - -%fragment("", "header") %{ -#include -%} - -%fragment("", "header") %{ -#include -%} - %fragment("SWIG_isfinite","header",fragment=",") %{ /* Getting isfinite working pre C99 across multiple platforms is non-trivial. Users can provide SWIG_isfinite on older platforms. */ #ifndef SWIG_isfinite diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index ccb09e3eb..3e0fd3282 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -485,9 +485,10 @@ static void add_symbols(Node *n) { SetFlag(n,"deleted"); SetFlag(n,"feature:ignore"); } - { - String *refqualifier = Getattr(n, "refqualifier"); - if (SwigType_isrvalue_reference(refqualifier) && Strcmp(symname, "$ignore") != 0) { + if (SwigType_isrvalue_reference(Getattr(n, "refqualifier"))) { + /* Ignore rvalue ref-qualifiers by default + * Use Getattr instead of GetFlag to handle explicit ignore and explicit not ignore */ + if (!(Getattr(n, "feature:ignore") || Strncmp(symname, "$ignore", 7) == 0)) { SWIG_WARN_NODE_BEGIN(n); Swig_warning(WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED, Getfile(n), Getline(n), "Method with rvalue ref-qualifier %s ignored.\n", Swig_name_decl(n)); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 4c3135e3a..d6e5e0cdc 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -1024,6 +1024,15 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas } } + if (!self && SwigType_isrvalue_reference(Getattr(n, "refqualifier"))) { + String *memory_header = NewString(""); + Setfile(memory_header, Getfile(n)); + Setline(memory_header, Getline(n)); + Swig_fragment_emit(memory_header); + self = NewString("std::move(*this)."); + Delete(memory_header); + } + call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type); cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call); From 330ef362f483fc999b6f4045ab85c0897c361352 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Aug 2017 22:52:56 +0100 Subject: [PATCH 0680/2031] Add docs for C++11 ref-qualifiers --- CHANGES.current | 23 +++++++++ Doc/Manual/CPlusPlus11.html | 100 ++++++++++++++++++++++++++++++++++++ Doc/Manual/Contents.html | 1 + Doc/Manual/SWIGPlus.html | 28 ++++++++-- Doc/Manual/Typemaps.html | 4 +- 5 files changed, 150 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 0629dfbb6..79c7df479 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,29 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-08-25: wsfulton + Issue #1059. Add support for C++11 ref-qualifiers on non-static member functions. + Members with lvalue ref-qualifiers such as: + + struct RQ { + void m1(int x) &; + void m2(int x) const &; + }; + + are wrapped like any other member function. Member functions with rvalue ref-qualifiers + are ignored by default, such as: + + struct RQ { + void m3(int x) &&; + void m4(int x) const &&; + }; + + example.i:7: Warning 405: Method with rvalue ref-qualifier m3(int) && ignored. + example.i:8: Warning 405: Method with rvalue ref-qualifier m4(int) const && ignored. + + These can be unignored and exposed to the target language, see further documentation in + CPlusPlus11.html. + 2017-08-16: wsfulton Fix #1063. Add using declarations to templates into typedef table. diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index e4dff6543..f9281bd56 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -42,6 +42,7 @@
  • Exception specifications and noexcept
  • Control and query object alignment
  • Attributes +
  • Methods with ref-qualifiers
  • Standard library changes
      @@ -971,6 +972,104 @@ int [[attr1]] i [[attr2, attr3]]; [[noreturn, nothrow]] void f [[noreturn]] ();
  • + +

    7.2.29 Methods with ref-qualifiers

    + + +

    +C++11 non-static member functions can be declared with ref-qualifiers. +Member functions declared with a & lvalue ref-qualifiers are wrapped like any other function without ref-qualifiers. +Member functions declared with a && rvalue ref-qualifiers are ignored by default +as they are unlikely to be required from non-C++ languages where the concept of rvalue-ness +for the implied *this pointer does not apply. +The warning is hidden by default, but can be displayed as described in the section on Enabling extra warnings. +

    + +

    +Consider: +

    + +
    +struct RQ {
    +  void m1(int x) &;
    +  void m2(int x) &&;
    +};
    +
    + +

    +The only wrapped method will be the lvalue ref-qualified method m1 +and if SWIG is run with the -Wextra command-line option, the following warning will be issued indicating m2 is not wrapped: +

    + +
    +
    +example.i:7: Warning 405: Method with rvalue ref-qualifier m2(int) && ignored.
    +
    +
    + +

    +If you unignore the method as follows, wrappers for m2 will be generated: +

    + +
    +%feature("ignore", "0") RQ::m2(int x) &&;
    +struct RQ {
    +  void m1(int x) &;
    +  void m2(int x) &&;
    +};
    +
    + +

    +Inspection of the generated C++ code, will show that std::move is used on the instance +of the RQ * class: +

    + +
    +  RQ *arg1 = (RQ *) 0 ;
    +  int arg2 ;
    +
    +  arg1 = ...marshalled from target language...
    +  arg2 = ...marshalled from target language...
    +
    +  std::move(*arg1).m2(arg2);
    +
    + +

    +This will compile but when run, the move effects may not be what you want. +As stated earlier, rvalue ref-qualifiers aren't really applicable outside the world of C++. +However, if you really know what you are doing, full control over the call to the method is +possible via the low-level "action" feature. +This feature completely replaces the call to the underlying function, that is, the last line in the snippet of code above. +

    + +
    +%feature("ignore", "0") RQ::m2(int x) &&;
    +%feature("action") RQ::m2(int x) && %{
    +  RQ().m2(arg2);
    +%}
    +struct RQ {
    +  void m1(int x) &;
    +  void m2(int x) &&;
    +};
    +
    + +

    +resulting in: +

    + +
    +  RQ *arg1 = (RQ *) 0 ;
    +  int arg2 ;
    +
    +  arg1 = ...marshalled from target language...
    +  arg2 = ...marshalled from target language...
    +
    +  RQ().m2(arg2);
    +
    + +

    +Compatibility note: SWIG-4.0.0 was the first version to support ref-qualifiers. +

    7.3 Standard library changes

    @@ -1177,5 +1276,6 @@ Phew, that is a lot of hard work to get a callback working. You could just go with the more attractive option of just using double as the return type in the function declaration instead of result_of!

    + diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 3d9f6fd3b..b879eaa04 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -310,6 +310,7 @@
  • Exception specifications and noexcept
  • Control and query object alignment
  • Attributes +
  • Methods with ref-qualifiers
  • Standard library changes
      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 57da73d31..f64de15e3 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2409,8 +2409,8 @@ the first renaming rule found on a depth-first traversal of the class hierarchy is used. -
    • The name matching rules strictly follow member qualification rules. -For example, if you have a class like this:

      +
    • The name matching rules strictly follow member qualifier rules. +For example, if you have a class and member with a member that is const qualified like this:

      @@ -2434,7 +2434,7 @@ the declaration
       

      -will not apply as there is no unqualified member bar(). The following will apply as +will not apply as there is no unqualified member bar(). The following will apply the rename as the qualifier matches correctly:

      @@ -2444,6 +2444,26 @@ the qualifier matches correctly: +

      +Similarly for combinations of cv-qualifiers and ref-qualifiers, all the qualifiers must be specified to match correctly: +

      + +
      +
      +%rename(name) Jam::bar();          // will not match
      +%rename(name) Jam::bar() &;        // will not match
      +%rename(name) Jam::bar() const;    // will not match
      +%rename(name) Jam::bar() const &;  // ok, will match
      +
      +class Jam {
      +public:
      +  ...
      +  void bar() const &;
      +  ...
      +};
      +
      +
      +

      An often overlooked C++ feature is that classes can define two different overloaded members that differ only in their qualifiers, like this: @@ -2476,7 +2496,7 @@ For example we can give them separate names in the target language:

      Similarly, if you merely wanted to ignore one of the declarations, use %ignore -with the full qualification. For example, the following directive +with the full qualifier. For example, the following directive would tell SWIG to ignore the const version of bar() above:

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index f274c9293..eeabdd89a 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -4021,7 +4021,7 @@ struct X { Forced inclusion of fragments can be used as a replacement for code insertion block, ensuring the code block is only generated once. Consider the contents of FileA.i below which first uses a code insertion block and then a forced fragment inclusion to generate code: -

      +

       // FileA.i
      @@ -4058,7 +4058,7 @@ The resulting code in the wrappers for FileB.i is:
       

      A note of caution must be mentioned when using %fragment forced inclusion or code insertion blocks with %import. If %import is used instead: -

      +

      
      From c9d425604c58a9c862b562ffffd260f6647b08c2 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 26 Aug 2017 14:00:44 +0100
      Subject: [PATCH 0681/2031] Re-organise parser grammar for declarator and
       initializer rules
      
      Step 1 to make these closer to the definitions used in the standard.
      The initializer rule should not include qualifiers and exception specification.
      
      - split cpp_const into add qualifiers_exception_specification and empty rules
      - simplify initializer to use new qualifiers_exception_specification rule
      ---
       Source/CParse/parser.y | 37 +++++++++++++------------------------
       1 file changed, 13 insertions(+), 24 deletions(-)
      
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index 3e0fd3282..4c73b8a25 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -1591,7 +1591,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
       
       /* Misc */
       %type        identifier;
      -%type     initializer cpp_const exception_specification cv_ref_qualifier;
      +%type     initializer cpp_const exception_specification cv_ref_qualifier qualifiers_exception_specification;
       %type        storage_class extern_string;
       %type        parms  ptail rawparms varargs_parms ;
       %type        templateparameters templateparameterstail;
      @@ -3268,38 +3268,22 @@ c_decl_tail    : SEMI {
                      }
                     ;
       
      -initializer   : def_args { 
      -                   $$ = $1; 
      +initializer   : def_args {
      +                   $$ = $1;
                          $$.qualifier = 0;
                          $$.refqualifier = 0;
       		   $$.throws = 0;
       		   $$.throwf = 0;
       		   $$.nexcept = 0;
                     }
      -              | cv_ref_qualifier def_args {
      -                   $$ = $2; 
      -		   $$.qualifier = $1.qualifier;
      -		   $$.refqualifier = $1.refqualifier;
      -		   $$.throws = 0;
      -		   $$.throwf = 0;
      -		   $$.nexcept = 0;
      -	      }
      -              | exception_specification def_args { 
      -		   $$ = $2; 
      -                   $$.qualifier = 0;
      -                   $$.refqualifier = 0;
      +              | qualifiers_exception_specification def_args {
      +                   $$ = $2;
      +                   $$.qualifier = $1.qualifier;
      +                   $$.refqualifier = $1.refqualifier;
       		   $$.throws = $1.throws;
       		   $$.throwf = $1.throwf;
       		   $$.nexcept = $1.nexcept;
                     }
      -              | cv_ref_qualifier exception_specification def_args {
      -                   $$ = $3; 
      -                   $$.qualifier = $1.qualifier;
      -		   $$.refqualifier = $1.refqualifier;
      -		   $$.throws = $2.throws;
      -		   $$.throwf = $2.throwf;
      -		   $$.nexcept = $2.nexcept;
      -              }
                     ;
       
       cpp_alternate_rettype : primitive_type { $$ = $1; }
      @@ -6688,7 +6672,7 @@ exception_specification : THROW LPAREN parms RPAREN {
       	       }
       	       ;	
       
      -cpp_const      : cv_ref_qualifier {
      +qualifiers_exception_specification : cv_ref_qualifier {
                           $$.throws = 0;
                           $$.throwf = 0;
                           $$.nexcept = 0;
      @@ -6705,6 +6689,11 @@ cpp_const      : cv_ref_qualifier {
                           $$.qualifier = $1.qualifier;
                           $$.refqualifier = $1.refqualifier;
                      }
      +               ;
      +
      +cpp_const      : qualifiers_exception_specification {
      +                    $$ = $1;
      +               }
                      | empty { 
                           $$.throws = 0;
                           $$.throwf = 0;
      
      From 8227c02267b1bc54e88c714251e2052260810650 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 26 Aug 2017 23:23:54 +0100
      Subject: [PATCH 0682/2031] Re-organise parser grammar for initializer rules
      
      Simply split initializer into const_cpp and initializer
      ---
       Source/CParse/parser.y | 73 +++++++++++++++++-------------------------
       1 file changed, 30 insertions(+), 43 deletions(-)
      
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index 4c73b8a25..b999a3796 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -3090,7 +3090,7 @@ c_declaration   : c_decl {
          A C global declaration of some kind (may be variable, function, typedef, etc.)
          ------------------------------------------------------------ */
       
      -c_decl  : storage_class type declarator initializer c_decl_tail {
      +c_decl  : storage_class type declarator cpp_const initializer c_decl_tail {
       	      String *decl = $3.type;
                     $$ = new_node("cdecl");
       	      if ($4.qualifier)
      @@ -3101,26 +3101,26 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
       	      Setattr($$,"name",$3.id);
       	      Setattr($$,"decl",decl);
       	      Setattr($$,"parms",$3.parms);
      -	      Setattr($$,"value",$4.val);
      +	      Setattr($$,"value",$5.val);
       	      Setattr($$,"throws",$4.throws);
       	      Setattr($$,"throw",$4.throwf);
       	      Setattr($$,"noexcept",$4.nexcept);
      -	      if ($4.val && $4.type) {
      +	      if ($5.val && $5.type) {
       		/* store initializer type as it might be different to the declared type */
      -		SwigType *valuetype = NewSwigType($4.type);
      +		SwigType *valuetype = NewSwigType($5.type);
       		if (Len(valuetype) > 0)
       		  Setattr($$,"valuetype",valuetype);
       		else
       		  Delete(valuetype);
       	      }
      -	      if (!$5) {
      +	      if (!$6) {
       		if (Len(scanner_ccode)) {
       		  String *code = Copy(scanner_ccode);
       		  Setattr($$,"code",code);
       		  Delete(code);
       		}
       	      } else {
      -		Node *n = $5;
      +		Node *n = $6;
       		/* Inherit attributes */
       		while (n) {
       		  String *type = Copy($2);
      @@ -3130,8 +3130,8 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
       		  Delete(type);
       		}
       	      }
      -	      if ($4.bitfield) {
      -		Setattr($$,"bitfield", $4.bitfield);
      +	      if ($5.bitfield) {
      +		Setattr($$,"bitfield", $5.bitfield);
       	      }
       
       	      if ($3.id) {
      @@ -3146,18 +3146,18 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
       		      String *lstr = Swig_scopename_last($3.id);
       		      Setattr($$, "name", lstr);
       		      Delete(lstr);
      -		      set_nextSibling($$, $5);
      +		      set_nextSibling($$, $6);
       		    } else {
       		      Delete($$);
      -		      $$ = $5;
      +		      $$ = $6;
       		    }
       		    Delete(p);
       		  } else {
       		    Delete($$);
      -		    $$ = $5;
      +		    $$ = $6;
       		  }
       		} else {
      -		  set_nextSibling($$, $5);
      +		  set_nextSibling($$, $6);
       		}
       	      } else {
       		Swig_error(cparse_file, cparse_line, "Missing symbol name for global declaration\n");
      @@ -3166,7 +3166,7 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
                  }
                  /* Alternate function syntax introduced in C++11:
                     auto funcName(int x, int y) -> int; */
      -           | storage_class AUTO declarator cpp_const ARROW cpp_alternate_rettype initializer c_decl_tail {
      +           | storage_class AUTO declarator cpp_const ARROW cpp_alternate_rettype cpp_const initializer c_decl_tail {
                     $$ = new_node("cdecl");
       	      if ($4.qualifier) SwigType_push($3.type, $4.qualifier);
       	      Setattr($$,"refqualifier",$4.refqualifier);
      @@ -3179,14 +3179,14 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
       	      Setattr($$,"throws",$4.throws);
       	      Setattr($$,"throw",$4.throwf);
       	      Setattr($$,"noexcept",$4.nexcept);
      -	      if (!$8) {
      +	      if (!$9) {
       		if (Len(scanner_ccode)) {
       		  String *code = Copy(scanner_ccode);
       		  Setattr($$,"code",code);
       		  Delete(code);
       		}
       	      } else {
      -		Node *n = $8;
      +		Node *n = $9;
       		while (n) {
       		  String *type = Copy($6);
       		  Setattr(n,"type",type);
      @@ -3207,18 +3207,18 @@ c_decl  : storage_class type declarator initializer c_decl_tail {
       		    String *lstr = Swig_scopename_last($3.id);
       		    Setattr($$,"name",lstr);
       		    Delete(lstr);
      -		    set_nextSibling($$, $8);
      +		    set_nextSibling($$, $9);
       		  } else {
       		    Delete($$);
      -		    $$ = $8;
      +		    $$ = $9;
       		  }
       		  Delete(p);
       		} else {
       		  Delete($$);
      -		  $$ = $8;
      +		  $$ = $9;
       		}
       	      } else {
      -		set_nextSibling($$, $8);
      +		set_nextSibling($$, $9);
       	      }
                  }
                  ;
      @@ -3229,28 +3229,28 @@ c_decl_tail    : SEMI {
                          $$ = 0;
                          Clear(scanner_ccode); 
                      }
      -               | COMMA declarator initializer c_decl_tail {
      +               | COMMA declarator cpp_const initializer c_decl_tail {
       		 $$ = new_node("cdecl");
       		 if ($3.qualifier) SwigType_push($2.type,$3.qualifier);
       		 Setattr($$,"refqualifier",$3.refqualifier);
       		 Setattr($$,"name",$2.id);
       		 Setattr($$,"decl",$2.type);
       		 Setattr($$,"parms",$2.parms);
      -		 Setattr($$,"value",$3.val);
      +		 Setattr($$,"value",$4.val);
       		 Setattr($$,"throws",$3.throws);
       		 Setattr($$,"throw",$3.throwf);
       		 Setattr($$,"noexcept",$3.nexcept);
      -		 if ($3.bitfield) {
      -		   Setattr($$,"bitfield", $3.bitfield);
      +		 if ($4.bitfield) {
      +		   Setattr($$,"bitfield", $4.bitfield);
       		 }
      -		 if (!$4) {
      +		 if (!$5) {
       		   if (Len(scanner_ccode)) {
       		     String *code = Copy(scanner_ccode);
       		     Setattr($$,"code",code);
       		     Delete(code);
       		   }
       		 } else {
      -		   set_nextSibling($$,$4);
      +		   set_nextSibling($$, $5);
       		 }
       	       }
                      | LBRACE { 
      @@ -3270,19 +3270,6 @@ c_decl_tail    : SEMI {
       
       initializer   : def_args {
                          $$ = $1;
      -                   $$.qualifier = 0;
      -                   $$.refqualifier = 0;
      -		   $$.throws = 0;
      -		   $$.throwf = 0;
      -		   $$.nexcept = 0;
      -              }
      -              | qualifiers_exception_specification def_args {
      -                   $$ = $2;
      -                   $$.qualifier = $1.qualifier;
      -                   $$.refqualifier = $1.refqualifier;
      -		   $$.throws = $1.throws;
      -		   $$.throwf = $1.throwf;
      -		   $$.nexcept = $1.nexcept;
                     }
                     ;
       
      @@ -3425,7 +3412,7 @@ c_enum_decl :  storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBR
       		    Namespaceprefix = Swig_symbol_qualifiedscopename(0);
       		  }
                      }
      -	       | storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE declarator initializer c_decl_tail {
      +	       | storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBRACE declarator cpp_const initializer c_decl_tail {
       		 Node *n;
       		 SwigType *ty = 0;
       		 String   *unnamed = 0;
      @@ -3472,8 +3459,8 @@ c_enum_decl :  storage_class c_enum_key ename c_enum_inherit LBRACE enumlist RBR
       		   SetFlag(n,"unnamedinstance");
       		   Delete(cty);
                        }
      -		 if ($10) {
      -		   Node *p = $10;
      +		 if ($11) {
      +		   Node *p = $11;
       		   set_nextSibling(n,p);
       		   while (p) {
       		     SwigType *cty = Copy(ty);
      @@ -3981,12 +3968,12 @@ cpp_class_decl  : storage_class cpptype idcolon inherit LBRACE {
                    ;
       
       cpp_opt_declarators :  SEMI { $$ = 0; }
      -                    |  declarator initializer c_decl_tail {
      +                    |  declarator cpp_const initializer c_decl_tail {
                               $$ = new_node("cdecl");
                               Setattr($$,"name",$1.id);
                               Setattr($$,"decl",$1.type);
                               Setattr($$,"parms",$1.parms);
      -			set_nextSibling($$,$3);
      +			set_nextSibling($$, $4);
                           }
                           ;
       /* ------------------------------------------------------------
      
      From 0e50ef30b1aef7e11e3e6e42948593001666961a Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 26 Aug 2017 23:39:34 +0100
      Subject: [PATCH 0683/2031] Alternate function syntax parsing improvement
      
      This was incorrectly accepting qualifiers and exception specifications
      in the wrong place.
      ---
       Source/CParse/parser.y | 12 ++++++++++--
       1 file changed, 10 insertions(+), 2 deletions(-)
      
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index b999a3796..f9dc6b32f 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -1629,7 +1629,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
       %type      lambda_introducer lambda_body;
       %type        lambda_tail;
       %type      optional_constant_directive;
      -%type       virt_specifier_seq;
      +%type       virt_specifier_seq virt_specifier_seq_opt;
       
       %%
       
      @@ -3166,7 +3166,7 @@ c_decl  : storage_class type declarator cpp_const initializer c_decl_tail {
                  }
                  /* Alternate function syntax introduced in C++11:
                     auto funcName(int x, int y) -> int; */
      -           | storage_class AUTO declarator cpp_const ARROW cpp_alternate_rettype cpp_const initializer c_decl_tail {
      +           | storage_class AUTO declarator cpp_const ARROW cpp_alternate_rettype virt_specifier_seq_opt initializer c_decl_tail {
                     $$ = new_node("cdecl");
       	      if ($4.qualifier) SwigType_push($3.type, $4.qualifier);
       	      Setattr($$,"refqualifier",$4.refqualifier);
      @@ -6627,6 +6627,14 @@ virt_specifier_seq : OVERRIDE {
       	       }
                      ;
       
      +virt_specifier_seq_opt : virt_specifier_seq {
      +                   $$ = 0;
      +               }
      +               | empty {
      +                   $$ = 0;
      +               }
      +               ;
      +
       exception_specification : THROW LPAREN parms RPAREN {
                           $$.throws = $3;
                           $$.throwf = NewString("1");
      
      From 950edc1c000daf15846eeb878111354ee3c293d7 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Tue, 29 Aug 2017 21:11:26 +0100
      Subject: [PATCH 0684/2031] Add support for conversion operators with
       ref-qualifiers
      
      ---
       Examples/test-suite/cpp11_ref_qualifiers.i        | 15 +++++++++++++++
       .../java/cpp11_ref_qualifiers_runme.java          |  9 +++++++++
       .../python/cpp11_ref_qualifiers_runme.py          |  8 ++++++++
       Source/CParse/parser.y                            | 11 ++++++++---
       4 files changed, 40 insertions(+), 3 deletions(-)
      
      diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i
      index 2115843a3..7e9f0e170 100644
      --- a/Examples/test-suite/cpp11_ref_qualifiers.i
      +++ b/Examples/test-suite/cpp11_ref_qualifiers.i
      @@ -74,3 +74,18 @@ struct Renames {
         string S3(int i) const & { return string(); }
       };
       %}
      +
      +// Conversion operators
      +%rename(StringConvertCopy) operator string() &;
      +%rename(StringConvertMove) operator string() &&;
      +%feature("ignore", "0") operator string() &&; // unignore as it is ignored by default
      +
      +%inline %{
      +struct ConversionOperators {
      +  virtual operator string() & { return string(); }
      +  virtual operator string() && { return std::move(string()); }
      +};
      +struct ConversionOperators2 {
      +  virtual operator string() && { return std::move(string()); }
      +};
      +%}
      diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
      index bbe6be8e3..4755f8d1f 100644
      --- a/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
      +++ b/Examples/test-suite/java/cpp11_ref_qualifiers_runme.java
      @@ -42,6 +42,15 @@ public class cpp11_ref_qualifiers_runme {
           r.SS1(0);
           r.SS2(0);
           r.SS3(0);
      +
      +    // Conversion operators
      +    String s = null;
      +    ConversionOperators co = new ConversionOperators();
      +    s = co.StringConvertCopy();
      +    s = co.StringConvertMove();
      +
      +    ConversionOperators2 co2 = new ConversionOperators2();
      +    s = co2.StringConvertMove();
         }
       }
       
      diff --git a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
      index 47c474218..d3aa98c47 100644
      --- a/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
      +++ b/Examples/test-suite/python/cpp11_ref_qualifiers_runme.py
      @@ -35,3 +35,11 @@ r.RR3()
       r.SS1(0)
       r.SS2(0)
       r.SS3(0)
      +
      +# Conversion operators
      +co = cpp11_ref_qualifiers.ConversionOperators()
      +s = co.StringConvertCopy()
      +s = co.StringConvertMove()
      +
      +co2 = cpp11_ref_qualifiers.ConversionOperators2()
      +s = co2.StringConvertMove()
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index f9dc6b32f..a982ce011 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -4656,6 +4656,7 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
       		 if ($8.qualifier) {
       		   SwigType_push($4,$8.qualifier);
       		 }
      +		 Setattr($$,"refqualifier",$8.refqualifier);
       		 Setattr($$,"decl",$4);
       		 Setattr($$,"parms",$6);
       		 Setattr($$,"conversion_operator","1");
      @@ -4673,6 +4674,7 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
       		 if ($8.qualifier) {
       		   SwigType_push(decl,$8.qualifier);
       		 }
      +		 Setattr($$,"refqualifier",$8.refqualifier);
       		 Setattr($$,"decl",decl);
       		 Setattr($$,"parms",$6);
       		 Setattr($$,"conversion_operator","1");
      @@ -4690,6 +4692,7 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
       		 if ($8.qualifier) {
       		   SwigType_push(decl,$8.qualifier);
       		 }
      +		 Setattr($$,"refqualifier",$8.refqualifier);
       		 Setattr($$,"decl",decl);
       		 Setattr($$,"parms",$6);
       		 Setattr($$,"conversion_operator","1");
      @@ -4709,6 +4712,7 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
       		 if ($9.qualifier) {
       		   SwigType_push(decl,$9.qualifier);
       		 }
      +		 Setattr($$,"refqualifier",$9.refqualifier);
       		 Setattr($$,"decl",decl);
       		 Setattr($$,"parms",$7);
       		 Setattr($$,"conversion_operator","1");
      @@ -4725,6 +4729,7 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
       		if ($7.qualifier) {
       		  SwigType_push(t,$7.qualifier);
       		}
      +		 Setattr($$,"refqualifier",$7.refqualifier);
       		Setattr($$,"decl",t);
       		Setattr($$,"parms",$5);
       		Setattr($$,"conversion_operator","1");
      @@ -4819,7 +4824,7 @@ cpp_vend       : cpp_const SEMI {
                            Clear(scanner_ccode);
                            $$.val = 0;
                            $$.qualifier = $1.qualifier;
      -                     $$.refqualifier = 0;
      +                     $$.refqualifier = $1.refqualifier;
                            $$.bitfield = 0;
                            $$.throws = $1.throws;
                            $$.throwf = $1.throwf;
      @@ -4829,7 +4834,7 @@ cpp_vend       : cpp_const SEMI {
                            Clear(scanner_ccode);
                            $$.val = $3.val;
                            $$.qualifier = $1.qualifier;
      -                     $$.refqualifier = 0;
      +                     $$.refqualifier = $1.refqualifier;
                            $$.bitfield = 0;
                            $$.throws = $1.throws; 
                            $$.throwf = $1.throwf; 
      @@ -4839,7 +4844,7 @@ cpp_vend       : cpp_const SEMI {
                            skip_balanced('{','}');
                            $$.val = 0;
                            $$.qualifier = $1.qualifier;
      -                     $$.refqualifier = 0;
      +                     $$.refqualifier = $1.refqualifier;
                            $$.bitfield = 0;
                            $$.throws = $1.throws; 
                            $$.throwf = $1.throwf; 
      
      From 7e4717320b73dd68f00a5709f2ec346ec53b7cc2 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 30 Aug 2017 06:57:51 +0100
      Subject: [PATCH 0685/2031] Add error for constructors, destructors, static
       methods declared with qualifiers
      
      SWIG parses a superset of valid C++ declarations. These ill-formed declarations
      were previously successfully parsed but now result an error message.
      ---
       .../errors/cpp_invalid_qualifiers.i           | 43 +++++++++++++++++++
       .../errors/cpp_invalid_qualifiers.stderr      | 20 +++++++++
       Source/CParse/parser.y                        | 26 ++++++++++-
       3 files changed, 88 insertions(+), 1 deletion(-)
       create mode 100644 Examples/test-suite/errors/cpp_invalid_qualifiers.i
       create mode 100644 Examples/test-suite/errors/cpp_invalid_qualifiers.stderr
      
      diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.i b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
      new file mode 100644
      index 000000000..fd3b36332
      --- /dev/null
      +++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.i
      @@ -0,0 +1,43 @@
      +%module cpp_invalid_qualifiers
      +
      +// Constructors, destructors and static methods cannot have qualifiers
      +struct A {
      +  ~A() const;
      +};
      +struct B {
      +  virtual ~B() const;
      +};
      +struct C {
      +  ~C() &;
      +};
      +struct D {
      +  virtual ~D() &;
      +};
      +struct E {
      +  ~E() &&;
      +};
      +struct F {
      +  virtual ~F() &&;
      +};
      +
      +struct J {
      +  J() const;
      +  J(int) const;
      +};
      +struct K {
      +  K() &;
      +  K(int) &;
      +};
      +struct L {
      +  L() &&;
      +  L(int) &&;
      +};
      +
      +struct M {
      +  static void m1() const;
      +  static void m2() &;
      +  thread_local static void m3() &&;
      +  static auto m4() const -> int;
      +  static auto m5() & -> int;
      +  static auto m6() && -> int;
      +};
      diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr b/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr
      new file mode 100644
      index 000000000..7b3e442eb
      --- /dev/null
      +++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.stderr
      @@ -0,0 +1,20 @@
      +cpp_invalid_qualifiers.i:5: Error: Destructor ~A() const cannot have a qualifier.
      +cpp_invalid_qualifiers.i:8: Error: Destructor ~B() const cannot have a qualifier.
      +cpp_invalid_qualifiers.i:11: Error: Destructor ~C() & cannot have a qualifier.
      +cpp_invalid_qualifiers.i:14: Error: Destructor ~D() & cannot have a qualifier.
      +cpp_invalid_qualifiers.i:17: Error: Destructor ~E() && cannot have a qualifier.
      +cpp_invalid_qualifiers.i:20: Error: Destructor ~F() && cannot have a qualifier.
      +cpp_invalid_qualifiers.i:24: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:25: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:28: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:29: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:32: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:33: Error: Constructor cannot have a qualifier.
      +cpp_invalid_qualifiers.i:37: Error: Static function m1() const cannot have a qualifier.
      +cpp_invalid_qualifiers.i:38: Error: Static function m2() & cannot have a qualifier.
      +cpp_invalid_qualifiers.i:39: Error: Static function m3() && cannot have a qualifier.
      +cpp_invalid_qualifiers.i:39: Warning 405: Method with rvalue ref-qualifier m3() && ignored.
      +cpp_invalid_qualifiers.i:40: Error: Static function m4() const cannot have a qualifier.
      +cpp_invalid_qualifiers.i:41: Error: Static function m5() & cannot have a qualifier.
      +cpp_invalid_qualifiers.i:42: Error: Static function m6() && cannot have a qualifier.
      +cpp_invalid_qualifiers.i:42: Warning 405: Method with rvalue ref-qualifier m6() && ignored.
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index a982ce011..f88eb5f60 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -3163,6 +3163,9 @@ c_decl  : storage_class type declarator cpp_const initializer c_decl_tail {
       		Swig_error(cparse_file, cparse_line, "Missing symbol name for global declaration\n");
       		$$ = 0;
       	      }
      +
      +	      if ($4.qualifier && $1 && Strstr($1, "static"))
      +		Swig_error(cparse_file, cparse_line, "Static function %s cannot have a qualifier.\n", Swig_name_decl($$));
                  }
                  /* Alternate function syntax introduced in C++11:
                     auto funcName(int x, int y) -> int; */
      @@ -3220,6 +3223,9 @@ c_decl  : storage_class type declarator cpp_const initializer c_decl_tail {
       	      } else {
       		set_nextSibling($$, $9);
       	      }
      +
      +	      if ($4.qualifier && $1 && Strstr($1, "static"))
      +		Swig_error(cparse_file, cparse_line, "Static function %s cannot have a qualifier.\n", Swig_name_decl($$));
                  }
                  ;
       
      @@ -4610,6 +4616,8 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
       	       Setattr($$,"noexcept",$6.nexcept);
       	       if ($6.val)
       	         Setattr($$,"value",$6.val);
      +	       if ($6.qualifier)
      +		 Swig_error(cparse_file, cparse_line, "Destructor %s %s cannot have a qualifier.\n", Swig_name_decl($$), SwigType_str($6.qualifier, 0));
       	       add_symbols($$);
       	      }
       
      @@ -4639,7 +4647,8 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
       		  Setattr($$,"decl",decl);
       		  Delete(decl);
       		}
      -
      +		if ($7.qualifier)
      +		  Swig_error(cparse_file, cparse_line, "Destructor %s %s cannot have a qualifier.\n", Swig_name_decl($$), SwigType_str($7.qualifier, 0));
       		add_symbols($$);
       	      }
                     ;
      @@ -4800,6 +4809,9 @@ cpp_swig_directive: pragma_directive { $$ = $1; }
       cpp_end        : cpp_const SEMI {
       	            Clear(scanner_ccode);
       		    $$.val = 0;
      +		    $$.qualifier = $1.qualifier;
      +		    $$.refqualifier = $1.refqualifier;
      +		    $$.bitfield = 0;
       		    $$.throws = $1.throws;
       		    $$.throwf = $1.throwf;
       		    $$.nexcept = $1.nexcept;
      @@ -4807,6 +4819,9 @@ cpp_end        : cpp_const SEMI {
                      | cpp_const EQUAL default_delete SEMI {
       	            Clear(scanner_ccode);
       		    $$.val = $3.val;
      +		    $$.qualifier = $1.qualifier;
      +		    $$.refqualifier = $1.refqualifier;
      +		    $$.bitfield = 0;
       		    $$.throws = $1.throws;
       		    $$.throwf = $1.throwf;
       		    $$.nexcept = $1.nexcept;
      @@ -4814,6 +4829,9 @@ cpp_end        : cpp_const SEMI {
                      | cpp_const LBRACE { 
       		    skip_balanced('{','}'); 
       		    $$.val = 0;
      +		    $$.qualifier = $1.qualifier;
      +		    $$.refqualifier = $1.refqualifier;
      +		    $$.bitfield = 0;
       		    $$.throws = $1.throws;
       		    $$.throwf = $1.throwf;
       		    $$.nexcept = $1.nexcept;
      @@ -6710,6 +6728,8 @@ ctor_end       : cpp_const ctor_initializer SEMI {
       		    $$.throws = $1.throws;
       		    $$.throwf = $1.throwf;
       		    $$.nexcept = $1.nexcept;
      +                    if ($1.qualifier)
      +                      Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n");
                      }
                      | cpp_const ctor_initializer LBRACE { 
                           skip_balanced('{','}'); 
      @@ -6718,6 +6738,8 @@ ctor_end       : cpp_const ctor_initializer SEMI {
                           $$.throws = $1.throws;
                           $$.throwf = $1.throwf;
                           $$.nexcept = $1.nexcept;
      +                    if ($1.qualifier)
      +                      Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n");
                      }
                      | LPAREN parms RPAREN SEMI { 
                           Clear(scanner_ccode); 
      @@ -6750,6 +6772,8 @@ ctor_end       : cpp_const ctor_initializer SEMI {
                           $$.throws = $1.throws;
                           $$.throwf = $1.throwf;
                           $$.nexcept = $1.nexcept;
      +                    if ($1.qualifier)
      +                      Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n");
                      }
                      ;
       
      
      From 61c24e9cd1fab8bbcdd937e515f0749b02cfd7fb Mon Sep 17 00:00:00 2001
      From: Frank Schlimbach 
      Date: Thu, 12 Jan 2017 06:50:25 -0600
      Subject: [PATCH 0686/2031] - allowing R package names with containing dosts
       ('.') - allowing mulitple get accessors in R
      
      ---
       Source/Modules/r.cxx | 16 +++++++++++-----
       1 file changed, 11 insertions(+), 5 deletions(-)
      
      diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
      index 6a326206f..70d6ca327 100644
      --- a/Source/Modules/r.cxx
      +++ b/Source/Modules/r.cxx
      @@ -1045,10 +1045,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
         bool has_prev = false;
         for(j = 0; j < numMems; j+=3) {
           String *item = Getitem(el, j);
      -    if (Getattr(itemList, item)) 
      -      continue;
      -    Setattr(itemList, item, "1");
      -    
           String *dup = Getitem(el, j + 1);
           char *ptr = Char(dup);
           ptr = &ptr[Len(dup) - 3];
      @@ -1056,6 +1052,10 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
           if (!strcmp(ptr, "get"))
             varaccessor++;
       
      +    if (Getattr(itemList, item))
      +      continue;
      +    Setattr(itemList, item, "1");
      +
           String *pitem;
           if (!Strcmp(item, "operator ()")) {
             pitem = NewString("call");
      @@ -2270,7 +2270,13 @@ int R::outputRegistrationRoutines(File *out) {
         if(!noInitializationCode) {
           if (inCPlusMode)
             Printv(out, "extern \"C\" ", NIL);
      -    Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage);
      +    { /* R allows pckage names to have '.' in the name, which is not allowed in C++ var names
      +         we simply replace all occurrences of '.' with '_' to construct the var name */
      +      String * Rpackage_sane = Copy(Rpackage);
      +      Replace(Rpackage_sane, ".", "_", DOH_REPLACE_ANY);
      +      Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage_sane);
      +      Delete(Rpackage_sane);
      +    }
           Printf(out, "%sR_registerRoutines(dll, NULL, CallEntries, NULL, NULL);\n", tab4);
           if(Len(s_init_routine)) {
             Printf(out, "\n%s\n", s_init_routine);
      
      From d4989aa7fc89b56bd9e89380eec3f320eedddad0 Mon Sep 17 00:00:00 2001
      From: Frank Schlimbach 
      Date: Fri, 13 Jan 2017 10:51:29 -0600
      Subject: [PATCH 0687/2031] fixing smart-pointer and NAMESPACE support
      
      ---
       Source/Modules/r.cxx | 26 ++++++++++++++++++++++----
       1 file changed, 22 insertions(+), 4 deletions(-)
      
      diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
      index 70d6ca327..b7b09545a 100644
      --- a/Source/Modules/r.cxx
      +++ b/Source/Modules/r.cxx
      @@ -12,6 +12,7 @@
        * ----------------------------------------------------------------------------- */
       
       #include "swigmod.h"
      +#include "cparse.h"
       
       static const double DEFAULT_NUMBER = .0000123456712312312323;
       
      @@ -908,7 +909,7 @@ int R::DumpCode(Node *n) {
           writeListByLine(namespaceFunctions, ns);
           Printf(ns, ")\n");
           Printf(ns, "\nexportMethods(\n");
      -    writeListByLine(namespaceFunctions, ns, 1);
      +    writeListByLine(namespaceMethods, ns, 1);
           Printf(ns, ")\n");
           Delete(ns);
           Delete(s_namespace);
      @@ -1826,8 +1827,16 @@ int R::functionWrapper(Node *n) {
         Printf(sfun->def, "# Start of %s\n", iname);         
         Printv(sfun->def, "\n`", sfname, "` = function(", NIL);
       
      -  if(outputNamespaceInfo) //XXX Need to be a little more discriminating
      -    addNamespaceFunction(iname);
      +  if(outputNamespaceInfo) {//XXX Need to be a little more discriminating
      +      if (constructor) {
      +          String *niname = Copy(iname);
      +          Replace(niname, "new_", "", DOH_REPLACE_FIRST);
      +          addNamespaceFunction(niname);
      +          Delete(niname);
      +      } else {
      +          addNamespaceFunction(iname);
      +      }
      +  }
       
         Swig_typemap_attach_parms("scoercein", l, f);
         Swig_typemap_attach_parms("scoerceout", l, f);
      @@ -2328,8 +2337,17 @@ void R::registerClass(Node *n) {
       
           Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base);
           Delete(base);
      +    String *smartptr = Getattr(n, "feature:smartptr");
      +    if (smartptr) {
      +        SwigType *spt = Swig_cparse_type(smartptr);
      +        String *smart = SwigType_typedef_resolve_all(spt);
      +        String *smart_rname = SwigType_manglestr(smart);
      +        Printf(s_classes, "setClass('_p%s', contains = c('%s'))\n", smart_rname, sname);
      +        Delete(spt);
      +        Delete(smart);
      +        Delete(smart_rname);
      +    }
         }
      -  
       }
       
       int R::classDeclaration(Node *n) {
      
      From e6a1a7dbd111421c9d0dbffa3817a6f2907d8ccf Mon Sep 17 00:00:00 2001
      From: Frank Schlimbach 
      Date: Tue, 24 Jan 2017 11:29:28 -0600
      Subject: [PATCH 0688/2031] constructors now returning smart pointers (if class
       declared as such)
      
      ---
       Source/Modules/r.cxx | 9 +++++++++
       1 file changed, 9 insertions(+)
      
      diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
      index b7b09545a..ccba6c794 100644
      --- a/Source/Modules/r.cxx
      +++ b/Source/Modules/r.cxx
      @@ -2137,6 +2137,15 @@ int R::functionWrapper(Node *n) {
         if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) {
           Replaceall(tm,"$source","ans");
           Replaceall(tm,"$result","ans");
      +    if (constructor) {
      +        Node * parent = Getattr(n, "parentNode");
      +        String * smartname = Getattr(parent, "feature:smartptr");
      +        if (smartname) {
      +            smartname = getRClassName(smartname, 1, 1);
      +            Replaceall(tm, "$R_class", smartname);
      +            Delete(smartname);
      +        }
      +    }
           replaceRClass(tm, Getattr(n, "type"));
           Chop(tm);
         }
      
      From 1df744e0c35ade8b6622b561e6c815457ecd76d7 Mon Sep 17 00:00:00 2001
      From: Frank Schlimbach 
      Date: Wed, 25 Jan 2017 10:57:26 -0600
      Subject: [PATCH 0689/2031] smart-pointer classes deriving from parent
       smart-pointers white-space cleanup
      
      ---
       Source/Modules/r.cxx | 791 ++++++++++++++++++++++---------------------
       1 file changed, 397 insertions(+), 394 deletions(-)
      
      diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
      index ccba6c794..ac78b13d9 100644
      --- a/Source/Modules/r.cxx
      +++ b/Source/Modules/r.cxx
      @@ -1,5 +1,5 @@
       /* -----------------------------------------------------------------------------
      - * This file is part of SWIG, which is licensed as a whole under version 3 
      + * This file is part of SWIG, which is licensed as a whole under version 3
        * (or any later version) of the GNU General Public License. Some additional
        * terms also apply to certain portions of SWIG. The full details of the SWIG
        * license and copyrights can be found in the LICENSE and COPYRIGHT files
      @@ -33,15 +33,15 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
         List *els = SwigType_split(t);
         int count = 0;
         int i;
      -  
      -  if(Strncmp(b, "struct ", 7) == 0) 
      +
      +  if(Strncmp(b, "struct ", 7) == 0)
           Replace(b, "struct ", "", DOH_REPLACE_FIRST);
      -  
      +
         /* Printf(stdout, " %s,base = %s\n", t, b);
      -     for(i = 0; i < Len(els); i++) 
      +     for(i = 0; i < Len(els); i++)
            Printf(stdout, "%d) %s, ", i, Getitem(els,i));
            Printf(stdout, "\n"); */
      -  
      +
         for(i = 0; i < Len(els); i++) {
           String *el = Getitem(els, i);
           if(Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) {
      @@ -51,18 +51,18 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
         }
         if(outCount)
           *outCount = count;
      -  
      +
         String *tmp = NewString("");
         char *retName = Char(SwigType_manglestr(t));
         Insert(tmp, 0, retName);
         return tmp;
      -  
      +
         /*
      -  if(count)
      +    if(count)
           return(b);
      -  
      -  Delete(b);
      -  return(NewString(""));
      +
      +    Delete(b);
      +    return(NewString(""));
         */
       }
       
      @@ -81,7 +81,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
         } else{
           Insert(tmp, 0, retName);
         }
      -  
      +
         return tmp;
       /*
       #if 1
      @@ -90,33 +90,33 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
         if(!l || n == 0) {
       #ifdef R_SWIG_VERBOSE
           if (debugMode)
      -      Printf(stdout, "SwigType_split return an empty list for %s\n", 
      -	     retType);
      +      Printf(stdout, "SwigType_split return an empty list for %s\n",
      +             retType);
       #endif
           return(tmp);
         }
      -  
      -  
      +
      +
         String *el = Getitem(l, n-1);
         char *ptr = Char(el);
         if(strncmp(ptr, "struct ", 7) == 0)
           ptr += 7;
      -  
      +
         Printf(tmp, "%s", ptr);
      -  
      +
         if(addRef) {
           for(int i = 0; i < n; i++) {
      -      if(Strcmp(Getitem(l, i), "p.") == 0 || 
      -	 Strncmp(Getitem(l, i), "a(", 2) == 0)
      -	Printf(tmp, "Ref");
      +      if(Strcmp(Getitem(l, i), "p.") == 0 ||
      +         Strncmp(Getitem(l, i), "a(", 2) == 0)
      +        Printf(tmp, "Ref");
           }
         }
      -  
      +
       #else
         char *retName = Char(SwigType_manglestr(retType));
         if(!retName)
           return(tmp);
      -  
      +
         if(addRef) {
           while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0)  {
             retName += 2;
      @@ -127,7 +127,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
           retName ++;
         Insert(tmp, 0, retName);
       #endif
      -  
      +
         return tmp;
       */
       }
      @@ -140,7 +140,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
       
       static String * getRClassNameCopyStruct(String *retType, int addRef) {
         String *tmp = NewString("");
      -  
      +
       #if 1
         List *l = SwigType_split(retType);
         int n = Len(l);
      @@ -150,36 +150,36 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
       #endif
           return(tmp);
         }
      -  
      -  
      +
      +
         String *el = Getitem(l, n-1);
         char *ptr = Char(el);
         if(strncmp(ptr, "struct ", 7) == 0)
           ptr += 7;
      -  
      +
         Printf(tmp, "%s", ptr);
      -  
      +
         if(addRef) {
           for(int i = 0; i < n; i++) {
      -      if(Strcmp(Getitem(l, i), "p.") == 0 || 
      +      if(Strcmp(Getitem(l, i), "p.") == 0 ||
       	 Strncmp(Getitem(l, i), "a(", 2) == 0)
       	Printf(tmp, "Ref");
           }
         }
      -  
      +
       #else
         char *retName = Char(SwigType_manglestr(retType));
         if(!retName)
           return(tmp);
      -  
      +
         if(addRef) {
      -    while(retName && strlen(retName) > 1 && 
      +    while(retName && strlen(retName) > 1 &&
       	  strncmp(retName, "_p", 2) == 0)  {
             retName += 2;
             Printf(tmp, "Ref");
           }
         }
      -  
      +
         if(retName[0] == '_')
           retName ++;
         Insert(tmp, 0, retName);
      @@ -198,10 +198,10 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
       
       static void writeListByLine(List *l, File *out, bool quote = 0) {
         int i, n = Len(l);
      -  for(i = 0; i < n; i++) 
      -    Printf(out, "%s%s%s%s%s\n", tab8, 
      -	   quote ? "\"" :"",  
      -	   Getitem(l, i), 
      +  for(i = 0; i < n; i++)
      +    Printf(out, "%s%s%s%s%s\n", tab8,
      +	   quote ? "\"" :"",
      +	   Getitem(l, i),
       	   quote ? "\"" :"", i < n-1 ? "," : "");
       }
       
      @@ -212,14 +212,14 @@ R Options (available with -r)\n\
            -cppcast         - Enable C++ casting operators (default) \n\
            -debug           - Output debug\n\
            -dll       - Name of the DLL (without the .dll or .so suffix).\n\
      -                        Default is the module name.\n\
      +	                Default is the module name.\n\
            -gc              - Aggressive garbage collection\n\
            -memoryprof      - Add memory profile\n\
            -namespace       - Output NAMESPACE file\n\
            -no-init-code    - Turn off the generation of the R_init_ code\n\
      -                        (registration information still generated)\n\
      +	                (registration information still generated)\n\
            -package   - Package name for the PACKAGE argument of the R .Call()\n\
      -                        invocations. Default is the module name.\n\
      +	                invocations. Default is the module name.\n\
       ";
       
       
      @@ -279,7 +279,7 @@ public:
         void registerClass(Node *n);
         void main(int argc, char *argv[]);
         int top(Node *n);
      -  
      +
         void dispatchFunction(Node *n);
         int functionWrapper(Node *n);
         int constantWrapper(Node *n);
      @@ -292,52 +292,52 @@ public:
       
         int typedefHandler(Node *n);
         static List *Swig_overload_rank(Node *n,
      -			   bool script_lang_wrapping);
      +	                          bool script_lang_wrapping);
       
         int memberfunctionHandler(Node *n) {
           if (debugMode)
      -      Printf(stdout, " %s %s\n", 
      +      Printf(stdout, " %s %s\n",
       	     Getattr(n, "name"),
       	     Getattr(n, "type"));
           member_name = Getattr(n, "sym:name");
           processing_class_member_function = 1;
      -    int status = Language::memberfunctionHandler(n);    
      +    int status = Language::memberfunctionHandler(n);
           processing_class_member_function = 0;
           return status;
         }
       
      -  /* Grab the name of the current class being processed so that we can 
      +  /* Grab the name of the current class being processed so that we can
            deal with members of that class. */
         int classHandler(Node *n){
      -    if(!ClassMemberTable) 
      +    if(!ClassMemberTable)
             ClassMemberTable = NewHash();
      -    
      +
           class_name = Getattr(n, "name");
           int status = Language::classHandler(n);
      -    
      +
           class_name = NULL;
           return status;
         }
       
         // Not used:
         String *runtimeCode();
      -  
      +
       protected:
         int addRegistrationRoutine(String *rname, int nargs);
         int outputRegistrationRoutines(File *out);
      -  
      +
         int outputCommandLineArguments(File *out);
      -  int generateCopyRoutines(Node *n); 
      +  int generateCopyRoutines(Node *n);
         int DumpCode(Node *n);
      -  
      +
         int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out);
         int OutputArrayMethod(String *className, List *el, File *out);
         int OutputClassMemberTable(Hash *tb, File *out);
         int OutputClassMethodsTable(File *out);
         int OutputClassAccessInfo(Hash *tb, File *out);
      -  
      +
         int defineArrayAccessors(SwigType *type);
      -  
      +
         void addNamespaceFunction(String *name) {
           if(!namespaceFunctions)
             namespaceFunctions = NewList();
      @@ -349,41 +349,41 @@ protected:
             namespaceMethods = NewList();
           Append(namespaceMethods, name);
         }
      -  
      +
         String* processType(SwigType *t, Node *n, int *nargs = NULL);
         String *createFunctionPointerHandler(SwigType *t, Node *n, int *nargs);
         int addFunctionPointerProxy(String *name, Node *n, SwigType *t, String *s_paramTypes) {
           /*XXX Do we need to put the t in there to get the return type later. */
      -    if(!functionPointerProxyTable) 
      +    if(!functionPointerProxyTable)
             functionPointerProxyTable = NewHash();
      -    
      +
           Setattr(functionPointerProxyTable, name, n);
      -    
      +
           Setattr(SClassDefs, name, name);
      -    Printv(s_classes, "setClass('", 
      +    Printv(s_classes, "setClass('",
       	   name,
      -	   "',\n", tab8, 
      +	   "',\n", tab8,
       	   "prototype = list(parameterTypes = c(", s_paramTypes, "),\n",
       	   tab8, tab8, tab8,
      -	   "returnType = '", SwigType_manglestr(t), "'),\n", tab8, 
      +	   "returnType = '", SwigType_manglestr(t), "'),\n", tab8,
       	   "contains = 'CRoutinePointer')\n\n##\n", NIL);
      -    
      +
           return SWIG_OK;
         }
      -  
       
      -  void addSMethodInfo(String *name, 
      +
      +  void addSMethodInfo(String *name,
       		      String *argType, int nargs);
      -  // Simple initialization such as constant strings that can be reused. 
      -  void init(); 
      -  
      -  
      -  void addAccessor(String *memberName, Wrapper *f, 
      +  // Simple initialization such as constant strings that can be reused.
      +  void init();
      +
      +
      +  void addAccessor(String *memberName, Wrapper *f,
       		   String *name, int isSet = -1);
      -  
      +
         static int getFunctionPointerNumArgs(Node *n, SwigType *tt);
       
      -protected: 
      +protected:
         bool copyStruct;
         bool memoryProfile;
         bool aggressiveGc;
      @@ -401,49 +401,49 @@ protected:
         String *s_init;
         String *s_init_routine;
         String *s_namespace;
      -  
      -  // State variables that carry information across calls to functionWrapper() 
      -  // from  member accessors and class declarations. 
      +
      +  // State variables that carry information across calls to functionWrapper()
      +  // from  member accessors and class declarations.
         String *opaqueClassDeclaration;
         int processing_variable;
         int processing_member_access_function;
         String *member_name;
         String *class_name;
      -  
      -  
      +
      +
         int processing_class_member_function;
         List *class_member_functions;
         List *class_member_set_functions;
      -  
      +
         /* */
         Hash *ClassMemberTable;
         Hash *ClassMethodsTable;
         Hash *SClassDefs;
         Hash *SMethodInfo;
      -  
      -  // Information about routines that are generated and to be registered with 
      -  // R for dynamic lookup. 
      +
      +  // Information about routines that are generated and to be registered with
      +  // R for dynamic lookup.
         Hash *registrationTable;
         Hash *functionPointerProxyTable;
      -  
      +
         List *namespaceFunctions;
         List *namespaceMethods;
         List *namespaceClasses; // Probably can do this from ClassMemberTable.
      -  
      -  
      -  // Store a copy of the command line. 
      -  // Need only keep a string that has it formatted. 
      +
      +
      +  // Store a copy of the command line.
      +  // Need only keep a string that has it formatted.
         char **Argv;
         int    Argc;
         bool inCPlusMode;
      -  
      +
         // State variables that we remember from the command line settings
         // potentially that govern the code we generate.
         String *DllName;
         String *Rpackage;
         bool    noInitializationCode;
         bool    outputNamespaceInfo;
      -  
      +
         String *UnProtectWrapupCode;
       
         // Static members
      @@ -509,7 +509,7 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
       
       void R::addSMethodInfo(String *name, String *argType, int nargs) {
         (void) argType;
      -  
      +
         if(!SMethodInfo)
           SMethodInfo = NewHash();
         if (debugMode)
      @@ -532,20 +532,20 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
           Setattr(tb, "max", str);
         }
       }
      - 
      +
       /*
      -Returns the name of the new routine.
      +  Returns the name of the new routine.
       */
       String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
         String *funName = SwigType_manglestr(t);
      -  
      +
         /* See if we have already processed this one. */
         if(functionPointerProxyTable && Getattr(functionPointerProxyTable, funName))
           return funName;
      -  
      +
         if (debugMode)
           Printf(stdout, " Defining %s\n",  t);
      -  
      +
         SwigType *rettype = Copy(Getattr(n, "type"));
         SwigType *funcparams = SwigType_functionpointer_decompose(rettype);
         String *rtype = SwigType_str(rettype, 0);
      @@ -559,13 +559,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
           Printf(stdout, "Type: %s\n", t);
           Printf(stdout, "Return type: %s\n", SwigType_base(t));
         }
      -  
      +
         bool isVoidType = Strcmp(rettype, "void") == 0;
         if (debugMode)
           Printf(stdout, "%s is void ? %s  (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
      -  
      +
         Wrapper *f = NewWrapper();
      -  
      +
         /* Go through argument list, attach lnames for arguments */
         int i = 0;
         Parm *p = parms;
      @@ -581,7 +581,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
       
           Setattr(p, "lname", lname);
         }
      -  
      +
         Swig_typemap_attach_parms("out", parms, f);
         Swig_typemap_attach_parms("scoerceout", parms, f);
         Swig_typemap_attach_parms("scheck", parms, f);
      @@ -590,7 +590,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
       
         emit_parameter_variables(parms, f);
         emit_return_variable(n, rettype, f);
      -//  emit_attach_parmmaps(parms,f);
      +  //  emit_attach_parmmaps(parms,f);
       
         /*  Using weird name and struct to avoid potential conflicts. */
         Wrapper_add_local(f, "r_swig_cb_data", "RCallbackFunctionData *r_swig_cb_data = R_SWIG_getCallbackFunctionData()");
      @@ -610,9 +610,9 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
           *numArgs = nargs;
           if (debugMode)
             Printf(stdout, "Setting number of parameters to %d\n", *numArgs);
      -  } 
      +  }
         String *setExprElements = NewString("");
      -  
      +
         String *s_paramTypes = NewString("");
         for(i = 0; p; i++) {
           SwigType *tt = Getattr(p, "type");
      @@ -641,35 +641,35 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
           Printf(setExprElements, "%s\n", tm);
           Printf(setExprElements, "SETCAR(r_swig_cb_data->el, %s);\n", "r_tmp");
           Printf(setExprElements, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n");
      -    
      +
           Printf(s_paramTypes, "'%s'", SwigType_manglestr(tt));
      -    
      -    
      +
      +
           p = nextSibling(p);
           if(p) {
             Printf(f->def, ", ");
             Printf(s_paramTypes, ", ");
           }
         }
      -  
      +
         Printf(f->def,  ") {\n");
      -  
      +
         Printf(f->code, "Rf_protect(%s->expr = Rf_allocVector(LANGSXP, %d));\n", lvar, nargs + 1);
         Printf(f->code, "r_nprotect++;\n");
         Printf(f->code, "r_swig_cb_data->el = r_swig_cb_data->expr;\n\n");
      -  
      +
         Printf(f->code, "SETCAR(r_swig_cb_data->el, r_swig_cb_data->fun);\n");
         Printf(f->code, "r_swig_cb_data->el = CDR(r_swig_cb_data->el);\n\n");
      -  
      +
         Printf(f->code, "%s\n\n", setExprElements);
      -  
      -  Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(", 
      +
      +  Printv(f->code, "r_swig_cb_data->retValue = R_tryEval(",
       	 "r_swig_cb_data->expr,",
       	 " R_GlobalEnv,",
       	 " &r_swig_cb_data->errorOccurred",
      -	 ");\n", 
      +	 ");\n",
       	 NIL);
      -  
      +
         Printv(f->code, "\n",
       	 "if(r_swig_cb_data->errorOccurred) {\n",
       	 "R_SWIG_popCallbackFunctionData(1);\n",
      @@ -678,11 +678,11 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
       	 ")\");\n",
       	 "}\n",
       	 NIL);
      -   
      -   
      -   
      +
      +
      +
         if(!isVoidType) {
      -    /* Need to deal with the return type of the function pointer, not the function pointer itself. 
      +    /* Need to deal with the return type of the function pointer, not the function pointer itself.
              So build a new node that has the relevant pieces.
              XXX  Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
              Is this still true? If so, will a SwigType_push() solve things?
      @@ -700,7 +700,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
           }
           Delete(bbase);
         }
      -  
      +
         Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
         Printv(f->code, "\n", UnProtectWrapupCode, NIL);
       
      @@ -711,40 +711,40 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
         } else if (!isVoidType) {
           Printv(f->code,  "return ", Swig_cresult_name(), ";\n", NIL);
         }
      -  
      +
         Printv(f->code, "\n}\n", NIL);
         Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
      -  
      +
         /* To coerce correctly in S, we really want to have an extra/intermediate
      -     function that handles the scoerceout. 
      +     function that handles the scoerceout.
            We need to check if any of the argument types have an entry in
            that map. If none do, the ignore and call the function straight.
            Otherwise, generate a marshalling function.
            Need to be able to find it in S. Or use an entirely generic one
            that evaluates the expressions.
            Handle errors in the evaluation of the function by restoring
      -     the stack, if there is one in use for this function (i.e. no 
      +     the stack, if there is one in use for this function (i.e. no
            userData).
         */
      -  
      +
         Wrapper_print(f, f_wrapper);
      -  
      +
         addFunctionPointerProxy(funName, n, t, s_paramTypes);
         Delete(s_paramTypes);
         Delete(rtype);
         Delete(rettype);
         Delete(funcparams);
         DelWrapper(f);
      -  
      +
         return funName;
       }
       
       void R::init() {
      -  UnProtectWrapupCode =  
      +  UnProtectWrapupCode =
           NewStringf("%s", "vmaxset(r_vmax);\nif(r_nprotect)  Rf_unprotect(r_nprotect);\n\n");
      -  
      +
         SClassDefs = NewHash();
      -  
      +
         sfile = NewString("");
         f_init = NewString("");
         s_header = NewString("");
      @@ -771,13 +771,13 @@ int R::cDeclaration(Node *n) {
       
       /**
          Method from Language that is called to start the entire
      -   processing off, i.e. the generation of the code. 
      +   processing off, i.e. the generation of the code.
          It is called after the input has been read and parsed.
          Here we open the output streams and generate the code.
       ***/
       int R::top(Node *n) {
         String *module = Getattr(n, "name");
      -  if(!Rpackage) 
      +  if(!Rpackage)
           Rpackage = Copy(module);
         if(!DllName)
           DllName = Copy(module);
      @@ -805,7 +805,7 @@ int R::top(Node *n) {
       
         Printf(f_runtime, "\n\n#ifndef SWIGR\n#define SWIGR\n#endif\n\n");
       
      -  
      +
         Swig_banner_target_lang(s_init, "#");
         outputCommandLineArguments(s_init);
       
      @@ -856,27 +856,27 @@ int R::top(Node *n) {
       ****************************************************/
       int R::DumpCode(Node *n) {
         String *output_filename = NewString("");
      -  
      -  
      +
      +
         /* The name of the file in which we will generate the S code. */
         Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage);
      -  
      +
       #ifdef R_SWIG_VERBOSE
         Printf(stdout, "Writing S code to %s\n", output_filename);
       #endif
      -  
      +
         File *scode = NewFile(output_filename, "w", SWIG_output_files());
         if (!scode) {
           FileErrorDisplay(output_filename);
           SWIG_exit(EXIT_FAILURE);
         }
         Delete(output_filename);
      -  
      -  
      +
      +
         Printf(scode, "%s\n\n", s_init);
         Printf(scode, "%s\n\n", s_classes);
         Printf(scode, "%s\n", sfile);
      -  
      +
         Delete(scode);
         String *outfile = Getattr(n,"outfile");
         File *runtime = NewFile(outfile,"w", SWIG_output_files());
      @@ -884,7 +884,7 @@ int R::DumpCode(Node *n) {
           FileErrorDisplay(outfile);
           SWIG_exit(EXIT_FAILURE);
         }
      -  
      +
         Printf(runtime, "%s", f_begin);
         Printf(runtime, "%s\n", f_runtime);
         Printf(runtime, "%s\n", s_header);
      @@ -902,7 +902,7 @@ int R::DumpCode(Node *n) {
             SWIG_exit(EXIT_FAILURE);
           }
           Delete(output_filename);
      -   
      +
           Printf(ns, "%s\n", s_namespace);
       
           Printf(ns, "\nexport(\n");
      @@ -921,7 +921,7 @@ int R::DumpCode(Node *n) {
       
       
       /*
      -  We may need to do more.... so this is left as a 
      +  We may need to do more.... so this is left as a
         stub for the moment.
       */
       int R::OutputClassAccessInfo(Hash *tb, File *out) {
      @@ -933,15 +933,15 @@ int R::OutputClassAccessInfo(Hash *tb, File *out) {
       /************************************************************************
         Currently this just writes the information collected about the
         different methods of the C++ classes that have been processed
      -  to the console. 
      +  to the console.
         This will be used later to define S4 generics and methods.
       **************************************************************************/
       int R::OutputClassMethodsTable(File *) {
         Hash *tb = ClassMethodsTable;
      -  
      +
         if(!tb)
           return SWIG_OK;
      -  
      +
         List *keys = Keys(tb);
         String *key;
         int i, n = Len(keys);
      @@ -965,35 +965,36 @@ int R::OutputClassMethodsTable(File *) {
       
       
       /*
      -  Iterate over the _set and <>_get 
      +  Iterate over the _set and <>_get
         elements and generate the $ and $<- functions
         that provide constrained access to the member
         fields in these elements.
       
         tb - a hash table that is built up in functionWrapper
         as we process each membervalueHandler.
      -  The entries are indexed by _set and 
      +  The entries are indexed by _set and
         _get. Each entry is a List *.
      -   
      +
         out - the stram where the code is to be written. This is the S
         code stream as we generate only S code here..
       */
       int R::OutputClassMemberTable(Hash *tb, File *out) {
         List *keys = Keys(tb), *el;
      -  
      +
         String *key;
         int i, n = Len(keys);
         /* Loop over all the  _set and _get entries in the table. */
         /* This function checks for names ending in _set - perhaps it should */
         /* use attributes of some other form, as it potentially clashes with */
         /* methods ending in _set */
      +
         if(n && outputNamespaceInfo) {
           Printf(s_namespace, "exportClasses(");
         }
         for(i = 0; i < n; i++) {
           key = Getitem(keys, i);
           el = Getattr(tb, key);
      -    
      +
           String *className = Getitem(el, 0);
           char *ptr = Char(key);
           int klen = Len(key);
      @@ -1003,42 +1004,42 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
             isSet = strcmp(ptr, "_set") == 0;
           }
       
      -    //        OutputArrayMethod(className, el, out);        
      +    //        OutputArrayMethod(className, el, out);  
           OutputMemberReferenceMethod(className, isSet, el, out);
      -    
      -    if(outputNamespaceInfo) 
      +
      +    if(outputNamespaceInfo)
             Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : "");
         }
      -  if(n && outputNamespaceInfo) { 
      +  if(n && outputNamespaceInfo) {
           Printf(s_namespace, ")\n");
         }
      -  
      +
         return n;
       }
       
       /*******************************************************************
      - Write the methods for $ or $<- for accessing a member field in an 
      + Write the methods for $ or $<- for accessing a member field in an
        struct or union (or class).
        className - the name of the struct or union (e.g. Bar for struct Bar)
      - isSet - a logical value indicating whether the method is for 
      -           modifying ($<-) or accessing ($) the member field.
      + isSet - a logical value indicating whether the method is for
      +	   modifying ($<-) or accessing ($) the member field.
        el - a list of length  2 * # accessible member elements  + 1.
      -      The first element is the name of the class. 
      +      The first element is the name of the class.
             The other pairs are  member name and the name of the R function to access it.
        out - the stream where we write the code.
       ********************************************************************/
      -int R::OutputMemberReferenceMethod(String *className, int isSet, 
      +int R::OutputMemberReferenceMethod(String *className, int isSet,
       				   List *el, File *out) {
         int numMems = Len(el), j;
         int varaccessor = 0;
      -  if (numMems == 0) 
      +  if (numMems == 0)
           return SWIG_OK;
      -  
      +
         Wrapper *f = NewWrapper(), *attr = NewWrapper();
      -  
      +
         Printf(f->def, "function(x, name%s)", isSet ? ", value" : "");
         Printf(attr->def, "function(x, i, j, ...%s)", isSet ? ", value" : "");
      -  
      +
         Printf(f->code, "{\n");
         Printf(f->code, "%saccessorFuns = list(", tab8);
       
      @@ -1049,7 +1050,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
           String *dup = Getitem(el, j + 1);
           char *ptr = Char(dup);
           ptr = &ptr[Len(dup) - 3];
      -    
      +
           if (!strcmp(ptr, "get"))
             varaccessor++;
       
      @@ -1069,7 +1070,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
           } else {
             pitem = Copy(item);
           }
      -    if (has_prev) 
      +    if (has_prev)
             Printf(f->code, ", ");
           Printf(f->code, "'%s' = %s", pitem, dup);
           has_prev = true;
      @@ -1077,7 +1078,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
         }
         Delete(itemList);
         Printf(f->code, ");\n");
      -  
      +
         if (!isSet && varaccessor > 0) {
           Printf(f->code, "%svaccessors = c(", tab8);
           int first = 1;
      @@ -1086,7 +1087,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
             String *dup = Getitem(el, j + 1);
             char *ptr = Char(dup);
             ptr = &ptr[Len(dup) - 3];
      -      
      +
             if (!strcmp(ptr, "get")) {
       	Printf(f->code, "%s'%s'", first ? "" : ", ", item);
       	first = 0;
      @@ -1094,15 +1095,15 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
           }
           Printf(f->code, ");\n");
         }
      -  
      -  
      +
      +
         /*    Printv(f->code, tab8,
       	"idx = pmatch(name, names(accessorFuns))\n",
       	tab8,
       	"if(is.na(idx)) {\n",
      -	tab8, tab4, 
      +	tab8, tab4,
       	"stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className,
      -	": fields are \", paste(names(accessorFuns), sep = \", \")", 
      +	": fields are \", paste(names(accessorFuns), sep = \", \")",
       	")", "\n}\n", NIL); */
         Printv(f->code, ";", tab8,
       	 "idx = pmatch(name, names(accessorFuns));\n",
      @@ -1124,67 +1125,67 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
           }
         }
         Printf(f->code, "}\n");
      -  
      -  
      +
      +
         Printf(out, "# Start of accessor method for %s\n", className);
         Printf(out, "setMethod('$%s', '_p%s', ",
      -	 isSet ? "<-" : "", 
      -	 getRClassName(className)); 
      +	 isSet ? "<-" : "",
      +	 getRClassName(className));
         Wrapper_print(f, out);
         Printf(out, ");\n");
      -  
      +
         if(isSet) {
      -    Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", 
      -	   getRClassName(className)); 
      +    Printf(out, "setMethod('[[<-', c('_p%s', 'character'),",
      +	   getRClassName(className));
           Insert(f->code, 2, "name = i;\n");
           Printf(attr->code, "%s", f->code);
           Wrapper_print(attr, out);
           Printf(out, ");\n");
         }
      -  
      +
         DelWrapper(attr);
         DelWrapper(f);
      -  
      +
         Printf(out, "# end of accessor method for %s\n", className);
      -  
      +
         return SWIG_OK;
       }
       
       /*******************************************************************
      - Write the methods for [ or [<- for accessing a member field in an 
      + Write the methods for [ or [<- for accessing a member field in an
        struct or union (or class).
        className - the name of the struct or union (e.g. Bar for struct Bar)
        el - a list of length  2 * # accessible member elements  + 1.
      -      The first element is the name of the class. 
      +      The first element is the name of the class.
             The other pairs are  member name and the name of the R function to access it.
        out - the stream where we write the code.
       ********************************************************************/
       int R::OutputArrayMethod(String *className, List *el, File *out) {
         int numMems = Len(el), j;
      -  
      +
         if(!el || numMems == 0)
           return(0);
      -  
      +
         Printf(out, "# start of array methods for %s\n", className);
         for(j = 0; j < numMems; j+=3) {
           String *item = Getitem(el, j);
           String *dup = Getitem(el, j + 1);
           if (!Strcmp(item, "__getitem__")) {
      -      Printf(out, 
      -	     "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", 
      +      Printf(out,
      +	     "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ",
       	     getRClassName(className));
             Printf(out, "  sapply(i, function (n)  %s(x, as.integer(n-1))))\n\n", dup);
           }
           if (!Strcmp(item, "__setitem__")) {
      -      Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", 
      +      Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)",
       	     getRClassName(className));
             Printf(out, "  sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup);
           }
      -    
      +
         }
      -  
      +
         Printf(out, "# end of array methods for %s\n", className);
      -  
      +
         return SWIG_OK;
       }
       
      @@ -1200,9 +1201,9 @@ int R::enumDeclaration(Node *n) {
       
         String *name = Getattr(n, "name");
         String *tdname = Getattr(n, "tdname");
      -  
      +
         /* Using name if tdname is empty. */
      -  
      +
         if(Len(tdname) == 0)
           tdname = name;
       
      @@ -1211,40 +1212,40 @@ int R::enumDeclaration(Node *n) {
           Language::enumDeclaration(n);
           return SWIG_OK;
         }
      -  
      +
         String *mangled_tdname = SwigType_manglestr(tdname);
         String *scode = NewString("");
      -  
      -  Printv(scode, "defineEnumeration('", mangled_tdname, "'", 
      +
      +  Printv(scode, "defineEnumeration('", mangled_tdname, "'",
       	 ",\n",  tab8, tab8, tab4, ".values = c(\n", NIL);
      -  
      +
         Node *c;
         int value = -1; // First number is zero
         for (c = firstChild(n); c; c = nextSibling(c)) {
           //      const char *tag = Char(nodeType(c));
      -    //      if (Strcmp(tag,"cdecl") == 0) {        
      +    //      if (Strcmp(tag,"cdecl") == 0) {
           name = Getattr(c, "name");
           String *val = Getattr(c, "enumvalue");
           if(val && Char(val)) {
             int inval = (int) getNumber(val);
      -      if(inval == DEFAULT_NUMBER) 
      +      if(inval == DEFAULT_NUMBER)
       	value++;
      -      else 
      +      else
       	value = inval;
           } else
             value++;
      -    
      +
           Printf(scode, "%s%s%s'%s' = %d%s\n", tab8, tab8, tab8, name, value,
       	   nextSibling(c) ? ", " : "");
           //      }
         }
      -  
      +
         Printv(scode, "))", NIL);
         Printf(sfile, "%s\n", scode);
      -  
      +
         Delete(scode);
         Delete(mangled_tdname);
      -  
      +
         return SWIG_OK;
       }
       
      @@ -1253,27 +1254,27 @@ int R::enumDeclaration(Node *n) {
       **************************************************************/
       int R::variableWrapper(Node *n) {
         String *name = Getattr(n, "sym:name");
      -  
      +
         processing_variable = 1;
         Language::variableWrapper(n); // Force the emission of the _set and _get function wrappers.
         processing_variable = 0;
      -  
      -  
      +
      +
         SwigType *ty = Getattr(n, "type");
         int addCopyParam = addCopyParameter(ty);
      -  
      +
         //XXX
         processType(ty, n);
      -  
      +
         if(!SwigType_isconst(ty)) {
           Wrapper *f = NewWrapper();
      -    Printf(f->def, "%s = \nfunction(value%s)\n{\n", 
      +    Printf(f->def, "%s = \nfunction(value%s)\n{\n",
       	   name, addCopyParam ? ", .copy = FALSE" : "");
      -    Printv(f->code, "if(missing(value)) {\n", 
      +    Printv(f->code, "if(missing(value)) {\n",
       	   name, "_get(", addCopyParam ? ".copy" : "", ")\n}", NIL);
      -    Printv(f->code, " else {\n", 
      +    Printv(f->code, " else {\n",
       	   name, "_set(value)\n}\n}", NIL);
      -    
      +
           Wrapper_print(f, sfile);
           DelWrapper(f);
         } else {
      @@ -1284,7 +1285,7 @@ int R::variableWrapper(Node *n) {
       }
       
       
      -void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, 
      +void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
       		    int isSet) {
         if(isSet < 0) {
           int n = Len(name);
      @@ -1293,9 +1294,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
             isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
           }
         }
      -  
      +
         List *l = isSet ? class_member_set_functions : class_member_functions;
      -  
      +
         if(!l) {
           l = NewList();
           if(isSet)
      @@ -1303,10 +1304,10 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
           else
             class_member_functions = l;
         }
      -  
      +
         Append(l, memberName);
         Append(l, name);
      -  
      +
         String *tmp = NewString("");
         Wrapper_print(wrapper, tmp);
         Append(l, tmp);
      @@ -1325,8 +1326,8 @@ struct Overloaded {
       };
       
       
      -List * R::Swig_overload_rank(Node *n, 
      -				 bool script_lang_wrapping) {
      +List * R::Swig_overload_rank(Node *n,
      +	                     bool script_lang_wrapping) {
         Overloaded  nodes[MAX_OVERLOAD];
         int         nnodes = 0;
         Node *o = Getattr(n,"sym:overloaded");
      @@ -1357,7 +1358,7 @@ List * R::Swig_overload_rank(Node *n,
           }
           c = Getattr(c,"sym:nextSibling");
         }
      -  
      +
         /* Sort the declarations by required argument count */
         {
           int i,j;
      @@ -1444,7 +1445,7 @@ List * R::Swig_overload_rank(Node *n,
       	      }
       
       	      /* Need subtype check here.  If t2 is a subtype of t1, then we need to change the
      -                 order */
      +	         order */
       
       	      if (SwigType_issubtype(t2,t1)) {
       		Overloaded t = nodes[i];
      @@ -1560,7 +1561,7 @@ List * R::Swig_overload_rank(Node *n,
           int i;
           for (i = 0; i < nnodes; i++) {
             if (nodes[i].error)
      -        Setattr(nodes[i].n, "overload:ignore", "1");
      +	Setattr(nodes[i].n, "overload:ignore", "1");
             Append(result,nodes[i].n);
             //      Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms));
             //      Swig_print_node(nodes[i].n);
      @@ -1573,7 +1574,7 @@ void R::dispatchFunction(Node *n) {
         Wrapper *f = NewWrapper();
         String *symname = Getattr(n, "sym:name");
         String *nodeType = Getattr(n, "nodeType");
      -  bool constructor = (!Cmp(nodeType, "constructor")); 
      +  bool constructor = (!Cmp(nodeType, "constructor"));
       
         String *sfname = NewString(symname);
       
      @@ -1587,7 +1588,7 @@ void R::dispatchFunction(Node *n) {
         }
         List *dispatch = Swig_overload_rank(n, true);
         int   nfunc = Len(dispatch);
      -  Printv(f->code, 
      +  Printv(f->code,
       	 "argtypes <- mapply(class, list(...));\n",
       	 "argv <- list(...);\n",
       	 "argc <- length(argtypes);\n", NIL );
      @@ -1600,7 +1601,7 @@ void R::dispatchFunction(Node *n) {
           Parm *pi = Getattr(ni,"wrap:parms");
           int num_arguments = emit_num_arguments(pi);
       
      -    String *overname = Getattr(ni,"sym:overname");      
      +    String *overname = Getattr(ni,"sym:overname");
           if (cur_args != num_arguments) {
             if (cur_args != -1) {
       	Printv(f->code, "} else ", NIL);
      @@ -1649,29 +1650,29 @@ void R::dispatchFunction(Node *n) {
       	if (tm) {
       	  if (Strcmp(tm,"numeric")==0) {
       	    Printf(f->code, "%sis.numeric(argv[[%d]])",
      -		j == 0 ? "" : " && ",
      -		j+1);
      +	           j == 0 ? "" : " && ",
      +	           j+1);
       	  }
       	  else if (Strcmp(tm,"integer")==0) {
       	    Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
      -		j == 0 ? "" : " && ",
      -		j+1, j+1);
      +	           j == 0 ? "" : " && ",
      +	           j+1, j+1);
       	  }
       	  else if (Strcmp(tm,"character")==0) {
       	    Printf(f->code, "%sis.character(argv[[%d]])",
      -		j == 0 ? "" : " && ",
      -		j+1);
      +	           j == 0 ? "" : " && ",
      +	           j+1);
       	  }
       	  else {
       	    Printf(f->code, "%sextends(argtypes[%d], '%s')",
      -		j == 0 ? "" : " && ",
      -		j+1,
      -		tm);
      +	           j == 0 ? "" : " && ",
      +	           j+1,
      +	           tm);
       	  }
       	}
       	if (!SwigType_ispointer(Getattr(p, "type"))) {
       	  Printf(f->code, " && length(argv[[%d]]) == 1",
      -	      j+1);
      +	         j+1);
       	}
       	p = Getattr(p, "tmap:in:next");
             }
      @@ -1699,40 +1700,40 @@ void R::dispatchFunction(Node *n) {
       int R::functionWrapper(Node *n) {
         String *fname = Getattr(n, "name");
         String *iname = Getattr(n, "sym:name");
      -  String *type = Getattr(n, "type"); 
      -  
      +  String *type = Getattr(n, "type");
      +
         if (debugMode) {
      -    Printf(stdout, 
      +    Printf(stdout,
       	   " %s %s %s\n", fname, iname, type);
         }
         String *overname = 0;
         String *nodeType = Getattr(n, "nodeType");
      -  bool constructor = (!Cmp(nodeType, "constructor")); 
      -  bool destructor = (!Cmp(nodeType, "destructor")); 
      -  
      +  bool constructor = (!Cmp(nodeType, "constructor"));
      +  bool destructor = (!Cmp(nodeType, "destructor"));
      +
         String *sfname = NewString(iname);
      -  
      +
         if (constructor)
           Replace(sfname, "new_", "", DOH_REPLACE_FIRST);
      -  
      +
         if (Getattr(n,"sym:overloaded")) {
      -    overname = Getattr(n,"sym:overname");      
      +    overname = Getattr(n,"sym:overname");
           Append(sfname, overname);
         }
      -  
      -  if (debugMode) 
      -    Printf(stdout, 
      +
      +  if (debugMode)
      +    Printf(stdout,
       	   " processing parameters\n");
      -  
      -  
      +
      +
         ParmList *l = Getattr(n, "parms");
         Parm *p;
         String *tm;
      -  
      +
         p = l;
         while(p) {
           SwigType *resultType = Getattr(p, "type");
      -    if (expandTypedef(resultType) && 
      +    if (expandTypedef(resultType) &&
       	SwigType_istypedef(resultType)) {
             SwigType *resolved =
       	SwigType_typedef_resolve_all(resultType);
      @@ -1741,43 +1742,43 @@ int R::functionWrapper(Node *n) {
             }
           }
           p = nextSibling(p);
      -  } 
      +  }
       
      -  String *unresolved_return_type = 
      +  String *unresolved_return_type =
           Copy(type);
         if (expandTypedef(type) &&
             SwigType_istypedef(type)) {
      -    SwigType *resolved = 
      +    SwigType *resolved =
             SwigType_typedef_resolve_all(type);
           if (expandTypedef(resolved)) {
             type = Copy(resolved);
             Setattr(n, "type", type);
           }
         }
      -  if (debugMode) 
      +  if (debugMode)
           Printf(stdout, " unresolved_return_type %s\n",
       	   unresolved_return_type);
         if(processing_member_access_function) {
           if (debugMode)
      -      Printf(stdout, " '%s' '%s' '%s' '%s'\n", 
      +      Printf(stdout, " '%s' '%s' '%s' '%s'\n",
       	     fname, iname, member_name, class_name);
      -    
      +
           if(opaqueClassDeclaration)
             return SWIG_OK;
      -      
      -      
      -    /* Add the name of this member to a list for this class_name. 
      +
      +
      +    /* Add the name of this member to a list for this class_name.
              We will dump all these at the end. */
      -    
      +
           int n = Len(iname);
           char *ptr = Char(iname);
           bool isSet(0);
           if (n > 4) isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0;
      -    
      -    
      +
      +
           String *tmp = NewString("");
           Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get");
      -    
      +
           List *memList = Getattr(ClassMemberTable, tmp);
           if(!memList) {
             memList = NewList();
      @@ -1788,29 +1789,29 @@ int R::functionWrapper(Node *n) {
           Append(memList, member_name);
           Append(memList, iname);
         }
      -  
      +
         int i;
         int nargs;
      -  
      +
         String *wname = Swig_name_wrapper(iname);
         Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST);
      -  if(overname) 
      +  if(overname)
           Append(wname, overname);
         Setattr(n,"wrap:name", wname);
       
         Wrapper *f = NewWrapper();
         Wrapper *sfun = NewWrapper();
      -  
      +
         int isVoidReturnType = (Strcmp(type, "void") == 0);
      -  // Need to use the unresolved return type since 
      -  // typedef resolution removes the const which causes a 
      +  // Need to use the unresolved return type since
      +  // typedef resolution removes the const which causes a
         // mismatch with the function action
         emit_return_variable(n, unresolved_return_type, f);
       
         SwigType *rtype = Getattr(n, "type");
         int addCopyParam = 0;
       
      -  if(!isVoidReturnType) 
      +  if(!isVoidReturnType)
           addCopyParam = addCopyParameter(rtype);
       
       
      @@ -1819,23 +1820,23 @@ int R::functionWrapper(Node *n) {
       
         //    if(addCopyParam)
         if (debugMode)
      -    Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", 
      +    Printf(stdout, "Adding a .copy argument to %s for %s = %s\n",
       	   iname, type, addCopyParam ? "yes" : "no");
       
         Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL);
       
      -  Printf(sfun->def, "# Start of %s\n", iname);         
      +  Printf(sfun->def, "# Start of %s\n", iname);
         Printv(sfun->def, "\n`", sfname, "` = function(", NIL);
       
         if(outputNamespaceInfo) {//XXX Need to be a little more discriminating
      -      if (constructor) {
      -          String *niname = Copy(iname);
      -          Replace(niname, "new_", "", DOH_REPLACE_FIRST);
      -          addNamespaceFunction(niname);
      -          Delete(niname);
      -      } else {
      -          addNamespaceFunction(iname);
      -      }
      +    if (constructor) {
      +      String *niname = Copy(iname);
      +      Replace(niname, "new_", "", DOH_REPLACE_FIRST);
      +      addNamespaceFunction(niname);
      +      Delete(niname);
      +    } else {
      +      addNamespaceFunction(iname);
      +    }
         }
       
         Swig_typemap_attach_parms("scoercein", l, f);
      @@ -1898,7 +1899,7 @@ int R::functionWrapper(Node *n) {
             name = Copy(name);
             Insert(name, 0, "s_");
           }
      -      
      +
           if(processing_variable) {
             name = Copy(name);
             Insert(name, 0, "s_");
      @@ -1923,7 +1924,7 @@ int R::functionWrapper(Node *n) {
       
       	String *snargs = NewStringf("%d", nargs);
       	Printv(sfun->code, "if(is.function(", name, ")) {", "\n",
      -	       "assert('...' %in% names(formals(", name, 
      +	       "assert('...' %in% names(formals(", name,
       	       ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL);
       	Delete(snargs);
       
      @@ -1978,11 +1979,11 @@ int R::functionWrapper(Node *n) {
       
       
             Printf(f->code,"%s\n",tm);
      -      if(funcptr_name) 
      -	Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n", 
      +      if(funcptr_name)
      +	Printf(f->code, "} else {\n%s = %s;\nR_SWIG_pushCallbackFunctionData(%s, NULL);\n}\n",
       	       lname, funcptr_name, name);
             Printv(f->def, inFirstArg ? "" : ", ", "SEXP ", name, NIL);
      -      if (Len(name) != 0) 
      +      if (Len(name) != 0)
       	inFirstArg = false;
             p = Getattr(p,"tmap:in:next");
       
      @@ -1999,7 +2000,7 @@ int R::functionWrapper(Node *n) {
           Printf(s_inputMap, "%s%s='%s'", inFirstType ? "" : ", ", name, tm);
           inFirstType = false;
       
      -    if(funcptr_name) 
      +    if(funcptr_name)
             Delete(funcptr_name);
         } /* end of looping over parameters. */
       
      @@ -2050,9 +2051,9 @@ int R::functionWrapper(Node *n) {
         String *actioncode = emit_action(n);
       
         /* Deal with the explicit return value. */
      -  if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { 
      +  if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
           SwigType *retType = Getattr(n, "type");
      -    //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");     
      +    //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
           /*      if(SwigType_isarray(retType)) {
       	    defineArrayAccessors(retType);
       	    } */
      @@ -2073,11 +2074,11 @@ int R::functionWrapper(Node *n) {
             Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n");
             Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n");
             Printf(f->code, "}\n else {\n");
      -    } 
      +    }
       #endif
           Printf(f->code, "%s\n", tm);
       #if 0
      -    if(addCopyParam) 
      +    if(addCopyParam)
             Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */
       #endif
       
      @@ -2094,8 +2095,8 @@ int R::functionWrapper(Node *n) {
           if(!isVoidReturnType)
             Printf(tmp, "Rf_protect(r_ans);\n");
       
      -    Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n", 
      -	   numOutArgs + !isVoidReturnType, 
      +    Printf(tmp, "Rf_protect(R_OutputValues = Rf_allocVector(VECSXP,%d));\nr_nprotect += %d;\n",
      +	   numOutArgs + !isVoidReturnType,
       	   isVoidReturnType ? 1 : 2);
       
           if(!isVoidReturnType)
      @@ -2103,7 +2104,7 @@ int R::functionWrapper(Node *n) {
           Printf(tmp, "r_ans = R_OutputValues;\n");
       
           Insert(outargs, 0, tmp);
      -    Delete(tmp); 
      +    Delete(tmp);
       
       
       
      @@ -2138,30 +2139,30 @@ int R::functionWrapper(Node *n) {
           Replaceall(tm,"$source","ans");
           Replaceall(tm,"$result","ans");
           if (constructor) {
      -        Node * parent = Getattr(n, "parentNode");
      -        String * smartname = Getattr(parent, "feature:smartptr");
      -        if (smartname) {
      -            smartname = getRClassName(smartname, 1, 1);
      -            Replaceall(tm, "$R_class", smartname);
      -            Delete(smartname);
      -        }
      +      Node * parent = Getattr(n, "parentNode");
      +      String * smartname = Getattr(parent, "feature:smartptr");
      +      if (smartname) {
      +	smartname = getRClassName(smartname, 1, 1);
      +	Replaceall(tm, "$R_class", smartname);
      +	Delete(smartname);
      +      }
           }
           replaceRClass(tm, Getattr(n, "type"));
           Chop(tm);
         }
       
       
      -  Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, 
      +  Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
       	 "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
         if(Len(tm))
           {
      -      Printf(sfun->code, "%s\n\n", tm); 
      +      Printf(sfun->code, "%s\n\n", tm);
             if (constructor)
      -	{ 
      +	{
       	  String *finalizer = NewString(iname);
       	  Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
       	  Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer);
      -	}                                                                      
      +	}
             Printf(sfun->code, "ans\n");
           }
       
      @@ -2182,17 +2183,17 @@ int R::functionWrapper(Node *n) {
         if(tm) {
           SwigType *retType = Getattr(n, "type");
           replaceRClass(tm, retType);
      -  }  
      -    
      -  Printv(sfile, "attr(`", sfname, "`, 'returnType') = '", 
      -	 isVoidReturnType ? "void" : (tm ? tm : ""), 
      -	 "'\n", NIL); 
      -    
      +  }
      +
      +  Printv(sfile, "attr(`", sfname, "`, 'returnType') = '",
      +	 isVoidReturnType ? "void" : (tm ? tm : ""),
      +	 "'\n", NIL);
      +
         if(nargs > 0)
           Printv(sfile, "attr(`", sfname, "`, \"inputTypes\") = c(",
       	   s_inputTypes, ")\n", NIL);
      -  Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('", 
      -	 sfname, "'))\n\n", NIL); 
      +  Printv(sfile, "class(`", sfname, "`) = c(\"SWIGFunction\", class('",
      +	 sfname, "'))\n\n", NIL);
       
         if (memoryProfile) {
           Printv(sfile, "memory.profile()\n", NIL);
      @@ -2205,8 +2206,8 @@ int R::functionWrapper(Node *n) {
       
       
       
      -  /* If we are dealing with a method in an C++ class, then 
      -     add the name of the R function and its definition. 
      +  /* If we are dealing with a method in an C++ class, then
      +     add the name of the R function and its definition.
            XXX need to figure out how to store the Wrapper if possible in the hash/list.
            Would like to be able to do this so that we can potentially insert
         */
      @@ -2240,21 +2241,21 @@ int R::constantWrapper(Node *n) {
       }
       
       /*****************************************************
      - Add the specified routine name to the collection of 
      + Add the specified routine name to the collection of
        generated routines that are called from R functions.
      - This is used to register the routines with R for 
      + This is used to register the routines with R for
        resolving symbols.
       
        rname - the name of the routine
      - nargs - the number of arguments it expects. 
      + nargs - the number of arguments it expects.
       ******************************************************/
       int R::addRegistrationRoutine(String *rname, int nargs) {
      -  if(!registrationTable) 
      +  if(!registrationTable)
           registrationTable = NewHash();
       
      -  String *el = 
      +  String *el =
           NewStringf("{\"%s\", (DL_FUNC) &%s, %d}", rname, rname, nargs);
      -  
      +
         Setattr(registrationTable, rname, el);
       
         return SWIG_OK;
      @@ -2267,17 +2268,17 @@ int R::addRegistrationRoutine(String *rname, int nargs) {
       ******************************************************/
       int R::outputRegistrationRoutines(File *out) {
         int i, n;
      -  if(!registrationTable) 
      +  if(!registrationTable)
           return(0);
      -  if(inCPlusMode) 
      +  if(inCPlusMode)
           Printf(out, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
       
         Printf(out, "#include \n\n");
      -  if(inCPlusMode) 
      +  if(inCPlusMode)
           Printf(out, "#ifdef __cplusplus\n}\n#endif\n\n");
       
         Printf(out, "SWIGINTERN R_CallMethodDef CallEntries[] = {\n");
      -    
      +
         List *keys = Keys(registrationTable);
         n = Len(keys);
         for(i = 0; i < n; i++)
      @@ -2289,7 +2290,7 @@ int R::outputRegistrationRoutines(File *out) {
           if (inCPlusMode)
             Printv(out, "extern \"C\" ", NIL);
           { /* R allows pckage names to have '.' in the name, which is not allowed in C++ var names
      -         we simply replace all occurrences of '.' with '_' to construct the var name */
      +	 we simply replace all occurrences of '.' with '_' to construct the var name */
             String * Rpackage_sane = Copy(Rpackage);
             Replace(Rpackage_sane, ".", "_", DOH_REPLACE_ANY);
             Printf(out, "SWIGEXPORT void R_init_%s(DllInfo *dll) {\n", Rpackage_sane);
      @@ -2310,14 +2311,14 @@ int R::outputRegistrationRoutines(File *out) {
       /****************************************************************************
         Process a struct, union or class declaration in the source code,
         or an anonymous typedef struct
      - 
      +
       *****************************************************************************/
      -//XXX What do we need to do here - 
      +//XXX What do we need to do here -
       // Define an S4 class to refer to this.
       
       void R::registerClass(Node *n) {
      -  String *name = Getattr(n, "name");    
      -  String *kind = Getattr(n, "kind");    
      +  String *name = Getattr(n, "name");
      +  String *kind = Getattr(n, "kind");
       
         if (debugMode)
           Swig_print_node(n);
      @@ -2333,42 +2334,57 @@ void R::registerClass(Node *n) {
       	Printf(base, "c(");
       	for(int i = 0; i < Len(l); i++) {
       	  registerClass(Getitem(l, i));
      -	  Printf(base, "'_p%s'%s", 
      -		 SwigType_manglestr(Getattr(Getitem(l, i), "name")), 
      -		 i < Len(l)-1 ? ", " : "");                
      +	  Printf(base, "'_p%s'%s",
      +		 SwigType_manglestr(Getattr(Getitem(l, i), "name")),
      +		 i < Len(l)-1 ? ", " : "");
       	}
       	Printf(base, ")");
             } else {
       	base = NewString("'C++Reference'");
             }
      -    } else 
      +    } else
             base = NewString("'ExternalReference'");
       
           Printf(s_classes, "setClass('%s', contains = %s)\n", sname, base);
           Delete(base);
           String *smartptr = Getattr(n, "feature:smartptr");
           if (smartptr) {
      -        SwigType *spt = Swig_cparse_type(smartptr);
      -        String *smart = SwigType_typedef_resolve_all(spt);
      -        String *smart_rname = SwigType_manglestr(smart);
      -        Printf(s_classes, "setClass('_p%s', contains = c('%s'))\n", smart_rname, sname);
      -        Delete(spt);
      -        Delete(smart);
      -        Delete(smart_rname);
      +      List *l = Getattr(n, "bases");
      +      SwigType *spt = Swig_cparse_type(smartptr);
      +      String *smart = SwigType_typedef_resolve_all(spt);
      +      String *smart_rname = SwigType_manglestr(smart);
      +      Printf(s_classes, "setClass('_p%s', contains = c('%s'", smart_rname, sname);
      +      Delete(spt);
      +      Delete(smart);
      +      Delete(smart_rname);
      +      for(int i = 0; i < Len(l); i++) {
      +	Node * b = Getitem(l, i);
      +	smartptr = Getattr(b, "feature:smartptr");
      +	if (smartptr) {
      +	  spt = Swig_cparse_type(smartptr);
      +	  smart = SwigType_typedef_resolve_all(spt);
      +	  smart_rname = SwigType_manglestr(smart);
      +	  Printf(s_classes, ", '_p%s'", smart_rname);
      +	  Delete(spt);
      +	  Delete(smart);
      +	  Delete(smart_rname);
      +	}
      +      }
      +      Printf(s_classes, "))\n");
           }
         }
       }
       
       int R::classDeclaration(Node *n) {
       
      -  String *name = Getattr(n, "name");    
      -  String *kind = Getattr(n, "kind");    
      +  String *name = Getattr(n, "name");
      +  String *kind = Getattr(n, "kind");
       
         if (debugMode)
           Swig_print_node(n);
         registerClass(n);
       
      -    
      +
         /* If we have a typedef union { ... } U, then we never get to see the typedef
            via a regular call to typedefHandler. Instead, */
         if(Getattr(n, "unnamed") && Getattr(n, "storage") && Strcmp(Getattr(n, "storage"), "typedef") == 0
      @@ -2388,7 +2404,7 @@ int R::classDeclaration(Node *n) {
         opaqueClassDeclaration = NULL;
       
       
      -  // OutputArrayMethod(name, class_member_functions, sfile);        
      +  // OutputArrayMethod(name, class_member_functions, sfile);
         if (class_member_functions)
           OutputMemberReferenceMethod(name, 0, class_member_functions, sfile);
         if (class_member_set_functions)
      @@ -2410,7 +2426,7 @@ int R::classDeclaration(Node *n) {
         }
         if(!opaque && !Strcmp(kind, "struct") && copyStruct) {
       
      -    String *def = 
      +    String *def =
             NewStringf("setClass(\"%s\",\n%srepresentation(\n", name, tab4);
           bool firstItem = true;
       
      @@ -2419,7 +2435,7 @@ int R::classDeclaration(Node *n) {
             String *tp;
       
             elName = Getattr(c, "name");
      - 
      +
             String *elKind = Getattr(c, "kind");
             if (!Equal(elKind, "variable")) {
       	c = nextSibling(c);
      @@ -2449,12 +2465,12 @@ int R::classDeclaration(Node *n) {
       
             if (!firstItem) {
       	Printf(def, ",\n");
      -      } 
      -      //	    else 
      +      }
      +      //	    else
             //XXX How can we tell if this is already done.
             //	      SwigType_push(elType, elDecl);
      -	    
      -	    
      +	
      +	
             // returns ""  tp = processType(elType, c, NULL);
             //	    Printf(stdout, " elType %p\n", elType);
             //	    tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
      @@ -2493,7 +2509,7 @@ int R::classDeclaration(Node *n) {
       int R::generateCopyRoutines(Node *n) {
         Wrapper *copyToR = NewWrapper();
         Wrapper *copyToC = NewWrapper();
      -  
      +
         String *name = Getattr(n, "name");
         String *tdname = Getattr(n, "tdname");
         String *kind = Getattr(n, "kind");
      @@ -2510,9 +2526,9 @@ int R::generateCopyRoutines(Node *n) {
         if (debugMode)
           Printf(stdout, "generateCopyRoutines:  name = %s, %s\n", name, type);
       
      -  Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n", 
      +  Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n",
       	 mangledName, name);
      -  Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n", 
      +  Printf(copyToC->def, "CopyToC%s = function(value, obj)\n{\n",
       	 mangledName);
       
         Node *c = firstChild(n);
      @@ -2548,22 +2564,22 @@ int R::generateCopyRoutines(Node *n) {
         }
         Printf(copyToR->code, "obj;\n}\n\n");
         String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref.
      -  Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName);  
      -  
      +  Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName);
      +
         Wrapper_print(copyToR, sfile);
         Printf(copyToC->code, "obj\n}\n\n");
         Wrapper_print(copyToC, sfile);
      -  
      -  
      -  Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);  
      -  Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, 
      +
      +
      +  Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);
      +  Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName,
       	 mangledName);
      -  Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, 
      +  Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName,
       	 mangledName);
      -  
      -  Printf(sfile, "# End definition of copy methods for %s\n", rclassName);  
      -  Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName);  
      -      
      +
      +  Printf(sfile, "# End definition of copy methods for %s\n", rclassName);
      +  Printf(sfile, "# End definition of copy functions & methods for %s\n", rclassName);
      +
         String *m = NewStringf("%sCopyToR", name);
         addNamespaceMethod(m);
         char *tt = Char(m);  tt[Len(m)-1] = 'C';
      @@ -2580,9 +2596,9 @@ int R::generateCopyRoutines(Node *n) {
       
       
       /*****
      -      Called when there is a typedef to be invoked. 
      +      Called when there is a typedef to be invoked.
       
      -      XXX Needs to be enhanced or split to handle the case where we have a 
      +      XXX Needs to be enhanced or split to handle the case where we have a
             typedef within a classDeclaration emission because the struct/union/etc.
             is anonymous.
       ******/
      @@ -2600,7 +2616,7 @@ int R::typedefHandler(Node *n) {
           trueName += 7;
           if (debugMode)
             Printf(stdout, " Defining S class %s\n", trueName);
      -    Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n", 
      +    Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n",
       	   SwigType_manglestr(name));
         }
       
      @@ -2612,7 +2628,7 @@ int R::typedefHandler(Node *n) {
       /*********************
         Called when processing a field in a "class", i.e. struct, union or
         actual class.  We set a state variable so that we can correctly
      -  interpret the resulting functionWrapper() call and understand that 
      +  interpret the resulting functionWrapper() call and understand that
         it is for a field element.
       **********************/
       int R::membervariableHandler(Node *n) {
      @@ -2621,7 +2637,7 @@ int R::membervariableHandler(Node *n) {
         processing_member_access_function = 1;
         member_name = Getattr(n,"sym:name");
         if (debugMode)
      -    Printf(stdout, " name = %s, sym:name = %s\n", 
      +    Printf(stdout, " name = %s, sym:name = %s\n",
       	   Getattr(n, "name"), member_name);
       
         int status(Language::membervariableHandler(n));
      @@ -2650,7 +2666,7 @@ String * R::runtimeCode() {
       
       
       /**
      -   Called when SWIG wants to initialize this 
      +   Called when SWIG wants to initialize this
          We initialize anythin we want here.
          Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module.
          Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error.
      @@ -2672,7 +2688,7 @@ void R::main(int argc, char *argv[]) {
         this->Argc = argc;
         this->Argv = argv;
       
      -  allow_overloading();// can we support this?    
      +  allow_overloading();// can we support this?
       
         for(int i = 0; i < argc; i++) {
           if(strcmp(argv[i], "-package") == 0) {
      @@ -2761,9 +2777,9 @@ int R::outputCommandLineArguments(File *out)
       
       
       
      -/* How SWIG instantiates an object from this module. 
      +/* How SWIG instantiates an object from this module.
          See swigmain.cxx */
      -extern "C" 
      +extern "C"
       Language *swig_r(void) {
         return new R();
       }
      @@ -2782,11 +2798,11 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
         SwigType *tmp = Getattr(n, "tdname");
         if (debugMode)
           Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
      -  
      +
         SwigType *td = t;
         if (expandTypedef(t) &&
             SwigType_istypedef(t)) {
      -    SwigType *resolved = 
      +    SwigType *resolved =
             SwigType_typedef_resolve_all(t);
           if (expandTypedef(resolved)) {
             td = Copy(resolved);
      @@ -2800,10 +2816,10 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
             if (debugMode)
       	Printf(stdout, " Defining class %s\n",  b);
       
      -      Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);       
      +      Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);
             Setattr(SClassDefs, b, b);
           }
      -     
      +
         }
       
       
      @@ -2812,9 +2828,9 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
       
         if(SwigType_isfunctionpointer(t)) {
           if (debugMode)
      -      Printf(stdout, 
      +      Printf(stdout,
       	     " Defining pointer handler %s\n",  t);
      -       
      +
           String *tmp = createFunctionPointerHandler(t, n, nargs);
           return tmp;
         }
      @@ -2826,17 +2842,4 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
           return NULL;
       }
       
      -
      -
      -
      -
      -
      -
      -
      -
       /*************************************************************************************/
      -
      -
      -
      -
      -
      
      From 711ae145418b6048234653d0fbba38020fb89333 Mon Sep 17 00:00:00 2001
      From: "Lamarre, Mathieu" 
      Date: Thu, 31 Aug 2017 09:43:07 -0400
      Subject: [PATCH 0690/2031] Define _DEBUG to 1 to do exactly like /LDd, /MDd or
       /MTd compiler options
      
      ---
       Lib/python/pyruntime.swg | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg
      index fad97be9f..26d3081a0 100644
      --- a/Lib/python/pyruntime.swg
      +++ b/Lib/python/pyruntime.swg
      @@ -3,7 +3,7 @@
       /* Use debug wrappers with the Python release dll */
       # undef _DEBUG
       # include 
      -# define _DEBUG
      +# define _DEBUG 1
       #else
       # include 
       #endif
      
      From eb68e4375dccfb337fad0896b4a5510c5515b3ad Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Tue, 5 Sep 2017 18:44:00 +0100
      Subject: [PATCH 0691/2031] Add support for member function pointers with
       ref-qualifiers
      
      ---
       Examples/test-suite/cpp11_ref_qualifiers.i  | 117 ++++++++++++++++++++
       Examples/test-suite/member_funcptr_galore.i |   2 +-
       Source/CParse/parser.y                      |  13 ++-
       Source/Swig/stype.c                         | 108 +++++++++++-------
       4 files changed, 195 insertions(+), 45 deletions(-)
      
      diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i
      index 7e9f0e170..781e52f23 100644
      --- a/Examples/test-suite/cpp11_ref_qualifiers.i
      +++ b/Examples/test-suite/cpp11_ref_qualifiers.i
      @@ -1,5 +1,11 @@
       %module cpp11_ref_qualifiers
       
      +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra2;
      +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ccextra3;
      +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc2;
      +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc3;
      +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) cc5;
      +
       %include 
       
       %ignore Host::h() const &;
      @@ -89,3 +95,114 @@ struct ConversionOperators2 {
         virtual operator string() && { return std::move(string()); }
       };
       %}
      +
      +%inline %{
      +struct Funcs {
      +  short FF(bool) { return 0; }
      +  short CC(bool) const & { return 0; }
      +};
      +
      +class MemberFuncPtrs
      +{
      +public:
      +  // member ref-qualified function pointers, unnamed parameters
      +  int aaa1(short (Funcs::*)(bool) &) const;
      +  int aaa2(short (Funcs::* const *&)(bool) &) const;
      +  int aaa3(short (Funcs::* *&)(bool) &) const;
      +  int aaa4(short (Funcs::* *const&)(bool) &) const;
      +  int aaa5(short (Funcs::* &)(bool) &) const;
      +  int aaa6(short (Funcs::* const)(bool) &) const;
      +  int aaa7(short (Funcs::* const&)(bool) &) const;
      +
      +  // member cv-qualified and ref-qualified function pointers, unnamed parameters
      +  int bbb1(short (Funcs::*)(bool) const &) const;
      +  int bbb2(short (Funcs::* const *&)(bool) const &) const;
      +  int bbb3(short (Funcs::* *&)(bool) const &) const;
      +  int bbb4(short (Funcs::* *const&)(bool) const &) const;
      +  int bbb5(short (Funcs::* &)(bool) const &) const;
      +  int bbb6(short (Funcs::* const)(bool) const &) const;
      +  int bbb7(short (Funcs::* const&)(bool) const &) const;
      +
      +  // member ref-qualified function pointers, named parameters
      +  int qqq1(short (Funcs::* qq1)(bool) &) const;
      +  int qqq2(short (Funcs::* const *& qq2)(bool) &) const;
      +  int qqq3(short (Funcs::* *& qq3)(bool) &) const;
      +  int qqq4(short (Funcs::* *const& qq4)(bool) &) const;
      +  int qqq5(short (Funcs::* & qq5)(bool) &) const;
      +  int qqq6(short (Funcs::* const qq6)(bool) &) const;
      +  int qqq7(short (Funcs::* const& qq7)(bool) &) const;
      +
      +  // member cv-qualified and ref-qualified function pointers, named parameters
      +  int rrr1(short (Funcs::* rr1)(bool) const &) const;
      +  int rrr2(short (Funcs::* const *& rr2)(bool) const &) const;
      +  int rrr3(short (Funcs::* *& rr3)(bool) const &) const;
      +  int rrr4(short (Funcs::* *const& rr4)(bool) const &) const;
      +  int rrr5(short (Funcs::* & rr5)(bool) const &) const;
      +  int rrr6(short (Funcs::* const rr6)(bool) const &) const;
      +  int rrr7(short (Funcs::* const& rr7)(bool) const &) const;
      +};
      +
      +// member ref-qualified function pointers, unnamed parameters
      +int MemberFuncPtrs::aaa1(short (Funcs::*)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa3(short (Funcs::* *&)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa4(short (Funcs::* *const&)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa5(short (Funcs::* &)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa6(short (Funcs::* const)(bool) &) const { return 0; }
      +int MemberFuncPtrs::aaa7(short (Funcs::* const&)(bool) &) const { return 0; }
      +
      +// member cv-qualified and ref-qualified function pointers, unnamed parameters
      +int MemberFuncPtrs::bbb1(short (Funcs::*)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb2(short (Funcs::* const *&)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb3(short (Funcs::* *&)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb4(short (Funcs::* *const&)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb5(short (Funcs::* &)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb6(short (Funcs::* const)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::bbb7(short (Funcs::* const&)(bool) const &) const { return 0; }
      +
      +// member ref-qualified function pointers, named parameters
      +int MemberFuncPtrs::qqq1(short (Funcs::* qq1)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq2(short (Funcs::* const *& qq2)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq3(short (Funcs::* *& qq3)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq4(short (Funcs::* *const& qq4)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool) &) const { return 0; }
      +int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool) &) const { return 0; }
      +
      +// member cv-qualified and ref-qualified function pointers, named parameters
      +int MemberFuncPtrs::rrr1(short (Funcs::* rr1)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr2(short (Funcs::* const *& rr2)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr3(short (Funcs::* *& rr3)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr4(short (Funcs::* *const& rr4)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr5(short (Funcs::* & rr5)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr6(short (Funcs::* const rr6)(bool) const &) const { return 0; }
      +int MemberFuncPtrs::rrr7(short (Funcs::* const& rr7)(bool) const &) const { return 0; }
      +
      +// member cv-qualified and ref-qualified pointer variables
      +short (Funcs::* cc1)(bool) const & = &Funcs::CC;
      +
      +short (Funcs::* const * ccextra2)(bool) const & = &cc1;
      +short (Funcs::* * ccextra3)(bool) const & = &cc1;
      +short (Funcs::* *const ccextra4)(bool) const & = &cc1;
      +
      +short (Funcs::* const *& cc2)(bool) const & = ccextra2;
      +short (Funcs::* *& cc3)(bool) const & = ccextra3;
      +short (Funcs::* *const& cc4)(bool) const & = ccextra4;
      +short (Funcs::* & cc5)(bool) const & = cc1;
      +short (Funcs::* const cc6)(bool) const & = &Funcs::CC;
      +short (Funcs::* const& cc7)(bool) const & = cc1;
      +%}
      +
      +%inline %{
      +
      +struct Funktions {
      +  int addByValue(const int &a, int b) const & { return a+b; }
      +  int * addByPointer(const int &a, int b) const & { static int val; val = a+b; return &val; }
      +  int & addByReference(const int &a, int b) const & { static int val; val = a+b; return val; }
      +};
      +
      +int call1(int (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
      +//int call2(int * (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return *(f.*d)(a, b); }
      +//int call3(int & (Funktions::*d)(const int &, int) const &, int a, int b) { Funktions f; return (f.*d)(a, b); }
      +%}
      +%constant int (Funktions::*ADD_BY_VALUE)(const int &, int) const & = &Funktions::addByValue;
      diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i
      index 01857ff1a..27c2f02a7 100644
      --- a/Examples/test-suite/member_funcptr_galore.i
      +++ b/Examples/test-suite/member_funcptr_galore.i
      @@ -161,7 +161,7 @@ public:
           int qqq7(short (Funcs::* const& qq7)(bool)) const;
       };
       
      -    // member const function pointers, unnamed parameters
      +// member const function pointers, unnamed parameters
       int MemberFuncPtrs::aaa1(short (Funcs::* )(bool) const) const { return 0; }
       int MemberFuncPtrs::aaa2(short (Funcs::* const *&)(bool) const) const { return 0; }
       int MemberFuncPtrs::aaa3(short (Funcs::* *& )(bool) const) const { return 0; }
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index f88eb5f60..9cf6f00c6 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -1897,10 +1897,10 @@ constant_directive :  CONSTANT identifier EQUAL definetype SEMI {
                      }
       	       /* Member const function pointers . eg.
       	         %constant short (Funcs::*pmf)(bool) const = &Funcs::F; */
      -	       | CONSTANT type direct_declarator LPAREN parms RPAREN CONST_QUAL def_args SEMI {
      +	       | CONSTANT type direct_declarator LPAREN parms RPAREN cv_ref_qualifier def_args SEMI {
       		 if (($8.type != T_ERROR) && ($8.type != T_SYMBOL)) {
       		   SwigType_add_function($2, $5);
      -		   SwigType_add_qualifier($2, "const");
      +		   SwigType_push($2, $7.qualifier);
       		   SwigType_push($2, $3.type);
       		   /* Sneaky callback function trick */
       		   if (SwigType_isfunction($2)) {
      @@ -5118,12 +5118,13 @@ parameter_declarator : declarator def_args {
                   }
       	    /* Member const function pointer parameters. eg.
       	      int f(short (Funcs::*parm)(bool) const); */
      -	    | direct_declarator LPAREN parms RPAREN CONST_QUAL {
      +	    | direct_declarator LPAREN parms RPAREN cv_ref_qualifier {
       	      SwigType *t;
       	      $$ = $1;
       	      t = NewStringEmpty();
       	      SwigType_add_function(t,$3);
      -	      SwigType_add_qualifier(t, "const");
      +	      if ($5.qualifier)
      +	        SwigType_push(t, $5.qualifier);
       	      if (!$$.have_parms) {
       		$$.parms = $3;
       		$$.have_parms = 1;
      @@ -5812,12 +5813,12 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
       		      $$.have_parms = 1;
       		    }
       		  }
      -                  | direct_abstract_declarator LPAREN parms RPAREN type_qualifier {
      +                  | direct_abstract_declarator LPAREN parms RPAREN cv_ref_qualifier {
       		    SwigType *t;
                           $$ = $1;
       		    t = NewStringEmpty();
                           SwigType_add_function(t,$3);
      -		    SwigType_push(t, $5);
      +		    SwigType_push(t, $5.qualifier);
       		    if (!$$.type) {
       		      $$.type = t;
       		    } else {
      diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
      index 4b745b335..346731996 100644
      --- a/Source/Swig/stype.c
      +++ b/Source/Swig/stype.c
      @@ -544,10 +544,9 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
         String *element = 0;
         String *nextelement;
         String *forwardelement;
      -  String *member_const_function_element = 0;
      +  SwigType *member_function_qualifiers = 0;
         List *elements;
         int nelements, i;
      -  int member_const_function = 0;
       
         if (id) {
           /* stringify the id expanding templates, for example when the id is a fully qualified templated class name */
      @@ -578,14 +577,12 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
             forwardelement = 0;
           }
           if (SwigType_isqualifier(element)) {
      -      if (!member_const_function) {
      +      if (!member_function_qualifiers) {
       	DOH *q = 0;
       	q = SwigType_parm(element);
       	Insert(result, 0, " ");
       	Insert(result, 0, q);
       	Delete(q);
      -      } else {
      -        member_const_function = 0;
             }
           } else if (SwigType_ispointer(element)) {
             Insert(result, 0, "*");
      @@ -602,19 +599,27 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
      -      if (SwigType_isqualifier(nextelement)) {
      -	member_const_function_element = nextelement;
      -	member_const_function = 1;
      +      {
      +	String *next3elements = NewStringEmpty();
      +	int j;
      +	for (j = i + 1; j < i + 4 && j < nelements; j++) {
      +	  Append(next3elements, Getitem(elements, j));
      +	}
      +	if (SwigType_isfunction(next3elements))
      +	  member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
      +	Delete(next3elements);
             }
             Delete(q);
           } else if (SwigType_isreference(element)) {
      -      Insert(result, 0, "&");
      +      if (!member_function_qualifiers)
      +	Insert(result, 0, "&");
             if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
           } else if (SwigType_isrvalue_reference(element)) {
      -      Insert(result, 0, "&&");
      +      if (!member_function_qualifiers)
      +	Insert(result, 0, "&&");
             if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
      @@ -639,12 +644,13 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
       	  Append(result, ",");
             }
             Append(result, ")");
      -      if (member_const_function_element) {
      -	String *p = SwigType_str(member_const_function_element, 0);
      +      if (member_function_qualifiers) {
      +	String *p = SwigType_str(member_function_qualifiers, 0);
       	Append(result, " ");
       	Append(result, p);
       	Delete(p);
      -	member_const_function_element = 0;
      +	Delete(member_function_qualifiers);
      +	member_function_qualifiers = 0;
             }
             Delete(parms);
           } else {
      @@ -678,7 +684,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
         int nelements, i;
         int firstarray = 1;
         int notypeconv = 0;
      -  int memberpointer = 0;
      +  int ignore_member_function_qualifiers = 0;
       
         result = NewStringEmpty();
         tc = Copy(s);
      @@ -705,6 +711,7 @@ SwigType *SwigType_ltype(const SwigType *s) {
             tc = td;
           }
         }
      +
         elements = SwigType_split(tc);
         nelements = Len(elements);
       
      @@ -714,18 +721,34 @@ SwigType *SwigType_ltype(const SwigType *s) {
           /* when we see a function, we need to preserve the following types */
           if (SwigType_isfunction(element)) {
             notypeconv = 1;
      +      ignore_member_function_qualifiers = 0;
           }
      -    if (SwigType_isqualifier(element)) {
      -      if (memberpointer)
      -	Append(result, element);
      -      /* otherwise ignore */
      +    if (ignore_member_function_qualifiers) {
      +      /* cv-qualifiers and ref-qualifiers up until the f() element have already been added */
      +    } else if (SwigType_isqualifier(element)) {
      +      /* swallow cv-qualifiers */
           } else if (SwigType_ispointer(element)) {
             Append(result, element);
             firstarray = 0;
           } else if (SwigType_ismemberpointer(element)) {
             Append(result, element);
      +      {
      +	String *next3elements = NewStringEmpty();
      +	int j;
      +	for (j = i + 1; j < i + 4 && j < nelements; j++) {
      +	  Append(next3elements, Getitem(elements, j));
      +	}
      +	if (SwigType_isfunction(next3elements)) {
      +	  SwigType *member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
      +	  /* compilers won't let us cast from a member function without qualifiers to one with qualifiers, so the qualifiers are kept in the ltype */
      +	  if (member_function_qualifiers)
      +	    Append(result, member_function_qualifiers);
      +	  Delete(member_function_qualifiers);
      +	  ignore_member_function_qualifiers = 1;
      +	}
      +	Delete(next3elements);
      +      }
             firstarray = 0;
      -      memberpointer = 1;
           } else if (SwigType_isreference(element)) {
             if (notypeconv) {
       	Append(result, element);
      @@ -764,13 +787,14 @@ SwigType *SwigType_ltype(const SwigType *s) {
       }
       
       /* -----------------------------------------------------------------------------
      - * SwigType_lstr(DOH *s, DOH *id)
      + * SwigType_lstr()
        *
        * Produces a type-string that is suitable as a lvalue in an expression.
        * That is, a type that can be freely assigned a value without violating
        * any C assignment rules.
        *
        *      -   Qualifiers such as 'const' and 'volatile' are stripped.
      + *          Except for member function cv-qualifiers and ref-qualifiers.
        *      -   Arrays are converted into a *single* pointer (i.e.,
        *          double [][] becomes double *).
        *      -   References are converted into a pointer.
      @@ -800,7 +824,7 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
         String *element = 0;
         String *nextelement;
         String *forwardelement;
      -  String *member_const_function_element = 0;
      +  String *member_function_qualifiers = 0;
         SwigType *td, *tc = 0;
         const SwigType *rs;
         List *elements;
      @@ -809,7 +833,6 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
         int firstarray = 1;
         int isreference = 0;
         int isfunction = 0;
      -  int member_const_function = 0;
       
         result = NewStringEmpty();
       
      @@ -858,15 +881,13 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
             forwardelement = 0;
           }
           if (SwigType_isqualifier(element)) {
      -      if (!member_const_function) {
      +      if (!member_function_qualifiers) {
       	DOH *q = 0;
       	q = SwigType_parm(element);
       	Insert(result, 0, " ");
       	Insert(result, 0, q);
       	Delete(q);
       	clear = 0;
      -      } else {
      -        member_const_function = 0;
             }
           } else if (SwigType_ispointer(element)) {
             Insert(result, 0, "*");
      @@ -880,32 +901,42 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
             Insert(result, 0, "::*");
             q = SwigType_parm(element);
             Insert(result, 0, q);
      -      Delete(q);
             if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
      -      if (SwigType_isqualifier(nextelement)) {
      -	member_const_function_element = nextelement;
      -	member_const_function = 1;
      +      {
      +	String *next3elements = NewStringEmpty();
      +	int j;
      +	for (j = i + 1; j < i + 4 && j < nelements; j++) {
      +	  Append(next3elements, Getitem(elements, j));
      +	}
      +	if (SwigType_isfunction(next3elements))
      +	  member_function_qualifiers = SwigType_pop_function_qualifiers(next3elements);
      +	Delete(next3elements);
             }
             firstarray = 0;
      +      Delete(q);
           } else if (SwigType_isreference(element)) {
      -      Insert(result, 0, "&");
      +      if (!member_function_qualifiers) {
      +	Insert(result, 0, "&");
      +	if (!isfunction)
      +	  isreference = 1;
      +      }
             if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
      -      if (!isfunction)
      -	isreference = 1;
           } else if (SwigType_isrvalue_reference(element)) {
      -      Insert(result, 0, "&&");
      +      if (!member_function_qualifiers) {
      +	Insert(result, 0, "&&");
      +	if (!isfunction)
      +	  isreference = 1;
      +      }
             if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
      -      if (!isfunction)
      -	isreference = 1;
             clear = 0;
           } else if (SwigType_isarray(element)) {
             DOH *size;
      @@ -935,12 +966,13 @@ String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
             }
             Append(result, ")");
             Delete(parms);
      -      if (member_const_function_element) {
      -	String *p = SwigType_str(member_const_function_element, 0);
      +      if (member_function_qualifiers) {
      +	String *p = SwigType_str(member_function_qualifiers, 0);
       	Append(result, " ");
       	Append(result, p);
       	Delete(p);
      -	member_const_function_element = 0;
      +	Delete(member_function_qualifiers);
      +	member_function_qualifiers = 0;
       	clear = 0;
             }
             isfunction = 1;
      
      From 45c161dfcea94d5eaae65e753483a7c117506425 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Thu, 7 Sep 2017 06:58:01 +0100
      Subject: [PATCH 0692/2031] Fix wrapping of some member function pointer
       parameters
      
      Generated code did not compile if both cv-qualifiers and rvalue
      ref-qualifiers were present in the member function pointer.
      ---
       Examples/test-suite/cpp11_ref_qualifiers.i | 16 ++++++++++++++++
       Source/Swig/stype.c                        |  2 +-
       2 files changed, 17 insertions(+), 1 deletion(-)
      
      diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i
      index 781e52f23..237234e9c 100644
      --- a/Examples/test-suite/cpp11_ref_qualifiers.i
      +++ b/Examples/test-suite/cpp11_ref_qualifiers.i
      @@ -114,6 +114,8 @@ public:
         int aaa6(short (Funcs::* const)(bool) &) const;
         int aaa7(short (Funcs::* const&)(bool) &) const;
       
      +  int aaa8(short (Funcs::* const&)(bool) &&) const;
      +
         // member cv-qualified and ref-qualified function pointers, unnamed parameters
         int bbb1(short (Funcs::*)(bool) const &) const;
         int bbb2(short (Funcs::* const *&)(bool) const &) const;
      @@ -123,6 +125,8 @@ public:
         int bbb6(short (Funcs::* const)(bool) const &) const;
         int bbb7(short (Funcs::* const&)(bool) const &) const;
       
      +  int bbb8(short (Funcs::*)(bool) const &&) const;
      +
         // member ref-qualified function pointers, named parameters
         int qqq1(short (Funcs::* qq1)(bool) &) const;
         int qqq2(short (Funcs::* const *& qq2)(bool) &) const;
      @@ -132,6 +136,8 @@ public:
         int qqq6(short (Funcs::* const qq6)(bool) &) const;
         int qqq7(short (Funcs::* const& qq7)(bool) &) const;
       
      +  int qqq8(short (Funcs::* const& qq8)(bool) &&) const;
      +
         // member cv-qualified and ref-qualified function pointers, named parameters
         int rrr1(short (Funcs::* rr1)(bool) const &) const;
         int rrr2(short (Funcs::* const *& rr2)(bool) const &) const;
      @@ -140,6 +146,8 @@ public:
         int rrr5(short (Funcs::* & rr5)(bool) const &) const;
         int rrr6(short (Funcs::* const rr6)(bool) const &) const;
         int rrr7(short (Funcs::* const& rr7)(bool) const &) const;
      +
      +  int rrr8(short (Funcs::* rr1)(bool) const &&) const;
       };
       
       // member ref-qualified function pointers, unnamed parameters
      @@ -151,6 +159,8 @@ int MemberFuncPtrs::aaa5(short (Funcs::* &)(bool) &) const { return 0; }
       int MemberFuncPtrs::aaa6(short (Funcs::* const)(bool) &) const { return 0; }
       int MemberFuncPtrs::aaa7(short (Funcs::* const&)(bool) &) const { return 0; }
       
      +int MemberFuncPtrs::aaa8(short (Funcs::* const&)(bool) &&) const { return 0; }
      +
       // member cv-qualified and ref-qualified function pointers, unnamed parameters
       int MemberFuncPtrs::bbb1(short (Funcs::*)(bool) const &) const { return 0; }
       int MemberFuncPtrs::bbb2(short (Funcs::* const *&)(bool) const &) const { return 0; }
      @@ -160,6 +170,8 @@ int MemberFuncPtrs::bbb5(short (Funcs::* &)(bool) const &) const { return 0; }
       int MemberFuncPtrs::bbb6(short (Funcs::* const)(bool) const &) const { return 0; }
       int MemberFuncPtrs::bbb7(short (Funcs::* const&)(bool) const &) const { return 0; }
       
      +int MemberFuncPtrs::bbb8(short (Funcs::*)(bool) const &&) const { return 0; }
      +
       // member ref-qualified function pointers, named parameters
       int MemberFuncPtrs::qqq1(short (Funcs::* qq1)(bool) &) const { return 0; }
       int MemberFuncPtrs::qqq2(short (Funcs::* const *& qq2)(bool) &) const { return 0; }
      @@ -169,6 +181,8 @@ int MemberFuncPtrs::qqq5(short (Funcs::* & qq5)(bool) &) const { return 0; }
       int MemberFuncPtrs::qqq6(short (Funcs::* const qq6)(bool) &) const { return 0; }
       int MemberFuncPtrs::qqq7(short (Funcs::* const& qq7)(bool) &) const { return 0; }
       
      +int MemberFuncPtrs::qqq8(short (Funcs::* const& qq8)(bool) &&) const { return 0; }
      +
       // member cv-qualified and ref-qualified function pointers, named parameters
       int MemberFuncPtrs::rrr1(short (Funcs::* rr1)(bool) const &) const { return 0; }
       int MemberFuncPtrs::rrr2(short (Funcs::* const *& rr2)(bool) const &) const { return 0; }
      @@ -178,6 +192,8 @@ int MemberFuncPtrs::rrr5(short (Funcs::* & rr5)(bool) const &) const { return 0;
       int MemberFuncPtrs::rrr6(short (Funcs::* const rr6)(bool) const &) const { return 0; }
       int MemberFuncPtrs::rrr7(short (Funcs::* const& rr7)(bool) const &) const { return 0; }
       
      +int MemberFuncPtrs::rrr8(short (Funcs::* rr1)(bool) const &&) const { return 0; }
      +
       // member cv-qualified and ref-qualified pointer variables
       short (Funcs::* cc1)(bool) const & = &Funcs::CC;
       
      diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
      index 346731996..364329d08 100644
      --- a/Source/Swig/stype.c
      +++ b/Source/Swig/stype.c
      @@ -620,7 +620,7 @@ String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
           } else if (SwigType_isrvalue_reference(element)) {
             if (!member_function_qualifiers)
       	Insert(result, 0, "&&");
      -      if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
      +      if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
       	Insert(result, 0, "(");
       	Append(result, ")");
             }
      
      From c4e280024fb1ed9881312dc997f36f6f3563f697 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 9 Sep 2017 23:46:14 +0100
      Subject: [PATCH 0693/2031] Add support for %typemap and member function
       pointers with qualifiers
      
      ---
       Examples/test-suite/common.mk                 |  1 +
       .../cpp11_ref_qualifiers_typemaps.i           | 74 +++++++++++++++++++
       .../cpp11_ref_qualifiers_typemaps_runme.java  | 39 ++++++++++
       Source/CParse/parser.y                        | 25 ++++++-
       4 files changed, 137 insertions(+), 2 deletions(-)
       create mode 100644 Examples/test-suite/cpp11_ref_qualifiers_typemaps.i
       create mode 100644 Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java
      
      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
      index 0d0a32c8c..4bd657c13 100644
      --- a/Examples/test-suite/common.mk
      +++ b/Examples/test-suite/common.mk
      @@ -563,6 +563,7 @@ CPP11_TEST_CASES += \
       	cpp11_raw_string_literals \
       	cpp11_ref_qualifiers \
       	cpp11_ref_qualifiers_rvalue_unignore \
      +	cpp11_ref_qualifiers_typemaps \
       	cpp11_result_of \
       	cpp11_rvalue_reference \
       	cpp11_rvalue_reference2 \
      diff --git a/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i
      new file mode 100644
      index 000000000..e9cce4bfb
      --- /dev/null
      +++ b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i
      @@ -0,0 +1,74 @@
      +%module cpp11_ref_qualifiers_typemaps
      +
      +%typemap(in) SWIGTYPE (CLASS::*) %{
      +  _this_will_fail_to_compile_if_used_
      +%}
      +
      +// typemaps to completely ignore the input parm and override it
      +%typemap(in) short (Funcs::*ff)(bool) const   %{ $1 = &Funcs::FF2; %}
      +%typemap(in) short (Funcs::*cc)(bool) &       %{ $1 = &Funcs::CC5; %}
      +%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GG8; %}
      +%typemap(in) short (Funcs::*hh)(bool) &&      %{ $1 = &Funcs::HH11; %}
      +
      +%typemap(in) short (Funcs::*)(bool) const   %{ $1 = &Funcs::FF3; %}
      +%typemap(in) short (Funcs::*)(bool) &       %{ $1 = &Funcs::CC6; %}
      +%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GG9; %}
      +%typemap(in) short (Funcs::*)(bool) &&      %{ $1 = &Funcs::HH12; %}
      +
      +%inline %{
      +struct Funcs {
      +  short FF1(bool) const { return 1; }
      +  short FF2(bool) const { return 2; }
      +  short FF3(bool) const { return 3; }
      +  short CC4(bool) & { return 4; }
      +  short CC5(bool) & { return 5; }
      +  short CC6(bool) & { return 6; }
      +  short GG7(bool) const & { return 7; }
      +  short GG8(bool) const & { return 8; }
      +  short GG9(bool) const & { return 9; }
      +  short HH10(bool) && { return 10; }
      +  short HH11(bool) && { return 11; }
      +  short HH12(bool) && { return 12; }
      +};
      +struct TypemapsNamedParms
      +{
      +  short fff(short (Funcs::*ff)(bool) const) {
      +    Funcs funcs;
      +    return (funcs.*ff)(true);
      +  }
      +  short ccc(short (Funcs::*cc)(bool) &) {
      +    Funcs funcs;
      +    return (funcs.*cc)(true);
      +  }
      +  short ggg(short (Funcs::*gg)(bool) const &) {
      +    Funcs funcs;
      +    return (funcs.*gg)(true);
      +  }
      +  short hhh(short (Funcs::*hh)(bool) &&) {
      +    return (Funcs().*hh)(true);
      +  }
      +};
      +struct TypemapsUnnamedParms
      +{
      +  short fff(short (Funcs::*f)(bool) const) {
      +    Funcs funcs;
      +    return (funcs.*f)(true);
      +  }
      +  short ccc(short (Funcs::*c)(bool) &) {
      +    Funcs funcs;
      +    return (funcs.*c)(true);
      +  }
      +  short ggg(short (Funcs::*g)(bool) const &) {
      +    Funcs funcs;
      +    return (funcs.*g)(true);
      +  }
      +  short hhh(short (Funcs::*h)(bool) &&) {
      +    return (Funcs().*h)(true);
      +  }
      +};
      +%}
      +
      +%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FF1;
      +%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CC4;
      +%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GG7;
      +%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HH10;
      diff --git a/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java b/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java
      new file mode 100644
      index 000000000..8c6a21b15
      --- /dev/null
      +++ b/Examples/test-suite/java/cpp11_ref_qualifiers_typemaps_runme.java
      @@ -0,0 +1,39 @@
      +import cpp11_ref_qualifiers_typemaps.*;
      +
      +public class cpp11_ref_qualifiers_typemaps_runme {
      +  static {
      +    try {
      +      System.loadLibrary("cpp11_ref_qualifiers_typemaps");
      +    } 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[]) 
      +  {
      +    {
      +      TypemapsNamedParms tm = new TypemapsNamedParms();
      +      if (tm.fff(cpp11_ref_qualifiers_typemaps.FF1_MFP) != 2)
      +        throw new RuntimeException("failed");
      +      if (tm.ccc(cpp11_ref_qualifiers_typemaps.CC4_MFP) != 5)
      +        throw new RuntimeException("failed");
      +      if (tm.ggg(cpp11_ref_qualifiers_typemaps.GG7_MFP) != 8)
      +        throw new RuntimeException("failed");
      +      if (tm.hhh(cpp11_ref_qualifiers_typemaps.HH10_MFP) != 11)
      +        throw new RuntimeException("failed");
      +    }
      +    {
      +      TypemapsUnnamedParms tm = new TypemapsUnnamedParms();
      +      if (tm.fff(cpp11_ref_qualifiers_typemaps.FF1_MFP) != 3)
      +        throw new RuntimeException("failed");
      +      if (tm.ccc(cpp11_ref_qualifiers_typemaps.CC4_MFP) != 6)
      +        throw new RuntimeException("failed");
      +      if (tm.ggg(cpp11_ref_qualifiers_typemaps.GG7_MFP) != 9)
      +        throw new RuntimeException("failed");
      +      if (tm.hhh(cpp11_ref_qualifiers_typemaps.HH10_MFP) != 12)
      +        throw new RuntimeException("failed");
      +    }
      +  }
      +}
      +
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index 9cf6f00c6..2e92cd01b 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -1895,7 +1895,7 @@ constant_directive :  CONSTANT identifier EQUAL definetype SEMI {
       		   $$ = 0;
       		 }
                      }
      -	       /* Member const function pointers . eg.
      +	       /* Member function pointers with qualifiers. eg.
       	         %constant short (Funcs::*pmf)(bool) const = &Funcs::F; */
       	       | CONSTANT type direct_declarator LPAREN parms RPAREN cv_ref_qualifier def_args SEMI {
       		 if (($8.type != T_ERROR) && ($8.type != T_SYMBOL)) {
      @@ -5116,7 +5116,7 @@ parameter_declarator : declarator def_args {
                     $$.id = 0;
       	      $$.defarg = $1.rawval ? $1.rawval : $1.val;
                   }
      -	    /* Member const function pointer parameters. eg.
      +	    /* Member function pointers with qualifiers. eg.
       	      int f(short (Funcs::*parm)(bool) const); */
       	    | direct_declarator LPAREN parms RPAREN cv_ref_qualifier {
       	      SwigType *t;
      @@ -5174,6 +5174,27 @@ plain_declarator : declarator {
       		$$.parms = 0;
       	      }
                   }
      +	    /* Member function pointers with qualifiers. eg.
      +	      int f(short (Funcs::*parm)(bool) const) */
      +	    | direct_declarator LPAREN parms RPAREN cv_ref_qualifier {
      +	      SwigType *t;
      +	      $$ = $1;
      +	      t = NewStringEmpty();
      +	      SwigType_add_function(t, $3);
      +	      if ($5.qualifier)
      +	        SwigType_push(t, $5.qualifier);
      +	      if (!$$.have_parms) {
      +		$$.parms = $3;
      +		$$.have_parms = 1;
      +	      }
      +	      if (!$$.type) {
      +		$$.type = t;
      +	      } else {
      +		SwigType_push(t, $$.type);
      +		Delete($$.type);
      +		$$.type = t;
      +	      }
      +	    }
                   | empty {
          	      $$.type = 0;
                     $$.id = 0;
      
      From f38e525a24fbaff57357c026824bc2c89ab98376 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 10 Sep 2017 12:49:24 +0100
      Subject: [PATCH 0694/2031] Warnings in testcases fix
      
      ---
       Examples/test-suite/cpp11_ref_qualifiers.i   | 2 ++
       Examples/test-suite/template_empty_inherit.i | 1 +
       2 files changed, 3 insertions(+)
      
      diff --git a/Examples/test-suite/cpp11_ref_qualifiers.i b/Examples/test-suite/cpp11_ref_qualifiers.i
      index 237234e9c..e37136770 100644
      --- a/Examples/test-suite/cpp11_ref_qualifiers.i
      +++ b/Examples/test-suite/cpp11_ref_qualifiers.i
      @@ -90,9 +90,11 @@ struct Renames {
       struct ConversionOperators {
         virtual operator string() & { return string(); }
         virtual operator string() && { return std::move(string()); }
      +  virtual ~ConversionOperators() {}
       };
       struct ConversionOperators2 {
         virtual operator string() && { return std::move(string()); }
      +  virtual ~ConversionOperators2() {}
       };
       %}
       
      diff --git a/Examples/test-suite/template_empty_inherit.i b/Examples/test-suite/template_empty_inherit.i
      index 308a01fda..5677b8b1a 100644
      --- a/Examples/test-suite/template_empty_inherit.i
      +++ b/Examples/test-suite/template_empty_inherit.i
      @@ -5,6 +5,7 @@
       %inline %{
       template struct Functor {
         virtual Result operator()(Arg x) const = 0;
      +  virtual ~Functor() {}
       };
       %}
       
      
      From 0646db73c354de147ad01888a4db55d7f9c3877a Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 10 Sep 2017 17:20:35 +0100
      Subject: [PATCH 0695/2031] Add _DEBUG set to 1 change into changes files
      
      ---
       CHANGES.current | 4 ++++
       1 file changed, 4 insertions(+)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 0629dfbb6..8e77d5bc0 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
       Version 4.0.0 (in progress)
       ===========================
       
      +2017-09-10: mlamarre
      +            [Python] Patch #1083. Define_DEBUG to 1 to do exactly like Visual Studio
      +            /LDd, /MDd or /MTd compiler options.
      +
       2017-08-16: wsfulton
                   Fix #1063. Add using declarations to templates into typedef table.
       
      
      From f18b45e677f90eef406152675b6abeae12567010 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Mon, 11 Sep 2017 08:16:57 +0100
      Subject: [PATCH 0696/2031] Travis workaround fix for pip install pep8 install
       fail
      
      Example failure:
      https://travis-ci.org/swig/swig/jobs/273885223#L557
      
      Error:
      IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pep8.pyc'
      ---
       .travis.yml | 1 +
       1 file changed, 1 insertion(+)
      
      diff --git a/.travis.yml b/.travis.yml
      index e2a47e6f1..99316f436 100644
      --- a/.travis.yml
      +++ b/.travis.yml
      @@ -1,4 +1,5 @@
       language: cpp
      +group: deprecated-2017Q3 # workaround for failing: pip install pep8
       matrix:
         include:
           - compiler: clang
      
      From d8556b011981e070d67acb1d68563cdc3ab9a00d Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Mon, 11 Sep 2017 08:21:55 +0100
      Subject: [PATCH 0697/2031] Remove node testing from Travis
      
      Travis is now testing on Ubuntu Trusty by default instead of Ubuntu
      Precise. SWIG wrappers need some work for this environment.
      Travis build failure: https://travis-ci.org/swig/swig/jobs/273885208
      Issue #971
      ---
       .travis.yml | 6 +++---
       1 file changed, 3 insertions(+), 3 deletions(-)
      
      diff --git a/.travis.yml b/.travis.yml
      index 99316f436..5dc3ce44a 100644
      --- a/.travis.yml
      +++ b/.travis.yml
      @@ -53,9 +53,9 @@ matrix:
             env: SWIGLANG=java
             sudo: required
             dist: trusty
      -    - compiler: gcc
      -      os: linux
      -      env: SWIGLANG=javascript ENGINE=node
      +#    - compiler: gcc
      +#      os: linux
      +#      env: SWIGLANG=javascript ENGINE=node
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=jsc
      
      From 64bc67f57e47ec59fd13ecb97d3615f8fff70fe5 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Mon, 11 Sep 2017 08:27:18 +0100
      Subject: [PATCH 0698/2031] Remove all Ubuntu Precise testing on Travis
      
      This is going end of life on Travis.
      ---
       .travis.yml | 4 +---
       1 file changed, 1 insertion(+), 3 deletions(-)
      
      diff --git a/.travis.yml b/.travis.yml
      index 5dc3ce44a..05681a110 100644
      --- a/.travis.yml
      +++ b/.travis.yml
      @@ -7,9 +7,6 @@ matrix:
             env: SWIGLANG=
             sudo: required
             dist: trusty
      -    - compiler: gcc
      -      os: linux
      -      env: SWIGLANG=
           - compiler: gcc
             os: linux
             env: SWIGLANG=
      @@ -56,6 +53,7 @@ matrix:
       #    - compiler: gcc
       #      os: linux
       #      env: SWIGLANG=javascript ENGINE=node
      +#      dist: trusty
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=jsc
      
      From 0587edd5597e773b700c8f10c42bd0cc00ef39b9 Mon Sep 17 00:00:00 2001
      From: luav 
      Date: Mon, 11 Sep 2017 22:13:19 +0200
      Subject: [PATCH 0699/2031] Includes inside %inline block documented, see #1068
      
      ---
       Doc/Manual/SWIG.html | 6 +++++-
       1 file changed, 5 insertions(+), 1 deletion(-)
      
      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
      index c05ed456c..f0c4837f1 100644
      --- a/Doc/Manual/SWIG.html
      +++ b/Doc/Manual/SWIG.html
      @@ -3293,7 +3293,6 @@ Vector *new_Vector() {
         return (Vector *) malloc(sizeof(Vector));
       }
       %}
      -
       

      @@ -3305,6 +3304,11 @@ declaration. Since the code inside an %inline %{ ... %} block is given to both the C compiler and SWIG, it is illegal to include any SWIG directives inside a %{ ... %} block.

      +

      +Note:Any #include directives are omitted inside the +%inline %{ ... %} block unless the -includeall command line +option is supplied.

      +

      5.6.4 Initialization blocks

      From f069d0a744ef9bf7b3e31a89877977e9153fc959 Mon Sep 17 00:00:00 2001 From: luav Date: Mon, 11 Sep 2017 22:55:13 +0200 Subject: [PATCH 0700/2031] %shared_ptr usage for the templates documented, see #1049 --- Doc/Manual/Library.html | 43 +++++++++++++++++++++++++++++++++++++++-- Doc/Manual/SWIG.html | 2 +- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index f41799bf0..40677cc9f 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1728,6 +1728,10 @@ Any thrown STL exceptions will then be gracefully handled instead of causing a c

      9.4.4 shared_ptr smart pointer

      +

      +%shared_ptr Basics +

      +

      Some target languages have support for handling the shared_ptr reference counted smart pointer. This smart pointer is available in the standard C++11 library as std::shared_ptr. @@ -1822,7 +1826,11 @@ System.out.println(val1 + " " + val2);

      -This shared_ptr library works quite differently to SWIG's normal, but somewhat limited, +%shared_ptr and Inheritance +

      + +

      +The shared_ptr library works quite differently to SWIG's normal, but somewhat limited, smart pointer handling. The shared_ptr library does not generate extra wrappers, just for smart pointer handling, in addition to the proxy class. The normal proxy class including inheritance relationships is generated as usual. @@ -1900,7 +1908,7 @@ Adding the missing %shared_ptr macros will fix this:

      -%include "boost_shared_ptr.i"
      +%include <boost_shared_ptr.i>
       %shared_ptr(GrandParent);
       %shared_ptr(Parent);
       %shared_ptr(Child);
      @@ -1909,6 +1917,37 @@ Adding the missing %shared_ptr macros will fix this:
       
      +

      +%shared_ptr and Templates +

      + +

      +Only the single %shared_ptr declaration should be used for all specializations +of the template before the first template instantiation using the following notation: +%shared_ptr(TemplateName<>). For example: +

      + +
      +
      +%include <std_shared_ptr.i>
      +
      +%shared_ptr(Graph<>);  //!< Declaration of the transparent shared ptr for the Graph template
      +
      +%{
      +  #include "graph.hpp"  // Graph definition (inside the namespace gany)
      +  using namespace gany;
      +%}
      +
      +%include "graph.h"  // Graph declaration (inside the namespace gany)
      +using namespace gany;
      +
      +%template(SGraph) Graph<false>;  //!< Simple graph 
      +// Note: the Graph name is redefined in the following line from the template to the specialization (class)
      +%template(Graph) Graph<true>;  //!< Weighted graph
      +
      +
      + +

      Note: There is somewhat limited support for %shared_ptr and the director feature and the degrees of success varies among the different target languages. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index f0c4837f1..965fae11c 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -3305,7 +3305,7 @@ is given to both the C compiler and SWIG, it is illegal to include any SWIG directives inside a %{ ... %} block.

      -Note:Any #include directives are omitted inside the +Note: Any #include directives are omitted inside the %inline %{ ... %} block unless the -includeall command line option is supplied.

      From 0c0384198a747748ba58c2dda43b0b425b54009b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Sep 2017 23:17:30 +0100 Subject: [PATCH 0701/2031] Fix testcase symbol name conflict FF1 is also defined in /usr/include/sys/termio.h on cygwin and used by Python.h. --- .../cpp11_ref_qualifiers_typemaps.i | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i index e9cce4bfb..0e1c3fe53 100644 --- a/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i +++ b/Examples/test-suite/cpp11_ref_qualifiers_typemaps.i @@ -5,30 +5,30 @@ %} // typemaps to completely ignore the input parm and override it -%typemap(in) short (Funcs::*ff)(bool) const %{ $1 = &Funcs::FF2; %} -%typemap(in) short (Funcs::*cc)(bool) & %{ $1 = &Funcs::CC5; %} -%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GG8; %} -%typemap(in) short (Funcs::*hh)(bool) && %{ $1 = &Funcs::HH11; %} +%typemap(in) short (Funcs::*ff)(bool) const %{ $1 = &Funcs::FFF2; %} +%typemap(in) short (Funcs::*cc)(bool) & %{ $1 = &Funcs::CCC5; %} +%typemap(in) short (Funcs::*gg)(bool) const & %{ $1 = &Funcs::GGG8; %} +%typemap(in) short (Funcs::*hh)(bool) && %{ $1 = &Funcs::HHH11; %} -%typemap(in) short (Funcs::*)(bool) const %{ $1 = &Funcs::FF3; %} -%typemap(in) short (Funcs::*)(bool) & %{ $1 = &Funcs::CC6; %} -%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GG9; %} -%typemap(in) short (Funcs::*)(bool) && %{ $1 = &Funcs::HH12; %} +%typemap(in) short (Funcs::*)(bool) const %{ $1 = &Funcs::FFF3; %} +%typemap(in) short (Funcs::*)(bool) & %{ $1 = &Funcs::CCC6; %} +%typemap(in) short (Funcs::*)(bool) const & %{ $1 = &Funcs::GGG9; %} +%typemap(in) short (Funcs::*)(bool) && %{ $1 = &Funcs::HHH12; %} %inline %{ struct Funcs { - short FF1(bool) const { return 1; } - short FF2(bool) const { return 2; } - short FF3(bool) const { return 3; } - short CC4(bool) & { return 4; } - short CC5(bool) & { return 5; } - short CC6(bool) & { return 6; } - short GG7(bool) const & { return 7; } - short GG8(bool) const & { return 8; } - short GG9(bool) const & { return 9; } - short HH10(bool) && { return 10; } - short HH11(bool) && { return 11; } - short HH12(bool) && { return 12; } + short FFF1(bool) const { return 1; } + short FFF2(bool) const { return 2; } + short FFF3(bool) const { return 3; } + short CCC4(bool) & { return 4; } + short CCC5(bool) & { return 5; } + short CCC6(bool) & { return 6; } + short GGG7(bool) const & { return 7; } + short GGG8(bool) const & { return 8; } + short GGG9(bool) const & { return 9; } + short HHH10(bool) && { return 10; } + short HHH11(bool) && { return 11; } + short HHH12(bool) && { return 12; } }; struct TypemapsNamedParms { @@ -68,7 +68,7 @@ struct TypemapsUnnamedParms }; %} -%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FF1; -%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CC4; -%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GG7; -%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HH10; +%constant short (Funcs::*FF1_MFP)(bool) const = &Funcs::FFF1; +%constant short (Funcs::*CC4_MFP)(bool) & = &Funcs::CCC4; +%constant short (Funcs::*GG7_MFP)(bool) const & = &Funcs::GGG7; +%constant short (Funcs::*HH10_MFP)(bool) && = &Funcs::HHH10; From 6077b808f737c1d05df158e31ce50f9189bf9506 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Sep 2017 23:18:55 +0100 Subject: [PATCH 0702/2031] Remove code duplication of Swig_overload_rank Allegrocl and R versions were also out of date --- Source/Modules/allegrocl.cxx | 279 ----------------------------------- Source/Modules/r.cxx | 256 -------------------------------- 2 files changed, 535 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 77f1319c7..f32d34976 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1685,285 +1685,6 @@ int ALLEGROCL::top(Node *n) { return SWIG_OK; } -/* very shamelessly 'borrowed' from overload.cxx, which - keeps the below Swig_overload_rank() code to itself. - We don't need a dispatch function in the C++ wrapper - code; we want it over on the lisp side. */ - -#define Swig_overload_rank Allegrocl_swig_overload_rank - -#define MAX_OVERLOAD 256 - -/* Overload "argc" and "argv" */ -// String *argv_template_string; -// String *argc_template_string; - -struct Overloaded { - Node *n; /* Node */ - int argc; /* Argument count */ - ParmList *parms; /* Parameters used for overload check */ - int error; /* Ambiguity error */ -}; - -/* ----------------------------------------------------------------------------- - * Swig_overload_rank() - * - * This function takes an overloaded declaration and creates a list that ranks - * all overloaded methods in an order that can be used to generate a dispatch - * function. - * Slight difference in the way this function is used by scripting languages and - * statically typed languages. The script languages call this method via - * Swig_overload_dispatch() - where wrappers for all overloaded methods are generated, - * however sometimes the code can never be executed. The non-scripting languages - * call this method via Swig_overload_check() for each overloaded method in order - * to determine whether or not the method should be wrapped. Note the slight - * difference when overloading methods that differ by const only. The - * scripting languages will ignore the const method, whereas the non-scripting - * languages ignore the first method parsed. - * ----------------------------------------------------------------------------- */ - -static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { - Overloaded nodes[MAX_OVERLOAD]; - int nnodes = 0; - Node *o = Getattr(n, "sym:overloaded"); - Node *c; - - if (!o) - return 0; - - c = o; - while (c) { - if (Getattr(c, "error")) { - c = Getattr(c, "sym:nextSibling"); - continue; - } - /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } */ - - /* Make a list of all the declarations (methods) that are overloaded with - * this one particular method name */ - if (Getattr(c, "wrap:name")) { - nodes[nnodes].n = c; - nodes[nnodes].parms = Getattr(c, "wrap:parms"); - nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); - nodes[nnodes].error = 0; - nnodes++; - } - c = Getattr(c, "sym:nextSibling"); - } - - /* Sort the declarations by required argument count */ - { - int i, j; - for (i = 0; i < nnodes; i++) { - for (j = i + 1; j < nnodes; j++) { - if (nodes[i].argc > nodes[j].argc) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - } - } - } - - /* Sort the declarations by argument types */ - { - int i, j; - for (i = 0; i < nnodes - 1; i++) { - if (nodes[i].argc == nodes[i + 1].argc) { - for (j = i + 1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { - Parm *p1 = nodes[i].parms; - Parm *p2 = nodes[j].parms; - int differ = 0; - int num_checked = 0; - while (p1 && p2 && (num_checked < nodes[i].argc)) { - // Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); - if (checkAttribute(p1, "tmap:in:numinputs", "0")) { - p1 = Getattr(p1, "tmap:in:next"); - continue; - } - if (checkAttribute(p2, "tmap:in:numinputs", "0")) { - p2 = Getattr(p2, "tmap:in:next"); - continue; - } - String *t1 = Getattr(p1, "tmap:typecheck:precedence"); - String *t2 = Getattr(p2, "tmap:typecheck:precedence"); - if ((!t1) && (!nodes[i].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); - nodes[i].error = 1; - } else if ((!t2) && (!nodes[j].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); - nodes[j].error = 1; - } - if (t1 && t2) { - int t1v, t2v; - t1v = atoi(Char(t1)); - t2v = atoi(Char(t2)); - differ = t1v - t2v; - } else if (!t1 && t2) - differ = 1; - else if (t1 && !t2) - differ = -1; - else if (!t1 && !t2) - differ = -1; - num_checked++; - if (differ > 0) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - break; - } else if ((differ == 0) && (Strcmp(t1, "0") == 0)) { - t1 = Getattr(p1, "ltype"); - if (!t1) { - t1 = SwigType_ltype(Getattr(p1, "type")); - if (Getattr(p1, "tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t1); - } - Setattr(p1, "ltype", t1); - } - t2 = Getattr(p2, "ltype"); - if (!t2) { - t2 = SwigType_ltype(Getattr(p2, "type")); - if (Getattr(p2, "tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t2); - } - Setattr(p2, "ltype", t2); - } - - /* Need subtype check here. If t2 is a subtype of t1, then we need to change the - order */ - - if (SwigType_issubtype(t2, t1)) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - - if (Strcmp(t1, t2) != 0) { - differ = 1; - break; - } - } else if (differ) { - break; - } - if (Getattr(p1, "tmap:in:next")) { - p1 = Getattr(p1, "tmap:in:next"); - } else { - p1 = nextSibling(p1); - } - if (Getattr(p2, "tmap:in:next")) { - p2 = Getattr(p2, "tmap:in:next"); - } else { - p2 = nextSibling(p2); - } - } - if (!differ) { - /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n, "decl"); - String *d2 = Getattr(nodes[j].n, "decl"); - if (d1 && d2) { - String *dq1 = Copy(d1); - String *dq2 = Copy(d2); - if (SwigType_isconst(d1)) { - Delete(SwigType_pop(dq1)); - } - if (SwigType_isconst(d2)) { - Delete(SwigType_pop(dq2)); - } - if (Strcmp(dq1, dq2) == 0) { - - if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { - if (script_lang_wrapping) { - // Swap nodes so that the const method gets ignored (shadowed by the non-const method) - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - } - nodes[j].error = 1; - } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - } - nodes[j].error = 1; - } - } - Delete(dq1); - Delete(dq2); - } - } - if (!differ) { - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), - "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } - } - } - } - } - } - List *result = NewList(); - { - int i; - for (i = 0; i < nnodes; i++) { - if (nodes[i].error) - Setattr(nodes[i].n, "overload:ignore", "1"); - Append(result, nodes[i].n); - // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); - // Swig_print_node(nodes[i].n); - } - } - return result; -} - -/* end shameless borrowing */ - int any_varargs(ParmList *pl) { Parm *p; diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 6a326206f..db94ec934 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -290,8 +290,6 @@ public: int membervariableHandler(Node *n); int typedefHandler(Node *n); - static List *Swig_overload_rank(Node *n, - bool script_lang_wrapping); int memberfunctionHandler(Node *n) { if (debugMode) @@ -1314,260 +1312,6 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp); } -#define MAX_OVERLOAD 256 - -struct Overloaded { - Node *n; /* Node */ - int argc; /* Argument count */ - ParmList *parms; /* Parameters used for overload check */ - int error; /* Ambiguity error */ -}; - - -List * R::Swig_overload_rank(Node *n, - bool script_lang_wrapping) { - Overloaded nodes[MAX_OVERLOAD]; - int nnodes = 0; - Node *o = Getattr(n,"sym:overloaded"); - - - if (!o) return 0; - - Node *c = o; - while (c) { - if (Getattr(c,"error")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } - /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } */ - - /* Make a list of all the declarations (methods) that are overloaded with - * this one particular method name */ - - if (Getattr(c,"wrap:name")) { - nodes[nnodes].n = c; - nodes[nnodes].parms = Getattr(c,"wrap:parms"); - nodes[nnodes].argc = emit_num_required(nodes[nnodes].parms); - nodes[nnodes].error = 0; - nnodes++; - } - c = Getattr(c,"sym:nextSibling"); - } - - /* Sort the declarations by required argument count */ - { - int i,j; - for (i = 0; i < nnodes; i++) { - for (j = i+1; j < nnodes; j++) { - if (nodes[i].argc > nodes[j].argc) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - } - } - } - - /* Sort the declarations by argument types */ - { - int i,j; - for (i = 0; i < nnodes-1; i++) { - if (nodes[i].argc == nodes[i+1].argc) { - for (j = i+1; (j < nnodes) && (nodes[j].argc == nodes[i].argc); j++) { - Parm *p1 = nodes[i].parms; - Parm *p2 = nodes[j].parms; - int differ = 0; - int num_checked = 0; - while (p1 && p2 && (num_checked < nodes[i].argc)) { - if (debugMode) { - Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type")); - } - if (checkAttribute(p1,"tmap:in:numinputs","0")) { - p1 = Getattr(p1,"tmap:in:next"); - continue; - } - if (checkAttribute(p2,"tmap:in:numinputs","0")) { - p2 = Getattr(p2,"tmap:in:next"); - continue; - } - String *t1 = Getattr(p1,"tmap:typecheck:precedence"); - String *t2 = Getattr(p2,"tmap:typecheck:precedence"); - if (debugMode) { - Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2); - } - if ((!t1) && (!nodes[i].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); - nodes[i].error = 1; - } else if ((!t2) && (!nodes[j].error)) { - Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s not supported (incomplete type checking rule - no precedence level in typecheck typemap for '%s').\n", - Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); - nodes[j].error = 1; - } - if (t1 && t2) { - int t1v, t2v; - t1v = atoi(Char(t1)); - t2v = atoi(Char(t2)); - differ = t1v-t2v; - } - else if (!t1 && t2) differ = 1; - else if (t1 && !t2) differ = -1; - else if (!t1 && !t2) differ = -1; - num_checked++; - if (differ > 0) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - break; - } else if ((differ == 0) && (Strcmp(t1,"0") == 0)) { - t1 = Getattr(p1,"ltype"); - if (!t1) { - t1 = SwigType_ltype(Getattr(p1,"type")); - if (Getattr(p1,"tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t1); - } - Setattr(p1,"ltype",t1); - } - t2 = Getattr(p2,"ltype"); - if (!t2) { - t2 = SwigType_ltype(Getattr(p2,"type")); - if (Getattr(p2,"tmap:typecheck:SWIGTYPE")) { - SwigType_add_pointer(t2); - } - Setattr(p2,"ltype",t2); - } - - /* Need subtype check here. If t2 is a subtype of t1, then we need to change the - order */ - - if (SwigType_issubtype(t2,t1)) { - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - - if (Strcmp(t1,t2) != 0) { - differ = 1; - break; - } - } else if (differ) { - break; - } - if (Getattr(p1,"tmap:in:next")) { - p1 = Getattr(p1,"tmap:in:next"); - } else { - p1 = nextSibling(p1); - } - if (Getattr(p2,"tmap:in:next")) { - p2 = Getattr(p2,"tmap:in:next"); - } else { - p2 = nextSibling(p2); - } - } - if (!differ) { - /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n, "decl"); - String *d2 = Getattr(nodes[j].n, "decl"); - if (d1 && d2) { - String *dq1 = Copy(d1); - String *dq2 = Copy(d2); - if (SwigType_isconst(d1)) { - Delete(SwigType_pop(dq1)); - } - if (SwigType_isconst(d2)) { - Delete(SwigType_pop(dq2)); - } - if (Strcmp(dq1, dq2) == 0) { - - if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { - if (script_lang_wrapping) { - // Swap nodes so that the const method gets ignored (shadowed by the non-const method) - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - } - nodes[j].error = 1; - } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { - differ = 1; - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), - "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - } - nodes[j].error = 1; - } - } - Delete(dq1); - Delete(dq2); - } - } - if (!differ) { - if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), - "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) { - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), - "using %s instead.\n", Swig_name_decl(nodes[i].n)); - } - } - nodes[j].error = 1; - } - } - } - } - } - } - List *result = NewList(); - { - int i; - for (i = 0; i < nnodes; i++) { - if (nodes[i].error) - Setattr(nodes[i].n, "overload:ignore", "1"); - Append(result,nodes[i].n); - // Printf(stdout,"[ %d ] %s\n", i, ParmList_errorstr(nodes[i].parms)); - // Swig_print_node(nodes[i].n); - } - } - return result; -} - void R::dispatchFunction(Node *n) { Wrapper *f = NewWrapper(); String *symname = Getattr(n, "sym:name"); From 73fe0fdc7e72311072235137d498864e15ccf2f2 Mon Sep 17 00:00:00 2001 From: luav Date: Tue, 12 Sep 2017 04:10:30 +0200 Subject: [PATCH 0703/2031] %rename for functions with default parameters explained, see #1087 --- Doc/Manual/SWIG.html | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 965fae11c..304377f29 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1736,6 +1736,43 @@ already defined in the target scripting language. However, if you are careful about namespaces and your use of modules, you can usually avoid these problems.

      +

      +%rename directive respects function parameters and discriminates default parameters from non-default, +which is essential for some languages including Python. Be careful renaming functions having default parameters: +

      +
      +%rename(toFFVal) to_val(FileFormat, bool bin=false);
      +int to_val(FileFormat flag, bool bin=false)
      +{
      +  return 0;
      +}
      +
      +%rename(toDFVal) to_val(DirFormat, bool bin);
      +int to_val(DirFormat flag, bool bin=false)
      +{
      +  return 0;
      +}
      +
      +%rename(toLFVal) to_val(FolderFormat, bool bin);
      +int to_val(FolderFormat flag, bool bin=false)
      +{
      +  return 0;
      +}
      +
      + +

      +The SWIG generator yields the following warning for the last renaming:
      + +rename.i:36: Warning 509: Overloaded method to_val(FolderFormat) effectively ignored,
      +rename.i:26: Warning 509: as it is shadowed by to_val(DirFormat).
      +
      +The renaming performed for the int to_val(FolderFormat flag, bool bin), +but not for the int to_val(FolderFormat flag), where the second parameter bool bin +is omitted taking the default value false. See details about the default +parameters processing in the Default Arguments section. +

      + +

      Closely related to %rename is the %ignore directive. %ignore instructs SWIG to ignore declarations that match a given identifier. For example: From 065c06159ee51e5babce59b542b75c2467449eef Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Sep 2017 07:48:25 +0100 Subject: [PATCH 0704/2031] Travis fix for pip install pep8 Fix for recent Travis image cleanup. Issue https://github.com/travis-ci/travis-ci/issues/8378 --- .travis.yml | 1 - Tools/travis-linux-install.sh | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05681a110..5cf93628e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: cpp -group: deprecated-2017Q3 # workaround for failing: pip install pep8 matrix: include: - compiler: clang diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 43bdb77bc..5e93d995f 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -88,7 +88,7 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install php$VER-cli php$VER-dev ;; "python") - pip install pep8 + pip install --user pep8 if [[ "$PY3" ]]; then travis_retry sudo apt-get install -qq python3-dev fi From cac396eb56991651eea8613d773590857d4b3357 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Sep 2017 08:32:49 +0100 Subject: [PATCH 0705/2031] Restore node testing on Travis (for Ubuntu Trusty) --- .travis.yml | 9 +++++---- Tools/travis-linux-install.sh | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5cf93628e..a82b2bc47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,10 +49,11 @@ matrix: env: SWIGLANG=java sudo: required dist: trusty -# - compiler: gcc -# os: linux -# env: SWIGLANG=javascript ENGINE=node -# dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=jsc diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 5e93d995f..4a958dfb8 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -33,10 +33,7 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - travis_retry sudo add-apt-repository -y ppa:chris-lea/node.js - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq nodejs rlwrap - travis_retry sudo npm install -g node-gyp + travis_retry sudo apt-get install -qq nodejs node-gyp ;; "jsc") travis_retry sudo apt-get install -qq libwebkitgtk-dev From b41fdba9ef483969f6641b94a75b14c0f12a5fde Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Sep 2017 08:36:53 +0100 Subject: [PATCH 0706/2031] Cosmetic changes for Java std::array wrappers --- Lib/java/std_array.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/java/std_array.i b/Lib/java/std_array.i index f75857e21..0944d932f 100644 --- a/Lib/java/std_array.i +++ b/Lib/java/std_array.i @@ -8,13 +8,13 @@ namespace std { template class array { public: - typedef T& reference; - typedef const T& const_reference; typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; + typedef T &reference; + typedef const T &const_reference; + typedef T *pointer; + typedef const T *const_pointer; array(); array(const array& other); size_type size() const; From 8a168795d35c5157474d046cf248118b905cf5ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Sep 2017 08:47:10 +0100 Subject: [PATCH 0707/2031] Cosmetic formatting fixes in generated code for exception handlers --- Source/Modules/emit.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 7c2607fc8..813a30924 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -454,7 +454,7 @@ String *emit_action(Node *n) { if (catchlist) { int unknown_catch = 0; int has_varargs = 0; - Printf(eaction, "}\n"); + Printf(eaction, "} "); for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) { String *em = Swig_typemap_lookup("throws", ep, "_e", 0); if (em) { From 2fee7c96cc86516671c24e5895619922122a11a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Oct 2016 07:04:33 +0100 Subject: [PATCH 0708/2031] Remove C casts in PyTypeObject for Python builtin type declarations Choose compile time failures over runtime errors. This change highlighted a problem in the constructor wrappers for tp_init where the kwargs parameter was missing in the generated wrapper function. Leave casts in for 0 initialization. --- Source/Modules/python.cxx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9039f07ca..4e9053395 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -177,7 +177,7 @@ static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_s static void printSlot(File *f, String *slotval, const char *slotname, const char *functype = NULL) { String *slotval_override = 0; - if (functype) + if (functype && Strcmp(slotval, "0") == 0) slotval = slotval_override = NewStringf("(%s) %s", functype, slotval); int len = Len(slotval); int fieldwidth = len > 41 ? (len > 61 ? 0 : 61 - len) : 41 - len; @@ -2501,7 +2501,8 @@ public: String *tmp = NewString(""); String *dispatch; - const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : "return %s(self, args);"; + const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : + (builtin_ctor ? "return %s(self, args, NULL);" : "return %s(self, args);"); if (castmode) { dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs); @@ -2515,7 +2516,8 @@ public: String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); - Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args) {", NIL); + const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : ""; + Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL); Wrapper_add_local(f, "argc", "Py_ssize_t argc"); Printf(tmp, "PyObject *argv[%d] = {0}", maxargs + 1); @@ -2729,9 +2731,10 @@ public: Append(wname, overname); } + const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : ""; if (!allow_kwargs || overname) { if (!varargs) { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL); } else { Printv(f->def, linkage, wrap_return, wname, "__varargs__", "(PyObject *", self_param, ", PyObject *args, PyObject *varargs) {", NIL); } @@ -2933,11 +2936,7 @@ public: } Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments); } else { - if (noargs) { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); - } else { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); - } + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL); if (onearg && !builtin_ctor) { Printf(parse_args, "if (!args) SWIG_fail;\n"); Append(parse_args, "swig_obj[0] = args;\n"); @@ -3241,7 +3240,7 @@ public: // Note: funpack is currently always false for varargs Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", Py_ssize_t nobjs, PyObject **swig_obj) {", NIL); } else { - Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args) {", NIL); + Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL); } Wrapper_add_local(f, "resultobj", builtin_ctor ? "int resultobj" : "PyObject *resultobj"); Wrapper_add_local(f, "varargs", "PyObject *varargs"); @@ -3351,7 +3350,7 @@ public: closure_name = Copy(wrapper_name); } if (func_type) { - String *s = NewStringf("(%s) %s", func_type, closure_name); + String *s = NewStringf("%s", closure_name); Delete(closure_name); closure_name = s; } From 169738011c7ee2f12aaf5d5fcbabd18045f5c30b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Sep 2017 07:39:16 +0100 Subject: [PATCH 0709/2031] Update version number to 4.0 in docs --- Doc/Manual/Sections.html | 4 ++-- Doc/Manual/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 739170745..c17f9e84e 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -1,11 +1,11 @@ -SWIG-3.0 Documentation +SWIG-4.0 Documentation -

      SWIG-3.0 Documentation

      +

      SWIG-4.0 Documentation

      Last update : SWIG-4.0.0 (in progress) diff --git a/Doc/Manual/index.html b/Doc/Manual/index.html index 26cc81ea1..e720e70d0 100644 --- a/Doc/Manual/index.html +++ b/Doc/Manual/index.html @@ -1,11 +1,11 @@ -SWIG-3.0 Documentation +SWIG-4.0 Documentation -

      SWIG-3.0 Documentation

      +

      SWIG-4.0 Documentation

      The SWIG documentation is available in one of the following formats.
        From ff52610dc58bec838d7298a9d9bd45d2770515b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Sep 2017 07:49:06 +0100 Subject: [PATCH 0710/2031] Move C++ 'Default arguments' section in manual --- Doc/Manual/Contents.html | 2 +- Doc/Manual/SWIGPlus.html | 228 +++++++++++++++++++-------------------- 2 files changed, 115 insertions(+), 115 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index b879eaa04..e3478ae91 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -228,7 +228,6 @@
      • Static members
      • Member data
      -
    • Default arguments
    • Protection
    • Enums and constants
    • Friends @@ -236,6 +235,7 @@
    • Pass and return by value
    • Inheritance
    • A brief discussion of multiple inheritance, pointers, and type checking +
    • Default arguments
    • Wrapping Overloaded Functions and Methods -
    • Default arguments
    • Protection
    • Enums and constants
    • Friends @@ -39,6 +38,7 @@
    • Pass and return by value
    • Inheritance
    • A brief discussion of multiple inheritance, pointers, and type checking +
    • Default arguments
    • Wrapping Overloaded Functions and Methods
      • Dispatch function generation @@ -1104,113 +1104,7 @@ a few problems related to structure wrapping and some of SWIG's customization features.

        -

        6.7 Default arguments

        - - -

        -SWIG will wrap all types of functions that have default arguments. For example member functions: -

        - -
        -
        -class Foo {
        -public:
        -  void bar(int x, int y = 3, int z = 4);
        -};
        -
        -
        - -

        -SWIG handles default arguments by generating an extra overloaded method for each defaulted argument. -SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods. -Thus for the example above, it is as if we had instead given the following to SWIG: -

        - -
        -
        -class Foo {
        -public:
        -  void bar(int x, int y, int z);
        -  void bar(int x, int y);
        -  void bar(int x);
        -};
        -
        -
        - -

        -The wrappers produced are exactly the same as if the above code was instead fed into SWIG. -Details of this are covered later in the Wrapping Overloaded Functions and Methods section. -This approach allows SWIG to wrap all possible default arguments, but can be verbose. -For example if a method has ten default arguments, then eleven wrapper methods are generated. -

        - -

        -Please see the Features and default arguments -section for more information on using %feature with functions with default arguments. -The Ambiguity resolution and renaming section -also deals with using %rename and %ignore on methods with default arguments. -If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. -See the Typemaps and overloading section for details or otherwise -use the compactdefaultargs feature flag as mentioned below. -

        - -

        -Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. -Instead a single wrapper method was generated and the default values were copied into the C++ wrappers -so that the method being wrapped was then called with all the arguments specified. -If the size of the wrappers are a concern then this approach to wrapping methods with default arguments -can be re-activated by using the compactdefaultargs -feature flag. -

        - -
        -
        -%feature("compactdefaultargs") Foo::bar;
        -class Foo {
        -public:
        -  void bar(int x, int y = 3, int z = 4);
        -};
        -
        -
        - - -

        -This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, -such as C# and Java, -which don't have optional arguments in the language, -Another restriction of this feature is that it cannot handle default arguments that are not public. -The following example illustrates this: -

        - -
        -
        -class Foo {
        -private:
        -  static const int spam;
        -public:
        -  void bar(int x, int y = spam);   // Won't work with %feature("compactdefaultargs") -
        -                                   // private default value
        -};
        -
        -
        - -

        -This produces uncompilable wrapper code because default values in C++ are -evaluated in the same scope as the member function whereas SWIG -evaluates them in the scope of a wrapper function (meaning that the -values have to be public). -

        - -

        -The compactdefaultargs feature is automatically turned on when wrapping C code with default arguments. -Some target languages will also automatically turn on this feature -if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs, -the compactdefaultargs feature is also automatically turned on. -Keyword arguments are a language feature of some scripting languages, for example Ruby and Python. -SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used. -

        - -

        6.8 Protection

        +

        6.7 Protection

        @@ -1230,7 +1124,7 @@ until you explicitly give a `public:' declaration (This is the same convention used by C++).

        -

        6.9 Enums and constants

        +

        6.8 Enums and constants

        @@ -1260,7 +1154,7 @@ Swig_STOUT = Swig::STOUT Members declared as const are wrapped as read-only members and do not create constants.

        -

        6.10 Friends

        +

        6.9 Friends

        @@ -1321,7 +1215,7 @@ namespace bar { and a wrapper for the method 'blah' will not be generated.

        -

        6.11 References and pointers

        +

        6.10 References and pointers

        @@ -1421,7 +1315,7 @@ templates and the STL. This was first added in SWIG-1.3.12.

        -

        6.12 Pass and return by value

        +

        6.11 Pass and return by value

        @@ -1525,7 +1419,7 @@ classes that don't define a default constructor. It is not used for C++ pointers or references.

        -

        6.13 Inheritance

        +

        6.12 Inheritance

        @@ -1711,7 +1605,7 @@ functions for virtual members that are already defined in a base class.

        -

        6.14 A brief discussion of multiple inheritance, pointers, and type checking

        +

        6.13 A brief discussion of multiple inheritance, pointers, and type checking

        @@ -1843,6 +1737,112 @@ int y = B_function((B *) pB); In practice, the pointer is held as an integral number in the target language proxy class.

        +

        6.14 Default arguments

        + + +

        +SWIG will wrap all types of functions that have default arguments. For example member functions: +

        + +
        +
        +class Foo {
        +public:
        +  void bar(int x, int y = 3, int z = 4);
        +};
        +
        +
        + +

        +SWIG handles default arguments by generating an extra overloaded method for each defaulted argument. +SWIG is effectively handling methods with default arguments as if it was wrapping the equivalent overloaded methods. +Thus for the example above, it is as if we had instead given the following to SWIG: +

        + +
        +
        +class Foo {
        +public:
        +  void bar(int x, int y, int z);
        +  void bar(int x, int y);
        +  void bar(int x);
        +};
        +
        +
        + +

        +The wrappers produced are exactly the same as if the above code was instead fed into SWIG. +Details of this are covered later in the Wrapping Overloaded Functions and Methods section. +This approach allows SWIG to wrap all possible default arguments, but can be verbose. +For example if a method has ten default arguments, then eleven wrapper methods are generated. +

        + +

        +Please see the Features and default arguments +section for more information on using %feature with functions with default arguments. +The Ambiguity resolution and renaming section +also deals with using %rename and %ignore on methods with default arguments. +If you are writing your own typemaps for types used in methods with default arguments, you may also need to write a typecheck typemap. +See the Typemaps and overloading section for details or otherwise +use the compactdefaultargs feature flag as mentioned below. +

        + +

        +Compatibility note: Versions of SWIG prior to SWIG-1.3.23 wrapped default arguments slightly differently. +Instead a single wrapper method was generated and the default values were copied into the C++ wrappers +so that the method being wrapped was then called with all the arguments specified. +If the size of the wrappers are a concern then this approach to wrapping methods with default arguments +can be re-activated by using the compactdefaultargs +feature flag. +

        + +
        +
        +%feature("compactdefaultargs") Foo::bar;
        +class Foo {
        +public:
        +  void bar(int x, int y = 3, int z = 4);
        +};
        +
        +
        + + +

        +This is great for reducing the size of the wrappers, but the caveat is it does not work for the statically typed languages, +such as C# and Java, +which don't have optional arguments in the language, +Another restriction of this feature is that it cannot handle default arguments that are not public. +The following example illustrates this: +

        + +
        +
        +class Foo {
        +private:
        +  static const int spam;
        +public:
        +  void bar(int x, int y = spam);   // Won't work with %feature("compactdefaultargs") -
        +                                   // private default value
        +};
        +
        +
        + +

        +This produces uncompilable wrapper code because default values in C++ are +evaluated in the same scope as the member function whereas SWIG +evaluates them in the scope of a wrapper function (meaning that the +values have to be public). +

        + +

        +The compactdefaultargs feature is automatically turned on when wrapping C code with default arguments. +Some target languages will also automatically turn on this feature +if the keyword arguments feature (kwargs) is specified for either C or C++ functions, and the target language supports kwargs, +the compactdefaultargs feature is also automatically turned on. +Keyword arguments are a language feature of some scripting languages, for example Ruby and Python. +SWIG is unable to support kwargs when wrapping overloaded methods, so the default approach cannot be used. +

        +

        6.15 Wrapping Overloaded Functions and Methods

        From d5d97a406927ebf6bd86ce2c4c7723e76fb8252b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Sep 2017 07:58:24 +0100 Subject: [PATCH 0711/2031] Overloaded methods section renamed slightly in docs --- Doc/Manual/Contents.html | 4 ++-- Doc/Manual/Php.html | 3 +-- Doc/Manual/SWIGPlus.html | 10 +++++----- Doc/Manual/Scilab.html | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e3478ae91..4211d8ab8 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -236,14 +236,14 @@
      • Inheritance
      • A brief discussion of multiple inheritance, pointers, and type checking
      • Default arguments -
      • Wrapping Overloaded Functions and Methods +
      • Overloaded functions and methods -
      • Wrapping overloaded operators +
      • Overloaded operators
      • Class extension
      • Templates
          diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 9a1178abf..9fbfd75c0 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -390,8 +390,7 @@ Although PHP does not support overloading functions natively, swig will generate dispatch functions which will use %typecheck typemaps to allow overloading. This dispatch function's operation and precedence is described in Wrapping -Overloaded Functions and Methods. +href="SWIGPlus.html#SWIGPlus_overloaded_methods">Overloaded functions and methods.

           %module(directors="1") example
           
           %{
          -  #include <string>
             #include <stdexcept>
          +  #include <iostream>
           %}
           
          -// Define exceptions in header section using std::runtime_error
          -%define DEFINE_EXCEPTION(NAME)
          -%{
          -  namespace MyNS {
          -    struct NAME : public std::runtime_error { NAME(const std::string &what) : runtime_error(what) {} };
          +// Generic catch handler for all wrapped methods
          +%exception %{
          +  try {
          +    $action
          +  } catch (const std::exception &e) {
          +    std::cout << "Generic std::exception catch handler" << std::endl;
          +    jclass clazz = jenv->FindClass("java/lang/RuntimeException");
          +    jenv->ThrowNew(clazz, e.what()); 
          +    return $null;
             }
           %}
          -%enddef
           
          -// Expose C++ exceptions as Java Exceptions by changing the Java base class and providing a getMessage()
          -%define DECLARE_EXCEPTION(NAME)
          -%typemap(javabase) MyNS::NAME "java.lang.Exception";
          -%rename(getMessage) MyNS::NAME::what;
          +// Expose C++ exception as a Java Exception by changing the Java base class and providing a getMessage()
          +%typemap(javabase) MyNS::MyException "java.lang.RuntimeException";
          +%rename(getMessage) MyNS::MyException::whatsup;
          +
          +%inline %{
           namespace MyNS {
          -  struct NAME {
          -    NAME(const std::string& what);
          -    const char * what();
          +  class MyException {
          +    std::string msg;
          +  public:
          +    MyException(const char *msg) : msg(msg) {}
          +    const char * whatsup() const { return msg.c_str(); }
             };
           }
          -%enddef
          +%}
           
          -DEFINE_EXCEPTION(ExceptionA)
          -DEFINE_EXCEPTION(ExceptionB)
          -DEFINE_EXCEPTION(Unexpected)
          -
          -%typemap(directorthrows) MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected %{
          -  if (Swig::ExceptionMatches(jenv, $error, "$packagepath/$javaclassname")) {
          +%typemap(directorthrows) MyNS::MyException %{
          +  if (Swig::ExceptionMatches(jenv, $error, "$packagepath/MyException")) {
          +    std::cout << "$1_type exception matched (directorthrows typemap)" << std::endl;
               throw $1_type(Swig::JavaExceptionMessage(jenv, $error).message());
             }
           %}
           
          -DECLARE_EXCEPTION(ExceptionA)
          -DECLARE_EXCEPTION(ExceptionB)
          -DECLARE_EXCEPTION(Unexpected)
          +%typemap(throws) MyNS::MyException %{
          +  std::cout << "$1_type caught (throws typemap)" << std::endl;
          +  jclass excep = jenv->FindClass("MyException");
          +  if (excep) {
          +    std::cout << "$1_type class found (throws typemap)" << std::endl;
          +    jenv->ThrowNew(excep, $1.whatsup());
          +  }
          +  return $null;
          +%}
           
          -%catches(MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected) MyClass::meth2();
          +// These are the exceptions that the director method MyClass::dirmethod will have catch handlers for.
          +// Note that this is also a virtual method / director method and the C++ exceptions listed can be
          +// thrown after converting them from Java exceptions.
          +%catches(MyNS::MyException, Swig::DirectorException) MyClass::dirmethod;
          +
          +// These are the exceptions that call_dirmethod C++ wrapper will have catch handlers for.
          +// Note that this is not a virtual method, hence not a director method.
          +%catches(MyNS::MyException, Swig::DirectorException) call_dirmethod;
           
           %feature("director") MyClass;
           
          -%inline {
          -  class MyClass {
          -  public:
          -    virtual void meth1(int x) throw(MyNS::ExceptionA, MyNS::ExceptionB) = 0;
          -    virtual void meth2() = 0;   /* throws MyNS::ExceptionA, MyNS::ExceptionB, MyNS::Unexpected */
          -    virtual void meth3(float x) throw(MyNS::Unexpected) = 0;
          -    virtual ~MyClass() {}
          -  };
          -}
          -
          -
          - -

          -In this case the three different "directorthrows" typemaps will be used -to generate the three different exception handlers for -meth1, meth2 and meth3. The generated -handlers will have "if" blocks for each exception type, where the exception types are listed in either -the exception specification or %catches feature. -

          - -

          Note that the "directorthrows" typemaps are important -only if it is important for the exceptions passed through the C++ -layer need to be mapped to distinct C++ exceptions. If director methods -are being called by C++ code that is itself wrapped in a -SWIG generated Java wrapper and access is always through this wrapper, -the default Swig::DirectorException class provides enough information -to reconstruct the original exception. In this case removing the -$directorthrowshandlers special variable from the -default director:except feature and simply always -throwing a Swig::DirectorException will achieve the desired result. -Along with this a generic exception feature is added to convert any -caught Swig::DirectorExceptions back into the underlying -Java exceptions via the Swig::DirectorException::raiseJavaException method, -as demonstrated with %javaexception below: -

          - -
          -
          -%javaexception("Exception") MyClass::myMethod %{
          -  try {
          -    $action
          -  } catch (Swig::DirectorException &e) {
          -    // raise/throw the Java exception that originally caused the DirectorException
          -    e.raiseJavaException(jenv);
          -    return $null;
          +%feature("director:except") MyClass::dirmethod(int x) {
          +  jthrowable $error = jenv->ExceptionOccurred();
          +  if ($error) {
          +    std::cout << "Upcall finished, an exception was thrown in Java" << std::endl;
          +    $directorthrowshandlers
          +    std::cout << "Upcall finished, no exception conversion, throwing DirectorException" << std::endl;
          +    Swig::DirectorException::raise(jenv, $error);
             }
          +}
          +
          +%inline %{
          +class MyClass {
          +public:
          +  /** Throws either a std::out_of_range or MyException on error */
          +  virtual void dirmethod(int x) {
          +    if (x <= 0)
          +      throw std::out_of_range("MyClass::dirmethod index is out of range");
          +    else if (x == 1)
          +      throw MyNS::MyException("MyClass::dirmethod some problem!");
          +  }
          +  virtual ~MyClass() {}
          +  static void call_dirmethod(MyClass& c, int x) {
          +    return c.dirmethod(x);
          +  }
          +};
           %}
           

          -See the Exception handling with %exception and %javaexception -section for more on converting C++ exceptions to Java exceptions. +The generated code for the call_dirmethod wrapper contains the various exception handlers. +The outer exception handler is from the %exception directive and the others +are from the "throws" typemaps.

          +
          +
          +SWIGEXPORT void JNICALL Java_exampleJNI_MyClass_1call_1dirmethod(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2) {
          +  ...
          +  try {
          +    try {
          +      MyClass::call_dirmethod(*arg1,arg2);
          +    } catch(MyNS::MyException &_e) {
          +      std::cout << "MyNS::MyException caught (throws typemap)" << std::endl;
          +      jclass excep = jenv->FindClass("MyException");
          +      if (excep) {
          +        std::cout << "MyNS::MyException class found (throws typemap)" << std::endl;
          +        jenv->ThrowNew(excep, (&_e)->whatsup());
          +      }
          +      return ;
          +      
          +    } catch(Swig::DirectorException &_e) {
          +      (&_e)->raiseJavaException(jenv);
          +      return ; 
          +    }
          +  } catch (const std::exception &e) {
          +    std::cout << "Generic std::exception catch handler" << std::endl;
          +    jclass clazz = jenv->FindClass("java/lang/RuntimeException");
          +    jenv->ThrowNew(clazz, e.what()); 
          +    return ;
          +  }
          +
          +
          + +

          +The director method calling up to Java contains the exception handling code from the "directorthrows" typemaps and director:except feature. +

          + +
          +
          +void SwigDirector_MyClass::dirmethod(int x) {
          +      ... [call up to Java using CallStaticVoidMethod]
          +      jthrowable swigerror = jenv->ExceptionOccurred();
          +      if (swigerror) {
          +        std::cout << "Upcall finished, an exception was thrown in Java" << std::endl;
          +        
          +        if (Swig::ExceptionMatches(jenv, swigerror, "MyException")) {
          +          std::cout << "MyNS::MyException exception matched (directorthrows typemap)" << std::endl;
          +          throw MyNS::MyException(Swig::JavaExceptionMessage(jenv, swigerror).message());
          +        }
          +        
          +        std::cout << "Upcall finished, no exception conversion, throwing DirectorException" << std::endl;
          +        Swig::DirectorException::raise(jenv, swigerror);
          +      }
          +
          +
          + +

          +Let's use the following Java class to override the director method. +

          + +
          +
          +class DerivedClass extends MyClass {
          +  @Override
          +  public void dirmethod(int x) {
          +    if (x < 0)
          +      throw new IndexOutOfBoundsException("Index is negative");
          +    else if (x == 0)
          +      throw new MyException("MyException: bad dirmethod");
          +  }
          +}
          +public class runme {
          +  public static void main(String argv[]) {
          +    System.loadLibrary("example");
          +    ... code snippets shown below ...
          +  }
          +}
          +
          +
          + +

          +Consider the output using the Java code in the four slightly different scenarios below. +

          + +

          +1. Non-director C++ class is used, thus, no upcall to a Java director method is made. +A std::out_of_range exception is thrown, which is derived from std::exception, +and hence caught by the generic exception handler in the call_dirmethod wrapper. +The Java code snippet and resulting output is: +

          + + +
          +
          +MyClass.call_dirmethod(new MyClass(), 0);
          +
          +
          + +
          +
          +Generic std::exception catch handler
          +Exception in thread "main" java.lang.RuntimeException: MyClass::dirmethod index is out of range
          +        at exampleJNI.MyClass_call_dirmethod(Native Method)
          +        at MyClass.call_dirmethod(MyClass.java:57)
          +        at runme.main(runme.java:14)
          +
          +
          + +

          +2. Non-director C++ class again but this time the MyNS::MyException class is thrown and caught: +

          + +
          +
          +MyClass.call_dirmethod(new MyClass(), 1);
          +
          +
          + +
          +
          +MyNS::MyException caught (throws typemap)
          +MyNS::MyException class found (throws typemap)
          +Exception in thread "main" MyException: MyClass::dirmethod some problem!
          +        at exampleJNI.MyClass_call_dirmethod(Native Method)
          +        at MyClass.call_dirmethod(MyClass.java:57)
          +        at runme.main(runme.java:15)
          +
          +
          + +

          +3. The DerivedClass director class is used so the upcall to Java occurs, but it throws +a Java MyException, which gets converted into a C++ MyNS::MyException, then caught and converted back +into a Java MyException: +

          + +
          +
          +MyClass.call_dirmethod(new DerivedClass(), 0);
          +
          +
          + +
          +
          +Upcall finished, an exception was thrown in Java
          +MyNS::MyException exception matched (directorthrows typemap)
          +MyNS::MyException caught (throws typemap)
          +MyNS::MyException class found (throws typemap)
          +Exception in thread "main" MyException: MyException: bad dirmethod
          +        at exampleJNI.MyClass_call_dirmethod(Native Method)
          +        at MyClass.call_dirmethod(MyClass.java:57)
          +        at runme.main(runme.java:16)
          +
          +
          + +

          +4. The director class is used again, but this time the director method throws a Java IndexOutOfBoundsException exception which is converted into a C++ Swig::DirectorException, thrown and caught again. +This time the original Java exception is extracted from the Swig::DirectorException and rethrown. +Note that this approach keeps the stack trace information of the original exception, so it has the exact location of where the IndexOutOfBoundsException exception was thrown. +This is arguably an improvement over the approach above that converts from a Java excepton to C++ exception and then back to a new Java exception, losing the location of the original exception. +

          + +
          +
          +MyClass.call_dirmethod(new DerivedClass(), -1);
          +
          +
          + +
          +
          +Upcall finished, an exception was thrown in Java
          +Upcall finished, no exception conversion, throwing DirectorException
          +Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negative
          +        at DerivedClass.dirmethod(runme.java:5)
          +        at exampleJNI.SwigDirector_MyClass_dirmethod(exampleJNI.java:23)
          +        at exampleJNI.MyClass_call_dirmethod(Native Method)
          +        at MyClass.call_dirmethod(MyClass.java:57)
          +        at runme.main(runme.java:17)
          +
          +
          +

          25.6 Accessing protected members

          diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 144a24d0a..5eac55261 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4630,7 +4630,7 @@ The next section details a way of simulating an exception specification or repla Exceptions are automatically handled for methods with an exception specification. Similar handling can be achieved for methods without exception specifications through the %catches feature. It is also possible to replace any declared exception specification using the %catches feature. -In fact, %catches uses the same "throws" typemaps that SWIG uses for exception specifications in handling exceptions. +In fact, %catches uses the same "throws" typemaps that SWIG uses for exception specifications in handling exceptions. The %catches feature must contain a list of possible types that can be thrown. For each type that is in the list, SWIG will generate a catch handler, in the same way that it would for types declared in the exception specification. Note that the list can also include the catch all specification "...". diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 371d0debd..d0d8d7951 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -67,7 +67,7 @@
        • "memberin" typemap
        • "varin" typemap
        • "varout" typemap -
        • "throws" typemap +
        • "throws" typemap
      • Some typemap examples
          @@ -2884,11 +2884,11 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

          -

          11.5.14 "throws" typemap

          +

          11.5.14 "throws" typemap

          -The "throws" typemap is only used when SWIG parses a C++ method with an exception specification or has the %catches feature attached to the method. +The "throws" typemap is only used when SWIG parses a C++ method with an exception specification or has the %catches feature attached to the method (see Exception handling with %catches). It provides a default mechanism for handling C++ methods that have declared the exceptions they will throw. The purpose of this typemap is to convert a C++ exception into an error or exception in the target language. It is slightly different to the other typemaps as it is based around the exception type rather than the type of a parameter or variable. @@ -2913,7 +2913,7 @@ For example:

          As can be seen from the resulting generated code below, SWIG generates an exception handler -with the catch block comprising the "throws" typemap content. +when wrapping the bar function with the catch block comprising the "throws" typemap content.

          From 901f8357b00f6de94a3ad9d70dd00722557b5430 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Nov 2017 20:25:58 +0000 Subject: [PATCH 0805/2031] Replace DirectorException::raiseJavaException with DirectorException::throwException This is part of a plan to provide a common DirectorException api for throwing the target language exception raised during a director method call. --- Doc/Manual/Java.html | 4 ++-- Examples/test-suite/java_director_exception_feature.i | 7 ++++--- .../test-suite/java_director_exception_feature_nspace.i | 7 ++++--- Lib/java/director.swg | 7 ++++++- Lib/java/java.swg | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 2b6ec6ce0..3b6cb3a05 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3992,7 +3992,7 @@ namespace Swig { // Reconstruct and raise/throw the Java Exception that caused the DirectorException // Note that any error in the JNI exception handling results in a Java RuntimeException - void raiseJavaException(JNIEnv *jenv) const; + void throwException(JNIEnv *jenv) const; // Create and throw the DirectorException static void raise(JNIEnv *jenv, jthrowable throwable) { @@ -4295,7 +4295,7 @@ SWIGEXPORT void JNICALL Java_exampleJNI_MyClass_1call_1dirmethod(JNIEnv *jenv, j return ; } catch(Swig::DirectorException &_e) { - (&_e)->raiseJavaException(jenv); + (&_e)->throwException(jenv); return ; } } catch (const std::exception &e) { diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i index 0cd555875..b5b9c3938 100644 --- a/Examples/test-suite/java_director_exception_feature.i +++ b/Examples/test-suite/java_director_exception_feature.i @@ -132,9 +132,10 @@ %} %feature ("except",throws="Exception") MyNS::Bar::genericpong %{ - try { $action } - catch (Swig::DirectorException & direxcp) { - direxcp.raiseJavaException(jenv); // jenv always available in JNI code + try { + $action + } catch (Swig::DirectorException & direxcp) { + direxcp.throwException(jenv); // jenv always available in JNI code return $null; } %} diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i index aa8c64cc9..9f542fd37 100644 --- a/Examples/test-suite/java_director_exception_feature_nspace.i +++ b/Examples/test-suite/java_director_exception_feature_nspace.i @@ -139,9 +139,10 @@ %} %feature ("except",throws="Exception") MyNS::Bar::genericpong %{ - try { $action } - catch (Swig::DirectorException & direxcp) { - direxcp.raiseJavaException(jenv); // jenv always available in JNI code + try { + $action + } catch (Swig::DirectorException & direxcp) { + direxcp.throwException(jenv); // jenv always available in JNI code return $null; } %} diff --git a/Lib/java/director.swg b/Lib/java/director.swg index 416361c27..2275976b8 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -339,7 +339,7 @@ namespace Swig { // Reconstruct and raise/throw the Java Exception that caused the DirectorException // Note that any error in the JNI exception handling results in a Java RuntimeException - void raiseJavaException(JNIEnv *jenv) const { + void throwException(JNIEnv *jenv) const { if (jenv) { if (jenv == jenv_ && throwable_) { // Throw original exception if not already pending @@ -371,6 +371,11 @@ namespace Swig { } } + // Deprecated - use throwException + void raiseJavaException(JNIEnv *jenv) const { + throwException(jenv); + } + // Create and throw the DirectorException static void raise(JNIEnv *jenv, jthrowable throwable) { throw DirectorException(jenv, throwable); diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 184ee56aa..ae984313b 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1053,7 +1053,7 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); } /* For methods to raise/throw the original Java exception thrown in a director method */ %typemap(throws) Swig::DirectorException -%{ $1.raiseJavaException(jenv); +%{ $1.throwException(jenv); return $null; %} /* Java to C++ DirectorException should already be handled. Suppress warning and do nothing in the From bf21e80267dd0c7170a0cb8799562753ea1bef66 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Nov 2017 20:30:40 +0000 Subject: [PATCH 0806/2031] Add recent Java director enhancements to the changes file --- CHANGES.current | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b1c35d46d..a8fec2709 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,16 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-11-29: wsfulton + [Java] director exception handling improvements. + + When a director method throws an exception and it is caught by DirectorException + and passed back to Java using Swig::DirectorException::throwException, the Java + stack trace now contains the original source line that threw the exception. + + Deprecate Swig::DirectorException::raiseJavaException, please replace usage with + Swig::DirectorException::throwException. + 2017-10-26: wsfulton Add support for C++11 ref-qualifiers when using directors. From 7eff4e7c1d40b4f6666aa8b635f30d8f6771e88f Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Mon, 4 Dec 2017 09:23:06 -0600 Subject: [PATCH 0807/2031] Terminate options when passed via env var The C standard requires that argv be terminated with a NULL pointer (that is, argv[argc] == NULL). There are several places in the swig codebase that require this to check for missing arguments. However, SWIG_merge_envopt() was not keeping the NULL terminator, resulting in argument parsing failures (typically program aborts) when arguments were passed via the SWIG_FEATURES environment variable. --- Source/Modules/swigmain.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 397677fc5..b49fe909a 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -125,7 +125,7 @@ void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, ch int argc = 1; int arge = oargc + 1024; - char **argv = (char **) malloc(sizeof(char *) * (arge)); + char **argv = (char **) malloc(sizeof(char *) * (arge + 1)); char *buffer = (char *) malloc(2048); char *b = buffer; char *be = b + 1023; @@ -147,6 +147,7 @@ void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, ch for (int i = 1; (i < oargc) && (argc < arge); ++i, ++argc) { argv[argc] = oargv[i]; } + argv[argc] = NULL; *nargc = argc; *nargv = argv; From b0e29fbdf31bb94b11cb8a7cc830b4a76467afa3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Dec 2017 18:41:55 +0000 Subject: [PATCH 0808/2031] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing u"\udcff" to the C layer (Python 3). --- CHANGES.current | 8 ++++++- Doc/Manual/Python.html | 22 ++++++++++++++++--- Doc/Manual/Varargs.html | 5 ++++- Examples/python/multimap/example.i | 12 +++++++++- .../python/unicode_strings_runme.py | 10 +++++++++ Examples/test-suite/python_varargs_typemap.i | 5 ++++- Examples/test-suite/unicode_strings.i | 2 ++ Lib/python/pyerrors.swg | 11 ++++++---- Lib/python/pyhead.swg | 16 ++++++++------ Lib/python/pyinit.swg | 4 ++-- Lib/python/pyrun.swg | 10 ++++++--- Lib/python/pystrings.swg | 12 ++++++++-- 12 files changed, 92 insertions(+), 25 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5cab80172..06b958f18 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -6,8 +6,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== + +2017-12-04: wsfulton + [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a + seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing + u"\udcff" to the C layer (Python 3). + 2017-11-24: joequant - Fix github #1124 and return R_NilValue for null pointers + Fix #1124 and return R_NilValue for null pointers 2017-11-29: wsfulton [Java] director exception handling improvements. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 0c0023dea..27ce084bd 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6521,14 +6521,16 @@ string that cannot be completely decoded as UTF-8:
           %module example
           
          -%include <std_string.i>
          -
           %inline %{
           
          -const char* non_utf8_c_str(void) {
          +const char * non_utf8_c_str(void) {
             return "h\xe9llo w\xc3\xb6rld";
           }
           
          +void instring(const char *s) {
          +  ...
          +}
          +
           %}
           
          @@ -6590,6 +6592,20 @@ For more details about the surrogateescape error handler, please see PEP 383.

          +

          +When Python 3 strings are passed to the C/C++ layer, they are expected to be valid UTF8 Unicode strings too. +For example, when the instring method above is wrapped and called, any invalid UTF8 Unicode code strings +will result in a TypeError because the attempted conversion fails: +

          + +
          +>>> example.instring('h\xe9llo')
          +>>> example.instring('h\udce9llo')
          +Traceback (most recent call last):
          +  File "<stdin>", line 1, in <module>
          +TypeError: in method 'instring', argument 1 of type 'char const *'
          +
          +

          In some cases, users may wish to instead handle all byte strings as bytes objects in Python 3. This can be accomplished by adding diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index eba816382..014a38cae 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -529,8 +529,11 @@ like this: SWIG_fail; } pystr = PyUnicode_AsUTF8String(pyobj); + if (!pystr) { + SWIG_fail; + } str = strdup(PyBytes_AsString(pystr)); - Py_XDECREF(pystr); + Py_DECREF(pystr); %#else if (!PyString_Check(pyobj)) { PyErr_SetString(PyExc_ValueError, "Expected a string"); diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 66c0f74c6..3ff5d52c0 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -39,7 +39,11 @@ extern int gcd(int x, int y); %#if PY_VERSION_HEX >= 0x03000000 { PyObject *utf8str = PyUnicode_AsUTF8String(s); - const char *cstr = PyBytes_AsString(utf8str); + const char *cstr; + if (!utf8str) { + SWIG_fail; + } + cstr = PyBytes_AsString(utf8str); $2[i] = strdup(cstr); Py_DECREF(utf8str); } @@ -72,6 +76,9 @@ extern int gcdmain(int argc, char *argv[]); SWIG_fail; } utf8str = PyUnicode_AsUTF8String($input); + if (!utf8str) { + SWIG_fail; + } PyBytes_AsStringAndSize(utf8str, &cstr, &len); $1 = strncpy((char *)malloc(len+1), cstr, (size_t)len); $2 = (int)len; @@ -105,6 +112,9 @@ extern int count(char *bytes, int len, char c); char *cstr; Py_ssize_t len; PyObject *utf8str = PyUnicode_AsUTF8String($input); + if (!utf8str) { + SWIG_fail; + } PyBytes_AsStringAndSize(utf8str, &cstr, &len); $1 = strncpy((char *)malloc(len+1), cstr, (size_t)len); $2 = (int)len; diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index fa9c51437..39e93b0fc 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -25,3 +25,13 @@ if sys.version_info[0:2] < (3, 0): check(unicode_strings.charstring(unicode("hello4")), "hello4") unicode_strings.charstring(u"hell\xb05") unicode_strings.charstring(u"hell\u00f66") + +low_surrogate_string = u"\udcff" +try: + unicode_strings.instring(low_surrogate_string) + # Will succeed with Python 2 +except TypeError, e: + # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError. + # The real error is actually: + # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed + pass diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i index f05fb98eb..d809bf1fa 100644 --- a/Examples/test-suite/python_varargs_typemap.i +++ b/Examples/test-suite/python_varargs_typemap.i @@ -23,8 +23,11 @@ SWIG_fail; } pystr = PyUnicode_AsUTF8String(pyobj); + if (!pystr) { + SWIG_fail; + } str = strdup(PyBytes_AsString(pystr)); - Py_XDECREF(pystr); + Py_DECREF(pystr); %#else if (!PyString_Check(pyobj)) { PyErr_SetString(PyExc_ValueError, "Expected a string"); diff --git a/Examples/test-suite/unicode_strings.i b/Examples/test-suite/unicode_strings.i index 9be3748e6..e7266266e 100644 --- a/Examples/test-suite/unicode_strings.i +++ b/Examples/test-suite/unicode_strings.i @@ -20,4 +20,6 @@ char *charstring(char *s) { return s; } +void instring(const char *s) { +} %} diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index fe7313554..463afae15 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -53,14 +53,17 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyObject *value = 0; PyObject *traceback = 0; - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (PyErr_Occurred()) + PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); PyErr_Clear(); Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + if (tmp) + PyErr_Format(type, "%s %s", tmp, mesg); + else + PyErr_Format(type, "%s", mesg); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); Py_DECREF(value); diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 55eb95a6d..2fa8b5b4c 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -38,14 +38,16 @@ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { #if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; + char *newstr = 0; str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); + if (str) { + char *cstr; + Py_ssize_t len; + 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); diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index fe45ac941..826f8411b 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -84,10 +84,10 @@ swig_varlink_str(swig_varlinkobject *v) { SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; PyObject *str = swig_varlink_str(v); + const char *tmp = SWIG_Python_str_AsChar(str); fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + fprintf(fp,"%s\n", tmp ? tmp : "Invalid global variable"); SWIG_Python_str_DelForPy3(tmp); Py_DECREF(str); return 0; diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index efc476613..430d3af18 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1672,14 +1672,16 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); + const char *tmp = SWIG_Python_str_AsChar(old_str); + if (!tmp) + tmp = "Invalid error message"; 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, tmp); } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", tmp, mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); @@ -1805,6 +1807,8 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { Py_INCREF(name); } else { encoded_name = PyUnicode_AsUTF8String(name); + if (!encoded_name) + return -1; } PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); Py_DECREF(encoded_name); diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index fd37855eb..301e0f3e1 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -16,6 +16,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#endif { char *cstr; Py_ssize_t len; + int ret = SWIG_OK; %#if PY_VERSION_HEX>=0x03000000 %#if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { @@ -26,7 +27,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); - if(alloc) *alloc = SWIG_NEWOBJ; + if (!obj) + return SWIG_TypeError; + if (alloc) + *alloc = SWIG_NEWOBJ; %#endif PyBytes_AsStringAndSize(obj, &cstr, &len); %#else @@ -64,6 +68,8 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#endif %#else *cptr = SWIG_Python_str_AsChar(obj); + if (!*cptr) + ret = SWIG_TypeError; %#endif } } @@ -71,7 +77,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#if PY_VERSION_HEX>=0x03000000 && !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) Py_XDECREF(obj); %#endif - return SWIG_OK; + return ret; } else { %#if defined(SWIG_PYTHON_2_UNICODE) %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) @@ -84,6 +90,8 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); + if (!obj) + return SWIG_TypeError; if (PyString_AsStringAndSize(obj, &cstr, &len) != -1) { if (cptr) { if (alloc) *alloc = SWIG_NEWOBJ; From 224bb9e0232a219b7cefd23472b592b39e277f46 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 8 Dec 2017 15:50:14 +1300 Subject: [PATCH 0809/2031] [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals This should make the generated code work with PHP 7.2.0. --- CHANGES.current | 4 ++++ Source/Modules/php.cxx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 06b958f18..ce71dcac2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-12-08: olly + [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this + should make the generated code work with PHP 7.2.0. + 2017-12-04: wsfulton [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index dcfe4e377..b32f3c63e 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -372,8 +372,8 @@ public: Printf(s_header, "int error_code;\n"); Printf(s_header, "ZEND_END_MODULE_GLOBALS(%s)\n", module); Printf(s_header, "ZEND_DECLARE_MODULE_GLOBALS(%s)\n", module); - Printf(s_header, "#define SWIG_ErrorMsg() (%s_globals.error_msg)\n", module); - Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module); + Printf(s_header, "#define SWIG_ErrorMsg() ZEND_MODULE_GLOBALS_ACCESSOR(%s, error_msg)\n", module); + Printf(s_header, "#define SWIG_ErrorCode() ZEND_MODULE_GLOBALS_ACCESSOR(%s, error_code)\n", module); /* The following can't go in Lib/php/phprun.swg as it uses SWIG_ErrorMsg(), etc * which has to be dynamically generated as it depends on the module name. From e86c881a70333af96694dae4310f1ba48e71dd64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 13 Dec 2017 20:47:05 +0000 Subject: [PATCH 0810/2031] Fix directorout typemaps which were causing undefined behaviour when returning pointers by reference. Closes #1167 --- CHANGES.current | 4 ++++ Lib/csharp/csharp.swg | 6 ++++-- Lib/d/dswigtype.swg | 4 +++- Lib/go/go.swg | 5 +++++ Lib/java/java.swg | 6 ++++-- Lib/typemaps/swigtype.swg | 6 ++++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ce71dcac2..331806b8f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-12-13: wsfulton + Issue #1167 Fix directorout typemaps which were causing undefined behaviour when + returning pointers by reference. + 2017-12-08: olly [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this should make the generated code work with PHP 7.2.0. diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 5b539332c..e1554dcb8 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -857,8 +857,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %{ $result = (void *)*$1; %} %typemap(directorin) SWIGTYPE *const& %{ $input = (void *) $1; %} -%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const& -%{ $result = ($1_ltype)&$input; %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) SWIGTYPE *const& +%{ static $*1_ltype swig_temp; + swig_temp = ($*1_ltype)$input; + $result = &swig_temp; %} %typemap(csdirectorin) SWIGTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : new $*csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *const& "$*csclassname.getCPtr($cscall).Handle" diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg index 19b700052..f0d604b6f 100644 --- a/Lib/d/dswigtype.swg +++ b/Lib/d/dswigtype.swg @@ -185,7 +185,9 @@ %typemap(directorin) SWIGTYPE *const& "$input = (void *) $1;" %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const& - "$result = ($1_ltype)&$input;" +%{ static $*1_ltype swig_temp; + swig_temp = ($*1_ltype)$input; + $result = &swig_temp; %} %typemap(ddirectorin, nativepointer="cast($dtype)$winput" ) SWIGTYPE *const& "($winput is null) ? null : new $*dclassname($winput, false)" diff --git a/Lib/go/go.swg b/Lib/go/go.swg index 3e1fab2d9..c225ed9ad 100644 --- a/Lib/go/go.swg +++ b/Lib/go/go.swg @@ -380,6 +380,11 @@ %typemap(directorout) SWIGTYPE & %{ *($&1_ltype)&$result = $input; %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const& +%{ static $*1_ltype swig_temp; + swig_temp = *($1_ltype)&$input; + $result = &swig_temp; %} + %typemap(gotype) SWIGTYPE && %{$gotypename%} diff --git a/Lib/java/java.swg b/Lib/java/java.swg index ae984313b..19e597bd9 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1183,8 +1183,10 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); } %{ *($1_ltype)&$result = *$1; %} %typemap(directorin,descriptor="L$packagepath/$*javaclassname;") SWIGTYPE *const& %{ *(($1_ltype)&$input) = ($*1_ltype) $1; %} -%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const& -%{ $result = ($1_ltype)&$input; %} +%typemap(directorout, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) SWIGTYPE *const& +%{ static $*1_ltype swig_temp; + swig_temp = *($1_ltype)&$input; + $result = &swig_temp; %} %typemap(javadirectorin) SWIGTYPE *const& "($jniinput == 0) ? null : new $*javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *const& "$*javaclassname.getCPtr($javacall)" diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index be684211c..723dc08bb 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -431,6 +431,7 @@ } /* directorout */ + #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) { swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag); @@ -471,8 +472,9 @@ if (!SWIG_IsOK(swig_res)) { %dirout_fail(swig_res,"$type"); } - $result = %reinterpret_cast(&swig_argp, $ltype); - swig_acquire_ownership_obj(%as_voidptr(*$result), own /* & TODO: SWIG_POINTER_OWN */); + $1_ltype swig_temp = new $*1_ltype(($*1_ltype)swig_argp); + swig_acquire_ownership(swig_temp); + $result = swig_temp; } %typemap(directorfree,noblock=1,match="directorout") SWIGTYPE *const& { if (director) { From 717b7866d4e438e1ae3483f796eb07f96e246fe6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Dec 2017 07:49:56 +0000 Subject: [PATCH 0811/2031] Perl - Add support for missing directorfree typemaps Related to issue #1167, to free up memory when returning reference types. SWIG_Perl_AcquirePtr still needs implementing. --- CHANGES.current | 3 +++ Lib/perl5/perlrun.swg | 9 +++++++++ Source/Modules/perl5.cxx | 9 +++++++++ 3 files changed, 21 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 331806b8f..1c361fbec 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-12-13: wsfulton + [Perl] add missing support for directorfree typemaps. + 2017-12-13: wsfulton Issue #1167 Fix directorout typemaps which were causing undefined behaviour when returning pointers by reference. diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index cc4ba446a..02714c451 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -20,6 +20,7 @@ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) #define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) #define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) +#define SWIG_AcquirePtr(ptr, src) SWIG_Perl_AcquirePtr(ptr, src) #define swig_owntype int /* for raw packed data */ @@ -229,6 +230,14 @@ SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { return 0; } +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Perl_AcquirePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, int own) { + /* TODO */ + return 0; +} + /* Function for getting a pointer value */ SWIGRUNTIME int diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index d49da695f..3212a501b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -900,6 +900,15 @@ public: Printf(f->code, "%s\n", tm); } + if (director_method) { + if ((tm = Swig_typemap_lookup("directorfree", n, Swig_cresult_name(), 0))) { + Replaceall(tm, "$input", Swig_cresult_name()); + Replaceall(tm, "$result", "ST(argvi)"); + Printf(f->code, "%s\n", tm); + Delete(tm); + } + } + Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL); /* Add the dXSARGS last */ From 589b7237e90405259a319de576a19bd1ae5c14e6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Dec 2017 18:58:06 +0000 Subject: [PATCH 0812/2031] Tweak Perl's director method's $result variable generation. Use same code as other languages - no real change in output. --- Source/Modules/perl5.cxx | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 3212a501b..be586b4db 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2138,27 +2138,26 @@ public: * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ - if (!is_void) { - if (!ignored_method || pure_virtual) { - if (!SwigType_isclass(returntype)) { - if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { - String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); - Delete(construct_result); - } else { - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); - } + if (!is_void && (!ignored_method || pure_virtual)) { + if (!SwigType_isclass(returntype)) { + if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { + String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); + Delete(construct_result); } else { - String *cres = SwigType_lstr(returntype, "c_result"); - Printf(w->code, "%s;\n", cres); - Delete(cres); + Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); } + } else { + String *cres = SwigType_lstr(returntype, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); } - if (!ignored_method) { - String *pres = NewStringf("SV *%s", Swig_cresult_name()); - Wrapper_add_local(w, Swig_cresult_name(), pres); - Delete(pres); - } + } + + if (!is_void && !ignored_method) { + String *pres = NewStringf("SV *%s", Swig_cresult_name()); + Wrapper_add_local(w, Swig_cresult_name(), pres); + Delete(pres); } if (ignored_method) { From a4884e45e1aa10623d03d38eaae167ca6b6eb665 Mon Sep 17 00:00:00 2001 From: Cyrille Faucheux Date: Tue, 5 Dec 2017 21:52:47 +0100 Subject: [PATCH 0813/2031] Do not abort when unlinking non-data ruby objects Fixes issue #1168. Remove a call to abort() (introduced by commit 0e725b5d9bd534964ae606852453df46d04037ee) made when SWIG_RubyUnlinkObjects() is called on non T_DATA objects. It can happen when the destruction of T_DATA objects is deferred: the Ruby GC first turn them to T_ZOMBIE, then calls their free method (SWIG_RubyUnlinkObjects()). --- Examples/ruby/free_function/runme.rb | 6 +++++- Lib/ruby/rubytracking.swg | 13 +++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Examples/ruby/free_function/runme.rb b/Examples/ruby/free_function/runme.rb index a517ed454..cf405d4cc 100644 --- a/Examples/ruby/free_function/runme.rb +++ b/Examples/ruby/free_function/runme.rb @@ -39,7 +39,11 @@ GC.start # C++ object ok = false begin - puts tiger2.get_name + # Let's stress the GC a bit, a single pass might not be enough. + 10.times { + GC.start + puts tiger2.get_name + } rescue ObjectPreviouslyDeleted => error ok = true end diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 8f9f01be8..b9fb249d8 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- * rubytracking.swg * - * This file contains support for tracking mappings from + * This file contains support for tracking mappings from * Ruby objects to C++ objects. This functionality is needed * to implement mark functions for Ruby's mark and sweep * garbage collector. @@ -28,7 +28,7 @@ extern "C" { #endif /* Global hash table to store Trackings from C/C++ - structs to Ruby Objects. + structs to Ruby Objects. */ static st_table* swig_ruby_trackings = NULL; @@ -42,7 +42,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { /* Create a hash table to store Trackings from C++ objects to Ruby objects. */ - /* Try to see if some other .so has already created a + /* Try to see if some other .so has already created a tracking hash table, which we keep hidden in an instance var in the SWIG module. This is done to allow multiple DSOs to share the same @@ -101,13 +101,14 @@ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) { /* This is a helper method that unlinks a Ruby object from its underlying C++ object. This is needed if the lifetime of the - Ruby object is longer than the C++ object */ + Ruby object is longer than the C++ object. */ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { VALUE object = SWIG_RubyInstanceFor(ptr); if (object != Qnil) { - if (TYPE(object) != T_DATA) - abort(); + // object might have the T_ZOMBIE type, but that's just + // because the GC has flagged it as such for a deferred + // destruction. Until then, it's still a T_DATA object. DATA_PTR(object) = 0; } } From 6b2bcfed0b1c8b0ed87d92ce492651c2325e067b Mon Sep 17 00:00:00 2001 From: David Avedissian Date: Wed, 27 Dec 2017 16:31:16 +0000 Subject: [PATCH 0814/2031] Added test case for a forward declaration in a typedef with the same name --- Examples/test-suite/common.mk | 2 ++ .../typedef_classforward_same_name_runme.java | 22 +++++++++++++++++++ .../typedef_classforward_same_name.i | 9 ++++++++ 3 files changed, 33 insertions(+) create mode 100644 Examples/test-suite/java/typedef_classforward_same_name_runme.java create mode 100644 Examples/test-suite/typedef_classforward_same_name.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index db9b13433..7a2136639 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -490,6 +490,7 @@ CPP_TEST_CASES += \ throw_exception \ typedef_array_member \ typedef_class \ + typedef_classforward_same_name \ typedef_funcptr \ typedef_inherit \ typedef_mptr \ @@ -676,6 +677,7 @@ C_TEST_CASES += \ string_simple \ struct_rename \ struct_initialization \ + typedef_classforward_same_name \ typedef_struct \ typemap_subst \ union_parameter \ diff --git a/Examples/test-suite/java/typedef_classforward_same_name_runme.java b/Examples/test-suite/java/typedef_classforward_same_name_runme.java new file mode 100644 index 000000000..23a06b913 --- /dev/null +++ b/Examples/test-suite/java/typedef_classforward_same_name_runme.java @@ -0,0 +1,22 @@ + +import typedef_classforward_same_name.*; + +public class typedef_classforward_same_name_runme { + + static { + try { + System.loadLibrary("typedef_classforward_same_name"); + } 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[]) { + Foo foo = new Foo(); + foo.setX(5); + if (typedef_classforward_same_name.extract(foo) == 5) { + // All good! + } + } +} \ No newline at end of file diff --git a/Examples/test-suite/typedef_classforward_same_name.i b/Examples/test-suite/typedef_classforward_same_name.i new file mode 100644 index 000000000..15e29c693 --- /dev/null +++ b/Examples/test-suite/typedef_classforward_same_name.i @@ -0,0 +1,9 @@ +%module typedef_classforward_same_name + +%inline %{ +typedef struct Foo Foo; +struct Foo { + int x; +}; +int extract(Foo* foo) { return foo->x; } +%} \ No newline at end of file From 3617e22fda7b276d727c24452250e64871d4117c Mon Sep 17 00:00:00 2001 From: David Avedissian Date: Sun, 31 Dec 2017 00:23:51 +0000 Subject: [PATCH 0815/2031] Fixed 'typedef class Foo Foo;' edge case by iterating through linked list. Suggested fix by wsfulton --- CHANGES.current | 5 +++++ Source/Modules/lang.cxx | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 1c361fbec..3b5bb3f85 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-12-30: davedissian + Fixed a symbol lookup issue when encountering a typedef of a symbol from the tag + namespace to the global namespace when the names are identical, such as 'typedef + struct Foo Foo;'. + 2017-12-13: wsfulton [Perl] add missing support for directorfree typemaps. diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 1e4a6bdb6..3464d2327 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3296,6 +3296,14 @@ Node *Language::classLookup(const SwigType *s) const { break; if (Strcmp(nodeType(n), "class") == 0) break; + Node *sibling = n; + while (sibling) { + sibling = Getattr(sibling, "csym:nextSibling"); + if (sibling && Strcmp(nodeType(sibling), "class") == 0) + break; + } + if (sibling) + break; n = parentNode(n); if (!n) break; From d1e5f1e0c87fce759b9106ebca525036149668b0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Dec 2017 17:07:15 +0000 Subject: [PATCH 0816/2031] Switch to using pycodestyle instead of pep8 --- Tools/travis-linux-install.sh | 2 +- configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 5704c4c28..110bd8b70 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -89,7 +89,7 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install php$VER-cli php$VER-dev ;; "python") - pip install --user pep8 + pip install --user pycodestyle if [[ "$PY3" ]]; then travis_retry sudo apt-get install -qq python3-dev fi diff --git a/configure.ac b/configure.ac index 85b24e701..cd5992d02 100644 --- a/configure.ac +++ b/configure.ac @@ -895,9 +895,9 @@ else fi if test -n "$PYINCLUDE" || test -n "$PY3INCLUDE" ; then - AC_CHECK_PROGS(PEP8, pep8) + AC_CHECK_PROGS(PEP8, pycodestyle) if test -n "$PEP8"; then - AC_MSG_CHECKING(pep8 version) + AC_MSG_CHECKING(pycodestyle version) pep8_version=`$PEP8 --version 2>/dev/null` AC_MSG_RESULT($pep8_version) fi From 0b0aed6842db720d72f197f7fccd4fb96e55f550 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Dec 2017 21:19:38 +0000 Subject: [PATCH 0817/2031] Fix pycodestyle 'E722 do not use bare except' --- Examples/python/variables/runme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/python/variables/runme.py b/Examples/python/variables/runme.py index 3388a0eba..fba485aca 100644 --- a/Examples/python/variables/runme.py +++ b/Examples/python/variables/runme.py @@ -52,14 +52,14 @@ print " Tring to set 'path'" try: example.cvar.path = "Whoa!" print "Hey, what's going on?!?! This shouldn't work" -except: +except Exception: print "Good." print " Trying to set 'status'" try: example.cvar.status = 0 print "Hey, what's going on?!?! This shouldn't work" -except: +except Exception: print "Good." From aff36823df43b31a0ef35cc5e1c0ec0eccb244f1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Dec 2017 21:37:05 +0000 Subject: [PATCH 0818/2031] Complete switch from pep8 to pycodestyle for Python testing --- CHANGES.current | 4 ++++ Examples/Makefile.in | 8 ++++---- Examples/test-suite/python/Makefile.in | 10 +++++----- configure.ac | 8 ++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1c361fbec..ac04b3b29 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2017-12-30: wsfulton + [Python] Replace pep8 with pycodestyle for checking the Python code style when + running Python tests. + 2017-12-13: wsfulton [Perl] add missing support for directorfree typemaps. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index e020a659a..81697c8b2 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -334,8 +334,8 @@ else SWIGOPTPY3 = -py3 endif -PEP8 = @PEP8@ -PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391 +PYCODESTYLE = @PYCODESTYLE@ +PYCODESTYLE_FLAGS = --ignore=E402,E501,E30,W291,W391 # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -389,8 +389,8 @@ endif PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` python_run: $(PYSCRIPT) -ifneq (,$(PEP8)) - $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(PYSCRIPT) +ifneq (,$(PYCODESTYLE)) + $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(PYSCRIPT) endif env PYTHONPATH=$$PWD $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 869426569..12844e311 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -10,8 +10,8 @@ endif LANGUAGE = python PYTHON = $(PYBIN) -PEP8 = @PEP8@ -PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391 +PYCODESTYLE = @PYCODESTYLE@ +PYCODESTYLE_FLAGS = --ignore=E30,E402,E501,E731,W291,W391 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py @@ -141,12 +141,12 @@ py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) -ifneq (,$(PEP8)) -check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py +ifneq (,$(PYCODESTYLE)) +check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py check_pep8_multi_cpp = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ - $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \ + $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $$f.py; \ done endif diff --git a/configure.ac b/configure.ac index cd5992d02..cfc338126 100644 --- a/configure.ac +++ b/configure.ac @@ -895,11 +895,11 @@ else fi if test -n "$PYINCLUDE" || test -n "$PY3INCLUDE" ; then - AC_CHECK_PROGS(PEP8, pycodestyle) - if test -n "$PEP8"; then + AC_CHECK_PROGS(PYCODESTYLE, pycodestyle) + if test -n "$PYCODESTYLE"; then AC_MSG_CHECKING(pycodestyle version) - pep8_version=`$PEP8 --version 2>/dev/null` - AC_MSG_RESULT($pep8_version) + pycodestyle_version=`$PYCODESTYLE --version 2>/dev/null` + AC_MSG_RESULT($pycodestyle_version) fi fi From 3c30dec661a9584c2b56eaf381533ac0816ff65a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Dec 2017 21:37:56 +0000 Subject: [PATCH 0819/2031] Remove php5 generated files inadvertently checked in --- Examples/test-suite/php5/newobject3.php | 93 ----------------------- Examples/test-suite/php5/php_newobject3.h | 36 --------- 2 files changed, 129 deletions(-) delete mode 100644 Examples/test-suite/php5/newobject3.php delete mode 100644 Examples/test-suite/php5/php_newobject3.h diff --git a/Examples/test-suite/php5/newobject3.php b/Examples/test-suite/php5/newobject3.php deleted file mode 100644 index 21e1769d7..000000000 --- a/Examples/test-suite/php5/newobject3.php +++ /dev/null @@ -1,93 +0,0 @@ -_cPtr,$value); - $this->_pData[$var] = $value; - } - - function __get($var) { - if ($var === 'thisown') return swig_newobject3_get_newobject($this->_cPtr); - return $this->_pData[$var]; - } - - function __isset($var) { - if ($var === 'thisown') return true; - return array_key_exists($var, $this->_pData); - } - - function __construct($res=null) { - if (is_resource($res) && get_resource_type($res) === '_p_Product') { - $this->_cPtr=$res; - return; - } - $this->_cPtr=new_Product(); - } -} - -class factory { - public $_cPtr=null; - protected $_pData=array(); - - function __set($var,$value) { - if ($var === 'thisown') return swig_newobject3_alter_newobject($this->_cPtr,$value); - $this->_pData[$var] = $value; - } - - function __get($var) { - if ($var === 'thisown') return swig_newobject3_get_newobject($this->_cPtr); - return $this->_pData[$var]; - } - - function __isset($var) { - if ($var === 'thisown') return true; - return array_key_exists($var, $this->_pData); - } - - function create($id_or_name,$type=0) { - $r=factory_create($this->_cPtr,$id_or_name,$type); - if (!is_resource($r)) return $r; - return new Product($r); - } - - function __construct($res=null) { - if (is_resource($res) && get_resource_type($res) === '_p_factory') { - $this->_cPtr=$res; - return; - } - $this->_cPtr=new_factory(); - } -} - - -?> diff --git a/Examples/test-suite/php5/php_newobject3.h b/Examples/test-suite/php5/php_newobject3.h deleted file mode 100644 index 6ff30705a..000000000 --- a/Examples/test-suite/php5/php_newobject3.h +++ /dev/null @@ -1,36 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 4.0.0 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -#ifndef PHP_NEWOBJECT3_H -#define PHP_NEWOBJECT3_H - -extern zend_module_entry newobject3_module_entry; -#define phpext_newobject3_ptr &newobject3_module_entry - -#ifdef PHP_WIN32 -# define PHP_NEWOBJECT3_API __declspec(dllexport) -#else -# define PHP_NEWOBJECT3_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -PHP_MINIT_FUNCTION(newobject3); -PHP_MSHUTDOWN_FUNCTION(newobject3); -PHP_RINIT_FUNCTION(newobject3); -PHP_RSHUTDOWN_FUNCTION(newobject3); -PHP_MINFO_FUNCTION(newobject3); - -ZEND_NAMED_FUNCTION(_wrap_new_Product); -ZEND_NAMED_FUNCTION(_wrap_factory_create); -ZEND_NAMED_FUNCTION(_wrap_new_factory); -#endif /* PHP_NEWOBJECT3_H */ From 0beec3cf7306d7b9d6fe771012bb9421877a9a82 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Dec 2017 20:56:25 +0000 Subject: [PATCH 0820/2031] Travis testing: use new deadsnakes repository for testing various python versions See https://github.com/deadsnakes/issues/issues/53 --- Tools/travis-linux-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 110bd8b70..e8a5e4c9c 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -95,7 +95,7 @@ case "$SWIGLANG" in fi WITHLANG=$SWIGLANG$PY3 if [[ "$VER" ]]; then - travis_retry sudo add-apt-repository -y ppa:fkrull/deadsnakes + travis_retry sudo add-apt-repository -y ppa:deadsnakes/ppa travis_retry sudo apt-get -qq update travis_retry sudo apt-get -qq install python${VER}-dev WITHLANG=$SWIGLANG$PY3=$SWIGLANG$VER From ce6960de9261f08bb653400555254f7dc01ca663 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 31 Dec 2017 16:25:55 +0000 Subject: [PATCH 0821/2031] Add more runtime typedef_classforward_same_name runtime testing --- .../java/typedef_classforward_same_name_runme.java | 12 ++++++++---- .../python/typedef_classforward_same_name_runme.py | 11 +++++++++++ Examples/test-suite/typedef_classforward_same_name.i | 10 ++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/python/typedef_classforward_same_name_runme.py diff --git a/Examples/test-suite/java/typedef_classforward_same_name_runme.java b/Examples/test-suite/java/typedef_classforward_same_name_runme.java index 23a06b913..86e713d14 100644 --- a/Examples/test-suite/java/typedef_classforward_same_name_runme.java +++ b/Examples/test-suite/java/typedef_classforward_same_name_runme.java @@ -15,8 +15,12 @@ public class typedef_classforward_same_name_runme { public static void main(String argv[]) { Foo foo = new Foo(); foo.setX(5); - if (typedef_classforward_same_name.extract(foo) == 5) { - // All good! - } + if (typedef_classforward_same_name.extractFoo(foo) != 5) + throw new RuntimeException("unexpected value"); + + Boo boo = new Boo(); + boo.setX(5); + if (typedef_classforward_same_name.extractBoo(boo) != 5) + throw new RuntimeException("unexpected value"); } -} \ No newline at end of file +} diff --git a/Examples/test-suite/python/typedef_classforward_same_name_runme.py b/Examples/test-suite/python/typedef_classforward_same_name_runme.py new file mode 100644 index 000000000..61f45fbee --- /dev/null +++ b/Examples/test-suite/python/typedef_classforward_same_name_runme.py @@ -0,0 +1,11 @@ +from typedef_classforward_same_name import * + +foo = Foo() +foo.x = 5 +if extractFoo(foo) != 5: + raise RuntimeError("unexpected value") + +boo = Boo() +boo.x = 5 +if extractBoo(boo) != 5: + raise RuntimeError("unexpected value") diff --git a/Examples/test-suite/typedef_classforward_same_name.i b/Examples/test-suite/typedef_classforward_same_name.i index 15e29c693..ad2e456f8 100644 --- a/Examples/test-suite/typedef_classforward_same_name.i +++ b/Examples/test-suite/typedef_classforward_same_name.i @@ -5,5 +5,11 @@ typedef struct Foo Foo; struct Foo { int x; }; -int extract(Foo* foo) { return foo->x; } -%} \ No newline at end of file +int extractFoo(Foo* foo) { return foo->x; } + +struct Boo { + int x; +}; +typedef struct Boo Boo; +int extractBoo(Boo* boo) { return boo->x; } +%} From cd9b7c3c34def07db975a2b706e425afc6500adb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Jan 2018 07:00:26 +0000 Subject: [PATCH 0822/2031] std_basic_string.i fixes - Remove python code from octave's std_basic_string.i - Correctly return an error to fix error handling when using std::basic_string in overloaded methods - issue #1171. --- Examples/test-suite/li_std_string_extra.i | 8 ++ .../python/li_std_string_extra_runme.py | 18 +++++ Lib/octave/std_basic_string.i | 47 +++--------- Lib/python/std_basic_string.i | 74 ++++++++----------- Lib/ruby/std_basic_string.i | 60 ++++++--------- Lib/scilab/std_basic_string.i | 3 +- 6 files changed, 92 insertions(+), 118 deletions(-) diff --git a/Examples/test-suite/li_std_string_extra.i b/Examples/test-suite/li_std_string_extra.i index 6bef12ff4..1fc2225ca 100644 --- a/Examples/test-suite/li_std_string_extra.i +++ b/Examples/test-suite/li_std_string_extra.i @@ -49,6 +49,14 @@ std::basic_string,std::allocator > test_value_ return x; } +std::basic_string,std::allocator > test_value_basic_overload(std::basic_string,std::allocator > x) { + return x; +} + +std::basic_string,std::allocator > test_value_basic_overload(int) { + return "int"; +} + #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } #else diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index b65f0774a..9835eaa81 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -87,6 +87,24 @@ if li_std_string_extra.test_value_basic2(x) != x: if li_std_string_extra.test_value_basic3(x) != x: raise RuntimeError, "bad string mapping" +if li_std_string_extra.test_value_basic_overload(x) != x: + raise RuntimeError, "bad overload string" + +if li_std_string_extra.test_value_basic_overload(123) != "int": + raise RuntimeError, "bad overload int" + +try: + li_std_string_extra.test_value_basic_overload([x]) + raise RuntimeError, "should throw NotImplementedError" +except NotImplementedError: + pass + +try: + li_std_string_extra.test_value_basic_overload([123]) + raise RuntimeError, "should throw NotImplementedError" +except NotImplementedError: + pass + # Global variables s = "initial string" if li_std_string_extra.cvar.GlobalString2 != "global string 2": diff --git a/Lib/octave/std_basic_string.i b/Lib/octave/std_basic_string.i index 19712e8d0..01a2c34a2 100644 --- a/Lib/octave/std_basic_string.i +++ b/Lib/octave/std_basic_string.i @@ -10,24 +10,20 @@ %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)(octave_value obj, std::string **val) { if (obj.is_string()) { if (val) *val = new std::string(obj.string_value()); return SWIG_NEWOBJ; } - if (val) - error("a string is expected"); - return 0; + return SWIG_ERROR; } } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE octave_value - SWIG_From(std::basic_string)(const std::string& s) - { + SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } @@ -45,41 +41,20 @@ SWIGINTERNINLINE octave_value %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int - SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) - { - static swig_type_info* string_info = - SWIG_TypeQuery("std::basic_string *"); - std::wstring *vptr; - if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - PyErr_Clear(); - wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { - if (buf) { - if (val) *val = new std::wstring(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 wstring is expected"); - SWIG_PYTHON_THREAD_END_BLOCK; - } - return 0; - } +SWIG_AsPtr(std::basic_string)(octave_value obj, std::wstring **val) { + if (obj.is_string()) { + if (val) + *val = new std::wstring(obj.string_value()); + return SWIG_NEWOBJ; } + return SWIG_ERROR; +} } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* - SWIG_From(std::basic_string)(const std::wstring& s) - { + SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } diff --git a/Lib/python/std_basic_string.i b/Lib/python/std_basic_string.i index 7d3366db5..e3f524dbd 100644 --- a/Lib/python/std_basic_string.i +++ b/Lib/python/std_basic_string.i @@ -9,41 +9,34 @@ %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int -SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) -{ - 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) { +SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) { + static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); + std::string *vptr; + if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { 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 (SWIG_IsOK(SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc))) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; + } else { + if (val) *val = 0; + return SWIG_OLDOBJ; } - } 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; + return SWIG_ERROR; } -} +} } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE PyObject* - SWIG_From(std::basic_string)(const std::string& s) - { + SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } @@ -59,41 +52,34 @@ SWIGINTERNINLINE PyObject* %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int - SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) - { - static swig_type_info* string_info = - SWIG_TypeQuery("std::basic_string *"); - std::wstring *vptr; - if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - PyErr_Clear(); - wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { - if (buf) { - if (val) *val = new std::wstring(buf, size - 1); - if (alloc == SWIG_NEWOBJ) %delete_array(buf); - return SWIG_NEWOBJ; - } +SWIG_AsPtr(std::basic_string)(PyObject* obj, std::wstring **val) { + static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); + std::wstring *vptr; + if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_IsOK(SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc))) { + if (buf) { + if (val) *val = new std::wstring(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 wstring is expected"); - SWIG_PYTHON_THREAD_END_BLOCK; + if (val) *val = 0; + return SWIG_OLDOBJ; } - return 0; } + return SWIG_ERROR; } } +} %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE PyObject* - SWIG_From(std::basic_string)(const std::wstring& s) - { + SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } diff --git a/Lib/ruby/std_basic_string.i b/Lib/ruby/std_basic_string.i index 4435b220d..ba13ba764 100644 --- a/Lib/ruby/std_basic_string.i +++ b/Lib/ruby/std_basic_string.i @@ -13,36 +13,30 @@ %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int -SWIG_AsPtr(std::basic_string)(VALUE obj, std::string **val) -{ - 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) { +SWIG_AsPtr(std::basic_string)(VALUE obj, std::string **val) { + static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); + std::string *vptr; + if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { if (val) *val = vptr; return SWIG_OLDOBJ; } else { char* buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (SWIG_IsOK(SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc))) { if (buf) { if (val) *val = new std::string(buf, size - 1); if (alloc == SWIG_NEWOBJ) %delete_array(buf); return SWIG_NEWOBJ; } } - if (val) { - rb_raise( rb_eTypeError, "a string is expected"); - } - return 0; + return SWIG_ERROR; } -} +} } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { SWIGINTERNINLINE VALUE - SWIG_From(std::basic_string)(const std::string& s) - { + SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); } } @@ -65,36 +59,30 @@ SWIGINTERNINLINE VALUE %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsWCharPtrAndSize") { SWIGINTERN int - SWIG_AsPtr(std::basic_string)(VALUE obj, std::wstring **val) - { - static swig_type_info* string_info = - SWIG_TypeQuery("std::basic_string *"); - std::wstring *vptr; - if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { - if (val) *val = vptr; - return SWIG_OLDOBJ; - } else { - wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; - if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { - if (buf) { - if (val) *val = new std::wstring(buf, size - 1); - if (alloc == SWIG_NEWOBJ) %delete_array(buf); - return SWIG_NEWOBJ; - } +SWIG_AsPtr(std::basic_string)(VALUE obj, std::wstring **val) { + static swig_type_info* string_info = SWIG_TypeQuery("std::basic_string *"); + std::wstring *vptr; + if (SWIG_IsOK(SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0))) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + wchar_t *buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_IsOK(SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc))) { + if (buf) { + if (val) *val = new std::wstring(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; } - if (val) { - rb_raise( rb_eTypeError, "a string is expected"); - } - return 0; } + return SWIG_ERROR; } } +} %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromWCharPtrAndSize") { SWIGINTERNINLINE VALUE - SWIG_From(std::basic_string)(const std::wstring& s) - { + SWIG_From(std::basic_string)(const std::wstring& s) { return SWIG_FromWCharPtrAndSize(s.data(), s.size()); } } diff --git a/Lib/scilab/std_basic_string.i b/Lib/scilab/std_basic_string.i index 43b660db6..b57353816 100644 --- a/Lib/scilab/std_basic_string.i +++ b/Lib/scilab/std_basic_string.i @@ -21,8 +21,7 @@ SWIG_AsPtr_dec(std::basic_string)(int _iVar, std::basic_string **_ps delete[] buf; } return SWIG_NEWOBJ; - } - else { + } else { if (_pstValue) { *_pstValue = NULL; } From ef378407d064142672ccb55cbff47723a14f162c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jan 2018 07:58:25 +0000 Subject: [PATCH 0823/2031] Fix parsing of default argument expressions containing ->. --- CHANGES.current | 4 ++++ Examples/test-suite/common.mk | 1 + Source/CParse/parser.y | 30 ++++++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ac04b3b29..5e7fbbf6e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-05: wsfulton + Fix default arguments using expressions containing -> syntax error. Problem reported on + swig-user mailing list. + 2017-12-30: wsfulton [Python] Replace pep8 with pycodestyle for checking the Python code style when running Python tests. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index db9b13433..d798a6853 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -164,6 +164,7 @@ CPP_TEST_CASES += \ cpp_typedef \ curiously_recurring_template_pattern \ default_args \ + default_arg_expressions \ default_arg_values \ default_constructor \ defvalue_constructor \ diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 857cecd0e..0c8d95ecd 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1604,7 +1604,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) %type type rawtype type_right anon_bitfield_type decltype ; %type base_list inherit raw_inherit; %type definetype def_args etype default_delete deleted_definition explicit_default; -%type expr exprnum exprcompound valexpr; +%type expr exprnum exprcompound valexpr exprmem; %type ename ; %type less_valparms_greater; %type type_qualifier; @@ -6266,7 +6266,33 @@ expr : valexpr { $$ = $1; } } ; -valexpr : exprnum { $$ = $1; } +/* simple member access expressions */ +exprmem : ID ARROW ID { + $$.val = NewStringf("%s->%s", $1, $3); + $$.type = 0; + } + | exprmem ARROW ID { + $$ = $1; + Printf($$.val, "->%s", $3); + } +/* This generates a shift-reduce + | ID PERIOD ID { + $$.val = NewStringf("%s.%s", $1, $3); + $$.type = 0; + } +*/ + | exprmem PERIOD ID { + $$ = $1; + Printf($$.val, ".%s", $3); + } + ; + +valexpr : exprnum { + $$ = $1; + } + | exprmem { + $$ = $1; + } | string { $$.val = $1; $$.type = T_STRING; From aef25cff0cd3fc1bbae1a8d26825fe5f80fce770 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jan 2018 18:31:48 +0000 Subject: [PATCH 0824/2031] Add missing default_arg_expressions.i testcase --- Examples/test-suite/default_arg_expressions.i | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Examples/test-suite/default_arg_expressions.i diff --git a/Examples/test-suite/default_arg_expressions.i b/Examples/test-suite/default_arg_expressions.i new file mode 100644 index 000000000..ca2a27e33 --- /dev/null +++ b/Examples/test-suite/default_arg_expressions.i @@ -0,0 +1,30 @@ +%module default_arg_expressions + +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ptr; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) UsdGeomTokensPtr; +%immutable UsdGeomTokens; + +%inline %{ +struct Numbers { + int val; + int *ptr; + Numbers() : val(), ptr(&val) {} +}; +struct TfToken { + Numbers val; + Numbers *ptr; + TfToken() : val(), ptr(&val) {} +}; +struct Tokens { + const TfToken face; + const TfToken *pface; + Tokens() : face(), pface(&face) {} +}; +static Tokens UsdGeomTokens; +static Tokens *UsdGeomTokensPtr = &UsdGeomTokens; +void CreateMaterialBindSubset1(const Tokens &elementType = UsdGeomTokens) {} +void CreateMaterialBindSubset2(int num = UsdGeomTokensPtr->pface->val.val) {} +void CreateMaterialBindSubset3(int num = UsdGeomTokensPtr->pface->ptr->val) {} +void CreateMaterialBindSubset4(int num = UsdGeomTokensPtr->face.val.val) {} +//void CreateMaterialBindSubset5(int num = UsdGeomTokens.face.val.val) {} +%} From 830422a87b29bc47ad5167d52d56f281736ddaf6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Jan 2018 23:44:43 +0000 Subject: [PATCH 0825/2031] Fix Makefile and skip testing python-2.4 for import_packages test --- Examples/python/import_packages/Makefile | 10 +++++----- Examples/python/import_packages/from_init1/runme.py | 4 ++++ Examples/python/import_packages/from_init2/runme.py | 4 ++++ Examples/python/import_packages/from_init3/runme.py | 4 ++++ .../python/import_packages/relativeimport1/runme.py | 4 ++++ .../python/import_packages/relativeimport2/runme.py | 4 ++++ .../python/import_packages/relativeimport3/runme.py | 4 ++++ Examples/python/import_packages/split_modules/Makefile | 8 ++++---- 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile index f428d6f5c..a70c97e8b 100644 --- a/Examples/python/import_packages/Makefile +++ b/Examples/python/import_packages/Makefile @@ -18,22 +18,22 @@ import_packages_subdirs = \ check: build if test "x$(SRCDIR)" != x; then \ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \ - mkdir -p `dirname $$file`; \ + mkdir -p `dirname $$file` \ cp "${SRCDIR}$$file" "$$file" || exit 1; \ done; \ fi; \ for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) check); \ + (cd $$s && $(MAKE) check) || exit 1; \ done build: for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \ done static: for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \ done clean: @@ -44,5 +44,5 @@ clean: done; \ fi; \ for s in $(import_packages_subdirs); do \ - (cd $$s && $(MAKE) clean); \ + (cd $$s && $(MAKE) clean) || exit 1; \ done diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py index dda397487..424e9ca44 100644 --- a/Examples/python/import_packages/from_init1/runme.py +++ b/Examples/python/import_packages/from_init1/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py index dda397487..424e9ca44 100644 --- a/Examples/python/import_packages/from_init2/runme.py +++ b/Examples/python/import_packages/from_init2/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py index dda397487..424e9ca44 100644 --- a/Examples/python/import_packages/from_init3/runme.py +++ b/Examples/python/import_packages/from_init3/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py index 997476b1d..5b1b5f45a 100644 --- a/Examples/python/import_packages/relativeimport1/runme.py +++ b/Examples/python/import_packages/relativeimport1/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) with -relativeimport" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py index 9789afc18..9d1a05ec8 100644 --- a/Examples/python/import_packages/relativeimport2/runme.py +++ b/Examples/python/import_packages/relativeimport2/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py index 997476b1d..5b1b5f45a 100644 --- a/Examples/python/import_packages/relativeimport3/runme.py +++ b/Examples/python/import_packages/relativeimport3/runme.py @@ -5,6 +5,10 @@ import os.path testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) with -relativeimport" +if sys.version_info < (2, 5): + print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + sys.exit(0) + if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" diff --git a/Examples/python/import_packages/split_modules/Makefile b/Examples/python/import_packages/split_modules/Makefile index 65d635bb7..9eaaabd32 100644 --- a/Examples/python/import_packages/split_modules/Makefile +++ b/Examples/python/import_packages/split_modules/Makefile @@ -6,21 +6,21 @@ subdirs = vanilla vanilla_split check: build for s in $(subdirs); do \ - (cd $$s && $(MAKE) check); \ + (cd $$s && $(MAKE) check) || exit 1; \ done build: for s in $(subdirs); do \ - (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build) || exit 1; \ done static: for s in $(subdirs); do \ - (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static); \ + (cd $$s && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static) || exit 1; \ done clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean for s in $(subdirs); do \ - (cd $$s && $(MAKE) clean); \ + (cd $$s && $(MAKE) clean) || exit 1; \ done From b0c910ac96c56a11a140ec24fbf12c976d43ebff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Jan 2018 23:12:52 +0000 Subject: [PATCH 0826/2031] Fix out of source import_packages Makefile --- Examples/python/import_packages/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile index a70c97e8b..e6c07fe75 100644 --- a/Examples/python/import_packages/Makefile +++ b/Examples/python/import_packages/Makefile @@ -18,7 +18,7 @@ import_packages_subdirs = \ check: build if test "x$(SRCDIR)" != x; then \ for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \ - mkdir -p `dirname $$file` \ + mkdir -p `dirname $$file`; \ cp "${SRCDIR}$$file" "$$file" || exit 1; \ done; \ fi; \ From 3066f8950c0dacdadec2c0119d0d7042a8f7e221 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Jan 2018 23:19:04 +0000 Subject: [PATCH 0827/2031] Minor tweaks in import_packages Makefile --- Examples/python/import_packages/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile index e6c07fe75..2857866d4 100644 --- a/Examples/python/import_packages/Makefile +++ b/Examples/python/import_packages/Makefile @@ -12,7 +12,7 @@ import_packages_subdirs = \ relativeimport2 \ relativeimport3 \ split_modules \ - namespace_pkg + namespace_pkg \ check: build @@ -21,7 +21,7 @@ check: build mkdir -p `dirname $$file`; \ cp "${SRCDIR}$$file" "$$file" || exit 1; \ done; \ - fi; \ + fi for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) check) || exit 1; \ done @@ -42,7 +42,7 @@ clean: for file in `cd $(SRCDIR) && find . -type f -name "*.py"`; do \ rm -f "$$file" || exit 1; \ done; \ - fi; \ + fi for s in $(import_packages_subdirs); do \ (cd $$s && $(MAKE) clean) || exit 1; \ done From 0d588d19ade9f1b8445aef8a1179c01a68f54715 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 7 Jan 2018 00:57:23 +0000 Subject: [PATCH 0828/2031] Fix out of source clean target in import_packages Makefile --- .../import_packages/split_modules/vanilla_split/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/python/import_packages/split_modules/vanilla_split/Makefile b/Examples/python/import_packages/split_modules/vanilla_split/Makefile index c322b5aec..5d1c3521c 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/Makefile +++ b/Examples/python/import_packages/split_modules/vanilla_split/Makefile @@ -19,4 +19,6 @@ static: clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean - cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean + if test -d pkg1; then \ + cd pkg1 && $(MAKE) -f $(TOP)/../Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean; \ + fi From 49af1907b82be03ee4848b415564bc1f1e26e6bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jan 2018 07:34:32 +0000 Subject: [PATCH 0829/2031] Add missing Java throws clause for interfaces when using the %interface family of macros. Fixes #1156. --- CHANGES.current | 4 ++++ .../test-suite/java/java_throws_runme.java | 22 +++++++++++++++++++ Examples/test-suite/java_throws.i | 17 ++++++++++++++ Source/Modules/java.cxx | 7 ++++-- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f39960bc3..0aad216de 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-12: wsfulton + [Java] Fix issue #1156. Add missing throws clause for interfaces when using the + %interface family of macros. + 2018-01-05: wsfulton Fix default arguments using expressions containing -> syntax error. Problem reported on swig-user mailing list. diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 0365b69ed..16eab7cad 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -93,6 +93,28 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 6 failed"); + // Interface function + pass = false; + try { + InterfaceTestImpl iti = new InterfaceTestImpl(); + iti.imethod(true); + } + catch (MyException e) { pass = true; } + + if (!pass) + throw new RuntimeException("Test interface 1 failed"); + + pass = false; + try { + InterfaceTestImpl iti = new InterfaceTestImpl(); + iti.imethod(false); + pass = true; + } + catch (MyException e) { pass = false; } + + if (!pass) + throw new RuntimeException("Test interface 2 failed"); + // Global function pass = false; try { diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index c628a45e6..875bce0ff 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -135,6 +135,23 @@ JAVAEXCEPTION(FeatureTest::staticMethod) }; %} +%include +%interface_impl(InterfaceTest); +JAVAEXCEPTION(imethod) + +%inline %{ + struct InterfaceTest { + virtual void imethod(bool raise) = 0; + }; + + struct InterfaceTestImpl : InterfaceTest { + void imethod(bool raise) { + if (raise) + throw MyException("raise message"); + } + }; +%} + // Mixing except feature and typemaps when both generate a class for the throws clause %typemap(in, throws="ClassNotFoundException") int both { $1 = (int)$input; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index f759aaf5d..d2b25426a 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2544,8 +2544,6 @@ public: Printf(imcall, ")"); Printf(function_code, ")"); - if (is_interface) - Printf(interface_class_code, ");\n"); // Transform return type used in JNI function (in intermediary class) to type used in Java wrapper function (in proxy class) if ((tm = Swig_typemap_lookup("javaout", n, "", 0))) { @@ -2603,6 +2601,11 @@ public: Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0)); } + if (is_interface) { + Printf(interface_class_code, ")"); + generateThrowsClause(n, interface_class_code); + Printf(interface_class_code, ";\n"); + } generateThrowsClause(n, function_code); Printf(function_code, " %s\n\n", tm ? (const String *) tm : empty_string); Printv(proxy_class_code, function_code, NIL); From 368cd3b52c8a17dd829ac42481a1901b449f9a60 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jan 2018 18:26:47 +0000 Subject: [PATCH 0830/2031] Add ToArray test for C# std::vector wrapper --- CHANGES.current | 3 +++ Examples/test-suite/csharp/li_std_vector_runme.cs | 11 +++++++++++ Lib/csharp/std_vector.i | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 0aad216de..07ab418cb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-12: Liryna + [C#] Patch #1128. Add ToArray function to std::vector wrappers. + 2018-01-12: wsfulton [Java] Fix issue #1156. Add missing throws clause for interfaces when using the %interface family of macros. diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs index 453faa6c1..0c6211ca5 100644 --- a/Examples/test-suite/csharp/li_std_vector_runme.cs +++ b/Examples/test-suite/csharp/li_std_vector_runme.cs @@ -177,6 +177,17 @@ public class li_std_vector_runme { if (doubleArray[i] != dvCopy[i]) throw new Exception("Copy constructor failed, index:" + i); } + if (dvCopy.Count != doubleArray.Length) + throw new Exception("Copy constructor lengths mismatch"); + + // ToArray test + double[] dvArray = dv.ToArray(); + for (int i=0; i Date: Tue, 28 Nov 2017 21:43:24 -0600 Subject: [PATCH 0831/2031] Add option file support Arguments may be passed using an option file prefixed with the '@' character. Processing of option files is the same as for the same feature in gcc. --- Source/Modules/main.cxx | 4 ++ Source/Modules/swigmain.cxx | 82 ++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 9822b6af7..c7ae02625 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -159,6 +159,10 @@ is equivalent to: \n\ \n\ $ swig -Wall -python interface.i \n\ \n\ +Arguments may also be passed in a file, separated by whitespace. For example:\n\ +\n\ + $ echo \"-Wall -python interface.i\" > args.txt\n\ + $ swig @args.txt\n\ \n"; // Local variables diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index b49fe909a..f72525b6f 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -119,7 +119,8 @@ static swig_module modules[] = { void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, char ***nargv) { if (!env) { *nargc = oargc; - *nargv = oargv; + *nargv = (char **)malloc(sizeof(char *) * (oargc + 1)); + memcpy(*nargv, oargv, sizeof(char *) * (oargc + 1)); return; } @@ -153,6 +154,84 @@ void SWIG_merge_envopt(const char *env, int oargc, char *oargv[], int *nargc, ch *nargv = argv; } +static void insert_option(int *argc, char ***argv, int index, char const *start, char const *end) { + int new_argc = *argc; + char **new_argv = *argv; + size_t option_len = end - start; + + // Preserve the NULL pointer at argv[argc] + new_argv = (char **)realloc(new_argv, (new_argc + 2) * sizeof(char *)); + memmove(&new_argv[index + 1], &new_argv[index], sizeof(char *) * (new_argc + 1 - index)); + new_argc++; + + new_argv[index] = (char *)malloc(option_len + 1); + memcpy(new_argv[index], start, option_len); + new_argv[index][option_len] = '\0'; + + *argc = new_argc; + *argv = new_argv; +} + +static void merge_options_files(int *argc, char ***argv) { + static const int BUFFER_SIZE = 4096; + char buffer[BUFFER_SIZE]; + int i; + int insert; + char **new_argv = *argv; + int new_argc = *argc; + FILE *f; + + i = 1; + while (i < new_argc) { + if (new_argv[i] && new_argv[i][0] == '@' && (f = fopen(&new_argv[i][1], "r"))) { + char c; + char *b; + char *be = &buffer[BUFFER_SIZE]; + int quote = 0; + bool escape = false; + + new_argc--; + memmove(&new_argv[i], &new_argv[i + 1], sizeof(char *) * (new_argc - i)); + insert = i; + b = buffer; + + while ((c = fgetc(f)) != EOF) { + if (escape) { + if (b != be) { + *b = c; + ++b; + } + escape = false; + } else if (c == '\\') { + escape = true; + } else if (!quote && (c == '\'' || c == '"')) { + quote = c; + } else if (quote && c == quote) { + quote = 0; + } else if (isspace(c) && !quote) { + if (b != buffer) { + insert_option(&new_argc, &new_argv, insert, buffer, b); + insert++; + + b = buffer; + } + } else if (b != be) { + *b = c; + ++b; + } + } + if (b != buffer) + insert_option(&new_argc, &new_argv, insert, buffer, b); + fclose(f); + } else { + ++i; + } + } + + *argv = new_argv; + *argc = new_argc; +} + int main(int margc, char **margv) { int i; Language *dl = 0; @@ -162,6 +241,7 @@ int main(int margc, char **margv) { char **argv; SWIG_merge_envopt(getenv("SWIG_FEATURES"), margc, margv, &argc, &argv); + merge_options_files(&argc, &argv); #ifdef MACSWIG SIOUXSettings.asktosaveonclose = false; From bc89aad59f4090bcd2b6cc1bb5f3acdbd56c5748 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Wed, 29 Nov 2017 20:29:21 -0600 Subject: [PATCH 0832/2031] Add documentation for option files --- Doc/Manual/SWIG.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index f6a62d55d..ffc373f24 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -163,6 +163,32 @@ can be obtained by typing swig -help or swig

          +

          +Arguments may also be passed in a command-line options file (also known as a +response file) which is useful if they exceed the system command line length +limit. To do this, put the arguments in a file, then provide the file name +prefixed with @ like so: +

          + +
          +swig @file
          +
          + +

          +The options read from the file are inserted in place of the file option. If the +file does not exist, or cannot be read, then the option will be treated +literally and not removed. +

          + +

          +Options in the file are separated by whitespace. A whitespace character may be +included in an option by surrounding the entire option in either single or +double quotes. Any character (including a backslash) may be included by +prefixing the character to be included with a backslash. The file may itself +contain additional @file options; any such options will be processed +recursively. +

          +

          5.1.1 Input format

          From af8d176c40b8d01b721fd04092155045478c855d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jan 2018 23:10:02 +0000 Subject: [PATCH 0833/2031] java_throws testcase warning fix --- Examples/test-suite/java_throws.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index 875bce0ff..bb5c6e48f 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -142,6 +142,7 @@ JAVAEXCEPTION(imethod) %inline %{ struct InterfaceTest { virtual void imethod(bool raise) = 0; + virtual ~InterfaceTest() {} }; struct InterfaceTestImpl : InterfaceTest { From ab5559f51ce55f31965cb54b060e8b8b0c65713b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Jan 2018 07:33:28 +0000 Subject: [PATCH 0834/2031] Fix out of bounds memory problems in handling simple macro arguments Fixes handling macro in swigmacros.swg: #define %arg(Arg...) Arg AddressSanitizer error running Python test-suite. --- Source/Preprocessor/cpp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index a8d386cea..df7458201 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -930,19 +930,21 @@ static String *expand_macro(String *name, List *args, String *line_file) { namelen = Len(aname); a = strstr(s, name); while (a) { - char ca = a[namelen + 1]; + char ca = a[namelen]; if (!isidchar((int) ca)) { /* Matched the entire vararg name, not just a prefix */ - t = a - 1; - if (*t == '\002') { - t--; - while (t >= s) { - if (isspace((int) *t)) - t--; - else if (*t == ',') { - *t = ' '; - } else - break; + if (a > s) { + t = a - 1; + if (*t == '\002') { + t--; + while (t >= s) { + if (isspace((int) *t)) + t--; + else if (*t == ',') { + *t = ' '; + } else + break; + } } } } From 9b0e06a8e8cffde10dc2ddc5f6bd41e4eb26b2ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Jan 2018 07:57:30 +0000 Subject: [PATCH 0835/2031] Seg fault fix running uffi tests --- Source/Modules/uffi.cxx | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index d56ed3b1f..10a53a561 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -363,23 +363,24 @@ int UFFI::classHandler(Node *n) { for (c = firstChild(n); c; c = nextSibling(c)) { SwigType *type = Getattr(c, "type"); SwigType *decl = Getattr(c, "decl"); - type = Copy(type); - SwigType_push(type, decl); - String *lisp_type; + if (type) { + type = Copy(type); + SwigType_push(type, decl); + String *lisp_type; - if (Strcmp(nodeType(c), "cdecl")) { - Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name); - Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type")); - SWIG_exit(EXIT_FAILURE); + if (Strcmp(nodeType(c), "cdecl")) { + Printf(stderr, "Structure %s has a slot that we can't deal with.\n", name); + Printf(stderr, "nodeType: %s, name: %s, type: %s\n", nodeType(c), Getattr(c, "name"), Getattr(c, "type")); + SWIG_exit(EXIT_FAILURE); + } + + /* Printf(stdout, "Converting %s in %s\n", type, name); */ + lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name")); + + Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type); + + Delete(lisp_type); } - - - /* Printf(stdout, "Converting %s in %s\n", type, name); */ - lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name")); - - Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type); - - Delete(lisp_type); } // Language::classHandler(n); From 07a30249f416ced2ae627e1a32c15d38cb403087 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 14 Jan 2018 19:36:09 +0000 Subject: [PATCH 0836/2031] Fix seg fault parsing invalid exponents Add error message when exponents are incomplete, for example 5e and 5.e --- CHANGES.current | 3 +++ .../test-suite/errors/cpp_invalid_exponents1.i | 4 ++++ .../errors/cpp_invalid_exponents1.stderr | 2 ++ .../test-suite/errors/cpp_invalid_exponents2.i | 4 ++++ .../errors/cpp_invalid_exponents2.stderr | 2 ++ Examples/test-suite/errors/pp_invalid_exponents.i | 7 +++++++ .../test-suite/errors/pp_invalid_exponents.stderr | 6 ++++++ Source/Swig/scanner.c | 14 ++++++++------ 8 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 Examples/test-suite/errors/cpp_invalid_exponents1.i create mode 100644 Examples/test-suite/errors/cpp_invalid_exponents1.stderr create mode 100644 Examples/test-suite/errors/cpp_invalid_exponents2.i create mode 100644 Examples/test-suite/errors/cpp_invalid_exponents2.stderr create mode 100644 Examples/test-suite/errors/pp_invalid_exponents.i create mode 100644 Examples/test-suite/errors/pp_invalid_exponents.stderr diff --git a/CHANGES.current b/CHANGES.current index 07ab418cb..0618e9725 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-14: wsfulton + Fix issue #1172. Seg fault parsing invalid exponents in the preprocessor. + 2018-01-12: Liryna [C#] Patch #1128. Add ToArray function to std::vector wrappers. diff --git a/Examples/test-suite/errors/cpp_invalid_exponents1.i b/Examples/test-suite/errors/cpp_invalid_exponents1.i new file mode 100644 index 000000000..1ff2c3603 --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_exponents1.i @@ -0,0 +1,4 @@ +%module xxx + +void bad(double nn = 5e); + diff --git a/Examples/test-suite/errors/cpp_invalid_exponents1.stderr b/Examples/test-suite/errors/cpp_invalid_exponents1.stderr new file mode 100644 index 000000000..6096114be --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_exponents1.stderr @@ -0,0 +1,2 @@ +cpp_invalid_exponents1.i:3: Error: Exponent does not have any digits +cpp_invalid_exponents1.i:3: Error: Syntax error in input(1). diff --git a/Examples/test-suite/errors/cpp_invalid_exponents2.i b/Examples/test-suite/errors/cpp_invalid_exponents2.i new file mode 100644 index 000000000..2e074872a --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_exponents2.i @@ -0,0 +1,4 @@ +%module xxx + +void bad(double nn = 6.6e); + diff --git a/Examples/test-suite/errors/cpp_invalid_exponents2.stderr b/Examples/test-suite/errors/cpp_invalid_exponents2.stderr new file mode 100644 index 000000000..e7d1bf07d --- /dev/null +++ b/Examples/test-suite/errors/cpp_invalid_exponents2.stderr @@ -0,0 +1,2 @@ +cpp_invalid_exponents2.i:3: Error: Exponent does not have any digits +cpp_invalid_exponents2.i:3: Error: Syntax error in input(1). diff --git a/Examples/test-suite/errors/pp_invalid_exponents.i b/Examples/test-suite/errors/pp_invalid_exponents.i new file mode 100644 index 000000000..73dcdb145 --- /dev/null +++ b/Examples/test-suite/errors/pp_invalid_exponents.i @@ -0,0 +1,7 @@ +%module xxx + +#if 123e +#endif + +#if 456.e +#endif diff --git a/Examples/test-suite/errors/pp_invalid_exponents.stderr b/Examples/test-suite/errors/pp_invalid_exponents.stderr new file mode 100644 index 000000000..735a31ceb --- /dev/null +++ b/Examples/test-suite/errors/pp_invalid_exponents.stderr @@ -0,0 +1,6 @@ +:EOF: Error: Exponent does not have any digits +pp_invalid_exponents.i:3: Warning 202: Could not evaluate expression '123e' +pp_invalid_exponents.i:3: Warning 202: Error: 'Syntax error' +:EOF: Error: Exponent does not have any digits +pp_invalid_exponents.i:6: Warning 202: Could not evaluate expression '456.e' +pp_invalid_exponents.i:6: Warning 202: Error: 'Syntax error' diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index f62ddda01..af4a38adb 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1118,27 +1118,29 @@ static int look(Scanner *s) { break; case 82: if ((c = nextchar(s)) == 0) { - retract(s, 1); - return SWIG_TOKEN_INT; + Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); + return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); - return (SWIG_TOKEN_INT); + Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); + return SWIG_TOKEN_ERROR; } break; case 820: /* Like case 82, but we've seen a decimal point. */ if ((c = nextchar(s)) == 0) { - retract(s, 1); - return SWIG_TOKEN_DOUBLE; + Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); + return SWIG_TOKEN_ERROR; } if ((isdigit(c)) || (c == '-') || (c == '+')) state = 86; else { retract(s, 2); - return (SWIG_TOKEN_DOUBLE); + Swig_error(cparse_file, cparse_start_line, "Exponent does not have any digits\n"); + return SWIG_TOKEN_ERROR; } break; case 83: From ea5b55ecf44091482fbc7d5484f61cc5efade4e1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Jan 2018 07:51:18 +0000 Subject: [PATCH 0837/2031] Fix floating point division by zero in preprocessor expressions. Closes #1183 --- CHANGES.current | 4 ++++ .../test-suite/errors/pp_expressions_bad.i | 13 +++++++++++++ .../errors/pp_expressions_bad.stderr | 8 ++++++++ Source/Preprocessor/expr.c | 18 ++++++++++++++---- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/errors/pp_expressions_bad.i create mode 100644 Examples/test-suite/errors/pp_expressions_bad.stderr diff --git a/CHANGES.current b/CHANGES.current index 0618e9725..e2072fd33 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-15: wsfulton + Fix issue #1183. Floating point exception evaluating preprocessor expressions + resulting in division by zero. + 2018-01-14: wsfulton Fix issue #1172. Seg fault parsing invalid exponents in the preprocessor. diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i new file mode 100644 index 000000000..8f7b3abb3 --- /dev/null +++ b/Examples/test-suite/errors/pp_expressions_bad.i @@ -0,0 +1,13 @@ +%module xxx + +#define ZERO 0 + +#if 1%ZERO +#endif +#if 2/ZERO +#endif + +#if 1%(5-5) +#endif +#if 2/(55-55) +#endif diff --git a/Examples/test-suite/errors/pp_expressions_bad.stderr b/Examples/test-suite/errors/pp_expressions_bad.stderr new file mode 100644 index 000000000..4f7aec541 --- /dev/null +++ b/Examples/test-suite/errors/pp_expressions_bad.stderr @@ -0,0 +1,8 @@ +pp_expressions_bad.i:5: Warning 202: Could not evaluate expression '1%ZERO' +pp_expressions_bad.i:5: Warning 202: Error: 'Modulo by zero in expression' +pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '2/ZERO' +pp_expressions_bad.i:7: Warning 202: Error: 'Division by zero in expression' +pp_expressions_bad.i:10: Warning 202: Could not evaluate expression '1%(5-5)' +pp_expressions_bad.i:10: Warning 202: Error: 'Modulo by zero in expression' +pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '2/(55-55)' +pp_expressions_bad.i:12: Warning 202: Error: 'Division by zero in expression' diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index 6d22c8c5e..f6de7ef84 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -188,12 +188,22 @@ static int reduce_op() { sp--; break; case SWIG_TOKEN_SLASH: - stack[sp - 2].value = stack[sp - 2].value / stack[sp].value; - sp -= 2; + if (stack[sp].value != 0) { + stack[sp - 2].value = stack[sp - 2].value / stack[sp].value; + sp -= 2; + } else { + errmsg = "Division by zero in expression"; + return 0; + } break; case SWIG_TOKEN_PERCENT: - stack[sp - 2].value = stack[sp - 2].value % stack[sp].value; - sp -= 2; + if (stack[sp].value != 0) { + stack[sp - 2].value = stack[sp - 2].value % stack[sp].value; + sp -= 2; + } else { + errmsg = "Modulo by zero in expression"; + return 0; + } break; case SWIG_TOKEN_LSHIFT: stack[sp - 2].value = stack[sp - 2].value << stack[sp].value; From 532999f4f2cb55c5b5b46681f5dc9126ef6b44aa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Jan 2018 08:09:14 +0000 Subject: [PATCH 0838/2031] Improve error message when preprocessor expressions result in a floating point constant Instead of a syntax error, the error is now: Warning 202: Error: 'Floating point constant in preprocessor expression' --- .../test-suite/errors/pp_expressions_bad.i | 13 +++++++++++ .../errors/pp_expressions_bad.stderr | 22 ++++++++++++------- Source/Preprocessor/expr.c | 4 ++++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i index 8f7b3abb3..19d740942 100644 --- a/Examples/test-suite/errors/pp_expressions_bad.i +++ b/Examples/test-suite/errors/pp_expressions_bad.i @@ -1,5 +1,7 @@ %module xxx +/* Note: needs -Wextra to see these warnings */ +/* Divide by zero */ #define ZERO 0 #if 1%ZERO @@ -11,3 +13,14 @@ #endif #if 2/(55-55) #endif + +/* Floating point */ +#if 1.2 +#endif + +#if 2e3 +#endif + +#if 0 +#elif 8.8 +#endif diff --git a/Examples/test-suite/errors/pp_expressions_bad.stderr b/Examples/test-suite/errors/pp_expressions_bad.stderr index 4f7aec541..3e1112206 100644 --- a/Examples/test-suite/errors/pp_expressions_bad.stderr +++ b/Examples/test-suite/errors/pp_expressions_bad.stderr @@ -1,8 +1,14 @@ -pp_expressions_bad.i:5: Warning 202: Could not evaluate expression '1%ZERO' -pp_expressions_bad.i:5: Warning 202: Error: 'Modulo by zero in expression' -pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '2/ZERO' -pp_expressions_bad.i:7: Warning 202: Error: 'Division by zero in expression' -pp_expressions_bad.i:10: Warning 202: Could not evaluate expression '1%(5-5)' -pp_expressions_bad.i:10: Warning 202: Error: 'Modulo by zero in expression' -pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '2/(55-55)' -pp_expressions_bad.i:12: Warning 202: Error: 'Division by zero in expression' +pp_expressions_bad.i:7: Warning 202: Could not evaluate expression '1%ZERO' +pp_expressions_bad.i:7: Warning 202: Error: 'Modulo by zero in expression' +pp_expressions_bad.i:9: Warning 202: Could not evaluate expression '2/ZERO' +pp_expressions_bad.i:9: Warning 202: Error: 'Division by zero in expression' +pp_expressions_bad.i:12: Warning 202: Could not evaluate expression '1%(5-5)' +pp_expressions_bad.i:12: Warning 202: Error: 'Modulo by zero in expression' +pp_expressions_bad.i:14: Warning 202: Could not evaluate expression '2/(55-55)' +pp_expressions_bad.i:14: Warning 202: Error: 'Division by zero in expression' +pp_expressions_bad.i:18: Warning 202: Could not evaluate expression '1.2' +pp_expressions_bad.i:18: Warning 202: Error: 'Floating point constant in preprocessor expression' +pp_expressions_bad.i:21: Warning 202: Could not evaluate expression '2e3' +pp_expressions_bad.i:21: Warning 202: Error: 'Floating point constant in preprocessor expression' +pp_expressions_bad.i:25: Warning 202: Could not evaluate expression '8.8' +pp_expressions_bad.i:25: Warning 202: Error: 'Floating point constant in preprocessor expression' diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index f6de7ef84..a36588983 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -319,6 +319,10 @@ int Preprocessor_expr(DOH *s, int *error) { stack[sp].value = 0; stack[sp].svalue = 0; stack[sp].op = EXPR_VALUE; + } else if ((token == SWIG_TOKEN_FLOAT) || (token == SWIG_TOKEN_DOUBLE)) { + errmsg = "Floating point constant in preprocessor expression"; + *error = 1; + return 0; } else goto syntax_error; break; From 72964a1fafd2be8849ddd8f6cc6f5a8e04871c53 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Jan 2018 19:57:10 +0000 Subject: [PATCH 0839/2031] Don't accept some invalid preprocessor code Whitespace or non-numeric characters are required after a preprocessor directive that requires an expression. --- CHANGES.current | 25 +++++++++++++++++++ .../test-suite/errors/pp_expressions_bad.i | 17 +++++++++++++ .../errors/pp_expressions_bad.stderr | 5 ++++ Source/Preprocessor/cpp.c | 2 +- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index e2072fd33..1db9cbca1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,31 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-16: wsfulton + Expressions following a preprocessor directive must now be separated by whitespace + or non-numeric characters. This syntax change makes the SWIG preprocessor work like + the C preprocessor in this area. + + For example, the following code used be accepted as valid syntax: + #if1 + #define ABC 123 + #endif + + Now you get an error: + example.h:1: Error: Unknown SWIG preprocessor directive: if1 (if this is a block of + target language code, delimit it with %{ and %}) + example.h:3: Error: Extraneous #endif. + + The following is the correct syntax: + #if 1 + #define ABC 123 + #endif + + The following of course also works: + #if(1) + #define ABC 123 + #endif + 2018-01-15: wsfulton Fix issue #1183. Floating point exception evaluating preprocessor expressions resulting in division by zero. diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i index 19d740942..454437f95 100644 --- a/Examples/test-suite/errors/pp_expressions_bad.i +++ b/Examples/test-suite/errors/pp_expressions_bad.i @@ -24,3 +24,20 @@ #if 0 #elif 8.8 #endif + +/* Missing whitespace after preproc directive */ +#if123 +#endif + +#if456e +#endif + +#if 0 +#warning This should not warn +#elif1 +#warning This should also not warn +#endif + +#if(1) +#warning Warning okay: #if(1) +#endif diff --git a/Examples/test-suite/errors/pp_expressions_bad.stderr b/Examples/test-suite/errors/pp_expressions_bad.stderr index 3e1112206..84104c6a8 100644 --- a/Examples/test-suite/errors/pp_expressions_bad.stderr +++ b/Examples/test-suite/errors/pp_expressions_bad.stderr @@ -12,3 +12,8 @@ pp_expressions_bad.i:21: Warning 202: Could not evaluate expression '2e3' pp_expressions_bad.i:21: Warning 202: Error: 'Floating point constant in preprocessor expression' pp_expressions_bad.i:25: Warning 202: Could not evaluate expression '8.8' pp_expressions_bad.i:25: Warning 202: Error: 'Floating point constant in preprocessor expression' +pp_expressions_bad.i:29: Error: Unknown SWIG preprocessor directive: if123 (if this is a block of target language code, delimit it with %{ and %}) +pp_expressions_bad.i:30: Error: Extraneous #endif. +pp_expressions_bad.i:32: Error: Unknown SWIG preprocessor directive: if456e (if this is a block of target language code, delimit it with %{ and %}) +pp_expressions_bad.i:33: Error: Extraneous #endif. +pp_expressions_bad.i:42: Warning 204: CPP #warning, "Warning okay: #if(1)". diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index df7458201..10018a787 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1454,7 +1454,7 @@ String *Preprocessor_parse(String *s) { break; case 41: /* Build up the name of the preprocessor directive */ - if ((isspace(c) || (!isalpha(c)))) { + if ((isspace(c) || (!isidchar(c)))) { Clear(value); Clear(comment); if (c == '\n') { From 862501480efea950e33215cc49c1a20cb2af2958 Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Tue, 30 Jan 2018 16:34:31 +0100 Subject: [PATCH 0840/2031] add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers --- CHANGES.current | 7 +++- Lib/scilab/scirun.swg | 85 +++++++++++++++++++++++++++++---------- Lib/scilab/sciruntime.swg | 6 ++- 3 files changed, 72 insertions(+), 26 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1db9cbca1..5f0daee0b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-01-30: smarchetto + [Scilab] add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers + 2018-01-16: wsfulton Expressions following a preprocessor directive must now be separated by whitespace or non-numeric characters. This syntax change makes the SWIG preprocessor work like @@ -71,7 +74,7 @@ Version 4.0.0 (in progress) should make the generated code work with PHP 7.2.0. 2017-12-04: wsfulton - [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a + [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing u"\udcff" to the C layer (Python 3). @@ -150,7 +153,7 @@ Version 4.0.0 (in progress) language as the C++ template name, for example, this is now possible: template struct X { ... }; - %template(X) X; + %template(X) X; 2017-09-23: wsfulton Issue #1098. Fix overloading of shared_ptr with underlying pointer types, eg: diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index 29f8096ef..a9e9d6351 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -446,36 +446,77 @@ int SWIG_this(SWIG_GatewayParameters) { extern "C" #endif int SWIG_ptr(SWIG_GatewayParameters) { - void *ptrValue = NULL; - double dValue = 0; - if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) { - SWIG_Scilab_SetOutputPosition(1); - return SWIG_Scilab_SetOutput(pvApiCtx, - SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, NULL, 0, NULL)); - } - else { - int *piAddr; - SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); - if(sciErr.iErr) { + if (SWIG_NbInputArgument(pvApiCtx) > 0) { + int *piAddrVar1 = NULL; + int iTypeVar1 = 0; + char *pstInputPtrTypeName = NULL; + char *pstOutputMListTypeName = NULL; + if (SWIG_NbInputArgument(pvApiCtx) > 2) { + int *piAddrVar2 = NULL; + int *piAddrVar3 = NULL; + SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrVar2); + if (sciErr.iErr) { + printError(&sciErr, 0); + return SWIG_ERROR; + } + if (getAllocatedSingleString(pvApiCtx, piAddrVar2, &pstInputPtrTypeName)) { + return SWIG_ERROR; + } + sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddrVar3); + if (sciErr.iErr) { + printError(&sciErr, 0); + return SWIG_ERROR; + } + if (getAllocatedSingleString(pvApiCtx, piAddrVar3, &pstOutputMListTypeName)) { + return SWIG_ERROR; + } + } + + SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrVar1); + if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } - if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) { - if (dValue != (uintptr_t)dValue) { - Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); - return SWIG_ValueError; + sciErr = getVarType(pvApiCtx, piAddrVar1, &iTypeVar1); + if (sciErr.iErr) { + printError(&sciErr, 0); + return SWIG_ERROR; + } + + if ((iTypeVar1 == sci_pointer) || (iTypeVar1 == sci_mlist)) { + void *ptrValue = NULL; + if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, (char *) "SWIG_ptr") == SWIG_OK) { + SWIG_Scilab_SetOutputPosition(1); + return SWIG_Scilab_SetOutput(pvApiCtx, + SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, pstOutputMListTypeName)); } - if ((dValue < 0) || (dValue > ULONG_MAX)) { - Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); - return SWIG_OverflowError; + } + else if (iTypeVar1 == sci_matrix) { + double dValue = 0; + if (getScalarDouble(pvApiCtx, piAddrVar1, &dValue) == 0) { + if (dValue != (uintptr_t)dValue) { + Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); + return SWIG_ValueError; + } + if ((dValue < 0) || (dValue > ULONG_MAX)) { + Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1); + return SWIG_OverflowError; + } + SWIG_Scilab_SetOutputPosition(1); + return SWIG_Scilab_SetOutput(pvApiCtx, + SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, pstOutputMListTypeName)); + } + else { + return SWIG_TypeError; } - SWIG_Scilab_SetOutputPosition(1); - return SWIG_Scilab_SetOutput(pvApiCtx, - SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0, NULL)); } else { - Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A pointer or a double expected.\n"), "SWIG_ptr", 1); + Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A mlist, pointer or a double expected.\n"), (char *) "SWIG_ptr", 1); return SWIG_TypeError; } } + else { + Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: A mlist, pointer, or a double expected.\n"), "SWIG_ptr", 1); + return SWIG_TypeError; + } } diff --git a/Lib/scilab/sciruntime.swg b/Lib/scilab/sciruntime.swg index 9abedfe3d..3de138e11 100644 --- a/Lib/scilab/sciruntime.swg +++ b/Lib/scilab/sciruntime.swg @@ -25,12 +25,14 @@ SWIG_Scilab_SetModule(swig_module_info *swig_module) { SWIGRUNTIME swig_type_info * SWIG_Scilab_TypeQuery(const char *name) { if (SWIG_Module_Initialized()) { - return SWIG_TypeQuery(name); + if (name) { + return SWIG_TypeQuery(name); + } } else { SWIG_Error(SWIG_RuntimeError, "the module is not initialized"); - return NULL; } + return NULL; } %} From 7a9ee39412bbb10d79d9cafb5f61a4fb5c00840e Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Thu, 1 Feb 2018 10:09:35 +0100 Subject: [PATCH 0841/2031] [Scilab] fix compilation error --- Lib/scilab/scirun.swg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index a9e9d6351..3b2a96520 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -447,6 +447,7 @@ extern "C" #endif int SWIG_ptr(SWIG_GatewayParameters) { if (SWIG_NbInputArgument(pvApiCtx) > 0) { + SciErr sciErr; int *piAddrVar1 = NULL; int iTypeVar1 = 0; char *pstInputPtrTypeName = NULL; @@ -454,7 +455,7 @@ int SWIG_ptr(SWIG_GatewayParameters) { if (SWIG_NbInputArgument(pvApiCtx) > 2) { int *piAddrVar2 = NULL; int *piAddrVar3 = NULL; - SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrVar2); + sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddrVar2); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; @@ -472,7 +473,7 @@ int SWIG_ptr(SWIG_GatewayParameters) { } } - SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrVar1); + sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddrVar1); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; From 164713536918485f31a888242a7a0df411d03ec9 Mon Sep 17 00:00:00 2001 From: Simon Marchetto Date: Thu, 1 Feb 2018 14:31:52 +0100 Subject: [PATCH 0842/2031] [scilab] fix compilation (checked with the additional compiler options) --- Lib/scilab/scirun.swg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index 3b2a96520..961ac1c21 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -491,6 +491,9 @@ int SWIG_ptr(SWIG_GatewayParameters) { return SWIG_Scilab_SetOutput(pvApiCtx, SwigScilabPtrFromObject(pvApiCtx, 1, ptrValue, SWIG_Scilab_TypeQuery(pstInputPtrTypeName), 0, pstOutputMListTypeName)); } + else { + return SWIG_ERROR; + } } else if (iTypeVar1 == sci_matrix) { double dValue = 0; From 449ba627f5711ca9e65a4282cb734e7ac0187040 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Jan 2018 22:13:03 +0000 Subject: [PATCH 0843/2031] Typo fix in SWIGPlus.html docs --- Doc/Manual/SWIGPlus.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 5eac55261..310a7a951 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3152,7 +3152,7 @@ redundant and will simply result in code bloat).

          -The template provide to %template for instantiation must be the actual template and not a typedef to a template. +The template provided to %template for instantiation must be the actual template and not a typedef to a template.

          From 7fbdd21b4999e5a064b77f99919f4f0c242899db Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 11 Feb 2018 11:12:24 +0000 Subject: [PATCH 0844/2031] Javascript - Fix compilation error wrapping std::complex via std_complex.i Closes #1187 --- CHANGES.current | 4 ++++ Lib/javascript/v8/javascriptcomplex.swg | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 5f0daee0b..79e7a3f8d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-02-11: wsfulton + [Javascript] #1187 Fix compilation error wrapping std::complex via + std_complex.i. + 2018-01-30: smarchetto [Scilab] add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index 1c0107beb..d3b4aaffa 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -17,7 +17,7 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { SWIGV8_HANDLESCOPE_ESC(); - v8::Local vals = SWIGV8_ARRAY_NEW(2); + v8::Local vals = SWIGV8_ARRAY_NEW(); vals->Set(0, SWIG_From(double)(Real(c))); vals->Set(1, SWIG_From(double)(Imag(c))); From e435f3b93b6fa52b7a9552a00b6aa3fd3a41f94f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 18 Feb 2018 21:12:10 +0000 Subject: [PATCH 0845/2031] Document command-line options file support in changes file --- CHANGES.current | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 79e7a3f8d..7e3bd76f9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-02-18: JPEWdev + Patch #1164 - Add support for a command-line options file, also sometimes + called a response file. This is useful if the command-line options exceed + the system command-line length limit. To use, put the command-line options + into a file, then provide the file name prefixed with @, for example using + a file called args.txt: + + swig @args.txt + 2018-02-11: wsfulton [Javascript] #1187 Fix compilation error wrapping std::complex via std_complex.i. From 575b250b249cc4ba5a98dfb36f767256a16c1007 Mon Sep 17 00:00:00 2001 From: Andrew Galante Date: Tue, 20 Feb 2018 10:36:09 -0800 Subject: [PATCH 0846/2031] Don't write-back buffer into Java array when calling const-ptr c function --- Lib/java/java.swg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 56516439d..138e47bab 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1381,7 +1381,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } } %typemap(argout) (const char *STRING, size_t LENGTH) { - if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); + if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, JNI_ABORT); } %typemap(directorin, descriptor="[B", noblock=1) (const char *STRING, size_t LENGTH) { $input = 0; @@ -1394,6 +1394,9 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } %typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput" %apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) } +%typemap(argout) (char *STRING, size_t LENGTH) { + if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); +} %typemap(directorargout, noblock=1) (char *STRING, size_t LENGTH) { if ($input && $1) JCALL4(GetByteArrayRegion, jenv, $input, 0, (jsize)$2, (jbyte *)$1); } %apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) } From 300fc6f66972121c8704fb4774b5865b61e7889a Mon Sep 17 00:00:00 2001 From: Andrew Galante Date: Tue, 20 Feb 2018 10:45:39 -0800 Subject: [PATCH 0847/2031] Add comment for non-const version --- Lib/java/java.swg | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 138e47bab..5657ca134 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1394,6 +1394,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } %typemap(javadirectorin, descriptor="[B") (const char *STRING, size_t LENGTH) "$jniinput" %apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) } +/* Enable write-back for non-const version */ %typemap(argout) (char *STRING, size_t LENGTH) { if ($input) JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0); } From d4badb3e1dc32a5f60ceb8a2ed454d6694e57951 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 3 Mar 2018 14:31:03 +0000 Subject: [PATCH 0848/2031] Travis OSX Python 3 build fix for recent changes in brew --- Tools/travis-osx-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 42cc33bb2..6bfb2276a 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -23,8 +23,7 @@ case "$SWIGLANG" in "python") WITHLANG=$SWIGLANG$PY3 if [[ "$PY3" ]]; then - travis_retry brew install python3 - travis_retry brew list -v python3 + travis_retry brew upgrade python fi ;; esac From 30719feaf955135586fc96f61c067c9ccf09d507 Mon Sep 17 00:00:00 2001 From: Luca Longinotti Date: Thu, 30 Nov 2017 11:10:44 +0100 Subject: [PATCH 0849/2031] Fix handling of // comments inside macro arguments /* */ are already handled correctly. This completes the fix from commit 624ec3e1b7dd8908b37ee86bce6f60423c915bc5 related to swig/swig#974. --- Source/Preprocessor/cpp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 10018a787..af1775007 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -610,6 +610,7 @@ static List *find_args(String *s, int ismacro, String *macro_name) { } else if (c == '/') { /* Ensure comments are ignored by eating up the characters */ c = Getc(s); + /* Handle / * ... * / type comments (multi-line) */ if (c == '*') { while ((c = Getc(s)) != EOF) { if (c == '*') { @@ -621,6 +622,16 @@ static List *find_args(String *s, int ismacro, String *macro_name) { c = Getc(s); continue; } + /* Handle // ... type comments (single-line) */ + if (c == '/') { + while ((c = Getc(s)) != EOF) { + if (c == '\n') { + break; + } + } + c = Getc(s); + continue; + } /* ensure char is available in the stream as this was not a comment*/ Ungetc(c, s); c = '/'; From d5e012f70f7626d3c381666d0112588be883fedf Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 7 Mar 2018 14:40:28 +1300 Subject: [PATCH 0850/2031] Add test coverage for // comment fix --- Examples/test-suite/preproc.i | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 1efc0dd98..6d6549be7 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -389,6 +389,20 @@ TCX_PACKED (typedef struct tcxMessageBugImpl { int mBid; /**< Bid price and size, check PresentMap if available in message */ }) tcxMessageBug; + + +TCX_PACKED (typedef struct tcxMessageTestImplSlashSlash +{ + int mHeader; ///< comment +}) tcxMessageTestSlashSlash; + + +TCX_PACKED (typedef struct tcxMessageBugImplSlashSlash +{ + int mBid; ///< Bid price and size, check PresentMap if available in message +}) tcxMessageBugSlashSlash; + + %} // Regression tests for https://github.com/swig/swig/pull/1111 From 538ce627750945262179606930850697e0317f6e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 7 Mar 2018 14:48:44 +1300 Subject: [PATCH 0851/2031] Add CHANGES.current entry for previous fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 7e3bd76f9..b3954a680 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-03-07: llongi + Github PR #1166 - Fix preprocessor handling of macros with commas + in a // comment. + 2018-02-18: JPEWdev Patch #1164 - Add support for a command-line options file, also sometimes called a response file. This is useful if the command-line options exceed From ba3773e1be7dfc0580ff2edb8881e418b6877b2f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 8 Mar 2018 06:10:08 +1300 Subject: [PATCH 0852/2031] preproc.i: Shorten classname for scilab Errors were: ../../../../../../Examples/test-suite/scilab/../preproc.i:400: Error: Wrapping functions names for member 'tcxMessageTestSlashSlash.mHeader' will exceed 24 characters, please rename the container of member 'tcxMessageTestSlashSlash'. ../../../../../../Examples/test-suite/scilab/../preproc.i:408: Error: Wrapping functions names for member 'tcxMessageBugSlashSlash.mBid' will exceed 24 characters, please rename the container of member 'tcxMessageBugSlashSlash'. --- Examples/test-suite/preproc.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 6d6549be7..f666911fe 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -391,16 +391,16 @@ TCX_PACKED (typedef struct tcxMessageBugImpl }) tcxMessageBug; -TCX_PACKED (typedef struct tcxMessageTestImplSlashSlash +TCX_PACKED (typedef struct tcxMessageTestImpl2 { int mHeader; ///< comment -}) tcxMessageTestSlashSlash; +}) tcxMessageTest2; -TCX_PACKED (typedef struct tcxMessageBugImplSlashSlash +TCX_PACKED (typedef struct tcxMessageBugImpl2 { int mBid; ///< Bid price and size, check PresentMap if available in message -}) tcxMessageBugSlashSlash; +}) tcxMessageBug2; %} From 1915740af8c26720f366162c768c223bddb15c7c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 8 Mar 2018 06:12:01 +1300 Subject: [PATCH 0853/2031] preproc.i: Also note URL for "// in macro" PR --- Examples/test-suite/preproc.i | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index f666911fe..3239798f7 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -373,7 +373,8 @@ int methodX(int x); int methodX(int x) { return x+100; } %} -// Comma in macro - Github issue #974 +// Comma in macro - https://github.com/swig/swig/issues/974 (for /* */) +// and https://github.com/swig/swig/pull/1166 (for //) %inline %{ #define swig__attribute__(x) #define TCX_PACKED(d) d swig__attribute__ ((__packed__)) From 60ee821bcaa9751b0dfeb4d9381b3263f592757e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Feb 2018 19:39:15 +0000 Subject: [PATCH 0854/2031] Correct C# warning for missing cstype typemap --- Source/Modules/csharp.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 9b28829ee..78d494fb7 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1384,7 +1384,7 @@ public: // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); Setattr(n, "type", typemap_lookup_type); - const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); + const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF); String *return_type = Copy(tm); substituteClassname(typemap_lookup_type, return_type); From 3ce3ce0683dd3c6ac4482abacd0f3734e9b95a3d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Feb 2018 19:45:03 +0000 Subject: [PATCH 0855/2031] Add std_shared_ptr.i for Scilab and R as boost_shared_ptr.i is already available --- Lib/r/std_shared_ptr.i | 2 ++ Lib/scilab/std_shared_ptr.i | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 Lib/r/std_shared_ptr.i create mode 100644 Lib/scilab/std_shared_ptr.i diff --git a/Lib/r/std_shared_ptr.i b/Lib/r/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/r/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include diff --git a/Lib/scilab/std_shared_ptr.i b/Lib/scilab/std_shared_ptr.i new file mode 100644 index 000000000..df873679c --- /dev/null +++ b/Lib/scilab/std_shared_ptr.i @@ -0,0 +1,2 @@ +#define SWIG_SHARED_PTR_NAMESPACE std +%include From b4f4ce4fd516f3fed319aaf0d9d8ec98a106de8b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Mar 2018 08:13:41 +0000 Subject: [PATCH 0856/2031] Fix Java swigReleaseOwnership() and swigTakeOwnership() regression Fixes segfault when using non-director classes. Restores a dynamic_cast which was previously removed. The dynamic_cast is not needed for the swig_connect_director call ... we'll have to find another solution for #449 for Java. Closes #1184 --- CHANGES.current | 4 ++ Examples/test-suite/common.mk | 1 + Examples/test-suite/director_ownership.i | 72 +++++++++++++++++++ .../java/director_ownership_runme.java | 42 +++++++++++ Source/Modules/java.cxx | 11 +-- 5 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/director_ownership.i create mode 100644 Examples/test-suite/java/director_ownership_runme.java diff --git a/CHANGES.current b/CHANGES.current index b3954a680..6dbfbe4a0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-03-09: fultonwi + [Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression + for non-director classes. Restores a dynamic_cast which was previously removed. + 2018-03-07: llongi Github PR #1166 - Fix preprocessor handling of macros with commas in a // comment. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3bcf67c8c..eaf8d38cf 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -194,6 +194,7 @@ CPP_TEST_CASES += \ director_nspace_director_name_collision \ director_overload \ director_overload2 \ + director_ownership \ director_pass_by_value \ director_primitives \ director_property \ diff --git a/Examples/test-suite/director_ownership.i b/Examples/test-suite/director_ownership.i new file mode 100644 index 000000000..3f8f1b512 --- /dev/null +++ b/Examples/test-suite/director_ownership.i @@ -0,0 +1,72 @@ +%module(directors="1") director_ownership + +// Github issue #1184 + +%include "std_string.i" + +%feature("director") example::ContentBase; +%feature("director") example::ContentDerived; + +%newobject example::make_content; + +%inline %{ +#include + +namespace example +{ + +class ContentBase +{ +public: + ContentBase() {} + virtual ~ContentBase() {} + virtual std::string get_name() const = 0; +}; + + +class ContentDerived: public ContentBase +{ +public: + ContentDerived():ContentBase() { m_name = "ContentDerived"; } + virtual ~ContentDerived() {} + virtual std::string get_name() const override { return m_name; } + +private: + std::string m_name; +}; + + +class Container +{ +public: + Container() { m_content = 0; } + ~Container() + { + clear_content(); + } + // the container takes the ownership of the content + void set_content(ContentBase* content) + { + clear_content(); + m_content = content; + } + ContentBase* get_content() { return m_content; } + +private: + void clear_content() + { + if(m_content) + { + delete m_content; + m_content = 0; + } + } + +private: + ContentBase* m_content; +}; + +static ContentBase* make_content() { return new ContentDerived(); } + +} // namespace example +%} diff --git a/Examples/test-suite/java/director_ownership_runme.java b/Examples/test-suite/java/director_ownership_runme.java new file mode 100644 index 000000000..c038f56a4 --- /dev/null +++ b/Examples/test-suite/java/director_ownership_runme.java @@ -0,0 +1,42 @@ +import director_ownership.*; + +public class director_ownership_runme { + + static { + try { + System.loadLibrary("director_ownership"); + } 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 set_content_and_release(Container container, ContentBase content) { + content.swigReleaseOwnership(); + container.set_content(content); + } + + public static void main(String argv[]) { + + Container container = new Container(); + + // make a content in java (cMemoryOwn true) + ContentBase content_java = new ContentDerived(); + + // make a content in c++ (cMemoryOwn true) + ContentBase content_cpp = director_ownership.make_content(); + + set_content_and_release(container, content_java); + if (!container.get_content().get_name().equals("ContentDerived")) + throw new RuntimeException("did not get ContentDerived"); + + // when swigReleaseOwnership() is called on content_cpp, swig tries a static_cast to director and calls the method + // director->swig_java_change_ownership. The content created in c++ native library is not a director, therefore a + // segfault may occur. + // With a check done using dynamic_cast this issue could be avoided. + set_content_and_release(container, content_cpp); + if (!container.get_content().get_name().equals("ContentDerived")) + throw new RuntimeException("did not get ContentDerived"); + } +} + diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index d2b25426a..0f4b13186 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3763,15 +3763,16 @@ public: Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr, smartptr); Printf(code_wrap->code, " // Keep a local instance of the smart pointer around while we are using the raw pointer\n"); Printf(code_wrap->code, " // Avoids using smart pointer specific API.\n"); - Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); - } - else { + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj->operator->());\n", dirClassName, dirClassName); + } else { Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name); - Printf(code_wrap->code, " %s *director = static_cast<%s *>(obj);\n", dirClassName, dirClassName); + Printf(code_wrap->code, " %s *director = dynamic_cast<%s *>(obj);\n", dirClassName, dirClassName); } Printf(code_wrap->code, " (void)jcls;\n"); - Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n"); + Printf(code_wrap->code, " if (director) {\n"); + Printf(code_wrap->code, " director->swig_java_change_ownership(jenv, jself, jtake_or_release ? true : false);\n"); + Printf(code_wrap->code, " }\n"); Printf(code_wrap->code, "}\n"); Wrapper_print(code_wrap, f_wrappers); From 98ebd56942019eacca543a6469c89119c88a0359 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Mar 2018 18:27:16 +0000 Subject: [PATCH 0857/2031] Remove c++11 override in testcase --- Examples/test-suite/director_ownership.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/director_ownership.i b/Examples/test-suite/director_ownership.i index 3f8f1b512..48e909758 100644 --- a/Examples/test-suite/director_ownership.i +++ b/Examples/test-suite/director_ownership.i @@ -29,7 +29,7 @@ class ContentDerived: public ContentBase public: ContentDerived():ContentBase() { m_name = "ContentDerived"; } virtual ~ContentDerived() {} - virtual std::string get_name() const override { return m_name; } + virtual std::string get_name() const { return m_name; } private: std::string m_name; From b5796019e042f10ad84d4c30c170fafe9415f768 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 21 Feb 2018 12:25:35 +0000 Subject: [PATCH 0858/2031] Remove deprecated autoconf macros AC_EXEEXT AC_OBJEXT are deprecated in the minimum autoconf version we use: 2.58. The compiler checking macros do the equivalent now. --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac index cfc338126..a40c6662d 100644 --- a/configure.ac +++ b/configure.ac @@ -28,8 +28,6 @@ AH_BOTTOM([ dnl Check for programs that a user requires to build SWIG AC_PROG_CC AC_PROG_CXX -AC_EXEEXT -AC_OBJEXT AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS AC_COMPILE_WARNINGS # Increase warning levels From d42a5f2ce332103731a01fc4c5f93e9bb4be53f3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 19 Mar 2018 21:52:47 +0100 Subject: [PATCH 0859/2031] Fix wrongly resetting indent after formulae in Doxygen comments Don't use IndentGuard unconditionally in handleMath(), it should only be used for display (or block) formulae, but not for the inline ones. This fixes "losing" the correct indent after a paragraph containing any inline formulae in the generated Python comments. --- .../DoxygenTranslator/src/PyDocConverter.cpp | 56 +++++++++++++------ 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index e1bae2792..76431af54 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -34,19 +34,35 @@ public: // One indent level. static const char* Level() { return " "; } + // Default ctor doesn't do anything and prevents the dtor from doing anything + // too and should only be used when the guard needs to be initialized + // conditionally as Init() can then be called after checking some condition. + // Otherwise, prefer to use the non default ctor below. + IndentGuard() + { + m_initialized = false; + } + // Ctor takes the output to determine the current indent and to remove the // extra indent added to it in the dtor and the variable containing the indent // to use, which must be used after every new line by the code actually // updating the output. - explicit IndentGuard(string& output, string& indent) : - m_output(output), - m_indent(indent) + IndentGuard(string& output, string& indent) { - const size_t lastNonSpace = m_output.find_last_not_of(' '); + Init(output, indent); + } + + // Really initializes the object created using the default ctor. + void Init(string& output, string& indent) + { + m_output = &output; + m_indent = &indent; + + const size_t lastNonSpace = m_output->find_last_not_of(' '); if (lastNonSpace == string::npos) { - m_firstLineIndent = m_output.length(); - } else if (m_output[lastNonSpace] == '\n') { - m_firstLineIndent = m_output.length() - (lastNonSpace + 1); + m_firstLineIndent = m_output->length(); + } else if ((*m_output)[lastNonSpace] == '\n') { + m_firstLineIndent = m_output->length() - (lastNonSpace + 1); } else { m_firstLineIndent = 0; } @@ -54,7 +70,9 @@ public: // Notice that the indent doesn't include the first line indent because it's // implicit, i.e. it is present in the input and so is copied into the // output anyhow. - m_indent = Level(); + *m_indent = Level(); + + m_initialized = true; } // Get the indent for the first line of the paragraph, which is smaller than @@ -63,23 +81,27 @@ public: ~IndentGuard() { - m_indent.clear(); + if (!m_initialized) + return; + + m_indent->clear(); // Get rid of possible remaining extra indent, e.g. if there were any trailing // new lines: we shouldn't add the extra indent level to whatever follows // this paragraph. static const size_t lenIndentLevel = strlen(Level()); - if (m_output.length() > lenIndentLevel) { - const size_t start = m_output.length() - lenIndentLevel; - if (m_output.compare(start, string::npos, Level()) == 0) - m_output.erase(start); + if (m_output->length() > lenIndentLevel) { + const size_t start = m_output->length() - lenIndentLevel; + if (m_output->compare(start, string::npos, Level()) == 0) + m_output->erase(start); } } private: - string& m_output; - string& m_indent; + string* m_output; + string* m_indent; unsigned m_firstLineIndent; + bool m_initialized; IndentGuard(const IndentGuard&); IndentGuard& operator=(const IndentGuard&); @@ -433,7 +455,7 @@ void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string& arg) { - IndentGuard indent(translatedComment, m_indent); + IndentGuard indent; // Only \f$ is translated to inline formulae, \f[ and \f{ are for the block ones. const bool inlineFormula = tag.typeOfEntity == "f$"; @@ -443,6 +465,8 @@ void PyDocConverter::handleMath(DoxygenEntity &tag, if (inlineFormula) { translatedComment += ":math:`"; } else { + indent.Init(translatedComment, m_indent); + trimWhitespace(translatedComment); translatedComment += '\n'; From 9b44d1bb7e00301d67e20c3cca451feb2f6c2779 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Mar 2018 23:58:20 +0000 Subject: [PATCH 0860/2031] Fix -Wimplicit-fallthrough gcc-7.3 warning --- CCache/snprintf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CCache/snprintf.c b/CCache/snprintf.c index 32187c1a5..9bf8a817b 100644 --- a/CCache/snprintf.c +++ b/CCache/snprintf.c @@ -292,6 +292,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'X': flags |= DP_F_UP; + /* FALLTHROUGH */ case 'x': flags |= DP_F_UNSIGNED; if (cflags == DP_C_SHORT) @@ -314,6 +315,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'E': flags |= DP_F_UP; + /* FALLTHROUGH */ case 'e': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); @@ -322,6 +324,7 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args break; case 'G': flags |= DP_F_UP; + /* FALLTHROUGH */ case 'g': if (cflags == DP_C_LDOUBLE) fvalue = va_arg (args, LDOUBLE); From 6fac581a2b9517b8058f978ea5442026f1340753 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Mar 2018 07:44:00 +0000 Subject: [PATCH 0861/2031] Stop testing Python on Appveyor msys/mingw I can't get python2 nor python3 to work with recent platform changes at Appveyor. Just compile SWIG binary for now. --- appveyor.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 74b1c045d..e2f6a6b32 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,8 +22,7 @@ environment: PY3: 1 - SWIGLANG: python OSVARIANT: cygwin - - SWIGLANG: python - OSVARIANT: mingw + - OSVARIANT: mingw install: - date /T & time /T @@ -85,8 +84,6 @@ install: - bash -c "which $CXX" - bash -c "$CC --version | head -n 1" - bash -c "$CXX --version | head -n 1" -- bash -c "which python" -- bash -c "python -V" - bash -c "make --version | head -n 2" - pwd - echo MAKEJOBS=%MAKEJOBS% @@ -105,9 +102,9 @@ test_script: - .\swig.exe -version - if not "%OSVARIANT%"=="" CCache\ccache-swig -V - bash -c "file ./swig.exe" -- bash -c "make check-%SWIGLANG%-version" -- bash -c "time make -k check-%SWIGLANG%-examples %CHECK_OPTIONS%" -- bash -c "time make -k check-%SWIGLANG%-test-suite -j%MAKEJOBS% %CHECK_OPTIONS%" +- if not "%SWIGLANG%"=="" bash -c "make check-%SWIGLANG%-version %CHECK_OPTIONS%" +- if not "%SWIGLANG%"=="" bash -c "time make -k check-%SWIGLANG%-examples %CHECK_OPTIONS%" +- if not "%SWIGLANG%"=="" bash -c "time make -k check-%SWIGLANG%-test-suite -j%MAKEJOBS% %CHECK_OPTIONS%" # Do not build on tags (GitHub only) skip_tags: true From a1cea4f483144952989580f54e73f38f94b90562 Mon Sep 17 00:00:00 2001 From: Joel Anderson Date: Wed, 21 Mar 2018 19:12:54 -0400 Subject: [PATCH 0862/2031] Fix ruby %alias directive for native c functions Using the %alias directive on native C functions causes swig to segfault due to a dereference of klass (which is NULL for native C functions) in the defineAliases function of the Ruby module. This commit adds support for an alias of native C functions for both separate module as well as global functions, as well as three test cases for the %alias directive of the Ruby module. Fixes: mod.i %module ruby_alias %alias get_my_name "nickname,fullname"; %inline %{ const char *get_my_name(){ return "Chester Tester"; } %} $ swig -ruby mod.i Segmentation fault Signed-off-by: Joel Anderson --- Examples/test-suite/ruby/Makefile.in | 4 +++ .../ruby/ruby_alias_global_function_runme.rb | 20 ++++++++++++++ .../ruby/ruby_alias_method_runme.rb | 24 +++++++++++++++++ .../ruby/ruby_alias_module_function_runme.rb | 26 +++++++++++++++++++ .../test-suite/ruby_alias_global_function.i | 11 ++++++++ Examples/test-suite/ruby_alias_method.i | 26 +++++++++++++++++++ .../test-suite/ruby_alias_module_function.i | 11 ++++++++ Source/Modules/ruby.cxx | 8 +++++- 8 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/ruby/ruby_alias_global_function_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_alias_method_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_alias_module_function_runme.rb create mode 100644 Examples/test-suite/ruby_alias_global_function.i create mode 100644 Examples/test-suite/ruby_alias_method.i create mode 100644 Examples/test-suite/ruby_alias_module_function.i diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 292244a9e..add65fe9f 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -22,6 +22,7 @@ CPP_TEST_CASES = \ li_std_stack \ li_std_wstring \ primitive_types \ + ruby_alias_method \ ruby_keywords \ ruby_minherit_shared_ptr \ ruby_naming \ @@ -44,6 +45,8 @@ CPP11_TEST_CASES = \ C_TEST_CASES += \ li_cstring \ + ruby_alias_global_function \ + ruby_alias_module_function \ ruby_manual_proxy \ include $(srcdir)/../common.mk @@ -52,6 +55,7 @@ include $(srcdir)/../common.mk SWIGOPT += -w801 -noautorename -features autodoc=4 # Custom tests - tests with additional commandline options +ruby_alias_global_function.ctest: SWIGOPT += -globalmodule ruby_naming.cpptest: SWIGOPT += -autorename # Rules for the different types of tests diff --git a/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb b/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb new file mode 100644 index 000000000..14e38e4cf --- /dev/null +++ b/Examples/test-suite/ruby/ruby_alias_global_function_runme.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +# +# Runtime tests for ruby_alias_global_function.i +# + +require 'swig_assert' +require 'ruby_alias_global_function' + +expected_name = get_my_name + +swig_assert(fullname == expected_name, msg: "nickname not working as expected") +swig_assert(nickname == expected_name, msg: "fullname not working as expected") + +if method(:nickname).respond_to?(:original_name) + swig_assert_equal_simple(method(:nickname).original_name, :get_my_name) + swig_assert_equal_simple(method(:fullname).original_name, :get_my_name) +else + swig_assert(method(:nickname) == method(:get_my_name), msg: "nickname is not an alias of get_my_name") + swig_assert(method(:fullname) == method(:get_my_name), msg: "fullname is not an alias of get_my_name") +end diff --git a/Examples/test-suite/ruby/ruby_alias_method_runme.rb b/Examples/test-suite/ruby/ruby_alias_method_runme.rb new file mode 100644 index 000000000..c19101e63 --- /dev/null +++ b/Examples/test-suite/ruby/ruby_alias_method_runme.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby +# +# Runtime tests for ruby_alias_method.i +# + +require 'swig_assert' +require 'ruby_alias_method' + +include Ruby_alias_method + +expected_name = "Chester Tester" +syn = Synonym.new(expected_name) + +swig_assert(syn.getMyName() == expected_name, msg: "getMyName not working as expected") +swig_assert(syn.nickname() == expected_name, msg: "nickname not working as expected") +swig_assert(syn.fullname() == expected_name, msg: "fullname not working as expected") + +if syn.method(:nickname).respond_to?(:original_name) + swig_assert_equal_simple(syn.method(:nickname).original_name, :getMyName) + swig_assert_equal_simple(syn.method(:fullname).original_name, :getMyName) +else + swig_assert(syn.method(:nickname) == syn.method(:getMyName)) + swig_assert(syn.method(:fullname) == syn.method(:getMyName)) +end diff --git a/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb b/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb new file mode 100644 index 000000000..1f4205f1f --- /dev/null +++ b/Examples/test-suite/ruby/ruby_alias_module_function_runme.rb @@ -0,0 +1,26 @@ +#!/usr/bin/env ruby +# +# Runtime tests for ruby_alias_module_function.i +# + +require 'swig_assert' +require 'ruby_alias_module_function' + +include Ruby_alias_module_function + +expected_name = Ruby_alias_module_function.get_my_name + +swig_assert(Ruby_alias_module_function.nickname == expected_name, msg: "nickname returned a different result than get_my_name") +swig_assert(Ruby_alias_module_function.fullname == expected_name, msg: "fullname returned a different result than get_my_name") + +nickname_method = Ruby_alias_module_function.method(:nickname) +fullname_method = Ruby_alias_module_function.method(:fullname) + +if nickname_method.respond_to?(:original_name) + swig_assert_equal_simple(nickname_method.original_name, :get_my_name) + swig_assert_equal_simple(fullname_method.original_name, :get_my_name) +else + original_method = Ruby_alias_module_function.method(:get_my_name) + swig_assert(nickname_method == original_method, msg: "nickname is not an alias of get_my_name") + swig_assert(fullname_method == original_method, msg: "fullname is not an alias of get_my_name") +end diff --git a/Examples/test-suite/ruby_alias_global_function.i b/Examples/test-suite/ruby_alias_global_function.i new file mode 100644 index 000000000..bddb24959 --- /dev/null +++ b/Examples/test-suite/ruby_alias_global_function.i @@ -0,0 +1,11 @@ +%module ruby_alias_global_function + +%alias get_my_name "nickname,fullname"; + +%inline %{ + +const char *get_my_name(){ + return "Chester Tester"; +} + +%} diff --git a/Examples/test-suite/ruby_alias_method.i b/Examples/test-suite/ruby_alias_method.i new file mode 100644 index 000000000..9ddcfce5e --- /dev/null +++ b/Examples/test-suite/ruby_alias_method.i @@ -0,0 +1,26 @@ +%module ruby_alias_method +%include + +%alias Synonym::getMyName "nickname,fullname" + +%inline %{ + +class Synonym { +private: + std::string myName; + +public: + Synonym(std::string myName); + + std::string getMyName(); +}; + +Synonym::Synonym(std::string myName){ + this->myName = myName; +}; + +std::string Synonym::getMyName(){ + return this->myName; +}; + +%} diff --git a/Examples/test-suite/ruby_alias_module_function.i b/Examples/test-suite/ruby_alias_module_function.i new file mode 100644 index 000000000..900de5f1d --- /dev/null +++ b/Examples/test-suite/ruby_alias_module_function.i @@ -0,0 +1,11 @@ +%module ruby_alias_module_function + +%alias get_my_name "nickname,fullname"; + +%inline %{ + +const char *get_my_name(){ + return "Chester Tester"; +} + +%} diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 69a849d16..78bd23a6e 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1316,7 +1316,13 @@ public: Iterator alias = First(aliases); while (alias.item) { if (Len(alias.item) > 0) { - if (multipleInheritance) { + if (current == NO_CPP) { + if (useGlobalModule) { + Printv(f_init, tab4, "rb_define_alias(rb_cObject, \"", alias.item, "\", \"", iname, "\");\n", NIL); + } else { + Printv(f_init, tab4, "rb_define_alias(rb_singleton_class(", modvar, "), \"", alias.item, "\", \"", iname, "\");\n", NIL); + } + } else if (multipleInheritance) { Printv(klass->init, tab4, "rb_define_alias(", klass->mImpl, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); } else { Printv(klass->init, tab4, "rb_define_alias(", klass->vname, ", \"", alias.item, "\", \"", iname, "\");\n", NIL); From 5f5ab92d5e9658ae0b120591176043049a002b52 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 3 Apr 2018 17:44:51 +1200 Subject: [PATCH 0863/2031] Fix typo --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 6dbfbe4a0..d923c2974 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -147,7 +147,7 @@ Version 4.0.0 (in progress) https://sourceforge.net/p/swig/bugs/826/ 2017-10-06: wsfulton - [Python] Issue #1108. Fix platorm inconsistency in Python default argument handling. + [Python] Issue #1108. Fix platform inconsistency in Python default argument handling. 32 bit and 64 bit compiled versions of SWIG generated different Python files when default arguments were outside the range of 32 bit signed integers. The default arguments specified in Python are now only those that are in the From 3bea8f6b7e0449946c12a0ce2c5aa893d6026883 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 3 Apr 2018 18:01:58 +1200 Subject: [PATCH 0864/2031] [Ruby] Pass Qnil instead of NULL to rb_funcall() This silences GCC -Wconversion-null warning (on by default with recent GCC). --- CHANGES.current | 4 ++++ Doc/Manual/Ruby.html | 20 ++++++++++---------- Examples/ruby/hashargs/example.i | 4 ++-- Source/Modules/ruby.cxx | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d923c2974..84842a830 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-04-03: olly + [Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC + -Wconversion-null warning (on by default with recent GCC). + 2018-03-09: fultonwi [Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression for non-director classes. Restores a dynamic_cast which was previously removed. diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 04a4f1cee..433afd7ad 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -3704,7 +3704,7 @@ value:

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
               Check_Type($input, T_HASH);
          -    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
           }
          @@ -3717,7 +3717,7 @@ the keys and values from the hash:

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
               Check_Type($input, T_HASH);
          -    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
               $2 = NULL;
               $3 = NULL;
               if ($1 > 0) {
          @@ -3736,13 +3736,13 @@ of the keys) and then start looping over the elements in that array: 

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
               Check_Type($input, T_HASH);
          -    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
               $2 = NULL;
               $3 = NULL;
               if ($1 > 0) {
                 $2 = (char **) malloc($1*sizeof(char *));
                 $3 = (int *) malloc($1*sizeof(int));
          -      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
          +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
                 for (i = 0; i < $1; i++) {
                 }
               }
          @@ -3758,13 +3758,13 @@ corresponding to that key in the hash: 

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
               Check_Type($input, T_HASH);
          -    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
               $2 = NULL;
               $3 = NULL;
               if ($1 > 0) {
                 $2 = (char **) malloc($1*sizeof(char *));
                 $3 = (int *) malloc($1*sizeof(int));
          -      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
          +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
                 for (i = 0; i < $1; i++) {
                   key = rb_ary_entry(keys_arr, i);
                   val = rb_hash_aref($input, key);
          @@ -3781,13 +3781,13 @@ value is a Fixnum: 

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
               Check_Type($input, T_HASH);
          -    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +    $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
               $2 = NULL;
               $3 = NULL;
               if ($1 > 0) {
                 $2 = (char **) malloc($1*sizeof(char *));
                 $3 = (int *) malloc($1*sizeof(int));
          -      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
          +      keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
                 for (i = 0; i < $1; i++) {
                   key = rb_ary_entry(keys_arr, i);
                   val = rb_hash_aref($input, key);
          @@ -3805,13 +3805,13 @@ equivalents and store them in our local C arrays: 

          %typemap(in) (int nattributes, const char **names, const int *values)
             (VALUE keys_arr, int i, VALUE key, VALUE val) {
             Check_Type($input, T_HASH);
          -  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
             $2 = NULL;
             $3 = NULL;
             if ($1 > 0) {
               $2 = (char **) malloc($1*sizeof(char *));
               $3 = (int *) malloc($1*sizeof(int));
          -    keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
          +    keys_arr = rb_funcall($input, rb_intern("keys"), 0, Qnil);
               for (i = 0; i < $1; i++) {
                 key = rb_ary_entry(keys_arr, i);
                 val = rb_hash_aref($input, key);
          diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i
          index 10e209e5f..4c3f3070b 100644
          --- a/Examples/ruby/hashargs/example.i
          +++ b/Examples/ruby/hashargs/example.i
          @@ -2,13 +2,13 @@
           
           %typemap(in) (int nattributes, const char **names, const int *values) (VALUE keys_ary, int i, VALUE key, VALUE val) {
             Check_Type($input, T_HASH);
          -  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
          +  $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, Qnil));
             $2 = NULL;
             $3 = NULL;
             if ($1 > 0) {
               $2 = (char **) malloc($1*sizeof(char *));
               $3 = (int *) malloc($1*sizeof(int));
          -    keys_ary = rb_funcall($input, rb_intern("keys"), 0, NULL);
          +    keys_ary = rb_funcall($input, rb_intern("keys"), 0, Qnil);
               for (i = 0; i < $1; i++) {
                 key = rb_ary_entry(keys_ary, i);
                 val = rb_hash_aref($input, key);
          diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
          index 69a849d16..641604620 100644
          --- a/Source/Modules/ruby.cxx
          +++ b/Source/Modules/ruby.cxx
          @@ -3046,7 +3046,7 @@ public:
                 if (argc > 0) {
           	Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), %d%s);\n", Swig_cresult_name(), methodName, argc, args);
                 } else {
          -	Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, NULL);\n", Swig_cresult_name(), methodName);
          +	Printf(w->code, "%s = rb_funcall(swig_get_self(), rb_intern(\"%s\"), 0, Qnil);\n", Swig_cresult_name(), methodName);
                 }
                 if ( initstack ) Printf(w->code, "SWIG_RELEASE_STACK;\n");
               }
          
          From 15a09ffbdc9e45f1f99da62391b797e0815f8706 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 7 Apr 2018 12:34:39 +0100
          Subject: [PATCH 0865/2031] Add changes entry for Ruby %alias fix for global
           functions
          
          ---
           CHANGES.current | 3 +++
           1 file changed, 3 insertions(+)
          
          diff --git a/CHANGES.current b/CHANGES.current
          index 84842a830..72764c694 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2018-04-07: goatshriek
          +            [Ruby] #1213 Fix ruby %alias directive for global C/C++ functions.
          +
           2018-04-03: olly
           	    [Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC
           	    -Wconversion-null warning (on by default with recent GCC).
          
          From cf8f99ba442c6cb0c658576c08522d455836633e Mon Sep 17 00:00:00 2001
          From: Ben Elliston 
          Date: Tue, 10 Apr 2018 10:07:47 +1000
          Subject: [PATCH 0866/2031] * Makefile.in (configfiles): Update URLs for latest
           configfiles.
          
          We haven't uploaded the latest version of these scripts to ftp.gnu.org
          in over 10 years. See ftp://ftp.gnu.org/pub/gnu/config/README. The
          best place to fetch them from is the Savannah git repository.
          ---
           Makefile.in | 4 ++--
           1 file changed, 2 insertions(+), 2 deletions(-)
          
          diff --git a/Makefile.in b/Makefile.in
          index c19e16a97..9f81598cd 100644
          --- a/Makefile.in
          +++ b/Makefile.in
          @@ -583,9 +583,9 @@ srcrpm:
           # version 1.10 for our case of not having a top level Makefile.am. Until then we
           # can fetch them manually and will have to commit them to Git.
           configfiles:
          -	wget ftp://ftp.gnu.org/pub/gnu/config/config.guess -O Tools/config/config.guess
          +	wget 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess' -O Tools/config/config.guess
           	chmod a+x Tools/config/config.guess
          -	wget ftp://ftp.gnu.org/pub/gnu/config/config.sub -O Tools/config/config.sub
          +	wget 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub' -O Tools/config/config.sub
           	chmod a+x Tools/config/config.sub
           
           # Regenerate Makefile if Makefile.in or config.status have changed.
          
          From 4ae4fe8a42597848b9759a4b0e7662deb76c382e Mon Sep 17 00:00:00 2001
          From: Jake Cobb 
          Date: Tue, 28 Feb 2017 11:24:08 -0500
          Subject: [PATCH 0867/2031] %pythonappend docs and memory management example
          
          Document 'val' variable for the %pythonappend directive.
          Add memory management example equivalent to Java and C#
          docs using %pythonappend.
          ---
           Doc/Manual/Python.html | 82 ++++++++++++++++++++++++++++++++++++++++++
           1 file changed, 82 insertions(+)
          
          diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
          index 27ce084bd..0b9a3eeec 100644
          --- a/Doc/Manual/Python.html
          +++ b/Doc/Manual/Python.html
          @@ -96,6 +96,7 @@
           
        • Mapping Python tuples into small arrays
        • Mapping sequences to C arrays
        • Pointer handling +
        • Memory management when returning references to member variables
      • Docstring Features
          @@ -3543,6 +3544,7 @@ proxy, just before the return statement. %feature("pythonappend") Foo::bar(int) %{ #do something after C++ call + #the 'val' variable holds the return value %} @@ -3572,6 +3574,7 @@ SWIG version 1.3.28 you can use the directive forms %pythonappend Foo::bar(int) %{ #do something after C++ call + #the 'val' variable holds the return value %} @@ -5267,6 +5270,85 @@ that has a this attribute. In addition, class object (if applicable).

          +

          36.9.7 Memory management when returning references to member variables

          + + +

          +This example shows how to prevent premature garbage collection of objects when the underlying C++ class returns a pointer or reference to a member variable. +The example is a direct equivalent to this Java equivalent. +

          + +

          +Consider the following C++ code: +

          + +
          +
          +struct Wheel {
          +  int size;
          +  Wheel(int sz) : size(sz) {}
          +};
          +
          +class Bike {
          +  Wheel wheel;
          +public:
          +  Bike(int val) : wheel(val) {}
          +  Wheel& getWheel() { return wheel; }
          +};
          +
          +
          + +

          +and the following usage from Python after running the code through SWIG: +

          + + +
          +
          +bike = Bike(10)
          +wheel = bike.getWheel()
          +print("wheel size: {}".format(wheel.size))
          +
          +del bike # Allow bike to be garbage collected
          +print("wheel size: {}".format(wheel.size))
          +
          +
          + +

          +Don't be surprised that if the resulting output gives strange results such as... +

          + +
          +
          +wheel size: 10
          +wheel size: 135019664
          +
          +
          + +

          +What has happened here is the garbage collector has collected the Bike instance as it doesn't think it is needed any more. +The proxy instance, wheel, contains a reference to memory that was deleted when the Bike instance was collected. +In order to prevent the garbage collector from collecting the Bike instance, a reference to the Bike must +be added to the wheel instance. You can do this by adding the reference when the getWheel() method +is called using the typemap-like %pythonappend directive (see 36.6.2 Adding additional Python code): +

          + + +
          +
          +%pythonappend getWheel %{
          +  # val is the Wheel proxy, self is the Bike instance
          +  val._bike = self
          +%}
          +
          +
          + +

          +The code gets appended to the Python code generated for the +Bike::getWheel function, where we store the Bike proxy +instance onto the Wheel proxy instance before it is returned to the +caller. +

          36.10 Docstring Features

          From 26e08be7ce465799ad9f40f2e0781b4780581454 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Fri, 13 Apr 2018 11:14:51 -0400 Subject: [PATCH 0868/2031] -builtin compatible ref example in Python docs --- Doc/Manual/Python.html | 49 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 0b9a3eeec..6d6402045 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -5329,10 +5329,18 @@ wheel size: 135019664 What has happened here is the garbage collector has collected the Bike instance as it doesn't think it is needed any more. The proxy instance, wheel, contains a reference to memory that was deleted when the Bike instance was collected. In order to prevent the garbage collector from collecting the Bike instance, a reference to the Bike must -be added to the wheel instance. You can do this by adding the reference when the getWheel() method -is called using the typemap-like %pythonappend directive (see 36.6.2 Adding additional Python code): +be added to the wheel instance. +

          + +

          +You can do this by adding the reference when the getWheel() method +is called using one of two approaches: +

          + +

          +The easier, but less optimized, way is to use the typemap-like %pythonappend directive +(see 36.6.2 Adding additional Python code):

          -
          @@ -5349,6 +5357,41 @@ The code gets appended to the Python code generated for the
           instance onto the Wheel proxy instance before it is returned to the 
           caller.
           

          + +

          +The second option, which performs better and is required if you use the +-builtin option, is to set the reference in the CPython implementation: + +

          +
          +%fragment("extra_reference", "header") {
          +
          +static PyObject *extra_reference() {
          +  static PyObject *extra_reference_string = NULL;
          +  if (!extra_reference_string)
          +    extra_reference_string = SWIG_Python_str_FromChar("_extra_reference");
          +  return extra_reference_string;
          +}
          +
          +}
          +
          +%extend Wheel {
          +%typemap(ret, fragment="extra_reference") Wheel& getWheel %{
          +  // A reference to the parent class is added to ensure the underlying C++
          +  // object is not deleted while the item is in use
          +  PyObject_SetAttr($result, extra_reference(), $self);
          +%}
          +/* FYI: Alternative approach, but is possibly harder to understand, so suggest above
          +%typemap(out, fragment="extra_reference") Wheel& getWheel %{
          +  $typemap(out, Wheel &)
          +  // A reference to the parent class is added to ensure the underlying C++
          +  // object is not deleted while the item is in use
          +  PyObject_SetAttr($result, extra_reference(), $self);
          +%}
          +*/
          +}
          +
          +

          36.10 Docstring Features

          From 46ab0c252da9ab846265a60517ca462e5256cd24 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Mon, 16 Apr 2018 19:52:29 +0200 Subject: [PATCH 0869/2031] Fix off-by-one error The condition only applies to guile 1.8 and older so it should really have been '<2' all along. As we already have such a conditional block earlier up, merge the two together as well. --- Lib/guile/guile_scm_run.swg | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 1cc08b024..274f19715 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -24,6 +24,8 @@ scm_module_variable (SCM module, SCM sym) return scm_sym2var (sym, scm_module_lookup_closure (module), SCM_BOOL_F); } +#define scm_to_utf8_string scm_to_locale_string +#define scm_from_utf8_string scm_from_locale_string #endif #if SCM_MAJOR_VERSION >= 2 @@ -40,10 +42,6 @@ typedef struct swig_guile_clientdata { SCM goops_class; } swig_guile_clientdata; -#if SCM_MAJOR_VERSION <= 2 -#define scm_to_utf8_string scm_to_locale_string -#define scm_from_utf8_string scm_from_locale_string -#endif #define SWIG_scm2str(s) \ SWIG_Guile_scm2newstr(s, NULL) #define SWIG_str02scm(str) \ From 209586c991c1a42df1e2cdb23f520fb18a79525c Mon Sep 17 00:00:00 2001 From: Ivan Leonov Date: Tue, 10 Apr 2018 14:22:15 +0300 Subject: [PATCH 0870/2031] Fix typo in help --with-jscoreinc and --with-jscorelib --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a40c6662d..7b5b54c65 100644 --- a/configure.ac +++ b/configure.ac @@ -1492,7 +1492,7 @@ else # check for include files AC_MSG_CHECKING(for JavaScriptCore/JavaScript.h) - AC_ARG_WITH(jscoreinc, [ --with-jscinc=path Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=]) + AC_ARG_WITH(jscoreinc, [ --with-jscoreinc=path Set location of Javascript include directory], [JSCOREINCDIR="$withval"], [JSCOREINCDIR=]) JSCOREVERSION= @@ -1526,7 +1526,7 @@ else fi # check for JavaScriptCore/Webkit libraries - AC_ARG_WITH(jscorelib,[ --with-jsclib=path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=]) + AC_ARG_WITH(jscorelib,[ --with-jscorelib=path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=]) if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then AC_MSG_CHECKING(for JavaScriptCore/Webkit library) From 34ee191769e885fefa380d4e7c09c17f3d103ae6 Mon Sep 17 00:00:00 2001 From: Ivan Leonov Date: Tue, 10 Apr 2018 14:32:27 +0300 Subject: [PATCH 0871/2031] Add if-no-present action for jsv8inc arg --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7b5b54c65..833cb37bf 100644 --- a/configure.ac +++ b/configure.ac @@ -1550,7 +1550,7 @@ else # check for include files AC_MSG_CHECKING(for V8 Javascript v8.h) - AC_ARG_WITH(jsv8inc, [ --with-jsv8inc=path Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"]) + AC_ARG_WITH(jsv8inc, [ --with-jsv8inc=path Set location of Javascript v8 include directory], [JSV8INCDIR="$withval"], [JSV8INCDIR=]) # if not include dir is specified we try to find if test -z "$JSV8INCDIR"; then From 2ab3f4d744682d6512e216f57e0fb7cecea04169 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 18 Apr 2018 17:00:02 +1200 Subject: [PATCH 0872/2031] [Python] Suppress new pycodestyle warning E252 missing whitespace around parameter equals --- CHANGES.current | 4 ++++ Examples/Makefile.in | 2 +- Examples/test-suite/python/Makefile.in | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 72764c694..f15c99e90 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-04-18: olly + [Python] Suppress new pycodestyle warning: + E252 missing whitespace around parameter equals + 2018-04-07: goatshriek [Ruby] #1213 Fix ruby %alias directive for global C/C++ functions. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 81697c8b2..8218f5122 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -335,7 +335,7 @@ else endif PYCODESTYLE = @PYCODESTYLE@ -PYCODESTYLE_FLAGS = --ignore=E402,E501,E30,W291,W391 +PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,W291,W391 # ---------------------------------------------------------------- # Build a C dynamically loadable module diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 12844e311..e2aad7c8b 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -11,7 +11,7 @@ endif LANGUAGE = python PYTHON = $(PYBIN) PYCODESTYLE = @PYCODESTYLE@ -PYCODESTYLE_FLAGS = --ignore=E30,E402,E501,E731,W291,W391 +PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,W291,W391 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py From 65dd1c49bc9f866edee64031a3c4769d1f15e8b3 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Wed, 18 Apr 2018 17:28:31 -0400 Subject: [PATCH 0873/2031] Python: Keep reference to owning container during element access --- Lib/python/pycontainer.swg | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 36557d75e..4a38febea 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -36,6 +36,13 @@ %include +%fragment("container_owner_attribute", "header") { + PyObject* container_owner_attribute() { + static PyObject* name = SWIG_Python_str_FromChar("__owner"); + return name; + } +} + %fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { namespace swig { template <> struct traits { @@ -766,6 +773,17 @@ namespace swig size_type __len__() const { return self->size(); } + + %typemap(ret, fragment="container_owner_attribute") value_type& { + PyObject* swigThis = PyObject_GetAttrString($result, "this"); + PyErr_Clear(); + if (swigThis && SwigPyObject_Check(swigThis) && + (reinterpret_cast(swigThis)->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { + // try to store reference to parent + PyObject_GenericSetAttr($result, container_owner_attribute(), $self); + } + Py_XDECREF(swigThis); + } } %enddef From cc2dc6b192103fad59782a089658d583b84195e3 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Wed, 18 Apr 2018 20:39:56 -0400 Subject: [PATCH 0874/2031] Python: Cleanup container back ref Use a single function in a fragment. Use SWIG_Python_GetSwigThis instead of directly grabbing the 'this' attribute. --- Lib/python/pycontainer.swg | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 4a38febea..18e1f3265 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -36,12 +36,26 @@ %include -%fragment("container_owner_attribute", "header") { - PyObject* container_owner_attribute() { - static PyObject* name = SWIG_Python_str_FromChar("__owner"); - return name; +%fragment("reference_container_owner", "header") { +namespace swig { + /** + * Call to add a back-reference to the owning object when returning a + * reference from a container. Will only set the reference if child + * is a SWIG wrapper object that does not own the pointer. + * + * @return if the reference was set or not + */ + bool reference_container_owner(PyObject* child, PyObject* owner) { + static PyObject* attr = SWIG_Python_str_FromChar("__owner"); + SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); + if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { + PyObject_GenericSetAttr(child, attr, owner); + return true; + } + return false; } } +} %fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { namespace swig { @@ -774,15 +788,8 @@ namespace swig return self->size(); } - %typemap(ret, fragment="container_owner_attribute") value_type& { - PyObject* swigThis = PyObject_GetAttrString($result, "this"); - PyErr_Clear(); - if (swigThis && SwigPyObject_Check(swigThis) && - (reinterpret_cast(swigThis)->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - // try to store reference to parent - PyObject_GenericSetAttr($result, container_owner_attribute(), $self); - } - Py_XDECREF(swigThis); + %typemap(ret, fragment="reference_container_owner") value_type& { + swig::reference_container_owner($result, $self); } } %enddef From 92df196408e34aa41eab44fea9f79a5514b4d962 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Thu, 19 Apr 2018 10:32:11 -0400 Subject: [PATCH 0875/2031] Python: Use PyObject_SetAttr instead of PyObject_GenericSetAttr for back-ref --- Lib/python/pycontainer.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 18e1f3265..f77c7cb34 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -49,7 +49,7 @@ namespace swig { static PyObject* attr = SWIG_Python_str_FromChar("__owner"); SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - PyObject_GenericSetAttr(child, attr, owner); + PyObject_SetAttr(child, attr, owner); return true; } return false; From 5f6012039abb6ec9e9dfea801effa6b02fd102bc Mon Sep 17 00:00:00 2001 From: Vsevolod Kvachev Date: Thu, 19 Apr 2018 23:04:37 +0300 Subject: [PATCH 0876/2031] Fix go version matching in configure for go1.10 --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 833cb37bf..ba1631743 100644 --- a/configure.ac +++ b/configure.ac @@ -2584,7 +2584,7 @@ else GOVERSIONOPTION=version go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') case "$go_version" in - go1 | go1.[[01234]]*) + go1 | go1.[[01234]] | go1.[[01234]].*) GOC=$(sh -c "$(go env) && echo \$GOCHAR")c ;; *) @@ -2593,7 +2593,7 @@ else esac AC_MSG_CHECKING([whether go version is too old]) case $go_version in - go1.1* | go1.0* | go1 ) + go1.1.* | go1.1 | go1.0 | go1.0.* | go1 ) AC_MSG_RESULT([yes - minimum version is 1.2]) GO= GOOPT="-intgosize 32" @@ -2611,13 +2611,13 @@ else ;; esac case $go_version in - go1.0* | go1 | go1.1*) + go1.0 | go1.0.* | go1 | go1.1 | go1.1.*) GOOPT="$GOOPT -use-shlib" ;; - go1.2*) + go1.2 | go1.2.*) GO12=true ;; - go1.3* | go1.4*) + go1.3 | go1.3.* | go1.4 | go1.4.*) GO13=true ;; *) From 0d2a6466549f34c74835943c979ee315feb3eda8 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 18 Apr 2018 11:10:11 +0200 Subject: [PATCH 0877/2031] guile - use more reliable method of finding guile executable based on guile-config This allows to only specify --with-guile-config=xyz to configure and it will pick up the correct guile executable in case more versions of guile are installed on the same system. For example on Fedora 27, I have /usr/bin/guile1.8 /usr/bin/guile (which is guile 2.0) /usr/bin/guile2.2 Without this patch the configure script would always pick /usr/bin/guile regardless of which guile-config I would specify (guile1.8-config, guile-config or guile-config2.2). With the patch guile2.2 is now correctly picked for guile-config2.2. Unfortunately it still won't work with guile 1.8 because that version can't provide the executable name via guile-config yet. In that case configure will fall back to the old behaviour. On my Fedora 27 system that would mean it would still pick the wrong executable. However this is not critical because that as well can be overridden by setting --with-guile=abc. I don't see an easy way to improve on this. --- configure.ac | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 833cb37bf..664c0fa1a 100644 --- a/configure.ac +++ b/configure.ac @@ -1704,13 +1704,20 @@ else fi if test -n "$GUILE_CONFIG" ; then if test x"$GUILE" = xyes; then - AC_MSG_CHECKING([for guile bindir]) - guile_bindir="`$GUILE_CONFIG info bindir`" - AC_MSG_RESULT([$guile_bindir]) - GUILE=$guile_bindir/guile - if ! test -f "$GUILE" ; then - GUILE= - AC_PATH_PROG(GUILE, guile) + AC_MSG_CHECKING([for guile executable]) + if $GUILE_CONFIG info guile > /dev/null 2>&1; then + GUILE="`$GUILE_CONFIG info guile`" + AC_MSG_RESULT([$GUILE]) + else + AC_MSG_RESULT([not in guile-config, constructing path]) + AC_MSG_CHECKING([for guile bindir]) + guile_bindir="`$GUILE_CONFIG info bindir`" + AC_MSG_RESULT([$guile_bindir]) + GUILE=$guile_bindir/guile + if ! test -f "$GUILE" ; then + GUILE= + AC_PATH_PROG(GUILE, guile) + fi fi fi From d1f7054b7e620deaf33e8f75eac73389a60141d9 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 18 Apr 2018 11:46:56 +0200 Subject: [PATCH 0878/2031] guile - replace obsolete scm_listify with scm_list_n scm_list_n is available in all guile versions supported by swig, while scm_listify no longer is in guile 2.2 --- Lib/guile/guile_scm.swg | 4 ++-- Lib/guile/typemaps.i | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/guile/guile_scm.swg b/Lib/guile/guile_scm.swg index dfd5da271..37eef6f33 100644 --- a/Lib/guile/guile_scm.swg +++ b/Lib/guile/guile_scm.swg @@ -26,10 +26,10 @@ else { \ if (!gswig_list_p) { \ gswig_list_p = 1; \ - gswig_result = scm_listify(gswig_result, object, SCM_UNDEFINED); \ + gswig_result = scm_list_n(gswig_result, object, SCM_UNDEFINED); \ } \ else \ - gswig_result = scm_append(scm_listify(gswig_result, scm_listify(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ + gswig_result = scm_append(scm_list_n(gswig_result, scm_list_n(object, SCM_UNDEFINED), SCM_UNDEFINED)); \ } %} diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index 0d130f523..f2926c163 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -69,13 +69,13 @@ %typemap(throws) SWIGTYPE { $<ype temp = new $ltype($1); scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(SWIG_NewPointerObj(temp, $&descriptor, 1), + scm_list_n(SWIG_NewPointerObj(temp, $&descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE & { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(SWIG_NewPointerObj(&$1, $descriptor, 1), + scm_list_n(SWIG_NewPointerObj(&$1, $descriptor, 1), SCM_UNDEFINED)); } @@ -87,13 +87,13 @@ %typemap(throws) SWIGTYPE * { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), + scm_list_n(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } %typemap(throws) SWIGTYPE [] { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(SWIG_NewPointerObj($1, $descriptor, 1), + scm_list_n(SWIG_NewPointerObj($1, $descriptor, 1), SCM_UNDEFINED)); } @@ -176,7 +176,7 @@ %typemap(varout) enum SWIGTYPE { $result = scm_from_long((int)$1); } %typemap(throws) enum SWIGTYPE { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(scm_from_long((int)$1), SCM_UNDEFINED)); + scm_list_n(scm_from_long((int)$1), SCM_UNDEFINED)); } /* The SIMPLE_MAP_WITH_EXPR macro below defines the whole set of @@ -225,7 +225,7 @@ %typemap(throws) C_NAME { C_NAME swig_c_value = $1; scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(C_TO_SCM_EXPR, SCM_UNDEFINED)); + scm_list_n(C_TO_SCM_EXPR, SCM_UNDEFINED)); } %enddef @@ -269,7 +269,7 @@ /* Throw typemap */ %typemap(throws) C_NAME { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(C_TO_SCM($1), SCM_UNDEFINED)); + scm_list_n(C_TO_SCM($1), SCM_UNDEFINED)); } %enddef @@ -344,7 +344,7 @@ SIMPLE_MAP(unsigned long long, scm_to_ulong_long, scm_from_ulong_long, integer); %typemap(throws) char * { scm_throw(scm_from_locale_symbol((char *) "swig-exception"), - scm_listify(SWIG_str02scm($1), SCM_UNDEFINED)); + scm_list_n(SWIG_str02scm($1), SCM_UNDEFINED)); } /* Void */ From a95ceabb70e9a28686440f0cc0dcb64eae281356 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Wed, 18 Apr 2018 11:52:54 +0200 Subject: [PATCH 0879/2031] guile - drop GDB_INTERFACE related stuff Guile itself has removed it a long time ago: http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commit;h=8510e39278161d3cbf8ec4ba87b123fe28763ed4 There's no need for it. I suspect it's just there because the interface file was created based on the then real main source file of guile. --- Lib/guile/guilemain.i | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Lib/guile/guilemain.i b/Lib/guile/guilemain.i index 925b81fee..809154e99 100644 --- a/Lib/guile/guilemain.i +++ b/Lib/guile/guilemain.i @@ -12,11 +12,6 @@ extern "C" { #endif -/* Debugger interface (don't change the order of the following lines) */ -#define GDB_TYPE SCM -#include -GDB_INTERFACE; - static void inner_main(void *closure, int argc, char **argv) { From b02cb7e0bcf0ae747355b988b45900ed81538823 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 19 Apr 2018 15:29:07 +0200 Subject: [PATCH 0880/2031] Fix guile executable detection on early 2.0.x guile versions Querying guile-config for the executable name was only introduced in guile 2.0.12. If it works it's the most reliable method in environments with more than one guile executable. If it doesn't work fall back to path detection, assuming the executable name is just 'guile'. If that's incorrect it's up to the caller to explicitly specify the path to the right guile executable. --- configure.ac | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 664c0fa1a..0720ad66f 100644 --- a/configure.ac +++ b/configure.ac @@ -1705,19 +1705,20 @@ else if test -n "$GUILE_CONFIG" ; then if test x"$GUILE" = xyes; then AC_MSG_CHECKING([for guile executable]) - if $GUILE_CONFIG info guile > /dev/null 2>&1; then - GUILE="`$GUILE_CONFIG info guile`" + # Try extracting it via guile-config first. If it's defined there it's the most reliable result + GUILE="`$GUILE_CONFIG info guile 2>/dev/null`" + if test -n "$GUILE"; then AC_MSG_RESULT([$GUILE]) else AC_MSG_RESULT([not in guile-config, constructing path]) AC_MSG_CHECKING([for guile bindir]) guile_bindir="`$GUILE_CONFIG info bindir`" AC_MSG_RESULT([$guile_bindir]) - GUILE=$guile_bindir/guile - if ! test -f "$GUILE" ; then - GUILE= - AC_PATH_PROG(GUILE, guile) - fi + GUILE="$guile_bindir/guile" + fi + if ! test -f "$GUILE" ; then + GUILE= + AC_PATH_PROG(GUILE, guile) fi fi From 7e798c18621d1b1b8291a6c8080692e1a3852e4b Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 19 Apr 2018 16:22:56 +0200 Subject: [PATCH 0881/2031] Disable guile configuration if guile-config and guile report a different version In addition - inform the user when guile gets disabled while it was requested - skip unecessary configuration work if guile gets disabled --- configure.ac | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 0720ad66f..789311d53 100644 --- a/configure.ac +++ b/configure.ac @@ -1710,7 +1710,7 @@ else if test -n "$GUILE"; then AC_MSG_RESULT([$GUILE]) else - AC_MSG_RESULT([not in guile-config, constructing path]) + AC_MSG_RESULT([not found via guile-config - constructing path]) AC_MSG_CHECKING([for guile bindir]) guile_bindir="`$GUILE_CONFIG info bindir`" AC_MSG_RESULT([$guile_bindir]) @@ -1722,7 +1722,9 @@ else fi fi - if test -f "$GUILE" ; then + if ! test -f "$GUILE" ; then + AC_MSG_WARN([no suitable guile executable found. Disabling Guile]) + else AC_MSG_CHECKING([for guile version]) guile_version=`$GUILE -c '(display (effective-version))'` AC_MSG_RESULT([$guile_version]) @@ -1730,20 +1732,33 @@ else guile_good_version=`$GUILE -c '(if (>= (string->number (effective-version)) 1.8) (display "yes") (display "no"))'` AC_MSG_RESULT([$guile_good_version]) if test x"$guile_good_version" != xyes ; then + AC_MSG_WARN([at least guile version 1.8 is required. Disabling Guile]) GUILE= fi fi - if test -z "$GUILE_CFLAGS" ; then - AC_MSG_CHECKING([for guile compile flags]) - GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty - AC_MSG_RESULT([$GUILE_CFLAGS]) + if test -f "$GUILE" ; then + # Test if guile-config and guile versions match. They should. + gc_version="`$GUILE_CONFIG --version 2>&1 | sed '1 s/.* //;q'`" + g_version="`$GUILE --version | sed '1 s/.* //;q'`" + if test "$gc_version" != "$g_version"; then + AC_MSG_WARN([different versions reported by $GUILE_CONFIG ($gc_version) and $GUILE ($g_version). Disabling Guile]) + GUILE= + fi fi - if test -z "$GUILE_LIBS" ; then - AC_MSG_CHECKING([for guile link flags]) - GUILE_LIBS="`$GUILE_CONFIG link`" - AC_MSG_RESULT([$GUILE_LIBS]) + if test -f "$GUILE" ; then + if test -z "$GUILE_CFLAGS" ; then + AC_MSG_CHECKING([for guile compile flags]) + GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty + AC_MSG_RESULT([$GUILE_CFLAGS]) + fi + + if test -z "$GUILE_LIBS" ; then + AC_MSG_CHECKING([for guile link flags]) + GUILE_LIBS="`$GUILE_CONFIG link`" + AC_MSG_RESULT([$GUILE_LIBS]) + fi fi fi fi From f8adc3e6139d80b758c162aea2725c810f35484b Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 20 Apr 2018 08:54:37 +0200 Subject: [PATCH 0882/2031] guile - resstructure some configure tests 1. move the 'no executable found' message up to be with the executable tests 2. test for an (non-)empty GUILE variable for all other conditions after that An empty GUILE variable means guile is disabled and consistently using the same test makes the code more readable. --- configure.ac | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 789311d53..5ee050c64 100644 --- a/configure.ac +++ b/configure.ac @@ -1720,11 +1720,12 @@ else GUILE= AC_PATH_PROG(GUILE, guile) fi + if test -z "$GUILE" ; then + AC_MSG_WARN([no suitable guile executable found. Disabling Guile]) + fi fi - if ! test -f "$GUILE" ; then - AC_MSG_WARN([no suitable guile executable found. Disabling Guile]) - else + if test -n "$GUILE" ; then AC_MSG_CHECKING([for guile version]) guile_version=`$GUILE -c '(display (effective-version))'` AC_MSG_RESULT([$guile_version]) @@ -1737,7 +1738,7 @@ else fi fi - if test -f "$GUILE" ; then + if test -n "$GUILE" ; then # Test if guile-config and guile versions match. They should. gc_version="`$GUILE_CONFIG --version 2>&1 | sed '1 s/.* //;q'`" g_version="`$GUILE --version | sed '1 s/.* //;q'`" @@ -1747,7 +1748,7 @@ else fi fi - if test -f "$GUILE" ; then + if test -n "$GUILE" ; then if test -z "$GUILE_CFLAGS" ; then AC_MSG_CHECKING([for guile compile flags]) GUILE_CFLAGS="`$GUILE_CONFIG compile`" # Note that this can sometimes be empty From d612c6a8353c0e535f5d664bdefed1d07a81030a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 21 Apr 2018 14:59:44 +1200 Subject: [PATCH 0883/2031] [ci] guile 2.2 build no longer expected to fail --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53b9226ac..527658709 100644 --- a/.travis.yml +++ b/.travis.yml @@ -338,10 +338,6 @@ matrix: env: SWIGLANG=tcl allow_failures: - # Started failing after upgrade from Guile 2.0.14 to Guile 2.2.0 - - compiler: clang - os: osx - env: SWIGLANG=guile # Lots of failing tests currently - compiler: gcc os: linux From db34df38f3d5ab3c0b35f57d581f7f327dc7dfee Mon Sep 17 00:00:00 2001 From: Sylvain Joubert Date: Mon, 23 Apr 2018 13:57:19 +0200 Subject: [PATCH 0884/2031] [Java] Suppress deprecation warning on finalize method Java 9 deprecates the finalize method. For now just suppress the deprecation warning. Fixes #1237 --- Examples/test-suite/java_director.i | 1 + Examples/test-suite/java_throws.i | 1 + Lib/java/java.swg | 1 + 3 files changed, 3 insertions(+) diff --git a/Examples/test-suite/java_director.i b/Examples/test-suite/java_director.i index 03d733d6a..6b2cb6dfe 100644 --- a/Examples/test-suite/java_director.i +++ b/Examples/test-suite/java_director.i @@ -7,6 +7,7 @@ %module(directors="1") java_director %typemap(javafinalize) SWIGTYPE %{ + @SuppressWarnings("deprecation") protected void finalize() { // System.out.println("Finalizing " + this); delete(); diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index bb5c6e48f..c137da804 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -192,6 +192,7 @@ try { // Need to handle the checked exception in NoExceptTest.delete() %typemap(javafinalize) SWIGTYPE %{ + @SuppressWarnings("deprecation") protected void finalize() { try { delete(); diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 19e597bd9..bcab5a6fd 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1273,6 +1273,7 @@ SWIG_JAVABODY_PROXY(protected, protected, SWIGTYPE) SWIG_JAVABODY_TYPEWRAPPER(protected, protected, protected, SWIGTYPE) %typemap(javafinalize) SWIGTYPE %{ + @SuppressWarnings("deprecation") protected void finalize() { delete(); } From 6fb6636ce2b2085384c3ffd656a966a25a599f96 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Sat, 28 Apr 2018 12:28:11 +1000 Subject: [PATCH 0885/2031] Remove superfluous parens in generated Python scripts. --- Source/Modules/python.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 4a1b4750d..57a5347cb 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -927,16 +927,16 @@ public: // Python-2.2 object hack Printv(f_shadow, "\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n", - tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own(value)\n", - tab4, "if (name == \"this\"):\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", + tab4, "if name == \"thisown\":\n", tab8, "return self.this.own(value)\n", + tab4, "if name == \"this\":\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", #ifdef USE_THISOWN tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n", #endif tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n", #ifdef USE_THISOWN - tab4, "if (not static) or (name == \"thisown\"):\n", + tab4, "if not static or name == \"thisown\":\n", #else - tab4, "if (not static):\n", + tab4, "if not static:\n", #endif NIL); if (!classic) { @@ -955,7 +955,7 @@ public: Printv(f_shadow, "\n", "def _swig_getattr(self, class_type, name):\n", - tab4, "if (name == \"thisown\"):\n", tab8, "return self.this.own()\n", + tab4, "if name == \"thisown\":\n", tab8, "return self.this.own()\n", tab4, "method = class_type.__swig_getmethods__.get(name, None)\n", tab4, "if method:\n", tab8, "return method(self)\n", tab4, "raise AttributeError(\"'%s' object has no attribute '%s'\" % (class_type.__name__, name))\n\n", NIL); @@ -978,7 +978,7 @@ public: #ifdef USE_THISOWN tab4, tab4, "if hasattr(self, name) or (name in (\"this\", \"thisown\")):\n", #else - tab4, tab4, "if (name == \"thisown\"):\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n", + tab4, tab4, "if name == \"thisown\":\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n", #endif tab4, tab4, tab4, "set(self, name, value)\n", tab4, tab4, "else:\n", From 0ba153c892e05fd45e12688ce726f1a4d45454b2 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Tue, 1 May 2018 21:22:20 -0500 Subject: [PATCH 0886/2031] Test NodeJS 4, 6, 8, and 10 --- .travis.yml | 11 ++++++++++- Tools/travis-linux-install.sh | 6 ++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index dce67cee7..08b688425 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,16 @@ matrix: dist: trusty - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node + env: SWIGLANG=javascript ENGINE=node VER=4 + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=6 + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=8 + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=10 - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=jsc diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 43bdb77bc..57f97b604 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -33,10 +33,8 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - travis_retry sudo add-apt-repository -y ppa:chris-lea/node.js - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq nodejs rlwrap - travis_retry sudo npm install -g node-gyp + curl -sL https://deb.nodesource.com/setup_${VER}.x | sudo -E bash - + travis_retry sudo apt-get install -y nodejs ;; "jsc") travis_retry sudo apt-get install -qq libwebkitgtk-dev From 7774cdf71ffec3d13980bcc2ec4f00ff912cdede Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 30 Apr 2018 18:46:34 +0100 Subject: [PATCH 0887/2031] Correct C shared library creation when specifing CC to configure --- configure.ac | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 0161e2778..bdfdcbb7a 100644 --- a/configure.ac +++ b/configure.ac @@ -186,19 +186,19 @@ then if test "$with_next_framework" ; then LDSHARED="$LDSHARED \$(LDLIBRARY)" fi ;; - *-*-linux*) LDSHARED="gcc -shared";; + *-*-linux*) LDSHARED="$CC -shared";; *-*-dgux*) LDSHARED="ld -G";; - *-*-freebsd3*) LDSHARED="gcc -shared";; + *-*-freebsd3*) LDSHARED="$CC -shared";; *-*-freebsd* | *-*-openbsd*) LDSHARED="ld -Bshareable";; *-*-netbsd*) if [[ "`$CC -dM -E - Date: Mon, 30 Apr 2018 19:42:54 +0100 Subject: [PATCH 0888/2031] Improve detection of Python's 2to3 tool Distributions seem to install it as 2to3-X.Y where the interpreter is installed as pythonX.Y --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bdfdcbb7a..0a90d39f5 100644 --- a/configure.ac +++ b/configure.ac @@ -904,7 +904,8 @@ fi AC_ARG_WITH(2to3, AS_HELP_STRING([--with-2to3=path], [Set location of Python 2to3 tool]), [PY2TO3BIN="$withval"], [PY2TO3BIN="yes"]) if test -n "$PYTHON3"; then if test "x$PY2TO3BIN" = xyes; then - AC_CHECK_PROGS(PY2TO3, 2to3) + py3to2=`echo $PYTHON3 | sed -e "s/python/2to3-/"` + AC_CHECK_PROGS(PY2TO3, $py3to2 2to3) else PY2TO3="$PY2TO3BIN" fi From ebd6558a30f9e7094fa8dd8e39e5a48834a28ccb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 18:55:42 +0100 Subject: [PATCH 0889/2031] __cplusplus macro usage tweak --- Lib/typemaps/fragments.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index aaf948c05..60292c350 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -102,7 +102,7 @@ /* isfinite() is a macro for C99 */ # if defined(isfinite) # define SWIG_isfinite(X) (isfinite(X)) -# elif defined __cplusplus && __cplusplus >= 201103L +# elif defined(__cplusplus) && __cplusplus >= 201103L /* Use a template so that this works whether isfinite() is std::isfinite() or * in the global namespace. The reality seems to vary between compiler * versions. From 35b792daed7bebaadd74c2f48a66c694fa4d70ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 18:57:46 +0100 Subject: [PATCH 0890/2031] test-suite support for C++17: exception specification throw removal --- Examples/test-suite/catches.i | 20 ++----- Examples/test-suite/cplusplus_throw.i | 22 ++------ Examples/test-suite/cpp11_final_override.i | 22 ++------ Examples/test-suite/cpp11_lambda_functions.i | 36 +++++-------- Examples/test-suite/csharp_exceptions.i | 45 ++++++---------- Examples/test-suite/default_args.i | 25 ++++----- Examples/test-suite/director_exception.i | 20 +++---- Examples/test-suite/exception_order.i | 22 ++------ Examples/test-suite/exception_partial_info.i | 22 ++------ Examples/test-suite/extern_throws.i | 22 ++------ Examples/test-suite/intermediary_classname.i | 22 +++----- .../java_director_exception_feature.i | 16 +++--- .../java_director_exception_feature_nspace.i | 14 ++--- Examples/test-suite/java_throws.i | 23 +++----- Examples/test-suite/li_std_except.i | 52 +++++++------------ Examples/test-suite/li_std_except_as_class.i | 22 ++------ Examples/test-suite/li_std_string.i | 32 +++--------- Examples/test-suite/li_std_wstring.i | 23 +++----- Examples/test-suite/primitive_types.i | 36 ++++++------- Examples/test-suite/python_builtin.i | 22 ++------ Examples/test-suite/threads_exception.i | 31 ++++------- Examples/test-suite/throw_exception.i | 40 +++++--------- Examples/test-suite/using_pointers.i | 20 ++----- 23 files changed, 190 insertions(+), 419 deletions(-) diff --git a/Examples/test-suite/catches.i b/Examples/test-suite/catches.i index 8456cc00b..d3402a303 100644 --- a/Examples/test-suite/catches.i +++ b/Examples/test-suite/catches.i @@ -1,13 +1,9 @@ %module catches +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %include // for throws(...) typemap @@ -27,7 +23,7 @@ void test_catches(int i) { throw ThreeException(); } } -void test_exception_specification(int i) throw(int, const char *, const ThreeException&) { +void test_exception_specification(int i) TESTCASE_THROW(int, const char *, const ThreeException&) { test_catches(i); } void test_catches_all(int i) { @@ -35,11 +31,3 @@ void test_catches_all(int i) { } %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/cplusplus_throw.i b/Examples/test-suite/cplusplus_throw.i index 112f9f3b5..4fba97f34 100644 --- a/Examples/test-suite/cplusplus_throw.i +++ b/Examples/test-suite/cplusplus_throw.i @@ -5,14 +5,10 @@ %module cplusplus_throw +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %nodefaultctor; @@ -24,17 +20,9 @@ class Foo { }; class Bar { public: void baz() const { }; - void foo() throw (Foo) { }; - void bazfoo() const throw (int) { }; + void foo() TESTCASE_THROW(Foo) { }; + void bazfoo() const TESTCASE_THROW(int) { }; }; %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/cpp11_final_override.i b/Examples/test-suite/cpp11_final_override.i index 3a0d963f0..1fa306cd5 100644 --- a/Examples/test-suite/cpp11_final_override.i +++ b/Examples/test-suite/cpp11_final_override.i @@ -6,14 +6,10 @@ %warnfilter(SWIGWARN_PARSE_KEYWORD) final; // 'final' is a java keyword, renaming to '_final' %warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override' +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %inline %{ @@ -43,8 +39,8 @@ struct Derived /*final*/ : Base { virtual void finaloverride2() override final {} virtual void finaloverride3() noexcept override final {} virtual void finaloverride4() const noexcept override final {} - virtual void finaloverride5() throw(int) override final {} - virtual void finaloverride6() const throw(int) override final {} + virtual void finaloverride5() TESTCASE_THROW(int) override final {} + virtual void finaloverride6() const TESTCASE_THROW(int) override final {} virtual ~Derived() override final {} }; void Derived::override2() const noexcept {} @@ -142,11 +138,3 @@ void DerivedNoVirtualStruct::ef() {} DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {} %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i index a12870ccd..c50839913 100644 --- a/Examples/test-suite/cpp11_lambda_functions.i +++ b/Examples/test-suite/cpp11_lambda_functions.i @@ -26,14 +26,10 @@ %warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::lambda19; %warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20; +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %inline %{ @@ -61,22 +57,22 @@ void fn() { } auto lambda6 = [] (int a, int b) mutable { return a + b; }; auto lambda7 = [] (int x, int y) -> int { return x+y; }; -auto lambda8 = [] (int x, int y) throw() -> int { return x+y; }; -auto lambda9 = [] (int x, int y) mutable throw() -> int { return x+y; }; -auto lambda10 = [] (int x, int y) throw(int) { return x+y; }; -auto lambda11 = [] (int x, int y) mutable throw(int) { return x+y; }; +auto lambda8 = [] (int x, int y) TESTCASE_THROW() -> int { return x+y; }; +auto lambda9 = [] (int x, int y) mutable TESTCASE_THROW() -> int { return x+y; }; +auto lambda10 = [] (int x, int y) TESTCASE_THROW(int) { return x+y; }; +auto lambda11 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; auto lambda12 = [] (int a, int b) { return a + b; }(1, 2); auto lambda13 = [] (int a, int b) mutable { return a + b; }(1, 2); -auto lambda14 = [] () throw () {}; -auto lambda15 = [] () mutable throw () {}; +auto lambda14 = [] () TESTCASE_THROW() {}; +auto lambda15 = [] () mutable TESTCASE_THROW() {}; auto lambda16 = [] { return thing; }; auto lambda17 = [] { return thing; }(); -constexpr auto lambda18 = [] (int x, int y) mutable throw(int) { return x+y; }; +constexpr auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space1 { - constexpr auto lambda19 = [] (int x, int y) mutable throw(int) { return x+y; }; + constexpr auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space2 { - constexpr auto lambda20 = [] (int x, int y) mutable throw(int) { return x+y; }; + constexpr auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; } } @@ -115,11 +111,3 @@ int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2); void lambda_init(int = ([=]{ return 0; })()); %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/csharp_exceptions.i b/Examples/test-suite/csharp_exceptions.i index 53e51eb09..639117b16 100644 --- a/Examples/test-suite/csharp_exceptions.i +++ b/Examples/test-suite/csharp_exceptions.i @@ -1,5 +1,11 @@ %module csharp_exceptions +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) +%} + %include %inline %{ @@ -36,25 +42,16 @@ } %inline %{ - -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - // %exception tests void ThrowByValue() { throw Ex("ThrowByValue"); } void ThrowByReference() { throw Ex("ThrowByReference"); } // %csnothrowexception void NoThrowException() { throw Ex("NoThrowException"); } // exception specifications -void ExceptionSpecificationValue() throw(Ex) { throw Ex("ExceptionSpecificationValue"); } -void ExceptionSpecificationReference() throw(Ex&) { throw Ex("ExceptionSpecificationReference"); } -void ExceptionSpecificationString() throw(const char *) { throw "ExceptionSpecificationString"; } -void ExceptionSpecificationInteger() throw(int) { throw 20; } +void ExceptionSpecificationValue() TESTCASE_THROW(Ex) { throw Ex("ExceptionSpecificationValue"); } +void ExceptionSpecificationReference() TESTCASE_THROW(Ex&) { throw Ex("ExceptionSpecificationReference"); } +void ExceptionSpecificationString() TESTCASE_THROW(const char *) { throw "ExceptionSpecificationString"; } +void ExceptionSpecificationInteger() TESTCASE_THROW(int) { throw 20; } %} // test exceptions in the default typemaps @@ -68,15 +65,15 @@ void NullValue(Ex e) {} // enums %inline %{ enum TestEnum {TestEnumItem}; -void ExceptionSpecificationEnumValue() throw(TestEnum) { throw TestEnumItem; } -void ExceptionSpecificationEnumReference() throw(TestEnum&) { throw TestEnumItem; } +void ExceptionSpecificationEnumValue() TESTCASE_THROW(TestEnum) { throw TestEnumItem; } +void ExceptionSpecificationEnumReference() TESTCASE_THROW(TestEnum&) { throw TestEnumItem; } %} // std::string %include %inline %{ -void ExceptionSpecificationStdStringValue() throw(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); } -void ExceptionSpecificationStdStringReference() throw(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); } +void ExceptionSpecificationStdStringValue() TESTCASE_THROW(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); } +void ExceptionSpecificationStdStringReference() TESTCASE_THROW(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); } void NullStdStringValue(std::string s) {} void NullStdStringReference(std::string &s) {} %} @@ -108,12 +105,8 @@ void MemoryLeakCheck() { %inline %{ struct constructor { constructor(std::string s) {} - constructor() throw(int) { throw 10; } + constructor() TESTCASE_THROW(int) { throw 10; } }; - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif %} // test exception pending in the csout typemaps @@ -244,11 +237,3 @@ struct ThrowsClass { void InnerExceptionTest() { throw Ex("My InnerException message"); } %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 2dc2bccc1..e6fe7a050 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -4,13 +4,14 @@ %{ #if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned #endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +%} + +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) %} %include @@ -203,18 +204,18 @@ // Default parameters with exception specifications %inline %{ -void exceptionspec(int a = -1) throw (int, const char*) { +void exceptionspec(int a = -1) TESTCASE_THROW(int, const char*) { if (a == -1) throw "ciao"; else throw a; } struct Except { - Except(bool throwException, int a = -1) throw (int) { + Except(bool throwException, int a = -1) TESTCASE_THROW(int) { if (throwException) throw a; } - void exspec(int a = 0) throw (int, const char*) { + void exspec(int a = 0) TESTCASE_THROW(int, const char*) { ::exceptionspec(a); } }; @@ -326,11 +327,3 @@ struct CDA { }; %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i index e25bfdcca..78bd715cd 100644 --- a/Examples/test-suite/director_exception.i +++ b/Examples/test-suite/director_exception.i @@ -3,18 +3,20 @@ %warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) return_const_char_star; %{ - +// throw is deprecated in C++11 and invalid in C++17 and later +#if defined(__cplusplus) && __cplusplus >= 201103L +#define throw(TYPES...) +#else +#define throw(TYPES...) throw(TYPES) #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 #endif +%} +%{ #include - // define dummy director exception classes to prevent spurious errors // in target languages that do not support directors. @@ -137,16 +139,16 @@ Foo *launder(Foo *f) { class Base { public: - virtual ~Base() throw () {} + virtual ~Base() throw() {} }; class Bar : public Base { public: - virtual std::string ping() throw (Exception1, Exception2&) { return "Bar::ping()"; } - virtual std::string pong() throw (Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); } - virtual std::string pang() throw () { return "Bar::pang()"; } + virtual std::string ping() throw(Exception1, Exception2&) { return "Bar::ping()"; } + virtual std::string pong() throw(Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); } + virtual std::string pang() throw() { return "Bar::pang()"; } }; // Class to allow regression testing SWIG/PHP not checking if an exception diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i index 194394332..87e87f896 100644 --- a/Examples/test-suite/exception_order.i +++ b/Examples/test-suite/exception_order.i @@ -12,14 +12,10 @@ %include "exception.i" +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} /* @@ -103,13 +99,13 @@ int efoovar; /* caught by the user's throw definition */ - int foo() throw(E1) + int foo() TESTCASE_THROW(E1) { throw E1(); return 0; } - int bar() throw(E2) + int bar() TESTCASE_THROW(E2) { throw E2(); return 0; @@ -151,11 +147,3 @@ bool is_python_builtin() { return false; } %template(ET_i) ET; %template(ET_d) ET; -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/exception_partial_info.i b/Examples/test-suite/exception_partial_info.i index e39ccb063..5d2ebfaf6 100644 --- a/Examples/test-suite/exception_partial_info.i +++ b/Examples/test-suite/exception_partial_info.i @@ -2,14 +2,10 @@ // This produced compilable code for Tcl, Python in 1.3.27, fails in 1.3.29 +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %{ @@ -40,8 +36,8 @@ class ex2 : public myException class Impl { public: - void f1() throw (myException) { ex1 e; throw e; } - void f2() throw (myException) { ex2 e; throw e; } + void f1() TESTCASE_THROW(myException) { ex1 e; throw e; } + void f2() TESTCASE_THROW(myException) { ex2 e; throw e; } }; %} @@ -53,11 +49,3 @@ class Impl #warning "UTL needs fixing for partial exception information" #endif -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/extern_throws.i b/Examples/test-suite/extern_throws.i index 81eeb64c2..082a346a2 100644 --- a/Examples/test-suite/extern_throws.i +++ b/Examples/test-suite/extern_throws.i @@ -1,30 +1,18 @@ %module extern_throws +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %inline %{ #include -extern int get() throw(std::exception); +extern int get() TESTCASE_THROW(std::exception); %} %{ -int get() throw(std::exception) { return 0; } +int get() TESTCASE_THROW(std::exception) { return 0; } %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i index 6e544f298..e0a4c97c1 100644 --- a/Examples/test-suite/intermediary_classname.i +++ b/Examples/test-suite/intermediary_classname.i @@ -4,6 +4,12 @@ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR); +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) +%} + // change the access to the intermediary class for testing purposes %pragma(java) jniclassclassmodifiers="public class"; %pragma(csharp) imclassclassmodifiers="public class"; @@ -41,14 +47,6 @@ template class vector { void testconst(const T x) { } }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - class Base { public: Base() : mVectInt(0) {} @@ -69,14 +67,8 @@ public: virtual Base& m1(Base &b) { return b; } virtual Base* m2(Base *b) { return b; } // virtual Base m3(Base b) { return b; } - void throwspec() throw (int, Base) {} + void throwspec() TESTCASE_THROW(int, Base) {} }; -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif %} %template(maxint) maximum; diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i index b5b9c3938..d9187a65d 100644 --- a/Examples/test-suite/java_director_exception_feature.i +++ b/Examples/test-suite/java_director_exception_feature.i @@ -4,14 +4,10 @@ %warnfilter(SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF) MyNS::Foo::directorthrows_warning; +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %include @@ -184,10 +180,10 @@ public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 - virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; + virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; - virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); } + virtual std::string directorthrows_warning(int excp) TESTCASE_THROW(double) { return std::string(); } }; // Make a bar from a foo, so a call to Java Bar @@ -196,7 +192,7 @@ public: class Bar { public: Bar(Foo* d) { delegate=d; } - virtual std::string ping(int excp) throw(int,MyNS::Exception2) + virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) { return delegate->ping(excp); } diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i index 9f542fd37..3f843147e 100644 --- a/Examples/test-suite/java_director_exception_feature_nspace.i +++ b/Examples/test-suite/java_director_exception_feature_nspace.i @@ -11,14 +11,10 @@ #define PACKAGESLASH "java_director_exception_feature_nspacePackage/" %} +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %include @@ -191,7 +187,7 @@ public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 - virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; + virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; }; @@ -202,7 +198,7 @@ public: class Bar { public: Bar(Foo* d) { delegate=d; } - virtual std::string ping(int excp) throw(int,MyNS::Exception2) + virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) { return delegate->ping(excp); } diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index bb5c6e48f..2e4d5c2ab 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -2,6 +2,12 @@ %module java_throws +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) +%} + // Exceptions are chosen at random but are ones which have to have a try catch block to compile %typemap(in, throws=" ClassNotFoundException") int num { $1 = (int)$input; @@ -39,22 +45,7 @@ short full_of_exceptions(int num) { return $null; } %inline %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - -bool throw_spec_function(int value) throw (int) { throw (int)0; } - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif +bool throw_spec_function(int value) TESTCASE_THROW(int) { throw (int)0; } %} %catches(int) catches_function(int value); diff --git a/Examples/test-suite/li_std_except.i b/Examples/test-suite/li_std_except.i index 8c96a11f8..fe621e3b4 100644 --- a/Examples/test-suite/li_std_except.i +++ b/Examples/test-suite/li_std_except.i @@ -2,17 +2,12 @@ %include +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} - %inline %{ struct E1 : public std::exception { @@ -23,32 +18,23 @@ }; struct Test { - int foo1() throw(std::bad_exception) { return 0; } - int foo2() throw(std::logic_error) { return 0; } - int foo3() throw(E1) { return 0; } - int foo4() throw(E2) { return 0; } + int foo1() TESTCASE_THROW(std::bad_exception) { return 0; } + int foo2() TESTCASE_THROW(std::logic_error) { return 0; } + int foo3() TESTCASE_THROW(E1) { return 0; } + int foo4() TESTCASE_THROW(E2) { return 0; } // all the STL exceptions... - void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); } - void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); } - void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); } - void throw_exception() throw(std::exception) { throw std::exception(); } - void throw_invalid_argument() throw(std::invalid_argument) { throw std::invalid_argument("oops"); } - void throw_length_error() throw(std::length_error) { throw std::length_error("oops"); } - void throw_logic_error() throw(std::logic_error) { throw std::logic_error("oops"); } - void throw_out_of_range() throw(std::out_of_range) { throw std::out_of_range("oops"); } - void throw_overflow_error() throw(std::overflow_error) { throw std::overflow_error("oops"); } - void throw_range_error() throw(std::range_error) { throw std::range_error("oops"); } - void throw_runtime_error() throw(std::runtime_error) { throw std::runtime_error("oops"); } - void throw_underflow_error() throw(std::underflow_error) { throw std::underflow_error("oops"); } + void throw_bad_cast() TESTCASE_THROW(std::bad_cast) { throw std::bad_cast(); } + void throw_bad_exception() TESTCASE_THROW(std::bad_exception) { throw std::bad_exception(); } + void throw_domain_error() TESTCASE_THROW(std::domain_error) { throw std::domain_error("oops"); } + void throw_exception() TESTCASE_THROW(std::exception) { throw std::exception(); } + void throw_invalid_argument() TESTCASE_THROW(std::invalid_argument) { throw std::invalid_argument("oops"); } + void throw_length_error() TESTCASE_THROW(std::length_error) { throw std::length_error("oops"); } + void throw_logic_error() TESTCASE_THROW(std::logic_error) { throw std::logic_error("oops"); } + void throw_out_of_range() TESTCASE_THROW(std::out_of_range) { throw std::out_of_range("oops"); } + void throw_overflow_error() TESTCASE_THROW(std::overflow_error) { throw std::overflow_error("oops"); } + void throw_range_error() TESTCASE_THROW(std::range_error) { throw std::range_error("oops"); } + void throw_runtime_error() TESTCASE_THROW(std::runtime_error) { throw std::runtime_error("oops"); } + void throw_underflow_error() TESTCASE_THROW(std::underflow_error) { throw std::underflow_error("oops"); } }; %} - -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i index 1b5dd6082..5055d013c 100644 --- a/Examples/test-suite/li_std_except_as_class.i +++ b/Examples/test-suite/li_std_except_as_class.i @@ -5,27 +5,23 @@ * if there were also functions throwing 'std::logic_error' and * 'std::exception' then the bug would not be fully replicated */ +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %{ #include #include -void test_domain_error() throw(std::domain_error) +void test_domain_error() TESTCASE_THROW(std::domain_error, int) { throw std::domain_error("std::domain_error"); } %} %include #define SWIG_STD_EXCEPTIONS_AS_CLASSES %include -void test_domain_error() throw(std::domain_error) +void test_domain_error() TESTCASE_THROW(std::domain_error, int) { throw std::domain_error("std::domain_error"); } %inline %{ @@ -36,11 +32,3 @@ bool is_python_builtin() { return false; } #endif %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i index 15042c464..280fe6f5a 100644 --- a/Examples/test-suite/li_std_string.i +++ b/Examples/test-suite/li_std_string.i @@ -6,17 +6,12 @@ %apply std::string& INOUT { std::string &inout } #endif +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} - %inline %{ std::string test_value(std::string x) { @@ -59,28 +54,23 @@ void test_reference_inout(std::string &inout) { inout += inout; } -void test_throw() throw(std::string){ +void test_throw() TESTCASE_THROW(std::string){ static std::string x = "test_throw message"; throw x; } -void test_const_reference_throw() throw(const std::string &){ +void test_const_reference_throw() TESTCASE_THROW(const std::string &){ static std::string x = "test_const_reference_throw message"; throw x; } -void test_pointer_throw() throw(std::string *) { +void test_pointer_throw() TESTCASE_THROW(std::string *) { throw new std::string("foo"); } -void test_const_pointer_throw() throw(const std::string *) { +void test_const_pointer_throw() TESTCASE_THROW(const std::string *) { throw new std::string("foo"); } - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif - %} /* Old way, now std::string is a %naturalvar by default @@ -162,11 +152,3 @@ public: } %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index fe1166be3..1bdeb9bf8 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -3,6 +3,12 @@ %include +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) +%} + %inline %{ struct A : std::wstring @@ -82,27 +88,12 @@ bool test_equal_abc(const std::wstring &s) { return L"abc" == s; } -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - -void test_throw() throw(std::wstring){ +void test_throw() TESTCASE_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 -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } #else diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i index c68b1fc8f..637934377 100644 --- a/Examples/test-suite/primitive_types.i +++ b/Examples/test-suite/primitive_types.i @@ -7,16 +7,6 @@ %rename(TestDir) TestDirector; #endif -%{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif -%} - // Ruby constant names #pragma SWIG nowarn=SWIGWARN_RUBY_WRONG_NAME @@ -263,14 +253,17 @@ macro(Param, pfx, paramc) macro(size_t, pfx, sizet) %enddef +%define catches_decl(type, pfx, name) + %catches(type) pfx##_##name(type x); +%enddef /* function passing by value */ %define val_decl(type, pfx, name) - type pfx##_##name(type x) throw (type) { return x; } + type pfx##_##name(type x) { return x; } %enddef /* function passing by ref */ %define ref_decl(type, pfx, name) - const type& pfx##_##name(const type& x) throw (type) { return x; } + const type& pfx##_##name(const type& x) { return x; } %enddef /* C++ constant declaration */ @@ -305,6 +298,11 @@ macro(size_t, pfx, sizet) %test_prim_types(sct_decl, sct) +%test_prim_types(catches_decl, val) +%test_prim_types(catches_decl, ref) +%test_prim_types(catches_decl, cct) +%test_prim_types(catches_decl, var) + %inline { %test_prim_types(val_decl, val) %test_prim_types(ref_decl, ref) @@ -456,12 +454,12 @@ macro(size_t, pfx, sizet) var_decl(namet, var, namet) - const char* val_namet(namet x) throw(namet) + const char* val_namet(namet x) { return x; } - const char* val_cnamet(const namet x) throw(namet) + const char* val_cnamet(const namet x) { return x; } @@ -469,7 +467,7 @@ macro(size_t, pfx, sizet) #if 0 /* I have no idea how to define a typemap for const namet&, where namet is a char[ANY] array */ - const namet& ref_namet(const namet& x) throw(namet) + const namet& ref_namet(const namet& x) { return x; } @@ -513,12 +511,12 @@ macro(size_t, pfx, sizet) var_namet[0]='h'; } - virtual const char* vval_namet(namet x) throw(namet) + virtual const char* vval_namet(namet x) { return x; } - virtual const char* vval_cnamet(const namet x) throw(namet) + virtual const char* vval_cnamet(const namet x) { return x; } @@ -526,7 +524,7 @@ macro(size_t, pfx, sizet) #if 0 /* I have no idea how to define a typemap for const namet&, where namet is a char[ANY] array */ - virtual const namet& vref_namet(const namet& x) throw(namet) + virtual const namet& vref_namet(const namet& x) { return x; } @@ -563,7 +561,7 @@ macro(size_t, pfx, sizet) %test_prim_types_ovr(ovr_decl, ovr) - virtual Test* vtest(Test* t) const throw (Test) + virtual Test* vtest(Test* t) const { return t; } diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i index 21cbda3e9..c8a755868 100644 --- a/Examples/test-suite/python_builtin.i +++ b/Examples/test-suite/python_builtin.i @@ -2,14 +2,10 @@ %module python_builtin +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %inline %{ @@ -196,13 +192,13 @@ void Dealloc2Destroyer(PyObject *v) { return size; } - int __getitem__(Py_ssize_t n) throw (std::out_of_range) { + int __getitem__(Py_ssize_t n) TESTCASE_THROW(std::out_of_range) { if (n >= (int)size) throw std::out_of_range("Index too large"); return numbers[n]; } - SimpleArray __getitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { + SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW(std::out_of_range, std::invalid_argument) { if (!PySlice_Check(slice)) throw std::invalid_argument("Slice object expected"); Py_ssize_t i, j, step; @@ -228,11 +224,3 @@ void Dealloc2Destroyer(PyObject *v) { }; %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i index a9865da3c..6d62a8b95 100644 --- a/Examples/test-suite/threads_exception.i +++ b/Examples/test-suite/threads_exception.i @@ -4,6 +4,12 @@ %module(threads="1") threads_exception +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) +%{ +#define TESTCASE_THROW(TYPES...) +%} + %{ struct A {}; %} @@ -11,14 +17,6 @@ struct A {}; %inline %{ #include -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - class Exc { public: Exc(int c, const char *m) { @@ -32,24 +30,24 @@ public: class Test { public: - int simple() throw(int) { + int simple() TESTCASE_THROW(int) { throw(37); return 1; } - int message() throw(const char *) { + int message() TESTCASE_THROW(const char *) { throw("I died."); return 1; } - int hosed() throw(Exc) { + int hosed() TESTCASE_THROW(Exc) { throw(Exc(42,"Hosed")); return 1; } - int unknown() throw(A*) { + int unknown() TESTCASE_THROW(A*) { static A a; throw &a; return 1; } - int multi(int x) throw(int, const char *, Exc) { + int multi(int x) TESTCASE_THROW(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); @@ -62,11 +60,4 @@ bool is_python_builtin() { return true; } #else bool is_python_builtin() { return false; } #endif - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif %} diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i index 777e55b9e..916208cce 100644 --- a/Examples/test-suite/throw_exception.i +++ b/Examples/test-suite/throw_exception.i @@ -1,13 +1,9 @@ %module throw_exception +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1; @@ -34,45 +30,45 @@ namespace Namespace { } class Foo { public: - void test_int() throw(int) { + void test_int() TESTCASE_THROW(int) { throw 37; } - void test_msg() throw(const char *) { + void test_msg() TESTCASE_THROW(const char *) { throw "Dead"; } - void test_cls() throw(CError) { + void test_cls() TESTCASE_THROW(CError) { throw CError(); } - void test_cls_ptr() throw(CError *) { + void test_cls_ptr() TESTCASE_THROW(CError *) { static CError StaticError; throw &StaticError; } - void test_cls_ref() throw(CError &) { + void test_cls_ref() TESTCASE_THROW(CError &) { static CError StaticError; throw StaticError; } - void test_cls_td() throw(Namespace::ErrorTypedef) { + void test_cls_td() TESTCASE_THROW(Namespace::ErrorTypedef) { throw CError(); } - void test_cls_ptr_td() throw(Namespace::ErrorPtr) { + void test_cls_ptr_td() TESTCASE_THROW(Namespace::ErrorPtr) { static CError StaticError; throw &StaticError; } - void test_cls_ref_td() throw(Namespace::ErrorRef) { + void test_cls_ref_td() TESTCASE_THROW(Namespace::ErrorRef) { static CError StaticError; throw StaticError; } - void test_array() throw(Namespace::IntArray) { + void test_array() TESTCASE_THROW(Namespace::IntArray) { static Namespace::IntArray array; for (int i=0; i<10; i++) { array[i] = i; } throw array; } - void test_enum() throw(Namespace::EnumTest) { + void test_enum() TESTCASE_THROW(Namespace::EnumTest) { throw Namespace::enum2; } - void test_multi(int x) throw(int, const char *, CError) { + void test_multi(int x) TESTCASE_THROW(int, const char *, CError) { if (x == 1) throw 37; if (x == 2) throw "Dead"; if (x == 3) throw CError(); @@ -81,11 +77,3 @@ public: %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} diff --git a/Examples/test-suite/using_pointers.i b/Examples/test-suite/using_pointers.i index 569acce25..8c7ff1702 100644 --- a/Examples/test-suite/using_pointers.i +++ b/Examples/test-suite/using_pointers.i @@ -4,14 +4,10 @@ %csmethodmodifiers x "public new" #endif +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW(TYPES...) throw(TYPES) %{ -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif +#define TESTCASE_THROW(TYPES...) %} %inline %{ @@ -20,7 +16,7 @@ int x; virtual ~Foo() { } virtual Foo* blah() { return this; } - virtual Foo* exception_spec(int what_to_throw) throw (int, const char *) { + virtual Foo* exception_spec(int what_to_throw) TESTCASE_THROW(int, const char *) { int num = 10; const char *str = "exception message"; if (what_to_throw == 1) throw num; @@ -38,11 +34,3 @@ %} -%{ -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif -%} From 63f7315c8ac504b5909b58101e06305aeeecafba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 19:10:50 +0100 Subject: [PATCH 0891/2031] test-suite support for C++17 (Java): exception specification throw removal --- .../java_director_exception_feature.i | 24 ++++++++++++------- .../java_director_exception_feature_nspace.i | 22 ++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i index d9187a65d..e4a06185e 100644 --- a/Examples/test-suite/java_director_exception_feature.i +++ b/Examples/test-suite/java_director_exception_feature.i @@ -4,12 +4,6 @@ %warnfilter(SWIGWARN_TYPEMAP_DIRECTORTHROWS_UNDEF) MyNS::Foo::directorthrows_warning; -// throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) -%{ -#define TESTCASE_THROW(TYPES...) -%} - %include // DEFINE exceptions in header section using std::runtime_error @@ -171,6 +165,18 @@ namespace MyNS { %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong; %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong; +%{ +// throw is deprecated in C++11 and invalid in C++17 and later +#if defined(__cplusplus) && __cplusplus >= 201103L +#define throw(TYPES...) +#else +#define throw(TYPES...) throw(TYPES) +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +#endif +%} + %inline %{ namespace MyNS { @@ -180,10 +186,10 @@ public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 - virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) = 0; + virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; - virtual std::string directorthrows_warning(int excp) TESTCASE_THROW(double) { return std::string(); } + virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); } }; // Make a bar from a foo, so a call to Java Bar @@ -192,7 +198,7 @@ public: class Bar { public: Bar(Foo* d) { delegate=d; } - virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) + virtual std::string ping(int excp) throw(int,MyNS::Exception2) { return delegate->ping(excp); } diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i index 3f843147e..a5f6a5315 100644 --- a/Examples/test-suite/java_director_exception_feature_nspace.i +++ b/Examples/test-suite/java_director_exception_feature_nspace.i @@ -11,12 +11,6 @@ #define PACKAGESLASH "java_director_exception_feature_nspacePackage/" %} -// throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) -%{ -#define TESTCASE_THROW(TYPES...) -%} - %include // DEFINE exceptions in header section using std::runtime_error @@ -178,6 +172,18 @@ namespace MyNS { %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Foo::pong; %catches(MyNS::Exception1,MyNS::Exception2,MyNS::Unexpected) MyNS::Bar::pong; +%{ +// throw is deprecated in C++11 and invalid in C++17 and later +#if defined(__cplusplus) && __cplusplus >= 201103L +#define throw(TYPES...) +#else +#define throw(TYPES...) throw(TYPES) +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +#endif +%} + %inline %{ namespace MyNS { @@ -187,7 +193,7 @@ public: virtual ~Foo() {} // ping java implementation throws a java Exception1 or an Exception2 if excp is 1 or 2. // pong java implementation throws Exception1,Exception2,Unexpected,NullPointerException for 1,2,3,4 - virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) = 0; + virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; }; @@ -198,7 +204,7 @@ public: class Bar { public: Bar(Foo* d) { delegate=d; } - virtual std::string ping(int excp) TESTCASE_THROW(int,MyNS::Exception2) + virtual std::string ping(int excp) throw(int,MyNS::Exception2) { return delegate->ping(excp); } From 4e0b2f1402217bb9ea864833c5bbdaad82450709 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 19:19:45 +0100 Subject: [PATCH 0892/2031] Cosmetic syntax tweak using throw in Octave directors --- Lib/octave/director.swg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/octave/director.swg b/Lib/octave/director.swg index 86ac3b004..bf71d18e8 100644 --- a/Lib/octave/director.swg +++ b/Lib/octave/director.swg @@ -51,7 +51,7 @@ namespace Swig { public: static void raise(const char *msg) { // ... todo - throw(DirectorException()); + throw DirectorException(); } static void raise(const octave_value &ov, const char *msg) { @@ -64,7 +64,7 @@ namespace Swig { public: static void raise(const char *msg) { // ... todo - throw(DirectorTypeMismatchException()); + throw DirectorTypeMismatchException(); } static void raise(const octave_value &ov, const char *msg) { @@ -77,7 +77,7 @@ namespace Swig { public: static void raise(const char *msg) { // ... todo - throw(DirectorPureVirtualException()); + throw DirectorPureVirtualException(); } static void raise(const octave_value &ov, const char *msg) { From c9a10eb7266e8c411541a00af2806e068850f58e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 19:20:42 +0100 Subject: [PATCH 0893/2031] Examples update to support C++17: exception specification throw removal --- Examples/javascript/exception/example.h | 25 +++++------------------ Examples/javascript/exception/example.i | 6 ++++++ Examples/lua/exception/example.h | 27 ++++++------------------- Examples/lua/exception/example.i | 6 ++++++ Examples/python/exception/example.h | 27 ++++++------------------- Examples/python/exception/example.i | 6 ++++++ Examples/python/exceptproxy/example.h | 18 +---------------- Examples/python/exceptproxy/example.i | 21 ++----------------- Examples/ruby/exceptproxy/example.h | 22 +------------------- Examples/ruby/exceptproxy/example.i | 1 + 10 files changed, 40 insertions(+), 119 deletions(-) diff --git a/Examples/javascript/exception/example.h b/Examples/javascript/exception/example.h index 1658ec770..bc744cda7 100644 --- a/Examples/javascript/exception/example.h +++ b/Examples/javascript/exception/example.h @@ -16,34 +16,26 @@ public: char msg[256]; }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - class Test { public: - int simple() throw(int) { + int simple() { throw(37); return 1; } - int message() throw(const char *) { + int message() { throw("I died."); return 1; } - int hosed() throw(Exc) { + int hosed() { throw(Exc(42,"Hosed")); return 1; } - int unknown() throw(A*) { + int unknown() { static A a; throw &a; return 1; } - int multi(int x) throw(int, const char *, Exc) { + int multi(int x) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); @@ -51,10 +43,3 @@ public: } }; -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - diff --git a/Examples/javascript/exception/example.i b/Examples/javascript/exception/example.i index 08672c3a8..ca1084452 100644 --- a/Examples/javascript/exception/example.i +++ b/Examples/javascript/exception/example.i @@ -7,6 +7,12 @@ %include "std_string.i" +%catches(int) Test::simple(); +%catches(const char *) Test::message(); +%catches(Exc) Test::hosed(); +%catches(A*) Test::unknown(); +%catches(int, const char *, Exc) Test::multi(int x); + /* Let's just grab the original header file here */ %include "example.h" diff --git a/Examples/lua/exception/example.h b/Examples/lua/exception/example.h index ea3b4fc63..bc744cda7 100644 --- a/Examples/lua/exception/example.h +++ b/Examples/lua/exception/example.h @@ -1,6 +1,6 @@ /* File : example.h */ -#include +#include #ifndef SWIG struct A { }; @@ -16,34 +16,26 @@ public: char msg[256]; }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - class Test { public: - int simple() throw(int) { + int simple() { throw(37); return 1; } - int message() throw(const char *) { + int message() { throw("I died."); return 1; } - int hosed() throw(Exc) { + int hosed() { throw(Exc(42,"Hosed")); return 1; } - int unknown() throw(A*) { + int unknown() { static A a; throw &a; return 1; } - int multi(int x) throw(int, const char *, Exc) { + int multi(int x) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); @@ -51,10 +43,3 @@ public: } }; -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - diff --git a/Examples/lua/exception/example.i b/Examples/lua/exception/example.i index 6187f8eff..a6b43837d 100644 --- a/Examples/lua/exception/example.i +++ b/Examples/lua/exception/example.i @@ -12,6 +12,12 @@ // note: only works if Exc is copyable %apply SWIGTYPE EXCEPTION_BY_VAL {Exc}; +%catches(int) Test::simple(); +%catches(const char *) Test::message(); +%catches(Exc) Test::hosed(); +%catches(A*) Test::unknown(); +%catches(int, const char *, Exc) Test::multi(int x); + /* Let's just grab the original header file here */ %include "example.h" diff --git a/Examples/python/exception/example.h b/Examples/python/exception/example.h index ea3b4fc63..bc744cda7 100644 --- a/Examples/python/exception/example.h +++ b/Examples/python/exception/example.h @@ -1,6 +1,6 @@ /* File : example.h */ -#include +#include #ifndef SWIG struct A { }; @@ -16,34 +16,26 @@ public: char msg[256]; }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - class Test { public: - int simple() throw(int) { + int simple() { throw(37); return 1; } - int message() throw(const char *) { + int message() { throw("I died."); return 1; } - int hosed() throw(Exc) { + int hosed() { throw(Exc(42,"Hosed")); return 1; } - int unknown() throw(A*) { + int unknown() { static A a; throw &a; return 1; } - int multi(int x) throw(int, const char *, Exc) { + int multi(int x) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); @@ -51,10 +43,3 @@ public: } }; -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - diff --git a/Examples/python/exception/example.i b/Examples/python/exception/example.i index 817c5221c..3a3a6548f 100644 --- a/Examples/python/exception/example.i +++ b/Examples/python/exception/example.i @@ -7,6 +7,12 @@ %include "std_string.i" +%catches(int) Test::simple(); +%catches(const char *) Test::message(); +%catches(Exc) Test::hosed(); +%catches(A*) Test::unknown(); +%catches(int, const char *, Exc) Test::multi(int x); + /* Let's just grab the original header file here */ %include "example.h" diff --git a/Examples/python/exceptproxy/example.h b/Examples/python/exceptproxy/example.h index 0c03873fc..3ee6d765d 100644 --- a/Examples/python/exceptproxy/example.h +++ b/Examples/python/exceptproxy/example.h @@ -8,14 +8,6 @@ class FullError { FullError(int m) : maxsize(m) { } }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - template class Queue { int maxsize; T *items; @@ -31,7 +23,7 @@ template class Queue { ~Queue() { delete [] items; } - void enqueue(T x) throw(FullError) { + void enqueue(T x) { if (nitems == maxsize) { throw FullError(maxsize); } @@ -51,11 +43,3 @@ template class Queue { } }; - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - diff --git a/Examples/python/exceptproxy/example.i b/Examples/python/exceptproxy/example.i index 0a46afbb6..f5f835149 100644 --- a/Examples/python/exceptproxy/example.i +++ b/Examples/python/exceptproxy/example.i @@ -20,29 +20,12 @@ the header file, the enqueue method throws FullError and the dequeue method throws EmptyError. Since we don't want to define an exception handler for everything, we - simply write a handler each method individually. + simply write a handler for each method individually. Note: the *::enqueue syntax means that we simply define the handler for any class with this method defined. */ -/* - First we need to 'disable' the default swig throw mechanism for the - FullError class. We do this by rethrowing the exception. - - Note that this is necessary since the class appears in a throw - declaration: - - - void enqueue(T x) throw(FullError); - - hence, swig recognizes it as an exception class and it will generate - the necessary code to catch it and rethrow it to the python side. - -*/ -%typemap(throws) FullError "(void)$1; throw;"; - - %exception *::enqueue { try { $action @@ -76,7 +59,7 @@ */ /* - Now, the EmpytError doesn't appear in a throw declaration, and hence + Now, the EmptyError doesn't appear in a throw declaration, and hence we need to 'mark' it as an exception class. In python, classes that are used as exception are 'special', and need to be wrapped as 'classic' ones. diff --git a/Examples/ruby/exceptproxy/example.h b/Examples/ruby/exceptproxy/example.h index c29a562db..3ee6d765d 100644 --- a/Examples/ruby/exceptproxy/example.h +++ b/Examples/ruby/exceptproxy/example.h @@ -8,14 +8,6 @@ class FullError { FullError(int m) : maxsize(m) { } }; -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated" // dynamic exception specifications are deprecated in C++11 -#endif - template class Queue { int maxsize; T *items; @@ -31,7 +23,7 @@ template class Queue { ~Queue() { delete [] items; } - void enqueue(T x) throw(FullError) { + void enqueue(T x) { if (nitems == maxsize) { throw FullError(maxsize); } @@ -51,15 +43,3 @@ template class Queue { } }; - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#if __GNUC__ >= 7 - #pragma GCC diagnostic pop -#endif - - - - - diff --git a/Examples/ruby/exceptproxy/example.i b/Examples/ruby/exceptproxy/example.i index 5094b7a60..8e00751b2 100644 --- a/Examples/ruby/exceptproxy/example.i +++ b/Examples/ruby/exceptproxy/example.i @@ -17,6 +17,7 @@ /* The EmpytError doesn't appear in a throw declaration, and hence we need to tell SWIG that the dequeue method throws it. This can now be done via the %catchs feature. */ +%catches(FullError) *::enqueue; %catches(EmptyError) *::dequeue(); From e6b3a88f8abc1fb2adc8b4e9fdfad90429591f4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 19:50:01 +0100 Subject: [PATCH 0894/2031] test-suite support for C++17: switch testing of the deprecated C++17 'register' keyword from C++ to C --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/register_par.i | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index eaf8d38cf..83f420a8a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -352,7 +352,6 @@ CPP_TEST_CASES += \ redefined_not \ refcount \ reference_global_vars \ - register_par \ rename1 \ rename2 \ rename3 \ @@ -672,6 +671,7 @@ C_TEST_CASES += \ preproc_defined \ preproc_include \ preproc_line_file \ + register_par \ ret_by_value \ simple_array \ sizeof_pointer \ diff --git a/Examples/test-suite/register_par.i b/Examples/test-suite/register_par.i index 030be4556..b4172c059 100644 --- a/Examples/test-suite/register_par.i +++ b/Examples/test-suite/register_par.i @@ -1,5 +1,9 @@ %module register_par +%{ +struct tree; +%} + // bug # 924413 %inline { void clear_tree_flags(register struct tree *tp, register int i) {} From e7d626d1b469a3baf40995bfbf4147912062a2ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 21:29:54 +0100 Subject: [PATCH 0895/2031] Remove use of 'register' in C source No noticable performance change using gcc x86-64 in Java and Python test-suites. --- Source/DOH/memory.c | 4 ++-- Source/DOH/string.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index b916870d7..e0e4c68bd 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -81,8 +81,8 @@ static void InitPools() { * ---------------------------------------------------------------------- */ int DohCheck(const DOH *ptr) { - register Pool *p = Pools; - register char *cptr = (char *) ptr; + Pool *p = Pools; + char *cptr = (char *) ptr; while (p) { if ((cptr >= p->pbeg) && (cptr < p->pend)) { #ifdef DOH_DEBUG_MEMORY_POOLS diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 490198dfa..94d2737fa 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -141,15 +141,15 @@ static int String_cmp(DOH *so1, DOH *so2) { static int String_equal(DOH *so1, DOH *so2) { String *s1 = (String *) ObjData(so1); String *s2 = (String *) ObjData(so2); - register int len = s1->len; + int len = s1->len; if (len != s2->len) { return 0; } else { - register char *c1 = s1->str; - register char *c2 = s2->str; + char *c1 = s1->str; + char *c2 = s2->str; #if 0 - register int mlen = len >> 2; - register int i = mlen; + int mlen = len >> 2; + int i = mlen; for (; i; --i) { if (*(c1++) != *(c2++)) return 0; @@ -180,11 +180,11 @@ static int String_hash(DOH *so) { if (s->hashkey >= 0) { return s->hashkey; } else { - register char *c = s->str; - register unsigned int len = s->len > 50 ? 50 : s->len; - register unsigned int h = 0; - register unsigned int mlen = len >> 2; - register unsigned int i = mlen; + char *c = s->str; + unsigned int len = s->len > 50 ? 50 : s->len; + unsigned int h = 0; + unsigned int mlen = len >> 2; + unsigned int i = mlen; for (; i; --i) { h = (h << 5) + *(c++); h = (h << 5) + *(c++); @@ -463,9 +463,9 @@ static int String_seek(DOH *so, long offset, int whence) { { #if 0 - register int sp = s->sp; - register char *tc = s->str; - register int len = s->len; + int sp = s->sp; + char *tc = s->str; + int len = s->len; while (sp != nsp) { int prev = sp + inc; if (prev >= 0 && prev <= len && tc[prev] == '\n') @@ -473,8 +473,8 @@ static int String_seek(DOH *so, long offset, int whence) { sp += inc; } #else - register int sp = s->sp; - register char *tc = s->str; + int sp = s->sp; + char *tc = s->str; if (inc > 0) { while (sp != nsp) { if (tc[++sp] == '\n') @@ -508,12 +508,12 @@ static long String_tell(DOH *so) { static int String_putc(DOH *so, int ch) { String *s = (String *) ObjData(so); - register int len = s->len; - register int sp = s->sp; + int len = s->len; + int sp = s->sp; s->hashkey = -1; if (sp >= len) { - register int maxsize = s->maxsize; - register char *tc = s->str; + int maxsize = s->maxsize; + char *tc = s->str; if (len > (maxsize - 2)) { maxsize *= 2; tc = (char *) DohRealloc(tc, maxsize); @@ -679,7 +679,7 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co int noquote = 0; char *c, *s, *t, *first; char *q, *q2; - register char *base; + char *base; int i; /* Figure out if anything gets replaced */ From 6cc6d21bd201a439c35c1dedba26dc1c3efd0b1e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 21:55:47 +0100 Subject: [PATCH 0896/2031] test-suite fix for c++17 and throw macro --- Examples/test-suite/director_exception.i | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i index 78bd715cd..8c2ccc61b 100644 --- a/Examples/test-suite/director_exception.i +++ b/Examples/test-suite/director_exception.i @@ -2,18 +2,6 @@ %warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) return_const_char_star; -%{ -// throw is deprecated in C++11 and invalid in C++17 and later -#if defined(__cplusplus) && __cplusplus >= 201103L -#define throw(TYPES...) -#else -#define throw(TYPES...) throw(TYPES) -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif -#endif -%} - %{ #include @@ -127,6 +115,18 @@ Foo *launder(Foo *f) { %feature("director") Bar; %feature("director") ReturnAllTypes; +%{ +// throw is deprecated in C++11 and invalid in C++17 and later +#if defined(__cplusplus) && __cplusplus >= 201103L +#define throw(TYPES...) +#else +#define throw(TYPES...) throw(TYPES) +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +#endif +%} + %inline %{ struct Exception1 { From 179b41067d76a4a1dc68bc00a789e0909a21320d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 22:35:31 +0100 Subject: [PATCH 0897/2031] Scilab array overbounds fix handling char type exceptions --- Lib/scilab/sciexception.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/scilab/sciexception.swg b/Lib/scilab/sciexception.swg index a5eb4c00f..1d653b314 100644 --- a/Lib/scilab/sciexception.swg +++ b/Lib/scilab/sciexception.swg @@ -43,7 +43,7 @@ } %typemap(throws, noblock=1) char, char& { - char obj[1]; + char obj[2]; sprintf(obj, "%c", (char)$1); SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor); } From 35c5a3a42a7875c6ac4f047b67017a59a35ba2d4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 May 2018 22:36:07 +0100 Subject: [PATCH 0898/2031] Scilab portability fixes - remove use of strdup --- Lib/scilab/scirun.swg | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index 961ac1c21..9c88df128 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -49,8 +49,13 @@ static char *SWIG_Scilab_GetFuncName(void) { static void SWIG_Scilab_SetFuncName(char *funcName) { if (SwigFuncName != NULL) { free(SwigFuncName); + SwigFuncName = NULL; + } + if (funcName) { + SwigFuncName = (char *)malloc(strlen(funcName) + 1); + if (SwigFuncName) + strcpy(SwigFuncName, funcName); } - SwigFuncName = strdup(funcName); } /* Api context management functions */ From 7ecf6a71b0c875880db49deba52d447ce262c054 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 May 2018 07:09:43 +0100 Subject: [PATCH 0899/2031] test-suite support for gcc-8 targeting C++11 and C++14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some code in this test case is actually only supported in c++17... cpp11_lambda_functions_wrap.cxx:275:87: error: the type ‘const’ of ‘constexpr’ variable ‘lambda18’ is not literal CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; ^ cpp11_lambda_functions_wrap.cxx:275:28: note: ‘’ is not literal because: CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; ^ cc1plus: note: ‘’ is a closure type, which is only literal in C++17 and later cpp11_lambda_functions_wrap.cxx:278:89: error: the type ‘const Space1::’ of ‘constexpr’ variable ‘Space1::lambda19’ is not literal CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; --- Examples/test-suite/cpp11_lambda_functions.i | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i index c50839913..eb368a626 100644 --- a/Examples/test-suite/cpp11_lambda_functions.i +++ b/Examples/test-suite/cpp11_lambda_functions.i @@ -67,12 +67,17 @@ auto lambda14 = [] () TESTCASE_THROW() {}; auto lambda15 = [] () mutable TESTCASE_THROW() {}; auto lambda16 = [] { return thing; }; auto lambda17 = [] { return thing; }(); -constexpr auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; +#if defined(SWIG) || (defined(__cplusplus) && __cplusplus >= 201703L) +#define CONSTEXPR constexpr +#else +#define CONSTEXPR +#endif +CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space1 { - constexpr auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; namespace Space2 { - constexpr auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; } } From 3e4b7269c0d8880f1c1dbed38320e1673470288a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 4 May 2018 19:40:18 +0100 Subject: [PATCH 0900/2031] Enhance SWIG_isfinite for older standards: C++03/C++98/C89 Fixes testcase overload_numeric with -std=c++98 (clang and gcc 6 and later) Issue #1239 --- Lib/typemaps/fragments.swg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 60292c350..e83f415c4 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -118,6 +118,12 @@ inline int SWIG_isfinite_func(T x) { return isfinite(x); } # define SWIG_isfinite(X) (SWIG_isfinite_func(X)) +# elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) +# define SWIG_isfinite(X) (__builtin_isfinite(X)) +# elif defined(__clang__) && defined(__has_builtin) +# if __has_builtin(__builtin_isfinite) +# define SWIG_isfinite(X) (__builtin_isfinite(X)) +# endif # elif defined(_MSC_VER) # define SWIG_isfinite(X) (_finite(X)) # elif defined(__sun) && defined(__SVR4) From 1c46662c39e5ed7c28473663728cce5264885d34 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 07:48:24 +0100 Subject: [PATCH 0901/2031] Enhance Travis testing to use gcc 8 and test C++17 and C17 --- .travis.yml | 14 +++++++++++++- Tools/travis-linux-install.sh | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 527658709..54ec4c3f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -297,6 +297,18 @@ matrix: env: SWIGLANG=python SWIG_CC=gcc-7 SWIG_CXX=g++-7 CPP14=1 sudo: required dist: trusty + - os: linux + env: SWIGLANG=csharp SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 + sudo: required + dist: trusty + - os: linux + env: SWIGLANG=java SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 + sudo: required + dist: trusty + - os: linux + env: SWIGLANG=python SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 PY3=3 VER=3.6 + sudo: required + dist: trusty - compiler: gcc os: osx env: SWIGLANG= @@ -363,7 +375,7 @@ install: - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi - - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++17 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++17; fi + - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++17 -Wall -Wextra" "CFLAGS=-std=c17 -Wall -Wextra") && export CSTD=c17 && export CPPSTD=c++17; fi - ls -la $(which $CC) - ls -la $(which $CXX) - $CC --version diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index e8a5e4c9c..d63b7c31a 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -17,6 +17,10 @@ elif [[ "$CC" == gcc-7 ]]; then travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test travis_retry sudo apt-get -qq update travis_retry sudo apt-get install -qq g++-7 +elif [[ "$CC" == gcc-8 ]]; then + travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test + travis_retry sudo apt-get -qq update + travis_retry sudo apt-get install -qq g++-8 fi travis_retry sudo apt-get -qq install libboost-dev From 196a965067ff677ad109ab84320e1a7aa69c77d1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 11:45:44 +0100 Subject: [PATCH 0902/2031] test-suite fixes for compilers that don't support vararg macros Split TESTCASE_THROW into multiple macros taking different number of arguments. Fixes Visual Studio compiler errors. --- Examples/test-suite/catches.i | 6 ++-- Examples/test-suite/cplusplus_throw.i | 8 ++--- Examples/test-suite/cpp11_final_override.i | 8 ++--- Examples/test-suite/cpp11_lambda_functions.i | 24 +++++++------ Examples/test-suite/csharp_exceptions.i | 22 ++++++------ Examples/test-suite/default_args.i | 12 ++++--- Examples/test-suite/exception_order.i | 14 ++++---- Examples/test-suite/exception_partial_info.i | 8 ++--- Examples/test-suite/extern_throws.i | 8 ++--- Examples/test-suite/intermediary_classname.i | 6 ++-- Examples/test-suite/java_throws.i | 6 ++-- Examples/test-suite/li_std_except.i | 36 ++++++++++---------- Examples/test-suite/li_std_except_as_class.i | 8 ++--- Examples/test-suite/li_std_string.i | 12 +++---- Examples/test-suite/li_std_wstring.i | 6 ++-- Examples/test-suite/python_builtin.i | 10 +++--- Examples/test-suite/threads_exception.i | 16 +++++---- Examples/test-suite/throw_exception.i | 28 ++++++++------- Examples/test-suite/using_pointers.i | 6 ++-- 19 files changed, 127 insertions(+), 117 deletions(-) diff --git a/Examples/test-suite/catches.i b/Examples/test-suite/catches.i index d3402a303..89cf43f8d 100644 --- a/Examples/test-suite/catches.i +++ b/Examples/test-suite/catches.i @@ -1,9 +1,9 @@ %module catches // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW3(T1, T2, T3) %} %include // for throws(...) typemap @@ -23,7 +23,7 @@ void test_catches(int i) { throw ThreeException(); } } -void test_exception_specification(int i) TESTCASE_THROW(int, const char *, const ThreeException&) { +void test_exception_specification(int i) TESTCASE_THROW3(int, const char *, const ThreeException&) { test_catches(i); } void test_catches_all(int i) { diff --git a/Examples/test-suite/cplusplus_throw.i b/Examples/test-suite/cplusplus_throw.i index 4fba97f34..72ae62938 100644 --- a/Examples/test-suite/cplusplus_throw.i +++ b/Examples/test-suite/cplusplus_throw.i @@ -6,9 +6,9 @@ %module cplusplus_throw // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %nodefaultctor; @@ -20,8 +20,8 @@ class Foo { }; class Bar { public: void baz() const { }; - void foo() TESTCASE_THROW(Foo) { }; - void bazfoo() const TESTCASE_THROW(int) { }; + void foo() TESTCASE_THROW1(Foo) { }; + void bazfoo() const TESTCASE_THROW1(int) { }; }; %} diff --git a/Examples/test-suite/cpp11_final_override.i b/Examples/test-suite/cpp11_final_override.i index 1fa306cd5..8d275b322 100644 --- a/Examples/test-suite/cpp11_final_override.i +++ b/Examples/test-suite/cpp11_final_override.i @@ -7,9 +7,9 @@ %warnfilter(SWIGWARN_PARSE_KEYWORD) override; // 'override' is a C# keyword, renaming to '_override' // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %inline %{ @@ -39,8 +39,8 @@ struct Derived /*final*/ : Base { virtual void finaloverride2() override final {} virtual void finaloverride3() noexcept override final {} virtual void finaloverride4() const noexcept override final {} - virtual void finaloverride5() TESTCASE_THROW(int) override final {} - virtual void finaloverride6() const TESTCASE_THROW(int) override final {} + virtual void finaloverride5() TESTCASE_THROW1(int) override final {} + virtual void finaloverride6() const TESTCASE_THROW1(int) override final {} virtual ~Derived() override final {} }; void Derived::override2() const noexcept {} diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i index eb368a626..fc02aadb2 100644 --- a/Examples/test-suite/cpp11_lambda_functions.i +++ b/Examples/test-suite/cpp11_lambda_functions.i @@ -27,9 +27,11 @@ %warnfilter(SWIGWARN_CPP11_LAMBDA) Space1::Space2::lambda20; // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW0() throw() +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW0() +#define TESTCASE_THROW1(T1) %} %inline %{ @@ -57,14 +59,14 @@ void fn() { } auto lambda6 = [] (int a, int b) mutable { return a + b; }; auto lambda7 = [] (int x, int y) -> int { return x+y; }; -auto lambda8 = [] (int x, int y) TESTCASE_THROW() -> int { return x+y; }; -auto lambda9 = [] (int x, int y) mutable TESTCASE_THROW() -> int { return x+y; }; -auto lambda10 = [] (int x, int y) TESTCASE_THROW(int) { return x+y; }; -auto lambda11 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; +auto lambda8 = [] (int x, int y) TESTCASE_THROW0() -> int { return x+y; }; +auto lambda9 = [] (int x, int y) mutable TESTCASE_THROW0() -> int { return x+y; }; +auto lambda10 = [] (int x, int y) TESTCASE_THROW1(int) { return x+y; }; +auto lambda11 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; }; auto lambda12 = [] (int a, int b) { return a + b; }(1, 2); auto lambda13 = [] (int a, int b) mutable { return a + b; }(1, 2); -auto lambda14 = [] () TESTCASE_THROW() {}; -auto lambda15 = [] () mutable TESTCASE_THROW() {}; +auto lambda14 = [] () TESTCASE_THROW0() {}; +auto lambda15 = [] () mutable TESTCASE_THROW0() {}; auto lambda16 = [] { return thing; }; auto lambda17 = [] { return thing; }(); #if defined(SWIG) || (defined(__cplusplus) && __cplusplus >= 201703L) @@ -72,12 +74,12 @@ auto lambda17 = [] { return thing; }(); #else #define CONSTEXPR #endif -CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; +CONSTEXPR auto lambda18 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; }; namespace Space1 { - CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda19 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; }; namespace Space2 { - CONSTEXPR auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW(int) { return x+y; }; + CONSTEXPR auto lambda20 = [] (int x, int y) mutable TESTCASE_THROW1(int) { return x+y; }; } } diff --git a/Examples/test-suite/csharp_exceptions.i b/Examples/test-suite/csharp_exceptions.i index 639117b16..71581480e 100644 --- a/Examples/test-suite/csharp_exceptions.i +++ b/Examples/test-suite/csharp_exceptions.i @@ -1,9 +1,9 @@ %module csharp_exceptions // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %include @@ -48,10 +48,10 @@ void ThrowByReference() { throw Ex("ThrowByRefer // %csnothrowexception void NoThrowException() { throw Ex("NoThrowException"); } // exception specifications -void ExceptionSpecificationValue() TESTCASE_THROW(Ex) { throw Ex("ExceptionSpecificationValue"); } -void ExceptionSpecificationReference() TESTCASE_THROW(Ex&) { throw Ex("ExceptionSpecificationReference"); } -void ExceptionSpecificationString() TESTCASE_THROW(const char *) { throw "ExceptionSpecificationString"; } -void ExceptionSpecificationInteger() TESTCASE_THROW(int) { throw 20; } +void ExceptionSpecificationValue() TESTCASE_THROW1(Ex) { throw Ex("ExceptionSpecificationValue"); } +void ExceptionSpecificationReference() TESTCASE_THROW1(Ex&) { throw Ex("ExceptionSpecificationReference"); } +void ExceptionSpecificationString() TESTCASE_THROW1(const char *) { throw "ExceptionSpecificationString"; } +void ExceptionSpecificationInteger() TESTCASE_THROW1(int) { throw 20; } %} // test exceptions in the default typemaps @@ -65,15 +65,15 @@ void NullValue(Ex e) {} // enums %inline %{ enum TestEnum {TestEnumItem}; -void ExceptionSpecificationEnumValue() TESTCASE_THROW(TestEnum) { throw TestEnumItem; } -void ExceptionSpecificationEnumReference() TESTCASE_THROW(TestEnum&) { throw TestEnumItem; } +void ExceptionSpecificationEnumValue() TESTCASE_THROW1(TestEnum) { throw TestEnumItem; } +void ExceptionSpecificationEnumReference() TESTCASE_THROW1(TestEnum&) { throw TestEnumItem; } %} // std::string %include %inline %{ -void ExceptionSpecificationStdStringValue() TESTCASE_THROW(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); } -void ExceptionSpecificationStdStringReference() TESTCASE_THROW(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); } +void ExceptionSpecificationStdStringValue() TESTCASE_THROW1(std::string) { throw std::string("ExceptionSpecificationStdStringValue"); } +void ExceptionSpecificationStdStringReference() TESTCASE_THROW1(const std::string&) { throw std::string("ExceptionSpecificationStdStringReference"); } void NullStdStringValue(std::string s) {} void NullStdStringReference(std::string &s) {} %} @@ -105,7 +105,7 @@ void MemoryLeakCheck() { %inline %{ struct constructor { constructor(std::string s) {} - constructor() TESTCASE_THROW(int) { throw 10; } + constructor() TESTCASE_THROW1(int) { throw 10; } }; %} diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index e6fe7a050..450a8c7bf 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -9,9 +9,11 @@ %} // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) +#define TESTCASE_THROW2(T1, T2) throw(T1, T2) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) +#define TESTCASE_THROW2(T1, T2) %} %include @@ -204,18 +206,18 @@ // Default parameters with exception specifications %inline %{ -void exceptionspec(int a = -1) TESTCASE_THROW(int, const char*) { +void exceptionspec(int a = -1) TESTCASE_THROW2(int, const char*) { if (a == -1) throw "ciao"; else throw a; } struct Except { - Except(bool throwException, int a = -1) TESTCASE_THROW(int) { + Except(bool throwException, int a = -1) TESTCASE_THROW1(int) { if (throwException) throw a; } - void exspec(int a = 0) TESTCASE_THROW(int, const char*) { + void exspec(int a = 0) TESTCASE_THROW2(int, const char*) { ::exceptionspec(a); } }; diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i index 87e87f896..e2411634b 100644 --- a/Examples/test-suite/exception_order.i +++ b/Examples/test-suite/exception_order.i @@ -13,9 +13,9 @@ %include "exception.i" // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} /* @@ -99,16 +99,16 @@ int efoovar; /* caught by the user's throw definition */ - int foo() TESTCASE_THROW(E1) + int foo() TESTCASE_THROW1(E1) { throw E1(); - return 0; + return 0; } - - int bar() TESTCASE_THROW(E2) + + int bar() TESTCASE_THROW1(E2) { throw E2(); - return 0; + return 0; } /* caught by %postexception */ diff --git a/Examples/test-suite/exception_partial_info.i b/Examples/test-suite/exception_partial_info.i index 5d2ebfaf6..3ac465cf6 100644 --- a/Examples/test-suite/exception_partial_info.i +++ b/Examples/test-suite/exception_partial_info.i @@ -3,9 +3,9 @@ // This produced compilable code for Tcl, Python in 1.3.27, fails in 1.3.29 // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %{ @@ -36,8 +36,8 @@ class ex2 : public myException class Impl { public: - void f1() TESTCASE_THROW(myException) { ex1 e; throw e; } - void f2() TESTCASE_THROW(myException) { ex2 e; throw e; } + void f1() TESTCASE_THROW1(myException) { ex1 e; throw e; } + void f2() TESTCASE_THROW1(myException) { ex2 e; throw e; } }; %} diff --git a/Examples/test-suite/extern_throws.i b/Examples/test-suite/extern_throws.i index 082a346a2..92ece4158 100644 --- a/Examples/test-suite/extern_throws.i +++ b/Examples/test-suite/extern_throws.i @@ -1,18 +1,18 @@ %module extern_throws // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %inline %{ #include -extern int get() TESTCASE_THROW(std::exception); +extern int get() TESTCASE_THROW1(std::exception); %} %{ -int get() TESTCASE_THROW(std::exception) { return 0; } +int get() TESTCASE_THROW1(std::exception) { return 0; } %} diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i index e0a4c97c1..585967ad4 100644 --- a/Examples/test-suite/intermediary_classname.i +++ b/Examples/test-suite/intermediary_classname.i @@ -5,9 +5,9 @@ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR); // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW2(T1, T2) throw(T1, T2) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW2(T1, T2) %} // change the access to the intermediary class for testing purposes @@ -67,7 +67,7 @@ public: virtual Base& m1(Base &b) { return b; } virtual Base* m2(Base *b) { return b; } // virtual Base m3(Base b) { return b; } - void throwspec() TESTCASE_THROW(int, Base) {} + void throwspec() TESTCASE_THROW2(int, Base) {} }; %} diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index 2e4d5c2ab..5dc353b6d 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -3,9 +3,9 @@ %module java_throws // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} // Exceptions are chosen at random but are ones which have to have a try catch block to compile @@ -45,7 +45,7 @@ short full_of_exceptions(int num) { return $null; } %inline %{ -bool throw_spec_function(int value) TESTCASE_THROW(int) { throw (int)0; } +bool throw_spec_function(int value) TESTCASE_THROW1(int) { throw (int)0; } %} %catches(int) catches_function(int value); diff --git a/Examples/test-suite/li_std_except.i b/Examples/test-suite/li_std_except.i index fe621e3b4..60bce999d 100644 --- a/Examples/test-suite/li_std_except.i +++ b/Examples/test-suite/li_std_except.i @@ -3,9 +3,9 @@ %include // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %inline %{ @@ -18,23 +18,23 @@ }; struct Test { - int foo1() TESTCASE_THROW(std::bad_exception) { return 0; } - int foo2() TESTCASE_THROW(std::logic_error) { return 0; } - int foo3() TESTCASE_THROW(E1) { return 0; } - int foo4() TESTCASE_THROW(E2) { return 0; } + int foo1() TESTCASE_THROW1(std::bad_exception) { return 0; } + int foo2() TESTCASE_THROW1(std::logic_error) { return 0; } + int foo3() TESTCASE_THROW1(E1) { return 0; } + int foo4() TESTCASE_THROW1(E2) { return 0; } // all the STL exceptions... - void throw_bad_cast() TESTCASE_THROW(std::bad_cast) { throw std::bad_cast(); } - void throw_bad_exception() TESTCASE_THROW(std::bad_exception) { throw std::bad_exception(); } - void throw_domain_error() TESTCASE_THROW(std::domain_error) { throw std::domain_error("oops"); } - void throw_exception() TESTCASE_THROW(std::exception) { throw std::exception(); } - void throw_invalid_argument() TESTCASE_THROW(std::invalid_argument) { throw std::invalid_argument("oops"); } - void throw_length_error() TESTCASE_THROW(std::length_error) { throw std::length_error("oops"); } - void throw_logic_error() TESTCASE_THROW(std::logic_error) { throw std::logic_error("oops"); } - void throw_out_of_range() TESTCASE_THROW(std::out_of_range) { throw std::out_of_range("oops"); } - void throw_overflow_error() TESTCASE_THROW(std::overflow_error) { throw std::overflow_error("oops"); } - void throw_range_error() TESTCASE_THROW(std::range_error) { throw std::range_error("oops"); } - void throw_runtime_error() TESTCASE_THROW(std::runtime_error) { throw std::runtime_error("oops"); } - void throw_underflow_error() TESTCASE_THROW(std::underflow_error) { throw std::underflow_error("oops"); } + void throw_bad_cast() TESTCASE_THROW1(std::bad_cast) { throw std::bad_cast(); } + void throw_bad_exception() TESTCASE_THROW1(std::bad_exception) { throw std::bad_exception(); } + void throw_domain_error() TESTCASE_THROW1(std::domain_error) { throw std::domain_error("oops"); } + void throw_exception() TESTCASE_THROW1(std::exception) { throw std::exception(); } + void throw_invalid_argument() TESTCASE_THROW1(std::invalid_argument) { throw std::invalid_argument("oops"); } + void throw_length_error() TESTCASE_THROW1(std::length_error) { throw std::length_error("oops"); } + void throw_logic_error() TESTCASE_THROW1(std::logic_error) { throw std::logic_error("oops"); } + void throw_out_of_range() TESTCASE_THROW1(std::out_of_range) { throw std::out_of_range("oops"); } + void throw_overflow_error() TESTCASE_THROW1(std::overflow_error) { throw std::overflow_error("oops"); } + void throw_range_error() TESTCASE_THROW1(std::range_error) { throw std::range_error("oops"); } + void throw_runtime_error() TESTCASE_THROW1(std::runtime_error) { throw std::runtime_error("oops"); } + void throw_underflow_error() TESTCASE_THROW1(std::underflow_error) { throw std::underflow_error("oops"); } }; %} diff --git a/Examples/test-suite/li_std_except_as_class.i b/Examples/test-suite/li_std_except_as_class.i index 5055d013c..3d9706c80 100644 --- a/Examples/test-suite/li_std_except_as_class.i +++ b/Examples/test-suite/li_std_except_as_class.i @@ -6,22 +6,22 @@ * 'std::exception' then the bug would not be fully replicated */ // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW2(T1, T2) throw(T1, T2) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW2(T1, T2) %} %{ #include #include -void test_domain_error() TESTCASE_THROW(std::domain_error, int) +void test_domain_error() TESTCASE_THROW2(std::domain_error, int) { throw std::domain_error("std::domain_error"); } %} %include #define SWIG_STD_EXCEPTIONS_AS_CLASSES %include -void test_domain_error() TESTCASE_THROW(std::domain_error, int) +void test_domain_error() TESTCASE_THROW2(std::domain_error, int) { throw std::domain_error("std::domain_error"); } %inline %{ diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i index 280fe6f5a..822368491 100644 --- a/Examples/test-suite/li_std_string.i +++ b/Examples/test-suite/li_std_string.i @@ -7,9 +7,9 @@ #endif // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %inline %{ @@ -54,21 +54,21 @@ void test_reference_inout(std::string &inout) { inout += inout; } -void test_throw() TESTCASE_THROW(std::string){ +void test_throw() TESTCASE_THROW1(std::string){ static std::string x = "test_throw message"; throw x; } -void test_const_reference_throw() TESTCASE_THROW(const std::string &){ +void test_const_reference_throw() TESTCASE_THROW1(const std::string &){ static std::string x = "test_const_reference_throw message"; throw x; } -void test_pointer_throw() TESTCASE_THROW(std::string *) { +void test_pointer_throw() TESTCASE_THROW1(std::string *) { throw new std::string("foo"); } -void test_const_pointer_throw() TESTCASE_THROW(const std::string *) { +void test_const_pointer_throw() TESTCASE_THROW1(const std::string *) { throw new std::string("foo"); } %} diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index 1bdeb9bf8..6c0929ae5 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -4,9 +4,9 @@ // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) %} %inline %{ @@ -88,7 +88,7 @@ bool test_equal_abc(const std::wstring &s) { return L"abc" == s; } -void test_throw() TESTCASE_THROW(std::wstring){ +void test_throw() TESTCASE_THROW1(std::wstring){ static std::wstring x = L"x"; throw x; diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i index c8a755868..c48867853 100644 --- a/Examples/test-suite/python_builtin.i +++ b/Examples/test-suite/python_builtin.i @@ -3,9 +3,11 @@ %module python_builtin // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) +#define TESTCASE_THROW2(T1, T2) throw(T1, T2) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) +#define TESTCASE_THROW2(T1, T2) %} %inline %{ @@ -192,13 +194,13 @@ void Dealloc2Destroyer(PyObject *v) { return size; } - int __getitem__(Py_ssize_t n) TESTCASE_THROW(std::out_of_range) { + int __getitem__(Py_ssize_t n) TESTCASE_THROW1(std::out_of_range) { if (n >= (int)size) throw std::out_of_range("Index too large"); return numbers[n]; } - SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW(std::out_of_range, std::invalid_argument) { + SimpleArray __getitem__(PySliceObject *slice) TESTCASE_THROW2(std::out_of_range, std::invalid_argument) { if (!PySlice_Check(slice)) throw std::invalid_argument("Slice object expected"); Py_ssize_t i, j, step; diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i index 6d62a8b95..4708633db 100644 --- a/Examples/test-suite/threads_exception.i +++ b/Examples/test-suite/threads_exception.i @@ -5,9 +5,11 @@ %module(threads="1") threads_exception // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) +#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) +#define TESTCASE_THROW3(T1, T2, T3) %} %{ @@ -30,24 +32,24 @@ public: class Test { public: - int simple() TESTCASE_THROW(int) { + int simple() TESTCASE_THROW1(int) { throw(37); return 1; } - int message() TESTCASE_THROW(const char *) { + int message() TESTCASE_THROW1(const char *) { throw("I died."); return 1; } - int hosed() TESTCASE_THROW(Exc) { + int hosed() TESTCASE_THROW1(Exc) { throw(Exc(42,"Hosed")); return 1; } - int unknown() TESTCASE_THROW(A*) { + int unknown() TESTCASE_THROW1(A*) { static A a; throw &a; return 1; } - int multi(int x) TESTCASE_THROW(int, const char *, Exc) { + int multi(int x) TESTCASE_THROW3(int, const char *, Exc) { if (x == 1) throw(37); if (x == 2) throw("Bleah!"); if (x == 3) throw(Exc(42,"No-go-diggy-die")); diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i index 916208cce..ed9288290 100644 --- a/Examples/test-suite/throw_exception.i +++ b/Examples/test-suite/throw_exception.i @@ -1,9 +1,11 @@ %module throw_exception // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW1(T1) throw(T1) +#define TESTCASE_THROW3(T1, T2, T3) throw(T1, T2, T3) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW1(T1) +#define TESTCASE_THROW3(T1, T2, T3) %} %warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1; @@ -30,45 +32,45 @@ namespace Namespace { } class Foo { public: - void test_int() TESTCASE_THROW(int) { + void test_int() TESTCASE_THROW1(int) { throw 37; } - void test_msg() TESTCASE_THROW(const char *) { + void test_msg() TESTCASE_THROW1(const char *) { throw "Dead"; } - void test_cls() TESTCASE_THROW(CError) { + void test_cls() TESTCASE_THROW1(CError) { throw CError(); } - void test_cls_ptr() TESTCASE_THROW(CError *) { + void test_cls_ptr() TESTCASE_THROW1(CError *) { static CError StaticError; throw &StaticError; } - void test_cls_ref() TESTCASE_THROW(CError &) { + void test_cls_ref() TESTCASE_THROW1(CError &) { static CError StaticError; throw StaticError; } - void test_cls_td() TESTCASE_THROW(Namespace::ErrorTypedef) { + void test_cls_td() TESTCASE_THROW1(Namespace::ErrorTypedef) { throw CError(); } - void test_cls_ptr_td() TESTCASE_THROW(Namespace::ErrorPtr) { + void test_cls_ptr_td() TESTCASE_THROW1(Namespace::ErrorPtr) { static CError StaticError; throw &StaticError; } - void test_cls_ref_td() TESTCASE_THROW(Namespace::ErrorRef) { + void test_cls_ref_td() TESTCASE_THROW1(Namespace::ErrorRef) { static CError StaticError; throw StaticError; } - void test_array() TESTCASE_THROW(Namespace::IntArray) { + void test_array() TESTCASE_THROW1(Namespace::IntArray) { static Namespace::IntArray array; for (int i=0; i<10; i++) { array[i] = i; } throw array; } - void test_enum() TESTCASE_THROW(Namespace::EnumTest) { + void test_enum() TESTCASE_THROW1(Namespace::EnumTest) { throw Namespace::enum2; } - void test_multi(int x) TESTCASE_THROW(int, const char *, CError) { + void test_multi(int x) TESTCASE_THROW3(int, const char *, CError) { if (x == 1) throw 37; if (x == 2) throw "Dead"; if (x == 3) throw CError(); diff --git a/Examples/test-suite/using_pointers.i b/Examples/test-suite/using_pointers.i index 8c7ff1702..1a3824afa 100644 --- a/Examples/test-suite/using_pointers.i +++ b/Examples/test-suite/using_pointers.i @@ -5,9 +5,9 @@ #endif // throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW(TYPES...) throw(TYPES) +#define TESTCASE_THROW2(T1, T2) throw(T1, T2) %{ -#define TESTCASE_THROW(TYPES...) +#define TESTCASE_THROW2(T1, T2) %} %inline %{ @@ -16,7 +16,7 @@ int x; virtual ~Foo() { } virtual Foo* blah() { return this; } - virtual Foo* exception_spec(int what_to_throw) TESTCASE_THROW(int, const char *) { + virtual Foo* exception_spec(int what_to_throw) TESTCASE_THROW2(int, const char *) { int num = 10; const char *str = "exception message"; if (what_to_throw == 1) throw num; From 9fb996b83f39244c6d6ce038f84c05bb90d817e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 12:19:26 +0100 Subject: [PATCH 0903/2031] Consistent spacing in generated exception specifications --- Source/Modules/csharp.cxx | 4 ++-- Source/Modules/d.cxx | 4 ++-- Source/Modules/java.cxx | 4 ++-- Source/Modules/lang.cxx | 4 ++-- Source/Modules/perl5.cxx | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 78d494fb7..854872917 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4398,8 +4398,8 @@ public: Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname); Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname); } else if (Getattr(n, "throw")) { - Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); - Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); + Printf(f_directors_h, " virtual ~%s() throw();\n", dirclassname); + Printf(w->def, "%s::~%s() throw() {\n", dirclassname, dirclassname); } else { Printf(f_directors_h, " virtual ~%s();\n", dirclassname); Printf(w->def, "%s::~%s() {\n", dirclassname, dirclassname); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 451f449a1..1837228d4 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2497,8 +2497,8 @@ public: Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirclassname); Printf(w->def, "%s::~%s() noexcept {\n", dirclassname, dirclassname); } else if (Getattr(n, "throw")) { - Printf(f_directors_h, " virtual ~%s() throw ();\n", dirclassname); - Printf(w->def, "%s::~%s() throw () {\n", dirclassname, dirclassname); + Printf(f_directors_h, " virtual ~%s() throw();\n", dirclassname); + Printf(w->def, "%s::~%s() throw() {\n", dirclassname, dirclassname); } else { Printf(f_directors_h, " virtual ~%s();\n", dirclassname); Printf(w->def, "%s::~%s() {\n", dirclassname, dirclassname); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0f4b13186..9ff8299c0 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4658,8 +4658,8 @@ public: Printf(f_directors_h, " virtual ~%s() noexcept;\n", dirClassName); Printf(w->def, "%s::~%s() noexcept {\n", dirClassName, dirClassName); } else if (Getattr(n, "throw")) { - Printf(f_directors_h, " virtual ~%s() throw ();\n", dirClassName); - Printf(w->def, "%s::~%s() throw () {\n", dirClassName, dirClassName); + Printf(f_directors_h, " virtual ~%s() throw();\n", dirClassName); + Printf(w->def, "%s::~%s() throw() {\n", dirClassName, dirClassName); } else { Printf(f_directors_h, " virtual ~%s();\n", dirClassName); Printf(w->def, "%s::~%s() {\n", dirClassName, dirClassName); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 3464d2327..42005ed3f 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2151,8 +2151,8 @@ int Language::classDirectorDestructor(Node *n) { File *f_directors = Swig_filebyname("director"); File *f_directors_h = Swig_filebyname("director_h"); if (Getattr(n, "throw")) { - Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName); - Printf(f_directors, "%s::~%s() throw () {\n}\n\n", DirectorClassName, DirectorClassName); + Printf(f_directors_h, " virtual ~%s() throw();\n", DirectorClassName); + Printf(f_directors, "%s::~%s() throw() {\n}\n\n", DirectorClassName, DirectorClassName); } else { Printf(f_directors_h, " virtual ~%s();\n", DirectorClassName); Printf(f_directors, "%s::~%s() {\n}\n\n", DirectorClassName, DirectorClassName); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index be586b4db..81fb32121 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2512,8 +2512,8 @@ public: Printf(f_directors_h, " virtual ~%s() noexcept;\n", DirectorClassName); Printf(f_directors, "%s::~%s() noexcept {%s}\n\n", DirectorClassName, DirectorClassName, body); } else if (Getattr(n, "throw")) { - Printf(f_directors_h, " virtual ~%s() throw ();\n", DirectorClassName); - Printf(f_directors, "%s::~%s() throw () {%s}\n\n", DirectorClassName, DirectorClassName, body); + Printf(f_directors_h, " virtual ~%s() throw();\n", DirectorClassName); + Printf(f_directors, "%s::~%s() throw() {%s}\n\n", DirectorClassName, DirectorClassName, body); } else { Printf(f_directors_h, " virtual ~%s();\n", DirectorClassName); Printf(f_directors, "%s::~%s() {%s}\n\n", DirectorClassName, DirectorClassName, body); From 50cb18087d2dffaf5283998b5ba8ab0cbabc8b70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 14:43:56 +0100 Subject: [PATCH 0904/2031] test-suite fixes (2) for compilers that don't support varargs Split director_exception testcase into two so that testing throw(), with no arguments, that is nothrows, can be tested separately to throw() taking arguments. [The throw keyword needs to be removed for C++ compilation in C++11 and later when it was deprecated.] --- Examples/test-suite/common.mk | 1 + Examples/test-suite/director_exception.i | 9 +++--- .../test-suite/director_exception_nothrow.i | 28 +++++++++++++++++++ .../php/director_exception_runme.php | 2 +- .../php5/director_exception_runme.php | 2 +- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/director_exception_nothrow.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 83f420a8a..d75d3242e 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -183,6 +183,7 @@ CPP_TEST_CASES += \ director_enum \ director_exception \ director_exception_catches \ + director_exception_nothrow \ director_extend \ director_finalizer \ director_frob \ diff --git a/Examples/test-suite/director_exception.i b/Examples/test-suite/director_exception.i index 8c2ccc61b..71366bef0 100644 --- a/Examples/test-suite/director_exception.i +++ b/Examples/test-suite/director_exception.i @@ -118,9 +118,9 @@ Foo *launder(Foo *f) { %{ // throw is deprecated in C++11 and invalid in C++17 and later #if defined(__cplusplus) && __cplusplus >= 201103L -#define throw(TYPES...) +#define throw(TYPE1, TYPE2, TYPE3) #else -#define throw(TYPES...) throw(TYPES) +#define throw(TYPE1, TYPE2, TYPE3) throw(TYPE1, TYPE2, TYPE3) #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif @@ -139,16 +139,15 @@ Foo *launder(Foo *f) { class Base { public: - virtual ~Base() throw() {} + virtual ~Base() {} }; class Bar : public Base { public: - virtual std::string ping() throw(Exception1, Exception2&) { return "Bar::ping()"; } + virtual std::string ping() throw(Exception1, Exception2&, double) { return "Bar::ping()"; } virtual std::string pong() throw(Unknown1, int, Unknown2&) { return "Bar::pong();" + ping(); } - virtual std::string pang() throw() { return "Bar::pang()"; } }; // Class to allow regression testing SWIG/PHP not checking if an exception diff --git a/Examples/test-suite/director_exception_nothrow.i b/Examples/test-suite/director_exception_nothrow.i new file mode 100644 index 000000000..8a072617f --- /dev/null +++ b/Examples/test-suite/director_exception_nothrow.i @@ -0,0 +1,28 @@ +%module(directors="1") director_exception_nothrow + +%include "std_string.i" + +%feature("director") Bar; + +%{ +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif +%} + +%inline %{ +#include + +class Base +{ +public: + virtual ~Base() throw() {} +}; + + +class Bar : public Base +{ +public: + virtual std::string pang() throw() { return "Bar::pang()"; } +}; +%} diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php index 8b852c2ce..47f645b07 100644 --- a/Examples/test-suite/php/director_exception_runme.php +++ b/Examples/test-suite/php/director_exception_runme.php @@ -4,7 +4,7 @@ require "tests.php"; require "director_exception.php"; // No new functions -check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin)); +check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin)); // No new classes check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes)); // now new vars diff --git a/Examples/test-suite/php5/director_exception_runme.php b/Examples/test-suite/php5/director_exception_runme.php index 8b852c2ce..47f645b07 100644 --- a/Examples/test-suite/php5/director_exception_runme.php +++ b/Examples/test-suite/php5/director_exception_runme.php @@ -4,7 +4,7 @@ require "tests.php"; require "director_exception.php"; // No new functions -check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin)); +check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin)); // No new classes check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes)); // now new vars From bea708c796a41b66793c0ae8c183fa2684c89677 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 14:48:32 +0100 Subject: [PATCH 0905/2031] Go - use director.swg like other languages Changes the location of the director code wrt to the generated _wrap.h file to fix throw macro skullduggery in the director_throws testcase (see previous commit). --- Lib/go/director.swg | 65 +++++++++++++++++++++++++++++++++++++++++ Lib/go/goruntime.swg | 69 -------------------------------------------- 2 files changed, 65 insertions(+), 69 deletions(-) diff --git a/Lib/go/director.swg b/Lib/go/director.swg index 69244ebea..103ba22a3 100644 --- a/Lib/go/director.swg +++ b/Lib/go/director.swg @@ -6,6 +6,7 @@ * ----------------------------------------------------------------------------- */ #include +#include namespace Swig { @@ -13,3 +14,67 @@ namespace Swig { }; } +/* Handle memory management for directors. */ + +namespace { + struct GCItem { + virtual ~GCItem() {} + }; + + struct GCItem_var { + GCItem_var(GCItem *item = 0) : _item(item) { + } + + GCItem_var& operator=(GCItem *item) { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() { + delete _item; + } + + GCItem* operator->() { + return _item; + } + + private: + GCItem *_item; + }; + + template + struct GCItem_T : GCItem { + GCItem_T(Type *ptr) : _ptr(ptr) { + } + + virtual ~GCItem_T() { + delete _ptr; + } + + private: + Type *_ptr; + }; +} + +class Swig_memory { +public: + template + void swig_acquire_pointer(Type* vptr) { + if (vptr) { + swig_owner[vptr] = new GCItem_T(vptr); + } + } +private: + typedef std::map swig_ownership_map; + swig_ownership_map swig_owner; +}; + +template +static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) { + if (!pmem) { + *pmem = new Swig_memory; + } + (*pmem)->swig_acquire_pointer(ptr); +} diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg index dc6193d04..269a4eefd 100644 --- a/Lib/go/goruntime.swg +++ b/Lib/go/goruntime.swg @@ -346,75 +346,6 @@ type _swig_fnptr *byte type _swig_memberptr *byte %} -/* Handle memory management for directors. */ - -%insert(director) %{ -#include - -namespace { - struct GCItem { - virtual ~GCItem() {} - }; - - struct GCItem_var { - GCItem_var(GCItem *item = 0) : _item(item) { - } - - GCItem_var& operator=(GCItem *item) { - GCItem *tmp = _item; - _item = item; - delete tmp; - return *this; - } - - ~GCItem_var() { - delete _item; - } - - GCItem* operator->() { - return _item; - } - - private: - GCItem *_item; - }; - - template - struct GCItem_T : GCItem { - GCItem_T(Type *ptr) : _ptr(ptr) { - } - - virtual ~GCItem_T() { - delete _ptr; - } - - private: - Type *_ptr; - }; -} - -class Swig_memory { -public: - template - void swig_acquire_pointer(Type* vptr) { - if (vptr) { - swig_owner[vptr] = new GCItem_T(vptr); - } - } -private: - typedef std::map swig_ownership_map; - swig_ownership_map swig_owner; -}; - -template -static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) { - if (!pmem) { - *pmem = new Swig_memory; - } - (*pmem)->swig_acquire_pointer(ptr); -} -%} - /* For directors we need C++ to track a Go pointer. Since we can't pass a Go pointer into C++, we use a map to track the pointers on the Go side. */ From 8555973a48b3f5e80610483e9aba13436f2a0c0d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 May 2018 15:35:46 +0100 Subject: [PATCH 0906/2031] test-suite fixes (Java directors) for compilers that don't support varargs --- Examples/test-suite/java_director_exception_feature.i | 6 +++--- .../test-suite/java_director_exception_feature_nspace.i | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/java_director_exception_feature.i b/Examples/test-suite/java_director_exception_feature.i index e4a06185e..7978ac2a1 100644 --- a/Examples/test-suite/java_director_exception_feature.i +++ b/Examples/test-suite/java_director_exception_feature.i @@ -168,9 +168,9 @@ namespace MyNS { %{ // throw is deprecated in C++11 and invalid in C++17 and later #if defined(__cplusplus) && __cplusplus >= 201103L -#define throw(TYPES...) +#define throw(TYPE1, TYPE2) #else -#define throw(TYPES...) throw(TYPES) +#define throw(TYPE1, TYPE2) throw(TYPE1, TYPE2) #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif @@ -189,7 +189,7 @@ public: virtual std::string ping(int excp) throw(int,MyNS::Exception2) = 0; virtual std::string pong(int excp) /* throws MyNS::Exception1 MyNS::Exception2 MyNS::Unexpected) */ = 0; virtual std::string genericpong(int excp) /* unspecified throws - exception is always DirectorException in C++, translated back to whatever thrown in java */ = 0; - virtual std::string directorthrows_warning(int excp) throw(double) { return std::string(); } + virtual std::string directorthrows_warning(int excp) throw(int,double) { return std::string(); } }; // Make a bar from a foo, so a call to Java Bar diff --git a/Examples/test-suite/java_director_exception_feature_nspace.i b/Examples/test-suite/java_director_exception_feature_nspace.i index a5f6a5315..b52c1acf4 100644 --- a/Examples/test-suite/java_director_exception_feature_nspace.i +++ b/Examples/test-suite/java_director_exception_feature_nspace.i @@ -175,9 +175,9 @@ namespace MyNS { %{ // throw is deprecated in C++11 and invalid in C++17 and later #if defined(__cplusplus) && __cplusplus >= 201103L -#define throw(TYPES...) +#define throw(TYPE1, TYPE2) #else -#define throw(TYPES...) throw(TYPES) +#define throw(TYPE1, TYPE2) throw(TYPE1, TYPE2) #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif From 6551d0feadc6e5d7820c18939d8d06890c1688e8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 6 May 2018 09:34:30 +0100 Subject: [PATCH 0907/2031] Java vector wrappers cast correction 64 bit windows, fixes: warning C4267: 'initializing': conversion from 'size_t' to 'jint' --- Lib/java/std_vector.i | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 57368c81a..cb1752c69 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -114,7 +114,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } void doAdd(jint index, const value_type& value) throw (std::out_of_range) { - const jint size = static_cast::size_type>(self->size()); + jint size = static_cast(self->size()); if (0 <= index && index <= size) { self->insert(self->begin() + index, value); } else { @@ -123,7 +123,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } value_type doRemove(jint index) throw (std::out_of_range) { - const jint size = static_cast::size_type>(self->size()); + jint size = static_cast(self->size()); if (0 <= index && index < size) { CTYPE const old_value = (*self)[index]; self->erase(self->begin() + index); @@ -134,7 +134,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } CREF_TYPE doGet(jint index) throw (std::out_of_range) { - const jint size = static_cast::size_type>(self->size()); + jint size = static_cast(self->size()); if (index >= 0 && index < size) return (*self)[index]; else @@ -142,7 +142,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } value_type doSet(jint index, const value_type& value) throw (std::out_of_range) { - const jint size = static_cast::size_type>(self->size()); + jint size = static_cast(self->size()); if (index >= 0 && index < size) { CTYPE const old_value = (*self)[index]; (*self)[index] = value; @@ -153,7 +153,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } void doRemoveRange(jint fromIndex, jint toIndex) throw (std::out_of_range) { - const jint size = static_cast::size_type>(self->size()); + jint size = static_cast(self->size()); if (0 <= fromIndex && fromIndex <= toIndex && toIndex <= size) { self->erase(self->begin() + fromIndex, self->begin() + toIndex); } else { From 0d5719684fa4c41fcc88c9e8a13ad5eee2dc4034 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 6 May 2018 10:06:47 +0100 Subject: [PATCH 0908/2031] Appveyor cl compiler warning fixes during configure --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index e2f6a6b32..20d4fe9ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -90,7 +90,7 @@ install: - uname -a build_script: -- set CCCL_OPTIONS=--cccl-muffle /W3 +- set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Sun, 6 May 2018 21:36:44 +0100 Subject: [PATCH 0909/2031] Javascript assert.h - move to header section Fixes compile problem due to throw macro skullduggery in the director_throws testcase --- Lib/javascript/v8/javascriptinit.swg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg index 34befa7ce..50df7256e 100644 --- a/Lib/javascript/v8/javascriptinit.swg +++ b/Lib/javascript/v8/javascriptinit.swg @@ -1,6 +1,8 @@ -%insert(init) %{ - +%insert(header) %{ #include +%} + +%insert(init) %{ SWIGRUNTIME void SWIG_V8_SetModule(void *, swig_module_info *swig_module) { From ee17f8d04f40bfc25ecaf146a6ebe667eabcffb6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 May 2018 18:09:51 +0100 Subject: [PATCH 0910/2031] C#, D, Java methodmodifiers on destructors Add support so that the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers can modify the method modifiers for the destructor wrappers in the proxy class: dispose, Dispose, delete. With this feature, it is now possible to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers can be removed using: %typemap(csclassmodifiers) X "public sealed class" %csmethodmodifiers X::~X "public /*virtual*/"; --- CHANGES.current | 10 ++ Doc/Manual/CSharp.html | 99 ++++++++++++++++++- Doc/Manual/Contents.html | 3 +- Doc/Manual/Java.html | 4 + Examples/test-suite/common.mk | 1 + .../test-suite/destructor_methodmodifiers.i | 61 ++++++++++++ Source/Modules/csharp.cxx | 16 ++- Source/Modules/d.cxx | 15 ++- Source/Modules/java.cxx | 14 ++- 9 files changed, 210 insertions(+), 13 deletions(-) create mode 100644 Examples/test-suite/destructor_methodmodifiers.i diff --git a/CHANGES.current b/CHANGES.current index f15c99e90..0acfddc7d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,16 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-05-11: wsfulton + [C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers, + %javamethodmodifiers can modify the method modifiers for the destructor wrappers + in the proxy class: dispose, Dispose, delete. With this feature, it is now possible + to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers + can be removed using: + + %typemap(csclassmodifiers) X "public sealed class" + %csmethodmodifiers X::~X "public /*virtual*/"; + 2018-04-18: olly [Python] Suppress new pycodestyle warning: E252 missing whitespace around parameter equals diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 13b6e4997..e96940626 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -44,7 +44,8 @@
        • Date marshalling using the csin typemap and associated attributes
        • A date example demonstrating marshalling of C# properties
        • Date example demonstrating the 'pre' and 'post' typemap attributes for directors -
        • Turning wrapped classes into partial classes +
        • Turning proxy classes into partial classes +
        • Turning proxy classes into sealed classes
        • Extending proxy classes with additional C# code
        • Underlying type for enums
        @@ -2515,7 +2516,7 @@ Pay special attention to the memory management issues, using these attributes.

        -

        20.8.6 Turning wrapped classes into partial classes

        +

        20.8.6 Turning proxy classes into partial classes

        @@ -2615,7 +2616,97 @@ 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.

        -

        20.8.7 Extending proxy classes with additional C# code

        +

        20.8.7 Turning proxy classes into sealed classes

        + + +

        +The technique in the previous section can be used to make the proxy class a sealed class. +Consider a C++ class NotABaseClass that you don't want to be derived from in C#: +

        + +
        +
        +struct NotABaseClass {
        +  NotABaseClass();
        +  ~NotABaseClass();
        +};
        +
        +
        + +

        +The default C# proxy class method generated with Dispose method is: +

        + +
        +
        +public class NotABaseClass : global::System.IDisposable {
        +  ...
        +  public virtual void Dispose() {
        +    ...
        +  }
        +}
        +
        +
        + +

        +The csclassmodifiers typemap can be used to modify the class modifiers and +the csmethodmodifiers feature can be used on the destructor to modify the proxy's Dispose method: +

        + +
        +
        +%typemap(csclassmodifiers) NotABaseClass "public sealed class"
        +%csmethodmodifiers NotABaseClass::~NotABaseClass "public /*virtual*/";
        +
        +
        + +

        +The relevant generated code is thus: +

        + +
        +
        +public sealed class NotABaseClass : global::System.IDisposable {
        +  ...
        +  public /*virtual*/ void Dispose() {
        +    ...
        +  }
        +}
        +
        +
        + +

        +Any attempt to derive from the NotABaseClass in C# will result in a C# compiler error, for example: +

        + +
        +
        +public class Derived : NotABaseClass {
        +};
        +
        +
        +
        +
        +runme.cs(6,14): error CS0509: `Derived': cannot derive from sealed type `NotABaseClass'
        +
        +
        + +

        +Finally, if you get a warning about use of 'protected' in the generated base class: +

        + +
        +
        +NotABaseClass.cs(14,18): warning CS0628: `NotABaseClass.swigCMemOwn': new protected member declared in sealed class
        +
        +
        + +

        +Either suppress the warning or modify the generated code by copying and tweaking the default +'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected. +

        + +

        20.8.8 Extending proxy classes with additional C# code

        @@ -2654,7 +2745,7 @@ public class ExtendMe : global::System.IDisposable { -

        20.8.8 Underlying type for enums

        +

        20.8.9 Underlying type for enums

        diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5cc796c8d..f77823d20 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -787,7 +787,8 @@

      • Date marshalling using the csin typemap and associated attributes
      • A date example demonstrating marshalling of C# properties
      • Date example demonstrating the 'pre' and 'post' typemap attributes for directors -
      • Turning wrapped classes into partial classes +
      • Turning proxy classes into partial classes +
      • Turning proxy classes into sealed classes
      • Extending proxy classes with additional C# code
      • Underlying type for enums
      diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 3b6cb3a05..6b84d540f 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6560,6 +6560,8 @@ used for all proxy classes except those which have a base class
      Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute. +If a %javamethodmodifiers is attached to the class' destructor, +it will be used in preference to the methodmodifiers typemap attribute for the class.

      %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")

      @@ -6571,6 +6573,8 @@ same as "javadestruct" but only used for derived proxy classes
      Note that the delete() method name is configurable and is specified by the methodname attribute. The method modifiers are also configurable via the methodmodifiers attribute. +If a %javamethodmodifiers is attached to the class' destructor, +it will be used in preference to the methodmodifiers typemap attribute for the class.

      %typemap(javaimports)

      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index d75d3242e..72c49648b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -170,6 +170,7 @@ CPP_TEST_CASES += \ defvalue_constructor \ derived_byvalue \ derived_nested \ + destructor_methodmodifiers \ destructor_reprotected \ director_abstract \ director_alternating \ diff --git a/Examples/test-suite/destructor_methodmodifiers.i b/Examples/test-suite/destructor_methodmodifiers.i new file mode 100644 index 000000000..93db7f2cc --- /dev/null +++ b/Examples/test-suite/destructor_methodmodifiers.i @@ -0,0 +1,61 @@ +%module destructor_methodmodifiers + +// This test changes the proxy classes so that they cannot be inherited from in the target language +// Previously the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers on destructors were ignored +// Now they can control the dispose/Dispose/delete method modifiers + +#if defined(SWIGCSHARP) + +// remove all use of protected and virtual keywords +%typemap(csclassmodifiers) NotForDeriving1, NotForDeriving2 "public sealed class" +%csmethodmodifiers NotForDeriving1::~NotForDeriving1 "public /*not virtual nor override*/"; +%csmethodmodifiers NotForDeriving2::~NotForDeriving2 "public /*not virtual nor override*/"; + +// remove protected keyword to remove compiler warning +%typemap(csbody) NotForDeriving1, NotForDeriving2 %{ + private global::System.Runtime.InteropServices.HandleRef swigCPtr; + private /*protected*/ bool swigCMemOwn; + + internal $csclassname(global::System.IntPtr cPtr, bool cMemoryOwn) { + swigCMemOwn = cMemoryOwn; + swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + } + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } +%} + +#elif defined(SWIGD) + +%typemap(dclassmodifiers) NotForDeriving1, NotForDeriving2 "final class" +%dmethodmodifiers NotForDeriving1::~NotForDeriving1 "public final"; +%dmethodmodifiers NotForDeriving2::~NotForDeriving2 "public final"; + +#elif defined(SWIGJAVA) + +%typemap(javaclassmodifiers) NotForDeriving1, NotForDeriving2 "public final class" +%javamethodmodifiers NotForDeriving1::~NotForDeriving1 "public synchronized final"; +%javamethodmodifiers NotForDeriving2::~NotForDeriving2 "public synchronized final"; + +#endif + +%inline %{ +//#include +struct NotForDeriving1 { + void notvirtual() {} + ~NotForDeriving1() { +// std::cout << "~NotForDeriving1 called" << std::endl; + } +}; +struct NotForDeriving2 { + void notvirtual() {} +#if defined(SWIG) +%extend { + ~NotForDeriving2() { +// std::cout << "~NotForDeriving2 called" << std::endl; + } +} +#endif +}; +%} diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 854872917..8bd25aa48 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1910,9 +1910,15 @@ public: Replaceall(destruct, "$imcall", destructor_call); else Replaceall(destruct, "$imcall", "throw new global::System.MethodAccessException(\"C++ destructor does not have public access\")"); - if (*Char(destruct)) - Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n", - NIL); + if (*Char(destruct)) { + Printv(proxy_class_def, "\n ", NIL); + const String *methodmods = Getattr(n, "destructmethodmodifiers"); + if (methodmods) + Printv(proxy_class_def, methodmods, NIL); + else + Printv(proxy_class_def, destruct_methodmodifiers, " ", derived ? "override" : "virtual", NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "() ", destruct, "\n", NIL); + } } if (*Char(interface_upcasts)) Printv(proxy_class_def, interface_upcasts, NIL); @@ -2860,7 +2866,11 @@ public: if (proxy_flag) { Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); + const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); + if (methodmods) + Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods); } + return SWIG_OK; } diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 1837228d4..0c3f020a8 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -1298,7 +1298,12 @@ public: virtual int destructorHandler(Node *n) { Language::destructorHandler(n); String *symname = Getattr(n, "sym:name"); + Printv(destructor_call, im_dmodule_fq_name, ".", Swig_name_destroy(getNSpace(),symname), "(cast(void*)swigCPtr)", NIL); + const String *methodmods = Getattr(n, "feature:d:methodmodifiers"); + if (methodmods) + Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods); + return SWIG_OK; } @@ -3312,9 +3317,13 @@ private: } if (*Char(dispose_code)) { - Printv(body, "\n", dispose_methodmodifiers, - (derived ? " override" : ""), " void ", dispose_methodname, "() ", - dispose_code, "\n", NIL); + Printv(body, "\n", NIL); + const String *methodmods = Getattr(n, "destructmethodmodifiers"); + if (methodmods) + Printv(body, methodmods, NIL); + else + Printv(body, dispose_methodmodifiers, (derived ? " override" : ""), NIL); + Printv(body, " void ", dispose_methodname, "() ", dispose_code, "\n", NIL); } } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 9ff8299c0..f89de4e12 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1987,8 +1987,15 @@ public: Replaceall(destruct, "$jnicall", destructor_call); 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); + if (*Char(destruct)) { + Printv(proxy_class_def, "\n ", NIL); + const String *methodmods = Getattr(n, "destructmethodmodifiers"); + if (methodmods) + Printv(proxy_class_def, methodmods, NIL); + else + Printv(proxy_class_def, destruct_methodmodifiers, NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); + } } if (*Char(interface_upcasts)) Printv(proxy_class_def, interface_upcasts, NIL); @@ -2830,6 +2837,9 @@ public: if (proxy_flag) { Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL); generateThrowsClause(n, destructor_throws_clause); + const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); + if (methodmods) + Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods); } return SWIG_OK; } From e8e507bf0bae72e7f3bb798e326ec5d81b230205 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 23:26:06 +1000 Subject: [PATCH 0911/2031] Lib/octave: fix function name passed to unwind_protect::begin_frame() --- Lib/octave/octruntime.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index f5e687123..96f7399f9 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -170,7 +170,7 @@ SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::st frame.protect_var(discard_error_messages); discard_error_messages = true; frame.protect_var(discard_warning_messages); discard_warning_messages = true; #else - unwind_protect::begin_frame("SWIG_Octave_LoadModule"); + unwind_protect::begin_frame("SWIG_Octave_InstallFunction"); unwind_protect_int(error_state); error_state = 0; unwind_protect_int(warning_state); warning_state = 0; unwind_protect_bool(discard_error_messages); discard_error_messages = true; From a46909a414ee9a1fd3e1996066111774e852557e Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 31 Jan 2017 11:43:42 +1300 Subject: [PATCH 0912/2031] Lib/octave: call octave::feval() instead of feval() for Octave >= 4.4 --- Lib/octave/octruntime.swg | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 96f7399f9..e468eb49e 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -139,7 +139,11 @@ SWIGINTERN bool SWIG_Octave_LoadModule(std::string name) { #endif #if SWIG_OCTAVE_PREREQ(4,2,0) try { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::feval(name, octave_value_list(), 0); +#else feval(name, octave_value_list(), 0); +#endif retn = true; } catch (octave::execution_exception&) { } #else @@ -181,7 +185,11 @@ SWIGINTERN bool SWIG_Octave_InstallFunction(octave_function *octloadfcn, std::st args.append(octloadfcn->fcn_file_name()); #if SWIG_OCTAVE_PREREQ(4,2,0) try { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::feval("autoload", args, 0); +#else feval("autoload", args, 0); +#endif retn = true; } catch (octave::execution_exception&) { } #else @@ -351,7 +359,11 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { "__swig_atexit__; " "atexit(\"__swig_atexit__\", false); " "atexit(\"__swig_atexit__\")"); +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::feval("evalin", eval_args, 0); +#else feval("evalin", eval_args, 0); +#endif #endif octave_swig_ref::register_type(); From 358345db9eb875cb6b2bd51c5ed10efb3816d4f3 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 20:32:50 +1000 Subject: [PATCH 0913/2031] Lib/octave: replace is_cell() with iscell() for Octave >= 4.4 --- Lib/octave/octcontainer.swg | 4 ++++ Lib/octave/octprimtypes.swg | 8 +++++++- Lib/octave/octrun.swg | 20 ++++++++++++++++++-- Lib/octave/std_pair.i | 16 ++++++++++++++-- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 9b6520739..269ff7544 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -567,7 +567,11 @@ namespace swig { if (seq) *seq = p; return SWIG_OLDOBJ; } +%#if SWIG_OCTAVE_PREREQ(4,4,0) + } else if (obj.iscell()) { +%#else } else if (obj.is_cell()) { +%#endif try { OctSequence_Cont octseq(obj); if (seq) { diff --git a/Lib/octave/octprimtypes.swg b/Lib/octave/octprimtypes.swg index 663d1fe10..308fe6499 100644 --- a/Lib/octave/octprimtypes.swg +++ b/Lib/octave/octprimtypes.swg @@ -214,7 +214,13 @@ SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) SWIGINTERN int SWIG_AsCharPtrAndSize(octave_value ov, char** cptr, size_t* psize, int *alloc) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +%#else + ov.is_cell() +%#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_string()) return SWIG_TypeError; diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 57a888fb4..d6f75a7b5 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -383,7 +383,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); return dim_vector(1,1); // Return value should be cell or matrix of integers +#if SWIG_OCTAVE_PREREQ(4,4,0) + if (out.iscell()) { +#else if (out.is_cell()) { +#endif const Cell & c=out.cell_value(); int ndim = c.rows(); if (ndim==1 && c.columns()!=1) ndim = c.columns(); @@ -1238,7 +1242,13 @@ namespace Swig { } SWIGRUNTIME octave_swig_type *swig_value_deref(octave_value ov) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +#else + ov.is_cell() +#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); return swig_value_deref(*ov.internal_rep()); } @@ -1357,7 +1367,13 @@ SWIGRUNTIME octave_value SWIG_Octave_NewPointerObj(void *ptr, swig_type_info *ty } SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_type_info *type, int flags, int *own) { - if (ov.is_cell() && ov.rows() == 1 && ov.columns() == 1) + if ( +#if SWIG_OCTAVE_PREREQ(4,4,0) + ov.iscell() +#else + ov.is_cell() +#endif + && ov.rows() == 1 && ov.columns() == 1) ov = ov.cell_value()(0); if (!ov.is_defined() || (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) { diff --git a/Lib/octave/std_pair.i b/Lib/octave/std_pair.i index 2f3d4dfa4..2f307380e 100644 --- a/Lib/octave/std_pair.i +++ b/Lib/octave/std_pair.i @@ -38,7 +38,13 @@ } static int asval(const octave_value& obj, std::pair *val) { - if (obj.is_cell()) { + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + obj.iscell() +%#else + obj.is_cell() +%#endif + ) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); @@ -96,7 +102,13 @@ } static int asptr(const octave_value& obj, std::pair **val) { - if (obj.is_cell()) { + if ( +%#if SWIG_OCTAVE_PREREQ(4,4,0) + obj.iscell() +%#else + obj.is_cell() +%#endif + ) { Cell c=obj.cell_value(); if (c.numel()<2) { error("pair from Cell array requires at least two elements"); From 6f0561eb5772a04162ac631951999698a466253b Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 20:33:21 +1000 Subject: [PATCH 0914/2031] Lib/octave: replace is_numeric_type() with isnumeric() for Octave >= 4.4 --- Lib/octave/octrun.swg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index d6f75a7b5..f5d8b3898 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -405,7 +405,11 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); if (error_state) return dim_vector(1,1); } return d; +#if SWIG_OCTAVE_PREREQ(4,4,0) + } else if (out.is_matrix_type() || out.isnumeric() ) { +#else } else if (out.is_matrix_type() || out.is_numeric_type() ) { +#endif if (out.rows()==1 || out.columns()==1) { Array a = out.int_vector_value(); if (error_state) return dim_vector(1,1); From 04357dca210a3e90e464e00c9ed1b71e38807723 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 03:52:59 +1000 Subject: [PATCH 0915/2031] Lib/octave: replace is_bool_type() with islogical() for Octave >= 4.4 --- Lib/octave/octprimtypes.swg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/octave/octprimtypes.swg b/Lib/octave/octprimtypes.swg index 308fe6499..1c9aa9089 100644 --- a/Lib/octave/octprimtypes.swg +++ b/Lib/octave/octprimtypes.swg @@ -18,7 +18,11 @@ SWIGINTERNINLINE octave_value SWIGINTERN int SWIG_AsVal_dec(bool)(const octave_value& ov, bool *val) { +%#if SWIG_OCTAVE_PREREQ(4,4,0) + if (!ov.islogical()) +%#else if (!ov.is_bool_type()) +%#endif return SWIG_ERROR; if (val) *val = ov.bool_value(); From 931656bcbe7c2bf37bb5d831b47fab9a38695e91 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 21:52:28 +1000 Subject: [PATCH 0916/2031] Lib/octave: 'octave_exit' not longer exists in Octave >= 4.4 - Instead must register atexit() function, since Octave still cannot clean up its memory usage on exit with SWIG modules --- Lib/octave/octruntime.swg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index e468eb49e..b2fde69c2 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -320,6 +320,8 @@ static const char *const SWIG_name_usage = "-*- texinfo -*- \n\ Loads the SWIG-generated module `" SWIG_name_d "'.\n\ @end deftypefn"; +void __swig_atexit__(void) { ::_Exit(0); } + DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { static octave_swig_type* module_ns = 0; @@ -330,7 +332,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { // version 3.4.*, but reappeared in 4.2.*, so turn on for all versions after 3.2.*. // can be turned off with macro definition. #ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK -#if SWIG_OCTAVE_PREREQ(3,2,0) +#if SWIG_OCTAVE_PREREQ(4,4,0) + atexit(__swig_atexit__); +#elif SWIG_OCTAVE_PREREQ(3,2,0) octave_exit = ::_Exit; #endif #endif From df92ad6ebcb0995f04194b38ee19e0b7f08c730a Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 22:03:41 +1000 Subject: [PATCH 0917/2031] Lib/octave: fix call to octave::call_stack::current() for Octave >= 4.4 --- Lib/octave/octruntime.swg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index b2fde69c2..d83a27f57 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -375,7 +375,12 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { SWIG_InitializeModule(0); SWIG_PropagateClientData(); +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::call_stack& stack = octave::interpreter::the_interpreter()->get_call_stack(); + octave_function *me = stack.current(); +#else octave_function *me = octave_call_stack::current(); +#endif if (!SWIG_Octave_InstallFunction(me, "subclass")) { return octave_value_list(); From ce67bce72e8b82c47295c320dd990d30d4c4bbde Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 10 May 2018 22:04:30 +1000 Subject: [PATCH 0918/2031] Lib/octave: fix call to mlock() for Octave >= 4.4 --- Lib/octave/octruntime.swg | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index d83a27f57..46faade9c 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -447,10 +447,12 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { } } -#if !SWIG_OCTAVE_PREREQ(3,2,0) - mlock(me->name()); -#else +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::interpreter::the_interpreter()->mlock(); +#elif SWIG_OCTAVE_PREREQ(3,2,0) mlock(); +#else + mlock(me->name()); #endif } From 84aab22f669e90609c417c39cf4d81809fa1c5b6 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 11 May 2018 15:31:26 +1000 Subject: [PATCH 0919/2031] Lib/Octave: in Octave >= 4.4, assign reference to base class in subclass - See Examples/octave/callback/runme.m: a.run() calls Octave callback, but due to changes in behaviour to subsref() a.Callback.run() can no longer be used to call C callback unless a.Callback actually exists; subsrefs() just gets the "Callback" call whereas prior to Octave 4.4 it would get both the "Callback" and "run" calls. So now a.Callback is set to the original base class (with own=0) so that it can be accessed --- Lib/octave/octrun.swg | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index f5d8b3898..6e297d388 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -484,8 +484,12 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); } types.insert(types.end(), rhs.types.begin(), rhs.types.end()); members.insert(rhs.members.begin(), rhs.members.end()); +#if SWIG_OCTAVE_PREREQ(4,4,0) + assign(rhs.swig_type_name(), rhs.as_value()); +#else rhs.types.clear(); rhs.members.clear(); +#endif } typedef member_map::const_iterator swig_member_const_iterator; From 94e8853e610cf545ba42bfa77d8ac1d659adb7a5 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 02:26:01 +1000 Subject: [PATCH 0920/2031] Lib/octave: fix operator installation for Octave >= 4.4 --- Lib/octave/octrun.swg | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 6e297d388..ae014f9bd 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1279,12 +1279,24 @@ SWIGRUNTIME octave_value swig_unary_op_##name(const octave_base_value &x) { \ SWIGRUNTIME octave_value swig_binary_op_##name(const octave_base_value&lhs,const octave_base_value &rhs) { \ return octave_swig_type::dispatch_binary_op(lhs,rhs,#name); \ } +#if SWIG_OCTAVE_PREREQ(4,4,0) +#define swigreg_unary_op(name) \ +if (!octave_value_typeinfo::lookup_unary_op(octave_value::op_##name,tid)) \ +typeinfo.register_unary_op(octave_value::op_##name,tid,swig_unary_op_##name); +#else #define swigreg_unary_op(name) \ if (!octave_value_typeinfo::lookup_unary_op(octave_value::op_##name,tid)) \ octave_value_typeinfo::register_unary_op(octave_value::op_##name,tid,swig_unary_op_##name); +#endif +#if SWIG_OCTAVE_PREREQ(4,4,0) +#define swigreg_binary_op(name) \ +if (!octave_value_typeinfo::lookup_binary_op(octave_value::op_##name,tid1,tid2)) \ +typeinfo.register_binary_op(octave_value::op_##name,tid1,tid2,swig_binary_op_##name); +#else #define swigreg_binary_op(name) \ if (!octave_value_typeinfo::lookup_binary_op(octave_value::op_##name,tid1,tid2)) \ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig_binary_op_##name); +#endif swig_unary_op(not); swig_unary_op(uplus); @@ -1318,6 +1330,9 @@ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig swig_binary_op(el_or); SWIGRUNTIME void SWIG_InstallUnaryOps(int tid) { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::type_info& typeinfo = octave::interpreter::the_interpreter()->get_type_info(); +#endif swigreg_unary_op(not); swigreg_unary_op(uplus); swigreg_unary_op(uminus); @@ -1327,6 +1342,9 @@ octave_value_typeinfo::register_binary_op(octave_value::op_##name,tid1,tid2,swig swigreg_unary_op(decr); } SWIGRUNTIME void SWIG_InstallBinaryOps(int tid1, int tid2) { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::type_info& typeinfo = octave::interpreter::the_interpreter()->get_type_info(); +#endif swigreg_binary_op(add); swigreg_binary_op(sub); swigreg_binary_op(mul); From d0b1105f3018516e4a94dd57e6bae83167bf2f1c Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 02:29:07 +1000 Subject: [PATCH 0921/2031] Lib/octave: use new class for function member dereference with Octave >= 4.4 --- Lib/octave/octrun.swg | 80 +++++++++++++++++++++++++++++++++++++-- Lib/octave/octruntime.swg | 30 +++++++++++++++ 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index ae014f9bd..45105e207 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -151,6 +151,67 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); const swig_type_info **base; }; +#if SWIG_OCTAVE_PREREQ(4,4,0) + // in Octave 4.4 behaviour of octave_builtin() appears to have changed and 'self' argument is no longer passed + // to function (maybe because this is now a 'method'??) so need to create our own octave_function subclass +#define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(new octave_swig_bound_func(func, args)) + class octave_swig_bound_func : public octave_function { + public: + + octave_swig_bound_func(void) : octave_function(), method(0), first_args() + { } + + octave_swig_bound_func(octave_function* _method, octave_value_list _first_args) + : octave_function("", ""), method(_method), first_args(_first_args) + { } + + octave_swig_bound_func(const octave_swig_bound_func& f) = delete; + + octave_swig_bound_func& operator= (const octave_swig_bound_func& f) = delete; + + ~octave_swig_bound_func(void) = default; + + bool is_function(void) const { return true; } + + octave_function* function_value(bool = false) { return this; } + + octave_value_list call(octave::tree_evaluator& tw, int nargout = 0, const octave_value_list& args = octave_value_list()) { + octave_value_list all_args; + all_args.append(first_args); + all_args.append(args); + return method->call(tw, nargout, all_args); + } + + octave_value subsref(const std::string &ops, const std::list < octave_value_list > &idx) { + octave_value_list ovl = subsref(ops, idx, 1); + return ovl.length() ? ovl(0) : octave_value(); + } + + octave_value_list subsref(const std::string &ops, const std::list < octave_value_list > &idx, int nargout) { + assert(ops.size() > 0); + assert(ops.size() == idx.size()); + if (ops != "(") + error("invalid function call"); + octave::tree_evaluator& tw = octave::interpreter::the_interpreter()->get_evaluator(); + return call(tw, nargout, *idx.begin()); + } + + protected: + + octave_function* method; + octave_value_list first_args; + + std::set dispatch_classes; + + private: + + DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + }; + DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_bound_func, "octave_swig_bound_func", "octave_swig_bound_func"); +#else +#define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(func) +#endif + // octave_swig_type plays the role of both the shadow class and the class // representation within Octave, since there is no support for classes. // @@ -323,13 +384,17 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); } octave_value_list member_deref(member_value_pair *m, const octave_value_list &args) { - if (m->second.is_defined()) - return m->second; - else if (m->first) { + if (m->second.is_defined()) { + if (m->second.is_function() || m->second.is_function_handle()) { + return SWIG_OCTAVE_BOUND_FUNC(m->second.function_value(), args); + } else { + return m->second; + } + } else if (m->first) { if (m->first->get_method) return m->first->get_method(args, 1); else if (m->first->method) - return octave_value(new octave_builtin(m->first->method)); + return SWIG_OCTAVE_BOUND_FUNC(new octave_builtin(m->first->method), args); } error("undefined member"); return octave_value_list(); @@ -860,7 +925,14 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); octave_function *fcn = is_valid_function(symbol, std::string(), false); if (!fcn) return false; +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::tree_evaluator& tw = octave::interpreter::the_interpreter()->get_evaluator(); + octave_value_list retval = fcn->call(tw, 1, args); + if (retval.length() == 1) + ret = retval(0); +#else ret = fcn->do_multi_index_op(1, args)(0); +#endif return true; } diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 46faade9c..f98bf4fe4 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -370,8 +370,38 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { #endif #endif +#if SWIG_OCTAVE_PREREQ(4,4,0) + { + octave::type_info& typeinfo = octave::interpreter::the_interpreter()->get_type_info(); + string_vector types = typeinfo.installed_type_names(); + bool register_octave_swig_ref = true; + bool register_octave_swig_packed = true; + bool register_octave_swig_bound_func = true; + for (int i = 0; i < types.numel(); ++i) { + if (types(i) == octave_swig_ref::static_type_name()) { + register_octave_swig_ref = false; + } + if (types(i) == octave_swig_packed::static_type_name()) { + register_octave_swig_packed = false; + } + if (types(i) == octave_swig_bound_func::static_type_name()) { + register_octave_swig_bound_func = false; + } + } + if (register_octave_swig_ref) { + octave_swig_ref::register_type(); + } + if (register_octave_swig_packed) { + octave_swig_packed::register_type(); + } + if (register_octave_swig_bound_func) { + octave_swig_bound_func::register_type(); + } + } +#else octave_swig_ref::register_type(); octave_swig_packed::register_type(); +#endif SWIG_InitializeModule(0); SWIG_PropagateClientData(); From 6586616e23e499189b2acaf9e8244d9574cbf5b0 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 02:36:13 +1000 Subject: [PATCH 0922/2031] Lib/octave: fix getting/setting global variables for Octave >= 4.4 --- Lib/octave/octrun.swg | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 45105e207..feed973cc 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1504,14 +1504,30 @@ SWIGRUNTIMEINLINE void SWIG_Octave_SetConstant(octave_swig_type *module_ns, cons } SWIGRUNTIMEINLINE octave_value SWIG_Octave_GetGlobalValue(std::string name) { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table(); + return symtab.global_varval(name); +#else return get_global_value(name, true); +#endif } SWIGRUNTIME void SWIG_Octave_SetGlobalValue(std::string name, const octave_value& value) { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table(); + symtab.global_assign(name, value); +#else set_global_value(name, value); +#endif } SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { +#if SWIG_OCTAVE_PREREQ(4,4,0) + octave::symbol_table& symtab = octave::interpreter::the_interpreter()->get_symbol_table(); + octave::symbol_scope symscope = octave::interpreter::the_interpreter()->get_current_scope(); + symscope.assign(name, symtab.global_varval(name)); + symscope.mark_global(name); +#else #if !SWIG_OCTAVE_PREREQ(3,2,0) link_to_global_variable(curr_sym_tab->lookup(name, true)); #else @@ -1520,6 +1536,7 @@ SWIGRUNTIME void SWIG_Octave_LinkGlobalValue(std::string name) { #endif symbol_table::mark_global(name); #endif +#endif } SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { From a169eef3c0ee5436a09ce7bbd97ebaf189ffa35d Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 11 May 2018 22:22:42 +1000 Subject: [PATCH 0923/2031] Examples/Makefile.in: unset OCTAVE_PATH when running Octave for tests --- Examples/Makefile.in | 2 +- Examples/test-suite/octave/Makefile.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 8218f5122..58da8ec1d 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -463,7 +463,7 @@ octave_cpp: $(SRCDIR_SRCS) # ----------------------------------------------------------------- octave_run: - OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) + env OCTAVE_PATH= OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index f5ad0e8a5..3c8f3b165 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -65,7 +65,7 @@ CSRCS = octave_empty.c # a file is found which has _runme.m appended after the testcase name. run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir) OCTAVE_HISTFILE=/dev/null $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi # Clean: remove the generated .m file From af97a312d41fa72ef2f6b86c6c8e858392f79330 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Tue, 31 Jan 2017 11:48:42 +1300 Subject: [PATCH 0924/2031] Examples/octave/module_load/runme.m: do not use duplicate function names --- Examples/octave/module_load/runme.m | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/octave/module_load/runme.m b/Examples/octave/module_load/runme.m index 0e327efcd..4069e9939 100644 --- a/Examples/octave/module_load/runme.m +++ b/Examples/octave/module_load/runme.m @@ -16,24 +16,24 @@ clear all # load module in a function globally before base context clear all; -function testme +function testme_1 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction -testme -testme +testme_1 +testme_1 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); clear all -function testme +function testme_2 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction -testme -testme +testme_2 +testme_2 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); @@ -44,24 +44,24 @@ clear all; swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); -function testme +function testme_3 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction -testme -testme +testme_3 +testme_3 clear all swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); -function testme +function testme_4 swigexample; assert(cvar.ivar == ifunc); assert(exist("swigexample","var")); endfunction -testme -testme +testme_4 +testme_4 clear all # octave 3.0.5 randomly crashes on the remaining tests From 64ad3f0ca87dcd9d4a54692e7afdbc887b793268 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 11 May 2018 21:15:09 +1000 Subject: [PATCH 0925/2031] Examples/octave/module_load/runme.m: update 'exist()' statements for Octave >= 4.4 --- Examples/octave/module_load/runme.m | 41 +++++++++++++++++++---------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/Examples/octave/module_load/runme.m b/Examples/octave/module_load/runme.m index 4069e9939..beab1213b 100644 --- a/Examples/octave/module_load/runme.m +++ b/Examples/octave/module_load/runme.m @@ -5,60 +5,70 @@ endif # load module clear all; +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); clear all +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); clear all # load module in a function globally before base context clear all; function testme_1 + assert(exist("swigexample") == 3); swigexample; + assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); - assert(exist("swigexample","var")); endfunction testme_1 testme_1 +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); clear all function testme_2 + assert(exist("swigexample") == 3); swigexample; + assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); - assert(exist("swigexample","var")); endfunction testme_2 testme_2 +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); clear all # load module in a function globally after base context clear all; +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); function testme_3 + assert(exist("swigexample") == 3); swigexample; + assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); - assert(exist("swigexample","var")); endfunction testme_3 testme_3 clear all +assert(exist("swigexample") == 3); swigexample; +assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); -assert(exist("swigexample","var")); function testme_4 + assert(exist("swigexample") == 3); swigexample; + assert(isglobal("swigexample")); assert(cvar.ivar == ifunc); - assert(exist("swigexample","var")); endfunction testme_4 testme_4 @@ -71,13 +81,16 @@ endif # load module with no cvar clear all; +who; +assert(exist("swigexample2") == 3); swigexample2; +assert(isglobal("swigexample2")); assert(swigexample2.ivar == ifunc); -assert(exist("swigexample2","var")); -assert(!isglobal("cvar")) +assert(!exist("cvar", "var")); clear all +assert(exist("swigexample2") == 3); swigexample2; +assert(isglobal("swigexample2")); assert(swigexample2.ivar == ifunc); -assert(exist("swigexample2","var")); -assert(!isglobal("cvar")) +assert(!exist("cvar", "var")); clear all From a2ab3d7b20feec5f46100d98712dd92cf4f9bc52 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 19:23:12 +1000 Subject: [PATCH 0926/2031] Examples/test-suite/register_par.i: rename 'tree' to 'swig_tree' - 'tree' is a declared symbol in Octave >= 4.4 headers --- Examples/test-suite/register_par.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/register_par.i b/Examples/test-suite/register_par.i index b4172c059..643841455 100644 --- a/Examples/test-suite/register_par.i +++ b/Examples/test-suite/register_par.i @@ -1,10 +1,10 @@ %module register_par %{ -struct tree; +struct swig_tree; %} // bug # 924413 %inline { - void clear_tree_flags(register struct tree *tp, register int i) {} + void clear_tree_flags(register struct swig_tree *tp, register int i) {} } From ebd0b52b3ec201bbd70391c106e541c859ceaaf9 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 02:57:27 +1000 Subject: [PATCH 0927/2031] .travis.yml: test against Octave 4.4 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 54ec4c3f9..d0e1239ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -94,6 +94,11 @@ matrix: env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.2 CPP11=1 sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=perl5 From 23e6f1329255a128bb702be0de77f17c47149ddf Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 12 May 2018 22:31:31 +1000 Subject: [PATCH 0928/2031] Update CHANGES.current --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0acfddc7d..3037b5928 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-05-12: kwwette + [Octave] add support for version 4.4 + - Should not introduce any user-visible incompatibilities + 2018-05-11: wsfulton [C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers can modify the method modifiers for the destructor wrappers From 348efc22babc12c80978493900ae7ea6836b0d89 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 May 2018 12:08:32 +0100 Subject: [PATCH 0929/2031] Add support for c++17 nested namespaces For example: namespace A::B { ... } which is the equivalent to C++98 namespaces: namespace A { namespace B { ... } } --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp17_nested_namespaces.i | 199 ++++++++++++++++++ .../java/cpp17_nested_namespaces_runme.java | 32 +++ Source/CParse/parser.y | 75 +++++-- 4 files changed, 284 insertions(+), 23 deletions(-) create mode 100644 Examples/test-suite/cpp17_nested_namespaces.i create mode 100644 Examples/test-suite/java/cpp17_nested_namespaces_runme.java diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 72c49648b..c502cfb65 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -162,6 +162,7 @@ CPP_TEST_CASES += \ cpp_nodefault \ cpp_static \ cpp_typedef \ + cpp17_nested_namespaces \ curiously_recurring_template_pattern \ default_args \ default_arg_expressions \ diff --git a/Examples/test-suite/cpp17_nested_namespaces.i b/Examples/test-suite/cpp17_nested_namespaces.i new file mode 100644 index 000000000..b9ec9bd5a --- /dev/null +++ b/Examples/test-suite/cpp17_nested_namespaces.i @@ -0,0 +1,199 @@ +%module cpp17_nested_namespaces +// Tests c++17 style nested namespaces +// Tests are designed so that code compiles with C++98 compilers + +#define CPP17 1 +%{ +#if __cplusplus >= 201703L +#define CPP17 1 +#endif +%} + +%inline %{ +// Tests with namespaces already defined using C++98 style (non-nested) namespaces +namespace A1 { + struct A1Struct { + void A1Method() {} + }; + namespace B1 { + struct B1Struct { + void B1Method() {} + }; + } +} +#if defined(CPP17) +namespace A1::B1 { +#else +namespace A1 { + namespace B1 { +#endif + A1Struct createA1Struct() { return ::A1::A1Struct(); } + B1Struct createB1Struct() { return ::A1::B1::B1Struct(); } +#if !defined(CPP17) + } +} +#else +} +#endif + +namespace A1 { + namespace B1 { + namespace C1 { + struct C1Struct { + void C1Method() {} + }; + } + } +} + +#if defined(CPP17) +namespace A1::B1::C1 { +#else +namespace A1 { + namespace B1 { + namespace C1 { +#endif + C1Struct createC1Struct() { return ::A1::B1::C1::C1Struct(); } +#if !defined(CPP17) + } + } +} +#else +} +#endif +%} + +%inline %{ +// Tests with namespaces already defined using C++17 style (nested) namespaces +#if defined(CPP17) +namespace A2::B2 { +#else +namespace A2 { + namespace B2 { +#endif + struct B2Struct { + void B2Method() {} + }; +#if !defined(CPP17) + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A2::B2 { +#else +namespace A2 { + namespace B2 { +#endif + B2Struct createB2Struct() { return ::A2::B2::B2Struct(); } +#if !defined(CPP17) + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A2::B2::C2 { +#else +namespace A2 { + namespace B2 { + namespace C2 { +#endif + struct C2Struct { + void C2Method() {} + }; +#if !defined(CPP17) + } + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A2::B2::C2 { +#else +namespace A2 { + namespace B2 { + namespace C2 { +#endif + C2Struct createC2Struct() { return ::A2::B2::C2::C2Struct(); } +#if !defined(CPP17) + } + } +} +#else +} +#endif +%} + + +%inline %{ +// Tests with namespaces already defined using C++17 style (nested) namespaces to 3 levels +#if defined(CPP17) +namespace A3::B3::C3 { +#else +namespace A3 { + namespace B3 { + namespace C3 { +#endif + struct C3Struct { + void C3Method() {} + }; +#if !defined(CPP17) + } + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A3::B3::C3 { +#else +namespace A3 { + namespace B3 { + namespace C3 { +#endif + C3Struct createC3Struct() { return ::A3::B3::C3::C3Struct(); } +#if !defined(CPP17) + } + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A3::B3 { +#else +namespace A3 { + namespace B3 { +#endif + struct B3Struct { + void B3Method() {} + }; +#if !defined(CPP17) + } +} +#else +} +#endif + +#if defined(CPP17) +namespace A3::B3 { +#else +namespace A3 { + namespace B3 { +#endif + B3Struct createB3Struct() { return ::A3::B3::B3Struct(); } +#if !defined(CPP17) + } +} +#else +} +#endif +%} diff --git a/Examples/test-suite/java/cpp17_nested_namespaces_runme.java b/Examples/test-suite/java/cpp17_nested_namespaces_runme.java new file mode 100644 index 000000000..ac29dee19 --- /dev/null +++ b/Examples/test-suite/java/cpp17_nested_namespaces_runme.java @@ -0,0 +1,32 @@ +import cpp17_nested_namespaces.*; + +public class cpp17_nested_namespaces_runme { + + static { + try { + System.loadLibrary("cpp17_nested_namespaces"); + } 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[]) { + new A1Struct().A1Method(); + new B1Struct().B1Method(); + new C1Struct().C1Method(); + cpp17_nested_namespaces.createA1Struct().A1Method(); + cpp17_nested_namespaces.createB1Struct().B1Method(); + cpp17_nested_namespaces.createC1Struct().C1Method(); + + new B2Struct().B2Method(); + new C2Struct().C2Method(); + cpp17_nested_namespaces.createB2Struct().B2Method(); + cpp17_nested_namespaces.createC2Struct().C2Method(); + + new B3Struct().B3Method(); + new C3Struct().C3Method(); + cpp17_nested_namespaces.createB3Struct().B3Method(); + cpp17_nested_namespaces.createC3Struct().C3Method(); + } +} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0c8d95ecd..cae20eb3f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4400,32 +4400,61 @@ cpp_using_decl : USING idcolon SEMI { cpp_namespace_decl : NAMESPACE idcolon LBRACE { Hash *h; - $1 = Swig_symbol_current(); - h = Swig_symbol_clookup($2,0); - if (h && ($1 == Getattr(h,"sym:symtab")) && (Strcmp(nodeType(h),"namespace") == 0)) { - if (Getattr(h,"alias")) { - h = Getattr(h,"namespace"); - Swig_warning(WARN_PARSE_NAMESPACE_ALIAS, cparse_file, cparse_line, "Namespace alias '%s' not allowed here. Assuming '%s'\n", - $2, Getattr(h,"name")); - $2 = Getattr(h,"name"); + Node *parent_ns = 0; + List *scopes = Swig_scopename_tolist($2); + int ilen = Len(scopes); + int i; + +/* +Printf(stdout, "==== Namespace %s creation...\n", $2); +*/ + $$ = 0; + for (i = 0; i < ilen; i++) { + Node *ns = new_node("namespace"); + Symtab *current_symtab = Swig_symbol_current(); + String *scopename = Getitem(scopes, i); + Setattr(ns, "name", scopename); + $$ = ns; + if (parent_ns) + appendChild(parent_ns, ns); + parent_ns = ns; + h = Swig_symbol_clookup(scopename, 0); + if (h && (current_symtab == Getattr(h, "sym:symtab")) && (Strcmp(nodeType(h), "namespace") == 0)) { +/* +Printf(stdout, " Scope %s [found C++17 style]\n", scopename); +*/ + if (Getattr(h, "alias")) { + h = Getattr(h, "namespace"); + Swig_warning(WARN_PARSE_NAMESPACE_ALIAS, cparse_file, cparse_line, "Namespace alias '%s' not allowed here. Assuming '%s'\n", + scopename, Getattr(h, "name")); + scopename = Getattr(h, "name"); + } + Swig_symbol_setscope(Getattr(h, "symtab")); + } else { +/* +Printf(stdout, " Scope %s [creating single scope C++17 style]\n", scopename); +*/ + h = Swig_symbol_newscope(); + Swig_symbol_setscopename(scopename); } - Swig_symbol_setscope(Getattr(h,"symtab")); - } else { - Swig_symbol_newscope(); - Swig_symbol_setscopename($2); + Delete(Namespaceprefix); + Namespaceprefix = Swig_symbol_qualifiedscopename(0); } - Delete(Namespaceprefix); - Namespaceprefix = Swig_symbol_qualifiedscopename(0); + Delete(scopes); } interface RBRACE { - Node *n = $5; - set_nodeType(n,"namespace"); - Setattr(n,"name",$2); - Setattr(n,"symtab", Swig_symbol_popscope()); - Swig_symbol_setscope($1); - $$ = n; - Delete(Namespaceprefix); - Namespaceprefix = Swig_symbol_qualifiedscopename(0); - add_symbols($$); + Node *n = $4; + Node *top_ns = 0; + do { + Setattr(n, "symtab", Swig_symbol_popscope()); + Delete(Namespaceprefix); + Namespaceprefix = Swig_symbol_qualifiedscopename(0); + add_symbols(n); + top_ns = n; + n = parentNode(n); + } while(n); + appendChild($4, firstChild($5)); + Delete($5); + $$ = top_ns; } | NAMESPACE LBRACE { Hash *h; From c8f5f3a6d1213591feb45b33125e442abd29640a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 18:55:10 +0100 Subject: [PATCH 0930/2031] Add c++17 nested namespaces runtime test for Python --- .../python/cpp17_nested_namespaces_runme.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Examples/test-suite/python/cpp17_nested_namespaces_runme.py diff --git a/Examples/test-suite/python/cpp17_nested_namespaces_runme.py b/Examples/test-suite/python/cpp17_nested_namespaces_runme.py new file mode 100644 index 000000000..562216625 --- /dev/null +++ b/Examples/test-suite/python/cpp17_nested_namespaces_runme.py @@ -0,0 +1,18 @@ +from cpp17_nested_namespaces import * + +A1Struct().A1Method() +B1Struct().B1Method() +C1Struct().C1Method() +createA1Struct().A1Method() +createB1Struct().B1Method() +createC1Struct().C1Method() + +B2Struct().B2Method() +C2Struct().C2Method() +createB2Struct().B2Method() +createC2Struct().C2Method() + +B3Struct().B3Method() +C3Struct().C3Method() +createB3Struct().B3Method() +createC3Struct().C3Method() From 5c39dcfb28569272a1b39aea5199c6afca082c0a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 18:58:21 +0100 Subject: [PATCH 0931/2031] Add c++17 nested namespaces runtime test for C# --- .../csharp/cpp17_nested_namespaces_runme.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs diff --git a/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs b/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs new file mode 100644 index 000000000..8707b4e20 --- /dev/null +++ b/Examples/test-suite/csharp/cpp17_nested_namespaces_runme.cs @@ -0,0 +1,25 @@ +using System; +using cpp17_nested_namespacesNamespace; + +public class cpp17_nested_namespaces_runme +{ + static void Main() + { + new A1Struct().A1Method(); + new B1Struct().B1Method(); + new C1Struct().C1Method(); + cpp17_nested_namespaces.createA1Struct().A1Method(); + cpp17_nested_namespaces.createB1Struct().B1Method(); + cpp17_nested_namespaces.createC1Struct().C1Method(); + + new B2Struct().B2Method(); + new C2Struct().C2Method(); + cpp17_nested_namespaces.createB2Struct().B2Method(); + cpp17_nested_namespaces.createC2Struct().C2Method(); + + new B3Struct().B3Method(); + new C3Struct().C3Method(); + cpp17_nested_namespaces.createB3Struct().B3Method(); + cpp17_nested_namespaces.createC3Struct().C3Method(); + } +} From 220247c1308c5c14d6d11f2f24d1ee6dea0c21ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 20:42:47 +0100 Subject: [PATCH 0932/2031] Test c++17 nested namespaces and %nspace --- Examples/test-suite/common.mk | 1 + .../cpp17_nspace_nested_namespaces.i | 13 ++++++++ .../cpp17_nspace_nested_namespaces_runme.cs | 25 ++++++++++++++++ Examples/test-suite/java/Makefile.in | 1 + .../cpp17_nspace_nested_namespaces_runme.java | 30 +++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 Examples/test-suite/cpp17_nspace_nested_namespaces.i create mode 100644 Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs create mode 100644 Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c502cfb65..644355958 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -163,6 +163,7 @@ CPP_TEST_CASES += \ cpp_static \ cpp_typedef \ cpp17_nested_namespaces \ + cpp17_nspace_nested_namespaces \ curiously_recurring_template_pattern \ default_args \ default_arg_expressions \ diff --git a/Examples/test-suite/cpp17_nspace_nested_namespaces.i b/Examples/test-suite/cpp17_nspace_nested_namespaces.i new file mode 100644 index 000000000..a88878de9 --- /dev/null +++ b/Examples/test-suite/cpp17_nspace_nested_namespaces.i @@ -0,0 +1,13 @@ +%module cpp17_nspace_nested_namespaces + +#if defined(SWIGJAVA) +SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) +#endif + +// nspace feature only supported by these languages +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) || defined(SWIGLUA) || defined(SWIGJAVASCRIPT) +%nspace; +#endif + + +%include "cpp17_nested_namespaces.i" diff --git a/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs b/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs new file mode 100644 index 000000000..61a8287f4 --- /dev/null +++ b/Examples/test-suite/csharp/cpp17_nspace_nested_namespaces_runme.cs @@ -0,0 +1,25 @@ +using System; +using cpp17_nspace_nested_namespacesNamespace; + +public class cpp17_nspace_nested_namespaces_runme +{ + static void Main() + { + new cpp17_nspace_nested_namespacesNamespace.A1.A1Struct().A1Method(); + new cpp17_nspace_nested_namespacesNamespace.A1.B1.B1Struct().B1Method(); + new cpp17_nspace_nested_namespacesNamespace.A1.B1.C1.C1Struct().C1Method(); + cpp17_nspace_nested_namespaces.createA1Struct().A1Method(); + cpp17_nspace_nested_namespaces.createB1Struct().B1Method(); + cpp17_nspace_nested_namespaces.createC1Struct().C1Method(); + + new cpp17_nspace_nested_namespacesNamespace.A2.B2.B2Struct().B2Method(); + new cpp17_nspace_nested_namespacesNamespace.A2.B2.C2.C2Struct().C2Method(); + cpp17_nspace_nested_namespaces.createB2Struct().B2Method(); + cpp17_nspace_nested_namespaces.createC2Struct().C2Method(); + + new cpp17_nspace_nested_namespacesNamespace.A3.B3.B3Struct().B3Method(); + new cpp17_nspace_nested_namespacesNamespace.A3.B3.C3.C3Struct().C3Method(); + cpp17_nspace_nested_namespaces.createB3Struct().B3Method(); + cpp17_nspace_nested_namespaces.createC3Struct().C3Method(); + } +} diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 5f1dc375b..87538de59 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -59,6 +59,7 @@ JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE) SWIGOPT += $(JAVA_PACKAGEOPT) # Custom tests - tests with additional commandline options +cpp17_nspace_nested_namespaces.%: JAVA_PACKAGE = $*Package director_nspace.%: JAVA_PACKAGE = $*Package director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package diff --git a/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java b/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java new file mode 100644 index 000000000..e603484ab --- /dev/null +++ b/Examples/test-suite/java/cpp17_nspace_nested_namespaces_runme.java @@ -0,0 +1,30 @@ +public class cpp17_nspace_nested_namespaces_runme { + + static { + try { + System.loadLibrary("cpp17_nspace_nested_namespaces"); + } 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[]) { + new cpp17_nspace_nested_namespacesPackage.A1.A1Struct().A1Method(); + new cpp17_nspace_nested_namespacesPackage.A1.B1.B1Struct().B1Method(); + new cpp17_nspace_nested_namespacesPackage.A1.B1.C1.C1Struct().C1Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createA1Struct().A1Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB1Struct().B1Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC1Struct().C1Method(); + + new cpp17_nspace_nested_namespacesPackage.A2.B2.B2Struct().B2Method(); + new cpp17_nspace_nested_namespacesPackage.A2.B2.C2.C2Struct().C2Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB2Struct().B2Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC2Struct().C2Method(); + + new cpp17_nspace_nested_namespacesPackage.A3.B3.B3Struct().B3Method(); + new cpp17_nspace_nested_namespacesPackage.A3.B3.C3.C3Struct().C3Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createB3Struct().B3Method(); + cpp17_nspace_nested_namespacesPackage.cpp17_nspace_nested_namespaces.createC3Struct().C3Method(); + } +} From aa6d7931ac159e633245e1402f66ea62b529fd2b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 20:58:11 +0100 Subject: [PATCH 0933/2031] Test for invalid C++17 nested namespace aliases --- .../errors/cpp_nested_namespace_alias.i | 34 +++++++++++++++++++ .../errors/cpp_nested_namespace_alias.stderr | 3 ++ 2 files changed, 37 insertions(+) create mode 100644 Examples/test-suite/errors/cpp_nested_namespace_alias.i create mode 100644 Examples/test-suite/errors/cpp_nested_namespace_alias.stderr diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.i b/Examples/test-suite/errors/cpp_nested_namespace_alias.i new file mode 100644 index 000000000..b7cbceb71 --- /dev/null +++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.i @@ -0,0 +1,34 @@ +%module cpp_nested_namespace_alias + +// C++17 nested namespaces + +namespace A +{ + namespace B + { + void ab1(); + } +} +namespace A::B +{ + void ab2(); +} +namespace AAlias = A; +namespace AAlias::B +{ + void ab3(); +} +namespace A +{ + namespace BAlias = B; + void ab4(); +} +namespace A::BAlias +{ + void ab5(); +} +namespace ABAlias = A::B; +namespace ABAlias +{ + void ab6(); +} diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr b/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr new file mode 100644 index 000000000..2506a3a2c --- /dev/null +++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.stderr @@ -0,0 +1,3 @@ +cpp_nested_namespace_alias.i:18: Warning 308: Namespace alias 'AAlias' not allowed here. Assuming 'A' +cpp_nested_namespace_alias.i:27: Warning 308: Namespace alias 'BAlias' not allowed here. Assuming 'B' +cpp_nested_namespace_alias.i:32: Warning 308: Namespace alias 'ABAlias' not allowed here. Assuming 'B' From 192aa2892cdd31069262c3bbbc3d70a2afa58543 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 21:00:51 +0100 Subject: [PATCH 0934/2031] Add changes notes for C++17 nested namespaces support --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0acfddc7d..b3463dacd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-05-14: wsfulton + Issue #1251 Add support for C++17 nested namespace definitions, + for example: + namespace A::B { ... } + 2018-05-11: wsfulton [C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers can modify the method modifiers for the destructor wrappers From 066c396ad6c1656a477997561def5a6131bafda5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 May 2018 21:23:27 +0100 Subject: [PATCH 0935/2031] Add C++17 documentation chapter --- Doc/Manual/Allegrocl.html | 108 ++++++++--------- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Chicken.html | 40 +++---- Doc/Manual/Contents.html | 83 +++++++------ Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Extending.html | 100 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 44 +++---- Doc/Manual/Introduction.html | 1 + Doc/Manual/Java.html | 220 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 50 ++++---- Doc/Manual/Lisp.html | 22 ++-- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modula3.html | 40 +++---- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 62 +++++----- Doc/Manual/Octave.html | 52 ++++---- Doc/Manual/Perl5.html | 108 ++++++++--------- Doc/Manual/Php.html | 50 ++++---- Doc/Manual/Pike.html | 24 ++-- Doc/Manual/Preprocessor.html | 26 ++-- Doc/Manual/Python.html | 192 ++++++++++++++--------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 +++++++++++++++---------------- Doc/Manual/SWIGPlus.html | 1 + Doc/Manual/Scilab.html | 90 +++++++------- Doc/Manual/Sections.html | 1 + Doc/Manual/Tcl.html | 92 +++++++------- Doc/Manual/Typemaps.html | 132 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 36 +++--- Doc/Manual/chapters | 1 + 39 files changed, 1131 insertions(+), 1112 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index c4d898130..f8e5d013e 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

      18 SWIG and Allegro Common Lisp

      +

      19 SWIG and Allegro Common Lisp

      -

      18.2.2 Foreign Wrappers

      +

      19.2.2 Foreign Wrappers

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

      -

      18.2.3 FFI Wrappers

      +

      19.2.3 FFI Wrappers

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

      -

      18.2.4 Non-overloaded Defuns

      +

      19.2.4 Non-overloaded Defuns

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

      -

      18.2.5 Overloaded Defuns

      +

      19.2.5 Overloaded Defuns

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

      -

      18.2.6 What about constant and variable access?

      +

      19.2.6 What about constant and variable access?

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

      -

      18.2.7 Object Wrapping

      +

      19.2.7 Object Wrapping

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

      -

      18.3 Wrapping Details

      +

      19.3 Wrapping Details

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

      -

      18.3.1 Namespaces

      +

      19.3.1 Namespaces

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

      -

      18.3.2 Constants

      +

      19.3.2 Constants

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

      -

      18.3.3 Variables

      +

      19.3.3 Variables

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

      18.3.4 Enumerations

      +

      19.3.4 Enumerations

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

      18.3.5 Arrays

      +

      19.3.5 Arrays

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

      18.3.6 Classes and Structs and Unions (oh my!)

      +

      19.3.6 Classes and Structs and Unions (oh my!)

      -

      18.3.6.1 CLOS wrapping of

      +

      19.3.6.1 CLOS wrapping of

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

      -

      18.3.6.2 CLOS Inheritance

      +

      19.3.6.2 CLOS Inheritance

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

      -

      18.3.6.3 Member fields and functions

      +

      19.3.6.3 Member fields and functions

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

      -

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

      +

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

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

      -

      18.3.7 Templates

      +

      19.3.7 Templates

      -

      18.3.7.1 Generating wrapper code for templates

      +

      19.3.7.1 Generating wrapper code for templates

      @@ -1187,7 +1187,7 @@ them. This is done via the directive.

      -

      18.3.7.2 Implicit Template instantiation

      +

      19.3.7.2 Implicit Template instantiation

      @@ -1197,7 +1197,7 @@ to include these templated classes in the foreign-type and CLOS class schema.

      -

      18.3.8 Typedef, Templates, and Synonym Types

      +

      19.3.8 Typedef, Templates, and Synonym Types

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

      18.3.8.1 Choosing a primary type

      +

      19.3.8.1 Choosing a primary type

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

    -

    18.3.9 Function overloading/Parameter defaulting

    +

    19.3.9 Function overloading/Parameter defaulting

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

    18.3.10 Operator wrapping and Operator overloading

    +

    19.3.10 Operator wrapping and Operator overloading

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

    18.3.11 Varargs

    +

    19.3.11 Varargs

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

    -

    18.3.12 C++ Exceptions

    +

    19.3.12 C++ Exceptions

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

    -

    18.3.13 Pass by value, pass by reference

    +

    19.3.13 Pass by value, pass by reference

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

    -

    18.4 Typemaps

    +

    19.4 Typemaps

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

    -

    18.4.1 Code Generation in the C++ Wrapper

    +

    19.4.1 Code Generation in the C++ Wrapper

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

    18.4.1.1 IN Typemap

    +

    19.4.1.1 IN Typemap

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

    18.4.1.2 OUT Typemap

    +

    19.4.1.2 OUT Typemap

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

    18.4.1.3 CTYPE Typemap

    +

    19.4.1.3 CTYPE Typemap

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

    -

    18.4.2 Code generation in Lisp wrappers

    +

    19.4.2 Code generation in Lisp wrappers

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

    -

    18.4.2.1 LIN Typemap

    +

    19.4.2.1 LIN Typemap

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

    18.4.2.2 LOUT Typemap

    +

    19.4.2.2 LOUT Typemap

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

    18.4.2.3 FFITYPE Typemap

    +

    19.4.2.3 FFITYPE Typemap

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

    18.4.2.4 LISPTYPE Typemap

    +

    19.4.2.4 LISPTYPE Typemap

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

    18.4.2.5 LISPCLASS Typemap

    +

    19.4.2.5 LISPCLASS Typemap

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

    18.4.3 Modifying SWIG behavior using typemaps

    +

    19.4.3 Modifying SWIG behavior using typemaps

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

    18.5 Identifier Converter functions

    +

    19.5 Identifier Converter functions

    -

    18.5.1 Creating symbols in the lisp environment

    +

    19.5.1 Creating symbols in the lisp environment

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

    -

    18.5.2 Existing identifier-converter functions

    +

    19.5.2 Existing identifier-converter functions

    Two basic identifier routines have been defined. -

    18.5.2.1 identifier-convert-null

    +

    19.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.

    -

    18.5.2.2 identifier-convert-lispify

    +

    19.5.2.2 identifier-convert-lispify

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

    -

    18.5.2.3 Default identifier to symbol conversions

    +

    19.5.2.3 Default identifier to symbol conversions

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

    -

    18.5.3 Defining your own identifier-converter

    +

    19.5.3 Defining your own identifier-converter

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

    -

    18.5.4 Instructing SWIG to use a particular identifier-converter

    +

    19.5.4 Instructing SWIG to use a particular identifier-converter

    diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 726314228..cc11ec26e 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

    19 SWIG and Android

    +

    20 SWIG and Android

    -

    10.1.3 Output parameters

    +

    11.1.3 Output parameters

    @@ -315,7 +315,7 @@ iresult, dresult = foo(3.5, 2) -

    10.1.4 Input/Output parameters

    +

    11.1.4 Input/Output parameters

    @@ -380,7 +380,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    10.1.5 Using different names

    +

    11.1.5 Using different names

    @@ -414,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    10.2 Applying constraints to input values

    +

    11.2 Applying constraints to input values

    @@ -424,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    10.2.1 Simple constraint example

    +

    11.2.1 Simple constraint example

    @@ -450,7 +450,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    10.2.2 Constraint methods

    +

    11.2.2 Constraint methods

    @@ -466,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only). -

    10.2.3 Applying constraints to new datatypes

    +

    11.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 521184ff0..77b54e31a 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -7,7 +7,7 @@ -

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

    +

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

    -

    17.14 HISTORY

    +

    18.14 HISTORY

    @@ -423,7 +423,7 @@ 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.

    -

    17.15 DIFFERENCES FROM COMPILERCACHE

    +

    18.15 DIFFERENCES FROM COMPILERCACHE

    @@ -441,7 +441,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    17.16 CREDITS

    +

    18.16 CREDITS

    @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    17.17 AUTHOR

    +

    18.17 AUTHOR

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index e96940626..85d651fd1 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

    20 SWIG and C#

    +

    21 SWIG and C#

    -

    20.4 C# Arrays

    +

    21.4 C# Arrays

    @@ -586,7 +586,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

    -

    20.4.1 The SWIG C arrays library

    +

    21.4.1 The SWIG C arrays library

    @@ -623,7 +623,7 @@ example.print_array(c.cast()); // Pass to C -

    20.4.2 Managed arrays using P/Invoke default array marshalling

    +

    21.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -750,7 +750,7 @@ and intermediary class method -

    20.4.3 Managed arrays using pinning

    +

    21.4.3 Managed arrays using pinning

    @@ -845,7 +845,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    20.5 C# Exceptions

    +

    21.5 C# Exceptions

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

    -

    20.5.1 C# exception example using "check" typemap

    +

    21.5.1 C# exception example using "check" typemap

    @@ -1124,7 +1124,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.

    -

    20.5.2 C# exception example using %exception

    +

    21.5.2 C# exception example using %exception

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

    20.5.3 C# exception example using exception specifications

    +

    21.5.3 C# exception example using exception specifications

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

    -

    20.5.4 Custom C# ApplicationException example

    +

    21.5.4 Custom C# ApplicationException example

    @@ -1379,7 +1379,7 @@ try { -

    20.6 C# Directors

    +

    21.6 C# Directors

    @@ -1392,7 +1392,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.

    -

    20.6.1 Directors example

    +

    21.6.1 Directors example

    @@ -1513,7 +1513,7 @@ CSharpDerived - UIntMethod(123) -

    20.6.2 Directors implementation

    +

    21.6.2 Directors implementation

    @@ -1721,7 +1721,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    20.6.3 Director caveats

    +

    21.6.3 Director caveats

    @@ -1769,7 +1769,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.

    -

    20.7 Multiple modules

    +

    21.7 Multiple modules

    @@ -1804,7 +1804,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    20.8 C# Typemap examples

    +

    21.8 C# Typemap examples

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

    20.8.1 Memory management when returning references to member variables

    +

    21.8.1 Memory management when returning references to member variables

    @@ -1936,7 +1936,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

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

    +

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

    @@ -2068,7 +2068,7 @@ as mentioned earlier, setElement is actually: -

    20.8.3 Date marshalling using the csin typemap and associated attributes

    +

    21.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2354,7 +2354,7 @@ public class example { -

    20.8.4 A date example demonstrating marshalling of C# properties

    +

    21.8.4 A date example demonstrating marshalling of C# properties

    @@ -2454,7 +2454,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    20.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    21.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2516,7 +2516,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    20.8.6 Turning proxy classes into partial classes

    +

    21.8.6 Turning proxy classes into partial classes

    @@ -2616,7 +2616,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.

    -

    20.8.7 Turning proxy classes into sealed classes

    +

    21.8.7 Turning proxy classes into sealed classes

    @@ -2706,7 +2706,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    20.8.8 Extending proxy classes with additional C# code

    +

    21.8.8 Extending proxy classes with additional C# code

    @@ -2745,7 +2745,7 @@ public class ExtendMe : global::System.IDisposable { -

    20.8.9 Underlying type for enums

    +

    21.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index b2f434a88..bf34ae507 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

    21 SWIG and Chicken

    +

    22 SWIG and Chicken

    -

    21.3 TinyCLOS

    +

    22.3 TinyCLOS

    @@ -333,7 +333,7 @@

    -

    21.4 Linkage

    +

    22.4 Linkage

    @@ -354,7 +354,7 @@

    -

    21.4.1 Static binary or shared library linked at compile time

    +

    22.4.1 Static binary or shared library linked at compile time

    We can easily use csc to build a static binary.

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

    -

    21.4.2 Building chicken extension libraries

    +

    22.4.2 Building chicken extension libraries

    Building a shared library like in the above section only works if the library @@ -453,7 +453,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.

    -

    21.4.3 Linking multiple SWIG modules with TinyCLOS

    +

    22.4.3 Linking multiple SWIG modules with TinyCLOS

    Linking together multiple modules that share type information using the %import @@ -477,7 +477,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.

    -

    21.5 Typemaps

    +

    22.5 Typemaps

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

    Lib/chicken/chicken.swg.

    -

    21.6 Pointers

    +

    22.6 Pointers

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

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

    -

    21.6.1 Garbage collection

    +

    22.6.1 Garbage collection

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

    must be called manually.

    -

    21.7 Unsupported features and known problems

    +

    22.7 Unsupported features and known problems

    -

    21.7.1 TinyCLOS problems with Chicken version <= 1.92

    +

    22.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 f77823d20..c79416e77 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -334,7 +334,22 @@ -

    8 Preprocessing

    +

    8 SWIG and C++17

    + + + + + +

    9 Preprocessing

    @@ -357,7 +372,7 @@
    -

    9 SWIG library

    +

    10 SWIG library

    @@ -400,7 +415,7 @@
    -

    10 Argument Handling

    +

    11 Argument Handling

    @@ -423,7 +438,7 @@
    -

    11 Typemaps

    +

    12 Typemaps

    @@ -517,7 +532,7 @@
    -

    12 Customization Features

    +

    13 Customization Features

    @@ -545,7 +560,7 @@
    -

    13 Contracts

    +

    14 Contracts

    @@ -558,7 +573,7 @@
    -

    14 Variable Length Arguments

    +

    15 Variable Length Arguments

    @@ -576,7 +591,7 @@
    -

    15 Warning Messages

    +

    16 Warning Messages

    @@ -604,7 +619,7 @@
    -

    16 Working with Modules

    +

    17 Working with Modules

    @@ -620,7 +635,7 @@
    -

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

    +

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

    @@ -646,7 +661,7 @@
    -

    18 SWIG and Allegro Common Lisp

    +

    19 SWIG and Allegro Common Lisp

    @@ -730,7 +745,7 @@
    -

    19 SWIG and Android

    +

    20 SWIG and Android

    @@ -748,7 +763,7 @@
    -

    20 SWIG and C#

    +

    21 SWIG and C#

    @@ -796,7 +811,7 @@
    -

    21 SWIG and Chicken

    +

    22 SWIG and Chicken

    @@ -834,7 +849,7 @@
    -

    22 SWIG and D

    +

    23 SWIG and D

    @@ -868,7 +883,7 @@
    -

    23 SWIG and Go

    +

    24 SWIG and Go

    @@ -912,7 +927,7 @@
    -

    24 SWIG and Guile

    +

    25 SWIG and Guile

    @@ -948,7 +963,7 @@
    -

    25 SWIG and Java

    +

    26 SWIG and Java

    @@ -1102,7 +1117,7 @@
    -

    26 SWIG and Javascript

    +

    27 SWIG and Javascript

    @@ -1144,7 +1159,7 @@
    -

    27 SWIG and Common Lisp

    +

    28 SWIG and Common Lisp

    @@ -1167,7 +1182,7 @@
    -

    28 SWIG and Lua

    +

    29 SWIG and Lua

    @@ -1235,7 +1250,7 @@
    -

    29 SWIG and Modula-3

    +

    30 SWIG and Modula-3

    @@ -1273,7 +1288,7 @@
    -

    30 SWIG and MzScheme/Racket

    +

    31 SWIG and MzScheme/Racket

    @@ -1285,7 +1300,7 @@
    -

    31 SWIG and Ocaml

    +

    32 SWIG and Ocaml

    @@ -1336,7 +1351,7 @@
    -

    32 SWIG and Octave

    +

    33 SWIG and Octave

    @@ -1376,7 +1391,7 @@
    -

    33 SWIG and Perl5

    +

    34 SWIG and Perl5

    @@ -1452,7 +1467,7 @@
    -

    34 SWIG and PHP

    +

    35 SWIG and PHP

    @@ -1493,7 +1508,7 @@
    -

    35 SWIG and Pike

    +

    36 SWIG and Pike

    @@ -1517,7 +1532,7 @@
    -

    36 SWIG and Python

    +

    37 SWIG and Python

    @@ -1653,7 +1668,7 @@
    -

    37 SWIG and R

    +

    38 SWIG and R

    @@ -1669,7 +1684,7 @@
    -

    38 SWIG and Ruby

    +

    39 SWIG and Ruby

    @@ -1807,7 +1822,7 @@
    -

    39 SWIG and Scilab

    +

    40 SWIG and Scilab

    @@ -1876,7 +1891,7 @@
    -

    40 SWIG and Tcl

    +

    41 SWIG and Tcl

    @@ -1942,7 +1957,7 @@
    -

    41 Extending SWIG to support new languages

    +

    42 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index ef1228cfb..2394db25e 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -7,7 +7,7 @@ -

    13 Contracts

    +

    14 Contracts

      @@ -39,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      13.1 The %contract directive

      +

      14.1 The %contract directive

      @@ -95,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    13.2 %contract and classes

    +

    14.2 %contract and classes

    @@ -174,7 +174,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    13.3 Constant aggregation and %aggregate_check

    +

    14.3 Constant aggregation and %aggregate_check

    @@ -263,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    13.4 Notes

    +

    14.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 269e659e0..27a291d0c 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -7,7 +7,7 @@ -

    12 Customization Features

    +

    13 Customization Features

    -

    12.1.4 Exception handlers for variables

    +

    13.1.4 Exception handlers for variables

    @@ -305,7 +305,7 @@ The %allowexception feature works like any other feature and so can be

    -

    12.1.5 Defining different exception handlers

    +

    13.1.5 Defining different exception handlers

    @@ -442,7 +442,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    12.1.6 Special variables for %exception

    +

    13.1.6 Special variables for %exception

    @@ -545,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    12.1.7 Using The SWIG exception library

    +

    13.1.7 Using The SWIG exception library

    @@ -600,7 +600,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    12.2 Object ownership and %newobject

    +

    13.2 Object ownership and %newobject

    @@ -757,7 +757,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    12.3 Features and the %feature directive

    +

    13.3 Features and the %feature directive

    @@ -839,7 +839,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    12.3.1 Feature attributes

    +

    13.3.1 Feature attributes

    @@ -880,7 +880,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    12.3.2 Feature flags

    +

    13.3.2 Feature flags

    @@ -978,7 +978,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    12.3.3 Clearing features

    +

    13.3.3 Clearing features

    @@ -1071,7 +1071,7 @@ The three macros below show this for the "except" feature: -

    12.3.4 Features and default arguments

    +

    13.3.4 Features and default arguments

    @@ -1146,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    12.3.5 Feature example

    +

    13.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 1a317a005..a252650ff 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    22 SWIG and D

    +

    23 SWIG and D

      @@ -41,7 +41,7 @@ -

      22.1 Introduction

      +

      23.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      22.2 Command line invocation

      +

      23.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      22.3 Typemaps

      +

      23.3 Typemaps

      -

      22.3.1 C# <-> D name comparison

      +

      23.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    22.3.2 ctype, imtype, dtype

    +

    23.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    22.3.3 in, out, directorin, directorout

    +

    23.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    22.3.4 din, dout, ddirectorin, ddirectorout

    +

    23.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

    22.3.5 typecheck typemaps

    +

    23.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    22.3.6 Code injection typemaps

    +

    23.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    22.3.7 Special variable macros

    +

    23.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    22.4 D and %feature

    +

    23.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    22.5 Pragmas

    +

    23.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    22.6 D Exceptions

    +

    23.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    22.7 D Directors

    +

    23.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    22.8 Other features

    +

    23.8 Other features

    -

    22.8.1 Extended namespace support (nspace)

    +

    23.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    22.8.2 Native pointer support

    +

    23.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    22.8.3 Operator overloading

    +

    23.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    22.8.4 Running the test-suite

    +

    23.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    22.9 D Typemap examples

    +

    23.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    22.10 Work in progress and planned features

    +

    23.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index b56657847..aafc650f6 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    41 Extending SWIG to support new languages

    +

    42 Extending SWIG to support new languages

    -

    41.4.4 Attribute namespaces

    +

    42.4.4 Attribute namespaces

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

    -

    41.4.5 Symbol Tables

    +

    42.4.5 Symbol Tables

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

    41.4.6 The %feature directive

    +

    42.4.6 The %feature directive

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

    -

    41.4.7 Code Generation

    +

    42.4.7 Code Generation

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

    -

    41.4.8 SWIG and XML

    +

    42.4.8 SWIG and XML

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

    -

    41.5 Primitive Data Structures

    +

    42.5 Primitive Data Structures

    @@ -988,7 +988,7 @@ typedef Hash Typetab; -

    41.5.1 Strings

    +

    42.5.1 Strings

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

    41.5.2 Hashes

    +

    42.5.2 Hashes

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

    41.5.3 Lists

    +

    42.5.3 Lists

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

    41.5.4 Common operations

    +

    42.5.4 Common operations

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

    41.5.5 Iterating over Lists and Hashes

    +

    42.5.5 Iterating over Lists and Hashes

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

    41.5.6 I/O

    +

    42.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1529,7 +1529,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    41.6 Navigating and manipulating parse trees

    +

    42.6 Navigating and manipulating parse trees

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

    41.7 Working with attributes

    +

    42.7 Working with attributes

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

    41.8 Type system

    +

    42.8 Type system

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

    -

    41.8.1 String encoding of types

    +

    42.8.1 String encoding of types

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

    -

    41.8.2 Type construction

    +

    42.8.2 Type construction

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

    41.8.3 Type tests

    +

    42.8.3 Type tests

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

    41.8.4 Typedef and inheritance

    +

    42.8.4 Typedef and inheritance

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

    41.8.5 Lvalues

    +

    42.8.5 Lvalues

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

    41.8.6 Output functions

    +

    42.8.6 Output functions

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

    41.9 Parameters

    +

    42.9 Parameters

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

    41.10 Writing a Language Module

    +

    42.10 Writing a Language Module

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

    -

    41.10.1 Execution model

    +

    42.10.1 Execution model

    @@ -2471,7 +2471,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.

    -

    41.10.2 Starting out

    +

    42.10.2 Starting out

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

    -

    41.10.3 Command line options

    +

    42.10.3 Command line options

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

    -

    41.10.4 Configuration and preprocessing

    +

    42.10.4 Configuration and preprocessing

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

    -

    41.10.5 Entry point to code generation

    +

    42.10.5 Entry point to code generation

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

    41.10.6 Module I/O and wrapper skeleton

    +

    42.10.6 Module I/O and wrapper skeleton

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

    41.10.7 Low-level code generators

    +

    42.10.7 Low-level code generators

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

    -

    41.10.8 Configuration files

    +

    42.10.8 Configuration files

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

    41.10.9 Runtime support

    +

    42.10.9 Runtime support

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

    -

    41.10.10 Standard library files

    +

    42.10.10 Standard library files

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

    -

    41.10.11 User examples

    +

    42.10.11 User examples

    @@ -3248,7 +3248,7 @@ during this process, see the section on .

    -

    41.10.12 Test driven development and the test-suite

    +

    42.10.12 Test driven development and the test-suite

    @@ -3307,7 +3307,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    41.10.12.1 Running the test-suite

    +

    42.10.12.1 Running the test-suite

    @@ -3499,7 +3499,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    41.10.13 Documentation

    +

    42.10.13 Documentation

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

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

    +

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

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

    -

    41.10.15 Coding style guidelines

    +

    42.10.15 Coding style guidelines

    @@ -3612,7 +3612,7 @@ 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.

    -

    41.11 Debugging Options

    +

    42.11 Debugging Options

    @@ -3639,7 +3639,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    41.12 Guide to parse tree nodes

    +

    42.12 Guide to parse tree nodes

    @@ -4047,7 +4047,7 @@ extern "X" { ... } declaration. -

    41.13 Further Development Information

    +

    42.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 820921bd5..432f932ad 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    23 SWIG and Go

    +

    24 SWIG and Go

    -

    23.3.1 Go-specific Commandline Options

    +

    24.3.1 Go-specific Commandline Options

    @@ -264,7 +264,7 @@ swig -go -help -

    23.3.2 Generated Wrapper Files

    +

    24.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -308,7 +308,7 @@ combined with the compiled MODULE.go using go tool pack. -

    23.4 A tour of basic C/C++ wrapping

    +

    24.4 A tour of basic C/C++ wrapping

    @@ -318,7 +318,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    23.4.1 Go Package Name

    +

    24.4.1 Go Package Name

    @@ -328,7 +328,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    23.4.2 Go Names

    +

    24.4.2 Go Names

    @@ -360,7 +360,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    23.4.3 Go Constants

    +

    24.4.3 Go Constants

    @@ -368,7 +368,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    23.4.4 Go Enumerations

    +

    24.4.4 Go Enumerations

    @@ -378,7 +378,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    23.4.5 Go Classes

    +

    24.4.5 Go Classes

    @@ -456,7 +456,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    23.4.5.1 Go Class Memory Management

    +

    24.4.5.1 Go Class Memory Management

    @@ -578,7 +578,7 @@ func (o *GoClassName) Close() { -

    23.4.5.2 Go Class Inheritance

    +

    24.4.5.2 Go Class Inheritance

    @@ -590,7 +590,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    23.4.6 Go Templates

    +

    24.4.6 Go Templates

    @@ -599,7 +599,7 @@ wrappers for a particular template instantation. To do this, use the %template directive. -

    23.4.7 Go Director Classes

    +

    24.4.7 Go Director Classes

    @@ -617,7 +617,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    23.4.7.1 Example C++ code

    +

    24.4.7.1 Example C++ code

    @@ -689,7 +689,7 @@ be found in the end of the guide.

    -

    23.4.7.2 Enable director feature

    +

    24.4.7.2 Enable director feature

    @@ -724,7 +724,7 @@ documentation on directors.

    -

    23.4.7.3 Constructor and destructor

    +

    24.4.7.3 Constructor and destructor

    @@ -777,7 +777,7 @@ embedding.

    -

    23.4.7.4 Override virtual methods

    +

    24.4.7.4 Override virtual methods

    @@ -843,7 +843,7 @@ the Go methods.

    -

    23.4.7.5 Call base methods

    +

    24.4.7.5 Call base methods

    @@ -880,7 +880,7 @@ be found in the end of the guide.

    -

    23.4.7.6 Subclass via embedding

    +

    24.4.7.6 Subclass via embedding

    @@ -948,7 +948,7 @@ class.

    -

    23.4.7.7 Memory management with runtime.SetFinalizer

    +

    24.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1013,7 +1013,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    23.4.7.8 Complete FooBarGo example class

    +

    24.4.7.8 Complete FooBarGo example class

    @@ -1142,7 +1142,7 @@ SWIG/Examples/go/director/.

    -

    23.4.8 Default Go primitive type mappings

    +

    24.4.8 Default Go primitive type mappings

    @@ -1249,7 +1249,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    23.4.9 Output arguments

    +

    24.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1302,7 +1302,7 @@ void f(char *output); -

    23.4.10 Adding additional go code

    +

    24.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1397,7 +1397,7 @@ func bar() { -

    23.4.11 Go typemaps

    +

    24.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 6acdd2dc3..31d822599 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    24 SWIG and Guile

    +

    25 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      24.1 Supported Guile Versions

      +

      25.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      24.2 Meaning of "Module"

      +

      25.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      24.3 Old GH Guile API

      +

      25.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      24.4 Linkage

      +

      25.4 Linkage

      @@ -89,7 +89,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. -

      24.4.1 Simple Linkage

      +

      25.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      24.4.2 Passive Linkage

      +

      25.4.2 Passive Linkage

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

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

      24.4.3 Native Guile Module Linkage

      +

      25.4.3 Native Guile Module Linkage

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

    -

    24.4.4 Old Auto-Loading Guile Module Linkage

    +

    25.4.4 Old Auto-Loading Guile Module Linkage

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

    24.4.5 Hobbit4D Linkage

    +

    25.4.5 Hobbit4D Linkage

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

    -

    24.5 Underscore Folding

    +

    25.5 Underscore Folding

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

    24.6 Typemaps

    +

    25.6 Typemaps

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

    -

    24.7 Representation of pointers as smobs

    +

    25.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    24.7.1 Smobs

    +

    25.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    24.7.2 Garbage Collection

    +

    25.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 24.8 Native Guile pointers +

    25.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    24.9 Exception Handling

    +

    25.9 Exception Handling

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

    24.10 Procedure documentation

    +

    25.10 Procedure documentation

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

    24.11 Procedures with setters

    +

    25.11 Procedures with setters

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

    24.12 GOOPS Proxy Classes

    +

    25.12 GOOPS Proxy Classes

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

    -

    24.12.1 Naming Issues

    +

    25.12.1 Naming Issues

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

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    24.12.2 Linking

    +

    25.12.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 0140bfa57..d4eee0d4d 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -337,6 +337,7 @@ major features include:

    Most of C++11 is also supported. Details are in the C++11 section. +C++17 support is covered in the C++17 section.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 6b84d540f..9dfaa1fd4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    25 SWIG and Java

    +

    26 SWIG and Java

    -

    25.3.3 Global variables

    +

    26.3.3 Global variables

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

    25.3.4 Constants

    +

    26.3.4 Constants

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

    -

    25.3.5 Enumerations

    +

    26.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    25.3.5.1 Anonymous enums

    +

    26.3.5.1 Anonymous enums

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

    -

    25.3.5.2 Typesafe enums

    +

    26.3.5.2 Typesafe enums

    @@ -1127,7 +1127,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.

    -

    25.3.5.3 Proper Java enums

    +

    26.3.5.3 Proper Java enums

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

    -

    25.3.5.4 Type unsafe enums

    +

    26.3.5.4 Type unsafe enums

    @@ -1228,7 +1228,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.

    -

    25.3.5.5 Simple enums

    +

    26.3.5.5 Simple enums

    @@ -1247,7 +1247,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.

    -

    25.3.6 Pointers

    +

    26.3.6 Pointers

    @@ -1335,7 +1335,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.

    -

    25.3.7 Structures

    +

    26.3.7 Structures

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

    25.3.8 C++ classes

    +

    26.3.8 C++ classes

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

    25.3.9 C++ inheritance

    +

    26.3.9 C++ inheritance

    @@ -1627,7 +1627,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.

    -

    25.3.10 Pointers, references, arrays and pass by value

    +

    26.3.10 Pointers, references, arrays and pass by value

    @@ -1682,7 +1682,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).

    -

    25.3.10.1 Null pointers

    +

    26.3.10.1 Null pointers

    @@ -1706,7 +1706,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.

    -

    25.3.11 C++ overloaded functions

    +

    26.3.11 C++ overloaded functions

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

    25.3.12 C++ default arguments

    +

    26.3.12 C++ default arguments

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

    -

    25.3.13 C++ namespaces

    +

    26.3.13 C++ namespaces

    @@ -1954,7 +1954,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    25.3.14 C++ templates

    +

    26.3.14 C++ templates

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

    -

    25.3.15 C++ Smart Pointers

    +

    26.3.15 C++ Smart Pointers

    -

    25.3.15.1 The shared_ptr Smart Pointer

    +

    26.3.15.1 The shared_ptr Smart Pointer

    @@ -2017,7 +2017,7 @@ in the shared_ptr smart pointer -

    25.3.15.2 Generic Smart Pointers

    +

    26.3.15.2 Generic Smart Pointers

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

    25.4 Further details on the generated Java classes

    +

    26.4 Further details on the generated Java classes

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

    -

    25.4.1 The intermediary JNI class

    +

    26.4.1 The intermediary JNI class

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

    -

    25.4.1.1 The intermediary JNI class pragmas

    +

    26.4.1.1 The intermediary JNI class pragmas

    @@ -2318,7 +2318,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    25.4.2 The Java module class

    +

    26.4.2 The Java module class

    @@ -2349,7 +2349,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.

    -

    25.4.2.1 The Java module class pragmas

    +

    26.4.2.1 The Java module class pragmas

    @@ -2400,7 +2400,7 @@ See The intermediary JNI class pragmas secti

    -

    25.4.3 Java proxy classes

    +

    26.4.3 Java proxy classes

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

    25.4.3.1 Memory management

    +

    26.4.3.1 Memory management

    @@ -2638,7 +2638,7 @@ and

    -

    25.4.3.2 Inheritance

    +

    26.4.3.2 Inheritance

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

    26.4.3.3 Proxy classes and garbage collection

    @@ -2837,7 +2837,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.

    -

    25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2959,7 +2959,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    25.4.3.5 Single threaded applications and thread safety

    +

    26.4.3.5 Single threaded applications and thread safety

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

    25.4.4 Type wrapper classes

    +

    26.4.4 Type wrapper classes

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

    25.4.5 Enum classes

    +

    26.4.5 Enum classes

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

    -

    25.4.5.1 Typesafe enum classes

    +

    26.4.5.1 Typesafe enum classes

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

    -

    25.4.5.2 Proper Java enum classes

    +

    26.4.5.2 Proper Java enum classes

    @@ -3305,7 +3305,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.

    -

    25.4.5.3 Type unsafe enum classes

    +

    26.4.5.3 Type unsafe enum classes

    @@ -3336,7 +3336,7 @@ public final class Beverage { -

    25.4.6 Interfaces

    +

    26.4.6 Interfaces

    @@ -3581,7 +3581,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    25.5 Cross language polymorphism using directors

    +

    26.5 Cross language polymorphism using directors

    @@ -3603,7 +3603,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.

    -

    25.5.1 Enabling directors

    +

    26.5.1 Enabling directors

    @@ -3671,7 +3671,7 @@ public: -

    25.5.2 Director classes

    +

    26.5.2 Director classes

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

    -

    25.5.3 Overhead and code bloat

    +

    26.5.3 Overhead and code bloat

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

    -

    25.5.4 Simple directors example

    +

    26.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    25.5.5 Director threading issues

    +

    26.5.5 Director threading issues

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

    25.5.6 Director performance tuning

    +

    26.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    25.5.7 Java exceptions from directors

    +

    26.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    25.5.7.1 Customizing director exceptions

    +

    26.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    25.6 Accessing protected members

    +

    26.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    25.7 Common customization features

    +

    26.7 Common customization features

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

    -

    25.7.1 C/C++ helper functions

    +

    26.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    25.7.2 Class extension with %extend

    +

    26.7.2 Class extension with %extend

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

    -

    25.7.3 Class extension with %proxycode

    +

    26.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    25.7.4 Exception handling with %exception and %javaexception

    +

    26.7.4 Exception handling with %exception and %javaexception

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

    -

    25.7.5 Method access with %javamethodmodifiers

    +

    26.7.5 Method access with %javamethodmodifiers

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

    25.8 Tips and techniques

    +

    26.8 Tips and techniques

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

    -

    25.8.1 Input and output parameters using primitive pointers and references

    +

    26.8.1 Input and output parameters using primitive pointers and references

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

    -

    25.8.2 Simple pointers

    +

    26.8.2 Simple pointers

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

    -

    25.8.3 Wrapping C arrays with Java arrays

    +

    26.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    25.8.4 Unbounded C Arrays

    +

    26.8.4 Unbounded C Arrays

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

    -

    25.8.5 Binary data vs Strings

    +

    26.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    25.8.6 Overriding new and delete to allocate from Java heap

    +

    26.8.6 Overriding new and delete to allocate from Java heap

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

    -

    25.9 Java typemaps

    +

    26.9 Java typemaps

    @@ -5657,7 +5657,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. -

    25.9.1 Default primitive type mappings

    +

    26.9.1 Default primitive type mappings

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

    -

    25.9.2 Default typemaps for non-primitive types

    +

    26.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    25.9.3 Sixty four bit JVMs

    +

    26.9.3 Sixty four bit JVMs

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

    -

    25.9.4 What is a typemap?

    +

    26.9.4 What is a typemap?

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

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

    +

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

    @@ -6240,7 +6240,7 @@ These are listed below: -

    25.9.6 Java typemap attributes

    +

    26.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    25.9.7 Java special variables

    +

    26.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    25.9.8 Typemaps for both C and C++ compilation

    +

    26.9.8 Typemaps for both C and C++ compilation

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

    -

    25.9.9 Java code typemaps

    +

    26.9.9 Java code typemaps

    @@ -6801,7 +6801,7 @@ to make the method and constructor public: -

    25.9.10 Director specific typemaps

    +

    26.9.10 Director specific typemaps

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

    25.10 Typemap Examples

    +

    26.10 Typemap Examples

    @@ -7088,7 +7088,7 @@ the SWIG library.

    -

    25.10.1 Simpler Java enums for enums without initializers

    +

    26.10.1 Simpler Java enums for enums without initializers

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

    -

    25.10.2 Handling C++ exception specifications as Java exceptions

    +

    26.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    25.10.3 NaN Exception - exception handling for a particular type

    +

    26.10.3 NaN Exception - exception handling for a particular type

    @@ -7447,7 +7447,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.

    -

    25.10.4 Converting Java String arrays to char **

    +

    26.10.4 Converting Java String arrays to char **

    @@ -7591,7 +7591,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    25.10.5 Expanding a Java object to multiple arguments

    +

    26.10.5 Expanding a Java object to multiple arguments

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

    25.10.6 Using typemaps to return arguments

    +

    26.10.6 Using typemaps to return arguments

    @@ -7791,7 +7791,7 @@ $ java runme 1 12.0 340.0 -

    25.10.7 Adding Java downcasts to polymorphic return types

    +

    26.10.7 Adding Java downcasts to polymorphic return types

    @@ -7997,7 +7997,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.

    -

    25.10.8 Adding an equals method to the Java classes

    +

    26.10.8 Adding an equals method to the Java classes

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

    25.10.9 Void pointers and a common Java base class

    +

    26.10.9 Void pointers and a common Java base class

    @@ -8100,7 +8100,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. -

    25.10.10 Struct pointer to pointer

    +

    26.10.10 Struct pointer to pointer

    @@ -8280,7 +8280,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.

    -

    25.10.11 Memory management when returning references to member variables

    +

    26.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

    @@ -8531,7 +8531,7 @@ as mentioned earlier, setElement is actually: -

    25.10.13 Date marshalling using the javain typemap and associated attributes

    +

    26.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8708,7 +8708,7 @@ A few things to note: -

    25.11 Living with Java Directors

    +

    26.11 Living with Java Directors

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

  • -

    25.12 Odds and ends

    +

    26.12 Odds and ends

    -

    25.12.1 JavaDoc comments

    +

    26.12.1 JavaDoc comments

    @@ -8946,7 +8946,7 @@ public class Barmy { -

    25.12.2 Functional interface without proxy classes

    +

    26.12.2 Functional interface without proxy classes

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

    25.12.3 Using your own JNI functions

    +

    26.12.3 Using your own JNI functions

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

    -

    25.12.4 Performance concerns and hints

    +

    26.12.4 Performance concerns and hints

    @@ -9078,7 +9078,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.

    -

    25.12.5 Debugging

    +

    26.12.5 Debugging

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

    -

    25.13 Java Examples

    +

    26.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index b1ec37055..10612f001 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    26 SWIG and Javascript

    +

    27 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      26.1 Overview

      +

      27.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      26.2 Preliminaries

      +

      27.2 Preliminaries

      -

      26.2.1 Running SWIG

      +

      27.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      26.2.2 Running Tests and Examples

      +

      27.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    26.2.3 Known Issues

    +

    27.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -170,12 +170,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    26.3 Integration

    +

    27.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    26.3.1 Creating node.js Extensions

    +

    27.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -221,7 +221,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    26.3.1.1 Troubleshooting

    +

    27.3.1.1 Troubleshooting

      @@ -233,12 +233,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      26.3.2 Embedded Webkit

      +

      27.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      26.3.2.1 Mac OS X

      +

      27.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -286,7 +286,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      26.3.2.2 GTK

      +

      27.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -331,7 +331,7 @@ int main(int argc, char* argv[]) } -

      26.3.3 Creating Applications with node-webkit

      +

      27.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -422,12 +422,12 @@ open new windows, and many more things. }; -

      26.4 Examples

      +

      27.4 Examples

      Some basic examples are shown here in more detail.

      -

      26.4.1 Simple

      +

      27.4.1 Simple

      The common example simple looks like this:

      @@ -477,7 +477,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      26.4.2 Class

      +

      27.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -607,12 +607,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      26.5 Implementation

      +

      27.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      26.5.1 Source Code

      +

      27.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -713,7 +713,7 @@ Template::Template(const String *code_) { ... } ... -

      26.5.2 Code Templates

      +

      27.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -752,7 +752,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      26.5.3 Emitter

      +

      27.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -871,7 +871,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      26.5.4 Emitter states

      +

      27.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -915,7 +915,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      26.5.5 Handling Exceptions in JavascriptCore

      +

      27.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 8a9053917..c2c02fc7d 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -7,7 +7,7 @@ -

      9 SWIG library

      +

      10 SWIG library

      -

      9.2.4 cdata.i

      +

      10.2.4 cdata.i

      @@ -769,7 +769,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      9.3 C string handling

      +

      10.3 C string handling

      @@ -789,7 +789,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      9.3.1 Default string handling

      +

      10.3.1 Default string handling

      @@ -830,7 +830,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      9.3.2 Passing binary data

      +

      10.3.2 Passing binary data

      @@ -872,7 +872,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      9.3.3 Using %newobject to release memory

      +

      10.3.3 Using %newobject to release memory

      @@ -913,7 +913,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      9.3.4 cstring.i

      +

      10.3.4 cstring.i

      @@ -1373,7 +1373,7 @@ structure or class instead.

    -

    9.4 STL/C++ library

    +

    10.4 STL/C++ library

    @@ -1420,7 +1420,7 @@ Please look for the library files in the appropriate language library directory.

    -

    9.4.1 std::string

    +

    10.4.1 std::string

    @@ -1504,7 +1504,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    9.4.2 std::vector

    +

    10.4.2 std::vector

    @@ -1683,7 +1683,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    9.4.3 STL exceptions

    +

    10.4.3 STL exceptions

    @@ -1733,10 +1733,10 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    9.4.4 shared_ptr smart pointer

    +

    10.4.4 shared_ptr smart pointer

    -

    9.4.4.1 shared_ptr basics

    +

    10.4.4.1 shared_ptr basics

    @@ -1832,7 +1832,7 @@ System.out.println(val1 + " " + val2); -

    9.4.4.2 shared_ptr and inheritance

    +

    10.4.4.2 shared_ptr and inheritance

    @@ -1923,7 +1923,7 @@ Adding the missing %shared_ptr macros will fix this: -

    9.4.4.3 shared_ptr and method overloading

    +

    10.4.4.3 shared_ptr and method overloading

    @@ -1945,7 +1945,7 @@ SWIG will choose to wrap just the first method by default. For the interested reader, SWIG detects that they are equivalent types via the typecheck typemaps in the shared_ptr library.

    -

    9.4.4.4 shared_ptr and templates

    +

    10.4.4.4 shared_ptr and templates

    @@ -1987,7 +1987,7 @@ The SWIG code below shows the required ordering: -

    9.4.4.5 shared_ptr and directors

    +

    10.4.4.5 shared_ptr and directors

    @@ -1995,7 +1995,7 @@ The languages that support shared_ptr also have support for using shared_ptr wit

    -

    9.4.5 auto_ptr smart pointer

    +

    10.4.5 auto_ptr smart pointer

    @@ -2044,10 +2044,10 @@ int value = k.getValue(); -

    9.5 Utility Libraries

    +

    10.5 Utility Libraries

    -

    9.5.1 exception.i

    +

    10.5.1 exception.i

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 7bf8562c5..0d9e3dc4f 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -7,7 +7,7 @@ -

    27 SWIG and Common Lisp

    +

    28 SWIG and Common Lisp

    -

    27.2.3 Generating CFFI bindings for C++ code

    +

    28.2.3 Generating CFFI bindings for C++ code

    This feature to SWIG (for CFFI) is very new and still far from @@ -582,7 +582,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. -

    27.2.4 Inserting user code into generated files

    +

    28.2.4 Inserting user code into generated files

    @@ -622,7 +622,7 @@ Note that the block %{ ... %} is effectively a shortcut for

    -

    27.3 CLISP

    +

    28.3 CLISP

    @@ -652,7 +652,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.

    -

    27.3.1 Additional Commandline Options

    +

    28.3.1 Additional Commandline Options

    @@ -685,7 +685,7 @@ shortcuts according to the typedefs in the input. -

    27.3.2 Details on CLISP bindings

    +

    28.3.2 Details on CLISP bindings

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

    27.4 UFFI

    +

    28.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index c5c944225..8e545776f 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

    28 SWIG and Lua

    +

    29 SWIG and Lua

      @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      28.1 Preliminaries

      +

      29.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      28.2 Running SWIG

      +

      29.2 Running SWIG

      @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      28.2.1 Additional command line options

      +

      29.2.1 Additional command line options

      @@ -179,7 +179,7 @@ swig -lua -help -

      28.2.2 Compiling and Linking and Interpreter

      +

      29.2.2 Compiling and Linking and Interpreter

      @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      28.2.3 Compiling a dynamic module

      +

      29.2.3 Compiling a dynamic module

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

      28.2.4 Using your module

      +

      29.2.4 Using your module

      @@ -336,19 +336,19 @@ $ ./my_lua >

    -

    28.3 A tour of basic C/C++ wrapping

    +

    29.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.

    -

    28.3.1 Modules

    +

    29.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.

    -

    28.3.2 Functions

    +

    29.3.2 Functions

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

    28.3.3 Global variables

    +

    29.3.3 Global variables

    @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    28.3.4 Constants and enums

    +

    29.3.4 Constants and enums

    @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    28.3.4.1 Constants/enums and classes/structures

    +

    29.3.4.1 Constants/enums and classes/structures

    @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    28.3.5 Pointers

    +

    29.3.5 Pointers

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

    28.3.6 Structures

    +

    29.3.6 Structures

    @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    28.3.7 C++ classes

    +

    29.3.7 C++ classes

    @@ -785,7 +785,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    28.3.8 C++ inheritance

    +

    29.3.8 C++ inheritance

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

    It is safe to use multiple inheritance with SWIG.

    -

    28.3.9 Pointers, references, values, and arrays

    +

    29.3.9 Pointers, references, values, and arrays

    @@ -841,7 +841,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.

    -

    28.3.10 C++ overloaded functions

    +

    29.3.10 C++ overloaded functions

    @@ -927,7 +927,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.

    -

    28.3.11 C++ operators

    +

    29.3.11 C++ operators

    @@ -1059,7 +1059,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    28.3.12 Class extension with %extend

    +

    29.3.12 Class extension with %extend

    @@ -1116,7 +1116,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).

    -

    28.3.13 Using %newobject to release memory

    +

    29.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1140,7 +1140,7 @@ char *foo();

    This will release the allocated memory.

    -

    28.3.14 C++ templates

    +

    29.3.14 C++ templates

    @@ -1175,7 +1175,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.

    -

    28.3.15 C++ Smart Pointers

    +

    29.3.15 C++ Smart Pointers

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

    28.3.16 C++ Exceptions

    +

    29.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    28.3.17 Namespaces

    +

    29.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    28.3.17.1 Compatibility Note

    +

    29.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    28.3.17.2 Names

    +

    29.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    28.3.17.3 Inheritance

    +

    29.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    28.4 Typemaps

    +

    29.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    28.4.1 What is a typemap?

    +

    29.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:

    @@ -1555,7 +1555,7 @@ Received an integer : 6 720 -

    28.4.2 Using typemaps

    +

    29.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.

    @@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);

    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).

    -

    28.4.3 Typemaps and arrays

    +

    29.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 @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

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

    -

    28.4.4 Typemaps and pointer-pointer functions

    +

    29.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:

    @@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    28.5 Writing typemaps

    +

    29.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.

    @@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    28.5.1 Typemaps you can write

    +

    29.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.

    @@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    28.5.2 SWIG's Lua-C API

    +

    29.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.

    @@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    28.6 Customization of your Bindings

    +

    29.6 Customization of your Bindings

    @@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -

    28.6.1 Writing your own custom wrappers

    +

    29.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    28.6.2 Adding additional Lua code

    +

    29.6.2 Adding additional Lua code

    @@ -1843,7 +1843,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.

    -

    28.7 Details on the Lua binding

    +

    29.7 Details on the Lua binding

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

    -

    28.7.1 Binding global data into the module.

    +

    29.7.1 Binding global data into the module.

    @@ -1914,7 +1914,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)'.

    -

    28.7.2 Userdata and Metatables

    +

    29.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    28.7.3 Memory management

    +

    29.7.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index 75f3f80ff..bdfc5992d 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -6,7 +6,7 @@ -

    29 SWIG and Modula-3

    +

    30 SWIG and Modula-3

    -

    29.4.5 Exceptions

    +

    30.4.5 Exceptions

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

    -

    29.4.6 Example

    +

    30.4.6 Example

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

    29.5 More hints to the generator

    +

    30.5 More hints to the generator

    -

    29.5.1 Features

    +

    30.5.1 Features

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

    29.5.2 Pragmas

    +

    30.5.2 Pragmas

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

    29.6 Remarks

    +

    30.6 Remarks

    -

    39.4.5 STL

    +

    40.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    39.5 Module initialization

    +

    40.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    39.6 Building modes

    +

    40.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    39.6.1 No-builder mode

    +

    40.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    39.6.2 Builder mode

    +

    40.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    39.7 Generated scripts

    +

    40.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    39.7.1 Builder script

    +

    40.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    39.7.2 Loader script

    +

    40.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    39.8 Other resources

    +

    40.8 Other resources

    -

    11.4 Code generation rules

    +

    12.4 Code generation rules

    @@ -1855,7 +1855,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    11.4.1 Scope

    +

    12.4.1 Scope

    @@ -1933,7 +1933,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    11.4.2 Declaring new local variables

    +

    12.4.2 Declaring new local variables

    @@ -2100,7 +2100,7 @@ each type must have its own local variable declaration. -

    11.4.3 Special variables

    +

    12.4.3 Special variables

    @@ -2352,7 +2352,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    11.4.4 Special variable macros

    +

    12.4.4 Special variable macros

    @@ -2364,7 +2364,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    11.4.4.1 $descriptor(type)

    +

    12.4.4.1 $descriptor(type)

    @@ -2375,7 +2375,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    11.4.4.2 $typemap(method, typepattern)

    +

    12.4.4.2 $typemap(method, typepattern)

    @@ -2433,7 +2433,7 @@ The result is the following expansion -

    11.4.5 Special variables and typemap attributes

    +

    12.4.5 Special variables and typemap attributes

    @@ -2460,7 +2460,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    11.4.6 Special variables combined with special variable macros

    +

    12.4.6 Special variables combined with special variable macros

    @@ -2502,7 +2502,7 @@ which then expands to: -

    11.5 Common typemap methods

    +

    12.5 Common typemap methods

    @@ -2510,7 +2510,7 @@ The set of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    11.5.1 "in" typemap

    +

    12.5.1 "in" typemap

    @@ -2570,7 +2570,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    11.5.2 "typecheck" typemap

    +

    12.5.2 "typecheck" typemap

    @@ -2597,7 +2597,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    11.5.3 "out" typemap

    +

    12.5.3 "out" typemap

    @@ -2628,7 +2628,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    11.5.4 "arginit" typemap

    +

    12.5.4 "arginit" typemap

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

    11.5.5 "default" typemap

    +

    12.5.5 "default" typemap

    @@ -2680,7 +2680,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    11.5.6 "check" typemap

    +

    12.5.6 "check" typemap

    @@ -2699,7 +2699,7 @@ converted. For example: -

    11.5.7 "argout" typemap

    +

    12.5.7 "argout" typemap

    @@ -2745,7 +2745,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    11.5.8 "freearg" typemap

    +

    12.5.8 "freearg" typemap

    @@ -2778,7 +2778,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    11.5.9 "newfree" typemap

    +

    12.5.9 "newfree" typemap

    @@ -2807,7 +2807,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    11.5.10 "ret" typemap

    +

    12.5.10 "ret" typemap

    @@ -2846,7 +2846,7 @@ This approach is an alternative to using the "newfree" typemap and %newobjec is no need to list all the functions that require the memory cleanup, it is purely done on types.

    -

    11.5.11 "memberin" typemap

    +

    12.5.11 "memberin" typemap

    @@ -2868,7 +2868,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    -

    11.5.12 "varin" typemap

    +

    12.5.12 "varin" typemap

    @@ -2876,7 +2876,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    11.5.13 "varout" typemap

    +

    12.5.13 "varout" typemap

    @@ -2884,7 +2884,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    11.5.14 "throws" typemap

    +

    12.5.14 "throws" typemap

    @@ -2934,7 +2934,7 @@ Note that if your methods do not have an exception specification but they do thr Please also see the Exception handling with %exception section for another way to handle exceptions.

    -

    11.6 Some typemap examples

    +

    12.6 Some typemap examples

    @@ -2942,7 +2942,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    11.6.1 Typemaps for arrays

    +

    12.6.1 Typemaps for arrays

    @@ -3201,7 +3201,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    11.6.2 Implementing constraints with typemaps

    +

    12.6.2 Implementing constraints with typemaps

    @@ -3249,7 +3249,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    11.7 Typemaps for multiple target languages

    +

    12.7 Typemaps for multiple target languages

    @@ -3279,7 +3279,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby, in) int "$1 = NUM2INT($input);".

    -

    11.8 Optimal code generation when returning by value

    +

    12.8 Optimal code generation when returning by value

    @@ -3468,7 +3468,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    11.9 Multi-argument typemaps

    +

    12.9 Multi-argument typemaps

    @@ -3745,7 +3745,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    11.10 Typemap warnings

    +

    12.10 Typemap warnings

    @@ -3754,7 +3754,7 @@ See the information in the issuing warnings

    -

    11.11 Typemap fragments

    +

    12.11 Typemap fragments

    @@ -4090,7 +4090,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    11.11.1 Fragment type specialization

    +

    12.11.1 Fragment type specialization

    @@ -4123,7 +4123,7 @@ struct A { -

    11.11.2 Fragments and automatic typemap specialization

    +

    12.11.2 Fragments and automatic typemap specialization

    @@ -4169,7 +4169,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    11.12 The run-time type checker

    +

    12.12 The run-time type checker

    @@ -4195,7 +4195,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    11.12.1 Implementation

    +

    12.12.1 Implementation

    @@ -4389,7 +4389,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    11.12.2 Usage

    +

    12.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4485,7 +4485,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    11.13 Typemaps and overloading

    +

    12.13 Typemaps and overloading

    @@ -4792,7 +4792,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    11.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    +

    12.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    @@ -4894,7 +4894,7 @@ Otherwise both can be wrapped by removing the overloading name ambiguity by rena The 'equivalent' attribute is used in the implementation for the shared_ptr smart pointer library.

    -

    11.14 More about %apply and %clear

    +

    12.14 More about %apply and %clear

    @@ -4980,7 +4980,7 @@ example: -

    11.15 Passing data between typemaps

    +

    12.15 Passing data between typemaps

    @@ -5017,7 +5017,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    11.16 C++ "this" pointer

    +

    12.16 C++ "this" pointer

    @@ -5077,7 +5077,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    11.17 Where to go for more information?

    +

    12.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 014a38cae..c6f0e8c63 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -7,7 +7,7 @@ -

    14 Variable Length Arguments

    +

    15 Variable Length Arguments

      @@ -43,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      14.1 Introduction

      +

      15.1 Introduction

      @@ -140,7 +140,7 @@ List make_list(const char *s, ...) {

    -

    14.2 The Problem

    +

    15.2 The Problem

    @@ -233,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    14.3 Default varargs support

    +

    15.3 Default varargs support

    @@ -302,7 +302,7 @@ Read on for further solutions.

    -

    14.4 Argument replacement using %varargs

    +

    15.4 Argument replacement using %varargs

    @@ -413,7 +413,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    14.5 Varargs and typemaps

    +

    15.5 Varargs and typemaps

    @@ -593,7 +593,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    14.6 Varargs wrapping with libffi

    +

    15.6 Varargs wrapping with libffi

    @@ -845,7 +845,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    14.7 Wrapping of va_list

    +

    15.7 Wrapping of va_list

    @@ -899,7 +899,7 @@ int my_vprintf(const char *fmt, ...) { -

    14.8 C++ Issues

    +

    15.8 C++ Issues

    @@ -968,7 +968,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    14.9 Discussion

    +

    15.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index e7b291f21..75ca11561 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -7,7 +7,7 @@ -

    15 Warning Messages

    +

    16 Warning Messages

    -

    15.5 Symbolic symbols

    +

    16.5 Symbolic symbols

    @@ -310,7 +310,7 @@ or -

    15.6 Commentary

    +

    16.6 Commentary

    @@ -327,7 +327,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    15.7 Warnings as errors

    +

    16.7 Warnings as errors

    @@ -336,7 +336,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    15.8 Message output format

    +

    16.8 Message output format

    @@ -355,10 +355,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    15.9 Warning number reference

    +

    16.9 Warning number reference

    -

    15.9.1 Deprecated features (100-199)

    +

    16.9.1 Deprecated features (100-199)

      @@ -386,7 +386,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    15.9.2 Preprocessor (200-299)

    +

    16.9.2 Preprocessor (200-299)

      @@ -398,7 +398,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    15.9.3 C/C++ Parser (300-399)

    +

    16.9.3 C/C++ Parser (300-399)

      @@ -475,7 +475,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    15.9.4 Types and typemaps (400-499)

    +

    16.9.4 Types and typemaps (400-499)

      @@ -506,7 +506,7 @@ example.i(4) : Syntax error in input(1). -

      15.9.5 Code generation (500-599)

      +

      16.9.5 Code generation (500-599)

        @@ -535,7 +535,7 @@ example.i(4) : Syntax error in input(1).
      • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.
      -

      15.9.6 Language module specific (700-899)

      +

      16.9.6 Language module specific (700-899)

        @@ -586,14 +586,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      15.9.7 User defined (900-999)

      +

      16.9.7 User defined (900-999)

      These numbers can be used by your own application.

      -

      15.10 History

      +

      16.10 History

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index d94a8a396..41ecc9c57 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -5,6 +5,7 @@ Scripting.html SWIG.html SWIGPlus.html CPlusPlus11.html +CPlusPlus17.html Preprocessor.html Library.html Arguments.html From 2171f526351cbb5a966e93a05d7f5b5a1aea2af4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 May 2018 22:22:10 +0100 Subject: [PATCH 0936/2031] Javascript %nspace fix in generated C++ code When using %nspace on namespaces that are more than two levels deep. Fixes cpp17_nspace_nested_namespaces testcase. --- CHANGES.current | 4 ++++ Source/Modules/javascript.cxx | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b3463dacd..4da8b846a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-05-15: wsfulton + [Javascript] Fix generated C++ code when using %nspace on namespaces that are more + than two levels deep. + 2018-05-14: wsfulton Issue #1251 Add support for C++17 nested namespace definitions, for example: diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 490ee7fd3..df51e3224 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -33,6 +33,7 @@ static bool js_template_enable_debug = false; #define GETTER "getter" #define SETTER "setter" #define PARENT "parent" +#define PARENT_MANGLED "parent_mangled" #define CTOR "ctor" #define CTOR_WRAPPERS "ctor_wrappers" #define CTOR_DISPATCHERS "ctor_dispatchers" @@ -262,7 +263,7 @@ protected: virtual int createNamespace(String *scope); - virtual Hash *createNamespaceEntry(const char *name, const char *parent); + virtual Hash *createNamespaceEntry(const char *name, const char *parent, const char *parent_mangled); virtual int emitNamespaces() = 0; @@ -664,7 +665,7 @@ int JSEmitter::initialize(Node * /*n */ ) { Delete(namespaces); } namespaces = NewHash(); - Hash *global_namespace = createNamespaceEntry("exports", 0); + Hash *global_namespace = createNamespaceEntry("exports", 0, 0); Setattr(namespaces, "::", global_namespace); current_namespace = global_namespace; @@ -1428,19 +1429,20 @@ int JSEmitter::createNamespace(String *scope) { } assert(parent_namespace != 0); - Hash *new_namespace = createNamespaceEntry(Char(scope), Char(Getattr(parent_namespace, "name"))); + Hash *new_namespace = createNamespaceEntry(Char(scope), Char(Getattr(parent_namespace, "name")), Char(Getattr(parent_namespace, "name_mangled"))); Setattr(namespaces, scope, new_namespace); Delete(parent_scope); return SWIG_OK; } -Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent) { +Hash *JSEmitter::createNamespaceEntry(const char *_name, const char *parent, const char *parent_mangled) { Hash *entry = NewHash(); String *name = NewString(_name); Setattr(entry, NAME, Swig_scopename_last(name)); Setattr(entry, NAME_MANGLED, Swig_name_mangle(name)); Setattr(entry, PARENT, NewString(parent)); + Setattr(entry, PARENT_MANGLED, NewString(parent_mangled)); Delete(name); return entry; @@ -1467,7 +1469,7 @@ protected: virtual int enterClass(Node *n); virtual int exitClass(Node *n); virtual void marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, MarshallingMode mode, bool is_member, bool is_static); - virtual Hash *createNamespaceEntry(const char *name, const char *parent); + virtual Hash *createNamespaceEntry(const char *name, const char *parent, const char *parent_mangled); virtual int emitNamespaces(); private: @@ -1773,8 +1775,8 @@ int JSCEmitter::exitClass(Node *n) { return SWIG_OK; } -Hash *JSCEmitter::createNamespaceEntry(const char *name, const char *parent) { - Hash *entry = JSEmitter::createNamespaceEntry(name, parent); +Hash *JSCEmitter::createNamespaceEntry(const char *name, const char *parent, const char *parent_mangled) { + Hash *entry = JSEmitter::createNamespaceEntry(name, parent, parent_mangled); Setattr(entry, "functions", NewString("")); Setattr(entry, "values", NewString("")); return entry; @@ -1786,8 +1788,7 @@ int JSCEmitter::emitNamespaces() { Hash *entry = it.item; String *name = Getattr(entry, NAME); String *name_mangled = Getattr(entry, NAME_MANGLED); - String *parent = Getattr(entry, PARENT); - String *parent_mangled = Swig_name_mangle(parent); + String *parent_mangled = Getattr(entry, PARENT_MANGLED); String *functions = Getattr(entry, "functions"); String *variables = Getattr(entry, "values"); @@ -2206,7 +2207,7 @@ int V8Emitter::emitNamespaces() { String *name = Getattr(entry, NAME); String *name_mangled = Getattr(entry, NAME_MANGLED); String *parent = Getattr(entry, PARENT); - String *parent_mangled = Swig_name_mangle(parent); + String *parent_mangled = Getattr(entry, PARENT_MANGLED); bool do_create = true; bool do_register = true; From 63a5a8af88271559a7b170794b4c61c30b8934ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Mar 2018 19:27:55 +0000 Subject: [PATCH 0937/2031] Fix lookup of csconstruct, dconstructor and javaconstruct typemaps The C++ namespace was previously ignored in the lookup type --- Source/Modules/csharp.cxx | 3 ++- Source/Modules/d.cxx | 3 ++- Source/Modules/java.cxx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 8bd25aa48..ff9c1ae8b 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -2788,7 +2788,8 @@ public: /* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); - String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"), + String *typemap_lookup_type = Getattr(getCurrentClass(), "classtypeobj"); + String *construct_tm = Copy(typemapLookup(n, "csconstruct", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 0c3f020a8..d740f0a17 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -1227,8 +1227,9 @@ public: // Insert the dconstructor typemap (replacing $directorconnect as needed). Hash *attributes = NewHash(); + String *typemap_lookup_type = Getattr(getCurrentClass(), "classtypeobj"); String *construct_tm = Copy(lookupCodeTypemap(n, "dconstructor", - Getattr(n, "name"), WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF, attributes)); + typemap_lookup_type, WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF, attributes)); if (construct_tm) { const bool use_director = (parentNode(n) && Swig_directorclass(n)); if (!use_director) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index f89de4e12..2c42a01be 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2767,7 +2767,8 @@ public: /* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); - String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"), + String *typemap_lookup_type = Getattr(getCurrentClass(), "classtypeobj"); + String *construct_tm = Copy(typemapLookup(n, "javaconstruct", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { From fecc4f246e75c83649286474a75fd331f32f287b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 May 2018 22:38:30 +0100 Subject: [PATCH 0938/2031] Add changes entry for csconstruct, dconstruct and javaconstruct fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 4da8b846a..1b028f301 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-05-15: wsfulton + [C#, D, Java] Fix lookup of csconstruct, dconstruct and javaconstruct typemaps. + The C++ namespace was previously ignored when looking up the typemap. + 2018-05-15: wsfulton [Javascript] Fix generated C++ code when using %nspace on namespaces that are more than two levels deep. From 1f76cda125668d9b89de5e5f70a5bc1d9dc06cca Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 May 2018 23:30:12 +0100 Subject: [PATCH 0939/2031] Javascript test-suite Makefile parallel jobs Suppress warning running test-suite and examples: make[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule. Note that node-gyp uses make under the hood and clearing the MAKEFILE env is the only way I could find to suppress this warning. --- Examples/Makefile.in | 2 +- Examples/test-suite/javascript/Makefile.in | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 58da8ec1d..d22450ec9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -671,7 +671,7 @@ javascript_build: $(SRCDIR_SRCS) javascript_build_cpp: $(SRCDIR_SRCS) ifeq (node,$(JSENGINE)) sed -e 's|$$srcdir|./$(SRCDIR)|g' $(SRCDIR)binding.gyp.in > binding.gyp - $(NODEGYP) --loglevel=silent configure build 1>>/dev/null + MAKEFLAGS= $(NODEGYP) --loglevel=silent configure build 1>>/dev/null else $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(JSINCLUDES) $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(JSDYNAMICLINKING) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index b430f236f..8127415f1 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -66,14 +66,14 @@ ifeq (node,$(JSENGINE)) $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='-javascript $(SWIGOPT) -o $*_wrap.cxx $(srcdir)/../$*.i' swiginvoke && \ - $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null + MAKEFLAGS= $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null swig_and_compile_cpp = \ $(setup_node) && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='-c++ -javascript $(SWIGOPT) $(srcdir)/../$*.i' swiginvoke && \ - $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null + MAKEFLAGS= $(COMPILETOOL) $(NODEGYP) --loglevel=silent --directory $* configure build 1>>/dev/null run_testcase = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ @@ -83,12 +83,12 @@ ifeq (node,$(JSENGINE)) %.ctest: $(_setup) - $(swig_and_compile_c) + +$(swig_and_compile_c) $(run_testcase) %.cpptest: $(_setup) - $(swig_and_compile_cpp) + +$(swig_and_compile_cpp) $(run_testcase) %.multicpptest: From f09952e30c96d3fae056fe75f3008865f9437d5c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 May 2018 07:53:42 +0100 Subject: [PATCH 0940/2031] Fixes for appveyor image changes Appveyor image has removed older boosts. Use latest - 1.67 available. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 20d4fe9ea..52ff742e0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -93,7 +93,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor -- if "%OSVARIANT%"=="" bash -c "exec 0 Date: Thu, 17 May 2018 08:20:01 +0100 Subject: [PATCH 0941/2031] Add Octave 4.4 to Travis allow_failures --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index d0e1239ce..528a4008f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -361,6 +361,12 @@ matrix: env: SWIGLANG=ocaml sudo: required dist: trusty + # Sometimes hits the Travis 50 minute time limit + - compiler: gcc + os: linux + env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 + sudo: required + dist: trusty # Not quite working yet - compiler: gcc os: linux From 60dfa31a67601f25a3ca171ae7d2503a46e0ec03 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Mon, 14 May 2018 11:00:52 -0400 Subject: [PATCH 0942/2031] Misc. typos found via `codespell` and `grep` --- CHANGES | 2 +- CHANGES.current | 4 ++-- Doc/Devel/tree.html | 2 +- Doc/Manual/Allegrocl.html | 4 ++-- Doc/Manual/CSharp.html | 4 ++-- Doc/Manual/Contents.html | 2 +- Doc/Manual/Go.html | 12 ++++++------ Doc/Manual/Java.html | 6 +++--- Doc/Manual/Javascript.html | 2 +- Doc/Manual/Preface.html | 2 +- Doc/Manual/Python.html | 4 ++-- Doc/Manual/Scilab.html | 14 +++++++------- Examples/go/director/director.go | 4 ++-- Examples/guile/matrix/runme.scm | 2 +- Examples/guile/multivalue/example.i | 4 ++-- Examples/javascript/exception/runme.js | 10 +++++----- Examples/javascript/variables/runme.js | 2 +- Examples/lua/arrays/runme.lua | 2 +- Examples/lua/class/runme.lua | 2 +- Examples/lua/constants/runme.lua | 2 +- Examples/lua/dual/dual.cpp | 2 +- Examples/lua/exception/runme.lua | 4 ++-- Examples/lua/funcptr3/runme.lua | 2 +- Examples/lua/functest/runme.lua | 2 +- Examples/lua/functor/runme.lua | 2 +- Examples/lua/import/runme.lua | 2 +- Examples/lua/nspace/runme.lua | 2 +- Examples/lua/owner/runme.lua | 2 +- Examples/lua/pointer/runme.lua | 2 +- Examples/lua/simple/runme.lua | 2 +- Examples/lua/variables/runme.lua | 8 ++++---- Examples/octave/variables/runme.m | 2 +- Examples/perl5/variables/runme.pl | 2 +- Examples/php/disown/runme.php | 4 ++-- Examples/php5/disown/runme.php | 4 ++-- Examples/python/variables/runme.py | 2 +- Examples/ruby/variables/runme.rb | 2 +- Examples/scilab/std_list/runme.sci | 2 +- Examples/scilab/variables/runme.sci | 2 +- Examples/tcl/variables/runme.tcl | 2 +- .../errors/pp_macro_missing_expression.i | 2 +- Examples/test-suite/lua/li_std_string_runme.lua | 4 ++-- Examples/test-suite/lua/newobject2_runme.lua | 4 ++-- Examples/test-suite/multivalue.i | 4 ++-- .../test-suite/octave/return_const_value_runme.m | 4 ++-- Examples/test-suite/php/tests.php | 2 +- .../test-suite/php/threads_exception_runme.php | 2 +- Examples/test-suite/php5/tests.php | 2 +- .../test-suite/php5/threads_exception_runme.php | 2 +- Examples/test-suite/python/python_pybuf_runme3.py | 2 +- .../test-suite/python/return_const_value_runme.py | 4 ++-- Examples/test-suite/redefined_not.i | 2 +- Examples/test-suite/scilab/Makefile.in | 2 +- .../scilab/li_std_container_typemaps_runme.sci | 4 ++-- Examples/test-suite/scilab/li_std_deque_runme.sci | 2 +- .../test-suite/scilab/scilab_li_matrix_runme.sci | 6 +++--- .../test-suite/scilab/throw_exception_runme.sci | 10 +++++----- Examples/test-suite/template_class_reuse_name.i | 2 +- Examples/test-suite/template_typedef_cplx5.i | 2 +- Lib/d/dprimitives.swg | 2 +- Lib/javascript/jsc/javascriptcode.swg | 2 +- Lib/javascript/v8/javascriptrun.swg | 4 ++-- Lib/lua/lua.swg | 2 +- Lib/lua/luarun.swg | 6 +++--- Lib/lua/typemaps.i | 2 +- Lib/octave/octiterators.swg | 2 +- Lib/python/pyuserdir.swg | 2 +- Lib/ruby/rubyiterators.swg | 2 +- Lib/ruby/rubyuserdir.swg | 2 +- Lib/scilab/sciiterators.swg | 2 +- Lib/scilab/scirun.swg | 6 +++--- Lib/tcl/mactkinit.c | 8 ++++---- Source/CParse/parser.y | 4 ++-- Source/Modules/allocate.cxx | 2 +- Source/Modules/csharp.cxx | 4 ++-- Source/Modules/d.cxx | 10 +++++----- Source/Modules/go.cxx | 2 +- Source/Modules/java.cxx | 6 +++--- Source/Modules/javascript.cxx | 6 +++--- Source/Modules/lang.cxx | 2 +- Source/Modules/lua.cxx | 6 +++--- Source/Modules/modula3.cxx | 8 ++++---- Source/Modules/mzscheme.cxx | 2 +- Source/Modules/ruby.cxx | 2 +- Source/Swig/misc.c | 2 +- Source/Swig/naming.c | 2 +- Source/Swig/scanner.c | 4 ++-- Source/Swig/swig.h | 2 +- Source/Swig/swigscan.h | 2 +- Source/Swig/typesys.c | 2 +- 90 files changed, 155 insertions(+), 155 deletions(-) diff --git a/CHANGES b/CHANGES index d18a11bb6..958e7cb0c 100644 --- a/CHANGES +++ b/CHANGES @@ -11605,7 +11605,7 @@ Version 1.3.23 (November 11, 2004) - Properly qualify type in syntax as 'long(2)' or 'Foo()', this solve old problem with default args, and probably other problems around. However, the default arg problem - was also already solved by William (see bellow). + was also already solved by William (see below). - Fix feature_set and feature_get methods. Before they look from particular to general and keep the first diff --git a/CHANGES.current b/CHANGES.current index 2e1934cce..5147a315f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -67,7 +67,7 @@ Version 4.0.0 (in progress) std_complex.i. 2018-01-30: smarchetto - [Scilab] add type name argument in SWIG_ptr() function to cast from pointer adress to typed pointers + [Scilab] add type name argument in SWIG_ptr() function to cast from pointer address to typed pointers 2018-01-16: wsfulton Expressions following a preprocessor directive must now be separated by whitespace @@ -201,7 +201,7 @@ Version 4.0.0 (in progress) 2017-10-01: joequant allow R package names with docs - allowing mulitple get accessors in R + allowing multiple get accessors in R fix smrt-pointer and NAMESPACE support constructors now returning smart pointers (if class declared as such) diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html index 73a49ed55..5bb4b6a1e 100644 --- a/Doc/Devel/tree.html +++ b/Doc/Devel/tree.html @@ -236,7 +236,7 @@ The following functions can be used to help debug SWIG parse trees.

      Prints the tag-structure of the parse tree to standard output. node is the top-level parse tree node. prefix is -a string prefix thats added to the start of each line. Normally, you would specify the empty string or NIL for prefix. +a string prefix that's added to the start of each line. Normally, you would specify the empty string or NIL for prefix. This function is called by the -debug-tags option to SWIG.
      diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html
      index f8e5d013e..874c4bc2e 100644
      --- a/Doc/Manual/Allegrocl.html
      +++ b/Doc/Manual/Allegrocl.html
      @@ -610,7 +610,7 @@ char *xxx();
       
       
         

      - In the case of overloaded functions, mulitple layers are + In the case of overloaded functions, multiple layers are generated. First, all the overloads for a given name are separated out into groups based on arity, and are wrapped in defmethods. Each method calls a distinct wrapper function, but are @@ -1239,7 +1239,7 @@ int zzz(A *inst = 0); /* return inst->x + inst->y */ We resolve this issue, by noting synonym relationships between types while generating the interface. A Primary type is selected (more on this below) from the candidate list of synonyms. For - all other synonyms, intead of generating a distinct CLOS class + all other synonyms, instead of generating a distinct CLOS class definition, we generate a form that expands to:

      diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 85d651fd1..15e89e517 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1989,7 +1989,7 @@ and more or less equivalent usage from C#

      The C++ code will always print out 20, but the value printed out may not be this in the C# equivalent code. -In order to understand why, consider a garbage collection occuring... +In order to understand why, consider a garbage collection occurring...

      @@ -2141,7 +2141,7 @@ The CDate & and const CDate & C# code is generated fro

      where '$csclassname' is translated into the proxy class name, CDate and '$csinput' is translated into the name of the parameter, eg dateIn. -From C#, the intention is then to call into a modifed API with something like: +From C#, the intention is then to call into a modified API with something like:

      diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index c79416e77..6a2daf9a8 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1853,7 +1853,7 @@
  • Pointers
  • Structures diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 432f932ad..c5efe8265 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -471,7 +471,7 @@ The most Go idiomatic way to manage the memory for some C++ class is to call defer of the DeleteClassName call. Using defer ensures that the memory of the C++ object is freed as soon as the function containing the defer -statement returns. Furthemore defer works great for short-lived +statement returns. Furthermore defer works great for short-lived objects and fits nicely C++'s RAII idiom. Example:

    @@ -512,7 +512,7 @@ func main() {

    Using defer has limitations though, especially when it comes to -long-lived C++ objects whichs lifetimes are hard to predict. For such C++ +long-lived C++ objects whose lifetimes are hard to predict. For such C++ objects a common technique is to store the C++ object into a Go object, and to use the Go function runtime.SetFinalizer to add a finalizer which frees the C++ object when the Go object is freed. It is strongly recommended to read @@ -788,7 +788,7 @@ DirectorInterface are a subset of the public and protected virtual methods of the C++ class. If the DirectorInterface contains a method with a matching signature to a virtual method of the C++ class then the virtual C++ method will be overwritten with the Go method. As Go doesn't support protected -methods all overriden protected virtual C++ methods will be public in Go. +methods all overridden protected virtual C++ methods will be public in Go.

    @@ -941,7 +941,7 @@ methods of the FooBarAbstract C++ class by means of embedding. The public FooBarGo interface type includes the FooBarAbstract interface and hence FooBarGo can be used as a drop in replacement for FooBarAbstract while the reverse isn't possible and would raise a -compile time error. Furthemore the constructor and destructor functions +compile time error. Furthermore the constructor and destructor functions NewFooBarGo and DeleteFooBarGo take care of all the director specifics and to the user the class appears as any other SWIG wrapped C++ class. @@ -1054,7 +1054,7 @@ type overwrittenMethodsOnFooBarAbstract struct { fb FooBarAbstract // If additional constructor arguments have been given they are typically - // stored here so that the overriden methods can use them. + // stored here so that the overridden methods can use them. } func (om *overwrittenMethodsOnFooBarAbstract) Foo() string { @@ -1081,7 +1081,7 @@ func NewFooBarGo() FooBarGo { // The memory of the FooBarAbstract director object instance can be // automatically freed once the FooBarGo instance is garbage collected by // uncommenting the following line. Please make sure to understand the - // runtime.SetFinalizer specific gotchas before doing this. Furthemore + // runtime.SetFinalizer specific gotchas before doing this. Furthermore // DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo // struct needs additional data to prevent double deletion. // runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 9dfaa1fd4..18a6c424e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -4029,7 +4029,7 @@ write handlers for a large number of methods will require repetitive duplication of the director:except feature code for each director method. To mitigate this, a second approach is provided via typemaps in a -fashion analagous to +fashion analogous to the "throws" typemap. The "throws" typemap provides a way to map all the C++ exceptions listed in a method's defined exceptions (either from @@ -8455,7 +8455,7 @@ System.out.println("element value: " + container.getElement().getValue());

    The C++ code will always print out 20, but the value printed out may not be this in the Java equivalent code. -In order to understand why, consider a garbage collection occuring... +In order to understand why, consider a garbage collection occurring...

    @@ -8597,7 +8597,7 @@ The CDate & and const CDate & Java code is generated f

    where '$javaclassname' is translated into the proxy class name, CDate and '$javainput' is translated into the name of the parameter, eg dateIn. -From Java, the intention is then to call into a modifed API with something like: +From Java, the intention is then to call into a modified API with something like:

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 10612f001..2acb2e274 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -101,7 +101,7 @@ that era had a component > 99. For example:

     $ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i
    -

    If you're targetting V8 >= 4.3.0, you would just run swig like so:

    +

    If you're targeting V8 >= 4.3.0, you would just run swig like so:

     $ swig -c++ -javascript -v8 example.i
    diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 3b654a6d2..78e2a1ab0 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -364,7 +364,7 @@ a number of packages to be installed. Full instructions at

    SWIG is known to work on various flavors of OS X. Follow the Unix installation instructions above. However, as of this writing, there is still great deal of -inconsistency with how shared libaries are handled by various scripting languages +inconsistency with how shared libraries are handled by various scripting languages on OS X.

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index d387b9a77..99d48588d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6217,8 +6217,8 @@ they treat it affects how the pure Python module will be able to locate the C module.

    -

    The details concerning this are covered completly in the documentation -for Python itself. Links to the relavent sections follow: +

    The details concerning this are covered completely in the documentation +for Python itself. Links to the relevant sections follow:

      diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 9c8e4b71b..2261c9af7 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -39,7 +39,7 @@
  • Pointers
  • Structures @@ -92,7 +92,7 @@ This chapter explains how to use SWIG for Scilab. After this introduction, you s

    -SWIG for Scilab supports Linux. Other operating sytems haven't been tested. +SWIG for Scilab supports Linux. Other operating systems haven't been tested.

    @@ -337,7 +337,7 @@ There are a few exceptions, such as constants and enumerations, which can be wra

    In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation disappears from Scilab 6.0 onwards). -
    By default, variable, member, and function names longer than 24 charaters are truncated, and a warning is produced for each truncation. +
    By default, variable, member, and function names longer than 24 characters are truncated, and a warning is produced for each truncation.

    This can cause ambiguities, especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names. In these cases, the %rename directive can be used to choose a different Scilab name. @@ -765,7 +765,7 @@ typedef enum { RED, BLUE, GREEN } color; Pointers are supported by SWIG. A pointer can be returned from a wrapped C/C++ function, stored in a Scilab variable, and used in input argument of another C/C++ function.

    -Also, thanks to the SWIG runtime which stores informations about types, pointer types are tracked between exchanges Scilab and the native code. Indeed pointer types are stored alongside the pointer adress. +Also, thanks to the SWIG runtime which stores information about types, pointer types are tracked between exchanges Scilab and the native code. Indeed pointer types are stored alongside the pointer address. A pointer is mapped to a Scilab structure (tlist), which contains as fields the pointer address and the pointer type (in fact a pointer to the type information structure in the SWIG runtime).
    Why a native pointer is not mapped to a Scilab pointer (type name: "pointer", type ID: 128) ? The big advantage of mapping to a tlist is that it exposes a new type for the pointer in Scilab, type which can be acessed in Scilab with the typeof function, and manipulated using the overloading mechanism. @@ -1441,7 +1441,7 @@ void throw_exception() throw(char const *) {

     -->throw_exception()
       !--error 999
    -SWIG/Scilab: Exception (char const *) occured: Bye world !
    +SWIG/Scilab: Exception (char const *) occurred: Bye world !
     

    @@ -1458,7 +1458,7 @@ It can be used with the lasterror() function as following: --> lasterror() ans = - SWIG/Scilab: Exception (char const *) occured: Bye world ! + SWIG/Scilab: Exception (char const *) occurred: Bye world !

    @@ -1488,7 +1488,7 @@ void throw_stl_invalid_arg(int i) throw(std::invalid_argument) {

     --> throw_int();
                 !--error 999
    -SWIG/Scilab: Exception (int) occured: 12
    +SWIG/Scilab: Exception (int) occurred: 12
     
     -->throw_stl_invalid_arg(-1);
                               !--error 999
    diff --git a/Examples/go/director/director.go b/Examples/go/director/director.go
    index 4f99bfc6d..c70606af1 100644
    --- a/Examples/go/director/director.go
    +++ b/Examples/go/director/director.go
    @@ -32,7 +32,7 @@ type overwrittenMethodsOnFooBarAbstract struct {
     	fb FooBarAbstract
     
     	// If additional constructor arguments have been given they are typically
    -	// stored here so that the overriden methods can use them.
    +	// stored here so that the overridden methods can use them.
     }
     
     func (om *overwrittenMethodsOnFooBarAbstract) Foo() string {
    @@ -59,7 +59,7 @@ func NewFooBarGo() FooBarGo {
     	// The memory of the FooBarAbstract director object instance can be
     	// automatically freed once the FooBarGo instance is garbage collected by
     	// uncommenting the following line.  Please make sure to understand the
    -	// runtime.SetFinalizer specific gotchas before doing this.  Furthemore
    +	// runtime.SetFinalizer specific gotchas before doing this.  Furthermore
     	// DeleteFooBarGo should be deleted if a finalizer is in use or the fooBarGo
     	// struct needs additional data to prevent double deletion.
     	// runtime.SetFinalizer(fbgs, FooBarGo.deleteFooBarAbstract)
    diff --git a/Examples/guile/matrix/runme.scm b/Examples/guile/matrix/runme.scm
    index 1d2332fb0..b898bb485 100644
    --- a/Examples/guile/matrix/runme.scm
    +++ b/Examples/guile/matrix/runme.scm
    @@ -12,7 +12,7 @@
     ;;; Explanation: The three lines at the beginning of this script are
     ;;; telling the kernel to load the enhanced guile interpreter named
     ;;; "matrix"; to execute the function "do-test" (-e option) after loading
    -;;; this script (-s option). There are a lot more options wich allow for
    +;;; this script (-s option). There are a lot more options which allow for
     ;;; even finer tuning. SEE ALSO: Section "Guile Scripts" in the "Guile
     ;;; reference manual -- Part I: Preliminaries".
     ;;;
    diff --git a/Examples/guile/multivalue/example.i b/Examples/guile/multivalue/example.i
    index 135389487..0ef710132 100644
    --- a/Examples/guile/multivalue/example.i
    +++ b/Examples/guile/multivalue/example.i
    @@ -15,14 +15,14 @@ back to this behavior, use: */
     
     void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
     
    -/* Multiple values as vectors. By issueing: */
    +/* Multiple values as vectors. By issuing: */
     %values_as_vector;
     /* vectors instead of lists will be used. */
     
     void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
     
     /* Multiple values for multiple-value continuations.
    -   (This is the most elegant way.)  By issueing: */
    +   (This is the most elegant way.)  By issuing: */
     %multiple_values;
     /* multiple values are passed to the multiple-value
        continuation, as created by `call-with-values' or the
    diff --git a/Examples/javascript/exception/runme.js b/Examples/javascript/exception/runme.js
    index 43ce66d6d..1001a7111 100644
    --- a/Examples/javascript/exception/runme.js
    +++ b/Examples/javascript/exception/runme.js
    @@ -10,7 +10,7 @@ try{
       if(error == -1) {
         console.log("t.unknown() didn't throw");
       } else {
    -    console.log("successfully catched throw in Test::unknown().");
    +    console.log("successfully caught throw in Test::unknown().");
       }
     }
     
    @@ -22,7 +22,7 @@ catch(error){
       if(error == -1) {
         console.log("t.simple() did not throw");
       } else {
    -    console.log("successfully catched throw in Test::simple().");
    +    console.log("successfully caught throw in Test::simple().");
       }
     }
     
    @@ -33,7 +33,7 @@ try{
       if(error == -1) {
         console.log("t.message() did not throw");
       } else {
    -    console.log("successfully catched throw in Test::message().");
    +    console.log("successfully caught throw in Test::message().");
       }
     }
         
    @@ -45,7 +45,7 @@ catch(error){
       if(error == -1) {
         console.log("t.hosed() did not throw");
       } else {
    -    console.log("successfully catched throw in Test::hosed().");
    +    console.log("successfully caught throw in Test::hosed().");
       }
     }
     
    @@ -58,7 +58,7 @@ for (var i=1; i<4; i++) {
         if(error == -1) {
           console.log("t.multi(" + i + ") did not throw");
         } else {
    -      console.log("successfully catched throw in Test::multi().");
    +      console.log("successfully caught throw in Test::multi().");
         }
       }
     }    
    diff --git a/Examples/javascript/variables/runme.js b/Examples/javascript/variables/runme.js
    index a2b5f791c..36ddc5fe9 100644
    --- a/Examples/javascript/variables/runme.js
    +++ b/Examples/javascript/variables/runme.js
    @@ -44,7 +44,7 @@ example.print_vars();
     
     console.log("\nNow I'm going to try and modify some read only variables");
     
    -console.log("Tring to set 'path'");
    +console.log("Trying to set 'path'");
     try{
         example.path = "Whoa!";
         console.log("Hey, what's going on?!?! This shouldn't work");
    diff --git a/Examples/lua/arrays/runme.lua b/Examples/lua/arrays/runme.lua
    index d0aa99813..daba2267f 100644
    --- a/Examples/lua/arrays/runme.lua
    +++ b/Examples/lua/arrays/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/class/runme.lua b/Examples/lua/class/runme.lua
    index 5d140defe..50ac35d6d 100644
    --- a/Examples/lua/class/runme.lua
    +++ b/Examples/lua/class/runme.lua
    @@ -5,7 +5,7 @@
     
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/constants/runme.lua b/Examples/lua/constants/runme.lua
    index 751e7d623..ad6bd45d2 100644
    --- a/Examples/lua/constants/runme.lua
    +++ b/Examples/lua/constants/runme.lua
    @@ -2,7 +2,7 @@
     
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/dual/dual.cpp b/Examples/lua/dual/dual.cpp
    index 2108a7275..d2b3c75c4 100644
    --- a/Examples/lua/dual/dual.cpp
    +++ b/Examples/lua/dual/dual.cpp
    @@ -16,7 +16,7 @@ and check to see if types Foo and Bar are registered with it
     (Bar should be & Foo should not)
     
     Note: Though both the modules exist and are loaded, they are not linked together,
    -as they are connected to seperate lua interpreters.
    +as they are connected to separate lua interpreters.
     
     When the third lua state loads both example.i and example2.i,
     the two modules are now linked together, and all can now find
    diff --git a/Examples/lua/exception/runme.lua b/Examples/lua/exception/runme.lua
    index a798efca7..adb2516c4 100644
    --- a/Examples/lua/exception/runme.lua
    +++ b/Examples/lua/exception/runme.lua
    @@ -2,7 +2,7 @@
     
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    @@ -48,7 +48,7 @@ else
     end
     
     -- this is a rather strange way to perform the multiple catch of exceptions
    -print "calling t:mutli()"
    +print "calling t:multi()"
     for i=1,3 do
         ok,res=pcall(function() t:multi(i) end)
         if ok then
    diff --git a/Examples/lua/funcptr3/runme.lua b/Examples/lua/funcptr3/runme.lua
    index b78c504ef..3cd58520f 100644
    --- a/Examples/lua/funcptr3/runme.lua
    +++ b/Examples/lua/funcptr3/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/functest/runme.lua b/Examples/lua/functest/runme.lua
    index 65b3cc215..773ab5dd6 100644
    --- a/Examples/lua/functest/runme.lua
    +++ b/Examples/lua/functest/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/functor/runme.lua b/Examples/lua/functor/runme.lua
    index adf124ac6..d6f4d08c7 100644
    --- a/Examples/lua/functor/runme.lua
    +++ b/Examples/lua/functor/runme.lua
    @@ -1,7 +1,7 @@
     -- Operator overloading example
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/import/runme.lua b/Examples/lua/import/runme.lua
    index 9cd7ae06c..7057b7bbd 100644
    --- a/Examples/lua/import/runme.lua
    +++ b/Examples/lua/import/runme.lua
    @@ -3,7 +3,7 @@
     print("Testing the %import directive")
     
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	function loadit(a)
     		lib=loadlib(a..'.dll','luaopen_'..a) or loadlib(a..'.so','luaopen_'..a)
     		assert(lib)()
    diff --git a/Examples/lua/nspace/runme.lua b/Examples/lua/nspace/runme.lua
    index 876814052..a894cf849 100644
    --- a/Examples/lua/nspace/runme.lua
    +++ b/Examples/lua/nspace/runme.lua
    @@ -5,7 +5,7 @@
     
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/owner/runme.lua b/Examples/lua/owner/runme.lua
    index 847645448..4d953cba6 100644
    --- a/Examples/lua/owner/runme.lua
    +++ b/Examples/lua/owner/runme.lua
    @@ -1,7 +1,7 @@
     -- Operator overloading example
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/pointer/runme.lua b/Examples/lua/pointer/runme.lua
    index 8deee67e6..2906cc663 100644
    --- a/Examples/lua/pointer/runme.lua
    +++ b/Examples/lua/pointer/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/simple/runme.lua b/Examples/lua/simple/runme.lua
    index 1e5a139c8..5f2e95c2f 100644
    --- a/Examples/lua/simple/runme.lua
    +++ b/Examples/lua/simple/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    diff --git a/Examples/lua/variables/runme.lua b/Examples/lua/variables/runme.lua
    index 05b2d3fbf..826845e90 100644
    --- a/Examples/lua/variables/runme.lua
    +++ b/Examples/lua/variables/runme.lua
    @@ -1,6 +1,6 @@
     ---- importing ----
     if string.sub(_VERSION,1,7)=='Lua 5.0' then
    -	-- lua5.0 doesnt have a nice way to do this
    +	-- lua5.0 doesn't have a nice way to do this
     	lib=loadlib('example.dll','luaopen_example') or loadlib('example.so','luaopen_example')
     	assert(lib)()
     else
    @@ -54,9 +54,9 @@ example.print_vars()
     
     print "\nNow I'm going to try and modify some read only variables";
     
    -print "     Tring to set 'path' to 'Whoa!'";
    +print "     Trying to set 'path' to 'Whoa!'";
     if pcall(function() example.path = "Whoa!" end)==true then
    -	print "     Thats funny, it didn't give an error!"
    +	print "     That's funny, it didn't give an error!"
     else
     	print "     It gave an error, as it should"
     end
    @@ -64,7 +64,7 @@ print("     Just checking the value: path      =", example.path)
     
     print "     Trying to set 'status' to '0'";
     if pcall(function() example.status = 0 end)==true then
    -	print "     Thats funny, it didn't give an error!"
    +	print "     That's funny, it didn't give an error!"
     else
     	print "     It gave an error, as it should"
     end
    diff --git a/Examples/octave/variables/runme.m b/Examples/octave/variables/runme.m
    index 71ac72f29..df4cad77c 100644
    --- a/Examples/octave/variables/runme.m
    +++ b/Examples/octave/variables/runme.m
    @@ -51,7 +51,7 @@ swigexample.print_vars();
     
     printf("\nNow I'm going to try and modify some read only variables\n");
     
    -printf("     Tring to set 'path'\n");
    +printf("     Trying to set 'path'\n");
     try
         swigexample.cvar.path = "Whoa!";
         printf("Hey, what's going on?!?! This shouldn't work\n");
    diff --git a/Examples/perl5/variables/runme.pl b/Examples/perl5/variables/runme.pl
    index 76e3dc8bc..2c3484db7 100644
    --- a/Examples/perl5/variables/runme.pl
    +++ b/Examples/perl5/variables/runme.pl
    @@ -65,7 +65,7 @@ if (!$@) {
     }
     print "     get error for 'status'\n";
     
    -print "     Tring to set 'path'\n";
    +print "     Trying to set 'path'\n";
     eval { $example::path = "Whoa!";};
     if (!$@) {
         die("path");
    diff --git a/Examples/php/disown/runme.php b/Examples/php/disown/runme.php
    index d90b03a9d..a70d7b061 100644
    --- a/Examples/php/disown/runme.php
    +++ b/Examples/php/disown/runme.php
    @@ -26,7 +26,7 @@ $container->addShape($s);
     print "\nA total of " . Shape::nshapes() . " shapes were created\n";
     
     # ----- Delete by the old references -----
    -# This should not truely delete the shapes because they are now owned
    +# This should not truly delete the shapes because they are now owned
     # by the ShapeContainer.
     
     print "Delete the old references.";
    @@ -38,7 +38,7 @@ $s = NULL;
     print "\nA total of " . Shape::nshapes() . " shapes remain\n";
     
     # ----- Delete by the container -----
    -# This should truely delete the shapes
    +# This should truly delete the shapes
     
     print "Delete the container.";
     $container = NULL;
    diff --git a/Examples/php5/disown/runme.php b/Examples/php5/disown/runme.php
    index d90b03a9d..a70d7b061 100644
    --- a/Examples/php5/disown/runme.php
    +++ b/Examples/php5/disown/runme.php
    @@ -26,7 +26,7 @@ $container->addShape($s);
     print "\nA total of " . Shape::nshapes() . " shapes were created\n";
     
     # ----- Delete by the old references -----
    -# This should not truely delete the shapes because they are now owned
    +# This should not truly delete the shapes because they are now owned
     # by the ShapeContainer.
     
     print "Delete the old references.";
    @@ -38,7 +38,7 @@ $s = NULL;
     print "\nA total of " . Shape::nshapes() . " shapes remain\n";
     
     # ----- Delete by the container -----
    -# This should truely delete the shapes
    +# This should truly delete the shapes
     
     print "Delete the container.";
     $container = NULL;
    diff --git a/Examples/python/variables/runme.py b/Examples/python/variables/runme.py
    index fba485aca..4d34e92dd 100644
    --- a/Examples/python/variables/runme.py
    +++ b/Examples/python/variables/runme.py
    @@ -48,7 +48,7 @@ example.print_vars()
     
     print "\nNow I'm going to try and modify some read only variables"
     
    -print "     Tring to set 'path'"
    +print "     Trying to set 'path'"
     try:
         example.cvar.path = "Whoa!"
         print "Hey, what's going on?!?! This shouldn't work"
    diff --git a/Examples/ruby/variables/runme.rb b/Examples/ruby/variables/runme.rb
    index 38531c833..b748384ce 100644
    --- a/Examples/ruby/variables/runme.rb
    +++ b/Examples/ruby/variables/runme.rb
    @@ -48,7 +48,7 @@ Example.print_vars()
     
     puts "\nNow I'm going to try and modify some read only variables";
     
    -puts "     Tring to set 'path'";
    +puts "     Trying to set 'path'";
     begin
       Example.path = "Whoa!"
       puts "Hey, what's going on?!?! This shouldn't work"
    diff --git a/Examples/scilab/std_list/runme.sci b/Examples/scilab/std_list/runme.sci
    index e4c04b029..6075d7ac7 100644
    --- a/Examples/scilab/std_list/runme.sci
    +++ b/Examples/scilab/std_list/runme.sci
    @@ -7,7 +7,7 @@ if ierr <> 0 then
     end
     example_Init();
     
    -// This example shows how to use C++ fonctions with STL lists arguments
    +// This example shows how to use C++ functions with STL lists arguments
     // Here, STL lists are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
     
     // integer lists
    diff --git a/Examples/scilab/variables/runme.sci b/Examples/scilab/variables/runme.sci
    index 98d76cfa0..1ef077467 100644
    --- a/Examples/scilab/variables/runme.sci
    +++ b/Examples/scilab/variables/runme.sci
    @@ -49,7 +49,7 @@ print_vars()
     
     // Immutable variables
     printf("\nNow I''m going to try and modify some read only variables\n");
    -printf("     Tring to set ''path''\n");
    +printf("     Trying to set ''path''\n");
     try
         path_set("Whoa!");
         printf("Hey, what''s going on?!?! This shouldn''t work\n");
    diff --git a/Examples/tcl/variables/runme.tcl b/Examples/tcl/variables/runme.tcl
    index b9e2fd418..71aec38b8 100644
    --- a/Examples/tcl/variables/runme.tcl
    +++ b/Examples/tcl/variables/runme.tcl
    @@ -48,7 +48,7 @@ print_vars
     
     puts "\nNow I'm going to try and modify some read only variables";
     
    -puts "     Tring to set 'path'";
    +puts "     Trying to set 'path'";
     if { [catch {
         set path "Whoa!"
         puts "Hey, what's going on?!?! This shouldn't work"
    diff --git a/Examples/test-suite/errors/pp_macro_missing_expression.i b/Examples/test-suite/errors/pp_macro_missing_expression.i
    index 2c7c9855d..a93a76f2e 100644
    --- a/Examples/test-suite/errors/pp_macro_missing_expression.i
    +++ b/Examples/test-suite/errors/pp_macro_missing_expression.i
    @@ -1,4 +1,4 @@
    -// Test "Missing identifier for ..." errrors
    +// Test "Missing identifier for ..." errors
     %module xxx
     
     #ifdef
    diff --git a/Examples/test-suite/lua/li_std_string_runme.lua b/Examples/test-suite/lua/li_std_string_runme.lua
    index 956bea0fc..a36bf7ef6 100644
    --- a/Examples/test-suite/lua/li_std_string_runme.lua
    +++ b/Examples/test-suite/lua/li_std_string_runme.lua
    @@ -32,8 +32,8 @@ assert(is_std_string(cobj) and cobj:c_str()=="x")	-- check type & value
     
     test_const_pointer(cobj)
     
    --- this shouldnt work, but it does
    --- swig doesnt appear to diff between const object ptrs & object ptrs very well
    +-- this shouldn't work, but it does
    +-- swig doesn't appear to diff between const object ptrs & object ptrs very well
     test_pointer(cobj)	-- this wants an non const object (give it a const one!)
     
     -- refs are also wrappered as ptrs (unless the correct typemaps are applied)
    diff --git a/Examples/test-suite/lua/newobject2_runme.lua b/Examples/test-suite/lua/newobject2_runme.lua
    index cf6c87ae7..748c95372 100644
    --- a/Examples/test-suite/lua/newobject2_runme.lua
    +++ b/Examples/test-suite/lua/newobject2_runme.lua
    @@ -1,8 +1,8 @@
     require("import")	-- the import fn
     import("newobject2",true)	-- import code
     
    -foo1 = newobject2.makeFoo()	-- lua doesnt yet support static fns properly
    -assert(newobject2.fooCount() == 1)	-- lua doesnt yet support static fns properly
    +foo1 = newobject2.makeFoo()	-- lua doesn't yet support static fns properly
    +assert(newobject2.fooCount() == 1)	-- lua doesn't yet support static fns properly
     
     foo2 = newobject2.makeFoo()
     assert(newobject2.fooCount() == 2)
    diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i
    index 59f3d7643..f92e6c78b 100644
    --- a/Examples/test-suite/multivalue.i
    +++ b/Examples/test-suite/multivalue.i
    @@ -11,14 +11,14 @@ back to this behavior, use: */
     
     void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
     
    -/* Multiple values as vectors. By issueing: */
    +/* Multiple values as vectors. By issuing: */
     %values_as_vector;
     /* vectors instead of lists will be used. */
     
     void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
     
     /* Multiple values for multiple-value continuations.
    -   (This is the most elegant way.)  By issueing: */
    +   (This is the most elegant way.)  By issuing: */
     %multiple_values;
     /* multiple values are passed to the multiple-value
        continuation, as created by `call-with-values' or the
    diff --git a/Examples/test-suite/octave/return_const_value_runme.m b/Examples/test-suite/octave/return_const_value_runme.m
    index 1219c9293..8b363f297 100644
    --- a/Examples/test-suite/octave/return_const_value_runme.m
    +++ b/Examples/test-suite/octave/return_const_value_runme.m
    @@ -2,10 +2,10 @@ return_const_value
     
     p = return_const_value.Foo_ptr.getPtr();
     if (p.getVal() != 17)
    -  error("Runtime test1 faild. p.getVal()=", p.getVal())
    +  error("Runtime test1 failed. p.getVal()=", p.getVal())
     endif
     
     p = return_const_value.Foo_ptr.getConstPtr();
     if (p.getVal() != 17)
    -  error("Runtime test2 faild. p.getVal()=", p.getVal())
    +  error("Runtime test2 failed. p.getVal()=", p.getVal())
     endif
    diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
    index d3fd66868..92939c71c 100644
    --- a/Examples/test-suite/php/tests.php
    +++ b/Examples/test-suite/php/tests.php
    @@ -119,7 +119,7 @@ class check {
           $parents[]=$c;
           $c=strtolower(get_parent_class($c));
         }
    -    if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n  %s\n",join("\n  ",$parents));
    +    if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierarchy:\n  %s\n",join("\n  ",$parents));
         return TRUE;
       }
     
    diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
    index 9e4d04e10..78c6bf592 100644
    --- a/Examples/test-suite/php/threads_exception_runme.php
    +++ b/Examples/test-suite/php/threads_exception_runme.php
    @@ -7,7 +7,7 @@ require "threads_exception.php";
     check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
     // Check classes.
     check::classes(array(Exc,Test,threads_exception));
    -// Chek globals.
    +// Check globals.
     check::globals(array(exc_code,exc_msg));
     
     $t = new Test();
    diff --git a/Examples/test-suite/php5/tests.php b/Examples/test-suite/php5/tests.php
    index d3fd66868..92939c71c 100644
    --- a/Examples/test-suite/php5/tests.php
    +++ b/Examples/test-suite/php5/tests.php
    @@ -119,7 +119,7 @@ class check {
           $parents[]=$c;
           $c=strtolower(get_parent_class($c));
         }
    -    if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierachy:\n  %s\n",join("\n  ",$parents));
    +    if ($c!=$b) return check::fail("Class $a does not inherit from class $b\nHierarchy:\n  %s\n",join("\n  ",$parents));
         return TRUE;
       }
     
    diff --git a/Examples/test-suite/php5/threads_exception_runme.php b/Examples/test-suite/php5/threads_exception_runme.php
    index 9e4d04e10..78c6bf592 100644
    --- a/Examples/test-suite/php5/threads_exception_runme.php
    +++ b/Examples/test-suite/php5/threads_exception_runme.php
    @@ -7,7 +7,7 @@ require "threads_exception.php";
     check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
     // Check classes.
     check::classes(array(Exc,Test,threads_exception));
    -// Chek globals.
    +// Check globals.
     check::globals(array(exc_code,exc_msg));
     
     $t = new Test();
    diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py
    index 4e57b69e8..f5ab0ec66 100644
    --- a/Examples/test-suite/python/python_pybuf_runme3.py
    +++ b/Examples/test-suite/python/python_pybuf_runme3.py
    @@ -6,7 +6,7 @@ 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
    +    k = 1000000  # number of times to execute the functions
     
         t = time.time()
         a = bytearray(b'hello world')
    diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py
    index 947102840..ff3bd5f02 100644
    --- a/Examples/test-suite/python/return_const_value_runme.py
    +++ b/Examples/test-suite/python/return_const_value_runme.py
    @@ -3,10 +3,10 @@ import sys
     
     p = return_const_value.Foo_ptr_getPtr()
     if (p.getVal() != 17):
    -    print "Runtime test1 faild. p.getVal()=", p.getVal()
    +    print "Runtime test1 failed. p.getVal()=", p.getVal()
         sys.exit(1)
     
     p = return_const_value.Foo_ptr_getConstPtr()
     if (p.getVal() != 17):
    -    print "Runtime test2 faild. p.getVal()=", p.getVal()
    +    print "Runtime test2 failed. p.getVal()=", p.getVal()
         sys.exit(1)
    diff --git a/Examples/test-suite/redefined_not.i b/Examples/test-suite/redefined_not.i
    index db9d3a248..fde5994fb 100644
    --- a/Examples/test-suite/redefined_not.i
    +++ b/Examples/test-suite/redefined_not.i
    @@ -1,6 +1,6 @@
     %module redefined_not
     
    -// These should not emit an Identifer redefined warning
    +// These should not emit an Identifier redefined warning
     %inline %{
     typedef unsigned int my_size_t;
     namespace Std {
    diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in
    index 483ed2439..f873b8687 100644
    --- a/Examples/test-suite/scilab/Makefile.in
    +++ b/Examples/test-suite/scilab/Makefile.in
    @@ -29,7 +29,7 @@ CPP_STD_TEST_CASES += \
     
     include $(srcdir)/../common.mk
     
    -# Overriden variables
    +# Overridden variables
     SRCDIR = ../$(srcdir)/
     
     # Local variables
    diff --git a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
    index e4832efe6..af87d54bf 100644
    --- a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
    +++ b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
    @@ -6,7 +6,7 @@ function checkerror(ierr, cmd)
       if ierr <> 0 then swigtesterror("error " + string(ierr) + " in """ + cmd + """"); end
     endfunction
     
    -// test container of pointers returned from fonction (expected a list)
    +// test container of pointers returned from function (expected a list)
     function [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2)
       classAPtr1 = new_ClassA(value1);
       classAPtr2 = new_ClassA(value2);
    @@ -57,7 +57,7 @@ endfunction
     //     computed on the container
     function testContainerType(container, value_type, value1, value2, ..
       expected_returned_container, expected_accumulate_value)
    -  // test container of basic type returned from fonction
    +  // test container of basic type returned from function
       func = msprintf("ret_%s_%s", value_type, container);
       if value_type == "string" then
         cmd = msprintf("c = %s(''%s'', ''%s'');", func, value1, value2);
    diff --git a/Examples/test-suite/scilab/li_std_deque_runme.sci b/Examples/test-suite/scilab/li_std_deque_runme.sci
    index c0680846b..0903db4ae 100644
    --- a/Examples/test-suite/scilab/li_std_deque_runme.sci
    +++ b/Examples/test-suite/scilab/li_std_deque_runme.sci
    @@ -25,7 +25,7 @@ IntDeque_push_back(intDeque, 6);
     avg = average(intDeque);
     checkequal(avg, 4.0, "average(intDeque)");
     
    -// half shoud return a deque with elements half of the input elements
    +// half should return a deque with elements half of the input elements
     RealDeque_clear(realDeque);
     RealDeque_push_front(realDeque, 2.0);
     RealDeque_push_front(realDeque, 4.0);
    diff --git a/Examples/test-suite/scilab/scilab_li_matrix_runme.sci b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
    index 41924d6f9..55184cc20 100644
    --- a/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
    +++ b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
    @@ -2,7 +2,7 @@
     
     exec("swigtest.start", -1);
     
    -// test matrix passed as output argument from fonction
    +// test matrix passed as output argument from function
     function test_outMatrix(func, valueType, expectedOutMatrix)
       funcName = msprintf("out%s%s", valueType, func);
       cmd = msprintf("outMatrix = %s();", funcName);
    @@ -13,7 +13,7 @@ function test_outMatrix(func, valueType, expectedOutMatrix)
       checkequal(outMatrix, expectedOutMatrix, funcName);
     endfunction
     
    -// test matrix passed as input argument of fonction
    +// test matrix passed as input argument of function
     function test_inMatrix(func, valueType, inMatrix, expectedInValue)
       funcName = msprintf("in%s%s", valueType, func);
       cmd = msprintf("inValue = %s(inMatrix);", funcName);
    @@ -24,7 +24,7 @@ function test_inMatrix(func, valueType, inMatrix, expectedInValue)
       checkequal(inValue, expectedInValue, funcName);
     endfunction
     
    -// test matrixes passed as input and output arguments of fonction
    +// test matrixes passed as input and output arguments of function
     function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
       funcName = msprintf("inout%s%s", valueType, func);
       cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
    diff --git a/Examples/test-suite/scilab/throw_exception_runme.sci b/Examples/test-suite/scilab/throw_exception_runme.sci
    index 2eada4be2..535a2f4b9 100644
    --- a/Examples/test-suite/scilab/throw_exception_runme.sci
    +++ b/Examples/test-suite/scilab/throw_exception_runme.sci
    @@ -8,15 +8,15 @@ endfunction
     
     foo = new_Foo();
     
    -checkException('Foo_test_int(foo)', 'Exception (int) occured: 37');
    +checkException('Foo_test_int(foo)', 'Exception (int) occurred: 37');
     
    -checkException('Foo_test_msg(foo)', 'Exception (char const *) occured: Dead');
    +checkException('Foo_test_msg(foo)', 'Exception (char const *) occurred: Dead');
     
    -checkException('Foo_test_multi(foo, 1)', 'Exception (int) occured: 37');
    +checkException('Foo_test_multi(foo, 1)', 'Exception (int) occurred: 37');
     
    -checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occured: Dead');
    +checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occurred: Dead');
     
    -checkException('Foo_test_cls(foo)', 'Exception (CError) occured.');
    +checkException('Foo_test_cls(foo)', 'Exception (CError) occurred.');
     
     delete_Foo(foo);
     
    diff --git a/Examples/test-suite/template_class_reuse_name.i b/Examples/test-suite/template_class_reuse_name.i
    index afbf31bd9..818816d0e 100644
    --- a/Examples/test-suite/template_class_reuse_name.i
    +++ b/Examples/test-suite/template_class_reuse_name.i
    @@ -26,7 +26,7 @@ namespace Space {
     %template(Bool4False) Space::Bool4;
     
     
    -// Forward declarated templates
    +// Forward declared templates
     %inline %{
     namespace Space {
       template  struct BoolForward1;
    diff --git a/Examples/test-suite/template_typedef_cplx5.i b/Examples/test-suite/template_typedef_cplx5.i
    index 84b09fd78..566696992 100644
    --- a/Examples/test-suite/template_typedef_cplx5.i
    +++ b/Examples/test-suite/template_typedef_cplx5.i
    @@ -7,7 +7,7 @@
     
     %inline %{
     
    -  // This typedef triggers an inifinite recursion
    +  // This typedef triggers an infinite recursion
       // in the next test1() nd test2() function declarations
     
       typedef std::complex complex;  
    diff --git a/Lib/d/dprimitives.swg b/Lib/d/dprimitives.swg
    index 445437957..eaee816d3 100644
    --- a/Lib/d/dprimitives.swg
    +++ b/Lib/d/dprimitives.swg
    @@ -20,7 +20,7 @@
     /*
      * The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive
      * types, because are more or less the same for all of them. The few special
    - * cases are handeled below.
    + * cases are handled below.
      */
     %define SWIG_D_PRIMITIVE(TYPE, DTYPE)
     %typemap(ctype) TYPE, const TYPE & "TYPE"
    diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg
    index 4b21c98b2..4050a6ee3 100644
    --- a/Lib/javascript/jsc/javascriptcode.swg
    +++ b/Lib/javascript/jsc/javascriptcode.swg
    @@ -388,7 +388,7 @@ static JSStaticFunction $jsmangledname_functions[] = {
      * jsc_nspace_declaration:  template for a namespace declaration
      *   - $jsnspace:           mangled name of the namespace
      *   - $jsglobalvariables:  list of variable entries
    - *   - $jsglobalfunctions:  list if fuction entries
    + *   - $jsglobalfunctions:  list of function entries
      * ----------------------------------------------------------------------------- */
     %fragment ("jsc_nspace_declaration", "templates")
     %{
    diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
    index 5ac52a51d..bacd8dcd6 100644
    --- a/Lib/javascript/v8/javascriptrun.swg
    +++ b/Lib/javascript/v8/javascriptrun.swg
    @@ -109,11 +109,11 @@ SWIGINTERN void SWIG_V8_Raise(const char *msg) {
       Note: There are two contexts for handling errors.
       A static V8ErrorHandler is used in not overloaded methods.
       For overloaded methods the throwing type checking mechanism is used
    -  during dispatching. As V8 exceptions can not be resetted properly
    +  during dispatching. As V8 exceptions can not be reset properly
       the trick is to use a dynamic ErrorHandler with same local name as the global
       one.
     
    -  - See defintion of SWIG_Error above.
    +  - See definition of SWIG_Error above.
       - See code templates 'JS_function_dispatcher', 'JS_functionwrapper_overload',
         and 'JS_function_dispatch_case' in javascriptcode.swg
     
    diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
    index 9c21d0812..6db3add6e 100644
    --- a/Lib/lua/lua.swg
    +++ b/Lib/lua/lua.swg
    @@ -33,7 +33,7 @@
     %typemap(consttab) char *, const char *, char [], const char []
            {SWIG_LUA_CONSTTAB_STRING("$symname", $value)}
     
    -// note: char is treated as a seperate special type
    +// note: char is treated as a separate special type
     // signed char & unsigned char are numbers
     %typemap(consttab) char
            {SWIG_LUA_CONSTTAB_CHAR("$symname", $value)}
    diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
    index 514336029..58ada4d6f 100644
    --- a/Lib/lua/luarun.swg
    +++ b/Lib/lua/luarun.swg
    @@ -181,7 +181,7 @@ typedef struct swig_elua_entry {
     
     /* Push the string STR on the Lua stack, like lua_pushstring, but
        prefixed with the location of the innermost Lua call-point
    -   (as formated by luaL_where).  */
    +   (as formatted by luaL_where).  */
     SWIGRUNTIME void
     SWIG_Lua_pusherrstring (lua_State *L, const char *str)
     {
    @@ -192,7 +192,7 @@ SWIG_Lua_pusherrstring (lua_State *L, const char *str)
     
     /* Push a formatted string generated from FMT and following args on
        the Lua stack, like lua_pushfstring, but prefixed with the
    -   location of the innermost Lua call-point (as formated by luaL_where).  */
    +   location of the innermost Lua call-point (as formatted by luaL_where).  */
     SWIGRUNTIME void
     SWIG_Lua_pushferrstring (lua_State *L, const char *fmt, ...)
     {
    @@ -289,7 +289,7 @@ to tell the two structures apart within SWIG, other than by looking at the type
     typedef struct {
       swig_type_info   *type;
       int     own;  /* 1 if owned & must be destroyed */
    -  char data[1];       /* arbitary amount of data */    
    +  char data[1];       /* arbitrary amount of data */    
     } swig_lua_rawdata;
     
     /* Common SWIG API */
    diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i
    index c662cd31e..8392e5bfa 100644
    --- a/Lib/lua/typemaps.i
    +++ b/Lib/lua/typemaps.i
    @@ -182,7 +182,7 @@ TYPE* SWIG_get_NAME_num_array_var(lua_State* L, int index, int* size);
     	// writes a table to Lua with all the specified numbers
     void SWIG_write_NAME_num_array(lua_State* L,TYPE *array,int size);
     	// read the specified table, and fills the array with numbers
    -	// returns 1 of ok (only fails if it doesnt find numbers)
    +	// returns 1 of ok (only fails if it doesn't find numbers)
     	// helper fn (called by SWIG_get_NAME_num_array_*() fns)
     int SWIG_read_NAME_num_array(lua_State* L,int index,TYPE *array,int size);
     
    diff --git a/Lib/octave/octiterators.swg b/Lib/octave/octiterators.swg
    index 79a20f833..e186c94a2 100644
    --- a/Lib/octave/octiterators.swg
    +++ b/Lib/octave/octiterators.swg
    @@ -1,7 +1,7 @@
     /* -----------------------------------------------------------------------------
      * octiterators.swg
      *
    - * Users can derive form the OctSwigIterator to implemet their
    + * Users can derive form the OctSwigIterator to implement their
      * own iterators. As an example (real one since we use it for STL/STD
      * containers), the template OctSwigIterator_T does the
      * implementation for generic C++ iterators.
    diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg
    index 00aec07d5..af9c86d3c 100644
    --- a/Lib/python/pyuserdir.swg
    +++ b/Lib/python/pyuserdir.swg
    @@ -163,7 +163,7 @@ These methods "may be called" if needed.
     
     /* ------------------------------------------------------------------------- */
     /*
    -  Enable keywords paramaters
    +  Enable keywords parameters
     */
     
     #define %kwargs      %feature("kwargs") 
    diff --git a/Lib/ruby/rubyiterators.swg b/Lib/ruby/rubyiterators.swg
    index 88f1e7c8c..89fea4527 100644
    --- a/Lib/ruby/rubyiterators.swg
    +++ b/Lib/ruby/rubyiterators.swg
    @@ -3,7 +3,7 @@
      *
      * Implement a C++ 'output' iterator for Ruby.
      *
    - * Users can derive form the Iterator to implemet their
    + * Users can derive form the Iterator to implement their
      * own iterators. As an example (real one since we use it for STL/STD
      * containers), the template Iterator_T does the
      * implementation for generic C++ iterators.
    diff --git a/Lib/ruby/rubyuserdir.swg b/Lib/ruby/rubyuserdir.swg
    index 638433c2d..1689c7f0d 100644
    --- a/Lib/ruby/rubyuserdir.swg
    +++ b/Lib/ruby/rubyuserdir.swg
    @@ -11,7 +11,7 @@
     
     /* ------------------------------------------------------------------------- */
     /*
    -  Enable keywords paramaters
    +  Enable keywords parameters
     */
     
     #define %kwargs      %feature("kwargs") 
    diff --git a/Lib/scilab/sciiterators.swg b/Lib/scilab/sciiterators.swg
    index 1c7ce4394..69cb04bee 100644
    --- a/Lib/scilab/sciiterators.swg
    +++ b/Lib/scilab/sciiterators.swg
    @@ -1,7 +1,7 @@
     /* -----------------------------------------------------------------------------
      * sciiterators.swg
      *
    - * Users can derive form the SciSwigIterator to implemet their
    + * Users can derive form the SciSwigIterator to implement their
      * own iterators. As an example (real one since we use it for STL/STD
      * containers), the template SwigSciIterator_T does the
      * implementation for generic C++ iterators.
    diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
    index 9c88df128..c1880d32c 100644
    --- a/Lib/scilab/scirun.swg
    +++ b/Lib/scilab/scirun.swg
    @@ -157,15 +157,15 @@ SWIGRUNTIME void
     SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) {
       if (type) {
         if (obj)
    -      Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj);
    +      Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occurred: %s\n", type, obj);
         else
    -      Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
    +      Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occurred.\n", type);
       }
     }
     
     SWIGRUNTIME void
     SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
    -  Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
    +  Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occurred.\n", type);
     }
     
     /* Module initialization */
    diff --git a/Lib/tcl/mactkinit.c b/Lib/tcl/mactkinit.c
    index 78391d445..8d1420088 100644
    --- a/Lib/tcl/mactkinit.c
    +++ b/Lib/tcl/mactkinit.c
    @@ -42,7 +42,7 @@ short			SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event));
      *
      * MacintoshInit --
      *
    - *	This procedure calls Mac specific initilization calls.  Most of
    + *	This procedure calls Mac specific initialization calls.  Most of
      *	these calls must be made as soon as possible in the startup
      *	process.
      *
    @@ -64,7 +64,7 @@ MacintoshInit()
     
         /*
          * Tk needs us to set the qd pointer it uses.  This is needed
    -     * so Tk doesn't have to assume the availablity of the qd global
    +     * so Tk doesn't have to assume the availiblity of the qd global
          * variable.  Which in turn allows Tk to be used in code resources.
          */
         tcl_macQdPtr = &qd;
    @@ -124,7 +124,7 @@ MacintoshInit()
      *
      * SetupMainInterp --
      *
    - *	This procedure calls initalization routines require a Tcl 
    + *	This procedure calls initialization routines require a Tcl 
      *	interp as an argument.  This call effectively makes the passed
      *	iterpreter the "main" interpreter for the application.
      *
    @@ -133,7 +133,7 @@ MacintoshInit()
      *	application should probably fail.
      *
      * Side effects:
    - *	More initilization.
    + *	More initialization.
      *
      *----------------------------------------------------------------------
      */
    diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
    index cae20eb3f..fc0d983fa 100644
    --- a/Source/CParse/parser.y
    +++ b/Source/CParse/parser.y
    @@ -512,7 +512,7 @@ static void add_symbols(Node *n) {
     	SetFlag(n, "feature:ignore");
           }
           if (!GetFlag(n, "feature:ignore") && Strcmp(symname,"$ignore") == 0) {
    -	/* Add feature:ignore if the symbol was explicitely ignored, regardless of visibility */
    +	/* Add feature:ignore if the symbol was explicitly ignored, regardless of visibility */
     	SetFlag(n, "feature:ignore");
           }
         } else {
    @@ -3789,7 +3789,7 @@ cpp_class_decl  : storage_class cpptype idcolon inherit LBRACE {
     		       if ($9) {
     			 appendSibling($$, $9);
     		       }
    -		     } else if (!SwigType_istemplate(ty) && template_parameters == 0) { /* for tempalte we need the class itself */
    +		     } else if (!SwigType_istemplate(ty) && template_parameters == 0) { /* for template we need the class itself */
     		       $$ = $9;
     		     }
     		   } else {
    diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
    index 780246f91..23683c385 100644
    --- a/Source/Modules/allocate.cxx
    +++ b/Source/Modules/allocate.cxx
    @@ -504,7 +504,7 @@ class Allocate:public Dispatcher {
     
            in emit.cxx
     
    -       and is either constructued from the "feature:catches" feature
    +       and is either constructed from the "feature:catches" feature
            or copied from the node "throws" list.
          */
         String *scatchlist = Getattr(n, "feature:catches");
    diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
    index ff9c1ae8b..c48a0a1f6 100644
    --- a/Source/Modules/csharp.cxx
    +++ b/Source/Modules/csharp.cxx
    @@ -68,8 +68,8 @@ class CSHARP:public Language {
       String *module_baseclass;	//inheritance for module class from %pragma
       String *imclass_interfaces;	//interfaces for intermediary class class from %pragma
       String *module_interfaces;	//interfaces for module class from %pragma
    -  String *imclass_class_modifiers;	//class modifiers for intermediary class overriden by %pragma
    -  String *module_class_modifiers;	//class modifiers for module class overriden by %pragma
    +  String *imclass_class_modifiers;	//class modifiers for intermediary class overridden by %pragma
    +  String *module_class_modifiers;	//class modifiers for module class overridden by %pragma
       String *upcasts_code;		//C++ casts for inheritance hierarchies C++ code
       String *imclass_cppcasts_code;	//C++ casts up inheritance hierarchies intermediary class code
       String *director_callback_typedefs;	// Director function pointer typedefs for callbacks
    diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
    index d740f0a17..4fa30dd60 100644
    --- a/Source/Modules/d.cxx
    +++ b/Source/Modules/d.cxx
    @@ -989,7 +989,7 @@ public:
         // Smart pointer classes do not mirror the inheritance hierarchy of the
         // underlying types, so aliasing the base class methods in is not required
         // for them.
    -    // DMD BUG: We have to emit the alias after the last function becasue
    +    // DMD BUG: We have to emit the alias after the last function because
         // taking a delegate in the overload checking code fails otherwise
         // (http://d.puremagic.com/issues/show_bug.cgi?id=4860).
         if (!Getattr(n, "sym:nextSibling") && !is_smart_pointer() &&
    @@ -1482,7 +1482,7 @@ public:
         }
         Delete(attributes);
     
    -    // Retrive the override value set via %dconstvalue, if any.
    +    // Retrieve the override value set via %dconstvalue, if any.
         String *override_value = Getattr(n, "feature:d:constvalue");
         if (override_value) {
           Printf(constants_code, "%s;\n", override_value);
    @@ -4353,7 +4353,7 @@ private:
        *
        * Determines whether the class the passed function node belongs to overrides
        * all the overlaods for the passed function node defined somewhere up the
    -   * inheritance hierachy.
    +   * inheritance hierarchy.
        * --------------------------------------------------------------------------- */
       bool areAllOverloadsOverridden(Node *n) const {
         List *base_list = Getattr(parentNode(n), "bases");
    @@ -4378,7 +4378,7 @@ private:
         }
     
         // We try to find at least a single overload which exists in the base class
    -    // so we can progress up the inheritance hierachy even if there have been
    +    // so we can progress up the inheritance hierarchy even if there have been
         // new overloads introduced after the topmost class.
         Node *base_function = NULL;
         String *symname = Getattr(n, "sym:name");
    @@ -4404,7 +4404,7 @@ private:
     	  !(Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode())) {
     	// If the base class function is »protected« and were are not in
     	// director mode, it is not emitted to the base class and thus we do
    -	// not count it. Otherwise, we would run into issues if the visiblity
    +	// not count it. Otherwise, we would run into issues if the visibility
     	// of some functions was changed from protected to public in a child
     	// class with the using directive.
     	continue;
    diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
    index 572985a6c..41e8f7d0a 100644
    --- a/Source/Modules/go.cxx
    +++ b/Source/Modules/go.cxx
    @@ -5940,7 +5940,7 @@ private:
        *
        * Given a C/C++ name, return a name in Go which will be exported.
        * If the first character is an upper case letter, this returns a
    -   * copy of its argment.  If the first character is a lower case
    +   * copy of its argument.  If the first character is a lower case
        * letter, this forces it to upper case.  Otherwise, this prepends
        * 'X'.
        * ---------------------------------------------------------------------- */
    diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
    index 2c42a01be..06daccf4a 100644
    --- a/Source/Modules/java.cxx
    +++ b/Source/Modules/java.cxx
    @@ -72,8 +72,8 @@ class JAVA:public Language {
       String *module_baseclass;	//inheritance for module class from %pragma
       String *imclass_interfaces;	//interfaces for intermediary class class from %pragma
       String *module_interfaces;	//interfaces for module class from %pragma
    -  String *imclass_class_modifiers;	//class modifiers for intermediary class overriden by %pragma
    -  String *module_class_modifiers;	//class modifiers for module class overriden by %pragma
    +  String *imclass_class_modifiers;	//class modifiers for intermediary class overridden by %pragma
    +  String *module_class_modifiers;	//class modifiers for module class overridden by %pragma
       String *upcasts_code;		//C++ casts for inheritance hierarchies C++ code
       String *imclass_cppcasts_code;	//C++ casts up inheritance hierarchies intermediary class code
       String *imclass_directors;	// Intermediate class director code
    @@ -168,7 +168,7 @@ public:
       /* -----------------------------------------------------------------------------
        * constructIntermediateClassName()
        *
    -   * Construct the fully qualified name of the intermidiate class and set
    +   * Construct the fully qualified name of the intermediate class and set
        * the full_imclass_name attribute accordingly.
        * ----------------------------------------------------------------------------- */
       void constructIntermediateClassName(Node *n) {
    diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
    index df51e3224..0840dd5f4 100644
    --- a/Source/Modules/javascript.cxx
    +++ b/Source/Modules/javascript.cxx
    @@ -994,7 +994,7 @@ int JSEmitter::emitDtor(Node *n) {
     
          Also, there is a problem where destructor_action is always true for me, even when not requesting %extend as above.
          So this code doesn't actually quite work as I expect. The end result is that the code still works because
    -     destructor_action calls free like the original template. The one caveat is the string in destructor_action casts to char* which is wierd.
    +     destructor_action calls free like the original template. The one caveat is the string in destructor_action casts to char* which is weird.
          I think there is a deeper underlying SWIG issue because I don't think it should be char*. However, it doesn't really matter for free.
     
          Maybe the fix for the destructor_action always true problem is that this is supposed to be embedded in the if(Extend) block above.
    @@ -1125,7 +1125,7 @@ int JSEmitter::emitConstant(Node *n) {
       Template t_getter(getTemplate("js_getter"));
     
       // call the variable methods as a constants are
    -  // registred in same way
    +  // registered in same way
       enterVariable(n);
       state.variable(GETTER, wname);
       // TODO: why do we need this?
    @@ -2428,7 +2428,7 @@ Template & Template::trim() {
     /* -----------------------------------------------------------------------------
      * Template&  Template::replace(const String* pattern, const String* repl) :
      *
    - *  replaces all occurences of a given pattern with a given replacement.
    + *  replaces all occurrences of a given pattern with a given replacement.
      *
      *  - pattern:  the pattern to be replaced
      *  - repl:     the replacement string
    diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
    index 42005ed3f..4be4478e7 100644
    --- a/Source/Modules/lang.cxx
    +++ b/Source/Modules/lang.cxx
    @@ -3781,7 +3781,7 @@ int Language::abstractClassTest(Node *n) {
         if (dirabstract) {
           if (is_public(dirabstract)) {
     	Swig_warning(WARN_LANG_DIRECTOR_ABSTRACT, Getfile(n), Getline(n),
    -		     "Director class '%s' is abstract, abstract method '%s' is not accesible, maybe due to multiple inheritance or 'nodirector' feature\n",
    +		     "Director class '%s' is abstract, abstract method '%s' is not accessible, maybe due to multiple inheritance or 'nodirector' feature\n",
     		     SwigType_namestr(Getattr(n, "name")), Getattr(dirabstract, "name"));
           } else {
     	Swig_warning(WARN_LANG_DIRECTOR_ABSTRACT, Getfile(n), Getline(n),
    diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
    index 08de34976..927b67953 100644
    --- a/Source/Modules/lua.cxx
    +++ b/Source/Modules/lua.cxx
    @@ -141,7 +141,7 @@ private:
       // This variable holds the name of the current class in Lua. Usually it is
       // the same as C++ class name, but rename directives can change it.
       String *proxy_class_name;
    -  // This is a so calld fully qualified symname - the above proxy class name
    +  // This is a so called fully qualified symname - the above proxy class name
       // prepended with class namespace. If class Lua name is the same as class C++ name,
       // then it is basically C++ fully qualified name with colons replaced with dots.
       String *full_proxy_class_name;	
    @@ -1359,7 +1359,7 @@ public:
         String *rt = Copy(getClassType());
         SwigType_add_pointer(rt);
     
    -    // Adding class to apropriate namespace
    +    // Adding class to appropriate namespace
         registerClass(nspace, wrap_class_name);
         Hash *nspaceHash = getCArraysHash(nspace);
     
    @@ -1461,7 +1461,7 @@ public:
         assert(proxy_class_name);
         assert(full_proxy_class_name);
         
    -    // Then print class isntance part
    +    // Then print class instance part
         Printv(f_wrappers, "static swig_lua_class *swig_", mangled_full_proxy_class_name, "_bases[] = {", base_class, "0};\n", NIL);
         Delete(base_class);
         Printv(f_wrappers, "static const char *swig_", mangled_full_proxy_class_name, "_base_names[] = {", base_class_names, "0};\n", NIL);
    diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
    index 9983e69d2..c606845ea 100644
    --- a/Source/Modules/modula3.cxx
    +++ b/Source/Modules/modula3.cxx
    @@ -219,8 +219,8 @@ private:
       String *module_baseclass;	//inheritance for module class from %pragma
       String *m3raw_interfaces;	//interfaces for intermediary class class from %pragma
       String *module_interfaces;	//interfaces for module class from %pragma
    -  String *m3raw_class_modifiers;	//class modifiers for intermediary class overriden by %pragma
    -  String *m3wrap_modifiers;	//class modifiers for module class overriden by %pragma
    +  String *m3raw_class_modifiers;	//class modifiers for intermediary class overridden by %pragma
    +  String *m3wrap_modifiers;	//class modifiers for module class overridden by %pragma
       String *upcasts_code;		//C++ casts for inheritance hierarchies C++ code
       String *m3raw_cppcasts_code;	//C++ casts up inheritance hierarchies intermediary class code
       String *destructor_call;	//C++ destructor call if any
    @@ -822,7 +822,7 @@ MODULA3():
         Printf(file, "\n");
         Printf(file, "int main (int argc, char *argv[]) {\n");
         Printf(file, "\
    -/*This progam must work for floating point numbers and integers.\n\
    +/*This program must work for floating point numbers and integers.\n\
       Thus all numbers are converted to double precision floating point format.*/\n");
         scanConstant(file, n);
         Printf(file, "  return 0;\n");
    @@ -3214,7 +3214,7 @@ MODULA3():
     
     	tm = Getattr(p, "tmap:m3wrapargvar");
     	if (tm != NIL) {
    -	  /* exceptions that may be raised but can't be catched,
    +	  /* exceptions that may be raised but can't be caught,
     	     thus we won't count them in num_exceptions */
     	  addImports(m3wrap_impl.import, "m3wrapargvar", p);
     	  addThrows(throws_hash, "m3wrapargvar", p);
    diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
    index dd3aecc40..e826e6b3c 100644
    --- a/Source/Modules/mzscheme.cxx
    +++ b/Source/Modules/mzscheme.cxx
    @@ -765,7 +765,7 @@ public:
     
     
       /* ------------------------------------------------------------
    -   * validIdentifer()
    +   * validIdentifier()
        * ------------------------------------------------------------ */
     
       virtual int validIdentifier(String *s) {
    diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
    index a2ede5ff6..b88ad3042 100644
    --- a/Source/Modules/ruby.cxx
    +++ b/Source/Modules/ruby.cxx
    @@ -436,7 +436,7 @@ private:
     
       String *make_autodoc(Node *n, autodoc_t ad_type) {
         int extended = 0;
    -    // If the function is overloaded then this funciton is called
    +    // If the function is overloaded then this function is called
         // for the last one.  Rewind to the first so the docstrings are
         // in order.
         while (Getattr(n, "sym:previousSibling"))
    diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
    index f80fb678f..a872628ef 100644
    --- a/Source/Swig/misc.c
    +++ b/Source/Swig/misc.c
    @@ -523,7 +523,7 @@ String *Swig_string_ucase(String *s) {
       /* We insert a underscore when:
          1. Lower case char followed by upper case char
          getFoo > get_foo; getFOo > get_foo; GETFOO > getfoo
    -     2. Number proceded by char and not end of string
    +     2. Number preceded by char and not end of string
          get2D > get_2d; get22D > get_22d; GET2D > get_2d
          but:
          asFloat2 > as_float2
    diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
    index d12770125..2557892e4 100644
    --- a/Source/Swig/naming.c
    +++ b/Source/Swig/naming.c
    @@ -1055,7 +1055,7 @@ static void name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, S
           Setattr(nameobj, "decl", decl);
         if (nname && Len(nname))
           Setattr(nameobj, "targetname", nname);
    -    /* put the new nameobj at the beginnig of the list, such that the
    +    /* put the new nameobj at the beginning of the list, such that the
            last inserted rule take precedence */
         Insert(name_list, 0, nameobj);
       } else {
    diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
    index af4a38adb..09c413a38 100644
    --- a/Source/Swig/scanner.c
    +++ b/Source/Swig/scanner.c
    @@ -749,11 +749,11 @@ static int look(Scanner *s) {
     	  }
     	  
     	  if (Strcmp( str_delimiter, end_delimiter )==0) {
    -	    Delete( end_delimiter ); /* Correct end delimiter )XXXX" occured */
    +	    Delete( end_delimiter ); /* Correct end delimiter )XXXX" occurred */
     	    Delete( str_delimiter );
     	    str_delimiter = 0;
     	    return SWIG_TOKEN_STRING;
    -	  } else {                   /* Incorrect end delimiter occured */
    +	  } else {                   /* Incorrect end delimiter occurred */
     	    if (c == 0) {
     	      Swig_error(cparse_file, cparse_start_line, "Unterminated raw string, started with R\"%s( is not terminated by )%s\"\n", str_delimiter, str_delimiter);
     	      return SWIG_TOKEN_ERROR;
    diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
    index 7452c374c..5fb9edbf7 100644
    --- a/Source/Swig/swig.h
    +++ b/Source/Swig/swig.h
    @@ -188,7 +188,7 @@ extern "C" {
       extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
       extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
     
    -/* --- Type-system managment --- */
    +/* --- Type-system management --- */
       extern void SwigType_typesystem_init(void);
       extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
       extern int SwigType_typedef_class(const_String_or_char_ptr name);
    diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
    index 6a181f86f..740a93610 100644
    --- a/Source/Swig/swigscan.h
    +++ b/Source/Swig/swigscan.h
    @@ -50,7 +50,7 @@ extern void         Scanner_locator(Scanner *, String *loc);
     #define   SWIG_TOKEN_COLON        12       /* : */
     #define   SWIG_TOKEN_DCOLON       13       /* :: */
     #define   SWIG_TOKEN_DCOLONSTAR   14       /* ::* */
    -#define   SWIG_TOKEN_ID           15       /* identifer */
    +#define   SWIG_TOKEN_ID           15       /* identifier */
     #define   SWIG_TOKEN_FLOAT        16       /* 3.1415F */
     #define   SWIG_TOKEN_DOUBLE       17       /* 3.1415 */
     #define   SWIG_TOKEN_INT          18       /* 314 */
    diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
    index a99a795f1..e3adce1e9 100644
    --- a/Source/Swig/typesys.c
    +++ b/Source/Swig/typesys.c
    @@ -570,7 +570,7 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) {
       List *inherit;
       Typetab *parent;
     
    -  /* if (!s) return 0; *//* now is checked bellow */
    +  /* if (!s) return 0; *//* now is checked below */
       /* Printf(stdout,"Typetab %s : %s\n", Getattr(s,"name"), base);  */
     
       if (!Getmark(s)) {
    
    From 706c91554c98f485847e3f4fc35d4bc0a2e49e4c Mon Sep 17 00:00:00 2001
    From: "luz.paz" 
    Date: Wed, 16 May 2018 22:44:51 -0400
    Subject: [PATCH 0943/2031] fixed typo again after merge conflict
    
    ---
     Doc/Manual/Scilab.html | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
    index 2261c9af7..dd2dacd72 100644
    --- a/Doc/Manual/Scilab.html
    +++ b/Doc/Manual/Scilab.html
    @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE".
     The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
     

    -

    40.3.6.1 Utility functions

    +

    40.3.6.1 Utility functions

    From 4434809e1304b5675114d8281f7024db79c63ded Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Thu, 17 May 2018 10:06:23 -0400 Subject: [PATCH 0944/2031] Changed scilab.html link anchor name per request --- Doc/Manual/Scilab.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index dd2dacd72..f1cc742a9 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE". The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    40.3.6.1 Utility functions

    +

    40.3.6.1 Utility functions

    From 6f698303211aa0d8820dd039f53a8f1fbbf070e3 Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Thu, 17 May 2018 10:26:00 -0400 Subject: [PATCH 0945/2031] follow-up typos --- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Extending.html | 2 +- Doc/Manual/Go.html | 2 +- Doc/Manual/Java.html | 2 +- Doc/Manual/Lisp.html | 2 +- Doc/Manual/Typemaps.html | 2 +- Lib/java/various.i | 2 +- Lib/python/std_unordered_map.i | 2 +- Lib/ruby/ruby.swg | 2 +- Lib/std/std_common.i | 2 +- Source/Modules/javascript.cxx | 4 ++-- Source/Modules/lang.cxx | 2 +- Source/Modules/lua.cxx | 4 ++-- Source/Modules/octave.cxx | 2 +- Tools/config/ax_boost_base.m4 | 2 +- 15 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 15e89e517..e710e66b5 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -2751,7 +2751,7 @@ public class ExtendMe : global::System.IDisposable {

    C# enums use int as the underlying type for each enum item. If you wish to change the underlying type to something else, then use the csbase typemap. -For example when your C++ code uses a value larget than int, this is necessary as the C# compiler will not compile values which are too large to fit into an int. +For example when your C++ code uses a value larger than int, this is necessary as the C# compiler will not compile values which are too large to fit into an int. Here is an example:

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index aafc650f6..f752ebbdc 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -278,7 +278,7 @@ or perl5.swg.

    -As a debugging aide, the text that SWIG feeds to its C++ parser can be +As a debugging aid, the text that SWIG feeds to its C++ parser can be obtained by running swig -E interface.i. This output probably isn't too useful in general, but it will show how macros have been expanded as well as everything else that goes into the low-level diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index c5efe8265..4a60e45e0 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -611,7 +611,7 @@ work is necessary.

    -This subchapter gives a step by step guide how to properly sublass a C++ class +This subchapter gives a step by step guide how to properly subclass a C++ class with a Go type. In general it is strongly recommended to follow this guide completely to avoid common pitfalls with directors in Go.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 18a6c424e..4c7b6d058 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3877,7 +3877,7 @@ Or target all wrapped methods using: This tells SWIG to generate a C++ catch handler using some code from the throws typemap for Swig::DirectorException that SWIG supplies by default, see Exception handling with %catches. This typemap code is written to simply catch the C++ Swig::DirectorException class and immediately return to Java throwing the original Java exception that it has stored. -The net result is a stack trace containing the original Java exception including the location that the exception was thown from. +The net result is a stack trace containing the original Java exception including the location that the exception was thrown from.

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 0d9e3dc4f..2e6ca8dda 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -650,7 +650,7 @@ swig -clisp -module module-name file-name generated by SWIG may not be absolutely correct, and you may need to modify them. The good thing is that you don't need to complex interface file for the CLISP module. The CLISP module tries to - produce code which is both human readable and easily modifyable. + produce code which is both human readable and easily modifiable.

    28.3.1 Additional Commandline Options

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 093ff7e95..ed5591da5 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1360,7 +1360,7 @@ Below is a list of the typical default types supplied by language modules, showi %typemap(in) SWIGTYPE * { ... default pointer handling ... }; %typemap(in) SWIGTYPE *const { ... default pointer const handling ... }; %typemap(in) SWIGTYPE *const& { ... default pointer const reference handling ... }; -%typemap(in) SWIGTYPE[ANY] { ... 1D fixed size arrays handlling ... }; +%typemap(in) SWIGTYPE[ANY] { ... 1D fixed size arrays handling ... }; %typemap(in) SWIGTYPE [] { ... unknown sized array handling ... }; %typemap(in) enum SWIGTYPE { ... default handling for enum values ... }; %typemap(in) const enum SWIGTYPE & { ... default handling for const enum reference values ... }; diff --git a/Lib/java/various.i b/Lib/java/various.i index 76fb2b129..24796ba84 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -129,7 +129,7 @@ /* * char *BYTE typemaps. * These are input typemaps for mapping a Java byte[] array to a C char array. - * Note that as a Java array is used and thus passeed by reference, the C routine + * Note that as a Java array is used and thus passed by reference, the C routine * can return data to Java via the parameter. * * Example usage wrapping: diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 53f6aa283..bec7d165d 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -31,7 +31,7 @@ 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!"); + items = PySequence_Fast(items, ".items() haven't returned a sequence!"); %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { diff --git a/Lib/ruby/ruby.swg b/Lib/ruby/ruby.swg index efa8ec2f7..d1335974e 100644 --- a/Lib/ruby/ruby.swg +++ b/Lib/ruby/ruby.swg @@ -14,7 +14,7 @@ /* Constants created by %constant or #define are UPPER_CASE */ %rename("%(uppercase)s", %$isconstant) ""; -/* SWIG only considers static class members with inline intializers +/* SWIG only considers static class members with inline initializers to be constants. For examples of what is and isn't considered a constant by SWIG see naming.i in the Ruby test suite. */ %rename("%(uppercase)s", %$ismember, %$isvariable,%$isimmutable,%$isstatic,%$hasvalue,%$hasconsttype) ""; diff --git a/Lib/std/std_common.i b/Lib/std/std_common.i index 05bc4325a..708f3ceed 100644 --- a/Lib/std/std_common.i +++ b/Lib/std/std_common.i @@ -5,7 +5,7 @@ // //#define SWIG_STD_MODERN_STL // -// Use this to deactive the previous definition, when using gcc-2.95 +// Use this to deactivate the previous definition, when using gcc-2.95 // or similar old compilers. // //#define SWIG_STD_NOMODERN_STL diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 0840dd5f4..8c87330b7 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -553,7 +553,7 @@ void JAVASCRIPT::main(int argc, char *argv[]) { emitter = swig_javascript_create_V8Emitter(); Preprocessor_define("SWIG_JAVASCRIPT_V8 1", 0); SWIG_library_directory("javascript/v8"); - // V8 API is C++, so output must be C++ compatibile even when wrapping C code + // V8 API is C++, so output must be C++ compatible even when wrapping C code if (!cparse_cplusplus) { Swig_cparse_cplusplusout(1); } @@ -2038,7 +2038,7 @@ int V8Emitter::exitClass(Node *n) { .pretty_print(f_init_inheritance); Delete(base_name_mangled); } - // emit registeration of class template + // emit registration of class template Template t_register = getTemplate("jsv8_register_class"); t_register.replace("$jsmangledname", state.clazz(NAME_MANGLED)) .replace("$jsname", state.clazz(NAME)) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 4be4478e7..37ce54a75 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3521,7 +3521,7 @@ int Language::need_nonpublic_ctor(Node *n) { Note: given all the complications here, I am always in favor to always enable 'dirprot', since is the C++ idea of protected - members, and use %ignore for the method you don't whan to add in + members, and use %ignore for the method you don't want to add in the director class. */ if (directorsEnabled()) { diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 927b67953..188b11c2b 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -2110,7 +2110,7 @@ public: // variable in resulting file getCArraysHash(0); } - // Because we cant access directly 'symtabs', instead we access + // Because we can't directly access 'symtabs', instead we access // top-level scope and look on all scope pseudo-symbols in it. Hash *top_scope = symbolScopeLookup(""); assert(top_scope); @@ -2193,7 +2193,7 @@ public: String *luaCurrentSymbolNSpace() { String *scope = 0; - // If ouside class, than NSpace is used. + // If outside class, than NSpace is used. // If inside class, but current[NO_CPP], then this is friend function. It belongs to NSpace if (!getCurrentClass() || current[NO_CPP]) { scope = getNSpace(); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 0d7168225..81434ce0b 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -139,7 +139,7 @@ public: SWIG_typemap_lang("octave"); allow_overloading(); - // Octave API is C++, so output must be C++ compatibile even when wrapping C code + // Octave API is C++, so output must be C++ compatible even when wrapping C code if (!cparse_cplusplus) Swig_cparse_cplusplusout(1); } diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4 index f3279f2b7..0e0f266dc 100644 --- a/Tools/config/ax_boost_base.m4 +++ b/Tools/config/ax_boost_base.m4 @@ -10,7 +10,7 @@ # # Test for the Boost C++ libraries of a particular version (or newer) # -# If no path to the installed boost library is given the macro searchs +# If no path to the installed boost library is given the macro searches # under /usr, /usr/local, /opt and /opt/local and evaluates the # $BOOST_ROOT environment variable. Further documentation is available at # . From 51a89d9feabc4a661b73d2e987e5e4797e026442 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 10:14:10 +1200 Subject: [PATCH 0946/2031] Fix another documentation typo --- Doc/Manual/Javascript.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 2acb2e274..c328bbb6b 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -161,7 +161,7 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    @@ -443,18 +373,12 @@ void JavaDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag, } } -void JavaDocConverter::handleHtmlEntity(DoxygenEntity&, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, std::string &arg) { // html entities can be preserved for Java translatedComment += arg + ';'; } -void JavaDocConverter::handleNewLine(DoxygenEntity&, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, std::string &) { //
    tag is added, because otherwise to much text is joined // into same paragraph by javadoc. For example, doxy list: // - item one @@ -466,10 +390,7 @@ void JavaDocConverter::handleNewLine(DoxygenEntity&, translatedComment += "
    \n * "; } -void JavaDocConverter::handleTagChar(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { // escape it if we need to, else just print if (arg.size()) translatedComment += arg; @@ -478,57 +399,37 @@ void JavaDocConverter::handleTagChar(DoxygenEntity& tag, } // handles tags which are the same in Doxygen and Javadoc. -void JavaDocConverter::handleTagSame(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { if (arg.size()) tag.typeOfEntity = arg; - translatedComment += formatCommand( - std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2); + translatedComment += formatCommand(std::string("@" + tag.typeOfEntity + " " + translateSubtree(tag)), 2); } -void JavaDocConverter::handleParagraph(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &) { translatedComment += formatCommand(translateSubtree(tag), 0); } -void JavaDocConverter::handlePlainString(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &) { translatedComment += tag.data; // if (tag.data.size() && tag.data[tag.data.size()-1] != ' ') - // translatedComment += " "; + // translatedComment += " "; } -void JavaDocConverter::handleTagVerbatim(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { translatedComment += arg + " "; - for (DoxygenEntityListCIt it = tag.entityList.begin(); - it != tag.entityList.end(); it++) { + for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) { translatedComment += it->data; } } -void JavaDocConverter::handleTagExtended(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { std::string dummy; translatedComment += "{@" + arg + " "; handleParagraph(tag, translatedComment, dummy); translatedComment += "}"; } -void JavaDocConverter::handleTagIf(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { std::string dummy; translatedComment += arg; if (tag.entityList.size()) { @@ -538,19 +439,13 @@ void JavaDocConverter::handleTagIf(DoxygenEntity& tag, } } -void JavaDocConverter::handleTagMessage(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg) -{ +void JavaDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg) { std::string dummy; translatedComment += formatCommand(arg, 0); handleParagraph(tag, translatedComment, dummy); } -void JavaDocConverter::handleTagImage(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &) { if (tag.entityList.size() < 2) return; @@ -577,10 +472,7 @@ void JavaDocConverter::handleTagImage(DoxygenEntity& tag, translatedComment += "/>"; } -void JavaDocConverter::handleTagPar(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &) { std::string dummy; translatedComment += "= rbracePos) + if (lbracePos == string::npos || rbracePos == string::npos || lbracePos >= rbracePos) return ""; string paramsStr = linkObject.substr(lbracePos + 1, - rbracePos - lbracePos - 1); + rbracePos - lbracePos - 1); // strip the params, to fill them later string additionalObject = linkObject.substr(rbracePos + 1, string::npos); linkObject = linkObject.substr(0, lbracePos); @@ -679,7 +563,7 @@ string JavaDocConverter::convertLink(string linkObject) SwigType_add_qualifier(swigType, "const"); // handle pointers, references and arrays - for (int j = (int) params[i].size() - 1; j >= 0; j--) { + for (int j = (int)params[i].size() - 1; j >= 0; j--) { // skip all the [...] blocks, write 'p.' for every of it if (paramStr[j] == ']') { while (j >= 0 && paramStr[j] != '[') @@ -699,8 +583,7 @@ string JavaDocConverter::convertLink(string linkObject) typeNameStart = 0; else typeNameStart++; - Append(swigType, - paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str()); + Append(swigType, paramStr.substr(typeNameStart, j - typeNameStart + 1).c_str()); break; } } @@ -708,11 +591,10 @@ string JavaDocConverter::convertLink(string linkObject) // make dummy param list, to lookup typemaps for it Parm *dummyParam = NewParm(swigType, "", 0); Swig_typemap_attach_parms("jstype", dummyParam, NULL); - Language::instance()->replaceSpecialVariables(0, - Getattr(dummyParam, "tmap:jstype"), dummyParam); + Language::instance()->replaceSpecialVariables(0, Getattr(dummyParam, "tmap:jstype"), dummyParam); //Swig_print(dummyParam, 1); - linkObject += Char (Getattr(dummyParam, "tmap:jstype")); + linkObject += Char(Getattr(dummyParam, "tmap:jstype")); if (i != params.size() - 1) linkObject += ","; @@ -724,10 +606,7 @@ string JavaDocConverter::convertLink(string linkObject) return linkObject + additionalObject; } -void JavaDocConverter::handleTagLink(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &) { std::string dummy; if (!tag.entityList.size()) return; @@ -743,10 +622,7 @@ void JavaDocConverter::handleTagLink(DoxygenEntity& tag, translatedComment += "}"; } -void JavaDocConverter::handleTagSee(DoxygenEntity& tag, - std::string& translatedComment, - std::string&) -{ +void JavaDocConverter::handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &) { std::string dummy; if (!tag.entityList.size()) return; @@ -762,7 +638,6 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag, // handleNewLine(*it, translatedComment, dummy); continue; } - // restore entities which may be used in C++ type declaration if (it->typeOfEntity == "&") { methodRef += '&'; @@ -779,8 +654,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag, size_t lbrace = methodRef.find('('); size_t dblColon = methodRef.find("::"); if (dblColon < lbrace) { - methodRef = methodRef.substr(0, dblColon) + '#' - + methodRef.substr(dblColon + 2); + methodRef = methodRef.substr(0, dblColon) + '#' + methodRef.substr(dblColon + 2); } translatedComment += "@see "; @@ -808,8 +682,7 @@ void JavaDocConverter::handleTagSee(DoxygenEntity& tag, |-endline * */ -int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) -{ +int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) { DoxygenEntityListIt it = root.entityList.begin(); while (it != root.entityList.end()) { // remove line endings @@ -828,7 +701,7 @@ int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) int removedCount = 0; while (!root.entityList.empty() - && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") { + && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") { root.entityList.pop_back(); removedCount++; } @@ -841,8 +714,7 @@ int JavaDocConverter::shiftEndlinesUpTree(DoxygenEntity &root, int level) * to indentation of the first line. Indentation of non-empty lines is not * changed - garbage in garbage out. */ -std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) -{ +std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) { size_t idx = doc.find('\n'); size_t indent = 0; @@ -857,10 +729,10 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) } } - if (indent == 0) { // we can't indent the first line less than 0 + if (indent == 0) { + // we can't indent the first line less than 0 indent = 1; } - // Create the first line of Javadoc comment. string indentStr(indent - 1, ' '); string translatedStr = indentStr + "/**"; @@ -881,13 +753,11 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) // line without '*' found - is it empty? if (translatedStr[nonspaceIdx] != '\n') { // add '* ' to each line without it - translatedStr = translatedStr.substr(0, nonspaceIdx) + "* " - + translatedStr.substr(nonspaceIdx); + translatedStr = translatedStr.substr(0, nonspaceIdx) + "* " + translatedStr.substr(nonspaceIdx); //printf(translatedStr.c_str()); } else { // we found empty line, replace it with indented '*' - translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* " - + translatedStr.substr(nonspaceIdx); + translatedStr = translatedStr.substr(0, idx + 1) + indentStr + "* " + translatedStr.substr(nonspaceIdx); } } idx = translatedStr.find('\n', nonspaceIdx); @@ -908,8 +778,7 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) return translatedStr; } -String *JavaDocConverter::makeDocumentation(Node *node) -{ +String *JavaDocConverter::makeDocumentation(Node *node) { String *documentation = getDoxygenComment(node); @@ -919,7 +788,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) if (GetFlag(node, "feature:doxygen:notranslate")) { - string doc = Char (documentation); + string doc = Char(documentation); string translatedStr = indentAndInsertAsterisks(doc); @@ -936,7 +805,6 @@ String *JavaDocConverter::makeDocumentation(Node *node) std::cout << "---RESORTED LIST---" << std::endl; printTree(entityList); } - // store the current node // (currently just to handle params) currentNode = node; @@ -949,13 +817,13 @@ String *JavaDocConverter::makeDocumentation(Node *node) // strip line endings at the beginning while (!root.entityList.empty() - && root.entityList.begin()->typeOfEntity == "plainstd::endl") { + && root.entityList.begin()->typeOfEntity == "plainstd::endl") { root.entityList.pop_front(); } // and at the end while (!root.entityList.empty() - && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") { + && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") { root.entityList.pop_back(); } @@ -971,8 +839,6 @@ String *JavaDocConverter::makeDocumentation(Node *node) return NewString(javaDocString.c_str()); } -void JavaDocConverter::addError(int warningType, const std::string &message) -{ - Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n", - message.c_str()); +void JavaDocConverter::addError(int warningType, const std::string &message) { + Swig_warning(warningType, "", 0, "Doxygen parser warning: %s. \n", message.c_str()); } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index eff00590c..df579e625 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -30,20 +30,23 @@ protected: * Used to properly format JavaDoc-style command */ std::string formatCommand(std::string unformattedLine, int indent); + /* * Translate every entity in a tree. */ - std::string translateSubtree(DoxygenEntity & doxygenEntity); + std::string translateSubtree(DoxygenEntity &doxygenEntity); + /* * Translate one entity with the appropriate handler, according * to the tagHandlers */ void translateEntity(DoxygenEntity &tag, std::string &translatedComment); + /* * Fix all endlines location, etc */ int shiftEndlinesUpTree(DoxygenEntity &root, int level = 0); - + /* * Convert params in link-objects and references */ @@ -53,18 +56,15 @@ protected: * Typedef for the function that handles one tag * arg - some string argument to easily pass it through lookup table */ - typedef void (JavaDocConverter::*tagHandler)(DoxygenEntity &tag, - std::string &translatedComment, std::string &arg); + typedef void (JavaDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /** * Copies verbatim args of the tag to output, used for commands like \f$, ... */ - void handleTagVerbatim(DoxygenEntity& tag, std::string& translatedComment, std::string &arg); + void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /** Creates anchor link. */ - void handleTagAnchor(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg); + void handleTagAnchor(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Wrap the command data with the html tag @@ -73,80 +73,87 @@ protected: void handleTagHtml(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* Handles HTML tags recognized by Doxygen, like ,
      , , ... */ - void handleDoxyHtmlTag(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg); + void handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* Handles HTML entities recognized by Doxygen, like <, ©, ... */ - void handleHtmlEntity(DoxygenEntity& tag, - std::string& translatedComment, - std::string &arg); + void handleHtmlEntity(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); /* * Just prints new line */ void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Print the name of tag to the output, used for escape-commands * arg - html-escaped variant, if not provided the command data is used */ void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Do not translate and print as-is * arg - the new tag name, if it needs to be renamed */ void handleTagSame(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Print only the content and strip original tag */ void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Print only data part of code */ void handlePlainString(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Print extended Javadoc command, like {@code ...} or {@literal ...} * arg - command name */ void handleTagExtended(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Print the if-elseif-else-endif section */ void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Prints the specified message, than the contents of the tag * arg - message */ void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Insert tag if the 'format' field is specified as 'html' */ void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Insert

      ...

      */ void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Insert \@param command, if it is really a function param */ void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Writes link for \ref tag. */ - void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, - std::string&); + void handleTagRef(DoxygenEntity &tag, std::string &translatedComment, std::string &); + /* * Insert {@link...} command, and handle all the s correctly * (like converting types of params, etc) */ void handleTagLink(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); + /* * Insert @see command, and handle all the s correctly * (like converting types of params, etc) */ void handleTagSee(DoxygenEntity &tag, std::string &translatedComment, std::string &arg); - private: Node *currentNode; // this contains the handler pointer and one string argument diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 76431af54..b6aaa2d91 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -28,18 +28,14 @@ using std::string; // Helper class increasing the provided indent string in its ctor and decreasing // it in its dtor. -class IndentGuard -{ +class IndentGuard { public: // One indent level. - static const char* Level() { return " "; } - - // Default ctor doesn't do anything and prevents the dtor from doing anything - // too and should only be used when the guard needs to be initialized - // conditionally as Init() can then be called after checking some condition. - // Otherwise, prefer to use the non default ctor below. - IndentGuard() - { + static const char *Level() { + return " "; + } + // Default ctor doesn't do anything and prevents the dtor from doing anything// too and should only be used when the guard needs to be initialized// conditionally as Init() can then be called after checking some condition.// Otherwise, prefer to use the non default ctor below. + IndentGuard() { m_initialized = false; } @@ -47,14 +43,12 @@ public: // extra indent added to it in the dtor and the variable containing the indent // to use, which must be used after every new line by the code actually // updating the output. - IndentGuard(string& output, string& indent) - { + IndentGuard(string &output, string &indent) { Init(output, indent); } // Really initializes the object created using the default ctor. - void Init(string& output, string& indent) - { + void Init(string &output, string &indent) { m_output = &output; m_indent = &indent; @@ -77,10 +71,11 @@ public: // Get the indent for the first line of the paragraph, which is smaller than // the indent for the subsequent lines. - string getFirstLineIndent() const { return string(m_firstLineIndent, ' '); } - - ~IndentGuard() - { + string getFirstLineIndent() const { + return string(m_firstLineIndent, ' '); + } + + ~IndentGuard() { if (!m_initialized) return; @@ -93,24 +88,23 @@ public: if (m_output->length() > lenIndentLevel) { const size_t start = m_output->length() - lenIndentLevel; if (m_output->compare(start, string::npos, Level()) == 0) - m_output->erase(start); + m_output->erase(start); } } private: - string* m_output; - string* m_indent; + string *m_output; + string *m_indent; unsigned m_firstLineIndent; bool m_initialized; - IndentGuard(const IndentGuard&); - IndentGuard& operator=(const IndentGuard&); + IndentGuard(const IndentGuard &); + IndentGuard &operator=(const IndentGuard &); }; // Return the indent of the given multiline string, i.e. the maximal number of // spaces present in the beginning of all its non-empty lines. -static size_t determineIndent(const string& s) -{ +static size_t determineIndent(const string &s) { size_t minIndent = static_cast(-1); for (size_t lineStart = 0; lineStart < s.length();) { @@ -136,8 +130,7 @@ static size_t determineIndent(const string& s) return minIndent; } -static void trimWhitespace(string& s) -{ +static void trimWhitespace(string &s) { const size_t lastNonSpace = s.find_last_not_of(' '); if (lastNonSpace == string::npos) s.clear(); @@ -146,21 +139,16 @@ static void trimWhitespace(string& s) } /* static */ -PyDocConverter::TagHandlersMap::mapped_type -PyDocConverter::make_handler(tagHandler handler) -{ +PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) { return make_pair(handler, std::string()); } /* static */ -PyDocConverter::TagHandlersMap::mapped_type -PyDocConverter::make_handler(tagHandler handler, const char* arg) -{ +PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler, const char *arg) { return make_pair(handler, arg); } -void PyDocConverter::fillStaticTables() -{ +void PyDocConverter::fillStaticTables() { if (tagHandlers.size()) // fill only once return; @@ -213,9 +201,7 @@ void PyDocConverter::fillStaticTables() tagHandlers["details"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["em"] = make_handler(&PyDocConverter::handleParagraph, " "); tagHandlers["example"] = make_handler(&PyDocConverter::handleParagraph); - tagHandlers["exception"] = - tagHandlers["throw"] = - tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException); + tagHandlers["exception"] = tagHandlers["throw"] = tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException); tagHandlers["htmlonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["invariant"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["latexonly"] = make_handler(&PyDocConverter::handleParagraph); @@ -228,8 +214,7 @@ void PyDocConverter::fillStaticTables() tagHandlers["remark"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["remarks"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["sa"] = make_handler(&PyDocConverter::handleTagMessage, "See also: "); - tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage, - "See also: "); + tagHandlers["see"] = make_handler(&PyDocConverter::handleTagMessage, "See also: "); tagHandlers["since"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph); @@ -239,27 +224,21 @@ void PyDocConverter::fillStaticTables() tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph); // these commands have special handlers tagHandlers["arg"] = make_handler(&PyDocConverter::handleTagMessage, "* "); - tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage, - "Conditional comment: "); + tagHandlers["cond"] = make_handler(&PyDocConverter::handleTagMessage, "Conditional comment: "); tagHandlers["else"] = make_handler(&PyDocConverter::handleTagIf, "Else: "); tagHandlers["elseif"] = make_handler(&PyDocConverter::handleTagIf, "Else if: "); - tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage, - "End of conditional comment."); + tagHandlers["endcond"] = make_handler(&PyDocConverter::handleTagMessage, "End of conditional comment."); tagHandlers["if"] = make_handler(&PyDocConverter::handleTagIf, "If: "); tagHandlers["ifnot"] = make_handler(&PyDocConverter::handleTagIf, "If not: "); tagHandlers["image"] = make_handler(&PyDocConverter::handleTagImage); tagHandlers["li"] = make_handler(&PyDocConverter::handleTagMessage, "* "); tagHandlers["overload"] = make_handler(&PyDocConverter::handleTagMessage, - "This is an overloaded member function, provided for" - " convenience.\nIt differs from the above function only in what" - " argument(s) it accepts."); + "This is an overloaded member function, provided for" + " convenience.\nIt differs from the above function only in what" " argument(s) it accepts."); tagHandlers["par"] = make_handler(&PyDocConverter::handleTagPar); - tagHandlers["param"] = - tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam); + tagHandlers["param"] = tagHandlers["tparam"] = make_handler(&PyDocConverter::handleTagParam); tagHandlers["ref"] = make_handler(&PyDocConverter::handleTagRef); - tagHandlers["result"] = - tagHandlers["return"] = - tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn); + tagHandlers["result"] = tagHandlers["return"] = tagHandlers["returns"] = make_handler(&PyDocConverter::handleTagReturn); // this command just prints it's contents // (it is internal command of swig's parser, contains plain text) @@ -268,15 +247,12 @@ void PyDocConverter::fillStaticTables() tagHandlers["n"] = make_handler(&PyDocConverter::handleNewLine); // \f commands output literal Latex formula, which is still better than nothing. - tagHandlers["f$"] = - tagHandlers["f["] = - tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath); + tagHandlers["f$"] = tagHandlers["f["] = tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath); // HTML tags tagHandlers[""); } -PyDocConverter::PyDocConverter(int flags) : - DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH( - false) -{ +PyDocConverter::PyDocConverter(int flags): +DoxygenTranslator(flags), m_tableLineLen(0), m_prevRowIsTH(false) { fillStaticTables(); } // Return the type as it should appear in the output documentation. -static -std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "") -{ +static std::string getPyDocType(Node *n, const_String_or_char_ptr lname = "") { std::string type; String *s = Swig_typemap_lookup("doctype", n, lname, 0); @@ -371,13 +342,13 @@ std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "") if (Language::classLookup(s)) { // In Python C++ namespaces are flattened, so remove all but last component // of the name. - String * const last = Swig_scopename_last(s); + String *const last = Swig_scopename_last(s); // We are not actually sure whether it's a documented class or not, but // there doesn't seem to be any harm in making it a reference if it isn't, // while there is a lot of benefit in having a hyperlink if it is. type = ":py:class:`"; - type += Char (last); + type += Char(last); type += "`"; Delete(last); @@ -390,14 +361,13 @@ std::string getPyDocType(Node* n, const_String_or_char_ptr lname = "") return type; } -std::string PyDocConverter::getParamType(std::string param) -{ +std::string PyDocConverter::getParamType(std::string param) { std::string type; ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); - for (Parm *p = plist; p;p = nextSibling(p)) { - String* pname = Getattr(p, "name"); - if (Char (pname) != param) + for (Parm *p = plist; p; p = nextSibling(p)) { + String *pname = Getattr(p, "name"); + if (Char(pname) != param) continue; type = getPyDocType(p, pname); @@ -407,8 +377,7 @@ std::string PyDocConverter::getParamType(std::string param) return type; } -std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) -{ +std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) { std::string translatedComment; if (doxygenEntity.isLeaf) @@ -433,28 +402,19 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) return translatedComment; } -void PyDocConverter::translateEntity(DoxygenEntity & doxyEntity, - std::string &translatedComment) -{ +void PyDocConverter::translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment) { // check if we have needed handler and call it std::map >::iterator it; it = tagHandlers.find(doxyEntity.typeOfEntity); if (it != tagHandlers.end()) - (this->*(it->second.first))(doxyEntity, translatedComment, - it->second.second); + (this->*(it->second.first)) (doxyEntity, translatedComment, it->second.second); } -void PyDocConverter::handleParagraph(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { translatedComment += translateSubtree(tag); } -void PyDocConverter::handleMath(DoxygenEntity &tag, - std::string &translatedComment, - const std::string& arg) -{ +void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { IndentGuard indent; // Only \f$ is translated to inline formulae, \f[ and \f{ are for the block ones. @@ -507,10 +467,7 @@ void PyDocConverter::handleMath(DoxygenEntity &tag, } } -void PyDocConverter::handleCode(DoxygenEntity &tag, - std::string &translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { IndentGuard indent(translatedComment, m_indent); trimWhitespace(translatedComment); @@ -552,43 +509,27 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, translatedComment += '\n'; } -void PyDocConverter::handlePlainString(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { translatedComment += tag.data; } -void PyDocConverter::handleTagVerbatim(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { translatedComment += arg + " "; - for (DoxygenEntityListCIt it = tag.entityList.begin(); - it != tag.entityList.end(); it++) { + for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) { translatedComment += it->data; } } -void PyDocConverter::handleTagMessage(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { translatedComment += arg; handleParagraph(tag, translatedComment); } -void PyDocConverter::handleTagChar(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { translatedComment += tag.typeOfEntity; } -void PyDocConverter::handleTagIf(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { translatedComment += arg; if (tag.entityList.size()) { translatedComment += tag.entityList.begin()->data; @@ -597,10 +538,7 @@ void PyDocConverter::handleTagIf(DoxygenEntity& tag, } } -void PyDocConverter::handleTagPar(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { translatedComment += "Title: "; if (tag.entityList.size()) translatedComment += tag.entityList.begin()->data; @@ -608,10 +546,7 @@ void PyDocConverter::handleTagPar(DoxygenEntity& tag, handleParagraph(tag, translatedComment); } -void PyDocConverter::handleTagImage(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { if (tag.entityList.size() < 2) return; tag.entityList.pop_front(); @@ -622,10 +557,7 @@ void PyDocConverter::handleTagImage(DoxygenEntity& tag, translatedComment += "(" + tag.entityList.begin()->data + ")"; } -void PyDocConverter::handleTagParam(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { if (tag.entityList.size() < 2) return; @@ -634,7 +566,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag, DoxygenEntity paramNameEntity = *tag.entityList.begin(); tag.entityList.pop_front(); - const std::string& paramName = paramNameEntity.data; + const std::string ¶mName = paramNameEntity.data; const std::string paramType = getParamType(paramName); if (!paramType.empty()) { @@ -648,10 +580,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity& tag, } -void PyDocConverter::handleTagReturn(DoxygenEntity &tag, - std::string &translatedComment, - const std::string &) -{ +void PyDocConverter::handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { IndentGuard indent(translatedComment, m_indent); const std::string pytype = getPyDocType(currentNode); @@ -667,10 +596,7 @@ void PyDocConverter::handleTagReturn(DoxygenEntity &tag, } -void PyDocConverter::handleTagException(DoxygenEntity &tag, - std::string &translatedComment, - const std::string &) -{ +void PyDocConverter::handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { IndentGuard indent(translatedComment, m_indent); translatedComment += ":raises: "; @@ -678,10 +604,7 @@ void PyDocConverter::handleTagException(DoxygenEntity &tag, } -void PyDocConverter::handleTagRef(DoxygenEntity& tag, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleTagRef(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { if (!tag.entityList.size()) return; @@ -695,26 +618,19 @@ void PyDocConverter::handleTagRef(DoxygenEntity& tag, } -void PyDocConverter::handleTagWrap(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { if (tag.entityList.size()) { // do not include empty tags std::string tagData = translateSubtree(tag); // wrap the thing, ignoring whitespace size_t wsPos = tagData.find_last_not_of("\n\t "); if (wsPos != std::string::npos && wsPos != tagData.size() - 1) - translatedComment += arg + tagData.substr(0, wsPos + 1) + arg - + tagData.substr(wsPos + 1); + translatedComment += arg + tagData.substr(0, wsPos + 1) + arg + tagData.substr(wsPos + 1); else translatedComment += arg + tagData + arg; } } -void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end html tag, for example " @@ -724,10 +640,7 @@ void PyDocConverter::handleDoxyHtmlTag(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end html tag, for example " @@ -736,10 +649,7 @@ void PyDocConverter::handleDoxyHtmlTagNoParam(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end html tag, " @@ -755,10 +665,7 @@ void PyDocConverter::handleDoxyHtmlTag_A(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end html tag, for example " @@ -768,18 +675,14 @@ void PyDocConverter::handleDoxyHtmlTag2(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &) -{ +void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { std::string htmlTagArgs = tag.data; size_t nlPos = translatedComment.rfind('\n'); if (htmlTagArgs == "/") { // end tag, appends vertical table line '|' translatedComment += '|'; if (nlPos != string::npos) { - size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t", - nlPos + 1); + size_t startOfTableLinePos = translatedComment.find_first_not_of(" \t", nlPos + 1); if (startOfTableLinePos != string::npos) { m_tableLineLen = translatedComment.size() - startOfTableLinePos; } @@ -800,10 +703,7 @@ void PyDocConverter::handleDoxyHtmlTag_tr(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &) -{ +void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end tag, is ignored @@ -813,10 +713,7 @@ void PyDocConverter::handleDoxyHtmlTag_th(DoxygenEntity& tag, } } -void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &) -{ +void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { std::string htmlTagArgs = tag.data; if (htmlTagArgs == "/") { // end tag, is ignored @@ -825,18 +722,12 @@ void PyDocConverter::handleDoxyHtmlTag_td(DoxygenEntity& tag, } } -void PyDocConverter::handleHtmlEntity(DoxygenEntity&, - std::string& translatedComment, - const std::string &arg) -{ +void PyDocConverter::handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg) { // html entities translatedComment += arg; } -void PyDocConverter::handleNewLine(DoxygenEntity&, - std::string& translatedComment, - const std::string&) -{ +void PyDocConverter::handleNewLine(DoxygenEntity &, std::string &translatedComment, const std::string &) { trimWhitespace(translatedComment); translatedComment += "\n"; @@ -844,8 +735,7 @@ void PyDocConverter::handleNewLine(DoxygenEntity&, translatedComment += m_indent; } -String *PyDocConverter::makeDocumentation(Node *n) -{ +String *PyDocConverter::makeDocumentation(Node *n) { String *documentation; std::string pyDocString; @@ -873,7 +763,7 @@ String *PyDocConverter::makeDocumentation(Node *n) String *comment = NewString(""); Append(comment, documentation); Replaceall(comment, "\n *", "\n"); - oneDoc = Char (comment); + oneDoc = Char(comment); Delete(comment); } else { std::list entityList = parser.createTree(n, documentation); @@ -898,12 +788,10 @@ String *PyDocConverter::makeDocumentation(Node *n) if (allDocumentation.size() > 1) { string indentStr; if (minIndent != static_cast(-1)) - indentStr.assign(minIndent, ' '); + indentStr.assign(minIndent, ' '); std::ostringstream concatDocString; - for (size_t realOverloadCount = 0; - realOverloadCount < allDocumentation.size(); - realOverloadCount++) { + for (size_t realOverloadCount = 0; realOverloadCount < allDocumentation.size(); realOverloadCount++) { if (realOverloadCount != 0) { // separate it from the preceding one. concatDocString << "\n" << indentStr << "|\n\n"; @@ -911,8 +799,7 @@ String *PyDocConverter::makeDocumentation(Node *n) oneDoc = allDocumentation[realOverloadCount]; trimWhitespace(oneDoc); - concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n" - << oneDoc; + concatDocString << indentStr << "*Overload " << (realOverloadCount + 1) << ":*\n" << oneDoc; } pyDocString = concatDocString.str(); } else if (allDocumentation.size() == 1) { @@ -927,7 +814,7 @@ String *PyDocConverter::makeDocumentation(Node *n) String *comment = NewString(""); Append(comment, documentation); Replaceall(comment, "\n *", "\n"); - pyDocString = Char (comment); + pyDocString = Char(comment); Delete(comment); } else { std::list entityList = parser.createTree(n, documentation); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 338b1fed9..b78d81ed3 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -20,8 +20,8 @@ #include "DoxygenEntity.h" #include "DoxygenTranslator.h" -#define DOC_STRING_LENGTH 64 // characters per line allowed -#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type +#define DOC_STRING_LENGTH 64 // characters per line allowed +#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type class PyDocConverter : public DoxygenTranslator { public: @@ -39,42 +39,45 @@ protected: * display. Prints title for every group of tags that have * a section title associated with them */ - std::string translateSubtree(DoxygenEntity & doxygenEntity); + std::string translateSubtree(DoxygenEntity &doxygenEntity); + /* * Translate one entity with the appropriate handler, according * to the tagHandlers */ - void translateEntity(DoxygenEntity & doxyEntity, std::string &translatedComment); + void translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment); /* * Typedef for the function that handles one tag * arg - some string argument to easily pass it through lookup table */ - typedef void (PyDocConverter::*tagHandler)(DoxygenEntity &tag, - std::string &translatedComment, const std::string &arg); + typedef void (PyDocConverter::*tagHandler) (DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* * Wrap the command data with the some string * arg - string to wrap with, like '_' or '*' */ void handleTagWrap(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Just prints new line */ void handleNewLine(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Print the name of tag to the output, used for escape-commands */ void handleTagChar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Format the contents of the \exception tag or its synonyms. */ void handleTagException(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Print only the content and strip original tag */ - void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, - const std::string &arg = std::string()); + void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string()); /* * Handle one of the Doxygen formula-related tags. @@ -94,78 +97,73 @@ protected: /** * Copies verbatim args of the tag to output, used for commands like \f$, ... */ - void handleTagVerbatim(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg); + void handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* * Print the if-elseif-else-endif section */ void handleTagIf(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Prints the specified message, than the contents of the tag * arg - message */ void handleTagMessage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Insert 'Title: ...' */ void handleTagPar(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Insert 'Image: ...' */ void handleTagImage(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Format nice param description with type information */ void handleTagParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Format the contents of the \return tag or its synonyms. */ void handleTagReturn(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); + /* * Writes text for \ref tag. */ - void handleTagRef(DoxygenEntity& tag, std::string& translatedComment, const std::string &arg); + void handleTagRef(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* Handles HTML tags recognized by Doxygen, like ,
        ,
      , ... */ - void handleDoxyHtmlTag(DoxygenEntity& tag, std::string& translatedComment, const std::string &arg); + void handleDoxyHtmlTag(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /** Does not output params of HTML tag, for example in
      * 'border=1' is not written to output. */ - void handleDoxyHtmlTagNoParam(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTagNoParam(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /** Translates tag text to: text ("url"). */ - void handleDoxyHtmlTag_A(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTag_A(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* * Handles HTML tags, which are translated to markdown-like syntax, for example * text --> _text_. Appends arg for start HTML tag and end HTML tag. */ - void handleDoxyHtmlTag2(DoxygenEntity& tag, - std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTag2(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* Handles HTML table, tag */ - void handleDoxyHtmlTag_tr(DoxygenEntity& tag, std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTag_tr(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* Handles HTML table, tag
      */ - void handleDoxyHtmlTag_th(DoxygenEntity& tag, std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTag_th(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* Handles HTML table, tag */ - void handleDoxyHtmlTag_td(DoxygenEntity& tag, std::string& translatedComment, - const std::string &arg); + void handleDoxyHtmlTag_td(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg); /* Handles HTML entities recognized by Doxygen, like <, ©, ... */ - void handleHtmlEntity(DoxygenEntity&, std::string& translatedComment, const std::string &arg); + void handleHtmlEntity(DoxygenEntity &, std::string &translatedComment, const std::string &arg); /* @@ -184,7 +182,7 @@ private: // this contains the handler pointer and one string argument - typedef std::map > TagHandlersMap; + typedef std::map >TagHandlersMap; static TagHandlersMap tagHandlers; // this contains the sections tittles, like 'Arguments:' or 'Notes:', that are printed only once @@ -192,7 +190,7 @@ private: // Helper functions for fillStaticTables(): make a new tag handler object. TagHandlersMap::mapped_type make_handler(tagHandler handler); - TagHandlersMap::mapped_type make_handler(tagHandler handler, const char* arg); + TagHandlersMap::mapped_type make_handler(tagHandler handler, const char *arg); void fillStaticTables(); }; From ef8d68c0ab4a5699c6d3166d24b922d2df65d71f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 May 2018 20:07:26 +0100 Subject: [PATCH 0954/2031] Remove doxygen Examples subdirectory Doesn't seem to be used or useful now. --- .../src/Examples/DoxygenTransWTokenizer.cpp | 1013 ----------------- .../src/Examples/DoxygenTransWTokenizer.h | 21 - .../DoxygenTranslator/src/Examples/Example1 | 6 - .../DoxygenTranslator/src/Examples/Example2 | 7 - .../DoxygenTranslator/src/Examples/Example3 | 10 - .../DoxygenTranslator/src/Examples/Example4 | 5 - .../DoxygenTranslator/src/Examples/Example5 | 0 .../DoxygenTranslator/src/Examples/Example6 | 0 .../src/Examples/translator.h | 155 --- 9 files changed, 1217 deletions(-) delete mode 100644 Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp delete mode 100644 Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h delete mode 100644 Source/DoxygenTranslator/src/Examples/Example1 delete mode 100644 Source/DoxygenTranslator/src/Examples/Example2 delete mode 100644 Source/DoxygenTranslator/src/Examples/Example3 delete mode 100644 Source/DoxygenTranslator/src/Examples/Example4 delete mode 100644 Source/DoxygenTranslator/src/Examples/Example5 delete mode 100644 Source/DoxygenTranslator/src/Examples/Example6 delete mode 100644 Source/DoxygenTranslator/src/Examples/translator.h diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp deleted file mode 100644 index dd803b75f..000000000 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp +++ /dev/null @@ -1,1013 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * DoxygenTransWTokenizer.cpp - * - * The main class for translating blobs of Doxygen for SWIG - * ----------------------------------------------------------------------------- */ - -//TODO DOH instead of STL? -//TODO Most commands are not fully implemented - -#include -#include -#include -#include -#include -#include "DoxygenEntity.h" -#include "TokenList.h" -#define SIMPLECOMMAND 1 -#define IGNOREDSIMPLECOMMAND 2 -#define COMMANDWORD 3 -#define IGNOREDCOMMANDWORD 4 -#define COMMANDLINE 5 -#define IGNOREDCOMMANDLINE 6 -#define COMMANDPARAGRAPH 7 -#define IGNORECOMMANDPARAGRAPH 8 -#define COMMANDENDCOMMAND 9 -#define COMMANDWORDPARAGRAPH 10 -#define COMMANDWORDLINE 11 -#define COMMANDWORDOWORDWORD 12 -#define COMMANDOWORD 13 -#define COMMANDERRORTHROW 14 -#define COMMANDUNIQUE 15 -using namespace std; - - -////////////////////////////////////////// -/*Set these to pick what internal functions -to test. */ - -//int testCommandParsingFunctions = 1;// not implemented - -int testCodeCrawlingFunctions = 0; -int demonstrateParsing = 0; -int runExamples = 0; -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(string commandName, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString); -////////////////////////////////////////// - - - -/* Globals*/ - - -// An array of all the commands and my generic description tag, plaindescription - -string commandArray[] = { "a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "//", "&", "~", "<", ">", "#", "%" -}; - - -string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" -}; - -/* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = { "n", "$", "@", "//", "&", "~", "<", ">", "#", "%" }; -string ignoredSimpleCommands[] = { "nothing at the moment" }; - -string commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno" -}; -string ignoredCommandWords[] = { "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" }; -string commandLines[] = { "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" }; -string ignoreCommandLines[] = { "nothing at the moment" }; - -string commandParagraph[] = { "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" -}; -string ignoreCommandParagraphs[] = { "nothing at the moment" }; - -string commandEndCommands[] = { "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link" -}; -string commandWordParagraphs[] = { "param", "tparam", "throw", "retval", "exception" }; -string commandWordLines[] = { "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" }; -string commandWordOWordOWords[] = { "category", "class", "protocol", "interface", "struct", "union" }; -string commandOWords[] = { "dir", "file", "cond" }; - -string commandErrorThrowings[] = { "annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif" -}; - -string commandUniques[] = { "xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li" -}; - - //int startIndex = 0; -int isNewLine = 0; -int briefDescExists = 0; - - /* Entity list is the root list. - * it is arranged this way to help documentation modules, - * such as the javaDoc one, "sort" entities where they need to. - */ - -list < DoxygenEntity > rootList; - -/* General (untested) assist methods */ - -string StringToLower(string stringToConvert) -{ - //change each element of the string to lower case - - for (unsigned int i = 0; i < stringToConvert.length(); i++) { - stringToConvert[i] = tolower(stringToConvert[i]); - } - return stringToConvert; //return the converted string -} - -int findCommand(string smallString) { - - smallString = StringToLower(smallString); - int a; - for (int i = 0; i < sizeof(commandArray) / sizeof(*commandArray); i++) { - if ((a = smallString.compare(commandArray[i])) == 0) { - return 101 + i; - } - - - } - return -1; -} - -int commandBelongs(string theCommand) { - string smallString = StringToLower(theCommand); - //cout << " Looking for command " << theCommand << endl; - int i = 0; - for (i = 0; i < sizeof(simpleCommands) / sizeof(*simpleCommands); i++) { - if (smallString.compare(simpleCommands[i]) == 0) { - return SIMPLECOMMAND; - } - } - for (i = 0; i < sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); i++) { - if (smallString.compare(ignoredSimpleCommands[i]) == 0) { - return IGNOREDSIMPLECOMMAND; - } - } - for (i = 0; i < sizeof(commandWords) / sizeof(*commandWords); i++) { - if (smallString.compare(commandWords[i]) == 0) { - return COMMANDWORD; - } - } - for (i = 0; i < sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); i++) { - if (smallString.compare(ignoredCommandWords[i]) == 0) { - return IGNOREDCOMMANDWORD; - } - } - for (i = 0; i < sizeof(commandLines) / sizeof(*commandLines); i++) { - if (smallString.compare(commandLines[i]) == 0) { - return COMMANDLINE; - } - } - for (i = 0; i < sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); i++) { - if (smallString.compare(ignoreCommandLines[i]) == 0) { - return IGNOREDCOMMANDLINE; - } - } - for (i = 0; i < sizeof(commandParagraph) / sizeof(*commandParagraph); i++) { - if (smallString.compare(commandParagraph[i]) == 0) { - return COMMANDPARAGRAPH; - } - } - /* IgnoreCommandParagraph */ - for (i = 0; i < sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); i++) { - if (smallString.compare(ignoreCommandParagraphs[i]) == 0) { - return IGNORECOMMANDPARAGRAPH; - } - } - for (i = 0; i < sizeof(commandEndCommands) / sizeof(*commandEndCommands); i++) { - if (smallString.compare(commandEndCommands[i]) == 0) { - return COMMANDENDCOMMAND; - } - } - for (i = 0; i < sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); i++) { - if (smallString.compare(commandWordParagraphs[i]) == 0) { - return COMMANDWORDPARAGRAPH; - } - } - for (i = 0; i < sizeof(commandWordLines) / sizeof(*commandWordLines); i++) { - if (smallString.compare(commandWordLines[i]) == 0) { - return COMMANDWORDLINE; - } - } - for (i = 0; i < sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); i++) { - if (smallString.compare(commandWordOWordOWords[i]) == 0) { - return COMMANDWORDOWORDWORD; - } - } - for (i = 0; i < sizeof(commandOWords) / sizeof(*commandOWords); i++) { - if (smallString.compare(commandOWords[i]) == 0) { - return COMMANDOWORD; - } - } - for (i = 0; i < sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); i++) { - if (smallString.compare(commandErrorThrowings[i]) == 0) { - return COMMANDERRORTHROW; - } - } - for (i = 0; i < sizeof(commandUniques) / sizeof(*commandUniques); i++) { - if (smallString.compare(commandUniques[i]) == 0) { - return COMMANDUNIQUE; - } - } - - return 0; - -} - - /* isSectionIndicator returns a boolean if the command is a section indicator - * This is a helper method for finding the end of a paragraph - * by Doxygen's terms - */ -int isSectionIndicator(string smallString) { - smallString = StringToLower(smallString); - - for (int i = 0; i < sizeof(sectionIndicators) / sizeof(*sectionIndicators); i++) { - if (smallString.compare(sectionIndicators[i]) == 0) { - return 1; - } - } - return 0; -} - - - /* HELPER METHODS - * To test these, change the flags at the top of this class - */ - - /* Tiny method to compartmentalise the removal of all optional comment fluff such as /// - * or **** that often occurs before commment blobs. - */ -int clearFluff(int &startInd, string doxygenString) { - int startIndex = startInd; - int amountRemoved = 0; - - while (doxygenString[startIndex] == '/' || doxygenString[startIndex] == '!' || doxygenString[startIndex] == '*' - || doxygenString[startIndex] == '\n' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t') { - startIndex++; - amountRemoved++; - } - startInd = startIndex; - return startIndex; -} - - /* Returns the next word ON THE CURRENT LINE ONLY - * if a new line is encountered, returns a blank string. - * Updates the index it is given after completion. - */ - -string getNextWord(int &startInd, string doxygenString) { - int startIndex = startInd; - string nextWord; - while (startIndex < doxygenString.length() && (doxygenString[startIndex] == '/' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\n' || doxygenString[startIndex] == '\t' - || doxygenString[startIndex] == '!')) { - if (doxygenString[startIndex] == '\n') { - startInd = startIndex; - return nextWord; - } - startIndex++; - //cout << "Start Index" << startIndex << endl; - } - //cout << doxygenString[startIndex] << endl; - int endIndex = startIndex; - - while (endIndex < doxygenString.length() && (doxygenString[endIndex] != '\n' && doxygenString[endIndex] != ' ')) { - endIndex++; - //cout << "End Index " << endIndex << endl; - } - nextWord = doxygenString.substr(startIndex, endIndex - startIndex); - startInd = endIndex; - //cout << "Next Word :" << nextWord << ":" << endl; - return nextWord; -} - - /* Returns the string remaining on a line - * and moved the index to the NEXT line - * returns "" if nothing on the current line. - */ -string getOneLine(int &startInd, string doxygenString) { - int startIndex = startInd; - while (doxygenString[startIndex] == '/' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\n' || doxygenString[startIndex] == '!' || doxygenString[startIndex] == '\t') { - if (doxygenString[startIndex] == '\n') - return ""; - startIndex++; - } - - int endIndex = startIndex; - while ((endIndex != doxygenString.length()) && (doxygenString[endIndex] != '\n')) { - endIndex++; - //cout << doxygenString[endIndex] << "End Index: " << endIndex << endl; - } - string returnedLine = doxygenString.substr(startIndex, endIndex - startIndex); - if (doxygenString[endIndex] == '\n' && (endIndex < doxygenString.length())) - endIndex++; - startInd = endIndex; - return returnedLine; -} - -/* Returns a properly formatted (all doxygen *, //! etc removed) - * up til ANY command or end of paragraph is encountered. Has all the same issues as - * getStringTilEndOfParagraph formatting wise. - */ -string getStringTilCommand(int &startInd, string doxygenString) { - if (startInd >= doxygenString.length()) - return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while (keepLooping) { - if (endIndex >= doxygenString.length()) { - finalIndex = endIndex; - keepLooping = 0; - } else if (doxygenString[endIndex] == '\n') { - //cout << "1 "; - counter = endIndex; - if (keepLooping && endIndex < doxygenString.length() - 1) { - counter++; - //cout << "Counter :" << counter << endl; - while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*' || doxygenString[counter] == '\n' - || doxygenString[counter] == '/' || doxygenString[counter] == '!' - || doxygenString[startIndex] == '\t')) { - if (doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter; - } else { - counter++; - } - } - - } - //endIndex = counter; - } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { - finalIndex = endIndex; - keepLooping = 0; - } else if (endIndex < doxygenString.length() - 2 && string("**/").compare(doxygenString.substr(endIndex, endIndex + 2)) == 0) { - finalIndex = endIndex; - //cout << "3 "; - keepLooping = 0; - } - if (keepLooping) { - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') - startIndex++; - - for (int i = startIndex; i < endIndex; i++) { - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' - || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - //if(noisy) cout << "Final Index is: " << finalIndex << endl; - startInd = finalIndex; - return description; -} - - -/* Returns a Paragraph- defined in Doxygen to be a paragraph of text - * seperate by either a structural command or a blank line - * This method is VERY messy currently - */ - //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters -string getStringTilEndOfParagraph(int &startInd, string doxygenString) { - if (startInd >= doxygenString.length()) - return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while (keepLooping) { - if (endIndex >= doxygenString.length()) { - finalIndex = endIndex; - keepLooping = 0; - } else if (doxygenString[endIndex] == '\n') { - //cout << "1 "; - counter = endIndex; - if (keepLooping && endIndex < doxygenString.length() - 1) { - counter++; - //cout << "Counter :" << counter << endl; - while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*' || doxygenString[startIndex] == '\t' - || doxygenString[counter] == '\n' || doxygenString[counter] == '/' - || doxygenString[counter] == '!')) { - if (doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter; - } else { - counter++; - } - } - - } - //endIndex = counter; - } - //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap - else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { - spareIndex = endIndex + 1; - - if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { - keepLooping = 0; - finalIndex = endIndex; - } - } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { - keepLooping = 0; - finalIndex = endIndex; - } - if (keepLooping) { - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') - startIndex++; - - for (int i = startIndex; i < endIndex; i++) { - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' || doxygenString[startIndex] == '!' - || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; -} - - /* This method is for a specific form of doxygen command - * that begins with a \command and ends in \endcommand - * such as \code and \endcode. The proper usage is - * progressTilEndCommand("endcode", index) - * currently this method does NOT process what is in between the two commands - */ - //TODO Make progressTilCommand return a formatted string -int progressTilEndCommand(string theCommand, int &startInd, string doxygenString) { - int endIndex = startInd; - while (endIndex < doxygenString.length()) { - if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { - //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; - if (theCommand.compare(doxygenString.substr(endIndex + 1, theCommand.length())) == 0) { - startInd = endIndex + theCommand.length() + 1; - return 1; - } - } - endIndex++; - } - //End command not found - return 0; -} - - /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered - */ - -string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString) { - if (startInd >= doxygenString.length()) - return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while (keepLooping) { - if (endIndex >= theCommand.length()) { - finalIndex = endIndex; - keepLooping = 0; - } else if (doxygenString[endIndex] == '\n') { - //cout << "1 "; - counter = endIndex; - if (keepLooping && endIndex < doxygenString.length() - 1) { - counter++; - //cout << "Counter :" << counter << endl; - while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*' || doxygenString[counter] == '\n' - || doxygenString[counter] == '/' || doxygenString[counter] == '!' - || doxygenString[startIndex] == '\t')) { - if (doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter; - } else { - counter++; - } - } - - } - //endIndex = counter; - } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { - //cout << "2 "; - spareIndex = endIndex; - if (endIndex + theCommand.length() < theCommand.length() - && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) - keepLooping = 0; - } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { - //cout << "3 "; - keepLooping = 0; - } - if (keepLooping) { - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') - startIndex++; - - for (int i = startIndex; i < endIndex; i++) { - - if (doxygenString[i] == '\n') { - - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; -} - - - /* prints the parse tree - * - */ -void printTree() { - - list < DoxygenEntity >::iterator p = rootList.begin(); - while (p != rootList.end()) { - (*p).printEntity(0); - p++; - } - -} - - - -list < DoxygenEntity > parse(int startInd, string doxygenString) { - string currWord; - int startIndex = startInd; - int savedIndex; - list < DoxygenEntity > aNewList; - int endIndex = doxygenString.length(); - int currCommand; - while (startIndex < endIndex) { - savedIndex = startIndex; - currWord = getNextWord(startIndex, doxygenString); - if (noisy) - cout << "Parsing for phrase starting in:" << currWord << endl; - if (currWord == "") { - if (startIndex < endIndex) - startIndex++; - } else if (currWord[0] == '\\' || currWord[0] == '@') { - currWord = currWord.substr(1, currWord.length() - 1); - currCommand = findCommand(currWord); - if (currCommand < 0) { - if (noisy) - cout << "BAD COMMAND: " << currWord << endl; - } - //cout << "Command: " << currWord << " " << currCommand << endl; - else - addCommand(currWord, startIndex, aNewList, doxygenString); - } else { - startIndex = savedIndex; - addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); - - } - } - - return aNewList; -} - - /* Method for Adding a Simple Command - * Format: @command - * Plain commands, such as newline etc, they contain no other data - * \n \\ \@ \& \$ \# \< \> \% - */ -int addSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - - if (noisy) - cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; -} - - /* NOT INCLUDED Simple Commands - * Format: @command - * Plain commands, such as newline etc, they contain no other data - */ -int ignoreSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - - if (noisy) - cout << "Not Adding " << theCommand << endl; - return 1; -} - - /* CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno" - */ -int addCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()) { - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } else - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; -} - - /* NOT INCLUDED CommandWord - * Format: @command - * Commands with a single WORD after then such as @b - * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" - */ -int ignoreCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Not Adding " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()) { - return 1; - } else - cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; -} - - /* CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" - */ -int addCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if (!line.empty()) { - int placement = 0; - list < DoxygenEntity > aNewList; - aNewList = parse(placement, line); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } else - cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; -} - - /* NOT INCLUDED CommandLine - * Format: @command (line) - * Commands with a single LINE after then such as @var - * - */ -int ignoreCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Not Adding " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if (!line.empty()) { - return 1; - } else - cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; -} - - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single paragraph after then such as @return - * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" - */ -int addCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if (!restOfParagraph.empty()) { - int placement = 0; - list < DoxygenEntity > aNewList; - aNewList = parse(placement, restOfParagraph); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } else - cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; -} - - /* CommandParagraph - * Format: @command {paragraph} - * Commands with a single LINE after then such as @var - * - */ -int ignoreCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Not Adding " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if (!restOfParagraph.empty()) { - return 1; - } else - cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; -} - - /* Command EndCommand - * Format: @command and ends at @endcommand - * Commands that take in a block of text such as @code - * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" - * Returns 1 if success, 0 if the endcommand is never encountered. - */ - -int ignoreCommandEndCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Not Adding " << theCommand << endl; - return progressTilEndCommand("end" + theCommand, startInd, doxygenString); - -} - - /* CommandWordParagraph - * Format: @command {paragraph} - * Commands such as param - * "param", "tparam", "throw", "retval", "exception" - */ -int addCommandWordParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if (!restOfParagraph.empty()) { - list < DoxygenEntity > aNewList; - aNewList = parse(placement, restOfParagraph); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } else - cout << "No paragraph followed " << theCommand << " command. Not added" << endl; - return 0; -} - - /* CommandWordLine - * Format: @command (line) - * Commands such as param - * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" - */ -int addCommandWordLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if (!restOfLine.empty()) { - list < DoxygenEntity > aNewList; - aNewList = parse(placement, restOfLine); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } else - cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; -} - - /* Command Word Optional Word Optional Word - * Format: @command [] [] - * Commands such as class - * "category", "class", "protocol", "interface", "struct", "union" - */ -int addCommandWordOWordOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()) { - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string headerfile = getNextWord(startInd, doxygenString); - string headername = getNextWord(startInd, doxygenString); - list < DoxygenEntity > aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) - aNewList.push_back(DoxygenEntity("plainstd::string", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; -} - - /* Command Optional Word - * Format: @command [] - * Commands such as dir - * "dir", "file", "cond" - */ -int addCommandOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - if (noisy) - cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; -} - - /* The actual "meat" of the doxygen parser. This is not yet fully implemented - * with my current design- however the skeletal outline is contained in - * the file Skeleton - */ - - -int addCommand(string commandString, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { - string theCommand = StringToLower(commandString); - string voidArray[] = { "" }; - /* @command */ - - - if (theCommand.compare("plainstd::string") == 0) { - string nextPhrase = getStringTilCommand(startInd, doxygenString); - if (noisy) - cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND) { - return addSimpleCommand(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == IGNOREDSIMPLECOMMAND) { - return ignoreSimpleCommand(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDWORD) { - return addCommandWord(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDWORD) { - return ignoreCommandWord(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDLINE) { - return addCommandLine(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDLINE) { - return ignoreCommandLine(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDPARAGRAPH) { - return addCommandParagraph(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH) { - return ignoreCommandParagraph(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDENDCOMMAND) { - return ignoreCommandEndCommand(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDPARAGRAPH) { - return addCommandWordParagraph(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDLINE) { - return addCommandWordLine(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDOWORDWORD) { - return addCommandWordOWordOWord(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDOWORD) { - return addCommandOWord(theCommand, startInd, doxyList, doxygenString); - } - if (commandNumber == COMMANDERRORTHROW) { - return 0; - } - if (commandNumber == COMMANDUNIQUE) { - return 0; - } - - return 0; -} - -int weirdTest() { - string doxygenString = "this is a test."; - string restOfParagraph; - int startIndex = 0; - restOfParagraph = getStringTilEndOfParagraph(startIndex, doxygenString); - cout << restOfParagraph << " " << startIndex << endl; - - startIndex = 0; - restOfParagraph = getStringTilCommand(startIndex, doxygenString); - cout << restOfParagraph << " " << startIndex << endl; -} - - - -int doRunExamples() { - string line; - string filename; - string exampleNames[] = { "Examples/Example1", "Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5" }; - int placement; - string doxygenString; - ifstream doxCommentFile; - for (int i = 0; i < 5; i++) { - doxCommentFile.open(exampleNames[i].c_str()); - doxCommentFile >> doxygenString; - while (getline(doxCommentFile, line)) { - doxygenString += line + "\n"; - } - doxCommentFile.close(); - placement = 0; - cout << "---RAW CODE---" << endl << doxygenString << endl << endl; - //clearFluff(placement, doxygenString); - //rootList = parse(placement, doxygenString); - TokenList tokList = TokenList(doxygenString); - tokList.printList(); - cout << "---THE TREE---" << endl; - printTree(); - } - return 1; -} - - - /* Returns a parse tree for a string */ -int main(int argc, char *argv[]) { - //weirdTest(); - if (testCodeCrawlingFunctions) - testCCF(); - if (runExamples) - doRunExamples(); - if (demonstrateParsing) { - string doxygenString = - "//! A normal member taking two arguments and returning an integer value.\n/*!\n \\param a an integer argument. \\param s a constant character pointer\n \\return The test results\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; - //string doxygenString = " /** This is a small sentence.\n *\n@param x this is a parameter. \n \n This is a line with a @b bold letter \n * \n @brief small @b description. \n\n * **/"; - //string doxygenString = "This is a description."; - int placement = 0; - clearFluff(placement, doxygenString); - rootList = parse(placement, doxygenString); - cout << "---THE TREE---" << endl; - printTree(); - } - string doxygenString2 = - "//! A normal member taking two arguments and returning an integer value.\n/*!\n \\param a an integer argument. \\param s a constant character pointer\n\n\n\n \\return The test results\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */"; - TokenList tokList = TokenList(doxygenString2); - tokList.printList(); - return 1; -} diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h deleted file mode 100644 index 8a51b4d02..000000000 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * DoxygenTransWTokenizer.h - * ----------------------------------------------------------------------------- */ - -#ifndef DOXYGENTRANSWTOKENIZER_H_ -#define DOXYGENTRANSWTOKENIZER_H_ - -class DoxygenTransWTokenizer { -public: - DoxygenTransWTokenizer(); - virtual ~DoxygenTransWTokenizer(); -}; - -#endif diff --git a/Source/DoxygenTranslator/src/Examples/Example1 b/Source/DoxygenTranslator/src/Examples/Example1 deleted file mode 100644 index 03aac4921..000000000 --- a/Source/DoxygenTranslator/src/Examples/Example1 +++ /dev/null @@ -1,6 +0,0 @@ -/*! \brief Brief description. - * Brief description continued. - * - * Detailed description starts here. - */ - diff --git a/Source/DoxygenTranslator/src/Examples/Example2 b/Source/DoxygenTranslator/src/Examples/Example2 deleted file mode 100644 index 27f915e4a..000000000 --- a/Source/DoxygenTranslator/src/Examples/Example2 +++ /dev/null @@ -1,7 +0,0 @@ -//! A normal member taking two arguments and returning an integer value. -/*! - \param a an integer argument. - \param s a constant character pointer. - \return The test results - \sa Test(), ~Test(), testMeToo() and publicVar() - */ diff --git a/Source/DoxygenTranslator/src/Examples/Example3 b/Source/DoxygenTranslator/src/Examples/Example3 deleted file mode 100644 index 8e24ba005..000000000 --- a/Source/DoxygenTranslator/src/Examples/Example3 +++ /dev/null @@ -1,10 +0,0 @@ - /** - * a normal member taking two arguments and returning an integer value. - * @param a an integer argument. - * @param s a constant character pointer. - * @see Test() - * @see ~Test() - * @see testMeToo() - * @see publicVar() - * @return The test results - */ diff --git a/Source/DoxygenTranslator/src/Examples/Example4 b/Source/DoxygenTranslator/src/Examples/Example4 deleted file mode 100644 index 55b68da18..000000000 --- a/Source/DoxygenTranslator/src/Examples/Example4 +++ /dev/null @@ -1,5 +0,0 @@ -//! Brief descripion. - -//! Detailed description -//! starts here. - diff --git a/Source/DoxygenTranslator/src/Examples/Example5 b/Source/DoxygenTranslator/src/Examples/Example5 deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/DoxygenTranslator/src/Examples/Example6 b/Source/DoxygenTranslator/src/Examples/Example6 deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/DoxygenTranslator/src/Examples/translator.h b/Source/DoxygenTranslator/src/Examples/translator.h deleted file mode 100644 index f9da98180..000000000 --- a/Source/DoxygenTranslator/src/Examples/translator.h +++ /dev/null @@ -1,155 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * translator.h - * ----------------------------------------------------------------------------- */ - -#ifndef TRANSLATOR_H_ -#define TRANSLATOR_H_ - -#define BRIEFDESCRIPTION 99 -#define LONGDESCRIPTION 100 -#define A_COMMAND 101 /* \a */ -#define ADDINDEX 102 /* \addindex */ -#define ADDTOGROUP 103 /* \addtogroup */ -#define ANCHOR 104 /* \anchor */ -#define ARG_COMMAND 105 /* \arg */ -#define ATTENTION 106 /* \attention */ -#define AUTHOR 107 /* \author */ -#define B_COMMAND 108 /* \b */ -#define BRIEF 109 /* \brief */ -#define BUG 110 /* \bug */ -#define C_COMMAND 111 /* \c */ -#define CALLGRAPH 112 /* \callgraph */ -#define CALLERGRAPH 113 /* \callergraph */ -#define CATEGORY 114 /* \category */ -#define CLASS_COMMAND 115 /* \class */ -#define CODE 116 /* \code */ -#define COND 117 /* \cond */ -#define COPYBRIEF 118 /* \copybrief */ -#define COPYDETAILS 119 /* \copydetails */ -#define COPYDOC 120 /* \copydoc */ -#define DATE 121 /* \date */ -#define DEF 122 /* \def */ -#define DEFGROUP 123 /* \defgroup */ -#define DEPRECATED 124 /* \deprecated */ -#define DETAILS 125 /* \details */ -#define DIR_COMMAND 126 /* \dir */ -#define DONTINCLUDE 127 /* \dontinclude */ -#define DOT 128 /* \dot */ -#define DOTFILE 129 /* \dotfile */ -#define E_COMMAND 130 /* \e */ -#define ELSE_COMMAND 131 /* \else */ -#define ELSEIF_COMMAND 132 /* \elseif */ -#define EM 133 /* \em */ -#define ENDCODE 134 /* \endcode */ -#define ENDCOND 135 /* \endcond */ -#define ENDDOT 136 /* \enddot */ -#define ENDHTMLONLY 137 /* \endhtmlonly */ -#define ENDIF 138 /* \endif */ -#define ENDLATEXONLY 139 /* \endlatexonly */ -#define ENDLINK 140 /* \endlink */ -#define ENDMANONLY 141 /* \endmanonly */ -#define ENDMSC 142 /* \endmsc */ -#define ENDVERBATIM 143 /* \endverbatim */ -#define ENDXMLONLY 144 /* \endxmlonly */ -#define ENUM 145 /* \enum */ -#define EXAMPLE 146 /* \example */ -#define EXCEPTION 147 /* \exception */ -#define FDOLLAR 148 /* \f$ */ -#define FLEFTSQUAREBRACKET 149 /* \f[ */ -#define FRIGHTSQUAREBRACKET 150 /* \f] */ -#define FLEFTBRACKET 151 /* \f{ */ -#define FRIGHTBRACKET 152 /* \f} */ -#define FILE_COMMAND 153 /* \file */ -#define FN_COMMAND 154 /* \fn */ -#define HEADERFILE 155 /* \headerfile */ -#define HIDEINITIALIZER 156 /* \hideinitializer */ -#define HTMLINCLUDE 157 /* \htmlinclude */ -#define HTMLONLY 158 /* \htmlonly */ -#define IF_COMMAND 159 /* \if */ -#define IFNOT_COMMAND 160 /* \ifnot */ -#define IMAGE 161 /* \image */ -#define INCLUDE_COMMAND 162 /* \include */ -#define INCLUDELINENO 163 /* \includelineno */ -#define INGROUP 164 /* \ingroup */ -#define INTERNAL 165 /* \internal */ -#define INVARIANT 166 /* \invariant */ -#define INTERFACE_COMMAND 167 /* \interface */ -#define LATEXONLY 168 /* \latexonly */ -#define LI 169 /* \li */ -#define LINE 170 /* \line */ -#define LINK 171 /* \link */ -#define MAINPAGE 172 /* \mainpage */ -#define MANONLY 173 /* \manonly */ -#define MSC 174 /* \msc */ -#define N 175 /* \n */ -#define NAME 176 /* \name */ -#define NAMESPACE 177 /* \namespace */ -#define NOSUBGROUPING 178 /* \nosubgrouping */ -#define NOTE 179 /* \note */ -#define OVERLOAD 180 /* \overload */ -#define P 181 /* \p */ -#define PACKAGE 182 /* \package */ -#define PAGE 183 /* \page */ -#define PAR 184 /* \par */ -#define PARAGRAPH 185 /* \paragraph */ -#define PARAM 186 /* \param */ -#define POST 187 /* \post */ -#define PRE 188 /* \pre */ -#define PRIVATE 189 /* \private (PHP only) */ -#define PRIVATESECTION 190 /* \privatesection (PHP only) */ -#define PROPERTY 191 /* \property */ -#define PROTECTED 192 /* \protected (PHP only) */ -#define PROTECTEDSECTION 193 /* \protectedsection (PHP only) */ -#define PROTOCOL 194 /* \protocol */ -#define PUBLIC 195 /* \public (PHP only) */ -#define PUBLICSECTION 196 /* \publicsection (PHP only) */ -#define REF 197 /* \ref */ -#define RELATES 198 /* \relates */ -#define RELATESALSO 199 /* \relatesalso */ -#define REMARKS 200 /* \remarks */ -#define RETURN_COMMAND 201 /* \return */ -#define RETVAL 202 /* \retval */ -#define SA 203 /* \sa */ -#define SECTION 204 /* \section */ -#define SEE 205 /* \see */ -#define SHOWINITIALIZER 206 /* \showinitializer */ -#define SINCE 207 /* \since */ -#define SKIP 208 /* \skip */ -#define SKIPLINE 209 /* \skipline */ -#define STRUCT 210 /* \struct */ -#define SUBPAGE 211 /* \subpage */ -#define SUBSECTION 212 /* \subsection */ -#define SUBSUBSECTION 213 /* \subsubsection */ -#define TEST 214 /* \test */ -#define THROW_COMMAND 215 /* \throw */ -#define TODO_COMMAND 216 /* \todo */ -#define TPARAM_COMMAND 217 /* \tparam */ -#define TYPEDEF_COMMAND 218 /* \typedef */ -#define UNION_COMMAND 219 /* \union */ -#define UNTIL_COMMAND 220 /* \until */ -#define VAR_COMMAND 221 /* \var */ -#define VERBATIM 222 /* \verbatim */ -#define VERBININCLUDE 223 /* \verbinclude */ -#define VERSION 224 /* \version */ -#define WARNING 225 /* \warning */ -#define WEAKGROUP 226 /* \weakgroup */ -#define XMLONLY 227 /* \xmlonly */ -#define XREFITEM 228 /* \xrefitem */ -#define DOLLAR_COMMAND 229 /* \$ */ -#define AT_COMMAND 230 /* \@ */ -#define SLASH_COMMAND 231 /* \\ */ -#define AND_COMMAND 232 /* \& */ -#define TILDE_COMMAND 233 /* \~ */ -#define LEFTANGLEBRACKET 234 /* \< */ -#define RIGHTANGLEBRACKET 235 /* \> */ -#define POUND_COMMAND 236 /* \# */ -#define PERCENT_COMMAND 237 /* \% */ - -#endif From 73736c3b89c9d1147d59bffde8dfd260289ab3e4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 May 2018 19:31:31 +0100 Subject: [PATCH 0955/2031] Doxygen html documentation updates and corrections --- Doc/Manual/Doxygen.html | 300 +++++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 139 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 5fa4b820e..886391972 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -32,7 +32,7 @@
    • Developer Information @@ -50,28 +50,20 @@ documentation language. Currently only Javadoc and Pydoc is supported.

      -

      39.1 Doxygen Translation Overview

      +

      39.1 Doxygen translation overview

      -The Doxygen Translation Module of SWIG is an ongoing effort from -a Google Summer of -Code proposal from Summer 2008. It adds an extra layer of -functionality to SWIG, allowing automated translation of Doxygen formatted comments +The Doxygen Translation module of SWIG adds an extra layer of +functionality to SWIG, allowing automated translation of Doxygen formatted comments from input files into a documentation language more suited for the target language. Currently this module only translates into Javadoc -and Pydoc for the SWIG Java and Python Modules, but other -extensions are to be added in time. -

      - -

      -Questions about running SWIG are best answered in -the SWIG Basics chapter as well as the -target language modules. (For now, only Java -and Python). The behaviour of this -functionality is wildly unpredictable if the interface file is not -proper to begin with! +and Pydoc for the SWIG Java and Python modules. +Other extensions could be added at a later date. +The Doxygen Translation module originally started as +a Google Summer of +Code proposal from Summer 2008.

      39.2 Preparations

      @@ -79,32 +71,24 @@ proper to begin with!

      To make use of the comment translation system, your documentation -comments must be in properly formatted Doxygen. They can be -present in your main interface file or any header file that it -imports. It is advised that you are certain your comments compile +comments must be in properly formatted Doxygen. Doxygen comments can be +present in your main SWIG interface file or any header file that it +imports. You are advised to be validate that your comments compile properly with Doxygen before you try to translate them. Doxygen -itself is a deeper tool and can provide you better feedback for +itself is a more comprehensive tool and can provide you better feedback for correcting any syntax errors that may be present. Please look at -Doxygen's Documenting the -code for proper specifications for comment format. However, SWIG's -Doxygen parser will still point you most of errors and warnings found +code for the full comment format specifications. However, SWIG's +Doxygen parser will still report many errors and warnings found in comments (like unterminated strings or missing ending tags).

      -
      -/*! This is describing class Shape
      - \author Bob
      - */
      -
      -class Shape {
      -
      -

      Currently, the whole subset of Doxygen comment styles is supported -(See -Documenting the code). Here they are: +(See +Documenting the code). Here they are:

       /**
      @@ -124,20 +108,20 @@ Documenting the code). Here they are:
       

      Also any of the above with '<' added after comment-starting symbol, like /**<, /*!<, ///<, or //!< will be -treated as post-comment and will be assigned to the node before the +treated as a post-comment and will be assigned to the code before the comment. -
      -Any number of '*' or '/' in Doxygen comment is considered to be a -separator and is not included in final comment, so you may safely use +Any number of '*' or '/' within a Doxygen comment is considered to be a +separator and is not included in the final comment, so you may safely use comments like /*********/ or //////////.

      -Please note, as SWIG parses input file by itself with strict grammar, +Please note, as SWIG parses the input file by itself with strict grammar, there is only a limited support for various cases of comment placement in the file. -
      +

      +

      Comments can be placed before C/C++ expressions on separate lines:

      @@ -192,15 +176,13 @@ enum E_NUMBERS

      -Just remember, if SWIG shows syntax error parsing the file because of -your comment, try to move it in some other, 'safer' place as described -above. -
      -Also, currently only the comments directly before or after the nodes -are supported. Doxygen structural comments are stripped out and not -assigned to anything. +Currently only comments directly before or after the code items +are supported. Doxygen also supports comments containing structural commands, +where the comments for a code item are not put directly before or after the code item. +These structural commands are stripped out by SWIG and are not assigned to anything.

      -

      39.2.1 Enabling Doxygen Translation

      + +

      39.2.1 Enabling Doxygen translation

      Doxygen comments translation is disabled by default and needs to be explicitly @@ -208,7 +190,7 @@ enabled using the command line -doxygen switch for the languages that do support it (currently Java and Python).

      -

      39.2.2 Doxygen-specific %feature Directives

      +

      39.2.2 Doxygen-specific %feature directives

      Translation of Doxygen comments is influenced by the following

      -Then you could also the same expansion for SWIG with: +Then you could also specify the same expansion for SWIG with:

      @@ -275,13 +257,19 @@ wrappers of the C++ API.
       

      doxygen:ignore:<command-name>

      -This feature allows to just ignore an unknown Doxygen command, instead of -replacing it with a predefined text as doxygen:alias features allows to -do. For example, you could use +This feature makes it possible to just ignore an unknown Doxygen command, instead of +replacing it with the predefined text that doxygen:alias does. +For example, you could use

      -%feature("doxygen:ignore:transferfull");
      +%feature("doxygen:ignore:transferfull") Fantastic();
      +/**
      +    A fantastic function.
      +
      +    @transferfull Command ignored, but anything here is still included.
      + */
      +int * Fantastic() { }
       

      @@ -303,11 +291,19 @@ feature directive:

       // Ignore occurrences of
       //
      -//    @compiler-options Some special C++ compiler options.
      +//    @compileroptions Some special C++ compiler options.
       //
      -// in Doxygen comments as C++ options are not interested for the target language
      +// in Doxygen comments as C++ options are not interesting for the target language
       // developers.
      -%feature("doxygen:ignore:compileroptions", range="line");
      +%feature("doxygen:ignore:compileroptions", range="line") Amazing();
      +
      +/**
      +    An amazing function.
      +
      +    @compileroptions This function must be compiled with /EHa when using MSVC.
      + */
      +void Amazing();
      +
       

      @@ -319,6 +315,14 @@ tags can also be ignored using the special value of range starting with

       %feature("doxygen:ignore:forcpponly", range="end"); // same as "end:endforcpponly"
      +/**
      +    An incredible function.
      +
      +    @forcpponly
      +    This is C++-specific.
      +    @endforcpponly
      + */
      +void Incredible();
       

      @@ -338,6 +342,15 @@ themselves should be ignored, but their contents should be parsed as usual and

       %feature("doxygen:ignore:beginPythonOnly", range="end:endPythonOnly", contents="parse");
      +/**
      +    A splendid function.
      +
      +    @beginPythonOnly
      +    This is specific to @b Python.
      +    @endPythonOnly
      + */
      +void Splendid();
      +
       

      @@ -371,7 +384,7 @@ then the following C++ Doxygen comment: @compileroptions This function must be compiled with /EHa when using MSVC. */ -void func(); +int * Contrived();

      @@ -391,7 +404,7 @@ def func(): -

      doxygen:nolinkranslate (Java-only currently)

      +

      doxygen:nolinktranslate (Java-only currently)

      Turn off automatic link-objects translation. @@ -406,14 +419,14 @@ Doxygen commands if the parameter is not found in the function signature.

      -

      39.2.3 Additional Command Line Options

      +

      39.2.3 Additional command line options

      ALSO TO BE ADDED (Javadoc auto brief?)

      -

      39.3 Doxygen To Javadoc

      +

      39.3 Doxygen to Javadoc

      @@ -422,7 +435,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

      -

      39.3.1 Basic Example

      +

      39.3.1 Basic example

      @@ -505,42 +518,41 @@ public class Shape {

      The code Java-wise should be identical to what would have been -generated without this feature enabled. When the Doxygen Translator -Module encounters a comment it finds nothing useful in or cannot -parse, it should not effect the functionality of the SWIG generated +generated without the doxygen functionality enabled. When the Doxygen Translator +module encounters a comment that contains nothing useful or a doxygen comment that it cannot +parse, it will not affect the functionality of the SWIG generated code.

      -Javadoc translator will handle most of the tags conversions (see the +The Javadoc translator will handle most of the tags conversions (see the table below). It will also automatically translate link-objects params, in \see and \link...\endlink commands. For example, 'someFunction(std::string)' will be converted to -'someFunction(String)'. If this works not really good for you, or if -you don't want such behaviour, you could turn this off by using +'someFunction(String)'. If +you don't want such behaviour, you could turn this off by using the 'doxygen:nolinktranslate' feature. Also all '\param' and '\tparam' -commands are stripped out, if specified parameter is not present in -function. Use 'doxygen:nostripparams' to avoid. +commands are stripped out, if the specified parameter is not present in +the function. Use 'doxygen:nostripparams' to avoid.

      Javadoc translator features summary (see %feature directives): -
      -

      -

      39.3.2 Javadoc Tags

      +

      39.3.2 Javadoc tags

      Here is the list of all Doxygen tags and the description of how they are translated to Javadoc -
      -Doxygen tags:

       
      +
      +  
      +
      @@ -792,15 +804,17 @@ Here is the list of all Doxygen tags and the description of how they are transla
       Doxygen has a wealth of tags such as @latexonly that have no
       equivalent in Javadoc (all supported tags are listed in
       Javadoc documentation).
      -As a result several tags that have no
      -translation (or particular use, such as some linking and section tags)
      -are suppressed with their content just printed out (if it has any
      +As a result several tags have no
      +translation or particular use, such as some linking and section tags.
      +These are suppressed with their content just printed out (if the tag has any
       sense, typically text content).
      -
      Here is the list of these tags:

       
      Doxygen tags
      \a wrapped with <i> html tag
      + + + @@ -956,6 +970,9 @@ comment, the whole comment block is ignored:

       
      Unsupported Doxygen tags
      \addindex \addtogroup
      + + + @@ -1016,25 +1033,25 @@ comment, the whole comment block is ignored: -

      39.3.4 Further Details

      +

      39.3.4 Further details

      TO BE ADDED.

      -

      39.4 Doxygen To Pydoc

      +

      39.4 Doxygen to Pydoc

      If translation is enabled, Pydoc formatted comments should be automatically placed in the correct locations in the resulting module and proxy files. The problem is that Pydoc has no tag mechanism like -Doxygen or Javadoc, so most of Doxygen commands are translated as -English plain text pieces. +Doxygen or Javadoc, so most of Doxygen commands are translated by merely +copying the appropriate command text.

      -

      39.4.1 Basic Example

      +

      39.4.1 Basic example

      @@ -1114,9 +1131,13 @@ their description is copied into the generated output using */ bool SetBreakpoint(const char* filename, int line_number); + +

      would be translated to +

      +
      -def SetBreakpoint(*args):
      +def SetBreakpoint(filename, line_number):
           r"""
           Set a breakpoint at the given location.
       
      @@ -1127,7 +1148,7 @@ def SetBreakpoint(*args):
           """
       

      -The types used for the parameter documentation come from doctype typemap which +The types used for the parameter documentation come from the "doctype" typemap which is defined for all the primitive types and a few others (e.g. std::string and shared_ptr<T>) but for non-primitive types is taken to be just the C++ name of the type with namespace scope delimiters (::) replaced with a dot. To @@ -1138,12 +1159,12 @@ change this, you can define your own typemaps for the custom types, e.g:

      -Currently Doxygen comments assigned to vars are not present in proxy -file, so they have no comment translated for them. +Currently Doxygen comments assigned to global variables and static member variables +are not present in generated code, so they have no comment translated for them.

      - Whitespace and tables
      + Whitespace and tables Whitespace is preserved when translating comments, so it makes sense to have Doxygen comments formatted in a readable way. This includes tables, where tags <th>, <td> and </tr>are translated @@ -1176,13 +1197,14 @@ translates to Python as:

      - Overloaded functions
      + Overloaded functions Since all the overloaded functions in c++ are wrapped into one Python function, Pydoc translator will combine every comment of every -overloaded function and put it in the comment for wrapping function. -
      -If you intend to use resulting proxy files with Doxygen docs -generator, rather than Pydoc, you may want to turn off translator +overloaded function and put it into the comment for the one wrapper function. +

      +

      +If you intend to use resulting generated Python file with the Doxygen docs +generator, rather than Pydoc, you may want to turn off translation completely (doxygen:notranslate feature). Then SWIG will just copy the comments to the proxy file and reformat them if needed, but all the comment content will be left as is. As Doxygen doesn't support @@ -1198,11 +1220,12 @@ to do the work.

      Here is the list of all Doxygen tags and the description of how they are translated to Pydoc -
      -Doxygen tags:

       
      Ignored Doxygen tags
      \addtogroup \callgraph
      + + + @@ -1415,11 +1438,13 @@ equivalent in Pydoc. As a result several tags that have no translation (or particular use, such as some linking and section tags) are suppressed with their content just printed out (if it has any sense, typically text content). -
      Here is the list of these tags:

       
      Doxygen tags
      \a wrapped with '_'
      + + + @@ -1588,26 +1613,26 @@ Here is the list of these tags:
      Unsupported Doxygen tags
      \addindex \addtogroup
      -

      39.4.4 Further Details

      +

      39.4.4 Further details

      TO BE ADDED.

      -

      39.5 Developer Information

      +

      39.5 Developer information

      -

      39.5.1 Module Design

      +

      39.5.1 Doxygen translator design

      If this functionality is turned on, SWIG places all comments found into the SWIG parse tree. Nodes contain an additional attribute -called DoxygenComment when a comment is present. Individual nodes +called doxygen when a comment is present. Individual nodes containing Doxygen with Structural Indicators, such as @file, as their first command, are also present in the parse tree. These individual "blobs" of Doxygen such as : @@ -1621,13 +1646,13 @@ first command, are also present in the parse tree. These individual

      -are passed on individually to the DoxygenTranslator Module. This +are passed on individually to the Doxygen Translator module. This module builds its own private parse tree and hands it to a separate class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

      -

      39.5.2 Debugging Doxygen parser and translator

      +

      39.5.2 Debugging the Doxygen parser and translator

      @@ -1644,58 +1669,55 @@ detailed debug information printing.

      -This part of SWIG currently has 6 runtime tests in both Java and Python. +Doxygen tests have been added to the regular SWIG test-suite. +There are a number of tests beginning doxygen_ in the Examples/test-suite sub-directory. +

      + +

      +Like any other SWIG test case, the tests are included in Examples/test-suite/common.mk and can be tested with +commands like make check-test-suite or make check-python-test-suite. +To run them individually, type +make -s <testname>.cpptest in the language-specific sub-directory in +Examples/test-suite directory. For example:

      -  doxygen_parsing
      -  doxygen_translate
      -  doxygen_translate_all_tags
      -  doxygen_basic_translate
      -  doxygen_basic_notranslate
      -  doxygen_translate_links
      -  doxygen_misc_constructs
      +  Examples/test-suite/java $ make -s doxygen_parsing.cpptest
       

      -All this tests are included in common.mk and are built with the -commands like 'make check-test-suite' or 'make -check-python-test-suite'. To run them individually, type -make <testname>.cpptest -s in the language-specific subdir in -Examples/test-suite directory. For example: -

      -  Examples/test-suite/java $ make doxygen_misc_constructs.cpptest -s
      -
      - If the test fails, both expected and translated comments are printed to std out, but also written to files expected.txt -and got.txt. Since it is often difficult to find a single +and got.txt. Since it is often difficult to find a single character difference in several lines of text, we can use some diff tool, for example: -
      -  Examples/test-suite/java $ kdiff3 expected.txt got.txt
      -
      +

      +
      +  Examples/test-suite/java $ kdiff3 expected.txt got.txt
      +
      -
      +

      Runtime tests in Java are implemented using Javadoc doclets. To make that work, you should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME -environmental var defined and pointing to the JDK location. -
      +environment variable defined and pointing to the JDK location. +

      +

      The Java's comment parsing code (the testing part) is located in commentParser.java. -You may see it to understand how the checking process works. There is also a possibility -to run that file as stand-alone program, with 'java commentParser ', -and it will print the list of comments found in the specified directory (in the format it's used -in runtime tests). So, when you want to create the new test of Doxygen comment translator, -just copy any existing one, and replace the actual comment content (section of entries in +It checks the generated code. It is possible +to run this file as a stand-alone program, with java commentParser <some java package>, +and it will print the list of comments found in the specified directory (in the format it has used +in the runtime tests). So, when you want to create a new Doxygen test case, +just copy an existing one and replace the actual comment content (section of entries in form 'wantedComments.put(...)' with the output of the above command. -
      -Runtime tests in Python are just plain strings comparison with the use of __doc__ +

      +

      +Runtime tests in Python are just plain string comparisons of the __doc__ properties.

      -

      39.6 Extending to Other Languages

      +

      39.6 Extending to other languages

      @@ -1705,7 +1727,7 @@ The basic gist is that anywhere a comment may reside on a node, there needs to b The other half of extension is building a target documentation language comment generator that handles one blob at a time. However, this is relatively simple and nowhere near as complex as the wrapper generating modules in SWIG. See DoxygenTranslator/JavaDocConverter.cpp for a good example. -The target language module hands the DoxygenTranslator the blob to translate, and receives back a translated text. +The target language module passes the Doxygen Translator the blob to translate, and receives back the translated text.

      What is given to the Doxygen Translator @@ -1728,7 +1750,7 @@ The target language module hands the DoxygenTranslator the blob to translate, an * @return Foo */ -

      Development of the comment translator itself is simplified by the fact that the DoxygenTranslator module can easily include a main function and thus be developed, compiled, and tested independently of SWIG. +

      Development of the comment translator itself is simplified by the fact that the Doxygen Translator module can easily include a main function and thus be developed, compiled, and tested independently of SWIG.

      From 6bad5ca3a119291d0fd8179d4306f7027cf81bbb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 May 2018 19:32:47 +0100 Subject: [PATCH 0956/2031] Doxygen testcase tweak to match that in the html docs --- Examples/test-suite/doxygen_ignore.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/doxygen_ignore.i b/Examples/test-suite/doxygen_ignore.i index d15110257..ce83470b6 100644 --- a/Examples/test-suite/doxygen_ignore.i +++ b/Examples/test-suite/doxygen_ignore.i @@ -36,6 +36,6 @@ @compileroptions This function must be compiled with /EHa when using MSVC. */ -void func() { } +int * func() { } %} From caccb20491c3c7e437525c81e8b399be6427fac7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 May 2018 19:50:33 +0100 Subject: [PATCH 0957/2031] Format files to unix format --- Examples/test-suite/doxygen_misc_constructs.h | 188 ++++++------- Examples/test-suite/doxygen_misc_constructs.i | 248 +++++++++--------- 2 files changed, 218 insertions(+), 218 deletions(-) diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h index 98856ac9a..d677dc3d3 100644 --- a/Examples/test-suite/doxygen_misc_constructs.h +++ b/Examples/test-suite/doxygen_misc_constructs.h @@ -1,94 +1,94 @@ -/* - * This file contains comments which demonstrate details about Doxygen processing, - * so they can be emulated in SWIG doxy comment translation - */ - - - -/**This comment without space after '*' is valid in Doxygen. - * - */ -void isNoSpaceValidA() -{} - -/**.This comment without space after '*' is valid in Doxygen. - * - */ -void isNoSpaceValidB() -{} - - -/***This is not Doxygen comment. - * - */ -void isNoSpaceValidC() -{} - - -/** - * Backslash following\c word is a valid doxygen command. Output contains - * 'followingword' with 'word' in code font. - */ -void backslashA() -{} - -// Output of escaped symbols below in doxygen generated HTML: -// Rendered: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text -// HTML source: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text - - -/** - * Doxy command without trailing \cspace space is ignored - nothing appears - * on output. Standalone \ and '\' get to output. - * Standalone @ and '@' get to output. - * Commands "in quoted \b strings are treated as plain text". - * Commands not recognized by Doxygen \blah @blah are ignored. - * Backslashes in DOS paths d:\xyz\qwe\myfile and words - * following them do not appear on output, we must quote them with - * double quotes: "d:\xyz\qwe\myfile", "@something". Single quotes do not help: - * 'd:\xyz\qwe\myfile'. Escaping works: d:\\xyz\\qwe\\myfile. Unix - * paths of course have no such problems: /xyz/qwe/myfile - * Commands for escaped symbols: - * \$ \@ \\ \& \~ \< \> \# \% \" \. \:: \@text \::text - */ -void backslashB() -{} - -/** - * Backslash e at end of \e line froze SWIG \e - * with old comment parser. - * - * @see MyClass::fun(char, - * float) - */ -void backslashC() -{} - -/** - * The next line contains expression: - *
      - * ['retVal < 10', 'g_counter == 23 && g_mode & 3']
      - *
      - * - * Both words should be emphasized \b isystem.connect. - * But not the last period. For \b example, comma should not be emphasized. - * Similar \b for: double colon. - * - * Spaces at the start of line should be taken into account: - * @param id used as prefix in log - * statements. The default value is empty string, which is OK if - * there is only one app. instance. Example: - *
      - *         ctrl.setBP("func1");
      - *     
      - * If we set the id to \c main_, we get: - *
      - *         main_ctrl.setBP("func1");
      - *     
      - * - * @param fileName name of the log file - */ -void cycle(int id, char *fileName) -{} - - +/* + * This file contains comments which demonstrate details about Doxygen processing, + * so they can be emulated in SWIG doxy comment translation + */ + + + +/**This comment without space after '*' is valid in Doxygen. + * + */ +void isNoSpaceValidA() +{} + +/**.This comment without space after '*' is valid in Doxygen. + * + */ +void isNoSpaceValidB() +{} + + +/***This is not Doxygen comment. + * + */ +void isNoSpaceValidC() +{} + + +/** + * Backslash following\c word is a valid doxygen command. Output contains + * 'followingword' with 'word' in code font. + */ +void backslashA() +{} + +// Output of escaped symbols below in doxygen generated HTML: +// Rendered: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text +// HTML source: Escaped symbols: $ @ \ & < > # % " \. :: @text ::text + + +/** + * Doxy command without trailing \cspace space is ignored - nothing appears + * on output. Standalone \ and '\' get to output. + * Standalone @ and '@' get to output. + * Commands "in quoted \b strings are treated as plain text". + * Commands not recognized by Doxygen \blah @blah are ignored. + * Backslashes in DOS paths d:\xyz\qwe\myfile and words + * following them do not appear on output, we must quote them with + * double quotes: "d:\xyz\qwe\myfile", "@something". Single quotes do not help: + * 'd:\xyz\qwe\myfile'. Escaping works: d:\\xyz\\qwe\\myfile. Unix + * paths of course have no such problems: /xyz/qwe/myfile + * Commands for escaped symbols: + * \$ \@ \\ \& \~ \< \> \# \% \" \. \:: \@text \::text + */ +void backslashB() +{} + +/** + * Backslash e at end of \e line froze SWIG \e + * with old comment parser. + * + * @see MyClass::fun(char, + * float) + */ +void backslashC() +{} + +/** + * The next line contains expression: + *
      + * ['retVal < 10', 'g_counter == 23 && g_mode & 3']
      + *
      + * + * Both words should be emphasized \b isystem.connect. + * But not the last period. For \b example, comma should not be emphasized. + * Similar \b for: double colon. + * + * Spaces at the start of line should be taken into account: + * @param id used as prefix in log + * statements. The default value is empty string, which is OK if + * there is only one app. instance. Example: + *
      + *         ctrl.setBP("func1");
      + *     
      + * If we set the id to \c main_, we get: + *
      + *         main_ctrl.setBP("func1");
      + *     
      + * + * @param fileName name of the log file + */ +void cycle(int id, char *fileName) +{} + + diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i index ed5fa4326..461415316 100644 --- a/Examples/test-suite/doxygen_misc_constructs.i +++ b/Examples/test-suite/doxygen_misc_constructs.i @@ -1,124 +1,124 @@ -// This file contains tests for situations, which do not normally -// appear in the code, but must nevertheless be handled correctly. - -%module doxygen_misc_constructs - -%warnfilter(SWIGWARN_DOXYGEN_UNKNOWN_COMMAND) backslashB; - -%inline %{ - - // Tag '@endink' must be recognized even if it is not - // followed by whitespace. - - /** Tag endlink must be recognized also when followed by nonspace charater. - * - * @link Connection::getId() @endlink
      */ - - char g_counter; - - - /** - Tag endlink must be recognized also when it is the last token - in the commment. - - @link Connection::getId() @endlink
      - @link debugIdeTraceProfilerCoverageSample.py Python example. @endlink - */ - int g_zipCode; - - - // Paramter 'isReportSize' must appear in comment of the overload, which - // has it. Empty line before link must be preserved. - /** - * Returns address of file line. - * - * @param fileName name of the file, where the source line is located - * @param line line number - * @param isGetSize if set, for every object location both address and size are returned - * - * @link Connection::getId() @endlink
      - */ - void getAddress(int &fileName, - int line, - bool isGetSize = false) {} - - // The first comment must be ignored. - /** - * \defgroup icFacade isystem.connect Facade - * - * This page shows the core classes, which can be used to control - * all aspects of winIDEA, for example: debugging, analyzers, IO module, ... - */ - - /** - * This class contains information for connection to winIDEA. Its methods - * return reference to self, so we can use it like this: - *
      -     * CConnectionConfig config = new CConnectionConfig();
      -     * config.discoveryPort(5534).dllPath("C:\\myWinIDEA\\connect.dll").id("main");
      -     * 
      - * - * All parameters are optional. Set only what is required, default values are - * used for unspecified parameters. - *

      - * - * @link advancedWinIDEALaunching.py Python example.@endlink
      - */ - class CConnectionConfig - { - }; - - // Text after '\c' must be kept unchanged in Python. - /** - * Determines how long the \c isystem.connect should wait for running - * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags - * may be specified. - */ - int waitTime(long waitTime) {return 33;} - - - // Line with tag \ingroup must not appear in translated comment: - /** \ingroup icFacade - * - * This function returns connection id. - */ - int getConnection() {return 3;} - - // the follwing must produce no comment in wrapper - /*******************************************************************/ - char getFirstLetter() {return 'a';} - - - /** - * Class description. - */ - class ClassWithNestedEnum { - public: - /** - * Enum description. - */ - typedef enum {ONE, ///< desc of one - TWO, ///< desc of two - THREE ///< desc of three - } ENested; - - }; - - /** - An example of a list in a documentation comment. - - - The first item of the list. - - The second list item, on - several indented lines, - showing that the indentation - is preserved. - - And the final list item after it. - - And this is not a list item any more. - */ - void showList() { } - - #include "doxygen_misc_constructs.h" - -%} - %include "doxygen_misc_constructs.h" +// This file contains tests for situations, which do not normally +// appear in the code, but must nevertheless be handled correctly. + +%module doxygen_misc_constructs + +%warnfilter(SWIGWARN_DOXYGEN_UNKNOWN_COMMAND) backslashB; + +%inline %{ + + // Tag '@endink' must be recognized even if it is not + // followed by whitespace. + + /** Tag endlink must be recognized also when followed by nonspace charater. + * + * @link Connection::getId() @endlink
      */ + + char g_counter; + + + /** + Tag endlink must be recognized also when it is the last token + in the commment. + + @link Connection::getId() @endlink
      + @link debugIdeTraceProfilerCoverageSample.py Python example. @endlink + */ + int g_zipCode; + + + // Paramter 'isReportSize' must appear in comment of the overload, which + // has it. Empty line before link must be preserved. + /** + * Returns address of file line. + * + * @param fileName name of the file, where the source line is located + * @param line line number + * @param isGetSize if set, for every object location both address and size are returned + * + * @link Connection::getId() @endlink
      + */ + void getAddress(int &fileName, + int line, + bool isGetSize = false) {} + + // The first comment must be ignored. + /** + * \defgroup icFacade isystem.connect Facade + * + * This page shows the core classes, which can be used to control + * all aspects of winIDEA, for example: debugging, analyzers, IO module, ... + */ + + /** + * This class contains information for connection to winIDEA. Its methods + * return reference to self, so we can use it like this: + *

      +     * CConnectionConfig config = new CConnectionConfig();
      +     * config.discoveryPort(5534).dllPath("C:\\myWinIDEA\\connect.dll").id("main");
      +     * 
      + * + * All parameters are optional. Set only what is required, default values are + * used for unspecified parameters. + *

      + * + * @link advancedWinIDEALaunching.py Python example.@endlink
      + */ + class CConnectionConfig + { + }; + + // Text after '\c' must be kept unchanged in Python. + /** + * Determines how long the \c isystem.connect should wait for running + * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags + * may be specified. + */ + int waitTime(long waitTime) {return 33;} + + + // Line with tag \ingroup must not appear in translated comment: + /** \ingroup icFacade + * + * This function returns connection id. + */ + int getConnection() {return 3;} + + // the follwing must produce no comment in wrapper + /*******************************************************************/ + char getFirstLetter() {return 'a';} + + + /** + * Class description. + */ + class ClassWithNestedEnum { + public: + /** + * Enum description. + */ + typedef enum {ONE, ///< desc of one + TWO, ///< desc of two + THREE ///< desc of three + } ENested; + + }; + + /** + An example of a list in a documentation comment. + + - The first item of the list. + - The second list item, on + several indented lines, + showing that the indentation + is preserved. + - And the final list item after it. + + And this is not a list item any more. + */ + void showList() { } + + #include "doxygen_misc_constructs.h" + +%} + %include "doxygen_misc_constructs.h" From 419e850ea0239c32548a944947a3d58952f3b37b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 07:02:21 +0100 Subject: [PATCH 0958/2031] Add missing CPlusPlus17.html file Mistakenly omitted from 066c396ad6c1656a477997561def5a6131bafda5 --- Doc/Manual/CPlusPlus17.html | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Doc/Manual/CPlusPlus17.html diff --git a/Doc/Manual/CPlusPlus17.html b/Doc/Manual/CPlusPlus17.html new file mode 100644 index 000000000..690173e6e --- /dev/null +++ b/Doc/Manual/CPlusPlus17.html @@ -0,0 +1,78 @@ + + + +SWIG and C++17 + + + + + +

      8 SWIG and C++17

      + + + + + + +

      8.1 Introduction

      + + +

      This chapter gives you a brief overview about the SWIG +implementation of the C++17 standard. +There isn't much in C++17 that affects SWIG, however, work has only just begun on adding +C++17 support. +

      + +

      8.2 Core language changes

      + + +

      8.2.1 Nested namespace definitions

      + + +

      +C++17 offers a more concise syntax for defining namespaces. +SWIG has support for nested namespace definitions such as: +

      + +
      +
      +namespace A::B::C {
      +  ...
      +}
      +
      +
      + +

      +This is the equivalent to the C++98 namespace definitions: +

      + +
      +
      +namespace A {
      +  namespace B {
      +    namespace C {
      +      ...
      +    }
      +  }
      +}
      +
      +
      + +

      +Compatibility note: SWIG-4.0.0 was the first version to support nested namespace definitions. +

      + +

      8.3 Standard library changes

      + + + + From a1b1ba105b0fd98da91a9b51653357e50150fa43 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 07:30:02 +0100 Subject: [PATCH 0959/2031] html fixes for Doxygen --- Doc/Manual/Doxygen.html | 55 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 886391972..9e92d31be 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -89,6 +89,7 @@ in comments (like unterminated strings or missing ending tags). Currently, the whole subset of Doxygen comment styles is supported (See Documenting the code). Here they are: +

       /**
      @@ -103,7 +104,6 @@ Documenting the code). Here they are:
       /// Single-line comment
       //! Another single-line comment
       
      -

      Also any of the above with '<' added after comment-starting symbol, @@ -120,8 +120,8 @@ comments like /*********/ or //////////. Please note, as SWIG parses the input file by itself with strict grammar, there is only a limited support for various cases of comment placement in the file. -

      +

      Comments can be placed before C/C++ expressions on separate lines:

      @@ -548,10 +548,10 @@ directives):

      Here is the list of all Doxygen tags and the description of how they are translated to Javadoc

      -
      -
      +
      +
      - + @@ -578,7 +578,6 @@ Here is the list of all Doxygen tags and the description of how they are transla - @@ -795,7 +794,7 @@ Here is the list of all Doxygen tags and the description of how they are transla
      Doxygen tagsDoxygen tags
      \awrapped with <code> html tag
      \cite wrapped with <i> html tag
      prints ::
      -
      +

      39.3.3 Unsupported tags

      @@ -810,10 +809,10 @@ These are suppressed with their content just printed out (if the tag has any sense, typically text content). Here is the list of these tags:

      -
      -
      +
      +
      - + @@ -959,19 +958,19 @@ Here is the list of these tags:
      Unsupported Doxygen tagsUnsupported Doxygen tags
      \addindex\category
      -
      + -

      +

      If one of the following Doxygen tags appears as the first tag in a comment, the whole comment block is ignored:

      -
      -
      +
      +
      - + @@ -1029,7 +1028,7 @@ comment, the whole comment block is ignored:
      Ignored Doxygen tagsIgnored Doxygen tags
      \addtogroup
      -
      + @@ -1183,10 +1182,10 @@ are not present in generated code, so they have no comment translated for them. * </table> */ -

      +

      translates to Python as: -

      -

      +

      +
         Animals
         | Column 1 | Column 2 |
         -----------------------
      @@ -1194,7 +1193,6 @@ translates to Python as:
         | cat      | mouse    |
         | horse    | parrot   |
       
      -

      Overloaded functions @@ -1221,10 +1219,10 @@ to do the work.

      Here is the list of all Doxygen tags and the description of how they are translated to Pydoc

      -
      -
      +
      +
      - + @@ -1427,7 +1425,7 @@ Here is the list of all Doxygen tags and the description of how they are transla
      Doxygen tagsDoxygen tags
      \aprints ::
      -
      +

      39.4.3 Unsupported tags

      @@ -1440,10 +1438,10 @@ are suppressed with their content just printed out (if it has any sense, typically text content). Here is the list of these tags:

      -
      -
      +
      +
      - + @@ -1611,7 +1609,7 @@ Here is the list of these tags:
      Unsupported Doxygen tagsUnsupported Doxygen tags
      \addindex\c
      -
      +

      39.4.4 Further details

      @@ -1624,6 +1622,7 @@ TO BE ADDED.

      +This section contains information for developers enhancing the Doxygen translator.

      39.5.1 Doxygen translator design

      From 62814e4ab73e49865234a418a560e27d7ac5eb0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 18:32:53 +0100 Subject: [PATCH 0960/2031] Fixes to makechap.py to detect ill-formed headers --- Doc/Manual/Doxygen.html | 10 +++++----- Doc/Manual/makechap.py | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 9e92d31be..a736fb6a4 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -197,7 +197,7 @@ Translation of Doxygen comments is influenced by the following %feature directives:

      -

      doxygen:notranslate

      +

      doxygen:notranslate

      Turns off translation of Doxygen comments to the target language syntax: the @@ -208,7 +208,7 @@ instead of the corresponding language tool (javadoc, sphinx,

      -

      doxygen:alias:<command-name>

      +

      doxygen:alias:<command-name>

      Specify an alias for a Doxygen command with the given name. This can be useful @@ -254,7 +254,7 @@ wrappers of the C++ API.

      -

      doxygen:ignore:<command-name>

      +

      doxygen:ignore:<command-name>

      This feature makes it possible to just ignore an unknown Doxygen command, instead of @@ -404,14 +404,14 @@ def func(): -

      doxygen:nolinktranslate (Java-only currently)

      +

      doxygen:nolinktranslate (Java-only currently)

      Turn off automatic link-objects translation.

      -

      doxygen:nostripparams (Java-only currently)

      +

      doxygen:nostripparams (Java-only currently)

      Turn off stripping of @param and @tparam diff --git a/Doc/Manual/makechap.py b/Doc/Manual/makechap.py index 61994e2a0..e30d14e0f 100644 --- a/Doc/Manual/makechap.py +++ b/Doc/Manual/makechap.py @@ -44,6 +44,8 @@ def getheadingname(m): def getheadingtext(m, s): prevheadingtext_newstyle = m.group(2) prevheadingtext_oldstyle = m.group(3) + if prevheadingtext_oldstyle is None or prevheadingtext_newstyle is None: + raise RuntimeError("Ill-formed heading in line:\n%s" % s) if len(prevheadingtext_oldstyle) == 0 and len(prevheadingtext_newstyle) == 0: raise RuntimeError("No heading text in line:\n%s" % s) if len(prevheadingtext_oldstyle) > 0 and len(prevheadingtext_newstyle) > 0: @@ -72,7 +74,7 @@ name = "" # Regexs for

      ,...

      sections -h1 = re.compile(r".*?

      (\s*[\d\s]*(.*?))*[\d\s]*(.*?)

      ", re.IGNORECASE) +h1 = re.compile(r".*?

      (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

      ", re.IGNORECASE) h2 = re.compile(r".*?

      (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

      ", re.IGNORECASE) h3 = re.compile(r".*?

      (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

      ", re.IGNORECASE) h4 = re.compile(r".*?

      (\s*[\d\.\s]*(.*?))*[\d\.\s]*(.*?)

      ", re.IGNORECASE) From 4cdca98709a4a722245005890269a7c4af887288 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 18:36:20 +0100 Subject: [PATCH 0961/2031] Update html chapter numbering for added Doxygen chapter --- Doc/Manual/Allegrocl.html | 108 +++++++++--------- Doc/Manual/Android.html | 16 +-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Chicken.html | 40 +++---- Doc/Manual/Contents.html | 134 +++++++++++----------- Doc/Manual/D.html | 44 ++++---- Doc/Manual/Doxygen.html | 100 +++++++++-------- Doc/Manual/Extending.html | 100 ++++++++--------- Doc/Manual/Go.html | 56 +++++----- Doc/Manual/Guile.html | 44 ++++---- Doc/Manual/Java.html | 220 ++++++++++++++++++------------------- Doc/Manual/Javascript.html | 44 ++++---- Doc/Manual/Lisp.html | 22 ++-- Doc/Manual/Lua.html | 88 +++++++-------- Doc/Manual/Modula3.html | 40 +++---- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 62 +++++------ Doc/Manual/Octave.html | 52 ++++----- Doc/Manual/Perl5.html | 108 +++++++++--------- Doc/Manual/Php.html | 50 ++++----- Doc/Manual/Pike.html | 24 ++-- Doc/Manual/Python.html | 192 ++++++++++++++++---------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 ++++++++++++++++----------------- Doc/Manual/Scilab.html | 90 +++++++-------- Doc/Manual/Sections.html | 1 + Doc/Manual/Tcl.html | 92 ++++++++-------- Doc/Manual/Warnings.html | 36 +++--- Doc/Manual/chapters | 2 +- 31 files changed, 1062 insertions(+), 1039 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index f8e5d013e..aaa2ec5f1 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

      19 SWIG and Allegro Common Lisp

      +

      20 SWIG and Allegro Common Lisp

      -

      19.2.2 Foreign Wrappers

      +

      20.2.2 Foreign Wrappers

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

      -

      19.2.3 FFI Wrappers

      +

      20.2.3 FFI Wrappers

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

      -

      19.2.4 Non-overloaded Defuns

      +

      20.2.4 Non-overloaded Defuns

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

      -

      19.2.5 Overloaded Defuns

      +

      20.2.5 Overloaded Defuns

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

      -

      19.2.6 What about constant and variable access?

      +

      20.2.6 What about constant and variable access?

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

      -

      19.2.7 Object Wrapping

      +

      20.2.7 Object Wrapping

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

      -

      19.3 Wrapping Details

      +

      20.3 Wrapping Details

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

      -

      19.3.1 Namespaces

      +

      20.3.1 Namespaces

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

      -

      19.3.2 Constants

      +

      20.3.2 Constants

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

      -

      19.3.3 Variables

      +

      20.3.3 Variables

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

      19.3.4 Enumerations

      +

      20.3.4 Enumerations

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

      19.3.5 Arrays

      +

      20.3.5 Arrays

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

      19.3.6 Classes and Structs and Unions (oh my!)

      +

      20.3.6 Classes and Structs and Unions (oh my!)

      -

      19.3.6.1 CLOS wrapping of

      +

      20.3.6.1 CLOS wrapping of

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

      -

      19.3.6.2 CLOS Inheritance

      +

      20.3.6.2 CLOS Inheritance

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

      -

      19.3.6.3 Member fields and functions

      +

      20.3.6.3 Member fields and functions

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

      -

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

      +

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

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

      -

      19.3.7 Templates

      +

      20.3.7 Templates

      -

      19.3.7.1 Generating wrapper code for templates

      +

      20.3.7.1 Generating wrapper code for templates

      @@ -1187,7 +1187,7 @@ them. This is done via the directive.

      -

      19.3.7.2 Implicit Template instantiation

      +

      20.3.7.2 Implicit Template instantiation

      @@ -1197,7 +1197,7 @@ to include these templated classes in the foreign-type and CLOS class schema.

      -

      19.3.8 Typedef, Templates, and Synonym Types

      +

      20.3.8 Typedef, Templates, and Synonym Types

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

      19.3.8.1 Choosing a primary type

      +

      20.3.8.1 Choosing a primary type

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

    • -

      19.3.9 Function overloading/Parameter defaulting

      +

      20.3.9 Function overloading/Parameter defaulting

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

      19.3.10 Operator wrapping and Operator overloading

      +

      20.3.10 Operator wrapping and Operator overloading

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

      19.3.11 Varargs

      +

      20.3.11 Varargs

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

      -

      19.3.12 C++ Exceptions

      +

      20.3.12 C++ Exceptions

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

      -

      19.3.13 Pass by value, pass by reference

      +

      20.3.13 Pass by value, pass by reference

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

      -

      19.4 Typemaps

      +

      20.4 Typemaps

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

      -

      19.4.1 Code Generation in the C++ Wrapper

      +

      20.4.1 Code Generation in the C++ Wrapper

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

      19.4.1.1 IN Typemap

      +

      20.4.1.1 IN Typemap

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

      19.4.1.2 OUT Typemap

      +

      20.4.1.2 OUT Typemap

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

      19.4.1.3 CTYPE Typemap

      +

      20.4.1.3 CTYPE Typemap

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

      -

      19.4.2 Code generation in Lisp wrappers

      +

      20.4.2 Code generation in Lisp wrappers

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

      -

      19.4.2.1 LIN Typemap

      +

      20.4.2.1 LIN Typemap

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

      19.4.2.2 LOUT Typemap

      +

      20.4.2.2 LOUT Typemap

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

      19.4.2.3 FFITYPE Typemap

      +

      20.4.2.3 FFITYPE Typemap

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

      19.4.2.4 LISPTYPE Typemap

      +

      20.4.2.4 LISPTYPE Typemap

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

      19.4.2.5 LISPCLASS Typemap

      +

      20.4.2.5 LISPCLASS Typemap

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

      19.4.3 Modifying SWIG behavior using typemaps

      +

      20.4.3 Modifying SWIG behavior using typemaps

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

      19.5 Identifier Converter functions

      +

      20.5 Identifier Converter functions

      -

      19.5.1 Creating symbols in the lisp environment

      +

      20.5.1 Creating symbols in the lisp environment

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

      -

      19.5.2 Existing identifier-converter functions

      +

      20.5.2 Existing identifier-converter functions

      Two basic identifier routines have been defined. -

      19.5.2.1 identifier-convert-null

      +

      20.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.

      -

      19.5.2.2 identifier-convert-lispify

      +

      20.5.2.2 identifier-convert-lispify

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

      -

      19.5.2.3 Default identifier to symbol conversions

      +

      20.5.2.3 Default identifier to symbol conversions

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

      -

      19.5.3 Defining your own identifier-converter

      +

      20.5.3 Defining your own identifier-converter

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

      -

      19.5.4 Instructing SWIG to use a particular identifier-converter

      +

      20.5.4 Instructing SWIG to use a particular identifier-converter

      diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index cc11ec26e..894724188 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

      20 SWIG and Android

      +

      21 SWIG and Android

      -

      18.16 CREDITS

      +

      19.16 CREDITS

      @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

    • Paul Russell for many suggestions and the debian packaging

      -

      18.17 AUTHOR

      +

      19.17 AUTHOR

      diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 85d651fd1..58d058a19 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

      21 SWIG and C#

      +

      22 SWIG and C#

      -

      21.4 C# Arrays

      +

      22.4 C# Arrays

      @@ -586,7 +586,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

      -

      21.4.1 The SWIG C arrays library

      +

      22.4.1 The SWIG C arrays library

      @@ -623,7 +623,7 @@ example.print_array(c.cast()); // Pass to C

    • -

      21.4.2 Managed arrays using P/Invoke default array marshalling

      +

      22.4.2 Managed arrays using P/Invoke default array marshalling

      @@ -750,7 +750,7 @@ and intermediary class method -

      21.4.3 Managed arrays using pinning

      +

      22.4.3 Managed arrays using pinning

      @@ -845,7 +845,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

      21.5 C# Exceptions

      +

      22.5 C# Exceptions

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

      -

      21.5.1 C# exception example using "check" typemap

      +

      22.5.1 C# exception example using "check" typemap

      @@ -1124,7 +1124,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.

      -

      21.5.2 C# exception example using %exception

      +

      22.5.2 C# exception example using %exception

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

      21.5.3 C# exception example using exception specifications

      +

      22.5.3 C# exception example using exception specifications

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

      -

      21.5.4 Custom C# ApplicationException example

      +

      22.5.4 Custom C# ApplicationException example

      @@ -1379,7 +1379,7 @@ try { -

      21.6 C# Directors

      +

      22.6 C# Directors

      @@ -1392,7 +1392,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.

      -

      21.6.1 Directors example

      +

      22.6.1 Directors example

      @@ -1513,7 +1513,7 @@ CSharpDerived - UIntMethod(123) -

      21.6.2 Directors implementation

      +

      22.6.2 Directors implementation

      @@ -1721,7 +1721,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

      21.6.3 Director caveats

      +

      22.6.3 Director caveats

      @@ -1769,7 +1769,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.

      -

      21.7 Multiple modules

      +

      22.7 Multiple modules

      @@ -1804,7 +1804,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

      -

      21.8 C# Typemap examples

      +

      22.8 C# Typemap examples

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

      21.8.1 Memory management when returning references to member variables

      +

      22.8.1 Memory management when returning references to member variables

      @@ -1936,7 +1936,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

      -

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

      +

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

      @@ -2068,7 +2068,7 @@ as mentioned earlier, setElement is actually: -

      21.8.3 Date marshalling using the csin typemap and associated attributes

      +

      22.8.3 Date marshalling using the csin typemap and associated attributes

      @@ -2354,7 +2354,7 @@ public class example { -

      21.8.4 A date example demonstrating marshalling of C# properties

      +

      22.8.4 A date example demonstrating marshalling of C# properties

      @@ -2454,7 +2454,7 @@ Some points to note:

    • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

      21.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

      +

      22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

      @@ -2516,7 +2516,7 @@ Pay special attention to the memory management issues, using these attributes.

      -

      21.8.6 Turning proxy classes into partial classes

      +

      22.8.6 Turning proxy classes into partial classes

      @@ -2616,7 +2616,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.

      -

      21.8.7 Turning proxy classes into sealed classes

      +

      22.8.7 Turning proxy classes into sealed classes

      @@ -2706,7 +2706,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

      -

      21.8.8 Extending proxy classes with additional C# code

      +

      22.8.8 Extending proxy classes with additional C# code

      @@ -2745,7 +2745,7 @@ public class ExtendMe : global::System.IDisposable { -

      21.8.9 Underlying type for enums

      +

      22.8.9 Underlying type for enums

      diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index bf34ae507..3a80811bd 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

      22 SWIG and Chicken

      +

      23 SWIG and Chicken

      -

      22.3 TinyCLOS

      +

      23.3 TinyCLOS

      @@ -333,7 +333,7 @@

      -

      22.4 Linkage

      +

      23.4 Linkage

      @@ -354,7 +354,7 @@

      -

      22.4.1 Static binary or shared library linked at compile time

      +

      23.4.1 Static binary or shared library linked at compile time

      We can easily use csc to build a static binary.

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

      -

      22.4.2 Building chicken extension libraries

      +

      23.4.2 Building chicken extension libraries

      Building a shared library like in the above section only works if the library @@ -453,7 +453,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.

      -

      22.4.3 Linking multiple SWIG modules with TinyCLOS

      +

      23.4.3 Linking multiple SWIG modules with TinyCLOS

      Linking together multiple modules that share type information using the %import @@ -477,7 +477,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.

      -

      22.5 Typemaps

      +

      23.5 Typemaps

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

      Lib/chicken/chicken.swg.

      -

      22.6 Pointers

      +

      23.6 Pointers

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

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

      -

      22.6.1 Garbage collection

      +

      23.6.1 Garbage collection

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

      must be called manually.

      -

      22.7 Unsupported features and known problems

      +

      23.7 Unsupported features and known problems

      -

      22.7.1 TinyCLOS problems with Chicken version <= 1.92

      +

      23.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 b8909322c..b7de00077 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -591,7 +591,51 @@ -

      16 Warning Messages

      +

      16 SWIG and Doxygen Translation

      + + + + + +

      17 Warning Messages

      @@ -619,7 +663,7 @@
      -

      17 Working with Modules

      +

      18 Working with Modules

      @@ -635,7 +679,7 @@
      -

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

      +

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

      @@ -661,7 +705,7 @@
      -

      19 SWIG and Allegro Common Lisp

      +

      20 SWIG and Allegro Common Lisp

      @@ -745,7 +789,7 @@
      -

      20 SWIG and Android

      +

      21 SWIG and Android

      @@ -763,7 +807,7 @@
      -

      21 SWIG and C#

      +

      22 SWIG and C#

      @@ -811,7 +855,7 @@
      -

      22 SWIG and Chicken

      +

      23 SWIG and Chicken

      @@ -849,7 +893,7 @@
      -

      23 SWIG and D

      +

      24 SWIG and D

      @@ -883,7 +927,7 @@
      -

      24 SWIG and Go

      +

      25 SWIG and Go

      @@ -927,7 +971,7 @@
      -

      25 SWIG and Guile

      +

      26 SWIG and Guile

      @@ -963,7 +1007,7 @@
      -

      26 SWIG and Java

      +

      27 SWIG and Java

      @@ -1117,7 +1161,7 @@
      -

      27 SWIG and Javascript

      +

      28 SWIG and Javascript

      @@ -1159,7 +1203,7 @@
      -

      28 SWIG and Common Lisp

      +

      29 SWIG and Common Lisp

      @@ -1182,7 +1226,7 @@
      -

      29 SWIG and Lua

      +

      30 SWIG and Lua

      @@ -1250,7 +1294,7 @@
      -

      30 SWIG and Modula-3

      +

      31 SWIG and Modula-3

      @@ -1288,7 +1332,7 @@
      -

      31 SWIG and MzScheme/Racket

      +

      32 SWIG and MzScheme/Racket

      @@ -1300,7 +1344,7 @@
      -

      32 SWIG and Ocaml

      +

      33 SWIG and Ocaml

      @@ -1351,7 +1395,7 @@
      -

      33 SWIG and Octave

      +

      34 SWIG and Octave

      @@ -1391,7 +1435,7 @@
      -

      34 SWIG and Perl5

      +

      35 SWIG and Perl5

      @@ -1467,7 +1511,7 @@
      -

      35 SWIG and PHP

      +

      36 SWIG and PHP

      @@ -1508,7 +1552,7 @@
      -

      36 SWIG and Pike

      +

      37 SWIG and Pike

      @@ -1532,7 +1576,7 @@
      -

      37 SWIG and Python

      +

      38 SWIG and Python

      @@ -1668,7 +1712,7 @@
      -

      38 SWIG and R

      +

      39 SWIG and R

      @@ -1684,7 +1728,7 @@
      -

      39 SWIG and Ruby

      +

      40 SWIG and Ruby

      @@ -1822,7 +1866,7 @@
      -

      40 SWIG and Scilab

      +

      41 SWIG and Scilab

      @@ -1891,7 +1935,7 @@
      -

      41 SWIG and Tcl

      +

      42 SWIG and Tcl

      @@ -1957,7 +2001,7 @@
      -

      42 Extending SWIG to support new languages

      +

      43 Extending SWIG to support new languages

      @@ -2025,42 +2069,6 @@
      -

      40 SWIG and Doxygen Translation

      - - - - - diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index a252650ff..5a6ee8f28 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

      23 SWIG and D

      +

      24 SWIG and D

        @@ -41,7 +41,7 @@ -

        23.1 Introduction

        +

        24.1 Introduction

        From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

        @@ -53,7 +53,7 @@

        To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

        -

        23.2 Command line invocation

        +

        24.2 Command line invocation

        To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

        @@ -83,10 +83,10 @@ -

        23.3 Typemaps

        +

        24.3 Typemaps

        -

        23.3.1 C# <-> D name comparison

        +

        24.3.1 C# <-> D name comparison

        If you already know the SWIG C# module, you might find the following name comparison table useful:

        @@ -112,7 +112,7 @@
      -

      23.3.2 ctype, imtype, dtype

      +

      24.3.2 ctype, imtype, dtype

      Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

      @@ -120,7 +120,7 @@

      The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

      -

      23.3.3 in, out, directorin, directorout

      +

      24.3.3 in, out, directorin, directorout

      Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

      @@ -130,7 +130,7 @@

      The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

      -

      23.3.4 din, dout, ddirectorin, ddirectorout

      +

      24.3.4 din, dout, ddirectorin, ddirectorout

      Typemaps for code generation in D proxy and type wrapper classes.

      @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

      23.3.5 typecheck typemaps

      +

      24.3.5 typecheck typemaps

      Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

      -

      23.3.6 Code injection typemaps

      +

      24.3.6 Code injection typemaps

      These typemaps are used for generating the skeleton of proxy classes for C++ types.

      @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

      -

      23.3.7 Special variable macros

      +

      24.3.7 Special variable macros

      The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

      @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

      23.4 D and %feature

      +

      24.4 D and %feature

      The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

      @@ -329,7 +329,7 @@ struct A { -

      23.5 Pragmas

      +

      24.5 Pragmas

      There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

      @@ -368,7 +368,7 @@ struct A { -

      23.6 D Exceptions

      +

      24.6 D Exceptions

      Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

      @@ -378,7 +378,7 @@ struct A {

      As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

      -

      23.7 D Directors

      +

      24.7 D Directors

      When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

      @@ -387,16 +387,16 @@ struct A {

      -

      23.8 Other features

      +

      24.8 Other features

      -

      23.8.1 Extended namespace support (nspace)

      +

      24.8.1 Extended namespace support (nspace)

      By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

      -

      23.8.2 Native pointer support

      +

      24.8.2 Native pointer support

      Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

      @@ -408,7 +408,7 @@ struct A {

      To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

      -

      23.8.3 Operator overloading

      +

      24.8.3 Operator overloading

      The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

      @@ -420,7 +420,7 @@ struct A {

      There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

      -

      23.8.4 Running the test-suite

      +

      24.8.4 Running the test-suite

      As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

      @@ -428,14 +428,14 @@ struct A {

      Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

      -

      23.9 D Typemap examples

      +

      24.9 D Typemap examples

      There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

      -

      23.10 Work in progress and planned features

      +

      24.10 Work in progress and planned features

      There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

      diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index a736fb6a4..de9ff5841 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,38 +5,45 @@ -

      39 SWIG and Doxygen Translation

      +

      16 SWIG and Doxygen Translation

    • Doxygen to Javadoc + -
    • Doxygen To Pydoc +
    • Doxygen to Pydoc -
    • Developer Information +
    • Developer information -
    • Extending to Other Languages +
    • Extending to other languages @@ -50,7 +57,7 @@ documentation language. Currently only Javadoc and Pydoc is supported.

      -

      39.1 Doxygen translation overview

      +

      16.1 Doxygen translation overview

      @@ -66,7 +73,7 @@ a Google Summer of Code proposal from Summer 2008.

      -

      39.2 Preparations

      +

      16.2 Preparations

      @@ -182,7 +189,8 @@ where the comments for a code item are not put directly before or after the code These structural commands are stripped out by SWIG and are not assigned to anything.

      -

      39.2.1 Enabling Doxygen translation

      +

      16.2.1 Enabling Doxygen translation

      +

      Doxygen comments translation is disabled by default and needs to be explicitly @@ -190,14 +198,16 @@ enabled using the command line -doxygen switch for the languages that do support it (currently Java and Python).

      -

      39.2.2 Doxygen-specific %feature directives

      +

      16.2.2 Doxygen-specific %feature directives

      +

      Translation of Doxygen comments is influenced by the following %feature directives:

      -

      doxygen:notranslate

      +

      16.2.2.1 doxygen:notranslate

      +

      Turns off translation of Doxygen comments to the target language syntax: the @@ -208,7 +218,8 @@ instead of the corresponding language tool (javadoc, sphinx,

      -

      doxygen:alias:<command-name>

      +

      16.2.2.2 doxygen:alias:<command-name>

      +

      Specify an alias for a Doxygen command with the given name. This can be useful @@ -254,7 +265,8 @@ wrappers of the C++ API.

      -

      doxygen:ignore:<command-name>

      +

      16.2.2.3 doxygen:ignore:<command-name>

      +

      This feature makes it possible to just ignore an unknown Doxygen command, instead of @@ -404,14 +416,16 @@ def func(): -

      doxygen:nolinktranslate (Java-only currently)

      +

      16.2.2.4 doxygen:nolinktranslate (Java-only currently)

      +

      Turn off automatic link-objects translation.

      -

      doxygen:nostripparams (Java-only currently)

      +

      16.2.2.5 doxygen:nostripparams (Java-only currently)

      +

      Turn off stripping of @param and @tparam @@ -419,14 +433,14 @@ Doxygen commands if the parameter is not found in the function signature.

      -

      39.2.3 Additional command line options

      +

      16.2.3 Additional command line options

      ALSO TO BE ADDED (Javadoc auto brief?)

      -

      39.3 Doxygen to Javadoc

      +

      16.3 Doxygen to Javadoc

      @@ -435,7 +449,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

      -

      39.3.1 Basic example

      +

      16.3.1 Basic example

      @@ -542,7 +556,7 @@ Javadoc translator features summary directives):

      -

      39.3.2 Javadoc tags

      +

      16.3.2 Javadoc tags

      @@ -796,7 +810,7 @@ Here is the list of all Doxygen tags and the description of how they are transla

    -

    39.3.3 Unsupported tags

    +

    16.3.3 Unsupported tags

    @@ -1032,14 +1046,14 @@ comment, the whole comment block is ignored: -

    39.3.4 Further details

    +

    16.3.4 Further details

    TO BE ADDED.

    -

    39.4 Doxygen to Pydoc

    +

    16.4 Doxygen to Pydoc

    @@ -1050,7 +1064,7 @@ Doxygen or Javadoc, so most of Doxygen commands are translated by merely copying the appropriate command text.

    -

    39.4.1 Basic example

    +

    16.4.1 Basic example

    @@ -1213,7 +1227,7 @@ docs), you may want to use some tool like doxypy to do the work.

    -

    39.4.2 Pydoc translator

    +

    16.4.2 Pydoc translator

    @@ -1427,7 +1441,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    39.4.3 Unsupported tags

    +

    16.4.3 Unsupported tags

    @@ -1611,21 +1625,21 @@ Here is the list of these tags: -

    39.4.4 Further details

    +

    16.4.4 Further details

    TO BE ADDED.

    -

    39.5 Developer information

    +

    16.5 Developer information

    This section contains information for developers enhancing the Doxygen translator.

    -

    39.5.1 Doxygen translator design

    +

    16.5.1 Doxygen translator design

    @@ -1651,7 +1665,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

    -

    39.5.2 Debugging the Doxygen parser and translator

    +

    16.5.2 Debugging the Doxygen parser and translator

    @@ -1664,7 +1678,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

    39.5.3 Tests

    +

    16.5.3 Tests

    @@ -1716,7 +1730,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

    -

    39.6 Extending to other languages

    +

    16.6 Extending to other languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index aafc650f6..8769aa36e 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    42 Extending SWIG to support new languages

    +

    43 Extending SWIG to support new languages

    -

    42.4.4 Attribute namespaces

    +

    43.4.4 Attribute namespaces

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

    -

    42.4.5 Symbol Tables

    +

    43.4.5 Symbol Tables

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

    42.4.6 The %feature directive

    +

    43.4.6 The %feature directive

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

    -

    42.4.7 Code Generation

    +

    43.4.7 Code Generation

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

    -

    42.4.8 SWIG and XML

    +

    43.4.8 SWIG and XML

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

    -

    42.5 Primitive Data Structures

    +

    43.5 Primitive Data Structures

    @@ -988,7 +988,7 @@ typedef Hash Typetab; -

    42.5.1 Strings

    +

    43.5.1 Strings

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

    42.5.2 Hashes

    +

    43.5.2 Hashes

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

    42.5.3 Lists

    +

    43.5.3 Lists

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

    42.5.4 Common operations

    +

    43.5.4 Common operations

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

    42.5.5 Iterating over Lists and Hashes

    +

    43.5.5 Iterating over Lists and Hashes

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

    42.5.6 I/O

    +

    43.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1529,7 +1529,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    42.6 Navigating and manipulating parse trees

    +

    43.6 Navigating and manipulating parse trees

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

    42.7 Working with attributes

    +

    43.7 Working with attributes

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

    42.8 Type system

    +

    43.8 Type system

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

    -

    42.8.1 String encoding of types

    +

    43.8.1 String encoding of types

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

    -

    42.8.2 Type construction

    +

    43.8.2 Type construction

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

    42.8.3 Type tests

    +

    43.8.3 Type tests

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

    42.8.4 Typedef and inheritance

    +

    43.8.4 Typedef and inheritance

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

    42.8.5 Lvalues

    +

    43.8.5 Lvalues

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

    42.8.6 Output functions

    +

    43.8.6 Output functions

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

    42.9 Parameters

    +

    43.9 Parameters

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

    42.10 Writing a Language Module

    +

    43.10 Writing a Language Module

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

    -

    42.10.1 Execution model

    +

    43.10.1 Execution model

    @@ -2471,7 +2471,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.

    -

    42.10.2 Starting out

    +

    43.10.2 Starting out

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

    -

    42.10.3 Command line options

    +

    43.10.3 Command line options

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

    -

    42.10.4 Configuration and preprocessing

    +

    43.10.4 Configuration and preprocessing

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

    -

    42.10.5 Entry point to code generation

    +

    43.10.5 Entry point to code generation

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

    42.10.6 Module I/O and wrapper skeleton

    +

    43.10.6 Module I/O and wrapper skeleton

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

    42.10.7 Low-level code generators

    +

    43.10.7 Low-level code generators

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

    -

    42.10.8 Configuration files

    +

    43.10.8 Configuration files

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

    42.10.9 Runtime support

    +

    43.10.9 Runtime support

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

    -

    42.10.10 Standard library files

    +

    43.10.10 Standard library files

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

    -

    42.10.11 User examples

    +

    43.10.11 User examples

    @@ -3248,7 +3248,7 @@ during this process, see the section on .

    -

    42.10.12 Test driven development and the test-suite

    +

    43.10.12 Test driven development and the test-suite

    @@ -3307,7 +3307,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    42.10.12.1 Running the test-suite

    +

    43.10.12.1 Running the test-suite

    @@ -3499,7 +3499,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    42.10.13 Documentation

    +

    43.10.13 Documentation

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

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

    +

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

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

    -

    42.10.15 Coding style guidelines

    +

    43.10.15 Coding style guidelines

    @@ -3612,7 +3612,7 @@ 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.

    -

    42.11 Debugging Options

    +

    43.11 Debugging Options

    @@ -3639,7 +3639,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    42.12 Guide to parse tree nodes

    +

    43.12 Guide to parse tree nodes

    @@ -4047,7 +4047,7 @@ extern "X" { ... } declaration. -

    42.13 Further Development Information

    +

    43.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 432f932ad..750a62514 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    24 SWIG and Go

    +

    25 SWIG and Go

    -

    24.3.1 Go-specific Commandline Options

    +

    25.3.1 Go-specific Commandline Options

    @@ -264,7 +264,7 @@ swig -go -help -

    24.3.2 Generated Wrapper Files

    +

    25.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -308,7 +308,7 @@ combined with the compiled MODULE.go using go tool pack. -

    24.4 A tour of basic C/C++ wrapping

    +

    25.4 A tour of basic C/C++ wrapping

    @@ -318,7 +318,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    24.4.1 Go Package Name

    +

    25.4.1 Go Package Name

    @@ -328,7 +328,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    24.4.2 Go Names

    +

    25.4.2 Go Names

    @@ -360,7 +360,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    24.4.3 Go Constants

    +

    25.4.3 Go Constants

    @@ -368,7 +368,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    24.4.4 Go Enumerations

    +

    25.4.4 Go Enumerations

    @@ -378,7 +378,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    24.4.5 Go Classes

    +

    25.4.5 Go Classes

    @@ -456,7 +456,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    24.4.5.1 Go Class Memory Management

    +

    25.4.5.1 Go Class Memory Management

    @@ -578,7 +578,7 @@ func (o *GoClassName) Close() { -

    24.4.5.2 Go Class Inheritance

    +

    25.4.5.2 Go Class Inheritance

    @@ -590,7 +590,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    24.4.6 Go Templates

    +

    25.4.6 Go Templates

    @@ -599,7 +599,7 @@ wrappers for a particular template instantation. To do this, use the %template directive. -

    24.4.7 Go Director Classes

    +

    25.4.7 Go Director Classes

    @@ -617,7 +617,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    24.4.7.1 Example C++ code

    +

    25.4.7.1 Example C++ code

    @@ -689,7 +689,7 @@ be found in the end of the guide.

    -

    24.4.7.2 Enable director feature

    +

    25.4.7.2 Enable director feature

    @@ -724,7 +724,7 @@ documentation on directors.

    -

    24.4.7.3 Constructor and destructor

    +

    25.4.7.3 Constructor and destructor

    @@ -777,7 +777,7 @@ embedding.

    -

    24.4.7.4 Override virtual methods

    +

    25.4.7.4 Override virtual methods

    @@ -843,7 +843,7 @@ the Go methods.

    -

    24.4.7.5 Call base methods

    +

    25.4.7.5 Call base methods

    @@ -880,7 +880,7 @@ be found in the end of the guide.

    -

    24.4.7.6 Subclass via embedding

    +

    25.4.7.6 Subclass via embedding

    @@ -948,7 +948,7 @@ class.

    -

    24.4.7.7 Memory management with runtime.SetFinalizer

    +

    25.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1013,7 +1013,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    24.4.7.8 Complete FooBarGo example class

    +

    25.4.7.8 Complete FooBarGo example class

    @@ -1142,7 +1142,7 @@ SWIG/Examples/go/director/.

    -

    24.4.8 Default Go primitive type mappings

    +

    25.4.8 Default Go primitive type mappings

    @@ -1249,7 +1249,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    24.4.9 Output arguments

    +

    25.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1302,7 +1302,7 @@ void f(char *output); -

    24.4.10 Adding additional go code

    +

    25.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1397,7 +1397,7 @@ func bar() { -

    24.4.11 Go typemaps

    +

    25.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 31d822599..9d55b632b 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    25 SWIG and Guile

    +

    26 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      25.1 Supported Guile Versions

      +

      26.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      25.2 Meaning of "Module"

      +

      26.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      25.3 Old GH Guile API

      +

      26.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      25.4 Linkage

      +

      26.4 Linkage

      @@ -89,7 +89,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. -

      25.4.1 Simple Linkage

      +

      26.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      25.4.2 Passive Linkage

      +

      26.4.2 Passive Linkage

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

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

      25.4.3 Native Guile Module Linkage

      +

      26.4.3 Native Guile Module Linkage

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

    -

    25.4.4 Old Auto-Loading Guile Module Linkage

    +

    26.4.4 Old Auto-Loading Guile Module Linkage

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

    25.4.5 Hobbit4D Linkage

    +

    26.4.5 Hobbit4D Linkage

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

    -

    25.5 Underscore Folding

    +

    26.5 Underscore Folding

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

    25.6 Typemaps

    +

    26.6 Typemaps

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

    -

    25.7 Representation of pointers as smobs

    +

    26.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    25.7.1 Smobs

    +

    26.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    25.7.2 Garbage Collection

    +

    26.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 25.8 Native Guile pointers +

    26.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    25.9 Exception Handling

    +

    26.9 Exception Handling

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

    25.10 Procedure documentation

    +

    26.10 Procedure documentation

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

    25.11 Procedures with setters

    +

    26.11 Procedures with setters

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

    25.12 GOOPS Proxy Classes

    +

    26.12 GOOPS Proxy Classes

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

    -

    25.12.1 Naming Issues

    +

    26.12.1 Naming Issues

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

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    25.12.2 Linking

    +

    26.12.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 9dfaa1fd4..f1ca6667e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    26 SWIG and Java

    +

    27 SWIG and Java

    -

    26.3.3 Global variables

    +

    27.3.3 Global variables

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

    26.3.4 Constants

    +

    27.3.4 Constants

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

    -

    26.3.5 Enumerations

    +

    27.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    26.3.5.1 Anonymous enums

    +

    27.3.5.1 Anonymous enums

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

    -

    26.3.5.2 Typesafe enums

    +

    27.3.5.2 Typesafe enums

    @@ -1127,7 +1127,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.

    -

    26.3.5.3 Proper Java enums

    +

    27.3.5.3 Proper Java enums

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

    -

    26.3.5.4 Type unsafe enums

    +

    27.3.5.4 Type unsafe enums

    @@ -1228,7 +1228,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.

    -

    26.3.5.5 Simple enums

    +

    27.3.5.5 Simple enums

    @@ -1247,7 +1247,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.

    -

    26.3.6 Pointers

    +

    27.3.6 Pointers

    @@ -1335,7 +1335,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.

    -

    26.3.7 Structures

    +

    27.3.7 Structures

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

    26.3.8 C++ classes

    +

    27.3.8 C++ classes

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

    26.3.9 C++ inheritance

    +

    27.3.9 C++ inheritance

    @@ -1627,7 +1627,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.

    -

    26.3.10 Pointers, references, arrays and pass by value

    +

    27.3.10 Pointers, references, arrays and pass by value

    @@ -1682,7 +1682,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).

    -

    26.3.10.1 Null pointers

    +

    27.3.10.1 Null pointers

    @@ -1706,7 +1706,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.

    -

    26.3.11 C++ overloaded functions

    +

    27.3.11 C++ overloaded functions

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

    26.3.12 C++ default arguments

    +

    27.3.12 C++ default arguments

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

    -

    26.3.13 C++ namespaces

    +

    27.3.13 C++ namespaces

    @@ -1954,7 +1954,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    26.3.14 C++ templates

    +

    27.3.14 C++ templates

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

    -

    26.3.15 C++ Smart Pointers

    +

    27.3.15 C++ Smart Pointers

    -

    26.3.15.1 The shared_ptr Smart Pointer

    +

    27.3.15.1 The shared_ptr Smart Pointer

    @@ -2017,7 +2017,7 @@ in the shared_ptr smart pointer -

    26.3.15.2 Generic Smart Pointers

    +

    27.3.15.2 Generic Smart Pointers

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

    26.4 Further details on the generated Java classes

    +

    27.4 Further details on the generated Java classes

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

    -

    26.4.1 The intermediary JNI class

    +

    27.4.1 The intermediary JNI class

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

    -

    26.4.1.1 The intermediary JNI class pragmas

    +

    27.4.1.1 The intermediary JNI class pragmas

    @@ -2318,7 +2318,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    26.4.2 The Java module class

    +

    27.4.2 The Java module class

    @@ -2349,7 +2349,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.

    -

    26.4.2.1 The Java module class pragmas

    +

    27.4.2.1 The Java module class pragmas

    @@ -2400,7 +2400,7 @@ See The intermediary JNI class pragmas secti

    -

    26.4.3 Java proxy classes

    +

    27.4.3 Java proxy classes

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

    26.4.3.1 Memory management

    +

    27.4.3.1 Memory management

    @@ -2638,7 +2638,7 @@ and

    -

    26.4.3.2 Inheritance

    +

    27.4.3.2 Inheritance

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

    27.4.3.3 Proxy classes and garbage collection

    @@ -2837,7 +2837,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.

    -

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    27.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2959,7 +2959,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    26.4.3.5 Single threaded applications and thread safety

    +

    27.4.3.5 Single threaded applications and thread safety

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

    26.4.4 Type wrapper classes

    +

    27.4.4 Type wrapper classes

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

    26.4.5 Enum classes

    +

    27.4.5 Enum classes

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

    -

    26.4.5.1 Typesafe enum classes

    +

    27.4.5.1 Typesafe enum classes

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

    -

    26.4.5.2 Proper Java enum classes

    +

    27.4.5.2 Proper Java enum classes

    @@ -3305,7 +3305,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.

    -

    26.4.5.3 Type unsafe enum classes

    +

    27.4.5.3 Type unsafe enum classes

    @@ -3336,7 +3336,7 @@ public final class Beverage { -

    26.4.6 Interfaces

    +

    27.4.6 Interfaces

    @@ -3581,7 +3581,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    26.5 Cross language polymorphism using directors

    +

    27.5 Cross language polymorphism using directors

    @@ -3603,7 +3603,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.

    -

    26.5.1 Enabling directors

    +

    27.5.1 Enabling directors

    @@ -3671,7 +3671,7 @@ public: -

    26.5.2 Director classes

    +

    27.5.2 Director classes

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

    -

    26.5.3 Overhead and code bloat

    +

    27.5.3 Overhead and code bloat

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

    -

    26.5.4 Simple directors example

    +

    27.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    26.5.5 Director threading issues

    +

    27.5.5 Director threading issues

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

    26.5.6 Director performance tuning

    +

    27.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    26.5.7 Java exceptions from directors

    +

    27.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    26.5.7.1 Customizing director exceptions

    +

    27.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    26.6 Accessing protected members

    +

    27.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    26.7 Common customization features

    +

    27.7 Common customization features

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

    -

    26.7.1 C/C++ helper functions

    +

    27.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    26.7.2 Class extension with %extend

    +

    27.7.2 Class extension with %extend

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

    -

    26.7.3 Class extension with %proxycode

    +

    27.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    26.7.4 Exception handling with %exception and %javaexception

    +

    27.7.4 Exception handling with %exception and %javaexception

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

    -

    26.7.5 Method access with %javamethodmodifiers

    +

    27.7.5 Method access with %javamethodmodifiers

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

    26.8 Tips and techniques

    +

    27.8 Tips and techniques

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

    -

    26.8.1 Input and output parameters using primitive pointers and references

    +

    27.8.1 Input and output parameters using primitive pointers and references

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

    -

    26.8.2 Simple pointers

    +

    27.8.2 Simple pointers

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

    -

    26.8.3 Wrapping C arrays with Java arrays

    +

    27.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    26.8.4 Unbounded C Arrays

    +

    27.8.4 Unbounded C Arrays

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

    -

    26.8.5 Binary data vs Strings

    +

    27.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    26.8.6 Overriding new and delete to allocate from Java heap

    +

    27.8.6 Overriding new and delete to allocate from Java heap

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

    -

    26.9 Java typemaps

    +

    27.9 Java typemaps

    @@ -5657,7 +5657,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. -

    26.9.1 Default primitive type mappings

    +

    27.9.1 Default primitive type mappings

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

    -

    26.9.2 Default typemaps for non-primitive types

    +

    27.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    26.9.3 Sixty four bit JVMs

    +

    27.9.3 Sixty four bit JVMs

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

    -

    26.9.4 What is a typemap?

    +

    27.9.4 What is a typemap?

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

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

    +

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

    @@ -6240,7 +6240,7 @@ These are listed below: -

    26.9.6 Java typemap attributes

    +

    27.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    26.9.7 Java special variables

    +

    27.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    26.9.8 Typemaps for both C and C++ compilation

    +

    27.9.8 Typemaps for both C and C++ compilation

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

    -

    26.9.9 Java code typemaps

    +

    27.9.9 Java code typemaps

    @@ -6801,7 +6801,7 @@ to make the method and constructor public: -

    26.9.10 Director specific typemaps

    +

    27.9.10 Director specific typemaps

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

    26.10 Typemap Examples

    +

    27.10 Typemap Examples

    @@ -7088,7 +7088,7 @@ the SWIG library.

    -

    26.10.1 Simpler Java enums for enums without initializers

    +

    27.10.1 Simpler Java enums for enums without initializers

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

    -

    26.10.2 Handling C++ exception specifications as Java exceptions

    +

    27.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    26.10.3 NaN Exception - exception handling for a particular type

    +

    27.10.3 NaN Exception - exception handling for a particular type

    @@ -7447,7 +7447,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.

    -

    26.10.4 Converting Java String arrays to char **

    +

    27.10.4 Converting Java String arrays to char **

    @@ -7591,7 +7591,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    26.10.5 Expanding a Java object to multiple arguments

    +

    27.10.5 Expanding a Java object to multiple arguments

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

    26.10.6 Using typemaps to return arguments

    +

    27.10.6 Using typemaps to return arguments

    @@ -7791,7 +7791,7 @@ $ java runme 1 12.0 340.0 -

    26.10.7 Adding Java downcasts to polymorphic return types

    +

    27.10.7 Adding Java downcasts to polymorphic return types

    @@ -7997,7 +7997,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.

    -

    26.10.8 Adding an equals method to the Java classes

    +

    27.10.8 Adding an equals method to the Java classes

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

    26.10.9 Void pointers and a common Java base class

    +

    27.10.9 Void pointers and a common Java base class

    @@ -8100,7 +8100,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. -

    26.10.10 Struct pointer to pointer

    +

    27.10.10 Struct pointer to pointer

    @@ -8280,7 +8280,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.

    -

    26.10.11 Memory management when returning references to member variables

    +

    27.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

    @@ -8531,7 +8531,7 @@ as mentioned earlier, setElement is actually: -

    26.10.13 Date marshalling using the javain typemap and associated attributes

    +

    27.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8708,7 +8708,7 @@ A few things to note: -

    26.11 Living with Java Directors

    +

    27.11 Living with Java Directors

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

  • -

    26.12 Odds and ends

    +

    27.12 Odds and ends

    -

    26.12.1 JavaDoc comments

    +

    27.12.1 JavaDoc comments

    @@ -8946,7 +8946,7 @@ public class Barmy { -

    26.12.2 Functional interface without proxy classes

    +

    27.12.2 Functional interface without proxy classes

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

    26.12.3 Using your own JNI functions

    +

    27.12.3 Using your own JNI functions

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

    -

    26.12.4 Performance concerns and hints

    +

    27.12.4 Performance concerns and hints

    @@ -9078,7 +9078,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.

    -

    26.12.5 Debugging

    +

    27.12.5 Debugging

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

    -

    26.13 Java Examples

    +

    27.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 10612f001..2a18aed8c 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    27 SWIG and Javascript

    +

    28 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      27.1 Overview

      +

      28.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      27.2 Preliminaries

      +

      28.2 Preliminaries

      -

      27.2.1 Running SWIG

      +

      28.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      27.2.2 Running Tests and Examples

      +

      28.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    27.2.3 Known Issues

    +

    28.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -170,12 +170,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    27.3 Integration

    +

    28.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    27.3.1 Creating node.js Extensions

    +

    28.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -221,7 +221,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    27.3.1.1 Troubleshooting

    +

    28.3.1.1 Troubleshooting

      @@ -233,12 +233,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      27.3.2 Embedded Webkit

      +

      28.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      27.3.2.1 Mac OS X

      +

      28.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -286,7 +286,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      27.3.2.2 GTK

      +

      28.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -331,7 +331,7 @@ int main(int argc, char* argv[]) } -

      27.3.3 Creating Applications with node-webkit

      +

      28.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -422,12 +422,12 @@ open new windows, and many more things. }; -

      27.4 Examples

      +

      28.4 Examples

      Some basic examples are shown here in more detail.

      -

      27.4.1 Simple

      +

      28.4.1 Simple

      The common example simple looks like this:

      @@ -477,7 +477,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      27.4.2 Class

      +

      28.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -607,12 +607,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      27.5 Implementation

      +

      28.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      27.5.1 Source Code

      +

      28.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -713,7 +713,7 @@ Template::Template(const String *code_) { ... } ... -

      27.5.2 Code Templates

      +

      28.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -752,7 +752,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      27.5.3 Emitter

      +

      28.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -871,7 +871,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      27.5.4 Emitter states

      +

      28.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -915,7 +915,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      27.5.5 Handling Exceptions in JavascriptCore

      +

      28.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 0d9e3dc4f..7ea6fb1b9 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -7,7 +7,7 @@ -

      28 SWIG and Common Lisp

      +

      29 SWIG and Common Lisp

      -

      28.2.3 Generating CFFI bindings for C++ code

      +

      29.2.3 Generating CFFI bindings for C++ code

      This feature to SWIG (for CFFI) is very new and still far from @@ -582,7 +582,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. -

      28.2.4 Inserting user code into generated files

      +

      29.2.4 Inserting user code into generated files

      @@ -622,7 +622,7 @@ Note that the block %{ ... %} is effectively a shortcut for

      -

      28.3 CLISP

      +

      29.3 CLISP

      @@ -652,7 +652,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.

      -

      28.3.1 Additional Commandline Options

      +

      29.3.1 Additional Commandline Options

      @@ -685,7 +685,7 @@ shortcuts according to the typedefs in the input. -

      28.3.2 Details on CLISP bindings

      +

      29.3.2 Details on CLISP bindings

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

      28.4 UFFI

      +

      29.4 UFFI

      diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 8e545776f..944223f3c 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

      29 SWIG and Lua

      +

      30 SWIG and Lua

        @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

        -

        29.1 Preliminaries

        +

        30.1 Preliminaries

        The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

        -

        29.2 Running SWIG

        +

        30.2 Running SWIG

        @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

        -

        29.2.1 Additional command line options

        +

        30.2.1 Additional command line options

        @@ -179,7 +179,7 @@ swig -lua -help -

        29.2.2 Compiling and Linking and Interpreter

        +

        30.2.2 Compiling and Linking and Interpreter

        @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

        -

        29.2.3 Compiling a dynamic module

        +

        30.2.3 Compiling a dynamic module

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

        29.2.4 Using your module

        +

        30.2.4 Using your module

        @@ -336,19 +336,19 @@ $ ./my_lua >

      -

      29.3 A tour of basic C/C++ wrapping

      +

      30.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.

      -

      29.3.1 Modules

      +

      30.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.

      -

      29.3.2 Functions

      +

      30.3.2 Functions

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

      29.3.3 Global variables

      +

      30.3.3 Global variables

      @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

      -

      29.3.4 Constants and enums

      +

      30.3.4 Constants and enums

      @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

      29.3.4.1 Constants/enums and classes/structures

      +

      30.3.4.1 Constants/enums and classes/structures

      @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

      -

      29.3.5 Pointers

      +

      30.3.5 Pointers

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

      29.3.6 Structures

      +

      30.3.6 Structures

      @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

      -

      29.3.7 C++ classes

      +

      30.3.7 C++ classes

      @@ -785,7 +785,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

      -

      29.3.8 C++ inheritance

      +

      30.3.8 C++ inheritance

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

      It is safe to use multiple inheritance with SWIG.

      -

      29.3.9 Pointers, references, values, and arrays

      +

      30.3.9 Pointers, references, values, and arrays

      @@ -841,7 +841,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.

      -

      29.3.10 C++ overloaded functions

      +

      30.3.10 C++ overloaded functions

      @@ -927,7 +927,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.

      -

      29.3.11 C++ operators

      +

      30.3.11 C++ operators

      @@ -1059,7 +1059,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    29.3.12 Class extension with %extend

    +

    30.3.12 Class extension with %extend

    @@ -1116,7 +1116,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).

    -

    29.3.13 Using %newobject to release memory

    +

    30.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1140,7 +1140,7 @@ char *foo();

    This will release the allocated memory.

    -

    29.3.14 C++ templates

    +

    30.3.14 C++ templates

    @@ -1175,7 +1175,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.

    -

    29.3.15 C++ Smart Pointers

    +

    30.3.15 C++ Smart Pointers

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

    29.3.16 C++ Exceptions

    +

    30.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    29.3.17 Namespaces

    +

    30.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    29.3.17.1 Compatibility Note

    +

    30.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    29.3.17.2 Names

    +

    30.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    29.3.17.3 Inheritance

    +

    30.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    29.4 Typemaps

    +

    30.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    29.4.1 What is a typemap?

    +

    30.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:

    @@ -1555,7 +1555,7 @@ Received an integer : 6 720 -

    29.4.2 Using typemaps

    +

    30.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.

    @@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);

    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).

    -

    29.4.3 Typemaps and arrays

    +

    30.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 @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

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

    -

    29.4.4 Typemaps and pointer-pointer functions

    +

    30.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:

    @@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    29.5 Writing typemaps

    +

    30.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.

    @@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    29.5.1 Typemaps you can write

    +

    30.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.

    @@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    29.5.2 SWIG's Lua-C API

    +

    30.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.

    @@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    29.6 Customization of your Bindings

    +

    30.6 Customization of your Bindings

    @@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -

    29.6.1 Writing your own custom wrappers

    +

    30.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    29.6.2 Adding additional Lua code

    +

    30.6.2 Adding additional Lua code

    @@ -1843,7 +1843,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.

    -

    29.7 Details on the Lua binding

    +

    30.7 Details on the Lua binding

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

    -

    29.7.1 Binding global data into the module.

    +

    30.7.1 Binding global data into the module.

    @@ -1914,7 +1914,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)'.

    -

    29.7.2 Userdata and Metatables

    +

    30.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    29.7.3 Memory management

    +

    30.7.3 Memory management

    diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index bdfc5992d..fc4ffa03c 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -6,7 +6,7 @@ -

    30 SWIG and Modula-3

    +

    31 SWIG and Modula-3

    -

    30.4.5 Exceptions

    +

    31.4.5 Exceptions

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

    -

    30.4.6 Example

    +

    31.4.6 Example

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

    30.5 More hints to the generator

    +

    31.5 More hints to the generator

    -

    30.5.1 Features

    +

    31.5.1 Features

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

    30.5.2 Pragmas

    +

    31.5.2 Pragmas

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

    30.6 Remarks

    +

    31.6 Remarks

    -

    40.4.5 STL

    +

    41.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    40.5 Module initialization

    +

    41.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    40.6 Building modes

    +

    41.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    40.6.1 No-builder mode

    +

    41.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    40.6.2 Builder mode

    +

    41.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    40.7 Generated scripts

    +

    41.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    40.7.1 Builder script

    +

    41.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    40.7.2 Loader script

    +

    41.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    40.8 Other resources

    +

    41.8 Other resources

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index de9ff5841..08d1aef94 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -18,8 +18,8 @@
  • doxygen:notranslate
  • doxygen:alias:<command-name>
  • doxygen:ignore:<command-name> -
  • doxygen:nolinktranslate (Java-only currently) -
  • doxygen:nostripparams (Java-only currently) +
  • doxygen:nolinktranslate +
  • doxygen:nostripparams
  • Additional command line options @@ -416,20 +416,22 @@ def func(): -

    16.2.2.4 doxygen:nolinktranslate (Java-only currently)

    +

    16.2.2.4 doxygen:nolinktranslate

    Turn off automatic link-objects translation. +This is only applicable to Java at the moment.

    -

    16.2.2.5 doxygen:nostripparams (Java-only currently)

    +

    16.2.2.5 doxygen:nostripparams

    Turn off stripping of @param and @tparam Doxygen commands if the parameter is not found in the function signature. +This is only applicable to Java at the moment.

    From cbaf6eb2b3b04fd75b152d94f9baa806aa698ab9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 19:18:55 +0100 Subject: [PATCH 0963/2031] Clean up merge problem --- Examples/test-suite/java/Makefile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index e3333692c..f1717b81b 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -76,7 +76,6 @@ java_nspacewithoutpackage.%: JAVA_PACKAGEOPT = multiple_inheritance_nspace.%: JAVA_PACKAGE = $*Package nspace.%: JAVA_PACKAGE = $*Package nspace_extend.%: JAVA_PACKAGE = $*Package -doxygen_misc_constructs.%: INCLUDES = -I../$(srcdir)/.. # Rules for the different types of tests %.cpptest: From 95caf875960d53adf4e79fcb5e157760d94ecfb8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 19:28:15 +0100 Subject: [PATCH 0964/2031] PEP8 conformance for comment verifier module --- Examples/test-suite/python/autodoc_runme.py | 4 +-- ...commentVerifier.py => comment_verifier.py} | 0 .../test-suite/python/doxygen_alias_runme.py | 4 +-- .../python/doxygen_basic_notranslate_runme.py | 16 +++++----- .../python/doxygen_basic_translate_runme.py | 18 +++++------ .../test-suite/python/doxygen_ignore_runme.py | 4 +-- .../python/doxygen_misc_constructs_runme.py | 30 +++++++++---------- .../python/doxygen_parsing_runme.py | 22 +++++++------- .../doxygen_translate_all_tags_runme.py | 22 +++++++------- .../python/doxygen_translate_links_runme.py | 4 +-- .../python/doxygen_translate_runme.py | 10 +++---- 11 files changed, 67 insertions(+), 67 deletions(-) rename Examples/test-suite/python/{commentVerifier.py => comment_verifier.py} (100%) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 7635f6c4a..11e499d25 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -1,5 +1,5 @@ from autodoc import * -import commentVerifier +import comment_verifier import inspect import sys @@ -8,7 +8,7 @@ def check(got, expected, expected_builtin=None, skip=False): expect = expected if is_python_builtin() and expected_builtin != None: expect = expected_builtin - commentVerifier.check(got, expect) + comment_verifier.check(got, expect) def is_new_style_class(cls): return hasattr(cls, "__class__") diff --git a/Examples/test-suite/python/commentVerifier.py b/Examples/test-suite/python/comment_verifier.py similarity index 100% rename from Examples/test-suite/python/commentVerifier.py rename to Examples/test-suite/python/comment_verifier.py diff --git a/Examples/test-suite/python/doxygen_alias_runme.py b/Examples/test-suite/python/doxygen_alias_runme.py index 4117f00e5..ad580f719 100644 --- a/Examples/test-suite/python/doxygen_alias_runme.py +++ b/Examples/test-suite/python/doxygen_alias_runme.py @@ -2,9 +2,9 @@ import doxygen_alias import inspect -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_alias.make_something), +comment_verifier.check(inspect.getdoc(doxygen_alias.make_something), """\ A function returning something. diff --git a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py index bf2703c21..17c03e32d 100644 --- a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py @@ -4,9 +4,9 @@ import doxygen_basic_notranslate import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function), r"""\brief Brief description. @@ -16,12 +16,12 @@ The comment text \sa function2""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function2), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function2), r"""A test of a very very very very very very very very very very very very very very very very very very very very very long comment string.""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function3), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function3), r"""*Overload 1:* A test for overloaded functions @@ -35,7 +35,7 @@ A test for overloaded functions This is function \b two""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function4), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function4), r"""A test of some mixed tag usage \if CONDITION This \a code fragment shows us something \. @@ -51,14 +51,14 @@ int main() { while(true); } \endcode \endif""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function5), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function5), r"""This is a post comment. """ ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function6), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function6), r"""Test for default args @param a Some parameter, default is 42""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_notranslate.function7), +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function7), r"""Test for a parameter with difficult type (mostly for python) @param a Very strange param""" diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index f566086e1..1be6b6b07 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -4,9 +4,9 @@ import doxygen_basic_translate import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function), """\ Brief description. @@ -19,12 +19,12 @@ Author: Some author See also: function2""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function2), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function2), """\ A test of a very very very very very very very very very very very very very very very very very very very very very long comment string.""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function3), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function3), """*Overload 1:* A test for overloaded functions @@ -37,7 +37,7 @@ This is function **one** A test for overloaded functions This is function **two**""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function4), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function4), """\ A test of some mixed tag usage If: CONDITION { @@ -56,16 +56,16 @@ Warning: This may not work as expected }""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function5), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5), """This is a post comment.""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function6), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function6), """\ Test for default args :type a: int :param a: Some parameter, default is 42""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.function7), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function7), """\ Test for a parameter with difficult type (mostly for python) @@ -73,7 +73,7 @@ Test for a parameter with difficult type :param a: Very strange param""" ) -commentVerifier.check(inspect.getdoc(doxygen_basic_translate.Atan2), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2), """\ Multiple parameters test. diff --git a/Examples/test-suite/python/doxygen_ignore_runme.py b/Examples/test-suite/python/doxygen_ignore_runme.py index 9e2e73da7..33329d2de 100644 --- a/Examples/test-suite/python/doxygen_ignore_runme.py +++ b/Examples/test-suite/python/doxygen_ignore_runme.py @@ -2,9 +2,9 @@ import doxygen_ignore import inspect -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_ignore.func), +comment_verifier.check(inspect.getdoc(doxygen_ignore.func), """\ A contrived example of ignoring too many commands in one comment. diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py index 316d7e69b..32ee912fd 100644 --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py @@ -4,10 +4,10 @@ import doxygen_misc_constructs import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress), r"""Returns address of file line. :type fileName: int @@ -19,7 +19,7 @@ commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress), Connection::getId() """) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.CConnectionConfig), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.CConnectionConfig), r"""This class contains information for connection to winIDEA. Its methods return reference to self, so we can use it like this: @@ -34,26 +34,26 @@ used for unspecified parameters. advancedWinIDEALaunching.py Python example.""") -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.waitTime), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.waitTime), r"""Determines how long the ``isystem.connect`` should wait for running instances to respond. Only one of ``lfWaitXXX`` flags from IConnect::ELaunchFlags may be specified.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection), r"""This function returns connection id.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter), r'' ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum), r"""Class description.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.showList), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.showList), r"""An example of a list in a documentation comment. - The first item of the list. @@ -66,24 +66,24 @@ commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.showList), And this is not a list item any more.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidA), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidA), r"""This comment without space after '*' is valid in Doxygen.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB), r""".This comment without space after '*' is valid in Doxygen.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC), r'' ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA), r"""Backslash following``word`` is a valid doxygen command. Output contains 'followingword' with 'word' in code font.""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashB), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashB), r"""Doxy command without trailing space is ignored - nothing appears on output. Standalone \ and '\' get to output. Standalone @ and '@' get to output. @@ -98,7 +98,7 @@ Commands for escaped symbols: $ @ \ & ~ < > # % " . :: @text ::text""" ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.backslashC), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashC), r"""Backslash e at end of *line* froze SWIG *with* old comment parser. @@ -107,7 +107,7 @@ See also: MyClass::fun(char, ) -commentVerifier.check(inspect.getdoc(doxygen_misc_constructs.cycle), +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.cycle), r"""The next line contains expression: ['retVal < 10', 'g_counter == 23 && g_mode & 3'] diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index 22ad83020..20e840df5 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -5,20 +5,20 @@ import inspect import string import os import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_parsing.someFunction), +comment_verifier.check(inspect.getdoc(doxygen_parsing.someFunction), "The function comment") -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeClass), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeClass), "The class comment") -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeStruct), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeStruct), "The struct comment") # There doesn't seem to be any way to specify the doc string for __init__ when # using "-builtin" (see http://stackoverflow.com/q/11913492/15275), so skip # this test in this case. if str(os.environ.get('SWIG_FEATURES')).find('-builtin') == -1: - commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.__init__), + comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.__init__), r"""*Overload 1:* First overloaded constructor. @@ -27,11 +27,11 @@ First overloaded constructor. *Overload 2:* Second overloaded constructor.""") -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethod), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethod), r"""The class method comment. SomeAnotherClass#classMethodExtended(int, int) a link text""") -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended), r"""The class method with parameter :type a: int @@ -39,7 +39,7 @@ commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMetho :type b: int :param b: Parameter b""" ) -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended2), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMethodExtended2), r"""The class method with parameter :type a: int @@ -47,9 +47,9 @@ commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.classMetho :type b: int :param b: Parameter b""" ) -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethod), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethod), r"""The struct method comment""") -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended), r"""The struct method with parameter :type a: int @@ -57,7 +57,7 @@ commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMet :type b: int :param b: Parameter b""" ) -commentVerifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended2), +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherStruct.structMethodExtended2), r"""The struct method with parameter :type a: int diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index f26c44328..ed66f4bcd 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -4,10 +4,10 @@ import doxygen_translate_all_tags import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func01), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func01), r"""*Hello* @@ -41,7 +41,7 @@ Not everything works right now... some test code""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func02), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func02), r"""Conditional comment: SOMECONDITION Some conditional comment End of conditional comment. @@ -65,7 +65,7 @@ Deprecated: Now use another function This is very large and detailed description of some thing""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func03), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func03), r"""Comment for **func03()**. @@ -85,7 +85,7 @@ emphazedWord Example: someFile.txt Some details on using the example""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func04), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func04), r""":raises: SuperError @@ -116,7 +116,7 @@ r""":raises: SuperError This will only appear in hmtl""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func05), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func05), r"""If: ANOTHERCONDITION { First part of comment If: SECONDCONDITION { @@ -150,7 +150,7 @@ Image: testImage.bmp("Hello, world!") Some text describing invariant.""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func06), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func06), r"""Comment for **func06()**. @@ -175,7 +175,7 @@ someMember Some description follows This will only appear in man""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func07), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func07), r"""Comment for **func07()**. @@ -204,7 +204,7 @@ Maybe even multiline :type a: int :param a: the first param""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func08), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func08), r"""Text after anchor. @@ -239,7 +239,7 @@ Another remarks section :rtype: void :return: may return""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func09), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func09), r"""This will only appear in RTF @@ -274,7 +274,7 @@ Since: version 0.0.0.1 :raises: RuntimeError""") -commentVerifier.check(inspect.getdoc(doxygen_translate_all_tags.func10), +comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func10), r"""TODO: Some very important task :type b: float diff --git a/Examples/test-suite/python/doxygen_translate_links_runme.py b/Examples/test-suite/python/doxygen_translate_links_runme.py index f0df1ebc1..b7e2b73fa 100644 --- a/Examples/test-suite/python/doxygen_translate_links_runme.py +++ b/Examples/test-suite/python/doxygen_translate_links_runme.py @@ -4,10 +4,10 @@ import doxygen_translate_links import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_translate_links.function), +comment_verifier.check(inspect.getdoc(doxygen_translate_links.function), r"""Testing typenames converting in @ link superFunc(int,std::string) diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 9a2ce53a2..cbdde5fec 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -4,10 +4,10 @@ import doxygen_translate import inspect import string import sys -import commentVerifier +import comment_verifier -commentVerifier.check(inspect.getdoc(doxygen_translate.function), +comment_verifier.check(inspect.getdoc(doxygen_translate.function), r"""*Hello* * some list item @@ -140,7 +140,7 @@ And here goes simple text""" -commentVerifier.check(inspect.getdoc(doxygen_translate.htmlFunction), +comment_verifier.check(inspect.getdoc(doxygen_translate.htmlFunction), r"""Test for html tags. See Doxygen doc for list of tags recognized by Doxygen. This is link ("http://acme.com/index.html") @@ -224,7 +224,7 @@ Starts a piece of text displayed in a typewriter font. underlined \b bold text - doxy commands are ignored inside 'htmlonly' section """) -commentVerifier.check(inspect.getdoc(doxygen_translate.htmlTableFunction), +comment_verifier.check(inspect.getdoc(doxygen_translate.htmlTableFunction), r"""The meaning of flags: :type byFlags: int @@ -240,7 +240,7 @@ r"""The meaning of flags: ``htmlTable...`` functions.""") -commentVerifier.check(inspect.getdoc(doxygen_translate.htmlEntitiesFunction), +comment_verifier.check(inspect.getdoc(doxygen_translate.htmlEntitiesFunction), r"""All entities are treated as commands (C) TM (R) should work also From 7d1578e58cd57199e5f9c48b38afefaa2ac89bf5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 May 2018 20:00:03 +0100 Subject: [PATCH 0965/2031] Add omitted doxygen_parsing_enums testcase Still needs a Python runtime test --- Examples/test-suite/common.mk | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e94ff7b02..520c1bbfe 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -607,15 +607,16 @@ $(eval HAS_DOXYGEN := $($(LANGUAGE)_HAS_DOXYGEN)) ifdef HAS_DOXYGEN DOXYGEN_TEST_CASES += \ - doxygen_parsing \ doxygen_alias \ - doxygen_ignore \ - doxygen_basic_translate \ doxygen_basic_notranslate \ + doxygen_basic_translate \ + doxygen_ignore \ + doxygen_misc_constructs \ + doxygen_parsing \ + doxygen_parsing_enums \ doxygen_translate \ doxygen_translate_all_tags \ doxygen_translate_links \ - doxygen_misc_constructs \ $(DOXYGEN_TEST_CASES:=.cpptest): SWIGOPT += -doxygen From 8344aec3a3cd999636f7908667024d5e13de8338 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 May 2018 08:27:47 +0100 Subject: [PATCH 0966/2031] Java enums output format fixes Restore generated Java enum code output to what it was pre-doxygen code changes. Improves code with doxygen comments too. --- Source/Modules/java.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 4a895f308..7a4bc8214 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1373,9 +1373,7 @@ public: } Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements - "\n\n", NIL); - - Printv(f_enum, enum_code, "\n", NIL); + "\n", enum_code, "\n", NIL); Printf(f_enum, "\n"); Delete(f_enum); @@ -1469,6 +1467,11 @@ public: if (!addSymbol(symname, n, scope)) return SWIG_ERROR; + if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { + if (!GetFlag(n, "firstenumitem")) + Printf(enum_code, ",\n"); + } + // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { String *doxygen_comments = doxygenTranslator->getDocumentation(n); @@ -1481,14 +1484,12 @@ public: if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. - Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, "(%s)", value); Delete(value); } - Printf(enum_code, ",\n"); } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); From 448691cfa8bc408bb7b38aba59ad2d66f5f48579 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 May 2018 23:18:57 +0100 Subject: [PATCH 0967/2031] Another merge fix from doxygen branches --- Examples/test-suite/python/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index b26253329..e2aad7c8b 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -167,7 +167,7 @@ convert_testcase = \ $(MAKE) $(SCRIPTDIR)/$(py_runme); \ fi -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(abspath $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)) +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) test x$< = x$@ || cp $< $@ || exit 1 test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1 From d1e0912ac0397bd0c2be697799069c5a6c581ea5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 May 2018 23:35:06 +0100 Subject: [PATCH 0968/2031] Correct source code headers --- Source/DoxygenTranslator/src/DoxygenCommands.h | 12 ++++++++++++ Source/DoxygenTranslator/src/DoxygenEntity.cpp | 4 ++-- Source/DoxygenTranslator/src/DoxygenEntity.h | 2 +- Source/DoxygenTranslator/src/DoxygenParser.cpp | 4 ++-- Source/DoxygenTranslator/src/DoxygenParser.h | 2 +- Source/DoxygenTranslator/src/DoxygenTranslator.cpp | 4 ++-- Source/DoxygenTranslator/src/DoxygenTranslator.h | 2 +- Source/DoxygenTranslator/src/JavaDocConverter.cpp | 4 ++-- Source/DoxygenTranslator/src/JavaDocConverter.h | 2 +- Source/DoxygenTranslator/src/PyDocConverter.cpp | 4 ++-- Source/DoxygenTranslator/src/PyDocConverter.h | 2 +- 11 files changed, 27 insertions(+), 15 deletions(-) diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/DoxygenTranslator/src/DoxygenCommands.h index 0be6a1851..eca148a50 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/DoxygenTranslator/src/DoxygenCommands.h @@ -1,3 +1,15 @@ +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * + * DoxygenCommands.h + * + * Part of the Doxygen comment translation module of SWIG. + * ----------------------------------------------------------------------------- */ #ifndef DOXYGENCOMMANDS_H #define DOXYGENCOMMANDS_H diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index 98329e84f..7e977ee9b 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -1,5 +1,5 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h index 29a0e2076..3c243462c 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index c14cdb9fd..4c7bcdd1c 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -1,5 +1,5 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 35204e670..ec5e24cc2 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 111822660..bd5963973 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -1,5 +1,5 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index ae7c211ba..35e521898 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 90da0eb1a..c2fd8577e 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,5 +1,5 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index df579e625..100a77818 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index b6aaa2d91..5edf7fa18 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -1,5 +1,5 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 +/* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index b78d81ed3..88e8f1f91 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files From 823465649714f37b6e929c239542f43d950bea4c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 May 2018 23:35:28 +0100 Subject: [PATCH 0969/2031] Correct python example headers --- Examples/test-suite/python/doxygen_alias_runme.py | 2 -- Examples/test-suite/python/doxygen_basic_notranslate_runme.py | 2 -- Examples/test-suite/python/doxygen_basic_translate_runme.py | 2 -- Examples/test-suite/python/doxygen_ignore_runme.py | 2 -- Examples/test-suite/python/doxygen_misc_constructs_runme.py | 2 -- Examples/test-suite/python/doxygen_parsing_runme.py | 2 -- Examples/test-suite/python/doxygen_translate_all_tags_runme.py | 2 -- Examples/test-suite/python/doxygen_translate_links_runme.py | 2 -- Examples/test-suite/python/doxygen_translate_runme.py | 2 -- 9 files changed, 18 deletions(-) diff --git a/Examples/test-suite/python/doxygen_alias_runme.py b/Examples/test-suite/python/doxygen_alias_runme.py index ad580f719..505261bcd 100644 --- a/Examples/test-suite/python/doxygen_alias_runme.py +++ b/Examples/test-suite/python/doxygen_alias_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_alias import inspect import comment_verifier diff --git a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py index 17c03e32d..81ac99975 100644 --- a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_basic_notranslate import inspect import string diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 1be6b6b07..e664e06f6 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_basic_translate import inspect import string diff --git a/Examples/test-suite/python/doxygen_ignore_runme.py b/Examples/test-suite/python/doxygen_ignore_runme.py index 33329d2de..9a7b2e5df 100644 --- a/Examples/test-suite/python/doxygen_ignore_runme.py +++ b/Examples/test-suite/python/doxygen_ignore_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_ignore import inspect import comment_verifier diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py index 32ee912fd..c441c3dfe 100644 --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_misc_constructs import inspect import string diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index 20e840df5..14579281d 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_parsing import inspect import string diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index ed66f4bcd..53d087e69 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_translate_all_tags import inspect import string diff --git a/Examples/test-suite/python/doxygen_translate_links_runme.py b/Examples/test-suite/python/doxygen_translate_links_runme.py index b7e2b73fa..89f276f6e 100644 --- a/Examples/test-suite/python/doxygen_translate_links_runme.py +++ b/Examples/test-suite/python/doxygen_translate_links_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_translate_links import inspect import string diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index cbdde5fec..2d0840a1f 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import doxygen_translate import inspect import string From 0ae73a67ff4ceed3a70991fbd05c7f93305f31be Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 May 2018 23:36:24 +0100 Subject: [PATCH 0970/2031] More merge fixes from doxygen branches --- Examples/php/reference/runme-proxy.php4 | 79 ------------------------ Examples/php/variables/runme.php4.old | 80 ------------------------- 2 files changed, 159 deletions(-) delete mode 100644 Examples/php/reference/runme-proxy.php4 delete mode 100644 Examples/php/variables/runme.php4.old diff --git a/Examples/php/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4 deleted file mode 100644 index 9d216f78b..000000000 --- a/Examples/php/reference/runme-proxy.php4 +++ /dev/null @@ -1,79 +0,0 @@ -print() . "\n"; -print " Created b: $b " . $b->print() . "\n"; - -# ----- Call an overloaded operator ----- - -# This calls the wrapper we placed around -# -# operator+(const Vector &a, const Vector &) -# -# It returns a new allocated object. - -print "Adding a+b\n"; -$c = addv($a,$b); -print " a+b =". $c->print()."\n"; - -# Note: Unless we free the result, a memory leak will occur -$c = 0; - -# ----- Create a vector array ----- - -# Note: Using the high-level interface here -print "Creating an array of vectors\n"; -$va = new VectorArray(10); - -print " va: $va size=".$va->size()."\n"; - -# ----- Set some values in the array ----- - -# These operators copy the value of $a and $b to the vector array -$va->set(0,$a); -$va->set(1,$b); - -$va->get(0); -# This will work, but it will cause a memory leak! - -$va->set(2,addv($a,$b)); - -# The non-leaky way to do it - -$c = addv($a,$b); -$va->set(3,$c); -$c = NULL; - -# Get some values from the array - -print "Getting some array values\n"; -for ($i = 0; $i < 5; $i++) { -print "do $i\n"; - $v = $va->get($i); - print " va($i) = ". $v->print(). "\n"; -} - -# Watch under resource meter to check on this -#print "Making sure we don't leak memory.\n"; -#for ($i = 0; $i < 1000000; $i++) { -# $c = VectorArray_get($va,$i % 10); -#} - -# ----- Clean up ----- -print "Cleaning up\n"; -# wants fixing FIXME -#delete_VectorArray($va); -#delete_Vector($a); -#delete_Vector($b); - -?> diff --git a/Examples/php/variables/runme.php4.old b/Examples/php/variables/runme.php4.old deleted file mode 100644 index 9a6bfb386..000000000 --- a/Examples/php/variables/runme.php4.old +++ /dev/null @@ -1,80 +0,0 @@ - - From ac85784a76066870b47ea624ccd155098ec0c4ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 26 May 2018 12:52:52 +0100 Subject: [PATCH 0971/2031] Doxygen source rename Source/DoxygenTranslator/src directory is renamed Source/Doxygen Renamed files in this directory to short names using lowercase as is the convention for the rest of the SWIG source. C++ extension is also .cxx like other SWIG source code. I used doxy as the prefix for most file renames because without this Doxygen/parser.* would be easily confused with CParse/parser.* so Doxygen/doxyparser.* is renamed from DoxygenTranslator/src/DoxygenParser.* --- Doc/Devel/plan-gsoc-2012.txt | 2 +- Doc/Manual/Doxygen.html | 2 +- .../doxycommands.h} | 2 +- .../doxyentity.cxx} | 4 ++-- .../DoxygenEntity.h => Doxygen/doxyentity.h} | 2 +- .../doxyparser.cxx} | 8 +++---- .../DoxygenParser.h => Doxygen/doxyparser.h} | 4 ++-- .../doxytranslator.cxx} | 4 ++-- .../doxytranslator.h} | 6 ++--- .../javadoc.cxx} | 8 +++---- .../JavaDocConverter.h => Doxygen/javadoc.h} | 4 ++-- .../PyDocConverter.cpp => Doxygen/pydoc.cxx} | 6 ++--- .../src/PyDocConverter.h => Doxygen/pydoc.h} | 6 ++--- Source/Makefile.am | 24 +++++++++---------- Source/Modules/java.cxx | 2 +- Source/Modules/python.cxx | 2 +- 16 files changed, 43 insertions(+), 43 deletions(-) rename Source/{DoxygenTranslator/src/DoxygenCommands.h => Doxygen/doxycommands.h} (99%) rename Source/{DoxygenTranslator/src/DoxygenEntity.cpp => Doxygen/doxyentity.cxx} (97%) rename Source/{DoxygenTranslator/src/DoxygenEntity.h => Doxygen/doxyentity.h} (98%) rename Source/{DoxygenTranslator/src/DoxygenParser.cpp => Doxygen/doxyparser.cxx} (99%) rename Source/{DoxygenTranslator/src/DoxygenParser.h => Doxygen/doxyparser.h} (99%) rename Source/{DoxygenTranslator/src/DoxygenTranslator.cpp => Doxygen/doxytranslator.cxx} (96%) rename Source/{DoxygenTranslator/src/DoxygenTranslator.h => Doxygen/doxytranslator.h} (96%) rename Source/{DoxygenTranslator/src/JavaDocConverter.cpp => Doxygen/javadoc.cxx} (99%) rename Source/{DoxygenTranslator/src/JavaDocConverter.h => Doxygen/javadoc.h} (99%) rename Source/{DoxygenTranslator/src/PyDocConverter.cpp => Doxygen/pydoc.cxx} (99%) rename Source/{DoxygenTranslator/src/PyDocConverter.h => Doxygen/pydoc.h} (98%) diff --git a/Doc/Devel/plan-gsoc-2012.txt b/Doc/Devel/plan-gsoc-2012.txt index 51d387d3c..ac764fb2a 100644 --- a/Doc/Devel/plan-gsoc-2012.txt +++ b/Doc/Devel/plan-gsoc-2012.txt @@ -321,7 +321,7 @@ make doxygen_tricky_constructs.cpptest -s Refactoring =========== -All the code in directory _DoxygenTranslator_ should be refactored: +All the code in directory _Doxygen_ should be refactored: -OK- all methods should be class members -OK- most static methods should be normal members -OK- replace C arrays of strings and sequential searches with STL data diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 08d1aef94..842f146d8 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -1741,7 +1741,7 @@ Searching for "doxygen" in the java.cxx module can give you a good idea of the p The basic gist is that anywhere a comment may reside on a node, there needs to be a catch for it in front of where that function, class, or other object is written out to a target language file. The other half of extension is building a target documentation language comment generator that handles one blob at a time. However, this is relatively simple and nowhere near as complex as the wrapper generating modules in SWIG. -See DoxygenTranslator/JavaDocConverter.cpp for a good example. +See Source/Doxygen/javadoc.cxx for a good example. The target language module passes the Doxygen Translator the blob to translate, and receives back the translated text.

    diff --git a/Source/DoxygenTranslator/src/DoxygenCommands.h b/Source/Doxygen/doxycommands.h similarity index 99% rename from Source/DoxygenTranslator/src/DoxygenCommands.h rename to Source/Doxygen/doxycommands.h index eca148a50..1f7b5fa5b 100644 --- a/Source/DoxygenTranslator/src/DoxygenCommands.h +++ b/Source/Doxygen/doxycommands.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenCommands.h + * doxycommands.h * * Part of the Doxygen comment translation module of SWIG. * ----------------------------------------------------------------------------- */ diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/Doxygen/doxyentity.cxx similarity index 97% rename from Source/DoxygenTranslator/src/DoxygenEntity.cpp rename to Source/Doxygen/doxyentity.cxx index 7e977ee9b..8b9f65736 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/Doxygen/doxyentity.cxx @@ -6,12 +6,12 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenEntity.cpp + * doxyentity.cxx * * Part of the Doxygen comment translation module of SWIG. * ----------------------------------------------------------------------------- */ -#include "DoxygenEntity.h" +#include "doxyentity.h" #include using std::cout; diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/Doxygen/doxyentity.h similarity index 98% rename from Source/DoxygenTranslator/src/DoxygenEntity.h rename to Source/Doxygen/doxyentity.h index 3c243462c..93737e604 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/Doxygen/doxyentity.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenEntity.h + * doxyentity.h * * Part of the Doxygen comment translation module of SWIG. * ----------------------------------------------------------------------------- */ diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/Doxygen/doxyparser.cxx similarity index 99% rename from Source/DoxygenTranslator/src/DoxygenParser.cpp rename to Source/Doxygen/doxyparser.cxx index 4c7bcdd1c..558b0401f 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/Doxygen/doxyparser.cxx @@ -6,11 +6,11 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenParser.cpp + * doxyparser.cxx * ----------------------------------------------------------------------------- */ -#include "DoxygenParser.h" -#include "DoxygenCommands.h" +#include "doxyparser.h" +#include "doxycommands.h" #include "swig.h" #include "swigwarn.h" @@ -46,7 +46,7 @@ void DoxygenParser::fillTables() { if (doxygenCommands.size()) return; - // fill in tables with data from DoxygenCommands.h + // fill in tables with data from doxycommands.h for (int i = 0; i < simpleCommandsSize; i++) doxygenCommands[simpleCommands[i]] = SIMPLECOMMAND; diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/Doxygen/doxyparser.h similarity index 99% rename from Source/DoxygenTranslator/src/DoxygenParser.h rename to Source/Doxygen/doxyparser.h index ec5e24cc2..96c71d22f 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/Doxygen/doxyparser.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenParser.h + * doxyparser.h * ----------------------------------------------------------------------------- */ #ifndef DOXYGENPARSER_H_ @@ -19,7 +19,7 @@ #include "swig.h" -#include "DoxygenEntity.h" +#include "doxyentity.h" class DoxygenParser { private: diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/Doxygen/doxytranslator.cxx similarity index 96% rename from Source/DoxygenTranslator/src/DoxygenTranslator.cpp rename to Source/Doxygen/doxytranslator.cxx index bd5963973..2684adcea 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/Doxygen/doxytranslator.cxx @@ -6,13 +6,13 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenTranslator.cpp + * doxytranslator.cxx * * Module to return documentation for nodes formatted for various documentation * systems. * ----------------------------------------------------------------------------- */ -#include "DoxygenTranslator.h" +#include "doxytranslator.h" DoxygenTranslator::DoxygenTranslator(int flags) : m_flags(flags), parser((flags &debug_parser) != 0) { } diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/Doxygen/doxytranslator.h similarity index 96% rename from Source/DoxygenTranslator/src/DoxygenTranslator.h rename to Source/Doxygen/doxytranslator.h index 35e521898..ffc378a7b 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/Doxygen/doxytranslator.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * DoxygenTranslator.h + * doxytranslator.h * * Module to return documentation for nodes formatted for various documentation * systems. @@ -16,8 +16,8 @@ #define DOXYGENTRANSLATOR_H_ #include "swig.h" -#include "DoxygenEntity.h" -#include "DoxygenParser.h" +#include "doxyentity.h" +#include "doxyparser.h" #include #include diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/Doxygen/javadoc.cxx similarity index 99% rename from Source/DoxygenTranslator/src/JavaDocConverter.cpp rename to Source/Doxygen/javadoc.cxx index c2fd8577e..3b81c55a5 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/Doxygen/javadoc.cxx @@ -6,15 +6,15 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * JavaDocConverter.cpp + * javadoc.cxx * ----------------------------------------------------------------------------- */ -#include "JavaDocConverter.h" -#include "DoxygenParser.h" +#include "javadoc.h" +#include "doxyparser.h" #include #include #include -#include "../../Modules/swigmod.h" +#include "swigmod.h" #define APPROX_LINE_LENGTH 64 // characters per line allowed #define TAB_SIZE 8 // current tab size in spaces //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/Doxygen/javadoc.h similarity index 99% rename from Source/DoxygenTranslator/src/JavaDocConverter.h rename to Source/Doxygen/javadoc.h index 100a77818..6feff5295 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/Doxygen/javadoc.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * JavaDocConverter.h + * javadoc.h * * Module to return documentation for nodes formatted for JavaDoc * ----------------------------------------------------------------------------- */ @@ -14,7 +14,7 @@ #ifndef JAVADOCCONVERTER_H_ #define JAVADOCCONVERTER_H_ -#include "DoxygenTranslator.h" +#include "doxytranslator.h" #include /* diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/Doxygen/pydoc.cxx similarity index 99% rename from Source/DoxygenTranslator/src/PyDocConverter.cpp rename to Source/Doxygen/pydoc.cxx index 5edf7fa18..0f8484d6b 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/Doxygen/pydoc.cxx @@ -6,13 +6,13 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * PyDocConverter.cpp + * pydoc.cxx * * Module to return documentation for nodes formatted for PyDoc * ----------------------------------------------------------------------------- */ -#include "PyDocConverter.h" -#include "DoxygenParser.h" +#include "pydoc.h" +#include "doxyparser.h" #include #include #include diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/Doxygen/pydoc.h similarity index 98% rename from Source/DoxygenTranslator/src/PyDocConverter.h rename to Source/Doxygen/pydoc.h index 88e8f1f91..8f432fd18 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/Doxygen/pydoc.h @@ -6,7 +6,7 @@ * included with the SWIG source code as distributed by the SWIG developers * and at http://www.swig.org/legal.html. * - * PyDocConverter.h + * pydoc.h * * Module to return documentation for nodes formatted for PyDoc * ----------------------------------------------------------------------------- */ @@ -17,8 +17,8 @@ #include #include #include "swig.h" -#include "DoxygenEntity.h" -#include "DoxygenTranslator.h" +#include "doxyentity.h" +#include "doxytranslator.h" #define DOC_STRING_LENGTH 64 // characters per line allowed #define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type diff --git a/Source/Makefile.am b/Source/Makefile.am index b1d6359b0..df3d4b75f 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -34,6 +34,16 @@ eswig_SOURCES = CParse/cscanner.c \ DOH/memory.c \ DOH/string.c \ DOH/void.c \ + Doxygen/doxyentity.cxx \ + Doxygen/doxyentity.h \ + Doxygen/doxyparser.cxx \ + Doxygen/doxyparser.h \ + Doxygen/doxytranslator.cxx \ + Doxygen/doxytranslator.h \ + Doxygen/javadoc.cxx \ + Doxygen/javadoc.h \ + Doxygen/pydoc.cxx \ + Doxygen/pydoc.h \ Modules/allegrocl.cxx \ Modules/allocate.cxx \ Modules/browser.cxx \ @@ -91,20 +101,10 @@ eswig_SOURCES = CParse/cscanner.c \ Swig/stype.c \ Swig/symbol.c \ Swig/tree.c \ - Swig/typeobj.c \ Swig/typemap.c \ + Swig/typeobj.c \ Swig/typesys.c \ - Swig/wrapfunc.c \ - DoxygenTranslator/src/DoxygenEntity.h\ - DoxygenTranslator/src/DoxygenEntity.cpp\ - DoxygenTranslator/src/DoxygenParser.h\ - DoxygenTranslator/src/DoxygenParser.cpp\ - DoxygenTranslator/src/DoxygenTranslator.h\ - DoxygenTranslator/src/DoxygenTranslator.cpp\ - DoxygenTranslator/src/JavaDocConverter.h\ - DoxygenTranslator/src/JavaDocConverter.cpp\ - DoxygenTranslator/src/PyDocConverter.h\ - DoxygenTranslator/src/PyDocConverter.cpp + Swig/wrapfunc.c bin_PROGRAMS = eswig eswig_LDADD = @SWIGLIBS@ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7a4bc8214..12da307cf 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -15,7 +15,7 @@ #include // for INT_MAX #include "cparse.h" #include -#include "../DoxygenTranslator/src/JavaDocConverter.h" +#include "../Doxygen/javadoc.h" /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 036124837..79edb6532 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -17,7 +17,7 @@ #include #include #include -#include "../DoxygenTranslator/src/PyDocConverter.h" +#include "../Doxygen/pydoc.h" #include #include From d721b4d6391c45cbf008fa1b75f45f06ec985e8c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 20 May 2018 10:31:45 +1200 Subject: [PATCH 0972/2031] Fix comment typo "aruments" --- Source/Modules/ocaml.cxx | 2 +- Source/Modules/perl5.cxx | 2 +- Source/Modules/python.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index d42bd4684..cfdb31ebd 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1592,7 +1592,7 @@ public: /* * Python method may return a simple object, or a tuple. - * for in/out aruments, we have to extract the appropriate values from the + * for in/out arguments, we have to extract the appropriate values from the * argument list, then marshal everything back to C/C++ (return value and * output arguments). */ diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 81fb32121..4d2db6ec2 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2354,7 +2354,7 @@ public: /* * Python method may return a simple object, or a tuple. - * for in/out aruments, we have to extract the appropriate PyObjects from the tuple, + * for in/out arguments, we have to extract the appropriate PyObjects from the tuple, * then marshal everything back to C/C++ (return value and output arguments). * */ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 57a5347cb..c745b95f2 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -5668,7 +5668,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { /* * Python method may return a simple object, or a tuple. - * for in/out aruments, we have to extract the appropriate PyObjects from the tuple, + * for in/out arguments, we have to extract the appropriate PyObjects from the tuple, * then marshal everything back to C/C++ (return value and output arguments). * */ From 7d11c2901e55829c760f420ed20cc9b62ee8f00c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 29 May 2018 09:07:25 +1200 Subject: [PATCH 0973/2031] Drop no longer needed warning suppression for clang 74345c92e47938a75817eff5ba48dc9d3ce2a281 fixed the underlying problem for Python, and it was fixed for other affected languages shortly after - see https://github.com/swig/swig/pull/1027 --- Examples/test-suite/li_std_vector_extra.i | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 531898a0e..114de3f11 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -12,17 +12,6 @@ #include #include #include - - -#if defined(__clang__) -// Suppress: -// warning: destination for this 'memset' call is a pointer to dynamic class -// 'Test::B'; vtable pointer will be overwritten [-Wdynamic-class-memaccess] -// memset(v_def,0,sizeof(Type)); -// Better generated code is probably needed though -#pragma clang diagnostic ignored "-Wdynamic-class-memaccess" -#endif - %} namespace std { From ec2cb809cd57b26ad2468894d7266c2ff7ddadc1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 May 2018 06:59:26 +0100 Subject: [PATCH 0974/2031] Add Doxygen to include paths --- Source/Makefile.am | 1 + Source/Modules/java.cxx | 2 +- Source/Modules/python.cxx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Makefile.am b/Source/Makefile.am index df3d4b75f..845fc33fd 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -13,6 +13,7 @@ AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/DOH \ -I$(SOURCE_DIR)/CParse \ + -I$(SOURCE_DIR)/Doxygen \ -I$(SOURCE_DIR)/Preprocessor \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 12da307cf..0d42ba7d5 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -15,7 +15,7 @@ #include // for INT_MAX #include "cparse.h" #include -#include "../Doxygen/javadoc.h" +#include "javadoc.h" /* Hash type used for upcalls from C/C++ */ typedef DOH UpcallData; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 79edb6532..fae1f66e1 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -17,7 +17,7 @@ #include #include #include -#include "../Doxygen/pydoc.h" +#include "pydoc.h" #include #include From 12e7926ee29d8749545bd2b5a17e5eda72f7ab14 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 May 2018 20:13:52 +0100 Subject: [PATCH 0975/2031] Doxygen example Replace the unnecessarily large number of doxygen examples with one doxygen example. --- .../doxygencomments/java/callback/Makefile | 18 -- .../doxygencomments/java/callback/example.cxx | 4 - .../doxygencomments/java/callback/example.h | 27 --- .../doxygencomments/java/callback/example.i | 14 -- .../doxygencomments/java/callback/index.html | 20 -- .../doxygencomments/java/callback/main.java | 56 ----- Examples/doxygencomments/java/check.list | 15 -- Examples/doxygencomments/java/class/Makefile | 18 -- .../doxygencomments/java/class/example.cxx | 28 --- Examples/doxygencomments/java/class/example.h | 51 ----- Examples/doxygencomments/java/class/example.i | 10 - .../doxygencomments/java/class/index.html | 197 ------------------ Examples/doxygencomments/java/class/main.java | 70 ------- .../doxygencomments/java/constants/Makefile | 18 -- .../doxygencomments/java/constants/example.i | 30 --- .../doxygencomments/java/constants/index.html | 52 ----- .../doxygencomments/java/constants/main.java | 44 ---- Examples/doxygencomments/java/enum/Makefile | 18 -- .../doxygencomments/java/enum/example.cxx | 37 ---- Examples/doxygencomments/java/enum/example.h | 23 -- Examples/doxygencomments/java/enum/example.i | 14 -- Examples/doxygencomments/java/enum/index.html | 29 --- Examples/doxygencomments/java/enum/main.java | 38 ---- Examples/doxygencomments/java/extend/Makefile | 18 -- .../doxygencomments/java/extend/example.cxx | 4 - .../doxygencomments/java/extend/example.h | 67 ------ .../doxygencomments/java/extend/example.i | 15 -- .../doxygencomments/java/extend/index.html | 19 -- .../doxygencomments/java/extend/main.java | 88 -------- .../doxygencomments/java/funcptr/Makefile | 18 -- .../doxygencomments/java/funcptr/example.c | 19 -- .../doxygencomments/java/funcptr/example.h | 10 - .../doxygencomments/java/funcptr/example.i | 16 -- .../doxygencomments/java/funcptr/index.html | 91 -------- .../doxygencomments/java/funcptr/main.java | 33 --- Examples/doxygencomments/java/index.html | 65 ------ .../doxygencomments/java/multimap/Makefile | 18 -- .../doxygencomments/java/multimap/example.c | 53 ----- .../doxygencomments/java/multimap/example.dsp | 158 -------------- .../doxygencomments/java/multimap/example.i | 109 ---------- .../doxygencomments/java/multimap/main.java | 40 ---- Examples/doxygencomments/java/native/Makefile | 18 -- .../doxygencomments/java/native/example.i | 67 ------ .../doxygencomments/java/native/index.html | 33 --- .../doxygencomments/java/native/main.java | 19 -- .../doxygencomments/java/pointer/Makefile | 18 -- .../doxygencomments/java/pointer/example.c | 16 -- .../doxygencomments/java/pointer/example.i | 38 ---- .../doxygencomments/java/pointer/index.html | 165 --------------- .../doxygencomments/java/pointer/main.java | 55 ----- .../doxygencomments/java/reference/Makefile | 18 -- .../java/reference/example.cxx | 46 ---- .../doxygencomments/java/reference/example.h | 26 --- .../doxygencomments/java/reference/example.i | 58 ------ .../doxygencomments/java/reference/index.html | 147 ------------- .../doxygencomments/java/reference/main.java | 79 ------- Examples/doxygencomments/java/simple/Makefile | 18 -- .../doxygencomments/java/simple/example.c | 18 -- .../doxygencomments/java/simple/example.dsp | 158 -------------- .../doxygencomments/java/simple/example.i | 11 - .../doxygencomments/java/simple/index.html | 108 ---------- .../doxygencomments/java/simple/main.java | 32 --- .../doxygencomments/java/template/Makefile | 18 -- .../doxygencomments/java/template/example.h | 39 ---- .../doxygencomments/java/template/example.i | 17 -- .../doxygencomments/java/template/index.html | 102 --------- .../doxygencomments/java/template/main.java | 45 ---- .../doxygencomments/java/typemap/Makefile | 18 -- .../doxygencomments/java/typemap/example.i | 101 --------- .../doxygencomments/java/typemap/index.html | 32 --- .../doxygencomments/java/typemap/main.java | 26 --- .../doxygencomments/java/variables/Makefile | 18 -- .../doxygencomments/java/variables/example.c | 91 -------- .../doxygencomments/java/variables/example.h | 6 - .../doxygencomments/java/variables/example.i | 57 ----- .../doxygencomments/java/variables/index.html | 85 -------- .../doxygencomments/java/variables/main.java | 97 --------- Examples/java/check.list | 1 + Examples/java/doxygen/Makefile | 21 ++ Examples/java/doxygen/example.cxx | 48 +++++ .../java/class => java/doxygen}/example.dsp | 4 +- Examples/java/doxygen/example.h | 107 ++++++++++ Examples/java/doxygen/example.i | 17 ++ Examples/java/doxygen/runme.java | 63 ++++++ 84 files changed, 259 insertions(+), 3574 deletions(-) delete mode 100644 Examples/doxygencomments/java/callback/Makefile delete mode 100644 Examples/doxygencomments/java/callback/example.cxx delete mode 100644 Examples/doxygencomments/java/callback/example.h delete mode 100644 Examples/doxygencomments/java/callback/example.i delete mode 100644 Examples/doxygencomments/java/callback/index.html delete mode 100644 Examples/doxygencomments/java/callback/main.java delete mode 100644 Examples/doxygencomments/java/check.list delete mode 100644 Examples/doxygencomments/java/class/Makefile delete mode 100644 Examples/doxygencomments/java/class/example.cxx delete mode 100644 Examples/doxygencomments/java/class/example.h delete mode 100644 Examples/doxygencomments/java/class/example.i delete mode 100644 Examples/doxygencomments/java/class/index.html delete mode 100644 Examples/doxygencomments/java/class/main.java delete mode 100644 Examples/doxygencomments/java/constants/Makefile delete mode 100644 Examples/doxygencomments/java/constants/example.i delete mode 100644 Examples/doxygencomments/java/constants/index.html delete mode 100644 Examples/doxygencomments/java/constants/main.java delete mode 100644 Examples/doxygencomments/java/enum/Makefile delete mode 100644 Examples/doxygencomments/java/enum/example.cxx delete mode 100644 Examples/doxygencomments/java/enum/example.h delete mode 100644 Examples/doxygencomments/java/enum/example.i delete mode 100644 Examples/doxygencomments/java/enum/index.html delete mode 100644 Examples/doxygencomments/java/enum/main.java delete mode 100644 Examples/doxygencomments/java/extend/Makefile delete mode 100644 Examples/doxygencomments/java/extend/example.cxx delete mode 100644 Examples/doxygencomments/java/extend/example.h delete mode 100644 Examples/doxygencomments/java/extend/example.i delete mode 100644 Examples/doxygencomments/java/extend/index.html delete mode 100644 Examples/doxygencomments/java/extend/main.java delete mode 100644 Examples/doxygencomments/java/funcptr/Makefile delete mode 100644 Examples/doxygencomments/java/funcptr/example.c delete mode 100644 Examples/doxygencomments/java/funcptr/example.h delete mode 100644 Examples/doxygencomments/java/funcptr/example.i delete mode 100644 Examples/doxygencomments/java/funcptr/index.html delete mode 100644 Examples/doxygencomments/java/funcptr/main.java delete mode 100644 Examples/doxygencomments/java/index.html delete mode 100644 Examples/doxygencomments/java/multimap/Makefile delete mode 100644 Examples/doxygencomments/java/multimap/example.c delete mode 100644 Examples/doxygencomments/java/multimap/example.dsp delete mode 100644 Examples/doxygencomments/java/multimap/example.i delete mode 100644 Examples/doxygencomments/java/multimap/main.java delete mode 100644 Examples/doxygencomments/java/native/Makefile delete mode 100644 Examples/doxygencomments/java/native/example.i delete mode 100644 Examples/doxygencomments/java/native/index.html delete mode 100644 Examples/doxygencomments/java/native/main.java delete mode 100644 Examples/doxygencomments/java/pointer/Makefile delete mode 100644 Examples/doxygencomments/java/pointer/example.c delete mode 100644 Examples/doxygencomments/java/pointer/example.i delete mode 100644 Examples/doxygencomments/java/pointer/index.html delete mode 100644 Examples/doxygencomments/java/pointer/main.java delete mode 100644 Examples/doxygencomments/java/reference/Makefile delete mode 100644 Examples/doxygencomments/java/reference/example.cxx delete mode 100644 Examples/doxygencomments/java/reference/example.h delete mode 100644 Examples/doxygencomments/java/reference/example.i delete mode 100644 Examples/doxygencomments/java/reference/index.html delete mode 100644 Examples/doxygencomments/java/reference/main.java delete mode 100644 Examples/doxygencomments/java/simple/Makefile delete mode 100644 Examples/doxygencomments/java/simple/example.c delete mode 100644 Examples/doxygencomments/java/simple/example.dsp delete mode 100644 Examples/doxygencomments/java/simple/example.i delete mode 100644 Examples/doxygencomments/java/simple/index.html delete mode 100644 Examples/doxygencomments/java/simple/main.java delete mode 100644 Examples/doxygencomments/java/template/Makefile delete mode 100644 Examples/doxygencomments/java/template/example.h delete mode 100644 Examples/doxygencomments/java/template/example.i delete mode 100644 Examples/doxygencomments/java/template/index.html delete mode 100644 Examples/doxygencomments/java/template/main.java delete mode 100644 Examples/doxygencomments/java/typemap/Makefile delete mode 100644 Examples/doxygencomments/java/typemap/example.i delete mode 100644 Examples/doxygencomments/java/typemap/index.html delete mode 100644 Examples/doxygencomments/java/typemap/main.java delete mode 100644 Examples/doxygencomments/java/variables/Makefile delete mode 100644 Examples/doxygencomments/java/variables/example.c delete mode 100644 Examples/doxygencomments/java/variables/example.h delete mode 100644 Examples/doxygencomments/java/variables/example.i delete mode 100644 Examples/doxygencomments/java/variables/index.html delete mode 100644 Examples/doxygencomments/java/variables/main.java create mode 100644 Examples/java/doxygen/Makefile create mode 100644 Examples/java/doxygen/example.cxx rename Examples/{doxygencomments/java/class => java/doxygen}/example.dsp (95%) create mode 100644 Examples/java/doxygen/example.h create mode 100644 Examples/java/doxygen/example.i create mode 100644 Examples/java/doxygen/runme.java diff --git a/Examples/doxygencomments/java/callback/Makefile b/Examples/doxygencomments/java/callback/Makefile deleted file mode 100644 index 14c301703..000000000 --- a/Examples/doxygencomments/java/callback/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/callback/example.cxx b/Examples/doxygencomments/java/callback/example.cxx deleted file mode 100644 index 450d75608..000000000 --- a/Examples/doxygencomments/java/callback/example.cxx +++ /dev/null @@ -1,4 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" - diff --git a/Examples/doxygencomments/java/callback/example.h b/Examples/doxygencomments/java/callback/example.h deleted file mode 100644 index a0c5fc4d2..000000000 --- a/Examples/doxygencomments/java/callback/example.h +++ /dev/null @@ -1,27 +0,0 @@ -/* File : example.h */ - -#include -#include - -/*! Let's document class CALLBACK! - /author Alfred - */ -class Callback { -public: - /** Information about Callback */ - virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } - virtual void run() { std::cout << "Callback::run()" << std::endl; } -}; - -/** Let's document class Caller! */ -class Caller { -private: - Callback *_callback; -public: - Caller(): _callback(0) {} - ~Caller() { delCallback(); }/**< Deletes Callback */ - void delCallback() { delete _callback; _callback = 0; } - void setCallback(Callback *cb) { delCallback(); _callback = cb; } - void call() { if (_callback) _callback->run(); } -}; - diff --git a/Examples/doxygencomments/java/callback/example.i b/Examples/doxygencomments/java/callback/example.i deleted file mode 100644 index 5dae4e7c1..000000000 --- a/Examples/doxygencomments/java/callback/example.i +++ /dev/null @@ -1,14 +0,0 @@ -/* File : example.i */ -/** Let's document module Example! */ -%module(directors="1") example -%{ -#include "example.h" -%} - -%include "std_string.i" - -/* turn on director wrapping Callback */ -%feature("director") Callback; - -%include "example.h" - diff --git a/Examples/doxygencomments/java/callback/index.html b/Examples/doxygencomments/java/callback/index.html deleted file mode 100644 index c25452018..000000000 --- a/Examples/doxygencomments/java/callback/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - -SWIG:Examples:java:callback - - - - - -SWIG/Examples/python/extend/ -


    - -

    Implementing C++ callbacks in Java

    - -

    -This example illustrates how to use directors to implement C++ callbacks in Java. -

    - -
    - - diff --git a/Examples/doxygencomments/java/callback/main.java b/Examples/doxygencomments/java/callback/main.java deleted file mode 100644 index 4800f8cc9..000000000 --- a/Examples/doxygencomments/java/callback/main.java +++ /dev/null @@ -1,56 +0,0 @@ -public class main -{ - static { - try { - System.loadLibrary("example"); - } 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[] args) - { - System.out.println("Adding and calling a normal C++ callback"); - System.out.println("----------------------------------------"); - - Caller caller = new Caller(); - Callback callback = new Callback(); - - caller.setCallback(callback); - caller.call(); - caller.delCallback(); - - callback = new JavaCallback(); - - System.out.println(); - System.out.println("Adding and calling a Java callback"); - System.out.println("------------------------------------"); - - caller.setCallback(callback); - caller.call(); - caller.delCallback(); - - // Test that a double delete does not occur as the object has already been deleted from the C++ layer. - // Note that the garbage collector can also call the delete() method via the finalizer (callback.finalize()) - // at any point after here. - callback.delete(); - - System.out.println(); - System.out.println("java exit"); - } -} - -class JavaCallback extends Callback -{ - public JavaCallback() - { - super(); - } - - public void run() - { - System.out.println("JavaCallback.run()"); - } -} - diff --git a/Examples/doxygencomments/java/check.list b/Examples/doxygencomments/java/check.list deleted file mode 100644 index 9728342f2..000000000 --- a/Examples/doxygencomments/java/check.list +++ /dev/null @@ -1,15 +0,0 @@ -# see top-level Makefile.in -callback -class -constants -enum -extend -funcptr -multimap -native -pointer -reference -simple -template -typemap -variables diff --git a/Examples/doxygencomments/java/class/Makefile b/Examples/doxygencomments/java/class/Makefile deleted file mode 100644 index 14c301703..000000000 --- a/Examples/doxygencomments/java/class/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/class/example.cxx b/Examples/doxygencomments/java/class/example.cxx deleted file mode 100644 index 1e8e203dd..000000000 --- a/Examples/doxygencomments/java/class/example.cxx +++ /dev/null @@ -1,28 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area(void) { - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} diff --git a/Examples/doxygencomments/java/class/example.h b/Examples/doxygencomments/java/class/example.h deleted file mode 100644 index ce9af23d3..000000000 --- a/Examples/doxygencomments/java/class/example.h +++ /dev/null @@ -1,51 +0,0 @@ -/*! \file example.h -comments on example.h */ - -/*! This is describing class Shape - \author Bob - \exception some sort of exception - \see OtherShapes() - */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - }; - double x, y; /*!< Important variables */ - void move(double dx, double dy); - virtual double area(void) = 0; /*!< \return the area \exception exception description */ - virtual double perimeter(void) = 0; /*!< \exception exception description - \return the perimeter */ - static int nshapes; /*!< Details about nshapes. */ -}; -/*! This is describing class Circle */ -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { }; - virtual double area(void); /*!< \return the area \exception exception description */ - virtual double perimeter(void); /*!< \exception exception description - \return the perimeter */ -}; - -/*! This is describing class square */ -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { }; /*!< Create square - /param w the width - /exception some description */ - virtual double area(void); - virtual double perimeter(void); -}; - - - - - diff --git a/Examples/doxygencomments/java/class/example.i b/Examples/doxygencomments/java/class/example.i deleted file mode 100644 index 05c0ca2ab..000000000 --- a/Examples/doxygencomments/java/class/example.i +++ /dev/null @@ -1,10 +0,0 @@ -/** File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" - diff --git a/Examples/doxygencomments/java/class/index.html b/Examples/doxygencomments/java/class/index.html deleted file mode 100644 index e9db7e94a..000000000 --- a/Examples/doxygencomments/java/class/index.html +++ /dev/null @@ -1,197 +0,0 @@ - - -SWIG:Examples:java:class - - - - - -SWIG/Examples/java/class/ -
    - -

    Wrapping a simple C++ class

    - -

    -This example illustrates the high level form of C++ class wrapping performed -by SWIG. In this case, a C++ class has a proxy Java class, which -provides access to C++ class members. - -

    The C++ Code

    - -Suppose you have some C++ classes described by the following (and admittedly lame) -header file: - -
    -
    -/* File : example.h */
    -
    -class Shape {
    -public:
    -  Shape() {
    -    nshapes++;
    -  }
    -  virtual ~Shape() {
    -    nshapes--;
    -  };
    -  double  x, y;   
    -  void    move(double dx, double dy);
    -  virtual double area() = 0;
    -  virtual double perimeter() = 0;
    -  static  int nshapes;
    -};
    -
    -class Circle : public Shape {
    -private:
    -  double radius;
    -public:
    -  Circle(double r) : radius(r) { };
    -  virtual double area();
    -  virtual double perimeter();
    -};
    -
    -class Square : public Shape {
    -private:
    -  double width;
    -public:
    -  Square(double w) : width(w) { };
    -  virtual double area();
    -  virtual double perimeter();
    -};
    -
    -
    - -

    The SWIG interface

    - -A simple SWIG interface for this can be built by simply grabbing the header file -like this: - -
    -
    -/* File : example.i */
    -%module example
    -
    -%{
    -#include "example.h"
    -%}
    -
    -/* Let's just grab the original header file here */
    -%include "example.h"
    -
    -
    - -Note: when creating a C++ extension, you must run SWIG with the -c++ option like this: -
    -
    -% swig -c++ -java example.i
    -
    -
    - -

    A sample Java program

    - -Click here to see a Java program that calls the C++ functions from Java. - -

    Key points

    - -
      -
    • To create a new object, you call a constructor like this: - -
      -
      -Circle c = new Circle(10);
      -
      -
      - -

      -

    • To access member data, a pair of accessor functions are used. -For example: - -
      -
      -c.setX(15);        // Set member data
      -x = c.getX();      // Get member data
      -
      -
      - -

      -

    • To invoke a member function, you simply do this - -
      -
      -System.out.println( "The area is " + c.area() );
      -
      -
      - -

      -

    • To invoke a destructor, simply do this - -
      -
      -c.delete();     // Deletes a shape
      -
      -
      - -

      -

    • Static member variables are wrapped with java static get and set access functions. For example: - -
      -
      -n = Shape.getNshapes();     // Get a static data member
      -Shape.setNshapes(13);       // Set a static data member
      -
      -
      - -
    - -

    General Comments

    - -
      -
    • This high-level interface using proxy classes is not the only way to handle C++ code. -A low level interface using c functions to access member variables and member functions is the alternative SWIG -approach. This entails passing around the c pointer or c++ 'this' pointer and as such it is not difficult to crash the JVM. -The abstraction of the underlying pointer by the java proxy classes far better fits the java programming paradigm. - -

      -

    • SWIG *does* know how to properly perform upcasting of objects in an inheritance -hierarchy (including multiple inheritance). However Java classes can only derive from one base class so multiple inheritance -is not implemented. Java classes can implement more than one interface so there is scope for improvement in the future. - -

      -

    • A wide variety of C++ features are not currently supported by SWIG. Here is the -short and incomplete list: - -

      -

        -
      • Overloaded methods and functions. SWIG wrappers don't know how to resolve name -conflicts so you must give an alternative name to any overloaded method name using the -%name directive like this: - -
        -
        -void foo(int a);  
        -%name(foo2) void foo(double a, double b);
        -
        -
        - -

        -

      • Overloaded operators. Not supported at all. The only workaround for this is -to write a helper function. For example: - -
        -
        -%inline %{
        -    Vector *vector_add(Vector *a, Vector *b) {
        -          ... whatever ...
        -    }
        -%}
        -
        -
        - -

        -

      • Namespaces. Not supported at all. Won't be supported until SWIG2.0 (if at all). - -
      -
    - -
    - - diff --git a/Examples/doxygencomments/java/class/main.java b/Examples/doxygencomments/java/class/main.java deleted file mode 100644 index 8ef35db6d..000000000 --- a/Examples/doxygencomments/java/class/main.java +++ /dev/null @@ -1,70 +0,0 @@ -// 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 main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - // ----- Object creation ----- - - System.out.println( "Creating some objects:" ); - Circle c = new Circle(10); - System.out.println( " Created circle " + c ); - Square s = new Square(10); - System.out.println( " Created square " + s ); - - // ----- Access a static member ----- - - System.out.println( "\nA total of " + Shape.getNshapes() + " shapes were created" ); - - // ----- Member data access ----- - - // Notice how we can do this using functions specific to - // the 'Circle' class. - c.setX(20); - c.setY(30); - - // Now use the same functions in the base class - Shape shape = s; - shape.setX(-10); - shape.setY(5); - - System.out.println( "\nHere is their current position:" ); - System.out.println( " Circle = (" + c.getX() + " " + c.getY() + ")" ); - System.out.println( " Square = (" + s.getX() + " " + s.getY() + ")" ); - - // ----- Call some methods ----- - - System.out.println( "\nHere are some properties of the shapes:" ); - Shape[] shapes = {c,s}; - for (int i=0; i - -SWIG:Examples:java:constants - - - - -SWIG/Examples/java/constants/ -
    - -

    Wrapping C Constants

    - -

    -When SWIG encounters C preprocessor macros and C declarations that look like constants, -it creates Java constant with an identical value. Click here -to see a SWIG interface with some constant declarations in it. - - -

    Accessing Constants from Java

    -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 -of the constants contained in the above file.

    -

    Key points

    -
      -
    • The values of preprocessor macros are converted into Java constants. -
    • Types are inferred by syntax (e.g., "3" is an integer and "3.5" is a float). -
    • Character constants such as 'x' are converted into Java strings. -
    • C string literals such as "Hello World" are converted into Java strings. -
    • Macros that are not fully defined are simply ignored. For example: -
      -
      -#define EXTERN extern
      -
      -
      -is ignored because SWIG has no idea what type of variable this would be. - -

      -

    • Expressions are allowed provided that all of their components are defined. Otherwise, the constant is ignored. - -
    • Certain C declarations involving 'const' are also turned into Java constants. -
    • The constants that appear in a SWIG interface file do not have to appear in any sort -of matching C source file since the creation of a constant does not require linkage -to a stored value (i.e., a value held in a C global variable or memory location). -
    - -
    - - - - diff --git a/Examples/doxygencomments/java/constants/main.java b/Examples/doxygencomments/java/constants/main.java deleted file mode 100644 index 7130c3d70..000000000 --- a/Examples/doxygencomments/java/constants/main.java +++ /dev/null @@ -1,44 +0,0 @@ -import java.lang.reflect.*; - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - System.out.println("ICONST = " + example.ICONST + " (should be 42)"); - System.out.println("FCONST = " + example.FCONST + " (should be 2.1828)"); - System.out.println("CCONST = " + example.CCONST + " (should be 'x')"); - System.out.println("CCONST2 = " + example.CCONST2 + " (this should be on a new line)"); - System.out.println("SCONST = " + example.SCONST + " (should be 'Hello World')"); - System.out.println("SCONST2 = " + example.SCONST2 + " (should be '\"Hello World\"')"); - System.out.println("EXPR = " + example.EXPR + " (should be 48.5484)"); - System.out.println("iconst = " + example.iconst + " (should be 37)"); - System.out.println("fconst = " + example.fconst + " (should be 3.14)"); - -// Use reflection to check if these variables are defined: - try - { - System.out.println("EXTERN = " + example.class.getField("EXTERN") + " (Arg! This shouldn't print anything)"); - } - catch (NoSuchFieldException e) - { - System.out.println("EXTERN isn't defined (good)"); - } - - try - { - System.out.println("FOO = " + example.class.getField("FOO") + " (Arg! This shouldn't print anything)"); - } - catch (NoSuchFieldException e) - { - System.out.println("FOO isn't defined (good)"); - } - } -} diff --git a/Examples/doxygencomments/java/enum/Makefile b/Examples/doxygencomments/java/enum/Makefile deleted file mode 100644 index 14c301703..000000000 --- a/Examples/doxygencomments/java/enum/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/enum/example.cxx b/Examples/doxygencomments/java/enum/example.cxx deleted file mode 100644 index df7bb6328..000000000 --- a/Examples/doxygencomments/java/enum/example.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" -#include - -void Foo::enum_test(speed s) { - if (s == IMPULSE) { - printf("IMPULSE speed\n"); - } else if (s == WARP) { - printf("WARP speed\n"); - } else if (s == LUDICROUS) { - printf("LUDICROUS speed\n"); - } else { - printf("Unknown speed\n"); - } -} - -void enum_test(color c, Foo::speed s) { - if (c == RED) { - printf("color = RED, "); - } else if (c == BLUE) { - printf("color = BLUE, "); - } else if (c == GREEN) { - printf("color = GREEN, "); - } else { - printf("color = Unknown color!, "); - } - if (s == Foo::IMPULSE) { - printf("speed = IMPULSE speed\n"); - } else if (s == Foo::WARP) { - printf("speed = WARP speed\n"); - } else if (s == Foo::LUDICROUS) { - printf("speed = LUDICROUS speed\n"); - } else { - printf("speed = Unknown speed!\n"); - } -} diff --git a/Examples/doxygencomments/java/enum/example.h b/Examples/doxygencomments/java/enum/example.h deleted file mode 100644 index 2142d8240..000000000 --- a/Examples/doxygencomments/java/enum/example.h +++ /dev/null @@ -1,23 +0,0 @@ - - -/** This is a block describing enum - */ - -enum color { RED, BLUE, GREEN }; - -/*! This is describing class foo - */ - -class Foo { - public: - Foo() { } - enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; - void enum_test(speed s); -}; - -/*! This is describing enum test -//! \param c the color c -//! \param s the speed - */ - -void enum_test(color c, Foo::speed s); diff --git a/Examples/doxygencomments/java/enum/example.i b/Examples/doxygencomments/java/enum/example.i deleted file mode 100644 index 1f1f9d526..000000000 --- a/Examples/doxygencomments/java/enum/example.i +++ /dev/null @@ -1,14 +0,0 @@ -/** File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/** Force the generated Java code to use the C enum values rather than making a JNI call */ -%javaconst(1); - -/** Let's just grab the original header file here */ - -%include "example.h" - diff --git a/Examples/doxygencomments/java/enum/index.html b/Examples/doxygencomments/java/enum/index.html deleted file mode 100644 index 52c06c5d1..000000000 --- a/Examples/doxygencomments/java/enum/index.html +++ /dev/null @@ -1,29 +0,0 @@ - - -SWIG:Examples:java:enum - - - - - -SWIG/Examples/java/enum/ -
    - -

    Wrapping enumerations

    - -

    -This example tests SWIG's ability to wrap enumerations. -SWIG wraps enums in numerous different ways. The default approach is to wrap -each enum with the typesafe enum pattern. Enums are handled as integers in the JNI layer. -See the documentation for the other approaches for wrapping enums. - - -

    - -
    - - diff --git a/Examples/doxygencomments/java/enum/main.java b/Examples/doxygencomments/java/enum/main.java deleted file mode 100644 index 8646e0087..000000000 --- a/Examples/doxygencomments/java/enum/main.java +++ /dev/null @@ -1,38 +0,0 @@ - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - // Print out the value of some enums - System.out.println("*** color ***"); - System.out.println(" " + color.RED + " = " + color.RED.swigValue()); - System.out.println(" " + color.BLUE + " = " + color.BLUE.swigValue()); - System.out.println(" " + color.GREEN + " = " + color.GREEN.swigValue()); - - System.out.println("\n*** Foo::speed ***"); - System.out.println(" Foo::" + Foo.speed.IMPULSE + " = " + Foo.speed.IMPULSE.swigValue()); - System.out.println(" Foo::" + Foo.speed.WARP + " = " + Foo.speed.WARP.swigValue()); - System.out.println(" Foo::" + Foo.speed.LUDICROUS + " = " + Foo.speed.LUDICROUS.swigValue()); - - System.out.println("\nTesting use of enums with functions\n"); - - example.enum_test(color.RED, Foo.speed.IMPULSE); - example.enum_test(color.BLUE, Foo.speed.WARP); - example.enum_test(color.GREEN, Foo.speed.LUDICROUS); - - System.out.println( "\nTesting use of enum with class method" ); - Foo f = new Foo(); - - f.enum_test(Foo.speed.IMPULSE); - f.enum_test(Foo.speed.WARP); - f.enum_test(Foo.speed.LUDICROUS); - } -} diff --git a/Examples/doxygencomments/java/extend/Makefile b/Examples/doxygencomments/java/extend/Makefile deleted file mode 100644 index 14c301703..000000000 --- a/Examples/doxygencomments/java/extend/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/extend/example.cxx b/Examples/doxygencomments/java/extend/example.cxx deleted file mode 100644 index 450d75608..000000000 --- a/Examples/doxygencomments/java/extend/example.cxx +++ /dev/null @@ -1,4 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" - diff --git a/Examples/doxygencomments/java/extend/example.h b/Examples/doxygencomments/java/extend/example.h deleted file mode 100644 index 9b882fd59..000000000 --- a/Examples/doxygencomments/java/extend/example.h +++ /dev/null @@ -1,67 +0,0 @@ -/* File : example.h */ - -#include -#include -#include -#include -#include - -/**This is describiing class Employee - /author Bob */ -class Employee { -private: - std::string name; -public: - /** Employee - \param n name of Employee - \throws some exception */ - Employee(const char* n): name(n) {} -/**This is describing method getTitle */ - virtual std::string getTitle() { return getPosition() + " " + getName(); } - virtual std::string getName() { return name; } - virtual std::string getPosition() const { return "Employee"; } - virtual ~Employee() { printf("~Employee() @ %p\n", this); } -}; - -/**This is describing class Manager */ -class Manager: public Employee { -public: - Manager(const char* n): Employee(n) {} - virtual std::string getPosition() const { return "Manager"; } -}; - - -class EmployeeList { - std::vector list; -public: - /** Initialises Employee List */ - EmployeeList() { - list.push_back(new Employee("Bob")); - list.push_back(new Employee("Jane")); - list.push_back(new Manager("Ted")); - } - /** Add employee - * \param p employee p - * \return void */ - void addEmployee(Employee *p) { - list.push_back(p); - std::cout << "New employee added. Current employees are:" << std::endl; - std::vector::iterator i; - for (i=list.begin(); i!=list.end(); i++) { - std::cout << " " << (*i)->getTitle() << std::endl; - } - } -/**This is describing class get item */ - const Employee *get_item(int i) { - return list[i]; - } - ~EmployeeList() { - std::vector::iterator i; - std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; - for (i=list.begin(); i!=list.end(); i++) { - delete *i; - } - std::cout << "~EmployeeList empty." << std::endl; - } -}; - diff --git a/Examples/doxygencomments/java/extend/example.i b/Examples/doxygencomments/java/extend/example.i deleted file mode 100644 index c8ec32e09..000000000 --- a/Examples/doxygencomments/java/extend/example.i +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.i */ -%module(directors="1") example -%{ -#include "example.h" -%} - -%include "std_vector.i" -%include "std_string.i" - -/* turn on director wrapping for Manager */ -%feature("director") Employee; -%feature("director") Manager; - -%include "example.h" - diff --git a/Examples/doxygencomments/java/extend/index.html b/Examples/doxygencomments/java/extend/index.html deleted file mode 100644 index c7c2c127d..000000000 --- a/Examples/doxygencomments/java/extend/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - -SWIG:Examples:java:extend - - - - - -SWIG/Examples/java/extend/ -
    - -

    Extending a simple C++ class in Java

    - -

    -This example illustrates the extending of a C++ class with cross language polymorphism. - -


    - - diff --git a/Examples/doxygencomments/java/extend/main.java b/Examples/doxygencomments/java/extend/main.java deleted file mode 100644 index ee3a94ed0..000000000 --- a/Examples/doxygencomments/java/extend/main.java +++ /dev/null @@ -1,88 +0,0 @@ -// This file illustrates the cross language polymorphism using directors. - - -// CEO class, which overrides Employee::getPosition(). - -class CEO extends Manager { - public CEO(String name) { - super(name); - } - public String getPosition() { - return "CEO"; - } - // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory. - public void disownMemory() { - swigCMemOwn = false; - } -} - - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - - // Create an instance of CEO, a class derived from the Java proxy of the - // underlying C++ class. The calls to getName() and getPosition() are standard, - // the call to getTitle() uses the director wrappers to call CEO.getPosition(). - - CEO e = new CEO("Alice"); - System.out.println( e.getName() + " is a " + e.getPosition() ); - System.out.println( "Just call her \"" + e.getTitle() + "\"" ); - System.out.println( "----------------------" ); - - - // Create a new EmployeeList instance. This class does not have a C++ - // director wrapper, but can be used freely with other classes that do. - - EmployeeList list = new EmployeeList(); - - // EmployeeList owns its items, so we must surrender ownership of objects we add. - e.disownMemory(); - list.addEmployee(e); - System.out.println( "----------------------" ); - - // Now we access the first four items in list (three are C++ objects that - // EmployeeList's constructor adds, the last is our CEO). The virtual - // methods of all these instances are treated the same. For items 0, 1, and - // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls - // getPosition which resolves in Java. The call to getPosition is - // slightly different, however, because of the overidden getPosition() call, since - // now the object reference has been "laundered" by passing through - // EmployeeList as an Employee*. Previously, Java resolved the call - // immediately in CEO, but now Java thinks the object is an instance of - // class Employee. So the call passes through the - // Employee proxy class and on to the C wrappers and C++ director, - // eventually ending up back at the Java CEO implementation of getPosition(). - // The call to getTitle() for item 3 runs the C++ Employee::getTitle() - // method, which in turn calls getPosition(). This virtual method call - // passes down through the C++ director class to the Java implementation - // in CEO. All this routing takes place transparently. - - System.out.println( "(position, title) for items 0-3:" ); - - System.out.println( " " + list.get_item(0).getPosition() + ", \"" + list.get_item(0).getTitle() + "\"" ); - System.out.println( " " + list.get_item(1).getPosition() + ", \"" + list.get_item(1).getTitle() + "\"" ); - System.out.println( " " + list.get_item(2).getPosition() + ", \"" + list.get_item(2).getTitle() + "\"" ); - System.out.println( " " + list.get_item(3).getPosition() + ", \"" + list.get_item(3).getTitle() + "\"" ); - System.out.println( "----------------------" ); - - // Time to delete the EmployeeList, which will delete all the Employee* - // items it contains. The last item is our CEO, which gets destroyed as well. - list.delete(); - System.out.println( "----------------------" ); - - // All done. - - System.out.println( "java exit" ); - - } -} diff --git a/Examples/doxygencomments/java/funcptr/Makefile b/Examples/doxygencomments/java/funcptr/Makefile deleted file mode 100644 index 968c92c6c..000000000 --- a/Examples/doxygencomments/java/funcptr/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/funcptr/example.c b/Examples/doxygencomments/java/funcptr/example.c deleted file mode 100644 index 5c4a3dabf..000000000 --- a/Examples/doxygencomments/java/funcptr/example.c +++ /dev/null @@ -1,19 +0,0 @@ -/* File : example.c */ - -int do_op(int a, int b, int (*op)(int,int)) { - return (*op)(a,b); -} - -int add(int a, int b) { - return a+b; -} - -int sub(int a, int b) { - return a-b; -} - -int mul(int a, int b) { - return a*b; -} - -int (*funcvar)(int,int) = add; diff --git a/Examples/doxygencomments/java/funcptr/example.h b/Examples/doxygencomments/java/funcptr/example.h deleted file mode 100644 index 5285737a3..000000000 --- a/Examples/doxygencomments/java/funcptr/example.h +++ /dev/null @@ -1,10 +0,0 @@ -/* file: example.h */ - -extern int do_op(int,int, int (*op)(int,int)); -/*! Describing function add */ -extern int add(int,int); -extern int sub(int,int); -extern int mul(int,int); - -extern int (*funcvar)(int,int); - diff --git a/Examples/doxygencomments/java/funcptr/example.i b/Examples/doxygencomments/java/funcptr/example.i deleted file mode 100644 index 82c3c2201..000000000 --- a/Examples/doxygencomments/java/funcptr/example.i +++ /dev/null @@ -1,16 +0,0 @@ -/* File : example.i */ -%module example -%{ -#include "example.h" -%} - -/** Wrap a function taking a pointer to a function */ -extern int do_op(int a, int b, int (*op)(int, int)); - -/** Now install a bunch of "ops" as constants */ -%constant int (*ADD)(int,int) = add; -%constant int (*SUB)(int,int) = sub; -%constant int (*MUL)(int,int) = mul; - -extern int (*funcvar)(int,int); - diff --git a/Examples/doxygencomments/java/funcptr/index.html b/Examples/doxygencomments/java/funcptr/index.html deleted file mode 100644 index 0ad2be1cf..000000000 --- a/Examples/doxygencomments/java/funcptr/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - -SWIG:Examples:java:funcptr - - - - - -SWIG/Examples/java/funcptr/ -
    - -

    Pointers to Functions

    - -

    -Okay, just what in the heck does SWIG do with a declaration like this? - -

    -
    -int do_op(int a, int b, int (*op)(int, int));
    -
    -
    - -Well, it creates a wrapper as usual. Of course, that does raise some -questions about the third argument (the pointer to a function). - -

    -In this case, SWIG will wrap the function pointer as it does for all other -pointers. However, in order to actually call this function from a Java program, -you will need to pass some kind of C function pointer object. In C, -this is easy, you just supply a function name as an argument like this: - -

    -
    -/* Some callback function */
    -int add(int a, int b) {
    -   return a+b;
    -} 
    -...
    -int r = do_op(x,y,add);
    -
    -
    - -To make this work with SWIG, you will need to do a little extra work. Specifically, -you need to create some function pointer objects using the %constant directive like this: - -
    -
    -%constant(int (*)(int,int)) ADD = add;
    -
    -
    - -Now, in a Java program, you would do this: - -
    -
    -int r = do_op(x,y, example.ADD)
    -
    -
    -where example is the module name. - -

    An Example

    - -Here are some files that illustrate this with a simple example: - - - -

    Notes

    - -
      -
    • The value of a function pointer must correspond to a function written in C or C++. -It is not possible to pass an arbitrary Java function in as a substitute for a C -function pointer. - -

      -

    • A Java function can be used as a C/C++ callback if you write some -clever typemaps and are very careful about how you create your extension. -This is an advanced topic not covered here. -
    - -
    - - - - - - diff --git a/Examples/doxygencomments/java/funcptr/main.java b/Examples/doxygencomments/java/funcptr/main.java deleted file mode 100644 index cf81f92b4..000000000 --- a/Examples/doxygencomments/java/funcptr/main.java +++ /dev/null @@ -1,33 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - - - int a = 37; - int b = 42; - - // Now call our C function with a bunch of callbacks - - System.out.println( "Trying some C callback functions" ); - System.out.println( " a = " + a ); - System.out.println( " b = " + b ); - System.out.println( " ADD(a,b) = " + example.do_op(a,b,example.ADD) ); - System.out.println( " SUB(a,b) = " + example.do_op(a,b,example.SUB) ); - System.out.println( " MUL(a,b) = " + example.do_op(a,b,example.MUL) ); - - System.out.println( "Here is what the C callback function classes are called in Java" ); - System.out.println( " ADD = " + example.ADD.getClass().getName() ); - System.out.println( " SUB = " + example.SUB.getClass().getName() ); - System.out.println( " MUL = " + example.MUL.getClass().getName() ); - } -} diff --git a/Examples/doxygencomments/java/index.html b/Examples/doxygencomments/java/index.html deleted file mode 100644 index d98f9a393..000000000 --- a/Examples/doxygencomments/java/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - -SWIG:Examples:java - - - -

    SWIG Java Examples

    - -

    -The following examples illustrate the use of SWIG with Java. - -

      -
    • simple. A minimal example showing how SWIG can -be used to wrap a C function, a global variable, and a constant. -
    • native. Comparing the manual and the SWIG approach to calling native code. -
    • typemap. Modifying the Java module's default behaviour by using typemaps. -
    • constants. This shows how preprocessor macros and -certain C declarations are turned into constants. -
    • variables. An example showing how to access C global variables. -
    • enum. Wrapping enumerations. -
    • class. How to wrap a simple C++ class. -
    • reference. C++ references. -
    • pointer. Simple pointer handling. -
    • template. C++ templates. -
    • funcptr. Pointers to functions. -
    • callback. C++ callbacks using directors. -
    • extend. Polymorphism using directors. -
    - -

    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 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. -

    -A Unix example: -

    -
    -$ make
    -$ export LD_LIBRARY_PATH=. #ksh 
    -$ java main
    -
    -
    -

    - - - -

    Compatibility

    - -The examples have been extensively tested on the following platforms: - -
      -
    • Solaris -
    • Linux -
    • Cygwin -
    • Windows -
    - -Your mileage may vary. If you experience a problem, please let us know by -contacting us on the mailing lists. - - - - diff --git a/Examples/doxygencomments/java/multimap/Makefile b/Examples/doxygencomments/java/multimap/Makefile deleted file mode 100644 index 968c92c6c..000000000 --- a/Examples/doxygencomments/java/multimap/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/multimap/example.c b/Examples/doxygencomments/java/multimap/example.c deleted file mode 100644 index b8360fa8a..000000000 --- a/Examples/doxygencomments/java/multimap/example.c +++ /dev/null @@ -1,53 +0,0 @@ -/* File : example.c */ -#include -#include -#include - -/* Compute the greatest common divisor of positive integers */ -int gcd(int x, int y) { - int g; - g = y; - while (x > 0) { - g = x; - x = y % x; - y = g; - } - return g; -} - -int gcdmain(int argc, char *argv[]) { - int x,y; - if (argc != 3) { - printf("usage: gcd x y\n"); - return -1; - } - x = atoi(argv[1]); - y = atoi(argv[2]); - printf("gcd(%d,%d) = %d\n", x,y,gcd(x,y)); - return 0; -} - -int count(char *bytes, int len, char c) { - int i; - int count = 0; - for (i = 0; i < len; i++) { - if (bytes[i] == c) count++; - } - return count; -} - -void capitalize(char *str, int len) { - int i; - for (i = 0; i < len; i++) { - str[i] = (char)toupper(str[i]); - } -} - -void circle(double x, double y) { - double a = x*x + y*y; - if (a > 1.0) { - printf("Bad points %g, %g\n", x,y); - } else { - printf("Good points %g, %g\n", x,y); - } -} diff --git a/Examples/doxygencomments/java/multimap/example.dsp b/Examples/doxygencomments/java/multimap/example.dsp deleted file mode 100644 index 8e1f8415e..000000000 --- a/Examples/doxygencomments/java/multimap/example.dsp +++ /dev/null @@ -1,158 +0,0 @@ -# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=example - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "example.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "example - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x809 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Java compile post-build step -PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java -# End Special Build Tool - -!ELSEIF "$(CFG)" == "example - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x809 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Java compile post-build step -PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "example - Win32 Debug" -# Name "example - Win32 Release" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\example.c -# End Source File -# Begin Source File - -SOURCE=.\example_wrap.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\example.i - -!IF "$(CFG)" == "example - Win32 Debug" - -# Begin Custom Build -InputPath=.\example.i -InputName=example - -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - echo In order to function correctly, please ensure the following environment variables are correctly set: - echo JAVA_INCLUDE: %JAVA_INCLUDE% - echo JAVA_BIN: %JAVA_BIN% - echo on - ..\..\..\swig.exe -java $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "example - Win32 Release" - -# Begin Custom Build -InputPath=.\example.i -InputName=example - -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - echo In order to function correctly, please ensure the following environment variables are correctly set: - echo JAVA_INCLUDE: %JAVA_INCLUDE% - echo JAVA_BIN: %JAVA_BIN% - echo on - ..\..\..\swig.exe -java $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# End Target -# End Project diff --git a/Examples/doxygencomments/java/multimap/example.i b/Examples/doxygencomments/java/multimap/example.i deleted file mode 100644 index 8d67282a5..000000000 --- a/Examples/doxygencomments/java/multimap/example.i +++ /dev/null @@ -1,109 +0,0 @@ -/* File : example.i */ -%module example - -%{ -extern int gcd(int x, int y); -extern int gcdmain(int argc, char *argv[]); -extern int count(char *bytes, int len, char c); -extern void capitalize (char *str, int len); -extern void circle (double cx, double cy); -extern int squareCubed (int n, int *OUTPUT); -%} - -extern int gcd(int x, int y); - -%typemap(jni) (int argc, char *argv[]) "jobjectArray" -%typemap(jtype) (int argc, char *argv[]) "String[]" -%typemap(jstype) (int argc, char *argv[]) "String[]" - -%typemap(javain) (int argc, char *argv[]) "$javainput" - -%typemap(in) (int argc, char *argv[]) (jstring *jsarray) { -int i; - - $1 = (*jenv)->GetArrayLength(jenv, $input); - if ($1 == 0) { - SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); - return $null; - } - $2 = (char **) malloc(($1+1)*sizeof(char *)); - jsarray = (jstring *) malloc($1*sizeof(jstring)); - for (i = 0; i < $1; i++) { - jsarray[i] = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, i); - $2[i] = (char *) (*jenv)->GetStringUTFChars(jenv, jsarray[i], 0); - } - $2[i] = 0; -} - -%typemap(argout) (int argc, char *argv[]) "" /* override char *[] default */ - -%typemap(freearg) (int argc, char *argv[]) { -int i; - for (i = 0; i < $1; i++) { - (*jenv)->ReleaseStringUTFChars(jenv, jsarray$argnum[i], $2[i]); - } - free($2); -} - -extern int gcdmain(int argc, char *argv[]); - -%typemap(jni) (char *bytes, int len) "jstring" -%typemap(jtype) (char *bytes, int len) "String" -%typemap(jstype) (char *bytes, int len) "String" - -%typemap(javain) (char *bytes, int len) "$javainput" - -%typemap(in) (char *bytes, int len) { - $1 = ($1_type)(*jenv)->GetStringUTFChars(jenv, $input, 0); - $2 = (*jenv)->GetStringUTFLength(jenv, $input); -} - -%typemap(freearg) (char *bytes, int len) %{ - (*jenv)->ReleaseStringUTFChars(jenv, $input, $1); -%} - -extern int count(char *bytes, int len, char c); - -/* This example shows how to wrap a function that mutates a c string. A one - * element Java string array is used so that the string can be returned modified.*/ - -%typemap(jni) (char *str, int len) "jobjectArray" -%typemap(jtype) (char *str, int len) "String[]" -%typemap(jstype) (char *str, int len) "String[]" - -%typemap(javain) (char *str, int len) "$javainput" - -%typemap(in) (char *str, int len) (jstring js) { - int index = 0; - js = (jstring) (*jenv)->GetObjectArrayElement(jenv, $input, index); - $1 = (char *) (*jenv)->GetStringUTFChars(jenv, js, 0); - $2 = (*jenv)->GetStringUTFLength(jenv, js); -} - -/* Return the mutated string as a modified element in the array. */ -%typemap(argout) (char *str, int len) { - jstring newstring = (*jenv)->NewStringUTF(jenv, $1); - (*jenv)->SetObjectArrayElement(jenv, $input, 0, newstring); -} - -/* Release memory */ -%typemap(freearg) (char *str, int len) { - (*jenv)->ReleaseStringUTFChars(jenv, js$argnum, $1); -} - -extern void capitalize(char *str, int len); - -/* A multi-valued constraint. Force two arguments to lie - inside the unit circle */ - -%typemap(check) (double cx, double cy) { - double a = $1*$1 + $2*$2; - if (a > 1.0) { - SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, "$1_name and $2_name must be in unit circle"); - return; - } -} - -extern void circle(double cx, double cy); - - diff --git a/Examples/doxygencomments/java/multimap/main.java b/Examples/doxygencomments/java/multimap/main.java deleted file mode 100644 index 331ac6b89..000000000 --- a/Examples/doxygencomments/java/multimap/main.java +++ /dev/null @@ -1,40 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - - // Call our gcd() function - int x = 42; - int y = 105; - int g = example.gcd(x,y); - System.out.println("The gcd of " + x + " and " + y + " is " + g); - - // Call the gcdmain() function - String[] args = {"gcdmain","42","105"}; - example.gcdmain(args); - - // Call the count function - System.out.println(example.count("Hello World", 'l')); - - // Call the capitalize function - String[] capitalizeMe = {"hello world"}; - example.capitalize(capitalizeMe); - System.out.println(capitalizeMe[0]); - } -} - - - - - - - diff --git a/Examples/doxygencomments/java/native/Makefile b/Examples/doxygencomments/java/native/Makefile deleted file mode 100644 index 92afbd4d0..000000000 --- a/Examples/doxygencomments/java/native/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/native/example.i b/Examples/doxygencomments/java/native/example.i deleted file mode 100644 index 21bcf528c..000000000 --- a/Examples/doxygencomments/java/native/example.i +++ /dev/null @@ -1,67 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include - -/*! Structure Point */ -typedef struct point { - int x; - int y; -} Point; - -/*! Point_create Description - /param x integer x - /param y some integer y - /return a point */ - -Point *point_create(int x, int y) { - Point *p = (Point *) malloc(sizeof(Point)); - p->x = x; - p->y = y; - - return p; -} - -/*! Point_create Description - /param format the format - /param p some p - /return a character string of the point p */ - -static char *point_toString(char *format, Point *p) { - static char buf[80]; - - sprintf(buf, format, p->x, p->y); - - return buf; -} - -/* this function will be wrapped by SWIG */ -char *point_toString1(Point *p) { - return point_toString("(%d,%d)", p); -} - -/* this one we wrapped manually*/ -JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass jcls, jlong jpoint) { - Point * p; - jstring result; - - (void)jcls; - - p = *(Point **)&jpoint; - - result = (*jenv)->NewStringUTF(jenv, point_toString("[%d,%d]", p)); - - return result; -} -%} - - -Point *point_create(int x, int y); -char *point_toString1(Point *p); - -/* give access to free() for memory cleanup of the malloc'd Point */ -extern void free(void *memblock); - -%native(point_toString2) char *point_toString2(Point *p); - diff --git a/Examples/doxygencomments/java/native/index.html b/Examples/doxygencomments/java/native/index.html deleted file mode 100644 index 7ecf129ce..000000000 --- a/Examples/doxygencomments/java/native/index.html +++ /dev/null @@ -1,33 +0,0 @@ - - -SWIG:Examples:java:native - - - - - -SWIG/Examples/java/native/ -
    - -

    SWIG wrapped and manually wrapped functions in Java

    - -Click here for the relevant section in the SWIG and Java documentation. -

    -This example compares wrapping a c global function using the manual way and the SWIG way. -

    - -
      -
    • example.i. Interface file comparing code wrapped by SWIG and wrapped manually. -
    • main.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. -
    - -

    Notes

    - -
      -
    • SWIG writes all the awkward JNI code for you. You just have to tell SWIG which functions to wrap. -
    • If memory is allocated in c it needs to be free'd. A function, such as free(), can be provided with access from Java to free the memory. -
    - -
    - - diff --git a/Examples/doxygencomments/java/native/main.java b/Examples/doxygencomments/java/native/main.java deleted file mode 100644 index f4760bb3d..000000000 --- a/Examples/doxygencomments/java/native/main.java +++ /dev/null @@ -1,19 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - SWIGTYPE_p_Point p = example.point_create(1, 2); - System.out.println("auto wrapped : " + example.point_toString1(p)); - System.out.println("manual wrapped: " + example.point_toString2(p)); - example.free(new SWIGTYPE_p_void(SWIGTYPE_p_Point.getCPtr(p), false)); //clean up c allocated memory - } -} diff --git a/Examples/doxygencomments/java/pointer/Makefile b/Examples/doxygencomments/java/pointer/Makefile deleted file mode 100644 index 968c92c6c..000000000 --- a/Examples/doxygencomments/java/pointer/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/pointer/example.c b/Examples/doxygencomments/java/pointer/example.c deleted file mode 100644 index b877d9a5b..000000000 --- a/Examples/doxygencomments/java/pointer/example.c +++ /dev/null @@ -1,16 +0,0 @@ -/* File : example.c */ - -void add(int *x, int *y, int *result) { - *result = *x + *y; -} - -void sub(int *x, int *y, int *result) { - *result = *x - *y; -} - -int divide(int n, int d, int *r) { - int q; - q = n/d; - *r = n - q*d; - return q; -} diff --git a/Examples/doxygencomments/java/pointer/example.i b/Examples/doxygencomments/java/pointer/example.i deleted file mode 100644 index 7ac3b8cf8..000000000 --- a/Examples/doxygencomments/java/pointer/example.i +++ /dev/null @@ -1,38 +0,0 @@ -/* File : example.i */ -%module example - -%{ -extern void add(int *, int *, int *); -extern void sub(int *, int *, int *); -extern int divide(int, int, int *); -%} - -/** This example illustrates a couple of different techniques - for manipulating C pointers */ - -/* First we'll use the pointer library */ - -/*! function add - \param x some int x - \param y some int y - \param result some result - */ -extern void add(int *x, int *y, int *result); -%include cpointer.i -%pointer_functions(int, intp); - -/* Next we'll use some typemaps */ - -%include typemaps.i -extern void sub(int *INPUT, int *INPUT, int *OUTPUT); - -/* Next we'll use typemaps and the %apply directive */ - -%apply int *OUTPUT { int *r }; -extern int divide(int n, int d, int *r); - - - - - - diff --git a/Examples/doxygencomments/java/pointer/index.html b/Examples/doxygencomments/java/pointer/index.html deleted file mode 100644 index c30d549e6..000000000 --- a/Examples/doxygencomments/java/pointer/index.html +++ /dev/null @@ -1,165 +0,0 @@ - - -SWIG:Examples:java:pointer - - - - -SWIG/Examples/java/pointer/ -
    - -

    Simple Pointer Handling

    - -

    -This example illustrates a couple of techniques for handling -simple pointers in SWIG. The prototypical example is a C function -that operates on pointers such as this: - -

    -
    -void add(int *x, int *y, int *r) { 
    -    *r = *x + *y;
    -}
    -
    -
    - -By default, SWIG wraps this function exactly as specified and creates -an interface that expects pointer objects for arguments. -SWIG wraps a C pointer with a type wrapper class, for example, SWIGTYPE_p_int for an int*. -The only problem is how does one go about creating these objects from a Java program? -

    - - -

    Possible Solutions

    - -
      -
    • Write some helper functions to explicitly create objects. For -example: - -
      -
      -int *new_int(int ivalue) {
      -  int *i = (int *) malloc(sizeof(ivalue));
      -  *i = ivalue;
      -  return i;
      -}
      -int get_int(int *i) {
      -  return *i;
      -}
      -
      -void delete_int(int *i) {
      -  free(i);
      -}
      -
      -
      - -

      -

    • The SWIG pointer library provides an easier way.
      -For example, in the interface file -you would do this: - -
      -
      -%include cpointer.i
      -%pointer_functions(int, intp);
      -
      -
      - -and from Java you would use pointers like this: - -
      -
      -SWIGTYPE_p_int a = example.new_intp();
      -SWIGTYPE_p_int b = example.new_intp();
      -SWIGTYPE_p_int c = example.new_intp();
      -example.intp_assign(a,37);
      -example.intp_assign(b,42);
      -
      -// Note that getCPtr() has package access by default
      -System.out.println("     a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a)));
      -System.out.println("     b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b)));
      -System.out.println("     c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c)));
      -
      -// Call the add() function with some pointers
      -example.add(a,b,c);
      -
      -// Now get the result
      -int res = example.intp_value(c);
      -System.out.println("     37 + 42 =" + res);
      -
      -// Clean up the pointers
      -example.delete_intp(a);
      -example.delete_intp(b);
      -example.delete_intp(c);
      -
      -
      - -

      -

    • Use the SWIG typemap library. This library allows you to completely -change the way arguments are processed by SWIG. For example: - -
      -
      -%include "typemaps.i"
      -void add(int *INPUT, int *INPUT, int *OUTPUT);
      -
      -
      - -And in a Java program: - -
      -
      -int[] r = {0};
      -example.sub(37,42,r);
      -System.out.println("Result =" + r[0]);
      -
      -
      -Needless to say, this is substantially easier although a bit unusual. - -

      -

    • A final alternative is to use the typemaps library in combination -with the %apply directive. This allows you to change the names of parameters -that behave as input or output parameters. For example: - -
      -
      -%include "typemaps.i"
      -%apply int *INPUT {int *x, int *y};
      -%apply int *OUTPUT {int *r};
      -
      -void add(int *x, int *y, int *r);
      -void sub(int *x, int *y, int *r);
      -void mul(int *x, int *y, int *r);
      -... etc ...
      -
      -
      - -
    - -

    Example

    - -The following example illustrates the use of these features for pointer -extraction. - - - -

    Notes

    - -
      -
    • Since pointers are used for so many different things (arrays, output values, -etc...) the complexity of pointer handling can be as complicated as you want to -make it. - -

      -

    • More documentation on the typemaps.i and cpointer.i library files can be -found in the SWIG user manual. The files also contain documentation. - -
    - -
    - - diff --git a/Examples/doxygencomments/java/pointer/main.java b/Examples/doxygencomments/java/pointer/main.java deleted file mode 100644 index e96e02eaa..000000000 --- a/Examples/doxygencomments/java/pointer/main.java +++ /dev/null @@ -1,55 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - - // First create some objects using the pointer library. - System.out.println("Testing the pointer library"); - SWIGTYPE_p_int a = example.new_intp(); - SWIGTYPE_p_int b = example.new_intp(); - SWIGTYPE_p_int c = example.new_intp(); - example.intp_assign(a,37); - example.intp_assign(b,42); - - // Note that getCPtr() has package access by default - System.out.println(" a =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(a))); - System.out.println(" b =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(b))); - System.out.println(" c =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(c))); - - // Call the add() function with some pointers - example.add(a,b,c); - - // Now get the result - int res = example.intp_value(c); - System.out.println(" 37 + 42 =" + res); - - // Clean up the pointers - example.delete_intp(a); - example.delete_intp(b); - example.delete_intp(c); - - // Now try the typemap library - // Now it is no longer necessary to manufacture pointers. - // Instead we use a single element array which in Java is modifiable. - - System.out.println("Trying the typemap library"); - int[] r = {0}; - example.sub(37,42,r); - System.out.println(" 37 - 42 = " + r[0]); - - // Now try the version with return value - - System.out.println("Testing return value"); - int q = example.divide(42,37,r); - System.out.println(" 42/37 = " + q + " remainder " + r[0]); - } -} diff --git a/Examples/doxygencomments/java/reference/Makefile b/Examples/doxygencomments/java/reference/Makefile deleted file mode 100644 index 14c301703..000000000 --- a/Examples/doxygencomments/java/reference/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/reference/example.cxx b/Examples/doxygencomments/java/reference/example.cxx deleted file mode 100644 index 8a513bf49..000000000 --- a/Examples/doxygencomments/java/reference/example.cxx +++ /dev/null @@ -1,46 +0,0 @@ -/* File : example.cxx */ - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -#include "example.h" -#include -#include - -Vector operator+(const Vector &a, const Vector &b) { - Vector r; - r.x = a.x + b.x; - r.y = a.y + b.y; - r.z = a.z + b.z; - return r; -} - -char *Vector::print() { - static char temp[512]; - sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); - return temp; -} - -VectorArray::VectorArray(int size) { - items = new Vector[size]; - maxsize = size; -} - -VectorArray::~VectorArray() { - delete [] items; -} - -Vector &VectorArray::operator[](int index) { - if ((index < 0) || (index >= maxsize)) { - printf("Panic! Array index out of bounds.\n"); - exit(1); - } - return items[index]; -} - -int VectorArray::size() { - return maxsize; -} - diff --git a/Examples/doxygencomments/java/reference/example.h b/Examples/doxygencomments/java/reference/example.h deleted file mode 100644 index 4915adb1b..000000000 --- a/Examples/doxygencomments/java/reference/example.h +++ /dev/null @@ -1,26 +0,0 @@ -/* File : example.h */ - -class Vector { -private: - double x,y,z; -public: - Vector() : x(0), y(0), z(0) { }; - Vector(double x, double y, double z) : x(x), y(y), z(z) { }; - friend Vector operator+(const Vector &a, const Vector &b); - char *print(); -}; - -class VectorArray { -private: - Vector *items; - int maxsize; -public: - VectorArray(int maxsize); - ~VectorArray(); - Vector &operator[](int); - int size(); -}; - - - - diff --git a/Examples/doxygencomments/java/reference/example.i b/Examples/doxygencomments/java/reference/example.i deleted file mode 100644 index 8e4d05239..000000000 --- a/Examples/doxygencomments/java/reference/example.i +++ /dev/null @@ -1,58 +0,0 @@ -/* File : example.i */ - -/* This file has a few "typical" uses of C++ references. */ - -%module example - -%{ -#include "example.h" -%} - -/*! Class vector description - \author Fred - \exception something random - \since 1.0 - \name ignoreme - \see something */ -class Vector { -public: - Vector(double x, double y, double z); - ~Vector(); - char *print(); -}; - -/** This helper function calls an overloaded operator */ -%inline %{ -Vector addv(Vector &a, Vector &b) { - return a+b; -} -%} - -/*! Class Vector Array - \exception something random - \since 1.3 - \see something - \author Fred */ -class VectorArray { -public: - VectorArray(int maxsize); - ~VectorArray(); - int size(); - - /* This wrapper provides an alternative to the [] operator */ - %extend { - Vector &get(int index) { - return (*$self)[index]; - } - void set(int index, Vector &a) { - (*$self)[index] = a; - } - } -}; - - - - - - - diff --git a/Examples/doxygencomments/java/reference/index.html b/Examples/doxygencomments/java/reference/index.html deleted file mode 100644 index 64b129cbb..000000000 --- a/Examples/doxygencomments/java/reference/index.html +++ /dev/null @@ -1,147 +0,0 @@ - - -SWIG:Examples:java:reference - - - - - -SWIG/Examples/java/reference/ -
    - -

    C++ Reference Handling

    - -

    -This example tests SWIG's handling of C++ references. Since C++ -references are closely related to pointers (as both refer to a -location in memory), SWIG simply collapses all references into -pointers when creating wrappers. - -

    Some examples

    - -References are most commonly used as function parameter. For example, -you might have an operator like this: - -
    -
    -Vector operator+(const Vector &a, const Vector &b) {
    -   Vector result;
    -   result.x = a.x + b.x;
    -   result.y = a.y + b.y;
    -   result.z = a.z + b.z;
    -   return result;
    -}
    -
    -
    - -or a function: - -
    -
    -Vector addv(const Vector &a, const Vector &b) {
    -   Vector result;
    -   result.x = a.x + b.x;
    -   result.y = a.y + b.y;
    -   result.z = a.z + b.z;
    -   return result;
    -}
    -
    -
    - -In these cases, SWIG transforms everything into a pointer and creates a wrapper -that looks like this: - -
    -
    -Vector wrap_addv(Vector *a, Vector *b) {
    -    return addv(*a,*b);
    -}
    -
    -
    - -Occasionally, a reference is used as a return value of a function -when the return result is to be used as an lvalue in an expression. -The prototypical example is an operator like this: - -
    -
    -Vector &operator[](int index);
    -
    -
    - -or a method: - -
    -
    -Vector &get(int index);
    -
    -
    - -For functions returning references, a wrapper like this is created: - -
    -
    -Vector *wrap_Object_get(Object *self, int index) {
    -    Vector &result = self->get(index);
    -    return &result;
    -}
    -
    -
    - -The following header file contains some class -definitions with some operators and use of references. - -

    SWIG Interface

    - -SWIG does NOT support overloaded operators so it can not directly build -an interface to the classes in the above file. However, a number of workarounds -can be made. For example, an overloaded operator can be stuck behind a function -call such as the addv() function above. Array access can be handled -with a pair of set/get functions like this: - -
    -
    -class VectorArray {
    -public:
    - ...
    -   %addmethods {
    -    Vector &get(int index) {
    -      return (*self)[index];
    -    }
    -    void set(int index, Vector &a) {
    -      (*self)[index] = a;
    -    }
    -   }
    -   ...
    -}
    -
    -
    - -Click here to see a SWIG interface file with these additions. - -

    Sample Java program

    - -Click here to see a Java program that manipulates some C++ references. - -

    Notes:

    - -
      -
    • C++ references primarily provide notational convenience for C++ -source code. However, Java only supports the 'x.a' -notation so it doesn't much matter. - -

      -

    • When a program returns a reference, a pointer is returned. -Unlike return by value, memory is not allocated to hold the -return result. - -

      -

    • SWIG has particular trouble handling various combinations of references -and pointers. This is side effect of an old parsing scheme and -type representation that will be replaced in future versions. - -
    - -
    - - diff --git a/Examples/doxygencomments/java/reference/main.java b/Examples/doxygencomments/java/reference/main.java deleted file mode 100644 index 4fd354761..000000000 --- a/Examples/doxygencomments/java/reference/main.java +++ /dev/null @@ -1,79 +0,0 @@ -// This example illustrates the manipulation of C++ references in Java. - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - System.out.println( "Creating some objects:" ); - Vector a = new Vector(3,4,5); - Vector b = new Vector(10,11,12); - - System.out.println( " Created " + a.print() ); - System.out.println( " Created " + b.print() ); - - // ----- Call an overloaded operator ----- - - // This calls the wrapper we placed around - // - // operator+(const Vector &a, const Vector &) - // - // It returns a new allocated object. - - System.out.println( "Adding a+b" ); - Vector c = example.addv(a,b); - System.out.println( " a+b = " + c.print() ); - - // Note: Unless we free the result, a memory leak will occur if the -noproxy commandline - // is used as the proxy classes define finalizers which call the delete() method. When - // -noproxy is not specified the memory management is controlled by the garbage collector. - // You can still call delete(). It will free the c++ memory immediately, but not the - // Java memory! You then must be careful not to call any member functions as it will - // use a NULL c pointer on the underlying c++ object. We set the Java object to null - // which will then throw a Java exception should we attempt to use it again. - c.delete(); - c = null; - - // ----- Create a vector array ----- - - System.out.println( "Creating an array of vectors" ); - VectorArray va = new VectorArray(10); - System.out.println( " va = " + va.toString() ); - - // ----- Set some values in the array ----- - - // These operators copy the value of Vector a and Vector b to the vector array - va.set(0,a); - va.set(1,b); - - // This works, but it would cause a memory leak if -noproxy was used! - - va.set(2,example.addv(a,b)); - - - // Get some values from the array - - System.out.println( "Getting some array values" ); - for (int i=0; i<5; i++) - System.out.println( " va(" + i + ") = " + va.get(i).print() ); - - // Watch under resource meter to check on this - System.out.println( "Making sure we don't leak memory." ); - for (int i=0; i<1000000; i++) - c = va.get(i%10); - - // ----- Clean up ----- - // This could be omitted. The garbage collector would then clean up for us. - System.out.println( "Cleaning up" ); - va.delete(); - a.delete(); - b.delete(); - } -} diff --git a/Examples/doxygencomments/java/simple/Makefile b/Examples/doxygencomments/java/simple/Makefile deleted file mode 100644 index 968c92c6c..000000000 --- a/Examples/doxygencomments/java/simple/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/simple/example.c b/Examples/doxygencomments/java/simple/example.c deleted file mode 100644 index 1c2af789c..000000000 --- a/Examples/doxygencomments/java/simple/example.c +++ /dev/null @@ -1,18 +0,0 @@ -/* File : example.c */ - -/* A global variable */ -double Foo = 3.0; - -/* Compute the greatest common divisor of positive integers */ -int gcd(int x, int y) { - int g; - g = y; - while (x > 0) { - g = x; - x = y % x; - y = g; - } - return g; -} - - diff --git a/Examples/doxygencomments/java/simple/example.dsp b/Examples/doxygencomments/java/simple/example.dsp deleted file mode 100644 index 8e1f8415e..000000000 --- a/Examples/doxygencomments/java/simple/example.dsp +++ /dev/null @@ -1,158 +0,0 @@ -# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=example - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "example.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "example - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x809 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /out:"example.dll" /pdbtype:sept -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Java compile post-build step -PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java -# End Special Build Tool - -!ELSEIF "$(CFG)" == "example - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(JAVA_INCLUDE)" /I "$(JAVA_INCLUDE)\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x809 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 /out:"example.dll" -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Desc=Java compile post-build step -PostBuild_Cmds=echo on "%JAVA_BIN%\javac" *.java -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "example - Win32 Debug" -# Name "example - Win32 Release" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\example.c -# End Source File -# Begin Source File - -SOURCE=.\example_wrap.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# Begin Source File - -SOURCE=.\example.i - -!IF "$(CFG)" == "example - Win32 Debug" - -# Begin Custom Build -InputPath=.\example.i -InputName=example - -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - echo In order to function correctly, please ensure the following environment variables are correctly set: - echo JAVA_INCLUDE: %JAVA_INCLUDE% - echo JAVA_BIN: %JAVA_BIN% - echo on - ..\..\..\swig.exe -java $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "example - Win32 Release" - -# Begin Custom Build -InputPath=.\example.i -InputName=example - -"$(InputName)_wrap.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - echo In order to function correctly, please ensure the following environment variables are correctly set: - echo JAVA_INCLUDE: %JAVA_INCLUDE% - echo JAVA_BIN: %JAVA_BIN% - echo on - ..\..\..\swig.exe -java $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# End Target -# End Project diff --git a/Examples/doxygencomments/java/simple/example.i b/Examples/doxygencomments/java/simple/example.i deleted file mode 100644 index d10fe5e19..000000000 --- a/Examples/doxygencomments/java/simple/example.i +++ /dev/null @@ -1,11 +0,0 @@ -/* File : example.i */ -%module example - -%inline %{ -/*! Function foo - \param x int x - \param y int y - \return the gcd */ -extern int gcd(int x, int y); -extern double Foo; /*!< description of double foo */ -%} diff --git a/Examples/doxygencomments/java/simple/index.html b/Examples/doxygencomments/java/simple/index.html deleted file mode 100644 index a363327fe..000000000 --- a/Examples/doxygencomments/java/simple/index.html +++ /dev/null @@ -1,108 +0,0 @@ - - -SWIG:Examples:java:simple - - - - - -SWIG/Examples/java/simple/ -
    - -

    Simple Java Example

    - -

    -This example illustrates how you can hook Java to a very simple C program containing -a function and a global variable. - -

    The C Code

    - -Suppose you have the following C code: - -
    -
    -/* File : example.c */
    -
    -/* A global variable */
    -double Foo = 3.0;
    -
    -/* Compute the greatest common divisor of positive integers */
    -int gcd(int x, int y) {
    -  int g;
    -  g = y;
    -  while (x > 0) {
    -    g = x;
    -    x = y % x;
    -    y = g;
    -  }
    -  return g;
    -}
    -
    -
    - -

    The SWIG interface

    - -Here is a simple SWIG interface file: - -
    -
    -/* File: example.i */
    -%module example
    -
    -extern int gcd(int x, int y);
    -extern double Foo;
    -
    -
    - -

    Compilation

    - -
      -
    1. swig -java example.i -

      -

    2. Compile example_wrap.c and example.c -to create the extension libexample.so (unix). -
    - -

    Using the extension

    - -Click here to see a program that calls our C functions from Java. -

    -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 main
    -
    -
    - -

    Key points

    - -
      -
    • Use the loadLibrary statement from java to load and access the generated java classes. For example: -
      -
      -System.loadLibrary("example");
      -
      -
      - -
    • C functions work just like Java functions. For example: -
      -
      -int g = example.gcd(42,105);
      -
      -
      - -
    • C global variables are accessed through get and set functions in the module class. For example: -
      -
      -double a = example.get_Foo();
      -example.set_Foo(20.0);
      -
      -
      -
    - -
    - - diff --git a/Examples/doxygencomments/java/simple/main.java b/Examples/doxygencomments/java/simple/main.java deleted file mode 100644 index 6d224a4dc..000000000 --- a/Examples/doxygencomments/java/simple/main.java +++ /dev/null @@ -1,32 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - // Call our gcd() function - - int x = 42; - int y = 105; - int g = example.gcd(x,y); - System.out.println("The gcd of " + x + " and " + y + " is " + g); - - // Manipulate the Foo global variable - - // Output its current value - System.out.println("Foo = " + example.getFoo()); - - // Change its value - example.setFoo(3.1415926); - - // See if the change took effect - System.out.println("Foo = " + example.getFoo()); - } -} diff --git a/Examples/doxygencomments/java/template/Makefile b/Examples/doxygencomments/java/template/Makefile deleted file mode 100644 index 2b3d35c6a..000000000 --- a/Examples/doxygencomments/java/template/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -CXXSRCS = -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/template/example.h b/Examples/doxygencomments/java/template/example.h deleted file mode 100644 index 9ec711391..000000000 --- a/Examples/doxygencomments/java/template/example.h +++ /dev/null @@ -1,39 +0,0 @@ -/* File : example.h */ - -// Some template definitions - -/*! Template class T - \author cmfoil - \sa something something */ - -template T max(T a, T b) { return a>b ? a : b; } - -/*! Template class Vector - \author cmfoil - \sa something something */ -template class vector { - T *v; - int sz; - public: - vector(int _sz) { - v = new T[_sz]; - sz = _sz; - } - T &get(int index) { - return v[index]; - } - void set(int index, T &val) { - v[index] = val; - } /*!< Something about set */ -#ifdef SWIG - %extend { - T getitem(int index) { - return $self->get(index); - }/*!< Something about get item */ - void setitem(int index, T val) { - $self->set(index,val); - } - } -#endif -}; - diff --git a/Examples/doxygencomments/java/template/example.i b/Examples/doxygencomments/java/template/example.i deleted file mode 100644 index 8f94c4da1..000000000 --- a/Examples/doxygencomments/java/template/example.i +++ /dev/null @@ -1,17 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" - -/* Now instantiate some specific template declarations */ - -%template(maxint) max; -%template(maxdouble) max; -%template(vecint) vector; -%template(vecdouble) vector; - diff --git a/Examples/doxygencomments/java/template/index.html b/Examples/doxygencomments/java/template/index.html deleted file mode 100644 index 1aebd4c2a..000000000 --- a/Examples/doxygencomments/java/template/index.html +++ /dev/null @@ -1,102 +0,0 @@ - - -SWIG:Examples:java:template - - - - - -SWIG/Examples/java/template/ -
    - -

    C++ template support

    - -

    -This example illustrates how C++ templates can be used from Java using SWIG. - -

    The C++ Code

    - -Lets take a templated function and a templated class as follows: - -
    -
    -/* File : example.h */
    -
    -// Some template definitions
    -
    -template T max(T a, T b) { return  a>b ? a : b; }
    -
    -template class vector {
    -  T *v;
    -  int sz;
    - public:
    -  vector(int _sz) {
    -    v = new T[_sz];
    -    sz = _sz;
    -  }
    -  T &get(int index) {
    -    return v[index];
    -  }
    -  void set(int index, T &val) {
    -    v[index] = val;
    -  }
    -#ifdef SWIG
    -  %addmethods {
    -    T getitem(int index) {
    -      return self->get(index);
    -    }
    -    void setitem(int index, T val) {
    -      self->set(index,val);
    -    }
    -  }
    -#endif
    -};
    -
    -
    -The %addmethods is used for a neater interface from Java as the functions get and set use C++ references to primitive types. These are tricky to use from Java as they end up as a pointer in Java (Java long). - -

    The SWIG interface

    - -A simple SWIG interface for this can be built by simply grabbing the header file -like this: - -
    -
    -/* File : example.i */
    -%module example
    -
    -%{
    -#include "example.h"
    -%}
    -
    -/* Let's just grab the original header file here */
    -%include "example.h"
    -
    -/* Now instantiate some specific template declarations */
    -
    -%template(maxint) max;
    -%template(maxdouble) max;
    -%template(vecint) vector;
    -%template(vecdouble) vector;
    -
    -
    - -Note that SWIG parses the templated function max and templated class vector and so knows about them. However to generate code for use from Java, SWIG has to be told which class/type to use as the template parameter. The SWIG directive %template is used for this. - -

    A sample Java program

    - -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. - -
    -
    -vecdouble dv = new vecdouble(1000);
    -dv.setitem(i, 12.34));
    -
    -
    - -
    - - diff --git a/Examples/doxygencomments/java/template/main.java b/Examples/doxygencomments/java/template/main.java deleted file mode 100644 index 9129fcf2a..000000000 --- a/Examples/doxygencomments/java/template/main.java +++ /dev/null @@ -1,45 +0,0 @@ -// This example illustrates how C++ templates can be used from Java. - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) - { - // Call some templated functions - System.out.println(example.maxint(3,7)); - System.out.println(example.maxdouble(3.14,2.18)); - - // Create some class - - vecint iv = new vecint(100); - vecdouble dv = new vecdouble(1000); - - for (int i=0; i<100; i++) - iv.setitem(i,2*i); - - for (int i=0; i<1000; i++) - dv.setitem(i, 1.0/(i+1)); - - { - int sum = 0; - for (int i=0; i<100; i++) - sum = sum + iv.getitem(i); - - System.out.println(sum); - } - - { - double sum = 0.0; - for (int i=0; i<1000; i++) - sum = sum + dv.getitem(i); - System.out.println(sum); - } - } -} diff --git a/Examples/doxygencomments/java/typemap/Makefile b/Examples/doxygencomments/java/typemap/Makefile deleted file mode 100644 index 92afbd4d0..000000000 --- a/Examples/doxygencomments/java/typemap/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/typemap/example.i b/Examples/doxygencomments/java/typemap/example.i deleted file mode 100644 index 7c97e6673..000000000 --- a/Examples/doxygencomments/java/typemap/example.i +++ /dev/null @@ -1,101 +0,0 @@ -/* File : example.i */ -%module example -%{ -/* - example of a function that returns a value in the char * argument - normally used like: - - char buf[bigenough]; - f1(buf); -*/ - -void f1(char *s) { - if(s != NULL) { - sprintf(s, "hello world"); - } -} - -void f2(char *s) { - f1(s); -} - -void f3(char *s) { - f1(s); -} - -%} - -/* default behaviour is that of input arg, Java cannot return a value in a - * string argument, so any changes made by f1(char*) will not be seen in the Java - * string passed to the f1 function. -*/ -void f1(char *s); - -%include various.i - -/* use the BYTE argout typemap to get around this. Changes in the string by - * f2 can be seen in Java. */ -void f2(char *BYTE); - - - -/* Alternative approach uses a StringBuffer typemap for argout */ - -/* Define the types to use in the generated JNI C code and Java code */ -%typemap(jni) char *SBUF "jobject" -%typemap(jtype) char *SBUF "StringBuffer" -%typemap(jstype) char *SBUF "StringBuffer" - -/* How to convert Java(JNI) type to requested C type */ -%typemap(in) char *SBUF { - - $1 = NULL; - if($input != NULL) { - /* Get the String from the StringBuffer */ - jmethodID setLengthID; - jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); - jmethodID toStringID = (*jenv)->GetMethodID(jenv, sbufClass, "toString", "()Ljava/lang/String;"); - jstring js = (jstring) (*jenv)->CallObjectMethod(jenv, $input, toStringID); - - /* Convert the String to a C string */ - const char *pCharStr = (*jenv)->GetStringUTFChars(jenv, js, 0); - - /* Take a copy of the C string as the typemap is for a non const C string */ - jmethodID capacityID = (*jenv)->GetMethodID(jenv, sbufClass, "capacity", "()I"); - jint capacity = (*jenv)->CallIntMethod(jenv, $input, capacityID); - $1 = (char *) malloc(capacity+1); - strcpy($1, pCharStr); - - /* Release the UTF string we obtained with GetStringUTFChars */ - (*jenv)->ReleaseStringUTFChars(jenv, js, pCharStr); - - /* Zero the original StringBuffer, so we can replace it with the result */ - setLengthID = (*jenv)->GetMethodID(jenv, sbufClass, "setLength", "(I)V"); - (*jenv)->CallVoidMethod(jenv, $input, setLengthID, (jint) 0); - } -} - -/* How to convert the C type to the Java(JNI) type */ -%typemap(argout) char *SBUF { - - if($1 != NULL) { - /* Append the result to the empty StringBuffer */ - jstring newString = (*jenv)->NewStringUTF(jenv, $1); - jclass sbufClass = (*jenv)->GetObjectClass(jenv, $input); - jmethodID appendStringID = (*jenv)->GetMethodID(jenv, sbufClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"); - (*jenv)->CallObjectMethod(jenv, $input, appendStringID, newString); - - /* Clean up the string object, no longer needed */ - free($1); - $1 = NULL; - } -} -/* Prevent the default freearg typemap from being used */ -%typemap(freearg) char *SBUF "" - -/* Convert the jstype to jtype typemap type */ -%typemap(javain) char *SBUF "$javainput" - -/* apply the new typemap to our function */ -void f3(char *SBUF); - diff --git a/Examples/doxygencomments/java/typemap/index.html b/Examples/doxygencomments/java/typemap/index.html deleted file mode 100644 index 486aa8e79..000000000 --- a/Examples/doxygencomments/java/typemap/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - -SWIG:Examples:java:typemap - - - - - -SWIG/Examples/java/typemap/ -
    - -

    Typemaps in Java

    - -

    -This example shows how typemaps can be used to modify the default behaviour of the Java SWIG module. - -

    - -

    Notes

    - -
      -
    • Shows how to pass strings to Java from c and visa versa. -
    • Typemaps can modify the default behaviour of the Java SWIG module. -
    • The default c to java mapping can be modified using typemaps. -
    - -
    - - diff --git a/Examples/doxygencomments/java/typemap/main.java b/Examples/doxygencomments/java/typemap/main.java deleted file mode 100644 index bd9a4e1b6..000000000 --- a/Examples/doxygencomments/java/typemap/main.java +++ /dev/null @@ -1,26 +0,0 @@ - -public class main { - - static { - try { - System.loadLibrary("example"); - } 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[]) { - String s = "brave new world"; - example.f1(s); - System.out.println("f1(String): " + s); - - byte b[] = new byte[25]; - example.f2(b); - System.out.println("f2(byte[]): " + new String(b)); - - StringBuffer sb = new StringBuffer(20); - example.f3(sb); - System.out.println("f3(StringBuffer): " + sb); - } -} diff --git a/Examples/doxygencomments/java/variables/Makefile b/Examples/doxygencomments/java/variables/Makefile deleted file mode 100644 index 968c92c6c..000000000 --- a/Examples/doxygencomments/java/variables/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = - -all:: java - -java:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - -check: all diff --git a/Examples/doxygencomments/java/variables/example.c b/Examples/doxygencomments/java/variables/example.c deleted file mode 100644 index aa4ffe9b3..000000000 --- a/Examples/doxygencomments/java/variables/example.c +++ /dev/null @@ -1,91 +0,0 @@ -/* File : example.c */ - -/* I'm a file containing some C global variables */ - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -#include -#include -#include "example.h" - -int ivar = 0; -short svar = 0; -long lvar = 0; -unsigned int uivar = 0; -unsigned short usvar = 0; -unsigned long ulvar = 0; -signed char scvar = 0; -unsigned char ucvar = 0; -char cvar = 0; -float fvar = 0; -double dvar = 0; -char *strvar = 0; -const char cstrvar[] = "Goodbye"; -int *iptrvar = 0; -char name[256] = "Dave"; -char path[256] = "/home/beazley"; - - -/* Global variables involving a structure */ -Point *ptptr = 0; -Point pt = { 10, 20 }; - -/* A variable that we will make read-only in the interface */ -int status = 1; - -/* A debugging function to print out their values */ - -void print_vars() { - printf("ivar = %d\n", ivar); - printf("svar = %d\n", svar); - printf("lvar = %ld\n", lvar); - printf("uivar = %u\n", uivar); - printf("usvar = %u\n", usvar); - printf("ulvar = %lu\n", ulvar); - printf("scvar = %d\n", scvar); - printf("ucvar = %u\n", ucvar); - printf("fvar = %g\n", fvar); - printf("dvar = %g\n", dvar); - printf("cvar = %c\n", cvar); - printf("strvar = %s\n", strvar ? strvar : "(null)"); - printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)"); - printf("iptrvar = %p\n", iptrvar); - printf("name = %s\n", name); - printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0); - printf("pt = (%d, %d)\n", pt.x, pt.y); - printf("status = %d\n", status); -} - -/* A function to create an integer (to test iptrvar) */ - -int *new_int(int value) { - int *ip = (int *) malloc(sizeof(int)); - *ip = value; - return ip; -} - -/* A function to create a point */ - -Point *new_Point(int x, int y) { - Point *p = (Point *) malloc(sizeof(Point)); - p->x = x; - p->y = y; - return p; -} - -char * Point_print(Point *p) { - static char buffer[256]; - if (p) { - sprintf(buffer,"(%d,%d)", p->x,p->y); - } else { - sprintf(buffer,"null"); - } - return buffer; -} - -void pt_print() { - printf("(%d, %d)\n", pt.x, pt.y); -} diff --git a/Examples/doxygencomments/java/variables/example.h b/Examples/doxygencomments/java/variables/example.h deleted file mode 100644 index 2265a45f3..000000000 --- a/Examples/doxygencomments/java/variables/example.h +++ /dev/null @@ -1,6 +0,0 @@ -/* File: example.h */ - -typedef struct { - int x,y; -} Point; /*!< Description of struct Point */ - diff --git a/Examples/doxygencomments/java/variables/example.i b/Examples/doxygencomments/java/variables/example.i deleted file mode 100644 index b9794f0cf..000000000 --- a/Examples/doxygencomments/java/variables/example.i +++ /dev/null @@ -1,57 +0,0 @@ -/* File : example.i */ -%module example -%{ -#include "example.h" -%} - -/* Some global variable declarations */ -%inline %{ -extern int ivar; /*!< Description of ivar */ -extern short svar; /*!< Description of svar */ -extern long lvar; /*!< Description of lvar */ -extern unsigned int uivar; /*!< Description of uivar */ -extern unsigned short usvar; /*!< Description of usvar */ -extern unsigned long ulvar; /*!< Description of ulvar */ -extern signed char scvar; /*!< Description of scvar */ -extern unsigned char ucvar; /*!< Description of ucvar */ -extern char cvar; /*!< Description of cvar */ -extern float fvar; /*!< Description of fvar */ -extern double dvar; /*!< Description of dvar */ -extern char *strvar; /*!< Description of strvar */ -extern const char cstrvar[]; /*!< Description of cstrvar */ -extern int *iptrvar; /*!< Description of iptrvar */ -extern char name[256]; /*!< Description of name */ - -extern Point *ptptr; /*!< Description of ptrptr */ -extern Point pt; /*!< Description of pt */ -%} - - -/* Some read-only variables */ - -%immutable; - -%inline %{ -extern int status; -extern char path[256]; -%} - -%mutable; - -/* Some helper functions to make it easier to test */ -%inline %{ -/*! this function prints variables - \author someone */ -extern void print_vars(); -extern int *new_int(int value); /*!< Description of new_int - \param value the value - \return a new int */ -/*! Description of new_point - \param x the value x - \param y the value y - \return a new point */ -extern Point *new_Point(int x, int y); -extern char *Point_print(Point *p); -extern void pt_print(); -%} - diff --git a/Examples/doxygencomments/java/variables/index.html b/Examples/doxygencomments/java/variables/index.html deleted file mode 100644 index 05aaa2d6e..000000000 --- a/Examples/doxygencomments/java/variables/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - -SWIG:Examples:java:variables - - - - -SWIG/Examples/java/variables/ -
    - -

    Wrapping C Global Variables

    - -

    -When a C global variable appears in an interface file, SWIG tries to -wrap it using a technique known as "variable linking." The idea is -pretty simple---we try to create a Java variable that magically -retrieves or updates the value of the underlying C variable when it is -accessed. Click here to see a SWIG interface with some variable -declarations in it. - - -

    Click here for the section on global variables in the SWIG and Java documentation.

    -

    Manipulating Variables from Java

    - -C variables are accessed through getters and setters from Java. Unfortunately this is the only way to get current values from variables because it is not possible to overload the dot operator in Java. All global variables are accessible from the module class. For example if the module class is called 'example', the global variable - -
    -
    -double foo;
    -
    -
    - -will be accessed in the Java module as -
    -
    -example.get_foo();
    -example.set_foo(12.3);
    -
    -
    - -Click here to see the example program that updates and prints -out the values of the variables using this technique. - -

    Key points

    - -
      -
    • When a global variable has the type "char *", SWIG manages it as a character -string. However, whenever the value of such a variable is set from Java, the old -value is destroyed using free() or delete (the choice of which depends -on whether or not SWIG was run with the -c++ option). -
    • signed char and unsigned char are handled as small 8-bit integers. -
    • String array variables such as 'char name[256]' are managed as Java strings, but -when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated. -
    • When structures and classes are used as global variables, they are mapped into pointers. -Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global. -
    - -

    Creating read-only variables

    - -The %immutable and %mutable directives can be used to -specify a collection of read-only variables. For example: - -
    -
    -%immutable;
    -int    status;
    -double blah;
    -...
    -%mutable;
    -
    -
    - -The %immutable directive remains in effect until it is explicitly disabled -using the %mutable directive. - -

    Comments

    -
      -
    • Management of global variables is one of the most problematic aspects -of C/C++ wrapping because the Java interface and resulting memory management -is much trickier than simply creating a wrapper function. -
    - - - -
    diff --git a/Examples/doxygencomments/java/variables/main.java b/Examples/doxygencomments/java/variables/main.java deleted file mode 100644 index 92745db99..000000000 --- a/Examples/doxygencomments/java/variables/main.java +++ /dev/null @@ -1,97 +0,0 @@ -// This example illustrates global variable access from Java. - -import java.lang.reflect.*; - -public class main { - static { - try { - System.loadLibrary("example"); - } 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[]) { - -// Try to set the values of some global variables - - example.setIvar(42); - example.setSvar((short)-31000); - example.setLvar(65537); - example.setUivar(123456); - example.setUsvar(61000); - example.setUlvar(654321); - example.setScvar((byte)-13); - example.setUcvar((short)251); - example.setCvar('S'); - example.setFvar((float)3.14159); - example.setDvar(2.1828); - example.setStrvar("Hello World"); - example.setIptrvar(example.new_int(37)); - example.setPtptr(example.new_Point(37,42)); - example.setName("Bill"); - - // Now print out the values of the variables - - System.out.println( "Variables (values printed from Java)" ); - - System.out.println( "ivar =" + example.getIvar() ); - System.out.println( "svar =" + example.getSvar() ); - System.out.println( "lvar =" + example.getLvar() ); - System.out.println( "uivar =" + example.getUivar() ); - System.out.println( "usvar =" + example.getUsvar() ); - System.out.println( "ulvar =" + example.getUlvar() ); - System.out.println( "scvar =" + example.getScvar() ); - System.out.println( "ucvar =" + example.getUcvar() ); - System.out.println( "fvar =" + example.getFvar() ); - System.out.println( "dvar =" + example.getDvar() ); - System.out.println( "cvar =" + (char)example.getCvar() ); - System.out.println( "strvar =" + example.getStrvar() ); - System.out.println( "cstrvar =" + example.getCstrvar() ); - System.out.println( "iptrvar =" + Long.toHexString(SWIGTYPE_p_int.getCPtr(example.getIptrvar())) ); - System.out.println( "name =" + example.getName() ); - System.out.println( "ptptr =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPtptr())) + example.Point_print(example.getPtptr()) ); - System.out.println( "pt =" + Long.toHexString(SWIGTYPE_p_Point.getCPtr(example.getPt())) + example.Point_print(example.getPt()) ); - - System.out.println( "\nVariables (values printed from C)" ); - - example.print_vars(); - - System.out.println( "\nNow I'm going to try and modify some read only variables" ); - - System.out.println( " Trying to set 'path'" ); - try { - Method m = example.class.getDeclaredMethod("setPath", new Class[] {String.class}); - m.invoke(example.class, new Object[] {"Whoa!"} ); - System.out.println( "Hey, what's going on?!?! This shouldn't work" ); - } - catch (NoSuchMethodException e) { - System.out.println( "Good." ); - } - catch (Throwable t) { - System.out.println( "You shouldn't see this!" ); - } - - System.out.println( " Trying to set 'status'" ); - try { - Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class}); - m.invoke(example.class, new Object[] {new Integer(0)} ); - System.out.println( "Hey, what's going on?!?! This shouldn't work" ); - } - catch (NoSuchMethodException e) { - System.out.println( "Good." ); - } - catch (Throwable t) { - System.out.println( "You shouldn't see this!" ); - } - - System.out.println( "\nI'm going to try and update a structure variable.\n" ); - - example.setPt(example.getPtptr()); - - System.out.println( "The new value is" ); - example.pt_print(); - System.out.println( "You should see the value" + example.Point_print(example.getPtptr()) ); - } -} diff --git a/Examples/java/check.list b/Examples/java/check.list index 825d04a6d..c30550a1c 100644 --- a/Examples/java/check.list +++ b/Examples/java/check.list @@ -2,6 +2,7 @@ callback class constants +doxygen enum extend funcptr diff --git a/Examples/java/doxygen/Makefile b/Examples/java/doxygen/Makefile new file mode 100644 index 000000000..9f471746e --- /dev/null +++ b/Examples/java/doxygen/Makefile @@ -0,0 +1,21 @@ +TOP = ../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +SWIGOPT = -doxygen +JAVASRCS = *.java + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java_cpp + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' JAVASRCS='$(JAVASRCS)' JAVAFLAGS='$(JAVAFLAGS)' java_compile + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' java_clean + rm -rf javadocs diff --git a/Examples/java/doxygen/example.cxx b/Examples/java/doxygen/example.cxx new file mode 100644 index 000000000..ccdb87dfe --- /dev/null +++ b/Examples/java/doxygen/example.cxx @@ -0,0 +1,48 @@ +/* File : example.cxx */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +Circle::Circle(double r) : radius(r) { + NumCircles++; +} + +double Circle::area() { + return M_PI*radius*radius; +} + +double Circle::perimeter() { + return 2*M_PI*radius; +} + +Square::Square(double w) : width(w) { + NumSquares++; +} + +double Square::area() { + return width*width; +} + +double Square::perimeter() { + return 4*width; +} + +int NumSquares = 0; +int NumCircles = 0; + +Square MakeSquare(double r) { + return Square(r); +} + +Circle MakeCircle(double w) { + return Circle(w); +} + diff --git a/Examples/doxygencomments/java/class/example.dsp b/Examples/java/doxygen/example.dsp similarity index 95% rename from Examples/doxygencomments/java/class/example.dsp rename to Examples/java/doxygen/example.dsp index fbe87e7a4..f52544b95 100644 --- a/Examples/doxygencomments/java/class/example.dsp +++ b/Examples/java/doxygen/example.dsp @@ -136,7 +136,7 @@ InputName=example echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on - ..\..\..\swig.exe -c++ -java $(InputPath) + ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build @@ -151,7 +151,7 @@ InputName=example echo JAVA_INCLUDE: %JAVA_INCLUDE% echo JAVA_BIN: %JAVA_BIN% echo on - ..\..\..\swig.exe -c++ -java $(InputPath) + ..\..\..\swig.exe -c++ -java "$(InputPath)" # End Custom Build diff --git a/Examples/java/doxygen/example.h b/Examples/java/doxygen/example.h new file mode 100644 index 000000000..203348ae4 --- /dev/null +++ b/Examples/java/doxygen/example.h @@ -0,0 +1,107 @@ +/*! \file example.h +This file provides a simple set of Shape classes. */ + +/*! Base class for all shapes. + \author Bob + */ +class Shape { +public: + /*! Default constructor for creating a Shape */ + Shape() { + nshapes++; + } + /*! Destructor for destroying a Shape */ + virtual ~Shape() { + nshapes--; + } + double x; /*!< x co-ordinate */ + double y; /*!< y co-ordinate */ + void move(double dx, double dy); /*!< Move a shape to a new co-ordinate + \param dx x co-ordinate + \param dy y co-ordinate */ + virtual double area() = 0; /*!< \return the area */ + virtual double perimeter() = 0; /*!< \return the perimeter */ + static int nshapes; /*!< Number of shapes currently in existence */ +}; + +/*! A class for representing a circle. + \author Jack + */ +class Circle : public Shape { +private: + double radius; +public: + /*! Construct a circle + * \param r radius of the circle */ + Circle(double r); + /*! Calculate the area of the circle + * \return calculated area */ + virtual double area(); + /*! Calculate the perimeter of the circle + * \return calculated perimeter of the circle */ + virtual double perimeter(); +}; + +/// A class for representing a square. +class Square : public Shape { +private: + double width; +public: + /** Construct a square + * \param w width of the square */ + Square(double w); + /** Calculate the area of the square + * \return calculated area */ + virtual double area(); + /** Calculate the perimeter of the square + * \return calculated perimeter of the square */ + virtual double perimeter(); +}; + +/// A class for representing a rectangle, templated on the type for the rectangle dimensions +template +class Rectangle : public Shape { +private: + T height; + T width; +public: + /** Construct a rectangle + * \param h height of the rectangle + * \param w width of the rectangle */ + Rectangle(T h, T w) : height(h), width(w) {} + /** Calculate the area of the rectangle + * \return calculated area */ + virtual double area() { return width*height; } + /** Calculate the perimeter of the rectangle + * \return calculated perimeter of the rectangle */ + virtual double perimeter() { return 2*height + 2*width; } +}; + + +/*! Factory function for creating a square + * \param r width of the square + * \return a fully constructed square */ +Square MakeSquare(double r); + +/*! Factory function for creating a circle + * \param w radius of the circle + * \return a fully constructed circle */ +Circle MakeCircle(double w); + +/*! Factory function for creating a rectangle + * \param h height of the rectangle + * \param w width of the rectangle + * \return a fully constructed rectangle */ +template +Rectangle MakeRectangle(T h, T w) { + return Rectangle(h, w); +} + + + +/*! Total number of circles ever created */ +extern int NumCircles; + +/// Total number of squares ever created +extern int NumSquares; + diff --git a/Examples/java/doxygen/example.i b/Examples/java/doxygen/example.i new file mode 100644 index 000000000..803563dd9 --- /dev/null +++ b/Examples/java/doxygen/example.i @@ -0,0 +1,17 @@ +%module example + +%{ +#include "example.h" +%} + +%immutable NumSquares; +%immutable NumCircles; + +%include "example.h" + +/*! - this instantiation uses type int */ +%template(RectangleInt) Rectangle; + +/*! - this instantiation uses type int */ +%template(MakeRectangleInt) MakeRectangle; + diff --git a/Examples/java/doxygen/runme.java b/Examples/java/doxygen/runme.java new file mode 100644 index 000000000..6b7bb3d01 --- /dev/null +++ b/Examples/java/doxygen/runme.java @@ -0,0 +1,63 @@ +// This example shows simple usage of the wrapped Shape classes. +// The main purpose of this example is to show the doxygen comments translation to JavaDoc comments. +// Users should look at the generated .java files and if javadoc is installed and working on your system, +// the generated Java docs can be viewed in a browser by opening the javadocs/index.html file. + +import java.io.*; + +public class runme { + static { + try { + System.loadLibrary("example"); + } 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[]) throws InterruptedException, IOException + { + System.out.println("Creating some objects:"); + Circle c = example.MakeCircle(10); + System.out.println(" Created circle " + c); + Square s = example.MakeSquare(10); + System.out.println(" Created square " + s); + RectangleInt r = example.MakeRectangleInt(10, 20); + System.out.println(" Created rectangle " + r); + + System.out.println("\nHere are some properties of the shapes:"); + Shape[] shapes = {c, s, r}; + for (int i=0; i Date: Thu, 31 May 2018 20:48:02 +0100 Subject: [PATCH 0976/2031] Add Python doxygen example --- Examples/python/check.list | 1 + Examples/python/doxygen/Makefile | 27 +++++ Examples/python/doxygen/example.cxx | 48 +++++++++ Examples/python/doxygen/example.dsp | 152 ++++++++++++++++++++++++++++ Examples/python/doxygen/example.h | 107 ++++++++++++++++++++ Examples/python/doxygen/example.i | 17 ++++ Examples/python/doxygen/runme.py | 28 +++++ 7 files changed, 380 insertions(+) create mode 100644 Examples/python/doxygen/Makefile create mode 100644 Examples/python/doxygen/example.cxx create mode 100644 Examples/python/doxygen/example.dsp create mode 100644 Examples/python/doxygen/example.h create mode 100644 Examples/python/doxygen/example.i create mode 100644 Examples/python/doxygen/runme.py diff --git a/Examples/python/check.list b/Examples/python/check.list index 73182025d..0798b5f7e 100644 --- a/Examples/python/check.list +++ b/Examples/python/check.list @@ -4,6 +4,7 @@ class constants contract docstrings +doxygen enum exception exceptproxy diff --git a/Examples/python/doxygen/Makefile b/Examples/python/doxygen/Makefile new file mode 100644 index 000000000..1a0e3d7c5 --- /dev/null +++ b/Examples/python/doxygen/Makefile @@ -0,0 +1,27 @@ +TOP = ../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = -lm +SWIGOPT = -doxygen + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' \ + TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean + rm -f example.html diff --git a/Examples/python/doxygen/example.cxx b/Examples/python/doxygen/example.cxx new file mode 100644 index 000000000..ccdb87dfe --- /dev/null +++ b/Examples/python/doxygen/example.cxx @@ -0,0 +1,48 @@ +/* File : example.cxx */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +Circle::Circle(double r) : radius(r) { + NumCircles++; +} + +double Circle::area() { + return M_PI*radius*radius; +} + +double Circle::perimeter() { + return 2*M_PI*radius; +} + +Square::Square(double w) : width(w) { + NumSquares++; +} + +double Square::area() { + return width*width; +} + +double Square::perimeter() { + return 4*width; +} + +int NumSquares = 0; +int NumCircles = 0; + +Square MakeSquare(double r) { + return Square(r); +} + +Circle MakeCircle(double w) { + return Circle(w); +} + diff --git a/Examples/python/doxygen/example.dsp b/Examples/python/doxygen/example.dsp new file mode 100644 index 000000000..95ad8f173 --- /dev/null +++ b/Examples/python/doxygen/example.dsp @@ -0,0 +1,152 @@ +# Microsoft Developer Studio Project File - Name="example" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=example - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "example.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "example.mak" CFG="example - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "example - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "example - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "example - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "$(PYTHON_INCLUDE)" /D "SWIG_PYTHON_INTERPRETER_NO_DEBUG" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /debug /machine:I386 /out:"_example.pyd" /pdbtype:sept + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EXAMPLE_EXPORTS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib "$(PYTHON_LIB)" /nologo /dll /machine:I386 /out:"_example.pyd" + +!ENDIF + +# Begin Target + +# Name "example - Win32 Debug" +# Name "example - Win32 Release" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\example.cxx +# End Source File +# Begin Source File + +SOURCE=.\example_wrap.cxx +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\example.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\example.i + +!IF "$(CFG)" == "example - Win32 Debug" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo PYTHON_INCLUDE: %PYTHON_INCLUDE% + echo PYTHON_LIB: %PYTHON_LIB% + echo on + ..\..\..\swig.exe -c++ -python "$(InputPath)" + +# End Custom Build + +!ELSEIF "$(CFG)" == "example - Win32 Release" + +# Begin Custom Build +InputPath=.\example.i +InputName=example + +"$(InputName)_wrap.cxx" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + echo In order to function correctly, please ensure the following environment variables are correctly set: + echo PYTHON_INCLUDE: %PYTHON_INCLUDE% + echo PYTHON_LIB: %PYTHON_LIB% + echo on + ..\..\..\swig.exe -c++ -python "$(InputPath)" + +# End Custom Build + +!ENDIF + +# End Source File +# End Target +# End Project diff --git a/Examples/python/doxygen/example.h b/Examples/python/doxygen/example.h new file mode 100644 index 000000000..203348ae4 --- /dev/null +++ b/Examples/python/doxygen/example.h @@ -0,0 +1,107 @@ +/*! \file example.h +This file provides a simple set of Shape classes. */ + +/*! Base class for all shapes. + \author Bob + */ +class Shape { +public: + /*! Default constructor for creating a Shape */ + Shape() { + nshapes++; + } + /*! Destructor for destroying a Shape */ + virtual ~Shape() { + nshapes--; + } + double x; /*!< x co-ordinate */ + double y; /*!< y co-ordinate */ + void move(double dx, double dy); /*!< Move a shape to a new co-ordinate + \param dx x co-ordinate + \param dy y co-ordinate */ + virtual double area() = 0; /*!< \return the area */ + virtual double perimeter() = 0; /*!< \return the perimeter */ + static int nshapes; /*!< Number of shapes currently in existence */ +}; + +/*! A class for representing a circle. + \author Jack + */ +class Circle : public Shape { +private: + double radius; +public: + /*! Construct a circle + * \param r radius of the circle */ + Circle(double r); + /*! Calculate the area of the circle + * \return calculated area */ + virtual double area(); + /*! Calculate the perimeter of the circle + * \return calculated perimeter of the circle */ + virtual double perimeter(); +}; + +/// A class for representing a square. +class Square : public Shape { +private: + double width; +public: + /** Construct a square + * \param w width of the square */ + Square(double w); + /** Calculate the area of the square + * \return calculated area */ + virtual double area(); + /** Calculate the perimeter of the square + * \return calculated perimeter of the square */ + virtual double perimeter(); +}; + +/// A class for representing a rectangle, templated on the type for the rectangle dimensions +template +class Rectangle : public Shape { +private: + T height; + T width; +public: + /** Construct a rectangle + * \param h height of the rectangle + * \param w width of the rectangle */ + Rectangle(T h, T w) : height(h), width(w) {} + /** Calculate the area of the rectangle + * \return calculated area */ + virtual double area() { return width*height; } + /** Calculate the perimeter of the rectangle + * \return calculated perimeter of the rectangle */ + virtual double perimeter() { return 2*height + 2*width; } +}; + + +/*! Factory function for creating a square + * \param r width of the square + * \return a fully constructed square */ +Square MakeSquare(double r); + +/*! Factory function for creating a circle + * \param w radius of the circle + * \return a fully constructed circle */ +Circle MakeCircle(double w); + +/*! Factory function for creating a rectangle + * \param h height of the rectangle + * \param w width of the rectangle + * \return a fully constructed rectangle */ +template +Rectangle MakeRectangle(T h, T w) { + return Rectangle(h, w); +} + + + +/*! Total number of circles ever created */ +extern int NumCircles; + +/// Total number of squares ever created +extern int NumSquares; + diff --git a/Examples/python/doxygen/example.i b/Examples/python/doxygen/example.i new file mode 100644 index 000000000..803563dd9 --- /dev/null +++ b/Examples/python/doxygen/example.i @@ -0,0 +1,17 @@ +%module example + +%{ +#include "example.h" +%} + +%immutable NumSquares; +%immutable NumCircles; + +%include "example.h" + +/*! - this instantiation uses type int */ +%template(RectangleInt) Rectangle; + +/*! - this instantiation uses type int */ +%template(MakeRectangleInt) MakeRectangle; + diff --git a/Examples/python/doxygen/runme.py b/Examples/python/doxygen/runme.py new file mode 100644 index 000000000..e23528874 --- /dev/null +++ b/Examples/python/doxygen/runme.py @@ -0,0 +1,28 @@ +# This example shows simple usage of the wrapped Shape classes. +# The main purpose of this example is to show the doxygen comments translation to PyDoc comments. +# Users should look at the generated example.py file. +# The generated PyDoc can be viewed in a browser by opening the example.html file. + +import example + +print "Creating some objects:" +c = example.MakeCircle(10) +print " Created circle", c +s = example.MakeSquare(10) +print " Created square", s +r = example.MakeRectangleInt(10, 20) +print " Created rectangle", r + +print "\nHere are some properties of the shapes:" +for o in [c, s, r]: + print " ", o + print " area = ", o.area() + print " perimeter = ", o.perimeter() + +print "\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py" + +import pydoc + +pydoc.writedoc("example") + +print "Open example.html in your browser to view the generated python docs" From 15f16155f2f3f4c82726e27dd77c219ba6c4732d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Jun 2018 21:00:06 +0100 Subject: [PATCH 0977/2031] Move doxygen warning numbers Move out of the range reserved for language modules --- .../errors/doxygen_unknown_command.stderr | 2 +- Source/Include/swigwarn.h | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/errors/doxygen_unknown_command.stderr b/Examples/test-suite/errors/doxygen_unknown_command.stderr index 1ac00d6b0..e92da6e6c 100644 --- a/Examples/test-suite/errors/doxygen_unknown_command.stderr +++ b/Examples/test-suite/errors/doxygen_unknown_command.stderr @@ -1 +1 @@ -doxygen_unknown_command.i:4: Warning 760: Doxygen parser warning: unknown command "unknown". +doxygen_unknown_command.i:4: Warning 560: Doxygen parser warning: unknown command "unknown". diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index c0921530f..a7f9526e1 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -209,6 +209,14 @@ #define WARN_LANG_EXTEND_CONSTRUCTOR 522 #define WARN_LANG_EXTEND_DESTRUCTOR 523 +/* -- Doxygen comments -- */ + +#define WARN_DOXYGEN_UNKNOWN_COMMAND 560 +#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 561 +#define WARN_DOXYGEN_COMMAND_EXPECTED 562 +#define WARN_DOXYGEN_UNTERMINATED_STRING 563 +#define WARN_DOXYGEN_COMMAND_ERROR 564 + /* -- Reserved (600-799) -- */ /* -- Language module specific warnings (700 - 899) -- */ @@ -241,14 +249,6 @@ /* please leave 740-759 free for Python */ -#define WARN_DOXYGEN_UNKNOWN_COMMAND 760 -#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 761 -#define WARN_DOXYGEN_COMMAND_EXPECTED 762 -#define WARN_DOXYGEN_UNTERMINATED_STRING 763 -#define WARN_DOXYGEN_COMMAND_ERROR 764 - -/* please leave 760-779 free for Doxygen */ - #define WARN_RUBY_WRONG_NAME 801 #define WARN_RUBY_MULTIPLE_INHERITANCE 802 From 396910c100cd4d50167ce5aa78a2fd110adbbb81 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Jun 2018 18:40:30 +0100 Subject: [PATCH 0978/2031] Doxygen warnings cleanup - Remove unused warnings. - Refactor some warnings. - Document all Doxygen warnings. --- Doc/Manual/Warnings.html | 12 ++++- .../errors/doxygen_unknown_command.stderr | 2 +- Source/Doxygen/doxyparser.cxx | 53 +++++++++---------- Source/Include/swigwarn.h | 3 +- 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 4fdff486b..853ab691e 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -506,7 +506,7 @@ example.i(4) : Syntax error in input(1). -

    17.9.5 Code generation (500-599)

    +

    17.9.5 Code generation (500-559)

      @@ -535,6 +535,16 @@ example.i(4) : Syntax error in input(1).
    • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.
    +

    Doxygen comments (560-599)

    + +
      +
    • 560: Unknown Doxygen command: command.
    • +
    • 561: Unexpected end of Doxygen comment encountered.
    • +
    • 562: Expected Doxygen command: command
    • +
    • 563: Doxygen HTML error for tag tag: error text.
    • +
    • 564: Error parsing Doxygen command command: error text. Command ignored."
    • +
    +

    17.9.6 Language module specific (700-899)

    diff --git a/Examples/test-suite/errors/doxygen_unknown_command.stderr b/Examples/test-suite/errors/doxygen_unknown_command.stderr index e92da6e6c..e5c32cc4b 100644 --- a/Examples/test-suite/errors/doxygen_unknown_command.stderr +++ b/Examples/test-suite/errors/doxygen_unknown_command.stderr @@ -1 +1 @@ -doxygen_unknown_command.i:4: Warning 560: Doxygen parser warning: unknown command "unknown". +doxygen_unknown_command.i:4: Warning 560: Unknown Doxygen command: unknown. diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 558b0401f..7286adeb0 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -279,7 +279,7 @@ std::string DoxygenParser::getStringTilEndCommand(const std::string &theCommand, m_tokenListIt++; } - printListError(WARN_DOXYGEN_COMMAND_EXPECTED, theCommand + " command expected"); + printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected Doxygen command: " + theCommand + "."); return description; } @@ -384,7 +384,7 @@ void DoxygenParser::addCommandWord(const std::string &theCommand, const TokenLis aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } else { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); } } @@ -412,7 +412,7 @@ void DoxygenParser::addCommandEndCommand(const std::string &theCommand, const To cout << "Parsing " << theCommand << endl; TokenListCIt endCommand = getEndCommand("end" + theCommand, tokList); if (endCommand == tokList.end()) { - printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected end" + theCommand); + printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected Doxygen command: end" + theCommand + "."); return; } DoxygenEntityList aNewList; @@ -428,7 +428,7 @@ void DoxygenParser::addCommandWordParagraph(const std::string &theCommand, const std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); return; } TokenListCIt endOfParagraph = getEndOfParagraph(tokList); @@ -443,7 +443,7 @@ void DoxygenParser::addCommandWordLine(const std::string &theCommand, const Toke cout << "Parsing " << theCommand << endl; std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); return; } @@ -461,7 +461,7 @@ void DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand, cons std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); return; } std::string headerfile = getNextWord(); @@ -487,8 +487,7 @@ void DoxygenParser::addCommandOWord(const std::string &theCommand, const TokenLi void DoxygenParser::addCommandErrorThrow(const std::string &theCommand, const TokenList &tokList, DoxygenEntityList &) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, - "Encountered: " + theCommand + "\nThis command should not have been encountered. Behaviour past this may be unpredictable"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": Unexpectedly encountered this command."); m_tokenListIt = getOneLine(tokList); } @@ -524,17 +523,17 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string key = getNextWord(); if (key.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No key followed the command. Command ignored."); return; } std::string heading = getNextWord(); if (key.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No heading followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No heading followed the command. Command ignored."); return; } std::string title = getNextWord(); if (title.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No title followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No title followed the command. Command ignored."); return; } TokenListCIt endOfParagraph = getEndOfParagraph(tokList); @@ -592,7 +591,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); return; } DoxygenEntityList aNewList; @@ -609,7 +608,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No key followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No key followed the command. Command ignored."); return; } DoxygenEntityList aNewList; @@ -638,7 +637,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No name followed the command. Command ignored."); return; } std::string text = getNextWord(); @@ -685,7 +684,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string file = getNextWord(); if (file.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No file followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No file followed the command. Command ignored."); return; } std::string caption = getNextWord(); @@ -700,12 +699,12 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string format = getNextWord(); if (format.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No format followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No format followed the command. Command ignored."); return; } std::string file = getNextWord(); if (file.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No name followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No name followed the command. Command ignored."); return; } std::string caption = getNextWord(); @@ -726,7 +725,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL cout << "Parsing " << theCommand << endl; std::string name = getNextWord(); if (name.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "There should be at least one word following the '" + theCommand + "' command. Command ignored."); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": There should be at least one word following the command. Command ignored."); return; } DoxygenEntityList aNewList; @@ -749,7 +748,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL if (needsCond) { cond = getNextWord(); if (cond.empty()) { - printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added"); + printListError(WARN_DOXYGEN_COMMAND_ERROR, "Error parsing Doxygen command " + theCommand + ": No word followed the command. Command ignored."); return; } } @@ -777,7 +776,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL } if (endCommand == tokList.end()) { - printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "No corresponding endif found"); + printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected Doxygen command: endif."); return; } @@ -835,7 +834,7 @@ void DoxygenParser::ignoreCommand(const std::string &theCommand, const TokenList if (!endCommand.empty()) { TokenListCIt itEnd = getEndCommand(endCommand, tokList); if (itEnd == tokList.end()) { - printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected " + endCommand); + printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected Doxygen command: " + endCommand + "."); return; } // If we ignore the command, also ignore any whitespace preceding it as we @@ -979,7 +978,7 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const Token if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) { // this could happen if we can't reach the original endParsingIndex - printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of comment encountered"); + printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of Doxygen comment encountered."); break; } } @@ -1052,7 +1051,7 @@ bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList, const std: const TokenListCIt itSave = m_tokenListIt; m_tokenListIt = m_tokenList.end(); - printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "unknown command \"" + cmd + '"'); + printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "Unknown Doxygen command: " + cmd + "."); m_tokenListIt = itSave; } @@ -1177,13 +1176,13 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) { // for example , , ... if (isEndHtmlTag) { m_tokenListIt = m_tokenList.end(); - printListError(WARN_DOXYGEN_COMMAND_ERROR, "Illegal end HTML tag without '>' found! Tag: " + cmd); + printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": Illegal end HTML tag without '>' found."); } endHtmlPos = line.find(">", pos); if (endHtmlPos == string::npos) { m_tokenListIt = m_tokenList.end(); - printListError(WARN_DOXYGEN_COMMAND_ERROR, "HTML tag without '>' found! Tag: " + cmd); + printListError(WARN_DOXYGEN_HTML_ERROR, "Doxygen HTML error for tag " + cmd + ": HTML tag without '>' found."); } // add args of HTML command, like link URL, image URL, ... m_tokenList.push_back(Token(PLAINSTRING, line.substr(pos, endHtmlPos - pos))); @@ -1268,7 +1267,7 @@ size_t DoxygenParser::processNormalComment(size_t pos, const std::string &line) break; default: m_tokenListIt = m_tokenList.end(); - printListError(WARN_DOXYGEN_COMMAND_ERROR, std::string("Unknown special character: ") + line[pos]); + printListError(WARN_DOXYGEN_UNKNOWN_CHARACTER, std::string("Unknown special character in Doxygen comment: ") + line[pos] + "."); } return pos; @@ -1418,5 +1417,5 @@ void DoxygenParser::printListError(int warningType, const std::string &message) } } - Swig_warning(warningType, m_fileName.c_str(), curLine, "Doxygen parser warning: %s.\n", message.c_str()); + Swig_warning(warningType, m_fileName.c_str(), curLine, "%s\n", message.c_str()); } diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index a7f9526e1..9f863f194 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -214,8 +214,9 @@ #define WARN_DOXYGEN_UNKNOWN_COMMAND 560 #define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 561 #define WARN_DOXYGEN_COMMAND_EXPECTED 562 -#define WARN_DOXYGEN_UNTERMINATED_STRING 563 +#define WARN_DOXYGEN_HTML_ERROR 563 #define WARN_DOXYGEN_COMMAND_ERROR 564 +#define WARN_DOXYGEN_UNKNOWN_CHARACTER 565 /* -- Reserved (600-799) -- */ From 088d7c7773e4395a0246dd90bbc85c7d27d2a7b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Jun 2018 18:52:30 +0100 Subject: [PATCH 0979/2031] Add some missing doctype tyemaps --- Lib/python/boost_shared_ptr.i | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index 8aeae5be5..709e7811d 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -399,7 +399,10 @@ %} %typemap(doctype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >& %{TYPE%} + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *, + SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& + %{TYPE%} %template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; From 85c094a325338de815fc623892998eef28742ee7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 6 Jun 2018 10:03:12 +1200 Subject: [PATCH 0980/2031] Clean up Lua probes for headers and libs Use the version reported by LUABIN to look for headers and libs. Previously you could get mismatched binary and headers (e.g. if you install packages lua5.3 and liblua5.2-dev on Debian you would get LUABIN from 5.3 but headers and libraries from 5.2 - now configure will fail to find the matching headers and not try to run Lua tests), and do a versioned search in /usr/local/include which fixes the CI failure for Lua on macOS (presumably homebrew recently started to version this path). --- CHANGES.current | 3 +++ configure.ac | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5147a315f..174c60ef6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-06: olly + [Lua] Improve configure probes for Lua headers and libs used in testsuite. + 2018-05-15: kwwette [Octave] add support for version 4.4 - Should not introduce any user-visible incompatibilities diff --git a/configure.ac b/configure.ac index 0a90d39f5..c23a82392 100644 --- a/configure.ac +++ b/configure.ac @@ -2399,35 +2399,36 @@ else if test "x$LUABIN" = xyes; then # We look for a versioned Lua binary first, as there can be # multiple versions of Lua installed on some systems (like Debian). - # The search order should match the include-file and library search - # orders below (a Lua shared library built for one version may not - # work with a Lua binary of a different version). AC_PATH_PROGS(LUABIN, [lua5.4 lua5.3 lua5.2 lua5.1 lua]) fi # check version: we need Lua 5.x if test "$LUABIN"; then AC_MSG_CHECKING(Lua version) - # if version 5.x - LUAV5=`$LUABIN -e 'if string.sub(_VERSION,5,5)=="5" then print "1" end'` - # if not version 5.0 - LUAV51=`$LUABIN -e 'if string.sub(_VERSION,5,7)~="5.0" then print "1" end'` - - if test -z "$LUAV5"; then - AC_MSG_WARN(Not Lua 5.x, SWIG does not support this version of Lua) - LUABIN="" - elif test -z "$LUAV51"; then - AC_MSG_RESULT(Lua 5.0.x) + [LUA_VERSION=`$LUABIN -e 'print(string.match(_VERSION, "%d+[.]%d+"))'`] + # For 5.0 and 5.1 header and libraries may be named using 50 or 51. + LUA_VERSION_NO_DOTS= + if test -n "$LUA_VERSION" ; then + AC_MSG_RESULT([Lua $LUA_VERSION.x]) else - AC_MSG_RESULT(Lua 5.1 or later) + AC_MSG_RESULT([failed]) fi + case $LUA_VERSION in + 5.0) LUA_VERSION_NO_DOTS=50 ;; + 5.1) LUA_VERSION_NO_DOTS=51 ;; + 5.*) ;; + *) + AC_MSG_WARN([Not Lua 5.x, SWIG does not support this version of Lua]) + LUABIN="" + ;; + esac fi if test "$LUABIN"; then AC_MSG_CHECKING(whether Lua dynamic loading is enabled) # using Lua to check Lua # lua 5.0 & 5.1 have different fn names - if test -z "$LUAV51"; then + if test "$LUA_VERSION" = "5.0"; then LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=loadlib("no_such_lib","") if c~="absent" then print "1" end'` else LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'` @@ -2456,7 +2457,12 @@ if test "$LUABIN"; then # The ordering of the include directories to search should match # the ordering of libraries to search in the library test below. inc=/usr/include - dirs="$inc/lua5.4 $inc/lua5.3 $inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include" + incloc=/usr/local/include + dirs="$inc/lua$LUA_VERSION" + test -z "$LUA_VERSION_NO_DOTS" || dirs="$dirs $inc/lua$LUA_VERSION_NO_DOTS" + dirs="$dirs $incloc/lua$LUA_VERSION" + test -z "$LUA_VERSION_NO_DOTS" || dirs="$dirs $incloc/lua$LUA_VERSION_NO_DOTS" + dirs="$dirs $incloc" for i in $dirs; do #echo "$i" if test -r $i/lua.h; then @@ -2479,11 +2485,13 @@ if test "$LUABIN"; then if test -n "$LUALIB"; then AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=]) else - AC_SEARCH_LIBS(lua_close, [lua lua5.4 lua5.3 lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=]) + libs="lua lua$LUA_VERSION" + test -z "$LUA_VERSION_NO_DOTS" || libs="$libs lua$LUA_VERSION_NO_DOTS" + AC_SEARCH_LIBS(lua_close, [$libs], [LUALINK="-l$ac_lib"],[LUABIN=]) fi # adding lualib for lua 5.0 - if test -z "$LUAV51"; then # extra for lua 5.0 + if test "$LUA_VERSION" = "5.0"; then LUALINK="$LUALINK -llualib" fi From f7a255c38acff21cad01e300ba8d8169aea9c377 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 6 Jun 2018 17:39:00 +1200 Subject: [PATCH 0981/2031] [ci] Drop builds for Python versions we're dropping We're decided that SWIG 4.0 will support Python 2.7 and >= 3.4. The patch to remove then (#1261) is waiting for the doxygen branch to be merged, but meanwhile we're wasting a lot of travis resources on 6 CI builds for Python versions we're not intending to support. [skip ci] --- .travis.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 528a4008f..59c06c637 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,36 +119,11 @@ matrix: env: SWIGLANG=php VER=7.1 sudo: required dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python VER=2.4 - sudo: required - dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python VER=2.5 - sudo: required - dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python VER=2.6 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=python # 2.7 sudo: required dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.2 - sudo: required - dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python PY3=3 VER=3.3 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.4 @@ -164,11 +139,6 @@ matrix: env: SWIGLANG=python PY3=3 VER=3.6 sudo: required dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin VER=2.6 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin From d6d5db122bb9900b4d12ebeee038b233b92b46ed Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 7 Jun 2018 18:04:45 +1200 Subject: [PATCH 0982/2031] Remove support for PHP5 PHP5 is no longer actively supported by the PHP developers and security support for it ends completely at the end of 2018, so it doesn't make sense to include support for it in the upcoming SWIG 4.0.0 release. See #701. --- .travis.yml | 8 - CHANGES.current | 6 + Doc/Manual/Php.html | 39 +- Doc/Manual/Preprocessor.html | 3 +- Doc/Manual/SWIG.html | 3 +- Examples/Makefile.in | 50 - Examples/php5/callback/Makefile | 19 - Examples/php5/callback/example.cxx | 4 - Examples/php5/callback/example.h | 22 - Examples/php5/callback/example.i | 11 - Examples/php5/callback/index.html | 19 - Examples/php5/callback/runme.php | 47 - Examples/php5/check.list | 19 - Examples/php5/class/Makefile | 20 - Examples/php5/class/example.cxx | 28 - Examples/php5/class/example.h | 34 - Examples/php5/class/example.i | 9 - Examples/php5/class/runme.php | 60 - Examples/php5/constants/Makefile | 20 - Examples/php5/constants/example.i | 26 - Examples/php5/constants/runme.php | 28 - Examples/php5/cpointer/Makefile | 20 - Examples/php5/cpointer/example.c | 16 - Examples/php5/cpointer/example.i | 31 - Examples/php5/cpointer/runme.php | 47 - Examples/php5/disown/Makefile | 20 - Examples/php5/disown/example.cxx | 51 - Examples/php5/disown/example.h | 50 - Examples/php5/disown/example.i | 12 - Examples/php5/disown/runme.php | 49 - Examples/php5/enum/Makefile | 20 - Examples/php5/enum/example.cxx | 37 - Examples/php5/enum/example.h | 13 - Examples/php5/enum/example.i | 12 - Examples/php5/enum/runme.php | 32 - Examples/php5/extend/Makefile | 19 - Examples/php5/extend/example.cxx | 4 - Examples/php5/extend/example.h | 56 - Examples/php5/extend/example.i | 15 - Examples/php5/extend/index.html | 19 - Examples/php5/extend/runme.php | 76 - Examples/php5/funcptr/Makefile | 20 - Examples/php5/funcptr/example.c | 17 - Examples/php5/funcptr/example.h | 7 - Examples/php5/funcptr/example.i | 15 - Examples/php5/funcptr/runme.php | 24 - Examples/php5/overloading/Makefile | 20 - Examples/php5/overloading/example.cxx | 55 - Examples/php5/overloading/example.h | 46 - Examples/php5/overloading/example.i | 8 - Examples/php5/overloading/runme.php | 58 - Examples/php5/pointer/Makefile | 20 - Examples/php5/pointer/example.c | 16 - Examples/php5/pointer/example.i | 30 - Examples/php5/pointer/runme.php | 35 - Examples/php5/pragmas/Makefile | 20 - Examples/php5/pragmas/example.i | 32 - Examples/php5/pragmas/include.php | 7 - Examples/php5/pragmas/runme.php | 6 - Examples/php5/proxy/Makefile | 20 - Examples/php5/proxy/example.cxx | 43 - Examples/php5/proxy/example.h | 43 - Examples/php5/proxy/example.i | 12 - Examples/php5/proxy/runme.php | 68 - Examples/php5/reference/Makefile | 20 - Examples/php5/reference/example.cxx | 49 - Examples/php5/reference/example.h | 22 - Examples/php5/reference/example.i | 43 - Examples/php5/reference/runme.php | 49 - Examples/php5/simple/Makefile | 20 - Examples/php5/simple/example.c | 23 - Examples/php5/simple/example.i | 8 - Examples/php5/simple/runme.php | 25 - Examples/php5/sync/Makefile | 20 - Examples/php5/sync/example.cxx | 13 - Examples/php5/sync/example.h | 9 - Examples/php5/sync/example.i | 7 - Examples/php5/sync/runme.php | 15 - Examples/php5/value/Makefile | 20 - Examples/php5/value/example.c | 13 - Examples/php5/value/example.h | 8 - Examples/php5/value/example.i | 17 - Examples/php5/value/runme.php | 43 - Examples/php5/variables/Makefile | 20 - Examples/php5/variables/example.c | 95 - Examples/php5/variables/example.h | 34 - Examples/php5/variables/example.i | 44 - Examples/php5/variables/runme.php | 96 - Examples/test-suite/php5/Makefile.in | 81 - .../php5/abstract_inherit_ok_runme.php | 12 - .../php5/abstract_inherit_runme.php | 14 - Examples/test-suite/php5/add_link_runme.php | 22 - Examples/test-suite/php5/argout_runme.php | 38 - Examples/test-suite/php5/arrayptr_runme.php | 14 - .../test-suite/php5/arrays_global_runme.php | 19 - .../php5/arrays_global_twodim_runme.php | 22 - Examples/test-suite/php5/arrays_runme.php | 18 - .../test-suite/php5/arrays_scope_runme.php | 16 - Examples/test-suite/php5/callback_runme.php | 9 - Examples/test-suite/php5/casts_runme.php | 18 - .../test-suite/php5/char_strings_runme.php | 43 - .../test-suite/php5/class_ignore_runme.php | 16 - .../php5/conversion_namespace_runme.php | 13 - .../php5/conversion_ns_template_runme.php | 10 - Examples/test-suite/php5/conversion_runme.php | 13 - ...pp11_strongly_typed_enumerations_runme.php | 169 - Examples/test-suite/php5/cpp_basic_runme.php | 20 - Examples/test-suite/php5/cpp_static_runme.php | 14 - .../php5/director_abstract_runme.php | 62 - .../test-suite/php5/director_basic_runme.php | 58 - .../php5/director_classic_runme.php | 150 - .../php5/director_default_runme.php | 20 - .../test-suite/php5/director_detect_runme.php | 55 - .../test-suite/php5/director_enum_runme.php | 25 - .../php5/director_exception_runme.php | 127 - .../test-suite/php5/director_extend_runme.php | 24 - .../php5/director_finalizer_runme.php | 61 - .../test-suite/php5/director_frob_runme.php | 19 - .../test-suite/php5/director_nested_runme.php | 74 - .../php5/director_pass_by_value_runme.php | 24 - .../php5/director_profile_runme.php | 53 - .../php5/director_protected_runme.php | 70 - .../test-suite/php5/director_stl_runme.php | 60 - .../test-suite/php5/director_string_runme.php | 34 - .../test-suite/php5/director_thread_runme.php | 32 - .../test-suite/php5/director_unroll_runme.php | 29 - .../php5/enum_scope_template_runme.php | 15 - .../test-suite/php5/evil_diamond_ns_runme.php | 18 - .../php5/evil_diamond_prop_runme.php | 38 - .../test-suite/php5/evil_diamond_runme.php | 16 - .../test-suite/php5/exception_order_runme.php | 39 - .../php5/extend_template_ns_runme.php | 12 - .../test-suite/php5/extend_template_runme.php | 12 - Examples/test-suite/php5/grouping_runme.php | 22 - .../php5/ignore_parameter_runme.php | 38 - .../test-suite/php5/import_nomodule_runme.php | 20 - .../test-suite/php5/li_carrays_cpp_runme.php | 22 - Examples/test-suite/php5/li_carrays_runme.php | 22 - Examples/test-suite/php5/li_factory_runme.php | 22 - .../test-suite/php5/li_std_string_runme.php | 31 - .../php5/li_std_vector_member_var_runme.php | 30 - Examples/test-suite/php5/newobject1_runme.php | 19 - Examples/test-suite/php5/newobject3_runme.php | 18 - .../test-suite/php5/overload_rename_runme.php | 19 - .../php5/overload_return_type_runme.php | 13 - .../test-suite/php5/php_iterator_runme.php | 24 - Examples/test-suite/php5/php_pragma_runme.php | 11 - .../php5/pointer_reference_runme.php | 18 - Examples/test-suite/php5/prefix_runme.php | 18 - .../php5/preproc_constants_c_runme.php | 69 - .../php5/preproc_constants_runme.php | 77 - .../test-suite/php5/primitive_ref_runme.php | 34 - .../test-suite/php5/rename_scope_runme.php | 16 - Examples/test-suite/php5/skel.php | 15 - .../php5/smart_pointer_rename_runme.php | 27 - .../test-suite/php5/swig_exception_runme.php | 33 - Examples/test-suite/php5/sym_runme.php | 22 - .../php5/template_arg_typename_runme.php | 18 - .../php5/template_construct_runme.php | 11 - Examples/test-suite/php5/tests.php | 237 -- .../php5/threads_exception_runme.php | 43 - .../php5/typedef_reference_runme.php | 13 - .../php5/typemap_ns_using_runme.php | 9 - Examples/test-suite/php5/using1_runme.php | 9 - Examples/test-suite/php5/using2_runme.php | 9 - .../php5/valuewrapper_base_runme.php | 13 - .../php5/virtual_vs_nonvirtual_base_runme.php | 11 - Examples/test-suite/php5/wrapmacro_runme.php | 12 - Examples/test-suite/restrict_cplusplus.i | 3 +- Lib/allkw.swg | 1 - Lib/cdata.i | 7 - Lib/exception.i | 7 - Lib/php/phpkw.swg | 107 +- Lib/php/phprun.swg | 2 +- Lib/php5/const.i | 51 - Lib/php5/director.swg | 170 - Lib/php5/factory.i | 109 - Lib/php5/globalvar.i | 361 -- Lib/php5/php.swg | 530 --- Lib/php5/phpinit.swg | 25 - Lib/php5/phpkw.swg | 866 ----- Lib/php5/phppointers.i | 42 - Lib/php5/phprun.swg | 280 -- Lib/php5/std_common.i | 10 - Lib/php5/std_deque.i | 1 - Lib/php5/std_map.i | 76 - Lib/php5/std_pair.i | 34 - Lib/php5/std_string.i | 79 - Lib/php5/std_vector.i | 102 - Lib/php5/stl.i | 12 - Lib/php5/typemaps.i | 322 -- Lib/php5/utils.i | 114 - Makefile.in | 10 +- Source/Makefile.am | 1 - Source/Modules/main.cxx | 2 +- Source/Modules/php.cxx | 27 +- Source/Modules/php5.cxx | 2889 ----------------- Source/Modules/swigmain.cxx | 4 +- Tools/testflags.py | 2 - Tools/travis-linux-install.sh | 3 - configure.ac | 61 - 201 files changed, 94 insertions(+), 11358 deletions(-) delete mode 100644 Examples/php5/callback/Makefile delete mode 100644 Examples/php5/callback/example.cxx delete mode 100644 Examples/php5/callback/example.h delete mode 100644 Examples/php5/callback/example.i delete mode 100644 Examples/php5/callback/index.html delete mode 100644 Examples/php5/callback/runme.php delete mode 100644 Examples/php5/check.list delete mode 100644 Examples/php5/class/Makefile delete mode 100644 Examples/php5/class/example.cxx delete mode 100644 Examples/php5/class/example.h delete mode 100644 Examples/php5/class/example.i delete mode 100644 Examples/php5/class/runme.php delete mode 100644 Examples/php5/constants/Makefile delete mode 100644 Examples/php5/constants/example.i delete mode 100644 Examples/php5/constants/runme.php delete mode 100644 Examples/php5/cpointer/Makefile delete mode 100644 Examples/php5/cpointer/example.c delete mode 100644 Examples/php5/cpointer/example.i delete mode 100644 Examples/php5/cpointer/runme.php delete mode 100644 Examples/php5/disown/Makefile delete mode 100644 Examples/php5/disown/example.cxx delete mode 100644 Examples/php5/disown/example.h delete mode 100644 Examples/php5/disown/example.i delete mode 100644 Examples/php5/disown/runme.php delete mode 100644 Examples/php5/enum/Makefile delete mode 100644 Examples/php5/enum/example.cxx delete mode 100644 Examples/php5/enum/example.h delete mode 100644 Examples/php5/enum/example.i delete mode 100644 Examples/php5/enum/runme.php delete mode 100644 Examples/php5/extend/Makefile delete mode 100644 Examples/php5/extend/example.cxx delete mode 100644 Examples/php5/extend/example.h delete mode 100644 Examples/php5/extend/example.i delete mode 100644 Examples/php5/extend/index.html delete mode 100644 Examples/php5/extend/runme.php delete mode 100644 Examples/php5/funcptr/Makefile delete mode 100644 Examples/php5/funcptr/example.c delete mode 100644 Examples/php5/funcptr/example.h delete mode 100644 Examples/php5/funcptr/example.i delete mode 100644 Examples/php5/funcptr/runme.php delete mode 100644 Examples/php5/overloading/Makefile delete mode 100644 Examples/php5/overloading/example.cxx delete mode 100644 Examples/php5/overloading/example.h delete mode 100644 Examples/php5/overloading/example.i delete mode 100644 Examples/php5/overloading/runme.php delete mode 100644 Examples/php5/pointer/Makefile delete mode 100644 Examples/php5/pointer/example.c delete mode 100644 Examples/php5/pointer/example.i delete mode 100644 Examples/php5/pointer/runme.php delete mode 100644 Examples/php5/pragmas/Makefile delete mode 100644 Examples/php5/pragmas/example.i delete mode 100644 Examples/php5/pragmas/include.php delete mode 100644 Examples/php5/pragmas/runme.php delete mode 100644 Examples/php5/proxy/Makefile delete mode 100644 Examples/php5/proxy/example.cxx delete mode 100644 Examples/php5/proxy/example.h delete mode 100644 Examples/php5/proxy/example.i delete mode 100644 Examples/php5/proxy/runme.php delete mode 100644 Examples/php5/reference/Makefile delete mode 100644 Examples/php5/reference/example.cxx delete mode 100644 Examples/php5/reference/example.h delete mode 100644 Examples/php5/reference/example.i delete mode 100644 Examples/php5/reference/runme.php delete mode 100644 Examples/php5/simple/Makefile delete mode 100644 Examples/php5/simple/example.c delete mode 100644 Examples/php5/simple/example.i delete mode 100644 Examples/php5/simple/runme.php delete mode 100644 Examples/php5/sync/Makefile delete mode 100644 Examples/php5/sync/example.cxx delete mode 100644 Examples/php5/sync/example.h delete mode 100644 Examples/php5/sync/example.i delete mode 100644 Examples/php5/sync/runme.php delete mode 100644 Examples/php5/value/Makefile delete mode 100644 Examples/php5/value/example.c delete mode 100644 Examples/php5/value/example.h delete mode 100644 Examples/php5/value/example.i delete mode 100644 Examples/php5/value/runme.php delete mode 100644 Examples/php5/variables/Makefile delete mode 100644 Examples/php5/variables/example.c delete mode 100644 Examples/php5/variables/example.h delete mode 100644 Examples/php5/variables/example.i delete mode 100644 Examples/php5/variables/runme.php delete mode 100644 Examples/test-suite/php5/Makefile.in delete mode 100644 Examples/test-suite/php5/abstract_inherit_ok_runme.php delete mode 100644 Examples/test-suite/php5/abstract_inherit_runme.php delete mode 100644 Examples/test-suite/php5/add_link_runme.php delete mode 100644 Examples/test-suite/php5/argout_runme.php delete mode 100644 Examples/test-suite/php5/arrayptr_runme.php delete mode 100644 Examples/test-suite/php5/arrays_global_runme.php delete mode 100644 Examples/test-suite/php5/arrays_global_twodim_runme.php delete mode 100644 Examples/test-suite/php5/arrays_runme.php delete mode 100644 Examples/test-suite/php5/arrays_scope_runme.php delete mode 100644 Examples/test-suite/php5/callback_runme.php delete mode 100644 Examples/test-suite/php5/casts_runme.php delete mode 100644 Examples/test-suite/php5/char_strings_runme.php delete mode 100644 Examples/test-suite/php5/class_ignore_runme.php delete mode 100644 Examples/test-suite/php5/conversion_namespace_runme.php delete mode 100644 Examples/test-suite/php5/conversion_ns_template_runme.php delete mode 100644 Examples/test-suite/php5/conversion_runme.php delete mode 100644 Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php delete mode 100644 Examples/test-suite/php5/cpp_basic_runme.php delete mode 100644 Examples/test-suite/php5/cpp_static_runme.php delete mode 100644 Examples/test-suite/php5/director_abstract_runme.php delete mode 100644 Examples/test-suite/php5/director_basic_runme.php delete mode 100644 Examples/test-suite/php5/director_classic_runme.php delete mode 100644 Examples/test-suite/php5/director_default_runme.php delete mode 100644 Examples/test-suite/php5/director_detect_runme.php delete mode 100644 Examples/test-suite/php5/director_enum_runme.php delete mode 100644 Examples/test-suite/php5/director_exception_runme.php delete mode 100644 Examples/test-suite/php5/director_extend_runme.php delete mode 100644 Examples/test-suite/php5/director_finalizer_runme.php delete mode 100644 Examples/test-suite/php5/director_frob_runme.php delete mode 100644 Examples/test-suite/php5/director_nested_runme.php delete mode 100644 Examples/test-suite/php5/director_pass_by_value_runme.php delete mode 100644 Examples/test-suite/php5/director_profile_runme.php delete mode 100644 Examples/test-suite/php5/director_protected_runme.php delete mode 100644 Examples/test-suite/php5/director_stl_runme.php delete mode 100644 Examples/test-suite/php5/director_string_runme.php delete mode 100644 Examples/test-suite/php5/director_thread_runme.php delete mode 100644 Examples/test-suite/php5/director_unroll_runme.php delete mode 100644 Examples/test-suite/php5/enum_scope_template_runme.php delete mode 100644 Examples/test-suite/php5/evil_diamond_ns_runme.php delete mode 100644 Examples/test-suite/php5/evil_diamond_prop_runme.php delete mode 100644 Examples/test-suite/php5/evil_diamond_runme.php delete mode 100644 Examples/test-suite/php5/exception_order_runme.php delete mode 100644 Examples/test-suite/php5/extend_template_ns_runme.php delete mode 100644 Examples/test-suite/php5/extend_template_runme.php delete mode 100644 Examples/test-suite/php5/grouping_runme.php delete mode 100644 Examples/test-suite/php5/ignore_parameter_runme.php delete mode 100644 Examples/test-suite/php5/import_nomodule_runme.php delete mode 100644 Examples/test-suite/php5/li_carrays_cpp_runme.php delete mode 100644 Examples/test-suite/php5/li_carrays_runme.php delete mode 100644 Examples/test-suite/php5/li_factory_runme.php delete mode 100644 Examples/test-suite/php5/li_std_string_runme.php delete mode 100644 Examples/test-suite/php5/li_std_vector_member_var_runme.php delete mode 100644 Examples/test-suite/php5/newobject1_runme.php delete mode 100644 Examples/test-suite/php5/newobject3_runme.php delete mode 100644 Examples/test-suite/php5/overload_rename_runme.php delete mode 100644 Examples/test-suite/php5/overload_return_type_runme.php delete mode 100644 Examples/test-suite/php5/php_iterator_runme.php delete mode 100644 Examples/test-suite/php5/php_pragma_runme.php delete mode 100644 Examples/test-suite/php5/pointer_reference_runme.php delete mode 100644 Examples/test-suite/php5/prefix_runme.php delete mode 100644 Examples/test-suite/php5/preproc_constants_c_runme.php delete mode 100644 Examples/test-suite/php5/preproc_constants_runme.php delete mode 100644 Examples/test-suite/php5/primitive_ref_runme.php delete mode 100644 Examples/test-suite/php5/rename_scope_runme.php delete mode 100644 Examples/test-suite/php5/skel.php delete mode 100644 Examples/test-suite/php5/smart_pointer_rename_runme.php delete mode 100644 Examples/test-suite/php5/swig_exception_runme.php delete mode 100644 Examples/test-suite/php5/sym_runme.php delete mode 100644 Examples/test-suite/php5/template_arg_typename_runme.php delete mode 100644 Examples/test-suite/php5/template_construct_runme.php delete mode 100644 Examples/test-suite/php5/tests.php delete mode 100644 Examples/test-suite/php5/threads_exception_runme.php delete mode 100644 Examples/test-suite/php5/typedef_reference_runme.php delete mode 100644 Examples/test-suite/php5/typemap_ns_using_runme.php delete mode 100644 Examples/test-suite/php5/using1_runme.php delete mode 100644 Examples/test-suite/php5/using2_runme.php delete mode 100644 Examples/test-suite/php5/valuewrapper_base_runme.php delete mode 100644 Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php delete mode 100644 Examples/test-suite/php5/wrapmacro_runme.php delete mode 100644 Lib/php5/const.i delete mode 100644 Lib/php5/director.swg delete mode 100644 Lib/php5/factory.i delete mode 100644 Lib/php5/globalvar.i delete mode 100644 Lib/php5/php.swg delete mode 100644 Lib/php5/phpinit.swg delete mode 100644 Lib/php5/phpkw.swg delete mode 100644 Lib/php5/phppointers.i delete mode 100644 Lib/php5/phprun.swg delete mode 100644 Lib/php5/std_common.i delete mode 100644 Lib/php5/std_deque.i delete mode 100644 Lib/php5/std_map.i delete mode 100644 Lib/php5/std_pair.i delete mode 100644 Lib/php5/std_string.i delete mode 100644 Lib/php5/std_vector.i delete mode 100644 Lib/php5/stl.i delete mode 100644 Lib/php5/typemaps.i delete mode 100644 Lib/php5/utils.i delete mode 100644 Source/Modules/php5.cxx diff --git a/.travis.yml b/.travis.yml index 59c06c637..7e7af91a2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -104,11 +104,6 @@ matrix: env: SWIGLANG=perl5 sudo: required dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=php5 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=php VER=7.0 @@ -308,9 +303,6 @@ matrix: - compiler: clang os: osx env: SWIGLANG=perl5 - - compiler: clang - os: osx - env: SWIGLANG=php5 - compiler: clang os: osx env: SWIGLANG=python diff --git a/CHANGES.current b/CHANGES.current index 174c60ef6..3a0e5c079 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-07: olly + [PHP5] Support for PHP5 has been removed. PHP5 is no longer + actively supported by the PHP developers and security support for + it ends completely at the end of 2018, so it doesn't make sense + to include support for it in the upcoming SWIG 4.0.0 release. + 2018-06-06: olly [Lua] Improve configure probes for Lua headers and libs used in testsuite. diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 8d2c3e8e4..d72bc058e 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -50,20 +50,13 @@

    -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 now supports most -of the features available in some of the other languages. +In this chapter, we discuss SWIG's support of PHP. SWIG currently supports +generating wrappers for PHP7. Support for PHP5 was removed in SWIG 4.0.0 +and support for PHP4 was removed in SWIG 1.3.37.

    -SWIG supports generating wrappers for PHP5 and PHP7. Support for PHP4 was removed -in SWIG 1.3.37. -

    - -

    -Currently any PHP5 or PHP7 release should work, but we don't regularly test with -PHP < 5.3. +Currently any PHP7 release should work.

    @@ -81,9 +74,9 @@ available.

    -To build a PHP extension, run swig using the -php5 or --php7 option as follows (-php is also supported -and currently is an alias for -php5): +To build a PHP extension, run swig using the -php7 option as follows +(-php is also supported and currently is an alias for -php7 +but prior to SWIG 4.0.0 it was an alias for -php5):

    @@ -107,9 +100,7 @@ also contain PHP class wrappers.
     SWIG can generate PHP extensions from C++ libraries as well when
     given the -c++ option.  The support for C++ is discussed in
     more detail in section 27.2.6.  The generated
    -C++ wrapper will be called example_wrap.cpp (for PHP5) or
    -example_wrap.cxx (for PHP7 where the default has been changed to align
    -with SWIG's default for every other language).  You can specify a
    +C++ wrapper will be called example_wrap.cxx.  You can specify a
     different extension for the C++ wrapper using -cppext -
     e.g. if you want example_wrap.cc use -cppext cc.
     

    @@ -172,8 +163,8 @@ PHP script which uses your extension:

    -But note that this doesn't work when running PHP through a webserver in PHP5.3 -and later - you'll need to use extension in php.ini as +But note that dl() isn't supported when running PHP through a +webserver - you'll need to use extension in php.ini as described above.

    @@ -199,7 +190,8 @@ It is important to understand that PHP uses a single global namespace into which all symbols from extension modules are loaded. It is quite possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them. At present -SWIG doesn't have support for the namespace feature added in PHP 5.3. +SWIG doesn't have support for generating wrappers which make use of PHP's +namespace feature.

    35.2.1 Constants

    @@ -525,13 +517,6 @@ this, one needs to include phppointers.i which defines the named typemap REF.

    -

    -Prior to SWIG 3.0, the REF typemaps relied on PHP's call-time -pass-by-reference, which was deprecated in PHP 5.3 and removed in PHP 5.4. -So if you use these REF typemaps, you should ensure that SWIG≥3.0 is -used to generate wrappers from your interface file. -

    -

    In case you write your own typemaps, SWIG supports an attribute called byref: if you set that, then SWIG will make sure that the generated diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 8e638f3ba..83a17f2c4 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -125,8 +125,7 @@ SWIGMZSCHEME Defined when using Mzscheme SWIGOCAML Defined when using Ocaml SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl -SWIGPHP Defined when using PHP5 or PHP7 -SWIGPHP5 Defined when using PHP5 +SWIGPHP Defined when using PHP (any version) SWIGPHP7 Defined when using PHP7 SWIGPIKE Defined when using Pike SWIGPYTHON Defined when using Python diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index ffc373f24..70fc694e3 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -131,7 +131,6 @@ can be obtained by typing swig -help or swig -ocaml Generate Ocaml wrappers -octave Generate Octave wrappers -perl Generate Perl wrappers --php5 Generate PHP5 wrappers -php7 Generate PHP7 wrappers -pike Generate Pike wrappers -python Generate Python wrappers @@ -145,7 +144,7 @@ can be obtained by typing swig -help or swig -c++ Enable C++ processing -cppext ext Change file extension of C++ generated files to ext - (default is cxx, except for PHP5 which uses cpp) + (default is cxx) -Dsymbol Define a preprocessor symbol -Fmicrosoft Display error/warning messages in Microsoft format -Fstandard Display error/warning messages in commonly used format diff --git a/Examples/Makefile.in b/Examples/Makefile.in index d22450ec9..3f07aed29 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1071,56 +1071,6 @@ ruby_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(RUBY_SO) -################################################################## -##### PHP5 ###### -################################################################## - -PHP5 = @PHP5@ -PHP5_INCLUDE = @PHP5INC@ -PHP5_SO = @PHP5_SO@ -PHP5_SCRIPT = $(SRCDIR)$(RUNME).php - -# ------------------------------------------------------------------- -# Build a PHP5 dynamically loadable module (C) -# ------------------------------------------------------------------- - -php5: $(SRCDIR_SRCS) - $(SWIG) -php5 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES) $(PHP5_INCLUDE) - $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO) - -# -------------------------------------------------------------------- -# Build a PHP5 dynamically loadable module (C++) -# -------------------------------------------------------------------- - -php5_cpp: $(SRCDIR_SRCS) - $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP5_INCLUDE) - $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP5_SO) - -# ----------------------------------------------------------------- -# Running a PHP5 example -# ----------------------------------------------------------------- - -php5_run: - $(RUNTOOL) $(PHP5) -n -q -d extension_dir=. -d safe_mode=Off $(PHP5_SCRIPT) $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -php5_version: - $(PHP5) -v | head -n 1 - -# ----------------------------------------------------------------- -# Cleaning the PHP5 examples -# ----------------------------------------------------------------- - -php5_clean: - rm -f *_wrap* *~ .~* example.php php_example.h - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *$(PHP5_SO) - ################################################################## ##### PHP7 ###### ################################################################## diff --git a/Examples/php5/callback/Makefile b/Examples/php5/callback/Makefile deleted file mode 100644 index 3a34106c3..000000000 --- a/Examples/php5/callback/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lm -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/callback/example.cxx b/Examples/php5/callback/example.cxx deleted file mode 100644 index 450d75608..000000000 --- a/Examples/php5/callback/example.cxx +++ /dev/null @@ -1,4 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" - diff --git a/Examples/php5/callback/example.h b/Examples/php5/callback/example.h deleted file mode 100644 index 2a0194999..000000000 --- a/Examples/php5/callback/example.h +++ /dev/null @@ -1,22 +0,0 @@ -/* File : example.h */ - -#include - -class Callback { -public: - virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } - virtual void run() { std::cout << "Callback::run()" << std::endl; } -}; - - -class Caller { -private: - Callback *_callback; -public: - Caller(): _callback(0) {} - ~Caller() { delCallback(); } - void delCallback() { delete _callback; _callback = 0; } - void setCallback(Callback *cb) { delCallback(); _callback = cb; } - void call() { if (_callback) _callback->run(); } -}; - diff --git a/Examples/php5/callback/example.i b/Examples/php5/callback/example.i deleted file mode 100644 index cf61ef9d2..000000000 --- a/Examples/php5/callback/example.i +++ /dev/null @@ -1,11 +0,0 @@ -/* File : example.i */ -%module(directors="1") example -%{ -#include "example.h" -%} - -/* turn on director wrapping Callback */ -%feature("director") Callback; - -%include "example.h" - diff --git a/Examples/php5/callback/index.html b/Examples/php5/callback/index.html deleted file mode 100644 index 2a6cbdff9..000000000 --- a/Examples/php5/callback/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - -SWIG:Examples:php5:callback - - - - - -SWIG/Examples/php5/callback/ -


    - -

    Implementing C++ callbacks in PHP5

    - -

    -This example illustrates how to use directors to implement C++ callbacks in PHP5. - -


    - - diff --git a/Examples/php5/callback/runme.php b/Examples/php5/callback/runme.php deleted file mode 100644 index 2be71994f..000000000 --- a/Examples/php5/callback/runme.php +++ /dev/null @@ -1,47 +0,0 @@ -thisown = 0; -$caller->setCallback($callback); -$caller->call(); -$caller->delCallback(); - -print "\n"; -print "Adding and calling a PHP callback\n"; -print "------------------------------------\n"; - -# Add a PHP callback. - -$callback = new PhpCallback(); -$callback->thisown = 0; -$caller->setCallback($callback); -$caller->call(); -$caller->delCallback(); - -# All done. - -print "php exit\n"; - -?> diff --git a/Examples/php5/check.list b/Examples/php5/check.list deleted file mode 100644 index fef3feba6..000000000 --- a/Examples/php5/check.list +++ /dev/null @@ -1,19 +0,0 @@ -# see top-level Makefile.in -# (see also top-level configure.ac kludge) -callback -class -constants -cpointer -disown -enum -extend -funcptr -overloading -pointer -pragmas -proxy -reference -simple -sync -value -variables diff --git a/Examples/php5/class/Makefile b/Examples/php5/class/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/class/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/class/example.cxx b/Examples/php5/class/example.cxx deleted file mode 100644 index 046304519..000000000 --- a/Examples/php5/class/example.cxx +++ /dev/null @@ -1,28 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area() { - return M_PI*radius*radius; -} - -double Circle::perimeter() { - return 2*M_PI*radius; -} - -double Square::area() { - return width*width; -} - -double Square::perimeter() { - return 4*width; -} diff --git a/Examples/php5/class/example.h b/Examples/php5/class/example.h deleted file mode 100644 index 0dff185b2..000000000 --- a/Examples/php5/class/example.h +++ /dev/null @@ -1,34 +0,0 @@ -/* File : example.h */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area() = 0; - virtual double perimeter() = 0; - static int nshapes; -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - virtual double area(); - virtual double perimeter(); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - virtual double area(); - virtual double perimeter(); -}; diff --git a/Examples/php5/class/example.i b/Examples/php5/class/example.i deleted file mode 100644 index fbdf7249f..000000000 --- a/Examples/php5/class/example.i +++ /dev/null @@ -1,9 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" diff --git a/Examples/php5/class/runme.php b/Examples/php5/class/runme.php deleted file mode 100644 index 99c253b46..000000000 --- a/Examples/php5/class/runme.php +++ /dev/null @@ -1,60 +0,0 @@ -x = 20; -$c->y = 30; -$s->x = -10; -$s->y = 5; - -print "\nHere is their current position:\n"; -print " Circle = ({$c->x},{$c->y})\n"; -print " Square = ({$s->x},{$s->y})\n"; - -# ----- Call some methods ----- - -# Notice how the Shape_area() and Shape_perimeter() functions really -# invoke the appropriate virtual method on each object. -print "\nHere are some properties of the shapes:\n"; -foreach (array($c,$s) as $o) { - print " ". get_class($o) . "\n"; - print " area = {$o->area()}\n"; - print " perimeter = {$o->perimeter()}\n"; -} - -# ----- Delete everything ----- - -print "\nGuess I'll clean up now\n"; - -# Note: this invokes the virtual destructor -$c = NULL; -$s = NULL; - -# and don't forget the $o from the for loop above. It still refers to -# the square. -$o = NULL; - -print Shape::nshapes() . " shapes remain\n"; -print "Goodbye\n"; - -?> diff --git a/Examples/php5/constants/Makefile b/Examples/php5/constants/Makefile deleted file mode 100644 index f9557fa89..000000000 --- a/Examples/php5/constants/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/constants/example.i b/Examples/php5/constants/example.i deleted file mode 100644 index 0098a893a..000000000 --- a/Examples/php5/constants/example.i +++ /dev/null @@ -1,26 +0,0 @@ -/* File : example.i */ -%module example - -/* A few preprocessor macros */ - -#define ICONST 42 -#define FCONST 2.1828 -#define CCONST 'x' -#define CCONST2 '\n' -#define SCONST "Hello World" -#define SCONST2 "\"Hello World\"" - -/* This should work just fine */ -#define EXPR ICONST + 3*(FCONST) - -/* This shouldn't do anything */ -#define EXTERN extern - -/* Neither should this (BAR isn't defined) */ -#define FOO (ICONST + BAR) - -/* The following statements also produce constants */ -%constant int iconst = 37; -%constant double fconst = 3.14; - - diff --git a/Examples/php5/constants/runme.php b/Examples/php5/constants/runme.php deleted file mode 100644 index cea06485f..000000000 --- a/Examples/php5/constants/runme.php +++ /dev/null @@ -1,28 +0,0 @@ - diff --git a/Examples/php5/cpointer/Makefile b/Examples/php5/cpointer/Makefile deleted file mode 100644 index 92085788a..000000000 --- a/Examples/php5/cpointer/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/cpointer/example.c b/Examples/php5/cpointer/example.c deleted file mode 100644 index 04dd08df0..000000000 --- a/Examples/php5/cpointer/example.c +++ /dev/null @@ -1,16 +0,0 @@ -/* File : example.c */ - -void add(int *x, int *y, int *result) { - *result = *x + *y; -} - -void sub(int *x, int *y, int *result) { - *result = *x - *y; -} - -int divide(int n, int d, int *r) { - int q; - q = n/d; - *r = n - q*d; - return q; -} diff --git a/Examples/php5/cpointer/example.i b/Examples/php5/cpointer/example.i deleted file mode 100644 index c61d92858..000000000 --- a/Examples/php5/cpointer/example.i +++ /dev/null @@ -1,31 +0,0 @@ -/* File : example.i */ -%module example - -%{ -extern void add(int *, int *, int *); -extern void sub(int *, int *, int *); -%} - -/* This example illustrates a couple of different techniques - for manipulating C pointers */ - -/* First we'll use the pointer library */ -extern void add(int *x, int *y, int *result); - -%include cpointer.i -%pointer_functions(int, intp); - -/* Next we'll use some typemaps */ - -%include typemaps.i -extern void sub(int *INPUT, int *INPUT, int *OUTPUT); - -/* Next we'll use typemaps and the %apply directive */ - -//%apply int *OUTPUT { int *r }; -//extern int divide(int n, int d, int *r); - - - - - diff --git a/Examples/php5/cpointer/runme.php b/Examples/php5/cpointer/runme.php deleted file mode 100644 index 22e8a681a..000000000 --- a/Examples/php5/cpointer/runme.php +++ /dev/null @@ -1,47 +0,0 @@ - diff --git a/Examples/php5/disown/Makefile b/Examples/php5/disown/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/disown/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/disown/example.cxx b/Examples/php5/disown/example.cxx deleted file mode 100644 index 6393735e9..000000000 --- a/Examples/php5/disown/example.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#include -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -int Shape::get_nshapes() { - return nshapes; -} - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -void Circle::set_radius( double r ) { - radius = r; -} - -double Circle::area(void) { - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} - -ShapeContainer::~ShapeContainer() { - iterator i=shapes.begin(); - for( iterator i = shapes.begin(); i != shapes.end(); ++i ) { - delete *i; - } -} - -void -ShapeContainer::addShape( Shape *s ) { - shapes.push_back( s ); -} diff --git a/Examples/php5/disown/example.h b/Examples/php5/disown/example.h deleted file mode 100644 index e9f96743f..000000000 --- a/Examples/php5/disown/example.h +++ /dev/null @@ -1,50 +0,0 @@ -/* File : example.h */ - -#include - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area(void) = 0; - virtual double perimeter(void) = 0; - static int nshapes; - static int get_nshapes(); -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - ~Circle() { } - void set_radius( double r ); - virtual double area(void); - virtual double perimeter(void); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - ~Square() { } - virtual double area(void); - virtual double perimeter(void); -}; - -class ShapeContainer { -private: - typedef std::vector::iterator iterator; - std::vector shapes; -public: - ShapeContainer() : shapes() {} - ~ShapeContainer(); - void addShape( Shape *s ); -}; diff --git a/Examples/php5/disown/example.i b/Examples/php5/disown/example.i deleted file mode 100644 index 599f162c5..000000000 --- a/Examples/php5/disown/example.i +++ /dev/null @@ -1,12 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -%apply SWIGTYPE *DISOWN {(Shape *s)}; - -/* Let's just grab the original header file here */ -%include "example.h" - diff --git a/Examples/php5/disown/runme.php b/Examples/php5/disown/runme.php deleted file mode 100644 index a70d7b061..000000000 --- a/Examples/php5/disown/runme.php +++ /dev/null @@ -1,49 +0,0 @@ -addShape($c); -$container->addShape($s); - -# ----- Access a static member ----- - -print "\nA total of " . Shape::nshapes() . " shapes were created\n"; - -# ----- Delete by the old references ----- -# This should not truly delete the shapes because they are now owned -# by the ShapeContainer. - -print "Delete the old references."; - -# Note: this invokes the virtual destructor -$c = NULL; -$s = NULL; - -print "\nA total of " . Shape::nshapes() . " shapes remain\n"; - -# ----- Delete by the container ----- -# This should truly delete the shapes - -print "Delete the container."; -$container = NULL; -print "\nA total of " . Shape::nshapes() . " shapes remain\n"; - -print "Goodbye\n"; - -?> diff --git a/Examples/php5/enum/Makefile b/Examples/php5/enum/Makefile deleted file mode 100644 index dc59a6c9b..000000000 --- a/Examples/php5/enum/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = -noproxy - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/enum/example.cxx b/Examples/php5/enum/example.cxx deleted file mode 100644 index df7bb6328..000000000 --- a/Examples/php5/enum/example.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" -#include - -void Foo::enum_test(speed s) { - if (s == IMPULSE) { - printf("IMPULSE speed\n"); - } else if (s == WARP) { - printf("WARP speed\n"); - } else if (s == LUDICROUS) { - printf("LUDICROUS speed\n"); - } else { - printf("Unknown speed\n"); - } -} - -void enum_test(color c, Foo::speed s) { - if (c == RED) { - printf("color = RED, "); - } else if (c == BLUE) { - printf("color = BLUE, "); - } else if (c == GREEN) { - printf("color = GREEN, "); - } else { - printf("color = Unknown color!, "); - } - if (s == Foo::IMPULSE) { - printf("speed = IMPULSE speed\n"); - } else if (s == Foo::WARP) { - printf("speed = WARP speed\n"); - } else if (s == Foo::LUDICROUS) { - printf("speed = LUDICROUS speed\n"); - } else { - printf("speed = Unknown speed!\n"); - } -} diff --git a/Examples/php5/enum/example.h b/Examples/php5/enum/example.h deleted file mode 100644 index 525d62afc..000000000 --- a/Examples/php5/enum/example.h +++ /dev/null @@ -1,13 +0,0 @@ -/* File : example.h */ - -enum color { RED, BLUE, GREEN }; - -class Foo { - public: - Foo() { } - enum speed { IMPULSE, WARP, LUDICROUS }; - void enum_test(speed s); -}; - -void enum_test(color c, Foo::speed s); - diff --git a/Examples/php5/enum/example.i b/Examples/php5/enum/example.i deleted file mode 100644 index abf254731..000000000 --- a/Examples/php5/enum/example.i +++ /dev/null @@ -1,12 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - - -/* Let's just grab the original header file here */ - -%include "example.h" - diff --git a/Examples/php5/enum/runme.php b/Examples/php5/enum/runme.php deleted file mode 100644 index 55b0bc4c3..000000000 --- a/Examples/php5/enum/runme.php +++ /dev/null @@ -1,32 +0,0 @@ - diff --git a/Examples/php5/extend/Makefile b/Examples/php5/extend/Makefile deleted file mode 100644 index 3a34106c3..000000000 --- a/Examples/php5/extend/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lm -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/extend/example.cxx b/Examples/php5/extend/example.cxx deleted file mode 100644 index 450d75608..000000000 --- a/Examples/php5/extend/example.cxx +++ /dev/null @@ -1,4 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" - diff --git a/Examples/php5/extend/example.h b/Examples/php5/extend/example.h deleted file mode 100644 index ca1aed28f..000000000 --- a/Examples/php5/extend/example.h +++ /dev/null @@ -1,56 +0,0 @@ -/* File : example.h */ - -#include -#include -#include -#include -#include - -class Employee { -private: - std::string name; -public: - Employee(const char* n): name(n) {} - virtual std::string getTitle() { return getPosition() + " " + getName(); } - virtual std::string getName() { return name; } - virtual std::string getPosition() const { return "Employee"; } - virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); } -}; - - -class Manager: public Employee { -public: - Manager(const char* n): Employee(n) {} - virtual std::string getPosition() const { return "Manager"; } -}; - - -class EmployeeList { - std::vector list; -public: - EmployeeList() { - list.push_back(new Employee("Bob")); - list.push_back(new Employee("Jane")); - list.push_back(new Manager("Ted")); - } - void addEmployee(Employee *p) { - list.push_back(p); - std::cout << "New employee added. Current employees are:" << std::endl; - std::vector::iterator i; - for (i=list.begin(); i!=list.end(); i++) { - std::cout << " " << (*i)->getTitle() << std::endl; - } - } - const Employee *get_item(int i) { - return list[i]; - } - ~EmployeeList() { - std::vector::iterator i; - std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; - for (i=list.begin(); i!=list.end(); i++) { - delete *i; - } - std::cout << "~EmployeeList empty." << std::endl; - } -}; - diff --git a/Examples/php5/extend/example.i b/Examples/php5/extend/example.i deleted file mode 100644 index c8ec32e09..000000000 --- a/Examples/php5/extend/example.i +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.i */ -%module(directors="1") example -%{ -#include "example.h" -%} - -%include "std_vector.i" -%include "std_string.i" - -/* turn on director wrapping for Manager */ -%feature("director") Employee; -%feature("director") Manager; - -%include "example.h" - diff --git a/Examples/php5/extend/index.html b/Examples/php5/extend/index.html deleted file mode 100644 index 32c6a4913..000000000 --- a/Examples/php5/extend/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - -SWIG:Examples:php:extend - - - - - -SWIG/Examples/php/extend/ -
    - -

    Extending a simple C++ class in PHP

    - -

    -This example illustrates the extending of a C++ class with cross language polymorphism. - -


    - - diff --git a/Examples/php5/extend/runme.php b/Examples/php5/extend/runme.php deleted file mode 100644 index 158683142..000000000 --- a/Examples/php5/extend/runme.php +++ /dev/null @@ -1,76 +0,0 @@ -getName() . " is a " . $e->getPosition() . "\n"; -printf("Just call her \"%s\"\n", $e->getTitle()); -print "----------------------\n"; - -# Create a new EmployeeList instance. This class does not have a C++ -# director wrapper, but can be used freely with other classes that do. - -$list = new EmployeeList(); - -# EmployeeList owns its items, so we must surrender ownership of objects -# we add. This involves first clearing the ->disown member to tell the -# C++ director to start reference counting. - -$e->thisown = 0; -$list->addEmployee($e); -print "----------------------\n"; - -# Now we access the first four items in list (three are C++ objects that -# EmployeeList's constructor adds, the last is our CEO). The virtual -# methods of all these instances are treated the same. For items 0, 1, and -# 2, both all methods resolve in C++. For item 3, our CEO, getTitle calls -# getPosition which resolves in PHP. The call to getPosition is -# slightly different, however, from the e.getPosition() call above, since -# now the object reference has been "laundered" by passing through -# EmployeeList as an Employee*. Previously, PHP resolved the call -# immediately in CEO, but now PHP thinks the object is an instance of -# class Employee (actually EmployeePtr). So the call passes through the -# Employee proxy class and on to the C wrappers and C++ director, -# eventually ending up back at the CEO implementation of getPosition(). -# The call to getTitle() for item 3 runs the C++ Employee::getTitle() -# method, which in turn calls getPosition(). This virtual method call -# passes down through the C++ director class to the PHP implementation -# in CEO. All this routing takes place transparently. - -print "(position, title) for items 0-3:\n"; - -printf(" %s, \"%s\"\n", $list->get_item(0)->getPosition(), $list->get_item(0)->getTitle()); -printf(" %s, \"%s\"\n", $list->get_item(1)->getPosition(), $list->get_item(1)->getTitle()); -printf(" %s, \"%s\"\n", $list->get_item(2)->getPosition(), $list->get_item(2)->getTitle()); -printf(" %s, \"%s\"\n", $list->get_item(3)->getPosition(), $list->get_item(3)->getTitle()); -print "----------------------\n"; - -# Time to delete the EmployeeList, which will delete all the Employee* -# items it contains. The last item is our CEO, which gets destroyed as its -# reference count goes to zero. The PHP destructor runs, and is still -# able to call the getName() method since the underlying C++ object still -# exists. After this destructor runs the remaining C++ destructors run as -# usual to destroy the object. - -unset($list); -print "----------------------\n"; - -# All done. - -print "php exit\n"; - -?> diff --git a/Examples/php5/funcptr/Makefile b/Examples/php5/funcptr/Makefile deleted file mode 100644 index 92085788a..000000000 --- a/Examples/php5/funcptr/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/funcptr/example.c b/Examples/php5/funcptr/example.c deleted file mode 100644 index 99583b72e..000000000 --- a/Examples/php5/funcptr/example.c +++ /dev/null @@ -1,17 +0,0 @@ -/* File : example.c */ - -int do_op(int a, int b, int (*op)(int,int)) { - return (*op)(a,b); -} - -int add(int a, int b) { - return a+b; -} - -int sub(int a, int b) { - return a-b; -} - -int mul(int a, int b) { - return a*b; -} diff --git a/Examples/php5/funcptr/example.h b/Examples/php5/funcptr/example.h deleted file mode 100644 index 58989db79..000000000 --- a/Examples/php5/funcptr/example.h +++ /dev/null @@ -1,7 +0,0 @@ -/* file: example.h */ - -extern int do_op(int,int, int (*op)(int,int)); -extern int add(int,int); -extern int sub(int,int); -extern int mul(int,int); - diff --git a/Examples/php5/funcptr/example.i b/Examples/php5/funcptr/example.i deleted file mode 100644 index 39390da27..000000000 --- a/Examples/php5/funcptr/example.i +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.i */ -%module example -%{ -#include "example.h" -%} - -/* Wrap a function taking a pointer to a function */ -extern int do_op(int a, int b, int (*op)(int, int)); - -/* Now install a bunch of "ops" as constants */ -%constant int (*ADD)(int,int) = add; -%constant int (*SUB)(int,int) = sub; -%constant int (*MUL)(int,int) = mul; - - diff --git a/Examples/php5/funcptr/runme.php b/Examples/php5/funcptr/runme.php deleted file mode 100644 index 712d4147c..000000000 --- a/Examples/php5/funcptr/runme.php +++ /dev/null @@ -1,24 +0,0 @@ - - diff --git a/Examples/php5/overloading/Makefile b/Examples/php5/overloading/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/overloading/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/overloading/example.cxx b/Examples/php5/overloading/example.cxx deleted file mode 100644 index 2f684f05c..000000000 --- a/Examples/php5/overloading/example.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#include -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -int Shape::get_nshapes() { - return nshapes; -} - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area(void) { - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} - -const char *overloaded(int i) { - return "Overloaded with int"; -} - -const char *overloaded(double d) { - return "Overloaded with double"; -} - -const char *overloaded(const char * str) { - return "Overloaded with char *"; -} - -const char *overloaded( const Circle& ) { - return "Overloaded with Circle"; -} - -const char *overloaded( const Shape& ) { - return "Overloaded with Shape"; -} diff --git a/Examples/php5/overloading/example.h b/Examples/php5/overloading/example.h deleted file mode 100644 index 01d71dd70..000000000 --- a/Examples/php5/overloading/example.h +++ /dev/null @@ -1,46 +0,0 @@ -/* File : example.h */ - -#include - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area(void) = 0; - virtual double perimeter(void) = 0; - static int nshapes; - static int get_nshapes(); -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - ~Circle() { } - virtual double area(void); - virtual double perimeter(void); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - ~Square() { } - virtual double area(void); - 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& ); - diff --git a/Examples/php5/overloading/example.i b/Examples/php5/overloading/example.i deleted file mode 100644 index 950d2549d..000000000 --- a/Examples/php5/overloading/example.i +++ /dev/null @@ -1,8 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -%include "example.h" diff --git a/Examples/php5/overloading/runme.php b/Examples/php5/overloading/runme.php deleted file mode 100644 index 56d515138..000000000 --- a/Examples/php5/overloading/runme.php +++ /dev/null @@ -1,58 +0,0 @@ -x = 20; -$c->y = 30; -$s->x = -10; -$s->y = 5; - -print "\nHere is their current position:\n"; -print " Circle = (" . $c->x . "," . $c->y . ")\n"; -print " Square = (" . $s->x . "," . $s->y . ")\n"; - -# ----- Call some methods ----- - -print "\nCall some overloaded methods:\n"; -foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) { - print " overloaded = " . overloaded($o) . "\n"; -} - -# Need to unset($o) or else we hang on to a reference to the Square object. -unset($o); - -# ----- Delete everything ----- - -print "\nGuess I'll clean up now\n"; - -# Note: this invokes the virtual destructor -unset($c); -$s = 42; - -print Shape::nshapes() . " shapes remain\n"; - -print "Goodbye\n"; - -?> diff --git a/Examples/php5/pointer/Makefile b/Examples/php5/pointer/Makefile deleted file mode 100644 index 92085788a..000000000 --- a/Examples/php5/pointer/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/pointer/example.c b/Examples/php5/pointer/example.c deleted file mode 100644 index 3326dec3e..000000000 --- a/Examples/php5/pointer/example.c +++ /dev/null @@ -1,16 +0,0 @@ -/* File : example.c */ - -void add(double *x, double *y, double *result) { - *result = *x + *y; -} - -void sub(int *x, int *y, int *result) { - *result = *x - *y; -} - -int divide(int n, int d, int *r) { - int q; - q = n/d; - *r = n - q*d; - return q; -} diff --git a/Examples/php5/pointer/example.i b/Examples/php5/pointer/example.i deleted file mode 100644 index 1f0059406..000000000 --- a/Examples/php5/pointer/example.i +++ /dev/null @@ -1,30 +0,0 @@ -/* File : example.i */ -%module example - -%{ -extern void add(double *, double *, double *); -extern void sub(int *, int *, int *); -extern int divide(int, int, int *); -%} - -/* This example illustrates a couple of different techniques - for manipulating C pointers */ - -%include phppointers.i -/* First we'll use the pointer library */ -extern void add(double *REF, double *REF, double *REF); - -/* Next we'll use some typemaps */ - -%include typemaps.i -extern void sub(int *INPUT, int *INPUT, int *OUTPUT); - -/* Next we'll use typemaps and the %apply directive */ - -//%apply int *OUTPUT { int *r }; -//extern int divide(int n, int d, int *r); - - - - - diff --git a/Examples/php5/pointer/runme.php b/Examples/php5/pointer/runme.php deleted file mode 100644 index e79b23810..000000000 --- a/Examples/php5/pointer/runme.php +++ /dev/null @@ -1,35 +0,0 @@ - diff --git a/Examples/php5/pragmas/Makefile b/Examples/php5/pragmas/Makefile deleted file mode 100644 index f9557fa89..000000000 --- a/Examples/php5/pragmas/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/pragmas/example.i b/Examples/php5/pragmas/example.i deleted file mode 100644 index f9307a663..000000000 --- a/Examples/php5/pragmas/example.i +++ /dev/null @@ -1,32 +0,0 @@ -/* File : example.i */ -%module example - -%init{ - zend_printf("This was %%init\n"); -} - -%minit{ - zend_printf("This was %%minit\n"); -} - -%mshutdown{ - zend_printf("This was %%shutdown\n"); -} - -%rinit{ - zend_printf("This was %%rinit\n"); -} - -%rshutdown{ - zend_printf("This was %%rshutdown\n"); -} - -%pragma(php) include="include.php"; - -%pragma(php) code=" -# This code is inserted into example.php -echo \"this was php code\\n\"; -" -%pragma(php) version="1.5" - -%pragma(php) phpinfo="php_info_print_table_start();" diff --git a/Examples/php5/pragmas/include.php b/Examples/php5/pragmas/include.php deleted file mode 100644 index e19880a06..000000000 --- a/Examples/php5/pragmas/include.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/Examples/php5/pragmas/runme.php b/Examples/php5/pragmas/runme.php deleted file mode 100644 index b99cf37a4..000000000 --- a/Examples/php5/pragmas/runme.php +++ /dev/null @@ -1,6 +0,0 @@ -getVersion()); -?> diff --git a/Examples/php5/proxy/Makefile b/Examples/php5/proxy/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/proxy/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/proxy/example.cxx b/Examples/php5/proxy/example.cxx deleted file mode 100644 index 94e4a7888..000000000 --- a/Examples/php5/proxy/example.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* File : example.c */ - -#include "example.h" -#include -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - -int Shape::get_nshapes() { - return nshapes; -} - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -void Circle::set_radius( double r ) { - radius = r; -} - -double Circle::area(void) { - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} - -Circle *CircleFactory( double r ) { - return new Circle(r); -} diff --git a/Examples/php5/proxy/example.h b/Examples/php5/proxy/example.h deleted file mode 100644 index 0683f07f3..000000000 --- a/Examples/php5/proxy/example.h +++ /dev/null @@ -1,43 +0,0 @@ -/* File : example.h */ - -#include - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area(void) = 0; - virtual double perimeter(void) = 0; - static int nshapes; - static int get_nshapes(); -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - ~Circle() { } - void set_radius( double r ); - virtual double area(void); - virtual double perimeter(void); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - ~Square() { } - virtual double area(void); - virtual double perimeter(void); -}; - -Circle *CircleFactory( double r ); - diff --git a/Examples/php5/proxy/example.i b/Examples/php5/proxy/example.i deleted file mode 100644 index ce73746d0..000000000 --- a/Examples/php5/proxy/example.i +++ /dev/null @@ -1,12 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ - -%newobject CircleFactory; -%include "example.h" - diff --git a/Examples/php5/proxy/runme.php b/Examples/php5/proxy/runme.php deleted file mode 100644 index e70ab229f..000000000 --- a/Examples/php5/proxy/runme.php +++ /dev/null @@ -1,68 +0,0 @@ -area() ."\n"; -$s = new Square(10); -print " Created square \$s\n"; - -# ----- Access a static member ----- - -print "\nA total of " . Shape::nshapes() . " shapes were created\n"; - -# ----- Member data access ----- - -# Set the location of the object. -# Note: methods in the base class Shape are used since -# x and y are defined there. - -$c->x = 20; -$c->y = 30; -$s->x = -10; -$s->y = 5; - -print "\nHere is their current position:\n"; -print " Circle = (" . $c->x . "," . $c->y . ")\n"; -print " Square = (" . $s->x . "," . $s->y . ")\n"; - -# ----- Call some methods ----- - -print "\nHere are some properties of the shapes:\n"; -foreach (array($c,$s) as $o) { - print " ".get_class($o)." \$o\n"; - print " x = " . $o->x . "\n"; - print " y = " . $o->y . "\n"; - print " area = " . $o->area() . "\n"; - print " perimeter = " . $o->perimeter() . "\n"; - } - -# Need to unset($o) or else we hang on to a reference to the Square object. -unset($o); - -# ----- Delete everything ----- - -print "\nGuess I'll clean up now\n"; - -# Note: this invokes the virtual destructor -unset($c); -$s = 42; - -print Shape::nshapes() . " shapes remain\n"; - -print "Manually setting nshapes\n"; - -Shape::nshapes(42); - -print Shape::get_nshapes() ." == 42\n"; - -print "Goodbye\n"; - -?> diff --git a/Examples/php5/reference/Makefile b/Examples/php5/reference/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/reference/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/reference/example.cxx b/Examples/php5/reference/example.cxx deleted file mode 100644 index 7ead7fbf6..000000000 --- a/Examples/php5/reference/example.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* File : example.cxx */ - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -#include "example.h" -#include -#include - -Vector operator+(const Vector &a, const Vector &b) { - Vector r; - r.x = a.x + b.x; - r.y = a.y + b.y; - r.z = a.z + b.z; - return r; -} - -char *Vector::as_string() { - static char temp[512]; - sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); - return temp; -} - -VectorArray::VectorArray(int size) { - items = new Vector[size]; - maxsize = size; - printf("VectorArray new: self=%p\n", (void *)this); -} - -VectorArray::~VectorArray() { - printf("VectorArray delete: self=%p\n", (void *)this); - delete [] items; -} - -Vector &VectorArray::operator[](int index) { - printf("VectorArray: read[%d] self=%p\n", index, (void *)this); - if ((index < 0) || (index >= maxsize)) { - printf("Panic! Array index out of bounds.\n"); - exit(1); - } - return items[index]; -} - -int VectorArray::size() { - printf("VectorArray: size %d self=%p\n", maxsize, (void *)this); - return maxsize; -} diff --git a/Examples/php5/reference/example.h b/Examples/php5/reference/example.h deleted file mode 100644 index 353b88835..000000000 --- a/Examples/php5/reference/example.h +++ /dev/null @@ -1,22 +0,0 @@ -/* File : example.h */ - -class Vector { -private: - double x,y,z; -public: - Vector() : x(0), y(0), z(0) { } - Vector(double x, double y, double z) : x(x), y(y), z(z) { } - friend Vector operator+(const Vector &a, const Vector &b); - char *as_string(); -}; - -class VectorArray { -private: - Vector *items; - int maxsize; -public: - VectorArray(int maxsize); - ~VectorArray(); - Vector &operator[](int); - int size(); -}; diff --git a/Examples/php5/reference/example.i b/Examples/php5/reference/example.i deleted file mode 100644 index df1459921..000000000 --- a/Examples/php5/reference/example.i +++ /dev/null @@ -1,43 +0,0 @@ -/* File : example.i */ - -/* This file has a few "typical" uses of C++ references. */ - -%module example - -%{ -#include "example.h" -%} - -class Vector { -public: - Vector(double x, double y, double z); - ~Vector(); - char *as_string(); -}; - -/* This helper function calls an overloaded operator */ -%inline %{ -Vector addv(Vector &a, Vector &b) { - return a+b; -} -%} - -/* Wrapper around an array of vectors class */ - -class VectorArray { -public: - VectorArray(int maxsize); - ~VectorArray(); - int size(); - - /* This wrapper provides an alternative to the [] operator */ - %extend { - Vector &get(int index) { - printf("VectorArray extended get: %p %d\n", (void *)$self, index); - return (*$self)[index]; - } - void set(int index, Vector &a) { - (*$self)[index] = a; - } - } -}; diff --git a/Examples/php5/reference/runme.php b/Examples/php5/reference/runme.php deleted file mode 100644 index 5d264ee43..000000000 --- a/Examples/php5/reference/runme.php +++ /dev/null @@ -1,49 +0,0 @@ -as_string()}\n"; -print " Created b: {$b->as_string()}\n"; - -# ----- Call an overloaded operator ----- - -# This calls the wrapper we placed around -# -# operator+(const Vector &a, const Vector &) -# -# It returns a new allocated object. - -print "Adding a+b\n"; -$c = example::addv($a, $b); -print " a+b ={$c->as_string()}\n"; - -# ----- Create a vector array ----- - -print "Creating an array of vectors\n"; -$va = new VectorArray(10); - -print " va: size={$va->size()}\n"; - -# ----- Set some values in the array ----- - -# These operators copy the value of $a and $b to the vector array -$va->set(0, $a); -$va->set(1, $b); -$va->set(2, addv($a, $b)); - -# Get some values from the array - -print "Getting some array values\n"; -for ($i = 0; $i < 5; $i++) { - print " va[$i] = {$va->get($i)->as_string()}\n"; -} - -?> diff --git a/Examples/php5/simple/Makefile b/Examples/php5/simple/Makefile deleted file mode 100644 index 92085788a..000000000 --- a/Examples/php5/simple/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/simple/example.c b/Examples/php5/simple/example.c deleted file mode 100644 index 2fe275632..000000000 --- a/Examples/php5/simple/example.c +++ /dev/null @@ -1,23 +0,0 @@ -/* File : example.c */ -#include - -/* A global variable */ -double Foo = 3.0; - -void print_Foo() { - printf("In C, Foo = %f\n",Foo); -} - -/* Compute the greatest common divisor of positive integers */ -int gcd(int x, int y) { - int g; - g = y; - while (x > 0) { - g = x; - x = y % x; - y = g; - } - return g; -} - - diff --git a/Examples/php5/simple/example.i b/Examples/php5/simple/example.i deleted file mode 100644 index 9d4e22aa9..000000000 --- a/Examples/php5/simple/example.i +++ /dev/null @@ -1,8 +0,0 @@ -/* File : example.i */ -%module example - -%inline %{ -extern int gcd(int x, int y); -extern double Foo; -void print_Foo(); -%} diff --git a/Examples/php5/simple/runme.php b/Examples/php5/simple/runme.php deleted file mode 100644 index 0e96fe800..000000000 --- a/Examples/php5/simple/runme.php +++ /dev/null @@ -1,25 +0,0 @@ - diff --git a/Examples/php5/sync/Makefile b/Examples/php5/sync/Makefile deleted file mode 100644 index 8346a1dae..000000000 --- a/Examples/php5/sync/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5_cpp - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/sync/example.cxx b/Examples/php5/sync/example.cxx deleted file mode 100644 index 0942279b2..000000000 --- a/Examples/php5/sync/example.cxx +++ /dev/null @@ -1,13 +0,0 @@ -#include "example.h" -#include - -int x = 42; -char *s = (char *)"Test"; - -void Sync::printer(void) { - - printf("The value of global s is %s\n", s); - printf("The value of global x is %d\n", x); - printf("The value of class s is %s\n", s); - printf("The value of class x is %d\n", x); -} diff --git a/Examples/php5/sync/example.h b/Examples/php5/sync/example.h deleted file mode 100644 index d67ec21dc..000000000 --- a/Examples/php5/sync/example.h +++ /dev/null @@ -1,9 +0,0 @@ -extern char *s; -extern int x; - -class Sync { - public: - int x; - char *s; - void printer(void); -}; diff --git a/Examples/php5/sync/example.i b/Examples/php5/sync/example.i deleted file mode 100644 index 17ff87cf3..000000000 --- a/Examples/php5/sync/example.i +++ /dev/null @@ -1,7 +0,0 @@ -%module example - -%{ -#include "example.h" -%} - -%include "example.h" diff --git a/Examples/php5/sync/runme.php b/Examples/php5/sync/runme.php deleted file mode 100644 index a7c43474f..000000000 --- a/Examples/php5/sync/runme.php +++ /dev/null @@ -1,15 +0,0 @@ -printer(); - -?> - diff --git a/Examples/php5/value/Makefile b/Examples/php5/value/Makefile deleted file mode 100644 index b0b5e20ac..000000000 --- a/Examples/php5/value/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = -noproxy - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/value/example.c b/Examples/php5/value/example.c deleted file mode 100644 index 3c402a214..000000000 --- a/Examples/php5/value/example.c +++ /dev/null @@ -1,13 +0,0 @@ -/* File : example.c */ - -#include "example.h" - -double dot_product(Vector a, Vector b) { - return (a.x*b.x + a.y*b.y + a.z*b.z); -} - -void vector_add(Vector a, Vector b, Vector* result) { - result->x = a.x + b.x; - result->y = a.y + b.y; - result->z = a.z + b.z; -} diff --git a/Examples/php5/value/example.h b/Examples/php5/value/example.h deleted file mode 100644 index f55752a5f..000000000 --- a/Examples/php5/value/example.h +++ /dev/null @@ -1,8 +0,0 @@ -/* File : example.h */ - -typedef struct { - double x, y, z; -} Vector; - -double dot_product(Vector a, Vector b); -void vector_add(Vector a, Vector b, Vector* result); diff --git a/Examples/php5/value/example.i b/Examples/php5/value/example.i deleted file mode 100644 index 20a453468..000000000 --- a/Examples/php5/value/example.i +++ /dev/null @@ -1,17 +0,0 @@ -// Tests SWIG's handling of pass-by-value for complex datatypes -%module example - -%{ -#include "example.h" -%} - -%include "example.h" - -/* Some helper functions for our interface */ -%inline %{ - -void vector_print(Vector *v) { - printf("Vector %p = (%g, %g, %g)\n", (void *)v, v->x, v->y, v->z); -} -%} - diff --git a/Examples/php5/value/runme.php b/Examples/php5/value/runme.php deleted file mode 100644 index 49115376c..000000000 --- a/Examples/php5/value/runme.php +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/Examples/php5/variables/Makefile b/Examples/php5/variables/Makefile deleted file mode 100644 index 92085788a..000000000 --- a/Examples/php5/variables/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php5 - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php5_clean diff --git a/Examples/php5/variables/example.c b/Examples/php5/variables/example.c deleted file mode 100644 index d4c6d026d..000000000 --- a/Examples/php5/variables/example.c +++ /dev/null @@ -1,95 +0,0 @@ -/* File : example.c */ - -/* I'm a file containing some C global variables */ - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -#include -#include -#include "example.h" - -int ivar = 0; -short svar = 0; -long lvar = 0; -unsigned int uivar = 0; -unsigned short usvar = 0; -unsigned long ulvar = 0; -signed char scvar = 0; -unsigned char ucvar = 0; -char cvar = 0; -float fvar = 0; -double dvar = 0; -char *strvar = 0; -const char cstrvar[] = "Goodbye"; -int *iptrvar = 0; -char name[5] = "Dave"; -char path[256] = "/home/beazley"; - - -/* Global variables involving a structure */ -Point *ptptr = 0; -Point pt = { 10, 20 }; - -/* A variable that we will make read-only in the interface */ -int status = 1; - -/* A debugging function to print out their values */ - -void print_vars() { - printf("ivar = %d\n", ivar); - printf("svar = %d\n", svar); - printf("lvar = %ld\n", lvar); - printf("uivar = %u\n", uivar); - printf("usvar = %u\n", usvar); - printf("ulvar = %lu\n", ulvar); - printf("scvar = %d\n", scvar); - printf("ucvar = %u\n", ucvar); - printf("fvar = %g\n", fvar); - printf("dvar = %g\n", dvar); - printf("cvar = %c\n", cvar); - printf("strvar = %s\n", strvar ? strvar : "(null)"); - printf("cstrvar = %s\n", cstrvar); - printf("iptrvar = %p\n", (void *)iptrvar); - printf("name = %c%c%c%c%c\n", name[0],name[1],name[2],name[3],name[4]); - printf("ptptr = %p %s\n", (void *)ptptr, Point_print( ptptr ) ); - printf("pt = (%d, %d)\n", pt.x, pt.y); - printf("status = %d\n", status); -} - -/* A function to create an integer (to test iptrvar) */ - -int *new_int(int value) { - int *ip = (int *) malloc(sizeof(int)); - *ip = value; - return ip; -} - -int value_int(int *value) { - return *value; -} - -/* A function to create a point */ - -Point *new_Point(int x, int y) { - Point *p = (Point *) malloc(sizeof(Point)); - p->x = x; - p->y = y; - return p; -} - -char * Point_print(Point *p) { - static char buffer[256]; - if (p) { - sprintf(buffer,"(%d,%d)", p->x,p->y); - } else { - sprintf(buffer,"null"); - } - return buffer; -} - -void pt_print() { - printf("(%d, %d)\n", pt.x, pt.y); -} diff --git a/Examples/php5/variables/example.h b/Examples/php5/variables/example.h deleted file mode 100644 index 3b3659ce5..000000000 --- a/Examples/php5/variables/example.h +++ /dev/null @@ -1,34 +0,0 @@ -/* File: example.h */ - -typedef struct { - int x,y; -} Point; - -/* Some global variable declarations */ -extern int ivar; -extern short svar; -extern long lvar; -extern unsigned int uivar; -extern unsigned short usvar; -extern unsigned long ulvar; -extern signed char scvar; -extern unsigned char ucvar; -extern char cvar; -extern float fvar; -extern double dvar; -extern char *strvar; -extern const char cstrvar[]; -extern int *iptrvar; -extern char name[5]; - -extern Point *ptptr; -extern Point pt; - -extern int status; -extern char path[256]; - -extern void print_vars(); -extern int *new_int(int value); -extern Point *new_Point(int x, int y); -extern char *Point_print(Point *p); -extern void pt_print(); diff --git a/Examples/php5/variables/example.i b/Examples/php5/variables/example.i deleted file mode 100644 index 3edbb72d7..000000000 --- a/Examples/php5/variables/example.i +++ /dev/null @@ -1,44 +0,0 @@ -/* File : example.i */ -%module example -%{ -#include "example.h" -%} - -/* Some global variable declarations */ -extern int ivar; -extern short svar; -extern long lvar; -extern unsigned int uivar; -extern unsigned short usvar; -extern unsigned long ulvar; -extern signed char scvar; -extern unsigned char ucvar; -extern char cvar; -extern float fvar; -extern double dvar; -extern char *strvar; -extern const char cstrvar[]; -extern int *iptrvar; -extern char name[5]; - -extern Point *ptptr; -extern Point pt; - -/* Some read-only variables */ - -%immutable; -extern int status; -extern char path[256]; -%mutable; - -/* Some helper functions to make it easier to test */ -extern void print_vars(); -extern int *new_int(int value); - -extern Point *new_Point(int x, int y); -extern char *Point_print(Point *p); -extern void pt_print(); - - - - diff --git a/Examples/php5/variables/runme.php b/Examples/php5/variables/runme.php deleted file mode 100644 index 14f27f389..000000000 --- a/Examples/php5/variables/runme.php +++ /dev/null @@ -1,96 +0,0 @@ - - diff --git a/Examples/test-suite/php5/Makefile.in b/Examples/test-suite/php5/Makefile.in deleted file mode 100644 index 179ce59d6..000000000 --- a/Examples/test-suite/php5/Makefile.in +++ /dev/null @@ -1,81 +0,0 @@ -####################################################################### -# Makefile for php5 test-suite -####################################################################### - -LANGUAGE = php5 -SCRIPTSUFFIX = _runme.php - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = @top_builddir@ - -CPP_TEST_CASES += \ - callback \ - li_factory \ - php_iterator \ - php_namewarn_rename \ - php_pragma \ - -include $(srcdir)/../common.mk - -# Overridden variables here -TARGETPREFIX =# Should be php_ for Windows, empty otherwise - -# Custom tests - tests with additional commandline options -prefix.cpptest: SWIGOPT += -prefix Project - -# write out tests without a _runme.php -missingcpptests: - for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done - -missingctests: - for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done - -missingtests: missingcpptests missingctests - -# Rules for the different types of tests -%.cpptest: - $(setup) - +$(swig_and_compile_cpp) - +$(run_testcase) - -%.ctest: - $(setup) - +$(swig_and_compile_c) - +$(run_testcase) - -%.multicpptest: - $(setup) - +$(swig_and_compile_multi_cpp) - +$(run_testcase) - -# Smart target -%.test: - @echo ' $(C_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ - $(MAKE) $*.ctest - @echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ - $(MAKE) $*.cpptest - @echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\ - $(MAKE) $*.multicpptest - -# Runs the testcase. Tries to run testcase_runme.php, and if that's not -# found, runs testcase.php, except for multicpptests. -run_testcase = \ - if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL='$(RUNTOOL)' php5_run; \ - elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php -a ! -f $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list ]; then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHP5_SCRIPT=$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.php RUNTOOL='$(RUNTOOL)' php5_run; \ - fi - -# Clean: remove the generated .php file -%.clean: - @rm -f $*.php php_$*.h - -clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' php5_clean - rm -f clientdata_prop_a.php clientdata_prop_b.php php_clientdata_prop_a.h php_clientdata_prop_b.h - rm -f import_stl_a.php import_stl_b.php php_import_stl_a.h php_import_stl_b.h - rm -f imports_a.php imports_b.php php_imports_a.h php_imports_b.h - rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h - rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h - rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h diff --git a/Examples/test-suite/php5/abstract_inherit_ok_runme.php b/Examples/test-suite/php5/abstract_inherit_ok_runme.php deleted file mode 100644 index c2d86499b..000000000 --- a/Examples/test-suite/php5/abstract_inherit_ok_runme.php +++ /dev/null @@ -1,12 +0,0 @@ -blah(),"spam object method"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/abstract_inherit_runme.php b/Examples/test-suite/php5/abstract_inherit_runme.php deleted file mode 100644 index 3554e6fd8..000000000 --- a/Examples/test-suite/php5/abstract_inherit_runme.php +++ /dev/null @@ -1,14 +0,0 @@ -blah(),"spam object method"); -//check::equal(0,Spam::blah($spam),"spam class method"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/add_link_runme.php b/Examples/test-suite/php5/add_link_runme.php deleted file mode 100644 index 7523bd604..000000000 --- a/Examples/test-suite/php5/add_link_runme.php +++ /dev/null @@ -1,22 +0,0 @@ -blah(); -check::is_a($foo_blah,foo); - -//fails, can't be called as a class method, should allow and make it nil? -//$class_foo_blah=foo::blah(); -//check::is_a($class_foo_blah,foo); - -check::done(); -?> diff --git a/Examples/test-suite/php5/argout_runme.php b/Examples/test-suite/php5/argout_runme.php deleted file mode 100644 index 33fbd8129..000000000 --- a/Examples/test-suite/php5/argout_runme.php +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/Examples/test-suite/php5/arrayptr_runme.php b/Examples/test-suite/php5/arrayptr_runme.php deleted file mode 100644 index 3b9baed05..000000000 --- a/Examples/test-suite/php5/arrayptr_runme.php +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/Examples/test-suite/php5/arrays_global_runme.php b/Examples/test-suite/php5/arrays_global_runme.php deleted file mode 100644 index 12a7806c9..000000000 --- a/Examples/test-suite/php5/arrays_global_runme.php +++ /dev/null @@ -1,19 +0,0 @@ - diff --git a/Examples/test-suite/php5/arrays_global_twodim_runme.php b/Examples/test-suite/php5/arrays_global_twodim_runme.php deleted file mode 100644 index 40ecf1719..000000000 --- a/Examples/test-suite/php5/arrays_global_twodim_runme.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/Examples/test-suite/php5/arrays_runme.php b/Examples/test-suite/php5/arrays_runme.php deleted file mode 100644 index ae17d05e7..000000000 --- a/Examples/test-suite/php5/arrays_runme.php +++ /dev/null @@ -1,18 +0,0 @@ -array_c="abc"; -check::equal($as->array_c,"a",'$as->array_c=="a"'); -check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)'); - -check::done(); -?> diff --git a/Examples/test-suite/php5/arrays_scope_runme.php b/Examples/test-suite/php5/arrays_scope_runme.php deleted file mode 100644 index c208b7518..000000000 --- a/Examples/test-suite/php5/arrays_scope_runme.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/Examples/test-suite/php5/callback_runme.php b/Examples/test-suite/php5/callback_runme.php deleted file mode 100644 index fefa32502..000000000 --- a/Examples/test-suite/php5/callback_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php5/casts_runme.php b/Examples/test-suite/php5/casts_runme.php deleted file mode 100644 index 10522dca4..000000000 --- a/Examples/test-suite/php5/casts_runme.php +++ /dev/null @@ -1,18 +0,0 @@ -hello(); - -check::done(); -?> diff --git a/Examples/test-suite/php5/char_strings_runme.php b/Examples/test-suite/php5/char_strings_runme.php deleted file mode 100644 index e06ee9d2b..000000000 --- a/Examples/test-suite/php5/char_strings_runme.php +++ /dev/null @@ -1,43 +0,0 @@ - diff --git a/Examples/test-suite/php5/class_ignore_runme.php b/Examples/test-suite/php5/class_ignore_runme.php deleted file mode 100644 index d5ce36217..000000000 --- a/Examples/test-suite/php5/class_ignore_runme.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/Examples/test-suite/php5/conversion_namespace_runme.php b/Examples/test-suite/php5/conversion_namespace_runme.php deleted file mode 100644 index e21ff7438..000000000 --- a/Examples/test-suite/php5/conversion_namespace_runme.php +++ /dev/null @@ -1,13 +0,0 @@ -toFoo(); -check::classname("foo",$foo); - -check::done(); -?> diff --git a/Examples/test-suite/php5/conversion_ns_template_runme.php b/Examples/test-suite/php5/conversion_ns_template_runme.php deleted file mode 100644 index 9702eedb7..000000000 --- a/Examples/test-suite/php5/conversion_ns_template_runme.php +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/Examples/test-suite/php5/conversion_runme.php b/Examples/test-suite/php5/conversion_runme.php deleted file mode 100644 index 1a10ff4f4..000000000 --- a/Examples/test-suite/php5/conversion_runme.php +++ /dev/null @@ -1,13 +0,0 @@ -toFoo(); -check::classname("foo",$foo); - -check::done(); -?> diff --git a/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php b/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php deleted file mode 100644 index bee59b209..000000000 --- a/Examples/test-suite/php5/cpp11_strongly_typed_enumerations_runme.php +++ /dev/null @@ -1,169 +0,0 @@ -class1Test1(Enum1_Val5a), 13); -enumCheck($class1->class1Test2(Class1::Enum12_Val5c), 1121); -#enumCheck($class1.class1Test3(Class1::Struct1.Enum12_Val5f), 3121); - -enumCheck(globalTest1(Enum1_Val5a), 13); -enumCheck(globalTest2(Class1::Enum12_Val5c), 1121); -#enumCheck(globalTest3(Class1::Struct1.Enum12_Val5f), 3121); - -?> diff --git a/Examples/test-suite/php5/cpp_basic_runme.php b/Examples/test-suite/php5/cpp_basic_runme.php deleted file mode 100644 index 6a8522e3e..000000000 --- a/Examples/test-suite/php5/cpp_basic_runme.php +++ /dev/null @@ -1,20 +0,0 @@ -func_ptr = get_func1_ptr(); -check::equal(test_func_ptr($f, 7), 2*7*3, "get_func1_ptr() didn't work"); -$f->func_ptr = get_func2_ptr(); -check::equal(test_func_ptr($f, 7), -7*3, "get_func2_ptr() didn't work"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/cpp_static_runme.php b/Examples/test-suite/php5/cpp_static_runme.php deleted file mode 100644 index 9b436b87c..000000000 --- a/Examples/test-suite/php5/cpp_static_runme.php +++ /dev/null @@ -1,14 +0,0 @@ - diff --git a/Examples/test-suite/php5/director_abstract_runme.php b/Examples/test-suite/php5/director_abstract_runme.php deleted file mode 100644 index ca3d676da..000000000 --- a/Examples/test-suite/php5/director_abstract_runme.php +++ /dev/null @@ -1,62 +0,0 @@ -ping(), "MyFoo::ping()", "MyFoo::ping failed"); - -check::equal($a->pong(), "Foo::pong();MyFoo::ping()", "MyFoo::pong failed"); - -class MyExample1 extends Example1 { - function Color($r, $g, $b) { - return $r; - } -} - -class MyExample2 extends Example1 { - function Color($r, $g, $b) { - return $g; - } -} - -class MyExample3 extends Example1 { - function Color($r, $g, $b) { - return $b; - } -} - -$me1 = new MyExample1(); -check::equal($me1->Color(1, 2, 3), 1, "Example1_get_color failed"); - -$me2 = new MyExample2(1, 2); -check::equal($me2->Color(1, 2, 3), 2, "Example2_get_color failed"); - -$me3 = new MyExample3(); -check::equal($me3->Color(1, 2, 3), 3, "Example3_get_color failed"); - -$class = new ReflectionClass('Example1'); -check::equal($class->isAbstract(), true, "Example1 abstractness failed"); - -$class = new ReflectionClass('Example2'); -check::equal($class->isAbstract(), true, "Example2 abstractness failed"); - -$class = new ReflectionClass('Example3_i'); -check::equal($class->isAbstract(), true, "Example3_i abstractness failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_basic_runme.php b/Examples/test-suite/php5/director_basic_runme.php deleted file mode 100644 index de6b50502..000000000 --- a/Examples/test-suite/php5/director_basic_runme.php +++ /dev/null @@ -1,58 +0,0 @@ -ping(), "PhpFoo::ping()", "ping failed"); - -check::equal($a->pong(), "Foo::pong();PhpFoo::ping()", "pong failed"); - -$b = new Foo(); - -check::equal($b->ping(), "Foo::ping()", "ping failed"); - -check::equal($b->pong(), "Foo::pong();Foo::ping()", "pong failed"); - -$a = new A1(1); - -check::equal($a->rg(2), 2, "rg failed"); - -class PhpClass extends MyClass { - function vmethod($b) { - $b->x = $b->x + 31; - return $b; - } -} - -$b = new Bar(3); -$d = new MyClass(); -$c = new PhpClass(); - -$cc = MyClass::get_self($c); -$dd = MyClass::get_self($d); - -$bc = $cc->cmethod($b); -$bd = $dd->cmethod($b); - -$cc->method($b); - -check::equal($bc->x, 34, "bc failed"); -check::equal($bd->x, 16, "bd failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_classic_runme.php b/Examples/test-suite/php5/director_classic_runme.php deleted file mode 100644 index d2da1b1ba..000000000 --- a/Examples/test-suite/php5/director_classic_runme.php +++ /dev/null @@ -1,150 +0,0 @@ -id(); - if ($debug) - print $ret . "\n"; - check::equal($ret, $expected, "#1 failed"); - - # Polymorphic call from C++ - $caller = new Caller(); - $caller->setCallback($person); - $ret = $caller->call(); - if ($debug) - print $ret . "\n"; - check::equal($ret, $expected, "#2 failed"); - - # Polymorphic call of object created in target language and passed to - # C++ and back again - $baseclass = $caller->baseClass(); - $ret = $baseclass->id(); - if ($debug) - print $ret . "\n"; - # TODO: Currently we do not track the dynamic type of returned - # objects, so in case it's possible that the dynamic type is not equal - # to the static type, we skip this check. - if (get_parent_class($person) === false) - check::equal($ret, $expected, "#3 failed"); - - $caller->resetCallback(); - if ($debug) - print "----------------------------------------\n"; -} - -$person = new Person(); -mycheck($person, "Person"); -unset($person); - -$person = new Child(); -mycheck($person, "Child"); -unset($person); - -$person = new GrandChild(); -mycheck($person, "GrandChild"); -unset($person); - -$person = new TargetLangPerson(); -mycheck($person, "TargetLangPerson"); -unset($person); - -$person = new TargetLangChild(); -mycheck($person, "TargetLangChild"); -unset($person); - -$person = new TargetLangGrandChild(); -mycheck($person, "TargetLangGrandChild"); -unset($person); - -# Semis - don't override id() in target language -$person = new TargetLangSemiPerson(); -mycheck($person, "Person"); -unset($person); - -$person = new TargetLangSemiChild(); -mycheck($person, "Child"); -unset($person); - -$person = new TargetLangSemiGrandChild(); -mycheck($person, "GrandChild"); -unset($person); - -# Orphans - don't override id() in C++ -$person = new OrphanPerson(); -mycheck($person, "Person"); -unset($person); - -$person = new OrphanChild(); -mycheck($person, "Child"); -unset($person); - -$person = new TargetLangOrphanPerson(); -mycheck($person, "TargetLangOrphanPerson"); -unset($person); - -$person = new TargetLangOrphanChild(); -mycheck($person, "TargetLangOrphanChild"); -unset($person); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_default_runme.php b/Examples/test-suite/php5/director_default_runme.php deleted file mode 100644 index f97fc7425..000000000 --- a/Examples/test-suite/php5/director_default_runme.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/Examples/test-suite/php5/director_detect_runme.php b/Examples/test-suite/php5/director_detect_runme.php deleted file mode 100644 index cc19c0302..000000000 --- a/Examples/test-suite/php5/director_detect_runme.php +++ /dev/null @@ -1,55 +0,0 @@ -val = $val; - } - - function get_value() { - $this->val = $this->val + 1; - return $this->val; - } - - function get_class() { - $this->val = $this->val + 1; - return new A(); - } - - function just_do_it() { - $this->val = $this->val + 1; - } - - /* clone is a reserved keyword */ - function clone_() { - return new MyBar($this->val); - } -} - -$b = new MyBar(); - -$f = $b->baseclass(); - -$v = $f->get_value(); -$a = $f->get_class(); -$f->just_do_it(); - -$c = $b->clone_(); -$vc = $c->get_value(); - -check::equal($v, 3, "f: Bad virtual detection"); -check::equal($b->val, 5, "b: Bad virtual detection"); -check::equal($vc, 6, "c: Bad virtual detection"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_enum_runme.php b/Examples/test-suite/php5/director_enum_runme.php deleted file mode 100644 index 8f6487a28..000000000 --- a/Examples/test-suite/php5/director_enum_runme.php +++ /dev/null @@ -1,25 +0,0 @@ -say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_exception_runme.php b/Examples/test-suite/php5/director_exception_runme.php deleted file mode 100644 index 47f645b07..000000000 --- a/Examples/test-suite/php5/director_exception_runme.php +++ /dev/null @@ -1,127 +0,0 @@ -msg = $a . $b; - } -} - -class MyFoo extends Foo { - function ping() { - throw new Exception("MyFoo::ping() EXCEPTION"); - } -} - -class MyFoo2 extends Foo { - function ping() { - return true; - } -} - -class MyFoo3 extends Foo { - function ping() { - throw new MyException("foo", "bar"); - } -} - -# Check that the Exception raised by MyFoo.ping() is returned by -# MyFoo.pong(). -$ok = 0; -$a = new MyFoo(); -# TODO: Currently we do not track the dynamic type of returned -# objects, so we skip the launder() call. -#$b = director_exception::launder($a); -$b = $a; -try { - $b->pong(); -} catch (Exception $e) { - $ok = 1; - check::equal($e->getMessage(), "MyFoo::ping() EXCEPTION", "Unexpected error message #1"); -} -check::equal($ok, 1, "Got no exception while expected one #1"); - -# Check that the director can return an exception which requires two -# arguments to the constructor, without mangling it. -$ok = 0; -$a = new MyFoo3(); -#$b = director_exception::launder($a); -$b = $a; -try { - $b->pong(); -} catch (Exception $e) { - $ok = 1; - check::equal($e->msg, "foobar", "Unexpected error message #2"); -} -check::equal($ok, 1, "Got no exception while expected one #2"); - -try { - throw new Exception2(); -} catch (Exception2 $e2) { -} - -try { - throw new Exception1(); -} catch (Exception1 $e1) { -} - -// Check that we can throw exceptions from director methods (this didn't used -// to work in all cases, as the exception gets "set" in PHP and the method -// then returns PHP NULL, which the directorout template may fail to convert. - -class Bad extends ReturnAllTypes { - function return_int() { throw new Exception("bad int"); } - function return_double() { throw new Exception("bad double"); } - function return_const_char_star() { throw new Exception("bad const_char_star"); } - function return_std_string() { throw new Exception("bad std_string"); } - function return_Bar() { throw new Exception("bad Bar"); } -} - -$bad = new Bad(); - -try { - $bad->call_int(); - check::fail("Exception wasn't propagated from Bad::return_int()"); -} catch (Exception $e) { - check::equal($e->getMessage(), "bad int", "propagated exception incorrect"); -} - -try { - $bad->call_double(); - check::fail("Exception wasn't propagated from Bad::return_double()"); -} catch (Exception $e) { - check::equal($e->getMessage(), "bad double", "propagated exception incorrect"); -} - -try { - $bad->call_const_char_star(); - check::fail("Exception wasn't propagated from Bad::return_const_char_star()"); -} catch (Exception $e) { - check::equal($e->getMessage(), "bad const_char_star", "propagated exception incorrect"); -} - -try { - $bad->call_std_string(); - check::fail("Exception wasn't propagated from Bad::return_std_string()"); -} catch (Exception $e) { - check::equal($e->getMessage(), "bad std_string", "propagated exception incorrect"); -} - -try { - $bad->call_Bar(); - check::fail("Exception wasn't propagated from Bad::return_Bar()"); -} catch (Exception $e) { - check::equal($e->getMessage(), "bad Bar", "propagated exception incorrect"); -} - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_extend_runme.php b/Examples/test-suite/php5/director_extend_runme.php deleted file mode 100644 index f283aefbe..000000000 --- a/Examples/test-suite/php5/director_extend_runme.php +++ /dev/null @@ -1,24 +0,0 @@ -dummy(), 666, "1st call"); -check::equal($m->dummy(), 666, "2st call"); // Locked system - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_finalizer_runme.php b/Examples/test-suite/php5/director_finalizer_runme.php deleted file mode 100644 index 0fcddfd8b..000000000 --- a/Examples/test-suite/php5/director_finalizer_runme.php +++ /dev/null @@ -1,61 +0,0 @@ -orStatus(2); - if (method_exists(parent, "__destruct")) { - parent::__destruct(); - } - } -} - -resetStatus(); - -$a = new MyFoo(); -unset($a); - -check::equal(getStatus(), 3, "getStatus() failed #1"); - -resetStatus(); - -$a = new MyFoo(); -launder($a); - -check::equal(getStatus(), 0, "getStatus() failed #2"); - -unset($a); - -check::equal(getStatus(), 3, "getStatus() failed #3"); - -resetStatus(); - -$a = new MyFoo(); -$a->thisown = 0; -deleteFoo($a); -unset($a); - -check::equal(getStatus(), 3, "getStatus() failed #4"); - -resetStatus(); - -$a = new MyFoo(); -$a->thisown = 0; -deleteFoo(launder($a)); -unset($a); - -check::equal(getStatus(), 3, "getStatus() failed #5"); - -resetStatus(); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_frob_runme.php b/Examples/test-suite/php5/director_frob_runme.php deleted file mode 100644 index 548b0b804..000000000 --- a/Examples/test-suite/php5/director_frob_runme.php +++ /dev/null @@ -1,19 +0,0 @@ -abs_method(); - -check::equal($s, "Bravo::abs_method()", "s failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_nested_runme.php b/Examples/test-suite/php5/director_nested_runme.php deleted file mode 100644 index 4965e94f7..000000000 --- a/Examples/test-suite/php5/director_nested_runme.php +++ /dev/null @@ -1,74 +0,0 @@ -step(), "Bar::step;Foo::advance;Bar::do_advance;A::do_step;", "Bad A virtual resolution"); - -class B extends FooBar_int { - function do_advance() { - return "B::do_advance;" . $this->do_step(); - } - - function do_step() { - return "B::do_step;"; - } - - function get_value() { - return 1; - } -} - -$b = new B(); - -check::equal($b->step(), "Bar::step;Foo::advance;B::do_advance;B::do_step;", "Bad B virtual resolution"); - -class C extends FooBar_int { - function do_advance() { - return "C::do_advance;" . parent::do_advance(); - } - - function do_step() { - return "C::do_step;"; - } - - function get_value() { - return 2; - } - - function get_name() { - return parent::get_name() . " hello"; - } -} - -$cc = new C(); -# TODO: Currently we do not track the dynamic type of returned -# objects, so we skip the get_self() call. -#$c = Foobar_int::get_self($cc); -$c = $cc; -$c->advance(); - -check::equal($c->get_name(), "FooBar::get_name hello", "get_name failed"); - -check::equal($c->name(), "FooBar::get_name hello", "name failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_pass_by_value_runme.php b/Examples/test-suite/php5/director_pass_by_value_runme.php deleted file mode 100644 index 8a8b84d67..000000000 --- a/Examples/test-suite/php5/director_pass_by_value_runme.php +++ /dev/null @@ -1,24 +0,0 @@ -call_virtualMethod(new director_pass_by_value_Derived()); -$ret = $passByVal->getVal(); -if ($ret != 0x12345678) { - check::fail("Bad return value, got " . dechex($ret)); -} - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_profile_runme.php b/Examples/test-suite/php5/director_profile_runme.php deleted file mode 100644 index c72421341..000000000 --- a/Examples/test-suite/php5/director_profile_runme.php +++ /dev/null @@ -1,53 +0,0 @@ -fi($a); #1 - $a = $b->fi($a); #2 - $a = $b->fi($a); #3 - $a = $b->fi($a); #4 - $a = $b->fi($a); #5 - $a = $b->fi($a); #6 - $a = $b->fi($a); #7 - $a = $b->fi($a); #8 - $a = $b->fi($a); #9 - $a = $b->fi($a); #10 - $a = $b->fi($a); #1 - $a = $b->fi($a); #2 - $a = $b->fi($a); #3 - $a = $b->fi($a); #4 - $a = $b->fi($a); #5 - $a = $b->fi($a); #6 - $a = $b->fi($a); #7 - $a = $b->fi($a); #8 - $a = $b->fi($a); #9 - $a = $b->fi($a); #20 - $i -= 1; -} - -print $a . "\n"; - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_protected_runme.php b/Examples/test-suite/php5/director_protected_runme.php deleted file mode 100644 index 18586ca62..000000000 --- a/Examples/test-suite/php5/director_protected_runme.php +++ /dev/null @@ -1,70 +0,0 @@ -create(); -$fb = new FooBar(); -$fb2 = new FooBar2(); -$fb3 = new FooBar3(); - -check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used"); - -check::equal($fb2->used(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used"); - -check::equal($b->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong"); - -check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"); - -check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong"); - -$method = new ReflectionMethod('Bar', 'ping'); -check::equal($method->isProtected(), true, "Foo::ping should be protected"); - -$method = new ReflectionMethod('Foo', 'ping'); -check::equal($method->isProtected(), true, "Foo::ping should be protected"); - -$method = new ReflectionMethod('FooBar', 'pang'); -check::equal($method->isProtected(), true, "FooBar::pang should be protected"); - -$method = new ReflectionMethod('Bar', 'cheer'); -check::equal($method->isProtected(), true, "Bar::cheer should be protected"); - -$method = new ReflectionMethod('Foo', 'cheer'); -check::equal($method->isProtected(), true, "Foo::cheer should be protected"); - -check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong"); -check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping"); -check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer"); -check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping"); -check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_stl_runme.php b/Examples/test-suite/php5/director_stl_runme.php deleted file mode 100644 index 29addd261..000000000 --- a/Examples/test-suite/php5/director_stl_runme.php +++ /dev/null @@ -1,60 +0,0 @@ -tping("hello"); -$a->tpong("hello"); - -# TODO: automatic conversion between PHP arrays and std::pair or -# std::vector is not yet implemented. -/*$p = array(1, 2); -$a->pident($p); -$v = array(3, 4); -$a->vident($v); - -$a->tpident($p); -$a->tvident($v); - -$v1 = array(3, 4); -$v2 = array(5, 6); - -$a->tvsecond($v1, $v2); - -$vs = array("hi", "hello"); -$vs; -$a->tvidents($vs);*/ - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_string_runme.php b/Examples/test-suite/php5/director_string_runme.php deleted file mode 100644 index 5ac583f78..000000000 --- a/Examples/test-suite/php5/director_string_runme.php +++ /dev/null @@ -1,34 +0,0 @@ -smem = "hello"; - } -} - -$b = new B("hello"); - -$b->get(0); -check::equal($b->get_first(),"hello world!", "get_first failed"); - -$b->call_process_func(); - -check::equal($b->smem, "hello", "smem failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_thread_runme.php b/Examples/test-suite/php5/director_thread_runme.php deleted file mode 100644 index 809dec3e2..000000000 --- a/Examples/test-suite/php5/director_thread_runme.php +++ /dev/null @@ -1,32 +0,0 @@ -val = $this->val - 1; - } -} - -$d = new Derived(); -$d->run(); - -if ($d->val >= 0) { - check::fail($d->val); -} - -$d->stop(); - -check::done(); -?> diff --git a/Examples/test-suite/php5/director_unroll_runme.php b/Examples/test-suite/php5/director_unroll_runme.php deleted file mode 100644 index 626b1f07d..000000000 --- a/Examples/test-suite/php5/director_unroll_runme.php +++ /dev/null @@ -1,29 +0,0 @@ -set($a); -$c = $b->get(); - -check::equal($a->this, $c->this, "this failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/enum_scope_template_runme.php b/Examples/test-suite/php5/enum_scope_template_runme.php deleted file mode 100644 index 85ba467b7..000000000 --- a/Examples/test-suite/php5/enum_scope_template_runme.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/Examples/test-suite/php5/evil_diamond_ns_runme.php b/Examples/test-suite/php5/evil_diamond_ns_runme.php deleted file mode 100644 index fcce0f767..000000000 --- a/Examples/test-suite/php5/evil_diamond_ns_runme.php +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/Examples/test-suite/php5/evil_diamond_prop_runme.php b/Examples/test-suite/php5/evil_diamond_prop_runme.php deleted file mode 100644 index 02d9944d6..000000000 --- a/Examples/test-suite/php5/evil_diamond_prop_runme.php +++ /dev/null @@ -1,38 +0,0 @@ -_foo,"1==foo->_foo"); - -$bar=new bar(); -check::is_a($bar,"bar"); -check::equal(1,$bar->_foo,"1==bar->_foo"); -check::equal(2,$bar->_bar,"2==bar->_bar"); - -$baz=new baz(); -check::is_a($baz,"baz"); -check::equal(1,$baz->_foo,"1==baz->_foo"); -check::equal(3,$baz->_baz,"3==baz->_baz"); - -$spam=new spam(); -check::is_a($spam,"spam"); -check::equal(1,$spam->_foo,"1==spam->_foo"); -check::equal(2,$spam->_bar,"2==spam->_bar"); -// multiple inheritance not supported in PHP -check::equal(null,$spam->_baz,"null==spam->_baz"); -check::equal(4,$spam->_spam,"4==spam->_spam"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/evil_diamond_runme.php b/Examples/test-suite/php5/evil_diamond_runme.php deleted file mode 100644 index a587ca359..000000000 --- a/Examples/test-suite/php5/evil_diamond_runme.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/Examples/test-suite/php5/exception_order_runme.php b/Examples/test-suite/php5/exception_order_runme.php deleted file mode 100644 index acb83561a..000000000 --- a/Examples/test-suite/php5/exception_order_runme.php +++ /dev/null @@ -1,39 +0,0 @@ -foo(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); -} - -try { - $a->bar(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ E2 exception thrown', ''); -} - -try { - $a->foobar(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'postcatch unknown', ''); -} - -try { - $a->barfoo(1); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ E1 exception thrown', ''); -} - -try { - $a->barfoo(2); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ E2 * exception thrown', ''); -} -?> diff --git a/Examples/test-suite/php5/extend_template_ns_runme.php b/Examples/test-suite/php5/extend_template_ns_runme.php deleted file mode 100644 index e6d3e9f73..000000000 --- a/Examples/test-suite/php5/extend_template_ns_runme.php +++ /dev/null @@ -1,12 +0,0 @@ -test1(2),"test1"); -check::equal(3,$foo->test2(3),"test2"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/extend_template_runme.php b/Examples/test-suite/php5/extend_template_runme.php deleted file mode 100644 index 41bde4458..000000000 --- a/Examples/test-suite/php5/extend_template_runme.php +++ /dev/null @@ -1,12 +0,0 @@ -test1(2),"test1"); -check::equal(3,$foo->test2(3),"test2"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/grouping_runme.php b/Examples/test-suite/php5/grouping_runme.php deleted file mode 100644 index 51446f473..000000000 --- a/Examples/test-suite/php5/grouping_runme.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/Examples/test-suite/php5/ignore_parameter_runme.php b/Examples/test-suite/php5/ignore_parameter_runme.php deleted file mode 100644 index 1c8c76ad4..000000000 --- a/Examples/test-suite/php5/ignore_parameter_runme.php +++ /dev/null @@ -1,38 +0,0 @@ -daimler(2,3.4),"hello",'$sc->daimler(2,3.4)=="hello"'); -check::equal($sc->astonmartin("eek",3.4),101,'$sc->mastonmartin("eek",3.4)==101'); -check::equal($sc->bugatti("eek",2),8.8,'$sc->bugatti("eek",2)==8.8'); -check::equal($sc->lamborghini(),101,'$sc->lamborghini(2)==101'); - -$mc=new minicooper(2,3.4); -check::classname("minicooper",$mc); - -$mm=new morrisminor("eek",3.4); -check::classname("morrisminor",$mm); - -$fa=new fordanglia("eek",2); -check::classname("fordanglia",$fa); - -$aa=new austinallegro(); -check::classname("austinallegro",$aa); - -check::done(); -?> diff --git a/Examples/test-suite/php5/import_nomodule_runme.php b/Examples/test-suite/php5/import_nomodule_runme.php deleted file mode 100644 index 41836ba0f..000000000 --- a/Examples/test-suite/php5/import_nomodule_runme.php +++ /dev/null @@ -1,20 +0,0 @@ - diff --git a/Examples/test-suite/php5/li_carrays_cpp_runme.php b/Examples/test-suite/php5/li_carrays_cpp_runme.php deleted file mode 100644 index e0f9ffe92..000000000 --- a/Examples/test-suite/php5/li_carrays_cpp_runme.php +++ /dev/null @@ -1,22 +0,0 @@ -setitem(0, 7); -$d->setitem(5, $d->getitem(0) + 3); -check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/li_carrays_runme.php b/Examples/test-suite/php5/li_carrays_runme.php deleted file mode 100644 index 40e82f9ea..000000000 --- a/Examples/test-suite/php5/li_carrays_runme.php +++ /dev/null @@ -1,22 +0,0 @@ -setitem(0, 7); -$d->setitem(5, $d->getitem(0) + 3); -check::equal($d->getitem(0) + $d->getitem(5), 17., "7+10==17"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/li_factory_runme.php b/Examples/test-suite/php5/li_factory_runme.php deleted file mode 100644 index 6623e2a8c..000000000 --- a/Examples/test-suite/php5/li_factory_runme.php +++ /dev/null @@ -1,22 +0,0 @@ -radius(); -check::equal($r, 1.5, "r failed"); - -$point = Geometry::create(Geometry::POINT); -$w = $point->width(); -check::equal($w, 1.0, "w failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/li_std_string_runme.php b/Examples/test-suite/php5/li_std_string_runme.php deleted file mode 100644 index ad62247e1..000000000 --- a/Examples/test-suite/php5/li_std_string_runme.php +++ /dev/null @@ -1,31 +0,0 @@ -MemberString2, "member string 2", "MemberString2 test 1"); -$myStructure->MemberString2 = $s; -check::equal($myStructure->MemberString2, $s, "MemberString2 test 2"); -check::equal($myStructure->ConstMemberString, "const member string", "ConstMemberString test"); - -check::equal(Structure::StaticMemberString2(), "static member string 2", "StaticMemberString2 test 1"); -Structure::StaticMemberString2($s); -check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2"); -// below broken ? -//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/li_std_vector_member_var_runme.php b/Examples/test-suite/php5/li_std_vector_member_var_runme.php deleted file mode 100644 index 238350352..000000000 --- a/Examples/test-suite/php5/li_std_vector_member_var_runme.php +++ /dev/null @@ -1,30 +0,0 @@ -x, 0, "Test::x != 0"); -check::equal($t->v->size(), 0, "Test::v.size() != 0"); - -$t->f(1); -check::equal($t->x, 1, "Test::x != 1"); -check::equal($t->v->size(), 1, "Test::v.size() != 1"); - -$t->f(2); -check::equal($t->x, 3, "Test::x != 3"); -check::equal($t->v->size(), 2, "Test::v.size() != 2"); - -$t->f(3); -check::equal($t->x, 6, "Test::x != 6"); -check::equal($t->v->size(), 3, "Test::v.size() != 3"); - -$T = new T(); -$T->start_t = new S(); -$T->length = 7; -check::equal($T->start_t->x, 4, "S::x != 4"); -check::equal($T->length, 7, "T::length != 7"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/newobject1_runme.php b/Examples/test-suite/php5/newobject1_runme.php deleted file mode 100644 index 5853a72c0..000000000 --- a/Examples/test-suite/php5/newobject1_runme.php +++ /dev/null @@ -1,19 +0,0 @@ -makeMore(); -check::equal(get_class($bar), "Foo", "regular failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/newobject3_runme.php b/Examples/test-suite/php5/newobject3_runme.php deleted file mode 100644 index edd5d8608..000000000 --- a/Examples/test-suite/php5/newobject3_runme.php +++ /dev/null @@ -1,18 +0,0 @@ -create(7)); -check::classname("Product", $factory->create(7, 6)); -check::classname("Product", $factory->create("test")); -check::classname("Product", $factory->create("test", 2)); - -check::isnull($factory->create(0), "create(0) should be NULL"); -check::isnull($factory->create(7, -1), "create(7, -1) should be NULL"); -check::isnull($factory->create(0, -1), "create(0, -1) should be NULL"); -check::isnull($factory->create("bad", -1), "create(\"bad\", -1) should be NULL"); - -?> diff --git a/Examples/test-suite/php5/overload_rename_runme.php b/Examples/test-suite/php5/overload_rename_runme.php deleted file mode 100644 index dce4c6cb3..000000000 --- a/Examples/test-suite/php5/overload_rename_runme.php +++ /dev/null @@ -1,19 +0,0 @@ - diff --git a/Examples/test-suite/php5/overload_return_type_runme.php b/Examples/test-suite/php5/overload_return_type_runme.php deleted file mode 100644 index 4fa19d22a..000000000 --- a/Examples/test-suite/php5/overload_return_type_runme.php +++ /dev/null @@ -1,13 +0,0 @@ -foo(1), 0, ""); -check::classname("A", $b->foo("test")); - -check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1"); -check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1"); - -?> diff --git a/Examples/test-suite/php5/php_iterator_runme.php b/Examples/test-suite/php5/php_iterator_runme.php deleted file mode 100644 index d69a5b385..000000000 --- a/Examples/test-suite/php5/php_iterator_runme.php +++ /dev/null @@ -1,24 +0,0 @@ - $v) { - $s .= "($k=>$v)"; -} -check::equal($s, '(0=>2)(1=>3)(2=>4)', 'Simple iteration failed'); - -check::done(); -?> diff --git a/Examples/test-suite/php5/php_pragma_runme.php b/Examples/test-suite/php5/php_pragma_runme.php deleted file mode 100644 index c76cfc9b5..000000000 --- a/Examples/test-suite/php5/php_pragma_runme.php +++ /dev/null @@ -1,11 +0,0 @@ -getVersion(),"1.5==version(php_pragma)"); - -check::done(); - -?> diff --git a/Examples/test-suite/php5/pointer_reference_runme.php b/Examples/test-suite/php5/pointer_reference_runme.php deleted file mode 100644 index 52946177e..000000000 --- a/Examples/test-suite/php5/pointer_reference_runme.php +++ /dev/null @@ -1,18 +0,0 @@ -value, 10, "pointer_reference::get() failed"); - -$ss = new Struct(20); -pointer_reference::set($ss); -$i = Struct::instance(); -check::equal($i->value, 20, "pointer_reference::set() failed"); - -check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed"); -check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/prefix_runme.php b/Examples/test-suite/php5/prefix_runme.php deleted file mode 100644 index ead064f5b..000000000 --- a/Examples/test-suite/php5/prefix_runme.php +++ /dev/null @@ -1,18 +0,0 @@ -get_self(); - -check::done(); -?> diff --git a/Examples/test-suite/php5/preproc_constants_c_runme.php b/Examples/test-suite/php5/preproc_constants_c_runme.php deleted file mode 100644 index d55d4233d..000000000 --- a/Examples/test-suite/php5/preproc_constants_c_runme.php +++ /dev/null @@ -1,69 +0,0 @@ - diff --git a/Examples/test-suite/php5/preproc_constants_runme.php b/Examples/test-suite/php5/preproc_constants_runme.php deleted file mode 100644 index 01137b06b..000000000 --- a/Examples/test-suite/php5/preproc_constants_runme.php +++ /dev/null @@ -1,77 +0,0 @@ - diff --git a/Examples/test-suite/php5/primitive_ref_runme.php b/Examples/test-suite/php5/primitive_ref_runme.php deleted file mode 100644 index 263a28074..000000000 --- a/Examples/test-suite/php5/primitive_ref_runme.php +++ /dev/null @@ -1,34 +0,0 @@ - diff --git a/Examples/test-suite/php5/rename_scope_runme.php b/Examples/test-suite/php5/rename_scope_runme.php deleted file mode 100644 index df620d796..000000000 --- a/Examples/test-suite/php5/rename_scope_runme.php +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/Examples/test-suite/php5/skel.php b/Examples/test-suite/php5/skel.php deleted file mode 100644 index 780a999ed..000000000 --- a/Examples/test-suite/php5/skel.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/Examples/test-suite/php5/smart_pointer_rename_runme.php b/Examples/test-suite/php5/smart_pointer_rename_runme.php deleted file mode 100644 index 26692dde5..000000000 --- a/Examples/test-suite/php5/smart_pointer_rename_runme.php +++ /dev/null @@ -1,27 +0,0 @@ -ftest1(1),"foo->ftest1"); -check::equal(2,$foo->ftest2(1,2),"foo->ftest2"); - -# check bar's ftest1, ftest2, ftest -check::equal(1,$bar->ftest1(1),"bar->ftest1"); -check::equal(2,$bar->ftest2(1,2),"bar->ftest2"); -check::equal(3,$bar->test(),"bar->test"); - -# check deref returns foo -check::classname("foo",$bar->__deref__()); - -check::done(); -?> diff --git a/Examples/test-suite/php5/swig_exception_runme.php b/Examples/test-suite/php5/swig_exception_runme.php deleted file mode 100644 index 76641996e..000000000 --- a/Examples/test-suite/php5/swig_exception_runme.php +++ /dev/null @@ -1,33 +0,0 @@ -throwException(); - check::fail("Exception wasn't thrown"); -} catch (Exception $e) { - if ($e->getMessage() != "OK") { - check::fail("Exception getMessage() should be \"OK\", actually \"".$e->getMessage()."\""); - } -} - -# ----- Delete everything ----- - -$c = NULL; -$s = NULL; -$e = NULL; - -if (Shape::nshapes() != 0) { - check::fail("Shape::nshapes() should be 0, actually ".Shape::nshapes()); -} - -?> diff --git a/Examples/test-suite/php5/sym_runme.php b/Examples/test-suite/php5/sym_runme.php deleted file mode 100644 index 483aaa980..000000000 --- a/Examples/test-suite/php5/sym_runme.php +++ /dev/null @@ -1,22 +0,0 @@ -hulahoops(),"flim-jam","flim()->hulahoops==flim-jam"); -check::equal($flim->jar(),"flim-jar","flim()->jar==flim-jar"); -check::equal($flam->jam(),"flam-jam","flam()->jam==flam-jam"); -check::equal($flam->jar(),"flam-jar","flam()->jar==flam-jar"); - -check::done(); -?> diff --git a/Examples/test-suite/php5/template_arg_typename_runme.php b/Examples/test-suite/php5/template_arg_typename_runme.php deleted file mode 100644 index 7d60285e3..000000000 --- a/Examples/test-suite/php5/template_arg_typename_runme.php +++ /dev/null @@ -1,18 +0,0 @@ - diff --git a/Examples/test-suite/php5/template_construct_runme.php b/Examples/test-suite/php5/template_construct_runme.php deleted file mode 100644 index 3a3986f7e..000000000 --- a/Examples/test-suite/php5/template_construct_runme.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/Examples/test-suite/php5/tests.php b/Examples/test-suite/php5/tests.php deleted file mode 100644 index 92939c71c..000000000 --- a/Examples/test-suite/php5/tests.php +++ /dev/null @@ -1,237 +0,0 @@ - diff --git a/Examples/test-suite/php5/threads_exception_runme.php b/Examples/test-suite/php5/threads_exception_runme.php deleted file mode 100644 index 78c6bf592..000000000 --- a/Examples/test-suite/php5/threads_exception_runme.php +++ /dev/null @@ -1,43 +0,0 @@ -unknown(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ A * exception thrown', ''); -} - -try { - $t->simple(); -} catch (Exception $e) { - check::equal($e->getCode(), 37, ''); -} - -try { - $t->message(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'I died.', ''); -} - -try { - $t->hosed(); -} catch (Exception $e) { - check::equal($e->getMessage(), 'C++ Exc exception thrown', ''); -} - -foreach (Array(1,2,3,4) as $i) { - try { - $t->multi($i); - } catch (Exception $e) { - } -} diff --git a/Examples/test-suite/php5/typedef_reference_runme.php b/Examples/test-suite/php5/typedef_reference_runme.php deleted file mode 100644 index 88a70f8d3..000000000 --- a/Examples/test-suite/php5/typedef_reference_runme.php +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/Examples/test-suite/php5/typemap_ns_using_runme.php b/Examples/test-suite/php5/typemap_ns_using_runme.php deleted file mode 100644 index 6a599f008..000000000 --- a/Examples/test-suite/php5/typemap_ns_using_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php5/using1_runme.php b/Examples/test-suite/php5/using1_runme.php deleted file mode 100644 index 51841bc78..000000000 --- a/Examples/test-suite/php5/using1_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php5/using2_runme.php b/Examples/test-suite/php5/using2_runme.php deleted file mode 100644 index 391a98f52..000000000 --- a/Examples/test-suite/php5/using2_runme.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/Examples/test-suite/php5/valuewrapper_base_runme.php b/Examples/test-suite/php5/valuewrapper_base_runme.php deleted file mode 100644 index 6a1abdbd2..000000000 --- a/Examples/test-suite/php5/valuewrapper_base_runme.php +++ /dev/null @@ -1,13 +0,0 @@ - diff --git a/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php b/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php deleted file mode 100644 index 0d4aa3d5f..000000000 --- a/Examples/test-suite/php5/virtual_vs_nonvirtual_base_runme.php +++ /dev/null @@ -1,11 +0,0 @@ -getInner()->get(), $fail->getInner()->get(), "should both be 10"); - -?> diff --git a/Examples/test-suite/php5/wrapmacro_runme.php b/Examples/test-suite/php5/wrapmacro_runme.php deleted file mode 100644 index f32da990e..000000000 --- a/Examples/test-suite/php5/wrapmacro_runme.php +++ /dev/null @@ -1,12 +0,0 @@ - diff --git a/Examples/test-suite/restrict_cplusplus.i b/Examples/test-suite/restrict_cplusplus.i index 62abffa52..53c5782a1 100644 --- a/Examples/test-suite/restrict_cplusplus.i +++ b/Examples/test-suite/restrict_cplusplus.i @@ -1,7 +1,8 @@ %module restrict_cplusplus %{ -// For PHP 5.3 / gcc-4.4 +// Workaround PHP's headers which do: +// #define restrict __restrict__ #ifdef restrict #undef restrict #endif diff --git a/Lib/allkw.swg b/Lib/allkw.swg index b9413191f..563190e19 100644 --- a/Lib/allkw.swg +++ b/Lib/allkw.swg @@ -24,7 +24,6 @@ %include %include %include -%include %include %include %include diff --git a/Lib/cdata.i b/Lib/cdata.i index 3ac693cfc..23b7211e7 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -29,13 +29,6 @@ typedef struct SWIGCDATA { } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); -#elif SWIGPHP5 - -%typemap(out) SWIGCDATA { - ZVAL_STRINGL($result, $1.data, $1.len, 1); -} -%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); - #elif SWIGPHP7 %typemap(out) SWIGCDATA { diff --git a/Lib/exception.i b/Lib/exception.i index da0d56cdd..3e7c7fd8e 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -12,13 +12,6 @@ %insert("runtime") "swigerrors.swg" -#ifdef SWIGPHP5 -%{ -#include "zend_exceptions.h" -#define SWIG_exception(code, msg) do { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); goto thrown; } while (0) -%} -#endif - #ifdef SWIGPHP7 %{ #include "zend_exceptions.h" diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index db451f957..8e5d3412e 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -36,7 +36,7 @@ PHPKW(and); PHPKW(array); PHPKW(as); PHPKW(break); -PHPKW(callable); // As of PHP 5.4 +PHPKW(callable); PHPKW(case); PHPKW(catch); PHPKW(class); @@ -61,22 +61,22 @@ PHPKW(eval); // "Language construct" PHPKW(exit); // "Language construct" PHPKW(extends); PHPKW(final); -PHPKW(finally); // As of PHP 5.5 +PHPKW(finally); PHPKW(for); PHPKW(foreach); PHPKW(function); PHPKW(global); -PHPKW(goto); // As of PHP 5.3 +PHPKW(goto); PHPKW(if); PHPKW(implements); PHPKW(include); // "Language construct" PHPKW(include_once); // "Language construct" PHPKW(instanceof); -PHPKW(insteadof); // As of PHP 5.4 +PHPKW(insteadof); PHPKW(interface); PHPKW(isset); // "Language construct" PHPKW(list); // "Language construct" -PHPKW(namespace); // As of PHP 5.3 +PHPKW(namespace); PHPKW(new); PHPKW(or); PHPKW(print); // "Language construct" @@ -89,27 +89,27 @@ PHPKW(return); // "Language construct" PHPKW(static); PHPKW(switch); PHPKW(throw); -PHPKW(trait); // As of PHP 5.4 +PHPKW(trait); PHPKW(try); PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); PHPKW(xor); -PHPKW(yield); // As of PHP 5.5 +PHPKW(yield); // Compile-time "magic" constants // From: http://php.net/manual/en/reserved.keywords.php // also at: http://php.net/manual/en/language.constants.predefined.php /* These *MUST* be listed in lower case here */ PHPKW(__class__); -PHPKW(__dir__); // As of PHP 5.3 +PHPKW(__dir__); PHPKW(__file__); PHPKW(__function__); PHPKW(__line__); PHPKW(__method__); -PHPKW(__namespace__); // As of PHP 5.3 -PHPKW(__trait__); // As of PHP 5.4 +PHPKW(__namespace__); +PHPKW(__trait__); /* We classify these as built-in names since they conflict, but PHP still runs */ @@ -122,27 +122,27 @@ PHPBN1(false); /* "Core Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ /* These are case sensitive */ PHPBN2(PHP_VERSION); -PHPBN2(PHP_MAJOR_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_MINOR_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_RELEASE_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_VERSION_ID); // As of PHP 5.2.7 -PHPBN2(PHP_EXTRA_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_ZTS); // As of PHP 5.2.7 -PHPBN2(PHP_DEBUG); // As of PHP 5.2.7 -PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3.0 +PHPBN2(PHP_MAJOR_VERSION); +PHPBN2(PHP_MINOR_VERSION); +PHPBN2(PHP_RELEASE_VERSION); +PHPBN2(PHP_VERSION_ID); +PHPBN2(PHP_EXTRA_VERSION); +PHPBN2(PHP_ZTS); +PHPBN2(PHP_DEBUG); +PHPBN2(PHP_MAXPATHLEN); PHPBN2(PHP_OS); PHPBN2(PHP_SAPI); -PHPBN2(PHP_EOL); // As of PHP 5.0.2 -PHPBN2(PHP_INT_MAX); // As of PHP 5.0.5 -PHPBN2(PHP_INT_SIZE); // As of PHP 5.0.5 +PHPBN2(PHP_EOL); +PHPBN2(PHP_INT_MAX); +PHPBN2(PHP_INT_SIZE); PHPBN2(DEFAULT_INCLUDE_PATH); PHPBN2(PEAR_INSTALL_DIR); PHPBN2(PEAR_EXTENSION_DIR); PHPBN2(PHP_EXTENSION_DIR); PHPBN2(PHP_PREFIX); PHPBN2(PHP_BINDIR); -PHPBN2(PHP_BINARY); // As of PHP 5.4 -PHPBN2(PHP_MANDIR); // As of PHP 5.3.7 +PHPBN2(PHP_BINARY); +PHPBN2(PHP_MANDIR); PHPBN2(PHP_LIBDIR); PHPBN2(PHP_DATADIR); PHPBN2(PHP_SYSCONFDIR); @@ -161,11 +161,11 @@ PHPBN2(E_COMPILE_WARNING); PHPBN2(E_USER_ERROR); PHPBN2(E_USER_WARNING); PHPBN2(E_USER_NOTICE); -PHPBN2(E_DEPRECATED); // As of PHP 5.3.0 -PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3.0 +PHPBN2(E_DEPRECATED); +PHPBN2(E_USER_DEPRECATED); PHPBN2(E_ALL); PHPBN2(E_STRICT); -PHPBN2(__COMPILER_HALT_OFFSET__); // As of PHP 5.1.0 +PHPBN2(__COMPILER_HALT_OFFSET__); // TRUE, FALSE, NULL are listed on the same page, but are actually // case-insensitive, whereas all the other constants listed there seem to be // case-sensitive, so we handle TRUE, FALSE, NULL in PHPBN1. @@ -174,17 +174,17 @@ PHPBN2(PHP_OUTPUT_HANDLER_CONT); PHPBN2(PHP_OUTPUT_HANDLER_END); /* These don't actually seem to be set (tested on Linux, I guess they're * Windows only?) */ -PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_NT_SERVER); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_NT_WORKSTATION); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_BUILD); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_MAJOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_MINOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3 +PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); +PHPBN2(PHP_WINDOWS_NT_SERVER); +PHPBN2(PHP_WINDOWS_NT_WORKSTATION); +PHPBN2(PHP_WINDOWS_VERSION_BUILD); +PHPBN2(PHP_WINDOWS_VERSION_MAJOR); +PHPBN2(PHP_WINDOWS_VERSION_MINOR); +PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); +PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); +PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); +PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); +PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); /* "Standard Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ PHPBN2(EXTR_OVERWRITE); PHPBN2(EXTR_SKIP); @@ -214,8 +214,8 @@ PHPBN2(INI_USER); PHPBN2(INI_PERDIR); PHPBN2(INI_SYSTEM); PHPBN2(INI_ALL); -PHPBN2(INI_SCANNER_NORMAL); // As of PHP 5.3 -PHPBN2(INI_SCANNER_RAW); // As of PHP 5.3 +PHPBN2(INI_SCANNER_NORMAL); +PHPBN2(INI_SCANNER_RAW); PHPBN2(M_E); PHPBN2(M_LOG2E); PHPBN2(M_LOG10E); @@ -229,10 +229,10 @@ PHPBN2(M_2_PI); PHPBN2(M_2_SQRTPI); PHPBN2(M_SQRT2); PHPBN2(M_SQRT1_2); -PHPBN2(M_EULER); // As of PHP 5.2 -PHPBN2(M_LNPI); // As of PHP 5.2 -PHPBN2(M_SQRT3); // As of PHP 5.2 -PHPBN2(M_SQRTPI); // As of PHP 5.2 +PHPBN2(M_EULER); +PHPBN2(M_LNPI); +PHPBN2(M_SQRT3); +PHPBN2(M_SQRTPI); PHPBN2(CRYPT_SALT_LENGTH); PHPBN2(CRYPT_STD_DES); PHPBN2(CRYPT_EXT_DES); @@ -273,7 +273,7 @@ PHPBN2(STR_PAD_BOTH); PHPBN2(PATHINFO_DIRNAME); PHPBN2(PATHINFO_BASENAME); PHPBN2(PATHINFO_EXTENSION); -PHPBN2(PATHINFO_FILENAME); // As of PHP 5.2 +PHPBN2(PATHINFO_FILENAME); PHPBN2(PATH_SEPARATOR); PHPBN2(CHAR_MAX); PHPBN2(LC_CTYPE); @@ -393,7 +393,6 @@ PHPBN2(LOG_NDELAY); PHPBN2(LOG_NOWAIT); PHPBN2(LOG_PERROR); -/* Added in PHP 5.2 */ PHPBN2(PREG_BACKTRACK_LIMIT_ERROR); PHPBN2(PREG_BAD_UTF8_ERROR); PHPBN2(PREG_INTERNAL_ERROR); @@ -415,10 +414,10 @@ PHPBN2(CURLFTPSSL_NONE); PHPBN2(CURLFTPSSL_TRY); PHPBN2(CURLOPT_FTP_SSL); PHPBN2(CURLOPT_FTPSSLAUTH); -PHPBN2(CURLOPT_TCP_NODELAY); // Added in PHP 5.2.1 -PHPBN2(CURLOPT_TIMEOUT_MS); // Added in PHP 5.2.3 -PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); // Added in PHP 5.2.3 -PHPBN2(GMP_VERSION); // Added in PHP 5.2.2 +PHPBN2(CURLOPT_TCP_NODELAY); +PHPBN2(CURLOPT_TIMEOUT_MS); +PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); +PHPBN2(GMP_VERSION); PHPBN2(SWFTEXTFIELD_USEFONT); PHPBN2(SWFTEXTFIELD_AUTOSIZE); PHPBN2(SWF_SOUND_NOT_COMPRESSED); @@ -440,7 +439,6 @@ PHPBN2(SNMP_OID_OUTPUT_NUMERIC); PHPBN2(MSG_EAGAIN); PHPBN2(MSG_ENOMSG); -/* Added in PHP 5.3 */ PHPBN2(CURLOPT_PROGRESSFUNCTION); PHPBN2(IMG_FILTER_PIXELATE); PHPBN2(JSON_ERROR_CTRL_CHAR); @@ -504,7 +502,6 @@ PHPBN2(SIG_UNBLOCK); PHPBN2(TRAP_BRKPT); PHPBN2(TRAP_TRACE); -/* Added in PHP 5.4 */ PHPBN2(ENT_DISALLOWED); PHPBN2(ENT_HTML401); PHPBN2(ENT_HTML5); @@ -583,7 +580,6 @@ PHPBN2(JSON_NUMERIC_CHECK); PHPBN2(JSON_UNESCAPED_UNICODE); PHPBN2(JSON_BIGINT_AS_STRING); -/* Added in PHP 5.5 */ PHPBN2(IMG_AFFINE_TRANSLATE); PHPBN2(IMG_AFFINE_SCALE); PHPBN2(IMG_AFFINE_ROTATE); @@ -622,7 +618,6 @@ PHPBN2(JSON_ERROR_INF_OR_NAN); PHPBN2(JSON_ERROR_UNSUPPORTED_TYPE); PHPBN2(MYSQLI_SERVER_PUBLIC_KEY); -/* Added in PHP 5.6 */ PHPBN2(LDAP_ESCAPE_DN); PHPBN2(LDAP_ESCAPE_FILTER); PHPBN2(OPENSSL_DEFAULT_STREAM_CIPHERS); @@ -654,10 +649,10 @@ PHPCN(stdclass); PHPCN(__php_incomplete_class); /* Added in PHP5. */ PHPCN(exception); -PHPCN(errorexception); // As of PHP 5.1 +PHPCN(errorexception); PHPCN(php_user_filter); -PHPCN(closure); // As of PHP 5.3 -PHPCN(generator); // As of PHP 5.5 +PHPCN(closure); +PHPCN(generator); PHPCN(self); PHPCN(static); PHPCN(parent); diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 5c62d1927..3aa75ca1c 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -13,7 +13,7 @@ extern "C" { #include "php.h" #if PHP_MAJOR_VERSION != 7 -# error These bindings need PHP7 - to generate PHP5 bindings use: swig -php5 +# error These bindings need PHP7 - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5 #endif #include "ext/standard/php_string.h" diff --git a/Lib/php5/const.i b/Lib/php5/const.i deleted file mode 100644 index 061ba99a2..000000000 --- a/Lib/php5/const.i +++ /dev/null @@ -1,51 +0,0 @@ -/* ----------------------------------------------------------------------------- - * const.i - * - * Typemaps for constants - * ----------------------------------------------------------------------------- */ - -%typemap(consttab) int, - unsigned int, - short, - unsigned short, - long, - unsigned long, - unsigned char, - signed char, - bool, - enum SWIGTYPE - "SWIG_LONG_CONSTANT($symname, ($1_type)$value);"; - -%typemap(consttab) float, - double - "SWIG_DOUBLE_CONSTANT($symname, $value);"; - -%typemap(consttab) char - "SWIG_CHAR_CONSTANT($symname, $value);"; - -%typemap(consttab) char *, - const char *, - char [], - const char [] - "SWIG_STRING_CONSTANT($symname, $value);"; - -%typemap(consttab) SWIGTYPE *, - SWIGTYPE &, - SWIGTYPE &&, - SWIGTYPE [] { - zval *z_var; - zend_constant c; - size_t len = sizeof("$symname") - 1; - MAKE_STD_ZVAL(z_var); - SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); - c.value = *z_var; - zval_copy_ctor(&c.value); - c.name = zend_strndup("$symname", len); - c.name_len = len+1; - c.flags = CONST_CS | CONST_PERSISTENT; - c.module_number = module_number; - zend_register_constant( &c TSRMLS_CC ); -} - -/* Handled as a global variable. */ -%typemap(consttab) SWIGTYPE (CLASS::*) ""; diff --git a/Lib/php5/director.swg b/Lib/php5/director.swg deleted file mode 100644 index 638a1697d..000000000 --- a/Lib/php5/director.swg +++ /dev/null @@ -1,170 +0,0 @@ -/* ----------------------------------------------------------------------------- - * director.swg - * - * This file contains support for director classes so that PHP proxy - * methods can be called from C++. - * ----------------------------------------------------------------------------- */ - -#ifndef SWIG_DIRECTOR_PHP_HEADER_ -#define SWIG_DIRECTOR_PHP_HEADER_ - -#include -#include -#include - -namespace Swig { - - /* memory handler */ - struct GCItem { - virtual ~GCItem() { - } - - virtual int get_own() const { - return 0; - } - }; - - struct GCItem_var { - GCItem_var(GCItem *item = 0) : _item(item) { - } - - GCItem_var& operator=(GCItem *item) { - GCItem *tmp = _item; - _item = item; - delete tmp; - return *this; - } - - ~GCItem_var() { - delete _item; - } - - GCItem * operator->() const { - return _item; - } - - private: - GCItem *_item; - }; - - struct GCItem_Object : GCItem { - GCItem_Object(int own) : _own(own) { - } - - virtual ~GCItem_Object() { - } - - int get_own() const { - return _own; - } - - private: - int _own; - }; - - template - struct GCItem_T : GCItem { - GCItem_T(Type *ptr) : _ptr(ptr) { - } - - virtual ~GCItem_T() { - delete _ptr; - } - - private: - Type *_ptr; - }; - - class Director { - protected: - zval *swig_self; - typedef std::map swig_ownership_map; - mutable swig_ownership_map swig_owner; -#ifdef ZTS - // Store the ZTS context so it's available when C++ calls back to PHP. - void *** swig_zts_ctx; -#endif - public: - Director(zval *self TSRMLS_DC) : swig_self(self) { - TSRMLS_SET_CTX(swig_zts_ctx); - } - - static bool swig_is_overridden_method(char *cname, char *lc_fname TSRMLS_DC) { - zend_class_entry **ce; - zend_function *mptr; - - if (zend_lookup_class(cname, strlen(cname), &ce TSRMLS_CC) != SUCCESS) { - return false; - } - if (zend_hash_find(&(*ce)->function_table, lc_fname, strlen(lc_fname) + 1, (void **) &mptr) != SUCCESS) { - return false; - } - // common.scope points to the declaring class - return strcmp(mptr->common.scope->name, cname); - } - - template - void swig_acquire_ownership(Type *vptr) const { - if (vptr) { - swig_owner[vptr] = new GCItem_T(vptr); - } - } - }; - - /* base class for director exceptions */ - class DirectorException : public std::exception { - protected: - std::string swig_msg; - public: - DirectorException(int code, const char *hdr, const char *msg TSRMLS_DC) : swig_msg(hdr) { - if (msg[0]) { - swig_msg += " "; - swig_msg += msg; - } - SWIG_ErrorCode() = code; - SWIG_ErrorMsg() = swig_msg.c_str(); - } - - virtual ~DirectorException() throw() { - } - - const char *what() const throw() { - return swig_msg.c_str(); - } - - static void raise(int code, const char *hdr, const char *msg TSRMLS_DC) { - throw DirectorException(code, hdr, msg TSRMLS_CC); - } - }; - - /* attempt to call a pure virtual method via a director method */ - class DirectorPureVirtualException : public DirectorException { - public: - DirectorPureVirtualException(const char *msg TSRMLS_DC) - : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg TSRMLS_CC) { - } - - static void raise(const char *msg TSRMLS_DC) { - throw DirectorPureVirtualException(msg TSRMLS_CC); - } - }; - - /* any php exception that occurs during a director method call */ - class DirectorMethodException : public DirectorException - { - public: - DirectorMethodException(const char *msg TSRMLS_DC) - : DirectorException(E_ERROR, "SWIG director method error", msg TSRMLS_CC) { - } - - static void raise(const char *msg TSRMLS_DC) { - throw DirectorMethodException(msg TSRMLS_CC); - } - }; -} - -// DirectorMethodException() is documented to be callable with no parameters -// so use a macro to insert TSRMLS_CC so any ZTS context gets passed. -#define DirectorMethodException() DirectorMethodException("" TSRMLS_CC) - -#endif diff --git a/Lib/php5/factory.i b/Lib/php5/factory.i deleted file mode 100644 index c4e082dd2..000000000 --- a/Lib/php5/factory.i +++ /dev/null @@ -1,109 +0,0 @@ -/* - Implement a more natural wrap for factory methods, for example, if - you have: - - ---- geometry.h -------- - struct Geometry { - enum GeomType{ - POINT, - CIRCLE - }; - - virtual ~Geometry() {} - virtual int draw() = 0; - - // - // Factory method for all the Geometry objects - // - static Geometry *create(GeomType i); - }; - - struct Point : Geometry { - int draw() { return 1; } - double width() { return 1.0; } - }; - - struct Circle : Geometry { - int draw() { return 2; } - double radius() { return 1.5; } - }; - - // - // Factory method for all the Geometry objects - // - Geometry *Geometry::create(GeomType type) { - switch (type) { - case POINT: return new Point(); - case CIRCLE: return new Circle(); - default: return 0; - } - } - ---- geometry.h -------- - - - You can use the %factory with the Geometry::create method as follows: - - %newobject Geometry::create; - %factory(Geometry *Geometry::create, Point, Circle); - %include "geometry.h" - - and Geometry::create will return a 'Point' or 'Circle' instance - instead of the plain 'Geometry' type. For example, in python: - - circle = Geometry.create(Geometry.CIRCLE) - r = circle.radius() - - where circle is a Circle proxy instance. - - NOTES: remember to fully qualify all the type names and don't - use %factory inside a namespace declaration, ie, instead of - - namespace Foo { - %factory(Geometry *Geometry::create, Point, Circle); - } - - use - - %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); - - -*/ - -/* for loop for macro with one argument */ -%define %_formacro_1(macro, arg1,...)macro(arg1) -#if #__VA_ARGS__ != "__fordone__" -%_formacro_1(macro, __VA_ARGS__) -#endif -%enddef - -/* for loop for macro with one argument */ -%define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef -%define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef - -/* for loop for macro with two arguments */ -%define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) -#if #__VA_ARGS__ != "__fordone__" -%_formacro_2(macro, __VA_ARGS__) -#endif -%enddef - -/* for loop for macro with two arguments */ -%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef - -%define %_factory_dispatch(Type) -if (!dcast) { - Type *dobj = dynamic_cast($1); - if (dobj) { - dcast = 1; - SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner); - } -}%enddef - -%define %factory(Method,Types...) -%typemap(out) Method { - int dcast = 0; - %formacro(%_factory_dispatch, Types) - if (!dcast) { - SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),$descriptor, $owner); - } -}%enddef diff --git a/Lib/php5/globalvar.i b/Lib/php5/globalvar.i deleted file mode 100644 index a3e99f510..000000000 --- a/Lib/php5/globalvar.i +++ /dev/null @@ -1,361 +0,0 @@ -/* ----------------------------------------------------------------------------- - * globalvar.i - * - * Global variables - add the variable to PHP - * ----------------------------------------------------------------------------- */ - -%typemap(varinit) char * -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_STRING; - if($1) { - z_var->value.str.val = estrdup($1); - z_var->value.str.len = strlen($1); - } else { - z_var->value.str.val = 0; - z_var->value.str.len = 0; - } - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); -} - -%typemap(varinit) char [] -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_STRING; - z_var->value.str.val = estrdup($1); - z_var->value.str.len = strlen($1); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); -} - -%typemap(varinit) int, - unsigned int, - unsigned short, - short, - unsigned short, - long, - unsigned long, - signed char, - unsigned char, - enum SWIGTYPE -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_LONG; - z_var->value.lval = (long)$1; - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); -} - -%typemap(varinit) bool -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_BOOL; - z_var->value.lval = ($1)?1:0; - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, sizeof(zval *), NULL); -} - -%typemap(varinit) float, double -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_DOUBLE; - z_var->value.dval = $1; - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, - sizeof(zval *), NULL); -} - -%typemap(varinit) char -{ - zval *z_var; - char c[2]; - MAKE_STD_ZVAL(z_var); - c[0] = $1; - c[1] = 0; - z_var->type = IS_STRING; - z_var->value.str.val = estrndup(c, 1); - z_var->value.str.len = 1; - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, - sizeof(zval *), NULL); -} - -%typemap(varinit) SWIGTYPE *, SWIGTYPE [] -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, 0); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void *)&z_var, - sizeof(zval *), NULL); -} - -%typemap(varinit) SWIGTYPE, SWIGTYPE &, SWIGTYPE && -{ - zval *z_var; - - MAKE_STD_ZVAL(z_var); - SWIG_SetPointerZval(z_var, (void*)&$1, $&1_descriptor, 0); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, - sizeof(zval *), NULL); -} - -%typemap(varinit) char [ANY] -{ - zval *z_var; - MAKE_STD_ZVAL(z_var); - z_var->type = IS_STRING; - ZVAL_STRINGL(z_var,(char*)$1, $1_dim0, 1); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); -} - -%typemap(varinit, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) -{ - void * p = emalloc(sizeof($1)); - memcpy(p, &$1, sizeof($1)); - zval * resource; - MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); -} - -%typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - convert_to_long_ex(z_var); - if ($1 != ($1_ltype)((*z_var)->value.lval)) { - $1 = Z_LVAL_PP(z_var); - } -} - -%typemap(varin) bool -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - convert_to_boolean_ex(z_var); - if ($1 != ($1_ltype)((*z_var)->value.lval)) { - $1 = Z_LVAL_PP(z_var); - } -} - -%typemap(varin) double,float -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - convert_to_double_ex(z_var); - if ($1 != ($1_ltype)((*z_var)->value.dval)) { - $1 = Z_DVAL_PP(z_var); - } -} - -%typemap(varin) char -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - convert_to_string_ex(z_var); - if ($1 != *((*z_var)->value.str.val)) { - $1 = *((*z_var)->value.str.val); - } -} - -%typemap(varin) char * -{ - zval **z_var; - char *s1; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - convert_to_string_ex(z_var); - s1 = Z_STRVAL_PP(z_var); - if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { - if (s1) - $1 = estrdup(s1); - else - $1 = NULL; - } -} - - -%typemap(varin) SWIGTYPE [] -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1) { - SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, $owner); - } -} - -%typemap(varin) char [ANY] -{ - zval **z_var; - char *s1; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - s1 = Z_STRVAL_PP(z_var); - if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { - if (s1) - strncpy($1, s1, $1_dim0); - } -} - -%typemap(varin) SWIGTYPE -{ - zval **z_var; - $&1_ltype _temp; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if (SWIG_ConvertPtr(*z_var, (void**)&_temp, $&1_descriptor, 0) < 0) { - SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); - } - - $1 = *($&1_ltype)_temp; - -} - -%typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && -{ - zval **z_var; - $1_ltype _temp; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if (SWIG_ConvertPtr(*z_var, (void **)&_temp, $1_descriptor, 0) < 0) { - SWIG_PHP_Error(E_ERROR,"Type error in value of $symname. Expected $&1_descriptor"); - } - - $1 = ($1_ltype)_temp; -} - -%typemap(varin, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); - memcpy(&$1, p, sizeof($1)); -} - -%typemap(varout) int, - unsigned int, - unsigned short, - short, - long, - unsigned long, - signed char, - unsigned char, - enum SWIGTYPE -{ - zval **z_var; - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1 != ($1_ltype)((*z_var)->value.lval)) { - (*z_var)->value.lval = (long)$1; - } -} - -//SAMFIX need to cast zval->type, what if zend-hash_find fails? etc? -%typemap(varout) bool -{ - zval **z_var; - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1 != ($1_ltype)((*z_var)->value.lval)) { - (*z_var)->value.lval = (long)$1; - } -} - -%typemap(varout) double, float -{ - zval **z_var; - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1 != ($1_ltype)((*z_var)->value.dval)) { - (*z_var)->value.dval = (double)$1; - } -} - -%typemap(varout) char -{ - zval **z_var; - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1 != *((*z_var)->value.str.val)) { - char c[2]; - efree((*z_var)->value.str.val); - c[0] = $1; - c[1] = 0; - (*z_var)->value.str.val = estrdup(c); - } -} - -%typemap(varout) char * -{ - zval **z_var; - char *s1; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - s1 = Z_STRVAL_PP(z_var); - if((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { - if(s1) - efree(s1); - if($1) { - (*z_var)->value.str.val = estrdup($1); - (*z_var)->value.str.len = strlen($1) + 1; - } else { - (*z_var)->value.str.val = 0; - (*z_var)->value.str.len = 0; - } - } -} - -%typemap(varout) SWIGTYPE -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - SWIG_SetPointerZval(*z_var, (void*)&$1, $&1_descriptor, 0); -} - -%typemap(varout) SWIGTYPE [] -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - if($1) - SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); -} - -%typemap(varout) char [ANY] -{ - zval **z_var; - char *s1; -deliberate error cos this code looks bogus to me - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - s1 = Z_STRVAL_PP(z_var); - if((s1 == NULL) || strcmp(s1, $1)) { - if($1) { - (*z_var)->value.str.val = estrdup($1); - (*z_var)->value.str.len = strlen($1) + 1; - } else { - (*z_var)->value.str.val = 0; - (*z_var)->value.str.len = 0; - } - } -} - -%typemap(varout) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && -{ - zval **z_var; - - zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); - SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); -} - -%typemap(varout, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) -{ - void * p = emalloc(sizeof($1)); - memcpy(p, &$1, sizeof($1)); - zval * resource; - MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, p, swig_member_ptr); - zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); -} diff --git a/Lib/php5/php.swg b/Lib/php5/php.swg deleted file mode 100644 index 6f8470ff9..000000000 --- a/Lib/php5/php.swg +++ /dev/null @@ -1,530 +0,0 @@ -/* ----------------------------------------------------------------------------- - * php.swg - * - * PHP configuration file - * ----------------------------------------------------------------------------- */ - -%runtime "swigrun.swg" // Common C API type-checking code -%runtime "phprun.swg" // PHP runtime functions - -%include // PHP initialization routine. - -%include // Global variables. -%include - -// use %init %{ "/*code goes here*/ " %} -// or %minit %{ "/* code goes here*/ " %} to -// insert code in the PHP_MINIT_FUNCTION -#define %minit %insert("init") - -// use %rinit %{ "/* code goes here*/ " %} to -// insert code in the PHP_RINIT_FUNCTION -#define %rinit %insert("rinit") - -// use %shutdown %{ " /*code goes here*/ " %} to -// insert code in the PHP_MSHUTDOWN_FUNCTION -#define %shutdown %insert("shutdown") -#define %mshutdown %insert("shutdown") - -// use %rshutdown %{ " /*code goes here*/" %} to -// insert code in the PHP_RSHUTDOWN_FUNCTION -#define %rshutdown %insert("rshutdown") - -/* Typemaps for input parameters by value */ - -%include - -%pass_by_val(bool,CONVERT_BOOL_IN); - -%pass_by_val(size_t, CONVERT_INT_IN); - -%pass_by_val(enum SWIGTYPE, CONVERT_INT_IN); - -%pass_by_val(signed int, CONVERT_INT_IN); -%pass_by_val(int,CONVERT_INT_IN); -%pass_by_val(unsigned int,CONVERT_INT_IN); - -%pass_by_val(signed short, CONVERT_INT_IN); -%pass_by_val(short,CONVERT_INT_IN); -%pass_by_val(unsigned short, CONVERT_INT_IN); - -%pass_by_val(signed long, CONVERT_INT_IN); -%pass_by_val(long, CONVERT_INT_IN); -%pass_by_val(unsigned long, CONVERT_INT_IN); - -%pass_by_val(signed long long, CONVERT_LONG_LONG_IN); -%pass_by_val(long long, CONVERT_LONG_LONG_IN); -%pass_by_val(unsigned long long, CONVERT_UNSIGNED_LONG_LONG_IN); - -%pass_by_val(signed char, CONVERT_INT_IN); -%pass_by_val(char, CONVERT_CHAR_IN); -%pass_by_val(unsigned char, CONVERT_INT_IN); - -%pass_by_val(float, CONVERT_FLOAT_IN); - -%pass_by_val(double, CONVERT_FLOAT_IN); - -%pass_by_val(char *, CONVERT_STRING_IN); -%typemap(in) char *& = const char *&; -%typemap(directorout) char *& = const char *&; - -// char array can be in/out, though the passed string may not be big enough... -// so we have to size it -%typemap(in) char[ANY] -{ - convert_to_string_ex($input); - $1 = ($1_ltype) Z_STRVAL_PP($input); -} - -%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t 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) -{ - if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); - } - $1 = *tmp; -} - -%typemap(directorout) SWIGTYPE ($&1_ltype tmp) -{ - /* If exit was via exception, PHP NULL is returned so skip the conversion. */ - if (!EG(exception)) { - if(SWIG_ConvertPtr($input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); - $result = *tmp; - } -} - -%typemap(in) SWIGTYPE *, - SWIGTYPE [] -{ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); - } -} - -%typemap(in) SWIGTYPE & -{ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); - } -} - -%typemap(in) SWIGTYPE && -{ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); - } -} - -%typemap(in) SWIGTYPE *const& ($*ltype temp) -{ - if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); - } - $1 = ($1_ltype)&temp; -} - -%typemap(in) SWIGTYPE *DISOWN -{ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); - } -} - -%typemap(argout) SWIGTYPE *, - SWIGTYPE [], - SWIGTYPE &, - SWIGTYPE &&; - -%typemap(in) void * -{ - if(SWIG_ConvertPtr(*$input, (void **) &$1, 0, 0) < 0) { - /* Allow NULL from php for void* */ - if ((*$input)->type==IS_NULL) $1=0; - else - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); - } -} - -/* Special case when void* is passed by reference so it can be made to point - to opaque api structs */ -%typemap(in) void ** ($*1_ltype ptr, int force), - void *& ($*1_ltype ptr, int force) -{ - /* If they pass NULL by reference, make it into a void* - This bit should go in arginit if arginit support init-ing scripting args */ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { - /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ - if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { - /* wasn't a pre/ref/thing, OR anything like an int thing */ - SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); - } - } - force=0; - if (arg1==NULL) { -#ifdef __cplusplus - ptr=new $*1_ltype(); -#else - ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); -#endif - $1=&ptr; - /* have to passback arg$arg too */ - force=1; - } -} -%typemap(argout) void **, - void *& -{ - if (force$argnum) { - SWIG_SetPointerZval( *$input, (void*) ptr$argnum, $*1_descriptor, 1); - } -} - -/* Typemap for output values */ - -%typemap(out) int, - unsigned int, - short, - unsigned short, - long, - unsigned long, - signed char, - unsigned char, - bool, - size_t -{ - ZVAL_LONG(return_value,$1); -} - -%typemap(out) enum SWIGTYPE -{ - ZVAL_LONG(return_value, (long)$1); -} - -%typemap(out) long long -%{ - if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) { - return_value->value.lval = (long)($1); - return_value->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%lld", (long long)$1); - ZVAL_STRING(return_value, temp, 1); - } -%} -%typemap(out) unsigned long long -%{ - if ($1 <= (unsigned long long)LONG_MAX) { - return_value->value.lval = (long)($1); - return_value->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%llu", (unsigned long long)$1); - ZVAL_STRING(return_value, temp, 1); - } -%} - -%typemap(out) const int &, - const unsigned int &, - const short &, - const unsigned short &, - const long &, - const unsigned long &, - const signed char &, - const unsigned char &, - const bool &, - const size_t & -{ - ZVAL_LONG(return_value,*$1); -} - -%typemap(out) const enum SWIGTYPE & -{ - ZVAL_LONG(return_value, (long)*$1); -} - -%typemap(out) const enum SWIGTYPE && -{ - ZVAL_LONG(return_value, (long)*$1); -} - -%typemap(out) const long long & -%{ - if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { - return_value->value.lval = (long)(*$1); - return_value->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%lld", (long long)(*$1)); - ZVAL_STRING(return_value, temp, 1); - } -%} -%typemap(out) const unsigned long long & -%{ - if (*$1 <= (unsigned long long)LONG_MAX) { - return_value->value.lval = (long)(*$1); - return_value->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%llu", (unsigned long long)(*$1)); - ZVAL_STRING(return_value, temp, 1); - } -%} - -%typemap(directorin) int, - unsigned int, - short, - unsigned short, - long, - unsigned long, - signed char, - unsigned char, - size_t, - enum SWIGTYPE -{ - ZVAL_LONG($input,$1); -} - -%typemap(directorin) enum SWIGTYPE -{ - ZVAL_LONG($input, (long)$1_name); -} - -%typemap(directorin) char *, char [] -{ - if(!$1) { - ZVAL_NULL($input); - } else { - ZVAL_STRING($input, (char *)$1, 1); - } -} - -%typemap(out) bool -{ - ZVAL_BOOL(return_value,($1)?1:0); -} - -%typemap(out) const bool & -{ - ZVAL_BOOL(return_value,(*$1)?1:0); -} - -%typemap(directorin) bool -{ - ZVAL_BOOL($input,($1)?1:0); -} - -%typemap(out) float, - double -{ - ZVAL_DOUBLE(return_value,$1); -} - -%typemap(out) const float &, - const double & -{ - ZVAL_DOUBLE(return_value,*$1); -} - -%typemap(directorin) float, - double -{ - ZVAL_DOUBLE($input,$1); -} - -%typemap(out) char -{ - ZVAL_STRINGL(return_value,&$1, 1, 1); -} - -%typemap(out) const char & -{ - ZVAL_STRINGL(return_value,&*$1, 1, 1); -} - -%typemap(out) char *, - char [] -{ - if(!$1) { - ZVAL_NULL(return_value); - } else { - ZVAL_STRING(return_value, (char *)$1, 1); - } -} - -%typemap(out) char *& -{ - if(!*$1) { - ZVAL_NULL(return_value); - } else { - ZVAL_STRING(return_value, (char *)*$1, 1); - } -} - -%typemap(out) SWIGTYPE *, - SWIGTYPE [], - SWIGTYPE &, - SWIGTYPE && -%{ - SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); -%} - -%typemap(out) SWIGTYPE *const& -%{ - SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); -%} - -%typemap(directorin) SWIGTYPE *, - SWIGTYPE [], - SWIGTYPE &, - SWIGTYPE && -%{ - SWIG_SetPointerZval($input, (void *)&$1, $1_descriptor, ($owner)|2); -%} - -%typemap(out, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) -{ - void * p = emalloc(sizeof($1)); - memcpy(p, &$1, sizeof($1)); - ZEND_REGISTER_RESOURCE(return_value, p, swig_member_ptr); -} - -%typemap(in, fragment="swig_php_init_member_ptr") SWIGTYPE (CLASS::*) -{ - void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, swig_member_ptr); - memcpy(&$1, p, sizeof($1)); -} - -%typemap(out) SWIGTYPE *DYNAMIC, - SWIGTYPE &DYNAMIC -{ - swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); - SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); -} - -%typemap(out) SWIGTYPE -#ifdef __cplusplus -{ - $&1_ltype resultobj = new $1_ltype((const $1_ltype &) $1); - SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); -} -#else -{ - $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); - memcpy(resultobj, &$1, sizeof($1_type)); - SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); -} -#endif - -%typemap(directorin) SWIGTYPE -{ - SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype((const $1_ltype &)$1)), $&1_descriptor, 1|2); -} - -%typemap(out) void ""; - -%typemap(out) char [ANY] -{ - int len = 0; - while (len < $1_dim0 && $1[len]) ++len; - RETVAL_STRINGL($1, len, 1); -} - -// This typecheck does hard checking for proper argument type. If you want -// an argument to be converted from a different PHP type, you must convert -// it yourself before passing it (e.g. (string)4.7 or (int)"6"). -%define %php_typecheck(_type,_prec,is) -%typemap(typecheck,precedence=_prec) _type, const _type & - " $1 = (Z_TYPE_PP($input) == is); " -%enddef - -%php_typecheck(int,SWIG_TYPECHECK_INTEGER,IS_LONG) -%php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG) -%php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG) -%php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG) -%php_typecheck(long,SWIG_TYPECHECK_INT32,IS_LONG) -%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT32,IS_LONG) -%php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG) -%php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG) -%php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG) -%php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG) -%php_typecheck(size_t,SWIG_TYPECHECK_SIZE,IS_LONG) -%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INTEGER,IS_LONG) -%php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL) -%php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE) -%php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE) -%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) - -%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char [] - " $1 = (Z_TYPE_PP($input) == IS_STRING); " - -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE -{ - void *tmp; - _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); -} - -%typecheck(SWIG_TYPECHECK_POINTER) - SWIGTYPE *, - SWIGTYPE [], - SWIGTYPE &, - SWIGTYPE &&, - SWIGTYPE *const& -{ - void *tmp; - _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); -} - -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& -{ - void *tmp; - _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); -} - -/* Exception handling */ - -%typemap(throws) int, - long, - short, - unsigned int, - unsigned long, - unsigned short { - zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), $1 TSRMLS_CC); - return; -} - -%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ - (void)$1; - zend_throw_exception(NULL, const_cast("C++ $1_type exception thrown"), 0 TSRMLS_CC); - return; -%} - -%typemap(throws) char * %{ - zend_throw_exception(NULL, const_cast($1), 0 TSRMLS_CC); - return; -%} - -/* Array reference typemaps */ -%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } -%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } - -/* const pointers */ -%apply SWIGTYPE * { SWIGTYPE *const } -%apply SWIGTYPE (CLASS::*) { SWIGTYPE (CLASS::*const) } -%apply SWIGTYPE & { SWIGTYPE (CLASS::*const&) } - -/* php keywords */ -%include diff --git a/Lib/php5/phpinit.swg b/Lib/php5/phpinit.swg deleted file mode 100644 index d8a61b02b..000000000 --- a/Lib/php5/phpinit.swg +++ /dev/null @@ -1,25 +0,0 @@ - -/* ------------------------------------------------------------ - * The start of the PHP initialization function - * ------------------------------------------------------------ */ - -%insert(init) "swiginit.swg" - -%init %{ -SWIG_php_minit { - SWIG_InitializeModule(0); -%} - -%fragment("swig_php_init_member_ptr2", "header") { -#define SWIG_MEMBER_PTR ((char*)"CLASS::*") - -static void swig_member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { - efree(rsrc->ptr); -} - -static int swig_member_ptr = 0; -} - -%fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") { - swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); -} diff --git a/Lib/php5/phpkw.swg b/Lib/php5/phpkw.swg deleted file mode 100644 index 36e535f52..000000000 --- a/Lib/php5/phpkw.swg +++ /dev/null @@ -1,866 +0,0 @@ -/* ----------------------------------------------------------------------------- - * phpkw.swg - * ----------------------------------------------------------------------------- */ - -/* Keyword (case insensitive) */ -#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x` - -/* Class (case insensitive) */ -#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, renaming to 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x` - -/* Constant (case insensitive) */ -#define PHPBN1a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem,sourcefmt="%(lower)s") `x` -#define PHPBN1b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant,sourcefmt="%(lower)s") `x` -%define PHPBN1(X) - PHPBN1a(X); PHPBN1b(X) -%enddef - -/* Constant (case sensitive) */ -#define PHPBN2a(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "enum conflicts with a built-in constant '"`x`"' in PHP"),%$isenumitem) `x` -#define PHPBN2b(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "constant conflicts with a built-in constant '"`x`"' in PHP"),%$isconstant) `x` -%define PHPBN2(X) - PHPBN2a(X); PHPBN2b(X) -%enddef - -#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renaming to 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` - -/* From: http://php.net/manual/en/reserved.keywords.php - * "You cannot use any of the following words as constants, class names, - * function or method names. Using them as variable names is generally OK, but - * could lead to confusion." - */ -/* Check is case insensitive - these *MUST* be listed in lower case here */ -PHPKW(__halt_compiler); -PHPKW(abstract); -PHPKW(and); -PHPKW(array); -PHPKW(as); -PHPKW(break); -PHPKW(callable); // As of PHP 5.4 -PHPKW(case); -PHPKW(catch); -PHPKW(class); -PHPKW(clone); -PHPKW(const); -PHPKW(continue); -PHPKW(declare); -PHPKW(default); -PHPKW(die); // "Language construct" -PHPKW(do); -PHPKW(echo); // "Language construct" -PHPKW(else); -PHPKW(elseif); -PHPKW(empty); // "Language construct" -PHPKW(enddeclare); -PHPKW(endfor); -PHPKW(endforeach); -PHPKW(endif); -PHPKW(endswitch); -PHPKW(endwhile); -PHPKW(eval); // "Language construct" -PHPKW(exit); // "Language construct" -PHPKW(extends); -PHPKW(final); -PHPKW(finally); // As of PHP 5.5 -PHPKW(for); -PHPKW(foreach); -PHPKW(function); -PHPKW(global); -PHPKW(goto); // As of PHP 5.3 -PHPKW(if); -PHPKW(implements); -PHPKW(include); // "Language construct" -PHPKW(include_once); // "Language construct" -PHPKW(instanceof); -PHPKW(insteadof); // As of PHP 5.4 -PHPKW(interface); -PHPKW(isset); // "Language construct" -PHPKW(list); // "Language construct" -PHPKW(namespace); // As of PHP 5.3 -PHPKW(new); -PHPKW(or); -PHPKW(print); // "Language construct" -PHPKW(private); -PHPKW(protected); -PHPKW(public); -PHPKW(require); // "Language construct" -PHPKW(require_once); // "Language construct" -PHPKW(return); // "Language construct" -PHPKW(static); -PHPKW(switch); -PHPKW(throw); -PHPKW(trait); // As of PHP 5.4 -PHPKW(try); -PHPKW(unset); // "Language construct" -PHPKW(use); -PHPKW(var); -PHPKW(while); -PHPKW(xor); -PHPKW(yield); // As of PHP 5.5 - -// Compile-time "magic" constants -// From: http://php.net/manual/en/reserved.keywords.php -// also at: http://php.net/manual/en/language.constants.predefined.php -/* These *MUST* be listed in lower case here */ -PHPKW(__class__); -PHPKW(__dir__); // As of PHP 5.3 -PHPKW(__file__); -PHPKW(__function__); -PHPKW(__line__); -PHPKW(__method__); -PHPKW(__namespace__); // As of PHP 5.3 -PHPKW(__trait__); // As of PHP 5.4 - -/* We classify these as built-in names since they conflict, but PHP still runs */ - -/* Predefined case-insensitive constants */ -/* These *MUST* be listed in lower case here */ -PHPBN1(null); -PHPBN1(true); -PHPBN1(false); - -/* "Core Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ -/* These are case sensitive */ -PHPBN2(PHP_VERSION); -PHPBN2(PHP_MAJOR_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_MINOR_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_RELEASE_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_VERSION_ID); // As of PHP 5.2.7 -PHPBN2(PHP_EXTRA_VERSION); // As of PHP 5.2.7 -PHPBN2(PHP_ZTS); // As of PHP 5.2.7 -PHPBN2(PHP_DEBUG); // As of PHP 5.2.7 -PHPBN2(PHP_MAXPATHLEN); // As of PHP 5.3.0 -PHPBN2(PHP_OS); -PHPBN2(PHP_SAPI); -PHPBN2(PHP_EOL); // As of PHP 5.0.2 -PHPBN2(PHP_INT_MAX); // As of PHP 5.0.5 -PHPBN2(PHP_INT_SIZE); // As of PHP 5.0.5 -PHPBN2(DEFAULT_INCLUDE_PATH); -PHPBN2(PEAR_INSTALL_DIR); -PHPBN2(PEAR_EXTENSION_DIR); -PHPBN2(PHP_EXTENSION_DIR); -PHPBN2(PHP_PREFIX); -PHPBN2(PHP_BINDIR); -PHPBN2(PHP_BINARY); // As of PHP 5.4 -PHPBN2(PHP_MANDIR); // As of PHP 5.3.7 -PHPBN2(PHP_LIBDIR); -PHPBN2(PHP_DATADIR); -PHPBN2(PHP_SYSCONFDIR); -PHPBN2(PHP_LOCALSTATEDIR); -PHPBN2(PHP_CONFIG_FILE_PATH); -PHPBN2(PHP_CONFIG_FILE_SCAN_DIR); -PHPBN2(PHP_SHLIB_SUFFIX); -PHPBN2(E_ERROR); -PHPBN2(E_WARNING); -PHPBN2(E_PARSE); -PHPBN2(E_NOTICE); -PHPBN2(E_CORE_ERROR); -PHPBN2(E_CORE_WARNING); -PHPBN2(E_COMPILE_ERROR); -PHPBN2(E_COMPILE_WARNING); -PHPBN2(E_USER_ERROR); -PHPBN2(E_USER_WARNING); -PHPBN2(E_USER_NOTICE); -PHPBN2(E_DEPRECATED); // As of PHP 5.3.0 -PHPBN2(E_USER_DEPRECATED); // As of PHP 5.3.0 -PHPBN2(E_ALL); -PHPBN2(E_STRICT); -PHPBN2(__COMPILER_HALT_OFFSET__); // As of PHP 5.1.0 -// TRUE, FALSE, NULL are listed on the same page, but are actually -// case-insensitive, whereas all the other constants listed there seem to be -// case-sensitive, so we handle TRUE, FALSE, NULL in PHPBN1. -PHPBN2(PHP_OUTPUT_HANDLER_START); -PHPBN2(PHP_OUTPUT_HANDLER_CONT); -PHPBN2(PHP_OUTPUT_HANDLER_END); -/* These don't actually seem to be set (tested on Linux, I guess they're - * Windows only?) */ -PHPBN2(PHP_WINDOWS_NT_DOMAIN_CONTROLLER); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_NT_SERVER); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_NT_WORKSTATION); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_BUILD); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_MAJOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_MINOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_PLATFORM); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_PRODUCTTYPE); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SP_MAJOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SP_MINOR); // As of PHP 5.3 -PHPBN2(PHP_WINDOWS_VERSION_SUITEMASK); // As of PHP 5.3 -/* "Standard Predefined Constants" from http://php.net/manual/en/reserved.constants.php */ -PHPBN2(EXTR_OVERWRITE); -PHPBN2(EXTR_SKIP); -PHPBN2(EXTR_PREFIX_SAME); -PHPBN2(EXTR_PREFIX_ALL); -PHPBN2(EXTR_PREFIX_INVALID); -PHPBN2(EXTR_PREFIX_IF_EXISTS); -PHPBN2(EXTR_IF_EXISTS); -PHPBN2(SORT_ASC); -PHPBN2(SORT_DESC); -PHPBN2(SORT_REGULAR); -PHPBN2(SORT_NUMERIC); -PHPBN2(SORT_STRING); -PHPBN2(CASE_LOWER); -PHPBN2(CASE_UPPER); -PHPBN2(COUNT_NORMAL); -PHPBN2(COUNT_RECURSIVE); -PHPBN2(ASSERT_ACTIVE); -PHPBN2(ASSERT_CALLBACK); -PHPBN2(ASSERT_BAIL); -PHPBN2(ASSERT_WARNING); -PHPBN2(ASSERT_QUIET_EVAL); -PHPBN2(CONNECTION_ABORTED); -PHPBN2(CONNECTION_NORMAL); -PHPBN2(CONNECTION_TIMEOUT); -PHPBN2(INI_USER); -PHPBN2(INI_PERDIR); -PHPBN2(INI_SYSTEM); -PHPBN2(INI_ALL); -PHPBN2(INI_SCANNER_NORMAL); // As of PHP 5.3 -PHPBN2(INI_SCANNER_RAW); // As of PHP 5.3 -PHPBN2(M_E); -PHPBN2(M_LOG2E); -PHPBN2(M_LOG10E); -PHPBN2(M_LN2); -PHPBN2(M_LN10); -PHPBN2(M_PI); -PHPBN2(M_PI_2); -PHPBN2(M_PI_4); -PHPBN2(M_1_PI); -PHPBN2(M_2_PI); -PHPBN2(M_2_SQRTPI); -PHPBN2(M_SQRT2); -PHPBN2(M_SQRT1_2); -PHPBN2(M_EULER); // As of PHP 5.2 -PHPBN2(M_LNPI); // As of PHP 5.2 -PHPBN2(M_SQRT3); // As of PHP 5.2 -PHPBN2(M_SQRTPI); // As of PHP 5.2 -PHPBN2(CRYPT_SALT_LENGTH); -PHPBN2(CRYPT_STD_DES); -PHPBN2(CRYPT_EXT_DES); -PHPBN2(CRYPT_MD5); -PHPBN2(CRYPT_BLOWFISH); -PHPBN2(DIRECTORY_SEPARATOR); -PHPBN2(SEEK_SET); -PHPBN2(SEEK_CUR); -PHPBN2(SEEK_END); -PHPBN2(LOCK_SH); -PHPBN2(LOCK_EX); -PHPBN2(LOCK_UN); -PHPBN2(LOCK_NB); -PHPBN2(HTML_SPECIALCHARS); -PHPBN2(HTML_ENTITIES); -PHPBN2(ENT_COMPAT); -PHPBN2(ENT_QUOTES); -PHPBN2(ENT_NOQUOTES); -PHPBN2(INFO_GENERAL); -PHPBN2(INFO_CREDITS); -PHPBN2(INFO_CONFIGURATION); -PHPBN2(INFO_MODULES); -PHPBN2(INFO_ENVIRONMENT); -PHPBN2(INFO_VARIABLES); -PHPBN2(INFO_LICENSE); -PHPBN2(INFO_ALL); -PHPBN2(CREDITS_GROUP); -PHPBN2(CREDITS_GENERAL); -PHPBN2(CREDITS_SAPI); -PHPBN2(CREDITS_MODULES); -PHPBN2(CREDITS_DOCS); -PHPBN2(CREDITS_FULLPAGE); -PHPBN2(CREDITS_QA); -PHPBN2(CREDITS_ALL); -PHPBN2(STR_PAD_LEFT); -PHPBN2(STR_PAD_RIGHT); -PHPBN2(STR_PAD_BOTH); -PHPBN2(PATHINFO_DIRNAME); -PHPBN2(PATHINFO_BASENAME); -PHPBN2(PATHINFO_EXTENSION); -PHPBN2(PATHINFO_FILENAME); // As of PHP 5.2 -PHPBN2(PATH_SEPARATOR); -PHPBN2(CHAR_MAX); -PHPBN2(LC_CTYPE); -PHPBN2(LC_NUMERIC); -PHPBN2(LC_TIME); -PHPBN2(LC_COLLATE); -PHPBN2(LC_MONETARY); -PHPBN2(LC_ALL); -PHPBN2(LC_MESSAGES); -PHPBN2(ABDAY_1); -PHPBN2(ABDAY_2); -PHPBN2(ABDAY_3); -PHPBN2(ABDAY_4); -PHPBN2(ABDAY_5); -PHPBN2(ABDAY_6); -PHPBN2(ABDAY_7); -PHPBN2(DAY_1); -PHPBN2(DAY_2); -PHPBN2(DAY_3); -PHPBN2(DAY_4); -PHPBN2(DAY_5); -PHPBN2(DAY_6); -PHPBN2(DAY_7); -PHPBN2(ABMON_1); -PHPBN2(ABMON_2); -PHPBN2(ABMON_3); -PHPBN2(ABMON_4); -PHPBN2(ABMON_5); -PHPBN2(ABMON_6); -PHPBN2(ABMON_7); -PHPBN2(ABMON_8); -PHPBN2(ABMON_9); -PHPBN2(ABMON_10); -PHPBN2(ABMON_11); -PHPBN2(ABMON_12); -PHPBN2(MON_1); -PHPBN2(MON_2); -PHPBN2(MON_3); -PHPBN2(MON_4); -PHPBN2(MON_5); -PHPBN2(MON_6); -PHPBN2(MON_7); -PHPBN2(MON_8); -PHPBN2(MON_9); -PHPBN2(MON_10); -PHPBN2(MON_11); -PHPBN2(MON_12); -PHPBN2(AM_STR); -PHPBN2(PM_STR); -PHPBN2(D_T_FMT); -PHPBN2(D_FMT); -PHPBN2(T_FMT); -PHPBN2(T_FMT_AMPM); -PHPBN2(ERA); -PHPBN2(ERA_YEAR); -PHPBN2(ERA_D_T_FMT); -PHPBN2(ERA_D_FMT); -PHPBN2(ERA_T_FMT); -PHPBN2(ALT_DIGITS); -PHPBN2(INT_CURR_SYMBOL); -PHPBN2(CURRENCY_SYMBOL); -PHPBN2(CRNCYSTR); -PHPBN2(MON_DECIMAL_POINT); -PHPBN2(MON_THOUSANDS_SEP); -PHPBN2(MON_GROUPING); -PHPBN2(POSITIVE_SIGN); -PHPBN2(NEGATIVE_SIGN); -PHPBN2(INT_FRAC_DIGITS); -PHPBN2(FRAC_DIGITS); -PHPBN2(P_CS_PRECEDES); -PHPBN2(P_SEP_BY_SPACE); -PHPBN2(N_CS_PRECEDES); -PHPBN2(N_SEP_BY_SPACE); -PHPBN2(P_SIGN_POSN); -PHPBN2(N_SIGN_POSN); -PHPBN2(DECIMAL_POINT); -PHPBN2(RADIXCHAR); -PHPBN2(THOUSANDS_SEP); -PHPBN2(THOUSEP); -PHPBN2(GROUPING); -PHPBN2(YESEXPR); -PHPBN2(NOEXPR); -PHPBN2(YESSTR); -PHPBN2(NOSTR); -PHPBN2(CODESET); -PHPBN2(LOG_EMERG); -PHPBN2(LOG_ALERT); -PHPBN2(LOG_CRIT); -PHPBN2(LOG_ERR); -PHPBN2(LOG_WARNING); -PHPBN2(LOG_NOTICE); -PHPBN2(LOG_INFO); -PHPBN2(LOG_DEBUG); -PHPBN2(LOG_KERN); -PHPBN2(LOG_USER); -PHPBN2(LOG_MAIL); -PHPBN2(LOG_DAEMON); -PHPBN2(LOG_AUTH); -PHPBN2(LOG_SYSLOG); -PHPBN2(LOG_LPR); -PHPBN2(LOG_NEWS); -PHPBN2(LOG_UUCP); -PHPBN2(LOG_CRON); -PHPBN2(LOG_AUTHPRIV); -PHPBN2(LOG_LOCAL0); -PHPBN2(LOG_LOCAL1); -PHPBN2(LOG_LOCAL2); -PHPBN2(LOG_LOCAL3); -PHPBN2(LOG_LOCAL4); -PHPBN2(LOG_LOCAL5); -PHPBN2(LOG_LOCAL6); -PHPBN2(LOG_LOCAL7); -PHPBN2(LOG_PID); -PHPBN2(LOG_CONS); -PHPBN2(LOG_ODELAY); -PHPBN2(LOG_NDELAY); -PHPBN2(LOG_NOWAIT); -PHPBN2(LOG_PERROR); - -/* Added in PHP 5.2 */ -PHPBN2(PREG_BACKTRACK_LIMIT_ERROR); -PHPBN2(PREG_BAD_UTF8_ERROR); -PHPBN2(PREG_INTERNAL_ERROR); -PHPBN2(PREG_NO_ERROR); -PHPBN2(PREG_RECURSION_LIMIT_ERROR); -PHPBN2(UPLOAD_ERR_EXTENSION); -PHPBN2(STREAM_SHUT_RD); -PHPBN2(STREAM_SHUT_WR); -PHPBN2(STREAM_SHUT_RDWR); -PHPBN2(CURLE_FILESIZE_EXCEEDED); -PHPBN2(CURLE_FTP_SSL_FAILED); -PHPBN2(CURLE_LDAP_INVALID_URL); -PHPBN2(CURLFTPAUTH_DEFAULT); -PHPBN2(CURLFTPAUTH_SSL); -PHPBN2(CURLFTPAUTH_TLS); -PHPBN2(CURLFTPSSL_ALL); -PHPBN2(CURLFTPSSL_CONTROL); -PHPBN2(CURLFTPSSL_NONE); -PHPBN2(CURLFTPSSL_TRY); -PHPBN2(CURLOPT_FTP_SSL); -PHPBN2(CURLOPT_FTPSSLAUTH); -PHPBN2(CURLOPT_TCP_NODELAY); // Added in PHP 5.2.1 -PHPBN2(CURLOPT_TIMEOUT_MS); // Added in PHP 5.2.3 -PHPBN2(CURLOPT_CONNECTTIMEOUT_MS); // Added in PHP 5.2.3 -PHPBN2(GMP_VERSION); // Added in PHP 5.2.2 -PHPBN2(SWFTEXTFIELD_USEFONT); -PHPBN2(SWFTEXTFIELD_AUTOSIZE); -PHPBN2(SWF_SOUND_NOT_COMPRESSED); -PHPBN2(SWF_SOUND_ADPCM_COMPRESSED); -PHPBN2(SWF_SOUND_MP3_COMPRESSED); -PHPBN2(SWF_SOUND_NOT_COMPRESSED_LE); -PHPBN2(SWF_SOUND_NELLY_COMPRESSED); -PHPBN2(SWF_SOUND_5KHZ); -PHPBN2(SWF_SOUND_11KHZ); -PHPBN2(SWF_SOUND_22KHZ); -PHPBN2(SWF_SOUND_44KHZ); -PHPBN2(SWF_SOUND_8BITS); -PHPBN2(SWF_SOUND_16BITS); -PHPBN2(SWF_SOUND_MONO); -PHPBN2(SWF_SOUND_STEREO); -PHPBN2(OPENSSL_VERSION_NUMBER); -PHPBN2(SNMP_OID_OUTPUT_FULL); -PHPBN2(SNMP_OID_OUTPUT_NUMERIC); -PHPBN2(MSG_EAGAIN); -PHPBN2(MSG_ENOMSG); - -/* Added in PHP 5.3 */ -PHPBN2(CURLOPT_PROGRESSFUNCTION); -PHPBN2(IMG_FILTER_PIXELATE); -PHPBN2(JSON_ERROR_CTRL_CHAR); -PHPBN2(JSON_ERROR_DEPTH); -PHPBN2(JSON_ERROR_NONE); -PHPBN2(JSON_ERROR_STATE_MISMATCH); -PHPBN2(JSON_ERROR_SYNTAX); -PHPBN2(JSON_FORCE_OBJECT); -PHPBN2(JSON_HEX_TAG); -PHPBN2(JSON_HEX_AMP); -PHPBN2(JSON_HEX_APOS); -PHPBN2(JSON_HEX_QUOT); -PHPBN2(LDAP_OPT_NETWORK_TIMEOUT); -PHPBN2(LIBXML_LOADED_VERSION); -PHPBN2(PREG_BAD_UTF8_OFFSET_ERROR); -PHPBN2(BUS_ADRALN); -PHPBN2(BUS_ADRERR); -PHPBN2(BUS_OBJERR); -PHPBN2(CLD_CONTIUNED); -PHPBN2(CLD_DUMPED); -PHPBN2(CLD_EXITED); -PHPBN2(CLD_KILLED); -PHPBN2(CLD_STOPPED); -PHPBN2(CLD_TRAPPED); -PHPBN2(FPE_FLTDIV); -PHPBN2(FPE_FLTINV); -PHPBN2(FPE_FLTOVF); -PHPBN2(FPE_FLTRES); -PHPBN2(FPE_FLTSUB); -PHPBN2(FPE_FLTUND); -PHPBN2(FPE_INTDIV); -PHPBN2(FPE_INTOVF); -PHPBN2(ILL_BADSTK); -PHPBN2(ILL_COPROC); -PHPBN2(ILL_ILLADR); -PHPBN2(ILL_ILLOPC); -PHPBN2(ILL_ILLOPN); -PHPBN2(ILL_ILLTRP); -PHPBN2(ILL_PRVOPC); -PHPBN2(ILL_PRVREG); -PHPBN2(POLL_ERR); -PHPBN2(POLL_HUP); -PHPBN2(POLL_IN); -PHPBN2(POLL_MSG); -PHPBN2(POLL_OUT); -PHPBN2(POLL_PRI); -PHPBN2(SEGV_ACCERR); -PHPBN2(SEGV_MAPERR); -PHPBN2(SI_ASYNCIO); -PHPBN2(SI_KERNEL); -PHPBN2(SI_MESGQ); -PHPBN2(SI_NOINFO); -PHPBN2(SI_QUEUE); -PHPBN2(SI_SIGIO); -PHPBN2(SI_TIMER); -PHPBN2(SI_TKILL); -PHPBN2(SI_USER); -PHPBN2(SIG_BLOCK); -PHPBN2(SIG_SETMASK); -PHPBN2(SIG_UNBLOCK); -PHPBN2(TRAP_BRKPT); -PHPBN2(TRAP_TRACE); - -/* Added in PHP 5.4 */ -PHPBN2(ENT_DISALLOWED); -PHPBN2(ENT_HTML401); -PHPBN2(ENT_HTML5); -PHPBN2(ENT_SUBSTITUTE); -PHPBN2(ENT_XML1); -PHPBN2(ENT_XHTML); -PHPBN2(IPPROTO_IP); -PHPBN2(IPPROTO_IPV6); -PHPBN2(IPV6_MULTICAST_HOPS); -PHPBN2(IPV6_MULTICAST_IF); -PHPBN2(IPV6_MULTICAST_LOOP); -PHPBN2(IP_MULTICAST_IF); -PHPBN2(IP_MULTICAST_LOOP); -PHPBN2(IP_MULTICAST_TTL); -PHPBN2(MCAST_JOIN_GROUP); -PHPBN2(MCAST_LEAVE_GROUP); -PHPBN2(MCAST_BLOCK_SOURCE); -PHPBN2(MCAST_UNBLOCK_SOURCE); -PHPBN2(MCAST_JOIN_SOURCE_GROUP); -PHPBN2(MCAST_LEAVE_SOURCE_GROUP); -PHPBN2(CURLOPT_MAX_RECV_SPEED_LARGE); -PHPBN2(CURLOPT_MAX_SEND_SPEED_LARGE); -PHPBN2(LIBXML_HTML_NODEFDTD); -PHPBN2(LIBXML_HTML_NOIMPLIED); -PHPBN2(LIBXML_PEDANTIC); -PHPBN2(OPENSSL_CIPHER_AES_128_CBC); -PHPBN2(OPENSSL_CIPHER_AES_192_CBC); -PHPBN2(OPENSSL_CIPHER_AES_256_CBC); -PHPBN2(OPENSSL_RAW_DATA); -PHPBN2(OPENSSL_ZERO_PADDING); -PHPBN2(PHP_OUTPUT_HANDLER_CLEAN); -PHPBN2(PHP_OUTPUT_HANDLER_CLEANABLE); -PHPBN2(PHP_OUTPUT_HANDLER_DISABLED); -PHPBN2(PHP_OUTPUT_HANDLER_FINAL); -PHPBN2(PHP_OUTPUT_HANDLER_FLUSH); -PHPBN2(PHP_OUTPUT_HANDLER_FLUSHABLE); -PHPBN2(PHP_OUTPUT_HANDLER_REMOVABLE); -PHPBN2(PHP_OUTPUT_HANDLER_STARTED); -PHPBN2(PHP_OUTPUT_HANDLER_STDFLAGS); -PHPBN2(PHP_OUTPUT_HANDLER_WRITE); -PHPBN2(PHP_SESSION_ACTIVE); -PHPBN2(PHP_SESSION_DISABLED); -PHPBN2(PHP_SESSION_NONE); -PHPBN2(STREAM_META_ACCESS); -PHPBN2(STREAM_META_GROUP); -PHPBN2(STREAM_META_GROUP_NAME); -PHPBN2(STREAM_META_OWNER); -PHPBN2(STREAM_META_OWNER_NAME); -PHPBN2(STREAM_META_TOUCH); -PHPBN2(ZLIB_ENCODING_DEFLATE); -PHPBN2(ZLIB_ENCODING_GZIP); -PHPBN2(ZLIB_ENCODING_RAW); -PHPBN2(U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR); -PHPBN2(IDNA_CHECK_BIDI); -PHPBN2(IDNA_CHECK_CONTEXTJ); -PHPBN2(IDNA_NONTRANSITIONAL_TO_ASCII); -PHPBN2(IDNA_NONTRANSITIONAL_TO_UNICODE); -PHPBN2(INTL_IDNA_VARIANT_2003); -PHPBN2(INTL_IDNA_VARIANT_UTS46); -PHPBN2(IDNA_ERROR_EMPTY_LABEL); -PHPBN2(IDNA_ERROR_LABEL_TOO_LONG); -PHPBN2(IDNA_ERROR_DOMAIN_NAME_TOO_LONG); -PHPBN2(IDNA_ERROR_LEADING_HYPHEN); -PHPBN2(IDNA_ERROR_TRAILING_HYPHEN); -PHPBN2(IDNA_ERROR_HYPHEN_3_4); -PHPBN2(IDNA_ERROR_LEADING_COMBINING_MARK); -PHPBN2(IDNA_ERROR_DISALLOWED); -PHPBN2(IDNA_ERROR_PUNYCODE); -PHPBN2(IDNA_ERROR_LABEL_HAS_DOT); -PHPBN2(IDNA_ERROR_INVALID_ACE_LABEL); -PHPBN2(IDNA_ERROR_BIDI); -PHPBN2(IDNA_ERROR_CONTEXTJ); -PHPBN2(JSON_PRETTY_PRINT); -PHPBN2(JSON_UNESCAPED_SLASHES); -PHPBN2(JSON_NUMERIC_CHECK); -PHPBN2(JSON_UNESCAPED_UNICODE); -PHPBN2(JSON_BIGINT_AS_STRING); - -/* Added in PHP 5.5 */ -PHPBN2(IMG_AFFINE_TRANSLATE); -PHPBN2(IMG_AFFINE_SCALE); -PHPBN2(IMG_AFFINE_ROTATE); -PHPBN2(IMG_AFFINE_SHEAR_HORIZONTAL); -PHPBN2(IMG_AFFINE_SHEAR_VERTICAL); -PHPBN2(IMG_CROP_DEFAULT); -PHPBN2(IMG_CROP_TRANSPARENT); -PHPBN2(IMG_CROP_BLACK); -PHPBN2(IMG_CROP_WHITE); -PHPBN2(IMG_CROP_SIDES); -PHPBN2(IMG_FLIP_BOTH); -PHPBN2(IMG_FLIP_HORIZONTAL); -PHPBN2(IMG_FLIP_VERTICAL); -PHPBN2(IMG_BELL); -PHPBN2(IMG_BESSEL); -PHPBN2(IMG_BICUBIC); -PHPBN2(IMG_BICUBIC_FIXED); -PHPBN2(IMG_BLACKMAN); -PHPBN2(IMG_BOX); -PHPBN2(IMG_BSPLINE); -PHPBN2(IMG_CATMULLROM); -PHPBN2(IMG_GAUSSIAN); -PHPBN2(IMG_GENERALIZED_CUBIC); -PHPBN2(IMG_HERMITE); -PHPBN2(IMG_HAMMING); -PHPBN2(IMG_HANNING); -PHPBN2(IMG_MITCHELL); -PHPBN2(IMG_POWER); -PHPBN2(IMG_QUADRATIC); -PHPBN2(IMG_SINC); -PHPBN2(IMG_NEAREST_NEIGHBOUR); -PHPBN2(IMG_WEIGHTED4); -PHPBN2(IMG_TRIANGLE); -PHPBN2(JSON_ERROR_RECURSION); -PHPBN2(JSON_ERROR_INF_OR_NAN); -PHPBN2(JSON_ERROR_UNSUPPORTED_TYPE); -PHPBN2(MYSQLI_SERVER_PUBLIC_KEY); - -/* Added in PHP 5.6 */ -PHPBN2(LDAP_ESCAPE_DN); -PHPBN2(LDAP_ESCAPE_FILTER); -PHPBN2(OPENSSL_DEFAULT_STREAM_CIPHERS); -PHPBN2(STREAM_CRYPTO_METHOD_ANY_CLIENT); -PHPBN2(STREAM_CRYPTO_METHOD_ANY_SERVER); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_0_SERVER); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_1_SERVER); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT); -PHPBN2(STREAM_CRYPTO_METHOD_TLSv1_2_SERVER); -PHPBN2(PGSQL_CONNECT_ASYNC); -PHPBN2(PGSQL_CONNECTION_AUTH_OK); -PHPBN2(PGSQL_CONNECTION_AWAITING_RESPONSE); -PHPBN2(PGSQL_CONNECTION_MADE); -PHPBN2(PGSQL_CONNECTION_SETENV); -PHPBN2(PGSQL_CONNECTION_SSL_STARTUP); -PHPBN2(PGSQL_CONNECTION_STARTED); -PHPBN2(PGSQL_DML_ESCAPE); -PHPBN2(PGSQL_POLLING_ACTIVE); -PHPBN2(PGSQL_POLLING_FAILED); -PHPBN2(PGSQL_POLLING_OK); -PHPBN2(PGSQL_POLLING_READING); -PHPBN2(PGSQL_POLLING_WRITING); - -/* Class names reserved by PHP (case insensitive) */ -PHPCN(directory); -PHPCN(stdclass); -PHPCN(__php_incomplete_class); -/* Added in PHP5. */ -PHPCN(exception); -PHPCN(errorexception); // As of PHP 5.1 -PHPCN(php_user_filter); -PHPCN(closure); // As of PHP 5.3 -PHPCN(generator); // As of PHP 5.5 -PHPCN(self); -PHPCN(static); -PHPCN(parent); -/* From extensions (which of these are actually predefined depends which - * extensions are loaded by default). */ -PHPCN(xmlwriter); -PHPCN(libxmlerror); -PHPCN(simplexmlelement); -PHPCN(soapclient); -PHPCN(soapvar); -PHPCN(soapserver); -PHPCN(soapfault); -PHPCN(soapparam); -PHPCN(soapheader); -PHPCN(recursiveiteratoriterator); -PHPCN(filteriterator); -PHPCN(recursivefilteriterator); -PHPCN(parentiterator); -PHPCN(limititerator); -PHPCN(cachingiterator); -PHPCN(recursivecachingiterator); -PHPCN(iteratoriterator); -PHPCN(norewinditerator); -PHPCN(appenditerator); -PHPCN(infiniteiterator); -PHPCN(emptyiterator); -PHPCN(arrayobject); -PHPCN(arrayiterator); -PHPCN(recursivearrayiterator); -PHPCN(splfileinfo); -PHPCN(directoryiterator); -PHPCN(recursivedirectoryiterator); -PHPCN(splfileobject); -PHPCN(spltempfileobject); -PHPCN(simplexmliterator); -PHPCN(logicexception); -PHPCN(badfunctioncallexception); -PHPCN(badmethodcallexception); -PHPCN(domainexception); -PHPCN(invalidargumentexception); -PHPCN(lengthexception); -PHPCN(outofrangeexception); -PHPCN(runtimeexception); -PHPCN(outofboundsexception); -PHPCN(overflowexception); -PHPCN(rangeexception); -PHPCN(underflowexception); -PHPCN(unexpectedvalueexception); -PHPCN(splobjectstorage); -PHPCN(reflectionexception); -PHPCN(reflection); -PHPCN(reflectionfunction); -PHPCN(reflectionparameter); -PHPCN(reflectionmethod); -PHPCN(reflectionclass); -PHPCN(reflectionobject); -PHPCN(reflectionproperty); -PHPCN(reflectionextension); -PHPCN(domexception); -PHPCN(domstringlist); -PHPCN(domnamelist); -PHPCN(domimplementationlist); -PHPCN(domimplementationsource); -PHPCN(domimplementation); -PHPCN(domnode); -PHPCN(domnamespacenode); -PHPCN(domdocumentfragment); -PHPCN(domdocument); -PHPCN(domnodelist); -PHPCN(domnamednodemap); -PHPCN(domcharacterdata); -PHPCN(domattr); -PHPCN(domelement); -PHPCN(domtext); -PHPCN(domcomment); -PHPCN(domtypeinfo); -PHPCN(domuserdatahandler); -PHPCN(domdomerror); -PHPCN(domerrorhandler); -PHPCN(domlocator); -PHPCN(domconfiguration); -PHPCN(domcdatasection); -PHPCN(domdocumenttype); -PHPCN(domnotation); -PHPCN(domentity); -PHPCN(domentityreference); -PHPCN(domprocessinginstruction); -PHPCN(domstringextend); -PHPCN(domxpath); -PHPCN(xmlreader); -PHPCN(sqlitedatabase); -PHPCN(sqliteresult); -PHPCN(sqliteunbuffered); -PHPCN(sqliteexception); -PHPCN(datetime); - -/* Built-in PHP functions (incomplete). */ -/* Includes Array Functions - http://php.net/manual/en/ref.array.php */ -/* Check is case insensitive - these *MUST* be listed in lower case here */ -PHPFN(acos); -PHPFN(array_change_key_case); -PHPFN(array_chunk); -PHPFN(array_column); -PHPFN(array_combine); -PHPFN(array_count_values); -PHPFN(array_diff); -PHPFN(array_diff_assoc); -PHPFN(array_diff_key); -PHPFN(array_diff_uassoc); -PHPFN(array_diff_ukey); -PHPFN(array_fill); -PHPFN(array_fill_keys); -PHPFN(array_filter); -PHPFN(array_flip); -PHPFN(array_intersect); -PHPFN(array_intersect_assoc); -PHPFN(array_intersect_key); -PHPFN(array_intersect_uassoc); -PHPFN(array_intersect_ukey); -PHPFN(array_key_exists); -PHPFN(array_keys); -PHPFN(array_map); -PHPFN(array_merge); -PHPFN(array_merge_recursive); -PHPFN(array_multisort); -PHPFN(array_pad); -PHPFN(array_pop); -PHPFN(array_product); -PHPFN(array_push); -PHPFN(array_rand); -PHPFN(array_reduce); -PHPFN(array_replace); -PHPFN(array_replace_recursive); -PHPFN(array_reverse); -PHPFN(array_search); -PHPFN(array_shift); -PHPFN(array_slice); -PHPFN(array_splice); -PHPFN(array_sum); -PHPFN(array_udiff); -PHPFN(array_udiff_assoc); -PHPFN(array_udiff_uassoc); -PHPFN(array_uintersect); -PHPFN(array_uintersect_assoc); -PHPFN(array_uintersect_uassoc); -PHPFN(array_unique); -PHPFN(array_unshift); -PHPFN(array_values); -PHPFN(array_walk); -PHPFN(array_walk_recursive); -PHPFN(arsort); -PHPFN(asin); -PHPFN(asort); -PHPFN(atan); -PHPFN(atan2); -PHPFN(ceil); -PHPFN(compact); -PHPFN(cos); -PHPFN(cosh); -PHPFN(count); -PHPFN(current); -PHPFN(each); -PHPFN(end); -PHPFN(exp); -PHPFN(extract); -PHPFN(floor); -PHPFN(fmod); -PHPFN(in_array); -PHPFN(key); -PHPFN(key_exists); -PHPFN(krsort); -PHPFN(ksort); -PHPFN(log); -PHPFN(log10); -PHPFN(max); -PHPFN(min); -PHPFN(natcasesort); -PHPFN(natsort); -PHPFN(next); -PHPFN(pos); -PHPFN(pow); -PHPFN(prev); -PHPFN(range); -PHPFN(reset); -PHPFN(rsort); -PHPFN(shuffle); -PHPFN(sin); -PHPFN(sinh); -PHPFN(sizeof); -PHPFN(sort); -PHPFN(sqrt); -PHPFN(tan); -PHPFN(tanh); -PHPFN(uasort); -PHPFN(uksort); -PHPFN(usort); - -#undef PHPKW -#undef PHPBN1a -#undef PHPBN1b -#undef PHPBN1 -#undef PHPBN2a -#undef PHPBN2b -#undef PHPBN2 -#undef PHPCN -#undef PHPFN diff --git a/Lib/php5/phppointers.i b/Lib/php5/phppointers.i deleted file mode 100644 index e50ada7ac..000000000 --- a/Lib/php5/phppointers.i +++ /dev/null @@ -1,42 +0,0 @@ -%define %pass_by_ref( TYPE, CONVERT_IN, CONVERT_OUT ) -%typemap(in, byref=1) TYPE *REF ($*1_ltype tmp), - TYPE &REF ($*1_ltype tmp) -%{ - /* First Check for SWIG wrapped type */ - if ( ZVAL_IS_NULL( *$input ) ) { - $1 = 0; - } else if ( PZVAL_IS_REF( *$input ) ) { - /* Not swig wrapped type, so we check if it's a PHP reference type */ - CONVERT_IN( tmp, $*1_ltype, $input ); - $1 = &tmp; - } else { - SWIG_PHP_Error( E_ERROR, SWIG_PHP_Arg_Error_Msg($argnum, Expected a reference) ); - } -%} -%typemap(argout) TYPE *REF, - TYPE &REF - "CONVERT_OUT(*$input, tmp$argnum );"; -%enddef - -%pass_by_ref( size_t, CONVERT_INT_IN, ZVAL_LONG ); - -%pass_by_ref( signed int, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( int, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( unsigned int, CONVERT_INT_IN, ZVAL_LONG ); - -%pass_by_ref( signed short, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( short, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( unsigned short, CONVERT_INT_IN, ZVAL_LONG ); - -%pass_by_ref( signed long, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( long, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( unsigned long, CONVERT_INT_IN, ZVAL_LONG ); - -%pass_by_ref( signed char, CONVERT_INT_IN, ZVAL_LONG ); -%pass_by_ref( char, CONVERT_CHAR_IN, ZVAL_STRING ); -%pass_by_ref( unsigned char, CONVERT_INT_IN, ZVAL_LONG ); - -%pass_by_ref( float, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); -%pass_by_ref( double, CONVERT_FLOAT_IN, ZVAL_DOUBLE ); - -%pass_by_ref( char *, CONVERT_CHAR_IN, ZVAL_STRING ); diff --git a/Lib/php5/phprun.swg b/Lib/php5/phprun.swg deleted file mode 100644 index a18e1fcbb..000000000 --- a/Lib/php5/phprun.swg +++ /dev/null @@ -1,280 +0,0 @@ -/* ----------------------------------------------------------------------------- - * phprun.swg - * - * PHP runtime library - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#endif -#include "zend.h" -#include "zend_API.h" -#include "zend_exceptions.h" -#include "php.h" - -#if PHP_MAJOR_VERSION != 5 -# error These bindings need PHP5 - to generate PHP7 bindings use: swig -php7 -#endif - -#include "ext/standard/php_string.h" -#include /* for abort(), used in generated code. */ - -#ifdef ZEND_RAW_FENTRY -/* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ -# define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_RAW_FENTRY((char*)#ZN, N, A, 0) -#else -/* This causes warnings from GCC >= 4.2 (assigning a string literal to char*). - * But this seems to be unavoidable without directly assuming knowledge of - * the structure, which changed between PHP4 and PHP5. */ -# define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) -#endif - -#ifndef ZEND_FE_END -# define ZEND_FE_END { NULL, NULL, NULL } -#endif - -#ifndef Z_SET_ISREF_P -/* For PHP < 5.3 */ -# define Z_SET_ISREF_P(z) (z)->is_ref = 1 -#endif -#ifndef Z_SET_REFCOUNT_P -/* For PHP < 5.3 */ -# define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) -#endif - -#define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) -#define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) -#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) -#define SWIG_CHAR_CONSTANT(N, V) do {\ - static char swig_char = (V);\ - zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ -} while (0) - -/* These TSRMLS_ stuff should already be defined now, but with older php under - redhat are not... */ -#ifndef TSRMLS_D -#define TSRMLS_D -#endif -#ifndef TSRMLS_DC -#define TSRMLS_DC -#endif -#ifndef TSRMLS_C -#define TSRMLS_C -#endif -#ifndef TSRMLS_CC -#define TSRMLS_CC -#endif - -#ifdef __cplusplus -} -#endif - -/* But in fact SWIG_ConvertPtr is the native interface for getting typed - pointer values out of zvals. We need the TSRMLS_ macros for when we - make PHP type calls later as we handle php resources */ -#define SWIG_ConvertPtr(obj,pp,type,flags) SWIG_ZTS_ConvertPtr(obj,pp,type,flags TSRMLS_CC) - - -#define SWIG_fail goto fail - -static const char *default_error_msg = "Unknown error occurred"; -static int default_error_code = E_ERROR; - -#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg - -#define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0) - -#define SWIG_contract_assert(expr,msg) \ - 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) - -/* used to wrap returned objects in so we know whether they are newobject - and need freeing, or not */ -typedef struct { - void * ptr; - int newobject; -} swig_object_wrapper; - -#define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) -#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) - -static void -SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { - /* - * First test for Null pointers. Return those as PHP native NULL - */ - if (!ptr ) { - ZVAL_NULL(z); - return; - } - if (type->clientdata) { - swig_object_wrapper *value; - if (! (*(int *)(type->clientdata))) - zend_error(E_ERROR, "Type: %s failed to register with zend",type->name); - value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); - value->ptr=ptr; - value->newobject=(newobject & 1); - if ((newobject & 2) == 0) { - /* Just register the pointer as a resource. */ - ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); - } else { - /* - * Wrap the resource in an object, the resource will be accessible - * via the "_cPtr" member. This is currently only used by - * directorin typemaps. - */ - zval *resource; - zend_class_entry **ce = NULL; - const char *type_name = type->name+3; /* +3 so: _p_Foo -> Foo */ - size_t type_name_len; - int result; - const char * p; - - /* Namespace__Foo -> Foo */ - /* FIXME: ugly and goes wrong for classes with __ in their names. */ - while ((p = strstr(type_name, "__")) != NULL) { - type_name = p + 2; - } - type_name_len = strlen(type_name); - - MAKE_STD_ZVAL(resource); - ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); - if (SWIG_PREFIX_LEN > 0) { - char * classname = (char*)emalloc(SWIG_PREFIX_LEN + type_name_len + 1); - strcpy(classname, SWIG_PREFIX); - strcpy(classname + SWIG_PREFIX_LEN, type_name); - result = zend_lookup_class(classname, SWIG_PREFIX_LEN + type_name_len, &ce TSRMLS_CC); - efree(classname); - } else { - result = zend_lookup_class((char *)type_name, type_name_len, &ce TSRMLS_CC); - } - if (result != SUCCESS) { - /* class does not exist */ - object_init(z); - } else { - object_init_ex(z, *ce); - } - Z_SET_REFCOUNT_P(z, 1); - Z_SET_ISREF_P(z); - zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval*), NULL); - } - return; - } - zend_error(E_ERROR, "Type: %s not registered with zend",type->name); -} - -/* This pointer conversion routine takes the native pointer p (along with - its type name) and converts it by calling appropriate casting functions - according to ty. The resultant pointer is returned, or NULL is returned - if the pointer can't be cast. - - Sadly PHP has no API to find a type name from a type id, only from an - instance of a resource of the type id, so we have to pass type_name as well. - - The two functions which might call this are: - SWIG_ZTS_ConvertResourcePtr which gets the type name from the resource - and the registered zend destructors for which we have one per type each - with the type name hard wired in. */ -static void * -SWIG_ZTS_ConvertResourceData(void * p, const char *type_name, swig_type_info *ty TSRMLS_DC) { - swig_cast_info *tc; - void *result = 0; - - if (!ty) { - /* They don't care about the target type, so just pass on the pointer! */ - return p; - } - - if (! type_name) { - /* can't convert p to ptr type ty if we don't know what type p is */ - return NULL; - } - - /* convert and cast p from type_name to ptr as ty. */ - tc = SWIG_TypeCheck(type_name, ty); - if (tc) { - int newmemory = 0; - result = SWIG_TypeCast(tc, p, &newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } - return result; -} - -/* This function returns a pointer of type ty by extracting the pointer - and type info from the resource in z. z must be a resource. - If it fails, NULL is returned. - It uses SWIG_ZTS_ConvertResourceData to do the real work. */ -static void * -SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { - swig_object_wrapper *value; - void *p; - int type; - const char *type_name; - - value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); - if (type==-1) return NULL; - if (flags & SWIG_POINTER_DISOWN) { - value->newobject = 0; - } - p = value->ptr; - - type_name=zend_rsrc_list_get_rsrc_type(z->value.lval TSRMLS_CC); - - return SWIG_ZTS_ConvertResourceData(p, type_name, ty TSRMLS_CC); -} - -/* We allow passing of a RESOURCE pointing to the object or an OBJECT whose - _cPtr is a resource pointing to the object */ -static int -SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC) { - if (z == NULL) { - *ptr = 0; - return 0; - } - - switch (z->type) { - case IS_OBJECT: { - zval ** _cPtr; - if (zend_hash_find(HASH_OF(z),(char*)"_cPtr",sizeof("_cPtr"),(void**)&_cPtr)==SUCCESS) { - if ((*_cPtr)->type==IS_RESOURCE) { - *ptr = SWIG_ZTS_ConvertResourcePtr(*_cPtr, ty, flags TSRMLS_CC); - return (*ptr == NULL ? -1 : 0); - } - } - break; - } - case IS_RESOURCE: - *ptr = SWIG_ZTS_ConvertResourcePtr(z, ty, flags TSRMLS_CC); - return (*ptr == NULL ? -1 : 0); - case IS_NULL: - *ptr = 0; - return 0; - } - - return -1; -} - -static char const_name[] = "swig_runtime_data_type_pointer"; -static swig_module_info *SWIG_Php_GetModule() { - zval *pointer; - swig_module_info *ret = 0; - TSRMLS_FETCH(); - - MAKE_STD_ZVAL(pointer); - - if (zend_get_constant(const_name, sizeof(const_name) - 1, pointer TSRMLS_CC)) { - if (pointer->type == IS_LONG) { - ret = (swig_module_info *) pointer->value.lval; - } - } - FREE_ZVAL(pointer); - return ret; -} - -static void SWIG_Php_SetModule(swig_module_info *pointer) { - TSRMLS_FETCH(); - REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, CONST_PERSISTENT | CONST_CS); -} diff --git a/Lib/php5/std_common.i b/Lib/php5/std_common.i deleted file mode 100644 index 092bf012b..000000000 --- a/Lib/php5/std_common.i +++ /dev/null @@ -1,10 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_common.i - * - * SWIG typemaps for STL - common utilities - * ----------------------------------------------------------------------------- */ - -%include - -%apply size_t { std::size_t }; - diff --git a/Lib/php5/std_deque.i b/Lib/php5/std_deque.i deleted file mode 100644 index cb98f6c2f..000000000 --- a/Lib/php5/std_deque.i +++ /dev/null @@ -1 +0,0 @@ -%include diff --git a/Lib/php5/std_map.i b/Lib/php5/std_map.i deleted file mode 100644 index 6d5e3db13..000000000 --- a/Lib/php5/std_map.i +++ /dev/null @@ -1,76 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_map.i - * - * SWIG typemaps for std::map - * ----------------------------------------------------------------------------- */ - -%include - -// ------------------------------------------------------------------------ -// std::map -// ------------------------------------------------------------------------ - -%{ -#include -#include -#include -%} - -// exported class - -namespace std { - - template class map { - // add typemaps here - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef K key_type; - typedef T mapped_type; - map(); - map(const map &); - - unsigned int size() const; - void clear(); - %extend { - const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, const T& x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map::iterator i = self->find(key); - return i != self->end(); - } - bool is_empty() const { - return self->empty(); - } - } - }; - -// Legacy macros (deprecated) -%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) -#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" -%enddef - -%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) -#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" -%enddef - -%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) -#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" -%enddef - -} diff --git a/Lib/php5/std_pair.i b/Lib/php5/std_pair.i deleted file mode 100644 index fe45ee676..000000000 --- a/Lib/php5/std_pair.i +++ /dev/null @@ -1,34 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_pair.i - * - * SWIG typemaps for std::pair - * ----------------------------------------------------------------------------- */ - -%include -%include - -// ------------------------------------------------------------------------ -// std::pair -// ------------------------------------------------------------------------ - -%{ -#include -%} - -namespace std { - - template struct pair { - - pair(); - pair(T first, U second); - pair(const pair& p); - - template pair(const pair &p); - - T first; - U second; - }; - - // add specializations here - -} diff --git a/Lib/php5/std_string.i b/Lib/php5/std_string.i deleted file mode 100644 index aaa5dc9cd..000000000 --- a/Lib/php5/std_string.i +++ /dev/null @@ -1,79 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_string.i - * - * SWIG typemaps for std::string types - * ----------------------------------------------------------------------------- */ - -// ------------------------------------------------------------------------ -// std::string is typemapped by value -// This can prevent exporting methods which return a string -// in order for the user to modify it. -// However, I think I'll wait until someone asks for it... -// ------------------------------------------------------------------------ - -%include - -%{ -#include -%} - -namespace std { - - %naturalvar string; - - class string; - - %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) string, const string& %{ - $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; - %} - - %typemap(in) string %{ - convert_to_string_ex($input); - $1.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); - %} - - %typemap(directorout) string %{ - convert_to_string_ex(&$input); - $result.assign(Z_STRVAL_P($input), Z_STRLEN_P($input)); - %} - - %typemap(out) string %{ - ZVAL_STRINGL($result, const_cast($1.data()), $1.size(), 1); - %} - - %typemap(directorin) string, const string& %{ - ZVAL_STRINGL($input, const_cast($1.data()), $1.size(), 1); - %} - - %typemap(out) const string & %{ - ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); - %} - - %typemap(throws) string, const string& %{ - zend_throw_exception(NULL, const_cast($1.c_str()), 0 TSRMLS_CC); - return; - %} - - /* These next two handle a function which takes a non-const reference to - * a std::string and modifies the string. */ - %typemap(in) string & ($*1_ltype temp) %{ - convert_to_string_ex($input); - temp.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); - $1 = &temp; - %} - - %typemap(directorout) string & ($*1_ltype *temp) %{ - convert_to_string_ex(&$input); - temp = new $*1_ltype(Z_STRVAL_P($input), Z_STRLEN_P($input)); - swig_acquire_ownership(temp); - $result = temp; - %} - - %typemap(argout) string & %{ - ZVAL_STRINGL(*($input), const_cast($1->data()), $1->size(), 1); - %} - - /* SWIG will apply the non-const typemap above to const string& without - * this more specific typemap. */ - %typemap(argout) const string & ""; -} diff --git a/Lib/php5/std_vector.i b/Lib/php5/std_vector.i deleted file mode 100644 index 9cc1486ef..000000000 --- a/Lib/php5/std_vector.i +++ /dev/null @@ -1,102 +0,0 @@ -/* ----------------------------------------------------------------------------- - * std_vector.i - * ----------------------------------------------------------------------------- */ - -%include - -%{ -#include -#include -%} - -namespace std { - - template class vector { - public: - typedef size_t size_type; - typedef T value_type; - typedef const value_type& const_reference; - vector(); - vector(size_type n); - size_type size() const; - size_type capacity() const; - void reserve(size_type n); - void clear(); - %rename(push) push_back; - void push_back(const value_type& x); - %extend { - bool is_empty() const { - return $self->empty(); - } - T pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty vector"); - T x = self->back(); - self->pop_back(); - return x; - } - const_reference get(int i) throw (std::out_of_range) { - int size = int(self->size()); - if (i>=0 && isize()); - if (i>=0 && i 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); - void clear(); - %rename(push) push_back; - void push_back(const value_type& x); - %extend { - bool is_empty() const { - return $self->empty(); - } - bool pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty vector"); - bool x = self->back(); - self->pop_back(); - return x; - } - bool get(int i) throw (std::out_of_range) { - int size = int(self->size()); - if (i>=0 && isize()); - if (i>=0 && i -%include -%include -%include -%include - diff --git a/Lib/php5/typemaps.i b/Lib/php5/typemaps.i deleted file mode 100644 index faae0a6ac..000000000 --- a/Lib/php5/typemaps.i +++ /dev/null @@ -1,322 +0,0 @@ -/* ----------------------------------------------------------------------------- - * typemaps.i. - * - * SWIG Typemap library for PHP. - * - * This library provides standard typemaps for modifying SWIG's behavior. - * With enough entries in this file, I hope that very few people actually - * ever need to write a typemap. - * - * Define macros to define the following typemaps: - * - * TYPE *INPUT. Argument is passed in as native variable by value. - * TYPE *OUTPUT. Argument is returned as an array from the function call. - * TYPE *INOUT. Argument is passed in by value, and out as part of returned list - * TYPE *REFERENCE. Argument is passed in as native variable with value - * semantics. Variable value is changed with result. - * Use like this: - * int foo(int *REFERENCE); - * - * $a = 0; - * $rc = foo($a); - * - * Even though $a looks like it's passed by value, - * its value can be changed by foo(). - * ----------------------------------------------------------------------------- */ - -%define BOOL_TYPEMAP(TYPE) -%typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) -%{ - convert_to_boolean_ex($input); - temp = Z_LVAL_PP($input) ? true : false; - $1 = &temp; -%} -%typemap(argout) TYPE *INPUT, TYPE &INPUT ""; -%typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; -%typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT -{ - zval *o; - MAKE_STD_ZVAL(o); - ZVAL_BOOL(o,temp$argnum); - t_output_helper( &$result, o TSRMLS_CC ); -} -%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) -%{ - convert_to_boolean_ex($input); - lvalue = (*$input)->value.lval ? true : false; - $1 = &lvalue; -%} -%typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE -%{ - (*$arg)->value.lval = lvalue$argnum ? true : false; - (*$arg)->type = IS_BOOL; -%} -%enddef - -%define DOUBLE_TYPEMAP(TYPE) -%typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) -%{ - convert_to_double_ex($input); - temp = (TYPE) Z_DVAL_PP($input); - $1 = &temp; -%} -%typemap(argout) TYPE *INPUT, TYPE &INPUT ""; -%typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; -%typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT -{ - zval *o; - MAKE_STD_ZVAL(o); - ZVAL_DOUBLE(o,temp$argnum); - t_output_helper( &$result, o TSRMLS_CC ); -} -%typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue) -%{ - convert_to_double_ex($input); - dvalue = (TYPE) (*$input)->value.dval; - $1 = &dvalue; -%} -%typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE -%{ - $1->value.dval = (double)(lvalue$argnum); - $1->type = IS_DOUBLE; -%} -%enddef - -%define INT_TYPEMAP(TYPE) -%typemap(in) TYPE *INPUT(TYPE temp), TYPE &INPUT(TYPE temp) -%{ - convert_to_long_ex($input); - temp = (TYPE) Z_LVAL_PP($input); - $1 = &temp; -%} -%typemap(argout) TYPE *INPUT, TYPE &INPUT ""; -%typemap(in,numinputs=0) TYPE *OUTPUT(TYPE temp), TYPE &OUTPUT(TYPE temp) "$1 = &temp;"; -%typemap(argout,fragment="t_output_helper") TYPE *OUTPUT, TYPE &OUTPUT -{ - zval *o; - MAKE_STD_ZVAL(o); - ZVAL_LONG(o,temp$argnum); - t_output_helper( &$result, o TSRMLS_CC ); -} -%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue) -%{ - convert_to_long_ex($input); - lvalue = (TYPE) (*$input)->value.lval; - $1 = &lvalue; -%} -%typemap(argout) TYPE *REFERENCE, TYPE &REFERENCE -%{ - (*$arg)->value.lval = (long)(lvalue$argnum); - (*$arg)->type = IS_LONG; -%} -%enddef - -BOOL_TYPEMAP(bool); - -DOUBLE_TYPEMAP(float); -DOUBLE_TYPEMAP(double); - -INT_TYPEMAP(int); -INT_TYPEMAP(short); -INT_TYPEMAP(long); -INT_TYPEMAP(unsigned int); -INT_TYPEMAP(unsigned short); -INT_TYPEMAP(unsigned long); -INT_TYPEMAP(unsigned char); -INT_TYPEMAP(signed 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", (long long)temp$argnum); - ZVAL_STRING(o, temp, 1); - } - t_output_helper( &$result, o TSRMLS_CC ); -} -%typemap(in) TYPE *REFERENCE (long long lvalue) -%{ - CONVERT_LONG_LONG_IN(lvalue, long long, $input) - $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", (long long)lvalue$argnum); - ZVAL_STRING((*$arg), temp, 1); - } -%} -%typemap(argout) long long &OUTPUT -%{ - if ((long long)LONG_MIN <= *arg$argnum && *arg$argnum <= (long long)LONG_MAX) { - ($result)->value.lval = (long)(*arg$argnum); - ($result)->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%lld", (long long)(*arg$argnum)); - ZVAL_STRING($result, 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", (unsigned long long)temp$argnum); - ZVAL_STRING(o, temp, 1); - } - t_output_helper( &$result, o TSRMLS_CC ); -} -%typemap(in) TYPE *REFERENCE (unsigned long long lvalue) -%{ - CONVERT_UNSIGNED_LONG_LONG_IN(lvalue, unsigned long long, $input) - $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", (unsigned long long)lvalue$argnum); - ZVAL_STRING((*$arg), temp, 1); - } -%} -%typemap(argout) unsigned long long &OUTPUT -%{ - if (*arg$argnum <= (unsigned long long)LONG_MAX) { - ($result)->value.lval = (long)(*arg$argnum); - ($result)->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%llu", (unsigned long long)(*arg$argnum)); - ZVAL_STRING($result, temp, 1); - } -%} - -%typemap(in) bool *INOUT = bool *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(in) signed char *INOUT = signed char *INPUT; - -%typemap(in) bool &INOUT = bool *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) long long &INPUT = 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) unsigned long long &INPUT = unsigned long long *INPUT; -%typemap(in) signed char &INOUT = signed char *INPUT; - -%typemap(argout) bool *INOUT = bool *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(argout) signed char *INOUT = signed char *OUTPUT; - -%typemap(argout) bool &INOUT = bool *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(argout) signed char &INOUT = signed char *OUTPUT; - -%typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) -%{ - convert_to_string_ex($input); - strncpy(temp,Z_STRVAL_PP($input),$1_dim0); - $1 = temp; -%} -%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] ) - "$1 = temp;"; -%typemap(argout,fragment="t_output_helper") char OUTPUT[ANY] -{ - zval *o; - MAKE_STD_ZVAL(o); - ZVAL_STRINGL(o,temp$argnum,$1_dim0); - t_output_helper( &$result, o TSRMLS_CC ); -} - -%typemap(in,numinputs=0) void **OUTPUT (int force), - void *&OUTPUT (int force) -%{ - /* If they pass NULL by reference, make it into a void* - This bit should go in arginit if arginit support init-ing scripting args */ - if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, 0) < 0) { - /* So... we didn't get a ref or ptr, but we'll accept NULL by reference */ - if (!((*$input)->type==IS_NULL && PZVAL_IS_REF(*$input))) { - /* wasn't a pre/ref/thing, OR anything like an int thing */ - SWIG_PHP_Error(E_ERROR, "Type error in argument $arg of $symname."); - } - } - force=0; - if (arg1==NULL) { -#ifdef __cplusplus - ptr=new $*1_ltype(); -#else - ptr=($*1_ltype) calloc(1,sizeof($*1_ltype)); -#endif - $1=&ptr; - /* have to passback arg$arg too */ - force=1; - } -%} - -%typemap(argout) void **OUTPUT, - void *&OUTPUT -%{ - if (force$argnum) { /* pass back arg$argnum through params ($arg) if we can */ - if (!PZVAL_IS_REF(*$arg)) { - SWIG_PHP_Error(E_WARNING, "Parameter $argnum of $symname wasn't passed by reference"); - } else { - SWIG_SetPointerZval(*$arg, (void *) ptr$argnum, $*1_descriptor, 1); - } - } -%} diff --git a/Lib/php5/utils.i b/Lib/php5/utils.i deleted file mode 100644 index 408a3b366..000000000 --- a/Lib/php5/utils.i +++ /dev/null @@ -1,114 +0,0 @@ - -%define CONVERT_BOOL_IN(lvar,t,invar) - convert_to_boolean_ex(invar); - lvar = (t) Z_LVAL_PP(invar); -%enddef - -%define CONVERT_INT_IN(lvar,t,invar) - convert_to_long_ex(invar); - lvar = (t) Z_LVAL_PP(invar); -%enddef - -%define CONVERT_LONG_LONG_IN(lvar,t,invar) - switch ((*(invar))->type) { - case IS_DOUBLE: - lvar = (t) (*(invar))->value.dval; - break; - case IS_STRING: { - char * endptr; - errno = 0; - lvar = (t) strtoll((*(invar))->value.str.val, &endptr, 10); - if (*endptr && !errno) break; - /* FALL THRU */ - } - default: - convert_to_long_ex(invar); - lvar = (t) (*(invar))->value.lval; - } -%enddef - -%define CONVERT_UNSIGNED_LONG_LONG_IN(lvar,t,invar) - switch ((*(invar))->type) { - case IS_DOUBLE: - lvar = (t) (*(invar))->value.dval; - break; - case IS_STRING: { - char * endptr; - errno = 0; - lvar = (t) strtoull((*(invar))->value.str.val, &endptr, 10); - if (*endptr && !errno) break; - /* FALL THRU */ - } - default: - convert_to_long_ex(invar); - lvar = (t) (*(invar))->value.lval; - } -%enddef - -%define CONVERT_INT_OUT(lvar,invar) - lvar = (t) Z_LVAL_PP(invar); -%enddef - -%define CONVERT_FLOAT_IN(lvar,t,invar) - convert_to_double_ex(invar); - lvar = (t) Z_DVAL_PP(invar); -%enddef - -%define CONVERT_CHAR_IN(lvar,t,invar) - convert_to_string_ex(invar); - lvar = (t) *Z_STRVAL_PP(invar); -%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); - } -%enddef - -%define %pass_by_val( TYPE, CONVERT_IN ) -%typemap(in) TYPE -%{ - CONVERT_IN($1,$1_ltype,$input); -%} -%typemap(in) const TYPE & ($*1_ltype temp) -%{ - CONVERT_IN(temp,$*1_ltype,$input); - $1 = &temp; -%} -%typemap(directorout) TYPE -%{ - CONVERT_IN($result,$1_ltype,&$input); -%} -%typemap(directorout) const TYPE & ($*1_ltype temp) -%{ - CONVERT_IN(temp,$*1_ltype,&$input); - $result = &temp; -%} -%enddef - -%fragment("t_output_helper","header") %{ -static void -t_output_helper(zval **target, zval *o TSRMLS_DC) { - zval *tmp; - if ( (*target)->type == IS_ARRAY ) { - /* it's already an array, just append */ - add_next_index_zval( *target, o ); - return; - } - if ( (*target)->type == IS_NULL ) { - REPLACE_ZVAL_VALUE(target,o,1); - FREE_ZVAL(o); - return; - } - ALLOC_INIT_ZVAL(tmp); - *tmp = **target; - zval_copy_ctor(tmp); - array_init(*target); - add_next_index_zval( *target, tmp); - add_next_index_zval( *target, o); - -} -%} diff --git a/Makefile.in b/Makefile.in index 9f81598cd..9d23fb303 100644 --- a/Makefile.in +++ b/Makefile.in @@ -67,7 +67,6 @@ 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-php5 = test -n "@SKIP_PHP5@" skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" skip-pike = test -n "@SKIP_PIKE@" @@ -118,7 +117,6 @@ check-aliveness: @$(skip-ocaml) || ./$(TARGET) -ocaml -help @$(skip-octave) || ./$(TARGET) -octave -help @$(skip-php) || ./$(TARGET) -php7 -help - @$(skip-php5) || ./$(TARGET) -php5 -help @$(skip-pike) || ./$(TARGET) -pike -help @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @@ -151,7 +149,6 @@ check-versions: \ check-ocaml-version \ check-octave-version \ check-php-version \ - check-php5-version \ check-pike-version \ check-chicken-version \ check-csharp-version \ @@ -192,7 +189,6 @@ check-examples: \ check-ocaml-examples \ check-octave-examples \ check-php-examples \ - check-php5-examples \ check-pike-examples \ check-chicken-examples \ check-csharp-examples \ @@ -219,7 +215,6 @@ 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) -php5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php5/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) @@ -268,7 +263,6 @@ check-test-suite: \ check-ocaml-test-suite \ check-octave-test-suite \ check-php-test-suite \ - check-php5-test-suite \ check-pike-test-suite \ check-csharp-test-suite \ check-modula3-test-suite \ @@ -323,7 +317,6 @@ all-test-suite: \ all-ocaml-test-suite \ all-octave-test-suite \ all-php-test-suite \ - all-php5-test-suite \ all-pike-test-suite \ all-csharp-test-suite \ all-modula3-test-suite \ @@ -354,7 +347,6 @@ broken-test-suite: \ broken-ocaml-test-suite \ broken-octave-test-suite \ broken-php-test-suite \ - broken-php5-test-suite \ broken-pike-test-suite \ broken-csharp-test-suite \ broken-modula3-test-suite \ @@ -499,7 +491,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 = typemaps tcl perl5 python guile java mzscheme ruby php php5 ocaml octave \ +lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ javascript/v8 scilab diff --git a/Source/Makefile.am b/Source/Makefile.am index efa3ac1e4..b04e3542f 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -62,7 +62,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/overload.cxx \ Modules/perl5.cxx \ Modules/php.cxx \ - Modules/php5.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c7ae02625..063275e3b 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -65,7 +65,7 @@ static const char *usage1 = (const char *) "\ -copyctor - Automatically generate copy constructors wherever possible\n\ -cpperraswarn - Treat the preprocessor #error statement as #warning (default)\n\ -cppext - Change file extension of generated C++ files to \n\ - (default is cxx, except for PHP5 which uses cpp)\n\ + (default is cxx)\n\ -copyright - Display copyright notices\n\ -debug-classes - Display information about the classes found in the interface\n\ -debug-module - Display module parse tree at stages 1-4, is a csv list of stages\n\ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index b32f3c63e..c324e0c82 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -12,7 +12,7 @@ * ----------------------------------------------------------------------------- */ -/* FIXME: PHP5 OO wrapping TODO list: +/* FIXME: PHP OO wrapping TODO list: * * Medium term: * @@ -530,7 +530,7 @@ public: Printf(s_init, "extern \"C\" {\n"); Printf(s_init, "#endif\n"); // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE - // in PHP5 has "extern "C" { ... }" around it so we can't do that. + // in PHP7 has "extern "C" { ... }" around it so we can't do that. Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module); Printf(s_init, "#ifdef __cplusplus\n"); Printf(s_init, "}\n"); @@ -1462,14 +1462,6 @@ public: /* We need $this to refer to the current class, so can't allow it * to be used as a parameter. */ 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). Similarly we use $c for the classname or new - * stdClass object. - */ - Setattr(seen, "r", seen); - Setattr(seen, "c", seen); for (int argno = 0; argno < max_num_of_arguments; ++argno) { String *&pname = arg_names[argno]; @@ -2207,7 +2199,6 @@ done: } Printf(s_phpclasses, "\t}\n"); - /* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */ /* __isset() should return true for read-only properties, so check for * *_get() not *_set(). */ Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); @@ -2870,3 +2861,17 @@ static Language *new_swig_php() { extern "C" Language *swig_php(void) { return new_swig_php(); } + +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. +} + +extern "C" Language *swig_php5(void) { + Printf(stderr, "*** -php5 is no longer supported.\n" + "*** Either upgrade to PHP7 or use SWIG < 4.0.0.\n"); + SWIG_exit(EXIT_FAILURE); + return NULL; // To avoid compiler warnings. +} diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx deleted file mode 100644 index 4710aa01a..000000000 --- a/Source/Modules/php5.cxx +++ /dev/null @@ -1,2889 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * php5.cxx - * - * PHP5 language module for SWIG. - * ----------------------------------------------------------------------------- - */ - -/* FIXME: PHP5 OO wrapping TODO list: - * - * Medium term: - * - * Handle default parameters on overloaded methods in PHP where possible. - * (Mostly done - just need to handle cases of overloaded methods with - * default parameters...) - * This is an optimisation - we could handle this case using a PHP - * default value, but currently we treat it as we would for a default - * value which is a compound C++ expression (i.e. as if we had a - * method with two overloaded forms instead of a single method with - * a default parameter value). - * - * Long term: - * - * Sort out locale-dependent behaviour of strtod() - it's harmless unless - * SWIG ever sets the locale and DOH/base.c calls atof, so we're probably - * OK currently at least. - */ - -/* - * TODO: Replace remaining stderr messages with Swig_error or Swig_warning - * (may need to add more WARN_PHP_xxx codes...) - */ - -#include "swigmod.h" - -#include -#include - -static const char *usage = "\ -PHP5 Options (available with -php5)\n\ - -noproxy - Don't generate proxy classes.\n\ - -prefix - Prepend to all class names in PHP wrappers\n\ -\n"; - -/* The original class wrappers for PHP stored 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. - * FIXME: Isn't using a leading underscore a bit suspect here? - */ -#define SWIG_PTR "_cPtr" - -/* This is the name of the hash where the variables existing only in PHP - * classes are stored. - */ -#define SWIG_DATA "_pData" - -static int constructors = 0; -static String *NOTCLASS = NewString("Not a class"); -static Node *classnode = 0; -static String *module = 0; -static String *cap_module = 0; -static String *prefix = 0; - -static String *shadow_classname = 0; - -static File *f_begin = 0; -static File *f_runtime = 0; -static File *f_runtime_h = 0; -static File *f_h = 0; -static File *f_phpcode = 0; -static File *f_directors = 0; -static File *f_directors_h = 0; -static String *phpfilename = 0; - -static String *s_header; -static String *s_wrappers; -static String *s_init; -static String *r_init; // RINIT user code -static String *s_shutdown; // MSHUTDOWN user code -static String *r_shutdown; // RSHUTDOWN user code -static String *s_vinit; // varinit initialization code. -static String *s_vdecl; -static String *s_cinit; // consttab initialization code. -static String *s_oinit; -static String *s_arginfo; -static String *s_entry; -static String *cs_entry; -static String *all_cs_entry; -static String *pragma_incl; -static String *pragma_code; -static String *pragma_phpinfo; -static String *pragma_version; -static String *s_oowrappers; -static String *s_fakeoowrappers; -static String *s_phpclasses; - -/* To reduce code size (generated and compiled) we only want to emit each - * different arginfo once, so we need to track which have been used. - */ -static Hash *arginfo_used; - -/* Variables for using PHP classes */ -static Node *current_class = 0; - -static Hash *shadow_get_vars; -static Hash *shadow_set_vars; -static Hash *zend_types = 0; - -static int shadow = 1; - -static bool class_has_ctor = false; -static String *wrapping_member_constant = NULL; - -// These static variables are used to pass some state from Handlers into functionWrapper -static enum { - standard = 0, - memberfn, - staticmemberfn, - membervar, - staticmembervar, - constructor, - directorconstructor -} wrapperType = standard; - -extern "C" { - static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0; -} - -static void SwigPHP_emit_resource_registrations() { - Iterator ki; - bool emitted_default_dtor = false; - - if (!zend_types) - return; - - ki = First(zend_types); - if (ki.key) - Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); - while (ki.key) { - DOH *key = ki.key; - Node *class_node = ki.item; - String *human_name = key; - String *rsrc_dtor_name = NULL; - - // write out body - if (class_node != NOTCLASS) { - String *destructor = Getattr(class_node, "destructor"); - human_name = Getattr(class_node, "sym:name"); - if (!human_name) - human_name = Getattr(class_node, "name"); - // Do we have a known destructor for this type? - if (destructor) { - rsrc_dtor_name = NewStringf("_wrap_destroy%s", key); - // Write out custom destructor function - Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(%s) {\n", rsrc_dtor_name); - Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); - Printf(s_wrappers, "}\n"); - } - } - - if (!rsrc_dtor_name) { - rsrc_dtor_name = NewString("_swig_default_rsrc_destroy"); - if (!emitted_default_dtor) { - // Write out custom destructor function - Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(%s) {\n", rsrc_dtor_name); - Printf(s_wrappers, " efree(rsrc->ptr);\n"); - Printf(s_wrappers, "}\n"); - emitted_default_dtor = true; - } - } - - // declare le_swig_ to store php registration - Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); - - // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" - "(%s, NULL, (char *)SWIGTYPE%s->name, module_number);\n", key, rsrc_dtor_name, key); - - // store php type in class struct - Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); - - Delete(rsrc_dtor_name); - - ki = Next(ki); - } -} - -class PHP5 : public Language { - String *emit_action(Node *n) { - // Adjust wrap:action to add TSRMLS_CC. - String * action = Getattr(n, "wrap:action"); - if (action) { - char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\""); - if (p) { - p += strlen("Swig::DirectorPureVirtualException::raise(\""); - p = strchr(p, '"'); - if (p) { - ++p; - Insert(action, (int)(p - Char(action)), " TSRMLS_CC"); - } - } - } - return ::emit_action(n); - } - -public: - PHP5() { - director_language = 1; - } - - /* ------------------------------------------------------------ - * main() - * ------------------------------------------------------------ */ - - virtual void main(int argc, char *argv[]) { - SWIG_library_directory("php5"); - 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]); - 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); - } 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"); - allow_overloading(); - } - - /* ------------------------------------------------------------ - * top() - * ------------------------------------------------------------ */ - - virtual int top(Node *n) { - - String *filen; - - /* Check if directors are enabled for this module. */ - Node *mod = Getattr(n, "module"); - if (mod) { - Node *options = Getattr(mod, "options"); - if (options && Getattr(options, "directors")) { - allow_directors(); - } - } - - /* Set comparison with null for ConstructorToFunction */ - setSubclassInstanceCheck(NewString("$arg->type != IS_NULL")); - - /* Initialize all of the output files */ - String *outfile = Getattr(n, "outfile"); - String *outfile_h = Getattr(n, "outfile_h"); - - /* main output file */ - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { - FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); - } - f_runtime = NewStringEmpty(); - - /* sections of the output file */ - s_init = NewStringEmpty(); - r_init = NewString("/* rinit section */\n"); - s_shutdown = NewString("/* shutdown section */\n"); - r_shutdown = NewString("/* rshutdown section */\n"); - s_header = NewString("/* header section */\n"); - s_wrappers = NewString("/* wrapper section */\n"); - /* subsections of the init section */ - s_vinit = NewString("/* vinit subsection */\n"); - s_vdecl = NewString("/* vdecl subsection */\n"); - s_cinit = NewString("/* cinit subsection */\n"); - s_oinit = NewString("/* oinit subsection */\n"); - pragma_phpinfo = NewStringEmpty(); - s_phpclasses = NewString("/* PHP Proxy Classes */\n"); - f_directors_h = NewStringEmpty(); - f_directors = NewStringEmpty(); - - if (directorsEnabled()) { - 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("begin", f_begin); - Swig_register_filebyname("runtime", f_runtime); - Swig_register_filebyname("init", s_init); - Swig_register_filebyname("rinit", r_init); - Swig_register_filebyname("shutdown", s_shutdown); - Swig_register_filebyname("rshutdown", r_shutdown); - Swig_register_filebyname("header", s_header); - Swig_register_filebyname("wrapper", s_wrappers); - Swig_register_filebyname("director", f_directors); - Swig_register_filebyname("director_h", f_directors_h); - - Swig_banner(f_begin); - - Printf(f_runtime, "\n\n#ifndef SWIGPHP\n#define SWIGPHP\n#endif\n\n"); - - if (directorsEnabled()) { - Printf(f_runtime, "#define SWIG_DIRECTORS\n"); - } - - /* Set the module name */ - module = Copy(Getattr(n, "name")); - cap_module = NewStringf("%(upper)s", module); - if (!prefix) - prefix = NewStringEmpty(); - - Printf(f_runtime, "#define SWIG_PREFIX \"%s\"\n", prefix); - Printf(f_runtime, "#define SWIG_PREFIX_LEN %lu\n", (unsigned long)Len(prefix)); - - if (directorsEnabled()) { - Swig_banner(f_directors_h); - Printf(f_directors_h, "\n"); - Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module); - Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", cap_module); - - String *filename = Swig_file_filename(outfile_h); - Printf(f_directors, "\n#include \"%s\"\n\n", filename); - Delete(filename); - } - - /* PHP module file */ - filen = NewStringEmpty(); - Printv(filen, SWIG_output_directory(), module, ".php", NIL); - phpfilename = NewString(filen); - - f_phpcode = NewFile(filen, "w", SWIG_output_files()); - if (!f_phpcode) { - FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); - } - - Printf(f_phpcode, "error_msg = default_error_msg;\n"); - Printf(s_header, " globals->error_code = default_error_code;\n"); - Printf(s_header, "}\n"); - - Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n"); - Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n"); - Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n"); - Printf(s_header, "}\n"); - - Append(s_header, "\n"); - Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_alter_newobject) {\n", module); - Append(s_header, " zval **args[2];\n"); - Append(s_header, " swig_object_wrapper *value;\n"); - Append(s_header, " int type;\n"); - Append(s_header, "\n"); - Append(s_header, " SWIG_ResetError(TSRMLS_C);\n"); - Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n"); - Append(s_header, " WRONG_PARAM_COUNT;\n"); - Append(s_header, " }\n"); - Append(s_header, "\n"); - Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); - Append(s_header, " value->newobject = zval_is_true(*args[1]);\n"); - Append(s_header, "\n"); - Append(s_header, " return;\n"); - Append(s_header, "}\n"); - Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_get_newobject) {\n", module); - Append(s_header, " zval **args[1];\n"); - Append(s_header, " swig_object_wrapper *value;\n"); - Append(s_header, " int type;\n"); - Append(s_header, "\n"); - Append(s_header, " SWIG_ResetError(TSRMLS_C);\n"); - Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n"); - Append(s_header, " WRONG_PARAM_COUNT;\n"); - Append(s_header, " }\n"); - Append(s_header, "\n"); - Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); - Append(s_header, " RETVAL_LONG(value->newobject);\n"); - Append(s_header, "\n"); - Append(s_header, " return;\n"); - Append(s_header, "}\n"); - - Printf(s_header, "#define SWIG_name \"%s\"\n", module); - Printf(s_header, "#ifdef __cplusplus\n"); - Printf(s_header, "extern \"C\" {\n"); - Printf(s_header, "#endif\n"); - Printf(s_header, "#include \"php.h\"\n"); - Printf(s_header, "#include \"php_ini.h\"\n"); - Printf(s_header, "#include \"ext/standard/info.h\"\n"); - Printf(s_header, "#include \"php_%s.h\"\n", module); - Printf(s_header, "#ifdef __cplusplus\n"); - Printf(s_header, "}\n"); - Printf(s_header, "#endif\n\n"); - - if (directorsEnabled()) { - // Insert director runtime - Swig_insert_file("director_common.swg", s_header); - Swig_insert_file("director.swg", s_header); - } - - /* Create the .h file too */ - filen = NewStringEmpty(); - Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); - f_h = NewFile(filen, "w", SWIG_output_files()); - if (!f_h) { - FileErrorDisplay(filen); - SWIG_exit(EXIT_FAILURE); - } - - Swig_banner(f_h); - - Printf(f_h, "\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); - Printf(f_h, "#define phpext_%s_ptr &%s_module_entry\n\n", module, module); - Printf(f_h, "#ifdef PHP_WIN32\n"); - Printf(f_h, "# define PHP_%s_API __declspec(dllexport)\n", cap_module); - Printf(f_h, "#else\n"); - Printf(f_h, "# define PHP_%s_API\n", cap_module); - Printf(f_h, "#endif\n\n"); - Printf(f_h, "#ifdef ZTS\n"); - Printf(f_h, "#include \"TSRM.h\"\n"); - Printf(f_h, "#endif\n\n"); - Printf(f_h, "PHP_MINIT_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_MSHUTDOWN_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_RINIT_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_RSHUTDOWN_FUNCTION(%s);\n", module); - Printf(f_h, "PHP_MINFO_FUNCTION(%s);\n\n", module); - - /* start the arginfo section */ - s_arginfo = NewString("/* arginfo subsection */\n"); - arginfo_used = NewHash(); - - /* start the function entry section */ - s_entry = NewString("/* entry subsection */\n"); - - /* holds all the per-class function entry sections */ - all_cs_entry = NewString("/* class entry subsection */\n"); - cs_entry = NULL; - - Printf(s_entry, "/* Every non-class user visible function must have an entry here */\n"); - Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); - - /* Emit all of the code */ - Language::top(n); - - SwigPHP_emit_resource_registrations(); - - /* start the init section */ - String * s_init_old = s_init; - s_init = NewString("/* init section */\n"); - Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n"); - Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n"); - Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n"); - Append(s_init, "#endif\n"); - Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL); - Printf(s_init, " STANDARD_MODULE_HEADER,\n"); - Printf(s_init, " (char*)\"%s\",\n", module); - Printf(s_init, " %s_functions,\n", module); - Printf(s_init, " PHP_MINIT(%s),\n", module); - Printf(s_init, " PHP_MSHUTDOWN(%s),\n", module); - Printf(s_init, " PHP_RINIT(%s),\n", module); - Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module); - Printf(s_init, " PHP_MINFO(%s),\n", module); - if (Len(pragma_version) > 0) { - Printf(s_init, " \"%s\",\n", pragma_version); - } else { - Printf(s_init, " NO_VERSION_YET,\n"); - } - Printf(s_init, " STANDARD_MODULE_PROPERTIES\n"); - Printf(s_init, "};\n"); - Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); - - Printf(s_init, "#ifdef __cplusplus\n"); - Printf(s_init, "extern \"C\" {\n"); - Printf(s_init, "#endif\n"); - // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE - // in PHP5 has "extern "C" { ... }" around it so we can't do that. - Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module); - Printf(s_init, "#ifdef __cplusplus\n"); - Printf(s_init, "}\n"); - 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 - */ - Printf(s_init, "#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module); - Printv(s_init, s_init_old, NIL); - Delete(s_init_old); - - // Printv(s_init,s_resourcetypes,NIL); - /* We need this after all classes written out by ::top */ - Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); - Printf(s_oinit, "/* end oinit subsection */\n"); - Printf(s_init, "%s\n", s_oinit); - - /* Constants generated during top call */ - Printf(s_cinit, "/* end cinit subsection */\n"); - Printf(s_init, "%s\n", s_cinit); - Clear(s_cinit); - Delete(s_cinit); - - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - // Now do REQUEST init which holds any user specified %rinit, and also vinit - Printf(s_init, "PHP_RINIT_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s\n", r_init); - - /* finish our init section which will have been used by class wrappers */ - Printf(s_vinit, "/* end vinit subsection */\n"); - Printf(s_init, "%s\n", s_vinit); - Clear(s_vinit); - Delete(s_vinit); - - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - Printv(s_init, "PHP_MSHUTDOWN_FUNCTION(", module, ")\n" - "{\n", - s_shutdown, - "#ifdef ZTS\n" - " ts_free_id(", module, "_globals_id);\n" - "#endif\n" - " return SUCCESS;\n" - "}\n\n", NIL); - - Printf(s_init, "PHP_RSHUTDOWN_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s\n", r_shutdown); - Printf(s_init, " return SUCCESS;\n"); - Printf(s_init, "}\n\n"); - - Printf(s_init, "PHP_MINFO_FUNCTION(%s)\n{\n", module); - Printf(s_init, "%s", pragma_phpinfo); - Printf(s_init, "}\n"); - Printf(s_init, "/* end init section */\n"); - - Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module); - - Delete(f_h); - - String *type_table = NewStringEmpty(); - SwigType_emit_type_table(f_runtime, type_table); - Printf(s_header, "%s", type_table); - Delete(type_table); - - /* Oh dear, more things being called in the wrong order. This whole - * function really needs totally redoing. - */ - - if (directorsEnabled()) { - Dump(f_directors_h, f_runtime_h); - Printf(f_runtime_h, "\n"); - Printf(f_runtime_h, "#endif\n"); - Delete(f_runtime_h); - } - - Printf(s_header, "/* end header section */\n"); - Printf(s_wrappers, "/* end wrapper section */\n"); - Printf(s_vdecl, "/* end vdecl subsection */\n"); - - Dump(f_runtime, f_begin); - Printv(f_begin, s_header, NIL); - if (directorsEnabled()) { - Dump(f_directors, f_begin); - } - Printv(f_begin, s_vdecl, s_wrappers, NIL); - Printv(f_begin, all_cs_entry, "\n\n", s_arginfo, "\n\n", s_entry, - " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n" - " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n" - " ZEND_FE_END\n};\n\n", NIL); - Printv(f_begin, s_init, NIL); - Delete(s_header); - Delete(s_wrappers); - Delete(s_init); - Delete(s_vdecl); - Delete(all_cs_entry); - Delete(s_entry); - Delete(s_arginfo); - Delete(f_runtime); - Delete(f_begin); - Delete(arginfo_used); - - Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); - if (s_fakeoowrappers) { - Printf(f_phpcode, "abstract class %s {", Len(prefix) ? prefix : module); - Printf(f_phpcode, "%s", s_fakeoowrappers); - Printf(f_phpcode, "}\n\n"); - Delete(s_fakeoowrappers); - s_fakeoowrappers = NULL; - } - Printf(f_phpcode, "%s\n?>\n", s_phpclasses); - Delete(f_phpcode); - - return SWIG_OK; - } - - /* Just need to append function names to function table to register with PHP. */ - void create_command(String *cname, String *iname, Node *n) { - // This is for the single main zend_function_entry record - Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); - - // We want to only emit each different arginfo once, as that reduces the - // size of both the generated source code and the compiled extension - // module. To do this, we name the arginfo to encode the number of - // parameters and which (if any) are passed by reference by using a - // sequence of 0s (for non-reference) and 1s (for by references). - ParmList *l = Getattr(n, "parms"); - String * arginfo_code = NewStringEmpty(); - for (Parm *p = l; p; p = Getattr(p, "tmap:in:next")) { - /* Ignored parameters */ - if (checkAttribute(p, "tmap:in:numinputs", "0")) { - continue; - } - Append(arginfo_code, GetFlag(p, "tmap:in:byref") ? "1" : "0"); - } - - if (!GetFlag(arginfo_used, arginfo_code)) { - // Not had this one before, so emit it. - SetFlag(arginfo_used, arginfo_code); - Printf(s_arginfo, "ZEND_BEGIN_ARG_INFO_EX(swig_arginfo_%s, 0, 0, 0)\n", arginfo_code); - for (const char * p = Char(arginfo_code); *p; ++p) { - Printf(s_arginfo, " ZEND_ARG_PASS_INFO(%c)\n", *p); - } - Printf(s_arginfo, "ZEND_END_ARG_INFO()\n"); - } - - String * s = cs_entry; - if (!s) s = s_entry; - Printf(s, " SWIG_ZEND_NAMED_FE(%(lower)s,%s,swig_arginfo_%s)\n", cname, iname, arginfo_code); - Delete(arginfo_code); - } - - /* ------------------------------------------------------------ - * dispatchFunction() - * ------------------------------------------------------------ */ - void dispatchFunction(Node *n) { - /* Last node in overloaded chain */ - - int maxargs; - String *tmp = NewStringEmpty(); - if (Swig_directorclass(n) && wrapperType == directorconstructor) { - /* We have an extra 'this' parameter. */ - SetFlag(n, "wrap:this"); - } - String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs); - - /* Generate a dispatch wrapper for all overloaded functions */ - - Wrapper *f = NewWrapper(); - String *symname = Getattr(n, "sym:name"); - String *wname = Swig_name_wrapper(symname); - - create_command(symname, wname, n); - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); - - Wrapper_add_local(f, "argc", "int argc"); - - Printf(tmp, "zval **argv[%d]", maxargs); - Wrapper_add_local(f, "argv", tmp); - - Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); - - Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); - - Replaceall(dispatch, "$args", "self,args"); - - Printv(f->code, dispatch, "\n", NIL); - - Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n"); - Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname); - Printv(f->code, "SWIG_FAIL(TSRMLS_C);\n", NIL); - - Printv(f->code, "}\n", NIL); - Wrapper_print(f, s_wrappers); - - DelWrapper(f); - Delete(dispatch); - Delete(tmp); - Delete(wname); - } - - /* ------------------------------------------------------------ - * functionWrapper() - * ------------------------------------------------------------ */ - - /* Helper method for PHP5::functionWrapper */ - bool is_class(SwigType *t) { - Node *n = classLookup(t); - if (n) { - String *r = Getattr(n, "php:proxy"); // Set by classDeclaration() - if (!r) - r = Getattr(n, "sym:name"); // Not seen by classDeclaration yet, but this is the name - if (r) - return true; - } - return false; - } - - virtual int functionWrapper(Node *n) { - String *name = GetChar(n, "name"); - String *iname = GetChar(n, "sym:name"); - SwigType *d = Getattr(n, "type"); - ParmList *l = Getattr(n, "parms"); - String *nodeType = Getattr(n, "nodeType"); - int newobject = GetFlag(n, "feature:new"); - int constructor = (Cmp(nodeType, "constructor") == 0); - - Parm *p; - int i; - int numopt; - String *tm; - Wrapper *f; - - String *wname; - int overloaded = 0; - String *overname = 0; - - if (Cmp(nodeType, "destructor") == 0) { - // We just generate the Zend List Destructor and let Zend manage the - // reference counting. There's no explicit destructor, but the user can - // just do `$obj = null;' to remove a reference to an object. - return CreateZendListDestructor(n); - } - // Test for overloading; - if (Getattr(n, "sym:overloaded")) { - overloaded = 1; - overname = Getattr(n, "sym:overname"); - } else { - if (!addSymbol(iname, n)) - return SWIG_ERROR; - } - - wname = Swig_name_wrapper(iname); - if (overname) { - Printf(wname, "%s", overname); - } - - f = NewWrapper(); - - String *outarg = NewStringEmpty(); - String *cleanup = NewStringEmpty(); - - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); - - emit_parameter_variables(l, f); - /* Attach standard typemaps */ - - emit_attach_parmmaps(l, f); - // Not issued for overloaded functions. - if (!overloaded) { - create_command(iname, wname, n); - } - - // wrap:parms is used by overload resolution. - Setattr(n, "wrap:parms", l); - - int num_arguments = emit_num_arguments(l); - int num_required = emit_num_required(l); - numopt = num_arguments - num_required; - - if (wrapperType == directorconstructor) - num_arguments++; - - if (num_arguments > 0) { - String *args = NewStringEmpty(); - if (wrapperType == directorconstructor) - Wrapper_add_local(f, "arg0", "zval *arg0"); - Printf(args, "zval **args[%d]", num_arguments); - Wrapper_add_local(f, "args", args); - Delete(args); - args = NULL; - } - - // This generated code may be called: - // 1) as an object method, or - // 2) as a class-method/function (without a "this_ptr") - // Option (1) has "this_ptr" for "this", option (2) needs it as - // first parameter - - // NOTE: possible we ignore this_ptr as a param for native constructor - - Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n"); - - 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) { - 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, "WRONG_PARAM_COUNT;\n}\n\n"); - } - if (wrapperType == directorconstructor) - Printf(f->code, "arg0 = *args[0];\n \n"); - - /* 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 - // reports. We can either take argbase into account when raising - // errors, or find a better way of dealing with _thisptr. - // I would like, if objects are wrapped, to assume _thisptr is always - // _this and not the first argument. - // This may mean looking at Language::memberfunctionHandler - - int limit = num_arguments; - if (wrapperType == directorconstructor) - limit--; - for (i = 0, p = l; i < limit; i++) { - String *source; - - /* Skip ignored arguments */ - //while (Getattr(p,"tmap:ignore")) { p = Getattr(p,"tmap:ignore:next");} - while (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - } - - SwigType *pt = Getattr(p, "type"); - - if (wrapperType == directorconstructor) { - source = NewStringf("args[%d]", i+1); - } else { - source = NewStringf("args[%d]", i); - } - - String *ln = Getattr(p, "lname"); - - /* Check if optional */ - if (i >= num_required) { - Printf(f->code, "\tif(arg_count > %d) {\n", i); - } - - if ((tm = Getattr(p, "tmap:in"))) { - Replaceall(tm, "$source", source); - Replaceall(tm, "$target", ln); - Replaceall(tm, "$input", source); - Setattr(p, "emit:input", source); - Printf(f->code, "%s\n", tm); - if (i == 0 && Getattr(p, "self")) { - Printf(f->code, "\tif(!arg1) SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");\n"); - } - p = Getattr(p, "tmap:in:next"); - if (i >= num_required) { - Printf(f->code, "}\n"); - } - continue; - } else { - Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); - } - if (i >= num_required) { - Printf(f->code, "\t}\n"); - } - Delete(source); - } - - if (is_member_director(n)) { - Wrapper_add_local(f, "upcall", "bool upcall = false"); - Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\" TSRMLS_CC);\n", - prefix, Swig_class_name(Swig_methodclass(n)), name); - } - - Swig_director_emit_dynamic_cast(n, f); - - /* Insert constraint checking code */ - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:check"))) { - Replaceall(tm, "$target", Getattr(p, "lname")); - Printv(f->code, tm, "\n", NIL); - p = Getattr(p, "tmap:check:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert cleanup code */ - for (i = 0, p = l; p; i++) { - if ((tm = Getattr(p, "tmap:freearg"))) { - Replaceall(tm, "$source", Getattr(p, "lname")); - Printv(cleanup, tm, "\n", NIL); - p = Getattr(p, "tmap:freearg:next"); - } else { - p = nextSibling(p); - } - } - - /* Insert argument output code */ - bool hasargout = false; - for (i = 0, p = l; p; i++) { - if ((tm = Getattr(p, "tmap:argout"))) { - hasargout = true; - Replaceall(tm, "$source", Getattr(p, "lname")); - // Replaceall(tm,"$input",Getattr(p,"lname")); - Replaceall(tm, "$target", "return_value"); - Replaceall(tm, "$result", "return_value"); - Replaceall(tm, "$arg", Getattr(p, "emit:input")); - Replaceall(tm, "$input", Getattr(p, "emit:input")); - Printv(outarg, tm, "\n", NIL); - p = Getattr(p, "tmap:argout:next"); - } else { - p = nextSibling(p); - } - } - - Setattr(n, "wrap:name", wname); - - /* emit function call */ - String *actioncode = emit_action(n); - - if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { - Replaceall(tm, "$input", Swig_cresult_name()); - Replaceall(tm, "$source", Swig_cresult_name()); - Replaceall(tm, "$target", "return_value"); - Replaceall(tm, "$result", "return_value"); - Replaceall(tm, "$owner", newobject ? "1" : "0"); - Printf(f->code, "%s\n", tm); - } 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); - } - emit_return_variable(n, d, f); - - if (outarg) { - Printv(f->code, outarg, NIL); - } - - if (cleanup) { - Printv(f->code, cleanup, NIL); - } - - /* Look to see if there is any newfree cleanup code */ - if (GetFlag(n, "feature:new")) { - if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) { - Printf(f->code, "%s\n", tm); - Delete(tm); - } - } - - /* See if there is any return cleanup code */ - if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) { - Printf(f->code, "%s\n", tm); - Delete(tm); - } - - Printf(f->code, "thrown:\n"); - Printf(f->code, "return;\n"); - - /* Error handling code */ - Printf(f->code, "fail:\n"); - Printv(f->code, cleanup, NIL); - Append(f->code, "SWIG_FAIL(TSRMLS_C);\n"); - - Printf(f->code, "}\n"); - - Replaceall(f->code, "$cleanup", cleanup); - Replaceall(f->code, "$symname", iname); - - Wrapper_print(f, s_wrappers); - DelWrapper(f); - f = NULL; - - if (overloaded && !Getattr(n, "sym:nextSibling")) { - dispatchFunction(n); - } - - Delete(wname); - wname = NULL; - - if (!shadow) { - return SWIG_OK; - } - - // Handle getters and setters. - if (wrapperType == membervar) { - const char *p = Char(iname); - if (strlen(p) > 4) { - p += strlen(p) - 4; - String *varname = Getattr(n, "membervariableHandler:sym:name"); - if (strcmp(p, "_get") == 0) { - Setattr(shadow_get_vars, varname, Getattr(n, "type")); - } else if (strcmp(p, "_set") == 0) { - Setattr(shadow_set_vars, varname, iname); - } - } - return SWIG_OK; - } - - // Only look at non-overloaded methods and the last entry in each overload - // chain (we check the last so that wrap:parms and wrap:name have been set - // for them all). - if (overloaded && Getattr(n, "sym:nextSibling") != 0) - return SWIG_OK; - - if (!s_oowrappers) - s_oowrappers = NewStringEmpty(); - - if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard || wrapperType == staticmembervar) { - bool handle_as_overload = false; - String **arg_names; - String **arg_values; - // Method or static method or plain function. - const char *methodname = 0; - String *output = s_oowrappers; - if (constructor) { - class_has_ctor = true; - // Skip the Foo:: prefix. - char *ptr = strrchr(GetChar(Swig_methodclass(n), "sym:name"), ':'); - if (ptr) { - ptr++; - } else { - ptr = GetChar(Swig_methodclass(n), "sym:name"); - } - if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) { - methodname = "__construct"; - } else { - // The class has multiple constructors and this one is - // renamed, so this will be a static factory function - methodname = GetChar(n, "constructorHandler:sym:name"); - } - } else if (wrapperType == memberfn) { - methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); - } else if (wrapperType == staticmemberfn) { - methodname = Char(Getattr(n, "staticmemberfunctionHandler:sym:name")); - } else if (wrapperType == staticmembervar) { - // Static member variable, wrapped as a function due to PHP limitations. - methodname = Char(Getattr(n, "staticmembervariableHandler:sym:name")); - } else { // wrapperType == standard - methodname = Char(iname); - if (!s_fakeoowrappers) - s_fakeoowrappers = NewStringEmpty(); - output = s_fakeoowrappers; - } - - bool really_overloaded = overloaded ? true : false; - int min_num_of_arguments = emit_num_required(l); - int max_num_of_arguments = emit_num_arguments(l); - - Hash *ret_types = NewHash(); - Setattr(ret_types, d, d); - - bool non_void_return = (Cmp(d, "void") != 0); - - if (overloaded) { - // Look at all the overloaded versions of this method in turn to - // decide if it's really an overloaded method, or just one where some - // parameters have default values. - Node *o = Getattr(n, "sym:overloaded"); - while (o) { - if (o == n) { - o = Getattr(o, "sym:nextSibling"); - continue; - } - - SwigType *d2 = Getattr(o, "type"); - if (!d2) { - assert(constructor); - } else if (!Getattr(ret_types, d2)) { - Setattr(ret_types, d2, d2); - non_void_return = non_void_return || (Cmp(d2, "void") != 0); - } - - ParmList *l2 = Getattr(o, "wrap:parms"); - int num_arguments = emit_num_arguments(l2); - int num_required = emit_num_required(l2); - if (num_required < min_num_of_arguments) - min_num_of_arguments = num_required; - - if (num_arguments > max_num_of_arguments) { - max_num_of_arguments = num_arguments; - } - o = Getattr(o, "sym:nextSibling"); - } - - o = Getattr(n, "sym:overloaded"); - while (o) { - if (o == n) { - o = Getattr(o, "sym:nextSibling"); - continue; - } - - ParmList *l2 = Getattr(o, "wrap:parms"); - Parm *p = l, *p2 = l2; - if (wrapperType == memberfn) { - p = nextSibling(p); - p2 = nextSibling(p2); - } - while (p && p2) { - if (Cmp(Getattr(p, "type"), Getattr(p2, "type")) != 0) - break; - if (Cmp(Getattr(p, "name"), Getattr(p2, "name")) != 0) - break; - String *value = Getattr(p, "value"); - String *value2 = Getattr(p2, "value"); - if (value && !value2) - break; - if (!value && value2) - break; - if (value) { - if (Cmp(value, value2) != 0) - break; - } - p = nextSibling(p); - p2 = nextSibling(p2); - } - if (p && p2) - break; - // One parameter list is a prefix of the other, so check that all - // remaining parameters of the longer list are optional. - if (p2) - p = p2; - while (p && Getattr(p, "value")) - p = nextSibling(p); - if (p) - break; - o = Getattr(o, "sym:nextSibling"); - } - if (!o) { - // This "overloaded method" is really just one with default args. - really_overloaded = false; - } - } - - if (wrapperType == memberfn) { - // Allow for the "this" pointer. - --min_num_of_arguments; - --max_num_of_arguments; - } - - arg_names = (String **) malloc(max_num_of_arguments * sizeof(String *)); - if (!arg_names) { - /* FIXME: How should this be handled? The rest of SWIG just seems - * to not bother checking for malloc failing! */ - fprintf(stderr, "Malloc failed!\n"); - exit(1); - } - for (i = 0; i < max_num_of_arguments; ++i) { - arg_names[i] = NULL; - } - - arg_values = (String **) malloc(max_num_of_arguments * sizeof(String *)); - if (!arg_values) { - /* FIXME: How should this be handled? The rest of SWIG just seems - * to not bother checking for malloc failing! */ - fprintf(stderr, "Malloc failed!\n"); - exit(1); - } - for (i = 0; i < max_num_of_arguments; ++i) { - arg_values[i] = NULL; - } - - Node *o; - if (overloaded) { - o = Getattr(n, "sym:overloaded"); - } else { - o = n; - } - while (o) { - int argno = 0; - Parm *p = Getattr(o, "wrap:parms"); - if (wrapperType == memberfn) - p = nextSibling(p); - while (p) { - if (GetInt(p, "tmap:in:numinputs") == 0) { - p = nextSibling(p); - continue; - } - assert(0 <= argno && argno < max_num_of_arguments); - String *&pname = arg_names[argno]; - const char *pname_cstr = GetChar(p, "name"); - // Just get rid of the C++ namespace part for now. - const char *ptr = NULL; - if (pname_cstr && (ptr = strrchr(pname_cstr, ':'))) { - pname_cstr = ptr + 1; - } - if (!pname_cstr) { - // Unnamed parameter, e.g. int foo(int); - } else if (!pname) { - pname = NewString(pname_cstr); - } else { - size_t len = strlen(pname_cstr); - size_t spc = 0; - size_t len_pname = strlen(Char(pname)); - while (spc + len <= len_pname) { - if (strncmp(pname_cstr, Char(pname) + spc, len) == 0) { - char ch = ((char *) Char(pname))[spc + len]; - if (ch == '\0' || ch == ' ') { - // Already have this pname_cstr. - pname_cstr = NULL; - break; - } - } - char *p = strchr(Char(pname) + spc, ' '); - if (!p) - break; - spc = (p + 4) - Char(pname); - } - if (pname_cstr) { - Printf(pname, " or_%s", pname_cstr); - } - } - String *value = NewString(Getattr(p, "value")); - if (Len(value)) { - /* Check that value is a valid constant in PHP (and adjust it if - * necessary, or replace it with "?" if it's just not valid). */ - SwigType *type = Getattr(p, "type"); - switch (SwigType_type(type)) { - case T_BOOL: { - if (Strcmp(value, "true") == 0 || Strcmp(value, "false") == 0) - break; - char *p; - errno = 0; - long n = strtol(Char(value), &p, 0); - Clear(value); - if (errno || *p) { - Append(value, "?"); - } else if (n) { - Append(value, "true"); - } else { - Append(value, "false"); - } - break; - } - case T_CHAR: - case T_SCHAR: - case T_SHORT: - case T_INT: - case T_LONG: - case T_LONGLONG: { - char *p; - errno = 0; - long n = strtol(Char(value), &p, 0); - (void) n; - if (errno || *p) { - Clear(value); - Append(value, "?"); - } - break; - } - case T_UCHAR: - case T_USHORT: - case T_UINT: - case T_ULONG: - case T_ULONGLONG: { - char *p; - errno = 0; - unsigned int n = strtoul(Char(value), &p, 0); - (void) n; - if (errno || *p) { - Clear(value); - Append(value, "?"); - } - break; - } - case T_FLOAT: - case T_DOUBLE: - case T_LONGDOUBLE: { - char *p; - errno = 0; - /* FIXME: strtod is locale dependent... */ - double val = strtod(Char(value), &p); - if (errno || *p) { - Clear(value); - Append(value, "?"); - } else if (strchr(Char(value), '.') == 0) { - // Ensure value is a double constant, not an integer one. - Append(value, ".0"); - double val2 = strtod(Char(value), &p); - if (errno || *p || val != val2) { - Clear(value); - Append(value, "?"); - } - } - break; - } - case T_STRING: - if (Len(value) < 2) { - // How can a string (including "" be less than 2 characters?) - Clear(value); - Append(value, "?"); - } else { - const char *v = Char(value); - if (v[0] != '"' || v[Len(value) - 1] != '"') { - Clear(value); - Append(value, "?"); - } - // Strings containing "$" require special handling, but we do - // that later. - } - break; - case T_VOID: - assert(false); - break; - case T_POINTER: { - const char *v = Char(value); - if (v[0] == '(') { - // Handle "(void*)0", "(TYPE*)0", "(char*)NULL", etc. - v += strcspn(v + 1, "*()") + 1; - if (*v == '*') { - do { - v++; - v += strspn(v, " \t"); - } while (*v == '*'); - if (*v++ == ')') { - v += strspn(v, " \t"); - String * old = value; - value = NewString(v); - Delete(old); - } - } - } - if (Strcmp(value, "NULL") == 0 || - Strcmp(value, "nullptr") == 0 || - Strcmp(value, "0") == 0 || - Strcmp(value, "0L") == 0) { - Clear(value); - Append(value, "null"); - } else { - Clear(value); - Append(value, "?"); - } - break; - } - default: - /* Safe default */ - Clear(value); - Append(value, "?"); - break; - } - - if (!arg_values[argno]) { - arg_values[argno] = value; - value = NULL; - } else if (Cmp(arg_values[argno], value) != 0) { - // If a parameter has two different default values in - // different overloaded forms of the function, we can't - // set its default in PHP. Flag this by setting its - // default to `?'. - Delete(arg_values[argno]); - arg_values[argno] = NewString("?"); - } - } else if (arg_values[argno]) { - // This argument already has a default value in another overloaded - // form, but doesn't in this form. So don't try to do anything - // clever, just let the C wrappers resolve the overload and set the - // default values. - // - // This handling is safe, but I'm wondering if it may be overly - // conservative (FIXME) in some cases. It seems it's only bad when - // there's an overloaded form with the appropriate number of - // parameters which doesn't want the default value, but I need to - // think about this more. - Delete(arg_values[argno]); - arg_values[argno] = NewString("?"); - } - Delete(value); - p = nextSibling(p); - ++argno; - } - if (!really_overloaded) - break; - o = Getattr(o, "sym:nextSibling"); - } - - /* Clean up any parameters which haven't yet got names, or whose - * names clash. */ - Hash *seen = NewHash(); - /* We need $this to refer to the current class, so can't allow it - * to be used as a parameter. */ - 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). Similarly we use $c for the classname or new - * stdClass object. - */ - Setattr(seen, "r", seen); - Setattr(seen, "c", seen); - - for (int argno = 0; argno < max_num_of_arguments; ++argno) { - String *&pname = arg_names[argno]; - if (pname) { - Replaceall(pname, " ", "_"); - } else { - /* We get here if the SWIG .i file has "int foo(int);" */ - pname = NewStringEmpty(); - Printf(pname, "arg%d", argno + 1); - } - // Check if we've already used this parameter name. - while (Getattr(seen, pname)) { - // Append "_" to clashing names until they stop clashing... - Printf(pname, "_"); - } - Setattr(seen, Char(pname), seen); - - if (arg_values[argno] && Cmp(arg_values[argno], "?") == 0) { - handle_as_overload = true; - } - } - Delete(seen); - seen = NULL; - - String *invoke = NewStringEmpty(); - String *prepare = NewStringEmpty(); - String *args = NewStringEmpty(); - - if (!handle_as_overload && !(really_overloaded && max_num_of_arguments > min_num_of_arguments)) { - Printf(invoke, "%s(", iname); - if (wrapperType == memberfn) { - Printf(invoke, "$this->%s", SWIG_PTR); - } - for (int i = 0; i < max_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - if (i || wrapperType == memberfn) - Printf(invoke, ","); - String *value = arg_values[i]; - if (value) { - const char *v = Char(value); - if (v[0] == '"') { - /* In a PHP double quoted string, $ needs to be escaped as \$. */ - Replaceall(value, "$", "\\$"); - } - Printf(args, "$%s=%s", arg_names[i], value); - } else { - Printf(args, "$%s", arg_names[i]); - } - Printf(invoke, "$%s", arg_names[i]); - } - Printf(invoke, ")"); - } else { - int i; - for (i = 0; i < min_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - Printf(args, "$%s", arg_names[i]); - } - String *invoke_args = NewStringEmpty(); - if (wrapperType == memberfn) { - Printf(invoke_args, "$this->%s", SWIG_PTR); - if (min_num_of_arguments > 0) - Printf(invoke_args, ","); - } - Printf(invoke_args, "%s", args); - bool had_a_case = false; - int last_handled_i = i - 1; - for (; i < max_num_of_arguments; ++i) { - if (i) - Printf(args, ","); - const char *value = Char(arg_values[i]); - // FIXME: (really_overloaded && handle_as_overload) is perhaps a - // little conservative, but it doesn't hit any cases that it - // shouldn't for Xapian at least (and we need it to handle - // "Enquire::get_mset()" correctly). - bool non_php_default = ((really_overloaded && handle_as_overload) || - !value || strcmp(value, "?") == 0); - if (non_php_default) - value = "null"; - Printf(args, "$%s=%s", arg_names[i], value); - if (non_php_default) { - if (!had_a_case) { - Printf(prepare, "\t\tswitch (func_num_args()) {\n"); - had_a_case = true; - } - Printf(prepare, "\t\t"); - while (last_handled_i < i) { - Printf(prepare, "case %d: ", ++last_handled_i); - } - if (non_void_return) { - if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) { - Append(prepare, "$r="); - } else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) { - Append(prepare, "$r="); - } else { - Printf(prepare, "$this->%s=", SWIG_PTR); - } - } - if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) { - Printf(prepare, "%s(%s); break;\n", iname, invoke_args); - } else if (!i) { - Printf(prepare, "%s($_this%s); break;\n", iname, invoke_args); - } else { - Printf(prepare, "%s($_this, %s); break;\n", iname, invoke_args); - } - } - if (i || wrapperType == memberfn) - Printf(invoke_args, ","); - Printf(invoke_args, "$%s", arg_names[i]); - } - Printf(prepare, "\t\t"); - if (had_a_case) - Printf(prepare, "default: "); - if (non_void_return) { - if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) { - Append(prepare, "$r="); - } else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) { - Append(prepare, "$r="); - } else { - Printf(prepare, "$this->%s=", SWIG_PTR); - } - } - - if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) { - Printf(prepare, "%s(%s);\n", iname, invoke_args); - } else { - Printf(prepare, "%s($_this, %s);\n", iname, invoke_args); - } - if (had_a_case) - Printf(prepare, "\t\t}\n"); - Delete(invoke_args); - Printf(invoke, "$r"); - } - - Printf(output, "\n"); - // If it's a member function or a class constructor... - if (wrapperType == memberfn || (constructor && current_class)) { - String *acc = NewString(Getattr(n, "access")); - // If a base has the same method with public access, then PHP - // requires to have it here as public as well - Node *bases = Getattr(Swig_methodclass(n), "bases"); - if (bases && Strcmp(acc, "public") != 0) { - String *warnmsg = 0; - int haspublicbase = 0; - Iterator i = First(bases); - while (i.item) { - Node *j = firstChild(i.item); - while (j) { - String *jname = Getattr(j, "name"); - if (!jname || Strcmp(jname, Getattr(n, "name")) != 0) { - j = nextSibling(j); - continue; - } - if (Strcmp(nodeType(j), "cdecl") == 0) { - if (!Getattr(j, "access") || checkAttribute(j, "access", "public")) { - haspublicbase = 1; - } - } else if (Strcmp(nodeType(j), "using") == 0 && firstChild(j) && Strcmp(nodeType(firstChild(j)), "cdecl") == 0) { - if (!Getattr(firstChild(j), "access") || checkAttribute(firstChild(j), "access", "public")) { - haspublicbase = 1; - } - } - if (haspublicbase) { - warnmsg = NewStringf("Modifying the access of '%s::%s' to public, as the base '%s' has it as public as well.\n", Getattr(current_class, "classtype"), Getattr(n, "name"), Getattr(i.item, "classtype")); - break; - } - j = nextSibling(j); - } - i = Next(i); - if (haspublicbase) { - break; - } - } - if (Getattr(n, "access") && haspublicbase) { - Delete(acc); - acc = NewStringEmpty(); // implicitly public - Swig_warning(WARN_PHP_PUBLIC_BASE, input_file, line_number, Char(warnmsg)); - Delete(warnmsg); - } - } - - if (Cmp(acc, "public") == 0) { - // The default visibility for methods is public, so don't specify - // that explicitly to keep the wrapper size down. - Delete(acc); - acc = NewStringEmpty(); - } else if (Cmp(acc, "") != 0) { - Append(acc, " "); - } - - if (constructor) { - const char * arg0; - if (max_num_of_arguments > 0) { - arg0 = Char(arg_names[0]); - } else { - arg0 = "res"; - Delete(args); - args = NewString("$res=null"); - } - String *mangled_type = SwigType_manglestr(Getattr(n, "type")); - Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); - Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%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, "\t%sfunction %s(%s) {\n", acc, methodname, args); - } - Delete(acc); - } else if (wrapperType == staticmembervar) { - // We're called twice for a writable static member variable - first - // with "foo_set" and then with "foo_get" - so generate half the - // wrapper function each time. - // - // For a const static member, we only get called once. - static bool started = false; - if (!started) { - Printf(output, "\tstatic function %s() {\n", methodname); - if (max_num_of_arguments) { - // Setter. - Printf(output, "\t\tif (func_num_args()) {\n"); - Printf(output, "\t\t\t%s(func_get_arg(0));\n", iname); - Printf(output, "\t\t\treturn;\n"); - Printf(output, "\t\t}\n"); - started = true; - goto done; - } - } - started = false; - } else { - Printf(output, "\tstatic function %s(%s) {\n", methodname, args); - } - - if (!constructor) - Printf(output, "%s", prepare); - if (constructor) { - if (!directorsEnabled() || !Swig_directorclass(n)) { - if (!Len(prepare)) { - if (strcmp(methodname, "__construct") == 0) { - Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); - } else { - String *classname = Swig_class_name(current_class); - Printf(output, "\t\treturn new %s%s(%s);\n", prefix, classname, invoke); - } - } - } else { - Node *parent = Swig_methodclass(n); - String *classname = Swig_class_name(parent); - Printf(output, "\t\tif (get_class($this) === '%s%s') {\n", prefix, classname); - Printf(output, "\t\t\t$_this = null;\n"); - Printf(output, "\t\t} else {\n"); - Printf(output, "\t\t\t$_this = $this;\n"); - Printf(output, "\t\t}\n"); - if (!Len(prepare)) { - if (num_arguments > 1) { - Printf(output, "\t\t$this->%s=%s($_this, %s);\n", SWIG_PTR, iname, args); - } else { - Printf(output, "\t\t$this->%s=%s($_this);\n", SWIG_PTR, iname); - } - } - } - Printf(output, "%s", prepare); - } else if (!non_void_return && !hasargout) { - if (Cmp(invoke, "$r") != 0) - Printf(output, "\t\t%s;\n", invoke); - } else if (is_class(d)) { - if (Cmp(invoke, "$r") != 0) - Printf(output, "\t\t$r=%s;\n", invoke); - if (Len(ret_types) == 1) { - /* If d is abstract we can't create a new wrapper type d. */ - Node *d_class = classLookup(d); - int is_abstract = 0; - if (Getattr(d_class, "abstracts")) { - is_abstract = 1; - } - if (newobject || !is_abstract) { - Printf(output, "\t\tif (is_resource($r)) {\n"); - if (Getattr(classLookup(Getattr(n, "type")), "module")) { - /* - * _p_Foo -> Foo, _p_ns__Bar -> Bar - * TODO: do this in a more elegant way - */ - if (Len(prefix) == 0) { - Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); - } else { - Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); - } - Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n"); - Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name")); - } else { - Printf(output, "\t\t\t$c = new stdClass();\n"); - Printf(output, "\t\t\t$c->" SWIG_PTR " = $r;\n"); - Printf(output, "\t\t\treturn $c;\n"); - } - Printf(output, "\t\t}\n\t\treturn $r;\n"); - } else { - Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); - Printf(output, "\t\treturn $this;\n"); - } - } else { - Printf(output, "\t\tif (!is_resource($r)) return $r;\n"); - String *wrapobj = NULL; - String *common = NULL; - Iterator i = First(ret_types); - while (i.item) { - SwigType *ret_type = i.item; - i = Next(i); - String *mangled = NewString("_p"); - Printf(mangled, "%s", SwigType_manglestr(ret_type)); - Node *class_node = Getattr(zend_types, mangled); - if (!class_node) { - /* This is needed when we're returning a pointer to a type - * rather than returning the type by value or reference. */ - Delete(mangled); - mangled = NewString(SwigType_manglestr(ret_type)); - class_node = Getattr(zend_types, mangled); - if (!class_node) { - // Return type isn't an object, so will be handled by the - // !is_resource() check before the switch. - continue; - } - } - const char *classname = GetChar(class_node, "sym:name"); - if (!classname) - classname = GetChar(class_node, "name"); - String * action = NewStringEmpty(); - if (classname) - Printf(action, "return new %s%s($r);\n", prefix, classname); - else - Printf(action, "return $r;\n"); - if (!wrapobj) { - wrapobj = NewString("\t\tswitch (get_resource_type($r)) {\n"); - common = action; - } else { - if (common && Cmp(common, action) != 0) { - Delete(common); - common = NULL; - } - } - Printf(wrapobj, "\t\t"); - if (i.item) { - Printf(wrapobj, "case '%s': ", mangled); - } else { - Printf(wrapobj, "default: "); - } - Printv(wrapobj, action, NIL); - if (action != common) Delete(action); - Delete(mangled); - } - Printf(wrapobj, "\t\t}\n"); - if (common) { - // All cases have the same action, so eliminate the switch - // wrapper. - Printf(output, "\t\t%s", common); - Delete(common); - } else { - Printv(output, wrapobj, NIL); - } - Delete(wrapobj); - } - } else { - if (non_void_return || hasargout) { - Printf(output, "\t\treturn %s;\n", invoke); - } else if (Cmp(invoke, "$r") != 0) { - Printf(output, "\t\t%s;\n", invoke); - } - } - Printf(output, "\t}\n"); - -done: - Delete(prepare); - Delete(invoke); - free(arg_values); - - Delete(args); - args = NULL; - - for (int i = 0; i < max_num_of_arguments; ++i) { - Delete(arg_names[i]); - } - free(arg_names); - arg_names = NULL; - } - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * globalvariableHandler() - * ------------------------------------------------------------ */ - - virtual int globalvariableHandler(Node *n) { - char *name = GetChar(n, "name"); - char *iname = GetChar(n, "sym:name"); - SwigType *t = Getattr(n, "type"); - String *tm; - - /* First do the wrappers such as name_set(), name_get() - * as provided by the baseclass's implementation of variableWrapper - */ - if (Language::globalvariableHandler(n) == SWIG_NOWRAP) { - return SWIG_NOWRAP; - } - - if (!addSymbol(iname, n)) - return SWIG_ERROR; - - /* First link C variables to PHP */ - - tm = Swig_typemap_lookup("varinit", n, name, 0); - if (tm) { - Replaceall(tm, "$target", name); - Printf(s_vinit, "%s\n", tm); - } else { - Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); - } - - /* Now generate PHP -> C sync blocks */ - /* - tm = Swig_typemap_lookup("varin", n, name, 0); - if(tm) { - Replaceall(tm, "$symname", iname); - Printf(f_c->code, "%s\n", tm); - } else { - Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); - } - */ - /* Now generate C -> PHP sync blocks */ - /* - if(!GetFlag(n,"feature:immutable")) { - - tm = Swig_typemap_lookup("varout", n, name, 0); - if(tm) { - Replaceall(tm, "$symname", iname); - Printf(f_php->code, "%s\n", tm); - } else { - Swig_error(input_file, line_number, "Unable to link with type %s\n", SwigType_str(t, 0)); - } - } - */ - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * constantWrapper() - * ------------------------------------------------------------ */ - - virtual int constantWrapper(Node *n) { - String *name = GetChar(n, "name"); - String *iname = GetChar(n, "sym:name"); - SwigType *type = Getattr(n, "type"); - String *rawval = Getattr(n, "rawval"); - String *value = rawval ? rawval : Getattr(n, "value"); - String *tm; - - if (!addSymbol(iname, n)) - return SWIG_ERROR; - - SwigType_remember(type); - - if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) { - Replaceall(tm, "$source", value); - Replaceall(tm, "$target", name); - Replaceall(tm, "$value", value); - Printf(s_cinit, "%s\n", tm); - } - - if (shadow) { - String *enumvalue = GetChar(n, "enumvalue"); - String *set_to = iname; - - if (!enumvalue) { - enumvalue = GetChar(n, "enumvalueex"); - } - - if (enumvalue && *Char(enumvalue)) { - // Check for a simple constant expression which is valid in PHP. - // If we find one, initialise the const member with it; otherwise - // we initialise it using the C/C++ wrapped constant. - const char *p; - for (p = Char(enumvalue); *p; ++p) { - if (!isdigit((unsigned char)*p) && !strchr(" +-", *p)) { - // FIXME: enhance to handle ` + 1' which is what - // we get for enums that don't have an explicit value set. - break; - } - } - if (!*p) - set_to = enumvalue; - } - - if (wrapping_member_constant) { - if (!s_oowrappers) - s_oowrappers = NewStringEmpty(); - Printf(s_oowrappers, "\n\tconst %s = %s;\n", wrapping_member_constant, set_to); - } else { - if (!s_fakeoowrappers) - s_fakeoowrappers = NewStringEmpty(); - Printf(s_fakeoowrappers, "\n\tconst %s = %s;\n", iname, set_to); - } - } - - return SWIG_OK; - } - - /* - * PHP5::pragma() - * - * Pragma directive. - * - * %pragma(php) code="String" # Includes a string in the .php file - * %pragma(php) include="file.php" # Includes a file in the .php file - */ - - virtual int pragmaDirective(Node *n) { - if (!ImportMode) { - String *lang = Getattr(n, "lang"); - String *type = Getattr(n, "name"); - String *value = Getattr(n, "value"); - - if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) { - if (Strcmp(type, "code") == 0) { - if (value) { - Printf(pragma_code, "%s\n", value); - } - } else if (Strcmp(type, "include") == 0) { - if (value) { - Printf(pragma_incl, "include '%s';\n", value); - } - } else if (Strcmp(type, "phpinfo") == 0) { - if (value) { - Printf(pragma_phpinfo, "%s\n", value); - } - } else if (Strcmp(type, "version") == 0) { - if (value) { - pragma_version = value; - } - } else { - Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); - } - } - } - return Language::pragmaDirective(n); - } - - /* ------------------------------------------------------------ - * classDeclaration() - * ------------------------------------------------------------ */ - - virtual int classDeclaration(Node *n) { - if (!Getattr(n, "feature:onlychildren")) { - String *symname = Getattr(n, "sym:name"); - Setattr(n, "php:proxy", symname); - } - - return Language::classDeclaration(n); - } - - /* ------------------------------------------------------------ - * classHandler() - * ------------------------------------------------------------ */ - - virtual int classHandler(Node *n) { - constructors = 0; - current_class = n; - - if (shadow) { - char *rename = GetChar(n, "sym:name"); - - if (!addSymbol(rename, n)) - return SWIG_ERROR; - shadow_classname = NewString(rename); - - 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_PHP_MULTIPLE_INHERITANCE, input_file, line_number, - "Warning for %s, base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); - base = Next(base); - } - } - } - } - - classnode = n; - Language::classHandler(n); - classnode = 0; - - if (shadow) { - List *baselist = Getattr(n, "bases"); - Iterator ki, base; - - if (baselist) { - base = First(baselist); - while (base.item && GetFlag(base.item, "feature:ignore")) { - base = Next(base); - } - } else { - base.item = NULL; - } - - if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) { - Printf(s_phpclasses, "abstract "); - } - - Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); - String *baseclass = NULL; - if (base.item && Getattr(base.item, "module")) { - baseclass = Getattr(base.item, "sym:name"); - if (!baseclass) - baseclass = Getattr(base.item, "name"); - Printf(s_phpclasses, "extends %s%s ", prefix, baseclass); - } else if (GetFlag(n, "feature:exceptionclass")) { - Append(s_phpclasses, "extends Exception "); - } - { - Node *node = NewHash(); - Setattr(node, "type", Getattr(n, "name")); - Setfile(node, Getfile(n)); - Setline(node, Getline(n)); - String * interfaces = Swig_typemap_lookup("phpinterfaces", node, "", 0); - if (interfaces) { - Printf(s_phpclasses, "implements %s ", interfaces); - } - Delete(node); - } - Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); - if (!baseclass) { - // Only store this in the base class (NB !baseclass means we *are* - // a base class...) - Printf(s_phpclasses, "\tprotected $%s=array();\n", SWIG_DATA); - } - - // Write property SET handlers - ki = First(shadow_set_vars); - if (ki.key) { - // This class has setters. - Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); - // FIXME: tune this threshold... - if (Len(shadow_set_vars) <= 2) { - // Not many setters, so avoid call_user_func. - for (; ki.key; ki = Next(ki)) { - DOH *key = ki.key; - String *iname = ki.item; - Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, iname, SWIG_PTR); - } - } else { - Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_set';\n", shadow_classname); - Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s,$value);\n", SWIG_PTR); - } - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - if (baseclass) { - Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); - } else { - Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - } else { - Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - if (baseclass) { - Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); - } else { - Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - } - - // Write property GET handlers - ki = First(shadow_get_vars); - if (ki.key) { - // This class has getters. - Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); - int non_class_getters = 0; - for (; ki.key; ki = Next(ki)) { - DOH *key = ki.key; - SwigType *d = ki.item; - if (!is_class(d)) { - ++non_class_getters; - continue; - } - Printv(s_phpclasses, "\t\tif ($var === '", key, "') return new ", prefix, Getattr(classLookup(d), "sym:name"), "(", shadow_classname, "_", key, "_get($this->", SWIG_PTR, "));\n", NIL); - } - // FIXME: tune this threshold... - if (non_class_getters <= 2) { - // Not many non-class getters, so avoid call_user_func. - for (ki = First(shadow_get_vars); non_class_getters && ki.key; ki = Next(ki)) { - DOH *key = ki.key; - SwigType *d = ki.item; - if (is_class(d)) continue; - Printv(s_phpclasses, "\t\tif ($var === '", key, "') return ", shadow_classname, "_", key, "_get($this->", SWIG_PTR, ");\n", NIL); - --non_class_getters; - } - } else { - Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); - Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); - } - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - if (baseclass) { - Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); - } else { - // Reading an unknown property name gives null in PHP. - Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - - /* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */ - /* __isset() should return true for read-only properties, so check for - * *_get() not *_set(). */ - Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); - Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_get')) return true;\n", shadow_classname); - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - if (baseclass) { - Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); - } else { - Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - } else { - Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - if (baseclass) { - Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); - } else { - Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - if (baseclass) { - Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); - } else { - Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); - } - Printf(s_phpclasses, "\t}\n"); - } - - if (!class_has_ctor) { - Printf(s_phpclasses, "\tfunction __construct($h) {\n"); - Printf(s_phpclasses, "\t\t$this->%s=$h;\n", SWIG_PTR); - Printf(s_phpclasses, "\t}\n"); - } - - if (s_oowrappers) { - Printf(s_phpclasses, "%s", s_oowrappers); - Delete(s_oowrappers); - s_oowrappers = NULL; - } - class_has_ctor = false; - - Printf(s_phpclasses, "}\n\n"); - - Delete(shadow_classname); - shadow_classname = NULL; - - Delete(shadow_set_vars); - shadow_set_vars = NULL; - Delete(shadow_get_vars); - shadow_get_vars = NULL; - } - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * memberfunctionHandler() - * ------------------------------------------------------------ */ - - virtual int memberfunctionHandler(Node *n) { - wrapperType = memberfn; - Language::memberfunctionHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * membervariableHandler() - * ------------------------------------------------------------ */ - - virtual int membervariableHandler(Node *n) { - wrapperType = membervar; - Language::membervariableHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * staticmembervariableHandler() - * ------------------------------------------------------------ */ - - virtual int staticmembervariableHandler(Node *n) { - wrapperType = staticmembervar; - Language::staticmembervariableHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * staticmemberfunctionHandler() - * ------------------------------------------------------------ */ - - virtual int staticmemberfunctionHandler(Node *n) { - wrapperType = staticmemberfn; - Language::staticmemberfunctionHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - int abstractConstructorHandler(Node *) { - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * constructorHandler() - * ------------------------------------------------------------ */ - - virtual int constructorHandler(Node *n) { - constructors++; - if (Swig_directorclass(n)) { - String *name = GetChar(Swig_methodclass(n), "name"); - String *ctype = GetChar(Swig_methodclass(n), "classtype"); - String *sname = GetChar(Swig_methodclass(n), "sym:name"); - String *args = NewStringEmpty(); - ParmList *p = Getattr(n, "parms"); - int i; - - for (i = 0; p; p = nextSibling(p), i++) { - if (i) { - Printf(args, ", "); - } - if (Strcmp(GetChar(p, "type"), SwigType_str(GetChar(p, "type"), 0))) { - SwigType *t = Getattr(p, "type"); - Printf(args, "%s", SwigType_rcaststr(t, 0)); - if (SwigType_isreference(t)) { - Append(args, "*"); - } - } - Printf(args, "arg%d", i+1); - } - - /* director ctor code is specific for each class */ - Delete(director_ctor_code); - director_ctor_code = NewStringEmpty(); - director_prot_ctor_code = NewStringEmpty(); - Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); - Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); - Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args); - Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args); - if (i) { - Insert(args, 0, ", "); - } - Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args); - Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0 TSRMLS_CC%s);\n}\n", Swig_cresult_name(), ctype, sname, args); - Delete(args); - - wrapperType = directorconstructor; - } else { - wrapperType = constructor; - } - Language::constructorHandler(n); - wrapperType = standard; - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * CreateZendListDestructor() - * ------------------------------------------------------------ */ - //virtual int destructorHandler(Node *n) { - //} - int CreateZendListDestructor(Node *n) { - String *name = GetChar(Swig_methodclass(n), "name"); - String *iname = GetChar(n, "sym:name"); - ParmList *l = Getattr(n, "parms"); - - String *destructorname = NewStringEmpty(); - Printf(destructorname, "_%s", Swig_name_wrapper(iname)); - Setattr(classnode, "destructor", destructorname); - - Wrapper *f = NewWrapper(); - Printf(f->def, "/* This function is designed to be called by the zend list destructors */\n"); - Printf(f->def, "/* to typecast and do the actual destruction */\n"); - Printf(f->def, "static void %s(zend_rsrc_list_entry *rsrc, const char *type_name TSRMLS_DC) {\n", destructorname); - - Wrapper_add_localv(f, "value", "swig_object_wrapper *value=(swig_object_wrapper *) rsrc->ptr", NIL); - Wrapper_add_localv(f, "ptr", "void *ptr=value->ptr", NIL); - Wrapper_add_localv(f, "newobject", "int newobject=value->newobject", NIL); - - emit_parameter_variables(l, f); - emit_attach_parmmaps(l, f); - - // Get type of first arg, thing to be destructed - // Skip ignored arguments - Parm *p = l; - //while (Getattr(p,"tmap:ignore")) {p = Getattr(p,"tmap:ignore:next");} - while (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - } - SwigType *pt = Getattr(p, "type"); - - Printf(f->code, " efree(value);\n"); - Printf(f->code, " if (! newobject) return; /* can't delete it! */\n"); - Printf(f->code, " arg1 = (%s)SWIG_ZTS_ConvertResourceData(ptr,type_name,SWIGTYPE%s TSRMLS_CC);\n", SwigType_lstr(pt, 0), SwigType_manglestr(pt)); - Printf(f->code, " if (! arg1) zend_error(E_ERROR, \"%s resource already free'd\");\n", Char(name)); - - Setattr(n, "wrap:name", destructorname); - - String *actioncode = emit_action(n); - Append(f->code, actioncode); - Delete(actioncode); - - Printf(f->code, "thrown:\n"); - Append(f->code, "return;\n"); - Append(f->code, "fail:\n"); - Append(f->code, "SWIG_FAIL(TSRMLS_C);\n"); - Printf(f->code, "}\n"); - - Wrapper_print(f, s_wrappers); - DelWrapper(f); - - return SWIG_OK; - } - - /* ------------------------------------------------------------ - * memberconstantHandler() - * ------------------------------------------------------------ */ - - virtual int memberconstantHandler(Node *n) { - wrapping_member_constant = Getattr(n, "sym:name"); - Language::memberconstantHandler(n); - wrapping_member_constant = NULL; - return SWIG_OK; - } - - int classDirectorInit(Node *n) { - String *declaration = Swig_director_declaration(n); - Printf(f_directors_h, "%s\n", declaration); - Printf(f_directors_h, "public:\n"); - Delete(declaration); - return Language::classDirectorInit(n); - } - - int classDirectorEnd(Node *n) { - Printf(f_directors_h, "};\n"); - return Language::classDirectorEnd(n); - } - - int classDirectorConstructor(Node *n) { - Node *parent = Getattr(n, "parentNode"); - String *decl = Getattr(n, "decl"); - String *supername = Swig_class_name(parent); - String *classname = NewStringEmpty(); - Printf(classname, "SwigDirector_%s", supername); - - /* insert self parameter */ - Parm *p; - ParmList *superparms = Getattr(n, "parms"); - ParmList *parms = CopyParmList(superparms); - String *type = NewString("zval"); - SwigType_add_pointer(type); - p = NewParm(type, NewString("self"), n); - set_nextSibling(p, parms); - parms = p; - - if (!Getattr(n, "defaultargs")) { - // There should always be a "self" parameter first. - assert(ParmList_len(parms) > 0); - - /* constructor */ - { - Wrapper *w = NewWrapper(); - String *call; - String *basetype = Getattr(parent, "classtype"); - - // We put TSRMLS_DC after the self parameter in order to cope with - // any default parameters. - String *target = Swig_method_decl(0, decl, classname, parms, 0); - const char * p = Char(target); - const char * comma = strchr(p, ','); - int ins = comma ? (int)(comma - p) : Len(target) - 1; - Insert(target, ins, " TSRMLS_DC"); - - call = Swig_csuperclass_call(0, basetype, superparms); - Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call); - Append(w->def, "}"); - Delete(target); - Wrapper_print(w, f_directors); - Delete(call); - DelWrapper(w); - } - - /* constructor header */ - { - // We put TSRMLS_DC after the self parameter in order to cope with - // any default parameters. - String *target = Swig_method_decl(0, decl, classname, parms, 1); - const char * p = Char(target); - const char * comma = strchr(p, ','); - int ins = comma ? (int)(comma - p) : Len(target) - 1; - Insert(target, ins, " TSRMLS_DC"); - - Printf(f_directors_h, " %s;\n", target); - Delete(target); - } - } - return Language::classDirectorConstructor(n); - } - - int classDirectorMethod(Node *n, Node *parent, String *super) { - int is_void = 0; - int is_pointer = 0; - String *decl = Getattr(n, "decl"); - String *returntype = Getattr(n, "type"); - String *name = Getattr(n, "name"); - String *classname = Getattr(parent, "sym:name"); - String *c_classname = Getattr(parent, "name"); - String *symname = Getattr(n, "sym:name"); - String *declaration = NewStringEmpty(); - ParmList *l = Getattr(n, "parms"); - Wrapper *w = NewWrapper(); - String *tm; - String *wrap_args = NewStringEmpty(); - String *value = Getattr(n, "value"); - String *storage = Getattr(n, "storage"); - bool pure_virtual = false; - int status = SWIG_OK; - int idx; - bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; - - if (Cmp(storage, "virtual") == 0) { - if (Cmp(value, "0") == 0) { - pure_virtual = true; - } - } - - /* determine if the method returns a pointer */ - is_pointer = SwigType_ispointer_return(decl); - is_void = (Cmp(returntype, "void") == 0 && !is_pointer); - - /* virtual method definition */ - String *target; - String *pclassname = NewStringf("SwigDirector_%s", classname); - String *qualified_name = NewStringf("%s::%s", pclassname, name); - SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0); - Printf(w->def, "%s", target); - Delete(qualified_name); - Delete(target); - /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 1); - Printf(declaration, " virtual %s", target); - Delete(target); - - // Get any exception classes in the throws typemap - if (Getattr(n, "noexcept")) { - Append(w->def, " noexcept"); - Append(declaration, " noexcept"); - } - ParmList *throw_parm_list = 0; - - if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { - Parm *p; - int gencomma = 0; - - Append(w->def, " throw("); - Append(declaration, " throw("); - - if (throw_parm_list) - Swig_typemap_attach_parms("throws", throw_parm_list, 0); - for (p = throw_parm_list; p; p = nextSibling(p)) { - if (Getattr(p, "tmap:throws")) { - if (gencomma++) { - Append(w->def, ", "); - Append(declaration, ", "); - } - String *str = SwigType_str(Getattr(p, "type"), 0); - Append(w->def, str); - Append(declaration, str); - Delete(str); - } - } - - Append(w->def, ")"); - Append(declaration, ")"); - } - - Append(w->def, " {"); - Append(declaration, ";\n"); - - Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n"); - - /* declare method return value - * if the return value is a reference or const reference, a specialized typemap must - * handle it, including declaration of c_result ($result). - */ - if (!is_void && (!ignored_method || pure_virtual)) { - if (!SwigType_isclass(returntype)) { - if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) { - String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0)); - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL); - Delete(construct_result); - } else { - Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL); - } - } else { - String *cres = SwigType_lstr(returntype, "c_result"); - Printf(w->code, "%s;\n", cres); - Delete(cres); - } - } - - if (ignored_method) { - if (!pure_virtual) { - if (!is_void) - Printf(w->code, "return "); - String *super_call = Swig_method_call(super, l); - Printf(w->code, "%s;\n", super_call); - Delete(super_call); - } else { - Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname), - SwigType_namestr(name)); - } - } else { - /* attach typemaps to arguments (C/C++ -> PHP) */ - String *parse_args = NewStringEmpty(); - - Swig_director_parms_fixup(l); - - /* remove the wrapper 'w' since it was producing spurious temps */ - Swig_typemap_attach_parms("in", l, 0); - Swig_typemap_attach_parms("directorin", l, w); - Swig_typemap_attach_parms("directorargout", l, w); - - Parm *p; - char source[256]; - - int outputs = 0; - if (!is_void) - outputs++; - - /* build argument list and type conversion string */ - idx = 0; - p = l; - while (p) { - if (checkAttribute(p, "tmap:in:numinputs", "0")) { - p = Getattr(p, "tmap:in:next"); - continue; - } - - if (Getattr(p, "tmap:directorargout") != 0) - outputs++; - - String *pname = Getattr(p, "name"); - String *ptype = Getattr(p, "type"); - - if ((tm = Getattr(p, "tmap:directorin")) != 0) { - String *parse = Getattr(p, "tmap:directorin:parse"); - if (!parse) { - sprintf(source, "obj%d", idx++); - String *input = NewStringf("&%s", source); - Setattr(p, "emit:directorinput", input); - Replaceall(tm, "$input", input); - Delete(input); - Replaceall(tm, "$owner", "0"); - Printv(wrap_args, "zval ", source, ";\n", NIL); - Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source); - Printv(wrap_args, "INIT_ZVAL(", source, ");\n", NIL); - - Printv(wrap_args, tm, "\n", NIL); - Putc('O', parse_args); - } else { - Append(parse_args, parse); - Setattr(p, "emit:directorinput", pname); - Replaceall(tm, "$input", pname); - Replaceall(tm, "$owner", "0"); - if (Len(tm) == 0) - Append(tm, pname); - } - p = Getattr(p, "tmap:directorin:next"); - continue; - } else if (Cmp(ptype, "void")) { - Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, - "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), - SwigType_namestr(c_classname), SwigType_namestr(name)); - status = SWIG_NOWRAP; - break; - } - p = nextSibling(p); - } - - /* exception handling */ - bool error_used_in_typemap = false; - tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); - if (!tm) { - tm = Getattr(n, "feature:director:except"); - if (tm) - tm = Copy(tm); - } - if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { - if (Replaceall(tm, "$error", "error")) { - /* Only declare error if it is used by the typemap. */ - error_used_in_typemap = true; - Append(w->code, "int error;\n"); - } - } else { - Delete(tm); - tm = NULL; - } - - if (!idx) { - Printf(w->code, "zval **args = NULL;\n"); - } else { - Printf(w->code, "zval *args[%d];\n", idx); - } - Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name()); - Append(w->code, "if (!swig_self) {\n"); - Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); - Append(w->code, "}\n\n"); - Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name()); - const char * funcname = GetChar(n, "sym:name"); - Printf(w->code, "ZVAL_STRINGL(&funcname, (char *)\"%s\", %d, 0);\n", funcname, strlen(funcname)); - - /* wrap complex arguments to zvals */ - Printv(w->code, wrap_args, NIL); - - if (error_used_in_typemap) { - Append(w->code, "error = "); - } - Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,"); - Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx); - - if (tm) { - Printv(w->code, Str(tm), "\n", NIL); - Delete(tm); - } - - /* marshal return value from PHP to C/C++ type */ - - String *cleanup = NewStringEmpty(); - String *outarg = NewStringEmpty(); - - idx = 0; - - /* marshal return value */ - if (!is_void) { - tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w); - if (tm != 0) { - Replaceall(tm, "$input", Swig_cresult_name()); - char temp[24]; - sprintf(temp, "%d", idx); - Replaceall(tm, "$argnum", temp); - - /* TODO check this */ - if (Getattr(n, "wrap:disown")) { - Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); - } else { - Replaceall(tm, "$disown", "0"); - } - Replaceall(tm, "$result", "c_result"); - Printv(w->code, tm, "\n", NIL); - Delete(tm); - } else { - Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, - "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname), - SwigType_namestr(name)); - status = SWIG_ERROR; - } - } - - /* marshal outputs */ - for (p = l; p;) { - if ((tm = Getattr(p, "tmap:directorargout")) != 0) { - Replaceall(tm, "$result", Swig_cresult_name()); - Replaceall(tm, "$input", Getattr(p, "emit:directorinput")); - Printv(w->code, tm, "\n", NIL); - p = Getattr(p, "tmap:directorargout:next"); - } else { - p = nextSibling(p); - } - } - - Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name()); - - Delete(parse_args); - Delete(cleanup); - Delete(outarg); - } - - Append(w->code, "thrown:\n"); - if (!is_void) { - if (!(ignored_method && !pure_virtual)) { - String *rettype = SwigType_str(returntype, 0); - if (!SwigType_isreference(returntype)) { - Printf(w->code, "return (%s) c_result;\n", rettype); - } else { - Printf(w->code, "return (%s) *c_result;\n", rettype); - } - Delete(rettype); - } - } else { - Append(w->code, "return;\n"); - } - - Append(w->code, "fail:\n"); - Append(w->code, "SWIG_FAIL(TSRMLS_C);\n"); - Append(w->code, "}\n"); - - // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method - String *inline_extra_method = NewStringEmpty(); - if (dirprot_mode() && !is_public(n) && !pure_virtual) { - Printv(inline_extra_method, declaration, NIL); - String *extra_method_name = NewStringf("%sSwigPublic", name); - Replaceall(inline_extra_method, name, extra_method_name); - Replaceall(inline_extra_method, ";\n", " {\n "); - if (!is_void) - Printf(inline_extra_method, "return "); - String *methodcall = Swig_method_call(super, l); - Printv(inline_extra_method, methodcall, ";\n }\n", NIL); - Delete(methodcall); - Delete(extra_method_name); - } - - /* emit the director method */ - if (status == SWIG_OK) { - if (!Getattr(n, "defaultargs")) { - Replaceall(w->code, "$symname", symname); - Wrapper_print(w, f_directors); - Printv(f_directors_h, declaration, NIL); - Printv(f_directors_h, inline_extra_method, NIL); - } - } - - /* clean up */ - Delete(wrap_args); - Delete(pclassname); - DelWrapper(w); - return status; - } - - int classDirectorDisown(Node *) { - return SWIG_OK; - } -}; /* class PHP */ - -static PHP5 *maininstance = 0; - -// We use this function to be able to write out zend_register_list_destructor_ex -// lines for most things in the type table -// NOTE: it's a function NOT A PHP5::METHOD -extern "C" { -static void typetrace(const SwigType *ty, String *mangled, String *clientdata) { - Node *class_node; - if (!zend_types) { - zend_types = NewHash(); - } - // we want to know if the type which reduced to this has a constructor - if ((class_node = maininstance->classLookup(ty))) { - if (!Getattr(zend_types, mangled)) { - // OK it may have been set before by a different SwigType but it would - // have had the same underlying class node I think - // - it is certainly required not to have different originating class - // nodes for the same SwigType - Setattr(zend_types, mangled, class_node); - } - } else { // a non-class pointer - Setattr(zend_types, mangled, NOTCLASS); - } - if (r_prevtracefunc) - (*r_prevtracefunc) (ty, mangled, (String *) clientdata); -} -} - -/* ----------------------------------------------------------------------------- - * new_swig_php5() - Instantiate module - * ----------------------------------------------------------------------------- */ - -static Language *new_swig_php5() { - maininstance = new PHP5; - if (!r_prevtracefunc) { - r_prevtracefunc = SwigType_remember_trace(typetrace); - } else { - Printf(stderr, "php Typetrace vector already saved!\n"); - assert(0); - } - 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. -} - -extern "C" Language *swig_php5(void) { - return new_swig_php5(); -} diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index f72525b6f..0f5f07b4e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -84,9 +84,9 @@ static swig_module modules[] = { {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, - {"-php", swig_php5, 0}, + {"-php", swig_php, 0}, {"-php4", swig_php4, 0}, - {"-php5", swig_php5, "PHP5"}, + {"-php5", swig_php5, 0}, {"-php7", swig_php, "PHP7"}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, diff --git a/Tools/testflags.py b/Tools/testflags.py index 564bc91e6..981e8d59a 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -15,7 +15,6 @@ def get_cflags(language, std, compiler): "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, - "php5":"-Werror " + c_common, "python":"-Werror " + c_common, "r":"-Werror " + c_common, "ruby":"-Werror " + c_common, @@ -45,7 +44,6 @@ def get_cxxflags(language, std, compiler): "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, - "php5":"-Werror " + cxx_common, "python":"-Werror " + cxx_common, "r":"-Werror " + cxx_common, "ruby":"-Werror " + cxx_common, diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index d63b7c31a..5e20558f5 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -84,9 +84,6 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install liboctave${VER}-dev fi ;; - "php5") - travis_retry sudo apt-get -qq install php5-cli php5-dev - ;; "php") travis_retry sudo add-apt-repository -y ppa:ondrej/php travis_retry sudo apt-get -qq update diff --git a/configure.ac b/configure.ac index c23a82392..12f1c1591 100644 --- a/configure.ac +++ b/configure.ac @@ -384,9 +384,6 @@ case $host in *) PHP_SO=$SO;; esac -AC_SUBST(PHP5_SO) -PHP5_SO=$PHP_SO - AC_SUBST(MZSCHEME_SO) case $host in *) MZSCHEME_SO=.so;; @@ -1943,55 +1940,6 @@ AC_SUBST(RUBYCCDLFLAGS) AC_SUBST(RUBYSO) AC_SUBST(RUBYDYNAMICLINKING) -#------------------------------------------------------------------------- -# Look for PHP5 -#------------------------------------------------------------------------- - -PHP5BIN= - -AC_ARG_WITH(php5, AS_HELP_STRING([--without-php5], [Disable PHP5]) -AS_HELP_STRING([--with-php5=path], [Set location of PHP5 executable]),[ PHP5BIN="$withval"], [PHP5BIN="$alllang_default"]) - -# First, check for "--without-php5" or "--with-php5=no". -if test x"${PHP5BIN}" = xno; then - AC_MSG_NOTICE([Disabling PHP5]) - PHP5= -else - if test "x$PHP5BIN" = xyes; then - AC_CHECK_PROGS(PHP5, [php5 php]) - else - PHP5=$PHP5BIN - fi - - if test -n "$PHP5"; then - AC_MSG_CHECKING(for PHP5 header files) - dnl /usr/bin/php5 -> /usr/bin/php-config5 - case $PHP5 in - *5) - PHP5CONFIG=`echo "$PHP5"|sed 's/5$/-config5/'` ;; - *) - PHP5CONFIG=$PHP5-config ;; - esac - php5_version=`$PHP5CONFIG --version 2>/dev/null` - case $php5_version in - 5*) - PHP5INC=`$PHP5CONFIG --includes 2>/dev/null` - if test -n "$PHP5INC"; then - AC_MSG_RESULT($PHP5INC) - else - AC_MSG_RESULT(not found) - fi - ;; - "") - AC_MSG_RESULT([could not find $PHP5CONFIG or obtain PHP5 version from it]) ;; - *) - AC_MSG_RESULT([found PHP $php_version - not PHP 5]) ;; - esac - fi -fi -AC_SUBST(PHP5) -AC_SUBST(PHP5INC) - #------------------------------------------------------------------------- # Look for PHP7 #------------------------------------------------------------------------- @@ -2862,13 +2810,6 @@ fi AC_SUBST(SKIP_PHP) -SKIP_PHP5= -if test -z "$PHP5" || test -z "$PHP5INC" ; then - SKIP_PHP5="1" -fi -AC_SUBST(SKIP_PHP5) - - SKIP_OCAML= if test -z "$OCAMLC" ; then SKIP_OCAML="1" @@ -3058,7 +2999,6 @@ AC_CONFIG_FILES([ Examples/test-suite/octave/Makefile Examples/test-suite/perl5/Makefile Examples/test-suite/php/Makefile - Examples/test-suite/php5/Makefile Examples/test-suite/pike/Makefile Examples/test-suite/python/Makefile Examples/test-suite/ruby/Makefile @@ -3133,7 +3073,6 @@ test -n "$SKIP_OCAML" || langs="${langs}ocaml " test -n "$SKIP_OCTAVE" || langs="${langs}octave " test -n "$SKIP_PERL5" || langs="${langs}perl5 " test -n "$SKIP_PHP" || langs="${langs}php " -test -n "$SKIP_PHP5" || langs="${langs}php5 " test -n "$SKIP_PIKE" || langs="${langs}pike " test -n "$SKIP_PYTHON" || langs="${langs}python " test -n "$SKIP_R" || langs="${langs}r " From d7ac8581b1caf4475d1503ed9fc10b105c1f8247 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 7 Jun 2018 18:09:14 +1200 Subject: [PATCH 0983/2031] [php] Drop support for long-deprecated %pragma(php4) Finally removed support for %pragma(php4) which was deprecated back in 2008. The replacement is %pragma(php), which has been supported since at least 2005. --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 3a0e5c079..7dbb8cd58 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-07: olly + [PHP] We've finally removed support for %pragma(php4) which was + deprecated back in 2008. Use %pragma(php) instead, which has been + supported since at least 2005. + 2018-06-07: olly [PHP5] Support for PHP5 has been removed. PHP5 is no longer actively supported by the PHP developers and security support for diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c324e0c82..2b89223fa 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1996,7 +1996,7 @@ done: String *type = Getattr(n, "name"); String *value = Getattr(n, "value"); - if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) { + if (Strcmp(lang, "php") == 0) { if (Strcmp(type, "code") == 0) { if (value) { Printf(pragma_code, "%s\n", value); From ac80a0ed265984492918f9ea4c89c87264028498 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 7 Jun 2018 07:42:08 +0100 Subject: [PATCH 0984/2031] Add changes entry for Doxygen support --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2e1934cce..3a3487e15 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-07: cmfoil, kabbi, Jamie Kirkpatrick, markok314, vadz, wsfulton, Yann Diorcet + #170 Doxygen documentation support added. This allows translation of Doxygen comments + into JavaDoc and PyDoc documentation. It is enabled via the -doxygen command line + option. See the Doxygen.html chapter in the documentation for further information. + 2018-05-15: kwwette [Octave] add support for version 4.4 - Should not introduce any user-visible incompatibilities From 6c0045b3fc69c51ed80c04c7cc795ecda159db09 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 7 Jun 2018 08:16:36 +0100 Subject: [PATCH 0985/2031] HTML chapter numbering updates --- Doc/Manual/Contents.html | 5 +++-- Doc/Manual/Scilab.html | 2 +- Doc/Manual/Warnings.html | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ef99ae55b..6a29394fc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -654,7 +654,8 @@
  • Preprocessor (200-299)
  • C/C++ Parser (300-399)
  • Types and typemaps (400-499) -
  • Code generation (500-599) +
  • Code generation (500-559) +
  • Doxygen comments (560-599)
  • Language module specific (700-899)
  • User defined (900-999) @@ -1897,7 +1898,7 @@
  • Pointers
  • Structures diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 19c196541..3ea21a753 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -39,7 +39,7 @@
  • Pointers
  • Structures diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 853ab691e..140090140 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -25,7 +25,8 @@
  • Preprocessor (200-299)
  • C/C++ Parser (300-399)
  • Types and typemaps (400-499) -
  • Code generation (500-599) +
  • Code generation (500-559) +
  • Doxygen comments (560-599)
  • Language module specific (700-899)
  • User defined (900-999) @@ -535,7 +536,8 @@ example.i(4) : Syntax error in input(1).
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'. -

    Doxygen comments (560-599)

    +

    17.9.6 Doxygen comments (560-599)

    +
    • 560: Unknown Doxygen command: command.
    • @@ -545,7 +547,7 @@ example.i(4) : Syntax error in input(1).
    • 564: Error parsing Doxygen command command: error text. Command ignored."
    -

    17.9.6 Language module specific (700-899)

    +

    17.9.7 Language module specific (700-899)

      @@ -596,7 +598,7 @@ example.i(4) : Syntax error in input(1).
    • 871. Unrecognized pragma pragma. (Php).
    -

    17.9.7 User defined (900-999)

    +

    17.9.8 User defined (900-999)

    From b189fb945689544d7cd5e400dc27a787f7799a30 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 7 Jun 2018 18:52:25 +0100 Subject: [PATCH 0986/2031] Fix missing return value in doxygen test --- Doc/Manual/Doxygen.html | 2 +- Examples/test-suite/doxygen_ignore.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 842f146d8..1e9bbb977 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -281,7 +281,7 @@ For example, you could use @transferfull Command ignored, but anything here is still included. */ -int * Fantastic() { } +int * Fantastic();

    diff --git a/Examples/test-suite/doxygen_ignore.i b/Examples/test-suite/doxygen_ignore.i index ce83470b6..8e5449f43 100644 --- a/Examples/test-suite/doxygen_ignore.i +++ b/Examples/test-suite/doxygen_ignore.i @@ -36,6 +36,6 @@ @compileroptions This function must be compiled with /EHa when using MSVC. */ -int * func() { } +int * func() { return 0; } %} From c9d2275a0c5a8c149e000b61bdb363e7074218fe Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 16:47:23 +1200 Subject: [PATCH 0987/2031] Remove lingering trace of support for Python 1.x --- Lib/python/pyrun.swg | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 430d3af18..6dcf2599a 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1538,36 +1538,6 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { return (swig_module_info *) type_pointer; } -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - SWIGRUNTIME void #ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) From 7c034ead322faa79ad7b94fe72250ce8a4fd5848 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 15:52:46 +1200 Subject: [PATCH 0988/2031] Remove special handling for Python < 2.6 See #701. --- Doc/Manual/Python.html | 72 ++----- .../python/li_std_containers_int_runme.py | 13 +- .../python/python_strict_unicode_runme.py | 12 +- Lib/python/builtin.swg | 20 -- Lib/python/pyhead.swg | 130 +----------- Lib/python/pyinit.swg | 12 -- Lib/python/pyrun.swg | 193 +++--------------- Lib/python/pythreads.swg | 4 +- Source/Modules/python.cxx | 54 +---- 9 files changed, 56 insertions(+), 454 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 77ac538b0..881ba275b 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -150,9 +150,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 (Python 2.6 and later, including Python 3). +If you still need to generate bindings which work with older versions of +Python, you'll have to use SWIG 3.0.x.

    @@ -860,8 +860,8 @@ installation under "Additional include directories".

  • Finally, select the settings for the entire project and go to "Link Options". Add the Python library file to your link libraries. -For example "python21.lib". Also, set the name of the output file to -match the name of your Python module, ie. _example.pyd - Note that _example.dll also worked with Python-2.4 and earlier. +For example "python27.lib". Also, set the name of the output file to +match the name of your Python module, i.e. _example.pyd
  • Build your project. @@ -2290,13 +2290,6 @@ please refer to the python documentation:

    Use of the -builtin option implies a couple of limitations:

      -
    • python version support:

      -
        -
      • Versions 2.5 and up are fully supported
      • -
      • Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
      • -
      • Versions older than 2.3 are not supported.
      • -
      -
    • Some legacy syntax is no longer supported; in particular:

      • The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
      • @@ -2808,43 +2801,6 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

        -

        38.4.4 Python 2.2 and classic classes

        - - -

        -SWIG makes every attempt to preserve backwards compatibility with -older versions of Python to the extent that it is possible. However, -in Python-2.2, an entirely new type of class system was introduced. -This new-style class system offers many enhancements including static -member functions, properties (managed attributes), and class methods. -Details about all of these changes can be found on www.python.org and is not repeated here. -

        - -

        -To address differences between Python versions, SWIG currently emits -dual-mode proxy class wrappers. In Python-2.2 and newer releases, -these wrappers encapsulate C++ objects in new-style classes that take -advantage of new features (static methods and properties). However, -if these very same wrappers are imported into an older version of Python, -old-style classes are used instead. -

        - -

        -This dual-nature of the wrapper code means that you can create extension -modules with SWIG and those modules will work with all versions of Python -ranging from Python-2.0 to the very latest release. Moreover, the wrappers take -advantage of Python-2.2 features when available. -

        - -

        -For the most part, the interface presented to users is the same regardless -of what version of Python is used. The only incompatibility lies in the handling -of static member functions. In Python-2.2, they can be accessed via the -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). -

        -

        38.5 Cross language polymorphism

        @@ -3430,7 +3386,9 @@ statements.

        -The following shows example usage for Python 2.6 to use print as it can in Python 3, that is, as a function instead of a statement: +The following example for Python 2.x shows how to insert code into the +generated wrapper to enable print to be used as a Python3-compatible +function instead of a statement:

        @@ -3447,13 +3405,13 @@ print("Loading", "Whizz", "Bang", sep=' ... ')

        -which can be seen when viewing the first few lines of the generated .py file: +The insert code can be seen at the start of the generated .py file:

         # This file was automatically generated by SWIG (http://www.swig.org).
        -# Version 2.0.11
        +# Version 4.0.0
         #
         # Do not make changes to this file unless you know what you are doing--modify
         # the SWIG interface file instead.
        @@ -6255,8 +6213,8 @@ to do this (remember you are now the Python importer) or use dynamic linking.
         
         
         

        -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 +SWIG is able to support Python 3.x. The wrapper code generated by +SWIG can be compiled with both Python 2.x or 3.x. 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 @@ -6274,7 +6232,7 @@ There is a list of known-to-be-broken features in Python 3:

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

      @@ -6333,8 +6291,8 @@ 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. +applied to both Python 2 and 3, since the bytearray type +was backported to 2.6.

      diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py index c7d262f60..941838a5f 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -84,16 +84,11 @@ def container_insert_step(i, j, step, newval): except IndexError, e: il_error = e - # Python 2.6 contains bug fixes in extended slicing syntax: - # http://docs.python.org/2/whatsnew/2.6.html - skip_check = ps_error != None and( - iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6)) - if not(skip_check): - if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + \ - str(ps_error) + " " + str(iv_error) + " " + str(il_error) + if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): + raise RuntimeError, "ValueError exception not consistently thrown: " + \ + str(ps_error) + " " + str(iv_error) + " " + str(il_error) - compare_containers(ps, iv, il) + compare_containers(ps, iv, il) # Check std::vector and std::list delete behaves same as Python list diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py index 642e127fa..afb9e8988 100644 --- a/Examples/test-suite/python/python_strict_unicode_runme.py +++ b/Examples/test-suite/python/python_strict_unicode_runme.py @@ -1,17 +1,9 @@ import python_strict_unicode -from sys import version_info -test_bytes = 'hello \x01world\x99' -BYTES = 'BYTES' +test_bytes = b'hello \x01world\x99' +BYTES = b'BYTES' test_unicode = u'h\udce9llo w\u00f6rld' -# Python < 2.6 rejects the b prefix for byte string literals as a SyntaxError, -# so instead create Python3 bytes objects by encoding unicode strings as -# latin-1, which maps code points 0-255 directly to the corresponding bytes. -if version_info[0] >= 3: - test_bytes = test_bytes.encode('latin-1') - BYTES = BYTES.encode('latin-1') - # Test that byte string inputs and outputs work as expected bdbl = python_strict_unicode.double_str(test_bytes) if bdbl != test_bytes + test_bytes: diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 99903a9b5..98fbfe4c6 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -254,12 +254,8 @@ SwigPyStaticVar_Type(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -267,20 +263,14 @@ SwigPyStaticVar_Type(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; staticvar_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - staticvar_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&staticvar_type) < 0) return NULL; -#endif } return &staticvar_type; } @@ -342,12 +332,8 @@ SwigPyObjectType(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -355,21 +341,15 @@ SwigPyObjectType(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; swigpyobjecttype_type = tmp; type_init = 1; swigpyobjecttype_type.tp_base = &PyType_Type; -#if PY_VERSION_HEX < 0x02020000 - swigpyobjecttype_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpyobjecttype_type) < 0) return NULL; -#endif } return &swigpyobjecttype_type; } diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 2fa8b5b4c..7cba916da 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -71,143 +71,15 @@ SWIG_Python_str_FromChar(const char *c) #endif } -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - #ifndef PyObject_DEL # define PyObject_DEL PyObject_Del #endif -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -typedef inquiry lenfunc; -typedef intargfunc ssizeargfunc; -typedef intintargfunc ssizessizeargfunc; -typedef intobjargproc ssizeobjargproc; -typedef intintobjargproc ssizessizeobjargproc; -typedef getreadbufferproc readbufferproc; -typedef getwritebufferproc writebufferproc; -typedef getsegcountproc segcountproc; -typedef getcharbufferproc charbufferproc; -static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) -{ - long result = 0; - PyObject *i = PyNumber_Int(x); - if (i) { - result = PyInt_AsLong(i); - Py_DECREF(i); - } - return result; -} -#endif - -#if PY_VERSION_HEX < 0x02050000 -#define PyInt_FromSize_t(x) PyInt_FromLong((long)x) -#endif - -#if PY_VERSION_HEX < 0x02040000 -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((op), arg); \ - if (vret) \ - return vret; \ - } \ - } while (0) -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef struct { - PyTypeObject type; - PyNumberMethods as_number; - PyMappingMethods as_mapping; - PySequenceMethods as_sequence; - PyBufferProcs as_buffer; - PyObject *name, *slots; -} PyHeapTypeObject; -#endif - -#if PY_VERSION_HEX < 0x02030000 -typedef destructor freefunc; -#endif - #if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ (PY_MAJOR_VERSION > 3)) # define SWIGPY_USE_CAPSULE -# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +# define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) #endif #if PY_VERSION_HEX < 0x03020000 diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 826f8411b..550477edf 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -175,15 +175,9 @@ swig_varlink_type(void) { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -191,20 +185,14 @@ swig_varlink_type(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; varlink_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - varlink_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&varlink_type) < 0) return NULL; -#endif } return &varlink_type; } diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 6dcf2599a..3004e0538 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -7,6 +7,10 @@ * * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX < 0x02060000 /* 2.6.0 */ +# error "This version of SWIG only supports Python >= 2.6" +#endif + /* Common SWIG API */ /* for raw pointers */ @@ -90,11 +94,7 @@ SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else PyDict_SetItemString(d, name, obj); -#endif Py_DECREF(obj); if (public_interface) SwigPyBuiltin_AddPublicSymbol(public_interface, name); @@ -104,11 +104,7 @@ SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *nam SWIGINTERN void SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { -#if PY_VERSION_HEX < 0x02030000 - PyDict_SetItemString(d, (char *)name, obj); -#else PyDict_SetItemString(d, name, obj); -#endif Py_DECREF(obj); } @@ -208,11 +204,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } /* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj); /* Helper for static pointer initialization for both C and C++ code, for example @@ -258,7 +250,7 @@ extern "C" { SWIGRUNTIMEINLINE PyObject * _SWIG_Py_None(void) { - PyObject *none = Py_BuildValue((char*)""); + PyObject *none = Py_BuildValue(""); Py_DECREF(none); return none; } @@ -323,11 +315,7 @@ SwigPyClientData_New(PyObject* obj) data->newargs = obj; Py_INCREF(obj); } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif + data->newraw = PyObject_GetAttrString(data->klass, "__new__"); if (data->newraw) { Py_INCREF(data->newraw); data->newargs = PyTuple_New(1); @@ -338,7 +326,7 @@ SwigPyClientData_New(PyObject* obj) Py_INCREF(data->newargs); } /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + data->destroy = PyObject_GetAttrString(data->klass, "__swig_destroy__"); if (PyErr_Occurred()) { PyErr_Clear(); data->destroy = 0; @@ -347,11 +335,7 @@ SwigPyClientData_New(PyObject* obj) int flags; Py_INCREF(data->destroy); flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif } else { data->delargs = 0; } @@ -439,20 +423,12 @@ SwigPyObject_hex(SwigPyObject *v) } SWIGRUNTIME PyObject * -#ifdef METH_NOARGS SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif { const char *name = SWIG_TypePrettyName(v->ty); PyObject *repr = SWIG_Python_str_FromFormat("", (name ? name : "unknown"), (void *)v); if (v->next) { -# ifdef METH_NOARGS PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -# else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -# endif # if PY_VERSION_HEX >= 0x03000000 PyObject *joined = PyUnicode_Concat(repr, nrep); Py_DecRef(repr); @@ -579,11 +555,6 @@ SWIGRUNTIME PyObject* SwigPyObject_append(PyObject* v, PyObject* next) { SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif if (!SwigPyObject_Check(next)) { PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); return NULL; @@ -594,11 +565,7 @@ SwigPyObject_append(PyObject* v, PyObject* next) } SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *) v; if (sobj->next) { @@ -610,11 +577,7 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = 0; @@ -622,11 +585,7 @@ SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) } SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif { SwigPyObject *sobj = (SwigPyObject *)v; sobj->own = SWIG_POINTER_OWN; @@ -637,13 +596,7 @@ SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#elif (PY_VERSION_HEX < 0x02050000) - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#else if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) -#endif { return NULL; } @@ -652,55 +605,26 @@ SwigPyObject_own(PyObject *v, PyObject *args) SwigPyObject *sobj = (SwigPyObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else if (PyObject_IsTrue(val)) { SwigPyObject_acquire(v,args); } else { SwigPyObject_disown(v,args); } -#endif } return obj; } } -#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 *)"acquires 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"}, + {"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", (PyCFunction)SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, "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 *)"acquires 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"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void) { @@ -745,12 +669,8 @@ SwigPyObject_TypeOnce(void) { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ #elif 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 */ +#else 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 */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ #endif }; @@ -764,16 +684,12 @@ SwigPyObject_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyObject", /* tp_name */ + "SwigPyObject", /* tp_name */ sizeof(SwigPyObject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 0, /* tp_print */ -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_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, tp_compare in 3.0.0 but not used */ @@ -796,7 +712,6 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_clear */ (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ swigobject_methods, /* tp_methods */ @@ -817,13 +732,8 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -831,20 +741,14 @@ SwigPyObject_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; swigpyobject_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpyobject_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpyobject_type) < 0) return NULL; -#endif } return &swigpyobject_type; } @@ -955,7 +859,7 @@ SwigPyPacked_TypeOnce(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"SwigPyPacked", /* tp_name */ + "SwigPyPacked", /* tp_name */ sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ @@ -983,7 +887,6 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ @@ -1004,13 +907,8 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_cache */ 0, /* tp_subclasses */ 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 0, /* tp_version_tag */ -#endif #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif @@ -1018,20 +916,14 @@ SwigPyPacked_TypeOnce(void) { 0, /* tp_allocs */ 0, /* tp_frees */ 0, /* tp_maxalloc */ -#if PY_VERSION_HEX >= 0x02050000 0, /* tp_prev */ -#endif 0 /* tp_next */ #endif }; swigpypacked_type = tmp; type_init = 1; -#if PY_VERSION_HEX < 0x02020000 - swigpypacked_type.ob_type = &PyType_Type; -#else if (PyType_Ready(&swigpypacked_type) < 0) return NULL; -#endif } return &swigpypacked_type; } @@ -1117,7 +1009,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) if (PyInstance_Check(pyobj)) { obj = _PyInstance_Lookup(pyobj, SWIG_This()); } else { @@ -1336,7 +1228,6 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t SWIGRUNTIME PyObject* SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) { -#if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; PyObject *newraw = data->newraw; if (newraw) { @@ -1374,45 +1265,13 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #endif } return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst = 0; - PyObject *dict = PyDict_New(); - if (dict) { - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif } SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { dict = *dictptr; @@ -1424,7 +1283,7 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) return; } #endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + dict = PyObject_GetAttrString(inst, "__dict__"); PyDict_SetItem(dict, SWIG_This(), swig_this); Py_DECREF(dict); } @@ -1526,8 +1385,8 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + type_pointer = PyCObject_Import((char *)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char *)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); @@ -1567,22 +1426,22 @@ SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { #if PY_VERSION_HEX >= 0x03000000 /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); + PyObject *module = PyImport_AddModule("swig_runtime_data" SWIG_RUNTIME_VERSION); #else static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); + PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif #ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } #else PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + PyModule_AddObject(module, "type_pointer" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } diff --git a/Lib/python/pythreads.swg b/Lib/python/pythreads.swg index a7552f1fe..d8797e659 100644 --- a/Lib/python/pythreads.swg +++ b/Lib/python/pythreads.swg @@ -5,9 +5,7 @@ #endif #if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ # if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif +# define SWIG_PYTHON_USE_GIL # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ # ifndef SWIG_PYTHON_INITIALIZE_THREADS diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 33893f8fc..e537237f0 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -755,30 +755,6 @@ public: 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"); - Printf(f_header, "# endif\n"); - Printf(f_header, "#endif\n"); - - if (modern) { - Printf(f_header, "#if (PY_VERSION_HEX <= 0x02020000)\n"); - Printf(f_header, "# error \"This python version requires swig to be run with the '-nomodern' option\"\n"); - Printf(f_header, "#endif\n"); - } - - if (modernargs) { - Printf(f_header, "#if (PY_VERSION_HEX <= 0x02020000)\n"); - Printf(f_header, "# error \"This python version requires swig to be run with the '-nomodernargs' option\"\n"); - Printf(f_header, "#endif\n"); - } - - if (fastunpack) { - Printf(f_header, "#ifndef METH_O\n"); - Printf(f_header, "# error \"This python version requires swig to be run with the '-nofastunpack' option\"\n"); - Printf(f_header, "#endif\n"); - } - if (fastquery) { Printf(f_header, "#ifdef SWIG_TypeQuery\n"); Printf(f_header, "# undef SWIG_TypeQuery\n"); @@ -863,9 +839,7 @@ public: * 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. + * in 2.6, and fail in 2.7 onwards). * * For python 2.7.0 and newer, first determine the shadow wrappers package * based on the __name__ it was given by the importer that loaded it. @@ -907,7 +881,7 @@ public: Printf(default_import_code, tab4 "%s = swig_import_helper()\n", module); Printv(default_import_code, tab4, "del swig_import_helper\n", NULL); Printv(default_import_code, "else:\n", NULL); - Printf(default_import_code, tab4 "import %s\n", module); + Printv(default_import_code, tab4, "raise RuntimeError('Python 2.6 or later required')\n", NULL); if (builtin) { /* @@ -939,10 +913,6 @@ public: * module. */ Printv(default_import_code, "del _swig_python_version_info\n\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\n", NULL); - } - /* Need builtins to qualify names like Exception that might also be defined in this module (try both Python 3 and Python 2 names) */ Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL); @@ -1012,9 +982,7 @@ public: } if (directorsEnabled()) { - // Try loading weakref.proxy, which is only available in Python 2.1 and higher - Printv(f_shadow, - "try:\n", tab4, "import weakref\n", tab4, "weakref_proxy = weakref.proxy\n", "except __builtin__.Exception:\n", tab4, "weakref_proxy = lambda x: x\n", "\n\n", NIL); + Printv(f_shadow, "import weakref\n\n", NIL); } } // Include some information in the code @@ -3961,7 +3929,7 @@ public: Printv(f_shadow, tab8, "self.this.disown()\n", NIL); #endif Printv(f_shadow, tab8, module, ".", mrename, "(self)\n", NIL); - Printv(f_shadow, tab8, "return weakref_proxy(self)\n", NIL); + Printv(f_shadow, tab8, "return weakref.proxy(self)\n", NIL); Delete(mrename); } } @@ -4253,9 +4221,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_subclasses"), "tp_subclasses", "PyObject *"); printSlot(f, getSlot(n, "feature:python:tp_weaklist"), "tp_weaklist", "PyObject *"); printSlot(f, getSlot(n, "feature:python:tp_del"), "tp_del", "destructor"); - Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_version_tag"), "tp_version_tag", "int"); - Printv(f, "#endif\n", NIL); Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); Printv(f, "#endif\n", NIL); @@ -4263,9 +4229,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_allocs"), "tp_allocs", "Py_ssize_t"); printSlot(f, getSlot(n, "feature:python:tp_frees"), "tp_frees", "Py_ssize_t"); printSlot(f, getSlot(n, "feature:python:tp_maxalloc"), "tp_maxalloc", "Py_ssize_t"); - Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_prev"), "tp_prev"); - Printv(f, "#endif\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_next"), "tp_next"); Printv(f, "#endif\n", NIL); Printf(f, " },\n"); @@ -4331,9 +4295,7 @@ public: printSlot(f, getSlot(n, "feature:python:nb_divide"), "nb_true_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_floor_divide"), "nb_inplace_floor_divide", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_divide"), "nb_inplace_true_divide", "binaryfunc"); - Printv(f, "#if PY_VERSION_HEX >= 0x02050000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_index"), "nb_index", "unaryfunc"); - Printv(f, "#endif\n", NIL); Printv(f, "#if PY_VERSION_HEX >= 0x03050000\n", NIL); printSlot(f, getSlot(n, "feature:python:nb_matrix_multiply"), "nb_matrix_multiply", "binaryfunc"); printSlot(f, getSlot(n, "feature:python:nb_inplace_matrix_multiply"), "nb_inplace_matrix_multiply", "binaryfunc"); @@ -4377,10 +4339,8 @@ public: printSlot(f, getSlot(n, "feature:python:bf_getsegcount"), "bf_getsegcount", "segcountproc"); printSlot(f, getSlot(n, "feature:python:bf_getcharbuffer"), "bf_getcharbuffer", "charbufferproc"); Printv(f, "#endif\n", NIL); - Printv(f, "#if PY_VERSION_HEX >= 0x02060000\n", NIL); printSlot(f, getSlot(n, "feature:python:bf_getbuffer"), "bf_getbuffer", "getbufferproc"); printSlot(f, getSlot(n, "feature:python:bf_releasebuffer"), "bf_releasebuffer", "releasebufferproc"); - Printv(f, "#endif\n", NIL); Printf(f, " },\n"); // PyObject *ht_name, *ht_slots, *ht_qualname; @@ -4590,7 +4550,7 @@ public: Printv(f_shadow, tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", NIL); } else { - Printv(f_shadow, tab4, "thisown = _swig_property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); + Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); /* Add static attribute */ if (GetFlag(n, "feature:python:nondynamic")) { Printv(f_shadow_file, @@ -5182,7 +5142,7 @@ public: if (!classic) { if (!modern) Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); - Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL); + Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); Printv(f_shadow, ")\n", NIL); @@ -5256,7 +5216,7 @@ public: if (!classic && !builtin) { if (!modern) Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); - Printv(f_shadow, tab4, symname, " = _swig_property(", module, ".", getname, NIL); + Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); Printv(f_shadow, ")\n", NIL); From 5d6a1b6858934f849b7460f70ef98fce8a9c5a80 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 8 Jun 2018 09:46:26 +1200 Subject: [PATCH 0989/2031] Remove long obsolete vms subdirectory This contains a separate build system for VMS, but it's not been touched at all since 2002 and clearly hasn't worked for a long time - e.g. it tries to build php4.cxx, which we removed a decade ago. It seems openvms is still alive, but keeping these files in the tree isn't helping anyone. If someone really wanted to build SWIG on openvms then I suspect starting over would be less work, but they could pull the files out of the git history if they're really still useful. Closes #1270. --- vms/aaareadme.txt | 18 ---- vms/build_end.com | 21 ---- vms/build_init.com | 13 --- vms/build_swig.com | 1 - vms/genbuild.py | 155 ---------------------------- vms/logicals.com | 18 ---- vms/scripts/build_all.com | 15 --- vms/scripts/compil_cparse.com | 98 ------------------ vms/scripts/compil_doh.com | 106 ------------------- vms/scripts/compil_modules1_1.com | 132 ----------------------- vms/scripts/compil_preprocessor.com | 94 ----------------- vms/scripts/compil_swig.com | 122 ---------------------- vms/swigconfig.h | 2 - 13 files changed, 795 deletions(-) delete mode 100644 vms/aaareadme.txt delete mode 100644 vms/build_end.com delete mode 100644 vms/build_init.com delete mode 100644 vms/build_swig.com delete mode 100644 vms/genbuild.py delete mode 100644 vms/logicals.com delete mode 100644 vms/scripts/build_all.com delete mode 100644 vms/scripts/compil_cparse.com delete mode 100644 vms/scripts/compil_doh.com delete mode 100644 vms/scripts/compil_modules1_1.com delete mode 100644 vms/scripts/compil_preprocessor.com delete mode 100644 vms/scripts/compil_swig.com delete mode 100644 vms/swigconfig.h diff --git a/vms/aaareadme.txt b/vms/aaareadme.txt deleted file mode 100644 index 52746a7e7..000000000 --- a/vms/aaareadme.txt +++ /dev/null @@ -1,18 +0,0 @@ -Port on OpenVMS 7.3 using CC 6.5 and CXX 6.5 - - -Building procedure: -$ @logicals -$ @build_all - -the logicals swig_root is defined by the procedure logicals.com. -The logicals.com procedure can be invoke with an optional argument -for the define command, for example: -$ @logicals "/system/exec" - - -genbuild.py is the python program use to generate all the procedures in the -[vms.scripts] directory. - - -jf.pieronne@laposte.net diff --git a/vms/build_end.com b/vms/build_end.com deleted file mode 100644 index 103302270..000000000 --- a/vms/build_end.com +++ /dev/null @@ -1,21 +0,0 @@ -$ set def swig_root:[vms] -$ -$ file = f$search("swig_root:[vms.o_alpha]*.obj") -$ newobj = 0 -$ if file .nes. "" -$ then -$ v = f$verify(1) -$ library/replace swig_root:[vms.o_alpha]swig.olb swig_root:[vms.o_alpha]*.obj -$ delete swig_root:[vms.o_alpha]*.obj;* -$ v = f$verify(v) -$ newobj = 1 -$ endif -$ file = f$search("swig_root:[vms]swig.exe") -$ if file .eqs. "" .or. newobj -$ then -$ v = f$verify(1) -$ cxxlink/exe=swig_root:[vms]swig.exe - - /repo=swig_root:[source.modules1_1.cxx_repository] - - swig_root:[vms.o_alpha]swig.olb/include=swigmain -$ v = f$verify(v) -$ endif diff --git a/vms/build_init.com b/vms/build_init.com deleted file mode 100644 index 9a1992dc4..000000000 --- a/vms/build_init.com +++ /dev/null @@ -1,13 +0,0 @@ -$ set def swig_root:[vms] -$ -$ swiglib = "swig_root:[vms.o_alpha]swig.olb -$ -$ if (f$search("swig_root:[vms]o_alpha.dir") .eqs. "") then $ - - create/dir swig_root:[vms.o_alpha] -$ -$ copy swigconfig.h [-.source.include] -$ copy swigver.h [-.source.include] -$ -$ if (f$search("''swiglib'") .eqs. "") then $ - - library/create/object 'swiglib' -$ diff --git a/vms/build_swig.com b/vms/build_swig.com deleted file mode 100644 index 5570db0bc..000000000 --- a/vms/build_swig.com +++ /dev/null @@ -1 +0,0 @@ -$ @swig_root:[vms.scripts]build_all diff --git a/vms/genbuild.py b/vms/genbuild.py deleted file mode 100644 index df18ce3ed..000000000 --- a/vms/genbuild.py +++ /dev/null @@ -1,155 +0,0 @@ -import os.path, string, posix, pyvms -# -# - -IDIR = ['swig_root:[source.swig]', 'swig_root:[source.doh.include]', - 'swig_root:[source.include]', 'swig_root:[source.preprocessor]'] - -def new_file(fg, dirname): - global IDIR - fn = 'swig_root:[vms.scripts]compil_' + os.path.basename(dirname) + '.com' - print >> fg, '$ @' + fn - f = open(fn, 'w') - print >> f, '$!' - print >> f, '$! Generated by genbuild.py' - print >> f, '$!' - print >> f, '$ libname = "swig_root:[vms.o_alpha]swig.olb"' - print >> f, '$' - print >> f, '$ set default', pyvms.crtl_to_vms(dirname)[0][0] - print >> f, '$' - print >> f, "$ idir := ", IDIR[0] - for i in range(1, len(IDIR)): - print >> f, '$ idir = idir + ",' + IDIR[i] + '"' - print >> f, '$' - print >> f, "$ iflags = \"/include=(''idir', sys$disk:[])\"" - print >> f, '$ oflags = \"/object=swig_root:[vms.o_alpha]' - print >> f, "$ cflags = \"''oflags'''iflags'''dflags'\"" - print >> f, "$ cxxflags = \"''oflags'''iflags'''dflags'\"" - print >> f, '$' - return f - - -def end_file(f): - print >>f,"""$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE""" - - -def listRep(args, dirname, filenames): - fg = args[0] - first = 1 - for fn in filenames: - if fn[-2:] == '.c': - if first: - first = 0 - fc = new_file(fg, dirname) - - cstr = "\"cc ''cflags'\" " - line = "$ call make swig_root:[vms.o_alpha]" - line += fn[:-1] + 'obj -' - print >> fc, line - line = "\t" + cstr + fn - print >> fc, line - elif fn[-4:] == '.cxx': - if first: - first = 0 - fc = new_file(fg, dirname) - - cstr = "\"cxx ''cxxflags'\" " - line = "$ call make swig_root:[vms.o_alpha]" - line += fn[:-3] + 'obj -' - print >> fc, line - line = "\t" + cstr + fn - print >> fc, line - if first == 0: - end_file(fc) - fc.close() -# -def genbuild(f, dir): - os.path.walk(dir, listRep, (f,)) - cmd = 'set default swig_root:[vms]' -# -f = open('swig_root:[vms.scripts]build_all.com','w') -print >> f, '$!' -print >> f, '$! Generated by genbuild.py' -print >> f, '$!' -print >> f, '$ set default swig_root:[vms]' -print >> f, '$' -print >> f, '$ @swig_root:[vms]build_init' -# -genbuild(f, '/swig_root/source') -print >> f, '$' -print >> f, '$ set default swig_root:[vms]' -print >> f, '$' -print >> f, '$ @swig_root:[vms]build_end' -f.close diff --git a/vms/logicals.com b/vms/logicals.com deleted file mode 100644 index 20da9d49a..000000000 --- a/vms/logicals.com +++ /dev/null @@ -1,18 +0,0 @@ -$! -$! -$! -$ proc = f$environment("PROCEDURE") -$ proc = f$parse(proc,"sys$disk:[]",,,"NO_CONCEAL") -$ cur_dev = f$parse(proc,,,"DEVICE","SYNTAX_ONLY") -$ cur_dir = f$parse(proc,,,"DIRECTORY","SYNTAX_ONLY") -$ cur_dir = f$extract(1,f$length(cur_dir)-2,cur_dir) -$ cur_dir = cur_dir - "[" -$ cur_dir = cur_dir - "]" -$ cur_dir = cur_dir - "<" -$ cur_dir = cur_dir - ">" -$ -$! remove trealing .VMS -$ root_dir = f$extract(0,f$length(cur_dir)-4,cur_dir) -$ -$ define 'p1' /trans=concealed swig_root 'cur_dev'['root_dir'.] - diff --git a/vms/scripts/build_all.com b/vms/scripts/build_all.com deleted file mode 100644 index d41198348..000000000 --- a/vms/scripts/build_all.com +++ /dev/null @@ -1,15 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ set default swig_root:[vms] -$ -$ @swig_root:[vms]build_init -$ @swig_root:[vms.scripts]compil_cparse.com -$ @swig_root:[vms.scripts]compil_doh.com -$ @swig_root:[vms.scripts]compil_modules1_1.com -$ @swig_root:[vms.scripts]compil_preprocessor.com -$ @swig_root:[vms.scripts]compil_swig.com -$ -$ set default swig_root:[vms] -$ -$ @swig_root:[vms]build_end diff --git a/vms/scripts/compil_cparse.com b/vms/scripts/compil_cparse.com deleted file mode 100644 index 4f78f4104..000000000 --- a/vms/scripts/compil_cparse.com +++ /dev/null @@ -1,98 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ libname = "swig_root:[vms.o_alpha]swig.olb" -$ -$ set default SWIG_ROOT:[SOURCE.CPARSE] -$ -$ idir := swig_root:[source.swig] -$ idir = idir + ",swig_root:[source.doh.include]" -$ idir = idir + ",swig_root:[source.include]" -$ idir = idir + ",swig_root:[source.preprocessor]" -$ -$ iflags = "/include=(''idir', sys$disk:[])" -$ oflags = "/object=swig_root:[vms.o_alpha] -$ cflags = "''oflags'''iflags'''dflags'" -$ cxxflags = "''oflags'''iflags'''dflags'" -$ -$ call make swig_root:[vms.o_alpha]cscanner.obj - - "cc ''cflags'" cscanner.c -$ call make swig_root:[vms.o_alpha]parser.obj - - "cc ''cflags'" parser.c -$ call make swig_root:[vms.o_alpha]templ.obj - - "cc ''cflags'" templ.c -$ call make swig_root:[vms.o_alpha]util.obj - - "cc ''cflags'" util.c -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/vms/scripts/compil_doh.com b/vms/scripts/compil_doh.com deleted file mode 100644 index 6d4ae89ad..000000000 --- a/vms/scripts/compil_doh.com +++ /dev/null @@ -1,106 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ libname = "swig_root:[vms.o_alpha]swig.olb" -$ -$ set default SWIG_ROOT:[SOURCE.DOH.DOH] -$ -$ idir := swig_root:[source.swig] -$ idir = idir + ",swig_root:[source.doh.include]" -$ idir = idir + ",swig_root:[source.include]" -$ idir = idir + ",swig_root:[source.preprocessor]" -$ -$ iflags = "/include=(''idir', sys$disk:[])" -$ oflags = "/object=swig_root:[vms.o_alpha] -$ cflags = "''oflags'''iflags'''dflags'" -$ cxxflags = "''oflags'''iflags'''dflags'" -$ -$ call make swig_root:[vms.o_alpha]base.obj - - "cc ''cflags'" base.c -$ call make swig_root:[vms.o_alpha]file.obj - - "cc ''cflags'" file.c -$ call make swig_root:[vms.o_alpha]fio.obj - - "cc ''cflags'" fio.c -$ call make swig_root:[vms.o_alpha]hash.obj - - "cc ''cflags'" hash.c -$ call make swig_root:[vms.o_alpha]list.obj - - "cc ''cflags'" list.c -$ call make swig_root:[vms.o_alpha]memory.obj - - "cc ''cflags'" memory.c -$ call make swig_root:[vms.o_alpha]string.obj - - "cc ''cflags'" string.c -$ call make swig_root:[vms.o_alpha]void.obj - - "cc ''cflags'" void.c -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/vms/scripts/compil_modules1_1.com b/vms/scripts/compil_modules1_1.com deleted file mode 100644 index c570dfe58..000000000 --- a/vms/scripts/compil_modules1_1.com +++ /dev/null @@ -1,132 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ libname = "swig_root:[vms.o_alpha]swig.olb" -$ -$ set default SWIG_ROOT:[SOURCE.MODULES1_1] -$ -$ idir := swig_root:[source.swig] -$ idir = idir + ",swig_root:[source.doh.include]" -$ idir = idir + ",swig_root:[source.include]" -$ idir = idir + ",swig_root:[source.preprocessor]" -$ -$ iflags = "/include=(''idir', sys$disk:[])" -$ oflags = "/object=swig_root:[vms.o_alpha] -$ cflags = "''oflags'''iflags'''dflags'" -$ cxxflags = "''oflags'''iflags'''dflags'" -$ -$ call make swig_root:[vms.o_alpha]allocate.obj - - "cxx ''cxxflags'" allocate.cxx -$ call make swig_root:[vms.o_alpha]browser.obj - - "cxx ''cxxflags'" browser.cxx -$ call make swig_root:[vms.o_alpha]contract.obj - - "cxx ''cxxflags'" contract.cxx -$ call make swig_root:[vms.o_alpha]emit.obj - - "cxx ''cxxflags'" emit.cxx -$ call make swig_root:[vms.o_alpha]guile.obj - - "cxx ''cxxflags'" guile.cxx -$ call make swig_root:[vms.o_alpha]java.obj - - "cxx ''cxxflags'" java.cxx -$ call make swig_root:[vms.o_alpha]lang.obj - - "cxx ''cxxflags'" lang.cxx -$ call make swig_root:[vms.o_alpha]main.obj - - "cxx ''cxxflags'" main.cxx -$ call make swig_root:[vms.o_alpha]module.obj - - "cxx ''cxxflags'" module.cxx -$ call make swig_root:[vms.o_alpha]mzscheme.obj - - "cxx ''cxxflags'" mzscheme.cxx -$ call make swig_root:[vms.o_alpha]ocaml.obj - - "cxx ''cxxflags'" ocaml.cxx -$ call make swig_root:[vms.o_alpha]overload.obj - - "cxx ''cxxflags'" overload.cxx -$ call make swig_root:[vms.o_alpha]perl5.obj - - "cxx ''cxxflags'" perl5.cxx -$ call make swig_root:[vms.o_alpha]php4.obj - - "cxx ''cxxflags'" php4.cxx -$ call make swig_root:[vms.o_alpha]pike.obj - - "cxx ''cxxflags'" pike.cxx -$ call make swig_root:[vms.o_alpha]python.obj - - "cxx ''cxxflags'" python.cxx -$ call make swig_root:[vms.o_alpha]ruby.obj - - "cxx ''cxxflags'" ruby.cxx -$ call make swig_root:[vms.o_alpha]swigmain.obj - - "cxx ''cxxflags'" swigmain.cxx -$ call make swig_root:[vms.o_alpha]tcl8.obj - - "cxx ''cxxflags'" tcl8.cxx -$ call make swig_root:[vms.o_alpha]typepass.obj - - "cxx ''cxxflags'" typepass.cxx -$ call make swig_root:[vms.o_alpha]xml.obj - - "cxx ''cxxflags'" xml.cxx -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/vms/scripts/compil_preprocessor.com b/vms/scripts/compil_preprocessor.com deleted file mode 100644 index f95961e8d..000000000 --- a/vms/scripts/compil_preprocessor.com +++ /dev/null @@ -1,94 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ libname = "swig_root:[vms.o_alpha]swig.olb" -$ -$ set default SWIG_ROOT:[SOURCE.PREPROCESSOR] -$ -$ idir := swig_root:[source.swig] -$ idir = idir + ",swig_root:[source.doh.include]" -$ idir = idir + ",swig_root:[source.include]" -$ idir = idir + ",swig_root:[source.preprocessor]" -$ -$ iflags = "/include=(''idir', sys$disk:[])" -$ oflags = "/object=swig_root:[vms.o_alpha] -$ cflags = "''oflags'''iflags'''dflags'" -$ cxxflags = "''oflags'''iflags'''dflags'" -$ -$ call make swig_root:[vms.o_alpha]cpp.obj - - "cc ''cflags'" cpp.c -$ call make swig_root:[vms.o_alpha]expr.obj - - "cc ''cflags'" expr.c -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/vms/scripts/compil_swig.com b/vms/scripts/compil_swig.com deleted file mode 100644 index 103e275f4..000000000 --- a/vms/scripts/compil_swig.com +++ /dev/null @@ -1,122 +0,0 @@ -$! -$! Generated by genbuild.py -$! -$ libname = "swig_root:[vms.o_alpha]swig.olb" -$ -$ set default SWIG_ROOT:[SOURCE.SWIG] -$ -$ idir := swig_root:[source.swig] -$ idir = idir + ",swig_root:[source.doh.include]" -$ idir = idir + ",swig_root:[source.include]" -$ idir = idir + ",swig_root:[source.preprocessor]" -$ -$ iflags = "/include=(''idir', sys$disk:[])" -$ oflags = "/object=swig_root:[vms.o_alpha] -$ cflags = "''oflags'''iflags'''dflags'" -$ cxxflags = "''oflags'''iflags'''dflags'" -$ -$ call make swig_root:[vms.o_alpha]cwrap.obj - - "cc ''cflags'" cwrap.c -$ call make swig_root:[vms.o_alpha]error.obj - - "cc ''cflags'" error.c -$ call make swig_root:[vms.o_alpha]fragment.obj - - "cc ''cflags'" fragment.c -$ call make swig_root:[vms.o_alpha]getopt.obj - - "cc ''cflags'" getopt.c -$ call make swig_root:[vms.o_alpha]include.obj - - "cc ''cflags'" include.c -$ call make swig_root:[vms.o_alpha]misc.obj - - "cc ''cflags'" misc.c -$ call make swig_root:[vms.o_alpha]naming.obj - - "cc ''cflags'" naming.c -$ call make swig_root:[vms.o_alpha]parms.obj - - "cc ''cflags'" parms.c -$ call make swig_root:[vms.o_alpha]scanner.obj - - "cc ''cflags'" scanner.c -$ call make swig_root:[vms.o_alpha]stype.obj - - "cc ''cflags'" stype.c -$ call make swig_root:[vms.o_alpha]symbol.obj - - "cc ''cflags'" symbol.c -$ call make swig_root:[vms.o_alpha]tree.obj - - "cc ''cflags'" tree.c -$ call make swig_root:[vms.o_alpha]typemap.obj - - "cc ''cflags'" typemap.c -$ call make swig_root:[vms.o_alpha]typesys.obj - - "cc ''cflags'" typesys.c -$ call make swig_root:[vms.o_alpha]warn.obj - - "cc ''cflags'" warn.c -$ call make swig_root:[vms.o_alpha]wrapfunc.obj - - "cc ''cflags'" wrapfunc.c -$ exit -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 = Source file -$! P4 - P8 What it depends on -$ -$ modname = f$parse(p3,,,"name") -$ set noon -$ set message/nofacility/noident/noseverity/notext -$ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname' -$ set message/facility/ident/severity/text -$ on error then exit -$ open/read swigtmp swig_root:[vms]swiglib.tmp -$! skip header -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$ read swigtmp r -$! -$ -$ read/end=module_not_found swigtmp r -$ modfound = 1 -$ Time = f$cvtime(f$extract(49, 20, r)) -$ goto end_search_module -$ module_not_found: -$ modfound = 0 -$ -$ end_search_module: -$ close swigtmp -$ delete swig_root:[vms]swiglib.tmp;* -$ -$ if modfound .eq. 0 then $ goto Makeit -$ -$! Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(1) -$ 'P2' 'P3' -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE diff --git a/vms/swigconfig.h b/vms/swigconfig.h deleted file mode 100644 index 3ee086407..000000000 --- a/vms/swigconfig.h +++ /dev/null @@ -1,2 +0,0 @@ - -/* Note that this file has changed. TODO Get the latest from the original version. */ From 0f88f9997c78a937eb9afa122389caf9666e33dc Mon Sep 17 00:00:00 2001 From: Philipp Kraft Date: Fri, 8 Jun 2018 00:31:49 +0200 Subject: [PATCH 0990/2031] Stop exposing _swigregister to Python It's not useful for user Python code to call this, and it just clutters the API unnecessarily. Fixes #1225 --- Source/Modules/python.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 Source/Modules/python.cxx diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx old mode 100644 new mode 100755 index e537237f0..ce7addc5b --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4684,8 +4684,8 @@ public: class_name); } } - Printf(f_shadow_file, "%s_swigregister = %s.%s_swigregister\n", class_name, module, class_name); - Printf(f_shadow_file, "%s_swigregister(%s)\n", class_name, class_name); + Printf(f_shadow_file, "# Register %s in %s:\n", class_name, module); + Printf(f_shadow_file, "%s.%s_swigregister(%s)\n", module, class_name, class_name); } shadow_indent = 0; From 838806d782540eb204e7c11febb8e0d08990976a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 8 Jun 2018 11:08:19 +1200 Subject: [PATCH 0991/2031] Add CHANGES.current entry for previous commit --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e9b566961..70f13c05f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-08: philippkraft + [Python] Stop exposing _swigregister to Python. It's not + useful for user Python code to call this, and it just clutters the + API unnecessarily. Fixes #1225. + 2018-06-07: cmfoil, kabbi, Jamie Kirkpatrick, markok314, vadz, wsfulton, Yann Diorcet #170 Doxygen documentation support added. This allows translation of Doxygen comments into JavaDoc and PyDoc documentation. It is enabled via the -doxygen command line From 78c56168abc50a35423821337c989c3e116004a4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 16:00:47 +1200 Subject: [PATCH 0992/2031] Update manual contents for removed Python section I removed the section on classic classes in the previous commit, but failed to update the contents list. --- Doc/Manual/Contents.html | 1 - Doc/Manual/Python.html | 1 - 2 files changed, 2 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 6a29394fc..b76e1d33a 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1625,7 +1625,6 @@
    • Operator overloads and slots -- use them!
  • Memory management -
  • Python 2.2 and classic classes
  • Cross language polymorphism
      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 881ba275b..3def2080e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -54,7 +54,6 @@
    • Operator overloads and slots -- use them!
  • Memory management -
  • Python 2.2 and classic classes
  • Cross language polymorphism
      From 1198155083835cdf884dc9e1427e12d0f801925b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 15:52:46 +1200 Subject: [PATCH 0993/2031] Drop Python 2.6 support too See #701. --- Doc/Manual/Python.html | 6 ++-- Lib/python/pyrun.swg | 8 ++--- Source/Modules/python.cxx | 67 ++++++++++++++------------------------- 3 files changed, 31 insertions(+), 50 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 3def2080e..9c43fb3fe 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -149,9 +149,9 @@

      This chapter describes SWIG's support of Python. SWIG is compatible -with most recent Python versions (Python 2.6 and later, including Python 3). -If you still need to generate bindings which work with older versions of -Python, you'll have to use SWIG 3.0.x. +with most recent Python versions (Python 2.7 and Python 3.x). If you still +need to generate bindings which work with older versions of Python, you'll have +to use SWIG 3.0.x.

      diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3004e0538..a19ab54cf 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -7,8 +7,8 @@ * * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX < 0x02060000 /* 2.6.0 */ -# error "This version of SWIG only supports Python >= 2.6" +#if PY_VERSION_HEX < 0x02070000 /* 2.7.0 */ +# error "This version of SWIG only supports Python >= 2.7" #endif /* Common SWIG API */ @@ -1385,8 +1385,8 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { # ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else - type_pointer = PyCObject_Import((char *)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char *)"type_pointer" SWIG_TYPE_TABLE_NAME); + type_pointer = PyCObject_Import("swig_runtime_data" SWIG_RUNTIME_VERSION, + "type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ce7addc5b..d1144522d 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -830,58 +830,39 @@ public: if (!builtin && fastproxy) { Printv(default_import_code, "if _swig_python_version_info >= (3, 0, 0):\n", NULL); Printf(default_import_code, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); - Printv(default_import_code, "else:\n", NULL); + Printv(default_import_code, "elif _swig_python_version_info >= (2, 7, 0):\n", NULL); Printv(default_import_code, tab4, "from new import instancemethod as new_instancemethod\n", NULL); + Printv(default_import_code, "else:\n", NULL); + Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\n", NULL); + } else { + Printv(default_import_code, "if _swig_python_version_info < (2, 7, 0):\n", NULL); + Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\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). + * onwards (implicit relative imports raised a DeprecationWarning in 2.6, + * and fail in 2.7 onwards). * - * For python 2.7.0 and newer, first determine the shadow wrappers package - * based on the __name__ it was given by the importer that loaded it. - * Then construct a name for the module based on the package name and the - * module name (we know the module name). Use importlib to try and load - * it. If an attempt to load the module with importlib fails with an - * ImportError then fallback and try and load just the module name from - * the global namespace. + * First determine the shadow wrappers package based on the __name__ it + * was given by the importer that loaded it. Then construct a name for + * the module based on the package name and the module name (we know the + * module name). Use importlib to try and load it. If an attempt to + * load the module with importlib fails with an ImportError then fallback + * and try and load just the module name from the global namespace. */ - Printv(default_import_code, "if _swig_python_version_info >= (2, 7, 0):\n", NULL); - Printv(default_import_code, tab4, "def swig_import_helper():\n", NULL); - Printv(default_import_code, tab8, "import importlib\n", NULL); - Printv(default_import_code, tab8, "pkg = __name__.rpartition('.')[0]\n", NULL); - Printf(default_import_code, tab8 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); - Printv(default_import_code, tab8, "try:\n", NULL); - Printv(default_import_code, tab8, tab4, "return importlib.import_module(mname)\n", NULL); - Printv(default_import_code, tab8, "except ImportError:\n", NULL); - Printf(default_import_code, tab8 tab4 "return importlib.import_module('%s')\n", module); - Printf(default_import_code, tab4 "%s = swig_import_helper()\n", module); - Printv(default_import_code, tab4, "del swig_import_helper\n", NULL); - Printv(default_import_code, "elif _swig_python_version_info >= (2, 6, 0):\n", NULL); - Printv(default_import_code, tab4, "def swig_import_helper():\n", NULL); - Printv(default_import_code, tab8, "from os.path import dirname\n", NULL); - Printv(default_import_code, tab8, "import imp\n", NULL); - Printv(default_import_code, tab8, "fp = None\n", NULL); - Printv(default_import_code, tab8, "try:\n", NULL); - Printf(default_import_code, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); - Printf(default_import_code, tab8 "except ImportError:\n"); - /* At here, the module may already loaded, so simply import it. */ - Printf(default_import_code, tab4 tab8 "import %s\n", module); - Printf(default_import_code, tab4 tab8 "return %s\n", module); - Printv(default_import_code, tab8 "try:\n", NULL); - /* imp.load_module() handles fp being None. */ - Printf(default_import_code, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); - Printv(default_import_code, tab8, "finally:\n", NULL); - Printv(default_import_code, tab4 tab8 "if fp is not None:\n", NULL); - Printv(default_import_code, tab8 tab8, "fp.close()\n", NULL); - Printv(default_import_code, tab8, "return _mod\n", NULL); - Printf(default_import_code, tab4 "%s = swig_import_helper()\n", module); - Printv(default_import_code, tab4, "del swig_import_helper\n", NULL); - Printv(default_import_code, "else:\n", NULL); - Printv(default_import_code, tab4, "raise RuntimeError('Python 2.6 or later required')\n", NULL); + Printv(default_import_code, "def swig_import_helper():\n", NULL); + Printv(default_import_code, tab4, "import importlib\n", NULL); + Printv(default_import_code, tab4, "pkg = __name__.rpartition('.')[0]\n", NULL); + Printf(default_import_code, tab4 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); + Printv(default_import_code, tab4, "try:\n", NULL); + Printv(default_import_code, tab8, "return importlib.import_module(mname)\n", NULL); + Printv(default_import_code, tab4, "except ImportError:\n", NULL); + Printf(default_import_code, tab8 "return importlib.import_module('%s')\n", module); + Printf(default_import_code, "%s = swig_import_helper()\n", module); + Printv(default_import_code, "del swig_import_helper\n", NULL); if (builtin) { /* From a82c1b943b6837c3a99bc1390e83a0f1a23d2ac2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 18 May 2018 17:07:18 +1200 Subject: [PATCH 0994/2031] Drop support for Python 3.0 to 3.3 See #701. --- Doc/Manual/Python.html | 6 +++--- Lib/python/builtin.swg | 5 +---- Lib/python/pyinit.swg | 9 --------- Lib/python/pyrun.swg | 4 ++++ Lib/python/pystrings.swg | 4 ---- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 9c43fb3fe..46a41a4d8 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -149,9 +149,9 @@

      This chapter describes SWIG's support of Python. SWIG is compatible -with most recent Python versions (Python 2.7 and Python 3.x). If you still -need to generate bindings which work with older versions of Python, you'll have -to use SWIG 3.0.x. +with all recent Python versions (Python 2.7 and Python >= 3.4). If you +still need to generate bindings which work with older versions of Python, +you'll have to use SWIG 3.0.x.

      diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 98fbfe4c6..4e39610fa 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -13,12 +13,9 @@ SWIGINTERN Py_hash_t SWIG_PyNumber_AsPyHash(PyObject *obj) { Py_hash_t result = -1; #if PY_VERSION_HEX < 0x03020000 -#if PY_VERSION_HEX < 0x03000000 if (PyInt_Check(obj)) result = PyInt_AsLong(obj); - else -#endif - if (PyLong_Check(obj)) + else if (PyLong_Check(obj)) result = PyLong_AsLong(obj); #else if (PyNumber_Check(obj)) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 550477edf..2d4fe2fb1 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -329,16 +329,7 @@ SWIG_init(void) { PyObject *m, *d, *md; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { -# if PY_VERSION_HEX >= 0x03020000 PyModuleDef_HEAD_INIT, -# else - { - PyObject_HEAD_INIT(NULL) - NULL, /* m_init */ - 0, /* m_index */ - NULL, /* m_copy */ - }, -# endif (char *) SWIG_name, NULL, -1, diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index a19ab54cf..3bf16b423 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -11,6 +11,10 @@ # error "This version of SWIG only supports Python >= 2.7" #endif +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03040000 +# error "This version of SWIG only supports Python 3 >= 3.4" +#endif + /* Common SWIG API */ /* for raw pointers */ diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 301e0f3e1..ac87d07ab 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -137,11 +137,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) %#if defined(SWIG_PYTHON_STRICT_BYTE_CHAR) return PyBytes_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); %#else -%#if PY_VERSION_HEX >= 0x03010000 return PyUnicode_DecodeUTF8(carray, %numeric_cast(size, Py_ssize_t), "surrogateescape"); -%#else - return PyUnicode_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); -%#endif %#endif %#else return PyString_FromStringAndSize(carray, %numeric_cast(size, Py_ssize_t)); From 2ea976f1d8d7a4c667047bc5bbb7fc915b6741b5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 8 Jun 2018 09:10:38 +1200 Subject: [PATCH 0995/2031] Always use PyCapsule It is supported by all the Python versions we now support. --- Lib/python/pyhead.swg | 6 ++---- Lib/python/pyrun.swg | 30 ------------------------------ 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 7cba916da..c820f9016 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -75,12 +75,10 @@ SWIG_Python_str_FromChar(const char *c) # define PyObject_DEL PyObject_Del #endif -#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ - (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ - (PY_MAJOR_VERSION > 3)) +// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user +// interface files check for it. # define SWIGPY_USE_CAPSULE # define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) -#endif #if PY_VERSION_HEX < 0x03020000 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 3bf16b423..70980c238 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1386,12 +1386,7 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { #ifdef SWIG_LINK_RUNTIME type_pointer = SWIG_ReturnGlobalTypeList((void *)0); #else -# ifdef SWIGPY_USE_CAPSULE type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); -# else - type_pointer = PyCObject_Import("swig_runtime_data" SWIG_RUNTIME_VERSION, - "type_pointer" SWIG_TYPE_TABLE_NAME); -# endif if (PyErr_Occurred()) { PyErr_Clear(); type_pointer = (void *)0; @@ -1402,17 +1397,9 @@ SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { } SWIGRUNTIME void -#ifdef SWIGPY_USE_CAPSULE SWIG_Python_DestroyModule(PyObject *obj) -#else -SWIG_Python_DestroyModule(void *vptr) -#endif { -#ifdef SWIGPY_USE_CAPSULE swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); -#else - swig_module_info *swig_module = (swig_module_info *) vptr; -#endif swig_type_info **types = swig_module->types; size_t i; for (i =0; i < swig_module->size; ++i) { @@ -1435,21 +1422,12 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ PyObject *module = Py_InitModule("swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); #endif -#ifdef SWIGPY_USE_CAPSULE PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, "type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); } else { Py_XDECREF(pointer); } -#else - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, "type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -#endif } /* The python cached type query */ @@ -1467,20 +1445,12 @@ SWIG_Python_TypeQuery(const char *type) PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { -#ifdef SWIGPY_USE_CAPSULE descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); -#else - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); -#endif } else { swig_module_info *swig_module = SWIG_GetModule(0); descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); if (descriptor) { -#ifdef SWIGPY_USE_CAPSULE obj = PyCapsule_New((void*) descriptor, NULL, NULL); -#else - obj = PyCObject_FromVoidPtr(descriptor, NULL); -#endif PyDict_SetItem(cache, key, obj); Py_DECREF(obj); } From 4e27fdbfc123dc4a0d41f4b5b27cb3cf4a792206 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Jun 2018 08:40:07 +0100 Subject: [PATCH 0996/2031] Fix java test-suite parallel build (doxygen test cases) CommentParser.class was being generated and read from multiple threads Compile it just once using make dependencies. --- Examples/test-suite/java/Makefile.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index f1717b81b..3ce692080 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -104,11 +104,15 @@ setup = \ mkdir $(JAVA_PACKAGE); \ fi -# Doxygen test cases need to be compiled together with the CommentsParser class +# Doxygen test cases need to be compiled together with the CommentParser class # which depends on com.sun.javadoc package which is located in this JAR. +CommentParser.class: + echo "Compiling $(srcdir)/CommentParser.java" + $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java + JAVA_CLASSPATH := . $(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_HOME)/lib/tools.jar$(JAVA_CLASSPATH_SEP)." -$(DOXYGEN_TEST_CASES:=.cpptest): DOXYGEN_COMMENT_PARSER := $(srcdir)/CommentParser.java +$(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class # Compiles java files then runs the testcase. A testcase is only run if # a file is found which has _runme.java appended after the testcase name. @@ -116,7 +120,7 @@ $(DOXYGEN_TEST_CASES:=.cpptest): DOXYGEN_COMMENT_PARSER := $(srcdir)/CommentPars run_testcase = \ cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(DOXYGEN_COMMENT_PARSER) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath $(JAVA_CLASSPATH) $*_runme; \ fi From 7373b99079557569202a88a1c3dad8083d2f1113 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Jun 2018 19:12:39 +0100 Subject: [PATCH 0997/2031] JAVA_HOME nad tools.jar not needed for Java testing tools.jar doesn't seem to be needed (in jdk9 anyway), so removing it. --- Doc/Manual/Doxygen.html | 4 +--- Examples/test-suite/java/Makefile.in | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 1e9bbb977..3495684c8 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -1714,9 +1714,7 @@ tool, for example:

      -Runtime tests in Java are implemented using Javadoc doclets. To make that work, you -should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME -environment variable defined and pointing to the JDK location. +Runtime tests in Java are implemented using Javadoc doclets in tools.jar in the JDK.

      The Java's comment parsing code (the testing part) is located in commentParser.java. diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 3ce692080..5af68ec4f 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -6,10 +6,8 @@ LANGUAGE = java JAVA = @JAVA@ JAVAC = @JAVAC@ JAVAFLAGS = @JAVAFLAGS@ -JAVA_CLASSPATH_SEP = @JAVA_CLASSPATH_SEP@ SCRIPTSUFFIX = _runme.java - -JAVA_HOME ?= @JAVA_HOME@ +JAVA_CLASSPATH = . srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ @@ -110,8 +108,6 @@ CommentParser.class: echo "Compiling $(srcdir)/CommentParser.java" $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java -JAVA_CLASSPATH := . -$(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_HOME)/lib/tools.jar$(JAVA_CLASSPATH_SEP)." $(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class # Compiles java files then runs the testcase. A testcase is only run if From b0a42e38e7f92057eb7e693fedc6ff84dc9a7247 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jun 2018 00:40:26 +0100 Subject: [PATCH 0998/2031] Revert "JAVA_HOME nad tools.jar not needed for Java testing" This reverts commit 7373b99079557569202a88a1c3dad8083d2f1113. Seems to be needed for older jdks - needs some more work, as the classpath used is not correct for jdk9. --- Doc/Manual/Doxygen.html | 4 +++- Examples/test-suite/java/Makefile.in | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 3495684c8..1e9bbb977 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -1714,7 +1714,9 @@ tool, for example:

      -Runtime tests in Java are implemented using Javadoc doclets in tools.jar in the JDK. +Runtime tests in Java are implemented using Javadoc doclets. To make that work, you +should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME +environment variable defined and pointing to the JDK location.

      The Java's comment parsing code (the testing part) is located in commentParser.java. diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 5af68ec4f..3ce692080 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -6,8 +6,10 @@ LANGUAGE = java JAVA = @JAVA@ JAVAC = @JAVAC@ JAVAFLAGS = @JAVAFLAGS@ +JAVA_CLASSPATH_SEP = @JAVA_CLASSPATH_SEP@ SCRIPTSUFFIX = _runme.java -JAVA_CLASSPATH = . + +JAVA_HOME ?= @JAVA_HOME@ srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ @@ -108,6 +110,8 @@ CommentParser.class: echo "Compiling $(srcdir)/CommentParser.java" $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java +JAVA_CLASSPATH := . +$(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_HOME)/lib/tools.jar$(JAVA_CLASSPATH_SEP)." $(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class # Compiles java files then runs the testcase. A testcase is only run if From a539d9e1e54388f8df01c71884935f57180f8bb8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jun 2018 00:49:56 +0100 Subject: [PATCH 0999/2031] Remove some debugging in java Makefile --- Examples/test-suite/java/Makefile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 3ce692080..b042193b9 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -107,7 +107,6 @@ setup = \ # Doxygen test cases need to be compiled together with the CommentParser class # which depends on com.sun.javadoc package which is located in this JAR. CommentParser.class: - echo "Compiling $(srcdir)/CommentParser.java" $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java JAVA_CLASSPATH := . From 369be6fac44a3c295c6df89ed97a7e8e0bc4556f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 9 Jun 2018 18:02:42 +0200 Subject: [PATCH 1000/2031] Add support for std::map<> comparator template argument for Java Allow exporting maps using non-default comparison function, similar to what was done for C# back in 9efaf954c71118d41ba9bf43ed371bbe83093564 --- CHANGES.current | 3 +++ Lib/java/std_map.i | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 70f13c05f..b24242a34 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-09: vadz + [Java] Allow exporting std::map using non-default comparison function. + 2018-06-08: philippkraft [Python] Stop exposing _swigregister to Python. It's not useful for user Python code to call this, and it just clutters the diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 2405571fa..a94a99576 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -18,21 +18,21 @@ namespace std { - template class map { + template > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -42,14 +42,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map::iterator i = self->find(key); return i != self->end(); } } From 7f9883011029674553a2a4b623d459f02b512458 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 11 Jun 2018 15:51:53 +1200 Subject: [PATCH 1001/2031] [Python] Fix new GCC8 warnings in generated code Avoid casts between incompatible function types where possible (when keyword args are in use, it is not possible to avoid such warnings as they are inherent in the design of Python's C API in that particular case). Fixes #1259. --- CHANGES.current | 7 +++++++ Lib/python/pyinit.swg | 4 ++-- Lib/python/pyrun.swg | 20 ++++++++++++++------ Source/Modules/python.cxx | 26 +++++++++++++------------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 70f13c05f..cddeda66a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-11: olly + [Python] Fix new GCC8 warnings in generated code by avoiding casts + between incompatible function types where possible (when keyword + args are in use, it is not possible to avoid such warnings as they + are inherent in the design of Python's C API in that particular + case). Fixes #1259. + 2018-06-08: philippkraft [Python] Stop exposing _swigregister to Python. It's not useful for user Python code to call this, and it just clutters the diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 2d4fe2fb1..7ef70585f 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -347,8 +347,8 @@ SWIG_init(void) { (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL }; static SwigPyGetSet thisown_getset_closure = { - (PyCFunction) SwigPyObject_own, - (PyCFunction) SwigPyObject_own + SwigPyObject_own, + SwigPyObject_own }; static PyGetSetDef thisown_getset_def = { (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 70980c238..90aa80b06 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -445,6 +445,14 @@ SwigPyObject_repr(SwigPyObject *v) return repr; } +/* We need a version taking two PyObject* parameters so it's a valid + * PyCFunction to use in swigobject_methods[]. */ +static PyObject * +SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) +{ + return SwigPyObject_repr((SwigPyObject*)v); +} + SWIGRUNTIME int SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) { @@ -621,12 +629,12 @@ SwigPyObject_own(PyObject *v, PyObject *args) static PyMethodDef swigobject_methods[] = { - {"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, - {"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, - {"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, - {"append", (PyCFunction)SwigPyObject_append, METH_O, "appends another 'this' object"}, - {"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, - {"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, "returns object representation"}, + {"disown", SwigPyObject_disown, METH_NOARGS, "releases ownership of the pointer"}, + {"acquire", SwigPyObject_acquire, METH_NOARGS, "acquires ownership of the pointer"}, + {"own", SwigPyObject_own, METH_VARARGS, "returns/sets ownership of the pointer"}, + {"append", SwigPyObject_append, METH_O, "appends another 'this' object"}, + {"next", SwigPyObject_next, METH_NOARGS, "returns the next 'this' object"}, + {"__repr__",SwigPyObject_repr2, METH_NOARGS, "returns object representation"}, {0, 0, 0, 0} }; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d1144522d..f5770a9a4 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1090,7 +1090,7 @@ public: * ------------------------------------------------------------ */ int add_pyinstancemethod_new() { String *name = NewString("SWIG_PyInstanceMethod_New"); - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); + Printf(methods, "\t { \"%s\", %s, METH_O, NULL},\n", name, name); Delete(name); return 0; } @@ -2507,17 +2507,17 @@ public: if (!kw) { if (n && funpack) { if (num_required == 0 && num_arguments == 0) { - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_NOARGS, ", name, function); + Printf(methods, "\t { \"%s\", %s, METH_NOARGS, ", name, function); } else if (num_required == 1 && num_arguments == 1) { - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, ", name, function); + Printf(methods, "\t { \"%s\", %s, METH_O, ", name, function); } else { - Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); + Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); } } else { - Printf(methods, "\t { (char *)\"%s\", %s, METH_VARARGS, ", name, function); + Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); } } else { - Printf(methods, "\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function); + Printf(methods, "\t { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, ", name, function); } if (!n) { @@ -3898,7 +3898,7 @@ public: if (shadow) { if (builtin) { String *rname = SwigType_namestr(real_classname); - Printf(builtin_methods, " { \"__disown__\", (PyCFunction) Swig::Director::swig_pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname); + Printf(builtin_methods, " { \"__disown__\", Swig::Director::swig_pyobj_disown< %s >, METH_NOARGS, \"\" },\n", rname); Delete(rname); } else { String *symname = Getattr(n, "sym:name"); @@ -4738,13 +4738,13 @@ public: int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; String *ds = have_docstring(n) ? cdocstring(n, AUTODOC_METHOD) : NewString(""); if (check_kwargs(n)) { - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS|METH_KEYWORDS, (char *) \"%s\" },\n", symname, wname, ds); + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, \"%s\" },\n", symname, wname, ds); } else if (argcount == 0) { - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_NOARGS, (char *) \"%s\" },\n", symname, wname, ds); + Printf(builtin_methods, " { \"%s\", %s, METH_NOARGS, \"%s\" },\n", symname, wname, ds); } else if (argcount == 1) { - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_O, (char *) \"%s\" },\n", symname, wname, ds); + Printf(builtin_methods, " { \"%s\", %s, METH_O, \"%s\" },\n", symname, wname, ds); } else { - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, METH_VARARGS, (char *) \"%s\" },\n", symname, wname, ds); + Printf(builtin_methods, " { \"%s\", %s, METH_VARARGS, \"%s\" },\n", symname, wname, ds); } Delete(fullname); Delete(wname); @@ -4845,10 +4845,10 @@ public: Append(pyflags, "METH_VARARGS"); if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_STATICFUNC); - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, (char *) \"%s\" },\n", symname, wname, pyflags, ds); + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"%s\" },\n", symname, wname, pyflags, ds); Delete(ds); } else { - Printf(builtin_methods, " { \"%s\", (PyCFunction) %s, %s, \"\" },\n", symname, wname, pyflags); + Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"\" },\n", symname, wname, pyflags); } Delete(fullname); Delete(wname); From cf3ff894330549c5a633f90118ebf06389c7b535 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Jun 2018 23:39:29 +0100 Subject: [PATCH 1002/2031] Fix doxygen testing for jdk < 9 --- Examples/Makefile.in | 1 - Examples/test-suite/java/Makefile.in | 5 ++--- configure.ac | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index ab4941252..3f07aed29 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -630,7 +630,6 @@ java_run: java_version: $(JAVA) -version $(JAVAC) -version || echo "Unknown javac version" - echo "JAVA_HOME=\"$(JAVA_HOME)\"" # ----------------------------------------------------------------- # Cleaning the java examples diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index b042193b9..cef59274b 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -7,10 +7,9 @@ JAVA = @JAVA@ JAVAC = @JAVAC@ JAVAFLAGS = @JAVAFLAGS@ JAVA_CLASSPATH_SEP = @JAVA_CLASSPATH_SEP@ +JAVA_TOOLS_JAR = @JAVA_TOOLS_JAR@ SCRIPTSUFFIX = _runme.java -JAVA_HOME ?= @JAVA_HOME@ - srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ top_builddir = ../@top_builddir@ @@ -110,7 +109,7 @@ CommentParser.class: $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java JAVA_CLASSPATH := . -$(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_HOME)/lib/tools.jar$(JAVA_CLASSPATH_SEP)." +$(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_TOOLS_JAR)$(JAVA_CLASSPATH_SEP)." $(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class # Compiles java files then runs the testcase. A testcase is only run if diff --git a/configure.ac b/configure.ac index c9e6afe68..4e7e22069 100644 --- a/configure.ac +++ b/configure.ac @@ -1349,6 +1349,7 @@ if test -z "$JAVAINCDIR" ; then if test -r "$d/jni.h" ; then JAVAINCDIR=$d JAVAINC=-I\"$d\" + JAVA_HOME_MAYBE="`dirname $d`" break fi done @@ -1375,6 +1376,26 @@ else fi fi +# Auto-detecting JAVA_HOME is not so easy, below will only work up to and including jdk8 +if test -z "$JAVA_HOME" && test -n "$JAVA_HOME_MAYBE" ; then + AC_MSG_CHECKING(for java jdk from jni include paths) + if test -r "$JAVA_HOME_MAYBE/lib/tools.jar" ; then + JAVA_HOME=$JAVA_HOME_MAYBE + AC_MSG_RESULT([$JAVA_HOME]) + else + AC_MSG_RESULT(not found) + fi +fi + +# Javadoc support required for the Java test-suite is available by default in jdk9+ and in tools.jar in earlier jdk versions +AC_MSG_CHECKING(for java tools.jar) +if test -n "$JAVA_HOME" && test -r "$JAVA_HOME/lib/tools.jar" ; then + JAVA_TOOLS_JAR="$JAVA_HOME/lib/tools.jar" + AC_MSG_RESULT([$JAVA_TOOLS_JAR]) +else + AC_MSG_RESULT(not found) +fi + case $host in *-*-cygwin*) # TODO: Only use this flag if the compiler supports it, later versions of gcc no longer have it @@ -1437,11 +1458,11 @@ fi # Turned off due to spurious warnings in later versions of openjdk-1.8 # JAVAFLAGS=-Xcheck:jni -AC_SUBST(JAVA_HOME) AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAVAINC) AC_SUBST(JAVA_CLASSPATH_SEP) +AC_SUBST(JAVA_TOOLS_JAR) AC_SUBST(JAVADYNAMICLINKING) AC_SUBST(JAVALIBRARYPREFIX) AC_SUBST(JAVASO) From ecf61f8e396db6beed9ea69e64130fb3df57a1a6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Jun 2018 07:10:43 +0100 Subject: [PATCH 1003/2031] Restore Python 3.2/3.3 support --- Doc/Manual/Python.html | 2 +- Lib/python/pyrun.swg | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 46a41a4d8..f3550baf2 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -149,7 +149,7 @@

      This chapter describes SWIG's support of Python. SWIG is compatible -with all recent Python versions (Python 2.7 and Python >= 3.4). If you +with all recent Python versions (Python 2.7 and Python >= 3.2). If you still need to generate bindings which work with older versions of Python, you'll have to use SWIG 3.0.x.

      diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 90aa80b06..34b3a1f41 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -11,8 +11,8 @@ # error "This version of SWIG only supports Python >= 2.7" #endif -#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03040000 -# error "This version of SWIG only supports Python 3 >= 3.4" +#if PY_VERSION_HEX >= 0x03000000 && PY_VERSION_HEX < 0x03020000 +# error "This version of SWIG only supports Python 3 >= 3.2" #endif /* Common SWIG API */ From 56f5b1c3c2bffd07ab2e1574ca75265df3633377 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Jun 2018 08:01:32 +0100 Subject: [PATCH 1004/2031] Restore Travis testing of Python 3.2/3.3 --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7e7af91a2..cabf45568 100644 --- a/.travis.yml +++ b/.travis.yml @@ -119,6 +119,16 @@ matrix: env: SWIGLANG=python # 2.7 sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.2 + sudo: required + dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.3 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.4 From 6bf1cba6b5a1737737bbc84cba5f8906067ea922 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Jun 2018 20:16:11 +0100 Subject: [PATCH 1005/2031] Note versions of Python which are no longer supported in changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index cddeda66a..9ba51c88d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-12: olly,wsfulton + [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1. + 2018-06-11: olly [Python] Fix new GCC8 warnings in generated code by avoiding casts between incompatible function types where possible (when keyword From 47297f34531d8773042ecff23d625da4c9dc2178 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Jun 2018 20:23:48 +0100 Subject: [PATCH 1006/2031] Mark some changes entries as potentially incompatible --- CHANGES.current | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9ba51c88d..f60516cfc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -10,6 +10,8 @@ Version 4.0.0 (in progress) 2018-06-12: olly,wsfulton [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1. + *** POTENTIAL INCOMPATIBILITY *** + 2018-06-11: olly [Python] Fix new GCC8 warnings in generated code by avoiding casts between incompatible function types where possible (when keyword @@ -32,12 +34,16 @@ Version 4.0.0 (in progress) deprecated back in 2008. Use %pragma(php) instead, which has been supported since at least 2005. + *** POTENTIAL INCOMPATIBILITY *** + 2018-06-07: olly [PHP5] Support for PHP5 has been removed. PHP5 is no longer actively supported by the PHP developers and security support for it ends completely at the end of 2018, so it doesn't make sense to include support for it in the upcoming SWIG 4.0.0 release. + *** POTENTIAL INCOMPATIBILITY *** + 2018-06-06: olly [Lua] Improve configure probes for Lua headers and libs used in testsuite. @@ -128,6 +134,8 @@ Version 4.0.0 (in progress) #define ABC 123 #endif + *** POTENTIAL INCOMPATIBILITY *** + 2018-01-15: wsfulton Fix issue #1183. Floating point exception evaluating preprocessor expressions resulting in division by zero. @@ -184,6 +192,8 @@ Version 4.0.0 (in progress) Deprecate Swig::DirectorException::raiseJavaException, please replace usage with Swig::DirectorException::throwException. + *** POTENTIAL INCOMPATIBILITY *** + 2017-10-26: wsfulton Add support for C++11 ref-qualifiers when using directors. From 4079fb927b3761ee4e44ff103f37440cb8f3e260 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Jun 2018 21:05:07 +0100 Subject: [PATCH 1007/2031] Python 3.7 support - deprecation of classes in the collections module Change the base classes in the pyabc.i file to use the collections.abc module instead of collections due to the deprecation of the classes in the collections module in Python 3.7. --- CHANGES.current | 16 +++++++++++++ Doc/Manual/Python.html | 17 +++++++++---- .../python/python_abstractbase_runme3.py | 24 +++++++++++++------ Lib/python/pyabc.i | 14 +++++------ 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f60516cfc..873f2b402 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,22 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-12: wsfulton + [Python] The %pythonabc feature in pyabc.i now uses base classes + collections.abc.MutableSequence + collections.abc.MutableMapping + collections.abc.MutableSet + instead of + collections.MutableSequence + collections.MutableMapping + collections.MutableSet + as the latter are deprecated in Python 3.7 and are due to be removed in Python 3.8. + The classes in collections.abc.* are available from Python 3.3 onwards. If you + require support for Python 3.2, then copy the pyabc.i file and modify by removing + the few instances of the .abc sub-module. + + *** POTENTIAL INCOMPATIBILITY *** + 2018-06-12: olly,wsfulton [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index f3550baf2..799342f6e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6426,7 +6426,8 @@ modify the buffer.

      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 +will automatically gain an appropriate abstract base class from the +collections.abc module. For example, the following SWIG interface:

      @@ -6443,8 +6444,8 @@ namespace std {

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

      @@ -6453,7 +6454,7 @@ used to define an abstract base class for your own C++ class:

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

      @@ -6461,6 +6462,14 @@ For details of abstract base class, please see PEP 3119.

      +

      +Compatibility Note: SWIG-4.0.0 changed the base classes to use the +collections.abc module instead of collections due to the deprecation +of the classes in the collections module in Python 3.7. +The collections.abc module was introduced in Python 3.3 and hence this feature +requires Python 3.3 or later. +

      +

      38.12.4 Byte string output conversion

      diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py index 4fdc79935..9f99dcb54 100644 --- a/Examples/test-suite/python/python_abstractbase_runme3.py +++ b/Examples/test-suite/python/python_abstractbase_runme3.py @@ -1,5 +1,11 @@ +import sys + +# collections.abc requires Python 3.3+ +if sys.version_info[0:2] < (3, 3): + exit(0) + from python_abstractbase import * -from collections import * +import collections.abc # This is expected to fail with -builtin option # Builtin types can't inherit from pure-python abstract bases @@ -10,12 +16,16 @@ if is_python_builtin(): if not is_swig_py3: exit(0) -assert issubclass(Mapii, MutableMapping) -assert issubclass(Multimapii, MutableMapping) -assert issubclass(IntSet, MutableSet) -assert issubclass(IntMultiset, MutableSet) -assert issubclass(IntVector, MutableSequence) -assert issubclass(IntList, MutableSequence) +def check_issubclass(derived, base): + if not issubclass(derived, base): + raise RuntimeError("{} is not a subclass of {}".format(derived, base)) + +check_issubclass(Mapii, collections.abc.MutableMapping) +check_issubclass(Multimapii, collections.abc.MutableMapping) +check_issubclass(IntSet, collections.abc.MutableSet) +check_issubclass(IntMultiset, collections.abc.MutableSet) +check_issubclass(IntVector, collections.abc.MutableSequence) +check_issubclass(IntList, collections.abc.MutableSequence) mapii = Mapii() multimapii = Multimapii() diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i index 12ce65985..fbd91dce4 100644 --- a/Lib/python/pyabc.i +++ b/Lib/python/pyabc.i @@ -1,10 +1,10 @@ %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); +%pythoncode %{import collections.abc%} +%pythonabc(std::vector, collections.abc.MutableSequence); +%pythonabc(std::list, collections.abc.MutableSequence); +%pythonabc(std::map, collections.abc.MutableMapping); +%pythonabc(std::multimap, collections.abc.MutableMapping); +%pythonabc(std::set, collections.abc.MutableSet); +%pythonabc(std::multiset, collections.abc.MutableSet); From 3915e7bd08c2e7cbe76a8f4363c6874be4302d2c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Jun 2018 06:57:53 +0100 Subject: [PATCH 1008/2031] Remove final remnants of GCJ - jstring.i --- Lib/perl5/jstring.i | 48 ----------------------------- Lib/python/jstring.i | 72 -------------------------------------------- Lib/ruby/jstring.i | 44 --------------------------- Lib/tcl/jstring.i | 42 -------------------------- 4 files changed, 206 deletions(-) delete mode 100644 Lib/perl5/jstring.i delete mode 100644 Lib/python/jstring.i delete mode 100644 Lib/ruby/jstring.i delete mode 100644 Lib/tcl/jstring.i diff --git a/Lib/perl5/jstring.i b/Lib/perl5/jstring.i deleted file mode 100644 index 1c179b754..000000000 --- a/Lib/perl5/jstring.i +++ /dev/null @@ -1,48 +0,0 @@ -%include - -%fragment(SWIG_AsVal_frag(jstring),"header") { -SWIGINTERN int -SWIG_AsVal_dec(jstring)(SV *obj, jstring *val) -{ - if (SvPOK(obj)) { - if (val) { - STRLEN len = 0; - char *cstr = SvPV(obj, len); - *val = JvNewStringLatin1(cstr, len); - } - return SWIG_OK; - } - return SWIG_ERROR; -} -} - -%fragment(SWIG_From_frag(jstring),"header") { -SWIGINTERNINLINE SV * -SWIG_From_dec(jstring)(jstring val) -{ - SV *obj = sv_newmortal(); - if (!val) { - sv_setsv(obj, &PL_sv_undef); - } else { - jsize len = JvGetStringUTFLength(val); - if (!len) { - sv_setsv(obj, &PL_sv_undef); - } else { - char *tmp = %new_array(len, char); - JvGetStringUTFRegion(val, 0, len, tmp); - sv_setpvn(obj, tmp, len); - SvUTF8_on(obj); - %delete_array(tmp); - } - } - return obj; -} -} - -%typemaps_asvalfrom(%checkcode(STRING), - %arg(SWIG_AsVal(jstring)), - %arg(SWIG_From(jstring)), - %arg(SWIG_AsVal_frag(jstring)), - %arg(SWIG_From_frag(jstring)), - java::lang::String *); - diff --git a/Lib/python/jstring.i b/Lib/python/jstring.i deleted file mode 100644 index bda95237b..000000000 --- a/Lib/python/jstring.i +++ /dev/null @@ -1,72 +0,0 @@ -%include - -%fragment(SWIG_AsVal_frag(jstring),"header") { -SWIGINTERN int -SWIG_AsVal(jstring)(PyObject *obj, jstring *val) -{ - if (obj == Py_None) { - if (val) *val = 0; - return SWIG_OK; - } - - PyObject *tmp = 0; - int isunicode = PyUnicode_Check(obj); - if (!isunicode && PyString_Check(obj)) { - if (val) { - obj = tmp = PyUnicode_FromObject(obj); - } - isunicode = 1; - } - if (isunicode) { - if (val) { - if (sizeof(Py_UNICODE) == sizeof(jchar)) { - *val = JvNewString((const jchar *) PyUnicode_AS_UNICODE(obj),PyUnicode_GET_SIZE(obj)); - return SWIG_NEWOBJ; - } else { - int len = PyUnicode_GET_SIZE(obj); - Py_UNICODE *pchars = PyUnicode_AS_UNICODE(obj); - *val = JvAllocString (len); - jchar *jchars = JvGetStringChars (*val); - for (int i = 0; i < len; ++i) { - jchars[i] = pchars[i]; - } - return SWIG_NEWOBJ; - } - } - Py_XDECREF(tmp); - return SWIG_OK; - } - return SWIG_TypeError; -} -} - -%fragment(SWIG_From_frag(jstring),"header") { -SWIGINTERNINLINE PyObject * -SWIG_From(jstring)(jstring val) -{ - if (!val) { - return SWIG_Py_Void(); - } - if (sizeof(Py_UNICODE) == sizeof(jchar)) { - return PyUnicode_FromUnicode((const Py_UNICODE *) JvGetStringChars(val), - JvGetStringUTFLength(val)); - } else { - int len = JvGetStringUTFLength(val); - Py_UNICODE pchars[len]; - jchar *jchars = JvGetStringChars(val); - - for (int i = 0; i < len; i++) { - pchars[i] = jchars[i]; - } - return PyUnicode_FromUnicode((const Py_UNICODE *) pchars, len); - } -} -} - -%typemaps_asvalfrom(%checkcode(STRING), - %arg(SWIG_AsVal(jstring)), - %arg(SWIG_From(jstring)), - %arg(SWIG_AsVal_frag(jstring)), - %arg(SWIG_From_frag(jstring)), - java::lang::String *); - diff --git a/Lib/ruby/jstring.i b/Lib/ruby/jstring.i deleted file mode 100644 index 17efa978d..000000000 --- a/Lib/ruby/jstring.i +++ /dev/null @@ -1,44 +0,0 @@ -%include - -%fragment(SWIG_AsVal_frag(jstring),"header") { -SWIGINTERN int -SWIG_AsVal(jstring)(VALUE obj, jstring *val) -{ - if (NIL_P(obj)){ - if (val) *val = 0; - return SWIG_OK; - } - if (TYPE(obj) == T_STRING) { - if (val) { - char *cstr = rb_string_value_ptr(&(obj)); - jsize len = RSTRING_LEN(obj); - *val = JvNewStringLatin1(cstr, len); - } - return SWIG_NEWOBJ; - } - return SWIG_TypeError; -} -} - -%fragment(SWIG_From_frag(jstring),"header") { -SWIGINTERNINLINE VALUE -SWIG_From(jstring)(jstring val) -{ - if (!val) { - return Qnil; - } else { - jint len = JvGetStringUTFLength(val); - char buf[len]; - JvGetStringUTFRegion(val, 0, len, buf); - return rb_str_new(buf,len); - } -} -} - -%typemaps_asvalfrom(%checkcode(STRING), - %arg(SWIG_AsVal(jstring)), - %arg(SWIG_From(jstring)), - %arg(SWIG_AsVal_frag(jstring)), - %arg(SWIG_From_frag(jstring)), - java::lang::String *); - diff --git a/Lib/tcl/jstring.i b/Lib/tcl/jstring.i deleted file mode 100644 index 7fb7b89fe..000000000 --- a/Lib/tcl/jstring.i +++ /dev/null @@ -1,42 +0,0 @@ -%include - -%fragment(SWIG_AsVal_frag(jstring),"header") { -SWIGINTERN int -SWIG_AsVal_dec(jstring)(Tcl_Obj * obj, jstring *val) -{ - int len = 0; - const char *cstr = Tcl_GetStringFromObj(obj, &len); - if (!cstr || (strcmp(cstr,"NULL") == 0)) { - if (val) *val = 0; - return SWIG_OK; - } else { - int len = 0; - const Tcl_UniChar *ucstr = Tcl_GetUnicodeFromObj(obj,&len); - if (val) { - *val = JvNewString((const jchar*)ucstr, len); - } - } - - return SWIG_NEWOBJ; -} -} - -%fragment(SWIG_From_frag(jstring),"header") { -SWIGINTERNINLINE Tcl_Obj * -SWIG_From_dec(jstring)(jstring val) -{ - if (!val) { - return Tcl_NewStringObj("NULL",-1); - } else { - return Tcl_NewUnicodeObj((Tcl_UniChar *)JvGetStringChars(val),JvGetStringUTFLength(val)); - } -} -} - -%typemaps_asvalfrom(%checkcode(STRING), - %arg(SWIG_AsVal(jstring)), - %arg(SWIG_From(jstring)), - %arg(SWIG_AsVal_frag(jstring)), - %arg(SWIG_From_frag(jstring)), - java::lang::String *); - From e96316bf316434be43e1f4ef21d3b0d739598c64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Jun 2018 19:14:52 +0100 Subject: [PATCH 1009/2031] Fix seg fault using Python 2 invalid utf-8 strings and wstring Fixes seg fault when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: %include void instring(const std::wstring& s); instring(b"h\xe9llooo") # Python --- CHANGES.current | 9 ++++++++ Doc/Manual/Python.html | 1 + Examples/test-suite/li_std_wstring.i | 8 +++++++ .../test-suite/python/li_std_wstring_runme.py | 23 +++++++++++++++++++ Lib/python/pywstrings.swg | 20 ++++++++++++---- 5 files changed, 57 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 873f2b402..c9aaecb62 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-15: wsfulton + [Python] Fix seg fault using Python 2 when passing a Python string, containing + invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: + + %include + void instring(const std::wstring& s); + + instring(b"h\xe9llooo") # Python + 2018-06-12: wsfulton [Python] The %pythonabc feature in pyabc.i now uses base classes collections.abc.MutableSequence diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 799342f6e..1a2fd9e81 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6501,6 +6501,7 @@ void instring(const char *s) {

      +Note that "\xe9" is an invalid UTF-8 encoding, but "\xc3\xb6" is valid. When this method is called from Python 3, the return value is the following text string:

      diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index 6c0929ae5..b2b7305da 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -94,6 +94,14 @@ void test_throw() TESTCASE_THROW1(std::wstring){ throw x; } +const char * non_utf8_c_str() { + return "h\xe9llo"; +} + +size_t size_wstring(const std::wstring& s) { + return s.size(); +} + #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } #else diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index e93196b80..bd49a4371 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -1,4 +1,5 @@ import li_std_wstring +import sys x = u"h" @@ -81,3 +82,25 @@ if b.name != "hello": b.a = li_std_wstring.A("hello") if b.a != u"hello": raise RuntimeError("bad string mapping") + +# Byte strings only converted in Python 2 +if sys.version_info[0:2] < (3, 0): + x = b"hello there" + if li_std_wstring.test_value(x) != x: + raise RuntimeError("bad string mapping") + +# Invalid utf-8 in a byte string fails in all versions +x = b"h\xe9llo" +try: + li_std_wstring.test_value(x) + raise RuntimeError("TypeError not thrown") +except TypeError: + pass + +# Check surrogateescape +if sys.version_info[0:2] > (3, 1): + x = u"h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo" + if li_std_wstring.non_utf8_c_str() != x: + raise RuntimeError("surrogateescape not working") + if li_std_wstring.size_wstring(x) != 5 and len(x) != 5: + raise RuntimeError("Unexpected length") diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index e64618762..a3b1f4f69 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -18,16 +18,28 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) int isunicode = PyUnicode_Check(obj); %#if PY_VERSION_HEX < 0x03000000 && !defined(SWIG_PYTHON_STRICT_UNICODE_WCHAR) if (!isunicode && PyString_Check(obj)) { - obj = tmp = PyUnicode_FromObject(obj); - isunicode = 1; + tmp = PyUnicode_FromObject(obj); + if (tmp) { + isunicode = 1; + obj = tmp; + } else { + PyErr_Clear(); + return SWIG_TypeError; + } } %#endif if (isunicode) { Py_ssize_t len = PyUnicode_GetSize(obj); if (cptr) { + Py_ssize_t length; *cptr = %new_array(len + 1, wchar_t); - PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); - (*cptr)[len] = 0; + length = PyUnicode_AsWideChar(SWIGPY_UNICODE_ARG(obj), *cptr, len); + if (length == -1) { + PyErr_Clear(); + Py_XDECREF(tmp); + return SWIG_TypeError; + } + (*cptr)[length] = 0; } if (psize) *psize = (size_t) len + 1; if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0; From 1665712fcb8692cccb0f13df243d2f41c21e31cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Jun 2018 19:34:36 +0100 Subject: [PATCH 1010/2031] Python 3.7 support: Remove use of deprecated PyUnicode_GetSize --- CHANGES.current | 6 +++++- Lib/python/pywstrings.swg | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index c9aaecb62..9fb57f9f0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -16,8 +16,12 @@ Version 4.0.0 (in progress) instring(b"h\xe9llooo") # Python +2018-06-15: wsfulton + [Python] Python 3.7 support: Replace use of deprecated PyUnicode_GetSize with + PyUnicode_GetLength to remove deprecated warnings compiling the C/C++ wrappers. + 2018-06-12: wsfulton - [Python] The %pythonabc feature in pyabc.i now uses base classes + [Python] Python 3.7 support: The %pythonabc feature in pyabc.i now uses base classes collections.abc.MutableSequence collections.abc.MutableMapping collections.abc.MutableSet diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index a3b1f4f69..0e5a78df5 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -29,7 +29,11 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) } %#endif if (isunicode) { +%#if PY_VERSION_HEX >= 0x03030000 + Py_ssize_t len = PyUnicode_GetLength(obj); +%#else Py_ssize_t len = PyUnicode_GetSize(obj); +%#endif if (cptr) { Py_ssize_t length; *cptr = %new_array(len + 1, wchar_t); From 57f7070406c347a566daf5d084a2ecf7876f8ecf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Jun 2018 19:40:35 +0100 Subject: [PATCH 1011/2031] Turn on Travis testing of Python 3.7 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index cabf45568..7b2b41c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -144,6 +144,11 @@ matrix: env: SWIGLANG=python PY3=3 VER=3.6 sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.7 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin From d22ecafb36c2e97aa3a2d140d232f8753b542d61 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 15:31:49 +0100 Subject: [PATCH 1012/2031] Fix Java doxygen:notranslate for single line comments Remove extra generated line --- Examples/test-suite/doxygen_basic_notranslate.i | 6 ++++++ .../test-suite/java/doxygen_basic_notranslate_runme.java | 7 ++++--- .../test-suite/python/doxygen_basic_notranslate_runme.py | 3 +++ Source/Doxygen/javadoc.cxx | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/doxygen_basic_notranslate.i b/Examples/test-suite/doxygen_basic_notranslate.i index 45e36c6e3..e62be5437 100644 --- a/Examples/test-suite/doxygen_basic_notranslate.i +++ b/Examples/test-suite/doxygen_basic_notranslate.i @@ -2,6 +2,7 @@ %include "doxygen_basic_translate.h" %feature("doxygen:notranslate") function; +%feature("doxygen:notranslate") function1; %feature("doxygen:notranslate") function2; %feature("doxygen:notranslate") function3; %feature("doxygen:notranslate") function4; @@ -25,6 +26,11 @@ int function() return 0; } +/** Single line comment */ +void function1() +{ +} + /** * A test of a very very very very very very very very very very very very very very very very * very very very very very long comment string. diff --git a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java index d1c433545..e3d9b0279 100644 --- a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java @@ -61,8 +61,7 @@ public class doxygen_basic_notranslate_runme { " \n" + ""); wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function5(int)", - " This is a post comment. \n" + - ""); + " This is a post comment. "); wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function7(doxygen_basic_notranslate.SWIGTYPE_p_p_p_Shape)", " \n" + " Test for a parameter with difficult type\n" + @@ -88,6 +87,8 @@ public class doxygen_basic_notranslate_runme { " @param a Some parameter, default is 42\n" + " \n" + ""); + wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function1()", + " Single line comment "); wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function2()", " \n" + " A test of a very very very very very very very very very very very very very very very very\n" + @@ -98,4 +99,4 @@ public class doxygen_basic_notranslate_runme { // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } -} \ No newline at end of file +} diff --git a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py index 81ac99975..1e654effc 100644 --- a/Examples/test-suite/python/doxygen_basic_notranslate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_notranslate_runme.py @@ -14,6 +14,9 @@ The comment text \sa function2""" ) +comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function1), + r"""Single line comment """ +) comment_verifier.check(inspect.getdoc(doxygen_basic_notranslate.function2), r"""A test of a very very very very very very very very very very very very very very very very very very very very very long comment string.""" diff --git a/Source/Doxygen/javadoc.cxx b/Source/Doxygen/javadoc.cxx index 3b81c55a5..18eaeb42d 100644 --- a/Source/Doxygen/javadoc.cxx +++ b/Source/Doxygen/javadoc.cxx @@ -718,10 +718,12 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) { size_t idx = doc.find('\n'); size_t indent = 0; + bool singleLineComment = idx == string::npos; // Detect indentation. // The first line in comment is the one after '/**', which may be // spaces and '\n' or the text. In any case it is not suitable to detect // indentation, so we have to skip the first '\n'. + // However, if there is just one line, then use that line to detect indentation. if (idx != string::npos) { size_t nonspaceIdx = doc.find_first_not_of(" \t", idx + 1); if (nonspaceIdx != string::npos) { @@ -767,7 +769,8 @@ std::string JavaDocConverter::indentAndInsertAsterisks(const string &doc) { size_t nonspaceEndIdx = translatedStr.find_last_not_of(" \t"); if (nonspaceEndIdx != string::npos) { if (translatedStr[nonspaceEndIdx] != '\n') { - translatedStr += '\n'; + if (!singleLineComment) + translatedStr += '\n'; } else { // remove trailing spaces translatedStr = translatedStr.substr(0, nonspaceEndIdx + 1); From 50d7f36f453b5a14523a99de42d6592fc56dd625 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 20:56:22 +0100 Subject: [PATCH 1013/2031] Correct JavaDoc from doxygen comments indentation Adds missing JavaDoc indentation for doxygen comments obtained from: - enum values - class methods - constructors - global functions/variables --- Source/Doxygen/doxytranslator.cxx | 23 +++++++++++++++-- Source/Doxygen/doxytranslator.h | 3 ++- Source/Doxygen/javadoc.cxx | 4 +-- Source/Modules/java.cxx | 43 +++++++++++++++---------------- Source/Modules/python.cxx | 2 +- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/Source/Doxygen/doxytranslator.cxx b/Source/Doxygen/doxytranslator.cxx index 2684adcea..fb21de75c 100644 --- a/Source/Doxygen/doxytranslator.cxx +++ b/Source/Doxygen/doxytranslator.cxx @@ -31,14 +31,33 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) { return Getattr(node, "doxygen"); } +/** + * Indent all lines in the comment by given indentation string + */ +void DoxygenTranslator::extraIndentation(String *comment, const_String_or_char_ptr indentationString) { + if (indentationString || Len(indentationString) > 0) { + int len = Len(comment); + bool trailing_newline = len > 0 && *(Char(comment) + len - 1) == '\n'; + Insert(comment, 0, indentationString); + String *replace = NewStringf("\n%s", indentationString); + Replaceall(comment, "\n", replace); + if (trailing_newline) { + len = Len(comment); + Delslice(comment, len - 2, len); // Remove added trailing spaces on last line + } + Delete(replace); + } +} -String *DoxygenTranslator::getDocumentation(Node *node) { +String *DoxygenTranslator::getDocumentation(Node *node, const_String_or_char_ptr indentationString) { if (!hasDocumentation(node)) { return NewString(""); } - return makeDocumentation(node); + String *documentation = makeDocumentation(node); + extraIndentation(documentation, indentationString); + return documentation; } diff --git a/Source/Doxygen/doxytranslator.h b/Source/Doxygen/doxytranslator.h index ffc378a7b..f07b632a2 100644 --- a/Source/Doxygen/doxytranslator.h +++ b/Source/Doxygen/doxytranslator.h @@ -56,7 +56,7 @@ public: * Return the documentation for a given node formated for the correct * documentation system. */ - String *getDocumentation(Node *node); + String *getDocumentation(Node *node, const_String_or_char_ptr indentationString); /* * Returns truem is the specified node has comment attached. @@ -84,6 +84,7 @@ protected: */ void printTree(const DoxygenEntityList &entityList); + void extraIndentation(String *comment, const_String_or_char_ptr indentationString); }; #endif diff --git a/Source/Doxygen/javadoc.cxx b/Source/Doxygen/javadoc.cxx index 18eaeb42d..628f5a666 100644 --- a/Source/Doxygen/javadoc.cxx +++ b/Source/Doxygen/javadoc.cxx @@ -795,9 +795,7 @@ String *JavaDocConverter::makeDocumentation(Node *node) { string translatedStr = indentAndInsertAsterisks(doc); - String *comment = NewString(translatedStr.c_str()); - // Append(comment, documentation); Replaceall(comment, "\n", "\n * "); - return comment; + return NewString(translatedStr.c_str()); } DoxygenEntityList entityList = parser.createTree(node, documentation); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 69abf6a80..195ad5a90 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -592,9 +592,9 @@ public: Printf(f_module, "%s\n", module_imports); if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); if (comment_creation_chatter) - Printf(f_module, "/* This was generated from top() */"); + Printf(f_module, "/* This was generated from top() */\n"); Printv(f_module, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1275,10 +1275,9 @@ public: String *typemap_lookup_type = Getattr(n, "name"); if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); - if (comment_creation_chatter) { - Printf(enum_code, "/* This was generated from enumDeclaration() */"); - } + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); + if (comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumDeclaration() */\n"); Printv(enum_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1307,9 +1306,9 @@ public: } else { // Translate and write javadoc comment for the enum itself if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); if (comment_creation_chatter) - Printf(constants_code, "/* This was generated from enumDeclaration() */"); + Printf(constants_code, "/* This was generated from enumDeclaration() */\n"); Printf(constants_code, "/* Comment for enum %s */\n", Getattr(n, "unnamedinstance") ? "" : symname); Printf(constants_code, Char(doxygen_comments)); Printf(constants_code, "\n"); @@ -1474,9 +1473,9 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) - Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */\n"); Printv(enum_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -1559,9 +1558,9 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); if (comment_creation_chatter) - Printf(constants_code, "/* This was generated from constantWrapper() */"); + Printf(constants_code, "/* This was generated from constantWrapper() */\n"); Printv(constants_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -2008,9 +2007,9 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); if (comment_creation_chatter) - Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */"); + Printf(proxy_class_def, "/* This was generated from emitProxyClassDefAndCPPCasts() */\n"); Printv(proxy_class_def, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -2505,9 +2504,9 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) - Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */"); + Printf(function_code, "/* This was generated from proxyclassfunctionhandler() */\n"); Printv(function_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -2747,11 +2746,11 @@ public: tm = Getattr(n, "tmap:jtype"); // typemaps were attached earlier to the node Printf(im_return_type, "%s", tm); - // Translate and write javadoc comment if flagged - if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + // Translate and write javadoc comment if flagged + if (doxygen && doxygenTranslator->hasDocumentation(n)) { + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) - Printf(function_code, "/* This was generated from constructionhandler() */"); + Printf(function_code, "/* This was generated from constructionhandler() */\n"); Printv(function_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } @@ -3023,9 +3022,9 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) - Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */"); + Printf(function_code, "/* This was generated from moduleClassFunctionHandler() */\n"); Printv(function_code, doxygen_comments, NIL); Delete(doxygen_comments); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f5770a9a4..bdbb4e9b9 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1678,7 +1678,7 @@ public: if (doxygen) { docstr = Getattr(n, "python:docstring"); if (!docstr && doxygenTranslator->hasDocumentation(n)) { - docstr = doxygenTranslator->getDocumentation(n); + docstr = doxygenTranslator->getDocumentation(n, 0); // Avoid rebuilding it again the next time: notice that we can't do // this for the combined doc string as autodoc part of it depends on From ecc66fdcbdf86e1dd945f6ea9d393fa4476495a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 22:36:08 +0100 Subject: [PATCH 1014/2031] Add Doxygen test for constant and fix JavaDoc indentation --- Examples/test-suite/doxygen_parsing.i | 5 +++++ Examples/test-suite/java/doxygen_parsing_runme.java | 3 +++ Source/Modules/java.cxx | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index 670d8699b..7ff19ecfa 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -36,6 +36,11 @@ struct SomeStruct */ int someVar=42; +/** + * The constant comment + */ +#define CONSTANT_VALUE 4242 + class SomeAnotherClass { public: diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index 7a8b0fae9..167010544 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -125,6 +125,9 @@ public class doxygen_parsing_runme { wantedComments.put("doxygen_parsing.SomeAnotherClass.setClassAttr2(int)", "The class attribute post-comment \n" + ""); + wantedComments.put("doxygen_parsing.doxygen_parsingConstants.CONSTANT_VALUE", + "The constant comment \n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 195ad5a90..a245da208 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1558,7 +1558,7 @@ public: // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) Printf(constants_code, "/* This was generated from constantWrapper() */\n"); Printv(constants_code, Char(doxygen_comments), NIL); From ae3218070929e5b0e812b116c7d495262a442bb2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 23:28:58 +0100 Subject: [PATCH 1015/2031] Remove duplicate doxygen comment when using simple Java enums --- Source/Modules/java.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index a245da208..7680148fc 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1274,17 +1274,17 @@ public: EnumFeature enum_feature = decodeEnumFeature(n); String *typemap_lookup_type = Getattr(n, "name"); - if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); - if (comment_creation_chatter) - Printf(enum_code, "/* This was generated from enumDeclaration() */\n"); - Printv(enum_code, Char(doxygen_comments), NIL); - Delete(doxygen_comments); - } - if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum + if (doxygen && doxygenTranslator->hasDocumentation(n)) { + String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); + if (comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumDeclaration() */\n"); + Printv(enum_code, Char(doxygen_comments), NIL); + Delete(doxygen_comments); + } + String *scope = getCurrentScopeName(nspace); if (!addSymbol(symname, n, scope)) return SWIG_ERROR; From cb8d42b750db3a6a34f0071a6b3cae1344fa318f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 23:38:02 +0100 Subject: [PATCH 1016/2031] Doxygen comment JavaDoc indentation fix for simple Java enums --- Source/Modules/java.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7680148fc..fee37028c 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1306,10 +1306,10 @@ public: } else { // Translate and write javadoc comment for the enum itself if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { - String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); + String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) Printf(constants_code, "/* This was generated from enumDeclaration() */\n"); - Printf(constants_code, "/* Comment for enum %s */\n", Getattr(n, "unnamedinstance") ? "" : symname); + Printf(constants_code, " /* Comment for enum %s */\n", Getattr(n, "unnamedinstance") ? "" : symname); Printf(constants_code, Char(doxygen_comments)); Printf(constants_code, "\n"); Delete(doxygen_comments); From 5cfb04adb7124904abad021a3f32b2259ec2cba3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Jun 2018 23:51:16 +0100 Subject: [PATCH 1017/2031] Show enum name in presence of Doxygen comment for simple Java enums --- Source/Modules/java.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index fee37028c..c725f7870 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1304,17 +1304,17 @@ public: Replaceall(enum_code, "$static ", ""); Delete(scope); } else { + if (symname && !Getattr(n, "unnamedinstance")) + Printf(constants_code, " // %s \n", symname); // Translate and write javadoc comment for the enum itself if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { String *doxygen_comments = doxygenTranslator->getDocumentation(n, " "); if (comment_creation_chatter) Printf(constants_code, "/* This was generated from enumDeclaration() */\n"); - Printf(constants_code, " /* Comment for enum %s */\n", Getattr(n, "unnamedinstance") ? "" : symname); Printf(constants_code, Char(doxygen_comments)); Printf(constants_code, "\n"); Delete(doxygen_comments); - } else if (symname && !Getattr(n, "unnamedinstance")) - Printf(constants_code, " // %s \n", symname); + } } // Emit each enum item From 9f3ee5b9656072909cf729d2093fa38a6190b202 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Jun 2018 00:10:06 +0100 Subject: [PATCH 1018/2031] Doxygen JavaDoc class comments fix Generate "javaimports" typemap contents before Doxygen JavaDoc comments. --- Source/Modules/java.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index c725f7870..ac845cb09 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2005,6 +2005,13 @@ public: // Pure Java interfaces const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); + if (*Char(interface_list) && *Char(pure_interfaces)) + Append(interface_list, ", "); + Append(interface_list, pure_interfaces); + // Start writing the proxy class + if (!has_outerclass) // Import statements + Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE),"\n", NIL); + // Translate and write javadoc comment if flagged if (doxygen && doxygenTranslator->hasDocumentation(n)) { String *doxygen_comments = doxygenTranslator->getDocumentation(n, 0); @@ -2013,14 +2020,8 @@ public: Printv(proxy_class_def, Char(doxygen_comments), NIL); Delete(doxygen_comments); } - - if (*Char(interface_list) && *Char(pure_interfaces)) - Append(interface_list, ", "); - Append(interface_list, pure_interfaces); - // Start writing the proxy class - if (!has_outerclass) // Import statements - Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE),"\n", NIL); - else + + if (has_outerclass) Printv(proxy_class_def, "static ", NIL); // C++ nested classes correspond to static java classes Printv(proxy_class_def, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases @@ -2510,7 +2511,7 @@ public: Printv(function_code, Char(doxygen_comments), NIL); Delete(doxygen_comments); } - + /* Start generating the proxy function */ const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); @@ -2518,7 +2519,7 @@ public: if (static_flag) Printf(function_code, "static "); Printf(function_code, "%s %s(", return_type, proxy_function_name); - + if (is_interface) Printf(interface_class_code, " %s %s(", return_type, proxy_function_name); From c5f9bb1e41efb14e7bdb09cbfd1246730c8321f4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Jun 2018 07:43:27 +0100 Subject: [PATCH 1019/2031] Add doxygen test for nested classes --- Examples/test-suite/common.mk | 1 + Examples/test-suite/doxygen_nested_class.i | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 Examples/test-suite/doxygen_nested_class.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 520c1bbfe..f4c871328 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -612,6 +612,7 @@ DOXYGEN_TEST_CASES += \ doxygen_basic_translate \ doxygen_ignore \ doxygen_misc_constructs \ + doxygen_nested_class \ doxygen_parsing \ doxygen_parsing_enums \ doxygen_translate \ diff --git a/Examples/test-suite/doxygen_nested_class.i b/Examples/test-suite/doxygen_nested_class.i new file mode 100644 index 000000000..2078392c4 --- /dev/null +++ b/Examples/test-suite/doxygen_nested_class.i @@ -0,0 +1,23 @@ +%module doxygen_nested_class + +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) DoxOuter::DoxInner; + +%inline %{ + +struct DoxOuter { + /** DoxOuter constructor */ + DoxOuter() {} + struct DoxInner { + /** DoxInner constructor */ + DoxInner() {} + /** doxInt variable */ + int doxInt; + /** doxShort const variable */ + static const short doxShort = 1.0; + /** doxMethod description */ + void doxMethod() {} + /** doxStaticMethod description */ + static void doxStaticMethod() {} + }; +}; +%} From 9cc05724efb1c6abc26066b2c50b3ee164920c10 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Jun 2018 18:55:14 +0100 Subject: [PATCH 1020/2031] Add java runtime test for nested classes --- .../java/doxygen_nested_class_runme.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Examples/test-suite/java/doxygen_nested_class_runme.java diff --git a/Examples/test-suite/java/doxygen_nested_class_runme.java b/Examples/test-suite/java/doxygen_nested_class_runme.java new file mode 100644 index 000000000..1c6e64a4f --- /dev/null +++ b/Examples/test-suite/java/doxygen_nested_class_runme.java @@ -0,0 +1,46 @@ +import doxygen_nested_class.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_nested_class_runme { + static { + try { + System.loadLibrary("doxygen_nested_class"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + CommentParser parser = new CommentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_nested_class runtime test", + "CommentParser", + new String[]{"-quiet", "doxygen_nested_class"}); + + HashMap wantedComments = new HashMap(); + +// wantedComments.put("doxygen_nested_class.DoxOuter.DoxOuter()", +// " DoxOuter constructor "); +// wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.DoxInner()", +// " DoxInner constructor "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.setDoxInt(int)", + " doxInt variable "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.getDoxInt()", + " doxInt variable "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxMethod()", + " doxMethod description "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxStaticMethod()", + " doxStaticMethod description "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.doxShort", + " doxShort const variable "); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} From 602b0d5a2c3d4fa0e0af0d9c6c64a62663f6092a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Jun 2018 18:56:21 +0100 Subject: [PATCH 1021/2031] Add doxygen testing of Java constructor wrappers --- Examples/test-suite/doxygen_nested_class.i | 1 + Examples/test-suite/doxygen_parsing.i | 1 + Examples/test-suite/java/CommentParser.java | 4 ++++ .../test-suite/java/doxygen_nested_class_runme.java | 10 ++++++---- Examples/test-suite/java/doxygen_parsing_runme.java | 6 ++++++ Examples/test-suite/python/doxygen_parsing_runme.py | 2 ++ 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/doxygen_nested_class.i b/Examples/test-suite/doxygen_nested_class.i index 2078392c4..91218e2bc 100644 --- a/Examples/test-suite/doxygen_nested_class.i +++ b/Examples/test-suite/doxygen_nested_class.i @@ -7,6 +7,7 @@ struct DoxOuter { /** DoxOuter constructor */ DoxOuter() {} + /** DoxInner class description */ struct DoxInner { /** DoxInner constructor */ DoxInner() {} diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index 7ff19ecfa..21b51bc51 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -41,6 +41,7 @@ int someVar=42; */ #define CONSTANT_VALUE 4242 +/// SomeAnotherClass description class SomeAnotherClass { public: diff --git a/Examples/test-suite/java/CommentParser.java b/Examples/test-suite/java/CommentParser.java index c8adc1d1e..7dc6d591d 100644 --- a/Examples/test-suite/java/CommentParser.java +++ b/Examples/test-suite/java/CommentParser.java @@ -34,6 +34,10 @@ public class CommentParser { if (f.getRawCommentText().length() > 0) m_parsedComments.put(f.qualifiedName(), f.getRawCommentText()); } + for (ConstructorDoc c : classDoc.constructors()) { + if (c.getRawCommentText().length() > 0) + m_parsedComments.put(c.toString(), c.getRawCommentText()); + } for (MethodDoc m : classDoc.methods()) { if (m.getRawCommentText().length() > 0) m_parsedComments.put(m.toString(), m.getRawCommentText()); diff --git a/Examples/test-suite/java/doxygen_nested_class_runme.java b/Examples/test-suite/java/doxygen_nested_class_runme.java index 1c6e64a4f..3ffa796f0 100644 --- a/Examples/test-suite/java/doxygen_nested_class_runme.java +++ b/Examples/test-suite/java/doxygen_nested_class_runme.java @@ -25,10 +25,12 @@ public class doxygen_nested_class_runme { HashMap wantedComments = new HashMap(); -// wantedComments.put("doxygen_nested_class.DoxOuter.DoxOuter()", -// " DoxOuter constructor "); -// wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.DoxInner()", -// " DoxInner constructor "); + wantedComments.put("doxygen_nested_class.DoxOuter()", + " DoxOuter constructor "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner", + " DoxInner class description "); + wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner()", + " DoxInner constructor "); wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.setDoxInt(int)", " doxInt variable "); wantedComments.put("doxygen_nested_class.DoxOuter.DoxInner.getDoxInt()", diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index 167010544..d58b1f486 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -26,6 +26,12 @@ public class doxygen_parsing_runme { HashMap wantedComments = new HashMap(); + wantedComments.put("doxygen_parsing.SomeAnotherClass", + " SomeAnotherClass description"); + wantedComments.put("doxygen_parsing.SomeAnotherClass(int)", + " First overloaded constructor."); + wantedComments.put("doxygen_parsing.SomeAnotherClass(java.lang.String)", + " Second overloaded constructor."); wantedComments.put("doxygen_parsing.SomeAnotherClass.getClassAttr()", " The class attribute comment \n" + " \n" + diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index 14579281d..f09f50761 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -11,6 +11,8 @@ comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeClass), "The class comment") comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeStruct), "The struct comment") +comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass), + "SomeAnotherClass description") # There doesn't seem to be any way to specify the doc string for __init__ when # using "-builtin" (see http://stackoverflow.com/q/11913492/15275), so skip From 6f2399e86da13a9feb436e3977e15d2b9738294e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Jun 2018 19:40:16 +0100 Subject: [PATCH 1022/2031] Switch Travis additional testing from python 3.6 to 3.7 --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b2b41c0f..8747913d0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -159,7 +159,7 @@ matrix: sudo: required dist: trusty - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 PY3=3 VER=3.6 + env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 PY3=3 VER=3.7 sudo: required dist: trusty - compiler: gcc @@ -174,12 +174,12 @@ matrix: dist: trusty - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.6 + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 sudo: required dist: trusty - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.6 SWIGOPTPY3= + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 SWIGOPTPY3= sudo: required dist: trusty - compiler: gcc @@ -291,7 +291,7 @@ matrix: sudo: required dist: trusty - os: linux - env: SWIGLANG=python SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 PY3=3 VER=3.6 + env: SWIGLANG=python SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 PY3=3 VER=3.7 sudo: required dist: trusty - compiler: gcc From d956081fd3e761aaa62409335adc2f36a54ff09f Mon Sep 17 00:00:00 2001 From: Petr Mitrichev Date: Thu, 28 Jun 2018 14:27:52 +0200 Subject: [PATCH 1023/2031] Avoid function-local statics that call Python code to avoid deadlocks with GIL --- Lib/python/pyinit.swg | 5 ++++ Lib/python/pyrun.swg | 53 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 7ef70585f..ea865c066 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -431,6 +431,11 @@ SWIG_init(void) { SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); #endif + SWIG_Py_None_global_Init(); + SwigPyObject_type_global_Init(); + SwigPyPacked_type_global_Init(); + SWIG_Python_TypeCache_global_Init(); + SWIG_InstallConstants(d,swig_const_table); %} diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 34b3a1f41..c0d96a014 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -258,11 +258,24 @@ _SWIG_Py_None(void) Py_DECREF(none); return none; } -SWIGRUNTIME PyObject * + +static PyObject *SWIG_Py_None_global = 0; + +SWIGRUNTIME void SWIG_Py_None_global_Init(void) { + SWIG_Py_None_global = _SWIG_Py_None(); +} + +SWIGRUNTIME PyObject * SWIG_Py_None(void) { - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; + assert(SWIG_Py_None_global); + return SWIG_Py_None_global; +} + +#else +SWIGRUNTIME void SWIG_Py_None_global_Init(void) +{ + // Do nothing } #endif @@ -488,11 +501,21 @@ SwigPyObject_type(void) { assert(cd->pytype); return cd->pytype; } + +SWIGRUNTIME void SwigPyObject_type_global_Init(void) { + // Do nothing +} #else +static PyTypeObject *SwigPyObject_type_global = 0; + +SWIGRUNTIME void SwigPyObject_type_global_Init(void) { + SwigPyObject_type_global = SwigPyObject_TypeOnce(); +} + SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); - return type; + assert(SwigPyObject_type_global); + return SwigPyObject_type_global; } #endif @@ -836,10 +859,16 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); +static PyTypeObject* SwigPyPacked_type_global = 0; + +SWIGRUNTIME void SwigPyPacked_type_global_Init(void) { + SwigPyPacked_type_global = SwigPyPacked_TypeOnce(); +} + SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); - return type; + assert(SwigPyPacked_type_global); + return SwigPyPacked_type_global; } SWIGRUNTIMEINLINE int @@ -1438,11 +1467,17 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { } } +static PyObject *SWIG_Python_TypeCache_global = 0; + +SWIGRUNTIME void SWIG_Python_TypeCache_global_Init(void) { + SWIG_Python_TypeCache_global = PyDict_New(); +} + /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; + assert(SWIG_Python_TypeCache_global); + return SWIG_Python_TypeCache_global; } SWIGRUNTIME swig_type_info * From 40ea0a960630ee26a7425bbb6d70355de031ff67 Mon Sep 17 00:00:00 2001 From: Petr Mitrichev Date: Thu, 28 Jun 2018 17:33:31 +0200 Subject: [PATCH 1024/2031] Add comments that explain the need for globals. --- Lib/python/pyrun.swg | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index c0d96a014..e262b657e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -259,6 +259,9 @@ _SWIG_Py_None(void) return none; } +/* This used to be a function-local static variable, but accessing Python + * C API from inside a function-local static initializer can lead to deadlocks. + * https://github.com/swig/swig/issues/1275 */ static PyObject *SWIG_Py_None_global = 0; SWIGRUNTIME void SWIG_Py_None_global_Init(void) { @@ -506,6 +509,9 @@ SWIGRUNTIME void SwigPyObject_type_global_Init(void) { // Do nothing } #else +/* This used to be a function-local static variable, but accessing Python + * C API from inside a function-local static initializer can lead to deadlocks. + * https://github.com/swig/swig/issues/1275 */ static PyTypeObject *SwigPyObject_type_global = 0; SWIGRUNTIME void SwigPyObject_type_global_Init(void) { @@ -859,6 +865,9 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); +/* This used to be a function-local static variable, but accessing Python + * C API from inside a function-local static initializer can lead to deadlocks. + * https://github.com/swig/swig/issues/1275 */ static PyTypeObject* SwigPyPacked_type_global = 0; SWIGRUNTIME void SwigPyPacked_type_global_Init(void) { @@ -1467,6 +1476,9 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { } } +/* This used to be a function-local static variable, but accessing Python + * C API from inside a function-local static initializer can lead to deadlocks. + * https://github.com/swig/swig/issues/1275 */ static PyObject *SWIG_Python_TypeCache_global = 0; SWIGRUNTIME void SWIG_Python_TypeCache_global_Init(void) { From b3763c8dc8359af2dca8abc0652ec25f24c7711a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Jun 2018 17:47:01 +0100 Subject: [PATCH 1025/2031] Remove SWIG_STATIC_POINTER (Python) It's use has been removed to discourage thread unsafe static initialisation. --- Lib/python/pyrun.swg | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index e262b657e..51ea81306 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -210,16 +210,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi /* A functor is a function object with one single object argument */ #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj); -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ From 4b4e0180f42e992de6ff458477b70e4ec63ecb49 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Jun 2018 19:18:06 +0100 Subject: [PATCH 1026/2031] Python initialization code tidy up I've moved the initialization of statics a little earlier on - a little safer as it is hard to follow exactly when some of these were being used, such as SWIG_Py_None which sometimes replaces Py_None. --- CHANGES.current | 5 ++++ Lib/python/pyinit.swg | 16 ++++++---- Lib/python/pyrun.swg | 70 +++++-------------------------------------- 3 files changed, 24 insertions(+), 67 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9fb57f9f0..2a5c1c9ac 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-30: petrmitrichev + [Python] #1275 #1279 Remove function-local statics that call Python code + in order to avoid deadlocks with multi-threaded usage. These are now + file scope static variables and are initialized during module initialization. + 2018-06-15: wsfulton [Python] Fix seg fault using Python 2 when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index ea865c066..e15eb0309 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -379,6 +379,14 @@ SWIG_init(void) { assert(metatype); #endif +#ifdef SWIG_PYTHON_BUILD_NONE + SWIG_Py_None_global = Py_BuildValue(""); + Py_DECREF(SWIG_Py_None_global); +#endif + + SWIG_This_global = SWIG_Python_str_FromChar("this"); + SWIG_Python_TypeCache_global = PyDict_New(); + /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); @@ -429,13 +437,11 @@ SWIG_init(void) { SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#else + SwigPyObject_type_global = SwigPyObject_TypeOnce(); #endif - SWIG_Py_None_global_Init(); - SwigPyObject_type_global_Init(); - SwigPyPacked_type_global_Init(); - SWIG_Python_TypeCache_global_Init(); - + SwigPyPacked_type_global = SwigPyPacked_TypeOnce(); SWIG_InstallConstants(d,swig_const_table); %} diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 51ea81306..5ad5713fd 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -241,42 +241,20 @@ extern "C" { # undef Py_None # define Py_None SWIG_Py_None() # endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue(""); - Py_DECREF(none); - return none; -} -/* This used to be a function-local static variable, but accessing Python - * C API from inside a function-local static initializer can lead to deadlocks. - * https://github.com/swig/swig/issues/1275 */ static PyObject *SWIG_Py_None_global = 0; -SWIGRUNTIME void SWIG_Py_None_global_Init(void) { - SWIG_Py_None_global = _SWIG_Py_None(); -} - SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ +SWIG_Py_None(void) { assert(SWIG_Py_None_global); return SWIG_Py_None_global; } - -#else -SWIGRUNTIME void SWIG_Py_None_global_Init(void) -{ - // Do nothing -} #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ +SWIG_Py_Void(void) { PyObject *none = Py_None; Py_INCREF(none); return none; @@ -485,6 +463,7 @@ SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; + SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; @@ -494,20 +473,9 @@ SwigPyObject_type(void) { assert(cd->pytype); return cd->pytype; } - -SWIGRUNTIME void SwigPyObject_type_global_Init(void) { - // Do nothing -} #else -/* This used to be a function-local static variable, but accessing Python - * C API from inside a function-local static initializer can lead to deadlocks. - * https://github.com/swig/swig/issues/1275 */ static PyTypeObject *SwigPyObject_type_global = 0; -SWIGRUNTIME void SwigPyObject_type_global_Init(void) { - SwigPyObject_type_global = SwigPyObject_TypeOnce(); -} - SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { assert(SwigPyObject_type_global); @@ -855,15 +823,8 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); -/* This used to be a function-local static variable, but accessing Python - * C API from inside a function-local static initializer can lead to deadlocks. - * https://github.com/swig/swig/issues/1275 */ static PyTypeObject* SwigPyPacked_type_global = 0; -SWIGRUNTIME void SwigPyPacked_type_global_Init(void) { - SwigPyPacked_type_global = SwigPyPacked_TypeOnce(); -} - SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { assert(SwigPyPacked_type_global); @@ -1004,20 +965,12 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -static PyObject *swig_this = NULL; +static PyObject *SWIG_This_global = NULL; SWIGRUNTIME PyObject * -SWIG_This(void) -{ - if (swig_this == NULL) - swig_this = _SWIG_This(); - return swig_this; +SWIG_This(void) { + assert(SWIG_This_global); + return SWIG_This_global; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -1446,7 +1399,7 @@ SWIG_Python_DestroyModule(PyObject *obj) } } Py_DECREF(SWIG_This()); - swig_this = NULL; + SWIG_This_global = NULL; } SWIGRUNTIME void @@ -1466,15 +1419,8 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { } } -/* This used to be a function-local static variable, but accessing Python - * C API from inside a function-local static initializer can lead to deadlocks. - * https://github.com/swig/swig/issues/1275 */ static PyObject *SWIG_Python_TypeCache_global = 0; -SWIGRUNTIME void SWIG_Python_TypeCache_global_Init(void) { - SWIG_Python_TypeCache_global = PyDict_New(); -} - /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { From f8ffc04215b1be9ade91d418c0e0cf309e1809a2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Jun 2018 19:30:58 +0100 Subject: [PATCH 1027/2031] Use SWIGRUNTIME for SwigPyObject_repr2 --- Lib/python/pyrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5ad5713fd..d8d2488ae 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -431,7 +431,7 @@ SwigPyObject_repr(SwigPyObject *v) /* We need a version taking two PyObject* parameters so it's a valid * PyCFunction to use in swigobject_methods[]. */ -static PyObject * +SWIGRUNTIME PyObject * SwigPyObject_repr2(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) { return SwigPyObject_repr((SwigPyObject*)v); From e05b5ea67fb7c394d1062868bc9c2c6a4782bf08 Mon Sep 17 00:00:00 2001 From: Rupert Nash Date: Tue, 3 Jul 2018 11:03:43 +0100 Subject: [PATCH 1028/2031] Make python shadow sub-modules runable Python modules can be run as main from the command line with the -c flag Currently this does not work as the python wrapper module does not correctly import the extension module. This commit makes the generated code consistent with PEP 366. --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bdbb4e9b9..3763710a8 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -855,7 +855,7 @@ public: */ Printv(default_import_code, "def swig_import_helper():\n", NULL); Printv(default_import_code, tab4, "import importlib\n", NULL); - Printv(default_import_code, tab4, "pkg = __name__.rpartition('.')[0]\n", NULL); + Printv(default_import_code, tab4, "pkg = __package__ if __package__ else __name__.rpartition('.')[0]\n", NULL); Printf(default_import_code, tab4 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); Printv(default_import_code, tab4, "try:\n", NULL); Printv(default_import_code, tab8, "return importlib.import_module(mname)\n", NULL); From 5a8c4fde4cbb9a962e6c8eb1aff180ffcdda99a3 Mon Sep 17 00:00:00 2001 From: Giacomo Mazzamuto Date: Wed, 4 Jul 2018 10:48:06 +0200 Subject: [PATCH 1029/2031] Enable test case for python_pybuf --- Examples/test-suite/python/Makefile.in | 2 +- ..._pybuf_runme3.py => python_pybuf_runme.py} | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) rename Examples/test-suite/python/{python_pybuf_runme3.py => python_pybuf_runme.py} (65%) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index e2aad7c8b..fee14afb0 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -67,6 +67,7 @@ CPP_TEST_CASES += \ python_nondynamic \ python_overload_simple_cast \ python_pickle \ + python_pybuf \ python_pythoncode \ python_richcompare \ python_strict_unicode \ @@ -78,7 +79,6 @@ CPP_TEST_CASES += \ # li_std_carray # director_profile -# python_pybuf CPP11_TEST_CASES = \ cpp11_hash_tables \ diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme.py similarity index 65% rename from Examples/test-suite/python/python_pybuf_runme3.py rename to Examples/test-suite/python/python_pybuf_runme.py index f5ab0ec66..58efe78bd 100644 --- a/Examples/test-suite/python/python_pybuf_runme3.py +++ b/Examples/test-suite/python/python_pybuf_runme.py @@ -1,8 +1,10 @@ # run: -# python python_pybuf_runme3.py benchmark +# python python_pybuf_runme.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 @@ -11,31 +13,31 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": t = time.time() a = bytearray(b'hello world') for i in range(k): - pybuf.title1(a) - print("Time used by bytearray:", time.time() - t) + python_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) + python_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) + python_pybuf.func1(buf1) assert buf1 == b'a' * 10 - pybuf.func2(buf2) + python_pybuf.func2(buf2) assert buf2.startswith(b"Hello world!\x00") - count = pybuf.func3(buf2) + count = python_pybuf.func3(buf2) assert count == 10 # number of alpha and number in 'Hello world!' - length = pybuf.func4(buf2) + length = python_pybuf.func4(buf2) assert length == 12 buf3 = bytearray(b"hello") - pybuf.title1(buf3) + python_pybuf.title1(buf3) assert buf3 == b'Hello' From 3594e54f7edb364369971b12a395ad2eff617515 Mon Sep 17 00:00:00 2001 From: Giacomo Mazzamuto Date: Wed, 4 Jul 2018 18:03:09 +0200 Subject: [PATCH 1030/2031] pybuffer: don't use the old deprecated buffer protocol for Python 3 --- Lib/python/pybuffer.i | 48 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i index 121cd709f..f4e08716e 100644 --- a/Lib/python/pybuffer.i +++ b/Lib/python/pybuffer.i @@ -13,9 +13,17 @@ */ %define %pybuffer_mutable_binary(TYPEMAP, SIZE) -%typemap(in) (TYPEMAP, SIZE) - (int res, Py_ssize_t size = 0, void *buf = 0) { +%typemap(in) (TYPEMAP, SIZE) { + int res; Py_ssize_t size = 0; void *buf = 0; +%#if PY_VERSION_HEX < 0x03000000 res = PyObject_AsWriteBuffer($input, &buf, &size); +%#else + Py_buffer view; + res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); +%#endif if (res<0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); @@ -39,9 +47,17 @@ */ %define %pybuffer_mutable_string(TYPEMAP) -%typemap(in) (TYPEMAP) - (int res, Py_ssize_t size = 0, void *buf = 0) { +%typemap(in) (TYPEMAP) { + int res; Py_ssize_t size = 0; void *buf = 0; +%#if PY_VERSION_HEX < 0x03000000 res = PyObject_AsWriteBuffer($input, &buf, &size); +%#else + Py_buffer view; + res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); +%#endif if (res<0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); @@ -65,9 +81,17 @@ */ %define %pybuffer_binary(TYPEMAP, SIZE) -%typemap(in) (TYPEMAP, SIZE) - (int res, Py_ssize_t size = 0, const void *buf = 0) { +%typemap(in) (TYPEMAP, SIZE) { + int res; Py_ssize_t size = 0; const void *buf = 0; +%#if PY_VERSION_HEX < 0x03000000 res = PyObject_AsReadBuffer($input, &buf, &size); +%#else + Py_buffer view; + res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); +%#endif if (res<0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); @@ -93,9 +117,17 @@ */ %define %pybuffer_string(TYPEMAP) -%typemap(in) (TYPEMAP) - (int res, Py_ssize_t size = 0, const void *buf = 0) { +%typemap(in) (TYPEMAP) { + int res; Py_ssize_t size = 0; const void *buf = 0; +%#if PY_VERSION_HEX < 0x03000000 res = PyObject_AsReadBuffer($input, &buf, &size); +%#else + Py_buffer view; + res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); +%#endif if (res<0) { %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } From 38f2ab0c30e369e63bbd0a6152108488d0de68e1 Mon Sep 17 00:00:00 2001 From: Chris Hogan Date: Mon, 16 Jul 2018 14:07:53 -0500 Subject: [PATCH 1031/2031] Fix garbage collection for guile >= 2.0.12 --- Lib/guile/guile_scm_run.swg | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 274f19715..0d04cb7c6 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -99,6 +99,7 @@ SWIG_Guile_scm2newstr(SCM str, size_t *len) { static int swig_initialized = 0; static scm_t_bits swig_tag = 0; static scm_t_bits swig_collectable_tag = 0; +static scm_t_bits swig_finalized_tag = 0; static scm_t_bits swig_destroyed_tag = 0; static scm_t_bits swig_member_function_tag = 0; static SCM swig_make_func = SCM_EOL; @@ -163,7 +164,19 @@ SWIG_Guile_PointerType(SCM object) } else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object); } - + +SWIGINTERN int +SWIG_Guile_IsValidSmob(SCM smob) +{ + /* We do not accept smobs representing destroyed pointers, but we have to + allow finalized smobs because Guile >= 2.0.12 sets all smob instances + to the 'finalized' type before calling their 'free' function. This change + was introduced to Guile in commit 8dff3af087c6eaa83ae0d72aa8b22aef5c65d65d */ + return SCM_SMOB_PREDICATE(swig_tag, smob) + || SCM_SMOB_PREDICATE(swig_collectable_tag, smob) + || SCM_SMOB_PREDICATE(swig_finalized_tag, smob); +} + SWIGINTERN int SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) { @@ -179,8 +192,7 @@ SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) *result = SCM_POINTER_VALUE(s); return SWIG_OK; #endif /* if SCM_MAJOR_VERSION >= 2 */ - } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { - /* we do not accept smobs representing destroyed pointers */ + } else if (SWIG_Guile_IsValidSmob(smob)) { from = (swig_type_info *) SCM_CELL_WORD_2(smob); if (!from) return SWIG_ERROR; if (type) { @@ -239,7 +251,7 @@ SWIG_Guile_MarkPointerNoncollectable(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { - if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + if (SWIG_Guile_IsValidSmob(smob)) { SCM_SET_CELL_TYPE(smob, swig_tag); } else scm_wrong_type_arg(NULL, 0, s); @@ -252,7 +264,7 @@ SWIG_Guile_MarkPointerDestroyed(SCM s) { SCM smob = SWIG_Guile_GetSmob(s); if (!SCM_NULLP(smob)) { - if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) { + if (SWIG_Guile_IsValidSmob(smob)) { SCM_SET_CELL_TYPE(smob, swig_destroyed_tag); } else scm_wrong_type_arg(NULL, 0, s); @@ -419,6 +431,8 @@ SWIG_Guile_Init () scm_set_smob_print(swig_collectable_tag, print_collectable_swig); scm_set_smob_equalp(swig_collectable_tag, equalp_swig); scm_set_smob_free(swig_collectable_tag, free_swig); + /* For Guile >= 2.0.12. See libguile/smob.c:clear_smobnum */ + swig_finalized_tag = swig_collectable_tag & ~0xff00; } if (ensure_smob_tag(swig_module, &swig_destroyed_tag, "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) { From 8e6799d783c7cf43961b63f1759e8412a5694fb1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Jul 2018 08:46:53 +0100 Subject: [PATCH 1032/2031] Revert "Merge branch 'petrmitrichev-remove-function-local-statics'" This reverts commit b8ed7759d5fccef3a6df33351a17a92629cfc682, reversing changes made to 6f2399e86da13a9feb436e3977e15d2b9738294e. --- CHANGES.current | 5 ---- Lib/python/pyinit.swg | 11 ------- Lib/python/pyrun.swg | 69 +++++++++++++++++++++++++++---------------- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2a5c1c9ac..9fb57f9f0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,11 +7,6 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== -2018-06-30: petrmitrichev - [Python] #1275 #1279 Remove function-local statics that call Python code - in order to avoid deadlocks with multi-threaded usage. These are now - file scope static variables and are initialized during module initialization. - 2018-06-15: wsfulton [Python] Fix seg fault using Python 2 when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index e15eb0309..7ef70585f 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -379,14 +379,6 @@ SWIG_init(void) { assert(metatype); #endif -#ifdef SWIG_PYTHON_BUILD_NONE - SWIG_Py_None_global = Py_BuildValue(""); - Py_DECREF(SWIG_Py_None_global); -#endif - - SWIG_This_global = SWIG_Python_str_FromChar("this"); - SWIG_Python_TypeCache_global = PyDict_New(); - /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); @@ -437,11 +429,8 @@ SWIG_init(void) { SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); for (i = 0; swig_const_table[i].name != 0; ++i) SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); -#else - SwigPyObject_type_global = SwigPyObject_TypeOnce(); #endif - SwigPyPacked_type_global = SwigPyPacked_TypeOnce(); SWIG_InstallConstants(d,swig_const_table); %} diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d8d2488ae..8898c6d93 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -210,6 +210,16 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi /* A functor is a function object with one single object argument */ #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj); +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + /* ----------------------------------------------------------------------------- * Pointer declarations * ----------------------------------------------------------------------------- */ @@ -241,20 +251,26 @@ extern "C" { # undef Py_None # define Py_None SWIG_Py_None() # endif - -static PyObject *SWIG_Py_None_global = 0; - -SWIGRUNTIME PyObject * -SWIG_Py_None(void) { - assert(SWIG_Py_None_global); - return SWIG_Py_None_global; +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue(""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; } #endif /* The python void return value */ SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) { +SWIG_Py_Void(void) +{ PyObject *none = Py_None; Py_INCREF(none); return none; @@ -463,7 +479,6 @@ SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); #ifdef SWIGPYTHON_BUILTIN static swig_type_info *SwigPyObject_stype = 0; - SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { SwigPyClientData *cd; @@ -474,12 +489,10 @@ SwigPyObject_type(void) { return cd->pytype; } #else -static PyTypeObject *SwigPyObject_type_global = 0; - SWIGRUNTIME PyTypeObject* SwigPyObject_type(void) { - assert(SwigPyObject_type_global); - return SwigPyObject_type_global; + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; } #endif @@ -823,12 +836,10 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); -static PyTypeObject* SwigPyPacked_type_global = 0; - SWIGRUNTIME PyTypeObject* SwigPyPacked_type(void) { - assert(SwigPyPacked_type_global); - return SwigPyPacked_type_global; + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; } SWIGRUNTIMEINLINE int @@ -965,12 +976,20 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -static PyObject *SWIG_This_global = NULL; +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; SWIGRUNTIME PyObject * -SWIG_This(void) { - assert(SWIG_This_global); - return SWIG_This_global; +SWIG_This(void) +{ + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -1399,7 +1418,7 @@ SWIG_Python_DestroyModule(PyObject *obj) } } Py_DECREF(SWIG_This()); - SWIG_This_global = NULL; + swig_this = NULL; } SWIGRUNTIME void @@ -1419,13 +1438,11 @@ SWIG_Python_SetModule(swig_module_info *swig_module) { } } -static PyObject *SWIG_Python_TypeCache_global = 0; - /* The python cached type query */ SWIGRUNTIME PyObject * SWIG_Python_TypeCache(void) { - assert(SWIG_Python_TypeCache_global); - return SWIG_Python_TypeCache_global; + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; } SWIGRUNTIME swig_type_info * From d56d7a725309c1458cad4855ab60598eb929582b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Jul 2018 19:56:12 +0100 Subject: [PATCH 1033/2031] Initialize Python function-local statics (singletons) Singletons are created during Python module initialization in order to avoid deadlocks with subsequent multi-threaded usage. Fixes #1275 #1279 --- CHANGES.current | 5 +++++ Lib/python/pyinit.swg | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9fb57f9f0..2e5d368a5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-07-17: petrmitrichev,wsfulton + [Python] #1275 #1279 Initialize function-local statics (singletons) that call Python + code during Python module initialization in order to avoid deadlocks with subsequent + multi-threaded usage. + 2018-06-15: wsfulton [Python] Fix seg fault using Python 2 when passing a Python string, containing invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 7ef70585f..516cd628b 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -379,6 +379,17 @@ SWIG_init(void) { assert(metatype); #endif + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ +#ifdef SWIG_PYTHON_BUILD_NONE + SWIG_Py_None(); +#endif + SWIG_This(); + SWIG_Python_TypeCache(); + SwigPyPacked_type(); +#ifndef SWIGPYTHON_BUILTIN + SwigPyObject_type(); +#endif + /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); From 344e9fefa8930b45b4595c0cda052ed9b2af5b40 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Jul 2018 20:23:55 +0100 Subject: [PATCH 1034/2031] Python singletons tidy up --- Lib/python/pyrun.swg | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 8898c6d93..e1e3268b4 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -251,17 +251,15 @@ extern "C" { # undef Py_None # define Py_None SWIG_Py_None() # endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue(""); - Py_DECREF(none); - return none; -} + SWIGRUNTIME PyObject * SWIG_Py_None(void) { - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + static PyObject *none = NULL; + if (!none == NULL) { + none = Py_BuildValue(""); + Py_DECREF(none); + } return none; } #endif @@ -976,20 +974,14 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) * pointers/data manipulation * ----------------------------------------------------------------------------- */ -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -static PyObject *swig_this = NULL; +static PyObject *Swig_This_global = NULL; SWIGRUNTIME PyObject * SWIG_This(void) { - if (swig_this == NULL) - swig_this = _SWIG_This(); - return swig_this; + if (Swig_This_global == NULL) + Swig_This_global = SWIG_Python_str_FromChar("this"); + return Swig_This_global; } /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ @@ -1418,7 +1410,7 @@ SWIG_Python_DestroyModule(PyObject *obj) } } Py_DECREF(SWIG_This()); - swig_this = NULL; + Swig_This_global = NULL; } SWIGRUNTIME void From 5ce880ee410394705bf620c37f41a987fdaa3a86 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Jul 2018 11:44:27 +0100 Subject: [PATCH 1035/2031] Fix SWIG_Py_None regression from last commit --- Lib/python/pyrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index e1e3268b4..fb5859cbf 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -256,7 +256,7 @@ SWIGRUNTIME PyObject * SWIG_Py_None(void) { static PyObject *none = NULL; - if (!none == NULL) { + if (!none) { none = Py_BuildValue(""); Py_DECREF(none); } From 7f886fd4fce5b2fff0705a37b37cbdbbcd115e16 Mon Sep 17 00:00:00 2001 From: furylynx Date: Sat, 21 Jul 2018 12:47:03 +0200 Subject: [PATCH 1036/2031] fix travis tests --- .travis.yml | 8 ++++---- Tools/travis-linux-install.sh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d80ba20e..be317aeee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,22 +51,22 @@ matrix: dist: trusty - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node VER=4 + env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1 sudo: required dist: trusty - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node VER=6 + env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1 sudo: required dist: trusty - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node VER=8 + env: SWIGLANG=javascript ENGINE=node VER=8 CPP11=1 sudo: required dist: trusty - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node VER=10 + env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required dist: trusty - compiler: gcc diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index cec76d812..82e5d62bb 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -37,8 +37,9 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - curl -sL https://deb.nodesource.com/setup_${VER}.x | sudo -E bash - + travis_retry curl -sL https://deb.nodesource.com/setup_${VER}.x | sudo -E bash - travis_retry sudo apt-get install -y nodejs + travis_retry npm install -g node-gyp ;; "jsc") travis_retry sudo apt-get install -qq libwebkitgtk-dev From 1cbabb2e06a2937d4d7b5f50e28361467c134994 Mon Sep 17 00:00:00 2001 From: furylynx Date: Sat, 21 Jul 2018 16:17:54 +0200 Subject: [PATCH 1037/2031] travis tests for different node versions --- .travis.yml | 5 +++++ Tools/travis-linux-install.sh | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index be317aeee..72b8d8a2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,11 @@ matrix: env: SWIGLANG=java sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1 diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 82e5d62bb..75e3ddbc4 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -37,8 +37,9 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - travis_retry curl -sL https://deb.nodesource.com/setup_${VER}.x | sudo -E bash - - travis_retry sudo apt-get install -y nodejs + travis_retry wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash + travis_retry sudo nvm install ${VER} + sudo nvm use ${VER} travis_retry npm install -g node-gyp ;; "jsc") From 278531370618a72d0a4c0a43c64ab3231b02e2cd Mon Sep 17 00:00:00 2001 From: furylynx Date: Sat, 21 Jul 2018 16:41:06 +0200 Subject: [PATCH 1038/2031] node tests: use provided version if present --- Tools/travis-linux-install.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 75e3ddbc4..7aeb12ada 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -37,10 +37,14 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - travis_retry wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash - travis_retry sudo nvm install ${VER} - sudo nvm use ${VER} - travis_retry npm install -g node-gyp + if [[ -z "$VER" ]]; then + travis_retry sudo apt-get install -qq nodejs node-gyp + else + travis_retry wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash + travis_retry sudo nvm install ${VER} + sudo nvm use ${VER} + travis_retry npm install -g node-gyp + fi ;; "jsc") travis_retry sudo apt-get install -qq libwebkitgtk-dev From bb73a1ce5254b92d7419f4131c9de5dc8fc608f0 Mon Sep 17 00:00:00 2001 From: furylynx Date: Sat, 21 Jul 2018 21:19:28 +0200 Subject: [PATCH 1039/2031] fixed nvm --- Tools/travis-linux-install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 7aeb12ada..5fe02d0eb 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -40,9 +40,11 @@ case "$SWIGLANG" in if [[ -z "$VER" ]]; then travis_retry sudo apt-get install -qq nodejs node-gyp else - travis_retry wget -qO- https://raw.githubusercontent.com/xtuple/nvm/master/install.sh | sudo bash - travis_retry sudo nvm install ${VER} - sudo nvm use ${VER} + travis_retry wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.10/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + travis_retry nvm install ${VER} + nvm use ${VER} travis_retry npm install -g node-gyp fi ;; From fe082382c72d140b2583f3a911a21119b8926f69 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 20 Jul 2018 17:58:36 +0100 Subject: [PATCH 1040/2031] Fix pythonnondynamic feature for modern classes Fixes nondynamic mode when an instance variable is set with the same name as a class variable in a class derived from a SWIG proxy class. The python_nondynamic testcase now works using -modern and testcase enhanced slightly too. Fixes #718 --- .../python/python_nondynamic_runme.py | 100 ++++++++++++++---- Examples/test-suite/python_nondynamic.i | 9 ++ Source/Modules/python.cxx | 29 +++-- 3 files changed, 112 insertions(+), 26 deletions(-) diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py index 6a430961e..9be47b3cc 100644 --- a/Examples/test-suite/python/python_nondynamic_runme.py +++ b/Examples/test-suite/python/python_nondynamic_runme.py @@ -1,21 +1,41 @@ import python_nondynamic +def is_python_modern(): + """Return True if SWIG is generating Python code using -modern. Works only if %python_nondynamic has been used.""" + return hasattr(python_nondynamic, "_swig_setattr_nondynamic_class_variable") + +def debug_print(s): + show_debug = False + if show_debug: + print(s) + aa = python_nondynamic.A() aa.a = 1 aa.b = 2 + +# Check values are really set +if python_nondynamic.retrieve_A_a(aa) != 1: raise RuntimeError("a not set correctly") +if python_nondynamic.retrieve_A_b(aa) != 2: raise RuntimeError("b not set correctly") + try: aa.c = 2 - err = 0 -except: - err = 1 - -if not err: - raise RuntimeError, "A is not static" + raise RuntimeError("A is not static") +except AttributeError as e: + debug_print(e) + pass +class PurePythonClass(object): + def __init__(self): + self.variables = dict() + def __set__(self, name, value): + self.variables[name] = value + pass class B(python_nondynamic.A): c = 4 + cc = PurePythonClass() + cc.nnn = "new attrib" def __init__(self): python_nondynamic.A.__init__(self) @@ -23,26 +43,66 @@ class B(python_nondynamic.A): pass bb = B() +bb.a = 4 +bb.b = 5 +# Check values are really set +if python_nondynamic.retrieve_A_a(bb) != 4: raise RuntimeError("a not set correctly") +if python_nondynamic.retrieve_A_b(bb) != 5: raise RuntimeError("b not set correctly") try: bb.c = 3 - err = 0 -except: - err = 1 - -if not err: - print "bb.c = %d" % bb.c - print "B.c = %d" % B.c - raise RuntimeError, "B.c class variable messes up nondynamic-ness of B" + print("bb.c = {}".format(bb.c)) + print("B.c = {}".format(B.c)) + raise RuntimeError("B.c class variable messes up nondynamic-ness of B") +except AttributeError as e: + debug_print(e) + pass try: bb.d = 2 - err = 0 -except: - err = 1 - -if not err: - raise RuntimeError, "B is not static" + raise RuntimeError("B is not static") +except AttributeError as e: + debug_print(e) + pass cc = python_nondynamic.C() cc.d = 3 + +# An inconsistency between builtin and (non-builtin/modern). +# Class variables cannot be set on builtin types, like other Python builtins, eg list.classvar=111 fails +if python_nondynamic.is_python_builtin(): + try: + python_nondynamic.C.classvar = 111 + raise RuntimeError("C should not allow static variables to be added when using builtin") + except AttributeError as e: + debug_print(e) + pass +else: + python_nondynamic.C.classvar = 111 + +if is_python_modern(): + # Not working with builtin or non-modern :( + try: + B.a = 10 + raise RuntimeError("B should not allow adding a class variable by setting it as an instance variable") + except AttributeError as e: + debug_print(e) + pass + + try: + python_nondynamic.A.a = 10 + raise RuntimeError("A should not allow adding a class variable by setting it as an instance variable") + except AttributeError as e: + debug_print(e) + pass + +if not python_nondynamic.is_python_builtin(): + try: + bb.cc = 3 + print("bb.cc = {}".format(bb.cc)) + print("B.cc = {}".format(B.cc)) + raise RuntimeError("B.cc class variable messes up nondynamic-ness of B") + except AttributeError as e: + debug_print(e) + pass + diff --git a/Examples/test-suite/python_nondynamic.i b/Examples/test-suite/python_nondynamic.i index 54a3f28ca..14c8d6b0e 100644 --- a/Examples/test-suite/python_nondynamic.i +++ b/Examples/test-suite/python_nondynamic.i @@ -54,5 +54,14 @@ int b; }; + int retrieve_A_a(const struct A* self) { return self->a; } + int retrieve_A_b(const struct A* self) { return self->b; } +%} +%inline %{ +#ifdef SWIGPYTHON_BUILTIN +int is_python_builtin() { return 1; } +#else +int is_python_builtin() { return 0; } +#endif %} diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bdbb4e9b9..a713f4eaa 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -951,15 +951,32 @@ public: } } if (modern) { - Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_method(set):\n", tab4, "def set_attr(self, name, value):\n", + Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_instance_variable(set):\n", + tab4, "def set_instance_attr(self, name, value):\n", #ifdef USE_THISOWN - tab4, tab4, "if hasattr(self, name) or (name in (\"this\", \"thisown\")):\n", + tab4, tab4, "if name in (\"this\", \"thisown\"):\n", + tab4, tab4, tab4, "set(self, name, value)\n", #else - tab4, tab4, "if name == \"thisown\":\n", tab8, tab4, "return self.this.own(value)\n", tab4, tab4, "if hasattr(self, name) or (name == \"this\"):\n", + tab4, tab4, "if name == \"thisown\":\n", + tab4, tab4, tab4, "self.this.own(value)\n", + tab4, tab4, "elif name == \"this\":\n", + tab4, tab4, tab4, "set(self, name, value)\n", #endif + tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n", tab4, tab4, tab4, "set(self, name, value)\n", tab4, tab4, "else:\n", - tab4, tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n", tab4, "return set_attr\n\n\n", NIL); + tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n", + tab4, "return set_instance_attr\n\n", NIL); + + Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_class_variable(set):\n", + tab4, "def set_class_attr(cls, name, value):\n", + tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n", + tab4, tab4, tab4, "set(cls, name, value)\n", + tab4, tab4, "else:\n", + tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n", + tab4, "return set_class_attr\n\n", NIL); + + Printv(f_shadow, "\n", NIL); } if (directorsEnabled()) { @@ -4535,8 +4552,8 @@ public: /* Add static attribute */ if (GetFlag(n, "feature:python:nondynamic")) { Printv(f_shadow_file, - tab4, "__setattr__ = _swig_setattr_nondynamic_method(object.__setattr__)\n", - tab4, "class __metaclass__(type):\n", tab4, tab4, "__setattr__ = _swig_setattr_nondynamic_method(type.__setattr__)\n", NIL); + tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", + tab4, "class __metaclass__(type):\n", tab4, tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n", NIL); } } } From 89f00ca2f3e49b7522267adf5806d1af6c2e1c97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jul 2018 06:58:13 +0100 Subject: [PATCH 1041/2031] Fix pythonnondynamic feature for modern classes and Python 3 Corrects adding metaclass to the nondynamic class so that the implementation works. Uses metaclass syntax that will work for both python 2 and 3 or proper Python 3 syntax when using -py3. --- Source/Modules/python.cxx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a713f4eaa..7a190aef1 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -951,7 +951,8 @@ public: } } if (modern) { - Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_instance_variable(set):\n", + Printv(f_shadow, "\n", + "def _swig_setattr_nondynamic_instance_variable(set):\n", tab4, "def set_instance_attr(self, name, value):\n", #ifdef USE_THISOWN tab4, tab4, "if name in (\"this\", \"thisown\"):\n", @@ -968,7 +969,8 @@ public: tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n", tab4, "return set_instance_attr\n\n", NIL); - Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_class_variable(set):\n", + Printv(f_shadow, "\n", + "def _swig_setattr_nondynamic_class_variable(set):\n", tab4, "def set_class_attr(cls, name, value):\n", tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n", tab4, tab4, tab4, "set(cls, name, value)\n", @@ -976,6 +978,19 @@ public: tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n", tab4, "return set_class_attr\n\n", NIL); + Printv(f_shadow, "\n", + "def _swig_add_metaclass(metaclass):\n", + tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n", + tab4, "def wrapper(cls):\n", + tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n", + tab4, "return wrapper\n\n", NIL); + + Printv(f_shadow, "\n", + "class _SwigNonDynamicMeta(type):\n", + tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n", + tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n", + "\n", NIL); + Printv(f_shadow, "\n", NIL); } @@ -4507,13 +4522,19 @@ public: Delete(rname); } } else { + if (modern && !py3) { + if (GetFlag(n, "feature:python:nondynamic")) + Printv(f_shadow, "@_swig_add_metaclass(_SwigNonDynamicMeta)\n", NIL); + } Printv(f_shadow, "class ", class_name, NIL); if (Len(base_class)) { Printf(f_shadow, "(%s)", base_class); } else { if (!classic) { - Printf(f_shadow, modern ? "(object)" : "(_object)"); + Printf(f_shadow, modern ? "(object" : "(_object"); + Printf(f_shadow, modern && py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")"); + Printf(f_shadow, ")"); } if (GetFlag(n, "feature:exceptionclass")) { Printf(f_shadow, "(Exception)"); @@ -4551,9 +4572,7 @@ public: Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); /* Add static attribute */ if (GetFlag(n, "feature:python:nondynamic")) { - Printv(f_shadow_file, - tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", - tab4, "class __metaclass__(type):\n", tab4, tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n", NIL); + Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", NIL); } } } From 037bf2b385a5744116bfd90433974c9d79c91fad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jul 2018 07:23:16 +0100 Subject: [PATCH 1042/2031] Slim down pythonnondynamic testing feature testing No need to test twice, just test using C. --- Examples/test-suite/python/Makefile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index e2aad7c8b..f3d89a962 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -64,7 +64,6 @@ CPP_TEST_CASES += \ python_docstring \ python_extranative \ python_moduleimport \ - python_nondynamic \ python_overload_simple_cast \ python_pickle \ python_pythoncode \ From 0bede22fbcd1a849573d1fdce2c2c2231b12710c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jul 2018 07:39:09 +0100 Subject: [PATCH 1043/2031] Add changes file entry for %pythonnondynamic fix --- CHANGES.current | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2e5d368a5..46bb5a96f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,16 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-23: wsfulton + [Python] #718 Fix pythonnondynamic feature for modern classes + + Fixes nondynamic mode when an instance variable is set with the same + name as a class variable in a class derived from a SWIG proxy class. + This corner case set an instance variable instead of raising an AttributeError. + + Also fix %pythonnondynamic in Python 3 with -modern. The metaclass + containing the implementation was previously not being applied in Python 3. + 2018-07-17: petrmitrichev,wsfulton [Python] #1275 #1279 Initialize function-local statics (singletons) that call Python code during Python module initialization in order to avoid deadlocks with subsequent From 8f224694e78cd17ecc3098be2f9f36378a54632e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Jul 2018 07:56:47 +0100 Subject: [PATCH 1044/2031] Python help for py3 update --- Source/Modules/python.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7a190aef1..89a9d2a8b 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -171,14 +171,13 @@ static const char *usage3 = "\ -oldrepr - Use shorter and old version of __repr__ in proxy classes\n\ -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ -proxydel - Generate a __del__ method even though it is now redundant (default) \n\ + -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\ -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ - -py3 - Generate code with Python 3 specific features:\n\ - Function annotation \n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { From 15e2bdac7a7357377ecaff074c7e490ebd20d1c4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Aug 2018 08:07:16 +0100 Subject: [PATCH 1045/2031] Add recent Javascript node improvements to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 46bb5a96f..1734c5e6c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-02: furylynx,jacobwgillespie,p2k + [Javascript] #1290, #968. Add support for NodeJS versions 2-10. + 2018-06-23: wsfulton [Python] #718 Fix pythonnondynamic feature for modern classes From 7a8efb901e9c2fe8b9f13af64e7da48a25a31918 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Aug 2018 19:20:40 +0100 Subject: [PATCH 1046/2031] Disable Travis OSX ruby and tcl builds These have started to fail since XCode was upgraded to 9.4 --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2c18f0060..68f75de8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -370,6 +370,15 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-O sudo: required dist: trusty + # Broken since Travis image moved from Xcode 8.3 to 9.4 + - compiler: clang + os: osx + env: SWIGLANG=ruby + # Broken since Travis image moved from Xcode 8.3 to 9.4 + - compiler: clang + os: osx + env: SWIGLANG=tcl + before_install: - date -u - uname -a From 4e523fb823fe21021504581942cf528cbf542122 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Aug 2018 07:25:50 +0100 Subject: [PATCH 1047/2031] Fix Travis Ruby MacOS builds with -Wno-deprecated-declarations Work around Ruby on MacOS Xcode 9.4 misconfiguration defining 'isfinite' to deprecated 'finite'. Example warning: li_std_list_wrap.cxx:7197:9: error: 'finite' is deprecated: first deprecated in macOS 10.9 [-Werror,-Wdeprecated-declarations] if (SWIG_Float_Overflow_Check(v)) { ^ li_std_list_wrap.cxx:7156:73: note: expanded from macro 'SWIG_Float_Overflow_Check' ^ li_std_list_wrap.cxx:7122:29: note: expanded from macro 'SWIG_isfinite' ^ /Users/travis/.rvm/rubies/ruby-2.4.3/include/ruby-2.4.0/ruby/missing.h:180:24: note: expanded from macro 'isfinite' ^ /usr/include/math.h:757:12: note: 'finite' has been explicitly marked deprecated here extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA); --- Tools/testflags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/testflags.py b/Tools/testflags.py index 981e8d59a..31ca2e7bd 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -46,7 +46,7 @@ def get_cxxflags(language, std, compiler): "php":"-Werror " + cxx_common, "python":"-Werror " + cxx_common, "r":"-Werror " + cxx_common, - "ruby":"-Werror " + cxx_common, + "ruby":"-Werror " + cxx_common + "-Wno-deprecated-declarations", # For Ruby on MacOS Xcode 9.4 misconfiguration defining 'isfinite' to deprecated 'finite' "scilab":"-Werror " + cxx_common, "tcl":"-Werror " + cxx_common, } From 82517489eef19293f9d2c097a55c2f0fcff05251 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Aug 2018 07:53:38 +0100 Subject: [PATCH 1048/2031] Fix to find tclConfig.sh on more recent versions of macOS --- configure.ac | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 4e7e22069..20e1a348e 100644 --- a/configure.ac +++ b/configure.ac @@ -480,16 +480,23 @@ if test x"${with_tclconfig}" != x ; then fi fi # check in a few common install locations +dirs="/usr/lib*/ /usr/lib*/tcl*/ /usr/local/lib*/ /usr/local/lib*/tcl*/" +case $host in +*-*-darwin*) + dirs="/System/Library/Frameworks/Tcl.framework/ $dirs" + ;; +*) + ;; +esac if test x"${TCLCONFIG}" = x ; then - for i in `ls -d -r /usr/lib*/ 2>/dev/null` \ - `ls -d -r /usr/lib*/tcl*/ 2>/dev/null` \ - `ls -d -r /usr/local/lib*/ 2>/dev/null` \ - `ls -d -r /usr/local/lib*/tcl*/ 2>/dev/null` ; do - if test -f $i"tclConfig.sh" ; then - TCLCONFIG=`(cd $i; pwd)` - break - fi + for d in $dirs ; do + for i in `ls -d -r $d 2>/dev/null` ; do + if test -f $i"tclConfig.sh" ; then + TCLCONFIG=`(cd $i; pwd)` + break + fi done + done fi if test x"${TCLCONFIG}" = x ; then AC_MSG_RESULT(no) From b998514a5957b5f14cd37be123a802f659b86b9a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Aug 2018 19:50:14 +0100 Subject: [PATCH 1049/2031] Restore Travis macOS Ruby and Tcl testing --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 68f75de8a..f8553845c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -370,14 +370,6 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-O sudo: required dist: trusty - # Broken since Travis image moved from Xcode 8.3 to 9.4 - - compiler: clang - os: osx - env: SWIGLANG=ruby - # Broken since Travis image moved from Xcode 8.3 to 9.4 - - compiler: clang - os: osx - env: SWIGLANG=tcl before_install: - date -u From aaa67702ec9967e0571fceeac35d2afede8b015b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 5 Jul 2018 08:45:41 +0100 Subject: [PATCH 1050/2031] Cosmetic corrections in python.cxx --- Source/Modules/python.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 89a9d2a8b..f7b26e08b 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3024,7 +3024,7 @@ public: } } } else { - Printf(parse_args, "if(!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments); + Printf(parse_args, "if (!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); } } @@ -3600,7 +3600,7 @@ public: /* Note, that we need special handling for function pointers, as * SwigType_base(fptr) does not return the underlying pointer-to-function * type but the return-type of function. */ - if(!SwigType_isfunction(uqtype) && !SwigType_isfunctionpointer(uqtype)) { + if (!SwigType_isfunction(uqtype) && !SwigType_isfunctionpointer(uqtype)) { SwigType *basetype = SwigType_base(uqtype); result = SwigType_isclass(basetype) != 0; Delete(basetype); From 779d76ca6af9a884e2a8a3f478a3a9f92593d85c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 Aug 2018 06:50:39 +0100 Subject: [PATCH 1051/2031] Correct Travis Ruby compilation flags --- Tools/testflags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/testflags.py b/Tools/testflags.py index 31ca2e7bd..a65299f0a 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -46,7 +46,7 @@ def get_cxxflags(language, std, compiler): "php":"-Werror " + cxx_common, "python":"-Werror " + cxx_common, "r":"-Werror " + cxx_common, - "ruby":"-Werror " + cxx_common + "-Wno-deprecated-declarations", # For Ruby on MacOS Xcode 9.4 misconfiguration defining 'isfinite' to deprecated 'finite' + "ruby":"-Werror " + cxx_common + " -Wno-deprecated-declarations", # For Ruby on MacOS Xcode 9.4 misconfiguration defining 'isfinite' to deprecated 'finite' "scilab":"-Werror " + cxx_common, "tcl":"-Werror " + cxx_common, } From 3738dcc7474d50e3e3a579404efc471e35757a8b Mon Sep 17 00:00:00 2001 From: Seth Troisi Date: Thu, 9 Aug 2018 12:54:15 -0700 Subject: [PATCH 1052/2031] [Minor Doc Fix] Fix Python struct example --- Doc/Manual/Python.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1a2fd9e81..b79a39789 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1311,7 +1311,7 @@ is used as follows: >>> v.x = 3.5 >>> v.y = 7.2 >>> print v.x, v.y, v.z -7.8 -4.5 0.0 +3.5 7.2 0.0 >>> From fd651ff4e2eca00e7c530b717b7a79e2a89440a6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 31 Jul 2018 19:12:02 +0100 Subject: [PATCH 1053/2031] Overloaded C++ function Python wrappers now raise a TypeError instead of NotImplementedError Occurs when the types passed are incorrect. This change means there is now consistency with non-overloaded function wrappers which have always raised TypeError when the incorrect types are passed. See issue #1293 --- CHANGES.current | 21 +++++++++++++++++++ Doc/Manual/Python.html | 2 +- .../python/li_std_string_extra_runme.py | 12 +++++++---- .../python/primitive_types_runme.py | 7 +------ Examples/test-suite/python/varargs_runme.py | 2 -- Source/Modules/python.cxx | 2 +- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 46bb5a96f..64a2e65fd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,27 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-07-31: wsfulton + [Python] #1293 Overloaded C++ function wrappers now raise a TypeError instead + of NotImplementedError when the types passed are incorrect. This change means + there is now consistency with non-overloaded function wrappers which have always + raised TypeError when the incorrect types are passed. The error message remains + the same and is for example now: + + TypeError: Wrong number or type of arguments for overloaded function 'f'. + Possible C/C++ prototypes are: + f(int) + f(char const *) + + instead of: + + NotImplementedError: Wrong number or type of arguments for overloaded function 'f'. + Possible C/C++ prototypes are: + f(int) + f(char const *) + + *** POTENTIAL INCOMPATIBILITY *** + 2018-06-23: wsfulton [Python] #718 Fix pythonnondynamic feature for modern classes diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1a2fd9e81..59690609a 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -4894,7 +4894,7 @@ If you don't you'll get an error message along the lines of: Traceback (most recent call last): File "runme.py", line 3, in >module< example.foo(["foo", "bar", "spam", "1"]) -NotImplementedError: Wrong number or type of arguments for overloaded function 'foo'. +TypeError: Wrong number or type of arguments for overloaded function 'foo'. Possible C/C++ prototypes are: foo(int, char **) foo() diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index 9835eaa81..53d2bdc75 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -95,14 +95,18 @@ if li_std_string_extra.test_value_basic_overload(123) != "int": try: li_std_string_extra.test_value_basic_overload([x]) - raise RuntimeError, "should throw NotImplementedError" -except NotImplementedError: + raise RuntimeError, "should throw TypeError" +except TypeError as e: + if str(e).find("Possible C/C++ prototypes are:") == -1: + raise RuntimeError("Incorrect error message text:\n{}".format(e)) pass try: li_std_string_extra.test_value_basic_overload([123]) - raise RuntimeError, "should throw NotImplementedError" -except NotImplementedError: + raise RuntimeError, "should throw TypeError" +except TypeError as e: + if str(e).find("Possible C/C++ prototypes are:") == -1: + raise RuntimeError("Incorrect error message text:\n{}".format(e)) pass # Global variables diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index b2060a028..c5009f640 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -549,14 +549,9 @@ def checkOverload(t, name, val, delta, prevval, limit): if t.ovr_str(val + delta) == name: raise RuntimeError, "bad " + name + " typemap" if val == limit: - # Should raise NotImplementedError here since this is the largest integral type - raise RuntimeError, "bad " + name + " typemap" - except NotImplementedError: - # NotImplementedError is expected only if this is the most extreme type - if val != limit: + # Should raise TypeError here since this is the largest integral type raise RuntimeError, "bad " + name + " typemap" except TypeError: - # TypeError is raised instead if swig is run with -O or -fastdispatch if val != limit: raise RuntimeError, "bad " + name + " typemap" diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py index 7105ba8d7..277ea757a 100644 --- a/Examples/test-suite/python/varargs_runme.py +++ b/Examples/test-suite/python/varargs_runme.py @@ -30,7 +30,5 @@ if varargs.test_plenty("Hello", 1, 2) != "Hello": try: varargs.test_plenty("Hello", 1, 2, 3) raise RuntimeError -except NotImplementedError: - pass except TypeError: pass diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 89a9d2a8b..f7ec22a51 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2645,7 +2645,7 @@ public: Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); - Printf(f->code, " SWIG_SetErrorMsg(PyExc_NotImplementedError," + Printf(f->code, " SWIG_SetErrorMsg(PyExc_TypeError," "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Printf(f->code, "return %s;\n", builtin_ctor ? "-1" : "0"); Delete(protoTypes); From e0b23969d0b27352f2411a3b087a4244b865adf3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 Aug 2018 08:54:40 +0100 Subject: [PATCH 1054/2031] Correct PyErr_Fetch/PyErr_Restore variable names --- Lib/python/builtin.swg | 6 +++--- Lib/python/pyrun.swg | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 4e39610fa..926f2d1c6 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -436,15 +436,15 @@ SwigPyBuiltin_destructor_closure(SwigPyWrapperFunction wrapper, const char *wrap Py_XDECREF(sobj->dict); if (sobj->own) { PyObject *o; - PyObject *val = 0, *type = 0, *tb = 0; - PyErr_Fetch(&val, &type, &tb); + PyObject *type = 0, *value = 0, *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); o = wrapper(a, NULL); if (!o) { PyObject *deallocname = PyString_FromString(wrappername); PyErr_WriteUnraisable(deallocname); Py_DECREF(deallocname); } - PyErr_Restore(val, type, tb); + PyErr_Restore(type, value, traceback); Py_XDECREF(o); } if (PyType_IS_GC(a->ob_type)) { diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index fb5859cbf..c3e83dcc9 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -530,8 +530,8 @@ SwigPyObject_dealloc(PyObject *v) remain true upon return from SwigPyObject_dealloc. So save and restore. */ - PyObject *val = NULL, *type = NULL, *tb = NULL; - PyErr_Fetch(&val, &type, &tb); + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); if (data->delargs) { /* we need to create a temporary object to carry the destroy operation */ @@ -546,7 +546,7 @@ SwigPyObject_dealloc(PyObject *v) if (!res) PyErr_WriteUnraisable(destroy); - PyErr_Restore(val, type, tb); + PyErr_Restore(type, value, traceback); Py_XDECREF(res); } From 4f7406624de3095f58816dcab73dc537d6d2e5c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 31 Jul 2018 20:00:20 +0100 Subject: [PATCH 1055/2031] Python fastdispatch error message improvements When overloaded C++ methods are called, the fastdispatch mode sometimes optimises out the generation of the typecheck typemap code, resulting in the 'Possible C/C++ prototypes' information not being in the error message. Now when a TypeError is thrown, the exception message is modified to contain the 'Possible C/C++ prototypes'. See issue #1293 --- CHANGES.current | 5 ++++ .../python/director_exception_runme.py | 26 +++++++++++++++- Lib/python/pyerrors.swg | 30 +++++++++++++++++++ Source/Modules/overload.cxx | 19 ++++++------ Source/Modules/python.cxx | 12 +++++--- Source/Modules/swigmod.h | 3 +- 6 files changed, 79 insertions(+), 16 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 64a2e65fd..04ea95c3d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-10: wsfulton + [Python] #1293 Improve TypeError message inconsistencies between default and fastdispatch + mode when handling overloaded C++ functions. Previously the error message did not always + display the possible C/C++ prototypes in fastdispatch mode. + 2018-07-31: wsfulton [Python] #1293 Overloaded C++ function wrappers now raise a TypeError instead of NotImplementedError when the types passed are incorrect. This change means diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 892c7e653..aa9d490a3 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -25,6 +25,13 @@ class MyFoo3(Foo): def ping(self): raise MyException("foo", "bar") +class MyFoo4(Foo): + + def ping(self, *args): + print(type("bad", "call")) # throws TypeError message: type() takes 1 or 3 arguments + return "Foo4.ping" + + # Check that the NotImplementedError raised by MyFoo.ping() is returned by # MyFoo.pong(). ok = 0 @@ -51,7 +58,8 @@ b = launder(a) try: b.pong() except TypeError, e: - if str(e) == "SWIG director type mismatch in output value of type 'std::string'": + # fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists + if str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"): ok = 1 else: print "Unexpected error message: %s" % str(e) @@ -74,6 +82,22 @@ except MyException, e: if not ok: raise RuntimeError + +# Check that the director returns the appropriate TypeError thrown in a director method +ok = 0 +a = MyFoo4() +b = launder(a) +try: + b.pong() +except TypeError as e: + if str(e).startswith("type() takes 1 or 3 arguments"): + ok = 1 + else: + print "Unexpected error message: %s" % str(e) +if not ok: + raise RuntimeError + + # This is expected to fail with -builtin option # Throwing builtin classes as exceptions not supported if not is_python_builtin(): diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index 463afae15..85c7d86db 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -71,3 +71,33 @@ SWIG_Python_AddErrorMsg(const char* mesg) PyErr_SetString(PyExc_RuntimeError, mesg); } } + +SWIGRUNTIME int +SWIG_Python_TypeErrorOccurred(PyObject *obj) +{ + PyObject *error; + if (obj) + return 0; + error = PyErr_Occurred(); + return error && PyErr_GivenExceptionMatches(error, PyExc_TypeError); +} + +SWIGRUNTIME void +SWIG_Python_RaiseOrModifyTypeError(const char *message) +{ + if (SWIG_Python_TypeErrorOccurred(NULL)) { + /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *type = NULL, *value = NULL, *traceback = NULL; + PyErr_Fetch(&type, &value, &traceback); +#if PY_VERSION_HEX >= 0x03000000 + PyObject *newvalue = PyUnicode_FromFormat("%S\nAdditional Information:\n%s", value, message); +#else + PyObject *newvalue = PyString_FromFormat("%s\nAdditional Information:\n%s", PyString_AsString(value), message); +#endif + Py_XDECREF(value); + PyErr_Restore(type, newvalue, traceback); + } else { + /* Raise TypeError using given message */ + PyErr_SetString(PyExc_TypeError, message); + } +} diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 3945d598f..5d278107c 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -442,7 +442,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int * /* Loop over the functions */ - bool emitcheck = 1; + bool emitcheck = true; for (i = 0; i < nfunc; i++) { int fn = 0; Node *ni = Getitem(dispatch, i); @@ -518,7 +518,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int * if (tml) Replaceid(tml, Getattr(pl, "lname"), "_v"); if (!tml || Cmp(tm, tml)) - emitcheck = 1; + emitcheck = true; //printf("tmap: %s[%d] (%d) => %s\n\n", // Char(Getattr(nk, "sym:name")), // l, emitcheck, tml?Char(tml):0); @@ -610,7 +610,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) { +static String *overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs, const_String_or_char_ptr fmt_fastdispatch) { int i, j; *maxargs = 1; @@ -653,6 +653,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int * // printf("overload: %s coll=%d\n", Char(Getattr(n, "sym:name")), Len(coll)); + bool emitcheck = false; int num_braces = 0; bool test = (Len(coll) > 0 && num_arguments); if (test) { @@ -673,7 +674,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int * /* if all the wrappers have the same type check on this argument we can optimize it out */ - bool emitcheck = 0; + emitcheck = false; for (int k = 0; k < Len(coll) && !emitcheck; k++) { Node *nk = Getitem(coll, k); Parm *pk = Getattr(nk, "wrap:parms"); @@ -695,7 +696,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int * if (tml) Replaceid(tml, Getattr(pl, "lname"), "_v"); if (!tml || Cmp(tm, tml)) - emitcheck = 1; + emitcheck = true; //printf("tmap: %s[%d] (%d) => %s\n\n", // Char(Getattr(nk, "sym:name")), // l, emitcheck, tml?Char(tml):0); @@ -752,8 +753,8 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int * for ( /* empty */ ; num_braces > 0; num_braces--) Printf(f, "}\n"); - - String *lfmt = ReplaceFormat(fmt, num_arguments); + // The language module may want to generate different code for last overloaded function called (with same number of arguments) + String *lfmt = ReplaceFormat(!emitcheck && fmt_fastdispatch ? fmt_fastdispatch : fmt, num_arguments); Printf(f, Char(lfmt), Getattr(ni, "wrap:name")); Printf(f, "}\n"); /* braces closes "if" for this method */ @@ -770,10 +771,10 @@ 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_ptr fmt, int *maxargs, const_String_or_char_ptr fmt_fastdispatch) { if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) { - return Swig_overload_dispatch_fast(n, fmt, maxargs); + return overload_dispatch_fast(n, fmt, maxargs, fmt_fastdispatch); } int i, j; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f7ec22a51..8e234d8ad 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2578,13 +2578,16 @@ public: String *tmp = NewString(""); String *dispatch; - const char *dispatch_code = funpack ? "return %s(self, argc, argv);" : - (builtin_ctor ? "return %s(self, args, NULL);" : "return %s(self, args);"); + + const char *dispatch_call = funpack ? "%s(self, argc, argv);" : (builtin_ctor ? "%s(self, args, NULL);" : "%s(self, args);"); + String *dispatch_code = NewStringf("return %s", dispatch_call); if (castmode) { dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs); } else { - dispatch = Swig_overload_dispatch(n, dispatch_code, &maxargs); + String *fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call); + dispatch = Swig_overload_dispatch(n, dispatch_code, &maxargs, fastdispatch_code); + Delete(fastdispatch_code); } /* Generate a dispatch wrapper for all overloaded functions */ @@ -2645,7 +2648,7 @@ public: Delete(fulldecl); } while ((sibl = Getattr(sibl, "sym:nextSibling"))); Append(f->code, "fail:\n"); - Printf(f->code, " SWIG_SetErrorMsg(PyExc_TypeError," + Printf(f->code, " SWIG_Python_RaiseOrModifyTypeError(" "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes); Printf(f->code, "return %s;\n", builtin_ctor ? "-1" : "0"); Delete(protoTypes); @@ -2662,6 +2665,7 @@ public: } DelWrapper(f); Delete(dispatch); + Delete(dispatch_code); Delete(tmp); Delete(wname); } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 1e49993bf..9626166a6 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -375,9 +375,8 @@ 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(Node *n, const_String_or_char_ptr fmt, int *, const_String_or_char_ptr fmt_fastdispatch = 0); 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 *); List *Swig_overload_rank(Node *n, bool script_lang_wrapping); SwigType *cplus_value_type(SwigType *t); From 91e9743014961f02cdf941a4c719d3a55e953c53 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Aug 2018 12:44:23 +0100 Subject: [PATCH 1056/2031] Fix to make ISOC89 compliant: -Werror=declaration-after-statement --- Lib/python/pyerrors.swg | 5 +++-- Source/Modules/python.cxx | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index 85c7d86db..f21d28b45 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -87,12 +87,13 @@ SWIG_Python_RaiseOrModifyTypeError(const char *message) { if (SWIG_Python_TypeErrorOccurred(NULL)) { /* Use existing TypeError to preserve stacktrace and enhance with given message */ + PyObject *newvalue; PyObject *type = NULL, *value = NULL, *traceback = NULL; PyErr_Fetch(&type, &value, &traceback); #if PY_VERSION_HEX >= 0x03000000 - PyObject *newvalue = PyUnicode_FromFormat("%S\nAdditional Information:\n%s", value, message); + newvalue = PyUnicode_FromFormat("%S\nAdditional Information:\n%s", value, message); #else - PyObject *newvalue = PyString_FromFormat("%s\nAdditional Information:\n%s", PyString_AsString(value), message); + newvalue = PyString_FromFormat("%s\nAdditional Information:\n%s", PyString_AsString(value), message); #endif Py_XDECREF(value); PyErr_Restore(type, newvalue, traceback); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index dfdee8d63..40bc06bca 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2586,6 +2586,10 @@ public: dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs); } else { String *fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call); + if (!CPlusPlus) { + Insert(fastdispatch_code, 0, "{\n"); + Append(fastdispatch_code, "\n}"); + } dispatch = Swig_overload_dispatch(n, dispatch_code, &maxargs, fastdispatch_code); Delete(fastdispatch_code); } From 3938e6f769f69a5d495107427161701c7b2791fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Aug 2018 18:39:53 +0100 Subject: [PATCH 1057/2031] Python2 -O testing finally no longer fails --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f8553845c..23207164f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -364,12 +364,6 @@ matrix: env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 sudo: required dist: trusty - # Not quite working yet - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-O - sudo: required - dist: trusty before_install: - date -u From e19ad6d471ec6a853b0f4e39ce4824a720cb78ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 10 Aug 2018 18:42:30 +0100 Subject: [PATCH 1058/2031] Test Python 3 -O on Travis (currently failing) --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 23207164f..82c7dffa5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -207,6 +207,11 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-O sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.7 + sudo: required + dist: trusty - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-classic @@ -364,6 +369,12 @@ matrix: env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 sudo: required dist: trusty + # Not quite working yet + - compiler: gcc + os: linux + env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 + sudo: required + dist: trusty before_install: - date -u From 7eeffe698ccf7eace3a7a324a88f6d89b7849d27 Mon Sep 17 00:00:00 2001 From: Bryan Atwood Date: Fri, 10 Aug 2018 17:12:34 -0700 Subject: [PATCH 1059/2031] Fix Java directorargout typemap crash when argument pointer is null --- Lib/java/typemaps.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index 1785d97ce..fd7c267a1 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -227,7 +227,7 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type { JNITYPE $1_jvalue; JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = ($*1_ltype)$1_jvalue; + if ($result) *$result = ($*1_ltype)$1_jvalue; } %typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; From 99f8e12d32cf95f22f7cce3c0b4975cf0a292d48 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 11 Aug 2018 17:11:24 +0100 Subject: [PATCH 1060/2031] Java director typemaps.i testing for pointers added Copy java_director_typemaps testcase to test pointers instead of references. --- Examples/test-suite/java/Makefile.in | 1 + .../java_director_typemaps_ptr_runme.java | 151 +++++++ .../java/java_director_typemaps_runme.java | 8 +- Examples/test-suite/java_director_typemaps.i | 13 +- .../test-suite/java_director_typemaps_ptr.i | 368 ++++++++++++++++++ 5 files changed, 531 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/java/java_director_typemaps_ptr_runme.java create mode 100644 Examples/test-suite/java_director_typemaps_ptr.i diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index cef59274b..8a98172ed 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -31,6 +31,7 @@ CPP_TEST_CASES = \ java_director_exception_feature_nspace \ java_director_ptrclass \ java_director_typemaps \ + java_director_typemaps_ptr \ java_enums \ java_jnitypes \ java_lib_arrays_dimensionless \ diff --git a/Examples/test-suite/java/java_director_typemaps_ptr_runme.java b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java new file mode 100644 index 000000000..fdd0bfd4e --- /dev/null +++ b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java @@ -0,0 +1,151 @@ +// Test director pointer typemaps in typemaps.i - similar to java_director_typemaps.i testcase + +import java_director_typemaps_ptr.*; +import java.math.BigInteger; + +public class java_director_typemaps_ptr_runme { + + static { + try { + System.loadLibrary("java_director_typemaps_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); + } + } + + + public static void main(String argv[]) { + Quux quux = new java_director_typemaps_ptr_MyQuux(); + quux.etest(); + } +} + +class java_director_typemaps_ptr_MyQuux extends Quux { + public java_director_typemaps_ptr_MyQuux() { + super(); + } + + public void director_method_output( + boolean[] bool_arg, + + byte[] signed_char_arg, + short[] unsigned_char_arg, + + short[] short_arg, + int[] unsigned_short_arg, + + int[] int_arg, + long[] unsigned_int_arg, + + int[] long_arg, + long[] unsigned_long_arg, + + long[] long_long_arg, + // BigInteger[] unsigned_long_long_arg, + + float[] float_arg, + double[] double_arg) + { + bool_arg[0] = true; + signed_char_arg[0] = 1; + unsigned_char_arg[0] = 2; + short_arg[0] = 3; + unsigned_short_arg[0] = 4; + int_arg[0] = 5; + unsigned_int_arg[0] = 6; + long_arg[0] = 7; + unsigned_long_arg[0] = 8; + long_long_arg[0] = 9; + // unsigned_long_long_arg[0] = 10; + float_arg[0] = 11; + double_arg[0] = 12; + } + + public void director_method_inout( + boolean[] bool_arg, + + byte[] signed_char_arg, + short[] unsigned_char_arg, + + short[] short_arg, + int[] unsigned_short_arg, + + int[] int_arg, + long[] unsigned_int_arg, + + int[] long_arg, + long[] unsigned_long_arg, + + long[] long_long_arg, + // BigInteger[] unsigned_long_long_arg, + + float[] float_arg, + double[] double_arg) + { + if (bool_arg[0]) throw new RuntimeException("unexpected value for bool_arg"); + + if (signed_char_arg[0] != 101) throw new RuntimeException("unexpected value for signed_char_arg"); + if (unsigned_char_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_char_arg"); + if (short_arg[0] != 101) throw new RuntimeException("unexpected value for short_arg"); + if (unsigned_short_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_short_arg"); + if (int_arg[0] != 101) throw new RuntimeException("unexpected value for int_arg"); + if (unsigned_int_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_int_arg"); + if (long_arg[0] != 101) throw new RuntimeException("unexpected value for long_arg"); + if (unsigned_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_arg"); + if (long_long_arg[0] != 101) throw new RuntimeException("unexpected value for long_long_arg"); + // if (unsigned_long_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_long_arg"); + if (float_arg[0] != 101) throw new RuntimeException("unexpected value for float_arg"); + if (double_arg[0] != 101) throw new RuntimeException("unexpected value for double_arg"); + + bool_arg[0] = false; + signed_char_arg[0] = 11; + unsigned_char_arg[0] = 12; + short_arg[0] = 13; + unsigned_short_arg[0] = 14; + int_arg[0] = 15; + unsigned_int_arg[0] = 16; + long_arg[0] = 17; + unsigned_long_arg[0] = 18; + long_long_arg[0] = 19; + // unsigned_long_long_arg[0] = 110; + float_arg[0] = 111; + double_arg[0] = 112; + } + + public void director_method_nameless_args( + boolean[] bool_arg, + + byte[] signed_char_arg, + short[] unsigned_char_arg, + + short[] short_arg, + int[] unsigned_short_arg, + + int[] int_arg, + long[] unsigned_int_arg, + + int[] long_arg, + long[] unsigned_long_arg, + + long[] long_long_arg, + // BigInteger[] unsigned_long_long_arg, + + float[] float_arg, + double[] double_arg) + { + bool_arg[0] = true; + signed_char_arg[0] = 12; + unsigned_char_arg[0] = 13; + short_arg[0] = 14; + unsigned_short_arg[0] = 15; + int_arg[0] = 16; + unsigned_int_arg[0] = 17; + long_arg[0] = 18; + unsigned_long_arg[0] = 19; + long_long_arg[0] = 20; + // unsigned_long_long_arg[0] = 111; + float_arg[0] = 112; + double_arg[0] = 113; + } +} diff --git a/Examples/test-suite/java/java_director_typemaps_runme.java b/Examples/test-suite/java/java_director_typemaps_runme.java index e07826410..a6ab1df39 100644 --- a/Examples/test-suite/java/java_director_typemaps_runme.java +++ b/Examples/test-suite/java/java_director_typemaps_runme.java @@ -1,4 +1,4 @@ -// tests for java/typemaps.i used for directors +// Test director reference typemaps in typemaps.i - similar to java_director_typemaps_ptr.i testcase import java_director_typemaps.*; import java.math.BigInteger; @@ -26,7 +26,7 @@ class java_director_typemaps_MyQuux extends Quux { super(); } - public void director_method_bool_output( + public void director_method_output( boolean[] bool_arg, byte[] signed_char_arg, @@ -62,7 +62,7 @@ class java_director_typemaps_MyQuux extends Quux { double_arg[0] = 12; } - public void director_method_bool_inout( + public void director_method_inout( boolean[] bool_arg, byte[] signed_char_arg, @@ -113,7 +113,7 @@ class java_director_typemaps_MyQuux extends Quux { double_arg[0] = 112; } - public void director_method_bool_nameless_args( + public void director_method_nameless_args( boolean[] bool_arg, byte[] signed_char_arg, diff --git a/Examples/test-suite/java_director_typemaps.i b/Examples/test-suite/java_director_typemaps.i index e7bc9a659..2ffdeae89 100644 --- a/Examples/test-suite/java_director_typemaps.i +++ b/Examples/test-suite/java_director_typemaps.i @@ -1,4 +1,5 @@ %module(directors="1") java_director_typemaps +// Test director reference typemaps in typemaps.i - similar to java_director_typemaps_ptr.i testcase %feature("director", assumeoverride=1) Quux; @@ -75,7 +76,7 @@ public: Quux() {} virtual ~Quux() {} - virtual void director_method_bool_output( + virtual void director_method_output( bool& boolarg_output, signed char& signed_chararg_output, @@ -117,7 +118,7 @@ public: doublearg_output = 50; } - virtual void director_method_bool_inout( + virtual void director_method_inout( bool& boolarg_inout, signed char& signed_chararg_inout, @@ -159,7 +160,7 @@ public: doublearg_inout = 50; } - virtual void director_method_bool_nameless_args( + virtual void director_method_nameless_args( bool& , signed char& , @@ -203,7 +204,7 @@ public: float floatarg_inout = 150; double doublearg_inout = 150; - director_method_bool_output( + director_method_output( boolarg_inout, signed_chararg_inout, @@ -263,7 +264,7 @@ public: floatarg_inout = 101; doublearg_inout = 101; - director_method_bool_inout( + director_method_inout( boolarg_inout, signed_chararg_inout, @@ -303,7 +304,7 @@ public: verify(floatarg_inout == 111); verify(doublearg_inout == 112); - director_method_bool_nameless_args( + director_method_nameless_args( boolarg_inout, signed_chararg_inout, diff --git a/Examples/test-suite/java_director_typemaps_ptr.i b/Examples/test-suite/java_director_typemaps_ptr.i new file mode 100644 index 000000000..dcae1d850 --- /dev/null +++ b/Examples/test-suite/java_director_typemaps_ptr.i @@ -0,0 +1,368 @@ +%module(directors="1") java_director_typemaps +// Test director pointer typemaps in typemaps.i - similar to java_director_typemaps.i testcase + +%feature("director", assumeoverride=1) Quux; + +%include + +%apply bool* OUTPUT {bool*}; + +%apply signed char* OUTPUT {signed char*}; +%apply unsigned char* OUTPUT {unsigned char*}; + +%apply short* OUTPUT {short*}; +%apply unsigned short* OUTPUT {unsigned short*}; + +%apply int* OUTPUT {int*}; +%apply unsigned int* OUTPUT {unsigned int*}; + +%apply long* OUTPUT {long*}; +%apply unsigned long* OUTPUT {unsigned long*}; + +%apply long long* OUTPUT {long long*}; +// %apply unsigned long long* OUTPUT {unsigned long long*}; + +%apply float* OUTPUT {float*}; +%apply double* OUTPUT {double*}; + +%apply bool* OUTPUT {bool* boolarg_output}; + +%apply signed char* OUTPUT {signed char* signed_chararg_output}; +%apply unsigned char* OUTPUT {unsigned char* unsigned_chararg_output}; + +%apply short* OUTPUT {short* shortarg_output}; +%apply unsigned short* OUTPUT {unsigned short* unsigned_shortarg_output}; + +%apply int* OUTPUT {int* intarg_output}; +%apply unsigned int* OUTPUT {unsigned int* unsigned_intarg_output}; + +%apply long* OUTPUT {long* longarg_output}; +%apply unsigned long* OUTPUT {unsigned long* unsigned_longarg_output}; + +%apply long long* OUTPUT {long long* long_longarg_output}; +// %apply unsigned long long* OUTPUT {unsigned long long* unsigned_long_longarg_output}; + +%apply float* OUTPUT {float* floatarg_output}; +%apply double* OUTPUT {double* doublearg_output}; + +%apply bool* INOUT {bool* boolarg_inout}; + +%apply signed char* INOUT {signed char* signed_chararg_inout}; +%apply unsigned char* INOUT {unsigned char* unsigned_chararg_inout}; + +%apply short* INOUT {short* shortarg_inout}; +%apply unsigned short* INOUT {unsigned short* unsigned_shortarg_inout}; + +%apply int* INOUT {int* intarg_inout}; +%apply unsigned int* INOUT {unsigned int* unsigned_intarg_inout}; + +%apply long* INOUT {long* longarg_inout}; +%apply unsigned long* INOUT {unsigned long* unsigned_longarg_inout}; + +%apply long long* INOUT {long long* long_longarg_inout}; +// %apply unsigned long long* INOUT {unsigned long long* unsigned_long_longarg_inout}; + +%apply float* INOUT {float* floatarg_inout}; +%apply double* INOUT {double* doublearg_inout}; + +%{ +#include +#define verify(ok) if (!(ok)) throw std::runtime_error(# ok); +%} +%inline %{ + +class Quux { +public: + Quux() {} + virtual ~Quux() {} + + virtual void director_method_output( + bool* boolarg_output, + + signed char* signed_chararg_output, + unsigned char* unsigned_chararg_output, + + short* shortarg_output, + unsigned short* unsigned_shortarg_output, + + int* intarg_output, + unsigned int* unsigned_intarg_output, + + long* longarg_output, + unsigned long* unsigned_longarg_output, + + long long* long_longarg_output, + // unsigned long long* unsigned_long_longarg_output, + + float* floatarg_output, + double* doublearg_output) + { + if (boolarg_output) *boolarg_output = false; + + if (signed_chararg_output) *signed_chararg_output = 50; + if (unsigned_chararg_output) *unsigned_chararg_output = 50; + + if (shortarg_output) *shortarg_output = 50; + if (unsigned_shortarg_output) *unsigned_shortarg_output = 50; + + if (intarg_output) *intarg_output = 50; + if (unsigned_intarg_output) *unsigned_intarg_output = 50; + + if (longarg_output) *longarg_output = 50; + if (unsigned_longarg_output) *unsigned_longarg_output = 50; + + if (long_longarg_output) *long_longarg_output = 50; + // if (unsigned_long_longarg_output) *unsigned_long_longarg_output = 50; + + if (floatarg_output) *floatarg_output = 50; + if (doublearg_output) *doublearg_output = 50; + } + + virtual void director_method_inout( + bool* boolarg_inout, + + signed char* signed_chararg_inout, + unsigned char* unsigned_chararg_inout, + + short* shortarg_inout, + unsigned short* unsigned_shortarg_inout, + + int* intarg_inout, + unsigned int* unsigned_intarg_inout, + + long* longarg_inout, + unsigned long* unsigned_longarg_inout, + + long long* long_longarg_inout, + // unsigned long long* unsigned_long_longarg_inout, + + float* floatarg_inout, + double* doublearg_inout) + { + if (boolarg_inout) *boolarg_inout = false; + + if (signed_chararg_inout) *signed_chararg_inout = 50; + if (unsigned_chararg_inout) *unsigned_chararg_inout = 50; + + if (shortarg_inout) *shortarg_inout = 50; + if (unsigned_shortarg_inout) *unsigned_shortarg_inout = 50; + + if (intarg_inout) *intarg_inout = 50; + if (unsigned_intarg_inout) *unsigned_intarg_inout = 50; + + if (longarg_inout) *longarg_inout = 50; + if (unsigned_longarg_inout) *unsigned_longarg_inout = 50; + + if (long_longarg_inout) *long_longarg_inout = 50; + // if (unsigned_long_longarg_inout) *unsigned_long_longarg_inout = 50; + + if (floatarg_inout) *floatarg_inout = 50; + if (doublearg_inout) *doublearg_inout = 50; + } + + virtual void director_method_nameless_args( + bool* , + + signed char* , + unsigned char* , + + short* , + unsigned short* , + + int* , + unsigned int* , + + long* , + unsigned long* , + + long long* , + // unsigned long long* , + + float* , + double*) + { + } + + void etest() { + bool boolarg_inout = false; + + signed char signed_chararg_inout = 111; + unsigned char unsigned_chararg_inout = 150; + + short shortarg_inout = 150; + unsigned short unsigned_shortarg_inout = 150; + + int intarg_inout = 150; + unsigned int unsigned_intarg_inout = 150; + + long longarg_inout = 150; + unsigned long unsigned_longarg_inout = 150; + + long long long_longarg_inout = 150; + // unsigned long long unsigned_long_longarg_inout = 150; + + float floatarg_inout = 150; + double doublearg_inout = 150; + + director_method_output( + &boolarg_inout, + + &signed_chararg_inout, + &unsigned_chararg_inout, + + &shortarg_inout, + &unsigned_shortarg_inout, + + &intarg_inout, + &unsigned_intarg_inout, + + &longarg_inout, + &unsigned_longarg_inout, + + &long_longarg_inout, + // &unsigned_long_longarg_inout, + + &floatarg_inout, + &doublearg_inout); + + verify(boolarg_inout == true); + verify(signed_chararg_inout == 1); + verify(unsigned_chararg_inout == 2); + + verify(shortarg_inout == 3); + verify(unsigned_shortarg_inout == 4); + + verify(intarg_inout == 5); + verify(unsigned_intarg_inout == 6); + + verify(longarg_inout == 7); + verify(unsigned_longarg_inout == 8); + + verify(long_longarg_inout == 9); + // verify(unsigned_long_longarg_inout == 10); + + verify(floatarg_inout == 11); + verify(doublearg_inout == 12); + + boolarg_inout = false; + + signed_chararg_inout = 101; + unsigned_chararg_inout = 101; + + shortarg_inout = 101; + unsigned_shortarg_inout = 101; + + intarg_inout = 101; + unsigned_intarg_inout = 101; + + longarg_inout = 101; + unsigned_longarg_inout = 101; + + long_longarg_inout = 101; + // unsigned_long_longarg_inout = 101; + + floatarg_inout = 101; + doublearg_inout = 101; + + director_method_inout( + &boolarg_inout, + + &signed_chararg_inout, + &unsigned_chararg_inout, + + &shortarg_inout, + &unsigned_shortarg_inout, + + &intarg_inout, + &unsigned_intarg_inout, + + &longarg_inout, + &unsigned_longarg_inout, + + &long_longarg_inout, + // &unsigned_long_longarg_inout, + + &floatarg_inout, + &doublearg_inout); + + verify(boolarg_inout == false); + verify(signed_chararg_inout == 11); + verify(unsigned_chararg_inout == 12); + + verify(shortarg_inout == 13); + verify(unsigned_shortarg_inout == 14); + + verify(intarg_inout == 15); + verify(unsigned_intarg_inout == 16); + + verify(longarg_inout == 17); + verify(unsigned_longarg_inout == 18); + + verify(long_longarg_inout == 19); + // verify(unsigned_long_longarg_inout == 110); + + verify(floatarg_inout == 111); + verify(doublearg_inout == 112); + + director_method_nameless_args( + &boolarg_inout, + + &signed_chararg_inout, + &unsigned_chararg_inout, + + &shortarg_inout, + &unsigned_shortarg_inout, + + &intarg_inout, + &unsigned_intarg_inout, + + &longarg_inout, + &unsigned_longarg_inout, + + &long_longarg_inout, + // &unsigned_long_longarg_inout, + + &floatarg_inout, + &doublearg_inout); + + verify(boolarg_inout == true); + verify(signed_chararg_inout == 12); + verify(unsigned_chararg_inout == 13); + + verify(shortarg_inout == 14); + verify(unsigned_shortarg_inout == 15); + + verify(intarg_inout == 16); + verify(unsigned_intarg_inout == 17); + + verify(longarg_inout == 18); + verify(unsigned_longarg_inout == 19); + + verify(long_longarg_inout == 20); + // verify(unsigned_long_longarg_inout == 111); + + verify(floatarg_inout == 112); + verify(doublearg_inout == 113); + } +}; +%} + +%clear bool*; + +%clear signed char*; +%clear unsigned char*; + +%clear short*; +%clear unsigned short*; + +%clear int*; +%clear unsigned int*; + +%clear long*; +%clear unsigned long*; + +%clear long long*; +// %clear unsigned long long*; + +%clear float*; +%clear double*; From 61d9dd40a02b20b54fcd0d9701861cc8bd631e92 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 Aug 2018 13:45:43 +0100 Subject: [PATCH 1061/2031] Fix crash Java directors Further crash fixes when using OUTPUT and INOUT typemaps in typemaps.i and passing NULL pointers in C++ to director method overloaded and implemented in Java. Don't create the one element array in these directorin typemaps if the input is a NULL pointer, that is, translate a NULL C++ pointer into a null Java object. Also add some missing JNI error checks in these typemaps. --- CHANGES.current | 4 + .../java_director_typemaps_ptr_runme.java | 157 ++++++++++++------ .../test-suite/java_director_typemaps_ptr.i | 65 ++++++++ Lib/java/typemaps.i | 50 ++++-- 4 files changed, 208 insertions(+), 68 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1f25e912d..85d1ffe54 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-12: brianhatwood,wsfulton + [Java] #1303 #1304 Fix crash in directors when using OUTPUT and INOUT typemaps in typemaps.i and + passing NULL pointers in C++ to director method overloaded and implemented in Java. + 2018-08-10: wsfulton [Python] #1293 Improve TypeError message inconsistencies between default and fastdispatch mode when handling overloaded C++ functions. Previously the error message did not always diff --git a/Examples/test-suite/java/java_director_typemaps_ptr_runme.java b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java index fdd0bfd4e..c387270cd 100644 --- a/Examples/test-suite/java/java_director_typemaps_ptr_runme.java +++ b/Examples/test-suite/java/java_director_typemaps_ptr_runme.java @@ -16,8 +16,11 @@ public class java_director_typemaps_ptr_runme { public static void main(String argv[]) { - Quux quux = new java_director_typemaps_ptr_MyQuux(); + java_director_typemaps_ptr_MyQuux myquux = new java_director_typemaps_ptr_MyQuux(); + Quux quux = myquux; quux.etest(); + myquux.testing_nulls = true; + quux.nulltest(); } } @@ -25,6 +28,7 @@ class java_director_typemaps_ptr_MyQuux extends Quux { public java_director_typemaps_ptr_MyQuux() { super(); } + public boolean testing_nulls = false; public void director_method_output( boolean[] bool_arg, @@ -47,19 +51,34 @@ class java_director_typemaps_ptr_MyQuux extends Quux { float[] float_arg, double[] double_arg) { - bool_arg[0] = true; - signed_char_arg[0] = 1; - unsigned_char_arg[0] = 2; - short_arg[0] = 3; - unsigned_short_arg[0] = 4; - int_arg[0] = 5; - unsigned_int_arg[0] = 6; - long_arg[0] = 7; - unsigned_long_arg[0] = 8; - long_long_arg[0] = 9; - // unsigned_long_long_arg[0] = 10; - float_arg[0] = 11; - double_arg[0] = 12; + if (testing_nulls) { + if (bool_arg != null) throw new RuntimeException("not null bool_arg"); + if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg"); + if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg"); + if (short_arg != null) throw new RuntimeException("not null short_arg"); + if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg"); + if (int_arg != null) throw new RuntimeException("not null int_arg"); + if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg"); + if (long_arg != null) throw new RuntimeException("not null long_arg"); + if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg"); + if (long_long_arg != null) throw new RuntimeException("not null long_long_arg"); + // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg"); + if (float_arg != null) throw new RuntimeException("not null float_arg"); + if (double_arg != null) throw new RuntimeException("not null double_arg"); + } + if (bool_arg != null) bool_arg[0] = true; + if (signed_char_arg != null) signed_char_arg[0] = 1; + if (unsigned_char_arg != null) unsigned_char_arg[0] = 2; + if (short_arg != null) short_arg[0] = 3; + if (unsigned_short_arg != null) unsigned_short_arg[0] = 4; + if (int_arg != null) int_arg[0] = 5; + if (unsigned_int_arg != null) unsigned_int_arg[0] = 6; + if (long_arg != null) long_arg[0] = 7; + if (unsigned_long_arg != null) unsigned_long_arg[0] = 8; + if (long_long_arg != null) long_long_arg[0] = 9; + // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 10; + if (float_arg != null) float_arg[0] = 11; + if (double_arg != null) double_arg[0] = 12; } public void director_method_inout( @@ -83,34 +102,49 @@ class java_director_typemaps_ptr_MyQuux extends Quux { float[] float_arg, double[] double_arg) { - if (bool_arg[0]) throw new RuntimeException("unexpected value for bool_arg"); + if (testing_nulls) { + if (bool_arg != null) throw new RuntimeException("not null bool_arg"); + if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg"); + if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg"); + if (short_arg != null) throw new RuntimeException("not null short_arg"); + if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg"); + if (int_arg != null) throw new RuntimeException("not null int_arg"); + if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg"); + if (long_arg != null) throw new RuntimeException("not null long_arg"); + if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg"); + if (long_long_arg != null) throw new RuntimeException("not null long_long_arg"); + // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg"); + if (float_arg != null) throw new RuntimeException("not null float_arg"); + if (double_arg != null) throw new RuntimeException("not null double_arg"); + } else { + if (bool_arg[0]) throw new RuntimeException("unexpected value for bool_arg"); + if (signed_char_arg[0] != 101) throw new RuntimeException("unexpected value for signed_char_arg"); + if (unsigned_char_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_char_arg"); + if (short_arg[0] != 101) throw new RuntimeException("unexpected value for short_arg"); + if (unsigned_short_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_short_arg"); + if (int_arg[0] != 101) throw new RuntimeException("unexpected value for int_arg"); + if (unsigned_int_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_int_arg"); + if (long_arg[0] != 101) throw new RuntimeException("unexpected value for long_arg"); + if (unsigned_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_arg"); + if (long_long_arg[0] != 101) throw new RuntimeException("unexpected value for long_long_arg"); + // if (unsigned_long_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_long_arg"); + if (float_arg[0] != 101) throw new RuntimeException("unexpected value for float_arg"); + if (double_arg[0] != 101) throw new RuntimeException("unexpected value for double_arg"); + } - if (signed_char_arg[0] != 101) throw new RuntimeException("unexpected value for signed_char_arg"); - if (unsigned_char_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_char_arg"); - if (short_arg[0] != 101) throw new RuntimeException("unexpected value for short_arg"); - if (unsigned_short_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_short_arg"); - if (int_arg[0] != 101) throw new RuntimeException("unexpected value for int_arg"); - if (unsigned_int_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_int_arg"); - if (long_arg[0] != 101) throw new RuntimeException("unexpected value for long_arg"); - if (unsigned_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_arg"); - if (long_long_arg[0] != 101) throw new RuntimeException("unexpected value for long_long_arg"); - // if (unsigned_long_long_arg[0] != 101) throw new RuntimeException("unexpected value for unsigned_long_long_arg"); - if (float_arg[0] != 101) throw new RuntimeException("unexpected value for float_arg"); - if (double_arg[0] != 101) throw new RuntimeException("unexpected value for double_arg"); - - bool_arg[0] = false; - signed_char_arg[0] = 11; - unsigned_char_arg[0] = 12; - short_arg[0] = 13; - unsigned_short_arg[0] = 14; - int_arg[0] = 15; - unsigned_int_arg[0] = 16; - long_arg[0] = 17; - unsigned_long_arg[0] = 18; - long_long_arg[0] = 19; - // unsigned_long_long_arg[0] = 110; - float_arg[0] = 111; - double_arg[0] = 112; + if (bool_arg != null) bool_arg[0] = false; + if (signed_char_arg != null) signed_char_arg[0] = 11; + if (unsigned_char_arg != null) unsigned_char_arg[0] = 12; + if (short_arg != null) short_arg[0] = 13; + if (unsigned_short_arg != null) unsigned_short_arg[0] = 14; + if (int_arg != null) int_arg[0] = 15; + if (unsigned_int_arg != null) unsigned_int_arg[0] = 16; + if (long_arg != null) long_arg[0] = 17; + if (unsigned_long_arg != null) unsigned_long_arg[0] = 18; + if (long_long_arg != null) long_long_arg[0] = 19; + // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 110; + if (float_arg != null) float_arg[0] = 111; + if (double_arg != null) double_arg[0] = 112; } public void director_method_nameless_args( @@ -134,18 +168,33 @@ class java_director_typemaps_ptr_MyQuux extends Quux { float[] float_arg, double[] double_arg) { - bool_arg[0] = true; - signed_char_arg[0] = 12; - unsigned_char_arg[0] = 13; - short_arg[0] = 14; - unsigned_short_arg[0] = 15; - int_arg[0] = 16; - unsigned_int_arg[0] = 17; - long_arg[0] = 18; - unsigned_long_arg[0] = 19; - long_long_arg[0] = 20; - // unsigned_long_long_arg[0] = 111; - float_arg[0] = 112; - double_arg[0] = 113; + if (testing_nulls) { + if (bool_arg != null) throw new RuntimeException("not null bool_arg"); + if (signed_char_arg != null) throw new RuntimeException("not null signed_char_arg"); + if (unsigned_char_arg != null) throw new RuntimeException("not null unsigned_char_arg"); + if (short_arg != null) throw new RuntimeException("not null short_arg"); + if (unsigned_short_arg != null) throw new RuntimeException("not null unsigned_short_arg"); + if (int_arg != null) throw new RuntimeException("not null int_arg"); + if (unsigned_int_arg != null) throw new RuntimeException("not null unsigned_int_arg"); + if (long_arg != null) throw new RuntimeException("not null long_arg"); + if (unsigned_long_arg != null) throw new RuntimeException("not null unsigned_long_arg"); + if (long_long_arg != null) throw new RuntimeException("not null long_long_arg"); + // if (unsigned_long_long_arg != null) throw new RuntimeException("not null unsigned_long_long_arg"); + if (float_arg != null) throw new RuntimeException("not null float_arg"); + if (double_arg != null) throw new RuntimeException("not null double_arg"); + } + if (bool_arg != null) bool_arg[0] = true; + if (signed_char_arg != null) signed_char_arg[0] = 12; + if (unsigned_char_arg != null) unsigned_char_arg[0] = 13; + if (short_arg != null) short_arg[0] = 14; + if (unsigned_short_arg != null) unsigned_short_arg[0] = 15; + if (int_arg != null) int_arg[0] = 16; + if (unsigned_int_arg != null) unsigned_int_arg[0] = 17; + if (long_arg != null) long_arg[0] = 18; + if (unsigned_long_arg != null) unsigned_long_arg[0] = 19; + if (long_long_arg != null) long_long_arg[0] = 20; + // if (unsigned_long_long_arg != null) unsigned_long_long_arg[0] = 111; + if (float_arg != null) float_arg[0] = 112; + if (double_arg != null) double_arg[0] = 113; } } diff --git a/Examples/test-suite/java_director_typemaps_ptr.i b/Examples/test-suite/java_director_typemaps_ptr.i index dcae1d850..578001ac1 100644 --- a/Examples/test-suite/java_director_typemaps_ptr.i +++ b/Examples/test-suite/java_director_typemaps_ptr.i @@ -344,6 +344,71 @@ public: verify(floatarg_inout == 112); verify(doublearg_inout == 113); } + + void nulltest() { + director_method_output( + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + // NULL, + + NULL, + NULL); + + director_method_inout( + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + // NULL, + + NULL, + NULL); + + director_method_nameless_args( + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + NULL, + + NULL, + // NULL, + + NULL, + NULL); + } }; %} diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index fd7c267a1..e130c1930 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -212,8 +212,16 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); } -%typemap(directorin,descriptor=JNIDESC) TYPE &OUTPUT, TYPE *OUTPUT %{ +%typemap(directorin,descriptor=JNIDESC) TYPE &OUTPUT %{ $input = JCALL1(New##JAVATYPE##Array, jenv, 1); + if (!$input) return $null; + Swig::LocalRefGuard $1_refguard(jenv, $input); %} + +%typemap(directorin,descriptor=JNIDESC) TYPE *OUTPUT %{ + if ($1) { + $input = JCALL1(New##JAVATYPE##Array, jenv, 1); + if (!$input) return $null; + } Swig::LocalRefGuard $1_refguard(jenv, $input); %} %typemap(directorargout, noblock=1) TYPE &OUTPUT @@ -225,9 +233,11 @@ There are no char *OUTPUT typemaps, however you can apply the signed char * type %typemap(directorargout, noblock=1) TYPE *OUTPUT { - JNITYPE $1_jvalue; - JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - if ($result) *$result = ($*1_ltype)$1_jvalue; + if ($result) { + JNITYPE $1_jvalue; + JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = ($*1_ltype)$1_jvalue; + } } %typemap(typecheck) TYPE *OUTPUT = TYPECHECKTYPE; @@ -273,9 +283,11 @@ OUTPUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray); %typemap(directorargout, noblock=1) bool *OUTPUT { - jboolean $1_jvalue; - JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = $1_jvalue ? true : false; + if ($result) { + jboolean $1_jvalue; + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = $1_jvalue ? true : false; + } } @@ -388,14 +400,18 @@ There are no char *INOUT typemaps, however you can apply the signed char * typem %typemap(directorin,descriptor=JNIDESC) TYPE &INOUT %{ $input = JCALL1(New##JAVATYPE##Array, jenv, 1); + if (!$input) return $null; JNITYPE $1_jvalue = (JNITYPE)$1; JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); Swig::LocalRefGuard $1_refguard(jenv, $input); %} %typemap(directorin,descriptor=JNIDESC) TYPE *INOUT %{ - $input = JCALL1(New##JAVATYPE##Array, jenv, 1); - JNITYPE $1_jvalue = (JNITYPE)*$1; - JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + if ($1) { + $input = JCALL1(New##JAVATYPE##Array, jenv, 1); + if (!$input) return $null; + JNITYPE $1_jvalue = (JNITYPE)*$1; + JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + } Swig::LocalRefGuard $1_refguard(jenv, $input); %} %typemap(directorargout, noblock=1) TYPE &INOUT @@ -406,8 +422,11 @@ There are no char *INOUT typemaps, however you can apply the signed char * typem %typemap(directorargout, noblock=1) TYPE *INOUT { - JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = ($*1_ltype)$1_jvalue; + if ($result) { + JNITYPE $1_jvalue; + JCALL4(Get##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = ($*1_ltype)$1_jvalue; + } } %typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; @@ -459,8 +478,11 @@ INOUT_TYPEMAP(double, jdouble, double, Double, "[D", jdoubleArray); %typemap(directorargout, noblock=1) bool *INOUT { - JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); - *$result = $1_jvalue ? true : false; + if ($result) { + jboolean $1_jvalue; + JCALL4(GetBooleanArrayRegion, jenv, $input, 0, 1, &$1_jvalue); + *$result = $1_jvalue ? true : false; + } } From 4313c2c16829da32408b9e69b6a42ae7c8a0b112 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 Aug 2018 15:02:28 +0100 Subject: [PATCH 1062/2031] Update pybuffer.i library to use new-style Python buffer C API. Removed old API altogether as Python 2.7 is now the minimum version supported and it supports the new-style buffer API. --- CHANGES.current | 3 +++ Doc/Manual/Python.html | 6 ++--- Examples/test-suite/python_pybuf.i | 4 ++-- Lib/python/pybuffer.i | 38 ++++++++---------------------- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 85d1ffe54..1ced20389 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-12: gmazzamuto + [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. + 2018-08-12: brianhatwood,wsfulton [Java] #1303 #1304 Fix crash in directors when using OUTPUT and INOUT typemaps in typemaps.i and passing NULL pointers in C++ to director method overloaded and implemented in Java. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 1dd84039a..a6f139e8b 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6272,8 +6272,8 @@ For detailed usage of function annotation, see

      -Buffer protocols were revised in Python 3. SWIG also gains a series of -new typemaps to support buffer interfaces. These typemap macros are +SWIG has a series of +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. @@ -6398,7 +6398,7 @@ type. 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 +%pybuffer_binary can accept both mutable and immutable buffers. As a result, the wrapped function should not modify the buffer.

      diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuf.i index 8e1302582..5bdc98920 100644 --- a/Examples/test-suite/python_pybuf.i +++ b/Examples/test-suite/python_pybuf.i @@ -1,6 +1,6 @@ %module python_pybuf -%include -%include +%include +%include /*functions for the test case*/ %pybuffer_mutable_binary(char *buf1, int len); %pybuffer_mutable_string(char *buf2); diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i index f4e08716e..577eb69c8 100644 --- a/Lib/python/pybuffer.i +++ b/Lib/python/pybuffer.i @@ -15,16 +15,12 @@ %define %pybuffer_mutable_binary(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { int res; Py_ssize_t size = 0; void *buf = 0; -%#if PY_VERSION_HEX < 0x03000000 - res = PyObject_AsWriteBuffer($input, &buf, &size); -%#else Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); size = view.len; buf = view.buf; PyBuffer_Release(&view); -%#endif - if (res<0) { + if (res < 0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } @@ -33,7 +29,7 @@ } %enddef -/* %pybuffer_mutable_string(TYPEMAP, SIZE) +/* %pybuffer_mutable_string(TYPEMAP) * * Macro for functions accept mutable zero terminated string pointer. * This can be used for both input and output. For example: @@ -48,19 +44,14 @@ %define %pybuffer_mutable_string(TYPEMAP) %typemap(in) (TYPEMAP) { - int res; Py_ssize_t size = 0; void *buf = 0; -%#if PY_VERSION_HEX < 0x03000000 - res = PyObject_AsWriteBuffer($input, &buf, &size); -%#else + int res; void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); - size = view.len; buf = view.buf; PyBuffer_Release(&view); -%#endif - if (res<0) { + if (res < 0) { PyErr_Clear(); - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + %argument_fail(res, "(TYPEMAP)", $symname, $argnum); } $1 = ($1_ltype) buf; } @@ -83,16 +74,12 @@ %define %pybuffer_binary(TYPEMAP, SIZE) %typemap(in) (TYPEMAP, SIZE) { int res; Py_ssize_t size = 0; const void *buf = 0; -%#if PY_VERSION_HEX < 0x03000000 - res = PyObject_AsReadBuffer($input, &buf, &size); -%#else Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); size = view.len; buf = view.buf; PyBuffer_Release(&view); -%#endif - if (res<0) { + if (res < 0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } @@ -101,7 +88,7 @@ } %enddef -/* %pybuffer_string(TYPEMAP, SIZE) +/* %pybuffer_string(TYPEMAP) * * Macro for functions accept read only zero terminated string pointer. * This can be used for input. For example: @@ -118,18 +105,13 @@ %define %pybuffer_string(TYPEMAP) %typemap(in) (TYPEMAP) { - int res; Py_ssize_t size = 0; const void *buf = 0; -%#if PY_VERSION_HEX < 0x03000000 - res = PyObject_AsReadBuffer($input, &buf, &size); -%#else + int res; const void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); - size = view.len; buf = view.buf; PyBuffer_Release(&view); -%#endif - if (res<0) { - %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); + if (res < 0) { + %argument_fail(res, "(TYPEMAP)", $symname, $argnum); } $1 = ($1_ltype) buf; } From fdd2bcf0e6a07093fc541b145e0dfe9fb00254f0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 12 Aug 2018 15:16:03 +0100 Subject: [PATCH 1063/2031] Remove asserts from Python testcase Also rename testcase python_pybuf to python_pybuffer. --- Examples/test-suite/python/Makefile.in | 2 +- ...ybuf_runme.py => python_pybuffer_runme.py} | 31 ++++++++++--------- .../{python_pybuf.i => python_pybuffer.i} | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) rename Examples/test-suite/python/{python_pybuf_runme.py => python_pybuffer_runme.py} (50%) rename Examples/test-suite/{python_pybuf.i => python_pybuffer.i} (97%) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 2f66caa89..4e688989c 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -66,7 +66,7 @@ CPP_TEST_CASES += \ python_moduleimport \ python_overload_simple_cast \ python_pickle \ - python_pybuf \ + python_pybuffer \ python_pythoncode \ python_richcompare \ python_strict_unicode \ diff --git a/Examples/test-suite/python/python_pybuf_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py similarity index 50% rename from Examples/test-suite/python/python_pybuf_runme.py rename to Examples/test-suite/python/python_pybuffer_runme.py index 58efe78bd..85cfb75d3 100644 --- a/Examples/test-suite/python/python_pybuf_runme.py +++ b/Examples/test-suite/python/python_pybuffer_runme.py @@ -1,9 +1,12 @@ # run: -# python python_pybuf_runme.py benchmark +# python python_pybuffer_runme.py benchmark # for the benchmark, other wise the test case will be run -import python_pybuf +import python_pybuffer import sys +def check(flag): + if not flag: + raise RuntimeError("Test failed") if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": # run the benchmark @@ -13,31 +16,31 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": t = time.time() a = bytearray(b'hello world') for i in range(k): - python_pybuf.title1(a) + python_pybuffer.title1(a) print "Time used by bytearray:", time.time() - t t = time.time() b = 'hello world' for i in range(k): - python_pybuf.title2(b) + python_pybuffer.title2(b) print "Time used by string:", time.time() - t else: # run the test case buf1 = bytearray(10) buf2 = bytearray(50) - python_pybuf.func1(buf1) - assert buf1 == b'a' * 10 + python_pybuffer.func1(buf1) + check(buf1 == b'a' * 10) - python_pybuf.func2(buf2) - assert buf2.startswith(b"Hello world!\x00") + python_pybuffer.func2(buf2) + check(buf2.startswith(b"Hello world!\x00")) - count = python_pybuf.func3(buf2) - assert count == 10 # number of alpha and number in 'Hello world!' + count = python_pybuffer.func3(buf2) + check(count == 10) # number of alpha and number in 'Hello world!' - length = python_pybuf.func4(buf2) - assert length == 12 + length = python_pybuffer.func4(buf2) + check(length == 12) buf3 = bytearray(b"hello") - python_pybuf.title1(buf3) - assert buf3 == b'Hello' + python_pybuffer.title1(buf3) + check(buf3 == b'Hello') diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuffer.i similarity index 97% rename from Examples/test-suite/python_pybuf.i rename to Examples/test-suite/python_pybuffer.i index 5bdc98920..b46d8c36a 100644 --- a/Examples/test-suite/python_pybuf.i +++ b/Examples/test-suite/python_pybuffer.i @@ -1,4 +1,4 @@ -%module python_pybuf +%module python_pybuffer %include %include /*functions for the test case*/ From 345b4fec436551d48a3539c7421a669eaeaeefc0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Aug 2018 08:55:55 +0100 Subject: [PATCH 1064/2031] Testcase fix --- .../python/python_overload_simple_cast_runme.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/python_overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py index 79ef6cd2e..d4cb8a37a 100644 --- a/Examples/test-suite/python/python_overload_simple_cast_runme.py +++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py @@ -168,9 +168,9 @@ ullmaxd = 9007199254740992.0 ullmin = 0 ullmind = 0.0 if ull(ullmin) != ullmin: - raise runtimeerror, "ull(ullmin)" + raise RuntimeError, "ull(ullmin)" if ull(ullmax) != ullmax: - raise runtimeerror, "ull(ullmax)" + raise RuntimeError, "ull(ullmax)" if ull(ullmind) != ullmind: raise RuntimeError, "ull(ullmind)" if ull(ullmaxd) != ullmaxd: @@ -183,9 +183,9 @@ llmin = -9223372036854775808 llmaxd = 9007199254740992.0 llmind = -9007199254740992.0 if ll(llmin) != llmin: - raise runtimeerror, "ll(llmin)" + raise RuntimeError, "ll(llmin)" if ll(llmax) != llmax: - raise runtimeerror, "ll(llmax)" + raise RuntimeError, "ll(llmax)" if ll(llmind) != llmind: raise RuntimeError, "ll(llmind)" if ll(llmaxd) != llmaxd: From bb5c46079bf7eb232c7c3c8f2021a494c8fd1855 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Aug 2018 19:16:25 +0100 Subject: [PATCH 1065/2031] Better detection of builtin in Python testcase --- Examples/test-suite/doxygen_parsing.i | 5 +++++ Examples/test-suite/python/doxygen_parsing_runme.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index 21b51bc51..40f37a4c2 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -132,4 +132,9 @@ struct SomeAnotherStruct } }; +#ifdef SWIGPYTHON_BUILTIN +bool is_python_builtin() { return true; } +#else +bool is_python_builtin() { return false; } +#endif %} diff --git a/Examples/test-suite/python/doxygen_parsing_runme.py b/Examples/test-suite/python/doxygen_parsing_runme.py index f09f50761..80e8892fa 100644 --- a/Examples/test-suite/python/doxygen_parsing_runme.py +++ b/Examples/test-suite/python/doxygen_parsing_runme.py @@ -17,7 +17,7 @@ comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass), # There doesn't seem to be any way to specify the doc string for __init__ when # using "-builtin" (see http://stackoverflow.com/q/11913492/15275), so skip # this test in this case. -if str(os.environ.get('SWIG_FEATURES')).find('-builtin') == -1: +if not doxygen_parsing.is_python_builtin(): comment_verifier.check(inspect.getdoc(doxygen_parsing.SomeAnotherClass.__init__), r"""*Overload 1:* First overloaded constructor. From 5a22bcf0070a08e22a38055ee76cca5bfe919dce Mon Sep 17 00:00:00 2001 From: Vladimir Kalinin Date: Tue, 14 Aug 2018 21:25:35 +0300 Subject: [PATCH 1066/2031] Nested structures in "C" mode symbol table fix --- Source/CParse/parser.y | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b9268cf03..91ab94c52 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3862,6 +3862,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { while (Getattr(outer, "nested:outer")) outer = Getattr(outer, "nested:outer"); appendSibling(outer, $$); + Swig_symbol_setscope(cscope); /* declaration goes in the parent scope */ add_symbols($9); set_scope_to_global(); Delete(Namespaceprefix); From c9cac931c7f346f13b9a0362b54e8e6b64df7303 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 17 Aug 2018 23:34:29 +0100 Subject: [PATCH 1067/2031] Re-implement Python -fastproxy option. The previous implementation failed with Python 3 and abstract base clases. The new implementation replaces the Python 2 implementation using new.instancemethod with C API PyMethod_New to match the equivalent Python 3 implementation which uses PyInstanceMethod_New. Closes #1310 --- CHANGES.current | 10 +++ Doc/Manual/Contents.html | 4 + Doc/Manual/Python.html | 97 +++++++++++++++++++++ Examples/test-suite/python/autodoc_runme.py | 11 ++- Lib/python/pyapi.swg | 9 +- Source/Modules/python.cxx | 45 +++++----- 6 files changed, 144 insertions(+), 32 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1ced20389..f3f4677f1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,16 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-18: wsfulton + [Python] #1310 Re-implement Python -fastproxy option. + + The previous implementation failed with Python 3 and abstract base clases. + The new implementation replaces the Python 2 implementation using + new.instancemethod with the C API PyMethod_New to match the equivalent Python 3 + implementation which uses PyInstanceMethod_New. + + The new approach runs slightly faster. See #1310. + 2018-08-12: gmazzamuto [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index b76e1d33a..a3179bfd7 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1642,6 +1642,10 @@
    • Adding additional Python code
    • Class extension with %extend
    • Exception handling with %exception +
    • Optimization options +
  • Tips and techniques
  • Tips and techniques
      @@ -3797,6 +3801,99 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

      +

      38.6.5 Optimization options

      + + +

      38.6.5.1 -fastproxy

      + + +

      +The -fastproxy command line option enables faster method calling as the call is made directly into the C/C++ layer rather than going through a method wrapper. +

      + +

      +Consider wrapping a C++ class: +

      + +
      +
      +struct Go {
      +  void callme0() {}
      +  void callme4(int a, int b, int c, int d) {}
      +  void callme8(double a, double b, double c, double d, double e, double f, double g, double i) {}
      +};
      +
      +
      + +

      +The default generated proxy class is: +

      + +
      +
      +class Go(object):
      +    def callme0(self):
      +        return _example.Go_callme0(self)
      +
      +    def callme4(self, a, b, c, d):
      +        return _example.Go_callme4(self, a, b, c, d)
      +
      +    def callme8(self, a, b, c, d, e, f, g, i):
      +        return _example.Go_callme8(self, a, b, c, d, e, f, g, i)
      +    ...
      +
      +
      + +

      +The generated code when using -fastproxy is: +

      + +
      +
      +%module example
      +class Go(_object):
      +    callme0 = _swig_new_instance_method(_example.Go_callme0)
      +    callme4 = _swig_new_instance_method(_example.Go_callme4)
      +    callme8 = _swig_new_instance_method(_example.Go_callme8)
      +    ...
      +
      +
      + +

      +where _swig_new_instance_method adds the method to the proxy class via C API calls. +The overhead calling into C/C++ from Python is reduced slightly using -fastproxy. +Below are some timings in microseconds calling the 3 functions in the example above: +

      + + + + + + + + + + + + + + + + + + + + + + +
      Method nameWithout -proxyWith -proxy
      callme00.570.48
      callme40.640.54
      callme80.730.57
      + +

      +Although the -fastproxy option results in faster code, the generated proxy code is not as user-friendly +as docstring/doxygen comments and functions with default values are not visible in the generated python proxy class. +

      + +

      38.7 Tips and techniques

      diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 11e499d25..d89c7a880 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -13,15 +13,20 @@ def check(got, expected, expected_builtin=None, skip=False): def is_new_style_class(cls): return hasattr(cls, "__class__") -def is_fastproxy(module): - return "new_instancemethod" in module +def is_fastproxy(): + fastproxy = True + try: + from autodoc import _swig_new_instance_method + except ImportError: + fastproxy = False + return fastproxy if not is_new_style_class(A): # Missing static methods make this hard to test... skip if -classic is # used! sys.exit(0) -if is_fastproxy(dir()): +if is_fastproxy(): # Detect when -fastproxy is specified and skip test as it changes the function names making it # hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved sys.exit(0) diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index 2da05f9e9..700f55d43 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -29,17 +29,14 @@ typedef struct swig_const_info { * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ -#if PY_VERSION_HEX >= 0x03000000 SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { +#if PY_VERSION_HEX >= 0x03000000 return PyInstanceMethod_New(func); -} #else -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) -{ - return NULL; -} + return PyMethod_New(func, NULL, NULL); #endif +} #ifdef __cplusplus } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 40bc06bca..0842c90e2 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -825,18 +825,8 @@ public: } Printv(default_import_code, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); - - if (!builtin && fastproxy) { - Printv(default_import_code, "if _swig_python_version_info >= (3, 0, 0):\n", NULL); - Printf(default_import_code, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); - Printv(default_import_code, "elif _swig_python_version_info >= (2, 7, 0):\n", NULL); - Printv(default_import_code, tab4, "from new import instancemethod as new_instancemethod\n", NULL); - Printv(default_import_code, "else:\n", NULL); - Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\n", NULL); - } else { - Printv(default_import_code, "if _swig_python_version_info < (2, 7, 0):\n", NULL); - Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\n", NULL); - } + Printv(default_import_code, "if _swig_python_version_info < (2, 7, 0):\n", NULL); + Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\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 @@ -897,6 +887,11 @@ public: defined in this module (try both Python 3 and Python 2 names) */ Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL); + if (!builtin && fastproxy) { + Printf(f_shadow, "\n"); + Printf(f_shadow, "_swig_new_instance_method = %s.SWIG_PyInstanceMethod_New\n", module); + } + /* if (!modern) */ /* always needed, a class can be forced to be no-modern, such as an exception */ { @@ -4682,32 +4677,36 @@ public: } /* Now emit methods */ - if (!builtin) + if (!builtin) { Printv(f_shadow_file, f_shadow, NIL); + if (fastproxy) { + Printf(f_shadow_file, "\n"); + List *shadow_list = Getattr(n, "shadow_methods"); + for (int i = 0; i < Len(shadow_list); ++i) { + String *symname = Getitem(shadow_list, i); + Printf(f_shadow_file, tab4); + Printf(f_shadow_file, "%s = _swig_new_instance_method(%s.%s)\n", symname, module, Swig_name_member(NSPACE_TODO, class_name, symname)); + } + } + } + /* Now the Ptr class */ if (classptr && !builtin) { Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); if (!modern) { Printv(f_shadow_file, tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); + tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); } else { Printv(f_shadow_file, tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n\n", NIL); + tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); } } if (!builtin) { - if (fastproxy) { - List *shadow_list = Getattr(n, "shadow_methods"); - for (int i = 0; i < Len(shadow_list); ++i) { - String *symname = Getitem(shadow_list, i); - Printf(f_shadow_file, "%s.%s = new_instancemethod(%s.%s, None, %s)\n", class_name, symname, module, Swig_name_member(NSPACE_TODO, class_name, symname), - class_name); - } - } + Printf(f_shadow_file, "\n"); Printf(f_shadow_file, "# Register %s in %s:\n", class_name, module); Printf(f_shadow_file, "%s.%s_swigregister(%s)\n", module, class_name, class_name); } From 3de67de8f0161e8767d51fd4abcfe9e02b37df54 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 18 Aug 2018 00:45:43 +0100 Subject: [PATCH 1068/2031] Travis: python3.5 -fastproxy no longer failing --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82c7dffa5..32d7fe242 100644 --- a/.travis.yml +++ b/.travis.yml @@ -369,12 +369,6 @@ matrix: env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 sudo: required dist: trusty - # Not quite working yet - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 - sudo: required - dist: trusty before_install: - date -u From 4930fab5a068ecc8a48ce4b6dc73828dea207377 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 19 Aug 2018 16:18:38 +0100 Subject: [PATCH 1069/2031] Fix some Python tests not being run in out of source tree builds When there is just a _runme3.py file and no _runme.py file, out of source builds were not running the script. Currently only applies to python_abstractbase_runme3.py. --- Examples/test-suite/python/Makefile.in | 49 +++++++++++++++++++++----- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4e688989c..efa2923b0 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -156,19 +156,50 @@ run_testcase = \ $(run_python);\ fi -# No copying/conversion needed for in-source-tree Python 2 scripts -ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX)) -convert_testcase = -else - -convert_testcase = \ +# Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3 +ifeq ($(SCRIPTDIR),$(srcdir)) + # in source tree build + ifeq (,$(PY3)) + convert_testcase = + else + convert_testcase = \ if [ -f $(srcdir)/$(py2_runme) ]; then \ $(MAKE) $(SCRIPTDIR)/$(py_runme); \ fi $(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) - test x$< = x$@ || cp $< $@ || exit 1 - test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1 + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + + endif +else + # out of source tree build + ifeq (,$(PY3)) + convert_testcase = \ + if [ -f $(srcdir)/$(py2_runme) ]; then \ + $(MAKE) $(SCRIPTDIR)/$(py_runme); \ + fi + +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) + cp $< $@ + + else + convert_testcase = \ + if [ -f $(srcdir)/$(py2_runme) ]; then \ + $(MAKE) $(SCRIPTDIR)/$(py_runme); \ + elif [ -f $(srcdir)/$(py3_runme) ]; then \ + $(MAKE) $(SCRIPTDIR)/$(py3_runme); \ + fi + +# For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX) + cp $< $@ + +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + + endif endif @@ -177,7 +208,7 @@ endif %.clean: @rm -f $*.py @if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi - @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi + @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py_runme); fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean From eb8135519620d9deba3a11c8589d3b8e0344651c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 19 Aug 2018 17:40:56 +0100 Subject: [PATCH 1070/2031] Fix makefile recursion when running python test-suite. Use terminal / double-colon rules in makefile pattern matching rule to prevent recursion reported on some versions of make. Closes #688 --- CHANGES.current | 3 +++ Examples/test-suite/python/Makefile.in | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f3f4677f1..8d8762229 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-18: wsfulton + [Python] #688 Fix makefile recursion when running python test-suite. + 2018-08-18: wsfulton [Python] #1310 Re-implement Python -fastproxy option. diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index efa2923b0..6ad3b634f 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -157,6 +157,8 @@ run_testcase = \ fi # Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3 +# Note terminal (double colon) rules creating runme files to fix possible infinite recursion, +# see https://github.com/swig/swig/pull/688 ifeq ($(SCRIPTDIR),$(srcdir)) # in source tree build ifeq (,$(PY3)) @@ -167,7 +169,8 @@ ifeq ($(SCRIPTDIR),$(srcdir)) $(MAKE) $(SCRIPTDIR)/$(py_runme); \ fi -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) +# For converting python 2 tests into Python 3 tests +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 @@ -180,7 +183,7 @@ else $(MAKE) $(SCRIPTDIR)/$(py_runme); \ fi -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) cp $< $@ else @@ -192,10 +195,11 @@ $(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCR fi # For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX) +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX) cp $< $@ -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) +# For converting python 2 tests into Python 3 tests +$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 From c2805e5a44493df996fd582fd4a5fb96399e4b31 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Aug 2018 07:37:29 +0100 Subject: [PATCH 1071/2031] Change location of Python -fastproxy methods in proxy class Output methods in the same place that they would be generated in the proxy class when not using -fastproxy. When using autodoc, the two definitions of the method are then right after each other. --- Source/Modules/python.cxx | 45 ++++++++++++--------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 0842c90e2..b3dbe19ab 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4676,36 +4676,24 @@ public: builtin_tp_init = 0; } - /* Now emit methods */ if (!builtin) { + /* Now emit methods */ Printv(f_shadow_file, f_shadow, NIL); - if (fastproxy) { - Printf(f_shadow_file, "\n"); - List *shadow_list = Getattr(n, "shadow_methods"); - for (int i = 0; i < Len(shadow_list); ++i) { - String *symname = Getitem(shadow_list, i); - Printf(f_shadow_file, tab4); - Printf(f_shadow_file, "%s = _swig_new_instance_method(%s.%s)\n", symname, module, Swig_name_member(NSPACE_TODO, class_name, symname)); + /* Now the Ptr class */ + if (classptr) { + Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); + if (!modern) { + Printv(f_shadow_file, + tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", + tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); + } else { + Printv(f_shadow_file, + tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", + tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); } } - } - /* Now the Ptr class */ - if (classptr && !builtin) { - Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); - if (!modern) { - Printv(f_shadow_file, - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); - } else { - Printv(f_shadow_file, - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); - } - } - - if (!builtin) { Printf(f_shadow_file, "\n"); Printf(f_shadow_file, "# Register %s in %s:\n", class_name, module); Printf(f_shadow_file, "%s.%s_swigregister(%s)\n", module, class_name, class_name); @@ -4840,13 +4828,8 @@ public: } } if (fproxy) { - List *shadow_list = Getattr(getCurrentClass(), "shadow_methods"); - if (!shadow_list) { - shadow_list = NewList(); - Setattr(getCurrentClass(), "shadow_methods", shadow_list); - Delete(shadow_list); - } - Append(shadow_list, symname); + Printf(f_shadow, tab4); + Printf(f_shadow, "%s = _swig_new_instance_method(%s.%s)\n", symname, module, Swig_name_member(NSPACE_TODO, class_name, symname)); } Delete(fullname); } From c39a3799423a095df98d7bd44d1ce4ecec6d8eb1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Aug 2018 19:21:14 +0100 Subject: [PATCH 1072/2031] Add testcase for nested C struct name conflict Issue #1305 --- CHANGES.current | 4 ++ Examples/test-suite/nested.i | 46 ++++++++++++++++++++++ Examples/test-suite/python/nested_runme.py | 20 ++++++++++ 3 files changed, 70 insertions(+) create mode 100644 Examples/test-suite/python/nested_runme.py diff --git a/CHANGES.current b/CHANGES.current index 1ced20389..a26205560 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-20: wkalinin + #1305 Fix nested structure symbol tables in C mode to fix member name conflicts + in different structs with the same nested struct member name. + 2018-08-12: gmazzamuto [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i index 216ee4224..2e6d2786f 100644 --- a/Examples/test-suite/nested.i +++ b/Examples/test-suite/nested.i @@ -114,4 +114,50 @@ typedef struct OutSt { #endif +%inline %{ + typedef struct { + union x_union { + int x; + } duplicate_p; + } x_t; + + typedef struct { + union y_union { + int y; + } duplicate_p; + } y_t; + + typedef struct A { + union a_union { + int a; + } duplicate_p; + } a_t; + + typedef struct B { + union b_union { + int b; + } duplicate_p; + } b_t; + + typedef struct { + union { + int c; + } duplicate_p; + } c_t; + + typedef struct { + union { + int d; + } duplicate_p; + } d_t; + + void set_union_values(int startval, x_t *x, y_t *y, a_t *a, b_t *b, c_t *c, d_t *d) { + x->duplicate_p.x = startval++; + y->duplicate_p.y = startval++; + a->duplicate_p.a = startval++; + b->duplicate_p.b = startval++; + c->duplicate_p.c = startval++; + d->duplicate_p.d = startval++; + } +%} diff --git a/Examples/test-suite/python/nested_runme.py b/Examples/test-suite/python/nested_runme.py new file mode 100644 index 000000000..0e839e64b --- /dev/null +++ b/Examples/test-suite/python/nested_runme.py @@ -0,0 +1,20 @@ +from nested import * + +def check(a, b): + if a != b: + raise RuntimeError("Problem: {} != {}".format(a, b)) +xx = x_t() +yy = y_t() +aa = a_t() +bb = b_t() +cc = c_t() +dd = d_t() + +set_union_values(100, xx, yy, aa, bb, cc, dd) + +check(xx.duplicate_p.x, 100) +check(yy.duplicate_p.y, 101) +check(aa.duplicate_p.a, 102) +check(bb.duplicate_p.b, 103) +check(cc.duplicate_p.c, 104) +check(dd.duplicate_p.d, 105) From f7818d5ed3ac9657e7e3fd71ecdb8b7261096142 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 20 Aug 2018 19:28:29 +0100 Subject: [PATCH 1073/2031] Simplify nested testcase Remove duplicate code (that just had shorter names for Scilab). --- Examples/test-suite/nested.i | 37 ------------------------------------ 1 file changed, 37 deletions(-) diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i index 2e6d2786f..6c4ffe34a 100644 --- a/Examples/test-suite/nested.i +++ b/Examples/test-suite/nested.i @@ -44,42 +44,6 @@ struct OuterStructNamed { %} -#if !defined(SWIGSCILAB) - -%inline %{ - -struct OuterStructUnnamed { - struct { - double xx; - } inner_struct_unnamed; - union { - double yy; - int zz; - } inner_union_unnamed; -}; - -typedef struct OuterStruct { - union { - - struct outer_nested_struct { - union inner_nested_union { -#define BAD_STYLE 1 - int red; - struct TestStruct green; - } InnerNestedUnion; - - struct inner_nested_struct { - int blue; - } InnerNestedStruct; - } OuterNestedStruct; - - } EmbeddedUnion; -} OuterStruct; - -%} - -#else - %inline %{ struct OutStUnnamed { @@ -112,7 +76,6 @@ typedef struct OutSt { %} -#endif %inline %{ typedef struct { From c33f352069f68ce2ee2e3a4f41b74e8ce6058bc1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 21 Aug 2018 22:41:02 +0100 Subject: [PATCH 1074/2031] python -> Python in html docs --- Doc/Manual/Introduction.html | 2 +- Doc/Manual/Lua.html | 2 +- Doc/Manual/Python.html | 106 +++++++++++++++++------------------ Doc/Manual/SWIGPlus.html | 14 ++--- Doc/Manual/Windows.html | 2 +- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index d4eee0d4d..ad6e34ed7 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -392,7 +392,7 @@ and many of the target language libraries for linking against. CMake knows how to build shared libraries and loadable modules on many different operating systems. This allows easy cross platform SWIG development. It can also generate the custom commands necessary for driving SWIG from IDEs and makefiles. All of this can be done from a single cross platform input file. -The following example is a CMake input file for creating a python wrapper for the SWIG interface file, example.i: +The following example is a CMake input file for creating a Python wrapper for the SWIG interface file, example.i:

      diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
      index 944223f3c..25d5e2cd5 100644
      --- a/Doc/Manual/Lua.html
      +++ b/Doc/Manual/Lua.html
      @@ -984,7 +984,7 @@ There are ways to make this operator appear as part of the class using the %
       Also, be aware that certain operators don't map cleanly to Lua, and some Lua operators don't map cleanly to C++ operators. For instance, overloaded assignment operators don't map to Lua semantics and will be ignored, and C++ doesn't support Lua's concatenation operator (..).
       

      -In order to keep maximum compatibility within the different languages in SWIG, the Lua bindings uses the same set of operator names as python. Although internally it renames the functions to something else (on order to work with Lua). +In order to keep maximum compatibility within the different languages in SWIG, the Lua bindings uses the same set of operator names as Python. Although internally it renames the functions to something else (on order to work with Lua).

      The current list of operators which can be overloaded (and the alternative function names) are:

      • __add__ operator+ diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 863714b84..db9bf978d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -218,7 +218,7 @@ int fact(int n);

        The #define SWIG_FILE_WITH_INIT line inserts a macro that specifies that the -resulting C file should be built as a python extension, inserting the module +resulting C file should be built as a Python extension, inserting the module init code. This .i file wraps the following simple C file:

        @@ -296,8 +296,8 @@ how you might go about compiling and using the generated files.

        -The preferred approach to building an extension module for python is to compile it with -distutils, which comes with all recent versions of python +The preferred approach to building an extension module for Python is to compile it with +distutils, which comes with all recent versions of Python (Distutils Docs).

        @@ -307,7 +307,7 @@ flags, headers, etc. for the version of Python it is run with. Distutils will co extension into a shared object file or DLL (.so on Linux, .pyd on Windows, etc). In addition, distutils can handle installing your package into site-packages, if that is desired. A configuration file (conventionally called: setup.py) -describes the extension (and related python modules). The distutils will +describes the extension (and related Python modules). The distutils will then generate all the right compiler directives to build it for you.

        @@ -344,9 +344,9 @@ setup (name = 'example', In this example, the line: example_module = Extension(....) creates an Extension module object, defining the name as _example, and using the source code files: example_wrap.c, generated by swig, and example.c, your original c -source. The swig (and other python extension modules) tradition is for the compiled -extension to have the name of the python portion, prefixed by an underscore. If the name -of your python module is "example.py", then the name of the corresponding object file +source. The swig (and other Python extension modules) tradition is for the compiled +extension to have the name of the Python portion, prefixed by an underscore. If the name +of your Python module is "example.py", then the name of the corresponding object file will be"_example.so"

        @@ -363,11 +363,11 @@ $ python setup.py build_ext --inplace

        And a .so, or .pyd or... will be created for you. It will build a version that matches the -python that you run the command with. Taking apart the command line: +Python that you run the command with. Taking apart the command line:

          -
        • python -- the version of python you want to build for +
        • python -- the version of Python you want to build for
        • setup.py -- the name of your setup script (it can be called anything, but setup.py is the tradition)
        • build_ext -- telling distutils to build extensions @@ -376,7 +376,7 @@ python that you run the command with. Taking apart the command line:

        -The distutils have many other features, consult the python distutils docs for details. +The distutils have many other features, consult the Python distutils docs for details.

        @@ -793,7 +793,7 @@ careful about the libraries you link with or the library path you use. In general, a Linux distribution will have two set of libraries, one for native x86_64 programs (under /usr/lib64), and another for 32 bits compatibility (under /usr/lib). Also, the compiler options -m32 -and -m64 allow you to choose the desired binary format for your python +and -m64 allow you to choose the desired binary format for your Python extension.

        @@ -1185,7 +1185,7 @@ When wrapped, you will be able to use the functions in a natural way from Python

        If this makes you uneasy, rest assured that there is no deep magic involved. Underneath the covers, pointers to C/C++ objects are -simply represented as opaque values using an especial python container object: +simply represented as opaque values using an especial Python container object:

        @@ -1213,7 +1213,7 @@ _c0671108_p_FILE
         
         

        Also, if you need to pass the raw pointer value to some external -python library, you can do it by casting the pointer object to an +Python library, you can do it by casting the pointer object to an integer:

        @@ -2254,8 +2254,8 @@ and built-in types, let's take a look at what a wrapped object looks like under both circumstances.

        -

        When proxy classes are used, each wrapped object in python is an instance -of a pure python class. As a reminder, here is what the __init__ method looks +

        When proxy classes are used, each wrapped object in Python is an instance +of a pure Python class. As a reminder, here is what the __init__ method looks like in a proxy class:

        @@ -2270,21 +2270,21 @@ class Foo(object):

        When a Foo instance is created, the call to _example.new_Foo() creates a new C++ Foo instance; wraps that C++ instance inside an instance of -a python built-in type called SwigPyObject; and stores the SwigPyObject -instance in the 'this' field of the python Foo object. Did you get all that? So, the -python Foo object is composed of three parts:

        +a Python built-in type called SwigPyObject; and stores the SwigPyObject +instance in the 'this' field of the Python Foo object. Did you get all that? So, the +Python Foo object is composed of three parts:

          -
        • The python Foo instance, which contains...
        • +
        • The Python Foo instance, which contains...
        • ... an instance of struct SwigPyObject, which contains...
        • ... a C++ Foo instance
        -

        When -builtin is used, the pure python layer is stripped off. Each -wrapped class is turned into a new python built-in type which inherits from +

        When -builtin is used, the pure Python layer is stripped off. Each +wrapped class is turned into a new Python built-in type which inherits from SwigPyObject, and SwigPyObject instances are returned directly -from the wrapped methods. For more information about python built-in extensions, -please refer to the python documentation:

        +from the wrapped methods. For more information about Python built-in extensions, +please refer to the Python documentation:

        http://docs.python.org/extending/newtypes.html

        @@ -2300,7 +2300,7 @@ please refer to the python documentation:

        They are instead accessed in the idiomatic way (Dances.FishSlap).
      -
    • Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:

      +
    • Wrapped types may not be raised as Python exceptions. Here's why: the Python internals expect that all sub-classes of Exception will have this struct layout:

      @@ -2345,7 +2345,7 @@ private:
       
      -

      ... you can define this python class, which may be raised as an exception:

      +

      ... you can define this Python class, which may be raised as an exception:

      @@ -2360,7 +2360,7 @@ class MyPyException(Exception):
       
    • Reverse binary operators (e.g., __radd__) are not supported.

      To illustrate this point, if you have a wrapped class called MyString, -and you want to use instances of MyString interchangeably with native python +and you want to use instances of MyString interchangeably with native Python strings, you can define an 'operator+ (const char*)' method :

      @@ -2375,7 +2375,7 @@ public:

      -SWIG will automatically create an operator overload in python that will allow this: +SWIG will automatically create an operator overload in Python that will allow this:

      @@ -2402,7 +2402,7 @@ episode = "Dead " + mystr

      -The above code fails, because the first operand -- a native python string -- +The above code fails, because the first operand -- a native Python string -- doesn't know how to add an instance of MyString to itself.

    • @@ -2438,7 +2438,7 @@ class Derived : public Base {

      The import "A.i" statement is required, because module B depends on module A.

      -

      As long as you obey these requirements, your python code may import the modules in any order :

      +

      As long as you obey these requirements, your Python code may import the modules in any order :

       import B
      @@ -2455,13 +2455,13 @@ assert(issubclass(B.Derived, A.Base))
       

      The entire justification for the -builtin option is improved performance. To that end, the best way to squeeze maximum performance out of your wrappers is to use operator overloads. -Named method dispatch is slow in python, even when compared to other scripting languages. -However, python built-in types have a large number of "slots", +Named method dispatch is slow in Python, even when compared to other scripting languages. +However, Python built-in types have a large number of "slots", analogous to C++ operator overloads, which allow you to short-circuit named method dispatch for certain common operations.

      -

      By default, SWIG will translate most C++ arithmetic operator overloads into python +

      By default, SWIG will translate most C++ arithmetic operator overloads into Python slot entries. For example, suppose you have this class:

      @@ -2478,7 +2478,7 @@ public:
      -

      SWIG will automatically register operator+ as a python slot operator for addition. You may write python code like this:

      +

      SWIG will automatically register operator+ as a Python slot operator for addition. You may write Python code like this:

      @@ -2491,24 +2491,24 @@ percival = nigel.add(emily)
       
      -

      The last two lines of the python code are equivalent, +

      The last two lines of the Python code are equivalent, but the line that uses the '+' operator is much faster.

      In-place operators (e.g., operator+=) and comparison operators -(operator==, operator<, etc.) are also converted to python +(operator==, operator<, etc.) are also converted to Python slot operators. For a complete list of C++ operators that are -automatically converted to python slot operators, refer to the file +automatically converted to Python slot operators, refer to the file python/pyopers.swig in the SWIG library.

      -Read about all of the available python slots here: +Read about all of the available Python slots here: http://docs.python.org/c-api/typeobj.html

      -There are two ways to define a python slot function: dispatch to a +There are two ways to define a Python slot function: dispatch to a statically defined function; or dispatch to a method defined on the operand.

      @@ -2595,7 +2595,7 @@ class MyClass {

      -NOTE: Some python slots use a method signature which does not +NOTE: Some Python slots use a method signature which does not match the signature of SWIG-wrapped methods. For those slots, SWIG will automatically generate a "closure" function to re-marshal the arguments before dispatching to the wrapped method. Setting @@ -2912,7 +2912,7 @@ public:

      -then at the python side you can define +then at the Python side you can define

      @@ -2925,7 +2925,7 @@ class MyFoo(mymodule.Foo): # super().__init__(foo) # Alternative construction for Python3 def one(self): - print "one from python" + print "one from Python"
      @@ -3440,7 +3440,7 @@ an error for invalid preprocessor directives, so you may have to update existing interface files to delimit blocks of Python code correctly.

      As an alternative to providing a block containing Python code, you can -include python code from a file. The code is inserted exactly as in the +include Python code from a file. The code is inserted exactly as in the file, so this avoids any issues with the SWIG preprocessor. It's a good approach if you have a non-trivial chunk of Python code to insert. To use this feature you specify a filename in double quotes, for example:

      @@ -3461,7 +3461,7 @@ entirely replace a proxy function you can use
       %module example
       
      -// Rewrite bar() python code
      +// Rewrite bar() Python code
       
       %feature("shadow") Foo::bar(int) %{
       def bar(*args):
      @@ -3496,7 +3496,7 @@ proxy, just before the return statement.
       
       %module example
       
      -// Add python code to bar()
      +// Add Python code to bar()
       
       %feature("pythonprepend") Foo::bar(int) %{
           #do something before C++ call
      @@ -3525,7 +3525,7 @@ SWIG version 1.3.28 you can use the directive forms
       
       %module example
       
      -// Add python code to bar()
      +// Add Python code to bar()
       
       %pythonprepend Foo::bar(int) %{
           #do something before C++ call
      @@ -3554,7 +3554,7 @@ as it will then get attached to all the overloaded C++ methods. For example:
       
       %module example
       
      -// Add python code to bar()
      +// Add Python code to bar()
       
       %pythonprepend Foo::bar %{
           #do something before C++ call
      @@ -3890,7 +3890,7 @@ Below are some timings in microseconds calling the 3 functions in the example ab
       
       

      Although the -fastproxy option results in faster code, the generated proxy code is not as user-friendly -as docstring/doxygen comments and functions with default values are not visible in the generated python proxy class. +as docstring/doxygen comments and functions with default values are not visible in the generated Python proxy class.

      @@ -4581,7 +4581,7 @@ looking at the files in the SWIG library. Just take into account that in the latest versions of swig (1.3.22+), the library files are not very pristine clear for the casual reader, as they used to be. The extensive use of macros and other ugly techniques in the latest -version produce a very powerful and consistent python typemap library, +version produce a very powerful and consistent Python typemap library, but at the cost of simplicity and pedagogic value.

      @@ -6064,7 +6064,7 @@ packages you can place these files in the following configurations:
      -

      Finally suppose that your pure python code is stored in a .zip file or +

      Finally suppose that your pure Python code is stored in a .zip file or some other way (database, web service connection, etc). Python can load the robin.py module using a custom importer. But the _robin.so module will need to be located on a file system. Implicit namespace packages make this @@ -6192,7 +6192,7 @@ from package import foo

      38.11.6.2 Split modules

      -

      The pure python module is in a package and the C/C++ module is global:

      +

      The pure Python module is in a package and the C/C++ module is global:

       /dir/package/foo.py
      @@ -6844,7 +6844,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai
           
      • - The -threads swig python option at the command line (or in setup.py): + The -threads SWIG Python option at the command line (or in setup.py):

        $ swig -python -threads example.i
      • @@ -6863,13 +6863,13 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai
      • You can partially disable thread support for a given method:

          -
        • To disable the C++/python thread protection:

          +
        • To disable the C++/Python thread protection:

          %feature("nothreadblock") method;
          or
          %nothreadblock method;
        • -

          To disable the python/C++ thread protection

          +

          To disable the Python/C++ thread protection

          %feature("nothreadallow") method;
          or
          %nothreadallow method;
          diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index db49a366e..1b57860c0 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -5035,19 +5035,19 @@ For example:

          where the code passed to the "ref" and "unref" features will be -executed as needed whenever a new object is passed to python, or when -python tries to release the proxy object instance, respectively. +executed as needed whenever a new object is passed to Python, or when +Python tries to release the proxy object instance, respectively.

          -On the python side, the use of a reference counted object is no +On the Python side, the use of a reference counted object is no different to any other regular instance:

           def create_A():
          -    a = A()         # SWIG ref 'a' - new object is passed to python (count: 1)
          +    a = A()         # SWIG ref 'a' - new object is passed to Python (count: 1)
               b1 = B(a)       # C++ ref 'a (count: 2)
               if 1 + 1 == 2:
                   b2 = B(a)   # C++ ref 'a' (count: 3)
          @@ -5075,8 +5075,8 @@ features:
           
           

          In other words, SWIG will not do anything special when a new object -is passed to python, and it will always 'delete' the underlying object when -python releases the proxy instance. +is passed to Python, and it will always 'delete' the underlying object when +Python releases the proxy instance.

          @@ -5283,7 +5283,7 @@ normal classes.

          If the target language doesn't support nested classes directly, or the support is not implemented in the -language module (like for python currently), then the visible nested classes are moved to the same name +language module (like for Python currently), then the visible nested classes are moved to the same name space as the containing class (nesting hierarchy is "flattened"). The same behaviour may be turned on for C# and Java by the %feature ("flatnested"); If there is a class with the same name in the outer namespace the inner class (or the global one) may be renamed or ignored: diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index b95105bdd..01caf6c7f 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -149,7 +149,7 @@ PERL5_LIB: D:\nsPerl5.004_04\lib\CORE\perl.lib

          PYTHON_INCLUDE : Set this to the directory that contains Python.h
          -PYTHON_LIB : Set this to the python library including path for linking

          +PYTHON_LIB : Set this to the Python library including path for linking

          Example using Python 2.1.1:
          PYTHON_INCLUDE: D:\python21\include
          From 63b689d7cdbe49f930c65b6baaef3ee4737368ac Mon Sep 17 00:00:00 2001 From: Chris Hogan Date: Wed, 22 Aug 2018 08:39:50 -0500 Subject: [PATCH 1075/2031] Run garbage collection in test for guile >= 2.0.12 --- Examples/test-suite/schemerunme/reference_global_vars.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Examples/test-suite/schemerunme/reference_global_vars.scm b/Examples/test-suite/schemerunme/reference_global_vars.scm index 4b3370cfc..29d0904b8 100644 --- a/Examples/test-suite/schemerunme/reference_global_vars.scm +++ b/Examples/test-suite/schemerunme/reference_global_vars.scm @@ -56,4 +56,12 @@ (if (!= (TestClass-num-get (value-TestClass (var-TestClass))) 20) (begin (display "Runtime test 13 failed.\n") (exit 1))) +; Test garbage collection on guile >= 2.0.12 +(if (or (and (string=? (major-version) "2") + (string=? (minor-version) "0") + (string>=? (micro-version) "12")) + (and (string>=? (major-version) "2") + (string>=? (minor-version) "1"))) + (gc)) + (exit 0) From 2f31c3e94ecbf6f28b3e9d6ee64b31448e07941d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Aug 2018 19:05:40 +0100 Subject: [PATCH 1076/2031] Python C++11 hash tables compilation fixes - std::unordered_map compilation fix when just using std_unordered_map.i standalone - std::unordered_multimap compilation fix when just using std_unordered_multimap.i standalone - Add in the standalone unordered STL test cases Closes #1319 --- CHANGES.current | 8 +++ Examples/test-suite/python/Makefile.in | 4 ++ Lib/python/std_unordered_map.i | 98 ++++++++++++++------------ Lib/python/std_unordered_multimap.i | 2 +- 4 files changed, 65 insertions(+), 47 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3bf9ac866..99f219372 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-08-31: wsfulton + [Python] #1319 C++11 hash tables support: + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + is now compiling and working (sorting using -builtin not fully functional yet though). + 2018-08-20: wkalinin #1305 Fix nested structure symbol tables in C mode to fix member name conflicts in different structs with the same nested struct member name. diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 6ad3b634f..1402239b9 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -85,6 +85,10 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ + cpp11_std_unordered_map \ + cpp11_std_unordered_multimap \ + cpp11_std_unordered_multiset \ + cpp11_std_unordered_set \ C_TEST_CASES += \ file_test \ diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index bec7d165d..959f303a3 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -1,8 +1,59 @@ /* Unordered Maps */ +%include -%fragment("StdUnorderedMapTraits","header",fragment="StdSequenceTraits") +%fragment("StdUnorderedMapForwardIteratorTraits","header") +{ + namespace swig { + template + struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T + { + SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyForwardIteratorClosed_T(curr, first, last, seq) + { + } + }; + + + template > + struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T + { + SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapForwardIterator_T(curr, first, last, seq) + { + } + }; + + template + inline SwigPyIterator* + make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapKeyForwardIterator_T(current, begin, end, seq); + } + + template > + struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T + { + SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : SwigPyMapForwardIterator_T(curr, first, last, seq) + { + } + }; + + + template + inline SwigPyIterator* + make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) + { + return new SwigPyMapValueForwardIterator_T(current, begin, end, seq); + } + } +} + +%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { template @@ -73,51 +124,6 @@ } } }; - - template - struct SwigPyMapForwardIterator_T : SwigPyForwardIteratorClosed_T - { - SwigPyMapForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyForwardIteratorClosed_T(curr, first, last, seq) - { - } - }; - - - template > - struct SwigPyMapKeyForwardIterator_T : SwigPyMapForwardIterator_T - { - SwigPyMapKeyForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T(curr, first, last, seq) - { - } - }; - - template - inline SwigPyIterator* - make_output_key_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapKeyForwardIterator_T(current, begin, end, seq); - } - - template > - struct SwigPyMapValueForwardIterator_T : SwigPyMapForwardIterator_T - { - SwigPyMapValueForwardIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapForwardIterator_T(curr, first, last, seq) - { - } - }; - - - template - inline SwigPyIterator* - make_output_value_forward_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) - { - return new SwigPyMapValueForwardIterator_T(current, begin, end, seq); - } } } diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index 6d7def900..aa29a7cff 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -3,7 +3,7 @@ */ %include -%fragment("StdUnorderedMultimapTraits","header",fragment="StdSequenceTraits") +%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { template From b3f736a9d1fe70da2b36bbf7b51b27b65b3b55f0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Aug 2018 20:30:35 +0100 Subject: [PATCH 1077/2031] Python typo fix --- Lib/python/pyname_compat.i | 2 +- Lib/python/std_map.i | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i index 96af343ca..dc276e686 100644 --- a/Lib/python/pyname_compat.i +++ b/Lib/python/pyname_compat.i @@ -34,7 +34,7 @@ %inline %{ #define PyMapIterator_T SwigPyMapIterator_T #define PyMapKeyIterator_T SwigPyMapKeyIterator_T -#define PyMapValueIterator_T SwigPyMapValueITerator_T +#define PyMapValueIterator_T SwigPyMapValueIterator_T #define PyObject_ptr SwigPtr_PyObject #define PyObject_var SwigVar_PyObject #define PyOper SwigPyOper diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index f61f79c44..781c4d498 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -56,9 +56,9 @@ template > - struct SwigPyMapValueITerator_T : SwigPyMapIterator_T + struct SwigPyMapValueIterator_T : SwigPyMapIterator_T { - SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + SwigPyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) : SwigPyMapIterator_T(curr, first, last, seq) { } @@ -69,7 +69,7 @@ inline SwigPyIterator* 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 SwigPyMapValueIterator_T(current, begin, end, seq); } } } From eda58ca3086c70e5cb2e6994777fdc651466033d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 1 Sep 2018 09:55:40 +0100 Subject: [PATCH 1078/2031] Add changes entry for guile gc fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 99f219372..22bdfb7ff 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-09-01: ChristopherHogan + [Guile] #1288 Fix garbage collection for guile >= 2.0.12. + 2018-08-31: wsfulton [Python] #1319 C++11 hash tables support: std::unordered_map From 016518073537e2b88c8ac3f33f4caebd6bede3c6 Mon Sep 17 00:00:00 2001 From: Andreas Gaeer Date: Mon, 3 Sep 2018 19:52:43 +0100 Subject: [PATCH 1079/2031] Fix assert in PyTuple_GET_SIZE Occurs in debug interpreter builds of python-3.7 when calling tp_new in a few testcases such as Examples/python/extend. Closes #1321 --- CHANGES.current | 4 ++++ Lib/python/pyrun.swg | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 22bdfb7ff..67afee72c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-09-02: andreas.gaeer,tkrasnukha + [Python] #1321 Fix assert in PyTuple_GET_SIZE in debug interpreter builds of python-3.7 + when calling tp_new. + 2018-09-01: ChristopherHogan [Guile] #1288 Fix garbage collection for guile >= 2.0.12. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index c3e83dcc9..b1276813d 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1254,10 +1254,14 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } else { #if PY_VERSION_HEX >= 0x03000000 - inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + PyObject *empty_args = PyTuple_New(0); + if (empty_args) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, Py_None); + Py_DECREF(empty_args); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } } #else PyObject *dict = PyDict_New(); From 3af1b74e57d220aeffba3d06237b0c5c17473fb4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Sep 2018 07:22:20 +0100 Subject: [PATCH 1080/2031] Python implicitconv assert fix using debug build of the Python interpreter An error was not being set if an implicit conversion was attempted calling an explicit constructor. Fixes: Fatal Python error: a function returned NULL without setting an error SystemError: returned NULL without setting an error File "Examples/test-suite/python/implicittest.py", line 106 in __init_ --- Lib/python/pyrun.swg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index b1276813d..13738b668 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -290,7 +290,10 @@ SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; + int fail = data ? data->implicitconv : 0; + if (fail) + PyErr_SetString(PyExc_TypeError, "Implicit conversion is prohibited for explicit constructors."); + return fail; } SWIGRUNTIMEINLINE PyObject * From de5a2c496bf036c4f35ef7891c3c2dcec25af353 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Sep 2018 07:35:41 +0100 Subject: [PATCH 1081/2031] Python runtime test invalid sequence fix Fixes: DeprecationWarning: invalid escape sequence \] shown using debug build of python-3.7 interpreter. --- Examples/test-suite/python/li_cstring_runme.py | 4 ++-- Examples/test-suite/python/li_cwstring_runme.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py index 55b51d1c7..6fec5362b 100644 --- a/Examples/test-suite/python/li_cstring_runme.py +++ b/Examples/test-suite/python/li_cstring_runme.py @@ -7,7 +7,7 @@ if count("ab\0ab\0ab\0", 0) != 3: if test1() != "Hello World": raise RuntimeError -if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": +if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError if test3("hello") != "hello-suffix": @@ -27,5 +27,5 @@ if test6(10) != 'xxxxx': if test7() != "Hello world!": raise RuntimeError -if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": +if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py index aaa5b6e62..b2b23a862 100644 --- a/Examples/test-suite/python/li_cwstring_runme.py +++ b/Examples/test-suite/python/li_cwstring_runme.py @@ -6,7 +6,7 @@ if count(u"ab\0ab\0ab\0", 0) != 3: if test1() != u"Hello World": raise RuntimeError -if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": +if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError if test3("hello") != u"hello-suffix": @@ -24,5 +24,5 @@ if test6(10) != u'xxxxx': if test7() != u"Hello world!": raise RuntimeError -if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_": +if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError From 0a102e28462200039a281014ce94d66b026714f0 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Thu, 6 Sep 2018 12:43:51 +0300 Subject: [PATCH 1082/2031] Fix class having method `Connect()` creating a name collision with `SwigDirectorConnect()`. Issue is fixed by prepending director methods with `SwigDirectorMethod` instead of `SwigDirector`. --- Doc/Manual/CSharp.html | 14 +++++++------- Examples/test-suite/director_basic.i | 3 +++ Source/Modules/csharp.cxx | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index d74707708..a4e0be799 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1575,9 +1575,9 @@ public class Base : global::System.IDisposable { private void SwigDirectorConnect() { if (SwigDerivedClassHasMethod("UIntMethod", swigMethodTypes0)) - swigDelegate0 = new SwigDelegateBase_0(SwigDirectorUIntMethod); + swigDelegate0 = new SwigDelegateBase_0(SwigDirectorMethodUIntMethod); if (SwigDerivedClassHasMethod("BaseBoolMethod", swigMethodTypes1)) - swigDelegate1 = new SwigDelegateBase_1(SwigDirectorBaseBoolMethod); + swigDelegate1 = new SwigDelegateBase_1(SwigDirectorMethodBaseBoolMethod); examplePINVOKE.Base_director_connect(swigCPtr, swigDelegate0, swigDelegate1); } @@ -1587,11 +1587,11 @@ public class Base : global::System.IDisposable { return hasDerivedMethod; } - private uint SwigDirectorUIntMethod(uint x) { + private uint SwigDirectorMethodUIntMethod(uint x) { return UIntMethod(x); } - private void SwigDirectorBaseBoolMethod(global::System.IntPtr b, bool flag) { + private void SwigDirectorMethodBaseBoolMethod(global::System.IntPtr b, bool flag) { BaseBoolMethod(new Base(b, false), flag); } @@ -1620,9 +1620,9 @@ It uses a support method, SwigDerivedClassHasMethod(), which simply use BaseBoolMethod, with the list of required parameter types, exists in a subclass. If it does not exist, the delegate is not initialised as there is no need for unmanaged code to call back into managed C# code. However, if there is an overridden method in any subclass, the delegate is required. -It is then initialised to the SwigDirectorBaseBoolMethod which in turn will call BaseBoolMethod if invoked. +It is then initialised to the SwigDirectorMethodBaseBoolMethod which in turn will call BaseBoolMethod if invoked. The delegate is not initialised to the BaseBoolMethod directly as quite often types will need marshalling from the unmanaged type -to the managed type in which case an intermediary method (SwigDirectorBaseBoolMethod) is required for the marshalling. +to the managed type in which case an intermediary method (SwigDirectorMethodBaseBoolMethod) is required for the marshalling. In this case, the C# Base class needs to be created from the unmanaged IntPtr type.

          @@ -2497,7 +2497,7 @@ The generated proxy class code will then contain the following wrapper for calli
           ...
          -  private void SwigDirectorsomeCallback(global::System.IntPtr date) {
          +  private void SwigDirectorMethodsomeCallback(global::System.IntPtr date) {
               System.DateTime tempdate = new System.DateTime();
               try {
                 someCallback(out tempdate);
          diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i
          index 4c258b097..5ab66288e 100644
          --- a/Examples/test-suite/director_basic.i
          +++ b/Examples/test-suite/director_basic.i
          @@ -121,6 +121,9 @@ public:
             static Bar * call_pmethod(MyClass *myclass, Bar *b) {
               return myclass->pmethod(b);
             }
          +
          +   // Collisions with generated method names
          +   virtual void Connect() { }
           };
           
           template
          diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
          index c48a0a1f6..bd00ffaf3 100644
          --- a/Source/Modules/csharp.cxx
          +++ b/Source/Modules/csharp.cxx
          @@ -1935,7 +1935,7 @@ public:
           	String *methid = Getattr(udata, "class_methodidx");
           	String *overname = Getattr(udata, "overname");
           	Printf(proxy_class_code, "    if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s))\n", method, methid);
          -	Printf(proxy_class_code, "      swigDelegate%s = new SwigDelegate%s_%s(SwigDirector%s);\n", methid, proxy_class_name, methid, overname);
          +	Printf(proxy_class_code, "      swigDelegate%s = new SwigDelegate%s_%s(SwigDirectorMethod%s);\n", methid, proxy_class_name, methid, overname);
                 }
                 String *director_connect_method_name = Swig_name_member(getNSpace(), getClassPrefix(), "director_connect");
                 Printf(proxy_class_code, "    %s.%s(swigCPtr", imclass_name, director_connect_method_name);
          @@ -3864,7 +3864,7 @@ public:
           	  Printf(director_delegate_definitions, "  %s\n", im_directoroutattributes);
                 }
           
          -      Printf(callback_def, "  private %s SwigDirector%s(", tm, overloaded_name);
          +      Printf(callback_def, "  private %s SwigDirectorMethod%s(", tm, overloaded_name);
                 if (!ignored_method) {
           	const String *csdirectordelegatemodifiers = Getattr(n, "feature:csdirectordelegatemodifiers");
           	String *modifiers = (csdirectordelegatemodifiers ? NewStringf("%s%s", csdirectordelegatemodifiers, Len(csdirectordelegatemodifiers) > 0 ? " " : "") : NewStringf("public "));
          
          From 040683d1b37da744635138b64f20303664465211 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Thu, 6 Sep 2018 21:07:59 +0100
          Subject: [PATCH 1083/2031] Fix Python -builtin and -fastdispatch regression.
          
          Generated code did not compile
          ---
           Source/Modules/python.cxx | 6 +++++-
           1 file changed, 5 insertions(+), 1 deletion(-)
          
          diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
          index b3dbe19ab..9861ddee6 100755
          --- a/Source/Modules/python.cxx
          +++ b/Source/Modules/python.cxx
          @@ -2580,7 +2580,11 @@ public:
               if (castmode) {
                 dispatch = Swig_overload_dispatch_cast(n, dispatch_code, &maxargs);
               } else {
          -      String *fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call);
          +      String *fastdispatch_code;
          +      if (builtin_ctor)
          +	fastdispatch_code = NewStringf("int retval = %s\nif (retval == 0 || !SWIG_Python_TypeErrorOccurred(NULL)) return retval;\nSWIG_fail;", dispatch_call);
          +      else
          +	fastdispatch_code = NewStringf("PyObject *retobj = %s\nif (!SWIG_Python_TypeErrorOccurred(retobj)) return retobj;\nSWIG_fail;", dispatch_call);
                 if (!CPlusPlus) {
           	Insert(fastdispatch_code, 0, "{\n");
           	Append(fastdispatch_code, "\n}");
          
          From 4d34d419b66258b0f9fa90f78f9e896645980656 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Thu, 6 Sep 2018 21:22:51 +0100
          Subject: [PATCH 1084/2031] Disable nondynamic testcase for Python -builtin -O
          
          ---
           Examples/test-suite/python/python_nondynamic_runme.py | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
          index 9be47b3cc..fbb60ad36 100644
          --- a/Examples/test-suite/python/python_nondynamic_runme.py
          +++ b/Examples/test-suite/python/python_nondynamic_runme.py
          @@ -80,7 +80,7 @@ if python_nondynamic.is_python_builtin():
           else:
               python_nondynamic.C.classvar = 111
           
          -if is_python_modern():
          +if is_python_modern() and not python_nondynamic.is_python_builtin():
               # Not working with builtin or non-modern :(
               try:
                   B.a = 10
          
          From bf85b6f7a96fb4356713a58997ad5207324f3dbd Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sun, 16 Sep 2018 17:24:37 +0100
          Subject: [PATCH 1085/2031] Add in an example/test for Python __pow__
          
          - A test for the ternaryfunc builtin slot
          - Example of how to wrap C++ class for Python's pow
          ---
           .../test-suite/python/python_builtin_runme.py | 15 +++++++++++++++
           Examples/test-suite/python_builtin.i          | 19 +++++++++++++++++++
           2 files changed, 34 insertions(+)
          
          diff --git a/Examples/test-suite/python/python_builtin_runme.py b/Examples/test-suite/python/python_builtin_runme.py
          index 7afab2a39..26e757ca7 100644
          --- a/Examples/test-suite/python/python_builtin_runme.py
          +++ b/Examples/test-suite/python/python_builtin_runme.py
          @@ -83,6 +83,7 @@ if is_python_builtin():
             if MyClass.less_than_counts != 6:
               raise RuntimeError("python:compare feature not working")
           
          +# Test 6
           sa = SimpleArray(5)
           elements = [x for x in sa]
           if elements != [0, 10, 20, 30, 40]:
          @@ -96,3 +97,17 @@ subslice = sa[1:3]
           elements = [x for x in subslice]
           if elements != [10, 20]:
             raise RuntimeError("slice not working")
          +
          +# Test 7 mapping to Python's pow
          +x = ANumber(2)
          +y = ANumber(4)
          +z = x ** y
          +if z.Value() != 16:
          +  raise RuntimeError("x ** y wrong")
          +z = pow(x, y)
          +if z.Value() != 16:
          +  raise RuntimeError("pow(x, y) wrong")
          +z = ANumber(9)
          +z = pow(x, y, z)
          +if z.Value() != 7:
          +  raise RuntimeError("pow(x, y, z) wrong")
          diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i
          index c48867853..f47e937c8 100644
          --- a/Examples/test-suite/python_builtin.i
          +++ b/Examples/test-suite/python_builtin.i
          @@ -226,3 +226,22 @@ void Dealloc2Destroyer(PyObject *v) {
             };
           %}
           
          +// Test 7 mapping to Python's pow
          +%pybinoperator(__pow__, ANumber::power, ternaryfunc, nb_power);
          +
          +%inline %{
          +class ANumber {
          +  int num;
          +public:
          +  ANumber(int d = 0) : num(d) {}
          +  ANumber __pow__(const ANumber &other, const ANumber *x) const {
          +    int val = (int)pow(num, other.num);
          +    val = x ? val % x->num : val;
          +    return ANumber(val);
          +  }
          +  int Value() const {
          +    return num;
          +  }
          +};
          +%}
          +
          
          From c6547ac44e336b0df3bbdea704231ed5b6ef303c Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Wed, 19 Sep 2018 19:45:57 +0100
          Subject: [PATCH 1086/2031] Fix functors (wrapped as __call__) when using
           -builtin -modern -fastunpack.
          
          ---
           CHANGES.current                               |  3 ++
           Examples/test-suite/functors.i                | 33 +++++++++++++++++++
           Examples/test-suite/python/functors_runme.py  | 12 +++++++
           .../python/operator_overload_runme.py         |  7 ++++
           Source/Modules/python.cxx                     |  3 +-
           5 files changed, 57 insertions(+), 1 deletion(-)
           create mode 100644 Examples/test-suite/functors.i
           create mode 100644 Examples/test-suite/python/functors_runme.py
          
          diff --git a/CHANGES.current b/CHANGES.current
          index 67afee72c..d73925dbb 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2018-09-19: wsfulton
          +            [Python] Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack.
          +
           2018-09-02: andreas.gaeer,tkrasnukha
                       [Python] #1321 Fix assert in PyTuple_GET_SIZE in debug interpreter builds of python-3.7
                       when calling tp_new.
          diff --git a/Examples/test-suite/functors.i b/Examples/test-suite/functors.i
          new file mode 100644
          index 000000000..363123000
          --- /dev/null
          +++ b/Examples/test-suite/functors.i
          @@ -0,0 +1,33 @@
          +%module functors
          +
          +// Rename operator() only if the language does not already do this by default
          +#if defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVA) || defined(SWIGJAVASCRIPT) || defined(SWIGPHP) || defined(SWIGSCILAB) || defined(SWIGTCL)
          +%rename(Funktor) operator();
          +#endif
          +
          +%inline %{
          +class Functor0 {
          +  int num;
          +public:
          +  Functor0(int num) : num(num) {}
          +  int operator()() { return -num; }
          +  int operate() { return this->operator()(); }
          +};
          +
          +class Functor1 {
          +  int num;
          +public:
          +  Functor1(int num) : num(num) {}
          +  int operator()(int x) { return num + x; }
          +  int operate(int x) { return this->operator()(x); }
          +};
          +
          +class Functor2 {
          +  int num;
          +public:
          +  Functor2(int num) : num(num) {}
          +  int operator()(int x, int x2) { return num + x + x2; }
          +  int operate(int x, int x2) { return this->operator()(x, x2); }
          +};
          +%}
          +
          diff --git a/Examples/test-suite/python/functors_runme.py b/Examples/test-suite/python/functors_runme.py
          new file mode 100644
          index 000000000..98945a047
          --- /dev/null
          +++ b/Examples/test-suite/python/functors_runme.py
          @@ -0,0 +1,12 @@
          +from functors import *
          +
          +a = Functor0(10)
          +b = Functor1(10)
          +c = Functor2(10)
          +
          +if a()!=-10:
          +    raise RuntimeError("a failed")
          +if b(1)!=11:
          +    raise RuntimeError("b failed")
          +if c(1, 2)!=13:
          +    raise RuntimeError("c failed")
          diff --git a/Examples/test-suite/python/operator_overload_runme.py b/Examples/test-suite/python/operator_overload_runme.py
          index cf4277f35..31c49058e 100644
          --- a/Examples/test-suite/python/operator_overload_runme.py
          +++ b/Examples/test-suite/python/operator_overload_runme.py
          @@ -75,3 +75,10 @@ if not -a==a:
           if not -b==Op(-5):
             raise RuntimeError("-b==Op(-5)")
           
          +# test functors
          +if not b()==5:
          +  raise RuntimeError("functor")
          +if not b(1)==6:
          +  raise RuntimeError("functor")
          +if not b(1, 2)==8:
          +  raise RuntimeError("functor")
          diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
          index 9861ddee6..90e8b0b44 100755
          --- a/Source/Modules/python.cxx
          +++ b/Source/Modules/python.cxx
          @@ -3020,8 +3020,9 @@ public:
           	  }
           	  Printf(parse_args, "if ((nobjs < %d) || (nobjs > %d)) SWIG_fail;\n", num_required, num_arguments);
           	} else {
          +	  int is_tp_call = Equal(Getattr(n, "feature:python:slot"), "tp_call");
           	  Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL);
          -	  if (onearg && !builtin_ctor) {
          +	  if (onearg && !builtin_ctor && !is_tp_call) {
           	    Printf(parse_args, "if (!args) SWIG_fail;\n");
           	    Append(parse_args, "swig_obj[0] = args;\n");
           	  } else if (!noargs) {
          
          From ad7b591d24be03fad41ee0f2057931739fca153c Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Wed, 19 Sep 2018 20:21:23 +0100
          Subject: [PATCH 1087/2031] Add python -builtin -O Travis testing
          
          ---
           .travis.yml | 10 ++++++++++
           1 file changed, 10 insertions(+)
          
          diff --git a/.travis.yml b/.travis.yml
          index 32d7fe242..56216838f 100644
          --- a/.travis.yml
          +++ b/.travis.yml
          @@ -174,6 +174,11 @@ matrix:
                 env: SWIGLANG=python SWIG_FEATURES=-builtin
                 sudo: required
                 dist: trusty
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=python SWIG_FEATURES="-builtin -O"
          +      sudo: required
          +      dist: trusty
               - os: linux
                 env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1
                 sudo: required
          @@ -197,6 +202,11 @@ matrix:
                 env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7
                 sudo: required
                 dist: trusty
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.7
          +      sudo: required
          +      dist: trusty
               - compiler: gcc
                 os: linux
                 env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 SWIGOPTPY3=
          
          From ed28e7cbe29f203fabefd8ad1ffec4d43a5bcff8 Mon Sep 17 00:00:00 2001
          From: "luz.paz" 
          Date: Sat, 15 Sep 2018 08:26:20 -0400
          Subject: [PATCH 1088/2031] Misc. typo and whitespace fixes
          
          Found via `codespell -q 3 -L "uint,bae,objext,cmo,goin,struc,ois,upto"`
          whitespaces were unintentionally fixed due to my editors settings.
          
          Rebased patch #1327
          ---
           Examples/test-suite/doxygen_misc_constructs.i | 28 +++++++++----------
           .../java/doxygen_misc_constructs_runme.java   | 24 ++++++++--------
           .../test-suite/lua/abstract_access_runme.lua  |  2 +-
           Examples/test-suite/ruby/newobject1_runme.rb  |  2 +-
           Examples/test-suite/ruby/newobject2_runme.rb  |  2 +-
           Examples/test-suite/ruby/swig_assert.rb       |  2 +-
           Examples/test-suite/template_virtual.i        |  2 +-
           Source/Modules/python.cxx                     |  2 +-
           8 files changed, 32 insertions(+), 32 deletions(-)
          
          diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i
          index 461415316..c95e85683 100644
          --- a/Examples/test-suite/doxygen_misc_constructs.i
          +++ b/Examples/test-suite/doxygen_misc_constructs.i
          @@ -10,16 +10,16 @@
               // Tag '@endink' must be recognized even if it is not
               // followed by whitespace.
           
          -    /** Tag endlink must be recognized also when followed by nonspace charater.
          +    /** Tag endlink must be recognized also when followed by nonspace character.
                *
                * @link Connection::getId() @endlink
          */ - + char g_counter; - /** + /** Tag endlink must be recognized also when it is the last token - in the commment. + in the comment. @link Connection::getId() @endlink
          @link debugIdeTraceProfilerCoverageSample.py Python example. @endlink @@ -27,7 +27,7 @@ int g_zipCode; - // Paramter 'isReportSize' must appear in comment of the overload, which + // Parameter 'isReportSize' must appear in comment of the overload, which // has it. Empty line before link must be preserved. /** * Returns address of file line. @@ -38,20 +38,20 @@ * * @link Connection::getId() @endlink
          */ - void getAddress(int &fileName, - int line, + void getAddress(int &fileName, + int line, bool isGetSize = false) {} // The first comment must be ignored. - /** + /** * \defgroup icFacade isystem.connect Facade * * This page shows the core classes, which can be used to control * all aspects of winIDEA, for example: debugging, analyzers, IO module, ... */ - /** - * This class contains information for connection to winIDEA. Its methods + /** + * This class contains information for connection to winIDEA. Its methods * return reference to self, so we can use it like this: *
                * CConnectionConfig config = new CConnectionConfig();
          @@ -70,7 +70,7 @@
           
               // Text after '\c' must be kept unchanged in Python.
               /**
          -     * Determines how long the \c isystem.connect should wait for running 
          +     * Determines how long the \c isystem.connect should wait for running
                * instances to respond. Only one of \c lfWaitXXX flags from IConnect::ELaunchFlags
                * may be specified.
                */
          @@ -84,11 +84,11 @@
                */
               int getConnection() {return 3;}
           
          -    // the follwing must produce no comment in wrapper
          +    // the following must produce no comment in wrapper
               /*******************************************************************/
               char getFirstLetter() {return 'a';}
           
          -    
          +
               /**
                * Class description.
                */
          @@ -119,6 +119,6 @@
               void showList() { }
           
               #include "doxygen_misc_constructs.h"
          -    
          +
           %}
               %include "doxygen_misc_constructs.h"
          diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
          index 7c799412e..6d018b9d2 100644
          --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java
          +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
          @@ -12,8 +12,8 @@ public class doxygen_misc_constructs_runme {
                 System.exit(1);
               }
             }
          -  
          -  public static void main(String argv[]) 
          +
          +  public static void main(String argv[])
             {
               /*
                 Here we are using internal javadoc tool, it accepts the name of the class as paramterer,
          @@ -25,7 +25,7 @@ public class doxygen_misc_constructs_runme {
                                                  new String[]{"-quiet", "doxygen_misc_constructs"});
           
               HashMap wantedComments = new HashMap();
          -    
          +
               wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getConnection()",
               		"\n" +
               		"\n" +
          @@ -42,7 +42,7 @@ public class doxygen_misc_constructs_runme {
               		"");
               wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getG_zipCode()",
               		" Tag endlink must be recognized also when it is the last token\n" +
          -    		" in the commment.\n" +
          +    		" in the comment.\n" +
               		" \n" +
               		" {@link Connection::getId()  }
          \n" + " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" + @@ -50,14 +50,14 @@ public class doxygen_misc_constructs_runme { ""); wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.setG_zipCode(int)", " Tag endlink must be recognized also when it is the last token\n" + - " in the commment.\n" + + " in the comment.\n" + "\n" + " {@link Connection::getId() }
          \n" + " {@link debugIdeTraceProfilerCoverageSample.py Python example. }\n" + "\n" + ""); wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.getG_counter()", - " Tag endlink must be recognized also when followed by nonspace charater.\n" + + " Tag endlink must be recognized also when followed by nonspace character.\n" + "\n" + " {@link Connection::getId() }
          \n" + "\n" + @@ -94,7 +94,7 @@ public class doxygen_misc_constructs_runme { "\n" + ""); wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.setG_counter(char)", - " Tag endlink must be recognized also when followed by nonspace charater.\n" + + " Tag endlink must be recognized also when followed by nonspace character.\n" + "\n" + " {@link Connection::getId() }
          \n" + "\n" + @@ -133,18 +133,18 @@ public class doxygen_misc_constructs_runme { " This comment without space after '*' is valid in Doxygen.\n" + "\n" + ""); - + wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.isNoSpaceValidB()", " .This comment without space after '*' is valid in Doxygen.\n" + "\n" + ""); - + wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashA()", " Backslash followingword is a valid doxygen command. Output contains\n" + " 'followingword' with 'word' in code font.\n" + "\n" + ""); - + wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.backslashB()", " Doxy command without trailing space is ignored - nothing appears\n" + " on output. Standalone \\ and '\\' get to output.\n" + @@ -189,8 +189,8 @@ public class doxygen_misc_constructs_runme { "
          \n" + "\n" + " @param fileName name of the log file\n"); - - + + // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); } diff --git a/Examples/test-suite/lua/abstract_access_runme.lua b/Examples/test-suite/lua/abstract_access_runme.lua index c1d836136..70467ee2b 100644 --- a/Examples/test-suite/lua/abstract_access_runme.lua +++ b/Examples/test-suite/lua/abstract_access_runme.lua @@ -6,7 +6,7 @@ local env = _ENV -- Lua 5.2 if not env then env = getfenv () end -- Lua 5.1 setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) --- trying to instantiate pure virual classes +-- trying to instantiate pure virtual classes -- should fail assert(pcall(abstract_access.A)==false) assert(pcall(abstract_access.B)==false) diff --git a/Examples/test-suite/ruby/newobject1_runme.rb b/Examples/test-suite/ruby/newobject1_runme.rb index f5dc12fb5..be1949377 100644 --- a/Examples/test-suite/ruby/newobject1_runme.rb +++ b/Examples/test-suite/ruby/newobject1_runme.rb @@ -8,7 +8,7 @@ # # Ruby's GC is somewhat broken in that it will mark some more stack space # leading to the collection of local objects to be delayed. -# Thus, upon invokation, it sometimes you can wait up to several +# Thus, upon invocation, it sometimes you can wait up to several # instructions to kick in. # See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449 # diff --git a/Examples/test-suite/ruby/newobject2_runme.rb b/Examples/test-suite/ruby/newobject2_runme.rb index 99bc24374..04129f4aa 100644 --- a/Examples/test-suite/ruby/newobject2_runme.rb +++ b/Examples/test-suite/ruby/newobject2_runme.rb @@ -2,7 +2,7 @@ # # Ruby's GC is somewhat broken in that it will mark some more stack space # leading to the collection of local objects to be delayed. -# Thus, upon invokation, it sometimes you can wait up to several +# Thus, upon invocation, it sometimes you can wait up to several # instructions to kick in. # See: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7449 # diff --git a/Examples/test-suite/ruby/swig_assert.rb b/Examples/test-suite/ruby/swig_assert.rb index 5b3f9b5ce..cbdfc036d 100644 --- a/Examples/test-suite/ruby/swig_assert.rb +++ b/Examples/test-suite/ruby/swig_assert.rb @@ -21,7 +21,7 @@ end def swig_assert_simple(a) unless a - raise SwigRubyError.new("assertion falied.") + raise SwigRubyError.new("assertion failed.") end end diff --git a/Examples/test-suite/template_virtual.i b/Examples/test-suite/template_virtual.i index 8c844f946..c760e1833 100644 --- a/Examples/test-suite/template_virtual.i +++ b/Examples/test-suite/template_virtual.i @@ -1,7 +1,7 @@ %module template_virtual // Submitted by Marcelo Matus -// assertion emmitted with templates + derivation + pure virtual member +// assertion emitted with templates + derivation + pure virtual member // allocate.cxx:47: int Allocate::is_abstract_inherit(Node*, Node*): // Assertion `dn' failed. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 90e8b0b44..a916a1da9 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -415,7 +415,7 @@ public: threads = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nothreads") == 0) { - /* Turn off thread suppor mode */ + /* Turn off thread support mode */ nothreads = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-safecstrings") == 0) { From 333209595d95f5e82b55e62f29dccb7c8a1e98e8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Sep 2018 23:33:16 +0100 Subject: [PATCH 1089/2031] Python builtin test fix for non-builtin --- Examples/test-suite/python_builtin.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python_builtin.i b/Examples/test-suite/python_builtin.i index f47e937c8..994c625e8 100644 --- a/Examples/test-suite/python_builtin.i +++ b/Examples/test-suite/python_builtin.i @@ -234,7 +234,7 @@ class ANumber { int num; public: ANumber(int d = 0) : num(d) {} - ANumber __pow__(const ANumber &other, const ANumber *x) const { + ANumber __pow__(const ANumber &other, const ANumber *x = 0) const { int val = (int)pow(num, other.num); val = x ? val % x->num : val; return ANumber(val); From 4715a4e72c7ab6119a65f0e1af7c7400ebfaebe8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Sep 2018 08:40:55 +0100 Subject: [PATCH 1090/2031] Python -builtin __contains__ fix for map and set like containers. Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL container's find method. Without it, Python will do its own slower sequence search. --- CHANGES.current | 5 +++ .../test-suite/python/std_containers_runme.py | 20 +++++++++++ Lib/python/builtin.swg | 36 +++++++++++++++++++ Lib/python/std_map.i | 2 +- Lib/python/std_set.i | 4 +++ Lib/python/std_unordered_map.i | 5 ++- Lib/python/std_unordered_set.i | 4 +++ Source/Modules/python.cxx | 2 ++ 8 files changed, 76 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d73925dbb..76b49d924 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-09-21: wsfulton + [Python] Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or + std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL + container's find method. Without it, Python will do its own slower sequence search. + 2018-09-19: wsfulton [Python] Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack. diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py index d4625daa0..63ff74c2a 100644 --- a/Examples/test-suite/python/std_containers_runme.py +++ b/Examples/test-suite/python/std_containers_runme.py @@ -69,6 +69,15 @@ for k in map: if map[k] != imap[k]: raise RuntimeError, "bad map" +# Test __contains__ (required for 'x in y' to work) +if not imap.__contains__('hello'): + raise RuntimeError("hello imap.__contains__") +if 'hello' not in imap: + raise RuntimeError("hello not in imap") +if imap.__contains__('oops'): + raise RuntimeError("oops imap.__contains__") +if 'oops' in imap: + raise RuntimeError("oops in imap") mapc = {} c1 = std_containers.C() @@ -114,3 +123,14 @@ for i in s: if i != j: raise RuntimeError j = j + 1 + +# Test __contains__ (required for 'x in y' to work) +if not s.__contains__(3): + raise RuntimeError("3 s.__contains__") +if 3 not in s: + raise RuntimeError("3 not in s") +if s.__contains__(-1): + raise RuntimeError("-1 s.__contains__") +if -1 in s: + raise RuntimeError("-1 in s") + diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 926f2d1c6..5b8050be2 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -635,6 +635,42 @@ SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a return result; } +#define SWIGPY_OBJOBJPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ + return SwigPyBuiltin_objobjproc_closure(wrapper, a, b); \ +} +SWIGINTERN int +SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { + int result; + PyObject *pyresult; + PyObject *tuple; + tuple = PyTuple_New(1); + assert(tuple); + PyTuple_SET_ITEM(tuple, 0, b); + Py_XINCREF(b); + pyresult = wrapper(a, tuple); + result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; + Py_XDECREF(pyresult); + Py_DECREF(tuple); + return result; +} + +#define SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE(wrapper) \ +SWIGINTERN int \ +wrapper##_objobjproc_closure(PyObject *a, PyObject *b) { \ + return SwigPyBuiltin_funpack_objobjproc_closure(wrapper, a, b); \ +} +SWIGINTERN int +SwigPyBuiltin_funpack_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyObject *b) { + int result; + PyObject *pyresult; + pyresult = wrapper(a, b); + result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; + Py_XDECREF(pyresult); + return result; +} + #define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper) \ SWIGINTERN int \ wrapper##_objobjargproc_closure(PyObject *a, PyObject *b, PyObject *c) { \ diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 781c4d498..8ae483cef 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -156,6 +156,7 @@ %feature("python:slot", "mp_length", functype="lenfunc") __len__; %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; + %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; %extend { %newobject iterkeys(PyObject **PYTHON_SELF); @@ -263,7 +264,6 @@ return itemList; } - // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i index 53f97e475..e80daee7e 100644 --- a/Lib/python/std_set.i +++ b/Lib/python/std_set.i @@ -36,6 +36,10 @@ %swig_sequence_iterator(set); %swig_container_methods(set); +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; +#endif + %extend { void append(value_type x) { self->insert(x); diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 959f303a3..0a900c65c 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -131,6 +131,10 @@ %swig_sequence_forward_iterator(Map); %swig_container_methods(Map) +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; +#endif + %extend { mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) { Map::const_iterator i = self->find(key); @@ -204,7 +208,6 @@ return itemList; } - // Python 2.2 methods bool __contains__(const key_type& key) { return self->find(key) != self->end(); } diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 6c646509c..4a4d849a7 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -43,6 +43,10 @@ %swig_sequence_forward_iterator(unordered_set); %swig_container_methods(unordered_set); +#if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; +#endif + %extend { void append(value_type x) { self->insert(x); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a916a1da9..62f6fd41c 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -210,6 +210,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", "ssizeobjargproc", "SWIGPY_SSIZEOBJARGPROC_CLOSURE", "ssizessizeobjargproc", "SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE", + "objobjproc", "SWIGPY_OBJOBJPROC_CLOSURE", "objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE", "reprfunc", "SWIGPY_REPRFUNC_CLOSURE", "hashfunc", "SWIGPY_HASHFUNC_CLOSURE", @@ -229,6 +230,7 @@ static String *getClosure(String *functype, String *wrapper, int funpack = 0) { "ssizessizeargfunc", "SWIGPY_SSIZESSIZEARGFUNC_CLOSURE", "ssizeobjargproc", "SWIGPY_SSIZEOBJARGPROC_CLOSURE", "ssizessizeobjargproc", "SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE", + "objobjproc", "SWIGPY_FUNPACK_OBJOBJPROC_CLOSURE", "objobjargproc", "SWIGPY_OBJOBJARGPROC_CLOSURE", "reprfunc", "SWIGPY_REPRFUNC_CLOSURE", "hashfunc", "SWIGPY_HASHFUNC_CLOSURE", From 05d6717de903c8ee0ab413060f8d75999ffaa8fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Sep 2018 19:19:01 +0100 Subject: [PATCH 1091/2031] Python builtin - add indexing support to std::set --- Examples/test-suite/python/li_std_set_runme.py | 2 ++ Lib/python/std_set.i | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py index ad3c6d881..f6fad5561 100644 --- a/Examples/test-suite/python/li_std_set_runme.py +++ b/Examples/test-suite/python/li_std_set_runme.py @@ -54,6 +54,8 @@ if i.next() != 2: if i.next() != 3: raise RuntimeError +if si[0] != 1: + raise RuntimeError i = s.begin() i.next() diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i index e80daee7e..0ef011998 100644 --- a/Lib/python/std_set.i +++ b/Lib/python/std_set.i @@ -37,10 +37,11 @@ %swig_container_methods(set); #if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; #endif - %extend { + %extend { void append(value_type x) { self->insert(x); } @@ -60,8 +61,7 @@ void discard(value_type x) { self->erase(x); } - - }; + } %enddef %include From 146998ce819f27c81f76e825c2a7845332469368 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Sep 2018 19:30:31 +0100 Subject: [PATCH 1092/2031] Python builtin - add indexing support to std::unordered_set --- Examples/test-suite/python/cpp11_hash_tables_runme.py | 1 + Lib/python/std_unordered_set.i | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index d8c63208a..d135a359a 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -38,6 +38,7 @@ for x in [cpp11_hash_tables.SetInt([1]), cpp11_hash_tables.UnorderedMultiSetInt([1])]: swig_assert_equal([e for e in x], [1]) + swig_assert_equal(x[0], 1) swig_assert_equal(1 in x, True) swig_assert_equal(2 in x, False) diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 4a4d849a7..06dfc261e 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -45,8 +45,10 @@ #if defined(SWIGPYTHON_BUILTIN) %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; + %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; #endif + %extend { void append(value_type x) { self->insert(x); From 603285ecb6064e5192fa5b69c37ea3adfbba0434 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Sep 2018 10:02:45 +0100 Subject: [PATCH 1093/2031] Python std::unordered_map improvements Pick up various bug fixes and improvements from the std::map implementation. --- Lib/python/std_unordered_map.i | 66 +++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 0a900c65c..f89a36a12 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -78,11 +78,12 @@ typedef std::unordered_map unordered_map_type; static int asptr(PyObject *obj, unordered_map_type **val) { int res = SWIG_ERROR; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; 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() haven't returned a sequence!"); + /* In Python 3.x the ".items()" method returns a dict_items object */ + items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { @@ -91,6 +92,7 @@ res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; } + SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; @@ -100,27 +102,32 @@ typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; typedef typename unordered_map_type::size_type size_type; - - static PyObject *from(const unordered_map_type& unordered_map) { + + static PyObject *asdict(const unordered_map_type& map) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + size_type size = map.size(); + Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; + if (pysize < 0) { + PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); + SWIG_PYTHON_THREAD_END_BLOCK; + return NULL; + } + 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); + PyDict_SetItem(obj, key, val); + } + SWIG_PYTHON_THREAD_END_BLOCK; + return obj; + } + + static PyObject *from(const unordered_map_type& map) { swig_type_info *desc = swig::type_info(); if (desc && desc->clientdata) { - return SWIG_InternalNewPointerObj(new unordered_map_type(unordered_map), desc, SWIG_POINTER_OWN); + return SWIG_InternalNewPointerObj(new unordered_map_type(map), desc, SWIG_POINTER_OWN); } else { - size_type size = unordered_map.size(); - Py_ssize_t pysize = (size <= (size_type) INT_MAX) ? (Py_ssize_t) size : -1; - if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); - SWIG_PYTHON_THREAD_END_BLOCK; - return NULL; - } - PyObject *obj = PyDict_New(); - for (const_iterator i= unordered_map.begin(); i!= unordered_map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); - PyDict_SetItem(obj, key, val); - } - return obj; + return asdict(map); } } }; @@ -136,14 +143,14 @@ #endif %extend { - mapped_type __getitem__(const key_type& key) const throw (std::out_of_range) { + mapped_type const & __getitem__(const key_type& key) throw (std::out_of_range) { Map::const_iterator i = self->find(key); if (i != self->end()) return i->second; else throw std::out_of_range("key not found"); } - + void __delitem__(const key_type& key) throw (std::out_of_range) { Map::iterator i = self->find(key); if (i != self->end()) @@ -160,8 +167,8 @@ PyObject* keys() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; @@ -171,14 +178,15 @@ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } + SWIG_PYTHON_THREAD_END_BLOCK; return keyList; } PyObject* values() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; @@ -188,14 +196,15 @@ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } + SWIG_PYTHON_THREAD_END_BLOCK; return valList; } PyObject* items() { Map::size_type size = self->size(); Py_ssize_t pysize = (size <= (Map::size_type) INT_MAX) ? (Py_ssize_t) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "unordered_map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; return NULL; @@ -205,6 +214,7 @@ for (Py_ssize_t j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } + SWIG_PYTHON_THREAD_END_BLOCK; return itemList; } @@ -249,7 +259,13 @@ void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) { (*self)[key] = x; } + + PyObject* asdict() { + return swig::traits_from< Map >::asdict(*self); + } } + + %enddef From 72ccea50809c4c4f9943e6597027359c65e0df24 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Sep 2018 08:55:01 +0100 Subject: [PATCH 1094/2031] Python std::unordered_map std::unordered_multimap improvements - Fixes for -builtin - Fix missing iterator support --- .../python/cpp11_hash_tables_runme.py | 17 ++++---- .../test-suite/python/li_std_map_runme.py | 17 ++++++++ Lib/python/std_unordered_map.i | 42 +++++++++++++++---- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index d135a359a..28158c79a 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -6,12 +6,18 @@ def swig_assert_equal(a, b): for x in [cpp11_hash_tables.MapIntInt({1:7}), cpp11_hash_tables.MultiMapIntInt({1:7}), -# TODO: fix for -builtin -# cpp11_hash_tables.UnorderedMapIntInt({1:7}), -# cpp11_hash_tables.UnorderedMultiMapIntInt({1:7}) + cpp11_hash_tables.UnorderedMapIntInt({1:7}), + cpp11_hash_tables.UnorderedMultiMapIntInt({1:7}) ]: swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)]) + swig_assert_equal(x.keys(), [1]) + swig_assert_equal(x.values(), [7]) + swig_assert_equal(x.items(), [(1, 7)]) + swig_assert_equal([k for k in x], [1]) + swig_assert_equal([i for i in x.iterkeys()], [1]) + swig_assert_equal([i for i in x.itervalues()], [7]) + swig_assert_equal([i for i in x.iteritems()], [(1, 7)]) swig_assert_equal(x[1], 7) swig_assert_equal(2 in x, False) @@ -27,10 +33,7 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}), for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: x[1] = 9 -# TODO: fix for -builtin -# swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) -# Is this broken?... -# swig_assert_equal(sorted([v for v in x[1]]), [7, 9]) + swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) for x in [cpp11_hash_tables.SetInt([1]), cpp11_hash_tables.MultiSetInt([1]), diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index af3e1d989..5b5e8f179 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -50,3 +50,20 @@ mii[1] = 2 if mii[1] != 2: raise RuntimeError + +if mii.keys() != [1]: + raise RuntimeError("keys") +if mii.values() != [2]: + raise RuntimeError("values") +if mii.items() != [(1, 2)]: + raise RuntimeError("items") + +if [k for k in mii] != [1]: + raise RuntimeError("iteration") + +if [i for i in mii.iterkeys()] != [1]: + raise RuntimeError("iterkeys") +if [i for i in mii.itervalues()] != [2]: + raise RuntimeError("itervalues") +if [i for i in mii.iteritems()] != [(1, 2)]: + raise RuntimeError("iteritems") diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index f89a36a12..79882b292 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -139,7 +139,39 @@ %swig_container_methods(Map) #if defined(SWIGPYTHON_BUILTIN) + %feature("python:slot", "mp_length", functype="lenfunc") __len__; + %feature("python:slot", "mp_subscript", functype="binaryfunc") __getitem__; + %feature("python:slot", "tp_iter", functype="getiterfunc") key_iterator; %feature("python:slot", "sq_contains", functype="objobjproc") __contains__; + + %extend { + %newobject iterkeys(PyObject **PYTHON_SELF); + swig::SwigPyIterator* iterkeys(PyObject **PYTHON_SELF) { + return swig::make_output_key_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject itervalues(PyObject **PYTHON_SELF); + swig::SwigPyIterator* itervalues(PyObject **PYTHON_SELF) { + return swig::make_output_value_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + + %newobject iteritems(PyObject **PYTHON_SELF); + swig::SwigPyIterator* iteritems(PyObject **PYTHON_SELF) { + return swig::make_output_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); + } + } + +#else + %extend { + %pythoncode %{def __iter__(self): + return self.key_iterator()%} + %pythoncode %{def iterkeys(self): + return self.key_iterator()%} + %pythoncode %{def itervalues(self): + return self.value_iterator()%} + %pythoncode %{def iteritems(self): + return self.iterator()%} + } #endif %extend { @@ -231,16 +263,8 @@ swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_forward_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } - - %pythoncode %{def __iter__(self): - return self.key_iterator()%} - %pythoncode %{def iterkeys(self): - return self.key_iterator()%} - %pythoncode %{def itervalues(self): - return self.value_iterator()%} - %pythoncode %{def iteritems(self): - return self.iterator()%} } + %enddef %define %swig_unordered_map_methods(Map...) From 631e26ae48a3e4e9b6485993deb3078f5fb3ea6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Sep 2018 17:02:19 +0100 Subject: [PATCH 1095/2031] Python std::unordered_set tidy up and additional testing --- Examples/test-suite/python/cpp11_hash_tables_runme.py | 2 ++ Lib/python/std_unordered_set.i | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index 28158c79a..7b772ff9a 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -34,6 +34,7 @@ for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: x[1] = 9 swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) + swig_assert_equal(len(x), 2) for x in [cpp11_hash_tables.SetInt([1]), cpp11_hash_tables.MultiSetInt([1]), @@ -56,3 +57,4 @@ for x in [cpp11_hash_tables.MultiSetInt([1]), cpp11_hash_tables.UnorderedMultiSetInt([1])]: x.append(1) swig_assert_equal(x.count(1), 2) + swig_assert_equal(len(x), 2) diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 06dfc261e..8736cb1b5 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -49,7 +49,7 @@ #endif - %extend { + %extend { void append(value_type x) { self->insert(x); } @@ -61,8 +61,7 @@ value_type __getitem__(difference_type i) const throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } - - }; + } %enddef %include From d30effd88688d262181ef13073cb8deb08553145 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 23 Sep 2018 19:20:22 +0100 Subject: [PATCH 1096/2031] Python builtin closure minor tweaks --- Lib/python/builtin.swg | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 5b8050be2..5062a8b42 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -89,8 +89,8 @@ SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) { } tuple = PyTuple_New(1); assert(tuple); + Py_INCREF(val); PyTuple_SET_ITEM(tuple, 0, val); - Py_XINCREF(val); result = (*getset->set)(obj, tuple); Py_DECREF(tuple); Py_XDECREF(result); @@ -385,8 +385,8 @@ SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) { ++base_count; tuple = PyTuple_New(base_count); for (i = 0; i < base_count; ++i) { - PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); Py_INCREF((PyObject *)bases[i]); + PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]); } type->tp_bases = tuple; } @@ -489,8 +489,8 @@ SwigPyBuiltin_binaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyO PyObject *tuple, *result; tuple = PyTuple_New(1); assert(tuple); + Py_INCREF(b); PyTuple_SET_ITEM(tuple, 0, b); - Py_XINCREF(b); result = wrapper(a, tuple); Py_DECREF(tuple); return result; @@ -508,10 +508,10 @@ SwigPyBuiltin_ternaryfunc_closure(SwigPyWrapperFunction wrapper, PyObject *a, Py PyObject *tuple, *result; tuple = PyTuple_New(2); assert(tuple); + Py_INCREF(b); PyTuple_SET_ITEM(tuple, 0, b); + Py_INCREF(c); PyTuple_SET_ITEM(tuple, 1, c); - Py_XINCREF(b); - Py_XINCREF(c); result = wrapper(a, tuple); Py_DECREF(tuple); return result; @@ -574,8 +574,8 @@ SwigPyBuiltin_ssizessizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObje PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c)); if (d) { - PyTuple_SET_ITEM(tuple, 2, d); Py_INCREF(d); + PyTuple_SET_ITEM(tuple, 2, d); } resultobj = wrapper(a, tuple); result = resultobj ? 0 : -1; @@ -626,8 +626,8 @@ SwigPyBuiltin_ssizeobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a tuple = PyTuple_New(2); assert(tuple); PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b)); + Py_INCREF(c); PyTuple_SET_ITEM(tuple, 1, c); - Py_XINCREF(c); resultobj = wrapper(a, tuple); result = resultobj ? 0 : -1; Py_XDECREF(resultobj); @@ -647,8 +647,8 @@ SwigPyBuiltin_objobjproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, PyO PyObject *tuple; tuple = PyTuple_New(1); assert(tuple); + Py_INCREF(b); PyTuple_SET_ITEM(tuple, 0, b); - Py_XINCREF(b); pyresult = wrapper(a, tuple); result = pyresult ? (PyObject_IsTrue(pyresult) ? 1 : 0) : -1; Py_XDECREF(pyresult); @@ -682,11 +682,11 @@ SwigPyBuiltin_objobjargproc_closure(SwigPyWrapperFunction wrapper, PyObject *a, int result; tuple = PyTuple_New(c ? 2 : 1); assert(tuple); + Py_INCREF(b); PyTuple_SET_ITEM(tuple, 0, b); - Py_XINCREF(b); if (c) { + Py_INCREF(c); PyTuple_SET_ITEM(tuple, 1, c); - Py_XINCREF(c); } resultobj = wrapper(a, tuple); result = resultobj ? 0 : -1; From 3872890c1cdc67efd71abb3a1a588fb06d3f1edf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 Sep 2018 07:07:25 +0100 Subject: [PATCH 1097/2031] Add changes file entry for Python hash table implementation --- CHANGES.current | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 76b49d924..36712fe9f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-09-24: wsfulton + [Python] #1319 C++11 hash tables implementation is finished now (including for -builtin): + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + 2018-09-21: wsfulton [Python] Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL From 7eba1cfea1ae356ecdf7df02f0f85362e9710d2e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 Sep 2018 07:15:59 +0100 Subject: [PATCH 1098/2031] Testcase code correction --- Examples/test-suite/doxygen_nested_class.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/doxygen_nested_class.i b/Examples/test-suite/doxygen_nested_class.i index 91218e2bc..55575e34f 100644 --- a/Examples/test-suite/doxygen_nested_class.i +++ b/Examples/test-suite/doxygen_nested_class.i @@ -14,7 +14,7 @@ struct DoxOuter { /** doxInt variable */ int doxInt; /** doxShort const variable */ - static const short doxShort = 1.0; + static const short doxShort = 1; /** doxMethod description */ void doxMethod() {} /** doxStaticMethod description */ From ea3140a981436cfe0497fd0893f6ae89ecc3f91f Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Thu, 6 Sep 2018 14:21:54 +0300 Subject: [PATCH 1099/2031] Improve correctness of SwigDerivedClassHasMethod() tests Tests first added in issue #1323 --- .../test-suite/csharp/director_basic_runme.cs | 10 ++++++++++ Examples/test-suite/director_basic.i | 20 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs index b9916108c..26153af27 100644 --- a/Examples/test-suite/csharp/director_basic_runme.cs +++ b/Examples/test-suite/csharp/director_basic_runme.cs @@ -48,6 +48,8 @@ public class runme if (myNewBar == null) throw new Exception("non-null pointer marshalling problem"); myNewBar.x = 10; + + my.testSwigDerivedClassHasMethod(); } } } @@ -69,6 +71,14 @@ class MyOverriddenClass : MyClass { throw new Exception("null not received as expected"); return b; } + + public bool nonVirtual() { + throw new Exception("non-virtual overrides virtual method"); + } + + public virtual bool nonOverride() { + throw new Exception("non-override overrides virtual method"); + } } } diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 5ab66288e..c9f24b825 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -65,6 +65,14 @@ %} + %typemap(cscode) MyClass %{ + public void testSwigDerivedClassHasMethod() { + if (SwigDerivedClassHasMethod("nonVirtual", swigMethodTypes3)) + throw new global::System.Exception("non-overriding non-virtual method would be when connecting director"); + if (SwigDerivedClassHasMethod("nonOverride", swigMethodTypes4)) + throw new global::System.Exception("non-overriding virtual method would be when connecting director"); + } + %} %feature("director") MyClass; @@ -122,8 +130,16 @@ public: return myclass->pmethod(b); } - // Collisions with generated method names - virtual void Connect() { } + virtual void nonVirtual() + { + } + + virtual void nonOverride() + { + } + + // Collisions with generated method names + virtual void Connect() { } }; template From e4a251f32105122f2a96c5db1a703bb5f0bedc51 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Fri, 7 Sep 2018 14:26:16 +0300 Subject: [PATCH 1100/2031] Add `new` keywords for non-verriding methods in director_basic test. --- Examples/test-suite/csharp/director_basic_runme.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs index 26153af27..06a42480d 100644 --- a/Examples/test-suite/csharp/director_basic_runme.cs +++ b/Examples/test-suite/csharp/director_basic_runme.cs @@ -72,11 +72,11 @@ class MyOverriddenClass : MyClass { return b; } - public bool nonVirtual() { + public new bool nonVirtual() { throw new Exception("non-virtual overrides virtual method"); } - public virtual bool nonOverride() { + public new virtual bool nonOverride() { throw new Exception("non-override overrides virtual method"); } } From b90e3ae35d9a9c6ccb5119cb4b84b288baa75443 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 25 Sep 2018 07:46:29 +0100 Subject: [PATCH 1101/2031] C# directors override/virtual - additional testing Add runtime test for scenario described in #1323. Expand testing to cover a mix of override/virtual method overloading. Remove testSwigDerivedClassHasMethod() test - not fixed yet. --- .../test-suite/csharp/director_basic_runme.cs | 46 ++++++++++++++++++- Examples/test-suite/director_basic.i | 16 ++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/csharp/director_basic_runme.cs b/Examples/test-suite/csharp/director_basic_runme.cs index 06a42480d..de299b145 100644 --- a/Examples/test-suite/csharp/director_basic_runme.cs +++ b/Examples/test-suite/csharp/director_basic_runme.cs @@ -49,7 +49,35 @@ public class runme throw new Exception("non-null pointer marshalling problem"); myNewBar.x = 10; - my.testSwigDerivedClassHasMethod(); + // Low level implementation check +// my.testSwigDerivedClassHasMethod(); + + // These should not call the C# implementations as they are not overridden + int v; + v = MyClass.call_nonVirtual(my); + if (v != 100) throw new Exception("call_nonVirtual broken() " + v); + + v = MyClass.call_nonOverride(my); + if (v != 101) throw new Exception("call_nonOverride broken() " + v); + + // A mix of overridden and non-overridden + MyClassEnd myend = new MyClassEnd(); + MyClass mc = myend; + + v = mc.nonVirtual(); + if (v != 202) throw new Exception("mc.nonVirtual() broken " + v); + + v = MyClass.call_nonVirtual(mc); + if (v != 202) throw new Exception("call_nonVirtual(mc) broken " + v); + + v = MyClass.call_nonVirtual(myend); + if (v != 202) throw new Exception("call_nonVirtual(myend) broken" + v); + + v = MyClass.call_nonOverride(mc); + if (v != 101) throw new Exception("call_nonOverride(mc) broken" + v); + + v = MyClass.call_nonOverride(myend); + if (v != 101) throw new Exception("call_nonOverride(myend) broken" + v); } } } @@ -81,4 +109,20 @@ class MyOverriddenClass : MyClass { } } +class MyClassMiddle : MyClass { + public override int nonVirtual() { + return 202; + } +} + +class MyClassEnd : MyClassMiddle { + public new bool nonVirtual() { + throw new Exception("non-virtual overrides virtual method"); + } + + public new virtual bool nonOverride() { + throw new Exception("non-override overrides virtual method"); + } +} + } diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index c9f24b825..a8399d699 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -130,12 +130,24 @@ public: return myclass->pmethod(b); } - virtual void nonVirtual() + virtual int nonVirtual() { + return 100; } - virtual void nonOverride() + virtual int nonOverride() { + return 101; + } + + static int call_nonVirtual(MyClass *myclass) + { + return myclass->nonVirtual(); + } + + static int call_nonOverride(MyClass *myclass) + { + return myclass->nonOverride(); } // Collisions with generated method names From 142d4062df56aa3a6dd74b06e86700d95421b774 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Sep 2018 07:08:12 +0100 Subject: [PATCH 1102/2031] Fix invalid free in SWIG_Python_AddErrMesg Closes #1331 --- Lib/python/pyrun.swg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 13738b668..53c3a32d1 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1484,14 +1484,13 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) if (value) { PyObject *old_str = PyObject_Str(value); const char *tmp = SWIG_Python_str_AsChar(old_str); - if (!tmp) - tmp = "Invalid error message"; + const char *errmesg = tmp ? tmp : "Invalid error message"; Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp); + PyErr_Format(type, "%s %s", mesg, errmesg); } else { - PyErr_Format(type, "%s %s", tmp, mesg); + PyErr_Format(type, "%s %s", errmesg, mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); From c0c2d904970b0977bb1aec512fb92c3db7cef229 Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Mon, 1 Oct 2018 09:31:42 +0200 Subject: [PATCH 1103/2031] [Python] Fix -Wstringop-overflow warning fixes #1332 --- Lib/python/pyinit.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 516cd628b..4e13ed57a 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -215,7 +215,7 @@ SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int size_t size = strlen(name)+1; gv->name = (char *)malloc(size); if (gv->name) { - strncpy(gv->name,name,size); + memcpy(gv->name, name, size); gv->get_attr = get_attr; gv->set_attr = set_attr; gv->next = v->vars; From 18383340e9554199367585a310c61b19e536ea44 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Oct 2018 08:06:01 +0100 Subject: [PATCH 1104/2031] Fix C default arguments with -builtin and -fastunpack and -modernargs. Problem occurred when there is just one (defaulted) parameter in the parameter list. Closes #1126 --- CHANGES.current | 4 +++ Examples/test-suite/default_args_c.i | 27 +++++++++++++++++++ .../test-suite/python/default_args_c_runme.py | 20 ++++++++++++++ Source/Modules/python.cxx | 13 ++++----- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 36712fe9f..27d000b93 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-10-04: wsfulton + [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. + Problem occurred when there is just one (defaulted) parameter in the parameter list. + 2018-09-24: wsfulton [Python] #1319 C++11 hash tables implementation is finished now (including for -builtin): std::unordered_map diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i index ed1c4de60..504a6b84a 100644 --- a/Examples/test-suite/default_args_c.i +++ b/Examples/test-suite/default_args_c.i @@ -20,3 +20,30 @@ int foo43(int x) { return x; } %} + +%inline %{ +struct FooStruct {}; +%} +%extend FooStruct { + void no_arg() {} + void one_req(int *required) {} + void one_opt(int *optional = NULL) {} + void two_arg(int *required, int *optional = NULL) {} +} + +%inline %{ +struct StaticStruct {}; +%} +%extend StaticStruct { + static void no_arg() {} + static void one_req(int *required) {} + static void one_opt(int *optional = NULL) {} + static void two_arg(int *required, int *optional = NULL) {} +} + +%{ +void global_opts1(int *optional) {} +void global_opts2(int *required, int *optional) {} +%} +void global_opts1(int *optional = NULL) {} +void global_opts2(int *required, int *optional = NULL) {} diff --git a/Examples/test-suite/python/default_args_c_runme.py b/Examples/test-suite/python/default_args_c_runme.py index 5985fd75c..65ca9178f 100644 --- a/Examples/test-suite/python/default_args_c_runme.py +++ b/Examples/test-suite/python/default_args_c_runme.py @@ -4,3 +4,23 @@ if default_args_c.foo1() != 1: raise RuntimeError("failed") if default_args_c.foo43() != 43: raise RuntimeError("failed") + +f = default_args_c.FooStruct() +f.no_arg() +f.one_req(None) +f.one_opt() +f.one_opt(None) +f.two_arg(None) +f.two_arg(None, None) + +default_args_c.StaticStruct.no_arg() +default_args_c.StaticStruct.one_req(None) +default_args_c.StaticStruct.one_opt() +default_args_c.StaticStruct.one_opt(None) +default_args_c.StaticStruct.two_arg(None) +default_args_c.StaticStruct.two_arg(None, None) + +default_args_c.global_opts1() +default_args_c.global_opts1(None) +default_args_c.global_opts2(None) +default_args_c.global_opts2(None, None) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 62f6fd41c..c2952d630 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -19,7 +19,6 @@ #include #include "pydoc.h" -#include #include #define PYSHADOW_MEMBER 0x2 @@ -2865,11 +2864,13 @@ public: int noargs = funpack && (tuple_required == 0 && tuple_arguments == 0); int onearg = funpack && (tuple_required == 1 && tuple_arguments == 1); - if (builtin && funpack && !overname && !builtin_ctor && - !(GetFlag(n, "feature:compactdefaultargs") && (tuple_arguments > tuple_required || varargs))) { - String *argattr = NewStringf("%d", tuple_arguments); - Setattr(n, "python:argcount", argattr); - Delete(argattr); + if (builtin && funpack && !overname && !builtin_ctor) { + int compactdefargs = ParmList_is_compactdefargs(l); + if (!(compactdefargs && (tuple_arguments > tuple_required || varargs))) { + String *argattr = NewStringf("%d", tuple_arguments); + Setattr(n, "python:argcount", argattr); + Delete(argattr); + } } /* Generate code for argument marshalling */ From 94377ef3edba0510bb3f4a4fda2b73d4b96f086b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 4 Oct 2018 19:09:11 +0100 Subject: [PATCH 1105/2031] Fix testcase for visual studio --- Examples/test-suite/default_args_c.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i index 504a6b84a..70c121dcb 100644 --- a/Examples/test-suite/default_args_c.i +++ b/Examples/test-suite/default_args_c.i @@ -22,7 +22,9 @@ int foo43(int x) { %} %inline %{ -struct FooStruct {}; +struct FooStruct { + int num; +}; %} %extend FooStruct { void no_arg() {} From 84f7b740ea8452bea32f2fbaea7d227fe520bf99 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Oct 2018 06:52:49 +0100 Subject: [PATCH 1106/2031] Fix testcase for visual studio (2) --- Examples/test-suite/default_args_c.i | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/default_args_c.i b/Examples/test-suite/default_args_c.i index 70c121dcb..f507aa797 100644 --- a/Examples/test-suite/default_args_c.i +++ b/Examples/test-suite/default_args_c.i @@ -34,7 +34,9 @@ struct FooStruct { } %inline %{ -struct StaticStruct {}; +struct StaticStruct { + int snum; +}; %} %extend StaticStruct { static void no_arg() {} From 51f1478df74a8ea732a1dddbc5992eff5cc13f08 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Oct 2018 20:45:52 +0100 Subject: [PATCH 1107/2031] Improve typemaps documentation for %apply and delete. Make %apply and %clear section clearer (hopefully). --- Doc/Manual/Typemaps.html | 84 ++++++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index ed5591da5..78c7036f2 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -364,7 +364,7 @@ int spam(foo::Number a, foo::Number b);

          In this case, the typemap is still applied to the proper arguments even though typenames don't always match the text "int". This ability to track types is a critical part of SWIG--in fact, all -of the target language modules work merely define a set of typemaps for the basic types. Yet, it +of the target language modules work merely define a family of typemaps for the basic types. Yet, it is never necessary to write new typemaps for typenames introduced by typedef.

          @@ -431,7 +431,8 @@ be copied and reused. One way to do this is to use assignment like this:

          -A more general form of copying is found in the %apply directive like this: +There is a more powerful way to copy a family of typemaps though. +Consider the following family of two typemap methods, "in" and "out" for type int:

          @@ -444,8 +445,29 @@ A more general form of copying is found in the %apply directive like th /* Return an integer value */ ... } +
          +
          -/* Apply all of the integer typemaps to size_t */ +

          +Each of the two typemap methods could be copied individually for type size_t as follows: +

          + +
          +
          +/* Apply all of the int typemaps to size_t */
          +%typemap(in) size_t = int;   
          +%typemap(out) size_t = int;   
          +
          +
          + +

          +A more powerful form of copying is available from the %apply directive. +The code below is identical to the above: +

          + +
          +
          +/* Apply all of the int typemaps to size_t */
           %apply int { size_t };    
           
          @@ -916,32 +938,33 @@ The patterns for %apply follow the same rules as for %typemap.

          -A typemap can be deleted by simply defining no code. For example: +A particular typemap can be deleted / cleared by simply defining no code. For example:

          -%typemap(in) int;               // Clears typemap for int
          -%typemap(in) int, long, short;  // Clears typemap for int, long, short
          +%typemap(in) int;                 // Clears the "in" typemap for int
          +%typemap(in) int, long, short;    // Clears the "in" typemap for int, long, short
           %typemap(in) int *output;       
           

          -The %clear directive clears all typemaps for a given type. +The above syntax deletes a typemap for just one typemap method - the "in" method in each of the examples above. +The %clear directive is more powerful and will delete / clear a family of typemaps, that is, all the typemap methods for a given type. For example:

          -%clear int;                     // Removes all types for int
          +%clear int;                       // Delete all typemaps ("in", "out", "varin", ...) for int
           %clear int *output, long *output;
           

          Note: Since SWIG's default behavior is defined by typemaps, clearing a fundamental type like -int will make that type unusable unless you also define a new set of typemaps immediately +int will make that type unusable unless you also define a new family of typemaps immediately after the clear operation.

          @@ -2506,7 +2529,7 @@ which then expands to:

          -The set of typemaps recognized by a language module may vary. However, +The family of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

          @@ -3284,7 +3307,7 @@ The example above also shows a common approach of issuing a warning for an as ye

          The "out" typemap is the main typemap for return types. -This typemap supports an optional attribute flag called "optimal", which is for reducing +This typemap supports an optional attribute flag called "optimal", which is for reducing the number of temporary variables and the amount of generated code, thereby giving the compiler the opportunity to use return value optimization for generating faster executing code. It only really makes a difference when returning objects by value and has some limitations on usage, @@ -4899,8 +4922,8 @@ The 'equivalent' attribute is used in the implementation for the @@ -4916,7 +4939,7 @@ a set of typemaps like this:

          To make it easier to apply the typemap to different argument types and names, the %apply directive -performs a copy of all typemaps from one type to another. For example, if you specify this, +performs a copy of all typemaps from a source type to one or more set of target types. For example, if you specify this,

          @@ -4926,12 +4949,14 @@ performs a copy of all typemaps from one type to another. For example, if you s

          -then all of the int *OUTPUT typemaps are copied to int *retvalue and int32 *output. +then all of the int *OUTPUT (source) typemap methods are copied to int *retvalue and int32 *output (the targets).

          -However, there is a subtle aspect of %apply that needs more description. Namely, %apply does not -overwrite a typemap rule if it is already defined for the target datatype. This behavior allows you to do two things: +However, there is a subtle aspect of %apply that needs clarification. +Namely, if a target contains a typemap method that the source does not, +the target typemap method is not overwritten / deleted. +This behavior allows you to do two things:

            @@ -4939,7 +4964,7 @@ overwrite a typemap rule if it is already defined for the target datatype. Thi %apply to incorporate the remaining pieces. -
          • Sets of different typemaps can be applied to the same datatype using repeated %apply directives. +
          • Different typemaps can be applied to the same datatype using repeated %apply directives.
          @@ -4961,6 +4986,10 @@ For example: } } +%typemap(arginit) int *invalue %{ + $1 = NULL; +%} + ... %apply int *INPUT { int *invalue }; %apply int *POSITIVE { int *invalue }; @@ -4968,9 +4997,11 @@ For example:

      -Since %apply does not overwrite or replace any existing rules, the only way to reset behavior is to -use the %clear directive. %clear removes all typemap rules defined for a specific datatype. For -example: +In this example, neither of the two %apply directives will overwrite / delete the "arginit" typemap as neither has an "arginit" typemap. +The result is a family of three relevant typemaps for int *invalue. +Since %apply does not overwrite / delete any existing rules, the only way to reset behavior is to +delete them, such as with the %clear directive. +For example:

      @@ -4979,6 +5010,17 @@ example:
      +

      +will delete the typemaps for all the typemap methods; namely "in", "check" and "arginit". Alternatively delete each one individually: +

      + +
      +
      +%typemap(in) int *invalue;
      +%typemap(check) int *invalue;
      +%typemap(arginit) int *invalue;
      +
      +

      12.15 Passing data between typemaps

      From 07268b8da6497a660b2c91e0379522295669430e Mon Sep 17 00:00:00 2001 From: Sam Hasinoff Date: Thu, 4 Oct 2018 13:07:13 -0700 Subject: [PATCH 1108/2031] Set thread name when attaching to Android JVM in SWIG Java director Otherwise the native thread name gets clobbered with "Thread-XX", which makes debugging hard. This issue seems to be specific to the Android JVM. Someone proposed a similar fix to SWIG: https://github.com/swig/swig/pull/831 but abandoned it. --- Lib/java/director.swg | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Lib/java/director.swg b/Lib/java/director.swg index 2275976b8..987b657ee 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -6,8 +6,13 @@ * ----------------------------------------------------------------------------- */ #if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) +#include +#include #include #endif +#if defined(__ANDROID__) +#include +#endif #include @@ -139,12 +144,26 @@ namespace Swig { void **jenv = (void **)&jenv_; #endif env_status = director_->swig_jvm_->GetEnv((void **)&jenv_, JNI_VERSION_1_2); + JavaVMAttachArgs args; + args.version = JNI_VERSION_1_2; + args.group = NULL; + args.name = NULL; +#if defined(__ANDROID__) + char thread_name[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. + if (pthread_getname_np(pthread_self(), thread_name, sizeof(thread_name)) == 0) { + args.name = thread_name; + } else { +#if defined(DEBUG_DIRECTOR_OWNED) + std::cout << "JNIEnvWrapper: Couldn't get thread name: " << strerror(errno) << std::endl; +#endif + } +#endif #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. - director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, NULL); + director_->swig_jvm_->AttachCurrentThreadAsDaemon(jenv, &args); #else - director_->swig_jvm_->AttachCurrentThread(jenv, NULL); + director_->swig_jvm_->AttachCurrentThread(jenv, &args); #endif } ~JNIEnvWrapper() { From 8dd86344209772d0afdd17580e12d35306310d80 Mon Sep 17 00:00:00 2001 From: Sam Hasinoff Date: Thu, 4 Oct 2018 14:06:09 -0700 Subject: [PATCH 1109/2031] Actually, pthread_getname_np is only available in recent versions of Android (API level >= 26). --- Lib/java/director.swg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/java/director.swg b/Lib/java/director.swg index 987b657ee..de3eb5603 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -149,6 +149,7 @@ namespace Swig { args.group = NULL; args.name = NULL; #if defined(__ANDROID__) +#if defined(__ANDROID_API__) && __ANDROID_API__ >= 26 char thread_name[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. if (pthread_getname_np(pthread_self(), thread_name, sizeof(thread_name)) == 0) { args.name = thread_name; @@ -158,6 +159,7 @@ namespace Swig { #endif } #endif +#endif #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. From 989f4289c16f7d298e9c0f5c63b58248771aaa67 Mon Sep 17 00:00:00 2001 From: Sam Hasinoff Date: Thu, 4 Oct 2018 17:59:38 -0700 Subject: [PATCH 1110/2031] Use prctl method to get thread names, which is available on all NDK versions --- Lib/java/director.swg | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Lib/java/director.swg b/Lib/java/director.swg index de3eb5603..ba06f9e0a 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -5,13 +5,16 @@ * methods can be called from C++. * ----------------------------------------------------------------------------- */ +#if defined(__ANDROID__) +#include +#endif + #if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) +#if defined(__ANDROID__) #include #include -#include #endif -#if defined(__ANDROID__) -#include +#include #endif #include @@ -149,17 +152,15 @@ namespace Swig { args.group = NULL; args.name = NULL; #if defined(__ANDROID__) -#if defined(__ANDROID_API__) && __ANDROID_API__ >= 26 char thread_name[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. - if (pthread_getname_np(pthread_self(), thread_name, sizeof(thread_name)) == 0) { + if (prctl(PR_GET_NAME, (unsigned long)thread_name, 0, 0, 0) == 0) { args.name = thread_name; } else { -#if defined(DEBUG_DIRECTOR_OWNED) - std::cout << "JNIEnvWrapper: Couldn't get thread name: " << strerror(errno) << std::endl; +#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) + std::cerr << "JNIEnvWrapper: Couldn't set thread name: " << strerror(errno) << std::endl; #endif } #endif -#endif #if defined(SWIG_JAVA_ATTACH_CURRENT_THREAD_AS_DAEMON) // Attach a daemon thread to the JVM. Useful when the JVM should not wait for // the thread to exit upon shutdown. Only for jdk-1.4 and later. From 3195c3e4dac605aaa9ee877ea956151bc3e15830 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Oct 2018 21:29:11 +0100 Subject: [PATCH 1111/2031] Java directors - more generic thread name setting Activated if a user sets SWIG_JAVA_USE_THREAD_NAME. Implementations provided for linux/android/macos/unix. A user's implementation will be used if SWIG_JAVA_GET_THREAD_NAME is defined. It must implement the function: namespace Swig { SWIGINTERN int GetThreadName(char *name, size_t len); } --- Examples/test-suite/director_thread.i | 20 ++++++- .../java/director_thread_runme.java | 6 ++ Lib/java/director.swg | 59 +++++++++++++++---- 3 files changed, 71 insertions(+), 14 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 260bce774..cb999ecc4 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -7,6 +7,11 @@ %module(directors="1") director_thread #endif +%begin %{ +#define SWIG_JAVA_USE_THREAD_NAME +//#define DEBUG_DIRECTOR_THREAD_NAME +%} + %{ #ifdef _WIN32 #include @@ -89,10 +94,23 @@ extern "C" { fprintf(stderr, "pthread_create failed in run()\n"); assert(0); } + int setname = pthread_setname_np(thread, "MyThreadName"); + if (setname != 0) { + fprintf(stderr, "pthread_setname_np failed in run()\n"); + assert(0); + } %#endif MilliSecondSleep(500); } - + + static bool namedThread() { +%#ifdef _WIN32 + return false; +%#else + return true; +%#endif + } + virtual void do_foo() { val += 1; } diff --git a/Examples/test-suite/java/director_thread_runme.java b/Examples/test-suite/java/director_thread_runme.java index c67d4104f..9bc4a93b5 100644 --- a/Examples/test-suite/java/director_thread_runme.java +++ b/Examples/test-suite/java/director_thread_runme.java @@ -30,6 +30,12 @@ class director_thread_Derived extends Foo { } public void do_foo() { + // Not all operating systems can name threads, so only test on those that can + if (Foo.namedThread()) { + String threadName = Thread.currentThread().getName(); + if (!threadName.equals("MyThreadName")) + throw new RuntimeException("Unexpected thread name: " + threadName); + } setVal(getVal() - 1); } } diff --git a/Lib/java/director.swg b/Lib/java/director.swg index ba06f9e0a..d4c88d5c6 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -5,20 +5,52 @@ * methods can be called from C++. * ----------------------------------------------------------------------------- */ -#if defined(__ANDROID__) -#include -#endif - -#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) -#if defined(__ANDROID__) -#include -#include -#endif +#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) || defined(DEBUG_DIRECTOR_THREAD_NAME) #include #endif #include +#if defined(SWIG_JAVA_USE_THREAD_NAME) + +#if !defined(SWIG_JAVA_GET_THREAD_NAME) +namespace Swig { + SWIGINTERN int GetThreadName(char *name, size_t len); +} + +#if defined(__linux__) + +#include +SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { + (void)len; +#if defined(PR_GET_NAME) + return prctl(PR_GET_NAME, (unsigned long)name, 0, 0, 0); +#else + (void)name; + return 1; +#endif +} + +#elif defined(__unix__) + +#include +SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { + return pthread_getname_np(pthread_self(), name, len); +} + +#else + +SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { + (void)len; + (void)name; + return 1; +} +#endif + +#endif + +#endif + namespace Swig { /* Java object wrapper */ @@ -151,13 +183,14 @@ namespace Swig { args.version = JNI_VERSION_1_2; args.group = NULL; args.name = NULL; -#if defined(__ANDROID__) +#if defined(SWIG_JAVA_USE_THREAD_NAME) char thread_name[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. - if (prctl(PR_GET_NAME, (unsigned long)thread_name, 0, 0, 0) == 0) { + if (Swig::GetThreadName(thread_name, sizeof(thread_name)) == 0) { args.name = thread_name; +#if defined(DEBUG_DIRECTOR_THREAD_NAME) + std::cout << "JNIEnvWrapper: thread name: " << thread_name << std::endl; } else { -#if defined(DEBUG_DIRECTOR_OWNED) || defined(DEBUG_DIRECTOR_EXCEPTION) - std::cerr << "JNIEnvWrapper: Couldn't set thread name: " << strerror(errno) << std::endl; + std::cout << "JNIEnvWrapper: Couldn't set Java thread name" << std::endl; #endif } #endif From 220a735ec5797df0750ffc20998383fcbd22f828 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Oct 2018 19:37:07 +0100 Subject: [PATCH 1112/2031] Update php test --- Examples/test-suite/php/director_basic_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/director_basic_runme.php b/Examples/test-suite/php/director_basic_runme.php index de6b50502..af6110103 100644 --- a/Examples/test-suite/php/director_basic_runme.php +++ b/Examples/test-suite/php/director_basic_runme.php @@ -4,7 +4,7 @@ require "tests.php"; require "director_basic.php"; // No new functions -check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method)); +check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method,myclass_nonvirtual,myclass_nonoverride,myclass_call_nonvirtual,myclass_call_nonoverride,myclass_connect)); // No new classes check::classes(array(Foo,A,A1,Bar,MyClass,MyClassT_i)); // now new vars From ca287ae13b069ab0f8c914a81a615de77c34dbcc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Oct 2018 19:44:00 +0100 Subject: [PATCH 1113/2031] Add support for non-default compare template argument in std::map wrappers --- CHANGES.current | 8 +- Lib/d/std_map.i | 10 +-- Lib/go/std_map.i | 10 +-- Lib/guile/std_map.i | 176 ++++++++++++++++++------------------- Lib/java/std_map.i | 8 +- Lib/lua/std_map.i | 10 +-- Lib/mzscheme/std_map.i | 192 ++++++++++++++++++++--------------------- Lib/ocaml/std_map.i | 10 +-- Lib/perl5/std_map.i | 10 +-- Lib/php/std_map.i | 10 +-- Lib/scilab/std_map.i | 10 +-- Lib/tcl/std_map.i | 10 +-- 12 files changed, 234 insertions(+), 230 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index be7ab45c0..b51ce0216 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,8 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== -2018-06-09: vadz - [Java] #1274 Allow exporting std::map using non-default comparison function. +2018-10-09: wsfulton + [D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl] + Allow wrapping of std::map using non-default comparison function. + +2018-10-09: vadz + [Java] #1274 Allow wrapping of std::map using non-default comparison function. 2018-10-04: wsfulton [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i index d2ba04118..968def214 100644 --- a/Lib/d/std_map.i +++ b/Lib/d/std_map.i @@ -17,21 +17,21 @@ %} namespace std { - template class map { + template > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -41,14 +41,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i index 84b0c74ff..f514cf743 100644 --- a/Lib/go/std_map.i +++ b/Lib/go/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,14 +28,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index 489acc187..e945afd86 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -40,12 +40,12 @@ namespace std { - template class map { - %typemap(in) map { + template > class map { + %typemap(in) map< K, T, C > { if (scm_is_null($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); } else if (scm_is_pair($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; @@ -72,13 +72,13 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp), - const map* (std::map temp) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp), + const map< K, T, C >* (std::map< K, T, C > temp) { if (scm_is_null($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -105,9 +105,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { SCM alist = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); @@ -117,7 +117,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -153,7 +153,7 @@ namespace std { } } else { /* wrapped map? */ - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -161,8 +161,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { /* native sequence? */ if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -198,7 +198,7 @@ namespace std { } } else { /* wrapped map? */ - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -219,14 +219,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T> &); + map(const map< K, T, C> &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& __getitem__(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -236,19 +236,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); @@ -263,12 +263,12 @@ namespace std { %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - %typemap(in) map { + template class map< K, T, C > { + %typemap(in) map< K, T, C > { if (scm_is_null($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); } else if (scm_is_pair($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); SCM alist = $input; while (!scm_is_null(alist)) { T* x; @@ -280,7 +280,7 @@ namespace std { val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) @@ -296,13 +296,13 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp), - const map* (std::map temp) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp), + const map< K, T, C >* (std::map< K, T, C > temp) { if (scm_is_null($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -315,7 +315,7 @@ namespace std { val = SCM_CDR(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) != 0) { if (!scm_is_pair(val)) @@ -330,9 +330,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { SCM alist = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); SCM k = CONVERT_TO(i->first); SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1); @@ -341,7 +341,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -375,7 +375,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -383,8 +383,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -418,7 +418,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -435,14 +435,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T > &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -452,19 +452,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_TO(i->first); result = scm_cons(k,result); } @@ -475,12 +475,12 @@ namespace std { %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - %typemap(in) map { + template class map< K, T, C > { + %typemap(in) map< K, T, C > { if (scm_is_null($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); } else if (scm_is_pair($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); SCM alist = $input; while (!scm_is_null(alist)) { K* k; @@ -497,7 +497,7 @@ namespace std { val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); @@ -507,13 +507,13 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp), - const map* (std::map temp) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp), + const map< K, T, C >* (std::map< K, T, C > temp) { if (scm_is_null($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -531,7 +531,7 @@ namespace std { val = SCM_CAR(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } temp[*k] = CONVERT_FROM(val); alist = SCM_CDR(alist); @@ -540,9 +540,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { SCM alist = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); SCM x = CONVERT_TO(i->second); @@ -551,7 +551,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -583,7 +583,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -591,8 +591,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -624,7 +624,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -641,14 +641,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T > &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -658,19 +658,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); result = scm_cons(k,result); @@ -683,12 +683,12 @@ namespace std { %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - %typemap(in) map { + template<> class map< K, T, C > { + %typemap(in) map< K, T, C > { if (scm_is_null($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); } else if (scm_is_pair($input)) { - $1 = std::map< K, T >(); + $1 = std::map< K, T, C >(); SCM alist = $input; while (!scm_is_null(alist)) { SCM entry, key, val; @@ -699,14 +699,14 @@ namespace std { val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); @@ -717,13 +717,13 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp), - const map* (std::map temp) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp), + const map< K, T, C >* (std::map< K, T, C > temp) { if (scm_is_null($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (scm_is_pair($input)) { - temp = std::map< K, T >(); + temp = std::map< K, T, C >(); $1 = &temp; SCM alist = $input; while (!scm_is_null(alist)) { @@ -735,14 +735,14 @@ namespace std { val = SCM_CDR(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (!CHECK_T(val)) { if (!scm_is_pair(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = SCM_CAR(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = SCM_CDR(alist); @@ -751,9 +751,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { SCM alist = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { SCM k = CONVERT_K_TO(i->first); SCM x = CONVERT_T_TO(i->second); SCM entry = scm_cons(k,x); @@ -761,7 +761,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -792,7 +792,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) == 0) $1 = 1; @@ -800,8 +800,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (scm_is_null($input)) { /* an empty sequence can be of any type */ @@ -832,7 +832,7 @@ namespace std { } } else { // wrapped map? - std::map< K, T >* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) == 0) $1 = 1; @@ -849,14 +849,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T> &); + map(const map< K, T, C> &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -866,19 +866,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } SCM keys() { SCM result = SCM_EOL; - for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { SCM k = CONVERT_K_TO(i->first); result = scm_cons(k,result); } diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index a94a99576..75d523cec 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -25,14 +25,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -42,14 +42,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index 84b0c74ff..8a203e133 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,14 +28,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C> &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index 849f8baf5..6a0cb2d36 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -40,12 +40,12 @@ namespace std { - template class map { - %typemap(in) map (std::map* m) { + template > class map { + %typemap(in) map< K, T, C > (std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); } else if (SCHEME_PAIRP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; @@ -72,15 +72,15 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp, - std::map* m), - const map* (std::map temp, - std::map* m) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp, + std::map< K, T, C >* m), + const map< K, T, C >* (std::map< K, T, C > temp, + std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { @@ -107,9 +107,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { Scheme_Object* alist = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); @@ -120,7 +120,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -156,7 +156,7 @@ namespace std { } } else { /* wrapped map? */ - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; @@ -164,8 +164,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { /* native sequence? */ if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -201,7 +201,7 @@ namespace std { } } else { /* wrapped map? */ - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; @@ -222,14 +222,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -239,19 +239,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=self->rbegin(); + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); @@ -267,12 +267,12 @@ namespace std { %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - %typemap(in) map (std::map* m) { + template class map< K, T, C > { + %typemap(in) map< K, T, C > (std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); } else if (SCHEME_PAIRP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { T* x; @@ -284,7 +284,7 @@ namespace std { val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) @@ -300,15 +300,15 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp, - std::map* m), - const map* (std::map temp, - std::map* m) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp, + std::map< K, T, C >* m), + const map< K, T, C >* (std::map< K, T, C > temp, + std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { @@ -321,7 +321,7 @@ namespace std { val = scheme_cdr(entry); if (!CHECK(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (SWIG_ConvertPtr(val,(void**) &x, $descriptor(T *), 0) == -1) { if (!SCHEME_PAIRP(val)) @@ -336,9 +336,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { Scheme_Object* alist = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { T* val = new T(i->second); Scheme_Object* k = CONVERT_TO(i->first); @@ -348,7 +348,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -382,7 +382,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; @@ -390,8 +390,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -425,7 +425,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; @@ -442,14 +442,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T& __getitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -459,19 +459,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=self->rbegin(); + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_TO(i->first); result = scheme_make_pair(k,result); @@ -483,12 +483,12 @@ namespace std { %enddef %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) - template class map { - %typemap(in) map (std::map* m) { + template class map< K, T, C > { + %typemap(in) map< K, T, C > (std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); } else if (SCHEME_PAIRP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { K* k; @@ -505,7 +505,7 @@ namespace std { val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } (($1_type &)$1)[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); @@ -515,15 +515,15 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp, - std::map* m), - const map* (std::map temp, - std::map* m) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp, + std::map< K, T, C >* m), + const map< K, T, C >* (std::map< K, T, C > temp, + std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { @@ -541,7 +541,7 @@ namespace std { val = scheme_car(val); if (!CHECK(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } temp[*k] = CONVERT_FROM(val); alist = scheme_cdr(alist); @@ -550,9 +550,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { Scheme_Object* alist = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); @@ -562,7 +562,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -595,7 +595,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; @@ -603,8 +603,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -637,7 +637,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; @@ -654,14 +654,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -671,19 +671,19 @@ namespace std { (*self)[key] = x; } void __delitem__(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=self->rbegin(); + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { K* key = new K(i->first); Scheme_Object* k = SWIG_NewPointerObj(key,$descriptor(K *), 1); @@ -697,12 +697,12 @@ namespace std { %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) - template<> class map { - %typemap(in) map (std::map* m) { + template<> class map< K, T, C > { + %typemap(in) map< K, T, C > (std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); } else if (SCHEME_PAIRP($input)) { - $1 = std::map(); + $1 = std::map< K, T, C >(); Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { Scheme_Object *entry, *key, *val; @@ -713,14 +713,14 @@ namespace std { val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } (($1_type &)$1)[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); @@ -731,15 +731,15 @@ namespace std { SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0)); } } - %typemap(in) const map& (std::map temp, - std::map* m), - const map* (std::map temp, - std::map* m) { + %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp, + std::map< K, T, C >* m), + const map< K, T, C >* (std::map< K, T, C > temp, + std::map< K, T, C >* m) { if (SCHEME_NULLP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; } else if (SCHEME_PAIRP($input)) { - temp = std::map(); + temp = std::map< K, T, C >(); $1 = &temp; Scheme_Object* alist = $input; while (!SCHEME_NULLP(alist)) { @@ -751,14 +751,14 @@ namespace std { val = scheme_cdr(entry); if (!CHECK_K(key)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); if (!CHECK_T(val)) { if (!SCHEME_PAIRP(val)) SWIG_exception(SWIG_TypeError,"alist expected"); val = scheme_car(val); if (!CHECK_T(val)) SWIG_exception(SWIG_TypeError, - "map<" #K "," #T "> expected"); + "map<" #K "," #T "," #C "> expected"); } temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val); alist = scheme_cdr(alist); @@ -767,9 +767,9 @@ namespace std { $1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0); } } - %typemap(out) map { + %typemap(out) map< K, T, C > { Scheme_Object* alist = scheme_null; - for (std::map::reverse_iterator i=$1.rbegin(); + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); Scheme_Object* x = CONVERT_T_TO(i->second); @@ -778,7 +778,7 @@ namespace std { } $result = alist; } - %typecheck(SWIG_TYPECHECK_MAP) map { + %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -809,7 +809,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $&1_descriptor, 0) != -1) $1 = 1; @@ -817,8 +817,8 @@ namespace std { $1 = 0; } } - %typecheck(SWIG_TYPECHECK_MAP) const map&, - const map* { + %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&, + const map< K, T, C >* { // native sequence? if (SCHEME_NULLP($input)) { /* an empty sequence can be of any type */ @@ -849,7 +849,7 @@ namespace std { } } else { // wrapped map? - std::map* m; + std::map< K, T, C >* m; if (SWIG_ConvertPtr($input,(void **) &m, $1_descriptor, 0) != -1) $1 = 1; @@ -866,14 +866,14 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { T __getitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -883,19 +883,19 @@ namespace std { (*self)[key] = x; } void __delitem__(K key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(K key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } Scheme_Object* keys() { Scheme_Object* result = scheme_null; - for (std::map::reverse_iterator i=self->rbegin(); + for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) { Scheme_Object* k = CONVERT_K_TO(i->first); result = scheme_make_pair(k,result); diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index 5656b7fa2..91756bec0 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -19,7 +19,7 @@ // exported class namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -27,14 +27,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -44,14 +44,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index af49ed38e..ae7c26601 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,14 +28,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map< K, T >::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index 6d5e3db13..020c20153 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,13 +28,13 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -44,14 +44,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } bool is_empty() const { diff --git a/Lib/scilab/std_map.i b/Lib/scilab/std_map.i index 250d2d84c..0255e2f6a 100644 --- a/Lib/scilab/std_map.i +++ b/Lib/scilab/std_map.i @@ -19,18 +19,18 @@ namespace std { - template class map { + template > class map { // add typemaps here public: map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -40,14 +40,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index ade2b0ad1..96e7cae80 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -19,7 +19,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -27,14 +27,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -44,14 +44,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } From c8fc6a0322de6ab8fc23c00e3946566652deb6d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Oct 2018 19:45:08 +0100 Subject: [PATCH 1114/2031] Fix guile std::map bug in out typemap --- Lib/guile/std_map.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index e945afd86..ca9883688 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -107,7 +107,7 @@ namespace std { } %typemap(out) map< K, T, C > { SCM alist = SCM_EOL; - for (std::map< K, T, C >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) { + for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) { K* key = new K(i->first); T* val = new T(i->second); SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1); From 967776189ed585e12f892b2c34716e45ea151b5e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Oct 2018 22:42:49 +0100 Subject: [PATCH 1115/2031] Add support for non-default compare template argument in std::map wrappers - Javascript --- Lib/javascript/jsc/std_map.i | 10 +++++----- Lib/javascript/v8/std_map.i | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i index e7812f38a..903f77aa5 100644 --- a/Lib/javascript/jsc/std_map.i +++ b/Lib/javascript/jsc/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,14 +28,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } diff --git a/Lib/javascript/v8/std_map.i b/Lib/javascript/v8/std_map.i index e7812f38a..903f77aa5 100644 --- a/Lib/javascript/v8/std_map.i +++ b/Lib/javascript/v8/std_map.i @@ -20,7 +20,7 @@ namespace std { - template class map { + template > class map { // add typemaps here public: typedef size_t size_type; @@ -28,14 +28,14 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map< K, T, C > &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) return i->second; else @@ -45,14 +45,14 @@ namespace std { (*self)[key] = x; } void del(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); if (i != self->end()) self->erase(i); else throw std::out_of_range("key not found"); } bool has_key(const K& key) { - std::map::iterator i = self->find(key); + std::map< K, T, C >::iterator i = self->find(key); return i != self->end(); } } From dcbccc6f6f83fa41484b99c4de1fb9df514a4dab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Oct 2018 22:43:19 +0100 Subject: [PATCH 1116/2031] Test non-default compare template argument in std::map --- .../test-suite/csharp/li_std_map_runme.cs | 14 +++++++++++++ Examples/test-suite/li_std_map.i | 21 +++++++++++++++++++ .../test-suite/python/li_std_map_runme.py | 12 +++++++++++ 3 files changed, 47 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index b21c81e4e..51510c9fc 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -240,6 +240,20 @@ public class li_std_map_runme { throw new Exception("Key test (2) on complex key map failed"); } + // Custom compare function + { + StringLengthNumberMap slmap = new StringLengthNumberMap(); + li_std_map.populate(slmap); + + string keys = string.Join(" ", new List(slmap.Keys)); + if (keys != "a aa zzz xxxx aaaaa") + throw new Exception("Keys are wrong or in wrong order: " + keys); + + string values = string.Join(" ", new List(slmap.Values)); + if (values != "1 2 3 4 5") + throw new Exception("Values are wrong or in wrong order: " + values); + } + // All done } } diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index bf24c35e1..238cc3393 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -117,4 +117,25 @@ namespace std { } } +%ignore LengthCompare::operator(); +%inline %{ +struct LengthCompare { + bool operator() (std::string s1, std::string s2) const { + return s1.size() < s2.size(); + } +}; +%} +// A map sorted by string lengths +%template(StringLengthNumberMap) std::map< std::string, int, LengthCompare >; + +%inline %{ +std::map< std::string, int, LengthCompare > MyMap; +void populate(std::map< std::string, int, LengthCompare >&m) { + m["aa"] = 2; + m["xxxx"] = 4; + m["a"] = 1; + m["aaaaa"] = 5; + m["zzz"] = 3; +} +%} diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index 5b5e8f179..ac214dd45 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -67,3 +67,15 @@ if [i for i in mii.itervalues()] != [2]: raise RuntimeError("itervalues") if [i for i in mii.iteritems()] != [(1, 2)]: raise RuntimeError("iteritems") + + +slmap = li_std_map.StringLengthNumberMap() +li_std_map.populate(slmap) + +keys = " ".join([k for k in slmap.keys()]) +if keys != "a aa zzz xxxx aaaaa": + raise RuntimeError("Keys are wrong or in wrong order: " + keys) + +values = " ".join([str(v) for v in slmap.values()]) +if values != "1 2 3 4 5": + raise RuntimeError("Values are wrong or in wrong order: " + values) From 728b8955bd50d79168e121f834295ef30fcdc89e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 19 May 2018 11:47:23 +1200 Subject: [PATCH 1117/2031] Drop support for Python classic classes There were only needed to support Python < 2.2, and we now require at least Python 2.6. Conflicts: .travis.yml Examples/test-suite/python/autodoc_runme.py Source/Modules/python.cxx This is a cherry-pick and merge from patch in #1261 --- .travis.yml | 5 -- Doc/Manual/Python.html | 4 +- Examples/python/exceptproxy/example.i | 16 ++-- .../import_packages/same_modnames1/runme.py | 4 - .../import_packages/same_modnames2/runme.py | 4 - Examples/test-suite/python/autodoc_runme.py | 8 -- .../test-suite/python/cpp_static_runme.py | 14 +--- .../test-suite/python/default_args_runme.py | 9 +-- .../python/director_abstract_runme.py | 16 +--- .../python/global_namespace_runme.py | 37 +++------ .../test-suite/python/implicittest_runme.py | 15 +--- .../python/li_boost_shared_ptr_bits_runme.py | 9 +-- .../python/namespace_class_runme.py | 16 +--- .../python/overload_template_fast_runme.py | 9 +-- .../test-suite/python/python_append_runme.py | 8 +- .../python/python_docstring_runme.py | 2 +- .../test-suite/python/python_pickle_runme.py | 6 -- .../python/python_richcompare_runme.py | 67 +++++++--------- .../python/smart_pointer_member_runme.py | 8 +- Source/Modules/python.cxx | 80 ++++++------------- 20 files changed, 96 insertions(+), 241 deletions(-) diff --git a/.travis.yml b/.travis.yml index 56216838f..29c3129d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -222,11 +222,6 @@ matrix: env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.7 sudo: required dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=python SWIG_FEATURES=-classic - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=r diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index db9bf978d..4958d80ab 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6313,9 +6313,7 @@ SWIG is able to support Python 3.x. The wrapper code generated by SWIG can be compiled with both Python 2.x or 3.x. 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. +subsections for details of these features).

      There is a list of known-to-be-broken features in Python 3: diff --git a/Examples/python/exceptproxy/example.i b/Examples/python/exceptproxy/example.i index f5f835149..4ad960845 100644 --- a/Examples/python/exceptproxy/example.i +++ b/Examples/python/exceptproxy/example.i @@ -59,15 +59,15 @@ */ /* - Now, the EmptyError doesn't appear in a throw declaration, and hence - we need to 'mark' it as an exception class. In python, classes that - are used as exception are 'special', and need to be wrapped as - 'classic' ones. - - This is a python issue, and if you don't mark the class, you will - see 'interesting' behaviours at the python side. - + Python classes that are used as exceptions need to be subclasses of the + "Exception" class, and so SWIG needs to know which wrapped classes may be + used in this way. You can explicitly tell SWIG this by using + %exceptionclass. SWIG will implicitly set this feature for classes which + appear in a throw declaration, but it's not a problem to explicitly + mark such classes as well. + This is a Python requirement - if you fail to mark such classes with + %exceptionclass you may see 'interesting' behaviour on the Python side. */ %exceptionclass EmptyError; %exceptionclass FullError; diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py index 3c3c00c1a..5f6a7f57f 100644 --- a/Examples/python/import_packages/same_modnames1/runme.py +++ b/Examples/python/import_packages/same_modnames1/runme.py @@ -10,10 +10,6 @@ print " Finished importing pkg2.foo" var2 = pkg2.foo.Pkg2_Foo() classname = str(type(var2)) -# Check for an old-style class if swig was run in -classic mode -if classname == "": - classname = str(var2.__class__) - if classname.find("pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) print " Successfully created object pkg2.foo.Pkg2_Foo" diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py index 38daad0a3..55f6826b9 100644 --- a/Examples/python/import_packages/same_modnames2/runme.py +++ b/Examples/python/import_packages/same_modnames2/runme.py @@ -9,10 +9,6 @@ print " Finished importing pkg1.pkg2.foo" var2 = pkg1.pkg2.foo.Pkg2_Foo() classname = str(type(var2)) -# Check for an old-style class if swig was run in -classic mode -if classname == "": - classname = str(var2.__class__) - if classname.find("pkg1.pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index d89c7a880..1350c6d67 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -10,9 +10,6 @@ def check(got, expected, expected_builtin=None, skip=False): expect = expected_builtin comment_verifier.check(got, expect) -def is_new_style_class(cls): - return hasattr(cls, "__class__") - def is_fastproxy(): fastproxy = True try: @@ -21,11 +18,6 @@ def is_fastproxy(): fastproxy = False return fastproxy -if not is_new_style_class(A): - # Missing static methods make this hard to test... skip if -classic is - # used! - sys.exit(0) - if is_fastproxy(): # Detect when -fastproxy is specified and skip test as it changes the function names making it # hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py index ef31f88af..e8c8cf615 100644 --- a/Examples/test-suite/python/cpp_static_runme.py +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -2,17 +2,9 @@ from cpp_static import * -def is_new_style_class(cls): - return hasattr(cls, "__class__") - -if is_new_style_class(StaticFunctionTest): - StaticFunctionTest.static_func() - StaticFunctionTest.static_func_2(1) - StaticFunctionTest.static_func_3(1, 2) -else: - StaticFunctionTest().static_func() - StaticFunctionTest().static_func_2(1) - StaticFunctionTest().static_func_3(1, 2) +StaticFunctionTest.static_func() +StaticFunctionTest.static_func_2(1) +StaticFunctionTest.static_func_3(1, 2) if is_python_builtin(): if not StaticMemberTest.static_int == 99: raise RuntimeError("static_int not 99") diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index 4d937d220..683314dfe 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -2,10 +2,6 @@ # the use of __main__ and the run function -def is_new_style_class(cls): - return hasattr(cls, "__class__") - - def run(module_name): default_args = __import__(module_name) ec = default_args.EnumClass() @@ -101,10 +97,7 @@ def run(module_name): if error: raise RuntimeError("Foo::meth ignore is not working") - if is_new_style_class(default_args.Klass): - Klass_inc = default_args.Klass.inc - else: - Klass_inc = default_args.Klass_inc + Klass_inc = default_args.Klass.inc if Klass_inc(100, default_args.Klass(22)).val != 122: raise RuntimeError("Klass::inc failed") diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py index 031c476d8..333b75fe5 100644 --- a/Examples/test-suite/python/director_abstract_runme.py +++ b/Examples/test-suite/python/director_abstract_runme.py @@ -1,10 +1,6 @@ import director_abstract -def is_new_style_class(cls): - return hasattr(cls, "__class__") - - class MyFoo(director_abstract.Foo): def __init__(self): @@ -44,20 +40,12 @@ me1 = MyExample1() if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1: raise RuntimeError -if is_new_style_class(MyExample2): - MyExample2_static = MyExample2 -else: - MyExample2_static = MyExample2(0, 0) me2 = MyExample2(1, 2) -if MyExample2_static.get_color(me2, 1, 2, 3) != 2: +if MyExample2.get_color(me2, 1, 2, 3) != 2: raise RuntimeError -if is_new_style_class(MyExample3): - MyExample3_static = MyExample3 -else: - MyExample3_static = MyExample3() me3 = MyExample3() -if MyExample3_static.get_color(me3, 1, 2, 3) != 3: +if MyExample3.get_color(me3, 1, 2, 3) != 3: raise RuntimeError error = 1 diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py index ac12fe2dc..a47f41047 100644 --- a/Examples/test-suite/python/global_namespace_runme.py +++ b/Examples/test-suite/python/global_namespace_runme.py @@ -1,9 +1,6 @@ from global_namespace import * -def is_new_style_class(cls): - return hasattr(cls, "__class__") - k1 = Klass1() k2 = Klass2() k3 = Klass3() @@ -12,12 +9,8 @@ k5 = Klass5() k6 = Klass6() k7 = Klass7() -if is_new_style_class(KlassMethods): - KlassMethods_static = KlassMethods -else: - KlassMethods_static = KlassMethods() -KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7) -KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) k1 = getKlass1A() k2 = getKlass2A() @@ -27,8 +20,8 @@ k5 = getKlass5A() k6 = getKlass6A() k7 = getKlass7A() -KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7) -KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) k1 = getKlass1B() k2 = getKlass2B() @@ -38,21 +31,11 @@ k5 = getKlass5B() k6 = getKlass6B() k7 = getKlass7B() -KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7) -KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7) +KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7) -if is_new_style_class(XYZMethods): - XYZMethods_static = XYZMethods -else: - XYZMethods_static = XYZMethods() -XYZMethods_static.methodA( - XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) -XYZMethods_static.methodB( - XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) +XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) +XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7()) -if is_new_style_class(TheEnumMethods): - TheEnumMethods_static = TheEnumMethods -else: - TheEnumMethods_static = TheEnumMethods() -TheEnumMethods_static.methodA(theenum1, theenum2, theenum3) -TheEnumMethods_static.methodA(theenum1, theenum2, theenum3) +TheEnumMethods.methodA(theenum1, theenum2, theenum3) +TheEnumMethods.methodA(theenum1, theenum2, theenum3) diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index 4646d08c0..f17788e97 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -6,9 +6,6 @@ def check(a, b): raise RuntimeError(str(a) + " does not equal " + str(b)) -def is_new_style_class(cls): - return hasattr(cls, "__class__") - #### Class #### # No implicit conversion @@ -45,17 +42,13 @@ check(2, A_int(1.0).get()) check(3, A_int(B()).get()) check(4, A_int("hello").get()) -if is_new_style_class(A_int): - A_int_static = A_int -else: - A_int_static = A_int(0) -check(1, A_int_static.sget(1)) -check(2, A_int_static.sget(1.0)) -check(3, A_int_static.sget(B())) +check(1, A_int.sget(1)) +check(2, A_int.sget(1.0)) +check(3, A_int.sget(B())) # explicit constructor: try: - check(4, A_int_static.sget("hello")) + check(4, A_int.sget("hello")) raise RuntimeError except TypeError: pass diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py index 9b9c7d683..adf9ac4cf 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py @@ -1,10 +1,6 @@ from li_boost_shared_ptr_bits import * -def is_new_style_class(cls): - return hasattr(cls, "__class__") - - def check(nd): nd.i = 200 i = nd.i @@ -35,7 +31,4 @@ if sum != 66: raise "sum is wrong" ################################ -if is_new_style_class(HiddenDestructor): - p = HiddenDestructor.create() -else: - p = HiddenDestructor_create() +p = HiddenDestructor.create() diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py index e0bd3ca09..aa5165562 100644 --- a/Examples/test-suite/python/namespace_class_runme.py +++ b/Examples/test-suite/python/namespace_class_runme.py @@ -1,9 +1,5 @@ from namespace_class import * - -def is_new_style_class(cls): - return hasattr(cls, "__class__") - try: p = Private1() error = 1 @@ -22,10 +18,7 @@ except: if (error): raise RuntimeError, "Private2 is private" -if is_new_style_class(EulerT3D): - EulerT3D.toFrame(1, 1, 1) -else: - EulerT3D().toFrame(1, 1, 1) +EulerT3D.toFrame(1, 1, 1) b = BooT_i() b = BooT_H() @@ -40,7 +33,6 @@ f.moo(1) f = FooT_H() f.foo(Hi) -if is_new_style_class(FooT_H): - f_type = str(type(f)) - if f_type.find("'namespace_class.FooT_H'") == -1: - raise RuntimeError("Incorrect type: " + f_type) +f_type = str(type(f)) +if f_type.find("'namespace_class.FooT_H'") == -1: + raise RuntimeError("Incorrect type: " + f_type) diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py index 95349a9b1..ca3cac9b5 100644 --- a/Examples/test-suite/python/overload_template_fast_runme.py +++ b/Examples/test-suite/python/overload_template_fast_runme.py @@ -1,9 +1,5 @@ from overload_template_fast import * - -def is_new_style_class(cls): - return hasattr(cls, "__class__") - f = foo() a = maximum(3, 4) @@ -145,9 +141,6 @@ if (nsoverload() != 1050): raise RuntimeError, ("nsoverload(const char *)") -if is_new_style_class(A): - A.foo(1) -else: - A_foo(1) +A.foo(1) b = B() b.foo(1) diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index ce5514dff..eddda53ff 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -1,19 +1,13 @@ from python_append import * -def is_new_style_class(cls): - return hasattr(cls, "__class__") - # test not relevant for -builtin if is_python_builtin(): exit(0) t = Test() t.funk() -if is_new_style_class(Test): - t.static_func() -else: - Test_static_func() +t.static_func() if grabpath() != os.path.dirname(mypath): raise RuntimeError("grabpath failed") diff --git a/Examples/test-suite/python/python_docstring_runme.py b/Examples/test-suite/python/python_docstring_runme.py index 0284ea0de..a601ecb54 100644 --- a/Examples/test-suite/python/python_docstring_runme.py +++ b/Examples/test-suite/python/python_docstring_runme.py @@ -9,7 +9,7 @@ def check(got, expected): raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list)) # When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options -# such as -O, -builtin, -classic produce different initial indentation. +# such as -O and -builtin may produce different initial indentation. check(inspect.getdoc(DocStrings.docstring1), " line 1\n" diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py index cf2847919..27c67ae10 100644 --- a/Examples/test-suite/python/python_pickle_runme.py +++ b/Examples/test-suite/python/python_pickle_runme.py @@ -3,17 +3,11 @@ import python_pickle import pickle import sys -def is_new_style_class(cls): - return hasattr(cls, "__class__") - def check(p): msg = p.msg if msg != "hi there": raise RuntimeError("Bad, got: " + msg) -if not is_new_style_class(python_pickle.PickleMe): - sys.exit(0) - python_pickle.cvar.debug = False p = python_pickle.PickleMe("hi there") diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py index 247660301..724d1d73c 100644 --- a/Examples/test-suite/python/python_richcompare_runme.py +++ b/Examples/test-suite/python/python_richcompare_runme.py @@ -6,9 +6,6 @@ def check_unorderable_types(exception): # raise RuntimeError("A TypeError 'unorderable types' exception was expected"), None, sys.exc_info()[2] pass # Exception message seems to vary from one version of Python to another -def is_new_style_class(cls): - return hasattr(cls, "__class__") - base1 = python_richcompare.BaseClass(1) base2 = python_richcompare.BaseClass(2) base3 = python_richcompare.BaseClass(3) @@ -103,39 +100,37 @@ if not (a2 <= b2): # Check inequalities to other objects #------------------------------------------------------------------------------- -if is_new_style_class(python_richcompare.BaseClass): - # Skip testing -classic option - if sys.version_info[0:2] < (3, 0): - if (base1 < 42): - raise RuntimeError("Comparing class to incompatible type, < returned True") - if (base1 <= 42): - raise RuntimeError("Comparing class to incompatible type, <= returned True") - if not (base1 > 42): - raise RuntimeError("Comparing class to incompatible type, > returned False") - if not (base1 >= 42): - raise RuntimeError("Comparing class to incompatible type, >= returned False") - else: - # Python 3 throws: TypeError: unorderable types - try: - res = base1 < 42 - raise RuntimeError("Failed to throw") - except TypeError,e: - check_unorderable_types(e) - try: - res = base1 <= 42 - raise RuntimeError("Failed to throw") - except TypeError,e: - check_unorderable_types(e) - try: - res = base1 > 42 - raise RuntimeError("Failed to throw") - except TypeError,e: - check_unorderable_types(e) - try: - res = base1 >= 42 - raise RuntimeError("Failed to throw") - except TypeError,e: - check_unorderable_types(e) +if sys.version_info[0:2] < (3, 0): + if (base1 < 42): + raise RuntimeError("Comparing class to incompatible type, < returned True") + if (base1 <= 42): + raise RuntimeError("Comparing class to incompatible type, <= returned True") + if not (base1 > 42): + raise RuntimeError("Comparing class to incompatible type, > returned False") + if not (base1 >= 42): + raise RuntimeError("Comparing class to incompatible type, >= returned False") +else: + # Python 3 throws: TypeError: unorderable types + try: + res = base1 < 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 <= 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 > 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) + try: + res = base1 >= 42 + raise RuntimeError("Failed to throw") + except TypeError,e: + check_unorderable_types(e) # Check inequalities used for ordering #------------------------------------------------------------------------- diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py index ce91da2bd..d2ed87e79 100644 --- a/Examples/test-suite/python/smart_pointer_member_runme.py +++ b/Examples/test-suite/python/smart_pointer_member_runme.py @@ -1,9 +1,6 @@ from smart_pointer_member import * -def is_new_style_class(cls): - return hasattr(cls, "__class__") - f = Foo() f.y = 1 @@ -24,6 +21,5 @@ if b.x != f.x: if b.z != f.z: raise RuntimeError -if is_new_style_class(Bar): # feature not supported in old style classes - if Foo.z == Bar.z: - raise RuntimeError +if Foo.z == Bar.z: + raise RuntimeError diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c2952d630..dbc0a98c6 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -65,7 +65,6 @@ static String *methods; static String *class_name; static String *shadow_indent = 0; static int in_class = 0; -static int classic = 0; static int modern = 0; static int new_repr = 1; static int no_header_file = 0; @@ -123,7 +122,6 @@ Python Options (available with -python)\n\ -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ - -classic - Use classic classes only\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ @@ -393,10 +391,8 @@ public: SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); } else if (strcmp(argv[i], "-classic") == 0) { - classic = 1; - modernargs = 0; - modern = 0; - Swig_mark_arg(i); + Printf(stderr, "*** %s is no longer supported.\n", argv[i]); + SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); @@ -510,7 +506,6 @@ public: proxydel = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0) { - classic = 0; modern = 1; modernargs = 1; Swig_mark_arg(i); @@ -527,7 +522,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - classic = 0; modern = 1; safecstrings = 0; buildnone = 0; @@ -562,11 +556,6 @@ public: } } - if (py3) { - /* force disable features that not compatible with Python 3.x */ - classic = 0; - } - if (cppcast) { Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } @@ -745,10 +734,6 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS\n"); } - if (classic) { - Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n"); - } - if (builtin) { Printf(f_runtime, "#define SWIGPYTHON_BUILTIN\n"); } @@ -911,14 +896,12 @@ public: tab4, "if not static:\n", #endif NIL); - if (!classic) { - if (!modern) - Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL); - Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL); - if (!modern) - Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL); - } - if (classic || !modern) + if (!modern) + Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL); + Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL); + if (!modern) + Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL); + if (!modern) Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL); Printv(f_shadow, tab4, "else:\n", @@ -937,7 +920,7 @@ public: tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n", tab4, "except __builtin__.Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); - if (!classic && !modern) { + if (!modern) { Printv(f_shadow, "try:\n", tab4, "_object = object\n", tab4, "_newclass = 1\n", @@ -1057,7 +1040,7 @@ public: if (shadow) { Swig_banner_target_lang(f_shadow_py, "#"); - if (!modern && !classic) { + if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); } if (Len(f_shadow_begin) > 0) @@ -4433,7 +4416,6 @@ public: } virtual int classHandler(Node *n) { - int oldclassic = classic; int oldmodern = modern; File *f_shadow_file = f_shadow; Node *base_node = NULL; @@ -4445,15 +4427,12 @@ public: have_repr = 0; if (GetFlag(n, "feature:classic")) { - classic = 1; modern = 0; } if (GetFlag(n, "feature:modern")) { - classic = 0; modern = 1; } if (GetFlag(n, "feature:exceptionclass")) { - classic = 1; modern = 0; } @@ -4541,14 +4520,13 @@ public: if (Len(base_class)) { Printf(f_shadow, "(%s)", base_class); } else { - if (!classic) { + if (GetFlag(n, "feature:exceptionclass")) { + Printf(f_shadow, "(Exception)"); + } else { Printf(f_shadow, modern ? "(object" : "(_object"); Printf(f_shadow, modern && py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")"); Printf(f_shadow, ")"); } - if (GetFlag(n, "feature:exceptionclass")) { - Printf(f_shadow, "(Exception)"); - } } Printf(f_shadow, ":\n"); @@ -4718,7 +4696,6 @@ public: Clear(builtin_methods); } - classic = oldclassic; modern = oldmodern; /* Restore shadow file back to original version */ @@ -4913,15 +4890,12 @@ public: } Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL); } else { - if (!classic) { - if (!modern) - Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); - Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), - ")\n", NIL); - } - if (classic || !modern) { - if (!classic) - Printv(f_shadow, tab4, "else:\n", tab4, NIL); + if (!modern) + Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); + Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), + ")\n", NIL); + if (!modern) { + Printv(f_shadow, tab4, "else:\n", tab4, NIL); Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); } } @@ -5153,14 +5127,12 @@ public: } Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); } - if (!classic) { - if (!modern) - Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); - Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); - if (assignable) - Printv(f_shadow, ", ", module, ".", setname, NIL); - Printv(f_shadow, ")\n", NIL); - } + if (!modern) + Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); + Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); + if (assignable) + Printv(f_shadow, ", ", module, ".", setname, NIL); + Printv(f_shadow, ")\n", NIL); Delete(mname); Delete(setname); Delete(getname); @@ -5227,7 +5199,7 @@ public: } Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); } - if (!classic && !builtin) { + if (!builtin) { if (!modern) Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); From e4fceee12f6ffda40f4d6b85176c9a3f2b15f818 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 19 May 2018 12:33:07 +1200 Subject: [PATCH 1118/2031] Hard-wire -modern and -modernargs on What SWIG calls "modern" classes are supported by Python 2.3 and up which means they're supported by all the Python versions we aim to support in 4.0.0. Conflicts: Source/Modules/python.cxx This is a cherry-pick and merge from the patch in #1261 --- Examples/test-suite/python_nondynamic.i | 2 - Lib/python/pyuserdir.swg | 3 - Source/Modules/python.cxx | 263 +++++++----------------- 3 files changed, 75 insertions(+), 193 deletions(-) diff --git a/Examples/test-suite/python_nondynamic.i b/Examples/test-suite/python_nondynamic.i index 14c8d6b0e..b08cec9e6 100644 --- a/Examples/test-suite/python_nondynamic.i +++ b/Examples/test-suite/python_nondynamic.i @@ -29,8 +29,6 @@ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 - and works for modern (-modern) and plain python. - */ diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg index af9c86d3c..311076079 100644 --- a/Lib/python/pyuserdir.swg +++ b/Lib/python/pyuserdir.swg @@ -41,9 +41,6 @@ The implementation is based on this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158 -and works for modern (-modern) and plain python. We do not use __slots__, -so, it works with old python versions. - */ #define %pythonnondynamic %feature("python:nondynamic", "1") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index dbc0a98c6..9c1f562da 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -65,7 +65,6 @@ static String *methods; static String *class_name; static String *shadow_indent = 0; static int in_class = 0; -static int modern = 0; static int new_repr = 1; static int no_header_file = 0; static int max_bases = 0; @@ -96,7 +95,6 @@ static int fastproxy = 0; static int fastquery = 0; static int fastinit = 0; static int olddefs = 0; -static int modernargs = 0; static int aliasobj0 = 0; static int castmode = 0; static int extranative = 0; @@ -135,9 +133,7 @@ Python Options (available with -python)\n\ -fastquery - Use fast query mechanism for types \n\ -globals - Set used to access C global variable [default: 'cvar']\n\ -interface - Set the lib name to \n\ - -keyword - Use keyword arguments\n\ - -modern - Use modern python features only, without compatibility code\n\ - -modernargs - Use \"modern\" args mechanism to pack/unpack the function arguments\n"; + -keyword - Use keyword arguments\n"; static const char *usage2 = "\ -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ @@ -152,9 +148,7 @@ static const char *usage2 = "\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions (default) \n\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ -nofastquery - Use traditional query mechanism for types (default) \n\ - -noh - Don't generate the output header file\n\ - -nomodern - Don't use modern python features which are not backwards compatible \n\ - -nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n"; + -noh - Don't generate the output header file\n"; static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -nooutputtuple - Use a PyList for appending output values (default) \n\ @@ -173,8 +167,8 @@ static const char *usage3 = "\ -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ - -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\ - -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ + -fastdispatch -nosafecstrings -fvirtual -noproxydel\n\ + -fastproxy -fastinit -fastunpack -fastquery -nobuildnone\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -390,9 +384,6 @@ public: use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-classic") == 0) { - Printf(stderr, "*** %s is no longer supported.\n", argv[i]); - SWIG_exit(EXIT_FAILURE); } else if (strcmp(argv[i], "-cppcast") == 0) { cppcast = 1; Swig_mark_arg(i); @@ -487,12 +478,6 @@ public: } else if (strcmp(argv[i], "-noextranative") == 0) { extranative = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-modernargs") == 0) { - modernargs = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nomodernargs") == 0) { - modernargs = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-aliasobj0") == 0) { aliasobj0 = 1; Swig_mark_arg(i); @@ -505,14 +490,6 @@ public: } else if (strcmp(argv[i], "-noproxydel") == 0) { proxydel = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-modern") == 0) { - modern = 1; - modernargs = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nomodern") == 0) { - modern = 0; - modernargs = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-noh") == 0) { no_header_file = 1; Swig_mark_arg(i); @@ -522,7 +499,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - modern = 1; safecstrings = 0; buildnone = 0; nobuildnone = 1; @@ -532,7 +508,6 @@ public: fastproxy = 1; fastinit = 1; fastquery = 1; - modernargs = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); @@ -551,6 +526,14 @@ public: } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-modern") == 0 || + strcmp(argv[i], "-modernargs") == 0) { + Printf(stderr, "Option %s is now always on.\n", argv[i]); + } else if (strcmp(argv[i], "-classic") == 0 || + strcmp(argv[i], "-nomodern") == 0 || + strcmp(argv[i], "-nomodernargs") == 0) { + Printf(stderr, "*** %s is no longer supported.\n", argv[i]); + SWIG_exit(EXIT_FAILURE); } } @@ -878,8 +861,6 @@ public: Printf(f_shadow, "_swig_new_instance_method = %s.SWIG_PyInstanceMethod_New\n", module); } - /* if (!modern) */ - /* always needed, a class can be forced to be no-modern, such as an exception */ { // Python-2.2 object hack Printv(f_shadow, @@ -896,13 +877,7 @@ public: tab4, "if not static:\n", #endif NIL); - if (!modern) - Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL); Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL); - if (!modern) - Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL); - if (!modern) - Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL); Printv(f_shadow, tab4, "else:\n", tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n", @@ -919,58 +894,49 @@ public: "\n", "def _swig_repr(self):\n", tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n", tab4, "except __builtin__.Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); - - if (!modern) { - Printv(f_shadow, - "try:\n", - tab4, "_object = object\n", tab4, "_newclass = 1\n", - "except __builtin__.Exception:\n", - tab4, "class _object:\n", tab8, "pass\n", tab4, "_newclass = 0\n\n", NIL); - } } - if (modern) { - Printv(f_shadow, "\n", - "def _swig_setattr_nondynamic_instance_variable(set):\n", - tab4, "def set_instance_attr(self, name, value):\n", + + Printv(f_shadow, "\n", + "def _swig_setattr_nondynamic_instance_variable(set):\n", + tab4, "def set_instance_attr(self, name, value):\n", #ifdef USE_THISOWN - tab4, tab4, "if name in (\"this\", \"thisown\"):\n", - tab4, tab4, tab4, "set(self, name, value)\n", + tab4, tab4, "if name in (\"this\", \"thisown\"):\n", + tab4, tab4, tab4, "set(self, name, value)\n", #else - tab4, tab4, "if name == \"thisown\":\n", - tab4, tab4, tab4, "self.this.own(value)\n", - tab4, tab4, "elif name == \"this\":\n", - tab4, tab4, tab4, "set(self, name, value)\n", + tab4, tab4, "if name == \"thisown\":\n", + tab4, tab4, tab4, "self.this.own(value)\n", + tab4, tab4, "elif name == \"this\":\n", + tab4, tab4, tab4, "set(self, name, value)\n", #endif - tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n", - tab4, tab4, tab4, "set(self, name, value)\n", - tab4, tab4, "else:\n", - tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n", - tab4, "return set_instance_attr\n\n", NIL); + tab4, tab4, "elif hasattr(self, name) and isinstance(getattr(type(self), name), property):\n", + tab4, tab4, tab4, "set(self, name, value)\n", + tab4, tab4, "else:\n", + tab4, tab4, tab4, "raise AttributeError(\"You cannot add instance attributes to %s\" % self)\n", + tab4, "return set_instance_attr\n\n", NIL); - Printv(f_shadow, "\n", - "def _swig_setattr_nondynamic_class_variable(set):\n", - tab4, "def set_class_attr(cls, name, value):\n", - tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n", - tab4, tab4, tab4, "set(cls, name, value)\n", - tab4, tab4, "else:\n", - tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n", - tab4, "return set_class_attr\n\n", NIL); + Printv(f_shadow, "\n", + "def _swig_setattr_nondynamic_class_variable(set):\n", + tab4, "def set_class_attr(cls, name, value):\n", + tab4, tab4, "if hasattr(cls, name) and not isinstance(getattr(cls, name), property):\n", + tab4, tab4, tab4, "set(cls, name, value)\n", + tab4, tab4, "else:\n", + tab4, tab4, tab4, "raise AttributeError(\"You cannot add class attributes to %s\" % cls)\n", + tab4, "return set_class_attr\n\n", NIL); - Printv(f_shadow, "\n", - "def _swig_add_metaclass(metaclass):\n", - tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n", - tab4, "def wrapper(cls):\n", - tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n", - tab4, "return wrapper\n\n", NIL); + Printv(f_shadow, "\n", + "def _swig_add_metaclass(metaclass):\n", + tab4, "\"\"\"Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass\"\"\"\n", + tab4, "def wrapper(cls):\n", + tab4, tab4, "return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())\n", + tab4, "return wrapper\n\n", NIL); - Printv(f_shadow, "\n", - "class _SwigNonDynamicMeta(type):\n", - tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n", - tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n", - "\n", NIL); + Printv(f_shadow, "\n", + "class _SwigNonDynamicMeta(type):\n", + tab4, "\"\"\"Meta class to enforce nondynamic attributes (no new attributes) for a class\"\"\"\n", + tab4, "__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)\n", + "\n", NIL); - Printv(f_shadow, "\n", NIL); - } + Printv(f_shadow, "\n", NIL); if (directorsEnabled()) { Printv(f_shadow, "import weakref\n\n", NIL); @@ -1040,9 +1006,6 @@ public: if (shadow) { Swig_banner_target_lang(f_shadow_py, "#"); - if (!modern) { - Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); - } if (Len(f_shadow_begin) > 0) Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); if (Len(f_shadow_after_begin) > 0) @@ -2843,7 +2806,7 @@ public: over_varargs = true; } - int funpack = modernargs && fastunpack && !varargs && !over_varargs && !allow_kwargs; + int funpack = fastunpack && !varargs && !over_varargs && !allow_kwargs; int noargs = funpack && (tuple_required == 0 && tuple_arguments == 0); int onearg = funpack && (tuple_required == 1 && tuple_arguments == 1); @@ -2990,7 +2953,7 @@ public: if (builtin && !funpack && in_class && tuple_arguments == 0) { Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname); - } else if (use_parse || allow_kwargs || !modernargs) { + } else if (use_parse || allow_kwargs) { Printf(parse_args, ":%s\"", iname); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); funpack = 0; @@ -3660,14 +3623,10 @@ public: Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname); Printf(f_wrappers, tab2 "PyObject *module;\n", tm); Printf(f_wrappers, tab2 "PyObject *d;\n"); - if (modernargs) { - if (fastunpack) { - Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); - } else { - Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); - } + if (fastunpack) { + Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); } else { - Printf(f_wrappers, tab2 "if (!PyArg_ParseTuple(args,(char *)\"O:swigconstant\", &module)) return NULL;\n"); + Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); } Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n"); Printf(f_wrappers, tab2 "if (!d) return NULL;\n"); @@ -4003,7 +3962,7 @@ public: String *mname = SwigType_manglestr(rname); String *pmname = SwigType_manglestr(pname); String *templ = NewStringf("SwigPyBuiltin_%s", mname); - int funpack = modernargs && fastunpack; + int funpack = fastunpack; static String *tp_new = NewString("PyType_GenericNew"); Printv(f_init, " SwigPyBuiltin_SetMetaType(builtin_pytype, metatype);\n", NIL); @@ -4416,7 +4375,6 @@ public: } virtual int classHandler(Node *n) { - int oldmodern = modern; File *f_shadow_file = f_shadow; Node *base_node = NULL; @@ -4426,16 +4384,6 @@ public: have_constructor = 0; have_repr = 0; - if (GetFlag(n, "feature:classic")) { - modern = 0; - } - if (GetFlag(n, "feature:modern")) { - modern = 1; - } - if (GetFlag(n, "feature:exceptionclass")) { - modern = 0; - } - class_name = Getattr(n, "sym:name"); real_classname = Getattr(n, "name"); @@ -4511,7 +4459,7 @@ public: Delete(rname); } } else { - if (modern && !py3) { + if (!py3) { if (GetFlag(n, "feature:python:nondynamic")) Printv(f_shadow, "@_swig_add_metaclass(_SwigNonDynamicMeta)\n", NIL); } @@ -4523,8 +4471,8 @@ public: if (GetFlag(n, "feature:exceptionclass")) { Printf(f_shadow, "(Exception)"); } else { - Printf(f_shadow, modern ? "(object" : "(_object"); - Printf(f_shadow, modern && py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")"); + Printf(f_shadow, "(object"); + Printf(f_shadow, py3 && GetFlag(n, "feature:python:nondynamic") ? ", metaclass=_SwigNonDynamicMeta" : "", ")"); Printf(f_shadow, ")"); } } @@ -4538,30 +4486,10 @@ public: Printv(f_shadow, tab4, str, "\n\n", NIL); } - if (!modern) { - Printv(f_shadow, tab4, "__swig_setmethods__ = {}\n", NIL); - if (Len(base_class)) { - Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_setmethods__.update(getattr(_s, '__swig_setmethods__', {}))\n", NIL); - } - - if (!GetFlag(n, "feature:python:nondynamic")) { - Printv(f_shadow, tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n", NIL); - } else { - Printv(f_shadow, tab4, "__setattr__ = lambda self, name, value: _swig_setattr_nondynamic(self, ", class_name, ", name, value)\n", NIL); - } - - Printv(f_shadow, tab4, "__swig_getmethods__ = {}\n", NIL); - if (Len(base_class)) { - Printv(f_shadow, tab4, "for _s in [", base_class, "]:\n", tab8, "__swig_getmethods__.update(getattr(_s, '__swig_getmethods__', {}))\n", NIL); - } - - Printv(f_shadow, tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n", NIL); - } else { - Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); - /* Add static attribute */ - if (GetFlag(n, "feature:python:nondynamic")) { - Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", NIL); - } + Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); + /* Add static attribute */ + if (GetFlag(n, "feature:python:nondynamic")) { + Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", NIL); } } } @@ -4612,14 +4540,10 @@ public: } else { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, " 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); - } else { - Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char *)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); - } + if (fastunpack) { + Printv(f_wrappers, " if (!SWIG_Python_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, " if (!PyArg_UnpackTuple(args,(char *)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } Printv(f_wrappers, @@ -4669,15 +4593,10 @@ public: /* Now the Ptr class */ if (classptr) { Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); - if (!modern) { - Printv(f_shadow_file, - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); - } else { - Printv(f_shadow_file, - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); - } + Printv(f_shadow_file, + tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", + tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); + } Printf(f_shadow_file, "\n"); @@ -4696,8 +4615,6 @@ public: Clear(builtin_methods); } - modern = oldmodern; - /* Restore shadow file back to original version */ Delete(f_shadow); f_shadow = f_shadow_file; @@ -4844,7 +4761,7 @@ public: String *fullname = Swig_name_member(NSPACE_TODO, class_name, symname); String *wname = Swig_name_wrapper(fullname); Setattr(class_members, symname, n); - int funpack = modernargs && fastunpack && !Getattr(n, "sym:overloaded"); + int funpack = fastunpack && !Getattr(n, "sym:overloaded"); String *pyflags = NewString("METH_STATIC|"); int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; if (funpack && argcount == 0) @@ -4890,14 +4807,8 @@ public: } Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL); } else { - if (!modern) - Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); - if (!modern) { - Printv(f_shadow, tab4, "else:\n", tab4, NIL); - Printv(f_shadow, tab4, symname, " = ", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), "\n", NIL); - } } } return SWIG_OK; @@ -5121,14 +5032,6 @@ public: String *setname = Swig_name_set(NSPACE_TODO, mname); String *getname = Swig_name_get(NSPACE_TODO, mname); int assignable = is_assignable(n); - if (!modern) { - if (assignable) { - Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", setname, "\n", NIL); - } - Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); - } - if (!modern) - Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); @@ -5178,7 +5081,7 @@ public: DelWrapper(f); int assignable = is_assignable(n); if (assignable) { - int funpack = modernargs && fastunpack; + int funpack = fastunpack; Wrapper *f = NewWrapper(); Printv(f->def, "SWIGINTERN PyObject *", wrapsetname, "(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {", NIL); Wrapper_add_local(f, "res", "int res"); @@ -5193,15 +5096,7 @@ public: add_method(setname, wrapsetname, 0, 0, funpack, 1, 1); DelWrapper(f); } - if (!modern && !builtin) { - if (assignable) { - Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", setname, "\n", NIL); - } - Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", getname, "\n", NIL); - } if (!builtin) { - if (!modern) - Printv(f_shadow, tab4, "if _newclass:\n", tab4, NIL); Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); @@ -5652,34 +5547,26 @@ 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) { + if (use_parse) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", Swig_cresult_name(), parse_args, arglist); } else { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunctionObjArgs(method %s, NULL);\n", Swig_cresult_name(), arglist); } } else { - if (modernargs) { - Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); - Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject *) args, NULL);\n", Swig_cresult_name()); - } else { - Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallFunction(method, NULL, NULL);\n", Swig_cresult_name()); - } + Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_Call(method, (PyObject *) args, NULL);\n", Swig_cresult_name()); } Append(w->code, "#else\n"); if (Len(parse_args) > 0) { - if (use_parse || !modernargs) { + if (use_parse) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), 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 %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), arglist); } } else { - if (!modernargs) { - Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", Swig_cresult_name(), pyname); - } else { - Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name()); - } + Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); + Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name()); } Append(w->code, "#endif\n"); From 4a48e59dc6b657f300b952f30ba4fc7c34dd91b6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 19 May 2018 16:05:10 +1200 Subject: [PATCH 1119/2031] Hard-wire -noproxydel on We only still default to generate a no-op __del__ method for theoretical compatibility with old code, and 4.0.0 is a good time to make a cut-off should such code really still exist. On the flip-side, the presence of a __del__ method seems to be able to prevent garbage collection from kicking in (see #1215), so it's definitely desirable to get rid of it when there's nothing for it to do. Conflicts: Source/Modules/python.cxx This is a cherry-pick and merge from the patch in #1261 --- Source/Modules/python.cxx | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9c1f562da..e5b58be75 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -89,7 +89,6 @@ static int nobuildnone = 0; static int safecstrings = 0; static int dirvtable = 0; static int doxygen = 0; -static int proxydel = 1; static int fastunpack = 0; static int fastproxy = 0; static int fastquery = 0; @@ -153,7 +152,6 @@ static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -nooutputtuple - Use a PyList for appending output values (default) \n\ -noproxy - Don't generate proxy classes \n\ - -noproxydel - Don't generate the redundant __del__ method \n\ -noproxyimport - Don't insert proxy import statements derived from the %import directive \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nosafecstrings - Avoid extra strings copies when possible (default)\n\ @@ -161,13 +159,12 @@ static const char *usage3 = "\ -olddefs - Keep the old method definitions even when using fastproxy\n\ -oldrepr - Use shorter and old version of __repr__ in proxy classes\n\ -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ - -proxydel - Generate a __del__ method even though it is now redundant (default) \n\ -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ - -fastdispatch -nosafecstrings -fvirtual -noproxydel\n\ + -fastdispatch -nosafecstrings -fvirtual\n\ -fastproxy -fastinit -fastunpack -fastquery -nobuildnone\n\ \n"; @@ -483,13 +480,6 @@ public: Swig_mark_arg(i); } else if (strcmp(argv[i], "-noaliasobj0") == 0) { aliasobj0 = 0; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-proxydel") == 0) { - proxydel = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-noproxydel") == 0) { - proxydel = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-noh") == 0) { no_header_file = 1; Swig_mark_arg(i); @@ -503,7 +493,6 @@ public: buildnone = 0; nobuildnone = 1; classptr = 0; - proxydel = 0; fastunpack = 1; fastproxy = 1; fastinit = 1; @@ -527,11 +516,13 @@ public: relativeimport = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0 || - strcmp(argv[i], "-modernargs") == 0) { + strcmp(argv[i], "-modernargs") == 0 || + strcmp(argv[i], "-noproxydel") == 0) { Printf(stderr, "Option %s is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-nomodern") == 0 || - strcmp(argv[i], "-nomodernargs") == 0) { + strcmp(argv[i], "-nomodernargs") == 0 || + strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "*** %s is no longer supported.\n", argv[i]); SWIG_exit(EXIT_FAILURE); } @@ -4989,9 +4980,6 @@ public: } else { Printv(f_shadow, tab4, "__swig_destroy__ = ", module, ".", Swig_name_destroy(NSPACE_TODO, symname), "\n", NIL); if (!have_pythonprepend(n) && !have_pythonappend(n)) { - if (proxydel) { - Printv(f_shadow, tab4, "def __del__(self):\n", tab8, "return None\n", NIL); - } return SWIG_OK; } Printv(f_shadow, tab4, "def __del__(self):\n", NIL); From fe155d75167cbfa67082b7554acf56d134ad64dc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Oct 2018 18:33:19 +0100 Subject: [PATCH 1120/2031] Disable Javascript Node 10 testing Upgrade from v10.11.0 to v10.12.0 on Travis started breaking the builds --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 29c3129d6..7f622bc85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -362,6 +362,12 @@ matrix: env: SWIGLANG=tcl allow_failures: + # Deprecated functions causing build failure since upgrade from Node v10.11.0 to v10.12.0 + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 + sudo: required + dist: trusty # Lots of failing tests currently - compiler: gcc os: linux From c97a455c34b2db473d10e83e6e052b24687d554f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Wed, 17 Oct 2018 13:00:04 +0200 Subject: [PATCH 1121/2031] Documentation refers to wrong chapter. Chapter 10, first section, refers to Chapter 3 (Getting started on Windows) but should presumably be Chapter 5 (SWIG Basics). --- Doc/Manual/Arguments.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index 54c226f70..fbdce7f27 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -32,7 +32,7 @@

      -In Chapter 3, SWIG's treatment of basic datatypes and pointers was +In Chapter 5, SWIG's treatment of basic datatypes and pointers was described. In particular, primitive types such as int and double are mapped to corresponding types in the target language. For everything else, pointers are used to refer to From 7d6bb6cd44114f6af235259e8bb445416fcf3c70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Oct 2018 07:32:38 +0100 Subject: [PATCH 1122/2031] Add missing run of the functors testcase --- Examples/test-suite/common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index f4c871328..3b46354b9 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -246,6 +246,7 @@ CPP_TEST_CASES += \ friends \ friends_template \ funcptr_cpp \ + functors \ fvirtual \ global_namespace \ global_ns_arg \ From 350396fcaecee6dd8d976742894b7729e1547a97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Oct 2018 08:12:45 +0100 Subject: [PATCH 1123/2031] Hardwire Python -fastinit option to be always on This option runs the equivalent init code in Python C code instead of pure Python code. The init code adds the C++ pointer into the 'this' variable. If the variable already exists, it appends it. This seems to only happen in directors and multiple inheritance, see PyMulti in director_basic_runme.py. --- Source/Modules/python.cxx | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e5b58be75..9e44363c3 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -92,7 +92,6 @@ static int doxygen = 0; static int fastunpack = 0; static int fastproxy = 0; static int fastquery = 0; -static int fastinit = 0; static int olddefs = 0; static int aliasobj0 = 0; static int castmode = 0; @@ -126,7 +125,6 @@ Python Options (available with -python)\n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ - -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ -fastproxy - Use fast proxy mechanism for member methods \n\ -fastquery - Use fast query mechanism for types \n\ @@ -143,7 +141,6 @@ static const char *usage2 = "\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ - -nofastinit - Use traditional init mechanism for classes \n\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions (default) \n\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ -nofastquery - Use traditional query mechanism for types (default) \n\ @@ -165,7 +162,7 @@ static const char *usage3 = "\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ -fastdispatch -nosafecstrings -fvirtual\n\ - -fastproxy -fastinit -fastunpack -fastquery -nobuildnone\n\ + -fastproxy -fastunpack -fastquery -nobuildnone\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -451,12 +448,6 @@ public: } else if (strcmp(argv[i], "-nofastquery") == 0) { fastquery = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-fastinit") == 0) { - fastinit = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nofastinit") == 0) { - fastinit = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-olddefs") == 0) { olddefs = 1; Swig_mark_arg(i); @@ -495,7 +486,6 @@ public: classptr = 0; fastunpack = 1; fastproxy = 1; - fastinit = 1; fastquery = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); @@ -515,11 +505,13 @@ public: } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-modern") == 0 || + } else if (strcmp(argv[i], "-fastinit") == 0 || + strcmp(argv[i], "-modern") == 0 || strcmp(argv[i], "-modernargs") == 0 || strcmp(argv[i], "-noproxydel") == 0) { Printf(stderr, "Option %s is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-classic") == 0 || + strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-proxydel") == 0) { @@ -4550,7 +4542,7 @@ public: if (!builtin) Printv(f_shadow_file, "\n", tab4, "def __init__(self, *args, **kwargs):\n", tab8, "raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\")\n", NIL); - } else if (fastinit && !builtin) { + } else if (!builtin) { 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); @@ -4892,13 +4884,7 @@ public: if (have_pythonprepend(n)) Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); Printv(f_shadow, pass_self, NIL); - if (fastinit) { - Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); - } else { - Printv(f_shadow, - tab8, "this = ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), "\n", - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", NIL); - } + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); if (have_pythonappend(n)) Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n\n", NIL); Delete(pass_self); From d84d26832f4f8cdaa4f14cf0f93126afb11363ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Oct 2018 19:11:02 +0100 Subject: [PATCH 1124/2031] Hardwire Python -fastquery option to be always on The Python dictionary cache used for SWIG types lookup is now always on. --- Source/Modules/python.cxx | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9e44363c3..00a27e089 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -91,7 +91,6 @@ static int dirvtable = 0; static int doxygen = 0; static int fastunpack = 0; static int fastproxy = 0; -static int fastquery = 0; static int olddefs = 0; static int aliasobj0 = 0; static int castmode = 0; @@ -127,7 +126,6 @@ Python Options (available with -python)\n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ -fastproxy - Use fast proxy mechanism for member methods \n\ - -fastquery - Use fast query mechanism for types \n\ -globals - Set used to access C global variable [default: 'cvar']\n\ -interface - Set the lib name to \n\ -keyword - Use keyword arguments\n"; @@ -143,7 +141,6 @@ static const char *usage2 = "\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions (default) \n\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ - -nofastquery - Use traditional query mechanism for types (default) \n\ -noh - Don't generate the output header file\n"; static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ @@ -162,7 +159,7 @@ static const char *usage3 = "\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ -fastdispatch -nosafecstrings -fvirtual\n\ - -fastproxy -fastunpack -fastquery -nobuildnone\n\ + -fastproxy -fastunpack -nobuildnone\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -442,12 +439,6 @@ public: } else if (strcmp(argv[i], "-nofastproxy") == 0) { fastproxy = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-fastquery") == 0) { - fastquery = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nofastquery") == 0) { - fastquery = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-olddefs") == 0) { olddefs = 1; Swig_mark_arg(i); @@ -486,7 +477,6 @@ public: classptr = 0; fastunpack = 1; fastproxy = 1; - fastquery = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); Swig_mark_arg(i); @@ -506,16 +496,18 @@ public: relativeimport = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastinit") == 0 || + strcmp(argv[i], "-fastquery") == 0 || strcmp(argv[i], "-modern") == 0 || strcmp(argv[i], "-modernargs") == 0 || strcmp(argv[i], "-noproxydel") == 0) { - Printf(stderr, "Option %s is now always on.\n", argv[i]); + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-nofastinit") == 0 || + strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-proxydel") == 0) { - Printf(stderr, "*** %s is no longer supported.\n", argv[i]); + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); SWIG_exit(EXIT_FAILURE); } @@ -706,12 +698,10 @@ public: Printf(f_runtime, "\n"); - if (fastquery) { - Printf(f_header, "#ifdef SWIG_TypeQuery\n"); - Printf(f_header, "# undef SWIG_TypeQuery\n"); - Printf(f_header, "#endif\n"); - Printf(f_header, "#define SWIG_TypeQuery SWIG_Python_TypeQuery\n"); - } + Printf(f_header, "#ifdef SWIG_TypeQuery\n"); + Printf(f_header, "# undef SWIG_TypeQuery\n"); + Printf(f_header, "#endif\n"); + Printf(f_header, "#define SWIG_TypeQuery SWIG_Python_TypeQuery\n"); /* Set module name */ From b2aa01f492846d8b835f51beb89df569fa6c504b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Oct 2018 21:53:03 +0100 Subject: [PATCH 1125/2031] Python options simplification: Remove -buildnone, -nobuildnone A custom implementation for Py_None was implemented in SWIG_Py_None(). This was used by default on Windows only. It isn't clear why this was done just for Windows. Now Py_None is the real Py_None on all operating systems. --- Lib/python/pyinit.swg | 3 --- Lib/python/pyrun.swg | 27 --------------------------- Source/Modules/python.cxx | 28 ++++------------------------ 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 4e13ed57a..d4985ee78 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -380,9 +380,6 @@ SWIG_init(void) { #endif /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ -#ifdef SWIG_PYTHON_BUILD_NONE - SWIG_Py_None(); -#endif SWIG_This(); SWIG_Python_TypeCache(); SwigPyPacked_type(); diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 53c3a32d1..9850a7c27 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -237,33 +237,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi extern "C" { #endif -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif - -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *none = NULL; - if (!none) { - none = Py_BuildValue(""); - Py_DECREF(none); - } - return none; -} -#endif - /* The python void return value */ SWIGRUNTIMEINLINE PyObject * diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 00a27e089..131ebbc75 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -84,8 +84,6 @@ static int nothreads = 0; static int classptr = 0; /* Other options */ static int shadowimport = 1; -static int buildnone = 0; -static int nobuildnone = 0; static int safecstrings = 0; static int dirvtable = 0; static int doxygen = 0; @@ -114,7 +112,6 @@ enum autodoc_t { static const char *usage1 = "\ Python Options (available with -python)\n\ -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ - -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ @@ -133,7 +130,6 @@ static const char *usage2 = "\ -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\ - -nobuildnone - Access Py_None directly (default in non-Windows systems)\n\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ @@ -159,7 +155,7 @@ static const char *usage3 = "\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ -fastdispatch -nosafecstrings -fvirtual\n\ - -fastproxy -fastunpack -nobuildnone\n\ + -fastproxy -fastunpack\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -403,14 +399,6 @@ public: } else if (strcmp(argv[i], "-nosafecstrings") == 0) { safecstrings = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-buildnone") == 0) { - buildnone = 1; - nobuildnone = 0; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nobuildnone") == 0) { - buildnone = 0; - nobuildnone = 1; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); @@ -472,8 +460,6 @@ public: Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { safecstrings = 0; - buildnone = 0; - nobuildnone = 1; classptr = 0; fastunpack = 1; fastproxy = 1; @@ -501,9 +487,11 @@ public: strcmp(argv[i], "-modernargs") == 0 || strcmp(argv[i], "-noproxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - } else if (strcmp(argv[i], "-classic") == 0 || + } else if (strcmp(argv[i], "-buildnone") == 0 || + strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || + strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-proxydel") == 0) { @@ -661,14 +649,6 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_SAFE_CSTRINGS\n"); } - if (buildnone) { - Printf(f_runtime, "#define SWIG_PYTHON_BUILD_NONE\n"); - } - - if (nobuildnone) { - Printf(f_runtime, "#define SWIG_PYTHON_NO_BUILD_NONE\n"); - } - if (!dirvtable) { Printf(f_runtime, "#define SWIG_PYTHON_DIRECTOR_NO_VTABLE\n"); } From de26ebbad17c37f4ad8156cd756b5fa0f9eb5438 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Oct 2018 11:03:19 +0100 Subject: [PATCH 1126/2031] Remove Python -safecstrings option. This option, if used, has not had any effect on Python 3 code since commit a863d3 9 years ago. I think we can assume that it is not needed for Python 3. Running the examples and test-suite (Python 2) doesn't change the code paths with and without -safecstrings because only SWIG_OLDOBJ and SWIG_NEWOBJ are used in the typemaps and the following code is thus unaltered by -safecstrings (which sets SWIG_PYTHON_SAFE_CSTRINGS): %#if defined(SWIG_PYTHON_SAFE_CSTRINGS) if (*alloc != SWIG_OLDOBJ) %#else if (*alloc == SWIG_NEWOBJ) %#endif { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; printf("safe strings: %s\n", *cptr ? *cptr : "NULLSTRING"); } else { *cptr = cstr; *alloc = SWIG_OLDOBJ; } Note: nosafecstrings was also the default and -O didn't actually change this. --- Lib/python/pystrings.swg | 16 +--------------- Source/Modules/python.cxx | 21 ++++----------------- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index ac87d07ab..93f48acfa 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -38,21 +38,7 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) %#endif if (cptr) { if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. - - The default behavior is just to return the pointer value, - so, be careful. - */ -%#if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) -%#else - if (*alloc == SWIG_NEWOBJ) -%#endif - { + if (*alloc == SWIG_NEWOBJ) { *cptr = %new_copy_array(cstr, len + 1, char); *alloc = SWIG_NEWOBJ; } else { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 131ebbc75..cd993d6fd 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -84,7 +84,6 @@ static int nothreads = 0; static int classptr = 0; /* Other options */ static int shadowimport = 1; -static int safecstrings = 0; static int dirvtable = 0; static int doxygen = 0; static int fastunpack = 0; @@ -144,18 +143,15 @@ static const char *usage3 = "\ -noproxy - Don't generate proxy classes \n\ -noproxyimport - Don't insert proxy import statements derived from the %import directive \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ - -nosafecstrings - Avoid extra strings copies when possible (default)\n\ -nothreads - Disable thread support for the entire interface\n\ -olddefs - Keep the old method definitions even when using fastproxy\n\ -oldrepr - Use shorter and old version of __repr__ in proxy classes\n\ -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ - -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ - -fastdispatch -nosafecstrings -fvirtual\n\ - -fastproxy -fastunpack\n\ + -fastdispatch -fastproxy -fastunpack -fvirtual\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -393,12 +389,6 @@ public: /* Turn off thread support mode */ nothreads = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-safecstrings") == 0) { - safecstrings = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nosafecstrings") == 0) { - safecstrings = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); @@ -459,7 +449,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - safecstrings = 0; classptr = 0; fastunpack = 1; fastproxy = 1; @@ -485,7 +474,8 @@ public: strcmp(argv[i], "-fastquery") == 0 || strcmp(argv[i], "-modern") == 0 || strcmp(argv[i], "-modernargs") == 0 || - strcmp(argv[i], "-noproxydel") == 0) { + strcmp(argv[i], "-noproxydel") == 0 || + strcmp(argv[i], "-safecstrings") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-classic") == 0 || @@ -494,6 +484,7 @@ public: strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || + strcmp(argv[i], "-nosafecstrings") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); SWIG_exit(EXIT_FAILURE); @@ -645,10 +636,6 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_THREADS\n"); } - if (safecstrings) { - Printf(f_runtime, "#define SWIG_PYTHON_SAFE_CSTRINGS\n"); - } - if (!dirvtable) { Printf(f_runtime, "#define SWIG_PYTHON_DIRECTOR_NO_VTABLE\n"); } From 18f433d8620247c12cee5413b02cc96c2697774d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Oct 2018 08:19:17 +0100 Subject: [PATCH 1127/2031] Tcl swig_const_info - use const char * --- Lib/tcl/tclapi.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/tcl/tclapi.swg b/Lib/tcl/tclapi.swg index 33dc324d4..2187de52e 100644 --- a/Lib/tcl/tclapi.swg +++ b/Lib/tcl/tclapi.swg @@ -16,7 +16,7 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { int type; - char *name; + const char *name; long lvalue; double dvalue; void *pvalue; From a1f40568d689bb722b7e72da4d40db5ab97bad39 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Oct 2018 08:20:13 +0100 Subject: [PATCH 1128/2031] Remove non-const char * usage where the Python API now supports it Python fixed many APIs to use const char * instead of char * at around Python 2.4. As we support 2.7 and later, we can now remove the non-const string usage. Types changed: PyArg_ParseTuple PyArg_ParseTupleAndKeywords PyArg_UnpackTuple PyDict_SetItemString PyMethodDef PyModuleDef SWIG_Python_UnpackTuple SWIG_Python_str_FromChar SWIG_addvarlink swig_const_info --- Lib/python/defarg.swg | 2 +- Lib/python/pyapi.swg | 2 +- Lib/python/pyinit.swg | 8 +++---- Lib/python/pyrun.swg | 33 +++++++++++++--------------- Lib/python/pytypemaps.swg | 2 +- Source/Modules/python.cxx | 46 +++++++++++++++++++-------------------- 6 files changed, 45 insertions(+), 48 deletions(-) diff --git a/Lib/python/defarg.swg b/Lib/python/defarg.swg index 10c991615..59450bd82 100644 --- a/Lib/python/defarg.swg +++ b/Lib/python/defarg.swg @@ -24,7 +24,7 @@ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) { PyObject *func; PyObject *parms; - if (!PyArg_ParseTuple(args,"OO",&func,&parms)) + if (!PyArg_ParseTuple(args, "OO", &func, &parms)) return NULL; if (!PyCallable_Check(func)) { diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index 700f55d43..89f57fc83 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -17,7 +17,7 @@ extern "C" { /* Constant information structure */ typedef struct swig_const_info { int type; - char *name; + const char *name; long lvalue; double dvalue; void *pvalue; diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index d4985ee78..621d6f9ed 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -151,7 +151,7 @@ swig_varlink_type(void) { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ #endif - (char *)"swigvarlink", /* tp_name */ + "swigvarlink", /* tp_name */ sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ @@ -208,7 +208,7 @@ SWIG_Python_newvarlink(void) { } SWIGINTERN void -SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { +SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { swig_varlinkobject *v = (swig_varlinkobject *) p; swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); if (gv) { @@ -330,7 +330,7 @@ SWIG_init(void) { #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, - (char *) SWIG_name, + SWIG_name, NULL, -1, SwigMethods, @@ -393,7 +393,7 @@ SWIG_init(void) { #if PY_VERSION_HEX >= 0x03000000 m = PyModule_Create(&SWIG_module); #else - m = Py_InitModule((char *) SWIG_name, SwigMethods); + m = Py_InitModule(SWIG_name, SwigMethods); #endif md = d = PyModule_GetDict(m); diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 9850a7c27..2e1ddddbc 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -208,7 +208,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } /* A functor is a function object with one single object argument */ -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char*)"O", obj); +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char *)"O", obj); /* Helper for static pointer initialization for both C and C++ code, for example @@ -582,23 +582,20 @@ SWIGINTERN PyObject* SwigPyObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; - if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) - { - return NULL; + if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) { + return NULL; + } else { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } - } - return obj; - } + return obj; + } } static PyMethodDef @@ -805,7 +802,7 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) size_t i = v->size; size_t j = w->size; int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); + return s ? s : strncmp((const char *)v->pack, (const char *)w->pack, 2*v->size); } SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg index 48b0bcdc8..0eda17cda 100644 --- a/Lib/python/pytypemaps.swg +++ b/Lib/python/pytypemaps.swg @@ -80,7 +80,7 @@ /* Consttab, needed for callbacks, it should be removed later */ %typemap(consttab) SWIGTYPE ((*)(ANY)) -{ SWIG_PY_POINTER, (char*)"$symname", 0, 0, (void *)($value), &$descriptor } +{ SWIG_PY_POINTER, "$symname", 0, 0, (void *)($value), &$descriptor } %typemap(consttab) SWIGTYPE ((* const)(ANY)) = SWIGTYPE ((*)(ANY)); %typemap(constcode) SWIGTYPE ((*)(ANY)) ""; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index cd993d6fd..541115773 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2437,10 +2437,10 @@ public: Append(methods, "NULL"); } else if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_FUNC); - Printf(methods, "(char *)\"%s\"", ds); + Printf(methods, "\"%s\"", ds); Delete(ds); } else if (Getattr(n, "feature:callback")) { - Printf(methods, "(char *)\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); + Printf(methods, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); } else { Append(methods, "NULL"); } @@ -2512,7 +2512,7 @@ public: Append(f->code, "argc++;\n"); } else { String *iname = Getattr(n, "sym:name"); - Printf(f->code, "if (!(argc = SWIG_Python_UnpackTuple(args,\"%s\",0,%d,argv%s))) SWIG_fail;\n", iname, maxargs, add_self ? "+1" : ""); + Printf(f->code, "if (!(argc = SWIG_Python_UnpackTuple(args, \"%s\", 0, %d, argv%s))) SWIG_fail;\n", iname, maxargs, add_self ? "+1" : ""); if (add_self) Append(f->code, "argv[0] = self;\n"); else @@ -2722,10 +2722,10 @@ public: } if (!builtin || !in_class || tuple_arguments > 0) { if (!allow_kwargs) { - Append(parse_args, " if (!PyArg_ParseTuple(args,(char *)\""); + Append(parse_args, " if (!PyArg_ParseTuple(args, \""); } else { - Append(parse_args, " if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)\""); - Append(arglist, ",kwnames"); + Append(parse_args, " if (!PyArg_ParseTupleAndKeywords(args, kwargs, \""); + Append(arglist, ", kwnames"); } } @@ -2815,7 +2815,7 @@ public: sprintf(source, "obj%d", builtin_ctor ? i + 1 : i); if (parse_from_tuple) { - Putc(',', arglist); + Printf(arglist, ", "); if (i == num_required) Putc('|', parse_args); /* Optional argument separator */ } @@ -2823,7 +2823,7 @@ public: /* Keyword argument handling */ if (allow_kwargs && parse_from_tuple) { String *name = makeParameterName(n, p, i + 1); - Printf(kwargs, "(char *) \"%s\",", name); + Printf(kwargs, " (char *)\"%s\", ", name); Delete(name); } @@ -2888,7 +2888,7 @@ public: /* finish argument marshalling */ Append(kwargs, " NULL }"); if (allow_kwargs) { - Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); + Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); } if (builtin && !funpack && in_class && tuple_arguments == 0) { @@ -2915,13 +2915,13 @@ public: Printf(parse_args, "if (!args) SWIG_fail;\n"); Append(parse_args, "swig_obj[0] = args;\n"); } else if (!noargs) { - Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,swig_obj)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); + Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args, \"%s\", %d, %d, swig_obj)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); } else if (noargs) { - Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args,\"%s\",%d,%d,0)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); + Printf(parse_args, "if (!SWIG_Python_UnpackTuple(args, \"%s\", %d, %d, 0)) SWIG_fail;\n", iname, num_fixed_arguments, tuple_arguments); } } } else { - Printf(parse_args, "if (!PyArg_UnpackTuple(args,(char *)\"%s\",%d,%d", iname, num_fixed_arguments, tuple_arguments); + Printf(parse_args, "if (!PyArg_UnpackTuple(args, \"%s\", %d, %d", iname, num_fixed_arguments, tuple_arguments); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); } } @@ -3381,7 +3381,7 @@ public: Python dictionary. */ if (!have_globals) { - Printf(f_init, "\t PyDict_SetItemString(md,(char *)\"%s\", SWIG_globals());\n", global_name); + Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", SWIG_globals());\n", global_name); if (builtin) Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name); have_globals = 1; @@ -3469,9 +3469,9 @@ public: Wrapper_print(getf, f_wrappers); /* Now add this to the variable linking mechanism */ - Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(),(char *)\"%s\",%s, %s);\n", iname, vargetname, varsetname); + Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(), \"%s\", %s, %s);\n", iname, vargetname, varsetname); if (builtin && shadow && !assignable && !in_class) { - Printf(f_init, "\t PyDict_SetItemString(md, (char *)\"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname); + Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname); Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", iname); } Delete(vargetname); @@ -3564,9 +3564,9 @@ public: Printf(f_wrappers, tab2 "PyObject *module;\n", tm); Printf(f_wrappers, tab2 "PyObject *d;\n"); if (fastunpack) { - Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); + Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); } else { - Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char *)\"swigconstant\", 1, 1,&module)) return NULL;\n"); + Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); } Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n"); Printf(f_wrappers, tab2 "if (!d) return NULL;\n"); @@ -3969,7 +3969,7 @@ public: String *gspair = NewStringf("%s_%s_getset", symname, memname); Printf(f, "static SwigPyGetSet %s = { %s, %s };\n", gspair, getter ? getter : "0", setter ? setter : "0"); String *entry = - NewStringf("{ (char *) \"%s\", (getter) %s, (setter) %s, (char *)\"%s.%s\", (void *) &%s }\n", memname, getter_closure, + NewStringf("{ (char *)\"%s\", (getter)%s, (setter)%s, (char *)\"%s.%s\", (void *)&%s }\n", memname, getter_closure, setter_closure, name, memname, gspair); if (GetFlag(mgetset, "static")) { Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry); @@ -4481,9 +4481,9 @@ public: Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, " PyObject *obj;\n", NIL); if (fastunpack) { - Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char *)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); + Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args, \"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, " if (!PyArg_UnpackTuple(args, \"swigregister\", 1, 1, &obj)) return NULL;\n", NIL); } Printv(f_wrappers, @@ -5018,7 +5018,7 @@ public: Wrapper_add_local(f, "res", "int res"); if (!funpack) { Wrapper_add_local(f, "value", "PyObject *value"); - Append(f->code, "if (!PyArg_ParseTuple(args,(char *)\"O:set\",&value)) return NULL;\n"); + Append(f->code, "if (!PyArg_ParseTuple(args, \"O:set\", &value)) return NULL;\n"); } Printf(f->code, "res = %s(%s);\n", varsetname, funpack ? "args" : "value"); Append(f->code, "return !res ? SWIG_Py_Void() : NULL;\n"); @@ -5492,11 +5492,11 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (use_parse) { Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", Swig_cresult_name(), 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 swig_method_name = SWIG_Python_str_FromChar(\"%s\");\n", pyname); Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", Swig_cresult_name(), 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 swig_method_name = SWIG_Python_str_FromChar(\"%s\");\n", pyname); Printf(w->code, "swig::SwigVar_PyObject %s = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n", Swig_cresult_name()); } Append(w->code, "#endif\n"); From 3917225fdb59063c62dac76d223bfc9c5fe71494 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Oct 2018 19:15:31 +0100 Subject: [PATCH 1129/2031] Cosmetic Python error message improvement --- Lib/python/pyerrors.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index f21d28b45..dcd99c939 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -91,9 +91,9 @@ SWIG_Python_RaiseOrModifyTypeError(const char *message) PyObject *type = NULL, *value = NULL, *traceback = NULL; PyErr_Fetch(&type, &value, &traceback); #if PY_VERSION_HEX >= 0x03000000 - newvalue = PyUnicode_FromFormat("%S\nAdditional Information:\n%s", value, message); + newvalue = PyUnicode_FromFormat("%S\nAdditional information:\n%s", value, message); #else - newvalue = PyString_FromFormat("%s\nAdditional Information:\n%s", PyString_AsString(value), message); + newvalue = PyString_FromFormat("%s\nAdditional information:\n%s", PyString_AsString(value), message); #endif Py_XDECREF(value); PyErr_Restore(type, newvalue, traceback); From 04c506169876628c4c5cf59e8bee1b76e93318b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Oct 2018 22:06:25 +0100 Subject: [PATCH 1130/2031] Hardwire Python -fastunpack be on by default The -nofastunpack option has been left in as there isn't much code simplification in removing the nofastunpack code. This is because the nofastunpack code is still sometimes needed (eg varags and overloaded functions). --- Source/Modules/python.cxx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 541115773..4941c1286 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -86,7 +86,7 @@ static int classptr = 0; static int shadowimport = 1; static int dirvtable = 0; static int doxygen = 0; -static int fastunpack = 0; +static int fastunpack = 1; static int fastproxy = 0; static int olddefs = 0; static int aliasobj0 = 0; @@ -120,7 +120,6 @@ Python Options (available with -python)\n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ -debug-doxygen-translator - Display doxygen translator module debugging information\n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ - -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ -fastproxy - Use fast proxy mechanism for member methods \n\ -globals - Set used to access C global variable [default: 'cvar']\n\ -interface - Set the lib name to \n\ @@ -151,7 +150,7 @@ static const char *usage3 = "\ -relativeimport - Use relative python imports \n\ -threads - Add thread support for all the interface\n\ -O - Enable the following optimization options: \n\ - -fastdispatch -fastproxy -fastunpack -fvirtual\n\ + -fastdispatch -fastproxy -fvirtual\n\ \n"; static String *getSlot(Node *n = NULL, const char *key = NULL, String *default_slot = NULL) { @@ -405,9 +404,6 @@ public: } else if (strcmp(argv[i], "-debug-doxygen-parser") == 0) { doxygen_translator_flags |= DoxygenTranslator::debug_parser; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-fastunpack") == 0) { - fastunpack = 1; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-nofastunpack") == 0) { fastunpack = 0; Swig_mark_arg(i); @@ -450,7 +446,6 @@ public: Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { classptr = 0; - fastunpack = 1; fastproxy = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); @@ -472,6 +467,7 @@ public: Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastinit") == 0 || strcmp(argv[i], "-fastquery") == 0 || + strcmp(argv[i], "-fastunpack") == 0 || strcmp(argv[i], "-modern") == 0 || strcmp(argv[i], "-modernargs") == 0 || strcmp(argv[i], "-noproxydel") == 0 || @@ -479,9 +475,9 @@ public: Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-classic") == 0 || + strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || - strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-nosafecstrings") == 0 || @@ -2416,7 +2412,7 @@ public: * add_method() * ------------------------------------------------------------ */ - void add_method(String *name, String *function, int kw, Node *n = 0, int funpack= 0, int num_required= -1, int num_arguments = -1) { + void add_method(String *name, String *function, int kw, Node *n = 0, int funpack = 0, int num_required = -1, int num_arguments = -1) { if (!kw) { if (n && funpack) { if (num_required == 0 && num_arguments == 0) { From cd8fc0a025fb19a801e88fc475589aa73e9a1265 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Oct 2018 22:38:51 +0100 Subject: [PATCH 1131/2031] Remove Python -aliasobj0 option This option was originally added to help users switch to using -fastunpack so that typemaps using obj0 did not need changing by providing an alias for swig_obj[0] to obj0. The correct solution was always to replace obj0 with $self in the typemap. This is now mandatory. However, the -nofastunpack option can still be used to circumvent using the mandatory typemap change. --- Source/Modules/python.cxx | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 4941c1286..c4b7e47a3 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -89,7 +89,6 @@ static int doxygen = 0; static int fastunpack = 1; static int fastproxy = 0; static int olddefs = 0; -static int aliasobj0 = 0; static int castmode = 0; static int extranative = 0; static int outputtuple = 0; @@ -110,7 +109,6 @@ enum autodoc_t { static const char *usage1 = "\ Python Options (available with -python)\n\ - -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ @@ -127,7 +125,6 @@ Python Options (available with -python)\n\ static const char *usage2 = "\ -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ - -noaliasobj0 - Don't generate an obj0 alias when using fastunpack (default) \n\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ @@ -431,11 +428,6 @@ public: } else if (strcmp(argv[i], "-noextranative") == 0) { extranative = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-aliasobj0") == 0) { - aliasobj0 = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-noaliasobj0") == 0) { - aliasobj0 = 0; } else if (strcmp(argv[i], "-noh") == 0) { no_header_file = 1; Swig_mark_arg(i); @@ -474,7 +466,9 @@ public: strcmp(argv[i], "-safecstrings") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-buildnone") == 0 || + strcmp(argv[i], "-aliasobj0") == 0 || strcmp(argv[i], "-classic") == 0 || + strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || @@ -2757,16 +2751,9 @@ public: /* Generate code for argument marshalling */ if (funpack) { - if (overname) { - if (aliasobj0) { - Append(f->code, "#define obj0 (swig_obj[0])\n"); - } - } else if (num_arguments) { + if (num_arguments > 0 && !overname) { sprintf(source, "PyObject *swig_obj[%d]", num_arguments); Wrapper_add_localv(f, "swig_obj", source, NIL); - if (aliasobj0) { - Append(f->code, "#define obj0 (swig_obj[0])\n"); - } } } @@ -3172,16 +3159,6 @@ public: } } - - if (funpack) { - if (aliasobj0) { - Append(f->code, "#if defined(obj0)\n"); - Append(f->code, "#undef obj0\n"); - Append(f->code, "#endif\n"); - } - } - - Append(f->code, "}\n"); /* Substitute the cleanup code */ From cd4732f3e31b5f7e2c9ad3fc6525f2cd114283d1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Oct 2018 08:16:59 +0100 Subject: [PATCH 1132/2031] Add changes entry about the reduced number of command line options --- CHANGES.current | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index b51ce0216..53fc73a47 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,8 +7,54 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-10-22: olly,wsfulton + [Python] #1261 #1340 Turn on many optimisation options by default and rationalise the + number of command line options. + + There were an unnecessary number of command line options and many of these have now + been removed in a drive for simplification. Some were needed to support older versions + of Python (2.6 and earlier). + + Many of the options could be turned on individually and when using -O. Previously -O + resulted in turning on a set of options: + + -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel + -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone + + Now -O results in turning on this reduced set: + + -fastdispatch -fastproxy -fvirtual + + The following options are now on by default, a deprecated warning is displayed if they + are used: + -fastinit Class initialisation code done in C/C++ rather than in Python code. + -fastquery Python dictionary used for lookup of types. + -fastunpack Faster unpacking of function arguments in C/C++ wrappers. + -modern Use Python 2.3 features such as object and property. + -modernargs Use Python 2.3 C APIs for unpacking arguments in tuples. + -noproxydel Stop generating a proxy __del__ method for backwards compatiblity. + -safecstrings No discernable difference + + The following options have been removed altogether: + -buildnone + -aliasobj0 + -noaliasobj0 + -nobuildnone + -nofastinit + -nofastquery + -nomodern + -nomodernargs + -nosafecstrings + -proxydel + +2018-10-22: olly + [Python] #1261 Remove command line option no longer needed as Python 2.3 and earlier + are no longer supported: + + -classic + 2018-10-09: wsfulton - [D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl] + [D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl] Allow wrapping of std::map using non-default comparison function. 2018-10-09: vadz From dc5885e22dd6e6d77d8221a3adc23ce327722028 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Oct 2018 18:32:34 +0100 Subject: [PATCH 1133/2031] Documentation correction about -fastproxy --- Doc/Manual/Python.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 4958d80ab..a15a86473 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3868,8 +3868,8 @@ Below are some timings in microseconds calling the 3 functions in the example ab - - + + From 411c17f15ddd5daebc9c3e04f7a32726c2e06e25 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Oct 2018 08:13:21 +0100 Subject: [PATCH 1134/2031] Remove Python 3 OSX Travis testing. Pouring gcc-8.2.0.high_sierra.bottle.1.tar.gz Error: The step did not complete successfully Above error needs fixing --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7f622bc85..4a68cb960 100644 --- a/.travis.yml +++ b/.travis.yml @@ -368,6 +368,10 @@ matrix: env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required dist: trusty + # 'brew upgrade python' failure due to conflicting files: c++ + - compiler: clang + os: osx + env: SWIGLANG=python PY3=3 # Lots of failing tests currently - compiler: gcc os: linux From 7375d4575a3667be1fe8a465d3042bf38f94c12d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Oct 2018 19:53:31 +0100 Subject: [PATCH 1135/2031] Typemap %apply docs clarification --- Doc/Manual/Typemaps.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 78c7036f2..1639423af 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -4955,7 +4955,7 @@ then all of the int *OUTPUT (source) typemap methods are copied to

      However, there is a subtle aspect of %apply that needs clarification. Namely, if a target contains a typemap method that the source does not, -the target typemap method is not overwritten / deleted. +the target typemap method remains in place and unchanged. This behavior allows you to do two things:

      From 1274c1abfc6ac27f515e8af4a080589e2502ae80 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Oct 2018 19:13:20 +0100 Subject: [PATCH 1136/2031] Remove Python -classptr option This option was for backwards compatibility with very old versions of SWIG that generated a shadow 'XPtr' class derived from proxy class X. If anyone is still using these, they are best off using the actual proxy class, or otherwise add them in manually using %pythoncode. Issue #1340. --- Source/Modules/python.cxx | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c4b7e47a3..9a8b99eac 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -81,7 +81,7 @@ static String *real_classname; /* Thread Support */ static int threads = 0; static int nothreads = 0; -static int classptr = 0; + /* Other options */ static int shadowimport = 1; static int dirvtable = 0; @@ -111,7 +111,6 @@ static const char *usage1 = "\ Python Options (available with -python)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ - -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ @@ -350,9 +349,6 @@ public: } else if ((strcmp(argv[i], "-old_repr") == 0) || (strcmp(argv[i], "-oldrepr") == 0)) { new_repr = 0; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-classptr") == 0) { - classptr = 1; - Swig_mark_arg(i); } else if ((strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); @@ -437,7 +433,6 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { - classptr = 0; fastproxy = 1; Wrapper_fast_dispatch_mode_set(1); Wrapper_virtual_elimination_mode_set(1); @@ -467,6 +462,7 @@ public: Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-aliasobj0") == 0 || + strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || @@ -4502,16 +4498,6 @@ public: if (!builtin) { /* Now emit methods */ Printv(f_shadow_file, f_shadow, NIL); - - /* Now the Ptr class */ - if (classptr) { - Printv(f_shadow_file, "\nclass ", class_name, "Ptr(", class_name, "):\n", tab4, "def __init__(self, this):\n", NIL); - Printv(f_shadow_file, - tab8, "try:\n", tab8, tab4, "self.this.append(this)\n", - tab8, "except __builtin__.Exception:\n", tab8, tab4, "self.this = this\n", tab8, "self.this.own(0)\n", tab8, "self.__class__ = ", class_name, "\n", NIL); - - } - Printf(f_shadow_file, "\n"); Printf(f_shadow_file, "# Register %s in %s:\n", class_name, module); Printf(f_shadow_file, "%s.%s_swigregister(%s)\n", module, class_name, class_name); From 39b48b86890b0594df1d6972b6b5b9c97967290f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Oct 2018 19:57:15 +0100 Subject: [PATCH 1137/2031] Remove Python -oldrepr option This option controlled the __repr__ proxy class method. Also removes: -old_repr -oldrepr -new_repr -newrepr Note: -newrepr was and remains on by default. When -oldrepr/-old_repr option resulted in code that did not run. --- Source/Modules/python.cxx | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9a8b99eac..af4a7c19b 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -65,7 +65,6 @@ static String *methods; static String *class_name; static String *shadow_indent = 0; static int in_class = 0; -static int new_repr = 1; static int no_header_file = 0; static int max_bases = 0; static int builtin_bases_needed = 0; @@ -122,7 +121,6 @@ Python Options (available with -python)\n\ -interface - Set the lib name to \n\ -keyword - Use keyword arguments\n"; static const char *usage2 = "\ - -newrepr - Use more informative version of __repr__ in proxy classes (default) \n\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ @@ -140,7 +138,6 @@ static const char *usage3 = "\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nothreads - Disable thread support for the entire interface\n\ -olddefs - Keep the old method definitions even when using fastproxy\n\ - -oldrepr - Use shorter and old version of __repr__ in proxy classes\n\ -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ @@ -343,12 +340,6 @@ public: } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { shadow = 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); - } else if ((strcmp(argv[i], "-old_repr") == 0) || (strcmp(argv[i], "-oldrepr") == 0)) { - new_repr = 0; - Swig_mark_arg(i); } else if ((strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); @@ -462,8 +453,10 @@ public: Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); } else if (strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-aliasobj0") == 0 || - strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-classic") == 0 || + strcmp(argv[i], "-classptr") == 0 || + strcmp(argv[i], "-new_repr") == 0 || + strcmp(argv[i], "-newrepr") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || strcmp(argv[i], "-nofastinit") == 0 || @@ -471,6 +464,8 @@ public: strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-nosafecstrings") == 0 || + strcmp(argv[i], "-old_repr") == 0 || + strcmp(argv[i], "-oldrepr") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); SWIG_exit(EXIT_FAILURE); @@ -4479,11 +4474,7 @@ public: if (!have_repr && !builtin) { /* Supply a repr method for this class */ String *rname = SwigType_namestr(real_classname); - if (new_repr) { - Printv(f_shadow_file, tab4, "__repr__ = _swig_repr\n", NIL); - } else { - Printv(f_shadow_file, tab4, "def __repr__(self):\n", tab8, "return \"\" % (self.this,)\n", NIL); - } + Printv(f_shadow_file, tab4, "__repr__ = _swig_repr\n", NIL); Delete(rname); } From 23ce449ea516cf77cd4966314bffded32b5de2ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Oct 2018 23:25:42 +0100 Subject: [PATCH 1138/2031] Remove Python -new_vwm Use the -newvwm alias name instead. --- Source/Modules/python.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index af4a7c19b..5a34d23ef 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -418,7 +418,7 @@ public: } else if (strcmp(argv[i], "-noh") == 0) { no_header_file = 1; Swig_mark_arg(i); - } else if ((strcmp(argv[i], "-new_vwm") == 0) || (strcmp(argv[i], "-newvwm") == 0)) { + } else if (strcmp(argv[i], "-newvwm") == 0) { /* Turn on new value wrapper mode */ Swig_value_wrapper_mode(1); no_header_file = 1; @@ -456,6 +456,7 @@ public: strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-new_repr") == 0 || + strcmp(argv[i], "-new_vwm") == 0 || strcmp(argv[i], "-newrepr") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || From ccbc16f8108f0387bae7c29d5a952a9693c347c3 Mon Sep 17 00:00:00 2001 From: Alexander Gabriel Date: Sun, 28 Oct 2018 20:41:16 +0100 Subject: [PATCH 1139/2031] PHP: Make reserved keywords to reserved function only (#1335) [php] Make Keywords which are functions reserved functions --- Lib/php/phpkw.swg | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index 8e5d3412e..5c5296a1f 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -30,10 +30,8 @@ * could lead to confusion." */ /* Check is case insensitive - these *MUST* be listed in lower case here */ -PHPKW(__halt_compiler); PHPKW(abstract); PHPKW(and); -PHPKW(array); PHPKW(as); PHPKW(break); PHPKW(callable); @@ -45,20 +43,15 @@ PHPKW(const); PHPKW(continue); PHPKW(declare); PHPKW(default); -PHPKW(die); // "Language construct" PHPKW(do); -PHPKW(echo); // "Language construct" PHPKW(else); PHPKW(elseif); -PHPKW(empty); // "Language construct" PHPKW(enddeclare); PHPKW(endfor); PHPKW(endforeach); PHPKW(endif); PHPKW(endswitch); PHPKW(endwhile); -PHPKW(eval); // "Language construct" -PHPKW(exit); // "Language construct" PHPKW(extends); PHPKW(final); PHPKW(finally); @@ -69,29 +62,20 @@ PHPKW(global); PHPKW(goto); PHPKW(if); PHPKW(implements); -PHPKW(include); // "Language construct" -PHPKW(include_once); // "Language construct" PHPKW(instanceof); PHPKW(insteadof); PHPKW(interface); -PHPKW(isset); // "Language construct" -PHPKW(list); // "Language construct" PHPKW(namespace); PHPKW(new); PHPKW(or); -PHPKW(print); // "Language construct" PHPKW(private); PHPKW(protected); PHPKW(public); -PHPKW(require); // "Language construct" -PHPKW(require_once); // "Language construct" -PHPKW(return); // "Language construct" PHPKW(static); PHPKW(switch); PHPKW(throw); PHPKW(trait); PHPKW(try); -PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); @@ -767,7 +751,9 @@ PHPCN(datetime); /* Built-in PHP functions (incomplete). */ /* Includes Array Functions - http://php.net/manual/en/ref.array.php */ /* Check is case insensitive - these *MUST* be listed in lower case here */ +PHPFN(__halt_compiler); PHPFN(acos); +PHPFN(array); PHPFN(array_change_key_case); PHPFN(array_chunk); PHPFN(array_column); @@ -829,17 +815,26 @@ PHPFN(cos); PHPFN(cosh); PHPFN(count); PHPFN(current); +PHPFN(die); // "Language construct" PHPFN(each); +PHPFN(echo); // "Language construct" +PHPFN(empty); PHPFN(end); +PHPFN(eval); // "Language construct" +PHPFN(exit); // "Language construct" PHPFN(exp); PHPFN(extract); PHPFN(floor); PHPFN(fmod); PHPFN(in_array); +PHPFN(include); // "Language construct" +PHPFN(include_once); // "Language construct" +PHPFN(isset); // "Language construct" PHPFN(key); PHPFN(key_exists); PHPFN(krsort); PHPFN(ksort); +PHPFN(list); // "Language construct" PHPFN(log); PHPFN(log10); PHPFN(max); @@ -850,9 +845,13 @@ PHPFN(next); PHPFN(pos); PHPFN(pow); PHPFN(prev); +PHPFN(print); // "Language construct" PHPFN(range); PHPFN(reset); PHPFN(rsort); +PHPFN(require); // "Language construct" +PHPFN(require_once); // "Language construct" +PHPFN(return); // "Language construct" PHPFN(shuffle); PHPFN(sin); PHPFN(sinh); @@ -863,6 +862,7 @@ PHPFN(tan); PHPFN(tanh); PHPFN(uasort); PHPFN(uksort); +PHPFN(unset); // "Language construct" PHPFN(usort); #undef PHPKW From 7a3af70419fe93202a1e83a2e7ce6239b1c75af0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 29 Oct 2018 08:44:46 +1300 Subject: [PATCH 1140/2031] Add changes entry for PHP7 reserved word change --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 53fc73a47..6db8329c7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-10-29: AlexanderGabriel + [PHP] The following PHP7 reserved keywords are now only renamed by + SWIG when used as function names in the API being wrapper: + __halt_compiler array die echo empty eval exit include include_once + isset list print require require_once return unset + 2018-10-22: olly,wsfulton [Python] #1261 #1340 Turn on many optimisation options by default and rationalise the number of command line options. From c06f2b4497bffeb185dbf0e65dc925514537ef37 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Oct 2018 08:07:08 +0100 Subject: [PATCH 1141/2031] Remove -cppcast and -nocppcast command line options The -cppcast option is still turned on by default. The -nocppcast option to turn off the use of c++ casts (const_cast, static_cast etc) has been removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts instead of C++ casts for C++ wrappers. --- Lib/typemaps/swigmacros.swg | 11 ++--------- Source/Modules/octave.cxx | 20 ++++++++------------ Source/Modules/perl5.cxx | 20 +++++++------------- Source/Modules/python.cxx | 23 +++++++---------------- Source/Modules/r.cxx | 19 +++++++------------ Source/Modules/ruby.cxx | 21 +++++++-------------- Source/Modules/tcl8.cxx | 18 +++++++----------- 7 files changed, 45 insertions(+), 87 deletions(-) diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index 3a63a256c..687b0680e 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -31,7 +31,7 @@ %as_voidptrptr(a) reinterpret_cast(a) or their C unsafe versions. In C++ we use the safe version unless - SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). + SWIG_NO_CPLUSPLUS_CAST is defined Memory allocation: @@ -123,14 +123,7 @@ nocppval * Casting operators * ----------------------------------------------------------------------------- */ -#if defined(SWIG_NO_CPLUSPLUS_CAST) -/* Disable 'modern' cplusplus casting operators */ -# if defined(SWIG_CPLUSPLUS_CAST) -# undef SWIG_CPLUSPLUS_CAST -# endif -#endif - -#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) +#if defined(__cplusplus) && !defined(SWIG_NO_CPLUSPLUS_CAST) # define %const_cast(a,Type...) const_cast< Type >(a) # define %static_cast(a,Type...) static_cast< Type >(a) # define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 81434ce0b..a1a40d8ea 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -19,10 +19,8 @@ static String *op_prefix = 0; static const char *usage = "\ Octave Options (available with -octave)\n\ - -cppcast - Enable C++ casting operators (default)\n\ -globals - Set used to access C global variables [default: 'cvar']\n\ Use '.' to load C global variables into module namespace\n\ - -nocppcast - Disable C++ casting operators\n\ -opprefix - Prefix for global operator functions [default: 'op_']\n\ \n"; @@ -92,8 +90,7 @@ public: } virtual void main(int argc, char *argv[]) { - int cppcast = 1; - + for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { @@ -116,12 +113,13 @@ public: } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } @@ -130,8 +128,6 @@ public: global_name = NewString("cvar"); if (!op_prefix) op_prefix = NewString("op_"); - if(cppcast) - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); SWIG_library_directory("octave"); Preprocessor_define("SWIGOCTAVE 1", 0); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 4d2db6ec2..9fa301a21 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -19,8 +19,6 @@ static const char *usage = "\ Perl5 Options (available with -perl5)\n\ -compat - Compatibility mode\n\ -const - Wrap constants as constants and not variables (implies -proxy)\n\ - -cppcast - Enable C++ casting operators\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nopm - Do not generate the .pm file\n\ -noproxy - Don't create proxy classes\n\ -proxy - Create proxy classes\n\ @@ -148,7 +146,6 @@ public: virtual void main(int argc, char *argv[]) { int i = 1; - int cppcast = 1; SWIG_library_directory("perl5"); @@ -189,25 +186,22 @@ public: } else if (strcmp(argv[i],"-v") == 0) { Swig_mark_arg(i); verbose++; - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-compat") == 0) { compat = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - Preprocessor_define("SWIGPERL 1", 0); // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5a34d23ef..8f2964662 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -110,7 +110,6 @@ static const char *usage1 = "\ Python Options (available with -python)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ - -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ @@ -123,7 +122,6 @@ Python Options (available with -python)\n\ static const char *usage2 = "\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -nocastmode - Disable the casting mode (default)\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ @@ -310,7 +308,6 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - int cppcast = 1; SWIG_library_directory("python"); @@ -350,12 +347,6 @@ public: use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-outputtuple") == 0) { outputtuple = 1; Swig_mark_arg(i); @@ -443,7 +434,8 @@ public: } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-fastinit") == 0 || + } else if (strcmp(argv[i], "-cppcast") == 0 || + strcmp(argv[i], "-fastinit") == 0 || strcmp(argv[i], "-fastquery") == 0 || strcmp(argv[i], "-fastunpack") == 0 || strcmp(argv[i], "-modern") == 0 || @@ -451,8 +443,9 @@ public: strcmp(argv[i], "-noproxydel") == 0 || strcmp(argv[i], "-safecstrings") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - } else if (strcmp(argv[i], "-buildnone") == 0 || - strcmp(argv[i], "-aliasobj0") == 0 || + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-aliasobj0") == 0 || + strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-new_repr") == 0 || @@ -460,6 +453,7 @@ public: strcmp(argv[i], "-newrepr") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || + strcmp(argv[i], "-nocppcast") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || @@ -469,16 +463,13 @@ public: strcmp(argv[i], "-oldrepr") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - if (doxygen) doxygenTranslator = new PyDocConverter(doxygen_translator_flags); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0fe730c83..a82b8d15a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -208,7 +208,6 @@ static void writeListByLine(List *l, File *out, bool quote = 0) { static const char *usage = "\ R Options (available with -r)\n\ -copystruct - Emit R code to copy C structs (on by default)\n\ - -cppcast - Enable C++ casting operators (default) \n\ -debug - Output debug\n\ -dll - Name of the DLL (without the .dll or .so suffix).\n\ Default is the module name.\n\ @@ -2695,7 +2694,6 @@ String * R::runtimeCode() { Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. **/ void R::main(int argc, char *argv[]) { - bool cppcast = true; init(); Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); @@ -2739,12 +2737,6 @@ void R::main(int argc, char *argv[]) { } else if(!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-cppcast")) { - cppcast = true; - Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-nocppcast")) { - cppcast = false; - Swig_mark_arg(i); } else if (!strcmp(argv[i],"-copystruct")) { copyStruct = true; Swig_mark_arg(i); @@ -2763,10 +2755,13 @@ void R::main(int argc, char *argv[]) { } else if (!strcmp(argv[i], "-noaggressivegc")) { aggressiveGc = false; Swig_mark_arg(i); - } - - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } if (debugMode) { diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index b88ad3042..306570d96 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -131,12 +131,10 @@ enum autodoc_t { static const char *usage = "\ Ruby Options (available with -ruby)\n\ -autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\ - -cppcast - Enable C++ casting operators (default)\n\ -globalmodule - Wrap everything into the global module\n\ -initname - Set entry function to Init_ (used by `require')\n\ -minherit - Attempt to support multiple inheritance\n\ -noautorename - Disable renaming of classes and methods (default)\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -prefix - Set a prefix to be prepended to all names\n\ "; @@ -844,7 +842,6 @@ public: virtual void main(int argc, char *argv[]) { - int cppcast = 1; int autorename = 0; /* Set location of SWIG library */ @@ -883,12 +880,6 @@ public: multipleInheritance = true; director_multiple_inheritance = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-autorename") == 0) { autorename = 1; Swig_mark_arg(i); @@ -907,15 +898,17 @@ public: } } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - /* Turn on cppcast mode */ - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - if (autorename) { /* Turn on the autorename mode */ Preprocessor_define((DOH *) "SWIG_RUBY_AUTORENAME", 0); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 1227af79c..57ef3e97b 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -76,7 +76,6 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - int cppcast = 1; SWIG_library_directory("tcl"); @@ -106,22 +105,19 @@ public: } else if (strcmp(argv[i], "-nosafe") == 0) { nosafe = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - Preprocessor_define("SWIGTCL 1", 0); // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); From 1251629f06f8b6b6d9555ad9f68a961b7cdd9f41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Nov 2018 17:13:50 +0000 Subject: [PATCH 1142/2031] Add Python struct member limitation documentation Closes #1336 --- Doc/Manual/Python.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index a15a86473..e2795d635 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1480,6 +1480,27 @@ everything works just like you would expect. For example: +

      +Note that there is a limitation with structs within structs that will cause a problem +if the outer struct is not a named variable in Python. The following will cause a segfault: +

      + +
      +
      +Bar().f.a = 3
      +
      +
      + +

      +because the unnamed Python proxy class for Bar() has its reference count +decremented by the Python interpreter after f has been obtained from it and +before f is used to obtain a. +This results in the underlying Bar instance being deleted, which of course also deletes +f inside it. Hence the pointer to f points to deleted +memory and use of it results in a segfault or some sort of other undefined behaviour. +

      + +

      38.3.7 C++ classes

      From fc79264a48f186f8bbd367e91fa9dbf9758aa092 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Nov 2018 17:22:05 +0000 Subject: [PATCH 1143/2031] Revert "Remove -cppcast and -nocppcast command line options" This reverts commit c06f2b4497bffeb185dbf0e65dc925514537ef37. More work to be done as it breaks Scilab and Javascript tests. --- Lib/typemaps/swigmacros.swg | 11 +++++++++-- Source/Modules/octave.cxx | 20 ++++++++++++-------- Source/Modules/perl5.cxx | 20 +++++++++++++------- Source/Modules/python.cxx | 23 ++++++++++++++++------- Source/Modules/r.cxx | 19 ++++++++++++------- Source/Modules/ruby.cxx | 21 ++++++++++++++------- Source/Modules/tcl8.cxx | 14 +++++++++----- 7 files changed, 85 insertions(+), 43 deletions(-) diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index 687b0680e..3a63a256c 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -31,7 +31,7 @@ %as_voidptrptr(a) reinterpret_cast(a) or their C unsafe versions. In C++ we use the safe version unless - SWIG_NO_CPLUSPLUS_CAST is defined + SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). Memory allocation: @@ -123,7 +123,14 @@ nocppval * Casting operators * ----------------------------------------------------------------------------- */ -#if defined(__cplusplus) && !defined(SWIG_NO_CPLUSPLUS_CAST) +#if defined(SWIG_NO_CPLUSPLUS_CAST) +/* Disable 'modern' cplusplus casting operators */ +# if defined(SWIG_CPLUSPLUS_CAST) +# undef SWIG_CPLUSPLUS_CAST +# endif +#endif + +#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) # define %const_cast(a,Type...) const_cast< Type >(a) # define %static_cast(a,Type...) static_cast< Type >(a) # define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index a1a40d8ea..81434ce0b 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -19,8 +19,10 @@ static String *op_prefix = 0; static const char *usage = "\ Octave Options (available with -octave)\n\ + -cppcast - Enable C++ casting operators (default)\n\ -globals - Set used to access C global variables [default: 'cvar']\n\ Use '.' to load C global variables into module namespace\n\ + -nocppcast - Disable C++ casting operators\n\ -opprefix - Prefix for global operator functions [default: 'op_']\n\ \n"; @@ -90,7 +92,8 @@ public: } virtual void main(int argc, char *argv[]) { - + int cppcast = 1; + for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { @@ -113,13 +116,12 @@ public: } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-cppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); - Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + } else if (strcmp(argv[i], "-cppcast") == 0) { + cppcast = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + cppcast = 0; + Swig_mark_arg(i); } } } @@ -128,6 +130,8 @@ public: global_name = NewString("cvar"); if (!op_prefix) op_prefix = NewString("op_"); + if(cppcast) + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); SWIG_library_directory("octave"); Preprocessor_define("SWIGOCTAVE 1", 0); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 9fa301a21..4d2db6ec2 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -19,6 +19,8 @@ static const char *usage = "\ Perl5 Options (available with -perl5)\n\ -compat - Compatibility mode\n\ -const - Wrap constants as constants and not variables (implies -proxy)\n\ + -cppcast - Enable C++ casting operators\n\ + -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nopm - Do not generate the .pm file\n\ -noproxy - Don't create proxy classes\n\ -proxy - Create proxy classes\n\ @@ -146,6 +148,7 @@ public: virtual void main(int argc, char *argv[]) { int i = 1; + int cppcast = 1; SWIG_library_directory("perl5"); @@ -186,22 +189,25 @@ public: } else if (strcmp(argv[i],"-v") == 0) { Swig_mark_arg(i); verbose++; + } else if (strcmp(argv[i], "-cppcast") == 0) { + cppcast = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + cppcast = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-compat") == 0) { compat = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); - } else if (strcmp(argv[i], "-cppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); - Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); } } } + if (cppcast) { + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } + Preprocessor_define("SWIGPERL 1", 0); // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8f2964662..5a34d23ef 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -110,6 +110,7 @@ static const char *usage1 = "\ Python Options (available with -python)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ + -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ @@ -122,6 +123,7 @@ Python Options (available with -python)\n\ static const char *usage2 = "\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -nocastmode - Disable the casting mode (default)\n\ + -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ @@ -308,6 +310,7 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { + int cppcast = 1; SWIG_library_directory("python"); @@ -347,6 +350,12 @@ public: use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); + } else if (strcmp(argv[i], "-cppcast") == 0) { + cppcast = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + cppcast = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-outputtuple") == 0) { outputtuple = 1; Swig_mark_arg(i); @@ -434,8 +443,7 @@ public: } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0 || - strcmp(argv[i], "-fastinit") == 0 || + } else if (strcmp(argv[i], "-fastinit") == 0 || strcmp(argv[i], "-fastquery") == 0 || strcmp(argv[i], "-fastunpack") == 0 || strcmp(argv[i], "-modern") == 0 || @@ -443,9 +451,8 @@ public: strcmp(argv[i], "-noproxydel") == 0 || strcmp(argv[i], "-safecstrings") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-aliasobj0") == 0 || - strcmp(argv[i], "-buildnone") == 0 || + } else if (strcmp(argv[i], "-buildnone") == 0 || + strcmp(argv[i], "-aliasobj0") == 0 || strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-new_repr") == 0 || @@ -453,7 +460,6 @@ public: strcmp(argv[i], "-newrepr") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || - strcmp(argv[i], "-nocppcast") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || @@ -463,13 +469,16 @@ public: strcmp(argv[i], "-oldrepr") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); - Swig_mark_arg(i); SWIG_exit(EXIT_FAILURE); } } } + if (cppcast) { + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } + if (doxygen) doxygenTranslator = new PyDocConverter(doxygen_translator_flags); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index a82b8d15a..0fe730c83 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -208,6 +208,7 @@ static void writeListByLine(List *l, File *out, bool quote = 0) { static const char *usage = "\ R Options (available with -r)\n\ -copystruct - Emit R code to copy C structs (on by default)\n\ + -cppcast - Enable C++ casting operators (default) \n\ -debug - Output debug\n\ -dll - Name of the DLL (without the .dll or .so suffix).\n\ Default is the module name.\n\ @@ -2694,6 +2695,7 @@ String * R::runtimeCode() { Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. **/ void R::main(int argc, char *argv[]) { + bool cppcast = true; init(); Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); @@ -2737,6 +2739,12 @@ void R::main(int argc, char *argv[]) { } else if(!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); + } else if (!strcmp(argv[i],"-cppcast")) { + cppcast = true; + Swig_mark_arg(i); + } else if (!strcmp(argv[i],"-nocppcast")) { + cppcast = false; + Swig_mark_arg(i); } else if (!strcmp(argv[i],"-copystruct")) { copyStruct = true; Swig_mark_arg(i); @@ -2755,13 +2763,10 @@ void R::main(int argc, char *argv[]) { } else if (!strcmp(argv[i], "-noaggressivegc")) { aggressiveGc = false; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); - Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + } + + if (cppcast) { + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); } if (debugMode) { diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 306570d96..b88ad3042 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -131,10 +131,12 @@ enum autodoc_t { static const char *usage = "\ Ruby Options (available with -ruby)\n\ -autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\ + -cppcast - Enable C++ casting operators (default)\n\ -globalmodule - Wrap everything into the global module\n\ -initname - Set entry function to Init_ (used by `require')\n\ -minherit - Attempt to support multiple inheritance\n\ -noautorename - Disable renaming of classes and methods (default)\n\ + -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -prefix - Set a prefix to be prepended to all names\n\ "; @@ -842,6 +844,7 @@ public: virtual void main(int argc, char *argv[]) { + int cppcast = 1; int autorename = 0; /* Set location of SWIG library */ @@ -880,6 +883,12 @@ public: multipleInheritance = true; director_multiple_inheritance = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-cppcast") == 0) { + cppcast = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + cppcast = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-autorename") == 0) { autorename = 1; Swig_mark_arg(i); @@ -898,17 +907,15 @@ public: } } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); - } else if (strcmp(argv[i], "-cppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); - Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); } } } + if (cppcast) { + /* Turn on cppcast mode */ + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } + if (autorename) { /* Turn on the autorename mode */ Preprocessor_define((DOH *) "SWIG_RUBY_AUTORENAME", 0); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 57ef3e97b..1227af79c 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -76,6 +76,7 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { + int cppcast = 1; SWIG_library_directory("tcl"); @@ -105,19 +106,22 @@ public: } else if (strcmp(argv[i], "-nosafe") == 0) { nosafe = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); } else if (strcmp(argv[i], "-cppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + cppcast = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-nocppcast") == 0) { - Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + cppcast = 0; Swig_mark_arg(i); - SWIG_exit(EXIT_FAILURE); + } else if (strcmp(argv[i], "-help") == 0) { + fputs(usage, stdout); } } } + if (cppcast) { + Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } + Preprocessor_define("SWIGTCL 1", 0); // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); From 6f5417499a7aa9147d53b9d2706f4f3cf2f2d309 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 12 Nov 2018 07:31:24 +0000 Subject: [PATCH 1144/2031] Fix incorrect casts for Scilab enums --- Lib/scilab/scitypemaps.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg index 682d18c44..99fdce7be 100644 --- a/Lib/scilab/scitypemaps.swg +++ b/Lib/scilab/scitypemaps.swg @@ -97,7 +97,7 @@ if (SWIG_AsVal_dec(Enum)($input, &val) != SWIG_OK) { return SWIG_ERROR; } - $1 = %reinterpret_cast(val, $ltype); + $1 = %static_cast(val, $1_ltype); } %typemap(out, fragment=SWIG_From_frag(Enum)) enum SWIGTYPE { From ebce0185421de0d83b25d1871a4baba212d8304d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Nov 2018 07:15:15 +0000 Subject: [PATCH 1145/2031] Fix constant function pointer typemaps The function pointer typemaps were not being used when the function pointer is const, like ADD_BY_VALUE_C in the funcptr_cpp.i testcase: %constant int (* const ADD_BY_VALUE_C)(const int &, int) = addByValue; Problem affecting Javascript and observable when running test-suite with -cppcast. --- Lib/typemaps/swigtype.swg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 723dc08bb..87fab7e69 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -669,6 +669,8 @@ } #endif +%apply SWIGTYPE ((*)(ANY)) { SWIGTYPE ((* const)(ANY)) } + %apply SWIGTYPE * { SWIGTYPE *const } /* ------------------------------------------------------------ From c0481ce99de08904be2a9e6f9104a31fedb89b2b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Nov 2018 07:30:04 +0000 Subject: [PATCH 1146/2031] Add Python runtime test for const function pointer --- Examples/test-suite/funcptr_cpp.i | 1 + Examples/test-suite/python/funcptr_cpp_runme.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i index 8e05d308d..d8ec8de4d 100644 --- a/Examples/test-suite/funcptr_cpp.i +++ b/Examples/test-suite/funcptr_cpp.i @@ -17,6 +17,7 @@ int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); } int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); } int call4(int & (*d)(int &, int *), int a, int b) { return d(a, &b); } int call5(int & (*d)(int &, int const * const), int a, int b) { return d(a, &b); } +int callconst1(int (* const d)(const int &, int), int a, int b) { return d(a, b); } %} %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue; diff --git a/Examples/test-suite/python/funcptr_cpp_runme.py b/Examples/test-suite/python/funcptr_cpp_runme.py index eb113d226..22c50b4e9 100644 --- a/Examples/test-suite/python/funcptr_cpp_runme.py +++ b/Examples/test-suite/python/funcptr_cpp_runme.py @@ -8,3 +8,6 @@ if call3(ADD_BY_REFERENCE, 14, 15) != 29: raise RuntimeError if call1(ADD_BY_VALUE_C, 2, 3) != 5: raise RuntimeError + +if callconst1(ADD_BY_VALUE_C, 2, 3) != 5: + raise RuntimeError From 027a38c71c77d5475afa91c6baf09d2113e74d15 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Nov 2018 07:36:09 +0000 Subject: [PATCH 1147/2031] Remove -cppcast and -nocppcast command line options The -cppcast option is still turned on by default. The -nocppcast option to turn off the use of c++ casts (const_cast, static_cast etc) has been removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts instead of C++ casts for C++ wrappers. This a revert of commit fc79264a48f186f8bbd367e91fa9dbf9758aa092: "Revert "Remove -cppcast and -nocppcast command line options"" The Scilab and Javascript casting problems are now fixed, so -cppcast is now switched on as default. --- Lib/typemaps/swigmacros.swg | 11 ++--------- Source/Modules/octave.cxx | 20 ++++++++------------ Source/Modules/perl5.cxx | 20 +++++++------------- Source/Modules/python.cxx | 23 +++++++---------------- Source/Modules/r.cxx | 19 +++++++------------ Source/Modules/ruby.cxx | 21 +++++++-------------- Source/Modules/tcl8.cxx | 18 +++++++----------- 7 files changed, 45 insertions(+), 87 deletions(-) diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index 3a63a256c..687b0680e 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -31,7 +31,7 @@ %as_voidptrptr(a) reinterpret_cast(a) or their C unsafe versions. In C++ we use the safe version unless - SWIG_NO_CPLUSPLUS_CAST is defined (usually via the -nocppcast swig flag). + SWIG_NO_CPLUSPLUS_CAST is defined Memory allocation: @@ -123,14 +123,7 @@ nocppval * Casting operators * ----------------------------------------------------------------------------- */ -#if defined(SWIG_NO_CPLUSPLUS_CAST) -/* Disable 'modern' cplusplus casting operators */ -# if defined(SWIG_CPLUSPLUS_CAST) -# undef SWIG_CPLUSPLUS_CAST -# endif -#endif - -#if defined(__cplusplus) && defined(SWIG_CPLUSPLUS_CAST) +#if defined(__cplusplus) && !defined(SWIG_NO_CPLUSPLUS_CAST) # define %const_cast(a,Type...) const_cast< Type >(a) # define %static_cast(a,Type...) static_cast< Type >(a) # define %reinterpret_cast(a,Type...) reinterpret_cast< Type >(a) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 81434ce0b..a1a40d8ea 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -19,10 +19,8 @@ static String *op_prefix = 0; static const char *usage = "\ Octave Options (available with -octave)\n\ - -cppcast - Enable C++ casting operators (default)\n\ -globals - Set used to access C global variables [default: 'cvar']\n\ Use '.' to load C global variables into module namespace\n\ - -nocppcast - Disable C++ casting operators\n\ -opprefix - Prefix for global operator functions [default: 'op_']\n\ \n"; @@ -92,8 +90,7 @@ public: } virtual void main(int argc, char *argv[]) { - int cppcast = 1; - + for (int i = 1; i < argc; i++) { if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { @@ -116,12 +113,13 @@ public: } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } @@ -130,8 +128,6 @@ public: global_name = NewString("cvar"); if (!op_prefix) op_prefix = NewString("op_"); - if(cppcast) - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); SWIG_library_directory("octave"); Preprocessor_define("SWIGOCTAVE 1", 0); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 4d2db6ec2..9fa301a21 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -19,8 +19,6 @@ static const char *usage = "\ Perl5 Options (available with -perl5)\n\ -compat - Compatibility mode\n\ -const - Wrap constants as constants and not variables (implies -proxy)\n\ - -cppcast - Enable C++ casting operators\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nopm - Do not generate the .pm file\n\ -noproxy - Don't create proxy classes\n\ -proxy - Create proxy classes\n\ @@ -148,7 +146,6 @@ public: virtual void main(int argc, char *argv[]) { int i = 1; - int cppcast = 1; SWIG_library_directory("perl5"); @@ -189,25 +186,22 @@ public: } else if (strcmp(argv[i],"-v") == 0) { Swig_mark_arg(i); verbose++; - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-compat") == 0) { compat = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - Preprocessor_define("SWIGPERL 1", 0); // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5a34d23ef..8f2964662 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -110,7 +110,6 @@ static const char *usage1 = "\ Python Options (available with -python)\n\ -builtin - Create new python built-in types, rather than proxy classes, for better performance\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ - -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ -debug-doxygen-parser - Display doxygen parser module debugging information\n\ @@ -123,7 +122,6 @@ Python Options (available with -python)\n\ static const char *usage2 = "\ -newvwm - New value wrapper mode, use only when everything else fails \n\ -nocastmode - Disable the casting mode (default)\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ @@ -310,7 +308,6 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - int cppcast = 1; SWIG_library_directory("python"); @@ -350,12 +347,6 @@ public: use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-outputtuple") == 0) { outputtuple = 1; Swig_mark_arg(i); @@ -443,7 +434,8 @@ public: } else if (strcmp(argv[i], "-relativeimport") == 0) { relativeimport = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-fastinit") == 0 || + } else if (strcmp(argv[i], "-cppcast") == 0 || + strcmp(argv[i], "-fastinit") == 0 || strcmp(argv[i], "-fastquery") == 0 || strcmp(argv[i], "-fastunpack") == 0 || strcmp(argv[i], "-modern") == 0 || @@ -451,8 +443,9 @@ public: strcmp(argv[i], "-noproxydel") == 0 || strcmp(argv[i], "-safecstrings") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); - } else if (strcmp(argv[i], "-buildnone") == 0 || - strcmp(argv[i], "-aliasobj0") == 0 || + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-aliasobj0") == 0 || + strcmp(argv[i], "-buildnone") == 0 || strcmp(argv[i], "-classic") == 0 || strcmp(argv[i], "-classptr") == 0 || strcmp(argv[i], "-new_repr") == 0 || @@ -460,6 +453,7 @@ public: strcmp(argv[i], "-newrepr") == 0 || strcmp(argv[i], "-noaliasobj0") == 0 || strcmp(argv[i], "-nobuildnone") == 0 || + strcmp(argv[i], "-nocppcast") == 0 || strcmp(argv[i], "-nofastinit") == 0 || strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || @@ -469,16 +463,13 @@ public: strcmp(argv[i], "-oldrepr") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - if (doxygen) doxygenTranslator = new PyDocConverter(doxygen_translator_flags); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0fe730c83..a82b8d15a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -208,7 +208,6 @@ static void writeListByLine(List *l, File *out, bool quote = 0) { static const char *usage = "\ R Options (available with -r)\n\ -copystruct - Emit R code to copy C structs (on by default)\n\ - -cppcast - Enable C++ casting operators (default) \n\ -debug - Output debug\n\ -dll - Name of the DLL (without the .dll or .so suffix).\n\ Default is the module name.\n\ @@ -2695,7 +2694,6 @@ String * R::runtimeCode() { Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. **/ void R::main(int argc, char *argv[]) { - bool cppcast = true; init(); Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); @@ -2739,12 +2737,6 @@ void R::main(int argc, char *argv[]) { } else if(!strcmp(argv[i], "-debug")) { debugMode = true; Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-cppcast")) { - cppcast = true; - Swig_mark_arg(i); - } else if (!strcmp(argv[i],"-nocppcast")) { - cppcast = false; - Swig_mark_arg(i); } else if (!strcmp(argv[i],"-copystruct")) { copyStruct = true; Swig_mark_arg(i); @@ -2763,10 +2755,13 @@ void R::main(int argc, char *argv[]) { } else if (!strcmp(argv[i], "-noaggressivegc")) { aggressiveGc = false; Swig_mark_arg(i); - } - - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } if (debugMode) { diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index b88ad3042..306570d96 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -131,12 +131,10 @@ enum autodoc_t { static const char *usage = "\ Ruby Options (available with -ruby)\n\ -autorename - Enable renaming of classes and methods to follow Ruby coding standards\n\ - -cppcast - Enable C++ casting operators (default)\n\ -globalmodule - Wrap everything into the global module\n\ -initname - Set entry function to Init_ (used by `require')\n\ -minherit - Attempt to support multiple inheritance\n\ -noautorename - Disable renaming of classes and methods (default)\n\ - -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -prefix - Set a prefix to be prepended to all names\n\ "; @@ -844,7 +842,6 @@ public: virtual void main(int argc, char *argv[]) { - int cppcast = 1; int autorename = 0; /* Set location of SWIG library */ @@ -883,12 +880,6 @@ public: multipleInheritance = true; director_multiple_inheritance = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-autorename") == 0) { autorename = 1; Swig_mark_arg(i); @@ -907,15 +898,17 @@ public: } } else if (strcmp(argv[i], "-help") == 0) { Printf(stdout, "%s\n", usage); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - /* Turn on cppcast mode */ - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - if (autorename) { /* Turn on the autorename mode */ Preprocessor_define((DOH *) "SWIG_RUBY_AUTORENAME", 0); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 1227af79c..57ef3e97b 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -76,7 +76,6 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - int cppcast = 1; SWIG_library_directory("tcl"); @@ -106,22 +105,19 @@ public: } else if (strcmp(argv[i], "-nosafe") == 0) { nosafe = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-cppcast") == 0) { - cppcast = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nocppcast") == 0) { - cppcast = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-help") == 0) { fputs(usage, stdout); + } else if (strcmp(argv[i], "-cppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is now always on.\n", argv[i]); + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nocppcast") == 0) { + Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); + Swig_mark_arg(i); + SWIG_exit(EXIT_FAILURE); } } } - if (cppcast) { - Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0); - } - Preprocessor_define("SWIGTCL 1", 0); // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); From 0a9b36d3beb0055ad685583fd8d91c715d8e0d7e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Nov 2018 19:46:31 +0000 Subject: [PATCH 1148/2031] Remove -outputtuple and -nooutputtuple command line options (Python) Both the command line and %module options of the same name have been removed. These were undocumented. The -outputtuple option returned a Python tuple instead of a list, mostly typically in the OUTPUT typemap implementations. It unclear why a tuple instead of a list return type is needed and hence this option has been removed as part of the simplification of the SWIG Python command line options for SWIG 4. Issue #1340. --- Lib/python/pyrun.swg | 24 ------------------------ Source/Modules/python.cxx | 21 ++++++--------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 2e1ddddbc..7386ff7e2 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -118,7 +118,6 @@ SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { SWIGINTERN PyObject* SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) if (!result) { result = obj; } else if (result == Py_None) { @@ -134,29 +133,6 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { Py_DECREF(obj); } return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif } /* Unpack the argument tuple */ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8f2964662..6f49765d2 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -90,7 +90,6 @@ static int fastproxy = 0; static int olddefs = 0; static int castmode = 0; static int extranative = 0; -static int outputtuple = 0; static int nortti = 0; static int relativeimport = 0; @@ -130,13 +129,11 @@ static const char *usage2 = "\ -noh - Don't generate the output header file\n"; static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ - -nooutputtuple - Use a PyList for appending output values (default) \n\ -noproxy - Don't generate proxy classes \n\ -noproxyimport - Don't insert proxy import statements derived from the %import directive \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nothreads - Disable thread support for the entire interface\n\ -olddefs - Keep the old method definitions even when using fastproxy\n\ - -outputtuple - Use a PyTuple for outputs instead of a PyList (use carefully with legacy interfaces) \n\ -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ -threads - Add thread support for all the interface\n\ @@ -347,12 +344,6 @@ public: use_kw = 1; SWIG_cparse_set_compact_default_args(1); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-outputtuple") == 0) { - outputtuple = 1; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nooutputtuple") == 0) { - outputtuple = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-nortti") == 0) { nortti = 1; Swig_mark_arg(i); @@ -458,9 +449,11 @@ public: strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || + strcmp(argv[i], "-nooutputtuple") == 0 || strcmp(argv[i], "-nosafecstrings") == 0 || strcmp(argv[i], "-old_repr") == 0 || strcmp(argv[i], "-oldrepr") == 0 || + strcmp(argv[i], "-outputtuple") == 0 || strcmp(argv[i], "-proxydel") == 0) { Printf(stderr, "Deprecated command line option: %s. This option is no longer supported.\n", argv[i]); Swig_mark_arg(i); @@ -530,10 +523,12 @@ public: extranative = 0; } if (Getattr(options, "outputtuple")) { - outputtuple = 1; + Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "outputtuple"); + SWIG_exit(EXIT_FAILURE); } if (Getattr(options, "nooutputtuple")) { - outputtuple = 0; + Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "nooutputtuple"); + SWIG_exit(EXIT_FAILURE); } mod_docstring = Getattr(options, "docstring"); package = Getattr(options, "package"); @@ -613,10 +608,6 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_DIRECTOR_NO_VTABLE\n"); } - if (outputtuple) { - Printf(f_runtime, "#define SWIG_PYTHON_OUTPUT_TUPLE\n"); - } - if (nortti) { Printf(f_runtime, "#ifndef SWIG_DIRECTOR_NORTTI\n"); Printf(f_runtime, "#define SWIG_DIRECTOR_NORTTI\n"); From abb2a9259c7357271d97f4bdfec9dc842cd18985 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 13 Nov 2018 21:55:58 +0000 Subject: [PATCH 1149/2031] Remove -noproxyimport command line option (Python) This option turned off the insertion of Python import statements derived from a %import directive. For example given: %module module_b %import "module_a.i" then module_b.py will contain: import module_a This option was originally added in 658add5, apparently to fix some sort of circular import problem of which there are no details. It is undocumented and is now removed as part of the simplification of the SWIG Python command line options for SWIG 4. Issue #1340. --- Source/Modules/python.cxx | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 6f49765d2..8e7bdd691 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -82,7 +82,6 @@ static int threads = 0; static int nothreads = 0; /* Other options */ -static int shadowimport = 1; static int dirvtable = 0; static int doxygen = 0; static int fastunpack = 1; @@ -130,7 +129,6 @@ static const char *usage2 = "\ static const char *usage3 = "\ -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -noproxy - Don't generate proxy classes \n\ - -noproxyimport - Don't insert proxy import statements derived from the %import directive \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nothreads - Disable thread support for the entire interface\n\ -olddefs - Keep the old method definitions even when using fastproxy\n\ @@ -337,9 +335,6 @@ public: } else if ((strcmp(argv[i], "-noproxy") == 0)) { shadow = 0; Swig_mark_arg(i); - } else if ((strcmp(argv[i], "-noproxyimport") == 0)) { - shadowimport = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-keyword") == 0) { use_kw = 1; SWIG_cparse_set_compact_default_args(1); @@ -450,6 +445,7 @@ public: strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || strcmp(argv[i], "-nooutputtuple") == 0 || + strcmp(argv[i], "-noproxyimport") == 0 || strcmp(argv[i], "-nosafecstrings") == 0 || strcmp(argv[i], "-old_repr") == 0 || strcmp(argv[i], "-oldrepr") == 0 || @@ -1251,18 +1247,18 @@ public: Node *options = Getattr(mod, "options"); String *pkg = options ? Getattr(options, "package") : 0; - if (shadowimport) { - if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { - String *_import = import_directive_string(package, pkg, modname, "_"); - if (!GetFlagAttr(f_shadow_imports, _import)) { - String *import = import_directive_string(package, pkg, modname); - Printf(builtin ? f_shadow_after_begin : f_shadow, "%s", import); - Delete(import); - SetFlag(f_shadow_imports, _import); - } - Delete(_import); + + if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { + String *_import = import_directive_string(package, pkg, modname, "_"); + if (!GetFlagAttr(f_shadow_imports, _import)) { + String *import = import_directive_string(package, pkg, modname); + Printf(builtin ? f_shadow_after_begin : f_shadow, "%s", import); + Delete(import); + SetFlag(f_shadow_imports, _import); } + Delete(_import); } + } } return Language::importDirective(n); From c7363fd95ee97144147aebc7e1cd858c17c78687 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 15 Nov 2018 08:29:17 +0000 Subject: [PATCH 1150/2031] Workaround for Python gcc MingGW WIN32 hypot declaration error Fixes: In file included from C:/msys64/mingw32/include/c++/7.3.0/math.h:36:0, from C:/Python27/include/pyport.h:325, from C:/Python27/include/Python.h:61, from example_wrap.cxx:174: C:/msys64/mingw32/include/c++/7.3.0/cmath:1136:11: error: '::hypot' has not been declared using ::hypot; ^~~~~ See https://stackoverflow.com/questions/28683358/error-hypot-has-not-been-declared-in-cmath-while-trying-to-embed-python/28683412 and https://bugs.python.org/issue11566 --- Lib/python/pyruntime.swg | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index 26d3081a0..751bc8d5f 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -1,4 +1,9 @@ %insert(runtime) %{ +#if defined(__GNUC__) && defined(_WIN32) && !defined(SWIG_PYTHON_NO_HYPOT_WORKAROUND) +/* Workaround for '::hypot' has not been declared', see https://bugs.python.org/issue11566 */ +# include +#endif + #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ # undef _DEBUG From e7638089f75736d85a917d191492d8fd9a6d1bd7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Nov 2018 07:26:49 +0000 Subject: [PATCH 1151/2031] Don't attempt to detect versions of Python < 2.7 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 20e1a348e..985f2ffb0 100644 --- a/configure.ac +++ b/configure.ac @@ -603,7 +603,7 @@ if test x"${PYBIN}" = xno; then 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]) + AC_CHECK_PROGS(PYTHON, [python python2.7]) else PYTHON="$PYBIN" fi From f3ad4e030cb62aa4aba10307ecd4ab25222a8895 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 16 Nov 2018 07:49:00 +0000 Subject: [PATCH 1152/2031] Don't attempt to detect Python 3.0 and 3.1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 985f2ffb0..a515f8bed 100644 --- a/configure.ac +++ b/configure.ac @@ -753,7 +753,7 @@ else if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\" -a $PYVER -ge 3; then PYTHON3="$PYTHON" else - for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0 ""; do + for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 ""; do AC_CHECK_PROGS(PYTHON3, [python$py_ver]) if test -n "$PYTHON3"; then AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config]) From b3cc8fe8f92598e49f0ccf9b54d9e2582fed4149 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 17 Nov 2018 01:37:24 +0000 Subject: [PATCH 1153/2031] configure fix for msys2 + mingw Python For some unknown reason msys2 and mingw adds trailing whitespace when running: python3-config --exec-prefix --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a515f8bed..c9241d0d8 100644 --- a/configure.ac +++ b/configure.ac @@ -826,7 +826,8 @@ else 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` + # Piped through xargs to strip trailing whitespace (bug in msys2 + mingw Python) + PY3EPREFIX=`($PY3CONFIG --exec-prefix | xargs) 2>/dev/null` AC_MSG_RESULT($PY3EPREFIX) # Note: I could not think of a standard way to get the version string from different versions. From 1540ff451f9682f414b8bc73b5491c90f754e8ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 17 Nov 2018 12:22:23 +0000 Subject: [PATCH 1154/2031] 2to3 detection for Windows Python distributions The 2to3 standalone tool does not exist on Windows. Use the 2to3.py script instead. --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index c9241d0d8..ac9efd9d5 100644 --- a/configure.ac +++ b/configure.ac @@ -911,6 +911,17 @@ if test -n "$PYTHON3"; then if test "x$PY2TO3BIN" = xyes; then py3to2=`echo $PYTHON3 | sed -e "s/python/2to3-/"` AC_CHECK_PROGS(PY2TO3, $py3to2 2to3) + if test -z "$PY2TO3"; then + # Windows distributions don't always have the 2to3 executable + AC_MSG_CHECKING(for 2to3.py) + py2to3script="$PY3PREFIX/Tools/scripts/2to3.py" + if test -f "$py2to3script"; then + AC_MSG_RESULT($py2to3script) + PY2TO3="$PYTHON3 $py2to3script" + else + AC_MSG_RESULT(Not found) + fi + fi else PY2TO3="$PY2TO3BIN" fi From 81b0abaf0b81732758ae2d68d230d69824b21f07 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 17 Nov 2018 15:34:19 +0000 Subject: [PATCH 1155/2031] Fix MinGW 64bit native windows Python linking problems Fixes linker error: undefined reference to `__imp_Py_InitModule4' --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 52ff742e0..533b7b532 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -67,6 +67,9 @@ install: $env:MSYSTEM="MINGW$env:MBITS" $env:CC="$env:MARCH-w64-mingw32-gcc" $env:CXX="$env:MARCH-w64-mingw32-g++" + if ($env:MBITS -eq "64" -and $env:SWIGLANG -eq "python") { + $env:CHECK_OPTIONS2="CFLAGS+=-DMS_WIN64 CXXFLAGS+=-DMS_WIN64" + } } - if "%OSVARIANT%"=="" bash -c "cd /usr/bin && curl --retry 15 -s -L https://github.com/swig/cccl/archive/cccl-1.0.tar.gz | tar -xz --strip 1 cccl-cccl-1.0/cccl" - if "%OSVARIANT%"=="" echo Using Visual Studio %VSVER%.0 at %VSCOMNTOOLS% From 72fc01384793314e464a338b5dd49fc5b1e1343b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 15 Nov 2018 07:38:15 +0000 Subject: [PATCH 1156/2031] Revert "Stop testing Python on Appveyor msys/mingw" This reverts commit 6fac581a2b9517b8058f978ea5442026f1340753. --- appveyor.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 533b7b532..19105d32d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,7 +22,8 @@ environment: PY3: 1 - SWIGLANG: python OSVARIANT: cygwin - - OSVARIANT: mingw + - SWIGLANG: python + OSVARIANT: mingw install: - date /T & time /T @@ -87,6 +88,8 @@ install: - bash -c "which $CXX" - bash -c "$CC --version | head -n 1" - bash -c "$CXX --version | head -n 1" +- bash -c "which python" +- bash -c "python -V" - bash -c "make --version | head -n 2" - pwd - echo MAKEJOBS=%MAKEJOBS% @@ -105,9 +108,9 @@ test_script: - .\swig.exe -version - if not "%OSVARIANT%"=="" CCache\ccache-swig -V - bash -c "file ./swig.exe" -- if not "%SWIGLANG%"=="" bash -c "make check-%SWIGLANG%-version %CHECK_OPTIONS%" -- if not "%SWIGLANG%"=="" bash -c "time make -k check-%SWIGLANG%-examples %CHECK_OPTIONS%" -- if not "%SWIGLANG%"=="" bash -c "time make -k check-%SWIGLANG%-test-suite -j%MAKEJOBS% %CHECK_OPTIONS%" +- bash -c "make check-%SWIGLANG%-version" +- bash -c "time make -k check-%SWIGLANG%-examples %CHECK_OPTIONS%" +- bash -c "time make -k check-%SWIGLANG%-test-suite -j%MAKEJOBS% %CHECK_OPTIONS%" # Do not build on tags (GitHub only) skip_tags: true From 902f3f0ac58faaacbb4f53f73449b8da42486bb1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Nov 2018 19:30:05 +0000 Subject: [PATCH 1157/2031] Appveyor mingw config changes to test Python Set paths correctly for msys2 + mingw. With this correction, there is no need to override the default gcc. Provide a way to specify the name of the python interpreter using a WITHLANG env variable. Needed where the native python3 executable is called python.exe which is needed and not MinGW's pre-installed python3.exe. --- appveyor.yml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 19105d32d..1eb7ae41d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,11 +19,17 @@ environment: - SWIGLANG: python VSVER: 14 VER: 36 - PY3: 1 + PY3: 3 - SWIGLANG: python OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw + VER: 27 + - SWIGLANG: python + OSVARIANT: mingw + WITHLANG: python + VER: 37 + PY3: 3 install: - date /T & time /T @@ -64,10 +70,11 @@ install: $env:CC="gcc" $env:CXX="g++" } elseif ($env:OSVARIANT -eq "mingw") { - $env:PATH="$env:MSYSBIN;$env:MINGWBIN;$env:PATH" - $env:MSYSTEM="MINGW$env:MBITS" - $env:CC="$env:MARCH-w64-mingw32-gcc" - $env:CXX="$env:MARCH-w64-mingw32-g++" + # Note mingw setup tests the native Windows Python distribution (not MinGW Python) with gcc + $env:PATH="$env:MINGWBIN;$env:MSYSBIN;$env:PATH" + $env:MSYSTEM="MINGW$env:MBITS" # This is important for msys2 + $env:CC="gcc" + $env:CXX="g++" if ($env:MBITS -eq "64" -and $env:SWIGLANG -eq "python") { $env:CHECK_OPTIONS2="CFLAGS+=-DMS_WIN64 CXXFLAGS+=-DMS_WIN64" } @@ -77,13 +84,15 @@ install: - if "%OSVARIANT%"=="" call "%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %VCVARS_PLATFORM% - if "%OSVARIANT%"=="" Tools\nuget-install.cmd pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre - if "%OSVARIANT%"=="" set PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native -- if "%OSVARIANT%"=="" set PATH=C:\Python%VER%%LANG_PLATFORM%;%PATH% +- if not "%OSVARIANT%"=="cygwin" set PATH=C:\Python%VER%%LANG_PLATFORM%;%PATH% - if "%OSVARIANT%"=="" bash -c "which cl.exe" - if "%OSVARIANT%"=="" bash -c "cl.exe /? 2>&1 | head -n 1" - if "%OSVARIANT%"=="" bash -c "which csc.exe" - if "%OSVARIANT%"=="" bash -c "csc.exe /? | head -n 1" - if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt" - if "%OSVARIANT%"=="mingw" bash -c "pacman --noconfirm --sync mingw%MBITS%/mingw-w64-%MARCH%-pcre mingw%MBITS%/mingw-w64-%MARCH%-boost" +- if not "%WITHLANG%"=="" set SWIGWITHLANG==%WITHLANG% +- if not "%WITHLANG%"=="" where %WITHLANG% - bash -c "which $CC" - bash -c "which $CXX" - bash -c "$CC --version | head -n 1" @@ -100,7 +109,7 @@ build_script: - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Thu, 22 Nov 2018 08:15:36 +0000 Subject: [PATCH 1158/2031] Update changes file with recent commandline option changes --- CHANGES.current | 51 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 6db8329c7..3d8a78f6f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,44 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-11-13: wsfulton + #1340 Remove -cppcast and -nocppcast command line options (this was an option + available to the scripting language targets). + + The -cppcast option is still turned on by default. The -nocppcast option + to turn off the use of c++ casts (const_cast, static_cast etc) has been + removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts + instead of C++ casts for C++ wrappers. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-11-13: wsfulton + [Python] #1340 Remove -outputtuple and -nooutputtuple command line options. + + Both the command line and %module options of the same name have been + removed. These were undocumented. The -outputtuple option returned a + Python tuple instead of a list, mostly typically in the OUTPUT + typemap implementations. + + It unclear why a tuple instead of a list return type is needed and + hence this option has been removed as part of the simplification of + the SWIG Python command line options for SWIG 4. + +2018-11-13: wsfulton + [Python] #1340 Remove -noproxyimport command line option. + + This option turned off the insertion of Python import statements + derived from a %import directive. For example given: + + %module module_b + %import "module_a.i" + + then module_b.py will contain: + + import module_a + + *** POTENTIAL INCOMPATIBILITY *** + 2018-10-29: AlexanderGabriel [PHP] The following PHP7 reserved keywords are now only renamed by SWIG when used as function names in the API being wrapper: @@ -42,17 +80,27 @@ Version 4.0.0 (in progress) -safecstrings No discernable difference The following options have been removed altogether: - -buildnone -aliasobj0 + -buildnone + -classptr + -new_repr + -newrepr -noaliasobj0 -nobuildnone -nofastinit -nofastquery -nomodern -nomodernargs + -nooutputtuple -nosafecstrings + -old_repr + -oldrepr -proxydel + -new_vwm is no longer supported. Use the -newvwm alias instead. + + *** POTENTIAL INCOMPATIBILITY *** + 2018-10-22: olly [Python] #1261 Remove command line option no longer needed as Python 2.3 and earlier are no longer supported: @@ -116,6 +164,7 @@ Version 4.0.0 (in progress) implementation which uses PyInstanceMethod_New. The new approach runs slightly faster. See #1310. + 2018-08-12: gmazzamuto [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. From 3208ff2bf54f523da3b0fd849df3cf7e686771fa Mon Sep 17 00:00:00 2001 From: Christian Landsiedel Date: Thu, 22 Nov 2018 14:24:49 +0100 Subject: [PATCH 1159/2031] fix for creating new shadow class in python 3.6 --- Lib/python/pyrun.swg | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 7386ff7e2..650e30d3e 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1205,12 +1205,16 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #if PY_VERSION_HEX >= 0x03000000 PyObject *empty_args = PyTuple_New(0); if (empty_args) { - inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, Py_None); - Py_DECREF(empty_args); - if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + PyObject *empty_kwargs = PyDict_New(); + if (empty_kwargs) { + inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); + Py_DECREF(empty_kwargs); + if (inst) { + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } } + Py_DECREF(empty_args); } #else PyObject *dict = PyDict_New(); From 55e1b5518b8e34c2ce9accdc9c2025c5a1d2e0ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Nov 2018 18:12:37 +0000 Subject: [PATCH 1160/2031] Update changes file with runnable Python modules fix --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 3d8a78f6f..2eb05fe25 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-11-22: rupertnash + [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) + + Previously any SWIG generated modules in a package would fail with an ImportError + when using 'python -m'. + 2018-11-13: wsfulton #1340 Remove -cppcast and -nocppcast command line options (this was an option available to the scripting language targets). From 2c16de295b772c44b8551f3d0688888339e41c03 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 23 Nov 2018 02:20:46 +0100 Subject: [PATCH 1161/2031] Remove unused cparse_template_expand() return type No real changes, just make a function which always returned 0 void as its return value was never used anyhow. --- Source/CParse/templ.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index e575073a4..3cc58de1b 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -49,32 +49,31 @@ void Swig_cparse_debug_templates(int x) { * template parameters * ----------------------------------------------------------------------------- */ -static int cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { +static void cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { static int expanded = 0; - int ret; String *nodeType; if (!n) - return 0; + return; nodeType = nodeType(n); if (Getattr(n, "error")) - return 0; + return; if (Equal(nodeType, "template")) { /* Change the node type back to normal */ if (!expanded) { expanded = 1; set_nodeType(n, Getattr(n, "templatetype")); - ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); expanded = 0; - return ret; + return; } else { /* Called when template appears inside another template */ /* Member templates */ set_nodeType(n, Getattr(n, "templatetype")); - ret = cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); set_nodeType(n, "template"); - return ret; + return; } } else if (Equal(nodeType, "cdecl")) { /* A simple C declaration */ @@ -221,7 +220,6 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String cn = nextSibling(cn); } } - return 0; } static From 4af2e950106add265cc6e42235547870bd2809a5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 23 Nov 2018 02:45:24 +0100 Subject: [PATCH 1162/2031] Stop mangling dtors of nested classes instead a template class cparse_template_expand() incorrectly appended template parameters to all destructor nodes it encountered during the tree traversal, including the dtors of any nested classes. This resulted in WARN_LANG_ILLEGAL_DESTRUCTOR warnings from Language::destructorDeclaration() later and possibly other problems due to not actually wrapping these dtors. Fix this by explicitly checking if the dtor is a child or, to account for %extend, a grandchild of the template node itself before appending template parameters to it. This commit is best viewed with "-w" (ignore whitespace changes) option as it indents, without changing, a block of code. --- Source/CParse/templ.c | 51 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 3cc58de1b..93c5dec2c 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -49,7 +49,7 @@ void Swig_cparse_debug_templates(int x) { * template parameters * ----------------------------------------------------------------------------- */ -static void cparse_template_expand(Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { +static void cparse_template_expand(Node *templnode, Node *n, String *tname, String *rname, String *templateargs, List *patchlist, List *typelist, List *cpatchlist) { static int expanded = 0; String *nodeType; if (!n) @@ -63,7 +63,7 @@ static void cparse_template_expand(Node *n, String *tname, String *rname, String if (!expanded) { expanded = 1; set_nodeType(n, Getattr(n, "templatetype")); - cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(templnode, n, tname, rname, templateargs, patchlist, typelist, cpatchlist); expanded = 0; return; } else { @@ -71,7 +71,7 @@ static void cparse_template_expand(Node *n, String *tname, String *rname, String /* Member templates */ set_nodeType(n, Getattr(n, "templatetype")); - cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(templnode, n, tname, rname, templateargs, patchlist, typelist, cpatchlist); set_nodeType(n, "template"); return; } @@ -130,7 +130,7 @@ static void cparse_template_expand(Node *n, String *tname, String *rname, String { Node *cn = firstChild(n); while (cn) { - cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } @@ -176,25 +176,30 @@ static void cparse_template_expand(Node *n, String *tname, String *rname, String add_parms(Getattr(n, "parms"), cpatchlist, typelist); 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); - } - 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); + /* We only need to patch the dtor of the template itself, not the destructors of any nested classes, so check that the parent of this node is the root + * template node, with the special exception for %extend which adds its methods under an intermediate node. */ + Node* parent = parentNode(n); + if (parent == templnode || (parentNode(parent) == templnode && Equal(nodeType(parent), "extend"))) { + String *name = Getattr(n, "name"); + if (name) { + if (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); + } + } + /* Setattr(n,"sym:name",name); */ + Append(cpatchlist, Getattr(n, "code")); } - /* Setattr(n,"sym:name",name); */ - Append(cpatchlist, Getattr(n, "code")); } else if (Equal(nodeType, "using")) { String *uname = Getattr(n, "uname"); if (uname && strchr(Char(uname), '<')) { @@ -216,7 +221,7 @@ static void cparse_template_expand(Node *n, String *tname, String *rname, String add_parms(Getattr(n, "throws"), cpatchlist, typelist); cn = firstChild(n); while (cn) { - cparse_template_expand(cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); cn = nextSibling(cn); } } @@ -304,7 +309,7 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab /* Printf(stdout,"targs = '%s'\n", templateargs); Printf(stdout,"rname = '%s'\n", rname); Printf(stdout,"tname = '%s'\n", tname); */ - cparse_template_expand(n, tname, rname, templateargs, patchlist, typelist, cpatchlist); + cparse_template_expand(n, n, tname, rname, templateargs, patchlist, typelist, cpatchlist); /* Set the name */ { From 65edf2258f359078e98291fb348bccc88653539a Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Fri, 23 Nov 2018 16:02:46 +0000 Subject: [PATCH 1163/2031] #1360: Leak of SWIG var link object --- CHANGES.current | 5 +++++ Lib/python/pyinit.swg | 8 ++++++-- Source/Modules/python.cxx | 15 +++++++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2eb05fe25..bcd081557 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-11-23: adr26 + [Python] #1360 Leak of SWIG var link object + + Fix reference counting on _SWIG_globals to allow var link to be freed on module unload. + 2018-11-22: rupertnash [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 621d6f9ed..dd58bad0b 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -227,7 +227,11 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + if (!_SWIG_globals) { + _SWIG_globals = SWIG_newvarlink(); + } else { + Py_INCREF(_SWIG_globals); + } return _SWIG_globals; } @@ -326,7 +330,7 @@ SWIGEXPORT void #endif SWIG_init(void) { - PyObject *m, *d, *md; + PyObject *m, *d, *md, *globals; #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f1434c603..5268b3f04 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3320,11 +3320,21 @@ public: getf = NewWrapper(); setf = NewWrapper(); + Printf(f_init, "\t globals = SWIG_globals();\n"); + Printf(f_init, "\t if (!globals) {\n"); + Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Failure to create SWIG globals.\");\n"); + Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); + Printf(f_init, "\t return NULL;\n"); + Printf(f_init, "#else\n"); + Printf(f_init, "\t return;\n"); + Printf(f_init, "#endif\n"); + Printf(f_init, "\t }\n"); + /* If this is our first call, add the globals variable to the Python dictionary. */ if (!have_globals) { - Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", SWIG_globals());\n", global_name); + Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", globals);\n", global_name); if (builtin) Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name); have_globals = 1; @@ -3412,11 +3422,12 @@ public: Wrapper_print(getf, f_wrappers); /* Now add this to the variable linking mechanism */ - Printf(f_init, "\t SWIG_addvarlink(SWIG_globals(), \"%s\", %s, %s);\n", iname, vargetname, varsetname); + Printf(f_init, "\t SWIG_addvarlink(globals,\"%s\",%s, %s);\n", iname, vargetname, varsetname); if (builtin && shadow && !assignable && !in_class) { Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname); Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", iname); } + Printf(f_init, "\t Py_DECREF(globals);\n"); Delete(vargetname); Delete(varsetname); Delete(getname); From 0f61c5a84743268d808bd8da372a27f8e2e88cbc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Nov 2018 18:08:33 +0000 Subject: [PATCH 1164/2031] Python minimum version checking fixes When using the moduleimport option, such as: %module(moduleimport="import $module") example the minimum Python version check disappeared from the generated Python file. The code has been refactored and _swig_python_version_info is no longer deleted after initial use as it can be used in a few places, in particular, when -builtin is used. --- Source/Modules/python.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f1434c603..19798b5f8 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -693,10 +693,6 @@ public: mod_docstring = NULL; } - Printv(default_import_code, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); - Printv(default_import_code, "if _swig_python_version_info < (2, 7, 0):\n", NULL); - Printv(default_import_code, tab4, "raise RuntimeError('Python 2.7 or later required')\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 @@ -748,10 +744,6 @@ public: Printf(default_import_code, tab4 "from %s import *\n", module); } - /* Delete the _swig_python_version_info symbol since we don't use it elsewhere in the - * module. */ - Printv(default_import_code, "del _swig_python_version_info\n\n", NULL); - /* Need builtins to qualify names like Exception that might also be defined in this module (try both Python 3 and Python 2 names) */ Printv(f_shadow, "try:\n", tab4, "import builtins as __builtin__\n", "except ImportError:\n", tab4, "import __builtin__\n", NULL); @@ -910,13 +902,19 @@ public: Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); if (Len(f_shadow_after_begin) > 0) Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL); + + Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); + Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL); + Printv(f_shadow_py, tab4, "raise RuntimeError('Python 2.7 or later required')\n\n", NULL); + if (moduleimport) { Replaceall(moduleimport, "$module", module); - Printv(f_shadow_py, "\n", moduleimport, "\n", NIL); + Printv(f_shadow_py, moduleimport, "\n", NIL); } else { Printv(f_shadow_py, default_import_code, NIL); } - Printv(f_shadow_py, f_shadow, "\n", NIL); + + Printv(f_shadow_py, "\n", f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); Delete(f_shadow_py); } @@ -1123,14 +1121,12 @@ public: Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod); Delete(apkg); } else { - Printf(out, "from sys import version_info as _swig_python_version_info\n"); Printf(out, "if _swig_python_version_info >= (2, 7, 0):\n"); if (py3_rlen1) Printf(out, tab4 "from . import %.*s\n", py3_rlen1, rpkg); Printf(out, tab4 "from .%s import %s%s\n", rpkg, pfx, mod); Printf(out, "else:\n"); Printf(out, tab4 "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod); - Printf(out, "del _swig_python_version_info\n"); Delete(rpkg); } return out; From 0f18b430fb39d44e126f9f981462c47fca7b8dba Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Wed, 21 Nov 2018 19:19:15 -0500 Subject: [PATCH 1165/2031] Add unordered_{set|map} and set to Java Add test suite Add to makefile Revert set change Fix java map test Fix some of the tests Fix unordered map test --- Examples/test-suite/java/Makefile.in | 4 + .../test-suite/java/li_std_map_runme.java | 101 ++++++++++++++++++ .../test-suite/java/li_std_set_runme.java | 40 +++++++ .../java/li_std_unordered_map_runme.java | 101 ++++++++++++++++++ .../java/li_std_unordered_set_runme.java | 40 +++++++ Examples/test-suite/li_std_set.i | 25 ++--- Examples/test-suite/li_std_unordered_map.i | 12 +++ Examples/test-suite/li_std_unordered_set.i | 11 ++ Lib/java/std_set.i | 47 ++++++++ Lib/java/std_unordered_map.i | 65 +++++++++++ Lib/java/std_unordered_set.i | 47 ++++++++ 11 files changed, 481 insertions(+), 12 deletions(-) create mode 100644 Examples/test-suite/java/li_std_map_runme.java create mode 100644 Examples/test-suite/java/li_std_set_runme.java create mode 100644 Examples/test-suite/java/li_std_unordered_map_runme.java create mode 100644 Examples/test-suite/java/li_std_unordered_set_runme.java create mode 100644 Examples/test-suite/li_std_unordered_map.i create mode 100644 Examples/test-suite/li_std_unordered_set.i create mode 100644 Lib/java/std_set.i create mode 100644 Lib/java/std_unordered_map.i create mode 100644 Lib/java/std_unordered_set.i diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 8a98172ed..acb0ef2e3 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -44,6 +44,10 @@ CPP_TEST_CASES = \ java_typemaps_proxy \ java_typemaps_typewrapper \ li_std_list \ + li_std_map \ + li_std_set \ + li_std_unordered_map \ + li_std_unordered_set \ # li_boost_intrusive_ptr CPP11_TEST_CASES = \ diff --git a/Examples/test-suite/java/li_std_map_runme.java b/Examples/test-suite/java/li_std_map_runme.java new file mode 100644 index 000000000..3cc794ced --- /dev/null +++ b/Examples/test-suite/java/li_std_map_runme.java @@ -0,0 +1,101 @@ +import li_std_map.*; + +public class li_std_map_runme { + + static { + try { + System.loadLibrary("li_std_map"); + } 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[]) throws Throwable + { + StringIntMap sim = new StringIntMap(); + IntIntMap iim = new IntIntMap(); + + if (!sim.empty()) throw new RuntimeException("Test (1) failed"); + if (!iim.empty()) throw new RuntimeException("Test (2) failed"); + + if (sim.size() != 0) throw new RuntimeException("Test (3) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (4) failed"); + + try { + sim.get("key"); + throw new RuntimeException("Test (5) failed"); + } catch (IndexOutOfBoundsException e) { + } + + try { + iim.get(1); + throw new RuntimeException("Test (6) failed"); + } catch (IndexOutOfBoundsException e) { + } + + sim.set("key", 1); + iim.set(1, 1); + + if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); + if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); + + sim.del("key"); + iim.del(1); + + if (sim.has_key("key")) throw new RuntimeException("Test (9) failed"); + if (iim.has_key(1)) throw new RuntimeException("Test (10) failed"); + + if (!sim.empty()) throw new RuntimeException("Test (11) failed"); + if (!iim.empty()) throw new RuntimeException("Test (12) failed"); + if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); + + try { + sim.del("key"); + throw new RuntimeException("Test (15) failed"); + } catch (IndexOutOfBoundsException e) { + } + + try { + iim.del(1); + throw new RuntimeException("Test (16) failed"); + } catch (IndexOutOfBoundsException e) { + } + + sim.set("key", 1); + iim.set(1, 1); + + if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); + if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); + + sim.clear(); + iim.clear(); + + if (sim.has_key("key")) throw new RuntimeException("Test (19) failed"); + if (iim.has_key(1)) throw new RuntimeException("Test (20) failed"); + + if (!sim.empty()) throw new RuntimeException("Test (21) failed"); + if (!iim.empty()) throw new RuntimeException("Test (22) failed"); + if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); + + sim.set("key", 1); + sim.set("key2", 2); + iim.set(1, 1); + iim.set(2, 2); + + if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); + if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); + if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); + if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); + + sim.set("key", 3); + iim.set(1, 3); + + if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); + if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); + if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); + if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); + } +} diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java new file mode 100644 index 000000000..61edd93dc --- /dev/null +++ b/Examples/test-suite/java/li_std_set_runme.java @@ -0,0 +1,40 @@ +import li_std_set.*; + +public class li_std_set_runme { + + static { + try { + System.loadLibrary("li_std_set"); + } 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[]) throws Throwable + { + StringSet ss = new StringSet(); + + if (!ss.empty()) throw new RuntimeException("Test (1) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (2) failed"); + if (ss.has("key")) throw new RuntimeException("Test (3) failed"); + if (ss.erase("key")) throw new RuntimeException("Test (4) failed"); + + if (!ss.insert("key")) throw new RuntimeException("Test (5) failed"); + if (ss.insert("key")) throw new RuntimeException("Test (6) failed"); + if (!ss.has("key")) throw new RuntimeException("Test (7) failed"); + + if (!ss.erase("key")) throw new RuntimeException("Test (8) failed"); + if (!ss.empty()) throw new RuntimeException("Test (9) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (10) failed"); + + if (!ss.insert("key1")) throw new RuntimeException("Test (11) failed"); + if (!ss.insert("key2")) throw new RuntimeException("Test (12) failed"); + if (!ss.insert("key3")) throw new RuntimeException("Test (13) failed"); + if (ss.size() != 3) throw new RuntimeException("Test (14) failed"); + + ss.clear(); + if (!ss.empty()) throw new RuntimeException("Test (15) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (16) failed"); + } +} diff --git a/Examples/test-suite/java/li_std_unordered_map_runme.java b/Examples/test-suite/java/li_std_unordered_map_runme.java new file mode 100644 index 000000000..8ab6f23e4 --- /dev/null +++ b/Examples/test-suite/java/li_std_unordered_map_runme.java @@ -0,0 +1,101 @@ +import li_std_unordered_map.*; + +public class li_std_unordered_map_runme { + + static { + try { + System.loadLibrary("li_std_unordered_map"); + } 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[]) throws Throwable + { + StringIntUnorderedMap sim = new StringIntUnorderedMap(); + IntIntUnorderedMap iim = new IntIntUnorderedMap(); + + if (!sim.empty()) throw new RuntimeException("Test (1) failed"); + if (!iim.empty()) throw new RuntimeException("Test (2) failed"); + + if (sim.size() != 0) throw new RuntimeException("Test (3) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (4) failed"); + + try { + sim.get("key"); + throw new RuntimeException("Test (5) failed"); + } catch (IndexOutOfBoundsException e) { + } + + try { + iim.get(1); + throw new RuntimeException("Test (6) failed"); + } catch (IndexOutOfBoundsException e) { + } + + sim.set("key", 1); + iim.set(1, 1); + + if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); + if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); + + sim.del("key"); + iim.del(1); + + if (sim.has_key("key")) throw new RuntimeException("Test (9) failed"); + if (iim.has_key(1)) throw new RuntimeException("Test (10) failed"); + + if (!sim.empty()) throw new RuntimeException("Test (11) failed"); + if (!iim.empty()) throw new RuntimeException("Test (12) failed"); + if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); + + try { + sim.del("key"); + throw new RuntimeException("Test (15) failed"); + } catch (IndexOutOfBoundsException e) { + } + + try { + iim.del(1); + throw new RuntimeException("Test (16) failed"); + } catch (IndexOutOfBoundsException e) { + } + + sim.set("key", 1); + iim.set(1, 1); + + if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); + if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); + + sim.clear(); + iim.clear(); + + if (sim.has_key("key")) throw new RuntimeException("Test (19) failed"); + if (iim.has_key(1)) throw new RuntimeException("Test (20) failed"); + + if (!sim.empty()) throw new RuntimeException("Test (21) failed"); + if (!iim.empty()) throw new RuntimeException("Test (22) failed"); + if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); + if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); + + sim.set("key", 1); + sim.set("key2", 2); + iim.set(1, 1); + iim.set(2, 2); + + if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); + if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); + if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); + if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); + + sim.set("key", 3); + iim.set(1, 3); + + if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); + if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); + if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); + if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); + } +} diff --git a/Examples/test-suite/java/li_std_unordered_set_runme.java b/Examples/test-suite/java/li_std_unordered_set_runme.java new file mode 100644 index 000000000..ce94f8fe4 --- /dev/null +++ b/Examples/test-suite/java/li_std_unordered_set_runme.java @@ -0,0 +1,40 @@ +import li_std_unordered_set.*; + +public class li_std_unordered_set_runme { + + static { + try { + System.loadLibrary("li_std_unordered_set"); + } 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[]) throws Throwable + { + StringUnorderedSet ss = new StringUnorderedSet(); + + if (!ss.empty()) throw new RuntimeException("Test (1) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (2) failed"); + if (ss.has("key")) throw new RuntimeException("Test (3) failed"); + if (ss.erase("key")) throw new RuntimeException("Test (4) failed"); + + if (!ss.insert("key")) throw new RuntimeException("Test (5) failed"); + if (ss.insert("key")) throw new RuntimeException("Test (6) failed"); + if (!ss.has("key")) throw new RuntimeException("Test (7) failed"); + + if (!ss.erase("key")) throw new RuntimeException("Test (8) failed"); + if (!ss.empty()) throw new RuntimeException("Test (9) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (10) failed"); + + if (!ss.insert("key1")) throw new RuntimeException("Test (11) failed"); + if (!ss.insert("key2")) throw new RuntimeException("Test (12) failed"); + if (!ss.insert("key3")) throw new RuntimeException("Test (13) failed"); + if (ss.size() != 3) throw new RuntimeException("Test (14) failed"); + + ss.clear(); + if (!ss.empty()) throw new RuntimeException("Test (15) failed"); + if (ss.size() != 0) throw new RuntimeException("Test (16) failed"); + } +} diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 2dcc2f17c..fc9db42a9 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -1,5 +1,5 @@ /* - * a test of set containers. + * a test of set containers. * Languages should define swig::LANGUAGE_OBJ to be * an entity of their native pointer type which can be * included in a STL container. @@ -13,22 +13,23 @@ %include %include -%include %include -%template(set_string) std::set; -%template(set_int) std::multiset; - - -%template(v_int) std::vector; - - - +// Use language macros since Java doesn't have multiset support (yet) +// and uses different naming conventions. +#if defined(SWIGRUBY) || defined(SWIGPYTHON) + %include + %template(set_int) std::multiset; + %template(v_int) std::vector; + %template(set_string) std::set; +#elif defined(SWIGJAVA) + %template(StringSet) std::set; +#endif #if defined(SWIGRUBY) -%template(LanguageSet) std::set; +%template(LanguageSet) std::set; #endif #if defined(SWIGPYTHON) -%template(pyset) std::set; +%template(pyset) std::set; #endif diff --git a/Examples/test-suite/li_std_unordered_map.i b/Examples/test-suite/li_std_unordered_map.i new file mode 100644 index 000000000..a6869cc0b --- /dev/null +++ b/Examples/test-suite/li_std_unordered_map.i @@ -0,0 +1,12 @@ +/* + * A test of unordered_map containers. + */ + +%module li_std_unordered_map + +%include +%include + +%template(IntIntUnorderedMap) std::unordered_map; +%template(StringIntUnorderedMap) std::unordered_map; + diff --git a/Examples/test-suite/li_std_unordered_set.i b/Examples/test-suite/li_std_unordered_set.i new file mode 100644 index 000000000..a051e9389 --- /dev/null +++ b/Examples/test-suite/li_std_unordered_set.i @@ -0,0 +1,11 @@ +/* + * A test of unordered_set containers. + */ + +%module li_std_unordered_set + +%include +%include + +%template(StringUnorderedSet) std::unordered_set; + diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i new file mode 100644 index 000000000..8c4bb7f17 --- /dev/null +++ b/Lib/java/std_set.i @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * std_set.i + * + * SWIG typemaps for std::set + * ----------------------------------------------------------------------------- */ + +%include + +// ------------------------------------------------------------------------ +// std::set +// ------------------------------------------------------------------------ + +%{ +#include +%} + +namespace std { + +template +class set { + public: + set(); + set(const set&); + + unsigned int size() const; + bool empty() const; + void clear(); + + %extend { + // Returns whether item was inserted. + bool insert(const KeyType& key) { + return self->insert(key).second; + } + + // Returns whether set contains key. + bool has(const KeyType& key) { + return (self->count(key) > 0); + } + + // Returns whether the item was erased. + bool erase(const KeyType& key) { + return (self->erase(key) > 0); + } + } +}; + +} // namespace std \ No newline at end of file diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i new file mode 100644 index 000000000..434292b07 --- /dev/null +++ b/Lib/java/std_unordered_map.i @@ -0,0 +1,65 @@ +/* ----------------------------------------------------------------------------- + * std_unordered_map.i + * + * SWIG typemaps for std::unordered_map + * ----------------------------------------------------------------------------- */ + +%include + +// ------------------------------------------------------------------------ +// std::unordered_map +// ------------------------------------------------------------------------ + +%{ +#include +#include +%} + +namespace std { + +template class unordered_map { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef KeyType key_type; + typedef MappedType mapped_type; + unordered_map(); + unordered_map(const unordered_map&); + + unsigned int size() const; + bool empty() const; + void clear(); + + %extend { + const MappedType& get(const KeyType& key) throw (std::out_of_range) { + std::unordered_map::iterator i = self->find(key); + + if (i != self->end()) { + return i->second; + } else { + throw std::out_of_range("key not found"); + } + } + + void set(const KeyType& key, const MappedType& x) { + (*self)[key] = x; + } + + void del(const KeyType& key) throw (std::out_of_range) { + std::unordered_map::iterator i = self->find(key); + + if (i != self->end()) { + self->erase(i); + } else { + throw std::out_of_range("key not found"); + } + } + + bool has_key(const KeyType& key) { + std::unordered_map::iterator i = self->find(key); + return i != self->end(); + } + } +}; + +} // namespace std diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i new file mode 100644 index 000000000..a9fac0f82 --- /dev/null +++ b/Lib/java/std_unordered_set.i @@ -0,0 +1,47 @@ +/* ----------------------------------------------------------------------------- + * std_unordered_set.i + * + * SWIG typemaps for std::unordered_set + * ----------------------------------------------------------------------------- */ + +%include + +// ------------------------------------------------------------------------ +// std::unordered_set +// ------------------------------------------------------------------------ + +%{ +#include +%} + +namespace std { + +template +class unordered_set { + public: + unordered_set(); + unordered_set(const unordered_set&); + + unsigned int size() const; + bool empty() const; + void clear(); + + %extend { + // Returns whether item was inserted. + bool insert(const KeyType& key) { + return self->insert(key).second; + } + + // Returns whether set contains key. + bool has(const KeyType& key) { + return (self->count(key) > 0); + } + + // Returns whether the item was erased. + bool erase(const KeyType& key) { + return (self->erase(key) > 0); + } + } +}; + +} // namespace std \ No newline at end of file From 4fe9406fae90fd01463d3199184fd53112a3f0e3 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Sat, 24 Nov 2018 10:00:23 -0500 Subject: [PATCH 1166/2031] Add test cases to C++11 list --- Examples/test-suite/java/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index acb0ef2e3..b5b1d65c7 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -46,8 +46,6 @@ CPP_TEST_CASES = \ li_std_list \ li_std_map \ li_std_set \ - li_std_unordered_map \ - li_std_unordered_set \ # li_boost_intrusive_ptr CPP11_TEST_CASES = \ @@ -56,6 +54,8 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ + li_std_unordered_map \ + li_std_unordered_set \ DOXYGEN_TEST_CASES := \ doxygen_parsing_enums_simple \ From 30bb977a6436fa7903aca041606c1110d37a2401 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 21 Nov 2018 00:07:14 +0100 Subject: [PATCH 1167/2031] Fix handling of abstract base classes nested inside templates Code handling %template in the parser created a totally new top-level module child of namespace type when handling templates inside a namespace and copied the nodes from the previously parsed C++ template declaration to it. However copies of this node kept their original values of "abstracts" attribute, which contained pointers to the classes in the original template declaration, i.e. outside of the subtree created for the instantiated template. This, in turn, meant that during the types resolution pass, the code in TypePass did not update the types used in the methods of the classes appearing in the "abstracts" List, even though it did update the types for the children of the instantiated template subtree. And this finally resulted in wrongly detecting overridden virtual methods as abstract in Allocate::is_abstract_inherit() during the next pass, as the signatures of the overridden method -- using resolved types -- and of the method from the class pointed to by "abstract" -- using the original types from C++ code -- didn't match. Resolve this simply by not copying "abstracts" attributes when creating the template subtree and doing another pass over this tree to recreate them using the new nodes, just as it's already done for "defaultargs" attribute, presumably for similar reasons. Note that doing another pass over the tree is not as efficient as doing everything in a single pass, but merging the new update_abstracts() with update_defaultargs() is not completely obvious, so for now keep it simple and optimize it later if necessary. Also, add a test checking for the situation described above. Closes #1353. --- CHANGES.current | 8 +++++ .../csharp/nested_in_template_runme.cs | 10 ++++++ Examples/test-suite/nested_in_template.i | 34 +++++++++++++++++++ .../python/nested_in_template_runme.py | 5 +++ Source/CParse/parser.y | 22 ++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 Examples/test-suite/csharp/nested_in_template_runme.cs create mode 100644 Examples/test-suite/nested_in_template.i create mode 100644 Examples/test-suite/python/nested_in_template_runme.py diff --git a/CHANGES.current b/CHANGES.current index 2eb05fe25..f32583568 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-11-24: vadz + #1358 Fix handling of abstract base classes nested inside templates + + Correct detecting of whether a derived class method overrides a pure virtual + base class method when both classes are nested inside a template class: this + notably didn't work correctly for methods taking parameters of the base class + type. + 2018-11-22: rupertnash [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) diff --git a/Examples/test-suite/csharp/nested_in_template_runme.cs b/Examples/test-suite/csharp/nested_in_template_runme.cs new file mode 100644 index 000000000..6d6f2e8a1 --- /dev/null +++ b/Examples/test-suite/csharp/nested_in_template_runme.cs @@ -0,0 +1,10 @@ +using System; +using nested_in_templateNamespace; + +public class runme { + static void Main() { + var cd = new OuterTemplate1.ConcreteDerived(8.8); + if (cd.m_value != 8.8) + throw new Exception("ConcreteDerived not created correctly"); + } +} diff --git a/Examples/test-suite/nested_in_template.i b/Examples/test-suite/nested_in_template.i new file mode 100644 index 000000000..d878c62b0 --- /dev/null +++ b/Examples/test-suite/nested_in_template.i @@ -0,0 +1,34 @@ +%module nested_in_template + +#if !defined(SWIGCSHARP) && !defined(SWIGJAVA) +%feature("flatnested"); +#endif + +%inline %{ +template +struct OuterTemplate; + +template <> +struct OuterTemplate<1> +{ + struct AbstractBase + { + virtual bool IsSameAs(const AbstractBase& other) const = 0; + virtual ~AbstractBase() {} + }; + + struct ConcreteDerived : AbstractBase + { + ConcreteDerived() : m_value(0.) {} + explicit ConcreteDerived(double value) : m_value(value) {} + + virtual bool IsSameAs(const AbstractBase& other) const { + return m_value == static_cast(other).m_value; + } + + double m_value; + }; +}; +%} + +%template(OuterTemplate1) OuterTemplate<1>; diff --git a/Examples/test-suite/python/nested_in_template_runme.py b/Examples/test-suite/python/nested_in_template_runme.py new file mode 100644 index 000000000..b4aa25b9b --- /dev/null +++ b/Examples/test-suite/python/nested_in_template_runme.py @@ -0,0 +1,5 @@ +from nested_in_template import * + +cd = ConcreteDerived(8.8) +if cd.m_value != 8.8: + raise RuntimeError("ConcreteDerived not created correctly") diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 91ab94c52..ee121abec 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -166,6 +166,11 @@ static Node *copy_node(Node *n) { Setattr(nn, "needs_defaultargs", "1"); continue; } + /* same for abstracts, which contains pointers to the source node children, and so will need to be patch too */ + if (strcmp(ckey,"abstracts") == 0) { + SetFlag(nn, "needs_abstracts"); + continue; + } /* Looks okay. Just copy the data using Copy */ ci = Copy(k.item); Setattr(nn, key, ci); @@ -788,6 +793,22 @@ static List *pure_abstracts(Node *n) { return abstracts; } +/* Recompute the "abstracts" attribute for the classes in instantiated templates, similarly to update_defaultargs() above. */ +static void update_abstracts(Node *n) { + for (; n; n = nextSibling(n)) { + Node* const child = firstChild(n); + if (!child) + continue; + + update_abstracts(child); + + if (Getattr(n, "needs_abstracts")) { + Setattr(n, "abstracts", pure_abstracts(child)); + Delattr(n, "needs_abstracts"); + } + } +} + /* Make a classname */ static String *make_class_name(String *name) { @@ -3056,6 +3077,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va nn = Getattr(nn,"sym:nextSibling"); /* repeat for overloaded templated functions. If a templated class there will never be a sibling. */ } update_defaultargs(linkliststart); + update_abstracts(linkliststart); } Swig_symbol_setscope(tscope); Delete(Namespaceprefix); From 493d96a732cda7c51fb2a6192a3441053cef8c88 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Sat, 24 Nov 2018 20:07:44 +0000 Subject: [PATCH 1168/2031] Fix unused variable warning. --- Lib/python/pyinit.swg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index dd58bad0b..6516b5159 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -331,6 +331,9 @@ SWIGEXPORT #endif SWIG_init(void) { PyObject *m, *d, *md, *globals; + + (void)globals; + #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, From 3c090307a48b0c6a1f034357b751bc9469cc111f Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Sun, 25 Nov 2018 04:23:18 +0000 Subject: [PATCH 1169/2031] Fix ISOC build errors. --- Lib/python/pyinit.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 6516b5159..c155185cd 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -332,8 +332,6 @@ SWIGEXPORT SWIG_init(void) { PyObject *m, *d, *md, *globals; - (void)globals; - #if PY_VERSION_HEX >= 0x03000000 static struct PyModuleDef SWIG_module = { PyModuleDef_HEAD_INIT, @@ -386,6 +384,8 @@ SWIG_init(void) { assert(metatype); #endif + (void)globals; + /* Create singletons now to avoid potential deadlocks with multi-threaded usage after module initialization */ SWIG_This(); SWIG_Python_TypeCache(); From e729a868b91a11eabf88b5c420351a80b43a07fd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 Nov 2018 21:53:57 +0000 Subject: [PATCH 1170/2031] Minimum Python version check correction Fixes Recent breakage when using -builtin and %import --- Source/Modules/python.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 19798b5f8..b31d9ce8f 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -731,7 +731,7 @@ public: * globals()[attr] = getattr(_foo, attr) * */ - Printf(default_import_code, "# pull in all the attributes from %s\n", module); + Printf(default_import_code, "\n# Pull in all the attributes from %s\n", module); Printv(default_import_code, "if __name__.rpartition('.')[0] != '':\n", NULL); Printv(default_import_code, tab4, "if _swig_python_version_info >= (2, 7, 0):\n", NULL); Printv(default_import_code, tab8, "try:\n", NULL); @@ -900,13 +900,14 @@ public: Swig_banner_target_lang(f_shadow_py, "#"); if (Len(f_shadow_begin) > 0) Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); - if (Len(f_shadow_after_begin) > 0) - Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL); Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL); Printv(f_shadow_py, tab4, "raise RuntimeError('Python 2.7 or later required')\n\n", NULL); + if (Len(f_shadow_after_begin) > 0) + Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL); + if (moduleimport) { Replaceall(moduleimport, "$module", module); Printv(f_shadow_py, moduleimport, "\n", NIL); From 865dc1e71c3d2f3e35197d2cdd188c4b878cbb7d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 25 Nov 2018 22:18:43 +0000 Subject: [PATCH 1171/2031] Remove Python 2.6 and earlier import code --- Source/Modules/python.cxx | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b31d9ce8f..1c43383a6 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -733,13 +733,10 @@ public: */ Printf(default_import_code, "\n# Pull in all the attributes from %s\n", module); Printv(default_import_code, "if __name__.rpartition('.')[0] != '':\n", NULL); - Printv(default_import_code, tab4, "if _swig_python_version_info >= (2, 7, 0):\n", NULL); - Printv(default_import_code, tab8, "try:\n", NULL); - Printf(default_import_code, tab8 tab4 "from .%s import *\n", module); - Printv(default_import_code, tab8 "except ImportError:\n", NULL); - Printf(default_import_code, tab8 tab4 "from %s import *\n", module); - Printv(default_import_code, tab4, "else:\n", NULL); - Printf(default_import_code, tab8 "from %s import *\n", module); + Printv(default_import_code, tab4, "try:\n", NULL); + Printf(default_import_code, tab4 tab4 "from .%s import *\n", module); + Printv(default_import_code, tab4 "except ImportError:\n", NULL); + Printf(default_import_code, tab4 tab4 "from %s import *\n", module); Printv(default_import_code, "else:\n", NULL); Printf(default_import_code, tab4 "from %s import *\n", module); } @@ -1122,12 +1119,9 @@ public: Printf(out, "import %s%s%s%s\n", apkg, *Char(apkg) ? "." : "", pfx, mod); Delete(apkg); } else { - Printf(out, "if _swig_python_version_info >= (2, 7, 0):\n"); if (py3_rlen1) - Printf(out, tab4 "from . import %.*s\n", py3_rlen1, rpkg); - Printf(out, tab4 "from .%s import %s%s\n", rpkg, pfx, mod); - Printf(out, "else:\n"); - Printf(out, tab4 "import %s%s%s%s\n", rpkg, *Char(rpkg) ? "." : "", pfx, mod); + Printf(out, "from . import %.*s\n", py3_rlen1, rpkg); + Printf(out, "from .%s import %s%s\n", rpkg, pfx, mod); Delete(rpkg); } return out; From 73ea48ba4a7fc2dd82c18aa18cda73fb4a4c9252 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Nov 2018 23:39:15 +0100 Subject: [PATCH 1172/2031] Add recently added nested_in_template to the list of test cases This should have been part of 30bb977a6436fa7903aca041606c1110d37a2401 See #1358. --- Examples/test-suite/common.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3b46354b9..fbde676ed 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -321,6 +321,7 @@ CPP_TEST_CASES += \ nested_directors \ nested_comment \ nested_ignore \ + nested_in_template \ nested_scope \ nested_template_base \ nested_workaround \ From 0fecd1538faa45b5818776b676be41aca7780c25 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 27 Nov 2018 23:30:51 +0000 Subject: [PATCH 1173/2031] Cleanup accessing/decref of globals, to avoid code bloat in init function. --- Lib/python/pyinit.swg | 6 +----- Source/Modules/python.cxx | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index c155185cd..d8f3bf444 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -227,11 +227,7 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) { - _SWIG_globals = SWIG_newvarlink(); - } else { - Py_INCREF(_SWIG_globals); - } + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); return _SWIG_globals; } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 329b890a1..edf70bb89 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3316,21 +3316,21 @@ public: getf = NewWrapper(); setf = NewWrapper(); - Printf(f_init, "\t globals = SWIG_globals();\n"); - Printf(f_init, "\t if (!globals) {\n"); - Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Failure to create SWIG globals.\");\n"); - Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); - Printf(f_init, "\t return NULL;\n"); - Printf(f_init, "#else\n"); - Printf(f_init, "\t return;\n"); - Printf(f_init, "#endif\n"); - Printf(f_init, "\t }\n"); - /* If this is our first call, add the globals variable to the Python dictionary. */ if (!have_globals) { + Printf(f_init, "\t globals = SWIG_globals();\n"); + Printf(f_init, "\t if (!globals) {\n"); + Printf(f_init, " PyErr_SetString(PyExc_TypeError, \"Failure to create SWIG globals.\");\n"); + Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); + Printf(f_init, "\t return NULL;\n"); + Printf(f_init, "#else\n"); + Printf(f_init, "\t return;\n"); + Printf(f_init, "#endif\n"); + Printf(f_init, "\t }\n"); Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", globals);\n", global_name); + Printf(f_init, "\t Py_DECREF(globals);\n"); if (builtin) Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name); have_globals = 1; @@ -3418,12 +3418,11 @@ public: Wrapper_print(getf, f_wrappers); /* Now add this to the variable linking mechanism */ - Printf(f_init, "\t SWIG_addvarlink(globals,\"%s\",%s, %s);\n", iname, vargetname, varsetname); + Printf(f_init, "\t SWIG_addvarlink(globals, \"%s\", %s, %s);\n", iname, vargetname, varsetname); if (builtin && shadow && !assignable && !in_class) { - Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", PyObject_GetAttrString(SWIG_globals(), \"%s\"));\n", iname, iname); + Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", PyObject_GetAttrString(globals, \"%s\"));\n", iname, iname); Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", iname); } - Printf(f_init, "\t Py_DECREF(globals);\n"); Delete(vargetname); Delete(varsetname); Delete(getname); From 6030f597410d1a64cffa72bfeb52d9cd7ca2b46a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Nov 2018 07:27:49 +0000 Subject: [PATCH 1174/2031] Fix operator Python example for -builtin Output was incorrect for -builtin as custom __str__ was not being called. --- Examples/python/operator/example.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/python/operator/example.i b/Examples/python/operator/example.i index e37e76b3e..1e4b7ce34 100644 --- a/Examples/python/operator/example.i +++ b/Examples/python/operator/example.i @@ -17,6 +17,7 @@ %include "example.h" /* An output method that turns a complex into a short string */ +%feature("python:slot", "tp_str", functype="reprfunc") Complex::__str__; // For -builtin option to use __str__ in the tp_str slot %extend Complex { char *__str__() { static char temp[512]; From b380de031e4c0ab8133d61b7a7eac80cd9225e7e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Nov 2018 08:06:05 +0000 Subject: [PATCH 1175/2031] Python -builtin %rename constructor refactor The implementation for a renamed constructor for -builtin no longer uses the same implementation for non-builtin mode which makes a call into the compiled C module, eg _constructor_rename for a module called constructor_rename. The output in the constructor_rename.py file is now: RenamedConstructor = new_RenamedConstructor instead of def RenamedConstructor(): val = _constructor_rename.new_RenamedConstructor() return val when wrapping: struct Foo { %rename(RenamedConstructor) Foo(); Foo() {} }; See the constructor_rename.i testcase. This change has been made to make the wrapper more efficient and is a step towards the next commit which will remove duplicating the symbols in both the pure Python module and implementation C module (constructor_rename and _constructor_rename respectively in this case). --- Source/Modules/python.cxx | 59 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 1c43383a6..c621e6175 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2599,6 +2599,7 @@ public: builtin_self = false; else builtin_ctor = true; + Delete(mrename); } bool director_class = (getCurrentClass() && Swig_directorclass(getCurrentClass())); bool add_self = builtin_self && (!builtin_ctor || director_class); @@ -4727,11 +4728,12 @@ public: Delete(cname); } + String *subfunc = Swig_name_construct(NSPACE_TODO, symname); if (!have_constructor && handled_as_init) { if (!builtin) { if (Getattr(n, "feature:shadow")) { String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), tab4, Getfile(n), Getline(n), "%feature(\"shadow\")"); - String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); + String *pyaction = NewStringf("%s.%s", module, subfunc); Replaceall(pycode, "$action", pyaction); Delete(pyaction); Printv(f_shadow, pycode, "\n", NIL); @@ -4761,7 +4763,7 @@ public: if (have_pythonprepend(n)) Printv(f_shadow, indent_pythoncode(pythonprepend(n), tab8, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); Printv(f_shadow, pass_self, NIL); - Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(Swig_name_construct(NSPACE_TODO, symname), callParms), ")\n", NIL); + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self, ", funcCall(subfunc, callParms), ")\n", NIL); if (have_pythonappend(n)) Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n\n", NIL); Delete(pass_self); @@ -4771,39 +4773,36 @@ public: } else { /* Hmmm. We seem to be creating a different constructor. We're just going to create a function for it. */ - if (Getattr(n, "feature:shadow")) { - String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n), "%feature(\"shadow\")"); - String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(NSPACE_TODO, symname)); - Replaceall(pycode, "$action", pyaction); - Delete(pyaction); - Printv(f_shadow_stubs, pycode, "\n", NIL); - Delete(pycode); - } else { - String *parms = make_pyParmList(n, false, false, allow_kwargs); - String *callParms = make_pyParmList(n, false, true, allow_kwargs); + if (!builtin) { + if (Getattr(n, "feature:shadow")) { + String *pycode = indent_pythoncode(Getattr(n, "feature:shadow"), "", Getfile(n), Getline(n), "%feature(\"shadow\")"); + String *pyaction = NewStringf("%s.%s", module, subfunc); + Replaceall(pycode, "$action", pyaction); + Delete(pyaction); + Printv(f_shadow_stubs, pycode, "\n", NIL); + Delete(pycode); + } else { + String *parms = make_pyParmList(n, false, false, allow_kwargs); + String *callParms = make_pyParmList(n, false, true, allow_kwargs); - Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\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, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); - String *subfunc = NULL; - /* - if (builtin) - subfunc = Copy(Getattr(getCurrentClass(), "sym:name")); - else - */ - subfunc = Swig_name_construct(NSPACE_TODO, symname); - Printv(f_shadow_stubs, tab4, "val = ", funcCall(subfunc, callParms), "\n", NIL); + Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\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, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", funcCall(subfunc, callParms), "\n", NIL); #ifdef USE_THISOWN - Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); + Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif - if (have_pythonappend(n)) - Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); - Printv(f_shadow_stubs, tab4, "return val\n", NIL); - Delete(subfunc); + if (have_pythonappend(n)) + Printv(f_shadow_stubs, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); + Printv(f_shadow_stubs, tab4, "return val\n", NIL); + } + } else { + Printf(f_shadow_stubs, "%s = %s\n", symname, subfunc); } } + Delete(subfunc); } } return SWIG_OK; From b1697d7772e2b96367b0a73a756106ed96295190 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Wed, 28 Nov 2018 16:51:53 -0500 Subject: [PATCH 1176/2031] Move unordered containers under cpp11_ prefix --- ...{li_std_unordered_map.i => cpp11_li_std_unordered_map.i} | 3 +-- ...{li_std_unordered_set.i => cpp11_li_std_unordered_set.i} | 3 +-- Examples/test-suite/java/Makefile.in | 4 ++-- ...map_runme.java => cpp11_li_std_unordered_map_runme.java} | 6 +++--- ...set_runme.java => cpp11_li_std_unordered_set_runme.java} | 6 +++--- 5 files changed, 10 insertions(+), 12 deletions(-) rename Examples/test-suite/{li_std_unordered_map.i => cpp11_li_std_unordered_map.i} (87%) rename Examples/test-suite/{li_std_unordered_set.i => cpp11_li_std_unordered_set.i} (82%) rename Examples/test-suite/java/{li_std_unordered_map_runme.java => cpp11_li_std_unordered_map_runme.java} (95%) rename Examples/test-suite/java/{li_std_unordered_set_runme.java => cpp11_li_std_unordered_set_runme.java} (91%) diff --git a/Examples/test-suite/li_std_unordered_map.i b/Examples/test-suite/cpp11_li_std_unordered_map.i similarity index 87% rename from Examples/test-suite/li_std_unordered_map.i rename to Examples/test-suite/cpp11_li_std_unordered_map.i index a6869cc0b..5f40e76fd 100644 --- a/Examples/test-suite/li_std_unordered_map.i +++ b/Examples/test-suite/cpp11_li_std_unordered_map.i @@ -2,11 +2,10 @@ * A test of unordered_map containers. */ -%module li_std_unordered_map +%module cpp11_li_std_unordered_map %include %include %template(IntIntUnorderedMap) std::unordered_map; %template(StringIntUnorderedMap) std::unordered_map; - diff --git a/Examples/test-suite/li_std_unordered_set.i b/Examples/test-suite/cpp11_li_std_unordered_set.i similarity index 82% rename from Examples/test-suite/li_std_unordered_set.i rename to Examples/test-suite/cpp11_li_std_unordered_set.i index a051e9389..e9711ce60 100644 --- a/Examples/test-suite/li_std_unordered_set.i +++ b/Examples/test-suite/cpp11_li_std_unordered_set.i @@ -2,10 +2,9 @@ * A test of unordered_set containers. */ -%module li_std_unordered_set +%module cpp11_li_std_unordered_set %include %include %template(StringUnorderedSet) std::unordered_set; - diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index b5b1d65c7..3323f8a9c 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -54,8 +54,8 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ - li_std_unordered_map \ - li_std_unordered_set \ + cpp11_li_std_unordered_map \ + cpp11_li_std_unordered_set \ DOXYGEN_TEST_CASES := \ doxygen_parsing_enums_simple \ diff --git a/Examples/test-suite/java/li_std_unordered_map_runme.java b/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java similarity index 95% rename from Examples/test-suite/java/li_std_unordered_map_runme.java rename to Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java index 8ab6f23e4..f216a0131 100644 --- a/Examples/test-suite/java/li_std_unordered_map_runme.java +++ b/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java @@ -1,10 +1,10 @@ -import li_std_unordered_map.*; +import cpp11_li_std_unordered_map.*; -public class li_std_unordered_map_runme { +public class cpp11_li_std_unordered_map_runme { static { try { - System.loadLibrary("li_std_unordered_map"); + System.loadLibrary("cpp11_li_std_unordered_map"); } 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); diff --git a/Examples/test-suite/java/li_std_unordered_set_runme.java b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java similarity index 91% rename from Examples/test-suite/java/li_std_unordered_set_runme.java rename to Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java index ce94f8fe4..ce33780f0 100644 --- a/Examples/test-suite/java/li_std_unordered_set_runme.java +++ b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java @@ -1,10 +1,10 @@ -import li_std_unordered_set.*; +import cpp11_li_std_unordered_set.*; -public class li_std_unordered_set_runme { +public class cpp11_li_std_unordered_set_runme { static { try { - System.loadLibrary("li_std_unordered_set"); + System.loadLibrary("cpp11_li_std_unordered_set"); } 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); From 6b5da094b26b17cd4aad3d48a3e47222db0bc0f0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Nov 2018 23:36:13 +0000 Subject: [PATCH 1177/2031] Simpler Python -builtin import When using -builtin, the two step C-extension module import is now one step and the wrapped API is only available once and not in an underlying module attribute like it is without -builtin. To understand this, consider a module named 'example' (using: %module example). The C-extension is compiled into a Python module called '_example' and a pure Python module provides the actual API from the module called 'example'. It was previously possible to additionally access the API from the module attribute 'example._example'. The latter was an implementation detail and is no longer available. It shouldn't have been used, but if necessary it can be resurrected using the moduleimport attribute described in the Python chapter of the documentation. If both modules are provided in a Python package, try: %module(moduleimport="from . import _example\nfrom ._example import *") example or more generically: %module(moduleimport="from . import $module\nfrom .$module import *") example and if both are provided as global modules, try: %module(moduleimport="import _example\nfrom _example import *") example or more generically: %module(moduleimport="import $module\nfrom $module import *") example The module import code shown will appear in the example.py file. --- CHANGES.current | 25 ++++++++++++++++++ Source/Modules/python.cxx | 55 ++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f32583568..aec1f140a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,31 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-11-28: wsfulton + [Python] When using -builtin, the two step C-extension module import is now + one step and the wrapped API is only available once and not in an underlying + module attribute like it is without -builtin. To understand this, consider a + module named 'example' (using: %module example). The C-extension is compiled into + a Python module called '_example' and a pure Python module provides the actual + API from the module called 'example'. It was previously possible to additionally + access the API from the module attribute 'example._example'. The latter was an + implementation detail and is no longer available. It shouldn't have been used, but + if necessary it can be resurrected using the moduleimport attribute described in the + Python chapter of the documentation. If both modules are provided in a Python + package, try: + + %module(moduleimport="from . import _example\nfrom ._example import *") example + or more generically: + %module(moduleimport="from . import $module\nfrom .$module import *") example + + and if both are provided as global modules, try: + + %module(moduleimport="import _example\nfrom _example import *") example + or more generically: + %module(moduleimport="import $module\nfrom $module import *") example + + The module import code shown will appear in the example.py file. + 2018-11-24: vadz #1358 Fix handling of abstract base classes nested inside templates diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c621e6175..2afe26867 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -693,37 +693,38 @@ public: mod_docstring = 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 raised a DeprecationWarning in 2.6, - * and fail in 2.7 onwards). - * - * First determine the shadow wrappers package based on the __name__ it - * was given by the importer that loaded it. Then construct a name for - * the module based on the package name and the module name (we know the - * module name). Use importlib to try and load it. If an attempt to - * load the module with importlib fails with an ImportError then fallback - * and try and load just the module name from the global namespace. - */ - Printv(default_import_code, "def swig_import_helper():\n", NULL); - Printv(default_import_code, tab4, "import importlib\n", NULL); - Printv(default_import_code, tab4, "pkg = __package__ if __package__ else __name__.rpartition('.')[0]\n", NULL); - Printf(default_import_code, tab4 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); - Printv(default_import_code, tab4, "try:\n", NULL); - Printv(default_import_code, tab8, "return importlib.import_module(mname)\n", NULL); - Printv(default_import_code, tab4, "except ImportError:\n", NULL); - Printf(default_import_code, tab8 "return importlib.import_module('%s')\n", module); - Printf(default_import_code, "%s = swig_import_helper()\n", module); - Printv(default_import_code, "del swig_import_helper\n", NULL); - - if (builtin) { + if (!builtin) { + /* 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 raised a DeprecationWarning in 2.6, + * and fail in 2.7 onwards). + * + * First determine the shadow wrappers package based on the __name__ it + * was given by the importer that loaded it. Then construct a name for + * the module based on the package name and the module name (we know the + * module name). Use importlib to try and load it. If an attempt to + * load the module with importlib fails with an ImportError then fallback + * and try and load just the module name from the global namespace. + */ + Printv(default_import_code, "def swig_import_helper():\n", NULL); + Printv(default_import_code, tab4, "import importlib\n", NULL); + Printv(default_import_code, tab4, "pkg = __package__ if __package__ else __name__.rpartition('.')[0]\n", NULL); + Printf(default_import_code, tab4 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); + Printv(default_import_code, tab4, "try:\n", NULL); + Printv(default_import_code, tab8, "return importlib.import_module(mname)\n", NULL); + Printv(default_import_code, tab4, "except ImportError:\n", NULL); + Printf(default_import_code, tab8 "return importlib.import_module('%s')\n", module); + Printf(default_import_code, "%s = swig_import_helper()\n", module); + Printv(default_import_code, "del swig_import_helper\n", NULL); + } else { /* * Pull in all the attributes from the C module. * * An alternative approach to doing this if/else chain was - * proposed by Michael Thon. Someone braver than I may try it out. + * proposed by Michael Thon at https://github.com/swig/swig/issues/691. + * Someone braver than I may try it out. * I fear some current swig user may depend on some side effect * of from _foo import * * From 75638e3371418a69ebd59c08d0d1e092a334ba28 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 28 Nov 2018 23:48:58 +0000 Subject: [PATCH 1178/2031] Update comments and docs regarding recent addition to use __package__ for Python module imports --- Doc/Manual/Python.html | 3 ++- Source/Modules/python.cxx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index e2795d635..eee47f922 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6137,7 +6137,8 @@ pure Python module uses to find the C/C++ module is as follows:
      1. The pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is - located in. The package name is determined from the __name__ + located in. The package name is determined from the __package__ + attribute if available, see PEP 366, otherwise it is derived from the __name__ attribute given to foo.py by the Python loader that imported foo.py. If foo.py is not in a package then _foo is loaded as a global module.

        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 2afe26867..c06497d8c 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -701,7 +701,8 @@ public: * onwards (implicit relative imports raised a DeprecationWarning in 2.6, * and fail in 2.7 onwards). * - * First determine the shadow wrappers package based on the __name__ it + * First check for __package__ which is available from 2.6 onwards, see PEP366. + * Next determine the shadow wrappers package based on the __name__ it * was given by the importer that loaded it. Then construct a name for * the module based on the package name and the module name (we know the * module name). Use importlib to try and load it. If an attempt to From 6ccc940a143406588f29d896fd0eb2f8113e0195 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Fri, 30 Nov 2018 18:21:02 -0500 Subject: [PATCH 1179/2031] Add set/unordered_set that extend AbstractSet --- .../cpp11_li_std_unordered_set_runme.java | 72 ++++++--- .../test-suite/java/li_std_set_runme.java | 72 ++++++--- Lib/java/std_set.i | 150 +++++++++++++++++- Lib/java/std_unordered_set.i | 150 +++++++++++++++++- 4 files changed, 400 insertions(+), 44 deletions(-) diff --git a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java index ce33780f0..15f6eba0a 100644 --- a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java +++ b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java @@ -11,30 +11,66 @@ public class cpp11_li_std_unordered_set_runme { } } + public static void failTest(int testNum) throws Throwable { + throw new RuntimeException("Test failed: " + testNum); + } + + public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { + if (!mustBeTrue) failTest(testNum); + } + public static void main(String argv[]) throws Throwable { - StringUnorderedSet ss = new StringUnorderedSet(); + java.util.AbstractSet ss = new StringUnorderedSet(); - if (!ss.empty()) throw new RuntimeException("Test (1) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (2) failed"); - if (ss.has("key")) throw new RuntimeException("Test (3) failed"); - if (ss.erase("key")) throw new RuntimeException("Test (4) failed"); + checkThat(ss.isEmpty(), 1); + checkThat(!ss.contains("key"), 2); + checkThat(!ss.remove("key"), 3); - if (!ss.insert("key")) throw new RuntimeException("Test (5) failed"); - if (ss.insert("key")) throw new RuntimeException("Test (6) failed"); - if (!ss.has("key")) throw new RuntimeException("Test (7) failed"); + checkThat(ss.add("key"), 4); + checkThat(!ss.add("key"), 5); + checkThat(ss.contains("key"), 6); + checkThat(ss.remove("key"), 7); + checkThat(ss.isEmpty(), 8); + checkThat(ss.size() == 0, 9); - if (!ss.erase("key")) throw new RuntimeException("Test (8) failed"); - if (!ss.empty()) throw new RuntimeException("Test (9) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (10) failed"); - - if (!ss.insert("key1")) throw new RuntimeException("Test (11) failed"); - if (!ss.insert("key2")) throw new RuntimeException("Test (12) failed"); - if (!ss.insert("key3")) throw new RuntimeException("Test (13) failed"); - if (ss.size() != 3) throw new RuntimeException("Test (14) failed"); + checkThat(ss.add("key1"), 10); + checkThat(ss.add("key2"), 11); + checkThat(ss.add("key3"), 12); + checkThat(ss.size() == 3, 13); ss.clear(); - if (!ss.empty()) throw new RuntimeException("Test (15) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (16) failed"); + checkThat(ss.isEmpty(), 14); + checkThat(ss.size() == 0, 15); + + checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")), 16); + checkThat(ss.size() == 3, 17); + checkThat(ss.contains("one"), 18); + checkThat(!ss.contains("four"), 19); + + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")), 20); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")), 21); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")), 22); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")), 23); + + checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")), 24); + + java.util.Set found = new java.util.HashSet(); + java.util.Iterator itr = ss.iterator(); + while (itr.hasNext()) { + found.add(itr.next()); + } + + checkThat(ss.containsAll(found), 25); + checkThat(found.containsAll(ss), 26); + + java.util.AbstractSet ss2 = new StringUnorderedSet(ss); + checkThat(ss2.containsAll(ss), 27); + checkThat(ss.containsAll(ss2), 28); + + checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")), 29); + checkThat(ss.removeAll(found), 30); + checkThat(ss.isEmpty(), 31); + checkThat(ss.size() == 0, 32); } } diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java index 61edd93dc..7bbd3fced 100644 --- a/Examples/test-suite/java/li_std_set_runme.java +++ b/Examples/test-suite/java/li_std_set_runme.java @@ -11,30 +11,66 @@ public class li_std_set_runme { } } + public static void failTest(int testNum) throws Throwable { + throw new RuntimeException("Test failed: " + testNum); + } + + public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { + if (!mustBeTrue) failTest(testNum); + } + public static void main(String argv[]) throws Throwable { - StringSet ss = new StringSet(); + java.util.AbstractSet ss = new StringSet(); - if (!ss.empty()) throw new RuntimeException("Test (1) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (2) failed"); - if (ss.has("key")) throw new RuntimeException("Test (3) failed"); - if (ss.erase("key")) throw new RuntimeException("Test (4) failed"); + checkThat(ss.isEmpty(), 1); + checkThat(!ss.contains("key"), 2); + checkThat(!ss.remove("key"), 3); - if (!ss.insert("key")) throw new RuntimeException("Test (5) failed"); - if (ss.insert("key")) throw new RuntimeException("Test (6) failed"); - if (!ss.has("key")) throw new RuntimeException("Test (7) failed"); + checkThat(ss.add("key"), 4); + checkThat(!ss.add("key"), 5); + checkThat(ss.contains("key"), 6); + checkThat(ss.remove("key"), 7); + checkThat(ss.isEmpty(), 8); + checkThat(ss.size() == 0, 9); - if (!ss.erase("key")) throw new RuntimeException("Test (8) failed"); - if (!ss.empty()) throw new RuntimeException("Test (9) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (10) failed"); - - if (!ss.insert("key1")) throw new RuntimeException("Test (11) failed"); - if (!ss.insert("key2")) throw new RuntimeException("Test (12) failed"); - if (!ss.insert("key3")) throw new RuntimeException("Test (13) failed"); - if (ss.size() != 3) throw new RuntimeException("Test (14) failed"); + checkThat(ss.add("key1"), 10); + checkThat(ss.add("key2"), 11); + checkThat(ss.add("key3"), 12); + checkThat(ss.size() == 3, 13); ss.clear(); - if (!ss.empty()) throw new RuntimeException("Test (15) failed"); - if (ss.size() != 0) throw new RuntimeException("Test (16) failed"); + checkThat(ss.isEmpty(), 14); + checkThat(ss.size() == 0, 15); + + checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")), 16); + checkThat(ss.size() == 3, 17); + checkThat(ss.contains("one"), 18); + checkThat(!ss.contains("four"), 19); + + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")), 20); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")), 21); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")), 22); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")), 23); + + checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")), 24); + + java.util.Set found = new java.util.HashSet(); + java.util.Iterator itr = ss.iterator(); + while (itr.hasNext()) { + found.add(itr.next()); + } + + checkThat(ss.containsAll(found), 25); + checkThat(found.containsAll(ss), 26); + + java.util.AbstractSet ss2 = new StringSet(ss); + checkThat(ss2.containsAll(ss), 27); + checkThat(ss.containsAll(ss2), 28); + + checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")), 29); + checkThat(ss.removeAll(found), 30); + checkThat(ss.isEmpty(), 31); + checkThat(ss.size() == 0, 32); } } diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 8c4bb7f17..57613f322 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -2,6 +2,8 @@ * std_set.i * * SWIG typemaps for std::set + * The Java proxy class extends java.util.AbstractSet. The std::set + * container looks and feels much like a java.util.HashSet from Java. * ----------------------------------------------------------------------------- */ %include @@ -12,35 +14,175 @@ %{ #include +#include %} +%fragment("SWIG_SetSize", "header", fragment="SWIG_JavaIntFromSize_t") { + SWIGINTERN jint SWIG_SetSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) { + throw std::out_of_range("set size is too large to fit into a Java int"); + } + + return sz; + } +} + +%javamethodmodifiers std::set::sizeImpl "private"; +%javamethodmodifiers std::set::containsImpl "private"; +%javamethodmodifiers std::set::removeImpl "private"; +%javamethodmodifiers std::set::hasNextImpl "private"; +%javamethodmodifiers std::set::begin "private"; +%javamethodmodifiers std::set::end "private"; + +%rename(Iterator) std::set::iterator; +%nodefaultctor std::set::iterator; +%javamethodmodifiers std::set::iterator::incrementUnchecked "private"; +%javamethodmodifiers std::set::iterator::derefUnchecked "private"; +%javamethodmodifiers std::set::iterator::isNot "private"; + namespace std { template class set { + +%typemap(javabase) std::set "java.util.AbstractSet<$typemap(jboxtype, KeyType)>" +%proxycode %{ + public $javaclassname(java.util.Collection collection) { + this(); + addAll(collection); + } + + public int size() { + return sizeImpl(); + } + + public boolean addAll(java.util.Collection collection) { + boolean didAddElement = false; + for (Object object : collection) { + didAddElement |= add(($typemap(jboxtype, KeyType))object); + } + + return didAddElement; + } + + public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() { + return new java.util.Iterator<$typemap(jboxtype, KeyType)>() { + private Iterator curr; + private Iterator end; + + private java.util.Iterator<$typemap(jboxtype, KeyType)> init() { + curr = $javaclassname.this.begin(); + end = $javaclassname.this.end(); + return this; + } + + public $typemap(jboxtype, KeyType) next() { + if (!hasNext()) { + throw new java.util.NoSuchElementException(); + } + + // Save the current position, increment it, + // then return the value at the position before the increment. + final $typemap(jboxtype, KeyType) currValue = curr.derefUnchecked(); + curr.incrementUnchecked(); + return currValue; + } + + public boolean hasNext() { + return curr.isNot(end); + } + }.init(); + } + + public boolean containsAll(java.util.Collection collection) { + for (Object object : collection) { + if (!contains(object)) { + return false; + } + } + + return true; + } + + public boolean contains(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return containsImpl(($typemap(jboxtype, KeyType))object); + } + + public boolean removeAll(java.util.Collection collection) { + boolean didRemoveElement = false; + for (Object object : collection) { + didRemoveElement |= remove(object); + } + + return didRemoveElement; + } + + public boolean remove(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return removeImpl(($typemap(jboxtype, KeyType))object); + } +%} + public: + + struct iterator { + %extend { + void incrementUnchecked() { + ++(*$self); + } + + KeyType derefUnchecked() const { + return **$self; + } + + bool isNot(const iterator other) const { + return (*$self != other); + } + } + }; + set(); set(const set&); - unsigned int size() const; + %rename(isEmpty) empty; bool empty() const; void clear(); + iterator begin(); + iterator end(); %extend { + %fragment("SWIG_SetSize"); + // Returns whether item was inserted. - bool insert(const KeyType& key) { + bool add(const KeyType& key) { return self->insert(key).second; } // Returns whether set contains key. - bool has(const KeyType& key) { + bool containsImpl(const KeyType& key) { return (self->count(key) > 0); } // Returns whether the item was erased. - bool erase(const KeyType& key) { + bool removeImpl(const KeyType& key) { return (self->erase(key) > 0); } + + jint sizeImpl() const throw (std::out_of_range) { + return SWIG_SetSize(self->size()); + } + + bool hasNextImpl(const iterator& itr) const { + return (itr != $self->end()); + } } }; diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index a9fac0f82..4074d8045 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -2,6 +2,8 @@ * std_unordered_set.i * * SWIG typemaps for std::unordered_set + * The Java proxy class extends java.util.AbstractSet. The std::unordered_set + * container looks and feels much like a java.util.HashSet from Java. * ----------------------------------------------------------------------------- */ %include @@ -12,35 +14,175 @@ %{ #include +#include %} +%fragment("SWIG_UnorderedSetSize", "header", fragment="SWIG_JavaIntFromSize_t") { + SWIGINTERN jint SWIG_UnorderedSetSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) { + throw std::out_of_range("unordered_set size is too large to fit into a Java int"); + } + + return sz; + } +} + +%javamethodmodifiers std::unordered_set::sizeImpl "private"; +%javamethodmodifiers std::unordered_set::containsImpl "private"; +%javamethodmodifiers std::unordered_set::removeImpl "private"; +%javamethodmodifiers std::unordered_set::hasNextImpl "private"; +%javamethodmodifiers std::unordered_set::begin "private"; +%javamethodmodifiers std::unordered_set::end "private"; + +%rename(Iterator) std::unordered_set::iterator; +%nodefaultctor std::unordered_set::iterator; +%javamethodmodifiers std::unordered_set::iterator::incrementUnchecked "private"; +%javamethodmodifiers std::unordered_set::iterator::derefUnchecked "private"; +%javamethodmodifiers std::unordered_set::iterator::isNot "private"; + namespace std { template class unordered_set { + +%typemap(javabase) std::unordered_set "java.util.AbstractSet<$typemap(jboxtype, KeyType)>" +%proxycode %{ + public $javaclassname(java.util.Collection collection) { + this(); + addAll(collection); + } + + public int size() { + return sizeImpl(); + } + + public boolean addAll(java.util.Collection collection) { + boolean didAddElement = false; + for (Object object : collection) { + didAddElement |= add(($typemap(jboxtype, KeyType))object); + } + + return didAddElement; + } + + public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() { + return new java.util.Iterator<$typemap(jboxtype, KeyType)>() { + private Iterator curr; + private Iterator end; + + private java.util.Iterator<$typemap(jboxtype, KeyType)> init() { + curr = $javaclassname.this.begin(); + end = $javaclassname.this.end(); + return this; + } + + public $typemap(jboxtype, KeyType) next() { + if (!hasNext()) { + throw new java.util.NoSuchElementException(); + } + + // Save the current position, increment it, + // then return the value at the position before the increment. + final $typemap(jboxtype, KeyType) currValue = curr.derefUnchecked(); + curr.incrementUnchecked(); + return currValue; + } + + public boolean hasNext() { + return curr.isNot(end); + } + }.init(); + } + + public boolean containsAll(java.util.Collection collection) { + for (Object object : collection) { + if (!contains(object)) { + return false; + } + } + + return true; + } + + public boolean contains(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return containsImpl(($typemap(jboxtype, KeyType))object); + } + + public boolean removeAll(java.util.Collection collection) { + boolean didRemoveElement = false; + for (Object object : collection) { + didRemoveElement |= remove(object); + } + + return didRemoveElement; + } + + public boolean remove(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return removeImpl(($typemap(jboxtype, KeyType))object); + } +%} + public: + + struct iterator { + %extend { + void incrementUnchecked() { + ++(*$self); + } + + KeyType derefUnchecked() const { + return **$self; + } + + bool isNot(const iterator other) const { + return (*$self != other); + } + } + }; + unordered_set(); unordered_set(const unordered_set&); - unsigned int size() const; + %rename(isEmpty) empty; bool empty() const; void clear(); + iterator begin(); + iterator end(); %extend { + %fragment("SWIG_UnorderedSetSize"); + // Returns whether item was inserted. - bool insert(const KeyType& key) { + bool add(const KeyType& key) { return self->insert(key).second; } // Returns whether set contains key. - bool has(const KeyType& key) { + bool containsImpl(const KeyType& key) { return (self->count(key) > 0); } // Returns whether the item was erased. - bool erase(const KeyType& key) { + bool removeImpl(const KeyType& key) { return (self->erase(key) > 0); } + + jint sizeImpl() const throw (std::out_of_range) { + return SWIG_UnorderedSetSize(self->size()); + } + + bool hasNextImpl(const iterator& itr) const { + return (itr != $self->end()); + } } }; From e6d86755137f40a6ec8e262a2a9a470554a0aac8 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Tue, 4 Dec 2018 01:08:47 -0500 Subject: [PATCH 1180/2031] Mostly working for map --- .../test-suite/java/li_std_map_runme.java | 131 +++++++------- Lib/java/std_map.i | 166 +++++++++++++----- 2 files changed, 187 insertions(+), 110 deletions(-) diff --git a/Examples/test-suite/java/li_std_map_runme.java b/Examples/test-suite/java/li_std_map_runme.java index 3cc794ced..ed5b43a31 100644 --- a/Examples/test-suite/java/li_std_map_runme.java +++ b/Examples/test-suite/java/li_std_map_runme.java @@ -11,91 +11,92 @@ public class li_std_map_runme { } } + public static void failTest(int testNum) throws Throwable { + throw new RuntimeException("Test failed: " + testNum); + } + + public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { + if (!mustBeTrue) failTest(testNum); + } + public static void main(String argv[]) throws Throwable { - StringIntMap sim = new StringIntMap(); - IntIntMap iim = new IntIntMap(); + java.util.AbstractMap sim = new StringIntMap(); + java.util.AbstractMap iim = new IntIntMap(); - if (!sim.empty()) throw new RuntimeException("Test (1) failed"); - if (!iim.empty()) throw new RuntimeException("Test (2) failed"); + checkThat(sim.isEmpty(), 1); + checkThat(iim.isEmpty(), 2); + checkThat(sim.size() == 0, 3); + checkThat(iim.size() == 0, 4); - if (sim.size() != 0) throw new RuntimeException("Test (3) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (4) failed"); + checkThat(sim.get("key") == null, 5); + checkThat(iim.get(1) == null, 6); - try { - sim.get("key"); - throw new RuntimeException("Test (5) failed"); - } catch (IndexOutOfBoundsException e) { - } + checkThat(!sim.containsKey("key"), 7); + checkThat(!iim.containsKey(1), 8); - try { - iim.get(1); - throw new RuntimeException("Test (6) failed"); - } catch (IndexOutOfBoundsException e) { - } + checkThat(sim.put("key", 2) == null, 9); + checkThat(iim.put(1, 2) == null, 10); - sim.set("key", 1); - iim.set(1, 1); + // if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); + // if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); - if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); - if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); + // sim.remove("key"); + // iim.remove(1); - sim.del("key"); - iim.del(1); + // if (sim.containsKey("key")) throw new RuntimeException("Test (9) failed"); + // if (iim.containsKey(1)) throw new RuntimeException("Test (10) failed"); - if (sim.has_key("key")) throw new RuntimeException("Test (9) failed"); - if (iim.has_key(1)) throw new RuntimeException("Test (10) failed"); + // if (!sim.isEmpty()) throw new RuntimeException("Test (11) failed"); + // if (!iim.isEmpty()) throw new RuntimeException("Test (12) failed"); + // if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); + // if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); - if (!sim.empty()) throw new RuntimeException("Test (11) failed"); - if (!iim.empty()) throw new RuntimeException("Test (12) failed"); - if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); + // try { + // sim.remove("key"); + // throw new RuntimeException("Test (15) failed"); + // } catch (IndexOutOfBoundsException e) { + // } - try { - sim.del("key"); - throw new RuntimeException("Test (15) failed"); - } catch (IndexOutOfBoundsException e) { - } + // try { + // iim.remove(1); + // throw new RuntimeException("Test (16) failed"); + // } catch (IndexOutOfBoundsException e) { + // } - try { - iim.del(1); - throw new RuntimeException("Test (16) failed"); - } catch (IndexOutOfBoundsException e) { - } + // sim.put("key", 1); + // iim.put(1, 1); - sim.set("key", 1); - iim.set(1, 1); + // if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); + // if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); - if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); - if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); + // sim.clear(); + // iim.clear(); - sim.clear(); - iim.clear(); + // if (sim.containsKey("key")) throw new RuntimeException("Test (19) failed"); + // if (iim.containsKey(1)) throw new RuntimeException("Test (20) failed"); - if (sim.has_key("key")) throw new RuntimeException("Test (19) failed"); - if (iim.has_key(1)) throw new RuntimeException("Test (20) failed"); + // if (!sim.isEmpty()) throw new RuntimeException("Test (21) failed"); + // if (!iim.isEmpty()) throw new RuntimeException("Test (22) failed"); + // if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); + // if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); - if (!sim.empty()) throw new RuntimeException("Test (21) failed"); - if (!iim.empty()) throw new RuntimeException("Test (22) failed"); - if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); + // sim.put("key", 1); + // sim.put("key2", 2); + // iim.put(1, 1); + // iim.put(2, 2); - sim.set("key", 1); - sim.set("key2", 2); - iim.set(1, 1); - iim.set(2, 2); + // if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); + // if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); + // if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); + // if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); - if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); - if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); - if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); - if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); + // sim.put("key", 3); + // iim.put(1, 3); - sim.set("key", 3); - iim.set(1, 3); - - if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); - if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); - if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); - if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); + // if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); + // if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); + // if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); + // if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); } } diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 75d523cec..4169a18b4 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -2,9 +2,12 @@ * std_map.i * * SWIG typemaps for std::map + * The Java proxy class extends java.util.AbstractMap. The std::map + * container looks and feels much like a java.util.HashMap from Java. * ----------------------------------------------------------------------------- */ %include +%include // ------------------------------------------------------------------------ // std::map @@ -12,60 +15,133 @@ %{ #include -#include #include %} +%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") { + SWIGINTERN jint SWIG_MapSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) { + throw std::out_of_range("map size is too large to fit into a Java int"); + } + + return sz; + } +} + +%javamethodmodifiers std::map::sizeImpl "private"; +%javamethodmodifiers std::map::containsImpl "private"; +%javamethodmodifiers std::map::getImpl "private"; +%javamethodmodifiers std::map::putImpl "private"; +%javamethodmodifiers std::map::removeImpl "private"; + namespace std { - template > class map { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef K key_type; - typedef T mapped_type; - map(); - map(const map< K, T, C > &); +template > class map { - unsigned int size() const; - bool empty() const; - void clear(); - %extend { - const T& get(const K& key) throw (std::out_of_range) { - std::map< K, T, C >::iterator i = self->find(key); - if (i != self->end()) - return i->second; - else - throw std::out_of_range("key not found"); - } - void set(const K& key, const T& x) { - (*self)[key] = x; - } - void del(const K& key) throw (std::out_of_range) { - std::map< K, T, C >::iterator i = self->find(key); - if (i != self->end()) - self->erase(i); - else - throw std::out_of_range("key not found"); - } - bool has_key(const K& key) { - std::map< K, T, C >::iterator i = self->find(key); - return i != self->end(); +%typemap(javabase) std::map + "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>" + +%proxycode %{ + + public int size() { + return sizeImpl(); + } + + public boolean containsKey(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return containsImpl(($typemap(jboxtype, KeyType))object); + } + + public $typemap(jboxtype, ValueType) get(Object object) { + if (!(object instanceof $typemap(jboxtype, KeyType))) { + return null; + } + + try { + getImpl(($typemap(jboxtype, KeyType)) object); + } catch (IndexOutOfBoundsException e) {} + + return null; + } + + public $typemap(jboxtype, ValueType) put($typemap(jboxtype, KeyType) key, + $typemap(jboxtype, ValueType) value) { + try { + $typemap(jboxtype, ValueType) oldValue = putImpl(key, value); + return oldValue; + } catch (IndexOutOfBoundsException e) {} + + return null; + } + + public $typemap(jboxtype, ValueType) remove($typemap(jboxtype, KeyType) key) { + try { + $typemap(jboxtype, ValueType) oldValue = removeImpl(key); + return oldValue; + } catch (IndexOutOfBoundsException e) {} + + return null; + } + + public java.util.Set> entrySet() { + throw new RuntimeException("Stub"); + } +%} + + public: + map(); + map(const map&); + + %rename(isEmpty) empty; + bool empty() const; + void clear(); + %extend { + %fragment("SWIG_MapSize"); + + jint sizeImpl() const throw (std::out_of_range) { + return SWIG_MapSize(self->size()); + } + + bool containsImpl(const KeyType& key) { + return (self->count(key) > 0); + } + + const ValueType& getImpl(const KeyType& key) throw (std::out_of_range) { + std::map::iterator itr = self->find(key); + if (itr != self->end()) { + return itr->second; + } else { + throw std::out_of_range("map::get() - key not found"); } } - }; -// Legacy macros (deprecated) -%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) -#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" -%enddef + ValueType putImpl(const KeyType& key, const ValueType& value) { + std::map::iterator itr = self->find(key); + if (itr != self->end()) { + ValueType oldValue = itr->second; + itr->second = value; + return oldValue; + } else { + (*self)[key] = value; + throw std::out_of_range("map::put() - no existing value for key"); + } + } -%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) -#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" -%enddef - -%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) -#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" -%enddef + ValueType removeImpl(const KeyType& key) throw (std::out_of_range) { + std::map::iterator itr = self->find(key); + if (itr != self->end()) { + ValueType oldValue = itr->second; + self->erase(itr); + return oldValue; + } else { + throw std::out_of_range("map::remove() - key not found"); + } + } + } +}; } From 9e83d5d5d9c65234f461c0cb6e04e4c9641b53dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Dec 2018 06:49:55 +0000 Subject: [PATCH 1181/2031] Fix nstest.py test Use subprocess.check_call as os.system won't stop the test in case of errors. --- .../python/import_packages/namespace_pkg/nstest.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py index 9b075ad8c..b0b146c92 100644 --- a/Examples/python/import_packages/namespace_pkg/nstest.py +++ b/Examples/python/import_packages/namespace_pkg/nstest.py @@ -1,6 +1,7 @@ import sys import os import shutil +import subprocess import zipfile @@ -17,10 +18,10 @@ def copyMods(): os.mkdir(os.path.join(d, 'brave')) shutil.copy('robin.py', os.path.join('path1', 'brave')) - os.system('cp _robin.* ' + os.path.join('path1', 'brave')) + subprocess.check_call('cp _robin.* ' + os.path.join('path1', 'brave'), shell=True) shutil.copy('robin.py', os.path.join('path2', 'brave')) - os.system('cp _robin.* ' + os.path.join('path3', 'brave')) + subprocess.check_call('cp _robin.* ' + os.path.join('path3', 'brave'), shell=True) mkzip() @@ -35,10 +36,10 @@ def main(): copyMods() # Run each test with a separate interpreter - os.system(sys.executable + " nonpkg.py") - os.system(sys.executable + " normal.py") - os.system(sys.executable + " split.py") - os.system(sys.executable + " zipsplit.py") + subprocess.check_call(sys.executable + " nonpkg.py", shell=True) + subprocess.check_call(sys.executable + " normal.py", shell=True) + subprocess.check_call(sys.executable + " split.py", shell=True) + subprocess.check_call(sys.executable + " zipsplit.py", shell=True) if __name__ == "__main__": From 604ae7186bcd9d5b8a2b781d5dcf9d52c0c759a3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Dec 2018 19:12:13 +0000 Subject: [PATCH 1182/2031] Fix for running 'python -m' when using swig -builtin Same as e05b5ea for -builtin. Also added runtime tests to check 'python -m'. --- CHANGES.current | 7 ++++++- .../python/import_packages/from_init1/runme.py | 18 +++++++++++++++++- .../python/import_packages/from_init2/runme.py | 12 +++++++++++- .../python/import_packages/from_init3/runme.py | 12 +++++++++++- .../import_packages/namespace_pkg/nonpkg.py | 11 +++++++++++ .../import_packages/namespace_pkg/normal.py | 10 ++++++++++ .../import_packages/namespace_pkg/runme.py | 3 ++- .../import_packages/namespace_pkg/split.py | 10 ++++++++++ .../import_packages/namespace_pkg/zipsplit.py | 10 ++++++++++ .../import_packages/relativeimport1/runme.py | 15 ++++++++++++++- .../import_packages/relativeimport2/runme.py | 15 ++++++++++++++- .../import_packages/relativeimport3/runme.py | 15 ++++++++++++++- .../import_packages/same_modnames1/runme.py | 6 ++++++ .../import_packages/same_modnames2/runme.py | 6 ++++++ .../split_modules/vanilla/runme.py | 6 ++++++ .../split_modules/vanilla_split/runme.py | 6 ++++++ Source/Modules/python.cxx | 2 +- 17 files changed, 155 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index aec1f140a..123c51f12 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-04: wsfulton + [Python] #1282 Fix running 'python -m' when using 'swig -builtin' + + Similar to the earlier PEP 366 conforming fix for non-builtin. + 2018-11-28: wsfulton [Python] When using -builtin, the two step C-extension module import is now one step and the wrapped API is only available once and not in an underlying @@ -44,7 +49,7 @@ Version 4.0.0 (in progress) [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) Previously any SWIG generated modules in a package would fail with an ImportError - when using 'python -m'. + when using 'python -m' for example 'python -m mypkg.mymodule'. 2018-11-13: wsfulton #1340 Remove -cppcast and -nocppcast command line options (this was an option diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py index 424e9ca44..aebe582a2 100644 --- a/Examples/python/import_packages/from_init1/runme.py +++ b/Examples/python/import_packages/from_init1/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,21 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py2.pkg2.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" + # commandline = sys.executable + " -m py3.pkg2.bar" + # subprocess.check_call(commandline, shell=True) + # print(" Finished running: " + commandline) + # commandline = sys.executable + " -m py3.pkg2.foo" + # subprocess.check_call(commandline, shell=True) + # print(" Finished running: " + commandline) + +# TODO: Commented out code above results in (from python-3.6 onwards): +# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py index 424e9ca44..88694db15 100644 --- a/Examples/python/import_packages/from_init2/runme.py +++ b/Examples/python/import_packages/from_init2/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,15 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" + # commandline = sys.executable + " -m py3.pkg2.bar" + # subprocess.check_call(commandline, shell=True) + # print(" Finished running: " + commandline) + +# TODO: Commented out code above results in (from python-3.6 onwards): +# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py index 424e9ca44..88694db15 100644 --- a/Examples/python/import_packages/from_init3/runme.py +++ b/Examples/python/import_packages/from_init3/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,15 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" + # commandline = sys.executable + " -m py3.pkg2.bar" + # subprocess.check_call(commandline, shell=True) + # print(" Finished running: " + commandline) + +# TODO: Commented out code above results in (from python-3.6 onwards): +# RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py index dc910b846..845758247 100644 --- a/Examples/python/import_packages/namespace_pkg/nonpkg.py +++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py @@ -1,6 +1,17 @@ +import os +import subprocess +import sys + +print(" Starting subtest " + os.path.basename(__file__)) + # import robin as a module in the global namespace import robin +print(" Finished importing robin") if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") + +commandline = sys.executable + " -m robin" +subprocess.check_call(commandline, shell=True) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py index 231d4cccd..d4bb39ef9 100644 --- a/Examples/python/import_packages/namespace_pkg/normal.py +++ b/Examples/python/import_packages/namespace_pkg/normal.py @@ -1,8 +1,18 @@ +import os +import subprocess import sys + +print(" Starting subtest " + os.path.basename(__file__)) + # Package brave found under one path sys.path.insert(0, 'path1') from brave import robin +print(" Finished from brave import robin") if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") + +commandline = sys.executable + " -m brave.robin" +subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path1"}) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/namespace_pkg/runme.py b/Examples/python/import_packages/namespace_pkg/runme.py index 9c22d36fb..d2af05619 100644 --- a/Examples/python/import_packages/namespace_pkg/runme.py +++ b/Examples/python/import_packages/namespace_pkg/runme.py @@ -1,7 +1,8 @@ # These examples rely on namespace packages. Don't # run them for old python interpreters. -import sys import os.path +import subprocess +import sys testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - namespace packages" diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py index 88d17d5fe..e92508db1 100644 --- a/Examples/python/import_packages/namespace_pkg/split.py +++ b/Examples/python/import_packages/namespace_pkg/split.py @@ -1,10 +1,20 @@ +import os +import subprocess import sys + +print(" Starting subtest " + os.path.basename(__file__)) + # Package brave split into two paths. # path2/brave/robin.py and path3/brave/_robin.so sys.path.insert(0, 'path2') sys.path.insert(0, 'path3') from brave import robin +print(" Finished from brave import robin") if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") + +commandline = sys.executable + " -m brave.robin" +subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path2:path3"}) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py index b027b11c1..fd24d522b 100644 --- a/Examples/python/import_packages/namespace_pkg/zipsplit.py +++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py @@ -1,10 +1,20 @@ +import os +import subprocess import sys + +print(" Starting subtest " + os.path.basename(__file__)) + # Package brave split into two paths. # brave/robin.py (in path4.zip) and path3/brave/_robin.so sys.path.insert(0, 'path4.zip') sys.path.insert(0, 'path3') from brave import robin +print(" Finished from brave import robin") if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") + +commandline = sys.executable + " -m brave.robin" +subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path3:path4.zip"}) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py index 5b1b5f45a..7de070af6 100644 --- a/Examples/python/import_packages/relativeimport1/runme.py +++ b/Examples/python/import_packages/relativeimport1/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,18 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py2.pkg2.pkg3.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" + commandline = sys.executable + " -m py3.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py3.pkg2.pkg3.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py index 9d1a05ec8..f4b5090a1 100644 --- a/Examples/python/import_packages/relativeimport2/runme.py +++ b/Examples/python/import_packages/relativeimport2/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,18 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py2.pkg2.pkg3.pkg4.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" + commandline = sys.executable + " -m py3.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py3.pkg2.pkg3.pkg4.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py index 5b1b5f45a..7de070af6 100644 --- a/Examples/python/import_packages/relativeimport3/runme.py +++ b/Examples/python/import_packages/relativeimport3/runme.py @@ -1,5 +1,6 @@ -import sys import os.path +import subprocess +import sys # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -12,6 +13,18 @@ if sys.version_info < (2, 5): if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" + commandline = sys.executable + " -m py2.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py2.pkg2.pkg3.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" + commandline = sys.executable + " -m py3.pkg2.bar" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) + commandline = sys.executable + " -m py3.pkg2.pkg3.foo" + subprocess.check_call(commandline, shell=True) + print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py index 5f6a7f57f..a3a579a17 100644 --- a/Examples/python/import_packages/same_modnames1/runme.py +++ b/Examples/python/import_packages/same_modnames1/runme.py @@ -1,4 +1,6 @@ import os.path +import subprocess +import sys # Test import of same modules from different packages testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) @@ -13,3 +15,7 @@ classname = str(type(var2)) if classname.find("pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) print " Successfully created object pkg2.foo.Pkg2_Foo" + +commandline = sys.executable + " -m pkg2.foo" +subprocess.check_call(commandline, shell=True) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py index 55f6826b9..cc1370286 100644 --- a/Examples/python/import_packages/same_modnames2/runme.py +++ b/Examples/python/import_packages/same_modnames2/runme.py @@ -1,4 +1,6 @@ import os.path +import subprocess +import sys testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -12,3 +14,7 @@ classname = str(type(var2)) if classname.find("pkg1.pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" + +commandline = sys.executable + " -m pkg1.pkg2.foo" +subprocess.check_call(commandline, shell=True) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py index 4c46ef200..35d5118aa 100644 --- a/Examples/python/import_packages/split_modules/vanilla/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla/runme.py @@ -1,4 +1,6 @@ import os.path +import subprocess +import sys testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - split modules" @@ -9,3 +11,7 @@ print " Finished importing pkg1.foo" if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") + +commandline = sys.executable + " -m pkg1.foo" +subprocess.check_call(commandline, shell=True) +print(" Finished running: " + commandline) diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py index 4c46ef200..35d5118aa 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py @@ -1,4 +1,6 @@ import os.path +import subprocess +import sys testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - split modules" @@ -9,3 +11,7 @@ print " Finished importing pkg1.foo" if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") + +commandline = sys.executable + " -m pkg1.foo" +subprocess.check_call(commandline, shell=True) +print(" Finished running: " + commandline) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c06497d8c..096dc3ce6 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -734,7 +734,7 @@ public: * */ Printf(default_import_code, "\n# Pull in all the attributes from %s\n", module); - Printv(default_import_code, "if __name__.rpartition('.')[0] != '':\n", NULL); + Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL); Printv(default_import_code, tab4, "try:\n", NULL); Printf(default_import_code, tab4 tab4 "from .%s import *\n", module); Printv(default_import_code, tab4 "except ImportError:\n", NULL); From 5e7426dcc6f269c10895a3bff6237a39e05888e4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 26 Nov 2018 14:47:20 +0100 Subject: [PATCH 1183/2031] Avoid comparing doubles in nested_in_template.i unit test This should also have been part of 30bb977a6436fa7903aca041606c1110d37a2401 See #1358. --- Examples/test-suite/csharp/nested_in_template_runme.cs | 4 ++-- Examples/test-suite/nested_in_template.i | 4 ++-- Examples/test-suite/python/nested_in_template_runme.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/csharp/nested_in_template_runme.cs b/Examples/test-suite/csharp/nested_in_template_runme.cs index 6d6f2e8a1..e57e03999 100644 --- a/Examples/test-suite/csharp/nested_in_template_runme.cs +++ b/Examples/test-suite/csharp/nested_in_template_runme.cs @@ -3,8 +3,8 @@ using nested_in_templateNamespace; public class runme { static void Main() { - var cd = new OuterTemplate1.ConcreteDerived(8.8); - if (cd.m_value != 8.8) + var cd = new OuterTemplate1.ConcreteDerived(88); + if (cd.m_value != 88) throw new Exception("ConcreteDerived not created correctly"); } } diff --git a/Examples/test-suite/nested_in_template.i b/Examples/test-suite/nested_in_template.i index d878c62b0..2e79fa574 100644 --- a/Examples/test-suite/nested_in_template.i +++ b/Examples/test-suite/nested_in_template.i @@ -20,13 +20,13 @@ struct OuterTemplate<1> struct ConcreteDerived : AbstractBase { ConcreteDerived() : m_value(0.) {} - explicit ConcreteDerived(double value) : m_value(value) {} + explicit ConcreteDerived(int value) : m_value(value) {} virtual bool IsSameAs(const AbstractBase& other) const { return m_value == static_cast(other).m_value; } - double m_value; + int m_value; }; }; %} diff --git a/Examples/test-suite/python/nested_in_template_runme.py b/Examples/test-suite/python/nested_in_template_runme.py index b4aa25b9b..69afd1604 100644 --- a/Examples/test-suite/python/nested_in_template_runme.py +++ b/Examples/test-suite/python/nested_in_template_runme.py @@ -1,5 +1,5 @@ from nested_in_template import * -cd = ConcreteDerived(8.8) -if cd.m_value != 8.8: +cd = ConcreteDerived(88) +if cd.m_value != 88: raise RuntimeError("ConcreteDerived not created correctly") From 9a7e2ed9ed29b3e14c7f28c4b6b327e529e05aca Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Dec 2018 20:10:49 +0000 Subject: [PATCH 1184/2031] Restore Python docstring location to immediately after the SWIG banner --- Source/Modules/python.cxx | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 096dc3ce6..396a5d22e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -681,18 +681,6 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("python", f_shadow); - if (mod_docstring) { - if (Len(mod_docstring)) { - const char *triple_double = "\"\"\""; - // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ - // reported by pep257: https://github.com/GreenSteam/pep257 - bool multi_line_ds = Strchr(mod_docstring, '\n') != 0; - Printv(f_shadow_after_begin, "\n", triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n", NIL); - } - Delete(mod_docstring); - mod_docstring = NULL; - } - if (!builtin) { /* Import the C-extension module. This should be a relative import, * since the shadow module may also have been imported by a relative @@ -897,6 +885,19 @@ public: if (shadow) { Swig_banner_target_lang(f_shadow_py, "#"); + + if (mod_docstring) { + if (Len(mod_docstring)) { + const char *triple_double = "\"\"\""; + // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ + // reported by pep257: https://github.com/GreenSteam/pep257 + bool multi_line_ds = Strchr(mod_docstring, '\n') != 0; + Printv(f_shadow_py, "\n", triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n", NIL); + } + Delete(mod_docstring); + mod_docstring = NULL; + } + if (Len(f_shadow_begin) > 0) Printv(f_shadow_py, "\n", f_shadow_begin, "\n", NIL); From 009415e43b1e4aa11dcf0725adcd00067ad6b05e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Dec 2018 22:15:52 +0000 Subject: [PATCH 1185/2031] Cosmetic changes in SWIG_globals Make local variable name standards compliant --- Lib/python/pyinit.swg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index d8f3bf444..2ca90188d 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -226,9 +226,10 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { - static PyObject *_SWIG_globals = 0; - if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); - return _SWIG_globals; + static PyObject *globals = 0; + if (!globals) + globals = SWIG_newvarlink(); + return globals; } /* ----------------------------------------------------------------------------- From 8d6f3010ea973f6debf81a046dbe4ed0aac5c7cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Dec 2018 22:35:47 +0000 Subject: [PATCH 1186/2031] Temporarily remove Python import_packages testcase The subprocess.check_call seems broken on Windows, needs investigation. --- Examples/python/check.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/python/check.list b/Examples/python/check.list index 0798b5f7e..ba93ba713 100644 --- a/Examples/python/check.list +++ b/Examples/python/check.list @@ -14,7 +14,7 @@ funcptr2 functor import import_template -import_packages +#import_packages #libffi multimap operator From ff93f2e26ee2b4999f62f576bd69604f75bcb2ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Dec 2018 19:43:13 +0000 Subject: [PATCH 1187/2031] Skip Python subprocess calls in import_packages testcase on Windows Getting these kind of errors on Appveyor which uses mingw/cygwin to run a Python interpreter: Native windows Python 3.6 running under cygwin and mingw Python 3.7 running under mingw: Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python Cygwin Python 2.7 running under cygwin: 0 [main] python2.7 496 child_info_fork::abort: address space needed by '_foo.dll' (0x6D0000) is already occupied --- .../python/import_packages/from_init1/runme.py | 18 ++++++++++-------- .../python/import_packages/from_init2/runme.py | 12 ++++++++---- .../python/import_packages/from_init3/runme.py | 12 ++++++++---- .../import_packages/namespace_pkg/nonpkg.py | 9 +++++++-- .../import_packages/namespace_pkg/normal.py | 9 +++++++-- .../import_packages/namespace_pkg/nstest.py | 13 +++++++++---- .../import_packages/namespace_pkg/split.py | 9 +++++++-- .../import_packages/namespace_pkg/zipsplit.py | 9 +++++++-- .../import_packages/relativeimport1/runme.py | 18 ++++++++++-------- .../import_packages/relativeimport2/runme.py | 18 ++++++++++-------- .../import_packages/relativeimport3/runme.py | 18 ++++++++++-------- .../import_packages/same_modnames1/runme.py | 9 +++++++-- .../import_packages/same_modnames2/runme.py | 9 +++++++-- .../split_modules/vanilla/runme.py | 9 +++++++-- .../split_modules/vanilla_split/runme.py | 9 +++++++-- 15 files changed, 121 insertions(+), 60 deletions(-) diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py index aebe582a2..a663a136b 100644 --- a/Examples/python/import_packages/from_init1/runme.py +++ b/Examples/python/import_packages/from_init1/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -14,20 +20,16 @@ if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" # commandline = sys.executable + " -m py3.pkg2.bar" - # subprocess.check_call(commandline, shell=True) - # print(" Finished running: " + commandline) + # run_except_on_windows(commandline) # commandline = sys.executable + " -m py3.pkg2.foo" - # subprocess.check_call(commandline, shell=True) - # print(" Finished running: " + commandline) + # run_except_on_windows(commandline) # TODO: Commented out code above results in (from python-3.6 onwards): # RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py index 88694db15..3c7b12693 100644 --- a/Examples/python/import_packages/from_init2/runme.py +++ b/Examples/python/import_packages/from_init2/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -14,14 +20,12 @@ if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" # commandline = sys.executable + " -m py3.pkg2.bar" - # subprocess.check_call(commandline, shell=True) - # print(" Finished running: " + commandline) + # run_except_on_windows(commandline) # TODO: Commented out code above results in (from python-3.6 onwards): # RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py index 88694db15..3c7b12693 100644 --- a/Examples/python/import_packages/from_init3/runme.py +++ b/Examples/python/import_packages/from_init3/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -14,14 +20,12 @@ if sys.version_info < (3, 0): import py2.pkg2 print " Finished importing py2.pkg2" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2 print " Finished importing py3.pkg2" # commandline = sys.executable + " -m py3.pkg2.bar" - # subprocess.check_call(commandline, shell=True) - # print(" Finished running: " + commandline) + # run_except_on_windows(commandline) # TODO: Commented out code above results in (from python-3.6 onwards): # RuntimeWarning: 'py3.pkg2.bar' found in sys.modules after import of package 'py3.pkg2', but prior to execution of 'py3.pkg2.bar'; this may result in unpredictable behaviour diff --git a/Examples/python/import_packages/namespace_pkg/nonpkg.py b/Examples/python/import_packages/namespace_pkg/nonpkg.py index 845758247..52be74db4 100644 --- a/Examples/python/import_packages/namespace_pkg/nonpkg.py +++ b/Examples/python/import_packages/namespace_pkg/nonpkg.py @@ -2,6 +2,12 @@ import os import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + print(" Starting subtest " + os.path.basename(__file__)) # import robin as a module in the global namespace @@ -13,5 +19,4 @@ if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") commandline = sys.executable + " -m robin" -subprocess.check_call(commandline, shell=True) -print(" Finished running: " + commandline) +run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py index d4bb39ef9..924142f74 100644 --- a/Examples/python/import_packages/namespace_pkg/normal.py +++ b/Examples/python/import_packages/namespace_pkg/normal.py @@ -2,6 +2,12 @@ import os import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + print(" Starting subtest " + os.path.basename(__file__)) # Package brave found under one path @@ -14,5 +20,4 @@ if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") commandline = sys.executable + " -m brave.robin" -subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path1"}) -print(" Finished running: " + commandline) +run_except_on_windows(commandline, env = {"PYTHONPATH": "path1"}) diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py index b0b146c92..e80289fb1 100644 --- a/Examples/python/import_packages/namespace_pkg/nstest.py +++ b/Examples/python/import_packages/namespace_pkg/nstest.py @@ -4,6 +4,11 @@ import shutil import subprocess import zipfile +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) def copyMods(): dirs = ['path1', 'path2', 'path3'] @@ -36,10 +41,10 @@ def main(): copyMods() # Run each test with a separate interpreter - subprocess.check_call(sys.executable + " nonpkg.py", shell=True) - subprocess.check_call(sys.executable + " normal.py", shell=True) - subprocess.check_call(sys.executable + " split.py", shell=True) - subprocess.check_call(sys.executable + " zipsplit.py", shell=True) + run_except_on_windows(sys.executable + " nonpkg.py") + run_except_on_windows(sys.executable + " normal.py") + run_except_on_windows(sys.executable + " split.py") + run_except_on_windows(sys.executable + " zipsplit.py") if __name__ == "__main__": diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py index e92508db1..8989954cc 100644 --- a/Examples/python/import_packages/namespace_pkg/split.py +++ b/Examples/python/import_packages/namespace_pkg/split.py @@ -2,6 +2,12 @@ import os import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + print(" Starting subtest " + os.path.basename(__file__)) # Package brave split into two paths. @@ -16,5 +22,4 @@ if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") commandline = sys.executable + " -m brave.robin" -subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path2:path3"}) -print(" Finished running: " + commandline) +run_except_on_windows(commandline , env = {"PYTHONPATH": "path2:path3"}) diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py index fd24d522b..8af9cf025 100644 --- a/Examples/python/import_packages/namespace_pkg/zipsplit.py +++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py @@ -2,6 +2,12 @@ import os import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + print(" Starting subtest " + os.path.basename(__file__)) # Package brave split into two paths. @@ -16,5 +22,4 @@ if not(robin.run() == "AWAY!"): raise RuntimeError("test failed") commandline = sys.executable + " -m brave.robin" -subprocess.check_call(commandline, shell=True, env = {"PYTHONPATH": "path3:path4.zip"}) -print(" Finished running: " + commandline) +run_except_on_windows(commandline, env = {"PYTHONPATH": "path3:path4.zip"}) diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py index 7de070af6..87101ea46 100644 --- a/Examples/python/import_packages/relativeimport1/runme.py +++ b/Examples/python/import_packages/relativeimport1/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) with -relativeimport" @@ -14,17 +20,13 @@ if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" commandline = sys.executable + " -m py3.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py index f4b5090a1..f5b55782f 100644 --- a/Examples/python/import_packages/relativeimport2/runme.py +++ b/Examples/python/import_packages/relativeimport2/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -14,17 +20,13 @@ if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.pkg4.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" commandline = sys.executable + " -m py3.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.pkg4.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py index 7de070af6..87101ea46 100644 --- a/Examples/python/import_packages/relativeimport3/runme.py +++ b/Examples/python/import_packages/relativeimport3/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) with -relativeimport" @@ -14,17 +20,13 @@ if sys.version_info < (3, 0): import py2.pkg2.bar print " Finished importing py2.pkg2.bar" commandline = sys.executable + " -m py2.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) else: import py3.pkg2.bar print " Finished importing py3.pkg2.bar" commandline = sys.executable + " -m py3.pkg2.bar" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.foo" - subprocess.check_call(commandline, shell=True) - print(" Finished running: " + commandline) + run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py index a3a579a17..a64551bfd 100644 --- a/Examples/python/import_packages/same_modnames1/runme.py +++ b/Examples/python/import_packages/same_modnames1/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + # Test import of same modules from different packages testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -17,5 +23,4 @@ if classname.find("pkg2.foo.Pkg2_Foo") == -1: print " Successfully created object pkg2.foo.Pkg2_Foo" commandline = sys.executable + " -m pkg2.foo" -subprocess.check_call(commandline, shell=True) -print(" Finished running: " + commandline) +run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py index cc1370286..c2cf2744c 100644 --- a/Examples/python/import_packages/same_modnames2/runme.py +++ b/Examples/python/import_packages/same_modnames2/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" @@ -16,5 +22,4 @@ if classname.find("pkg1.pkg2.foo.Pkg2_Foo") == -1: print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" commandline = sys.executable + " -m pkg1.pkg2.foo" -subprocess.check_call(commandline, shell=True) -print(" Finished running: " + commandline) +run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py index 35d5118aa..79d79b4c3 100644 --- a/Examples/python/import_packages/split_modules/vanilla/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - split modules" @@ -13,5 +19,4 @@ if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") commandline = sys.executable + " -m pkg1.foo" -subprocess.check_call(commandline, shell=True) -print(" Finished running: " + commandline) +run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py index 35d5118aa..79d79b4c3 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py @@ -2,6 +2,12 @@ import os.path import subprocess import sys +def run_except_on_windows(commandline, env=None): + if os.name != "nt" and sys.platform != "cygwin": + # Strange failures on windows/cygin/mingw + subprocess.check_call(commandline, env=env, shell=True) + print(" Finished running: " + commandline) + testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) print "Testing " + testname + " - split modules" @@ -13,5 +19,4 @@ if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") commandline = sys.executable + " -m pkg1.foo" -subprocess.check_call(commandline, shell=True) -print(" Finished running: " + commandline) +run_except_on_windows(commandline) From 84dcb9bfffc964a5e35c9485f4c80ced14ec8564 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Dec 2018 19:57:44 +0000 Subject: [PATCH 1188/2031] Revert "Temporarily remove Python import_packages testcase" This reverts commit 8d6f3010ea973f6debf81a046dbe4ed0aac5c7cf. --- Examples/python/check.list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/python/check.list b/Examples/python/check.list index ba93ba713..0798b5f7e 100644 --- a/Examples/python/check.list +++ b/Examples/python/check.list @@ -14,7 +14,7 @@ funcptr2 functor import import_template -#import_packages +import_packages #libffi multimap operator From ba61d51124873c57a170e87cbf5922583fb7b6f0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Dec 2018 20:22:35 +0000 Subject: [PATCH 1189/2031] Visual C++ 64-bit warning fixes in doxygen sources --- Source/Doxygen/javadoc.cxx | 10 +++++----- Source/Doxygen/pydoc.cxx | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Doxygen/javadoc.cxx b/Source/Doxygen/javadoc.cxx index 628f5a666..72f84ab6c 100644 --- a/Source/Doxygen/javadoc.cxx +++ b/Source/Doxygen/javadoc.cxx @@ -243,10 +243,10 @@ JavaDocConverter::JavaDocConverter(int flags) : std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { std::string formattedLines; return unformattedLine; // currently disabled - int lastPosition = 0; - int i = 0; + std::string::size_type lastPosition = 0; + std::string::size_type i = 0; int isFirstLine = 1; - while (i != -1 && i < (int) unformattedLine.length()) { + while (i != std::string::npos && i < unformattedLine.length()) { lastPosition = i; if (isFirstLine) { i += APPROX_LINE_LENGTH; @@ -256,7 +256,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < (int) unformattedLine.length()) { + if (i > 0 && i + 1 < unformattedLine.length()) { if (!isFirstLine) for (int j = 0; j < indent; j++) { formattedLines.append("\t"); @@ -268,7 +268,7 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind } } - if (lastPosition < (int) unformattedLine.length()) { + if (lastPosition < unformattedLine.length()) { if (!isFirstLine) { for (int j = 0; j < indent; j++) { formattedLines.append("\t"); diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 0f8484d6b..8c3090035 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -52,7 +52,7 @@ public: m_output = &output; m_indent = &indent; - const size_t lastNonSpace = m_output->find_last_not_of(' '); + const string::size_type lastNonSpace = m_output->find_last_not_of(' '); if (lastNonSpace == string::npos) { m_firstLineIndent = m_output->length(); } else if ((*m_output)[lastNonSpace] == '\n') { @@ -95,7 +95,7 @@ public: private: string *m_output; string *m_indent; - unsigned m_firstLineIndent; + string::size_type m_firstLineIndent; bool m_initialized; IndentGuard(const IndentGuard &); @@ -131,7 +131,7 @@ static size_t determineIndent(const string &s) { } static void trimWhitespace(string &s) { - const size_t lastNonSpace = s.find_last_not_of(' '); + const string::size_type lastNonSpace = s.find_last_not_of(' '); if (lastNonSpace == string::npos) s.clear(); else From 0147fb2e64d12284262ce0db741ba241028e0992 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Dec 2018 07:44:34 +0000 Subject: [PATCH 1190/2031] Workaround for incorrect output formatting --- Lib/python/pyinit.swg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 2ca90188d..6a0e08af4 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -227,8 +227,9 @@ SWIG_Python_addvarlink(PyObject *p, const char *name, PyObject *(*get_attr)(void SWIGINTERN PyObject * SWIG_globals(void) { static PyObject *globals = 0; - if (!globals) + if (!globals) { globals = SWIG_newvarlink(); + } return globals; } From 248039d708ab9ab646adba5bd5aa45f536ae8c7f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Dec 2018 07:53:46 +0000 Subject: [PATCH 1191/2031] Updates to .gitignore for python and java examples --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index d2e6b841f..ad1a32c64 100644 --- a/.gitignore +++ b/.gitignore @@ -152,6 +152,7 @@ Examples/guile/*/my-guile Examples/test-suite/java/*/ Examples/java/*/*.java !Examples/java/*/runme.java +Examples/java/doxygen/javadocs # Javascript Examples/test-suite/javascript/*/ @@ -185,6 +186,8 @@ Examples/python/**/bar.py Examples/python/**/base.py Examples/python/**/foo.py Examples/python/**/spam.py +Examples/python/**/robin.py +Examples/python/doxygen/example.html # R Examples/test-suite/r/*.R From ebb3eb725a7e6a80cbaa1d98226c6aba02ba9c08 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Dec 2018 08:57:21 +0000 Subject: [PATCH 1192/2031] Add changes file entry for missing nested destructor wrapper fix Issue #1359 --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e08aa5cb6..c484ef6c0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-06: vadz + #1359 #1364 Add missing nested class destructor wrapper when the nested class is + inside a template. Removes associated bogus 'Illegal destructor name' warning. Only + occurred when the nested class' destructor is explicitly specified. + 2018-12-04: wsfulton [Python] #1282 Fix running 'python -m' when using 'swig -builtin' From b19d3e06b3132b0c212fd2fb8c2ceb5cc1cac263 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Dec 2018 20:25:58 +0000 Subject: [PATCH 1193/2031] Update packages section in Python html docs Updates given only Python 2.7, 3.2+ are now supported. --- Doc/Manual/Python.html | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index eee47f922..ff5ef2993 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -5853,12 +5853,19 @@ class M2(pkg2.mod3.M3): pass -

        By default, SWIG would generate mod2.py proxy file with +

        By default, SWIG will generate mod2.py proxy file with import directive as in point 1. This can be changed with the -relativeimport command line option. The -relativeimport instructs -SWIG to organize imports as in point 2 (for Python < 2.7.0) or as in point 4 -for Python 2.7.0 and newer. This is a check done at the time the module is -imported. In short, if you have +SWIG to organize imports as in point 4 for Python 2.7.0 and newer. +

        + +

        +Compatibility Note: Versions of SWIG prior to SWIG-4.0.0 supported Python < 2.7.0 +and would organize the imports as in point 2 if an older version of Python was detected at runtime. +

        + +

        +In short, if you have mod2.i and mod3.i as above, then without -relativeimport SWIG will write

        @@ -5873,13 +5880,8 @@ write

        -from sys import version_info
        -if version_info >= (2, 7, 0):
        -    from . import pkg2
        -    import pkg1.pkg2.mod3
        -else:
        -    import pkg2.mod3
        -del version_info
        +from . import pkg2
        +from .pkg2 import mod3
         
        @@ -5917,7 +5919,7 @@ from __future__ import absolute_import -

        at the very beginning of his proxy *.py file. In SWIG, it may be +

        at the very beginning of your proxy *.py file. In SWIG, it may be accomplished with %pythonbegin directive as follows:

        @@ -6129,8 +6131,8 @@ covered next.

        -The pure Python module needs to load the C/C++ module in order to link -to the wrapped C/C++ methods. To do this it must make some assumptions +The pure Python module needs to load the C/C++ module in order to call +the wrapped C/C++ methods. To do this it must make some assumptions about what package the C/C++ module may be located in. The approach the pure Python module uses to find the C/C++ module is as follows:

        From 51dadaeacde6de32ab945ef0c930e1f3d95f2ae0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Dec 2018 22:31:26 +0000 Subject: [PATCH 1194/2031] Add example to test the Python module being renamed to __init__.py This examples tests the SWIG generated module being placed into a directory and then renamed __init__.py to convert the module into a package. This ability stopped working in swig-3.0.9. However, only Python 2.7 or 3.3 and later work. If Python 3.2 support is needed, use moduleimport in %module to customise the import code. Issue #1282 --- CHANGES.current | 6 +++++ Examples/python/import_packages/Makefile | 1 + .../import_packages/module_is_init/Makefile | 15 +++++++++++ .../import_packages/module_is_init/README | 18 +++++++++++++ .../module_is_init/pkg1/Makefile | 20 ++++++++++++++ .../module_is_init/pkg1/foo.hpp | 10 +++++++ .../import_packages/module_is_init/pkg1/foo.i | 5 ++++ .../import_packages/module_is_init/runme.py | 26 +++++++++++++++++++ 8 files changed, 101 insertions(+) create mode 100644 Examples/python/import_packages/module_is_init/Makefile create mode 100644 Examples/python/import_packages/module_is_init/README create mode 100644 Examples/python/import_packages/module_is_init/pkg1/Makefile create mode 100644 Examples/python/import_packages/module_is_init/pkg1/foo.hpp create mode 100644 Examples/python/import_packages/module_is_init/pkg1/foo.i create mode 100644 Examples/python/import_packages/module_is_init/runme.py diff --git a/CHANGES.current b/CHANGES.current index c484ef6c0..c4cc251e6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -61,6 +61,12 @@ Version 4.0.0 (in progress) Previously any SWIG generated modules in a package would fail with an ImportError when using 'python -m' for example 'python -m mypkg.mymodule'. + This fix also allows the SWIG generated module to be placed into a directory and + then renamed __init__.py to convert the module into a package again. This ability + stopped working in swig-3.0.9. However, only Python 2.7 or 3.3 and later work. If + Python 3.2 support is needed, use moduleimport in %module to customise the import + code. + 2018-11-13: wsfulton #1340 Remove -cppcast and -nocppcast command line options (this was an option available to the scripting language targets). diff --git a/Examples/python/import_packages/Makefile b/Examples/python/import_packages/Makefile index 2857866d4..c7f9a830b 100644 --- a/Examples/python/import_packages/Makefile +++ b/Examples/python/import_packages/Makefile @@ -8,6 +8,7 @@ import_packages_subdirs = \ from_init1 \ from_init2 \ from_init3 \ + module_is_init \ relativeimport1 \ relativeimport2 \ relativeimport3 \ diff --git a/Examples/python/import_packages/module_is_init/Makefile b/Examples/python/import_packages/module_is_init/Makefile new file mode 100644 index 000000000..43763aa4b --- /dev/null +++ b/Examples/python/import_packages/module_is_init/Makefile @@ -0,0 +1,15 @@ +TOP = ../../.. +LIBS = + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run + +build: + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build + +static: + cd pkg1 && $(MAKE) SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean + cd pkg1 && $(MAKE) clean diff --git a/Examples/python/import_packages/module_is_init/README b/Examples/python/import_packages/module_is_init/README new file mode 100644 index 000000000..ee7391cda --- /dev/null +++ b/Examples/python/import_packages/module_is_init/README @@ -0,0 +1,18 @@ +This example tests renaming the generated SWIG pure Python module to __init__.py +to turn the module into a Python package. + +Use 'python runme.py' to run the test. + +Overview: +--------- + +SWIG generates a pure Python module foo.py from the input interface file foo.i. +The foo.py file is generated within the pkg1 directory and is then renamed __init__.py. +This results in everything in the SWIG generated module being available in the Python +pkg1 package. + +This approach of turning the SWIG generated module into a package worked in versions +of SWIG up to swig-3.0.8, but stopped working from swig-3.0.9 until it was +re-instated in swig-4.0.0. However, Python 2.7 or 3.3 and later are needed to +work out of the box. Python 3.2 does not work as this version of Python does +not set __package__ in __init__.py. diff --git a/Examples/python/import_packages/module_is_init/pkg1/Makefile b/Examples/python/import_packages/module_is_init/pkg1/Makefile new file mode 100644 index 000000000..d9d83ed0a --- /dev/null +++ b/Examples/python/import_packages/module_is_init/pkg1/Makefile @@ -0,0 +1,20 @@ +TOP = ../../../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = +LIBS = + +build: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp + mv foo.py __init__.py + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean + rm -f __init__.py diff --git a/Examples/python/import_packages/module_is_init/pkg1/foo.hpp b/Examples/python/import_packages/module_is_init/pkg1/foo.hpp new file mode 100644 index 000000000..01c462266 --- /dev/null +++ b/Examples/python/import_packages/module_is_init/pkg1/foo.hpp @@ -0,0 +1,10 @@ + +int foofunction(int i) { + return i *= 10; +} + +struct FooClass { + int foomethod(int i) { + return i += 5; + } +}; diff --git a/Examples/python/import_packages/module_is_init/pkg1/foo.i b/Examples/python/import_packages/module_is_init/pkg1/foo.i new file mode 100644 index 000000000..f8d71380c --- /dev/null +++ b/Examples/python/import_packages/module_is_init/pkg1/foo.i @@ -0,0 +1,5 @@ +%module foo +%{ +#include "./foo.hpp" +%} +%include "./foo.hpp" diff --git a/Examples/python/import_packages/module_is_init/runme.py b/Examples/python/import_packages/module_is_init/runme.py new file mode 100644 index 000000000..b5e646e85 --- /dev/null +++ b/Examples/python/import_packages/module_is_init/runme.py @@ -0,0 +1,26 @@ +import os.path +import sys + +# Test import of a SWIG generated module renamed as the package's __init__.py +testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) +print "Testing " + testname + " - module renamed as __init__.py" + +if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0): + print " Not importing as Python version is >= 3.0 and < 3.3" + # Package detection does not work in these versions. + # Can be fixed by using this in the interface file: + # %module(moduleimport="from . import $module") foo # without -builtin + # %module(moduleimport="from .$module import *") foo # with -builtin + sys.exit(0) + +import pkg1 +print " Finished importing pkg1" + +if pkg1.foofunction(123) != 1230: + raise RuntimeError("foofunction failed") + +fc = pkg1.FooClass() +if fc.foomethod(1) != 6: + raise RuntimeError("foomethod failed") + +print " Finished testing pkg1" From 67f5ade7ad03f15a2811190df899196dbf5a12fe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Dec 2018 07:07:49 +0000 Subject: [PATCH 1195/2031] Remove -noolddefs command line option This was a pointless option as it is off by default. --- Source/Modules/python.cxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 66d34992a..8764fd97f 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -127,11 +127,10 @@ static const char *usage2 = "\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ -noh - Don't generate the output header file\n"; static const char *usage3 = "\ - -noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\ -noproxy - Don't generate proxy classes \n\ -nortti - Disable the use of the native C++ RTTI with directors\n\ -nothreads - Disable thread support for the entire interface\n\ - -olddefs - Keep the old method definitions even when using fastproxy\n\ + -olddefs - Keep the old method definitions when using -fastproxy\n\ -py3 - Generate code with Python 3 specific features and syntax\n\ -relativeimport - Use relative python imports \n\ -threads - Add thread support for all the interface\n\ @@ -377,9 +376,6 @@ public: } else if (strcmp(argv[i], "-olddefs") == 0) { olddefs = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-noolddefs") == 0) { - olddefs = 0; - Swig_mark_arg(i); } else if (strcmp(argv[i], "-castmode") == 0) { castmode = 1; Swig_mark_arg(i); @@ -444,6 +440,7 @@ public: strcmp(argv[i], "-nofastquery") == 0 || strcmp(argv[i], "-nomodern") == 0 || strcmp(argv[i], "-nomodernargs") == 0 || + strcmp(argv[i], "-noolddefs") == 0 || strcmp(argv[i], "-nooutputtuple") == 0 || strcmp(argv[i], "-noproxyimport") == 0 || strcmp(argv[i], "-nosafecstrings") == 0 || From f8bf286a6e26bfcefebe99815a03acbd7176e90d Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 27 Nov 2018 23:36:26 +0000 Subject: [PATCH 1196/2031] #1368: AV in tp_print caused by mismatched Python/extension CRT usage --- Lib/python/pyinit.swg | 2 +- Lib/python/pyrun.swg | 2 +- Source/Modules/python.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 6a0e08af4..1c426e615 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -155,7 +155,7 @@ swig_varlink_type(void) { sizeof(swig_varlinkobject), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor) swig_varlink_dealloc, /* tp_dealloc */ - (printfunc) swig_varlink_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc) swig_varlink_getattr, /* tp_getattr */ (setattrfunc) swig_varlink_setattr, /* tp_setattr */ 0, /* tp_compare */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 7386ff7e2..53b952599 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -822,7 +822,7 @@ SwigPyPacked_TypeOnce(void) { sizeof(SwigPyPacked), /* tp_basicsize */ 0, /* tp_itemsize */ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ + 0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ #if PY_VERSION_HEX>=0x03000000 diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8764fd97f..a595a83fd 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4013,7 +4013,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_basicsize", tp_basicsize), "tp_basicsize"); printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize"); printSlot(f, getSlot(n, "feature:python:tp_dealloc", tp_dealloc_bad), "tp_dealloc", "destructor"); - printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc"); + Printv(f, " 0, /* tp_print */\n"); printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc"); printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); From 23d62a8969678a4ee64ceb62229ed676e84de729 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 4 Dec 2018 23:09:39 +0000 Subject: [PATCH 1197/2031] Update changelog. --- CHANGES.current | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index c4cc251e6..25a6d060f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -12,6 +12,13 @@ Version 4.0.0 (in progress) inside a template. Removes associated bogus 'Illegal destructor name' warning. Only occurred when the nested class' destructor is explicitly specified. +2018-12-04: adr26 + [Python] #1368 AV in tp_print caused by mismatched Python/extension CRT usage + + Remove all use of tp_print, as this API uses a FILE*, which can be + mismatched when modules are built with different C libraries from + the main python executable. + 2018-12-04: wsfulton [Python] #1282 Fix running 'python -m' when using 'swig -builtin' From 90221812c67bb94180e27c6f58afbb99bf40fc5b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Dec 2018 08:00:44 +0000 Subject: [PATCH 1198/2031] Revert removal of tp_print slot for Python -builtin Some users might still want to customize this slot. --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a595a83fd..8764fd97f 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4013,7 +4013,7 @@ public: printSlot(f, getSlot(n, "feature:python:tp_basicsize", tp_basicsize), "tp_basicsize"); printSlot(f, getSlot(n, "feature:python:tp_itemsize"), "tp_itemsize"); printSlot(f, getSlot(n, "feature:python:tp_dealloc", tp_dealloc_bad), "tp_dealloc", "destructor"); - Printv(f, " 0, /* tp_print */\n"); + printSlot(f, getSlot(n, "feature:python:tp_print"), "tp_print", "printfunc"); printSlot(f, getSlot(n, "feature:python:tp_getattr"), "tp_getattr", "getattrfunc"); printSlot(f, getSlot(n, "feature:python:tp_setattr"), "tp_setattr", "setattrfunc"); Printv(f, "#if PY_VERSION_HEX >= 0x03000000\n", NIL); From b8fc71b5f875f85297cf79c7cb85e339e96c04c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Dec 2018 08:08:14 +0000 Subject: [PATCH 1199/2031] Remove functions associated with tp_print that are now redundant Removes SwigPyPacked_print and swig_varlink_print --- Lib/python/pyinit.swg | 11 ----------- Lib/python/pyname_compat.i | 1 - Lib/python/pyrun.swg | 14 -------------- 3 files changed, 26 deletions(-) diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 1c426e615..3409fbb4a 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -82,17 +82,6 @@ swig_varlink_str(swig_varlinkobject *v) { return str; } -SWIGINTERN int -swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - PyObject *str = swig_varlink_str(v); - const char *tmp = SWIG_Python_str_AsChar(str); - fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp ? tmp : "Invalid global variable"); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(str); - return 0; -} - SWIGINTERN void swig_varlink_dealloc(swig_varlinkobject *v) { swig_globalvar *var = v->vars; diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i index dc276e686..a9630dbe7 100644 --- a/Lib/python/pyname_compat.i +++ b/Lib/python/pyname_compat.i @@ -76,7 +76,6 @@ #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 diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 53b952599..32ce2d923 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -736,20 +736,6 @@ typedef struct { size_t size; } SwigPyPacked; -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - SWIGRUNTIME PyObject * SwigPyPacked_repr(SwigPyPacked *v) { From 230b979c0f6e4d57fa213c6a89945357a6b2a0aa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 11 Dec 2018 08:17:56 +0000 Subject: [PATCH 1200/2031] Update changes file with tp_print removal --- CHANGES.current | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 25a6d060f..f41db17ca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -13,12 +13,17 @@ Version 4.0.0 (in progress) occurred when the nested class' destructor is explicitly specified. 2018-12-04: adr26 - [Python] #1368 AV in tp_print caused by mismatched Python/extension CRT usage + [Python] #1368 #1369 Access Violation in tp_print caused by mismatched Python/extension + CRT usage Remove all use of tp_print, as this API uses a FILE*, which can be mismatched when modules are built with different C libraries from the main python executable. + This change also brings consistent output between Python 2 and 3 for the 'cvar' SWIG + object (that contains the global variables) and SWIG packed objects (such as callback + constants). + 2018-12-04: wsfulton [Python] #1282 Fix running 'python -m' when using 'swig -builtin' From 871ece78e644875a51d7e165bd6452515742f298 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Mon, 10 Dec 2018 15:37:41 -0800 Subject: [PATCH 1201/2031] repair uses of EXTEND() in Perl typemaps closes #1374 * enhance testing around multiple return values Examples/test-suite/perl5/scilab_multivalue_runme.pl fails in perl-5.28.1 compiled with -DDEBUGING without the typemap updates * repair EXTEND() handling in typemaps * Use PL_sv_undef for VOID_Object --- CHANGES.current | 3 + .../perl5/scilab_multivalue_runme.pl | 88 +++++++++++++++++++ Lib/perl5/perltypemaps.swg | 4 +- Lib/perl5/typemaps.i | 10 +-- 4 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/perl5/scilab_multivalue_runme.pl diff --git a/CHANGES.current b/CHANGES.current index c4cc251e6..90239a2a5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-11: tlby + [Perl] #1374 repair EXTEND() handling in typemaps + 2018-12-06: vadz #1359 #1364 Add missing nested class destructor wrapper when the nested class is inside a template. Removes associated bogus 'Illegal destructor name' warning. Only diff --git a/Examples/test-suite/perl5/scilab_multivalue_runme.pl b/Examples/test-suite/perl5/scilab_multivalue_runme.pl new file mode 100644 index 000000000..8be8834f7 --- /dev/null +++ b/Examples/test-suite/perl5/scilab_multivalue_runme.pl @@ -0,0 +1,88 @@ +use strict; +use warnings; +use Test::More tests => 44; +BEGIN { use_ok('scilab_multivalue') } +require_ok('scilab_multivalue'); + +my($a, $b, $c, $d, $ret); + +# OUTPUT + +($a, $b) = scilab_multivalue::output2(); +is($a, 1, "[a, b] = output2(): a"); +is($b, 2, "[a, b] = output2(): b"); + +($ret, $a, $b) = scilab_multivalue::output2Ret(); +is($ret, 3, "[a, b] = output2Ret(): b"); +is($a, 1, "[a, b] = output2Ret(): a"); +is($b, 2, "[a, b] = output2Ret(): b"); + +($c, $d) = scilab_multivalue::output2Input2(1, 2); +is($c, 2, "[c, d] = output2Input2(1, 2): c"); +is($d, 4, "[c, d] = output2Input2(1, 2): d"); + +($ret, $c, $d) = scilab_multivalue::output2Input2Ret(1, 2); +is($ret, 6, "[ret, c, d] = output2Input2Ret(1, 2): ret"); +is($c, 2, "[ret, c, d] = output2Input2Ret(1, 2): c"); +is($d, 4, "[ret, c, d = output2Input2Ret(1, 2): d"); + +($ret, $a, $b, $c) = scilab_multivalue::output3Input1Ret(10); +is($ret, 10, "[ret, a, b, c] = output3Input1Ret(10): ret"); +is($a, 11, "[ret, a, b, c] = output3Input1Ret(10): a"); +is($b, 12, "[ret, a, b, c] = output3Input1Ret(10): b"); +is($c, 13, "[ret, a, b, c] = output3Input1Ret(10): c"); + +($ret, $a, $b, $c) = scilab_multivalue::output3Input3Ret(10, 20, 30); +is($ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret"); +is($a, 11, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): a"); +is($b, 22, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): b"); +is($c, 33, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): c"); + + +# INOUT + +($a, $b) = scilab_multivalue::inout2(1, 2); +is($a, 2, "[a, b] = output2(1, 2): a"); +is($b, 4, "[a, b] = output2(1, 2): b"); + +($ret, $a, $b) = scilab_multivalue::inout2Ret(1, 2); +is($ret, 6, "[a, b] = inout2Ret(1, 2): b"); +is($a, 2, "[a, b] = inout2Ret(1, 2): a"); +is($b, 4, "[a, b] = inout2Ret(1, 2): b"); + +($c, $d) = scilab_multivalue::inout2Input2(1, 2, 1, 1); +is($c, 2, "[c, d] = inout2Input2(1, 2): c"); +is($d, 3, "[c, d] = inout2Input2(1, 2): d"); + +($ret, $c, $d) = scilab_multivalue::inout2Input2Ret(1, 2, 1, 1); +is($ret, 5, "[c, d] = inout2Input2Ret(1, 2): ret"); +is($c, 2, "[c, d] = inout2Input2Ret(1, 2): c"); +is($d, 3, "[c, d] = inout2Input2Ret(1, 4): d"); + +($ret, $a, $b, $c) = scilab_multivalue::inout3Input1Ret(10, 1, 2, 3); +is($ret, 10, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): ret"); +is($a, 11, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): a"); +is($b, 12, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): b"); +is($c, 13, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): c"); + +($ret, $a, $b, $c) = scilab_multivalue::inout3Input3Ret(10, 1, 20, 2, 30, 3); +is($ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret"); +is($a, 11, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): a"); +is($b, 22, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): b"); +is($c, 33, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): c"); + + +# CLASS + +$a = scilab_multivalue::ClassA->new(); + +($ret, $c, $d) = $a->output2Input2Ret(1, 2); +is($ret, 6, "[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2): ret"); +is($c, 2, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): c"); +is($d, 4, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): d"); + +($ret, $c, $d) = $a->inout2Input2Ret(1, 2, 1, 1); +is($ret, 5, "[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2): ret"); +is($c, 2, "[c, d] = ClassA_inout2Input2(a, 1, 2): c"); +is($d, 3, "[c, d] = ClassA_inout2Input2(a, 1, 2): d"); + diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index a86d3ad54..bf1596e9f 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -43,7 +43,7 @@ /* Perl types */ #define SWIG_Object SV * -#define VOID_Object sv_newmortal() +#define VOID_Object &PL_sv_undef /* Perl $shadow flag */ #define %newpointer_flags $shadow @@ -56,7 +56,7 @@ %define %set_output(obj) $result = obj; argvi++ %enddef /* append output */ -%define %append_output(obj) if (argvi >= items) EXTEND(sp,1); %set_output(obj) %enddef +%define %append_output(obj) if (argvi >= items) EXTEND(sp, argvi+1); %set_output(obj) %enddef /* variable output */ %define %set_varoutput(obj) sv_setsv($result,obj) %enddef diff --git a/Lib/perl5/typemaps.i b/Lib/perl5/typemaps.i index 7d96f2ace..3e1f60d90 100644 --- a/Lib/perl5/typemaps.i +++ b/Lib/perl5/typemaps.i @@ -168,7 +168,7 @@ output values. bool *OUTPUT, bool &OUTPUT { if (argvi >= items) { - EXTEND(sp,1); + EXTEND(sp, argvi+1); } $result = sv_newmortal(); sv_setiv($result,(IV) *($1)); @@ -181,7 +181,7 @@ output values. unsigned char *OUTPUT, unsigned char &OUTPUT { if (argvi >= items) { - EXTEND(sp,1); + EXTEND(sp, argvi+1); } $result = sv_newmortal(); sv_setuv($result,(UV) *($1)); @@ -194,7 +194,7 @@ output values. double *OUTPUT, double &OUTPUT { if (argvi >= items) { - EXTEND(sp,1); + EXTEND(sp, argvi+1); } $result = sv_newmortal(); sv_setnv($result,(double) *($1)); @@ -204,7 +204,7 @@ output values. %typemap(argout) long long *OUTPUT, long long &OUTPUT { char temp[256]; if (argvi >= items) { - EXTEND(sp,1); + EXTEND(sp, argvi+1); } sprintf(temp,"%lld", (long long)*($1)); $result = sv_newmortal(); @@ -215,7 +215,7 @@ output values. %typemap(argout) unsigned long long *OUTPUT, unsigned long long &OUTPUT { char temp[256]; if (argvi >= items) { - EXTEND(sp,1); + EXTEND(sp, argvi+1); } sprintf(temp,"%llu", (unsigned long long)*($1)); $result = sv_newmortal(); From 03323f5c8b8ebefd85649cde3a96b84841871ad6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Dec 2018 16:34:04 +0000 Subject: [PATCH 1202/2031] The Python module import logic has changed to stop obfuscating real ImportError problems. Only one import of the low-level C/C++ module from the pure Python module is attempted now. Previously a second import of the low-level C/C++ module was attempted after an ImportError occurred and was done to support 'split modules'. A 'split module' is a configuration where the pure Python module is a module within a Python package and the low-level C/C++ module is a global Python module. Now a 'split module' configuration is no longer supported by default. This configuration can be supported with a simple customization, such as: %module(package="mypackage", moduleimport="import $module") foo or if using -builtin: %module(package="mypackage", moduleimport="from $module import *") foo instead of %module(package="mypackage") foo See the updated Python chapter titled "Location of modules" in the documentation. Closes #848 #1343 --- CHANGES.current | 22 ++ Doc/Manual/Contents.html | 7 +- Doc/Manual/Python.html | 331 +++++++++++++----- .../import_packages/split_modules/README | 3 + .../split_modules/vanilla_split/foo.i | 7 +- Source/Modules/python.cxx | 31 +- 6 files changed, 275 insertions(+), 126 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f41db17ca..290408409 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,28 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-16: wsfulton + [Python] #848 #1343 The module import logic has changed to stop obfuscating real ImportError + problems. Only one import of the low-level C/C++ module from the pure Python module is + attempted now. Previously a second import of the low-level C/C++ module was attempted + after an ImportError occurred and was done to support 'split modules'. A 'split module' is + a configuration where the pure Python module is a module within a Python package and the + low-level C/C++ module is a global Python module. Now a 'split module' configuration is + no longer supported by default. This configuration can be supported with a simple + customization, such as: + + %module(package="mypackage", moduleimport="import $module") foo + + or if using -builtin: + + %module(package="mypackage", moduleimport="from $module import *") foo + + instead of + + %module(package="mypackage") foo + + See the updated Python chapter titled "Location of modules" in the documentation. + 2018-12-06: vadz #1359 #1364 Add missing nested class destructor wrapper when the nested class is inside a template. Removes associated bogus 'Illegal destructor name' warning. Only diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index a3179bfd7..4919d2c6a 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1690,12 +1690,13 @@
      2. Absolute and relative imports
      3. Enforcing absolute import semantics
      4. Importing from __init__.py -
      5. Implicit Namespace Packages -
      6. Searching for the wrapper module +
      7. Implicit namespace packages +
      8. Location of modules diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index ff5ef2993..2b2b6e1b9 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -119,12 +119,13 @@
      9. Absolute and relative imports
      10. Enforcing absolute import semantics
      11. Importing from __init__.py -
      12. Implicit Namespace Packages -
      13. Searching for the wrapper module +
      14. Implicit namespace packages +
      15. Location of modules @@ -5686,15 +5687,14 @@ Python3 adds another option for packages with namespace packages). Implicit namespace packages no longer use __init__.py files. SWIG generated Python modules support implicit namespace packages. See -36.11.5 Implicit Namespace -Packages for more information. +Implicit namespace +packages for more information.

        -If you place a SWIG generated module into a Python package then there -are details concerning the way SWIG -searches for the wrapper module -that you may want to familiarize yourself with. +You can place a SWIG generated module into a Python package or keep as a global module, +details are covered a little later in +Location of modules.

        The way Python defines its modules and packages impacts SWIG users. Some @@ -6040,7 +6040,7 @@ class Bar(pkg3.foo.Foo): pass effect (note, that the Python 2 case also needs the -relativeimport workaround).

        -

        38.11.5 Implicit Namespace Packages

        +

        38.11.5 Implicit namespace packages

        Python 3.3 introduced @@ -6118,14 +6118,14 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

        -

        38.11.6 Searching for the wrapper module

        +

        38.11.6 Location of modules

        When SWIG creates wrappers from an interface file, say foo.i, two Python modules are created. There is a pure Python module (foo.py) and C/C++ code which is -built and linked into a dynamically (or statically) loaded low-level module _foo -(see the Preliminaries section for details). So, the interface +compiled and linked into a dynamically (or statically) loaded low-level module _foo +(see the Preliminaries section for details). So, the interface file really defines two Python modules. How these two modules are loaded is covered next.

        @@ -6133,28 +6133,168 @@ covered next.

        The pure Python module needs to load the C/C++ module in order to call the wrapped C/C++ methods. To do this it must make some assumptions -about what package the C/C++ module may be located in. The approach the -pure Python module uses to find the C/C++ module is as follows: +about the location of the C/C++ module. +There are two configurations that are supported by default.

          -
        1. The pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is - located in. The package name is determined from the __package__ - attribute if available, see PEP 366, otherwise it is derived from the __name__ - attribute given to foo.py by the Python loader that imported - foo.py. If foo.py is not in a package then _foo is loaded - as a global module.

          +
        2. Both modules in the same package

        3. -
        4. If the above import of _foo results in an ImportError - being thrown, then foo.py makes a final attempt to load _foo - as a global module.

          +
        5. Both modules are global

        -The Python code implementing the loading logic described above is quite complex to handle multiple -versions of Python, but it can be replaced with custom code. -This is not recommended unless you understand the full intricacies of importing Python modules. +Additional configurations are supported but require custom import code. +

        + + +

        +The following sub-sections look more closely at the two default configurations as well as some customized configurations. +An input interface file, foo.i, results in the two modules foo.py and _foo.so for each of the configurations. +

        + +

        38.11.6.1 Both modules in the same package

        + + +

        +In this configuration, the pure Python module, foo.py, tries to load the C/C++ module, _foo, from the same package foo.py is +located in. The package name is determined from the __package__ +attribute if available, see PEP 366. Otherwise it is derived from the __name__ +attribute given to foo.py by the Python loader that imported foo.py. +The interface file for this configuration would contain: +

        + +
        +
        +%module(package="mypackage") foo
        +
        +
        + +

        The location of the files could be as follows:

        +
        +
        +/dir/mypackage/foo.py
        +/dir/mypackage/__init__.py
        +/dir/mypackage/_foo.so
        +
        +
        + +

        Assuming /dir/ is in PYTHONPATH, the module can be imported using

        + +
        +
        +from mypackage import foo
        +
        +
        + + +

        38.11.6.2 Both modules are global

        + + +

        +In this configuration, there are no packages. +If foo.py is not in a package, that is, it is a global module, then _foo is loaded +as a global module. +The interface file for this configuration would contain: +

        + +
        +
        +%module foo
        +
        +
        + +

        The location of the files could be as follows:

        +
        +
        +/dir/foo.py
        +/dir/_foo.so
        +
        +
        + +

        Assuming /dir/ is in PYTHONPATH, the module can be imported using

        + +
        +
        +import foo
        +
        +
        + +

        38.11.6.3 Split modules custom configuration

        + + +

        In this non-standard 'split module' configuration, the pure Python module is in a package and the low level C/C++ module is global. +This configuration is not generally recommended and is not supported by default as it needs a custom configuration. +The module import code customization required is via the moduleimport attribute in the %module directive. +The next sub-section elaborates further on this. +The interface file for this split module configuration would contain: +

        + +
        +
        +%module(package="mypackage", moduleimport="import _foo") foo
        +
        +
        + +

        +When using -builtin, use the following instead (the reasons are also covered shortly in the next sub-section): +

        + +
        +
        +%module(package="mypackage", moduleimport="from _foo import *") foo
        +
        +
        + +

        The location of the files could be as follows:

        +
        +
        +/dir/mypackage/foo.py
        +/dir/mypackage/__init__.py
        +/dir/_foo.so
        +
        +
        + +

        Assuming /dir/ is in PYTHONPATH, the module can be imported using

        + +
        +
        +from mypackage import foo
        +
        +
        + +

        +Compatibility Note: Versions of SWIG prior to SWIG-4.0.0 supported split modules without the above customization. +However, this had to be removed as the default import code often led to confusion due to obfuscation of genuine Python ImportError problems. +Using one of the two default configurations is the recommended approach now. +

        + + +

        38.11.6.4 More on customizing the module import code

        + + +

        +The Python code implementing the default import logic is shown below. It supports the two configurations described earlier, that is, +either both modules are in a package or loading both as global modules. +The code is generated into the pure Python module, foo.py, and merely imports the low-level _foo module. +

        + +
        +
        +def swig_import_helper():
        +    import importlib
        +    pkg = __package__ if __package__ else __name__.rpartition('.')[0]
        +    mname = '.'.join((pkg, '_foo')).lstrip('.')
        +    return importlib.import_module(mname)
        +_foo = swig_import_helper()
        +del swig_import_helper
        +
        +
        + +

        +This import code implementation is non-trivial but it can be replaced with custom code providing opportunities to make it simpler and/or more flexible. +This is not normally recommended though unless you have a good understanding of the intricacies of importing Python modules. The custom code can be specified by setting the moduleimport option of the %module directive with the appropriate import code. For example:

        @@ -6165,8 +6305,33 @@ The custom code can be specified by setting the moduleimport option of

        -The special variable $module will also be expanded into the low-level C/C++ module name, _foo in the case above. -When you have more than just a line or so then you can retain the easy +This will replace the default import logic above and generate the following into the pure Python module, foo.py: +

        + +
        +
        +import _foo
        +
        +
        + +

        +In fact the above is a simplification customization for the configuration where both modules are global; +it removes the logic for also handling the modules being in a package. +

        + +

        +There is a special variable, $module, which is expanded into the low-level C/C++ module name, _foo in the case above. +The identical output would be generated if instead the following had been used: +

        + +
        +
        +%module(moduleimport="import $module") foo
        +
        +
        + +

        +When you have many lines you can retain the easy readability of the %module directive by using a macro. For example:

        @@ -6185,79 +6350,51 @@ print 'Module has loaded' -

        -Now let's consider an example using the SWIG default loading logic. -Suppose foo.i is compiled into foo.py and _foo.so. Assuming -/dir is on PYTHONPATH, then the two modules can be installed and used in the -following ways: +This will of course generate the following into the pure Python module:

        - -

        38.11.6.1 Both modules in the same package

        - - -

        Both modules are in one package:

        -
        +
        -/dir/package/foo.py
        -/dir/package/__init__.py
        -/dir/package/_foo.so
        -
        -
        -

        And imported with

        -
        -
        -from package import foo
        -
        -
        - - -

        38.11.6.2 Split modules

        - - -

        The pure Python module is in a package and the C/C++ module is global:

        -
        -
        -/dir/package/foo.py
        -/dir/package/__init__.py
        -/dir/_foo.so
        -
        -
        -

        And imported with

        -
        -
        -from package import foo
        -
        -
        - - -

        38.11.6.3 Both modules are global

        - - -

        Both modules are global:

        -
        -
        -/dir/foo.py
        -/dir/_foo.so
        -
        -
        -

        And imported with

        -
        -
        -import foo
        +print 'Loading low-level module $module'
        +import _foo
        +print 'Module has loaded'
         

        -If _foo is statically linked into an embedded Python interpreter, then it may or -may not be in a Python package. This depends in the exact way the module was -loaded statically. The above search order will still be used for statically -loaded modules. So, one may place the module either globally or in a package -as desired. +When using the -builtin option, the link between the pure Python module and the low-level C/C++ module is slightly different as +all the objects from the low-level module are imported directly into the pure Python module. +The default import loading code is thus different:

        -

        38.11.6.4 Statically linked C modules

        +
        +
        +if __package__ or __name__.rpartition('.')[0]:
        +    from ._foo import *
        +else:
        +    from _foo import *
        +
        +
        + +

        +Any customizations must import the code in a similar manner. +The best way to support both with and without -builtin is to make use of the SWIGPYTHON_BUILTIN macro which is defined when -builtin is specified. +The following will do this for the split modules case above. +

        + + +
        +
        +#if defined(SWIGPYTHON_BUILTIN) /* defined when using -builtin */
        +%module(package="mypackage", moduleimport="from $module import *") foo
        +#else
        +%module(package="mypackage", moduleimport="import $module") foo
        +#endif
        +
        +
        + +

        38.11.6.5 Statically linked C modules

        It is strongly recommended to use dynamically linked modules for the C @@ -6266,7 +6403,7 @@ If for some reason you still need to link the C module of the pair of Python modules generated by SWIG into your interpreter, then this section provides some details on how this impacts the pure Python modules ability to locate the other part of the pair. -Please also see the Static Linking section. +Please also see the Static Linking section.

        When Python is extended with C code the Python interpreter needs to be @@ -6283,7 +6420,7 @@ new SWIG C module exists. which would have normally been called when the shared object was dynamically loaded. The specific name of this method is not given here because statically linked modules are not encouraged with SWIG -(Static Linking). However one can find this +(Static Linking). However one can find this init function in the C file generated by SWIG.

        @@ -6306,21 +6443,21 @@ for Python itself. Links to the relevant sections follow:

        There are two keys things to understand. The first is that in Python 2 the init() function returns void. In Python 3 the init() function -returns a PyObject * which points to the new module. Secondly, when +returns a PyObject * which points to the new module. Secondly, when you call the init() method manually, you are the Python importer. So, you determine which package the C module will be located in.

        So, if you are using Python 3 it is important that you follow what is described in the Python documentation linked above. In particular, you can't -simply call the init() function generated by SWIG and cast the PyObject +simply call the init() function generated by SWIG and cast the PyObject pointer it returns over the side. If you do then Python 3 will have no idea that your C module exists and the pure Python half of your wrapper will not be able to find it. You need to register your module with the Python interpreter as described in the Python docs.

        -

        With Python 2 things are somewhat more simple. In this case the init function +

        With Python 2 things are somewhat more simple. In this case the init() function returns void. Calling it will register your new C module as a global module. The pure Python part of the SWIG wrapper will be able to find it because it tries both the pure Python module it is part of and the global diff --git a/Examples/python/import_packages/split_modules/README b/Examples/python/import_packages/split_modules/README index 0cb543e8a..d2ca15e7a 100644 --- a/Examples/python/import_packages/split_modules/README +++ b/Examples/python/import_packages/split_modules/README @@ -2,6 +2,9 @@ between two packages. Specifically the pure python part is part of a package and the C/C++ part is not in any package at all. Historically SWIG has supported this sort of thing. +From SWIG 4.0.0 onwards, split modules are not supported by default. +The %module directive needs to be customised with the moduleimport attribute +in order to import the a global C/C++ module. vanilla # "plane Jane" module both halves in pkg1 vanilla_split # python 1/2 in pkg1 C 1/2 in global namespace diff --git a/Examples/python/import_packages/split_modules/vanilla_split/foo.i b/Examples/python/import_packages/split_modules/vanilla_split/foo.i index 60ce16ec3..81ad43a5b 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/foo.i +++ b/Examples/python/import_packages/split_modules/vanilla_split/foo.i @@ -1,4 +1,9 @@ -%module(package="pkg1") foo +#if defined(SWIGPYTHON_BUILTIN) /* defined when using -builtin */ +%module(package="pkg1", moduleimport="from $module import *") foo +#else +%module(package="pkg1", moduleimport="import $module") foo +#endif + %{ static unsigned count(void) { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8764fd97f..e7bc76757 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -697,35 +697,16 @@ public: Printv(default_import_code, "def swig_import_helper():\n", NULL); Printv(default_import_code, tab4, "import importlib\n", NULL); Printv(default_import_code, tab4, "pkg = __package__ if __package__ else __name__.rpartition('.')[0]\n", NULL); - Printf(default_import_code, tab4 "mname = '.'.join((pkg, '%s')).lstrip('.')\n", module); - Printv(default_import_code, tab4, "try:\n", NULL); - Printv(default_import_code, tab8, "return importlib.import_module(mname)\n", NULL); - Printv(default_import_code, tab4, "except ImportError:\n", NULL); - Printf(default_import_code, tab8 "return importlib.import_module('%s')\n", module); - Printf(default_import_code, "%s = swig_import_helper()\n", module); + Printv(default_import_code, tab4, "mname = '.'.join((pkg, '", module, "')).lstrip('.')\n", NULL); + Printv(default_import_code, tab4, "return importlib.import_module(mname)\n", NULL); + Printv(default_import_code, module, " = swig_import_helper()\n", NULL); Printv(default_import_code, "del swig_import_helper\n", NULL); } else { - /* - * Pull in all the attributes from the C module. - * - * An alternative approach to doing this if/else chain was - * proposed by Michael Thon at https://github.com/swig/swig/issues/691. - * Someone braver than I may try it out. - * I fear some current swig user may depend on some side effect - * of from _foo import * - * - * for attr in _foo.__all__: - * globals()[attr] = getattr(_foo, attr) - * - */ - Printf(default_import_code, "\n# Pull in all the attributes from %s\n", module); + Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL); Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL); - Printv(default_import_code, tab4, "try:\n", NULL); - Printf(default_import_code, tab4 tab4 "from .%s import *\n", module); - Printv(default_import_code, tab4 "except ImportError:\n", NULL); - Printf(default_import_code, tab4 tab4 "from %s import *\n", module); + Printv(default_import_code, tab4, "from .", module, " import *\n", NULL); Printv(default_import_code, "else:\n", NULL); - Printf(default_import_code, tab4 "from %s import *\n", module); + Printv(default_import_code, tab4, "from ", module, " import *\n", NULL); } /* Need builtins to qualify names like Exception that might also be From 2a00d0f7840f3095c968c842d7e8efc33311023b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Dec 2018 07:25:40 +0000 Subject: [PATCH 1203/2031] Simpler Python module loading Simplification possible given Python 2.7 is now the minimum supported. Issue #848 --- Doc/Manual/Python.html | 11 ++++------- Source/Modules/python.cxx | 26 +++++++++++--------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 2b2b6e1b9..4e2b0943d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6282,13 +6282,10 @@ The code is generated into the pure Python module, foo.py, and merely imports th

        -def swig_import_helper():
        -    import importlib
        -    pkg = __package__ if __package__ else __name__.rpartition('.')[0]
        -    mname = '.'.join((pkg, '_foo')).lstrip('.')
        -    return importlib.import_module(mname)
        -_foo = swig_import_helper()
        -del swig_import_helper
        +if __package__ or __name__.rpartition('.')[0]:
        +    from . import _foo
        +else:
        +    import _foo
         
        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e7bc76757..2e09d3aaa 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -679,28 +679,24 @@ public: Swig_register_filebyname("python", f_shadow); if (!builtin) { - /* Import the C-extension module. This should be a relative import, + /* Import the low-level C/C++ 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 + * import, and there is thus no guarantee that the low-level C/C++ module is on * sys.path. Relative imports must be explicitly specified from 2.6.0 * onwards (implicit relative imports raised a DeprecationWarning in 2.6, * and fail in 2.7 onwards). * * First check for __package__ which is available from 2.6 onwards, see PEP366. - * Next determine the shadow wrappers package based on the __name__ it - * was given by the importer that loaded it. Then construct a name for - * the module based on the package name and the module name (we know the - * module name). Use importlib to try and load it. If an attempt to - * load the module with importlib fails with an ImportError then fallback - * and try and load just the module name from the global namespace. + * Next try determine the shadow wrapper's package based on the __name__ it + * was given by the importer that loaded it. + * If the module is in a package, load the low-level C/C++ module from the + * same package, otherwise load it as a global module. */ - Printv(default_import_code, "def swig_import_helper():\n", NULL); - Printv(default_import_code, tab4, "import importlib\n", NULL); - Printv(default_import_code, tab4, "pkg = __package__ if __package__ else __name__.rpartition('.')[0]\n", NULL); - Printv(default_import_code, tab4, "mname = '.'.join((pkg, '", module, "')).lstrip('.')\n", NULL); - Printv(default_import_code, tab4, "return importlib.import_module(mname)\n", NULL); - Printv(default_import_code, module, " = swig_import_helper()\n", NULL); - Printv(default_import_code, "del swig_import_helper\n", NULL); + Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL); + Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL); + Printv(default_import_code, tab4, "from . import ", module, "\n", NULL); + Printv(default_import_code, "else:\n", NULL); + Printv(default_import_code, tab4, "import ", module, "\n", NULL); } else { Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL); Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL); From 355395200f42bf9c39c2a36f9ac3ad2947ee38ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Dec 2018 07:50:48 +0000 Subject: [PATCH 1204/2031] More Python module loading simplification Slightly faster checking to see if a module is in a package. Issue #848 --- Doc/Manual/Python.html | 4 ++-- Source/Modules/python.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 4e2b0943d..d2b090b72 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6282,7 +6282,7 @@ The code is generated into the pure Python module, foo.py, and merely imports th
        -if __package__ or __name__.rpartition('.')[0]:
        +if __package__ or '.' in __name__:
             from . import _foo
         else:
             import _foo
        @@ -6367,7 +6367,7 @@ The default import loading code is thus different:
         
         
        -if __package__ or __name__.rpartition('.')[0]:
        +if __package__ or '.' in __name__:
             from ._foo import *
         else:
             from _foo import *
        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
        index 2e09d3aaa..8b6e08acf 100755
        --- a/Source/Modules/python.cxx
        +++ b/Source/Modules/python.cxx
        @@ -693,13 +693,13 @@ public:
         	 * same package, otherwise load it as a global module.
         	 */
                 Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL);
        -        Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL);
        +        Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
                 Printv(default_import_code, tab4, "from . import ", module, "\n", NULL);
                 Printv(default_import_code, "else:\n", NULL);
                 Printv(default_import_code, tab4, "import ", module, "\n", NULL);
               } else {
                 Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL);
        -        Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL);
        +        Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
                 Printv(default_import_code, tab4, "from .", module, " import *\n", NULL);
                 Printv(default_import_code, "else:\n", NULL);
                 Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
        
        From 152b66deaffccf30b9dd420d6afc81da1b069d73 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Tue, 18 Dec 2018 18:32:55 +0000
        Subject: [PATCH 1205/2031] Tidy up Python command line options help text
        
        Also remove non-existent -noexcept option
        ---
         Source/Modules/python.cxx | 27 +++++++++++++--------------
         1 file changed, 13 insertions(+), 14 deletions(-)
        
        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
        index 8b6e08acf..6b3c9ef40 100755
        --- a/Source/Modules/python.cxx
        +++ b/Source/Modules/python.cxx
        @@ -108,33 +108,32 @@ static const char *usage1 = "\
         Python Options (available with -python)\n\
              -builtin        - Create new python built-in types, rather than proxy classes, for better performance\n\
              -castmode       - Enable the casting mode, which allows implicit cast between types in python\n\
        -     -dirvtable      - Generate a pseudo virtual table for directors for faster dispatch \n\
        -     -doxygen        - Convert C++ doxygen comments to pydoc comments in proxy classes \n\
              -debug-doxygen-parser     - Display doxygen parser module debugging information\n\
              -debug-doxygen-translator - Display doxygen translator module debugging information\n\
        -     -extranative    - Return extra native C++ wraps for std containers when possible \n\
        -     -fastproxy      - Use fast proxy mechanism for member methods \n\
        -     -globals  - Set  used to access C global variable [default: 'cvar']\n\
        -     -interface - Set the lib name to \n\
        +     -dirvtable      - Generate a pseudo virtual table for directors for faster dispatch\n\
        +     -doxygen        - Convert C++ doxygen comments to pydoc comments in proxy classes\n\
        +     -extranative    - Return extra native wrappers for C++ std containers wherever possible\n\
        +     -fastproxy      - Use fast proxy mechanism for member methods\n\
        +     -globals  - Set  used to access C global variable (default: 'cvar')\n\
        +     -interface - Set low-level C/C++ module name to  (default: module name prefixed by '_')\n\
              -keyword        - Use keyword arguments\n";
         static const char *usage2 = "\
        -     -newvwm         - New value wrapper mode, use only when everything else fails \n\
        +     -newvwm         - New value wrapper mode, use only when everything else fails\n\
              -nocastmode     - Disable the casting mode (default)\n\
              -nodirvtable    - Don't use the virtual table feature, resolve the python method each time (default)\n\
        -     -noexcept       - No automatic exception handling\n\
        -     -noextranative  - Don't use extra native C++ wraps for std containers when possible (default) \n\
        -     -nofastunpack   - Use traditional UnpackTuple method to parse the argument functions (default) \n\
        -     -nofastproxy    - Use traditional proxy mechanism for member methods (default) \n\
        +     -noextranative  - Don't use extra native C++ wraps for std containers when possible (default)\n\
        +     -nofastproxy    - Use traditional proxy mechanism for member methods (default)\n\
        +     -nofastunpack   - Use traditional UnpackTuple method to parse the argument functions (default)\n\
              -noh            - Don't generate the output header file\n";
         static const char *usage3 = "\
        -     -noproxy        - Don't generate proxy classes \n\
        +     -noproxy        - Don't generate proxy classes\n\
              -nortti         - Disable the use of the native C++ RTTI with directors\n\
              -nothreads      - Disable thread support for the entire interface\n\
              -olddefs        - Keep the old method definitions when using -fastproxy\n\
              -py3            - Generate code with Python 3 specific features and syntax\n\
        -     -relativeimport - Use relative python imports \n\
        +     -relativeimport - Use relative python imports\n\
              -threads        - Add thread support for all the interface\n\
        -     -O              - Enable the following optimization options: \n\
        +     -O              - Enable the following optimization options:\n\
                                  -fastdispatch -fastproxy -fvirtual\n\
         \n";
         
        
        From 398ac5f01c6d99c7167c7fafb67d7ea695e08e47 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Tue, 18 Dec 2018 18:53:31 +0000
        Subject: [PATCH 1206/2031] Remove redundant Python options: -nocastmode
         -nodirvtable -noextranative -nofastproxy
        
        Also remove redundant %module options: nocastmode, noextranative
        Issue #1340
        ---
         Examples/test-suite/li_implicit.i |  5 ++++-
         Source/Modules/python.cxx         | 28 +++++++++-------------------
         2 files changed, 13 insertions(+), 20 deletions(-)
        
        diff --git a/Examples/test-suite/li_implicit.i b/Examples/test-suite/li_implicit.i
        index 0ce10dd6e..9f3ea318b 100644
        --- a/Examples/test-suite/li_implicit.i
        +++ b/Examples/test-suite/li_implicit.i
        @@ -1,4 +1,7 @@
        -%module("nocastmode") li_implicit
        +%module li_implicit
        +
        +// Tests nocastmode
        +
         #pragma SWIG nowarn=SWIGWARN_PP_CPP_WARNING
         %include implicit.i
         
        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
        index 6b3c9ef40..4aeb388b8 100755
        --- a/Source/Modules/python.cxx
        +++ b/Source/Modules/python.cxx
        @@ -119,11 +119,7 @@ Python Options (available with -python)\n\
              -keyword        - Use keyword arguments\n";
         static const char *usage2 = "\
              -newvwm         - New value wrapper mode, use only when everything else fails\n\
        -     -nocastmode     - Disable the casting mode (default)\n\
        -     -nodirvtable    - Don't use the virtual table feature, resolve the python method each time (default)\n\
        -     -noextranative  - Don't use extra native C++ wraps for std containers when possible (default)\n\
        -     -nofastproxy    - Use traditional proxy mechanism for member methods (default)\n\
        -     -nofastunpack   - Use traditional UnpackTuple method to parse the argument functions (default)\n\
        +     -nofastunpack   - Use traditional UnpackTuple method to parse the argument functions\n\
              -noh            - Don't generate the output header file\n";
         static const char *usage3 = "\
              -noproxy        - Don't generate proxy classes\n\
        @@ -350,9 +346,6 @@ public:
         	} else if (strcmp(argv[i], "-dirvtable") == 0) {
         	  dirvtable = 1;
         	  Swig_mark_arg(i);
        -	} else if (strcmp(argv[i], "-nodirvtable") == 0) {
        -	  dirvtable = 0;
        -	  Swig_mark_arg(i);
         	} else if (strcmp(argv[i], "-doxygen") == 0) {
         	  doxygen = 1;
         	  scan_doxygen_comments = 1;
        @@ -369,24 +362,15 @@ public:
         	} else if (strcmp(argv[i], "-fastproxy") == 0) {
         	  fastproxy = 1;
         	  Swig_mark_arg(i);
        -	} else if (strcmp(argv[i], "-nofastproxy") == 0) {
        -	  fastproxy = 0;
        -	  Swig_mark_arg(i);
         	} else if (strcmp(argv[i], "-olddefs") == 0) {
         	  olddefs = 1;
         	  Swig_mark_arg(i);
         	} else if (strcmp(argv[i], "-castmode") == 0) {
         	  castmode = 1;
         	  Swig_mark_arg(i);
        -	} else if (strcmp(argv[i], "-nocastmode") == 0) {
        -	  castmode = 0;
        -	  Swig_mark_arg(i);
         	} else if (strcmp(argv[i], "-extranative") == 0) {
         	  extranative = 1;
         	  Swig_mark_arg(i);
        -	} else if (strcmp(argv[i], "-noextranative") == 0) {
        -	  extranative = 0;
        -	  Swig_mark_arg(i);
         	} else if (strcmp(argv[i], "-noh") == 0) {
         	  no_header_file = 1;
         	  Swig_mark_arg(i);
        @@ -434,8 +418,12 @@ public:
         		   strcmp(argv[i], "-newrepr") == 0 ||
         		   strcmp(argv[i], "-noaliasobj0") == 0 ||
         		   strcmp(argv[i], "-nobuildnone") == 0 ||
        +		   strcmp(argv[i], "-nocastmode") == 0 ||
         		   strcmp(argv[i], "-nocppcast") == 0 ||
        +		   strcmp(argv[i], "-nodirvtable") == 0 ||
        +		   strcmp(argv[i], "-noextranative") == 0 ||
         		   strcmp(argv[i], "-nofastinit") == 0 ||
        +		   strcmp(argv[i], "-nofastproxy") == 0 ||
         		   strcmp(argv[i], "-nofastquery") == 0 ||
         		   strcmp(argv[i], "-nomodern") == 0 ||
         		   strcmp(argv[i], "-nomodernargs") == 0 ||
        @@ -506,13 +494,15 @@ public:
         	    castmode = 1;
         	  }
         	  if (Getattr(options, "nocastmode")) {
        -	    castmode = 0;
        +	    Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "nocastmode");
        +	    SWIG_exit(EXIT_FAILURE);
         	  }
         	  if (Getattr(options, "extranative")) {
         	    extranative = 1;
         	  }
         	  if (Getattr(options, "noextranative")) {
        -	    extranative = 0;
        +	    Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "noextranative");
        +	    SWIG_exit(EXIT_FAILURE);
         	  }
         	  if (Getattr(options, "outputtuple")) {
         	    Printf(stderr, "Deprecated module option: %s. This option is no longer supported.\n", "outputtuple");
        
        From 5d6786598c9a94c5e11ebfe416839924e2172da4 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Tue, 18 Dec 2018 18:59:13 +0000
        Subject: [PATCH 1207/2031] Python command line options tidyup
        
        ---
         Source/Modules/python.cxx | 6 +++---
         1 file changed, 3 insertions(+), 3 deletions(-)
        
        diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
        index 4aeb388b8..f1d76b7fc 100755
        --- a/Source/Modules/python.cxx
        +++ b/Source/Modules/python.cxx
        @@ -106,8 +106,8 @@ enum autodoc_t {
         
         static const char *usage1 = "\
         Python Options (available with -python)\n\
        -     -builtin        - Create new python built-in types, rather than proxy classes, for better performance\n\
        -     -castmode       - Enable the casting mode, which allows implicit cast between types in python\n\
        +     -builtin        - Create Python built-in types rather than proxy classes, for better performance\n\
        +     -castmode       - Enable the casting mode, which allows implicit cast between types in Python\n\
              -debug-doxygen-parser     - Display doxygen parser module debugging information\n\
              -debug-doxygen-translator - Display doxygen translator module debugging information\n\
              -dirvtable      - Generate a pseudo virtual table for directors for faster dispatch\n\
        @@ -127,7 +127,7 @@ static const char *usage3 = "\
              -nothreads      - Disable thread support for the entire interface\n\
              -olddefs        - Keep the old method definitions when using -fastproxy\n\
              -py3            - Generate code with Python 3 specific features and syntax\n\
        -     -relativeimport - Use relative python imports\n\
        +     -relativeimport - Use relative Python imports\n\
              -threads        - Add thread support for all the interface\n\
              -O              - Enable the following optimization options:\n\
                                  -fastdispatch -fastproxy -fvirtual\n\
        
        From 574f8112d6c180bf0af8ce0c00f1d82c0ee17c58 Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Tue, 18 Dec 2018 19:21:30 +0000
        Subject: [PATCH 1208/2031] Document all the Python command line options
        
        Issue #1340
        ---
         Doc/Manual/Contents.html |  3 ++-
         Doc/Manual/Python.html   | 50 ++++++++++++++++++++++++++++++++++++++--
         2 files changed, 50 insertions(+), 3 deletions(-)
        
        diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
        index 4919d2c6a..d9bc4bc05 100644
        --- a/Doc/Manual/Contents.html
        +++ b/Doc/Manual/Contents.html
        @@ -1592,7 +1592,8 @@
         
      16. Using your module
      17. Compilation of C++ extensions
      18. Compiling for 64-bit platforms -
      19. Building Python Extensions under Windows +
      20. Building Python extensions under Windows +
      21. Additional Python commandline options
      22. A tour of basic C/C++ wrapping
      23. A tour of basic C/C++ wrapping
      Method nameWithout -proxyWith -proxyWithout -fastproxyWith -fastproxy
      callme0
      + + + + + + + + + + + + + + + + + + + + + + + + + + +
      Python specific options
      -builtin Create Python built-in types rather than proxy classes, for better performance
      -castmode Enable the casting mode, which allows implicit cast between types in Python
      -debug-doxygen-parser Display doxygen parser module debugging information
      -debug-doxygen-translator Display doxygen translator module debugging information
      -dirvtable Generate a pseudo virtual table for directors for faster dispatch
      -doxygen Convert C++ doxygen comments to pydoc comments in proxy classes
      -extranative Return extra native wrappers for C++ std containers wherever possible
      -fastproxy Use fast proxy mechanism for member methods
      -globals <name> Set <name> used to access C global variable (default: 'cvar')
      -interface <mod>Set low-level C/C++ module name to <mod> (default: module name prefixed by '_')
      -keyword Use keyword arguments
      -nofastunpack Use traditional UnpackTuple method to parse the argument functions
      -noh Don't generate the output header file
      -noproxy Don't generate proxy classes
      -nortti Disable the use of the native C++ RTTI with directors
      -nothreads Disable thread support for the entire interface
      -olddefs Keep the old method definitions when using -fastproxy
      -py3 Generate code with Python 3 specific features and syntax
      -relativeimport Use relative Python imports
      -threads Add thread support for all the interface
      -O Enable the following optimization options: -fastdispatch -fastproxy -fvirtual
      + +

      +Many of these options are covered later on and their use should become clearer by the time you have finished reading this section on SWIG and Python. +

      +

      38.3 A tour of basic C/C++ wrapping

      From d314b53820e53240927c9d45edf6b294b6de4cbd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Dec 2018 19:31:42 +0000 Subject: [PATCH 1209/2031] Python -newvwm command line option remains undocumented Remove option from -help output text It is hard to explain exactly what it does and is unclear as to how useful it is! --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f1d76b7fc..a0f049449 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -118,7 +118,6 @@ Python Options (available with -python)\n\ -interface - Set low-level C/C++ module name to (default: module name prefixed by '_')\n\ -keyword - Use keyword arguments\n"; static const char *usage2 = "\ - -newvwm - New value wrapper mode, use only when everything else fails\n\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions\n\ -noh - Don't generate the output header file\n"; static const char *usage3 = "\ @@ -376,6 +375,7 @@ public: Swig_mark_arg(i); } else if (strcmp(argv[i], "-newvwm") == 0) { /* Turn on new value wrapper mode */ + /* Undocumented option, did have -help text: New value wrapper mode, use only when everything else fails */ Swig_value_wrapper_mode(1); no_header_file = 1; Swig_mark_arg(i); From 2e51328fd8526a4ba5db5126351b14aeb6879d9f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Dec 2018 19:43:42 +0000 Subject: [PATCH 1210/2031] Changes file update --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 0ae928730..9adecb8d6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -184,7 +184,11 @@ Version 4.0.0 (in progress) -newrepr -noaliasobj0 -nobuildnone + -nocastmode + -nodirvtable + -noextranative -nofastinit + -nofastproxy -nofastquery -nomodern -nomodernargs From 83ab3567dc67972caec58517b04e80398bcca2d0 Mon Sep 17 00:00:00 2001 From: Lewis Chambers Date: Thu, 20 Dec 2018 09:21:50 +1000 Subject: [PATCH 1211/2031] [Python] Add missing keywords 'async' and 'await' to pythonkw.swg. --- Lib/python/pythonkw.swg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/python/pythonkw.swg b/Lib/python/pythonkw.swg index 1a4329d20..0138e40e4 100644 --- a/Lib/python/pythonkw.swg +++ b/Lib/python/pythonkw.swg @@ -14,6 +14,8 @@ PYTHONKW(and); PYTHONKW(as); PYTHONKW(assert); +PYTHONKW(async); +PYTHONKW(await); PYTHONKW(break); PYTHONKW(class); PYTHONKW(continue); From 6e2b54be2f127ac03b5c23557bfd0037f362b46c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Dec 2018 08:05:54 +0000 Subject: [PATCH 1212/2031] Testcase for testing __new__ override Python 3.6 fix Issue #1357 --- CHANGES.current | 5 ++++ .../python/python_pythoncode_runme.py | 4 +++ Examples/test-suite/python_pythoncode.i | 30 +++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 6db8329c7..a231b03b3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-20: chlandsi + [Python] #1357. Fix overriding __new__ in Python 3.6. + + Fixes SystemError: Objects/tupleobject.c:81: bad argument to internal function" + 2018-10-29: AlexanderGabriel [PHP] The following PHP7 reserved keywords are now only renamed by SWIG when used as function names in the API being wrapper: diff --git a/Examples/test-suite/python/python_pythoncode_runme.py b/Examples/test-suite/python/python_pythoncode_runme.py index da238780d..c27f4452d 100644 --- a/Examples/test-suite/python/python_pythoncode_runme.py +++ b/Examples/test-suite/python/python_pythoncode_runme.py @@ -3,3 +3,7 @@ import python_pythoncode # No need to actually do anything, this is a regression test for a bug which # caused an invalid python_pythoncode.py to be generated, so if we can import # it the bug is still fixed. + +# A later test enhancement checking __new__ requires some code... +f = python_pythoncode.get_foo() +f = python_pythoncode.Foo() diff --git a/Examples/test-suite/python_pythoncode.i b/Examples/test-suite/python_pythoncode.i index 70474d44c..8191aa121 100644 --- a/Examples/test-suite/python_pythoncode.i +++ b/Examples/test-suite/python_pythoncode.i @@ -29,3 +29,33 @@ struct TYPE2 { struct TYPE { }; struct TYPE2 { }; %} + + +// Overriding __new__ test: https://github.com/swig/swig/pull/1357 +%inline %{ +class Foo { + public: + virtual ~Foo() {} + Foo() {} +}; + +Foo* get_foo() {return new Foo();} +%} + +%pythoncode %{ + print_debug = True +%} + +%extend Foo { + // Note that %pythoncode is not available with -builtin + %pythoncode %{ + def __new__(cls, *args, **kwargs): + if print_debug: + print('in Foo.__new__()') + return super(Foo, cls).__new__(cls) + + def __init__(self): + if print_debug: + print('in Foo.__init__()') + %} +}; From f948a756bb434ba448258762b8cd52999742a646 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Dec 2018 21:00:37 +0000 Subject: [PATCH 1213/2031] Increased Java thread name size. MacOS thread_info.h can handle thread names up to 64 characters. See issue #1334. --- Lib/java/director.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/java/director.swg b/Lib/java/director.swg index d4c88d5c6..b65e6bf93 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -184,7 +184,7 @@ namespace Swig { args.group = NULL; args.name = NULL; #if defined(SWIG_JAVA_USE_THREAD_NAME) - char thread_name[16]; // MAX_TASK_COMM_LEN=16 is hard-coded in the kernel. + char thread_name[64]; // MAX_TASK_COMM_LEN=16 is hard-coded in the Linux kernel and MacOS has MAXTHREADNAMESIZE=64. if (Swig::GetThreadName(thread_name, sizeof(thread_name)) == 0) { args.name = thread_name; #if defined(DEBUG_DIRECTOR_THREAD_NAME) From 88729d91c2d620f0ed4975fed90245fe2d2dea0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Dec 2018 21:08:33 +0000 Subject: [PATCH 1214/2031] Add changes entry for setting Java thread name --- CHANGES.current | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 27d000b93..f1d166600 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,17 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-12-20: hasinoff,wsfulton + [Java] #1334 Set Java thread name to native thread name when using directors. + + Default is to use name "Thread-XXX" and is still works like this by default. However, + adding the following will turn on the thread name setting (works for more recent + versions of Linux and MacOS): + + %begin %{ + #define SWIG_JAVA_USE_THREAD_NAME + %} + 2018-10-04: wsfulton [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. Problem occurred when there is just one (defaulted) parameter in the parameter list. From 50f223f454f9759d2fd29c93d4ebf2ab0d4cdbb6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Dec 2018 07:57:07 +0000 Subject: [PATCH 1215/2031] Fix director_thread test for MacOS pthread_setname_np is defined differently on MacOS --- Examples/test-suite/director_thread.i | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index cb999ecc4..979ed9d9a 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -94,13 +94,25 @@ extern "C" { fprintf(stderr, "pthread_create failed in run()\n"); assert(0); } - int setname = pthread_setname_np(thread, "MyThreadName"); +%#endif + MilliSecondSleep(500); + } + + void setThreadName() { +%#ifdef _WIN32 +%#else + +%#ifdef __APPLE__ + int setname = pthread_setname_np("MyThreadName"); +%#else + int setname = pthread_setname_np(pthread_self(), "MyThreadName"); +%#endif + if (setname != 0) { fprintf(stderr, "pthread_setname_np failed in run()\n"); assert(0); } %#endif - MilliSecondSleep(500); } static bool namedThread() { @@ -126,6 +138,7 @@ extern "C" { #endif { Foo* f = static_cast(t); + f->setThreadName(); while (!get_thread_terminate()) { MilliSecondSleep(50); f->do_foo(); From 1faf5a879fdf93b268c61b7e39eab9755f3601f7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Dec 2018 08:15:59 +0000 Subject: [PATCH 1216/2031] Avoid thread name checking testing on MacOS It's not working! --- Examples/test-suite/director_thread.i | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 979ed9d9a..eae5672e6 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -118,8 +118,12 @@ extern "C" { static bool namedThread() { %#ifdef _WIN32 return false; +%#else +%#ifdef __APPLE__ + return false; %#else return true; +%#endif %#endif } From 5a388863faae4d49bf861b4be7794a6823d12800 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Dec 2018 19:08:15 +0000 Subject: [PATCH 1217/2031] director_thread test fixes for MacOS Add extra debugging and correctly detect MacOS using __APPLE__ macro --- Examples/test-suite/director_thread.i | 12 ++++++------ Lib/java/director.swg | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index eae5672e6..c4f08f4f9 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -19,6 +19,8 @@ #include #else #include +#include +#include #include #include #endif @@ -91,7 +93,8 @@ extern "C" { %#else int create = pthread_create(&thread,NULL,working,this); if (create != 0) { - fprintf(stderr, "pthread_create failed in run()\n"); + errno = create; + perror("pthread_create in run()"); assert(0); } %#endif @@ -109,7 +112,8 @@ extern "C" { %#endif if (setname != 0) { - fprintf(stderr, "pthread_setname_np failed in run()\n"); + errno = setname; + perror("calling pthread_setname_np in setThreadName()"); assert(0); } %#endif @@ -118,12 +122,8 @@ extern "C" { static bool namedThread() { %#ifdef _WIN32 return false; -%#else -%#ifdef __APPLE__ - return false; %#else return true; -%#endif %#endif } diff --git a/Lib/java/director.swg b/Lib/java/director.swg index b65e6bf93..d3bd162ec 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -31,7 +31,7 @@ SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { #endif } -#elif defined(__unix__) +#elif defined(__unix__) || defined(__APPLE__) #include SWIGINTERN int Swig::GetThreadName(char *name, size_t len) { From f5d2e9722897df946accf4aac870c8fed5017a41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Dec 2018 12:27:15 +0000 Subject: [PATCH 1218/2031] Python documentation improvements for -olddefs and -builtin performance The performance figures have been changed because the default options have changed the performance. Add some explanation for using -olddefs. [skip ci] --- Doc/Manual/Python.html | 57 +++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 6ec572575..ddcd6407b 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3913,13 +3913,13 @@ class Go(object):

      -The generated code when using -fastproxy is: +The generated proxy class when using -fastproxy is:

       %module example
      -class Go(_object):
      +class Go(object):
           callme0 = _swig_new_instance_method(_example.Go_callme0)
           callme4 = _swig_new_instance_method(_example.Go_callme4)
           callme8 = _swig_new_instance_method(_example.Go_callme8)
      @@ -3930,37 +3930,70 @@ class Go(_object):
       

      where _swig_new_instance_method adds the method to the proxy class via C API calls. The overhead calling into C/C++ from Python is reduced slightly using -fastproxy. -Below are some timings in microseconds calling the 3 functions in the example above: +Below are some timings in microseconds calling the 3 functions in the example above. +Also included in the table for comparison is using the -builtin option covered in the +Built-in Types.

      - - + + + - - + + + - - + + + - - + + +
      Method nameWithout -fastproxyWith -fastproxyDefault-fastproxy-builtin
      callme00.570.480.150.090.07
      callme40.640.540.260.160.14
      callme80.730.570.320.200.17

      -Although the -fastproxy option results in faster code, the generated proxy code is not as user-friendly +Although the -fastproxy option results in faster code over the default, the generated proxy code is not as user-friendly as docstring/doxygen comments and functions with default values are not visible in the generated Python proxy class. +The -olddefs option can rectify this.

      +

      +The generated proxy class for the example above when using -fastproxy -olddefs is: +

      + +
      +
      +class Go(object):
      +    def callme0(self):
      +        return _example.Go_callme0(self)
      +    callme0 = _swig_new_instance_method(_example.Go_callme0)
      +
      +    def callme4(self, a, b, c, d):
      +        return _example.Go_callme4(self, a, b, c, d)
      +    callme4 = _swig_new_instance_method(_example.Go_callme4)
      +
      +    def callme8(self, a, b, c, d, e, f, g, i):
      +        return _example.Go_callme8(self, a, b, c, d, e, f, g, i)
      +    callme8 = _swig_new_instance_method(_example.Go_callme8)
      +    ...
      +
      +
      + +

      +The class defines each method in two different ways. The first definition is replaced by the second definition and so the second definition is the one used when the method is called. +While this possibly provides the best of both worlds, the time to import the module will be slighly slower when the class is defined due to the additional method definitions. +

      38.7 Tips and techniques

      From 315c7dab060ac91413d5715423624c0074404052 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 22 Dec 2018 18:47:34 +0000 Subject: [PATCH 1219/2031] Remove debug display in python_pythoncode testcase --- Examples/test-suite/python_pythoncode.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python_pythoncode.i b/Examples/test-suite/python_pythoncode.i index 8191aa121..017f076c4 100644 --- a/Examples/test-suite/python_pythoncode.i +++ b/Examples/test-suite/python_pythoncode.i @@ -43,7 +43,7 @@ Foo* get_foo() {return new Foo();} %} %pythoncode %{ - print_debug = True + print_debug = False %} %extend Foo { From 573ddb061e86541326ef1ff3256af65ff70c7afe Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Thu, 27 Dec 2018 01:11:54 -0500 Subject: [PATCH 1220/2031] Maps both working as java.util impls --- .../cpp11_li_std_unordered_map_runme.java | 149 +++++++------ .../cpp11_li_std_unordered_set_runme.java | 75 ++++--- .../test-suite/java/li_std_map_runme.java | 144 +++++++------ .../test-suite/java/li_std_set_runme.java | 75 ++++--- Lib/java/std_map.i | 158 +++++++++----- Lib/java/std_unordered_map.i | 198 +++++++++++++++--- 6 files changed, 514 insertions(+), 285 deletions(-) diff --git a/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java b/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java index f216a0131..bb85eeadd 100644 --- a/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java +++ b/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java @@ -11,91 +11,112 @@ public class cpp11_li_std_unordered_map_runme { } } + public static void checkThat(boolean mustBeTrue) throws Throwable { + if (!mustBeTrue) { + // Index [2], since this function is one hop away from main, and [1] is the current method. + throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber()); + } + } + public static void main(String argv[]) throws Throwable { - StringIntUnorderedMap sim = new StringIntUnorderedMap(); - IntIntUnorderedMap iim = new IntIntUnorderedMap(); + java.util.AbstractMap sim = new StringIntUnorderedMap(); + java.util.AbstractMap iim = new IntIntUnorderedMap(); - if (!sim.empty()) throw new RuntimeException("Test (1) failed"); - if (!iim.empty()) throw new RuntimeException("Test (2) failed"); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); + checkThat(sim.size() == 0); + checkThat(iim.size() == 0); - if (sim.size() != 0) throw new RuntimeException("Test (3) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (4) failed"); + checkThat(sim.get("key") == null); + checkThat(iim.get(1) == null); - try { - sim.get("key"); - throw new RuntimeException("Test (5) failed"); - } catch (IndexOutOfBoundsException e) { - } + checkThat(!sim.containsKey("key")); + checkThat(!iim.containsKey(1)); - try { - iim.get(1); - throw new RuntimeException("Test (6) failed"); - } catch (IndexOutOfBoundsException e) { - } + checkThat(sim.put("key", 2) == null); + checkThat(iim.put(1, 2) == null); - sim.set("key", 1); - iim.set(1, 1); + checkThat(sim.size() == 1); + checkThat(iim.size() == 1); + checkThat(!sim.isEmpty()); + checkThat(!iim.isEmpty()); - if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); - if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); + checkThat(sim.get("key") == 2); + checkThat(iim.get(1) == 2); - sim.del("key"); - iim.del(1); + checkThat(sim.remove("key") == 2); + checkThat(iim.remove(1) == 2); - if (sim.has_key("key")) throw new RuntimeException("Test (9) failed"); - if (iim.has_key(1)) throw new RuntimeException("Test (10) failed"); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); + checkThat(sim.size() == 0); + checkThat(iim.size() == 0); - if (!sim.empty()) throw new RuntimeException("Test (11) failed"); - if (!iim.empty()) throw new RuntimeException("Test (12) failed"); - if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); + checkThat(sim.get("key") == null); + checkThat(iim.get(1) == null); - try { - sim.del("key"); - throw new RuntimeException("Test (15) failed"); - } catch (IndexOutOfBoundsException e) { - } + checkThat(sim.remove("key") == null); + checkThat(iim.remove(1) == null); - try { - iim.del(1); - throw new RuntimeException("Test (16) failed"); - } catch (IndexOutOfBoundsException e) { - } - - sim.set("key", 1); - iim.set(1, 1); - - if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); - if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); + checkThat(sim.put("key", 2) == null); + checkThat(iim.put(1, 2) == null); sim.clear(); iim.clear(); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); - if (sim.has_key("key")) throw new RuntimeException("Test (19) failed"); - if (iim.has_key(1)) throw new RuntimeException("Test (20) failed"); + checkThat(sim.put("key1", 1) == null); + checkThat(iim.put(1, 1) == null); + checkThat(sim.put("key2", 2) == null); + checkThat(iim.put(2, 2) == null); - if (!sim.empty()) throw new RuntimeException("Test (21) failed"); - if (!iim.empty()) throw new RuntimeException("Test (22) failed"); - if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); - if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); + checkThat(sim.size() == 2); + checkThat(iim.size() == 2); + checkThat(sim.get("key1") == 1); + checkThat(iim.get(1) == 1); + checkThat(sim.get("key2") == 2); + checkThat(iim.get(2) == 2); - sim.set("key", 1); - sim.set("key2", 2); - iim.set(1, 1); - iim.set(2, 2); + checkThat(sim.put("key1", 3) == 1); + checkThat(iim.put(1, 3) == 1); - if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); - if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); - if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); - if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); + checkThat(sim.size() == 2); + checkThat(iim.size() == 2); + checkThat(sim.get("key1") == 3); + checkThat(iim.get(1) == 3); - sim.set("key", 3); - iim.set(1, 3); + java.util.Set> sim_es = sim.entrySet(); + java.util.Map sim_default = new java.util.HashMap(); + sim_default.put("key1", 3); + sim_default.put("key2", 2); + java.util.Set> sim_es_default = sim_default.entrySet(); + checkThat(sim_es.size() == sim_es_default.size()); + for (java.util.Map.Entry entry : sim_es) { + checkThat(sim_es_default.contains(entry)); + checkThat(sim_default.containsKey(entry.getKey())); + checkThat(sim_default.containsValue(entry.getValue())); - if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); - if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); - if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); - if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); + Integer oldValue = entry.getValue(); + entry.setValue(oldValue + 1); + checkThat(sim.get(entry.getKey()) == (oldValue + 1)); + } + + java.util.Set> iim_es = iim.entrySet(); + java.util.Map iim_default = new java.util.HashMap(); + iim_default.put(1, 3); + iim_default.put(2, 2); + java.util.Set> iim_es_default = iim_default.entrySet(); + checkThat(iim_es.size() == iim_es_default.size()); + for (java.util.Map.Entry entry : iim_es) { + checkThat(iim_es_default.contains(entry)); + checkThat(iim_default.containsKey(entry.getKey())); + checkThat(iim_default.containsValue(entry.getValue())); + + Integer oldValue = entry.getValue(); + entry.setValue(oldValue + 1); + checkThat(iim.get(entry.getKey()) == (oldValue + 1)); + } } } diff --git a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java index 15f6eba0a..dddf00307 100644 --- a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java +++ b/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java @@ -11,49 +11,48 @@ public class cpp11_li_std_unordered_set_runme { } } - public static void failTest(int testNum) throws Throwable { - throw new RuntimeException("Test failed: " + testNum); - } - - public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { - if (!mustBeTrue) failTest(testNum); + public static void checkThat(boolean mustBeTrue) throws Throwable { + if (!mustBeTrue) { + // Index [2], since this function is one hop away from main, and [1] is the current method. + throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber()); + } } public static void main(String argv[]) throws Throwable { java.util.AbstractSet ss = new StringUnorderedSet(); - checkThat(ss.isEmpty(), 1); - checkThat(!ss.contains("key"), 2); - checkThat(!ss.remove("key"), 3); + checkThat(ss.isEmpty()); + checkThat(!ss.contains("key")); + checkThat(!ss.remove("key")); - checkThat(ss.add("key"), 4); - checkThat(!ss.add("key"), 5); - checkThat(ss.contains("key"), 6); - checkThat(ss.remove("key"), 7); - checkThat(ss.isEmpty(), 8); - checkThat(ss.size() == 0, 9); + checkThat(ss.add("key")); + checkThat(!ss.add("key")); + checkThat(ss.contains("key")); + checkThat(ss.remove("key")); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); - checkThat(ss.add("key1"), 10); - checkThat(ss.add("key2"), 11); - checkThat(ss.add("key3"), 12); - checkThat(ss.size() == 3, 13); + checkThat(ss.add("key1")); + checkThat(ss.add("key2")); + checkThat(ss.add("key3")); + checkThat(ss.size() == 3); ss.clear(); - checkThat(ss.isEmpty(), 14); - checkThat(ss.size() == 0, 15); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); - checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")), 16); - checkThat(ss.size() == 3, 17); - checkThat(ss.contains("one"), 18); - checkThat(!ss.contains("four"), 19); + checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three"))); + checkThat(ss.size() == 3); + checkThat(ss.contains("one")); + checkThat(!ss.contains("four")); - checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")), 20); - checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")), 21); - checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")), 22); - checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")), 23); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three"))); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two"))); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four"))); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four"))); - checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")), 24); + checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three"))); java.util.Set found = new java.util.HashSet(); java.util.Iterator itr = ss.iterator(); @@ -61,16 +60,16 @@ public class cpp11_li_std_unordered_set_runme { found.add(itr.next()); } - checkThat(ss.containsAll(found), 25); - checkThat(found.containsAll(ss), 26); + checkThat(ss.containsAll(found)); + checkThat(found.containsAll(ss)); java.util.AbstractSet ss2 = new StringUnorderedSet(ss); - checkThat(ss2.containsAll(ss), 27); - checkThat(ss.containsAll(ss2), 28); + checkThat(ss2.containsAll(ss)); + checkThat(ss.containsAll(ss2)); - checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")), 29); - checkThat(ss.removeAll(found), 30); - checkThat(ss.isEmpty(), 31); - checkThat(ss.size() == 0, 32); + checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four"))); + checkThat(ss.removeAll(found)); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); } } diff --git a/Examples/test-suite/java/li_std_map_runme.java b/Examples/test-suite/java/li_std_map_runme.java index ed5b43a31..7ad4370cc 100644 --- a/Examples/test-suite/java/li_std_map_runme.java +++ b/Examples/test-suite/java/li_std_map_runme.java @@ -11,12 +11,11 @@ public class li_std_map_runme { } } - public static void failTest(int testNum) throws Throwable { - throw new RuntimeException("Test failed: " + testNum); - } - - public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { - if (!mustBeTrue) failTest(testNum); + public static void checkThat(boolean mustBeTrue) throws Throwable { + if (!mustBeTrue) { + // Index [2], since this function is one hop away from main, and [1] is the current method. + throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber()); + } } public static void main(String argv[]) throws Throwable @@ -24,79 +23,100 @@ public class li_std_map_runme { java.util.AbstractMap sim = new StringIntMap(); java.util.AbstractMap iim = new IntIntMap(); - checkThat(sim.isEmpty(), 1); - checkThat(iim.isEmpty(), 2); - checkThat(sim.size() == 0, 3); - checkThat(iim.size() == 0, 4); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); + checkThat(sim.size() == 0); + checkThat(iim.size() == 0); - checkThat(sim.get("key") == null, 5); - checkThat(iim.get(1) == null, 6); + checkThat(sim.get("key") == null); + checkThat(iim.get(1) == null); - checkThat(!sim.containsKey("key"), 7); - checkThat(!iim.containsKey(1), 8); + checkThat(!sim.containsKey("key")); + checkThat(!iim.containsKey(1)); - checkThat(sim.put("key", 2) == null, 9); - checkThat(iim.put(1, 2) == null, 10); + checkThat(sim.put("key", 2) == null); + checkThat(iim.put(1, 2) == null); - // if (sim.size() != 1) throw new RuntimeException("Test (7) failed"); - // if (iim.size() != 1) throw new RuntimeException("Test (8) failed"); + checkThat(sim.size() == 1); + checkThat(iim.size() == 1); + checkThat(!sim.isEmpty()); + checkThat(!iim.isEmpty()); - // sim.remove("key"); - // iim.remove(1); + checkThat(sim.get("key") == 2); + checkThat(iim.get(1) == 2); - // if (sim.containsKey("key")) throw new RuntimeException("Test (9) failed"); - // if (iim.containsKey(1)) throw new RuntimeException("Test (10) failed"); + checkThat(sim.remove("key") == 2); + checkThat(iim.remove(1) == 2); - // if (!sim.isEmpty()) throw new RuntimeException("Test (11) failed"); - // if (!iim.isEmpty()) throw new RuntimeException("Test (12) failed"); - // if (sim.size() != 0) throw new RuntimeException("Test (13) failed"); - // if (iim.size() != 0) throw new RuntimeException("Test (14) failed"); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); + checkThat(sim.size() == 0); + checkThat(iim.size() == 0); - // try { - // sim.remove("key"); - // throw new RuntimeException("Test (15) failed"); - // } catch (IndexOutOfBoundsException e) { - // } + checkThat(sim.get("key") == null); + checkThat(iim.get(1) == null); - // try { - // iim.remove(1); - // throw new RuntimeException("Test (16) failed"); - // } catch (IndexOutOfBoundsException e) { - // } + checkThat(sim.remove("key") == null); + checkThat(iim.remove(1) == null); - // sim.put("key", 1); - // iim.put(1, 1); + checkThat(sim.put("key", 2) == null); + checkThat(iim.put(1, 2) == null); - // if (sim.size() != 1) throw new RuntimeException("Test (17) failed"); - // if (iim.size() != 1) throw new RuntimeException("Test (18) failed"); + sim.clear(); + iim.clear(); + checkThat(sim.isEmpty()); + checkThat(iim.isEmpty()); - // sim.clear(); - // iim.clear(); + checkThat(sim.put("key1", 1) == null); + checkThat(iim.put(1, 1) == null); + checkThat(sim.put("key2", 2) == null); + checkThat(iim.put(2, 2) == null); - // if (sim.containsKey("key")) throw new RuntimeException("Test (19) failed"); - // if (iim.containsKey(1)) throw new RuntimeException("Test (20) failed"); + checkThat(sim.size() == 2); + checkThat(iim.size() == 2); + checkThat(sim.get("key1") == 1); + checkThat(iim.get(1) == 1); + checkThat(sim.get("key2") == 2); + checkThat(iim.get(2) == 2); - // if (!sim.isEmpty()) throw new RuntimeException("Test (21) failed"); - // if (!iim.isEmpty()) throw new RuntimeException("Test (22) failed"); - // if (sim.size() != 0) throw new RuntimeException("Test (23) failed"); - // if (iim.size() != 0) throw new RuntimeException("Test (24) failed"); + checkThat(sim.put("key1", 3) == 1); + checkThat(iim.put(1, 3) == 1); - // sim.put("key", 1); - // sim.put("key2", 2); - // iim.put(1, 1); - // iim.put(2, 2); + checkThat(sim.size() == 2); + checkThat(iim.size() == 2); + checkThat(sim.get("key1") == 3); + checkThat(iim.get(1) == 3); - // if (sim.get("key") != 1) throw new RuntimeException("Test (25) failed"); - // if (sim.get("key2") != 2) throw new RuntimeException("Test (26) failed"); - // if (iim.get(1) != 1) throw new RuntimeException("Test (27) failed"); - // if (iim.get(2) != 2) throw new RuntimeException("Test (28) failed"); + java.util.Set> sim_es = sim.entrySet(); + java.util.Map sim_default = new java.util.HashMap(); + sim_default.put("key1", 3); + sim_default.put("key2", 2); + java.util.Set> sim_es_default = sim_default.entrySet(); + checkThat(sim_es.size() == sim_es_default.size()); + for (java.util.Map.Entry entry : sim_es) { + checkThat(sim_es_default.contains(entry)); + checkThat(sim_default.containsKey(entry.getKey())); + checkThat(sim_default.containsValue(entry.getValue())); - // sim.put("key", 3); - // iim.put(1, 3); + Integer oldValue = entry.getValue(); + entry.setValue(oldValue + 1); + checkThat(sim.get(entry.getKey()) == (oldValue + 1)); + } - // if (sim.get("key") != 3) throw new RuntimeException("Test (29) failed"); - // if (sim.get("key2") != 2) throw new RuntimeException("Test (30) failed"); - // if (iim.get(1) != 3) throw new RuntimeException("Test (31) failed"); - // if (iim.get(2) != 2) throw new RuntimeException("Test (32) failed"); + java.util.Set> iim_es = iim.entrySet(); + java.util.Map iim_default = new java.util.HashMap(); + iim_default.put(1, 3); + iim_default.put(2, 2); + java.util.Set> iim_es_default = iim_default.entrySet(); + checkThat(iim_es.size() == iim_es_default.size()); + for (java.util.Map.Entry entry : iim_es) { + checkThat(iim_es_default.contains(entry)); + checkThat(iim_default.containsKey(entry.getKey())); + checkThat(iim_default.containsValue(entry.getValue())); + + Integer oldValue = entry.getValue(); + entry.setValue(oldValue + 1); + checkThat(iim.get(entry.getKey()) == (oldValue + 1)); + } } } diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java index 7bbd3fced..9763484c2 100644 --- a/Examples/test-suite/java/li_std_set_runme.java +++ b/Examples/test-suite/java/li_std_set_runme.java @@ -11,49 +11,48 @@ public class li_std_set_runme { } } - public static void failTest(int testNum) throws Throwable { - throw new RuntimeException("Test failed: " + testNum); - } - - public static void checkThat(boolean mustBeTrue, int testNum) throws Throwable { - if (!mustBeTrue) failTest(testNum); + public static void checkThat(boolean mustBeTrue) throws Throwable { + if (!mustBeTrue) { + // Index [2], since this function is one hop away from main, and [1] is the current method. + throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber()); + } } public static void main(String argv[]) throws Throwable { java.util.AbstractSet ss = new StringSet(); - checkThat(ss.isEmpty(), 1); - checkThat(!ss.contains("key"), 2); - checkThat(!ss.remove("key"), 3); + checkThat(ss.isEmpty()); + checkThat(!ss.contains("key")); + checkThat(!ss.remove("key")); - checkThat(ss.add("key"), 4); - checkThat(!ss.add("key"), 5); - checkThat(ss.contains("key"), 6); - checkThat(ss.remove("key"), 7); - checkThat(ss.isEmpty(), 8); - checkThat(ss.size() == 0, 9); + checkThat(ss.add("key")); + checkThat(!ss.add("key")); + checkThat(ss.contains("key")); + checkThat(ss.remove("key")); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); - checkThat(ss.add("key1"), 10); - checkThat(ss.add("key2"), 11); - checkThat(ss.add("key3"), 12); - checkThat(ss.size() == 3, 13); + checkThat(ss.add("key1")); + checkThat(ss.add("key2")); + checkThat(ss.add("key3")); + checkThat(ss.size() == 3); ss.clear(); - checkThat(ss.isEmpty(), 14); - checkThat(ss.size() == 0, 15); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); - checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three")), 16); - checkThat(ss.size() == 3, 17); - checkThat(ss.contains("one"), 18); - checkThat(!ss.contains("four"), 19); + checkThat(ss.addAll(java.util.Arrays.asList("one", "two", "three"))); + checkThat(ss.size() == 3); + checkThat(ss.contains("one")); + checkThat(!ss.contains("four")); - checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three")), 20); - checkThat(ss.containsAll(java.util.Arrays.asList("one", "two")), 21); - checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four")), 22); - checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four")), 23); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two", "three"))); + checkThat(ss.containsAll(java.util.Arrays.asList("one", "two"))); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "four"))); + checkThat(!ss.containsAll(java.util.Arrays.asList("one", "two", "three", "four"))); - checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three")), 24); + checkThat(!ss.addAll(java.util.Arrays.asList("one", "two", "three"))); java.util.Set found = new java.util.HashSet(); java.util.Iterator itr = ss.iterator(); @@ -61,16 +60,16 @@ public class li_std_set_runme { found.add(itr.next()); } - checkThat(ss.containsAll(found), 25); - checkThat(found.containsAll(ss), 26); + checkThat(ss.containsAll(found)); + checkThat(found.containsAll(ss)); java.util.AbstractSet ss2 = new StringSet(ss); - checkThat(ss2.containsAll(ss), 27); - checkThat(ss.containsAll(ss2), 28); + checkThat(ss2.containsAll(ss)); + checkThat(ss.containsAll(ss2)); - checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four")), 29); - checkThat(ss.removeAll(found), 30); - checkThat(ss.isEmpty(), 31); - checkThat(ss.size() == 0, 32); + checkThat(!ss.removeAll(java.util.Arrays.asList("five", "four"))); + checkThat(ss.removeAll(found)); + checkThat(ss.isEmpty()); + checkThat(ss.size() == 0); } } diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 4169a18b4..d59ceb8fc 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -7,7 +7,6 @@ * ----------------------------------------------------------------------------- */ %include -%include // ------------------------------------------------------------------------ // std::map @@ -31,9 +30,19 @@ %javamethodmodifiers std::map::sizeImpl "private"; %javamethodmodifiers std::map::containsImpl "private"; -%javamethodmodifiers std::map::getImpl "private"; -%javamethodmodifiers std::map::putImpl "private"; -%javamethodmodifiers std::map::removeImpl "private"; +%javamethodmodifiers std::map::putUnchecked "private"; +%javamethodmodifiers std::map::removeUnchecked "private"; +%javamethodmodifiers std::map::find "private"; +%javamethodmodifiers std::map::begin "private"; +%javamethodmodifiers std::map::end "private"; + +%rename(Iterator) std::map::iterator; +%nodefaultctor std::map::iterator; +%javamethodmodifiers std::map::iterator::getNextUnchecked "private"; +%javamethodmodifiers std::map::iterator::isNot "private"; +%javamethodmodifiers std::map::iterator::getKey "private"; +%javamethodmodifiers std::map::iterator::getValue "private"; +%javamethodmodifiers std::map::iterator::setValue "private"; namespace std { @@ -48,47 +57,88 @@ template > return sizeImpl(); } - public boolean containsKey(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + public boolean containsKey(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { return false; } - return containsImpl(($typemap(jboxtype, KeyType))object); + return containsImpl(($typemap(jboxtype, KeyType))key); } - public $typemap(jboxtype, ValueType) get(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + public $typemap(jboxtype, ValueType) get(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { return null; } - try { - getImpl(($typemap(jboxtype, KeyType)) object); - } catch (IndexOutOfBoundsException e) {} + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + return itr.getValue(); + } return null; } public $typemap(jboxtype, ValueType) put($typemap(jboxtype, KeyType) key, $typemap(jboxtype, ValueType) value) { - try { - $typemap(jboxtype, ValueType) oldValue = putImpl(key, value); + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + itr.setValue(value); return oldValue; - } catch (IndexOutOfBoundsException e) {} - - return null; + } else { + putUnchecked(key, value); + return null; + } } - public $typemap(jboxtype, ValueType) remove($typemap(jboxtype, KeyType) key) { - try { - $typemap(jboxtype, ValueType) oldValue = removeImpl(key); - return oldValue; - } catch (IndexOutOfBoundsException e) {} + public $typemap(jboxtype, ValueType) remove(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { + return null; + } - return null; + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + removeUnchecked(itr); + return oldValue; + } else { + return null; + } } public java.util.Set> entrySet() { - throw new RuntimeException("Stub"); + java.util.Set> setToReturn = + new java.util.HashSet>(); + + Iterator itr = begin(); + final Iterator end = end(); + while(itr.isNot(end)) { + setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>() { + private Iterator iterator; + + private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)> init(Iterator iterator) { + this.iterator = iterator; + return this; + } + + public $typemap(jboxtype, KeyType) getKey() { + return iterator.getKey(); + } + + public $typemap(jboxtype, ValueType) getValue() { + return iterator.getValue(); + } + + public $typemap(jboxtype, ValueType) setValue($typemap(jboxtype, ValueType) newValue) { + $typemap(jboxtype, ValueType) oldValue = iterator.getValue(); + iterator.setValue(newValue); + return oldValue; + } + }.init(itr)); + itr = itr.getNextUnchecked(); + } + + return setToReturn; } %} @@ -96,9 +146,37 @@ template > map(); map(const map&); + struct iterator { + %extend { + std::map::iterator getNextUnchecked() { + std::map::iterator copy = (*$self); + return ++copy; + } + + bool isNot(const iterator other) const { + return (*$self != other); + } + + KeyType getKey() const { + return (*$self)->first; + } + + ValueType getValue() const { + return (*$self)->second; + } + + void setValue(const ValueType& newValue) { + (*$self)->second = newValue; + } + } + }; + %rename(isEmpty) empty; bool empty() const; void clear(); + iterator find(const KeyType&); + iterator begin(); + iterator end(); %extend { %fragment("SWIG_MapSize"); @@ -110,36 +188,12 @@ template > return (self->count(key) > 0); } - const ValueType& getImpl(const KeyType& key) throw (std::out_of_range) { - std::map::iterator itr = self->find(key); - if (itr != self->end()) { - return itr->second; - } else { - throw std::out_of_range("map::get() - key not found"); - } + void putUnchecked(const KeyType& key, const ValueType& value) { + (*self)[key] = value; } - ValueType putImpl(const KeyType& key, const ValueType& value) { - std::map::iterator itr = self->find(key); - if (itr != self->end()) { - ValueType oldValue = itr->second; - itr->second = value; - return oldValue; - } else { - (*self)[key] = value; - throw std::out_of_range("map::put() - no existing value for key"); - } - } - - ValueType removeImpl(const KeyType& key) throw (std::out_of_range) { - std::map::iterator itr = self->find(key); - if (itr != self->end()) { - ValueType oldValue = itr->second; - self->erase(itr); - return oldValue; - } else { - throw std::out_of_range("map::remove() - key not found"); - } + void removeUnchecked(const std::map::iterator itr) { + self->erase(itr); } } }; diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 434292b07..b0e8b3e40 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -2,6 +2,8 @@ * std_unordered_map.i * * SWIG typemaps for std::unordered_map + * The Java proxy class extends java.util.AbstractMap. The std::unordered_map + * container looks and feels much like a java.util.HashMap from Java. * ----------------------------------------------------------------------------- */ %include @@ -15,51 +17,185 @@ #include %} +%fragment("SWIG_MapSize", "header", fragment="SWIG_JavaIntFromSize_t") { + SWIGINTERN jint SWIG_MapSize(size_t size) { + jint sz = SWIG_JavaIntFromSize_t(size); + if (sz == -1) { + throw std::out_of_range("map size is too large to fit into a Java int"); + } + + return sz; + } +} + +%javamethodmodifiers std::unordered_map::sizeImpl "private"; +%javamethodmodifiers std::unordered_map::containsImpl "private"; +%javamethodmodifiers std::unordered_map::putUnchecked "private"; +%javamethodmodifiers std::unordered_map::removeUnchecked "private"; +%javamethodmodifiers std::unordered_map::find "private"; +%javamethodmodifiers std::unordered_map::begin "private"; +%javamethodmodifiers std::unordered_map::end "private"; + +%rename(Iterator) std::unordered_map::iterator; +%nodefaultctor std::unordered_map::iterator; +%javamethodmodifiers std::unordered_map::iterator::getNextUnchecked "private"; +%javamethodmodifiers std::unordered_map::iterator::isNot "private"; +%javamethodmodifiers std::unordered_map::iterator::getKey "private"; +%javamethodmodifiers std::unordered_map::iterator::getValue "private"; +%javamethodmodifiers std::unordered_map::iterator::setValue "private"; + namespace std { -template class unordered_map { - public: - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef KeyType key_type; - typedef MappedType mapped_type; - unordered_map(); - unordered_map(const unordered_map&); +template class unordered_map { - unsigned int size() const; +%typemap(javabase) std::unordered_map + "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>" + +%proxycode %{ + + public int size() { + return sizeImpl(); + } + + public boolean containsKey(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { + return false; + } + + return containsImpl(($typemap(jboxtype, KeyType))key); + } + + public $typemap(jboxtype, ValueType) get(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { + return null; + } + + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + return itr.getValue(); + } + + return null; + } + + public $typemap(jboxtype, ValueType) put($typemap(jboxtype, KeyType) key, + $typemap(jboxtype, ValueType) value) { + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + itr.setValue(value); + return oldValue; + } else { + putUnchecked(key, value); + return null; + } + } + + public $typemap(jboxtype, ValueType) remove(Object key) { + if (!(key instanceof $typemap(jboxtype, KeyType))) { + return null; + } + + Iterator itr = find(($typemap(jboxtype, KeyType)) key); + if (itr.isNot(end())) { + $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + removeUnchecked(itr); + return oldValue; + } else { + return null; + } + } + + public java.util.Set> entrySet() { + java.util.Set> setToReturn = + new java.util.HashSet>(); + + Iterator itr = begin(); + final Iterator end = end(); + while(itr.isNot(end)) { + setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>() { + private Iterator iterator; + + private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)> init(Iterator iterator) { + this.iterator = iterator; + return this; + } + + public $typemap(jboxtype, KeyType) getKey() { + return iterator.getKey(); + } + + public $typemap(jboxtype, ValueType) getValue() { + return iterator.getValue(); + } + + public $typemap(jboxtype, ValueType) setValue($typemap(jboxtype, ValueType) newValue) { + $typemap(jboxtype, ValueType) oldValue = iterator.getValue(); + iterator.setValue(newValue); + return oldValue; + } + }.init(itr)); + itr = itr.getNextUnchecked(); + } + + return setToReturn; + } +%} + + public: + unordered_map(); + unordered_map(const unordered_map&); + + struct iterator { + %extend { + std::unordered_map::iterator getNextUnchecked() { + std::unordered_map::iterator copy = (*$self); + return ++copy; + } + + bool isNot(const iterator other) const { + return (*$self != other); + } + + KeyType getKey() const { + return (*$self)->first; + } + + ValueType getValue() const { + return (*$self)->second; + } + + void setValue(const ValueType& newValue) { + (*$self)->second = newValue; + } + } + }; + + %rename(isEmpty) empty; bool empty() const; void clear(); - + iterator find(const KeyType&); + iterator begin(); + iterator end(); %extend { - const MappedType& get(const KeyType& key) throw (std::out_of_range) { - std::unordered_map::iterator i = self->find(key); + %fragment("SWIG_MapSize"); - if (i != self->end()) { - return i->second; - } else { - throw std::out_of_range("key not found"); - } + jint sizeImpl() const throw (std::out_of_range) { + return SWIG_MapSize(self->size()); } - void set(const KeyType& key, const MappedType& x) { - (*self)[key] = x; + bool containsImpl(const KeyType& key) { + return (self->count(key) > 0); } - void del(const KeyType& key) throw (std::out_of_range) { - std::unordered_map::iterator i = self->find(key); - - if (i != self->end()) { - self->erase(i); - } else { - throw std::out_of_range("key not found"); - } + void putUnchecked(const KeyType& key, const ValueType& value) { + (*self)[key] = value; } - bool has_key(const KeyType& key) { - std::unordered_map::iterator i = self->find(key); - return i != self->end(); + void removeUnchecked(const std::unordered_map::iterator itr) { + self->erase(itr); } } }; -} // namespace std +} From 7e9f1a79724d6c0d480999958109f2a2f2e3494f Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Thu, 27 Dec 2018 01:15:18 -0500 Subject: [PATCH 1221/2031] Add to STL file as well --- Lib/java/std_set.i | 2 +- Lib/java/std_unordered_set.i | 2 +- Lib/java/stl.i | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 57613f322..de0c31fba 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -186,4 +186,4 @@ class set { } }; -} // namespace std \ No newline at end of file +} // namespace std diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 4074d8045..ca9af0f19 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -186,4 +186,4 @@ class unordered_set { } }; -} // namespace std \ No newline at end of file +} // namespace std diff --git a/Lib/java/stl.i b/Lib/java/stl.i index 04f86014f..6f2a4342a 100644 --- a/Lib/java/stl.i +++ b/Lib/java/stl.i @@ -3,8 +3,11 @@ * ----------------------------------------------------------------------------- */ %include -%include -%include %include %include +%include +%include +%include +%include +%include From 945bd7c8088af6813195d9584e6b373e47341363 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Thu, 27 Dec 2018 11:47:16 -0500 Subject: [PATCH 1222/2031] Remove c++11 from stl.i --- Lib/java/stl.i | 3 --- 1 file changed, 3 deletions(-) diff --git a/Lib/java/stl.i b/Lib/java/stl.i index 6f2a4342a..a04adf7b6 100644 --- a/Lib/java/stl.i +++ b/Lib/java/stl.i @@ -7,7 +7,4 @@ %include %include %include -%include -%include %include - From 3efea1f4abe747e60549336cdbb1ff73f438ab06 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 11:45:46 +0000 Subject: [PATCH 1223/2031] Fix typecheck typemaps for non-pointers and NULL The typecheck typemaps succeed for non pointers (SWIGTYPE, SWIGTYPE&, SWIGTYPE&&) when the equivalent to C NULL is passed from the target language. This commit implements a fix for Python to not accept a Python None for non-pointer types. Issue #1202 --- Examples/test-suite/python/implicittest_runme.py | 10 +--------- Lib/python/pyrun.swg | 2 +- Lib/swigrun.swg | 1 + Lib/typemaps/swigtype.swg | 16 ++++++++-------- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py index f17788e97..625613a95 100644 --- a/Examples/test-suite/python/implicittest_runme.py +++ b/Examples/test-suite/python/implicittest_runme.py @@ -13,15 +13,7 @@ check(1, A(1).get()) check(2, A(1.0).get()) check(3, A(B()).get()) check(4, A("hello").get()) -try: - check(3, A(None).get()) - raise RuntimeError -except ValueError: - # ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &' - # Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value, - # references and pointers to different types, where pointers ought to be - # given a slightly higher precedence. - pass +check(4, A(None).get()) check(1, get(1)) check(2, get(1.0)) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 7f0502198..0759b8f27 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1018,7 +1018,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (obj == Py_None && !implicit_conv) { if (ptr) *ptr = 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } res = SWIG_ERROR; diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 1ef676187..59118ecad 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -43,6 +43,7 @@ /* Flags for pointer conversions */ #define SWIG_POINTER_DISOWN 0x1 #define SWIG_CAST_NEW_MEMORY 0x2 +#define SWIG_POINTER_NO_NULL 0x4 /* Flags for new pointer objects */ #define SWIG_POINTER_OWN 0x1 diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 87fab7e69..581de1a90 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -358,46 +358,46 @@ %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE & { void *vptr = 0; - int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && { void *vptr = 0; - int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } #if defined(__cplusplus) && defined(%implicitconv_flag) %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & { - int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); + int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && { - int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag); + int res = SWIG_ConvertPtr($input, 0, $descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE { - int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag); + int res = SWIG_ConvertPtr($input, 0, $&descriptor, SWIG_POINTER_NO_NULL | %implicitconv_flag); $1 = SWIG_CheckState(res); } #else %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE & { void *vptr = 0; - int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && { void *vptr = 0; - int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0); + int res = SWIG_ConvertPtr($input, &vptr, $descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE { void *vptr = 0; - int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, 0); + int res = SWIG_ConvertPtr($input, &vptr, $&descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } #endif From ef8a92578b79d624eaa60a1417201cffb0b898b7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 12:09:04 +0000 Subject: [PATCH 1224/2031] Correct Python implicitconv code Py_None is only possible with implicitconv so move this block of code into the implicitconv if block. --- Lib/python/pyrun.swg | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 0759b8f27..ad1b81963 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1098,13 +1098,13 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } } } - } - if (!SWIG_IsOK(res) && obj == Py_None) { - if (ptr) - *ptr = 0; - if (PyErr_Occurred()) - PyErr_Clear(); - res = SWIG_OK; + if (!SWIG_IsOK(res) && obj == Py_None) { + if (ptr) + *ptr = 0; + if (PyErr_Occurred()) + PyErr_Clear(); + res = SWIG_OK; + } } } return res; From c459019814962e9e31228d7ddc4a40941b9b8d0d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 13:30:00 +0000 Subject: [PATCH 1225/2031] .gitinit update For Examples/python/import_packages --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ad1a32c64..a2acc0053 100644 --- a/.gitignore +++ b/.gitignore @@ -181,12 +181,13 @@ Examples/php/*/example.php /__pycache__/ Examples/test-suite/python/*.py !Examples/test-suite/python/*runme.py -Examples/python/*/example.py +Examples/python/**/example.py Examples/python/**/bar.py Examples/python/**/base.py Examples/python/**/foo.py Examples/python/**/spam.py Examples/python/**/robin.py +Examples/python/import_packages/module_is_init/pkg1/__init__.py Examples/python/doxygen/example.html # R From 2769a8763c0737229d786a30b030972f1e57b17e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 13:28:01 +0000 Subject: [PATCH 1226/2031] Add test for overloading and NULL --- Examples/test-suite/common.mk | 1 + Examples/test-suite/overload_null.i | 52 +++++++++++++++++++ .../test-suite/python/overload_null_runme.py | 44 ++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 Examples/test-suite/overload_null.i create mode 100644 Examples/test-suite/python/overload_null_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index fbde676ed..96c9c4b14 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -340,6 +340,7 @@ CPP_TEST_CASES += \ overload_extend \ overload_method \ overload_numeric \ + overload_null \ overload_polymorphic \ overload_rename \ overload_return_type \ diff --git a/Examples/test-suite/overload_null.i b/Examples/test-suite/overload_null.i new file mode 100644 index 000000000..d4879fdb5 --- /dev/null +++ b/Examples/test-suite/overload_null.i @@ -0,0 +1,52 @@ +%module overload_null + +%{ +struct F {}; +%} + +%inline %{ +struct X {}; +struct Y {}; +struct F; + +struct Overload { + int byval1(X x) { return 1; } + int byval1(Y* y) { return 2; } + + int byval2(Y* y) { return 3; } + int byval2(X x) { return 4; } + + int byref1(X& x) { return 5; } + int byref1(Y* y) { return 6; } + + int byref2(Y* y) { return 7; } + int byref2(X& x) { return 8; } + + int byconstref1(const X& x) { return 9; } + int byconstref1(Y* y) { return 10; } + + int byconstref2(Y* y) { return 11; } + int byconstref2(const X& x) { return 12; } + + // const pointer references + int byval1cpr(X x) { return 13; } + int byval1cpr(Y*const& y) { return 14; } + + int byval2cpr(Y*const& y) { return 15; } + int byval2cpr(X x) { return 16; } + + // forward class declaration + int byval1forwardptr(X x) { return 17; } + int byval1forwardptr(F* f) { return 18; } + + int byval2forwardptr(F* f) { return 19; } + int byval2forwardptr(X x) { return 20; } + + int byval1forwardref(X x) { return 21; } + int byval1forwardref(F& f) { return -21; } + + int byval2forwardref(F& f) { return -22; } + int byval2forwardref(X x) { return 22; } + +}; +%} diff --git a/Examples/test-suite/python/overload_null_runme.py b/Examples/test-suite/python/overload_null_runme.py new file mode 100644 index 000000000..a34524255 --- /dev/null +++ b/Examples/test-suite/python/overload_null_runme.py @@ -0,0 +1,44 @@ +from overload_null import * + +def check(a, b): + if a != b: + raise RuntimeError(str(a) + " does not equal " + str(b)) + +o = Overload() +x = X() + +check(1, o.byval1(x)) +check(2, o.byval1(None)) + +check(3, o.byval2(None)) +check(4, o.byval2(x)) + +check(5, o.byref1(x)) +check(6, o.byref1(None)) + +check(7, o.byref2(None)) +check(8, o.byref2(x)) + +check(9, o.byconstref1(x)) +check(10, o.byconstref1(None)) + +check(11, o.byconstref2(None)) +check(12, o.byconstref2(x)) + +# const pointer references +check(13, o.byval1cpr(x)) +check(14, o.byval1cpr(None)) + +check(15, o.byval2cpr(None)) +check(16, o.byval2cpr(x)) + +# forward class declaration +check(17, o.byval1forwardptr(x)) +check(18, o.byval1forwardptr(None)) + +check(19, o.byval2forwardptr(None)) +check(20, o.byval2forwardptr(x)) + +check(21, o.byval1forwardref(x)) + +check(22, o.byval2forwardref(x)) From d14c97408ddee10fb10f967ffc520a92ee1eccf8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 13:46:40 +0000 Subject: [PATCH 1227/2031] Fix overloading for non-pointers and NULL - Ruby --- .../test-suite/ruby/overload_null_runme.rb | 52 +++++++++++++++++++ Lib/ruby/rubyrun.swg | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/ruby/overload_null_runme.rb diff --git a/Examples/test-suite/ruby/overload_null_runme.rb b/Examples/test-suite/ruby/overload_null_runme.rb new file mode 100644 index 000000000..eabea5e40 --- /dev/null +++ b/Examples/test-suite/ruby/overload_null_runme.rb @@ -0,0 +1,52 @@ +#!/usr/bin/env ruby +# +# Put script description here. +# +# +# +# +# + +require 'swig_assert' +require 'overload_null' + +include Overload_null + +o = Overload.new +x = X.new + +swig_assert(1 == o.byval1(x)) +swig_assert(2 == o.byval1(nil)) + +swig_assert(3 == o.byval2(nil)) +swig_assert(4 == o.byval2(x)) + +swig_assert(5 == o.byref1(x)) +swig_assert(6 == o.byref1(nil)) + +swig_assert(7 == o.byref2(nil)) +swig_assert(8 == o.byref2(x)) + +swig_assert(9 == o.byconstref1(x)) +swig_assert(10 == o.byconstref1(nil)) + +swig_assert(11 == o.byconstref2(nil)) +swig_assert(12 == o.byconstref2(x)) + +# const pointer references +swig_assert(13 == o.byval1cpr(x)) +swig_assert(14 == o.byval1cpr(nil)) + +swig_assert(15 == o.byval2cpr(nil)) +swig_assert(16 == o.byval2cpr(x)) + +# forward class declaration +swig_assert(17 == o.byval1forwardptr(x)) +swig_assert(18 == o.byval1forwardptr(nil)) + +swig_assert(19 == o.byval2forwardptr(nil)) +swig_assert(20 == o.byval2forwardptr(x)) + +swig_assert(21 == o.byval1forwardref(x)) + +swig_assert(22 == o.byval2forwardref(x)) diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 1afc5c1d0..b4dd9ddf0 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -266,7 +266,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, if (NIL_P(obj)) { if (ptr) *ptr = 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { if (TYPE(obj) != T_DATA) { return SWIG_ERROR; From b1178cf130e86435c9109f0c0c056077884fd026 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 14:10:41 +0000 Subject: [PATCH 1228/2031] Fix overloading for non-pointers and NULL - Perl --- .../test-suite/perl5/overload_null_runme.pl | 44 +++++++++++++++++++ Lib/perl5/perlrun.swg | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/perl5/overload_null_runme.pl diff --git a/Examples/test-suite/perl5/overload_null_runme.pl b/Examples/test-suite/perl5/overload_null_runme.pl new file mode 100644 index 000000000..7cc5090de --- /dev/null +++ b/Examples/test-suite/perl5/overload_null_runme.pl @@ -0,0 +1,44 @@ +use strict; +use warnings; +use Test::More tests => 24; +BEGIN { use_ok('overload_null') } +require_ok('overload_null'); + +my $o = new overload_null::Overload(); +my $x = new overload_null::X(); + +is(1, $o->byval1($x)); +is(2, $o->byval1(undef)); + +is(3, $o->byval2(undef)); +is(4, $o->byval2($x)); + +is(5, $o->byref1($x)); +is(6, $o->byref1(undef)); + +is(7, $o->byref2(undef)); +is(8, $o->byref2($x)); + +is(9, $o->byconstref1($x)); +is(10, $o->byconstref1(undef)); + +is(11, $o->byconstref2(undef)); +is(12, $o->byconstref2($x)); + +# const pointer references +is(13, $o->byval1cpr($x)); +is(14, $o->byval1cpr(undef)); + +is(15, $o->byval2cpr(undef)); +is(16, $o->byval2cpr($x)); + +# forward class declaration +is(17, $o->byval1forwardptr($x)); +is(18, $o->byval1forwardptr(undef)); + +is(19, $o->byval2forwardptr(undef)); +is(20, $o->byval2forwardptr($x)); + +is(21, $o->byval1forwardref($x)); + +is(22, $o->byval2forwardref($x)); diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 02714c451..b04002f5d 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -277,7 +277,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ voidptr = INT2PTR(void *,tmp); } else if (! SvOK(sv)) { /* Check for undef */ *(ptr) = (void *) 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else if (SvTYPE(sv) == SVt_RV) { /* Check for NULL pointer */ if (!SvROK(sv)) { /* In Perl 5.12 and later, SVt_RV == SVt_IV, so sv could be a valid integer value. */ From 12eb0f81ae77dd6ee5ee50a096f8ce0001189248 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Dec 2018 14:55:43 +0000 Subject: [PATCH 1229/2031] Fix overloading for non-pointers and NULL - Tcl --- .../test-suite/tcl/overload_null_runme.tcl | 52 +++++++++++++++++++ Lib/tcl/tclrun.swg | 3 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/tcl/overload_null_runme.tcl diff --git a/Examples/test-suite/tcl/overload_null_runme.tcl b/Examples/test-suite/tcl/overload_null_runme.tcl new file mode 100644 index 000000000..3716612ab --- /dev/null +++ b/Examples/test-suite/tcl/overload_null_runme.tcl @@ -0,0 +1,52 @@ + +if [ catch { load ./overload_null[info sharedlibextension] overload_null} err_msg ] { + puts stderr "Could not load shared object:\n$err_msg" +} + +proc check {what expected actual} { + if {$expected != $actual } { + error "Failed: $what Expected: $expected , Actual: $actual" + } +} + +set o [Overload] +set x [X] + +check "test1 " 1 [$o byval1 $x] +check "test2 " 2 [$o byval1 "NULL"] + +check "testX" 1 [$o byval1 $x] +check "testX" 2 [$o byval1 "NULL"] + +check "testX" 3 [$o byval2 "NULL"] +check "testX" 4 [$o byval2 $x] + +check "testX" 5 [$o byref1 $x] +check "testX" 6 [$o byref1 "NULL"] + +check "testX" 7 [$o byref2 "NULL"] +check "testX" 8 [$o byref2 $x] + +check "testX" 9 [$o byconstref1 $x] +check "testX" 10 [$o byconstref1 "NULL"] + +check "testX" 11 [$o byconstref2 "NULL"] +check "testX" 12 [$o byconstref2 $x] + +# const pointer references +check "testX" 13 [$o byval1cpr $x] +check "testX" 14 [$o byval1cpr "NULL"] + +check "testX" 15 [$o byval2cpr "NULL"] +check "testX" 16 [$o byval2cpr $x] + +# forward class declaration +check "testX" 17 [$o byval1forwardptr $x] +check "testX" 18 [$o byval1forwardptr "NULL"] + +check "testX" 19 [$o byval2forwardptr "NULL"] +check "testX" 20 [$o byval2forwardptr $x] + +check "testX" 21 [$o byval1forwardref $x] + +check "testX" 22 [$o byval2forwardref $x] diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index 408ddac3d..9010b9c87 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -125,7 +125,8 @@ SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swi /* Pointer values must start with leading underscore */ while (*c != '_') { *ptr = (void *) 0; - if (strcmp(c,"NULL") == 0) return SWIG_OK; + if (strcmp(c,"NULL") == 0) + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; /* Empty string: not a pointer */ if (*c == 0) return SWIG_ERROR; From 997362826813aee77d148a3ddd73352e10892b9a Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 29 Dec 2018 08:24:24 -0700 Subject: [PATCH 1230/2031] [OCaml] Update OCaml for out-of-source builds This is one of the steps needed to fix the OCaml test suite. In addition, disable the creation of toplevels by default in the OCaml examples (toplevels are currently broken). --- Examples/Makefile.in | 26 ++++++++++++------------- Examples/ocaml/shapes/Makefile | 2 +- Examples/ocaml/string_from_ptr/Makefile | 2 +- Examples/ocaml/strings_test/Makefile | 2 +- Examples/test-suite/ocaml/Makefile.in | 3 ++- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3f07aed29..3595120da 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -917,8 +917,8 @@ ocaml_static: $(SRCDIR_SRCS) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) - $(OCC) -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_dynamic: $(SRCDIR_SRCS) @@ -930,7 +930,7 @@ ocaml_dynamic: $(SRCDIR_SRCS) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLFIND) $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) ocaml_static_toplevel: $(SRCDIR_SRCS) @@ -938,41 +938,41 @@ ocaml_static_toplevel: $(SRCDIR_SRCS) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) - $(OCC) -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) 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: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) + $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) - $(OCC) -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) + $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) - $(OCC) -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(TARGET)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_dynamic_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC + $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(CPP_DLLIBS) $(LIBS) $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > $(INTERFACE:%.i=%_dynamic.ml) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) $(OCAMLPP) -c $(PROGFILE) + test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(TARGET) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' # ----------------------------------------------------------------- diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index b291d07e8..8aa35d79f 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -12,7 +12,7 @@ OBJS = example.o check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static static_top +build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index f9b027802..9987d0052 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -12,7 +12,7 @@ OBJS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static static_top +build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 24e2e6cca..2ddbe5f61 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -9,7 +9,7 @@ PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static top +build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 5cea4b236..11d2f374a 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -51,7 +51,8 @@ run_testcase = \ $(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; \ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ + $(foreach ext,cmo cmi,mv $(srcdir)/$(*)_runme.$(ext) $(*)_runme.$(ext) 2>/dev/null;) \ + $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && \ $(RUNTOOL) ./runme; \ fi ; From eb151e43be28a707e57ff3cec4cfd8408baa64b5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 09:26:33 +0000 Subject: [PATCH 1231/2031] Fix overloading for non-pointers and NULL - Guile --- .../test-suite/guile/overload_null_runme.scm | 53 +++++++++++++++++++ Lib/guile/guile_scm.swg | 1 + Lib/guile/guile_scm_run.swg | 2 +- Lib/guile/typemaps.i | 10 +++- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/guile/overload_null_runme.scm diff --git a/Examples/test-suite/guile/overload_null_runme.scm b/Examples/test-suite/guile/overload_null_runme.scm new file mode 100644 index 000000000..f764d9c20 --- /dev/null +++ b/Examples/test-suite/guile/overload_null_runme.scm @@ -0,0 +1,53 @@ +;; The SWIG modules have "passive" Linkage, i.e., they don't generate +;; Guile modules (namespaces) but simply put all the bindings into the +;; current module. That's enough for such a simple test. +(dynamic-call "scm_init_overload_null_module" (dynamic-link "./liboverload_null")) + +(define-macro (check form) + `(if (not ,form) + (error "Check failed: " ',form))) + +(define (=~ a b) + (< (abs (- a b)) 1e-8)) + +(define o (new-Overload)) +(define x (new-X)) + +(check (=~ 1 (Overload-byval1 o x))) +(check (=~ 2 (Overload-byval1 o #nil))) + +(check (=~ 3 (Overload-byval2 o #nil))) +(check (=~ 4 (Overload-byval2 o x))) + +(check (=~ 5 (Overload-byref1 o x))) +(check (=~ 6 (Overload-byref1 o #nil))) + +(check (=~ 7 (Overload-byref2 o #nil))) +(check (=~ 8 (Overload-byref2 o x))) + +(check (=~ 9 (Overload-byconstref1 o x))) +(check (=~ 10 (Overload-byconstref1 o #nil))) + +(check (=~ 11 (Overload-byconstref2 o #nil))) +(check (=~ 12 (Overload-byconstref2 o x))) + +; const pointer references +; No SWIGTYPE *const& typemaps for Guile yet +;(check (=~ 13 (Overload-byval1cpr o x))) +;(check (=~ 14 (Overload-byval1cpr o #nil))) + +;(check (=~ 15 (Overload-byval2cpr o #nil))) +;(check (=~ 16 (Overload-byval2cpr o x))) + +; forward class declaration +(check (=~ 17 (Overload-byval1forwardptr o x))) +(check (=~ 18 (Overload-byval1forwardptr o #nil))) + +(check (=~ 19 (Overload-byval2forwardptr o #nil))) +(check (=~ 20 (Overload-byval2forwardptr o x))) + +(check (=~ 21 (Overload-byval1forwardref o x))) + +(check (=~ 22 (Overload-byval2forwardref o x))) + +(exit 0) diff --git a/Lib/guile/guile_scm.swg b/Lib/guile/guile_scm.swg index 37eef6f33..16dc8aa92 100644 --- a/Lib/guile/guile_scm.swg +++ b/Lib/guile/guile_scm.swg @@ -8,6 +8,7 @@ #define SWIGGUILE_SCM %runtime "swigrun.swg" // Common C API type-checking code +%runtime "swigerrors.swg" // SWIG errors %runtime "guile_scm_run.swg" %include diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 0d04cb7c6..86e5c3be0 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -186,7 +186,7 @@ SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags) if (SCM_NULLP(smob)) { *result = NULL; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; #if SCM_MAJOR_VERSION >= 2 } else if (SCM_POINTER_P(s)) { *result = SCM_POINTER_VALUE(s); diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index f2926c163..cfccced88 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -444,15 +444,21 @@ typedef unsigned long SCM; $1 = scm_is_string($input) ? 1 : 0; } -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { void *ptr; int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); $1 = SWIG_CheckState(res); } +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && { + void *ptr; + int res = SWIG_ConvertPtr($input, &ptr, $1_descriptor, SWIG_POINTER_NO_NULL); + $1 = SWIG_CheckState(res); +} + %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; - int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, 0); + int res = SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL); $1 = SWIG_CheckState(res); } From 701dc125e17bde578e7ea6cf8594cf6ce7e0bde2 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 30 Dec 2018 02:50:46 -0700 Subject: [PATCH 1232/2031] [OCaml] Add missing keywords to ocamlkw.swg The asr, land, lor, lsl, lsr, lxor, mod, and nonrec keywords were missing from ocamlkw.swg. --- Lib/ocaml/ocamlkw.swg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/ocaml/ocamlkw.swg b/Lib/ocaml/ocamlkw.swg index 92d822219..950bee682 100644 --- a/Lib/ocaml/ocamlkw.swg +++ b/Lib/ocaml/ocamlkw.swg @@ -12,6 +12,7 @@ OCAMLKW(and); OCAMLKW(as); +OCAMLKW(asr); OCAMLKW(assert); OCAMLKW(begin); OCAMLKW(class); @@ -33,13 +34,20 @@ OCAMLKW(in); OCAMLKW(include); OCAMLKW(inherit); OCAMLKW(initializer); +OCAMLKW(land); OCAMLKW(lazy); OCAMLKW(let); +OCAMLKW(lor); +OCAMLKW(lsl); +OCAMLKW(lsr); +OCAMLKW(lxor); OCAMLKW(match); OCAMLKW(method); +OCAMLKW(mod); OCAMLKW(module); OCAMLKW(mutable); OCAMLKW(new); +OCAMLKW(nonrec); OCAMLKW(object); OCAMLKW(of); OCAMLKW(open); From c74ef14bb22a1c4d191e91a80bcb1a2afc992880 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 30 Dec 2018 02:51:58 -0700 Subject: [PATCH 1233/2031] Update a dead link. --- Lib/ocaml/ocamlkw.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ocaml/ocamlkw.swg b/Lib/ocaml/ocamlkw.swg index 950bee682..5e66085e0 100644 --- a/Lib/ocaml/ocamlkw.swg +++ b/Lib/ocaml/ocamlkw.swg @@ -6,7 +6,7 @@ /* from - http://caml.inria.fr/ocaml/htmlman/manual044.html + https://caml.inria.fr/pub/docs/manual-ocaml/lex.html */ From ec8d9789951597fd561adf39b685f7811dd5a6a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 10:11:35 +0000 Subject: [PATCH 1234/2031] Overloading for non-pointers and NULL - Javascript Overloading support for Javascript is generally incomplete as there are no typecheck typemaps, so the overloading and NULL support added here doesn't work and won't work until the typecheck typemaps are implemented. --- .../javascript/overload_null_runme.js | 49 +++++++++++++++++++ Lib/javascript/jsc/javascriptrun.swg | 2 +- Lib/javascript/v8/javascriptrun.swg | 2 +- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/javascript/overload_null_runme.js diff --git a/Examples/test-suite/javascript/overload_null_runme.js b/Examples/test-suite/javascript/overload_null_runme.js new file mode 100644 index 000000000..f1e35cac7 --- /dev/null +++ b/Examples/test-suite/javascript/overload_null_runme.js @@ -0,0 +1,49 @@ +// There are no typecheck typemaps in Javascript yet, so most of this test +// does not actually worked - the check functions have thus been commented out. +var overload_null = require("overload_null"); + +var check = function(expected, actual) { + if (expected !== actual) { + throw new Error(a + " does not equal " + b); + } +}; + + +var o = new overload_null.Overload(); +var x = new overload_null.X(); + +check(1, o.byval1(x)); +// check(2, o.byval1(null)); + +// check(3, o.byval2(null)); +check(4, o.byval2(x)); + +check(5, o.byref1(x)); +// check(6, o.byref1(null)); + +// check(7, o.byref2(null)); +check(8, o.byref2(x)); + +check(9, o.byconstref1(x)); +// check(10, o.byconstref1(null)); + +// check(11, o.byconstref2(null)); +check(12, o.byconstref2(x)); + +// const pointer references +check(13, o.byval1cpr(x)); +// check(14, o.byval1cpr(null)); + +// check(15, o.byval2cpr(null)); +check(16, o.byval2cpr(x)); + +// forward class declaration +check(17, o.byval1forwardptr(x)); +// check(18, o.byval1forwardptr(null)); + +// check(19, o.byval2forwardptr(null)); +check(20, o.byval2forwardptr(x)); + +check(21, o.byval1forwardref(x)); + +check(22, o.byval2forwardref(x)); diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg index 30ee032ed..4a8fc5be5 100644 --- a/Lib/javascript/jsc/javascriptrun.swg +++ b/Lib/javascript/jsc/javascriptrun.swg @@ -150,7 +150,7 @@ SWIGRUNTIME int SWIG_JSC_ConvertPtr(JSContextRef context, JSValueRef valRef, voi /* special case: JavaScript null => C NULL pointer */ if(JSValueIsNull(context, valRef)) { *ptr=0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } if(!JSValueIsObject(context, valRef)) { diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 39b0362a3..84bd4cc67 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -347,7 +347,7 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle valRef, void **ptr, swi /* special case: JavaScript null => C NULL pointer */ if(valRef->IsNull()) { *ptr=0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } if(!valRef->IsObject()) { return SWIG_TypeError; From cd7772a274a889cf96523fb1ebcc99d1390a177e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 10:54:53 +0000 Subject: [PATCH 1235/2031] Fix overloading for non-pointers and NULL - Lua --- .../test-suite/lua/overload_null_runme.lua | 41 +++++++++++++++++++ Lib/lua/luarun.swg | 7 +++- Lib/lua/luaruntime.swg | 5 ++- Lib/lua/luatypemaps.swg | 10 ++--- 4 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/lua/overload_null_runme.lua diff --git a/Examples/test-suite/lua/overload_null_runme.lua b/Examples/test-suite/lua/overload_null_runme.lua new file mode 100644 index 000000000..69b7de2db --- /dev/null +++ b/Examples/test-suite/lua/overload_null_runme.lua @@ -0,0 +1,41 @@ +require("import") -- the import fn +import("overload_null") -- import lib into global + +o = overload_null.Overload() +x = overload_null.X() + +assert(1 == o:byval1(x)) +assert(2 == o:byval1(nil)) + +assert(3 == o:byval2(nil)) +assert(4 == o:byval2(x)) + +assert(5 == o:byref1(x)) +assert(6 == o:byref1(nil)) + +assert(7 == o:byref2(nil)) +assert(8 == o:byref2(x)) + +assert(9 == o:byconstref1(x)) +assert(10 == o:byconstref1(nil)) + +assert(11 == o:byconstref2(nil)) +assert(12 == o:byconstref2(x)) + +-- const pointer references +assert(13 == o:byval1cpr(x)) +assert(14 == o:byval1cpr(nil)) + +assert(15 == o:byval2cpr(nil)) +assert(16 == o:byval2cpr(x)) + +-- forward class declaration +assert(17 == o:byval1forwardptr(x)) +assert(18 == o:byval1forwardptr(nil)) + +assert(19 == o:byval2forwardptr(nil)) +assert(20 == o:byval2forwardptr(x)) + +assert(21 == o:byval1forwardref(x)) + +assert(22 == o:byval2forwardref(x)) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 58ada4d6f..9636cdc9b 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1765,7 +1765,12 @@ SWIGRUNTIME int SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type { swig_lua_userdata *usr; swig_cast_info *cast; - if (lua_isnil(L,index)){*ptr=0; return SWIG_OK;} /* special case: lua nil => NULL pointer */ + /* special case: lua nil => NULL pointer */ + if (lua_isnil(L,index)) + { + *ptr=0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; + } usr=(swig_lua_userdata*)lua_touserdata(L,index); /* get data */ if (usr) { diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index 8df46e8cb..399bb640e 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -4,8 +4,9 @@ * all the runtime code for . * ----------------------------------------------------------------------------- */ -%runtime "swigrun.swg"; /* Common C API type-checking code */ -%runtime "luarun.swg"; /* Lua runtime stuff */ +%runtime "swigrun.swg" /* Common C API type-checking code */ +%runtime "swigerrors.swg" /* SWIG errors */ +%runtime "luarun.swg" /* Lua runtime stuff */ %insert(initbeforefunc) "swiginit.swg" diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index 4c68d1d1d..8959f201e 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -189,7 +189,7 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) { // Also needed for object ptrs by const ref // eg A* const& ref_pointer(A* const& a); // found in mixed_types.i -%typemap(in,checkfn="lua_isuserdata") SWIGTYPE *const&($*ltype temp) +%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE *const&($*ltype temp) %{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname"); $1=($1_ltype)&temp;%} @@ -327,7 +327,7 @@ parameters match which function %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr; - if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { $1 = 1; @@ -336,7 +336,7 @@ parameters match which function %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr; - if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, 0)) { + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { $1 = 1; @@ -345,7 +345,7 @@ parameters match which function %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; - if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, 0)) { + if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { $1 = 1; @@ -367,7 +367,7 @@ parameters match which function %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *ptr; - if (lua_isuserdata(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { + if (SWIG_isptrtype(L,$input)==0 || SWIG_ConvertPtr(L,$input, (void **) &ptr, $*descriptor, 0)) { $1 = 0; } else { $1 = 1; From e354ba8cdc534c1c06dc9c87d48c656bbd15c84c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 11:25:41 +0000 Subject: [PATCH 1236/2031] Fix overloading for non-pointers and NULL - Octave --- .../test-suite/octave/overload_null_runme.m | 52 +++++++++++++++++++ Lib/octave/octrun.swg | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/octave/overload_null_runme.m diff --git a/Examples/test-suite/octave/overload_null_runme.m b/Examples/test-suite/octave/overload_null_runme.m new file mode 100644 index 000000000..a7c346c26 --- /dev/null +++ b/Examples/test-suite/octave/overload_null_runme.m @@ -0,0 +1,52 @@ +# do not dump Octave core +if exist("crash_dumps_octave_core", "builtin") + crash_dumps_octave_core(0); +endif + +overload_null + +function check(a, b) + if (a != b) + error("%i does not equal %i", a, b); + endif +end + +o = Overload(); +x = X(); +null = []; # NULL pointer + +check(1, o.byval1(x)); +check(2, o.byval1(null)); + +check(3, o.byval2(null)); +check(4, o.byval2(x)); + +check(5, o.byref1(x)); +check(6, o.byref1(null)); + +check(7, o.byref2(null)); +check(8, o.byref2(x)); + +check(9, o.byconstref1(x)); +check(10, o.byconstref1(null)); + +check(11, o.byconstref2(null)); +check(12, o.byconstref2(x)); + +# const pointer references +check(13, o.byval1cpr(x)); +check(14, o.byval1cpr(null)); + +check(15, o.byval2cpr(null)); +check(16, o.byval2cpr(x)); + +# forward class declaration +check(17, o.byval1forwardptr(x)); +check(18, o.byval1forwardptr(null)); + +check(19, o.byval2forwardptr(null)); +check(20, o.byval2forwardptr(x)); + +check(21, o.byval1forwardref(x)); + +check(22, o.byval2forwardref(x)); diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index feed973cc..301233103 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1477,7 +1477,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_t (ov.is_matrix_type() && ov.rows() == 0 && ov.columns() == 0) ) { if (ptr) *ptr = 0; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } if (ov.type_id() != octave_swig_ref::static_type_id()) return SWIG_ERROR; From b7db45661a909c79ac4e3b47e3376d4b59397dcd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 12:00:49 +0000 Subject: [PATCH 1237/2031] Fix overloading for non-pointers and NULL - Php --- .../test-suite/php/overload_null_runme.php | 46 +++++++++++++++++++ Lib/php/php.swg | 13 ++++-- Lib/php/phprun.swg | 2 +- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/php/overload_null_runme.php diff --git a/Examples/test-suite/php/overload_null_runme.php b/Examples/test-suite/php/overload_null_runme.php new file mode 100644 index 000000000..22824d4fb --- /dev/null +++ b/Examples/test-suite/php/overload_null_runme.php @@ -0,0 +1,46 @@ +byval1($x), "test 1"); +check::equal(2, $o->byval1(null), "test 2"); + +check::equal(3, $o->byval2(null), "test 3"); +check::equal(4, $o->byval2($x), "test 4"); + +check::equal(5, $o->byref1($x), "test 5"); +check::equal(6, $o->byref1(null), "test 6"); + +check::equal(7, $o->byref2(null), "test 7"); +check::equal(8, $o->byref2($x), "test 8"); + +check::equal(9, $o->byconstref1($x), "test 9"); +check::equal(10, $o->byconstref1(null), "test 10"); + +check::equal(11, $o->byconstref2(null), "test 11"); +check::equal(12, $o->byconstref2($x), "test 12"); + +# const pointer references +check::equal(13, $o->byval1cpr($x), "test 13"); +check::equal(14, $o->byval1cpr(null), "test 14"); + +check::equal(15, $o->byval2cpr(null), "test 15"); +check::equal(16, $o->byval2cpr($x), "test 16"); + +# forward class declaration +check::equal(17, $o->byval1forwardptr($x), "test 17"); +check::equal(18, $o->byval1forwardptr(null), "test 18"); + +check::equal(19, $o->byval2forwardptr(null), "test 19"); +check::equal(20, $o->byval2forwardptr($x), "test 20"); + +check::equal(21, $o->byval1forwardref($x), "test 21"); + +check::equal(22, $o->byval2forwardref($x), "test 22"); + +check::done(); +?> diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 83f76217a..97cbf68c4 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -5,6 +5,7 @@ * ----------------------------------------------------------------------------- */ %runtime "swigrun.swg" // Common C API type-checking code +%runtime "swigerrors.swg" // SWIG errors %runtime "phprun.swg" // PHP runtime functions %include // PHP initialization routine. @@ -470,20 +471,26 @@ %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *tmp; - _v = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, 0) >= 0); + _v = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, SWIG_POINTER_NO_NULL) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], - SWIGTYPE &, - SWIGTYPE &&, SWIGTYPE *const& { void *tmp; _v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, 0) >= 0); } +%typecheck(SWIG_TYPECHECK_POINTER) + SWIGTYPE &, + SWIGTYPE && +{ + void *tmp; + _v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, SWIG_POINTER_NO_NULL) >= 0); +} + %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *tmp; diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 3aa75ca1c..44276acc5 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -217,7 +217,7 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) { return (*ptr == NULL ? -1 : 0); case IS_NULL: *ptr = 0; - return 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } return -1; From f181d20dd1367ca5d3b961ca197631c65e7bdd83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 13:46:51 +0000 Subject: [PATCH 1238/2031] Fix overloading for non-pointers and NULL - R --- Examples/test-suite/r/overload_null_runme.R | 49 +++++++++++++++++++++ Lib/r/r.swg | 2 +- Lib/r/rrun.swg | 2 +- Source/Modules/r.cxx | 38 +++++++--------- 4 files changed, 66 insertions(+), 25 deletions(-) create mode 100644 Examples/test-suite/r/overload_null_runme.R diff --git a/Examples/test-suite/r/overload_null_runme.R b/Examples/test-suite/r/overload_null_runme.R new file mode 100644 index 000000000..d187a1fbb --- /dev/null +++ b/Examples/test-suite/r/overload_null_runme.R @@ -0,0 +1,49 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("overload_null", .Platform$dynlib.ext, sep="")) +source("overload_null.R") +cacheMetaData(1) + +o <- Overload() +x <- X() + +unittest(1, o$byval1(x)) +unittest(2, o$byval1(NULL)) + +unittest(3, o$byval2(NULL)) +unittest(4, o$byval2(x)) + +unittest(5, o$byref1(x)) +unittest(6, o$byref1(NULL)) + +unittest(7, o$byref2(NULL)) +unittest(8, o$byref2(x)) + +unittest(9, o$byconstref1(x)) +unittest(10, o$byconstref1(NULL)) + +unittest(11, o$byconstref2(NULL)) +unittest(12, o$byconstref2(x)) + +# const pointer references +# No SWIGTYPE *const& typemaps for R yet +#unittest(13, o$byval1cpr(x)) +#unittest(14, o$byval1cpr(NULL)) + +#unittest(15, o$byval2cpr(NULL)) +#unittest(16, o$byval2cpr(x)) + +# forward class declaration +unittest(17, o$byval1forwardptr(x)) +unittest(18, o$byval1forwardptr(NULL)) + +unittest(19, o$byval2forwardptr(NULL)) +unittest(20, o$byval2forwardptr(x)) + +unittest(21, o$byval1forwardref(x)) + +unittest(22, o$byval2forwardref(x)) + +q(save="no") + diff --git a/Lib/r/r.swg b/Lib/r/r.swg index cf1cfc8f9..a9035331b 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -3,9 +3,9 @@ %insert("header") "swiglabels.swg" -%insert("header") "swigerrors.swg" %insert("init") "swiginit.swg" %insert("runtime") "swigrun.swg" +%insert("runtime") "swigerrors.swg" %insert("runtime") "rrun.swg" %init %{ diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index 8067f0a18..c341321a1 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -278,7 +278,7 @@ SWIG_R_ConvertPtr(SEXP obj, void **ptr, swig_type_info *ty, int flags) { if (!obj) return SWIG_ERROR; if (obj == R_NilValue) { if (ptr) *ptr = NULL; - return SWIG_OK; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } vptr = R_ExternalPtrAddr(obj); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index a82b8d15a..019d5dd66 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1664,37 +1664,29 @@ void R::dispatchFunction(Node *n) { Printf(stdout, "%s\n", tmcheck); } Printf(f->code, "%s(%s)", - j == 0? "" : " && ", + j == 0 ? "" : " && ", tmcheck); p = Getattr(p, "tmap:in:next"); continue; } + // Below should be migrated into rtypecheck typemaps if (tm) { - if (Strcmp(tm,"numeric")==0) { - Printf(f->code, "%sis.numeric(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); - } - else if (Strcmp(tm,"integer")==0) { - Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", - j == 0 ? "" : " && ", - j+1, j+1); - } - else if (Strcmp(tm,"character")==0) { - Printf(f->code, "%sis.character(argv[[%d]])", - j == 0 ? "" : " && ", - j+1); - } - else { - Printf(f->code, "%sextends(argtypes[%d], '%s')", - j == 0 ? "" : " && ", - j+1, - tm); + Printf(f->code, "%s", j == 0 ? "" : " && "); + if (Strcmp(tm, "numeric") == 0) { + Printf(f->code, "is.numeric(argv[[%d]])", j+1); + } else if (Strcmp(tm, "integer") == 0) { + Printf(f->code, "(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))", j+1, j+1); + } else if (Strcmp(tm, "character") == 0) { + Printf(f->code, "is.character(argv[[%d]])", j+1); + } else { + if (SwigType_ispointer(Getattr(p, "type"))) + Printf(f->code, "(extends(argtypes[%d], '%s') || is.null(argv[[%d]]))", j+1, tm, j+1); + else + Printf(f->code, "extends(argtypes[%d], '%s')", j+1, tm); } } if (!SwigType_ispointer(Getattr(p, "type"))) { - Printf(f->code, " && length(argv[[%d]]) == 1", - j+1); + Printf(f->code, " && length(argv[[%d]]) == 1", j+1); } p = Getattr(p, "tmap:in:next"); } From b48339cfcafb95ef6bdbe27f75ea087432ac267e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 14:22:13 +0000 Subject: [PATCH 1239/2031] Fix overloading for non-pointers and NULL - Scilab --- .../test-suite/scilab/overload_null_runme.sci | 45 +++++++++++++++++++ Lib/scilab/scirun.swg | 5 ++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/scilab/overload_null_runme.sci diff --git a/Examples/test-suite/scilab/overload_null_runme.sci b/Examples/test-suite/scilab/overload_null_runme.sci new file mode 100644 index 000000000..e3939ac5c --- /dev/null +++ b/Examples/test-suite/scilab/overload_null_runme.sci @@ -0,0 +1,45 @@ +exec("swigtest.start", -1); + +NULL = SWIG_ptr(0); + +o = new_Overload(); +x = new_X(); + +checkequal(1, Overload_byval1(o, x), "test 1"); +checkequal(2, Overload_byval1(o, NULL), "test 2"); + +checkequal(3, Overload_byval2(o, NULL), "test 3"); +checkequal(4, Overload_byval2(o, x), "test 4"); + +checkequal(5, Overload_byref1(o, x), "test 5"); +checkequal(6, Overload_byref1(o, NULL), "test 6"); + +checkequal(7, Overload_byref2(o, NULL), "test 7"); +checkequal(8, Overload_byref2(o, x), "test 8"); + +checkequal(9, Overload_byconstref1(o, x), "test 9"); +checkequal(10, Overload_byconstref1(o, NULL), "test 10"); + +checkequal(11, Overload_byconstref2(o, NULL), "test 11"); +checkequal(12, Overload_byconstref2(o, x), "test 12"); + +// const pointer references +checkequal(13, Overload_byval1cpr(o, x), "test 13"); +checkequal(14, Overload_byval1cpr(o, NULL), "test 14"); + +checkequal(15, Overload_byval2cpr(o, NULL), "test 15"); +checkequal(16, Overload_byval2cpr(o, x), "test 16"); + +// forward class declaration +checkequal(17, Overload_byval1forwardptr(o, x), "test 17"); +checkequal(18, Overload_byval1forwardptr(o, NULL), "test 18"); + +checkequal(19, Overload_byval2forwardptr(o, NULL), "test 19"); +checkequal(20, Overload_byval2forwardptr(o, x), "test 20"); + +checkequal(21, Overload_byval1forwardref(o, x), "test 21"); + +checkequal(22, Overload_byval2forwardref(o, x), "test 22"); + +exec("swigtest.quit", -1); + diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg index c1880d32c..51df9a59e 100644 --- a/Lib/scilab/scirun.swg +++ b/Lib/scilab/scirun.swg @@ -303,7 +303,10 @@ SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pvObj, swig_type_info *de if (pvObj) { *pvObj = pvPtr; - return SWIG_OK; + if (pvPtr) + return SWIG_OK; + else + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { return SWIG_ERROR; From cbc1f7f1712831898c3a4c6d4c68158cf94e8389 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 17:02:58 +0000 Subject: [PATCH 1240/2031] Overloading for non-pointers and NULL - Chicken Rework this to be consistent with other target languages --- Lib/chicken/chicken.swg | 22 ++++++++++------------ Lib/chicken/chickenrun.swg | 1 + 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index 571c392ea..7df676754 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -11,8 +11,9 @@ #include %} -%insert(runtime) "swigrun.swg"; // Common C API type-checking code -%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code +%insert(runtime) "swigrun.swg" // Common C API type-checking code +%insert(runtime) "swigerrors.swg" // SWIG errors +%insert(runtime) "chickenrun.swg" // CHICKEN run-time code /* ----------------------------------------------------------------------------- * standard typemaps @@ -617,7 +618,7 @@ $result = C_SCHEME_UNDEFINED; $1 = C_swig_is_string ($input); } -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { void *ptr; $1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0); } @@ -630,33 +631,30 @@ $result = C_SCHEME_UNDEFINED; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE & { void *ptr = 0; - if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { - /* error */ + if (SWIG_ConvertPtr($input, &ptr, $descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { - $1 = (ptr != 0); + $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE && { void *ptr = 0; - if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) { - /* error */ + if (SWIG_ConvertPtr($input, &ptr, $descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { - $1 = (ptr != 0); + $1 = 1; } } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr = 0; - if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) { - /* error */ + if (SWIG_ConvertPtr($input, &ptr, $&descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { - $1 = (ptr != 0); + $1 = 1; } } diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index f13400181..d4255c365 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -265,6 +265,7 @@ SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags if (s == C_SCHEME_FALSE) { *result = NULL; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else if (C_swig_is_swigpointer(s)) { /* try and convert type */ from = (swig_type_info *) C_block_item(s, 1); From 330201018a543cc8595e05a88ada717b2686e7aa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 30 Dec 2018 17:12:33 +0000 Subject: [PATCH 1241/2031] Fix overloading for non-pointers and NULL - MzScheme --- Lib/mzscheme/mzrun.swg | 2 +- Lib/mzscheme/mzscheme.swg | 1 + Lib/mzscheme/typemaps.i | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/mzscheme/mzrun.swg b/Lib/mzscheme/mzrun.swg index 06447d78d..c438c9ce8 100644 --- a/Lib/mzscheme/mzrun.swg +++ b/Lib/mzscheme/mzrun.swg @@ -158,7 +158,7 @@ SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type, if (SCHEME_NULLP(s)) { *result = NULL; - return 0; + return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else if (SCHEME_TYPE(s) == swig_type) { struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) s; if (type) { diff --git a/Lib/mzscheme/mzscheme.swg b/Lib/mzscheme/mzscheme.swg index 9ae242845..f45c87250 100644 --- a/Lib/mzscheme/mzscheme.swg +++ b/Lib/mzscheme/mzscheme.swg @@ -7,6 +7,7 @@ /* Include headers */ %runtime "swigrun.swg" // Common C API type-checking code +%runtime "swigerrors.swg" // SWIG errors %runtime "mzrun.swg" %define SWIG_APPEND_VALUE(value) diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index 9346349bd..09bda2cca 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -329,7 +329,7 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double, $1 = (SCHEME_STRINGP($input)) ? 1 : 0; } -%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [] { void *ptr; if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, 0)) { $1 = 0; @@ -338,9 +338,18 @@ REF_MAP(double, SCHEME_REALP, scheme_real_to_double, } } +%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &, SWIGTYPE && { + void *ptr; + if (SWIG_ConvertPtr($input, (void **) &ptr, $1_descriptor, SWIG_POINTER_NO_NULL)) { + $1 = 0; + } else { + $1 = 1; + } +} + %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *ptr; - if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, 0)) { + if (SWIG_ConvertPtr($input, (void **) &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL)) { $1 = 0; } else { $1 = 1; From 5c19f4de2f4ff33ffb430e79aa3cc796630c2d3b Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 31 Dec 2018 05:55:10 -0700 Subject: [PATCH 1242/2031] [OCaml] Add missing warning filters for OCaml keywords in the test suite --- Examples/test-suite/constant_directive.i | 4 ++++ Examples/test-suite/cpp_namespace.i | 4 ++++ Examples/test-suite/default_arg_expressions.i | 4 ++++ Examples/test-suite/default_args.i | 4 ++++ Examples/test-suite/derived_byvalue.i | 4 ++++ Examples/test-suite/director_basic.i | 4 ++++ Examples/test-suite/director_classes.i | 4 ++++ Examples/test-suite/director_overload.i | 4 ++++ Examples/test-suite/director_property.i | 4 ++++ Examples/test-suite/director_thread.i | 4 ++++ Examples/test-suite/extend.i | 4 ++++ Examples/test-suite/features.i | 4 ++++ Examples/test-suite/li_boost_shared_ptr_bits.i | 4 ++++ Examples/test-suite/li_std_map.i | 4 ++++ Examples/test-suite/li_std_vector_ptr.i | 4 ++++ Examples/test-suite/nested_structs.i | 4 ++++ Examples/test-suite/nested_template_base.i | 4 ++++ Examples/test-suite/overload_arrays.i | 3 +++ Examples/test-suite/overload_method.i | 5 +++++ Examples/test-suite/overload_simple.i | 4 ++++ Examples/test-suite/preproc.i | 5 +++++ Examples/test-suite/pure_virtual.i | 4 ++++ Examples/test-suite/static_const_member_2.i | 4 ++++ Examples/test-suite/template_default_class_parms.i | 4 ++++ Examples/test-suite/template_default_class_parms_typedef.i | 4 ++++ Examples/test-suite/template_typedef_class_template.i | 4 ++++ Examples/test-suite/template_typemaps.i | 4 ++++ Examples/test-suite/template_typemaps_typedef.i | 4 ++++ Examples/test-suite/template_typemaps_typedef2.i | 4 ++++ Examples/test-suite/typemap_delete.i | 4 ++++ Examples/test-suite/valuewrapper_opaque.i | 4 ++++ Examples/test-suite/virtual_poly.i | 4 ++++ 32 files changed, 129 insertions(+) diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i index 89f13cecc..b102ffea2 100644 --- a/Examples/test-suite/constant_directive.i +++ b/Examples/test-suite/constant_directive.i @@ -2,6 +2,10 @@ // %constant and struct +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ #if defined(_MSC_VER) #pragma warning(disable : 4190) // warning C4190: 'result' has C-linkage specified, but returns UDT 'Type1' which is incompatible with C diff --git a/Examples/test-suite/cpp_namespace.i b/Examples/test-suite/cpp_namespace.i index d7bf95e9f..a415917db 100644 --- a/Examples/test-suite/cpp_namespace.i +++ b/Examples/test-suite/cpp_namespace.i @@ -2,6 +2,10 @@ %module cpp_namespace +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %inline %{ typedef int Bad; diff --git a/Examples/test-suite/default_arg_expressions.i b/Examples/test-suite/default_arg_expressions.i index ca2a27e33..d83dc05bc 100644 --- a/Examples/test-suite/default_arg_expressions.i +++ b/Examples/test-suite/default_arg_expressions.i @@ -1,5 +1,9 @@ %module default_arg_expressions +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) ptr; %warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) UsdGeomTokensPtr; %immutable UsdGeomTokens; diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 450a8c7bf..6b680f561 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -2,6 +2,10 @@ %module default_args +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %{ #if defined(_MSC_VER) #pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned diff --git a/Examples/test-suite/derived_byvalue.i b/Examples/test-suite/derived_byvalue.i index a251a8fc6..21de809a5 100644 --- a/Examples/test-suite/derived_byvalue.i +++ b/Examples/test-suite/derived_byvalue.i @@ -1,5 +1,9 @@ %module derived_byvalue +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %inline %{ struct Foo { diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index a8399d699..07d627589 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -1,5 +1,9 @@ %module(directors="1") director_basic +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; %{ diff --git a/Examples/test-suite/director_classes.i b/Examples/test-suite/director_classes.i index 8b54d8b9d..52342bfc8 100644 --- a/Examples/test-suite/director_classes.i +++ b/Examples/test-suite/director_classes.i @@ -5,6 +5,10 @@ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::Ptr; %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Base::ConstPtrRef; +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %module(directors="1") director_classes %feature("director") Base; diff --git a/Examples/test-suite/director_overload.i b/Examples/test-suite/director_overload.i index 55bdf2caa..604ffe5ca 100644 --- a/Examples/test-suite/director_overload.i +++ b/Examples/test-suite/director_overload.i @@ -1,5 +1,9 @@ %module(directors="1") director_overload +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %feature("director"); #ifdef SWIGPYTHON diff --git a/Examples/test-suite/director_property.i b/Examples/test-suite/director_property.i index da37ca4ae..d64e0c439 100644 --- a/Examples/test-suite/director_property.i +++ b/Examples/test-suite/director_property.i @@ -2,6 +2,10 @@ %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %{ #include diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index c4f08f4f9..c4564737f 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -7,6 +7,10 @@ %module(directors="1") director_thread #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %begin %{ #define SWIG_JAVA_USE_THREAD_NAME //#define DEBUG_DIRECTOR_THREAD_NAME diff --git a/Examples/test-suite/extend.i b/Examples/test-suite/extend.i index 29e258f5b..ab0c651a5 100644 --- a/Examples/test-suite/extend.i +++ b/Examples/test-suite/extend.i @@ -1,5 +1,9 @@ %module extend +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %extend Base { ~Base() { delete $self; diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i index 2ccbe725a..a8b56527d 100644 --- a/Examples/test-suite/features.i +++ b/Examples/test-suite/features.i @@ -2,6 +2,10 @@ %warnfilter(SWIGWARN_LANG_IDENTIFIER,SWIGWARN_IGNORE_OPERATOR_PLUSEQ); +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + // This testcase checks that %feature is working for templates and non user supplied constructors/destructors and is just generally working // If the default %exception is used it will not compile. It shouldn't get used. diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i index b61fd2aa6..7cf84010e 100644 --- a/Examples/test-suite/li_boost_shared_ptr_bits.i +++ b/Examples/test-suite/li_boost_shared_ptr_bits.i @@ -4,6 +4,10 @@ #define SHARED_PTR_WRAPPERS_IMPLEMENTED #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + #if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED) %include diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 238cc3393..161ec6aca 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -1,6 +1,10 @@ %module("templatereduce") li_std_map %feature("trackobjects"); +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ namespace another { struct map { diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i index 4d6794717..8c3b71e65 100644 --- a/Examples/test-suite/li_std_vector_ptr.i +++ b/Examples/test-suite/li_std_vector_ptr.i @@ -5,6 +5,10 @@ %template(IntPtrVector) std::vector; +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ #include using namespace std; diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i index c70924958..48bd9f2b9 100644 --- a/Examples/test-suite/nested_structs.i +++ b/Examples/test-suite/nested_structs.i @@ -12,6 +12,10 @@ #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + // bug #491476 %inline %{ struct Outer { diff --git a/Examples/test-suite/nested_template_base.i b/Examples/test-suite/nested_template_base.i index 0b0272224..4d99e8af5 100644 --- a/Examples/test-suite/nested_template_base.i +++ b/Examples/test-suite/nested_template_base.i @@ -1,5 +1,9 @@ %module nested_template_base +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ template class OuterT { public: diff --git a/Examples/test-suite/overload_arrays.i b/Examples/test-suite/overload_arrays.i index 25007e2bd..272c96a3d 100644 --- a/Examples/test-suite/overload_arrays.i +++ b/Examples/test-suite/overload_arrays.i @@ -18,6 +18,9 @@ %rename(Foos) Foo; #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) type; +#endif %immutable Spam::type; diff --git a/Examples/test-suite/overload_method.i b/Examples/test-suite/overload_method.i index 8b44b8172..f282df6e2 100644 --- a/Examples/test-suite/overload_method.i +++ b/Examples/test-suite/overload_method.i @@ -1,6 +1,11 @@ /* This test confirms the fix to sourceforge bug #3478922 for R */ %module overload_method + +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %inline %{ class Base { diff --git a/Examples/test-suite/overload_simple.i b/Examples/test-suite/overload_simple.i index 00079f203..ba1900b40 100644 --- a/Examples/test-suite/overload_simple.i +++ b/Examples/test-suite/overload_simple.i @@ -19,6 +19,10 @@ %rename(Foos) Foo; #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) type; +#endif + %immutable Spam::type; %inline %{ diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 3239798f7..215fdd0ef 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -21,6 +21,11 @@ #endif %} +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + /* check __cplusplus case */ %header %{ diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index 9e345e2a4..c1c7edc15 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -12,6 +12,10 @@ SWIGWARN_D_MULTIPLE_INHERITANCE, SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */ +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %nodefaultctor C; %nodefaultdtor C; %nodefaultctor E; diff --git a/Examples/test-suite/static_const_member_2.i b/Examples/test-suite/static_const_member_2.i index 0b6d38d21..0b38b394b 100644 --- a/Examples/test-suite/static_const_member_2.i +++ b/Examples/test-suite/static_const_member_2.i @@ -4,6 +4,10 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::CavityPackFlags::backward_field; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) oss::modules::Test::current_profile; +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ namespace oss { diff --git a/Examples/test-suite/template_default_class_parms.i b/Examples/test-suite/template_default_class_parms.i index d07a1309f..02e993f32 100644 --- a/Examples/test-suite/template_default_class_parms.i +++ b/Examples/test-suite/template_default_class_parms.i @@ -1,5 +1,9 @@ %module template_default_class_parms +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %inline %{ namespace Space { struct SomeType {}; diff --git a/Examples/test-suite/template_default_class_parms_typedef.i b/Examples/test-suite/template_default_class_parms_typedef.i index 0767498bf..748b23cbb 100644 --- a/Examples/test-suite/template_default_class_parms_typedef.i +++ b/Examples/test-suite/template_default_class_parms_typedef.i @@ -4,6 +4,10 @@ %feature("python:nondynamic"); +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %inline %{ namespace Space { struct SomeType {}; diff --git a/Examples/test-suite/template_typedef_class_template.i b/Examples/test-suite/template_typedef_class_template.i index fc8151ff0..e391c6a3a 100644 --- a/Examples/test-suite/template_typedef_class_template.i +++ b/Examples/test-suite/template_typedef_class_template.i @@ -1,5 +1,9 @@ %module template_typedef_class_template +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ namespace Standard { template struct Pair { diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i index d01945460..38a9c66de 100644 --- a/Examples/test-suite/template_typemaps.i +++ b/Examples/test-suite/template_typemaps.i @@ -25,6 +25,10 @@ %typemap(out) Integer2 { /* do nothing */ } #endif +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %{ typedef int Integer1; %} diff --git a/Examples/test-suite/template_typemaps_typedef.i b/Examples/test-suite/template_typemaps_typedef.i index 022fe884f..44c485dfb 100644 --- a/Examples/test-suite/template_typemaps_typedef.i +++ b/Examples/test-suite/template_typemaps_typedef.i @@ -2,6 +2,10 @@ // Similar to template_typedef_class_template // Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ namespace Standard { template struct Pair { diff --git a/Examples/test-suite/template_typemaps_typedef2.i b/Examples/test-suite/template_typemaps_typedef2.i index 64055c4ea..443fa3627 100644 --- a/Examples/test-suite/template_typemaps_typedef2.i +++ b/Examples/test-suite/template_typemaps_typedef2.i @@ -4,6 +4,10 @@ // Similar to template_typedef_class_template // Testing typemaps of a typedef of a nested class in a template and where the template uses default parameters +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %inline %{ namespace Standard { template struct Pair { diff --git a/Examples/test-suite/typemap_delete.i b/Examples/test-suite/typemap_delete.i index eb6abe73c..fa62803cb 100644 --- a/Examples/test-suite/typemap_delete.i +++ b/Examples/test-suite/typemap_delete.i @@ -1,5 +1,9 @@ %module typemap_delete +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) val; +#endif + %typemap(in) Rect* (Rect temp) { $1 = 0; will_not_compile diff --git a/Examples/test-suite/valuewrapper_opaque.i b/Examples/test-suite/valuewrapper_opaque.i index 52da89391..bc7ba8683 100644 --- a/Examples/test-suite/valuewrapper_opaque.i +++ b/Examples/test-suite/valuewrapper_opaque.i @@ -4,6 +4,10 @@ * Opaque types */ +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + %feature("valuewrapper") C; class C; diff --git a/Examples/test-suite/virtual_poly.i b/Examples/test-suite/virtual_poly.i index 5f2f1d201..8b500539e 100644 --- a/Examples/test-suite/virtual_poly.i +++ b/Examples/test-suite/virtual_poly.i @@ -13,6 +13,10 @@ #endif %} +#ifdef SWIGOCAML +%warnfilter(SWIGWARN_PARSE_KEYWORD) method; +#endif + // // Check this example with directors wherever possible. // From 3c2b8d23ef0c663cf21ddb2b3dbc895490fd2aa5 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Mon, 31 Dec 2018 15:55:59 +0100 Subject: [PATCH 1243/2031] Install xml files --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index df882ce34..b2c5e8928 100644 --- a/Makefile.in +++ b/Makefile.in @@ -512,7 +512,7 @@ install-main: lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php php5 ocaml octave \ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ - javascript/v8 scilab + javascript/v8 scilab xml lib-modules = std From 07884f10eea6d4009115c4bf88bc2ddc23f8a894 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jan 2019 12:12:56 +0000 Subject: [PATCH 1244/2031] Python - remove duplicate proxy method definitions for global function wrappers. Global functions previously generated two definitions, eg: def foo(): return _example.foo() foo = _example.foo The first definition is replaced by the second definition and so the second definition is the one used when the method is actually called. Now just the first definition is generated by default and if the -fastproxy command line option is used, just the second definition is generated. The second definition is faster as it avoids the proxy Python method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs command line options will restore the previously generated code as it will generate both method definitions. With this change, the wrappers for global C/C++ functions and C++ class methods now work in the same way wrt to generating just a proxy method by default and control via -fastproxy/-olddefs options. Closes #639. --- CHANGES.current | 21 +++++++++++++++++++++ Doc/Manual/Python.html | 12 +++++++++++- Source/Modules/python.cxx | 39 +++++++++++++++++++++++++-------------- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 21cd23149..ef46ccd12 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,27 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-01: wsfulton + [Python] #639 remove duplicate proxy method definitions for global function wrappers. + + Global functions previously generated two definitions, eg: + + def foo(): + return _example.foo() + foo = _example.foo + + The first definition is replaced by the second definition and so the second definition + is the one used when the method is actually called. Now just the first definition is + generated by default and if the -fastproxy command line option is used, just the second + definition is generated. The second definition is faster as it avoids the proxy Python + method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs + command line options will restore the previously generated code as it will generate both + method definitions. + + With this change, the wrappers for global C/C++ functions and C++ class methods now work + in the same way wrt to generating just a proxy method by default and control via + -fastproxy/-olddefs options. + 2018-12-20: hasinoff,wsfulton [Java] #1334 Set Java thread name to native thread name when using directors. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index ddcd6407b..8d1678a7f 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3913,6 +3913,7 @@ class Go(object):

      +Each method in the Python class contains a Python proxy method which passes the arguments on to the underlying function in the low-level C/C++ module (_example in this case). The generated proxy class when using -fastproxy is:

      @@ -3928,7 +3929,12 @@ class Go(object):

      -where _swig_new_instance_method adds the method to the proxy class via C API calls. +where _swig_new_instance_method adds the method to the proxy class via C API calls for direct access to the underlying function in the low-level C/C++ module. +Note that for some methods it is not possible to generate the direct access call and so -fastproxy is ignored. +This happens, for example, when adding additional code to Python proxy methods, such as using %pythonprepend. +

      + +

      The overhead calling into C/C++ from Python is reduced slightly using -fastproxy. Below are some timings in microseconds calling the 3 functions in the example above. Also included in the table for comparison is using the -builtin option covered in the @@ -3995,6 +4001,10 @@ The class defines each method in two different ways. The first definition is rep While this possibly provides the best of both worlds, the time to import the module will be slighly slower when the class is defined due to the additional method definitions.

      +

      +The command line options mentioned above also apply to wrapped C/C++ global functions, not just class methods. +

      +

      38.7 Tips and techniques

      diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a0f049449..83858d44c 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2144,6 +2144,9 @@ public: if (nn) n = nn; + Parm *parms = Getattr(n, "parms"); + bool varargs = parms ? emit_isvarargs(parms) : 0; + /* We prefer to explicitly list all parameters of the C function in the generated Python code as this makes the function more convenient to use, however in some cases we must replace the real parameters list with just @@ -2153,8 +2156,9 @@ public: 2. We were explicitly asked to use the "compact" arguments form. 3. We were explicitly asked to use default args from C via the "python:cdefaultargs" feature. 4. One of the default argument values can't be represented in Python. + 5. Varargs that haven't been forced to use a fixed number of arguments with %varargs. */ - if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || GetFlag(n, "feature:python:cdefaultargs") || !is_representable_as_pyargs(n)) { + if (is_real_overloaded(n) || GetFlag(n, "feature:compactdefaultargs") || GetFlag(n, "feature:python:cdefaultargs") || !is_representable_as_pyargs(n) || varargs) { String *parms = NewString(""); if (in_class) Printf(parms, "self, "); @@ -2295,21 +2299,28 @@ 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, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); - if (have_pythonprepend(n)) - Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); - if (have_pythonappend(n)) { - Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); - Printv(f_dest, tab4 "return val\n", NIL); - } else { - Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); + + // Callbacks need the C function in order to extract the pointer from the swig_ptr: string + bool fast = (fastproxy && !have_addtofunc(n)) || Getattr(n, "feature:callback"); + + if (!fast || olddefs) { + /* Make a wrapper function to insert the code into */ + Printv(f_dest, "\n", "def ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); + if (have_docstring(n)) + Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + if (have_pythonprepend(n)) + Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); + if (have_pythonappend(n)) { + Printv(f_dest, tab4 "val = ", funcCall(name, callParms), "\n", NIL); + Printv(f_dest, indent_pythoncode(pythonappend(n), tab4, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); + Printv(f_dest, tab4 "return val\n", NIL); + } else { + Printv(f_dest, tab4 "return ", funcCall(name, callParms), "\n", NIL); + } } - if (!have_addtofunc(n)) { + // Below may result in a 2nd definition of the method when -olddefs is used. The Python interpreter will use the second definition as it overwrites the first. + if (fast) { /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); } From 5988c3bb24883e3e75681ced6d26c5f815f3783b Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 1 Jan 2019 06:28:35 -0700 Subject: [PATCH 1245/2031] [OCaml] Replace SWIGSTATIC with SWIGINTERN Use SWIGINTERN to silence unused function warnings. In addition, remove the declarations for SWIG_MustGetPtr(), wrap_delete_void(), enum_to_int(), and int_to_enum() -- these lacked definitions and caused compiler warnings. --- Lib/ocaml/ocaml.i | 4 --- Lib/ocaml/ocaml.swg | 78 +++++++++++++++++++++--------------------- Lib/ocaml/ocamldec.swg | 68 ++++++++++++++++-------------------- 3 files changed, 69 insertions(+), 81 deletions(-) diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i index e099f7c10..96a36c8b2 100644 --- a/Lib/ocaml/ocaml.i +++ b/Lib/ocaml/ocaml.i @@ -4,10 +4,6 @@ * SWIG Configuration File for Ocaml * ----------------------------------------------------------------------------- */ -%runtime %{ -#define SWIGSTATIC static -%} - /* Insert common stuff */ %insert(runtime) "swigrun.swg" diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index a00252b28..49ec2e7d5 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -31,7 +31,7 @@ extern "C" { /* Cast a pointer if possible; returns 1 if successful */ - SWIGSTATIC int + SWIGINTERN int SWIG_Cast (void *source, swig_type_info *source_type, void **ptr, swig_type_info *dest_type) { @@ -79,7 +79,7 @@ extern "C" { } /* Return 0 if successful. */ - SWIGSTATIC int + SWIGINTERN int SWIG_GetPtr(void *inptr, void **outptr, swig_type_info *intype, swig_type_info *outtype) { if (intype) { @@ -91,9 +91,9 @@ extern "C" { } } - SWIGSTATIC void caml_print_list( CAML_VALUE v ); + SWIGINTERN void caml_print_list( CAML_VALUE v ); - SWIGSTATIC void caml_print_val( CAML_VALUE v ) { + SWIGINTERN void caml_print_val( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_bool: if( Bool_val(SWIG_Field(v,0)) ) fprintf( stderr, "true " ); @@ -157,7 +157,7 @@ extern "C" { } } - SWIGSTATIC void caml_print_list( CAML_VALUE v ) { + SWIGINTERN void caml_print_list( CAML_VALUE v ) { CAMLparam1(v); while( v && Is_block(v) ) { fprintf( stderr, "[ " ); @@ -168,7 +168,7 @@ extern "C" { CAMLreturn0; } - SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { + SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ) { CAMLparam1(lst); int i = 0; while( i < n && lst && Is_block(lst) ) { @@ -178,7 +178,7 @@ extern "C" { else CAMLreturn(SWIG_Field(lst,0)); } - SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { + SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ) { CAMLparam2(lst,elt); SWIG_CAMLlocal3(v,vt,lh); lh = Val_unit; @@ -212,20 +212,20 @@ extern "C" { CAMLreturn(lh); } - SWIGSTATIC int caml_list_length( CAML_VALUE lst ) { + SWIGINTERN int caml_list_length( CAML_VALUE lst ) { CAMLparam1(lst); int i = 0; while( lst && Is_block(lst) ) { i++; lst = SWIG_Field(lst,1); } CAMLreturn(i); } - SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { + SWIGINTERN void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ) { CAMLparam2(arr,item); SWIG_Store_field(SWIG_Field(arr,0),n,item); CAMLreturn0; } - SWIGSTATIC value caml_array_nth( CAML_VALUE arr, int n ) { + SWIGINTERN value caml_array_nth( CAML_VALUE arr, int n ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(SWIG_Field(SWIG_Field(arr,0),n)); @@ -235,7 +235,7 @@ extern "C" { failwith("Need array or list"); } - SWIGSTATIC int caml_array_len( CAML_VALUE arr ) { + SWIGINTERN int caml_array_len( CAML_VALUE arr ) { CAMLparam1(arr); if( SWIG_Tag_val(arr) == C_array ) CAMLreturn(Wosize_val(SWIG_Field(arr,0))); @@ -245,11 +245,11 @@ extern "C" { failwith("Need array or list"); } - SWIGSTATIC CAML_VALUE caml_swig_alloc(int x,int y) { + SWIGINTERN CAML_VALUE caml_swig_alloc(int x,int y) { return caml_alloc(x,y); } - SWIGSTATIC value caml_array_new( int n ) { + SWIGINTERN value caml_array_new( int n ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(1,C_array); @@ -257,7 +257,7 @@ extern "C" { CAMLreturn(vv); } - SWIGSTATIC CAML_VALUE caml_val_bool( int b ) { + SWIGINTERN CAML_VALUE caml_val_bool( int b ) { CAMLparam0(); SWIG_CAMLlocal1(bv); bv = caml_swig_alloc(1,C_bool); @@ -265,7 +265,7 @@ extern "C" { CAMLreturn(bv); } - SWIGSTATIC CAML_VALUE caml_val_char( char c ) { + SWIGINTERN CAML_VALUE caml_val_char( char c ) { CAMLparam0(); SWIG_CAMLlocal1(cv); cv = caml_swig_alloc(1,C_char); @@ -273,7 +273,7 @@ extern "C" { CAMLreturn(cv); } - SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char uc ) { + SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char uc ) { CAMLparam0(); SWIG_CAMLlocal1(ucv); ucv = caml_swig_alloc(1,C_uchar); @@ -281,7 +281,7 @@ extern "C" { CAMLreturn(ucv); } - SWIGSTATIC CAML_VALUE caml_val_short( short s ) { + SWIGINTERN CAML_VALUE caml_val_short( short s ) { CAMLparam0(); SWIG_CAMLlocal1(sv); sv = caml_swig_alloc(1,C_short); @@ -289,7 +289,7 @@ extern "C" { CAMLreturn(sv); } - SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short us ) { + SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short us ) { CAMLparam0(); SWIG_CAMLlocal1(usv); usv = caml_swig_alloc(1,C_ushort); @@ -297,7 +297,7 @@ extern "C" { CAMLreturn(usv); } - SWIGSTATIC CAML_VALUE caml_val_int( int i ) { + SWIGINTERN CAML_VALUE caml_val_int( int i ) { CAMLparam0(); SWIG_CAMLlocal1(iv); iv = caml_swig_alloc(1,C_int); @@ -305,7 +305,7 @@ extern "C" { CAMLreturn(iv); } - SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int ui ) { + SWIGINTERN CAML_VALUE caml_val_uint( unsigned int ui ) { CAMLparam0(); SWIG_CAMLlocal1(uiv); uiv = caml_swig_alloc(1,C_int); @@ -313,7 +313,7 @@ extern "C" { CAMLreturn(uiv); } - SWIGSTATIC CAML_VALUE caml_val_long( long l ) { + SWIGINTERN CAML_VALUE caml_val_long( long l ) { CAMLparam0(); SWIG_CAMLlocal1(lv); lv = caml_swig_alloc(1,C_int64); @@ -321,7 +321,7 @@ extern "C" { CAMLreturn(lv); } - SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long ul ) { + SWIGINTERN CAML_VALUE caml_val_ulong( unsigned long ul ) { CAMLparam0(); SWIG_CAMLlocal1(ulv); ulv = caml_swig_alloc(1,C_int64); @@ -329,7 +329,7 @@ extern "C" { CAMLreturn(ulv); } - SWIGSTATIC CAML_VALUE caml_val_float( float f ) { + SWIGINTERN CAML_VALUE caml_val_float( float f ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_float); @@ -337,7 +337,7 @@ extern "C" { CAMLreturn(fv); } - SWIGSTATIC CAML_VALUE caml_val_double( double d ) { + SWIGINTERN CAML_VALUE caml_val_double( double d ) { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_double); @@ -345,7 +345,7 @@ extern "C" { CAMLreturn(fv); } - SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { + SWIGINTERN CAML_VALUE caml_val_ptr( void *p, swig_type_info *info ) { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(2,C_ptr); @@ -354,7 +354,7 @@ extern "C" { CAMLreturn(vv); } - SWIGSTATIC CAML_VALUE caml_val_string( const char *p ) { + SWIGINTERN CAML_VALUE caml_val_string( const char *p ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); @@ -363,7 +363,7 @@ extern "C" { CAMLreturn(vv); } - SWIGSTATIC CAML_VALUE caml_val_string_len( const char *p, int len ) { + SWIGINTERN CAML_VALUE caml_val_string_len( const char *p, int len ) { CAMLparam0(); SWIG_CAMLlocal1(vv); if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); @@ -374,14 +374,14 @@ extern "C" { } #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) - SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { + SWIGINTERN CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { CAMLparam0(); CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), caml_val_ptr(v,type), copy_string(name))); } - SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) { + SWIGINTERN long caml_long_val_full( CAML_VALUE v, char *name ) { CAMLparam1(v); if( !Is_block(v) ) return 0; @@ -417,11 +417,11 @@ extern "C" { } } - SWIGSTATIC long caml_long_val( CAML_VALUE v ) { + SWIGINTERN long caml_long_val( CAML_VALUE v ) { return caml_long_val_full(v,0); } - SWIGSTATIC double caml_double_val( CAML_VALUE v ) { + SWIGINTERN double caml_double_val( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0.0; switch( SWIG_Tag_val(v) ) { @@ -446,7 +446,7 @@ extern "C" { } } - SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + SWIGINTERN int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ) { CAMLparam1(v); void *outptr = NULL; @@ -488,7 +488,7 @@ extern "C" { CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); } - SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { + SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { CAMLparam0(); #ifdef TYPE_CAST_VERBOSE caml_print_val( v ); @@ -500,11 +500,11 @@ extern "C" { failwith( "No appropriate conversion found." ); } - SWIGSTATIC char *caml_string_val( CAML_VALUE v ) { + SWIGINTERN char *caml_string_val( CAML_VALUE v ) { return (char *)caml_ptr_val( v, 0 ); } - SWIGSTATIC int caml_string_len( CAML_VALUE v ) { + SWIGINTERN int caml_string_len( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_string: return string_length(SWIG_Field(v,0)); @@ -513,7 +513,7 @@ extern "C" { } } - SWIGSTATIC int caml_bool_check( CAML_VALUE v ) { + SWIGINTERN int caml_bool_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; @@ -528,7 +528,7 @@ extern "C" { } } - SWIGSTATIC int caml_int_check( CAML_VALUE v ) { + SWIGINTERN int caml_int_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; @@ -549,7 +549,7 @@ extern "C" { } } - SWIGSTATIC int caml_float_check( CAML_VALUE v ) { + SWIGINTERN int caml_float_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; @@ -563,7 +563,7 @@ extern "C" { } } - SWIGSTATIC int caml_ptr_check( CAML_VALUE v ) { + SWIGINTERN int caml_ptr_check( CAML_VALUE v ) { CAMLparam1(v); if( !Is_block(v) ) return 0; diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index 96e1cd2ce..dcc8784e1 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -113,54 +113,46 @@ CAMLextern int64 Int64_val(caml_value_t v); #define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else - SWIGSTATIC int + SWIGINTERN int SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); + + SWIGINTERN CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); + SWIGINTERN CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); + SWIGINTERN int caml_list_length( CAML_VALUE lst ); + SWIGINTERN CAML_VALUE caml_array_new( int n ); + SWIGINTERN void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); + SWIGINTERN CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); + SWIGINTERN int caml_array_len( CAML_VALUE arr ); + + SWIGINTERN CAML_VALUE caml_val_char( char c ); + SWIGINTERN CAML_VALUE caml_val_uchar( unsigned char c ); + + SWIGINTERN CAML_VALUE caml_val_short( short s ); + SWIGINTERN CAML_VALUE caml_val_ushort( unsigned short s ); - SWIGSTATIC void * - SWIG_MustGetPtr (CAML_VALUE v, swig_type_info *type); - - SWIGSTATIC CAML_VALUE _wrap_delete_void( CAML_VALUE ); - - SWIGSTATIC int enum_to_int( char *name, CAML_VALUE v ); - SWIGSTATIC CAML_VALUE int_to_enum( char *name, int v ); + SWIGINTERN CAML_VALUE caml_val_int( int x ); + SWIGINTERN CAML_VALUE caml_val_uint( unsigned int x ); - SWIGSTATIC CAML_VALUE caml_list_nth( CAML_VALUE lst, int n ); - SWIGSTATIC CAML_VALUE caml_list_append( CAML_VALUE lst, CAML_VALUE elt ); - SWIGSTATIC int caml_list_length( CAML_VALUE lst ); - SWIGSTATIC CAML_VALUE caml_array_new( int n ); - SWIGSTATIC void caml_array_set( CAML_VALUE arr, int n, CAML_VALUE item ); - SWIGSTATIC CAML_VALUE caml_array_nth( CAML_VALUE arr, int n ); - SWIGSTATIC int caml_array_len( CAML_VALUE arr ); + SWIGINTERN CAML_VALUE caml_val_long( long x ); + SWIGINTERN CAML_VALUE caml_val_ulong( unsigned long x ); - SWIGSTATIC CAML_VALUE caml_val_char( char c ); - SWIGSTATIC CAML_VALUE caml_val_uchar( unsigned char c ); + SWIGINTERN CAML_VALUE caml_val_float( float f ); + SWIGINTERN CAML_VALUE caml_val_double( double d ); - SWIGSTATIC CAML_VALUE caml_val_short( short s ); - SWIGSTATIC CAML_VALUE caml_val_ushort( unsigned short s ); - - SWIGSTATIC CAML_VALUE caml_val_int( int x ); - SWIGSTATIC CAML_VALUE caml_val_uint( unsigned int x ); + SWIGINTERN CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); - SWIGSTATIC CAML_VALUE caml_val_long( long x ); - SWIGSTATIC CAML_VALUE caml_val_ulong( unsigned long x ); + SWIGINTERN CAML_VALUE caml_val_string( const char *str ); + SWIGINTERN CAML_VALUE caml_val_string_len( const char *str, int len ); - SWIGSTATIC CAML_VALUE caml_val_float( float f ); - SWIGSTATIC CAML_VALUE caml_val_double( double d ); + SWIGINTERN long caml_long_val( CAML_VALUE v ); + SWIGINTERN double caml_double_val( CAML_VALUE v ); - SWIGSTATIC CAML_VALUE caml_val_ptr( void *p, swig_type_info *descriptor ); - - SWIGSTATIC CAML_VALUE caml_val_string( const char *str ); - SWIGSTATIC CAML_VALUE caml_val_string_len( const char *str, int len ); - - SWIGSTATIC long caml_long_val( CAML_VALUE v ); - SWIGSTATIC double caml_double_val( CAML_VALUE v ); - - SWIGSTATIC int caml_ptr_val_internal( CAML_VALUE v, void **out, + SWIGINTERN int caml_ptr_val_internal( CAML_VALUE v, void **out, swig_type_info *descriptor ); - SWIGSTATIC void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); + SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ); - SWIGSTATIC char *caml_string_val( CAML_VALUE v ); - SWIGSTATIC int caml_string_len( CAML_VALUE v ); + SWIGINTERN char *caml_string_val( CAML_VALUE v ); + SWIGINTERN int caml_string_len( CAML_VALUE v ); #ifdef __cplusplus } From f682490ce92b1a92c47f20b5df22ff2e9a988208 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 1 Jan 2019 09:22:36 -0700 Subject: [PATCH 1246/2031] [OCaml] Add an OCaml entry to .gitignore [skip ci] --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index a2acc0053..53b6187e7 100644 --- a/.gitignore +++ b/.gitignore @@ -158,6 +158,18 @@ Examples/java/doxygen/javadocs Examples/test-suite/javascript/*/ *.gyp +# OCaml +Examples/test-suite/ocaml/*.ml* +Examples/test-suite/ocaml/*.cm* +Examples/test-suite/ocaml/runme +!Examples/test-suite/ocaml/*runme.ml +Examples/ocaml/**/example.ml* +Examples/ocaml/**/example +Examples/ocaml/**/example_top +Examples/ocaml/**/*.cm* +Examples/ocaml/**/swig.ml* +Examples/ocaml/**/swigp4.ml + # Octave swigexample*.oct Examples/test-suite/octave/*.oct From 552760b84ba21030744ed4dc3a2ce0312aca85a7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Jan 2019 19:03:18 +0000 Subject: [PATCH 1247/2031] Turn Travis OSX Python 3 testing back on brew is working again with Python 3.7.1 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a68cb960..7f622bc85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -368,10 +368,6 @@ matrix: env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required dist: trusty - # 'brew upgrade python' failure due to conflicting files: c++ - - compiler: clang - os: osx - env: SWIGLANG=python PY3=3 # Lots of failing tests currently - compiler: gcc os: linux From 5f941bc3c7a68cd544024329e5c3ff2c11debe32 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 2 Jan 2019 01:33:53 -0700 Subject: [PATCH 1248/2031] Replace mv hack. --- Examples/test-suite/ocaml/Makefile.in | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 11d2f374a..35efc831a 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -44,16 +44,19 @@ preproc_constants_c \ string_simple \ unions \ +ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) + run_testcase = \ - if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ - -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then \ - $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(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; \ - elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - $(COMPILETOOL) $(OCAMLC) -c $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - $(foreach ext,cmo cmi,mv $(srcdir)/$(*)_runme.$(ext) $(*)_runme.$(ext) 2>/dev/null;) \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && \ - $(RUNTOOL) ./runme; \ + if [ -f $(srcdir)/$(ml_runme) ]; then \ + if [ $(srcdir) != $(SCRIPTDIR) ]; then \ + cp $(srcdir)/$(ml_runme) $(ml_runme); \ + fi ; \ + $(COMPILETOOL) $(OCAMLC) -c $(ml_runme) && \ + if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \ + $(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; \ + else \ + $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && $(RUNTOOL) ./runme; \ + fi ; \ fi ; check_quant: @@ -68,7 +71,7 @@ check_quant: include $(srcdir)/../common.mk # Overridden variables here -# none! +SCRIPTDIR = . # Custom tests - tests with additional commandline options # none! From f2a05bda8b5a4b9f04931ae072e9559227ed530c Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 2 Jan 2019 05:01:54 -0700 Subject: [PATCH 1249/2031] Don't override SCRIPTDIR. --- Examples/test-suite/ocaml/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 35efc831a..069c128b1 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -48,7 +48,7 @@ ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) run_testcase = \ if [ -f $(srcdir)/$(ml_runme) ]; then \ - if [ $(srcdir) != $(SCRIPTDIR) ]; then \ + if [ $(srcdir) != . ]; then \ cp $(srcdir)/$(ml_runme) $(ml_runme); \ fi ; \ $(COMPILETOOL) $(OCAMLC) -c $(ml_runme) && \ @@ -71,7 +71,7 @@ check_quant: include $(srcdir)/../common.mk # Overridden variables here -SCRIPTDIR = . +# none! # Custom tests - tests with additional commandline options # none! From 5be27fd69c1e3ee017fca44cdb1059020983ba3e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jan 2019 07:46:29 +0000 Subject: [PATCH 1250/2031] Make OCaml configure output more consistent with other languages --- configure.ac | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index ac9efd9d5..ad06fd42a 100644 --- a/configure.ac +++ b/configure.ac @@ -2040,7 +2040,7 @@ AC_SUBST(PHP) AC_SUBST(PHPINC) #---------------------------------------------------------------- -# Look for ocaml +# Look for OCaml #---------------------------------------------------------------- AC_ARG_WITH(ocaml, AS_HELP_STRING([--without-ocaml], [Disable OCaml]), [with_ocaml="$withval"], [with_ocaml="$alllang_default"]) @@ -2055,31 +2055,31 @@ if test x"${with_ocaml}" = xno; then AC_MSG_NOTICE([Disabling OCaml]) OCAMLC= else - AC_MSG_CHECKING(for Ocaml DL load generator) + # OCaml DL load generator if test -z "$OCAMLDLGEN"; then AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen) fi - AC_MSG_CHECKING(for Ocaml package tool) - if test -z "$OCAMLFIND"; then + # OCaml package tool + if test -z "$OCAMLFIND"; then AC_CHECK_PROGS(OCAMLFIND, ocamlfind) fi - AC_MSG_CHECKING(for Ocaml compiler) - if test -z "$OCAMLC"; then + # OCaml compiler + if test -z "$OCAMLC"; then AC_CHECK_PROGS(OCAMLC, ocamlc) fi - AC_MSG_CHECKING(for Ocaml toplevel creator) + # OCaml toplevel creator if test -z "$OCAMLMKTOP"; then AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop) fi - AC_MSG_CHECKING(for Ocaml Pre-Processor-Pretty-Printer) + # OCaml Pre-Processor-Pretty-Printer if test -z "$CAMLP4"; then AC_CHECK_PROGS(CAMLP4, camlp4) fi -fi # Disabling ocaml +fi AC_SUBST(OCAMLC) AC_SUBST(OCAMLDLGEN) From f17e993ed73107ef64855c2659090bec054e9edd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jan 2019 07:54:29 +0000 Subject: [PATCH 1251/2031] Remove some non-standard cruft from OCaml test-suite --- Examples/test-suite/ocaml/Makefile.in | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 069c128b1..879682f10 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -59,15 +59,6 @@ run_testcase = \ fi ; \ fi ; -check_quant: - : > testing - : > success - $(MAKE) check - echo "Failed:" > results - diff testing success | sed 's/^< //p;d' >> results - echo "Success:" >> results - cat success >> results - include $(srcdir)/../common.mk # Overridden variables here @@ -78,31 +69,19 @@ include $(srcdir)/../common.mk # Rules for the different types of tests %.cpptest: - echo $@ >> testing $(setup) +$(swig_and_compile_cpp) $(run_testcase) - if [ -f $(@:%.cpptest=%_wrap.o) ] ; then \ - echo $@ >> success ; \ - fi %.ctest: - echo $@ >> testing $(setup) +$(swig_and_compile_c) $(run_testcase) - if [ -f $(@:%.ctest=%_wrap.o) ] ; then \ - echo $@ >> success ; \ - fi %.multicpptest: - echo $@ >> testing +$(swig_and_compile_multi_cpp) $(setup) $(run_testcase) - if [ -f $(@:%.multicpptest=%_runtime_wrap.o) ] ; then \ - echo $@ >> success ; \ - fi # Clean %.clean: From 539d145b96e85bf6c17dee6619dc41776c9e73c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jan 2019 08:00:29 +0000 Subject: [PATCH 1252/2031] Add OCaml test-suite fixes to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index ef46ccd12..27f57ec70 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-03: ZackerySpytz + [OCaml] #1386 Fix OCaml out-of-source test-suite + 2019-01-01: wsfulton [Python] #639 remove duplicate proxy method definitions for global function wrappers. From 1be9f5fec35bb17df5ac02eaeca10b9b87fed8a4 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 3 Jan 2019 07:34:25 -0700 Subject: [PATCH 1253/2031] [OCaml] Fix some of the OCaml examples Update some of the OCaml examples so that they run successfully with `make check-ocaml-examples` (important for the CI). Some of the examples were written to depend on passed arguments. Temporarily disable the broken std_string example. --- Examples/ocaml/argout_ref/example_prog.ml | 13 ++----------- Examples/ocaml/check.list | 2 +- Examples/ocaml/contract/example_prog.ml | 7 ++++++- Examples/ocaml/scoped_enum/example_prog.ml | 3 ++- Examples/ocaml/strings_test/example.i | 1 + 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Examples/ocaml/argout_ref/example_prog.ml b/Examples/ocaml/argout_ref/example_prog.ml index c6de34597..b91285c1c 100644 --- a/Examples/ocaml/argout_ref/example_prog.ml +++ b/Examples/ocaml/argout_ref/example_prog.ml @@ -5,17 +5,8 @@ open Example exception BadReturn -let _ = if Array.length Sys.argv < 3 then - begin - print_endline - ("Usage: " ^ Sys.argv.(0) ^ " n1 n2\n" ^ - " Displays the least factors of the numbers that have the same\n" ^ - " relationship, 16 12 -> 4 3\n") ; - exit 0 - end - -let x = int_of_string Sys.argv.(1) -let y = int_of_string Sys.argv.(2) +let x = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 16 +let y = if Array.length Sys.argv > 2 then int_of_string Sys.argv.(2) else 12 let (xf,yf) = match _factor '((x to int),(y to int)) with C_list [ C_int a ; C_int b ] -> a,b | _ -> raise BadReturn diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list index cbdf270f0..1f1e6e709 100644 --- a/Examples/ocaml/check.list +++ b/Examples/ocaml/check.list @@ -1,6 +1,6 @@ # see top-level Makefile.in simple -std_string +#std_string std_vector stl argout_ref diff --git a/Examples/ocaml/contract/example_prog.ml b/Examples/ocaml/contract/example_prog.ml index 748109c2b..a77eed701 100644 --- a/Examples/ocaml/contract/example_prog.ml +++ b/Examples/ocaml/contract/example_prog.ml @@ -4,4 +4,9 @@ open Example let _ = print_endline "This won't throw." let _ = Printf.printf "Cos 1.0 is %f\n" (_cos '(1.0) as float) let _ = print_endline "This will throw." -let _ = Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float) +let _ = + try + Printf.printf "Cos 5.0 is %f\n" (_cos '(5.0) as float) + with Failure s -> + print_endline s ; + print_endline "Exception thrown." diff --git a/Examples/ocaml/scoped_enum/example_prog.ml b/Examples/ocaml/scoped_enum/example_prog.ml index e19bb3454..f70b6e1f8 100644 --- a/Examples/ocaml/scoped_enum/example_prog.ml +++ b/Examples/ocaml/scoped_enum/example_prog.ml @@ -1,4 +1,5 @@ open Swig open Example -let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2) +let arg = if Array.length Sys.argv > 1 then Sys.argv.(1) else "Tag1" +let _ = _f (match arg with "Tag1" -> ``Tag1 | _ -> ``Tag2) diff --git a/Examples/ocaml/strings_test/example.i b/Examples/ocaml/strings_test/example.i index be9eabfbc..d360715c1 100644 --- a/Examples/ocaml/strings_test/example.i +++ b/Examples/ocaml/strings_test/example.i @@ -11,4 +11,5 @@ using std::string; #include "example.h" %} +%include "std_string.i" %include example.h From c8a5ed151c2918d0f6bfe0b0301b47b2b7b5fcd1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 3 Jan 2019 20:11:32 +0000 Subject: [PATCH 1254/2031] Add changes entry for overloading fix --- CHANGES.current | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 27f57ec70..c5347143c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-03: wsfulton + #1202 Fix overloading of non-pointer class types in scripting languages when overloaded + with a pointer and a NULL scripting language equivalent is used, eg None in Python. + + The implementation changes the SWIGTYPE, SWIGTYPE& and SWIGTYPE&& typecheck typemaps to + prevent accepting a conversion to a NULL pointer. + 2019-01-03: ZackerySpytz [OCaml] #1386 Fix OCaml out-of-source test-suite From fe85dd22d8c8c2fb262ac1deb1c42781cb849bcd Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 5 Jan 2019 11:17:06 -0700 Subject: [PATCH 1255/2031] [OCaml] Don't generate unused _v variables --- Source/Modules/ocaml.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index cfdb31ebd..a73219abc 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -515,7 +515,6 @@ public: // adds local variables Wrapper_add_local(f, "args", "CAMLparam1(args)"); Wrapper_add_local(f, "ret", "SWIG_CAMLlocal2(swig_result,rv)"); - Wrapper_add_local(f, "_v", "int _v = 0"); if (isOverloaded) { Wrapper_add_local(f, "i", "int i"); Wrapper_add_local(f, "argc", "int argc = caml_list_length(args)"); @@ -711,7 +710,6 @@ public: "free(argv);\n" "CAMLreturn(%s(args));\n", &maxargs); - Wrapper_add_local(df, "_v", "int _v = 0"); Wrapper_add_local(df, "argv", "CAML_VALUE *argv"); /* Undifferentiate name .. this is the dispatch function */ From 96d33287b4ef2183a2a786513598752b2e355b97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Jan 2019 19:21:04 +0000 Subject: [PATCH 1256/2031] Fix Ruby docstring feature. The docstring was not encapsulated within /* */ comments. The implementation had code for autodoc strings being either single or multi-line and then adding extra newlines. However, in practice only multi-line autodoc string are ever generated, so this bit of code handling was removed. The docstring feature does not attempt to add newlines depending on the existence of newlines in the docstring. Closes #538 --- CHANGES.current | 3 +++ Source/Modules/ruby.cxx | 37 +++++++++++++------------------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c5347143c..333c5f871 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-05: wsfulton + [Ruby] #538. Fix Ruby support for %feature("docstring"). + 2019-01-03: wsfulton #1202 Fix overloading of non-pointer class types in scripting languages when overloaded with a pointer and a NULL scripting language equivalent is used, eg None in Python. diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 306570d96..08ba4e2b3 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -255,32 +255,22 @@ private: autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } - // If there is more than one line then make docstrings like this: - // - // This is line1 - // And here is line2 followed by the rest of them - // - // otherwise, put it all on a single line - // + + if (have_auto || have_ds) + doc = NewString("/*"); + if (have_auto && have_ds) { // Both autodoc and docstring are present - doc = NewString(""); - Printv(doc, "\n", autodoc, "\n", str, NIL); + Printv(doc, "\n", autodoc, "\n", str, "\n", NIL); } else if (!have_auto && have_ds) { // only docstring - if (Strchr(str, '\n') == 0) { - doc = NewString(str); - } else { - doc = NewString(""); - Printv(doc, str, NIL); - } + Printv(doc, str, NIL); } else if (have_auto && !have_ds) { // only autodoc - if (Strchr(autodoc, '\n') == 0) { - doc = NewStringf("%s", autodoc); - } else { - doc = NewString(""); - Printv(doc, "\n", autodoc, NIL); - } - } else + Printv(doc, "\n", autodoc, "\n", NIL); + } else { doc = NewString(""); + } + + if (have_auto || have_ds) + Append(doc, "*/\n"); // Save the generated strings in the parse tree in case they are used later // by post processing tools @@ -520,7 +510,7 @@ private: last_mode = ad_type; last_autodoc = Copy(methodName); - String *doc = NewString("/*\n"); + String *doc = NewString(""); int counter = 0; bool skipAuto = false; Node* on = n; @@ -760,7 +750,6 @@ private: n = Getattr(n, "sym:nextSibling"); } - Append(doc, "\n*/\n"); Delete(full_name); Delete(class_name); Delete(super_names); From 0c4491eaae3459c2826b62a869f35ef2ad407970 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 5 Jan 2019 23:54:02 +0000 Subject: [PATCH 1257/2031] Add more tests for C++11 raw string literals Test added to check fixes for: - Issue #948 and issue #1019 and issue #1273 - raw string delimiters not being stripped off - Issue #538 - Ruby support for "docstring" feature --- CHANGES.current | 6 ++ .../test-suite/cpp11_raw_string_literals.i | 40 +++++++++++ .../java/cpp11_raw_string_literals_runme.java | 67 +++++++++++++++++++ .../python/cpp11_raw_string_literals_runme.py | 27 ++++++++ 4 files changed, 140 insertions(+) create mode 100644 Examples/test-suite/java/cpp11_raw_string_literals_runme.java diff --git a/CHANGES.current b/CHANGES.current index 333c5f871..89e817415 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-05: wsfulton + #948 #1019 #1273 Fix for C++11 raw strings where the delimiters were mistakenly left + in the string contents in situations where the string was copied into generated code. + For example, %constant, the "docstring" feature and for C#/Java/D constants turned on + with %javaconst/%csconst/%dmanifestconst. + 2019-01-05: wsfulton [Ruby] #538. Fix Ruby support for %feature("docstring"). diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i index 1dea90e0c..195d0551f 100644 --- a/Examples/test-suite/cpp11_raw_string_literals.i +++ b/Examples/test-suite/cpp11_raw_string_literals.i @@ -59,3 +59,43 @@ const char16_t *hh = uR"XXX(I'm a "raw UTF-16" \ string.)XXX"; const char32_t *ii = UR"XXX(I'm a "raw UTF-32" \ string.)XXX"; %} +// Constants +#if defined(SWIGJAVA) +%javaconst(1); +#elif SWIGCSHARP +%csconst(1); +#elif SWIGD +%dmanifestconst; +#endif + +%inline %{ +#define jj ")I'm an \"ascii\" \\ string constant." +#define kk R"XXX()I'm an "ascii" \ string constant.)XXX"; +%} + +%constant mm = R"XXX()I'm an "ascii" \ string constant with multiple + +lines.)XXX"; + +// docstring feature +%feature("docstring") RawStringDoc::WW "Single line documentation comment" +%feature("docstring") RawStringDoc::XX %{ +Multi-line +documentation +comment +%} +%feature("docstring") RawStringDoc::YY R"RRR(Single line "raw string" documentation comment)RRR" +%feature("docstring") RawStringDoc::ZZ R"FOO(Documentation comment + +as a "raw string" +on multiple lines including a \ backslash)FOO" + +%inline %{ +struct RawStringDoc { + void WW() {} + void XX() {} + void YY() {} + void ZZ() {} +}; +%} + diff --git a/Examples/test-suite/java/cpp11_raw_string_literals_runme.java b/Examples/test-suite/java/cpp11_raw_string_literals_runme.java new file mode 100644 index 000000000..396c0ba06 --- /dev/null +++ b/Examples/test-suite/java/cpp11_raw_string_literals_runme.java @@ -0,0 +1,67 @@ +import cpp11_raw_string_literals.*; + +public class cpp11_raw_string_literals_runme { + + static { + try { + System.loadLibrary("cpp11_raw_string_literals"); + } 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[]) { + if (cpp11_raw_string_literals.getL() != 100) + throw new RuntimeException("failed!"); + + if (cpp11_raw_string_literals.getU8() != 100) + throw new RuntimeException("failed!"); + + if (cpp11_raw_string_literals.getU() != 100) + throw new RuntimeException("failed!"); + + if (UStruct.U != 100) + throw new RuntimeException("failed!"); + + + if (cpp11_raw_string_literals.getR() != 100) + throw new RuntimeException("failed!"); + + if (cpp11_raw_string_literals.getLR() != 100) + throw new RuntimeException("failed!"); + + if (cpp11_raw_string_literals.getU8R() != 100) + throw new RuntimeException("failed!"); + + if (cpp11_raw_string_literals.getUR() != 100) + throw new RuntimeException("failed!"); + + if (URStruct.UR != 100) + throw new RuntimeException("failed!"); + + + if (!cpp11_raw_string_literals.getAa().equals("Wide string")) + throw new RuntimeException("failed!"); + + if (!cpp11_raw_string_literals.getBb().equals("UTF-8 string")) + throw new RuntimeException("failed!"); + + if (!cpp11_raw_string_literals.getXx().equals(")I'm an \"ascii\" \\ string.")) + throw new RuntimeException("failed!"); + + if (!cpp11_raw_string_literals.getEe().equals(")I'm an \"ascii\" \\ string.")) + throw new RuntimeException("failed!"); + + if (!cpp11_raw_string_literals.getFf().equals("I'm a \"raw wide\" \\ string.")) + throw new RuntimeException("failed!"); + + if (!cpp11_raw_string_literals.getGg().equals("I'm a \"raw UTF-8\" \\ string.")) + throw new RuntimeException("failed!"); + + + + if (!cpp11_raw_string_literalsConstants.mm.equals(")I'm an \"ascii\" \\ string constant with multiple\n\nlines.")) + throw new RuntimeException("failed!"); + } +} diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py index 29e53c6a7..6a587b860 100644 --- a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py +++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py @@ -1,4 +1,5 @@ from cpp11_raw_string_literals import * +import inspect if cvar.L != 100: raise RuntimeError @@ -46,3 +47,29 @@ if cvar.ff != "I'm a \"raw wide\" \\ string.": if cvar.gg != "I'm a \"raw UTF-8\" \\ string.": raise RuntimeError, cvar.gg + + +def check(got, expected): + expected_list = expected.split("\n") + got_list = got.split("\n") + + if expected_list != got_list: + raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got : " + str(got_list)) + +# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options +# such as -O and -builtin may produce different initial indentation. +check(inspect.getdoc(RawStringDoc.WW), "Single line documentation comment") +check(inspect.getdoc(RawStringDoc.XX), +"""Multi-line +documentation +comment""") +check(inspect.getdoc(RawStringDoc.YY), """Single line "raw string" documentation comment""") +check(inspect.getdoc(RawStringDoc.ZZ), +"""Documentation comment + +as a "raw string" +on multiple lines including a \ backslash""") + +check(mm, """)I'm an "ascii" \ string constant with multiple + +lines.""") From 4a912668fcc5c73c9725ee8d07c9af57f0256e3f Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 6 Jan 2019 09:40:25 -0700 Subject: [PATCH 1258/2031] [OCaml] Fix member var getters and setters Add `membervariableHandler()` to the `OCAML` class in ocaml.cxx (it is partly based on the code in python.cxx and octave.cxx). In Lib/ocaml/class.swg, wrapped classes/structs were not being added to `class_master_list`. This is fixed by adding a call to `register_class_byname`. Add a unit test in the form of struct_value_runme.ml. --- .../test-suite/ocaml/struct_value_runme.ml | 11 +++++ Lib/ocaml/class.swg | 1 + Lib/ocaml/swig.ml | 2 +- Source/Modules/ocaml.cxx | 45 +++++++++++-------- 4 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 Examples/test-suite/ocaml/struct_value_runme.ml diff --git a/Examples/test-suite/ocaml/struct_value_runme.ml b/Examples/test-suite/ocaml/struct_value_runme.ml new file mode 100644 index 000000000..73688bef3 --- /dev/null +++ b/Examples/test-suite/ocaml/struct_value_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Struct_value + +let b = new_Bar (C_void) +let a = (invoke b) "[a]" (C_void) +let _ = (invoke a) "[x]" (C_int 3) +let _ = assert((invoke a) "[x]" (C_void) = C_int 3) + +let bb = (invoke b) "[b]" (C_void) +let _ = (invoke bb) "[x]" (C_int 3) +let _ = assert((invoke bb) "[x]" (C_void) = C_int 3) diff --git a/Lib/ocaml/class.swg b/Lib/ocaml/class.swg index 0ee304cab..eb369cd70 100644 --- a/Lib/ocaml/class.swg +++ b/Lib/ocaml/class.swg @@ -56,6 +56,7 @@ begin (fun mth arg -> invoke_inner raw_ptr mth arg) end +let _ = register_class_byname "$realname" create_$classname_from_ptr let _ = Callback.register "create_$normalized_from_ptr" create_$classname_from_ptr diff --git a/Lib/ocaml/swig.ml b/Lib/ocaml/swig.ml index d0658e78c..8ac301dc6 100644 --- a/Lib/ocaml/swig.ml +++ b/Lib/ocaml/swig.ml @@ -155,5 +155,5 @@ let _ = Callback.register "swig_set_type_info" set_type_info let class_master_list = Hashtbl.create 20 let register_class_byname nm co = Hashtbl.replace class_master_list nm (Obj.magic co) -let create_class nm arg = +let create_class nm = try (Obj.magic (Hashtbl.find class_master_list nm)) with _ -> raise (NoSuchClass nm) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index cfdb31ebd..0c97cd1d3 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -417,6 +417,29 @@ public: return SwigType_isarray(SwigType_typedef_resolve_all(t)); } + virtual int membervariableHandler(Node *n) { + String *symname = Getattr(n, "sym:name"); + Language::membervariableHandler(n); + + String *mname = Swig_name_member(NSPACE_TODO, classname, symname); + String *getname = Swig_name_get(NSPACE_TODO, mname); + String *mangled_getname = mangleNameForCaml(getname); + Delete(getname); + + if (!GetFlag(n, "feature:immutable")) { + String *setname = Swig_name_set(NSPACE_TODO, mname); + String *mangled_setname = mangleNameForCaml(setname); + Delete(setname); + Printf(f_class_ctors, " \"[%s]\", (fun args -> " "if args = (C_list [ raw_ptr ]) then _%s args else _%s args) ;\n", symname, mangled_getname, mangled_setname); + Delete(mangled_setname); + } else { + Printf(f_class_ctors, " \"[%s]\", (fun args -> " "if args = (C_list [ raw_ptr ]) then _%s args else C_void) ;\n", symname, mangled_getname); + } + Delete(mangled_getname); + Delete(mname); + return SWIG_OK; + } + /* ------------------------------------------------------------ * functionWrapper() * Create a function declaration and register it with the interpreter. @@ -477,26 +500,12 @@ public: Delete(mangled_name_nounder); } else if (classmode && in_destructor) { Printf(f_class_ctors, " \"~\", %s ;\n", mangled_name); - } else if (classmode && !in_constructor && !in_destructor && !static_member_function) { + } else if (classmode && !in_constructor && !in_destructor && !static_member_function && + !Getattr(n, "membervariableHandler:sym:name")) { String *opname = Copy(Getattr(n, "memberfunctionHandler:sym:name")); Replaceall(opname, "operator ", ""); - - if (strstr(Char(mangled_name), "__get__")) { - String *set_name = Copy(mangled_name); - if (!GetFlag(n, "feature:immutable")) { - Replaceall(set_name, "__get__", "__set__"); - Printf(f_class_ctors, " \"%s\", (fun args -> " "if args = (C_list [ raw_ptr ]) then %s args else %s args) ;\n", opname, mangled_name, set_name); - Delete(set_name); - } else { - Printf(f_class_ctors, " \"%s\", (fun args -> " "if args = (C_list [ raw_ptr ]) then %s args else C_void) ;\n", opname, mangled_name); - } - } else if (strstr(Char(mangled_name), "__set__")) { - ; /* Nothing ... handled by the case above */ - } else { - Printf(f_class_ctors, " \"%s\", %s ;\n", opname, mangled_name); - } - + Printf(f_class_ctors, " \"%s\", %s ;\n", opname, mangled_name); Delete(opname); } @@ -1103,7 +1112,7 @@ public: */ int classHandler(Node *n) { - String *name = Getattr(n, "name"); + String *name = Getattr(n, "sym:name"); if (!name) return SWIG_OK; From 747ea5bfb63f2a5b760db9543ade818e1fb9a022 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 6 Jan 2019 10:29:17 -0700 Subject: [PATCH 1259/2031] Fix race conds when running the OCaml test suite with parallel make Don't try to rm files that have been checked out of the SWIG library. Don't repeatedly attempt to compile swig.ml, swig.mli, and swigp4.ml. --- Examples/Makefile.in | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3595120da..f9d1ddd63 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -904,13 +904,12 @@ 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 && \ - $(SWIG) -ocaml -co swig.ml 2>/dev/null && \ - $(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" -c swigp4.ml + (test -f swig.mli || $(SWIG) -ocaml -co swig.mli 2>/dev/null) && \ + (test -f swig.ml || $(SWIG) -ocaml -co swig.ml 2>/dev/null) && \ + (test -f swigp4.ml || $(SWIG) -ocaml -co swigp4.ml 2>/dev/null) && \ + (test -f swig.cmi || $(OCC) -c swig.mli) && \ + (test -f swig.cmo || $(OCC) -c swig.ml) && \ + (test -f swigp4.cmi || $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml) ocaml_static: $(SRCDIR_SRCS) $(OCAMLCORE) From b463870b0cd900a0dc839ea944f19c3da2a412b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 7 Jan 2019 18:46:14 +0000 Subject: [PATCH 1260/2031] Add missing VOID definition to windows.i Closes #358 --- CHANGES.current | 3 +++ Lib/windows.i | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 89e817415..bbf7a54af 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-07: wsfulton + #358 Add VOID to windows.i + 2019-01-05: wsfulton #948 #1019 #1273 Fix for C++11 raw strings where the delimiters were mistakenly left in the string contents in situations where the string was copied into generated code. diff --git a/Lib/windows.i b/Lib/windows.i index 2c093dacc..3e4626196 100644 --- a/Lib/windows.i +++ b/Lib/windows.i @@ -112,6 +112,9 @@ typedef unsigned __int64 DWORD64, *PDWORD64; // Types from winnt.h typedef void *PVOID; typedef void *PVOID64; +#ifndef VOID +#define VOID void +#endif typedef char CHAR; typedef short SHORT; typedef long LONG; From 8f7bc4cc1078cd2223c051c8db12559d3d3d031e Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 7 Jan 2019 11:59:07 -0700 Subject: [PATCH 1261/2031] [OCaml] Rename example_prog.ml to runme.ml in the OCaml examples Name the output executable "runme" in the examples. Replace use of "foolib" in the string_from_ptr example. Fix a warning in the std_vector example. Add strings_test to Examples/ocaml/check.list. Disable two tests that were causing the OCaml test suite to fail. --- .gitignore | 4 ++-- Examples/Makefile.in | 14 +++++++------- Examples/ocaml/argout_ref/Makefile | 2 +- .../ocaml/argout_ref/{example_prog.ml => runme.ml} | 2 +- Examples/ocaml/check.list | 1 + Examples/ocaml/contract/Makefile | 2 +- .../ocaml/contract/{example_prog.ml => runme.ml} | 0 Examples/ocaml/scoped_enum/Makefile | 2 +- .../scoped_enum/{example_prog.ml => runme.ml} | 0 Examples/ocaml/shapes/Makefile | 2 +- .../ocaml/shapes/{example_prog.ml => runme.ml} | 2 +- Examples/ocaml/simple/Makefile | 2 +- .../ocaml/simple/{example_prog.ml => runme.ml} | 2 +- Examples/ocaml/std_vector/runme.ml | 4 ++-- Examples/ocaml/string_from_ptr/Makefile | 6 +++--- .../ocaml/string_from_ptr/{foolib.i => example.i} | 2 +- .../string_from_ptr/{example_prog.ml => runme.ml} | 4 +--- Examples/test-suite/ocaml/Makefile.in | 2 ++ 18 files changed, 27 insertions(+), 26 deletions(-) rename Examples/ocaml/argout_ref/{example_prog.ml => runme.ml} (95%) rename Examples/ocaml/contract/{example_prog.ml => runme.ml} (100%) rename Examples/ocaml/scoped_enum/{example_prog.ml => runme.ml} (100%) rename Examples/ocaml/shapes/{example_prog.ml => runme.ml} (98%) rename Examples/ocaml/simple/{example_prog.ml => runme.ml} (95%) rename Examples/ocaml/string_from_ptr/{foolib.i => example.i} (94%) rename Examples/ocaml/string_from_ptr/{example_prog.ml => runme.ml} (88%) diff --git a/.gitignore b/.gitignore index 53b6187e7..8aff2c699 100644 --- a/.gitignore +++ b/.gitignore @@ -164,8 +164,8 @@ Examples/test-suite/ocaml/*.cm* Examples/test-suite/ocaml/runme !Examples/test-suite/ocaml/*runme.ml Examples/ocaml/**/example.ml* -Examples/ocaml/**/example -Examples/ocaml/**/example_top +Examples/ocaml/**/runme +Examples/ocaml/**/runme_top Examples/ocaml/**/*.cm* Examples/ocaml/**/swig.ml* Examples/ocaml/**/swigp4.ml diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 3595120da..6d6dc95af 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -919,7 +919,7 @@ ocaml_static: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" + $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_dynamic: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -931,7 +931,7 @@ ocaml_dynamic: $(SRCDIR_SRCS) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLFIND) $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) + $(NOLINK) || $(OCAMLFIND) $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) ocaml_static_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -940,7 +940,7 @@ ocaml_static_toplevel: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(TARGET)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" + $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_static_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -950,7 +950,7 @@ ocaml_static_cpp: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(TARGET) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -960,7 +960,7 @@ ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(TARGET)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' ocaml_dynamic_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -973,14 +973,14 @@ ocaml_dynamic_cpp: $(SRCDIR_SRCS) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(TARGET) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(RUNME) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' # ----------------------------------------------------------------- # Run ocaml example # ----------------------------------------------------------------- ocaml_run: - $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + $(RUNTOOL) ./$(RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index 8b7fc959e..d8c8e9056 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -5,7 +5,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml -PROGFILE = example_prog.ml +PROGFILE = runme.ml OBJS = example.o check: build diff --git a/Examples/ocaml/argout_ref/example_prog.ml b/Examples/ocaml/argout_ref/runme.ml similarity index 95% rename from Examples/ocaml/argout_ref/example_prog.ml rename to Examples/ocaml/argout_ref/runme.ml index b91285c1c..cb9a94255 100644 --- a/Examples/ocaml/argout_ref/example_prog.ml +++ b/Examples/ocaml/argout_ref/runme.ml @@ -1,4 +1,4 @@ -(* example_prog.ml *) +(* runme.ml *) open Swig open Example diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list index 1f1e6e709..bcc63fa7f 100644 --- a/Examples/ocaml/check.list +++ b/Examples/ocaml/check.list @@ -8,3 +8,4 @@ shapes contract scoped_enum string_from_ptr +strings_test diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index c77e6dcc4..868dc82b2 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -5,7 +5,7 @@ SRCS = TARGET = example INTERFACE = example.i MLFILE = example.ml -PROGFILE = example_prog.ml +PROGFILE = runme.ml OBJS = check: build diff --git a/Examples/ocaml/contract/example_prog.ml b/Examples/ocaml/contract/runme.ml similarity index 100% rename from Examples/ocaml/contract/example_prog.ml rename to Examples/ocaml/contract/runme.ml diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index 9655c98e6..0fa3af226 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -5,7 +5,7 @@ SRCS = TARGET = example INTERFACE = example.i MLFILE = example.ml -PROGFILE = example_prog.ml +PROGFILE = runme.ml OBJS = check: build diff --git a/Examples/ocaml/scoped_enum/example_prog.ml b/Examples/ocaml/scoped_enum/runme.ml similarity index 100% rename from Examples/ocaml/scoped_enum/example_prog.ml rename to Examples/ocaml/scoped_enum/runme.ml diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index 8aa35d79f..d34b48738 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -6,7 +6,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml -PROGFILE = example_prog.ml +PROGFILE = runme.ml OBJS = example.o check: build diff --git a/Examples/ocaml/shapes/example_prog.ml b/Examples/ocaml/shapes/runme.ml similarity index 98% rename from Examples/ocaml/shapes/example_prog.ml rename to Examples/ocaml/shapes/runme.ml index b9e35158a..a7a2f9374 100644 --- a/Examples/ocaml/shapes/example_prog.ml +++ b/Examples/ocaml/shapes/runme.ml @@ -1,4 +1,4 @@ -(* example_prog.ml *) +(* runme.ml *) open Swig ;; open Example ;; diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index 88fef7435..bec1526f1 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -5,7 +5,7 @@ SRCS = example.c TARGET = example INTERFACE = example.i MLFILE = example.ml -PROGFILE = example_prog.ml +PROGFILE = runme.ml OBJS = example.o check: build diff --git a/Examples/ocaml/simple/example_prog.ml b/Examples/ocaml/simple/runme.ml similarity index 95% rename from Examples/ocaml/simple/example_prog.ml rename to Examples/ocaml/simple/runme.ml index cc3b973d8..4f7a407ef 100644 --- a/Examples/ocaml/simple/example_prog.ml +++ b/Examples/ocaml/simple/runme.ml @@ -1,4 +1,4 @@ -(* example_prog.ml *) +(* runme.ml *) open Swig open Example diff --git a/Examples/ocaml/std_vector/runme.ml b/Examples/ocaml/std_vector/runme.ml index feb70dd5e..0f5519b6f 100644 --- a/Examples/ocaml/std_vector/runme.ml +++ b/Examples/ocaml/std_vector/runme.ml @@ -14,7 +14,7 @@ let print_DoubleVector v = (fun v i -> print_float ((v '[i to int]) as float) ; print_string " ") ; - print_endline + print_endline "" end (* Call average with a Ocaml array... *) @@ -27,7 +27,7 @@ let rec fill_dv v x = fill_dv v (x *. x) end let _ = fill_dv v 0.999 -let _ = print_DoubleVector v ; print_endline "" +let _ = print_DoubleVector v let u = new_IntVector '() let _ = for i = 1 to 4 do u -> push_back ((i to int)) diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 9987d0052..3433022a8 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -4,9 +4,9 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SWIGOPT = -c++ SRCS = TARGET = example -INTERFACE = foolib.i -MLFILE = foolib.ml -PROGFILE = example_prog.ml +INTERFACE = example.i +MLFILE = example.ml +PROGFILE = runme.ml OBJS = check: build diff --git a/Examples/ocaml/string_from_ptr/foolib.i b/Examples/ocaml/string_from_ptr/example.i similarity index 94% rename from Examples/ocaml/string_from_ptr/foolib.i rename to Examples/ocaml/string_from_ptr/example.i index 86e0880eb..d66487940 100644 --- a/Examples/ocaml/string_from_ptr/foolib.i +++ b/Examples/ocaml/string_from_ptr/example.i @@ -1,4 +1,4 @@ -%module foolib +%module example %{ static int foo( char **buf ) { *buf = "string from c"; diff --git a/Examples/ocaml/string_from_ptr/example_prog.ml b/Examples/ocaml/string_from_ptr/runme.ml similarity index 88% rename from Examples/ocaml/string_from_ptr/example_prog.ml rename to Examples/ocaml/string_from_ptr/runme.ml index 8069dc228..039762017 100644 --- a/Examples/ocaml/string_from_ptr/example_prog.ml +++ b/Examples/ocaml/string_from_ptr/runme.ml @@ -1,7 +1,5 @@ -(* foo_program.ml -- the program using foolib *) - open Swig (* Give access to the swig library *) -open Foolib (* This is the name of your swig output *) +open Example (* This is the name of your swig output *) let results = _foo '() (* Function names are prefixed with _ in order to make them lex as identifiers in ocaml. Consider that diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 879682f10..0fe1533d1 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -21,6 +21,7 @@ default_constructor \ director_binary_string \ director_enum \ director_exception \ +director_exception_nothrow \ director_ignore \ director_nested \ director_pass_by_value \ @@ -30,6 +31,7 @@ director_redefined \ director_string \ director_using \ enum_thorough \ +li_windows \ member_pointer_const \ minherit \ nested_directors \ From 8d9d4cc5f12501c770304e275eff741a82f353cd Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 7 Jan 2019 14:24:58 -0700 Subject: [PATCH 1262/2031] [OCaml] Improve "make clean" and similar When cleaning, remove the runme file and generated *.mli files. Remove unneeded MLFILE variables from Makefiles. --- Examples/Makefile.in | 2 +- Examples/ocaml/argout_ref/Makefile | 7 +++---- Examples/ocaml/contract/Makefile | 9 ++++----- Examples/ocaml/scoped_enum/Makefile | 9 ++++----- Examples/ocaml/shapes/Makefile | 9 ++++----- Examples/ocaml/simple/Makefile | 9 ++++----- Examples/ocaml/string_from_ptr/Makefile | 9 ++++----- Examples/test-suite/ocaml/Makefile.in | 4 ++++ 8 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6d6dc95af..b5b650865 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -994,7 +994,7 @@ ocaml_version: # ----------------------------------------------------------------- ocaml_clean: - rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo + rm -f *_wrap* *~ .~* *.cmo *.cmi *.mli $(TARGET).ml $(RUNME) $(RUNME)_top swig.ml swigp4.ml rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index d8c8e9056..234713da5 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -4,7 +4,6 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = example.o @@ -16,16 +15,16 @@ build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index 868dc82b2..1f36642e4 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -4,7 +4,6 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = @@ -16,23 +15,23 @@ build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index 0fa3af226..f0f53173f 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -4,7 +4,6 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = @@ -16,23 +15,23 @@ build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index d34b48738..a98c6a8e6 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -5,7 +5,6 @@ SWIGOPT = SRCS = example.c TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = example.o @@ -18,22 +17,22 @@ static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index bec1526f1..3b24a6bcb 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -4,7 +4,6 @@ SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib SRCS = example.c TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = example.o @@ -16,23 +15,23 @@ build: static dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_toplevel clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 3433022a8..64df2df41 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -5,7 +5,6 @@ SWIGOPT = -c++ SRCS = TARGET = example INTERFACE = example.i -MLFILE = example.ml PROGFILE = runme.ml OBJS = @@ -18,22 +17,22 @@ static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp static_top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp_toplevel dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' - MLFILE='$(MLFILE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_dynamic_cpp clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' MLFILE='$(MLFILE)' ocaml_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 0fe1533d1..6e1a9f17d 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -88,6 +88,10 @@ include $(srcdir)/../common.mk # Clean %.clean: @rm -f $*.ml $*.mli; + @if test $(srcdir) != .; then rm -f $(ml_runme); fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean + rm -f clientdata_prop_a.ml clientdata_prop_b.ml import_stl_a.ml import_stl_b.ml + rm -f imports_a.ml imports_b.ml mod_a.ml mod_b.ml multi_import_a.ml + rm -f multi_import_b.ml packageoption_a.ml packageoption_b.ml packageoption_c.ml From 4ca6fdc551ed103de63c7186ab2e0e1ee27937cc Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 8 Jan 2019 20:10:07 -0700 Subject: [PATCH 1263/2031] OCaml's classHandler() requires name, not sym:name. In classHandler(), assign sym:name to the classname global so that it can be used in membervariableHandler(). Add a small runme test for li_std_vector. Use swigp4 when compiling the runme tests. --- Examples/test-suite/ocaml/Makefile.in | 3 ++- .../test-suite/ocaml/li_std_vector_runme.ml | 23 +++++++++++++++++++ Source/Modules/ocaml.cxx | 16 ++++++------- 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 Examples/test-suite/ocaml/li_std_vector_runme.ml diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 879682f10..bb342e039 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -4,6 +4,7 @@ LANGUAGE = ocaml OCAMLC = @OCAMLC@ +OCAMLPP = -pp "camlp4o ./swigp4.cmo" VARIANT = _static SCRIPTSUFFIX = _runme.ml @@ -51,7 +52,7 @@ run_testcase = \ if [ $(srcdir) != . ]; then \ cp $(srcdir)/$(ml_runme) $(ml_runme); \ fi ; \ - $(COMPILETOOL) $(OCAMLC) -c $(ml_runme) && \ + $(COMPILETOOL) $(OCAMLC) $(OCAMLPP) -c $(ml_runme) && \ if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \ $(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; \ else \ diff --git a/Examples/test-suite/ocaml/li_std_vector_runme.ml b/Examples/test-suite/ocaml/li_std_vector_runme.ml new file mode 100644 index 000000000..64e9ec9f2 --- /dev/null +++ b/Examples/test-suite/ocaml/li_std_vector_runme.ml @@ -0,0 +1,23 @@ +open Swig +open Li_std_vector + +let _ = + let iv = new_IntVector '() in + assert (iv -> "empty" () as bool); + assert ((iv -> "size" () as int) = 0); + ignore (iv -> "push_back" (123)); + assert ((iv -> "empty" () as bool) = false); + assert ((iv -> "size" () as int) = 1); + assert ((iv -> "[]" (0) as int) = 123); + ignore (iv -> "clear" ()); + assert (iv -> "empty" () as bool); + assert ((iv -> "size" () as int) = 0); +;; + +let _ = + let rv = new_RealVector '() in + ignore (rv -> "push_back" (100.)); + ignore (rv -> "push_back" (200.)); + assert ((rv -> "[]" (0) as float) = 100.); + assert ((rv -> "[]" (1) as float) = 200.); +;; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 0c97cd1d3..56d6fd270 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1112,12 +1112,13 @@ public: */ int classHandler(Node *n) { - String *name = Getattr(n, "sym:name"); + String *name = Getattr(n, "name"); + classname = Getattr(n, "sym:name"); if (!name) return SWIG_OK; - String *mangled_sym_name = mangleNameForCaml(name); + String *mangled_name = mangleNameForCaml(name); String *this_class_def = NewString(f_classtemplate); String *name_normalized = normalizeTemplatedClassName(name); String *old_class_ctors = f_class_ctors; @@ -1126,7 +1127,6 @@ public: bool sizeof_feature = generate_sizeof && isSimpleType(name); - classname = mangled_sym_name; classmode = true; int rv = Language::classHandler(n); classmode = false; @@ -1134,15 +1134,15 @@ public: if (sizeof_feature) { Printf(f_wrappers, "SWIGEXT CAML_VALUE _wrap_%s_sizeof( CAML_VALUE args ) {\n" - " CAMLparam1(args);\n" " CAMLreturn(Val_int(sizeof(%s)));\n" "}\n", mangled_sym_name, name_normalized); + " CAMLparam1(args);\n" " CAMLreturn(Val_int(sizeof(%s)));\n" "}\n", mangled_name, name_normalized); - Printf(f_mlbody, "external __%s_sizeof : unit -> int = " "\"_wrap_%s_sizeof\"\n", classname, mangled_sym_name); + Printf(f_mlbody, "external __%s_sizeof : unit -> int = " "\"_wrap_%s_sizeof\"\n", mangled_name, mangled_name); } /* Insert sizeof operator for concrete classes */ if (sizeof_feature) { - Printv(f_class_ctors, "\"sizeof\" , (fun args -> C_int (__", classname, "_sizeof ())) ;\n", NIL); + Printv(f_class_ctors, "\"sizeof\" , (fun args -> C_int (__", mangled_name, "_sizeof ())) ;\n", NIL); } /* Handle up-casts in a nice way */ List *baselist = Getattr(n, "bases"); @@ -1161,7 +1161,7 @@ public: } } - Replaceall(this_class_def, "$classname", classname); + Replaceall(this_class_def, "$classname", mangled_name); Replaceall(this_class_def, "$normalized", name_normalized); Replaceall(this_class_def, "$realname", name); Replaceall(this_class_def, "$baselist", base_classes); @@ -1174,7 +1174,7 @@ public: Multiwrite(this_class_def); - Setattr(n, "ocaml:ctor", classname); + Setattr(n, "ocaml:ctor", mangled_name); return rv; } From 65f21119157108b1e6e4129a1cb7ab58dbecb1ea Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 8 Jan 2019 21:36:06 -0700 Subject: [PATCH 1264/2031] [OCaml] Use int64_t instead of int64 for OCaml versions >= 4.03.0 OCaml's int64 type was replaced with the C99 int64_t in OCaml 4.03.0. https://github.com/ocaml/ocaml/commit/b868c05ec91a7ee193010a421de768a3b1a80952 Closes #1194. --- Lib/ocaml/ocamldec.swg | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index dcc8784e1..4f705b225 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -23,6 +23,7 @@ SWIGEXT { #include #include #include +#include #define caml_array_set swig_caml_array_set @@ -101,9 +102,17 @@ SWIGEXT { #ifndef ARCH_ALIGN_INT64 +#if OCAML_VERSION >= 40300 +#define SWIG_Int64_val(v) (*((int64_t *) SWIG_Data_custom_val(v))) +#else #define SWIG_Int64_val(v) (*((int64 *) SWIG_Data_custom_val(v))) +#endif +#else +#if OCAML_VERSION >= 40300 +CAMLextern int64_t Int64_val(caml_value_t v); #else CAMLextern int64 Int64_val(caml_value_t v); +#endif #define SWIG_Int64_val(v) Int64_val(v) #endif From 2315ed878b0cdac1d47853a7c526cacf2a83c23f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 9 Jan 2019 18:24:36 +0000 Subject: [PATCH 1265/2031] Improve Python docs on memory management and member variables --- Doc/Manual/Contents.html | 1 + Doc/Manual/Python.html | 89 ++++++++++++++++++++++++++++------------ 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index d9bc4bc05..f8a731fe2 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1671,6 +1671,7 @@
    • Mapping Python tuples into small arrays
    • Mapping sequences to C arrays
    • Pointer handling +
    • Memory management when returning references to member variables
  • Docstring Features
      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 6f8e1ddfa..e94d9d9cb 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -5435,7 +5435,7 @@ that has a this attribute. In addition, class object (if applicable).

      -

      36.9.7 Memory management when returning references to member variables

      +

      38.9.7 Memory management when returning references to member variables

      @@ -5449,9 +5449,11 @@ Consider the following C++ code:

      +#include <iostream>
       struct Wheel {
         int size;
         Wheel(int sz) : size(sz) {}
      +  ~Wheel() { std::cout << "~Wheel" << std::endl; }
       };
       
       class Bike {
      @@ -5474,7 +5476,7 @@ bike = Bike(10)
       wheel = bike.getWheel()
       print("wheel size: {}".format(wheel.size))
       
      -del bike # Allow bike to be garbage collected
      +del bike  # Allow bike to be garbage collected
       print("wheel size: {}".format(wheel.size))
       
      @@ -5486,6 +5488,7 @@ Don't be surprised that if the resulting output gives strange results such as...
       wheel size: 10
      +~Wheel
       wheel size: 135019664
       
      @@ -5499,66 +5502,100 @@ be added to the wheel instance.

      You can do this by adding the reference when the getWheel() method -is called using one of two approaches: +is called using one of three approaches:

      -The easier, but less optimized, way is to use the typemap-like %pythonappend directive -(see 36.6.2 Adding additional Python code): +The easier, but less optimized, way is to use the %pythonappend directive +(see Adding additional Python code):

       %pythonappend getWheel %{
         # val is the Wheel proxy, self is the Bike instance
      -  val._bike = self
      +  val.__bike_reference = self
       %}
       

      The code gets appended to the Python code generated for the -Bike::getWheel function, where we store the Bike proxy +Bike::getWheel wrapper function, where we store the Bike proxy instance onto the Wheel proxy instance before it is returned to the -caller. +caller as follows.

      +
      +
      +class Bike(object):
      +    ...
      +    def getWheel(self):
      +        val = _example.Bike_getWheel(self)
      +
      +        # val is the Wheel proxy, self is the Bike instance
      +        val.__bike_reference = self
      +
      +        return val
      +
      +
      + +

      The second option, which performs better and is required if you use the -builtin option, is to set the reference in the CPython implementation:

      -%fragment("extra_reference", "header") {
      +%extend Wheel {
      +// A reference to the parent class is added to ensure the underlying C++
      +// object is not deleted while the item is in use
      +%typemap(ret) Wheel& getWheel {
      +  PyObject *bike_reference_string = SWIG_Python_str_FromChar("__bike_reference");
      +  PyObject_SetAttr($result, bike_reference_string, $self);
      +  Py_DecRef(bike_reference_string);
      +}
      +}
      +
      +
      -static PyObject *extra_reference() { - static PyObject *extra_reference_string = NULL; - if (!extra_reference_string) - extra_reference_string = SWIG_Python_str_FromChar("_extra_reference"); - return extra_reference_string; +

      +The third approach, shown below, is an optimization of the above approach and creates the "__bike_reference" Python string object just once. +While this looks more complex, it is just a small variation on the above typemap plus a support function +bike_reference() in a fragment called bike_reference_function. +The bike_reference_init typemap generates code into the "init" section for an initial call to bike_reference() when the module +is initialized and is done to create the "__bike_reference" Python string singleton in a thread-safe manner. +

      + +
      +
      +%fragment("bike_reference_init", "init") {
      +  // Thread-safe initialization - initialize during Python module initialization
      +  bike_reference();
      +}
      +
      +%fragment("bike_reference_function", "header", fragment="bike_reference_init") {
      +
      +static PyObject *bike_reference() {
      +  static PyObject *bike_reference_string = SWIG_Python_str_FromChar("__bike_reference");
      +  return bike_reference_string;
       }
       
       }
       
       %extend Wheel {
      -%typemap(ret, fragment="extra_reference") Wheel& getWheel %{
      -  // A reference to the parent class is added to ensure the underlying C++
      -  // object is not deleted while the item is in use
      -  PyObject_SetAttr($result, extra_reference(), $self);
      +// A reference to the parent class is added to ensure the underlying C++
      +// object is not deleted while the item is in use
      +%typemap(ret, fragment="bike_reference_function") Wheel& getWheel %{
      +  PyObject_SetAttr($result, bike_reference(), $self);
       %}
      -/* FYI: Alternative approach, but is possibly harder to understand, so suggest above
      -%typemap(out, fragment="extra_reference") Wheel& getWheel %{
      -  $typemap(out, Wheel &)
      -  // A reference to the parent class is added to ensure the underlying C++
      -  // object is not deleted while the item is in use
      -  PyObject_SetAttr($result, extra_reference(), $self);
      -%}
      -*/
       }
       
      + +

      38.10 Docstring Features

      From 7c653ba7dfbfc45962c2d6c8fdb8a0be3996e573 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 10 Jan 2019 14:11:16 -0700 Subject: [PATCH 1266/2031] Add rules for swig.cmi, swig.cmo, and swigp4.cmi In addition, give runme executables unique names (based on the go Makefile). --- Examples/test-suite/ocaml/Makefile.in | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 6e1a9f17d..743a29789 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -3,7 +3,8 @@ ####################################################################### LANGUAGE = ocaml -OCAMLC = @OCAMLC@ +OCAMLP4WHERE =`$(COMPILETOOL) @CAMLP4@ -where` +OCC =$(COMPILETOOL) @OCAMLC@ VARIANT = _static SCRIPTSUFFIX = _runme.ml @@ -53,11 +54,11 @@ run_testcase = \ if [ $(srcdir) != . ]; then \ cp $(srcdir)/$(ml_runme) $(ml_runme); \ fi ; \ - $(COMPILETOOL) $(OCAMLC) -c $(ml_runme) && \ + $(OCC) -c $(ml_runme) && \ if [ -f $(top_srcdir)/Examples/test-suite/$*.list ]; then \ - $(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; \ + $(OCC) 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; \ else \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && $(RUNTOOL) ./runme; \ + $(OCC) swig.cmo -custom -g -cc '$(CXX)' -o $*_runme $(*).cmo $(*)_runme.cmo $(*)_wrap.o && $(RUNTOOL) ./$*_runme; \ fi ; \ fi ; @@ -85,9 +86,24 @@ include $(srcdir)/../common.mk $(setup) $(run_testcase) +swig.cmi: + env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.mli + $(OCC) -c swig.mli +swig.cmo: + env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swig.ml + $(OCC) -c swig.ml +swigp4.cmi: + env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swigp4.ml + $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml +extra_obs: swig.cmi swig.cmo swigp4.cmi + +$(C_TEST_CASES:=.ctest): extra_obs +$(CPP_TEST_CASES:=.cpptest): extra_obs +$(MULTI_CPP_TEST_CASES:=.multicpptest): extra_obs + # Clean %.clean: - @rm -f $*.ml $*.mli; + @rm -f $*.ml $*.mli $*_runme; @if test $(srcdir) != .; then rm -f $(ml_runme); fi clean: From 5bdb52b31975834ece1ec69fd82a7f9774c8573e Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 9 Jan 2019 20:31:24 -0700 Subject: [PATCH 1267/2031] [OCaml] class_scope_weird, cpp_static, and ignore_parameter runtime tests They are based on the corresponding python runtime tests. --- .../ocaml/class_scope_weird_runme.ml | 6 ++++++ Examples/test-suite/ocaml/cpp_static_runme.ml | 17 ++++++++++++++++ .../ocaml/ignore_parameter_runme.ml | 20 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 Examples/test-suite/ocaml/class_scope_weird_runme.ml create mode 100644 Examples/test-suite/ocaml/cpp_static_runme.ml create mode 100644 Examples/test-suite/ocaml/ignore_parameter_runme.ml diff --git a/Examples/test-suite/ocaml/class_scope_weird_runme.ml b/Examples/test-suite/ocaml/class_scope_weird_runme.ml new file mode 100644 index 000000000..de7f457d4 --- /dev/null +++ b/Examples/test-suite/ocaml/class_scope_weird_runme.ml @@ -0,0 +1,6 @@ +open Swig +open Class_scope_weird + +let f = new_Foo (C_void) +let g = new_Foo (C_int 3) +let _ = assert (get_int ((invoke f) "bar" (C_int 3)) = 3) diff --git a/Examples/test-suite/ocaml/cpp_static_runme.ml b/Examples/test-suite/ocaml/cpp_static_runme.ml new file mode 100644 index 000000000..9b04abced --- /dev/null +++ b/Examples/test-suite/ocaml/cpp_static_runme.ml @@ -0,0 +1,17 @@ +open Swig +open Cpp_static + +let _ = _StaticFunctionTest_static_func (C_void) +let _ = _StaticFunctionTest_static_func_2 (C_int 1) +let _ = _StaticFunctionTest_static_func_3 (C_list [C_int 1; C_int 2]) + +let _ = assert (get_int (_StaticMemberTest_static_int (C_void)) = 99) +let _ = _StaticMemberTest_static_int (C_int 10) +let _ = assert (get_int (_StaticMemberTest_static_int (C_void)) = 10) + +let _ = assert (get_int (_StaticBase_statty (C_void)) = 11) +let _ = assert (get_int (_StaticDerived_statty (C_void)) = 111) +let _ = _StaticBase_statty (C_int 22) +let _ = _StaticDerived_statty (C_int 222) +let _ = assert (get_int (_StaticBase_statty (C_void)) = 22) +let _ = assert (get_int (_StaticDerived_statty (C_void)) = 222) diff --git a/Examples/test-suite/ocaml/ignore_parameter_runme.ml b/Examples/test-suite/ocaml/ignore_parameter_runme.ml new file mode 100644 index 000000000..358b25ebb --- /dev/null +++ b/Examples/test-suite/ocaml/ignore_parameter_runme.ml @@ -0,0 +1,20 @@ +open Swig +open Ignore_parameter + +let _ = + assert (get_string (_jaguar (C_list [ C_int 200 ; C_float 0. ])) = "hello"); + assert (get_int (_lotus (C_list [ C_string "fast" ; C_float 0. ])) = 101); + assert (get_float (_tvr (C_list [ C_string "fast" ; C_int 200 ])) = 8.8); + assert (get_int (_ferrari (C_void)) = 101); +;; +let sc = new_SportsCars (C_void) +let _ = + assert (get_string ((invoke sc) "daimler" (C_list [ C_int 200 ; C_float 0. ])) = "hello"); + assert (get_int ((invoke sc) "astonmartin" (C_list [ C_string "fast" ; C_float 0. ])) = 101); + assert (get_float ((invoke sc) "bugatti" (C_list [ C_string "fast" ; C_int 200 ])) = 8.8); + assert (get_int ((invoke sc) "lamborghini" (C_void)) = 101); +;; +let mc = new_MiniCooper (C_list [ C_int 200 ; C_float 0. ]) +let mm = new_MorrisMinor (C_list [ C_string "slow" ; C_float 0. ]) +let fa = new_FordAnglia (C_list [ C_string "slow" ; C_int 200 ]) +let aa = new_AustinAllegro (C_void) From d6cd52f5863bdb6494fa91b7d4ffa9dddca17cd3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jan 2019 19:31:37 +0000 Subject: [PATCH 1268/2031] Fix OCAML typemap warnings wrapping C code Fixes: Lib/ocaml/typemaps.i:366: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined. Lib/ocaml/typemaps.i:367: Warning 453: Can't apply (SWIGTYPE &&). No typemaps are defined. Lib/ocaml/typemaps.i:372: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined. --- Lib/ocaml/typemaps.i | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index b70b78928..3e0233ffa 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -27,7 +27,16 @@ $result = caml_val_ptr($1,$descriptor); } -#ifdef __cplusplus +%typemap(in) char *& (char *temp) { + /* %typemap(in) char *& */ + temp = (char*)caml_val_ptr($1,$descriptor); + $1 = &temp; +} + +%typemap(argout) char *& { + /* %typemap(argout) char *& */ + swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); +} %typemap(in) SWIGTYPE & { /* %typemap(in) SWIGTYPE & */ @@ -105,6 +114,8 @@ $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } +#ifdef __cplusplus + %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ $&1_ltype temp = new $ltype((const $1_ltype &) $1); @@ -116,23 +127,8 @@ } } -%typemap(in) char *& (char *temp) { - /* %typemap(in) char *& */ - temp = (char*)caml_val_ptr($1,$descriptor); - $1 = &temp; -} - -%typemap(argout) char *& { - /* %typemap(argout) char *& */ - swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); -} - #else -%typemap(in) SWIGTYPE { - $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; -} - %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ void *temp = calloc(1,sizeof($ltype)); @@ -145,9 +141,6 @@ } } -%apply SWIGTYPE { const SWIGTYPE & }; -%apply SWIGTYPE { const SWIGTYPE && }; - #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed From bbad9eab8cd67807a24e668278bb93ed42ca1ce6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jan 2019 19:38:10 +0000 Subject: [PATCH 1269/2031] OCaml fix getters/setters changes file addition Issue #1400 [skip ci] --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index bbf7a54af..6ba34a90a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-11: ZackerySpytz + [OCaml] #1400 Fix getters and setters. + 2019-01-07: wsfulton #358 Add VOID to windows.i From 96c5a95878ba93b893b443c71a767bfac73ac462 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 11 Jan 2019 17:53:38 -0700 Subject: [PATCH 1270/2031] [OCaml] Add a class example It is based on the Python class example. The Makefile is based on the Makefile used in the OCaml shapes example. --- Examples/ocaml/check.list | 9 +++--- Examples/ocaml/class/Makefile | 31 ++++++++++++++++++ Examples/ocaml/class/example.c | 28 +++++++++++++++++ Examples/ocaml/class/example.h | 34 ++++++++++++++++++++ Examples/ocaml/class/example.i | 9 ++++++ Examples/ocaml/class/runme.ml | 57 ++++++++++++++++++++++++++++++++++ 6 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 Examples/ocaml/class/Makefile create mode 100644 Examples/ocaml/class/example.c create mode 100644 Examples/ocaml/class/example.h create mode 100644 Examples/ocaml/class/example.i create mode 100644 Examples/ocaml/class/runme.ml diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list index bcc63fa7f..fb7317b3a 100644 --- a/Examples/ocaml/check.list +++ b/Examples/ocaml/check.list @@ -1,11 +1,12 @@ # see top-level Makefile.in +argout_ref +class +contract +scoped_enum +shapes simple #std_string std_vector stl -argout_ref -shapes -contract -scoped_enum string_from_ptr strings_test diff --git a/Examples/ocaml/class/Makefile b/Examples/ocaml/class/Makefile new file mode 100644 index 000000000..4cb4ef3dd --- /dev/null +++ b/Examples/ocaml/class/Makefile @@ -0,0 +1,31 @@ +TOP = ../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = +SRCS = example.c +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml +OBJS = example.o + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run + +build: static + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + ocaml_static_cpp + +static_top: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + ocaml_static_cpp_toplevel + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/class/example.c b/Examples/ocaml/class/example.c new file mode 100644 index 000000000..3bac43244 --- /dev/null +++ b/Examples/ocaml/class/example.c @@ -0,0 +1,28 @@ +/* File : example.c */ + +#include "example.h" +#define M_PI 3.14159265358979323846 + +/* Move the shape to a new location */ +void Shape::move(double dx, double dy) { + x += dx; + y += dy; +} + +int Shape::nshapes = 0; + +double Circle::area() { + return M_PI*radius*radius; +} + +double Circle::perimeter() { + return 2*M_PI*radius; +} + +double Square::area() { + return width*width; +} + +double Square::perimeter() { + return 4*width; +} diff --git a/Examples/ocaml/class/example.h b/Examples/ocaml/class/example.h new file mode 100644 index 000000000..0dff185b2 --- /dev/null +++ b/Examples/ocaml/class/example.h @@ -0,0 +1,34 @@ +/* File : example.h */ + +class Shape { +public: + Shape() { + nshapes++; + } + virtual ~Shape() { + nshapes--; + } + double x, y; + void move(double dx, double dy); + virtual double area() = 0; + virtual double perimeter() = 0; + static int nshapes; +}; + +class Circle : public Shape { +private: + double radius; +public: + Circle(double r) : radius(r) { } + virtual double area(); + virtual double perimeter(); +}; + +class Square : public Shape { +private: + double width; +public: + Square(double w) : width(w) { } + virtual double area(); + virtual double perimeter(); +}; diff --git a/Examples/ocaml/class/example.i b/Examples/ocaml/class/example.i new file mode 100644 index 000000000..fbdf7249f --- /dev/null +++ b/Examples/ocaml/class/example.i @@ -0,0 +1,9 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" diff --git a/Examples/ocaml/class/runme.ml b/Examples/ocaml/class/runme.ml new file mode 100644 index 000000000..37993aee4 --- /dev/null +++ b/Examples/ocaml/class/runme.ml @@ -0,0 +1,57 @@ +(* file: runme.ml + + This file illustrates the proxy class C++ interface generated + by SWIG. *) + +open Swig +open Example + +let repr o = + Printf.sprintf "<%s at %#x>" (o -> ":classof" () as string) (o -> "&" () as int) + +(* ----- Object creation ----- *) + +let _ = print_endline "Creating some objects:" +let c = new_Circle '(10) +let _ = Printf.printf " Created circle %s\n" (repr c) +let s = new_Square '(10) +let _ = Printf.printf " Created square %s\n" (repr s) + +(* ----- Access a static member ----- *) + +let _ = Printf.printf "\nA total of %d shapes were created\n" (_Shape_nshapes '() as int) + +(* ----- Member data access ----- *) + +(* Set the location of the object *) + +let _ = c -> "[x]" (20) +let _ = c -> "[y]" (30) + +(* Temp var to work around a swigp4 bug (it doesn't properly handle "-" in some cases). *) +let arg = (-10. to float) +let _ = s -> "[x]" (arg) +let _ = s -> "[y]" (5) + +let _ = print_endline "\nHere is their current position:" +let _ = Printf.printf " Circle = (%f, %f)\n" (c -> "[x]" () as float) (c -> "[y]" () as float) +let _ = Printf.printf " Square = (%f, %f)\n" (s -> "[x]" () as float) (s -> "[y]" () as float) + +(* ----- Call some methods ----- *) + +let _ = print_endline "\nHere are some properties of the shapes:" + +let _ = List.iter (fun o -> + Printf.printf " %s\n" (repr o); + Printf.printf " area = %f\n" (o -> area () as float); + Printf.printf " perimeter = %f\n" (o -> perimeter () as float) + ) [c; s] + +let _ = print_endline "\nGuess I'll clean up now" + +(* Note: this invokes the virtual destructor *) +let _ = c -> "~" () +let _ = s -> "~" () + +let _ = Printf.printf "%d shapes remain\n" (_Shape_nshapes '() as int) +let _ = print_endline "Goodbye" From a851e0a9ac448e21754f16c4e0978535049682da Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 11 Jan 2019 17:59:23 -0700 Subject: [PATCH 1271/2031] [OCaml] Re-enable the using_protected unit test Use the [member-variable] syntax in using_protected_runme.ml as required by the OCaml module's documentation and implementation. Fix the return type for vec_write() in example.h in the OCaml stl example. --- Examples/ocaml/class/runme.ml | 2 +- Examples/ocaml/stl/example.h | 2 +- Examples/test-suite/ocaml/Makefile.in | 1 - Examples/test-suite/ocaml/using_protected_runme.ml | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Examples/ocaml/class/runme.ml b/Examples/ocaml/class/runme.ml index 37993aee4..5e7b1f26c 100644 --- a/Examples/ocaml/class/runme.ml +++ b/Examples/ocaml/class/runme.ml @@ -41,7 +41,7 @@ let _ = Printf.printf " Square = (%f, %f)\n" (s -> "[x]" () as float) (s -> " let _ = print_endline "\nHere are some properties of the shapes:" -let _ = List.iter (fun o -> +let _ = List.iter (fun o -> Printf.printf " %s\n" (repr o); Printf.printf " area = %f\n" (o -> area () as float); Printf.printf " perimeter = %f\n" (o -> perimeter () as float) diff --git a/Examples/ocaml/stl/example.h b/Examples/ocaml/stl/example.h index df5762bfc..da1d50e22 100644 --- a/Examples/ocaml/stl/example.h +++ b/Examples/ocaml/stl/example.h @@ -8,7 +8,7 @@ using std::string; -double vec_write(std::vector v) { +void vec_write(std::vector v) { int n = 0; for( std::vector::iterator i = v.begin(); i != v.end(); diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 661540bc4..5e4960169 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -39,7 +39,6 @@ nested_directors \ preproc_constants \ smart_pointer_inherit \ typedef_mptr \ -using_protected \ FAILING_C_TESTS = \ enums \ diff --git a/Examples/test-suite/ocaml/using_protected_runme.ml b/Examples/test-suite/ocaml/using_protected_runme.ml index 4dc4fe1c9..29647c288 100644 --- a/Examples/test-suite/ocaml/using_protected_runme.ml +++ b/Examples/test-suite/ocaml/using_protected_runme.ml @@ -2,7 +2,7 @@ open Swig open Using_protected let f = new_FooBar C_void -let _ = (invoke f) "x" (C_int 3) +let _ = (invoke f) "[x]" (C_int 3) let _ = if (invoke f) "blah" (C_int 4) <> (C_int 4) then raise (Failure "blah(int)") From ded4abab62da503f399221bb625e460a0a6f6c06 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 11 Jan 2019 21:31:42 -0700 Subject: [PATCH 1272/2031] Some renaming Add OCaml to Tools/testflags.py. --- Examples/test-suite/ocaml/Makefile.in | 8 ++++---- Tools/testflags.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 79dcafd7f..9128b3720 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -96,11 +96,11 @@ swig.cmo: swigp4.cmi: env SWIG_LIB=$(SWIG_LIB_DIR) $(SWIGEXE) -ocaml -co swigp4.ml $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml -extra_obs: swig.cmi swig.cmo swigp4.cmi +extra_objects: swig.cmi swig.cmo swigp4.cmi -$(C_TEST_CASES:=.ctest): extra_obs -$(CPP_TEST_CASES:=.cpptest): extra_obs -$(MULTI_CPP_TEST_CASES:=.multicpptest): extra_obs +$(C_TEST_CASES:=.ctest): extra_objects +$(CPP_TEST_CASES:=.cpptest): extra_objects +$(MULTI_CPP_TEST_CASES:=.multicpptest): extra_objects # Clean %.clean: diff --git a/Tools/testflags.py b/Tools/testflags.py index a65299f0a..ac8048e5f 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -12,6 +12,7 @@ def get_cflags(language, std, compiler): "java":"-Werror " + c_common, "javascript":"-Werror " + c_common, "lua":"-Werror " + c_common, + "ocaml":"-Werror " + c_common, "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, "php":"-Werror " + c_common, @@ -41,6 +42,7 @@ def get_cxxflags(language, std, compiler): "java":"-Werror " + cxx_common, "javascript":"-Werror " + cxx_common + " -Wno-error=unused-function", # Until overload_rename is fixed for node "lua":"-Werror " + cxx_common, + "ocaml":"-Werror " + cxx_common, "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, "php":"-Werror " + cxx_common, From e5b470327b67f36a1367eda148d51bd090119958 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 11 Jan 2019 22:26:11 -0700 Subject: [PATCH 1273/2031] [OCaml] Runtime tests for abstract_access, abstract_typedef and some others Add runtime tests for abstract_access, abstract_typedef, abstract_typedef2, abstract_virtual, aggregate, cast_operator, and constover. The aggregate and cast_operator tests are based on the corresponding ruby tests, and the rest are based on python tests. --- .../test-suite/ocaml/abstract_access_runme.ml | 5 +++++ .../test-suite/ocaml/abstract_typedef2_runme.ml | 4 ++++ .../test-suite/ocaml/abstract_typedef_runme.ml | 6 ++++++ .../test-suite/ocaml/abstract_virtual_runme.ml | 5 +++++ Examples/test-suite/ocaml/aggregate_runme.ml | 15 +++++++++++++++ Examples/test-suite/ocaml/cast_operator_runme.ml | 5 +++++ Examples/test-suite/ocaml/constover_runme.ml | 16 ++++++++++++++++ 7 files changed, 56 insertions(+) create mode 100644 Examples/test-suite/ocaml/abstract_access_runme.ml create mode 100644 Examples/test-suite/ocaml/abstract_typedef2_runme.ml create mode 100644 Examples/test-suite/ocaml/abstract_typedef_runme.ml create mode 100644 Examples/test-suite/ocaml/abstract_virtual_runme.ml create mode 100644 Examples/test-suite/ocaml/aggregate_runme.ml create mode 100644 Examples/test-suite/ocaml/cast_operator_runme.ml create mode 100644 Examples/test-suite/ocaml/constover_runme.ml diff --git a/Examples/test-suite/ocaml/abstract_access_runme.ml b/Examples/test-suite/ocaml/abstract_access_runme.ml new file mode 100644 index 000000000..77ad88667 --- /dev/null +++ b/Examples/test-suite/ocaml/abstract_access_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Abstract_access + +let d = new_D '() +let _ = assert ((d -> "do_x" () as int) = 1) diff --git a/Examples/test-suite/ocaml/abstract_typedef2_runme.ml b/Examples/test-suite/ocaml/abstract_typedef2_runme.ml new file mode 100644 index 000000000..64aa19b91 --- /dev/null +++ b/Examples/test-suite/ocaml/abstract_typedef2_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Abstract_typedef2 + +let a = new_A_UF '() diff --git a/Examples/test-suite/ocaml/abstract_typedef_runme.ml b/Examples/test-suite/ocaml/abstract_typedef_runme.ml new file mode 100644 index 000000000..728c25b3b --- /dev/null +++ b/Examples/test-suite/ocaml/abstract_typedef_runme.ml @@ -0,0 +1,6 @@ +open Swig +open Abstract_typedef + +let e = new_Engine '() +let a = new_A '() +let _ = assert ((a -> "write" (e) as bool) = true) diff --git a/Examples/test-suite/ocaml/abstract_virtual_runme.ml b/Examples/test-suite/ocaml/abstract_virtual_runme.ml new file mode 100644 index 000000000..60f4f4ab7 --- /dev/null +++ b/Examples/test-suite/ocaml/abstract_virtual_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Abstract_virtual + +let d = new_D '() +let e = new_E '() diff --git a/Examples/test-suite/ocaml/aggregate_runme.ml b/Examples/test-suite/ocaml/aggregate_runme.ml new file mode 100644 index 000000000..f8fff0f30 --- /dev/null +++ b/Examples/test-suite/ocaml/aggregate_runme.ml @@ -0,0 +1,15 @@ +open Swig +open Aggregate + +let _ = + assert((_move (_UP '()) as int) = (_UP '() as int)); + assert((_move (_DOWN '()) as int) = (_DOWN '() as int)); + assert((_move (_LEFT '()) as int) = (_LEFT '() as int)); + assert((_move (_RIGHT '()) as int) = (_RIGHT '() as int)); +;; + +let _ = + try + _move(0 to int) + with Failure _ -> exit 0 +let _ = raise (Failure "0 test failed") diff --git a/Examples/test-suite/ocaml/cast_operator_runme.ml b/Examples/test-suite/ocaml/cast_operator_runme.ml new file mode 100644 index 000000000..99c390a19 --- /dev/null +++ b/Examples/test-suite/ocaml/cast_operator_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Cast_operator + +let a = new_A '() +let _ = assert ((a -> "tochar" () as string) = "hi") diff --git a/Examples/test-suite/ocaml/constover_runme.ml b/Examples/test-suite/ocaml/constover_runme.ml new file mode 100644 index 000000000..0ca2a5c01 --- /dev/null +++ b/Examples/test-suite/ocaml/constover_runme.ml @@ -0,0 +1,16 @@ +open Swig +open Constover + +let test_str = "test" to string +let _ = + assert ((_test (test_str) as string) = "test"); + assert ((_test_pconst (test_str) as string) = "test_pconst"); +;; + +let f = new_Foo '() +let _ = + assert ((f -> "test" (test_str) as string) = "test"); + assert ((f -> "test_pconst" (test_str) as string) = "test_pconst"); + assert ((f -> "test_constm" (test_str) as string) = "test_constmethod"); + assert ((f -> "test_pconstm" (test_str) as string) = "test_pconstmethod"); +;; From 48d9e3bc0204acf61c8da31ab03040515393086b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Jan 2019 13:42:29 +0000 Subject: [PATCH 1274/2031] Fix OCaml version detection if caml/version.h is not available Needed for OCaml versions < 4.02.0 Issue #1403 --- Lib/ocaml/ocamldec.swg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index 4f705b225..287760eaf 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -23,7 +23,13 @@ SWIGEXT { #include #include #include + +#if defined(CAMLassert) +/* Both this macro and version.h were introduced in version 4.02.0 */ #include +#else +#define OCAML_VERSION 0 /* Unknown, but < 40200 */ +#endif #define caml_array_set swig_caml_array_set From 3075eccdd6efb56c92b6423cd256de815d76057f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Jan 2019 13:55:10 +0000 Subject: [PATCH 1275/2031] Add changes entry for fixing OCaml int64_t compile problem --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index bbf7a54af..75dfbecf5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-12: ZackerySpytz + [OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using + int64_t instead of int64. + 2019-01-07: wsfulton #358 Add VOID to windows.i From b82d3007f3754cf321838fe4e78115b2d8b3e85b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Jan 2019 14:09:37 +0000 Subject: [PATCH 1276/2031] ocaml test-suite is now passing in Travis --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f622bc85..7de1eb6c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -368,12 +368,6 @@ matrix: env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required dist: trusty - # Lots of failing tests currently - - compiler: gcc - os: linux - env: SWIGLANG=ocaml - sudo: required - dist: trusty # Sometimes hits the Travis 50 minute time limit - compiler: gcc os: linux From 83df4e8ed678e9e7e5b8ce57a4b20990f163cacd Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 13 Jan 2019 17:28:00 -0700 Subject: [PATCH 1277/2031] [OCaml] Fix and re-enable the string_simple, minherit, and unions tests copy_string() is a macro in the OCaml C API, so rename the function to copy_str(). Add a runtime test. The minherit runtime test was fixed by b64d685. Use the proper syntax for accessing member variables in unions_runme.ml --- .../javascript/string_simple_runme.js | 2 +- Examples/test-suite/ocaml/Makefile.in | 3 --- .../test-suite/ocaml/string_simple_runme.ml | 9 +++++++ Examples/test-suite/ocaml/unions_runme.ml | 24 +++++++++---------- Examples/test-suite/string_simple.i | 4 ++-- Lib/ocaml/std_string.i | 2 +- Lib/ocaml/std_vector.i | 2 +- 7 files changed, 26 insertions(+), 20 deletions(-) create mode 100644 Examples/test-suite/ocaml/string_simple_runme.ml diff --git a/Examples/test-suite/javascript/string_simple_runme.js b/Examples/test-suite/javascript/string_simple_runme.js index 39ae84e9e..71fbb7bd0 100644 --- a/Examples/test-suite/javascript/string_simple_runme.js +++ b/Examples/test-suite/javascript/string_simple_runme.js @@ -3,7 +3,7 @@ var string_simple = require("string_simple"); // Test unicode string var str = "olé"; -var copy = string_simple.copy_string(str); +var copy = string_simple.copy_str(str); if (str !== copy) { throw "Error: copy is not equal: original="+str+", copy="+copy; diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 9128b3720..3036d90c0 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -35,7 +35,6 @@ director_using \ enum_thorough \ li_windows \ member_pointer_const \ -minherit \ nested_directors \ preproc_constants \ smart_pointer_inherit \ @@ -45,8 +44,6 @@ using_protected \ FAILING_C_TESTS = \ enums \ preproc_constants_c \ -string_simple \ -unions \ ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) diff --git a/Examples/test-suite/ocaml/string_simple_runme.ml b/Examples/test-suite/ocaml/string_simple_runme.ml new file mode 100644 index 000000000..327fb85d2 --- /dev/null +++ b/Examples/test-suite/ocaml/string_simple_runme.ml @@ -0,0 +1,9 @@ +open Swig +open String_simple + +let str = "olé" + +let copy = _copy_str (C_string str) as string + +let _ = if str <> copy then + raise (Failure ("Error: copy is not equal: original="^str^", copy="^copy)) diff --git a/Examples/test-suite/ocaml/unions_runme.ml b/Examples/test-suite/ocaml/unions_runme.ml index cbf1628ac..c451cb2be 100644 --- a/Examples/test-suite/ocaml/unions_runme.ml +++ b/Examples/test-suite/ocaml/unions_runme.ml @@ -8,21 +8,21 @@ let b = new_BigStruct C_void let c = new_UnionTest C_void let d = new_EmbeddedUnionTest C_void -let _ = (invoke a) "jill" (C_short 3) -let _ = (invoke b) "jack" (C_char 'a') (* Int conversion *) -let _ = (invoke b) "smallstruct" a (* Put a in b *) -let _ = (invoke c) "bs" b +let _ = (invoke a) "[jill]" (C_short 3) +let _ = (invoke b) "[jack]" (C_char 'a') (* Int conversion *) +let _ = (invoke b) "[smallstruct]" a (* Put a in b *) +let _ = (invoke c) "[bs]" b -let _ = if get_int ((invoke a) "jill" C_void) != 3 then +let _ = if get_int ((invoke a) "[jill]" C_void) != 3 then raise (Failure "jill value is not preserved") -let _ = if get_int ((invoke b) "jack" C_void) != (int_of_char 'a') then +let _ = if get_int ((invoke b) "[jack]" C_void) != (int_of_char 'a') then raise (Failure "jack value is not preserved") -let _ = if get_int ((invoke ((invoke b) "smallstruct" C_void)) - "jill" C_void) != 3 then +let _ = if get_int ((invoke ((invoke b) "[smallstruct]" C_void)) + "[jill]" C_void) != 3 then raise (Failure "jill value is not embedded in bigstruct") -let _ = if get_int ((invoke ((invoke c) "bs" C_void)) - "jack" C_void) != (int_of_char 'a') then +let _ = if get_int ((invoke ((invoke c) "[bs]" C_void)) + "[jack]" C_void) != (int_of_char 'a') then raise (Failure "union set of bigstruct did not take") -let _ = if get_int ((invoke ((invoke c) "ss" C_void)) - "jill" C_void) != (int_of_char 'a') then +let _ = if get_int ((invoke ((invoke c) "[ss]" C_void)) + "[jill]" C_void) != (int_of_char 'a') then raise (Failure "corresponding union values are not the same") diff --git a/Examples/test-suite/string_simple.i b/Examples/test-suite/string_simple.i index c319aa1ef..537daa570 100644 --- a/Examples/test-suite/string_simple.i +++ b/Examples/test-suite/string_simple.i @@ -1,10 +1,10 @@ %module string_simple -%newobject copy_string; +%newobject copy_str; %inline %{ #include -const char* copy_string(const char* str) { +const char* copy_str(const char* str) { size_t len = strlen(str); char* newstring = (char*) malloc(len + 1); strcpy(newstring, str); diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index bd5be0da2..b70b895f6 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -114,7 +114,7 @@ char **c_charptr_array( const std::vector &str_v ); let string_array_to_vector sa = let nv = _new_StringVector C_void in - array_to_vector nv (fun x -> C_string x) sa ; nv + ignore (array_to_vector nv (fun x -> C_string x) sa) ; nv let c_string_array ar = _c_charptr_array (string_array_to_vector ar) diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index 53d107447..6f82058b5 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -71,7 +71,7 @@ namespace std { let array_to_vector v argcons array = for i = 0 to (Array.length array) - 1 do - (invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ]) + ignore ((invoke v) "set" (C_list [ C_int i ; (argcons array.(i)) ])) done ; v From 5b6c57e6ae507549dc2d182a10054a00739f75fe Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 13 Jan 2019 22:44:31 -0700 Subject: [PATCH 1278/2031] [OCaml] Runtime tests for constructor_rename, cpp_nodefault and some others Add runtime tests for constructor_rename, cpp_nodefault, extend, extend_special_variables, extend_template, extern_c, and global_ns_arg. --- .../ocaml/constructor_rename_runme.ml | 5 ++++ .../test-suite/ocaml/cpp_nodefault_runme.ml | 18 +++++++++++++ Examples/test-suite/ocaml/extend_runme.ml | 26 +++++++++++++++++++ .../ocaml/extend_special_variables_runme.ml | 14 ++++++++++ .../test-suite/ocaml/extend_template_runme.ml | 8 ++++++ Examples/test-suite/ocaml/extern_c_runme.ml | 4 +++ .../test-suite/ocaml/global_ns_arg_runme.ml | 5 ++++ 7 files changed, 80 insertions(+) create mode 100644 Examples/test-suite/ocaml/constructor_rename_runme.ml create mode 100644 Examples/test-suite/ocaml/cpp_nodefault_runme.ml create mode 100644 Examples/test-suite/ocaml/extend_runme.ml create mode 100644 Examples/test-suite/ocaml/extend_special_variables_runme.ml create mode 100644 Examples/test-suite/ocaml/extend_template_runme.ml create mode 100644 Examples/test-suite/ocaml/extern_c_runme.ml create mode 100644 Examples/test-suite/ocaml/global_ns_arg_runme.ml diff --git a/Examples/test-suite/ocaml/constructor_rename_runme.ml b/Examples/test-suite/ocaml/constructor_rename_runme.ml new file mode 100644 index 000000000..5e5553838 --- /dev/null +++ b/Examples/test-suite/ocaml/constructor_rename_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Constructor_rename + +let x = new_RenamedConstructor '() +let _ = assert ((x -> ":classof" () as string) = "Foo") diff --git a/Examples/test-suite/ocaml/cpp_nodefault_runme.ml b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml new file mode 100644 index 000000000..51809c2ef --- /dev/null +++ b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml @@ -0,0 +1,18 @@ +open Swig +open Cpp_nodefault + +let foo1 = new_Foo '(1, 2) +let _ = foo1 -> "[a]" (5) +let _ = assert ((foo1 -> "[a]" () as int) = 5) + +let foo2 = _create '(1, 2) +let _ = _consume '(foo1,foo2) + +let bar1 = new_Bar '() +let gvar = _gvar '() +let args = (C_list [ gvar ; foo2 ]) +let _ = bar1 -> "consume" (args) +let args = '(1, 2) +let foo3 = bar1 -> "create" (args) +let _ = foo3 -> "[a]" (6) +let _ = assert ((foo3 -> "[a]" () as int) = 6) diff --git a/Examples/test-suite/ocaml/extend_runme.ml b/Examples/test-suite/ocaml/extend_runme.ml new file mode 100644 index 000000000..695282f9c --- /dev/null +++ b/Examples/test-suite/ocaml/extend_runme.ml @@ -0,0 +1,26 @@ +open Swig +open Extend + +let _ = + let base1 = new_Base '() and base2 = new_Base '(10) in + assert ((base1 -> "[value]" () as int) = 0); + assert ((base2 -> "[value]" () as int) = 10); + let cint = C_int 5 in + assert ((base1 -> "method" (cint) as int) = 5); + assert ((_Base_zeroVal '() as int) = 0); + assert ((base2 -> "currentValue" () as int) = 10); + let cint = C_int 7 in + assert ((base2 -> "extendmethod" (cint) as int) = 14); +;; + +let _ = + let der1 = new_Derived '(0) and der2 = new_Derived '(17) in + assert ((der1 -> "[value]" () as int) = 0); + let cint = C_int 5 in + assert ((der1 -> "method" (cint) as int) = 10); + assert ((der2 -> "[value]" () as int) = 34); + let cfloat = C_float 200. in + ignore (der2 -> "[extendval]" (cfloat)); + assert (abs_float ((der2 -> "[actualval]" () as float) -. 2.) < 0.001); + assert (abs_float ((der2 -> "[extendval]" () as float) -. 200.) < 0.001); +;; diff --git a/Examples/test-suite/ocaml/extend_special_variables_runme.ml b/Examples/test-suite/ocaml/extend_special_variables_runme.ml new file mode 100644 index 000000000..387d8fd0a --- /dev/null +++ b/Examples/test-suite/ocaml/extend_special_variables_runme.ml @@ -0,0 +1,14 @@ +open Swig +open Extend_special_variables + +let f = new_ForExtensionNewName '() +let s = f -> "extended_renamed" () as string +let s2 = f -> "extended_renamed" (10) as string + +let _ = + assert (s = "name:extended symname:extended_renamed wrapname: overname:__SWIG_0 decl:ForExtension::extended() fulldecl:char const * ForExtension::extended() parentclasssymname:ForExtensionNewName parentclassname:ForExtension") + assert (s2 = "name:extended symname:extended_renamed wrapname: overname:__SWIG_1 decl:ForExtension::extended(int) fulldecl:char const * ForExtension::extended(int) parentclasssymname:ForExtensionNewName parentclassname:ForExtension") +;; + +let e = new_ExtendTemplateInt '() +let _ = e -> "extending" () diff --git a/Examples/test-suite/ocaml/extend_template_runme.ml b/Examples/test-suite/ocaml/extend_template_runme.ml new file mode 100644 index 000000000..2d611a14a --- /dev/null +++ b/Examples/test-suite/ocaml/extend_template_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Extend_template + +let f = new_Foo_0 '() +let _ = + assert((f -> "test1" (37) as int) = 37); + assert((f -> "test2" (42) as int) = 42); +;; diff --git a/Examples/test-suite/ocaml/extern_c_runme.ml b/Examples/test-suite/ocaml/extern_c_runme.ml new file mode 100644 index 000000000..18e672255 --- /dev/null +++ b/Examples/test-suite/ocaml/extern_c_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Extern_c + +let _ = _RealFunction '(2) diff --git a/Examples/test-suite/ocaml/global_ns_arg_runme.ml b/Examples/test-suite/ocaml/global_ns_arg_runme.ml new file mode 100644 index 000000000..a78910db4 --- /dev/null +++ b/Examples/test-suite/ocaml/global_ns_arg_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Global_ns_arg + +let _ = assert ((_foo '(1) as int) = 1) +let _ = assert ((_bar_fn '(1) as int) = 1) From 05589508a6aca2866210dfda27e79d12abd8f5f6 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 14 Jan 2019 20:45:13 -0700 Subject: [PATCH 1279/2031] [OCaml] Add the caml_ prefix to some OCaml functions In OCaml 3.08.0, many functions in the OCaml C API were renamed to include a caml_ prefix. Their previous names were retained as macros in caml/compatibility.h and were (apparently) deprecated. Rename occurrences of alloc_string, alloc_tuple, callback, callback2, callback3, copy_double, copy_int64, copy_string, failwith, and modify in the OCaml module. The OCaml module requires OCaml >= 3.08.3, so this change is safe for all supported OCaml versions. --- Lib/exception.i | 2 +- Lib/ocaml/carray.i | 4 ++-- Lib/ocaml/director.swg | 2 +- Lib/ocaml/ocaml.swg | 50 ++++++++++++++++++++-------------------- Lib/ocaml/ocamldec.swg | 4 ++-- Lib/ocaml/typemaps.i | 20 ++++++++-------- Source/Modules/ocaml.cxx | 6 ++--- 7 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Lib/exception.i b/Lib/exception.i index 3e7c7fd8e..c75d71483 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -131,7 +131,7 @@ SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { SWIGINTERN void SWIG_exception_(int code, const char *msg) { char msg_buf[OCAML_MSG_BUF_LEN]; sprintf( msg_buf, "Exception(%d): %s\n", code, msg ); - failwith( msg_buf ); + caml_failwith( msg_buf ); } #define SWIG_exception(a,b) SWIG_exception_((a),(b)) %} diff --git a/Lib/ocaml/carray.i b/Lib/ocaml/carray.i index bbf1ddd58..f968edfff 100644 --- a/Lib/ocaml/carray.i +++ b/Lib/ocaml/carray.i @@ -89,7 +89,7 @@ type _value = c_obj caml_array_set ($result, i, - callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); + caml_callback(*fromval,caml_val_ptr((void *)&$1[i],$*1_descriptor))); } else { caml_array_set ($result, @@ -119,7 +119,7 @@ type _value = c_obj caml_array_set ($result, i, - callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), + caml_callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"), *caml_named_value("$type_marker"), Val_int($1[i]))); } diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index 158cbfeec..86b2cd4e2 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -93,7 +93,7 @@ namespace Swig { void swig_disown() const { if (!swig_disown_flag) { swig_disown_flag=true; - callback(*caml_named_value("caml_obj_disown"),swig_self); + caml_callback(*caml_named_value("caml_obj_disown"),swig_self); } } }; diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 49ec2e7d5..d0007f856 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -189,22 +189,22 @@ extern "C" { while( lst && Is_block(lst) ) { if( v && v != Val_unit ) { - vt = alloc_tuple(2); + vt = caml_alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { - v = lh = alloc_tuple(2); + v = lh = caml_alloc_tuple(2); } SWIG_Store_field(v,0,SWIG_Field(lst,0)); lst = SWIG_Field(lst,1); } if( v && Is_block(v) ) { - vt = alloc_tuple(2); + vt = caml_alloc_tuple(2); SWIG_Store_field(v,1,vt); v = vt; } else { - v = lh = alloc_tuple(2); + v = lh = caml_alloc_tuple(2); } SWIG_Store_field(v,0,elt); SWIG_Store_field(v,1,Val_unit); @@ -232,7 +232,7 @@ extern "C" { else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_nth(arr,0)); else - failwith("Need array or list"); + caml_failwith("Need array or list"); } SWIGINTERN int caml_array_len( CAML_VALUE arr ) { @@ -242,7 +242,7 @@ extern "C" { else if( SWIG_Tag_val(arr) == C_list ) CAMLreturn(caml_list_length(arr)); else - failwith("Need array or list"); + caml_failwith("Need array or list"); } SWIGINTERN CAML_VALUE caml_swig_alloc(int x,int y) { @@ -253,7 +253,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(1,C_array); - SWIG_Store_field(vv,0,alloc_tuple(n)); + SWIG_Store_field(vv,0,caml_alloc_tuple(n)); CAMLreturn(vv); } @@ -317,7 +317,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(lv); lv = caml_swig_alloc(1,C_int64); - SWIG_Store_field(lv,0,copy_int64(l)); + SWIG_Store_field(lv,0,caml_copy_int64(l)); CAMLreturn(lv); } @@ -325,7 +325,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(ulv); ulv = caml_swig_alloc(1,C_int64); - SWIG_Store_field(ulv,0,copy_int64(ul)); + SWIG_Store_field(ulv,0,caml_copy_int64(ul)); CAMLreturn(ulv); } @@ -333,7 +333,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_float); - SWIG_Store_field(fv,0,copy_double((double)f)); + SWIG_Store_field(fv,0,caml_copy_double((double)f)); CAMLreturn(fv); } @@ -341,7 +341,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(fv); fv = caml_swig_alloc(1,C_double); - SWIG_Store_field(fv,0,copy_double(d)); + SWIG_Store_field(fv,0,caml_copy_double(d)); CAMLreturn(fv); } @@ -349,8 +349,8 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(vv); vv = caml_swig_alloc(2,C_ptr); - SWIG_Store_field(vv,0,copy_int64((long)p)); - SWIG_Store_field(vv,1,copy_int64((long)info)); + SWIG_Store_field(vv,0,caml_copy_int64((long)p)); + SWIG_Store_field(vv,1,caml_copy_int64((long)info)); CAMLreturn(vv); } @@ -359,7 +359,7 @@ extern "C" { SWIG_CAMLlocal1(vv); if( !p ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); - SWIG_Store_field(vv,0,copy_string(p)); + SWIG_Store_field(vv,0,caml_copy_string(p)); CAMLreturn(vv); } @@ -368,7 +368,7 @@ extern "C" { SWIG_CAMLlocal1(vv); if( !p || len < 0 ) CAMLreturn(caml_val_ptr( (void *)p, 0 )); vv = caml_swig_alloc(1,C_string); - SWIG_Store_field(vv,0,alloc_string(len)); + SWIG_Store_field(vv,0,caml_alloc_string(len)); memcpy(String_val(SWIG_Field(vv,0)),p,len); CAMLreturn(vv); } @@ -376,9 +376,9 @@ extern "C" { #define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name) SWIGINTERN CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) { CAMLparam0(); - CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"), + CAMLreturn(caml_callback2(*caml_named_value("caml_create_object_fn"), caml_val_ptr(v,type), - copy_string(name))); + caml_copy_string(name))); } SWIGINTERN long caml_long_val_full( CAML_VALUE v, char *name ) { @@ -408,12 +408,12 @@ extern "C" { case C_enum: { SWIG_CAMLlocal1(ret); CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); - if( !name ) failwith( "Not an enum conversion" ); - ret = callback2(*enum_to_int,*caml_named_value(name),v); + if( !name ) caml_failwith( "Not an enum conversion" ); + ret = caml_callback2(*enum_to_int,*caml_named_value(name),v); CAMLreturn(caml_long_val(ret)); } default: - failwith("No conversion to int"); + caml_failwith("No conversion to int"); } } @@ -442,7 +442,7 @@ extern "C" { CAMLreturn_type(Double_val(SWIG_Field(v,0))); default: fprintf( stderr, "Unknown block tag %d\n", SWIG_Tag_val(v) ); - failwith("No conversion to double"); + caml_failwith("No conversion to double"); } } @@ -470,7 +470,7 @@ extern "C" { case C_obj: CAMLreturn (caml_ptr_val_internal - (callback(*caml_named_value("caml_obj_ptr"),v), + (caml_callback(*caml_named_value("caml_obj_ptr"),v), out,descriptor)); case C_string: outptr = (void *)String_val(SWIG_Field(v,0)); @@ -497,7 +497,7 @@ extern "C" { if( !caml_ptr_val_internal( v, &out, descriptor ) ) CAMLreturn_type(out); else - failwith( "No appropriate conversion found." ); + caml_failwith( "No appropriate conversion found." ); } SWIGINTERN char *caml_string_val( CAML_VALUE v ) { @@ -581,7 +581,7 @@ extern "C" { static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) { CAML_VALUE pointer; - pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); + pointer = caml_callback(*caml_named_value("swig_find_type_info"), caml_val_int(0)); if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) { return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0)); } @@ -592,7 +592,7 @@ extern "C" { CAML_VALUE mod_pointer; mod_pointer = caml_val_ptr(pointer, NULL); - callback(*caml_named_value("swig_set_type_info"), mod_pointer); + caml_callback(*caml_named_value("swig_set_type_info"), mod_pointer); } #ifdef __cplusplus diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index 287760eaf..aea0ec9e5 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -63,7 +63,7 @@ SWIGEXT { #define SWIG_Store_field(block, offset, val) do{ \ mlsize_t caml__temp_offset = (offset); \ caml_value_t caml__temp_val = (val); \ - modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ + caml_modify (&SWIG_Field ((block), caml__temp_offset), caml__temp_val); \ }while(0) #define SWIG_Data_custom_val(v) ((void *) &SWIG_Field((v), 1)) @@ -126,7 +126,7 @@ CAMLextern int64 Int64_val(caml_value_t v); #define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata) #define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer) -#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else +#define SWIG_contract_assert(expr, msg) if(!(expr)) {caml_failwith(msg);} else SWIGINTERN int SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type); diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 3e0233ffa..bf2ddfe85 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -62,7 +62,7 @@ /* %typemap(out) SWIGTYPE & */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } @@ -72,7 +72,7 @@ /* %typemap(out) SWIGTYPE && */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *) &$1,$1_descriptor); } @@ -84,7 +84,7 @@ if( fromval ) { swig_result = caml_list_append(swig_result, - callback(*fromval,caml_val_ptr((void *) $1, + caml_callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = @@ -97,7 +97,7 @@ if( fromval ) { swig_result = caml_list_append(swig_result, - callback(*fromval,caml_val_ptr((void *) $1, + caml_callback(*fromval,caml_val_ptr((void *) $1, $1_descriptor))); } else { swig_result = @@ -121,7 +121,7 @@ $&1_ltype temp = new $ltype((const $1_ltype &) $1); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } @@ -135,7 +135,7 @@ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); memmove( temp, &$1, sizeof( $1_type ) ); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); } else { $result = caml_val_ptr ((void *)temp,$&1_descriptor); } @@ -234,7 +234,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %typemap(out) ArrayCarrier * { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } @@ -299,7 +299,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { - $result = callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); + $result = caml_callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); } else { $result = caml_val_ptr ((void *)$1,$1_descriptor); } @@ -321,7 +321,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %define %swigtype_array_fail(how,msg) %typemap(how) SWIGTYPE [] { - failwith(msg); + caml_failwith(msg); } %enddef @@ -343,7 +343,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %define %swig_enum_out(how) %typemap(how) enum SWIGTYPE { - $result = callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); + $result = caml_callback2(*caml_named_value(SWIG_MODULE "_int_to_enum"),*caml_named_value("$type_marker"),Val_int((int)$1)); } %enddef diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 09d3ba980..86701e0fc 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -68,7 +68,7 @@ public: director_prot_ctor_code = NewString(""); Printv(director_prot_ctor_code, "if ( $comparison ) { /* subclassed */\n", - " $director_new \n", "} else {\n", " failwith(\"accessing abstract class or protected constructor\"); \n", "}\n", NIL); + " $director_new \n", "} else {\n", " caml_failwith(\"accessing abstract class or protected constructor\"); \n", "}\n", NIL); director_multiple_inheritance = 1; director_language = 1; } @@ -733,7 +733,7 @@ public: "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); Printv(df->code, dispatch, "\n", NIL); - Printf(df->code, "failwith(\"No matching function for overloaded '%s'\");\n", iname); + Printf(df->code, "caml_failwith(\"No matching function for overloaded '%s'\");\n", iname); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); @@ -1583,7 +1583,7 @@ public: /* pass the method call on to the Python object */ Printv(w->code, "swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0); - Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name")); + Printf(w->code, "swig_result = " "caml_callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name")); /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { From c61c22105781fbf8bae88b7adbfd2652881d0176 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 15 Jan 2019 16:37:26 -0700 Subject: [PATCH 1280/2031] [OCaml] Fix the wrapping of static const member chars OCaml's constantWrapper() was adding unneeded quotes when wrapping static const member chars. Add runtime tests for char_constant, chartest, and static_const_member. --- .../test-suite/ocaml/char_constant_runme.ml | 16 ++++++++++ Examples/test-suite/ocaml/chartest_runme.ml | 25 ++++++++++++++++ .../ocaml/static_const_member_runme.ml | 9 ++++++ Source/Modules/ocaml.cxx | 30 ++----------------- 4 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 Examples/test-suite/ocaml/char_constant_runme.ml create mode 100644 Examples/test-suite/ocaml/chartest_runme.ml create mode 100644 Examples/test-suite/ocaml/static_const_member_runme.ml diff --git a/Examples/test-suite/ocaml/char_constant_runme.ml b/Examples/test-suite/ocaml/char_constant_runme.ml new file mode 100644 index 000000000..9d0ce6903 --- /dev/null +++ b/Examples/test-suite/ocaml/char_constant_runme.ml @@ -0,0 +1,16 @@ +open Swig +open Char_constant + +let _ = + assert (_CHAR_CONSTANT '() as char = 'x'); + assert (_STRING_CONSTANT '() as string = "xyzzy"); + assert (_ESC_CONST '() as char = '\x01'); + assert (_NULL_CONST '() as char = '\x00'); + assert (_SPECIALCHARA '() as char = 'A'); + assert (_SPECIALCHARB '() as char = 'B'); + assert (_SPECIALCHARC '() as char = 'C'); + assert (_SPECIALCHARD '() as char = 'D'); + assert (_SPECIALCHARE '() as char = 'E'); + assert (_ia '() as char = 'a'); + assert (_ib '() as char = 'b'); +;; diff --git a/Examples/test-suite/ocaml/chartest_runme.ml b/Examples/test-suite/ocaml/chartest_runme.ml new file mode 100644 index 000000000..3a2c81d03 --- /dev/null +++ b/Examples/test-suite/ocaml/chartest_runme.ml @@ -0,0 +1,25 @@ +open Swig +open Chartest + +let _ = + assert (_GetPrintableChar '() as char = 'a'); + assert (_GetUnprintableChar '() as char = '\127'); + assert (_printable_global_char '() as char = 'a'); + assert (_unprintable_global_char '() as char = '\127'); + assert (_globchar0 '() as char = '\x00'); + assert (_globchar1 '() as char = '\x01'); + assert (_globchar2 '() as char = '\n'); + assert (_globcharA '() as char = 'A'); + assert (_globcharB '() as char = 'B'); + assert (_globcharC '() as char = 'C'); + assert (_globcharD '() as char = 'D'); + assert (_globcharE '() as char = 'E'); + assert (_CharTestClass_memberchar0 '() as char = '\x00'); + assert (_CharTestClass_memberchar1 '() as char = '\x01'); + assert (_CharTestClass_memberchar2 '() as char = '\n'); + assert (_CharTestClass_membercharA '() as char = 'A'); + assert (_CharTestClass_membercharB '() as char = 'B'); + assert (_CharTestClass_membercharC '() as char = 'C'); + assert (_CharTestClass_membercharD '() as char = 'D'); + assert (_CharTestClass_membercharE '() as char = 'E'); +;; diff --git a/Examples/test-suite/ocaml/static_const_member_runme.ml b/Examples/test-suite/ocaml/static_const_member_runme.ml new file mode 100644 index 000000000..02dd2fe4b --- /dev/null +++ b/Examples/test-suite/ocaml/static_const_member_runme.ml @@ -0,0 +1,9 @@ +open Swig +open Static_const_member + +let _ = + assert (_X_PN '() as int = 0); + assert (_X_CN '() as int = 1); + assert (_X_EN '() as int = 2); + assert (_X_CHARTEST '() as char = 'A'); +;; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 09d3ba980..c2826ed64 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -905,10 +905,9 @@ public: virtual int constantWrapper(Node *n) { String *name = Getattr(n, "feature:symname"); SwigType *type = Getattr(n, "type"); - String *value = Getattr(n, "value"); + String *rawval = Getattr(n, "rawval"); + String *value = rawval ? rawval : Getattr(n, "value"); SwigType *qname = Getattr(n, "qualified:name"); - String *rvalue = NewString(""); - String *temp = 0; if (qname) value = qname; @@ -920,31 +919,8 @@ public: } // See if there's a typemap - Printv(rvalue, value, NIL); - if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 1)) { - temp = Copy(rvalue); - Clear(rvalue); - Printv(rvalue, "\"", temp, "\"", NIL); - Delete(temp); - } - if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 0)) { - temp = Copy(rvalue); - Clear(rvalue); - Printv(rvalue, "'", temp, "'", NIL); - Delete(temp); - } // Create variable and assign it a value - - Printf(f_header, "static %s = ", SwigType_lstr(type, name)); - bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); - if ((SwigType_type(type) == T_STRING)) { - Printf(f_header, "\"%s\";\n", value); - } else if (SwigType_type(type) == T_CHAR && !is_enum_item) { - Printf(f_header, "\'%s\';\n", value); - } else { - Printf(f_header, "%s;\n", value); - } - + Printf(f_header, "static %s = %s;\n", SwigType_lstr(type, name), value); SetFlag(n, "feature:immutable"); variableWrapper(n); return SWIG_OK; From 3f5c17824c5f20023bac58f7ebfc8de8532d6881 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 16 Jan 2019 04:12:27 +0100 Subject: [PATCH 1281/2031] Improve handling parameters clashing with language keywords Previously, only Python tried to preserve the original parameter name (by prepending or appending an underscore to it, but otherwise keeping the original name) if it conflicted with one of the language keywords, while all the other languages replaced the parameter name with a meaningless "argN" in this case. Now do this for all languages as this results in more readable generated code and there doesn't seem to be any reason to restrict this to Python only. --- Source/Modules/lang.cxx | 12 +++++++++--- Source/Modules/python.cxx | 15 --------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 96588dcc3..92445dc3f 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3602,7 +3602,7 @@ String *Language::makeParameterName(Node *n, Parm *p, int arg_num, bool setter) String *arg = 0; String *pn = Getattr(p, "name"); - // Use C parameter name unless it is a duplicate or an empty parameter name + // Check if parameter name is a duplicate. int count = 0; ParmList *plist = Getattr(n, "parms"); while (plist) { @@ -3610,8 +3610,14 @@ String *Language::makeParameterName(Node *n, Parm *p, int arg_num, bool setter) count++; plist = nextSibling(plist); } - String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0; - arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn); + + // If the parameter has no name at all or has a non-unique name, replace it with "argN". + if (!pn || count > 1) { + arg = NewStringf("arg%d", arg_num); + } else { + // Otherwise, try to use the original C name, but modify it if necessary to avoid conflicting with the language keywords. + arg = Swig_name_make(p, 0, pn, 0, 0); + } if (setter && Cmp(arg, "self") != 0) { // Some languages (C#) insist on calling the input variable "value" while diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 83858d44c..2eb704e06 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1591,21 +1591,6 @@ public: return ds; } - virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool = false) const { - // For the keyword arguments, we want to preserve the names as much as possible, - // so we only minimally rename them in Swig_name_make(), e.g. replacing "keyword" - // with "_keyword" if they have any name at all. - if (check_kwargs(n)) { - String *name = Getattr(p, "name"); - if (name) - return Swig_name_make(p, 0, name, 0, 0); - } - - // For the other cases use the general function which replaces arguments whose - // names clash with keywords with (less useful) "argN". - return Language::makeParameterName(n, p, arg_num); - } - /* ----------------------------------------------------------------------------- * addMissingParameterNames() * From 22158807fa36fe8fc5b8550236edcfe05c860105 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 16 Jan 2019 04:29:04 +0100 Subject: [PATCH 1282/2031] Add more tests for Python parameter renaming These tests were proposed by @wsfulton. See https://github.com/swig/swig/issues/1272 --- Examples/test-suite/autodoc.i | 8 ++++++++ Examples/test-suite/python/autodoc_runme.py | 2 ++ Examples/test-suite/python/keyword_rename_runme.py | 2 ++ 3 files changed, 12 insertions(+) diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 97c05d791..ec7307a35 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -148,3 +148,11 @@ bool is_python_builtin() { return true; } bool is_python_builtin() { return false; } #endif %} + +// Autodoc Python keywords +%warnfilter(SWIGWARN_PARSE_KEYWORD) process; +%feature(autodoc,0) process; +%feature("compactdefaultargs") process; +%inline %{ +int process(int from) { return from; } +%} diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 1350c6d67..ab963a748 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -202,3 +202,5 @@ check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)") check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >") check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip) check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger") + +check(inspect.getdoc(process), "process(_from) -> int") diff --git a/Examples/test-suite/python/keyword_rename_runme.py b/Examples/test-suite/python/keyword_rename_runme.py index 5646ce7d6..0bdd64b10 100644 --- a/Examples/test-suite/python/keyword_rename_runme.py +++ b/Examples/test-suite/python/keyword_rename_runme.py @@ -1,4 +1,6 @@ #!/usr/bin/env python import keyword_rename keyword_rename._in(1) +keyword_rename._in(_except=1) keyword_rename._except(1) +keyword_rename._except(_in=1) From a641966e0b06e748b745a17e5e8afdb2352e0d0b Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 16 Jan 2019 00:53:13 -0700 Subject: [PATCH 1283/2031] [OCaml] Add a callback example It is based on the the Python and Go examples. --- Examples/ocaml/callback/Makefile | 31 +++++++++++++++++++++++++++++++ Examples/ocaml/callback/example.c | 3 +++ Examples/ocaml/callback/example.h | 20 ++++++++++++++++++++ Examples/ocaml/callback/example.i | 10 ++++++++++ Examples/ocaml/callback/runme.ml | 30 ++++++++++++++++++++++++++++++ Examples/ocaml/check.list | 1 + Examples/ocaml/stl/example.i | 2 -- 7 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Examples/ocaml/callback/Makefile create mode 100644 Examples/ocaml/callback/example.c create mode 100644 Examples/ocaml/callback/example.h create mode 100644 Examples/ocaml/callback/example.i create mode 100644 Examples/ocaml/callback/runme.ml diff --git a/Examples/ocaml/callback/Makefile b/Examples/ocaml/callback/Makefile new file mode 100644 index 000000000..4cb4ef3dd --- /dev/null +++ b/Examples/ocaml/callback/Makefile @@ -0,0 +1,31 @@ +TOP = ../.. +SWIGEXE = $(TOP)/../swig +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib +SWIGOPT = +SRCS = example.c +TARGET = example +INTERFACE = example.i +PROGFILE = runme.ml +OBJS = example.o + +check: build + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run + +build: static + +static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + ocaml_static_cpp + +static_top: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ + ocaml_static_cpp_toplevel + +clean: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/callback/example.c b/Examples/ocaml/callback/example.c new file mode 100644 index 000000000..4ead01f58 --- /dev/null +++ b/Examples/ocaml/callback/example.c @@ -0,0 +1,3 @@ +/* File : example.c */ + +#include "example.h" diff --git a/Examples/ocaml/callback/example.h b/Examples/ocaml/callback/example.h new file mode 100644 index 000000000..12d888595 --- /dev/null +++ b/Examples/ocaml/callback/example.h @@ -0,0 +1,20 @@ +/* File : example.h */ + +#include + +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std::endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + + +class Caller { + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void call() { if (_callback) _callback->run(); } +}; diff --git a/Examples/ocaml/callback/example.i b/Examples/ocaml/callback/example.i new file mode 100644 index 000000000..584da73d9 --- /dev/null +++ b/Examples/ocaml/callback/example.i @@ -0,0 +1,10 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%feature("director") Callback; + +%include "example.h" + diff --git a/Examples/ocaml/callback/runme.ml b/Examples/ocaml/callback/runme.ml new file mode 100644 index 000000000..a7d705241 --- /dev/null +++ b/Examples/ocaml/callback/runme.ml @@ -0,0 +1,30 @@ +(* file: runme.ml + +This file illustrates cross-language polymorphism using directors. *) + +open Swig +open Example + +let new_OCamlCallback ob meth args = + match meth with + | "run" -> print_endline "OCamlCallback.run()"; C_void + | _ -> (invoke ob) meth args + +let caller = new_Caller '() + +let _ = print_endline "Adding and calling a normal C++ callback" +let _ = print_endline "----------------------------------------" + +let callback = new_Callback '() +let _ = caller -> "setCallback" (callback) +let _ = caller -> "call" () +let _ = caller -> "delCallback" (0) + +let _ = print_endline "\nAdding and calling an OCaml callback" +let _ = print_endline "------------------------------------" + +let callback = new_derived_object new_Callback (new_OCamlCallback) '() +let _ = caller -> "setCallback" (callback) +let _ = caller -> "call" () +let _ = caller -> "delCallback" (0) +let _ = print_endline "\nOCaml exit" diff --git a/Examples/ocaml/check.list b/Examples/ocaml/check.list index fb7317b3a..cab5a6545 100644 --- a/Examples/ocaml/check.list +++ b/Examples/ocaml/check.list @@ -1,5 +1,6 @@ # see top-level Makefile.in argout_ref +callback class contract scoped_enum diff --git a/Examples/ocaml/stl/example.i b/Examples/ocaml/stl/example.i index 19a80a605..214ac47a5 100644 --- a/Examples/ocaml/stl/example.i +++ b/Examples/ocaml/stl/example.i @@ -7,6 +7,4 @@ #define ENABLE_STRING_VECTOR %include stl.i -%feature("director"); - %include example.h From cf1624ebc4f4bbeb72956435ebe48c44192ad90d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Jan 2019 08:21:00 +0000 Subject: [PATCH 1284/2031] Python static method wrapper changes - Static method wrappers were using the 'fastproxy' approach by default. This is inconsistent with instance method wrappers. The fastproxy approach is now turned off by default to be consistent with instance methods. Static method wrappers can now also be controlled using the -fastproxy and -olddefs options. Example: struct Klass { static int statmethod(int a = 2); }; generates: class Klass(object): ... @staticmethod def statmethod(a=2): return _example.Klass_statmethod(a) instead of: class Klass(object): ... statmethod = staticmethod(_example.Klass_statmethod) - Modernise wrappers for static methods to use decorator syntax - @staticmethod. - Add missing runtime test for static class methods and using the actual class method. --- CHANGES.current | 35 ++++++++++++++++++++ Examples/test-suite/python/callback_runme.py | 3 ++ Source/Modules/python.cxx | 14 +++++--- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b9363f7d8..c81bdebde 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,41 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-16: wsfulton + Python static method wrapper changes + + - Static method wrappers were using the 'fastproxy' approach by default. + This is inconsistent with instance method wrappers. The fastproxy approach + is now turned off by default to be consistent with instance methods. + Static method wrappers can now also be controlled using the -fastproxy and + -olddefs options. + + Example: + + struct Klass { + static int statmethod(int a = 2); + }; + + generates by default: + + class Klass(object): + ... + @staticmethod + def statmethod(a=2): + return _example.Klass_statmethod(a) + + instead of the following (which can be restored by using -fastproxy): + + class Klass(object): + ... + statmethod = staticmethod(_example.Klass_statmethod) + + +- Modernise wrappers for static methods to use decorator syntax - @staticmethod. + +- Add missing runtime test for static class methods and using the actual class method. + + 2019-01-12: ZackerySpytz [OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using int64_t instead of int64. diff --git a/Examples/test-suite/python/callback_runme.py b/Examples/test-suite/python/callback_runme.py index ef7baad4e..91518fbf2 100644 --- a/Examples/test-suite/python/callback_runme.py +++ b/Examples/test-suite/python/callback_runme.py @@ -13,6 +13,9 @@ if foobar(3, _callback.foo) != foo(3): if foobar(3, foo) != foo(3): raise RuntimeError +if foobar(3, A.bar) != A.bar(3): + raise RuntimeError + if foobar(3, A_bar) != A_bar(3): raise RuntimeError diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 83858d44c..d3d157ddf 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4637,10 +4637,12 @@ public: } if (shadow) { - if (!Getattr(n, "feature:python:callback") && have_addtofunc(n)) { + bool fast = (fastproxy && !have_addtofunc(n)) || Getattr(n, "feature:callback"); + if (!fast || olddefs) { 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, "\n", tab4, "@staticmethod", NIL); Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); @@ -4649,12 +4651,14 @@ public: if (have_pythonappend(n)) { Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); Printv(f_shadow, indent_pythoncode(pythonappend(n), tab8, Getfile(n), Getline(n), "%pythonappend or %feature(\"pythonappend\")"), "\n", NIL); - Printv(f_shadow, tab8, "return val\n\n", NIL); + Printv(f_shadow, tab8, "return val\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(NSPACE_TODO, class_name, symname), callParms), "\n", NIL); } - Printv(f_shadow, tab4, symname, " = staticmethod(", symname, ")\n", NIL); - } else { + } + + // Below may result in a 2nd definition of the method when -olddefs is used. The Python interpreter will use the second definition as it overwrites the first. + if (fast) { Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); } From 7e9181d70e55e5cd966c15e4717508086f4ca93f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 16 Jan 2019 18:52:19 +0100 Subject: [PATCH 1285/2031] Update error messages test suite List the expected warnings about renaming "def" to "_def" too. --- Examples/test-suite/errors/swig_typemap_warn.stderr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/errors/swig_typemap_warn.stderr b/Examples/test-suite/errors/swig_typemap_warn.stderr index 5116dbc91..dde790024 100644 --- a/Examples/test-suite/errors/swig_typemap_warn.stderr +++ b/Examples/test-suite/errors/swig_typemap_warn.stderr @@ -3,5 +3,7 @@ swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 314: 'def' is a python keyword, renaming to '_def' swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int +swig_typemap_warn.i:7: Warning 314: 'def' is a python keyword, renaming to '_def' From 1bd1142d025e31e4f6fec5ea70deeb760416cc96 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 16 Jan 2019 20:10:37 +0000 Subject: [PATCH 1286/2031] Fix python callback test-suite failure --- Examples/test-suite/python/callback_runme.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/callback_runme.py b/Examples/test-suite/python/callback_runme.py index 91518fbf2..de8a372f6 100644 --- a/Examples/test-suite/python/callback_runme.py +++ b/Examples/test-suite/python/callback_runme.py @@ -13,8 +13,9 @@ if foobar(3, _callback.foo) != foo(3): if foobar(3, foo) != foo(3): raise RuntimeError -if foobar(3, A.bar) != A.bar(3): - raise RuntimeError +# Needs some more work for -builtin +# if foobar(3, A.bar) != A.bar(3): +# raise RuntimeError if foobar(3, A_bar) != A_bar(3): raise RuntimeError From cb426b107405f153e2374ed76f2f2f6605aa18bf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 Jan 2019 01:25:43 +0100 Subject: [PATCH 1287/2031] Enable keyword arguments for keyword_rename unit test This is required for the recently added Python test checking that an argument clashing with a Python keyword is also renamed when using keyword arguments and fixes this test failure when using -builtin Python option. --- Examples/test-suite/keyword_rename.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/keyword_rename.i b/Examples/test-suite/keyword_rename.i index 46c3338b3..23c01087d 100644 --- a/Examples/test-suite/keyword_rename.i +++ b/Examples/test-suite/keyword_rename.i @@ -4,6 +4,8 @@ %module keyword_rename +%feature("kwargs"); + #pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD %inline %{ From fa1a0a378cc73d00926d36752218b6e24832185a Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 16 Jan 2019 20:00:40 -0700 Subject: [PATCH 1288/2031] [OCaml] Fix dead code generation in overloaded function wrappers The OCaml module was generating dead code in the wrappers for overloaded functions. Only the generated dispatch function needs to allocate an array for the passed arguments. In addition, add overload_extend, overload_rename and overload_subtype runtime tests. --- Examples/test-suite/ocaml/overload_extend_runme.ml | 11 +++++++++++ Examples/test-suite/ocaml/overload_rename_runme.ml | 7 +++++++ Examples/test-suite/ocaml/overload_subtype_runme.ml | 8 ++++++++ Source/Modules/ocaml.cxx | 11 ----------- 4 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 Examples/test-suite/ocaml/overload_extend_runme.ml create mode 100644 Examples/test-suite/ocaml/overload_rename_runme.ml create mode 100644 Examples/test-suite/ocaml/overload_subtype_runme.ml diff --git a/Examples/test-suite/ocaml/overload_extend_runme.ml b/Examples/test-suite/ocaml/overload_extend_runme.ml new file mode 100644 index 000000000..3793cdbb0 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_extend_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Overload_extend + +let _ = + let f = new_Foo '() in + assert (f -> test () as int = 0); + assert (f -> test (3) as int = 1); + assert (f -> test ("hello") as int = 2); + assert (f -> test (3., 2.) as float = 5.); + assert (f -> test (3.) as float = 1003.) +;; diff --git a/Examples/test-suite/ocaml/overload_rename_runme.ml b/Examples/test-suite/ocaml/overload_rename_runme.ml new file mode 100644 index 000000000..9e012c0c5 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_rename_runme.ml @@ -0,0 +1,7 @@ +open Swig +open Overload_rename + +let _ = new_Foo (C_float 1.) +let _ = new_Foo (C_list [ C_float 1. ; C_float 1. ]) +let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ]) +let _ = new_Foo_int (C_list [ C_float 1. ; C_int 1 ; C_float 1. ]) diff --git a/Examples/test-suite/ocaml/overload_subtype_runme.ml b/Examples/test-suite/ocaml/overload_subtype_runme.ml new file mode 100644 index 000000000..6f0aeab56 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_subtype_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Overload_subtype + +let _ = + let f = new_Foo '() and b = new_Bar '() in + assert (_spam (f) as int = 1); + assert (_spam (b) as int = 2) +;; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 3e39c302c..c5392dbaf 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -524,15 +524,6 @@ public: // adds local variables Wrapper_add_local(f, "args", "CAMLparam1(args)"); Wrapper_add_local(f, "ret", "SWIG_CAMLlocal2(swig_result,rv)"); - if (isOverloaded) { - Wrapper_add_local(f, "i", "int i"); - Wrapper_add_local(f, "argc", "int argc = caml_list_length(args)"); - Wrapper_add_local(f, "argv", "CAML_VALUE *argv"); - - Printv(f->code, - "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" - "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); - } d = SwigType_typedef_qualified(d); emit_parameter_variables(l, f); @@ -701,8 +692,6 @@ public: // Wrap things up (in a manner of speaking) Printv(f->code, tab4, "swig_result = caml_list_append(swig_result,rv);\n", NIL); - if (isOverloaded) - Printv(f->code, "free(argv);\n", NIL); Printv(f->code, tab4, "CAMLreturn(swig_result);\n", NIL); Printv(f->code, "}\n", NIL); From b3f903722b5473c5260484d19859766710b096c7 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 16 Jan 2019 23:08:12 -0700 Subject: [PATCH 1289/2031] [OCaml] Improve the error message for incorrect overloaded function calls List the possible prototypes in the error message. The code was taken from python.cxx's dispatchFunction(). --- Source/Modules/ocaml.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 3e39c302c..4df9acfee 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -733,7 +733,18 @@ public: "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); Printv(df->code, dispatch, "\n", NIL); - Printf(df->code, "caml_failwith(\"No matching function for overloaded '%s'\");\n", iname); + Node *sibl = n; + while (Getattr(sibl, "sym:previousSibling")) + sibl = Getattr(sibl, "sym:previousSibling"); + String *protoTypes = NewString(""); + do { + String *fulldecl = Swig_name_decl(sibl); + Printf(protoTypes, "\n\" %s\\n\"", fulldecl); + Delete(fulldecl); + } while ((sibl = Getattr(sibl, "sym:nextSibling"))); + Printf(df->code, "caml_failwith(\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" + "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", iname, protoTypes); + Delete(protoTypes); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); From f71ee5be67c655db048a12a62cd44615a4303105 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 17 Jan 2019 15:58:48 -0700 Subject: [PATCH 1290/2031] [OCaml] Runtime tests for fvirtual, overload_polymorphic and some others Add runtime tests for conversion, extend_typedef_class, extend_constructor_destructor, fvirtual, overload_polymorphic, template_rename, and using1. --- Examples/test-suite/ocaml/conversion_runme.ml | 9 +++++++++ .../ocaml/extend_constructor_destructor_runme.ml | 12 ++++++++++++ .../test-suite/ocaml/extend_typedef_class_runme.ml | 12 ++++++++++++ Examples/test-suite/ocaml/fvirtual_runme.ml | 10 ++++++++++ .../test-suite/ocaml/overload_polymorphic_runme.ml | 9 +++++++++ Examples/test-suite/ocaml/template_rename_runme.ml | 12 ++++++++++++ Examples/test-suite/ocaml/using1_runme.ml | 4 ++++ 7 files changed, 68 insertions(+) create mode 100644 Examples/test-suite/ocaml/conversion_runme.ml create mode 100644 Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml create mode 100644 Examples/test-suite/ocaml/extend_typedef_class_runme.ml create mode 100644 Examples/test-suite/ocaml/fvirtual_runme.ml create mode 100644 Examples/test-suite/ocaml/overload_polymorphic_runme.ml create mode 100644 Examples/test-suite/ocaml/template_rename_runme.ml create mode 100644 Examples/test-suite/ocaml/using1_runme.ml diff --git a/Examples/test-suite/ocaml/conversion_runme.ml b/Examples/test-suite/ocaml/conversion_runme.ml new file mode 100644 index 000000000..8e4c19f2d --- /dev/null +++ b/Examples/test-suite/ocaml/conversion_runme.ml @@ -0,0 +1,9 @@ +open Swig +open Conversion + +let _ = + let bar = new_Bar '() in + assert (bar -> ":classof" () as string = "Bar"); + let foo = bar -> toFoo () in + assert (foo -> ":classof" () as string = "Foo"); +;; diff --git a/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml b/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml new file mode 100644 index 000000000..432d9d7dc --- /dev/null +++ b/Examples/test-suite/ocaml/extend_constructor_destructor_runme.ml @@ -0,0 +1,12 @@ +open Swig +open Extend_constructor_destructor + +let check o v = + assert ((o -> "[ivar]" () as int) = v); + ignore (o -> "~" ()); + assert ((_globalVar '() as int) = -v) + +let ctors = [new_AStruct; new_BStruct; new_CStruct; new_DStruct; new_EStruct; + new_FStruct; new_GStruct] + +let _ = List.iteri (fun i c -> let j = succ i in check (c (C_int j)) j) ctors diff --git a/Examples/test-suite/ocaml/extend_typedef_class_runme.ml b/Examples/test-suite/ocaml/extend_typedef_class_runme.ml new file mode 100644 index 000000000..b5d97e2ad --- /dev/null +++ b/Examples/test-suite/ocaml/extend_typedef_class_runme.ml @@ -0,0 +1,12 @@ +open Swig +open Extend_typedef_class + +let test_obj o v = + let cint = C_int v in + let _ = o -> "[membervar]" (cint) in + assert ((o -> "getvar" () as int) = v) + +let ctors = [new_AClass; new_BClass; new_CClass; new_DClass; new_AStruct; + new_BStruct; new_CStruct; new_DStruct] + +let _ = List.iteri (fun i c -> test_obj (c '()) i) ctors diff --git a/Examples/test-suite/ocaml/fvirtual_runme.ml b/Examples/test-suite/ocaml/fvirtual_runme.ml new file mode 100644 index 000000000..6b0782b20 --- /dev/null +++ b/Examples/test-suite/ocaml/fvirtual_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Fvirtual + +let _ = + let sw = new_NodeSwitch '() and n = new_Node '() in + assert (n -> addChild (n) as int = 1); + assert (sw -> addChild (n) as int = 2); + assert (sw -> addChild (sw) as int = 2); + assert (sw -> addChild (n, false) as int = 3) +;; diff --git a/Examples/test-suite/ocaml/overload_polymorphic_runme.ml b/Examples/test-suite/ocaml/overload_polymorphic_runme.ml new file mode 100644 index 000000000..5ed5f45f4 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_polymorphic_runme.ml @@ -0,0 +1,9 @@ +open Swig +open Overload_polymorphic + +let _ = + let t = new_Derived '() in + assert (_test (t) as int = 0); + assert (_test '(1) as int = 1); + assert (_test2 (t) as int = 1) +;; diff --git a/Examples/test-suite/ocaml/template_rename_runme.ml b/Examples/test-suite/ocaml/template_rename_runme.ml new file mode 100644 index 000000000..be19aa107 --- /dev/null +++ b/Examples/test-suite/ocaml/template_rename_runme.ml @@ -0,0 +1,12 @@ +open Swig +open Template_rename + +let _ = + let i = new_iFoo '() and d = new_dFoo '() in + assert (i -> blah_test (4) as int = 4); + assert (i -> spam_test (5) as int = 5); + assert (i -> groki_test (6) as int = 6); + assert (d -> blah_test (7) as int = 7); + assert (d -> spam (8) as int = 8); + assert (d -> grok_test (9) as int = 9) +;; diff --git a/Examples/test-suite/ocaml/using1_runme.ml b/Examples/test-suite/ocaml/using1_runme.ml new file mode 100644 index 000000000..defda603c --- /dev/null +++ b/Examples/test-suite/ocaml/using1_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Using1 + +let _ = assert (_spam '(37) as int = 37) From ffb7b30be97c8aa35e4a19e5dffdb8c7541d50bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Jan 2019 07:35:47 +0000 Subject: [PATCH 1291/2031] Fix gdb error: Undefined command: "Printf". The swig.gdb file provides the swigprint and locswigprint user-defined commands which stopped working somewhere around gdb 8.0 - 8.2. ``` (gdb) swigprint n Undefined command: "Printf". Try "help". (gdb) locswigprint n Undefined command: "Printf". Try "help". (gdb) ``` I couldn't find any mention of gdb's Printf, but replacing Printf with printf works and is documented at https://sourceware.org/gdb/download/onlinedocs/gdb/Output.html#Output Fixes issue #1420 [skip ci] --- CHANGES.current | 13 +++++++++---- Tools/swig.gdb | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c81bdebde..ea728a569 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-18: wsfulton + #1420 Fix gdb debugger functions 'swigprint' and 'locswigprint' from swig.gdb to + work with newer versions of gdb-8. Fixes errors when debugging SWIG source with gdb: + + (gdb) swigprint n + Undefined command: "Printf". Try "help". + 2019-01-16: wsfulton Python static method wrapper changes @@ -36,11 +43,9 @@ Version 4.0.0 (in progress) ... statmethod = staticmethod(_example.Klass_statmethod) + - Modernise wrappers for static methods to use decorator syntax - @staticmethod. -- Modernise wrappers for static methods to use decorator syntax - @staticmethod. - -- Add missing runtime test for static class methods and using the actual class method. - + - Add missing runtime test for static class methods and using the actual class method. 2019-01-12: ZackerySpytz [OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using diff --git a/Tools/swig.gdb b/Tools/swig.gdb index 61872c5d6..5a652cae8 100644 --- a/Tools/swig.gdb +++ b/Tools/swig.gdb @@ -15,7 +15,7 @@ define swigprint else set $expand_count = -1 end - Printf "%s\n", Swig_to_string($arg0, $expand_count) + printf "%s\n", Swig_to_string($arg0, $expand_count) end document swigprint Displays any SWIG DOH object @@ -31,7 +31,7 @@ define locswigprint else set $expand_count = -1 end - Printf "%s\n", Swig_to_string_with_location($arg0, $expand_count) + printf "%s\n", Swig_to_string_with_location($arg0, $expand_count) end document locswigprint Displays any SWIG DOH object prefixed with file and line location From b879ccdc3e63a1b55dab90ea843f34563fe6988b Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 18 Jan 2019 23:42:59 -0700 Subject: [PATCH 1292/2031] [OCaml] Fix the handling of bools in overloaded functions Use the SWIG_TYPECHECK_BOOL precedence level instead of SWIG_TYPECHECK_INTEGER when checking for bools. Add a runtime test in the form of overload_bool_runme.ml. --- Examples/test-suite/ocaml/overload_bool_runme.ml | 15 +++++++++++++++ Lib/ocaml/typecheck.i | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/ocaml/overload_bool_runme.ml diff --git a/Examples/test-suite/ocaml/overload_bool_runme.ml b/Examples/test-suite/ocaml/overload_bool_runme.ml new file mode 100644 index 000000000..ce0ce9e40 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_bool_runme.ml @@ -0,0 +1,15 @@ +open Swig +open Overload_bool + +let _ = + assert (_overloaded '(true) as string = "bool"); + assert (_overloaded '(false) as string = "bool"); + assert (_overloaded '(0) as string = "int"); + assert (_overloaded '(1) as string = "int"); + assert (_overloaded '(2) as string = "int"); + assert (_overloaded '("1234") as string = "string"); + assert (_boolfunction '(true) as string = "true"); + assert (_boolfunction '(false) as string = "false"); + assert (_intfunction '(true) as string = "int"); + assert (_intfunction '(false) as string = "int"); +;; diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index a13e1552e..9d95e2717 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -78,7 +78,7 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) bool, oc_bool, BOOL, const bool &, const oc_bool &, const BOOL & { +%typecheck(SWIG_TYPECHECK_BOOL) bool, oc_bool, const bool &, const oc_bool & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { From 6da9bd485e8f0584b241a873a3b3b0696baa2a62 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 18 Jan 2019 23:48:46 -0700 Subject: [PATCH 1293/2031] [OCaml] Remove the last remnants of libswigocaml Parts of it were removed in 79785d403c80eb6c10b23668b07b106251373c1b Remove the oc_bool type. --- Lib/ocaml/extra-install.list | 1 - Lib/ocaml/libswigocaml.h | 20 -------------------- Lib/ocaml/typecheck.i | 2 +- Lib/ocaml/typemaps.i | 1 - 4 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 Lib/ocaml/libswigocaml.h diff --git a/Lib/ocaml/extra-install.list b/Lib/ocaml/extra-install.list index a63c7fc2f..16486eb2c 100644 --- a/Lib/ocaml/extra-install.list +++ b/Lib/ocaml/extra-install.list @@ -1,5 +1,4 @@ # see top-level Makefile.in -# libswigocaml is not needed anymore. swigp4.ml swig.mli swig.ml diff --git a/Lib/ocaml/libswigocaml.h b/Lib/ocaml/libswigocaml.h deleted file mode 100644 index e752540fe..000000000 --- a/Lib/ocaml/libswigocaml.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Ocaml runtime support */ - -#ifdef __cplusplus -extern "C" { -#endif - - typedef int oc_bool; - extern void *nullptr; - - extern oc_bool isnull( void *v ); - - extern void *get_char_ptr( char *str ); - extern void *make_ptr_array( int size ); - extern void *get_ptr( void *arrayptr, int elt ); - extern void set_ptr( void *arrayptr, int elt, void *elt_v ); - extern void *offset_ptr( void *ptr, int n ); - -#ifdef __cplusplus -}; -#endif diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 9d95e2717..707302fff 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -78,7 +78,7 @@ } } -%typecheck(SWIG_TYPECHECK_BOOL) bool, oc_bool, const bool &, const oc_bool & { +%typecheck(SWIG_TYPECHECK_BOOL) bool, const bool & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index bf2ddfe85..2bf456a46 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -198,7 +198,6 @@ %enddef SIMPLE_MAP(bool, caml_val_bool, caml_long_val); -SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val); SIMPLE_MAP(char, caml_val_char, caml_long_val); SIMPLE_MAP(signed char, caml_val_char, caml_long_val); SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val); From 1329ed7a5cb3ce8963316619871ca81c8b49cb62 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 18 Jan 2019 19:08:49 +0000 Subject: [PATCH 1294/2031] Suppress rename warnings when parameter names are keywords Parameter renaming is not fully implemented. Mainly because there is no C/C++ syntax to for %rename to fully qualify a function's parameter name from outside the function. Hence it is not possible to implemented targetted warning suppression on one parameter in one function. Issue #1420 --- Examples/test-suite/errors/swig_typemap_warn.stderr | 2 -- Source/Swig/naming.c | 12 +++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/errors/swig_typemap_warn.stderr b/Examples/test-suite/errors/swig_typemap_warn.stderr index dde790024..5116dbc91 100644 --- a/Examples/test-suite/errors/swig_typemap_warn.stderr +++ b/Examples/test-suite/errors/swig_typemap_warn.stderr @@ -3,7 +3,5 @@ swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int -swig_typemap_warn.i:7: Warning 314: 'def' is a python keyword, renaming to '_def' swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int -swig_typemap_warn.i:7: Warning 314: 'def' is a python keyword, renaming to '_def' diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 2557892e4..180e54774 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1508,9 +1508,15 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, if ((msg) && (Len(msg))) { if (!Getmeta(nname, "already_warned")) { if (n) { - SWIG_WARN_NODE_BEGIN(n); - Swig_warning(0, Getfile(n), Getline(n), "%s\n", msg); - SWIG_WARN_NODE_END(n); + /* Parameter renaming is not fully implemented. Mainly because there is no C/C++ syntax to + * for %rename to fully qualify a function's parameter name from outside the function. Hence it + * is not possible to implemented targetted warning suppression on one parameter in one function. */ + int suppress_parameter_rename_warning = Equal(nodeType(n), "parm"); + if (!suppress_parameter_rename_warning) { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(0, Getfile(n), Getline(n), "%s\n", msg); + SWIG_WARN_NODE_END(n); + } } else { Swig_warning(0, Getfile(name), Getline(name), "%s\n", msg); } From 721f6ddef16b0df06f6045a1ca9888ac335f21e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Jan 2019 19:36:03 +0000 Subject: [PATCH 1295/2031] Add autodoc and keyword argument tests --- CHANGES.current | 9 +++++++++ Examples/test-suite/autodoc.i | 19 +++++++++++++++---- Examples/test-suite/python/autodoc_runme.py | 5 ++++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index ea728a569..27eb7d1c5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-19: vadz + #1272, #1421 When a function's parameter is a keyword, the name of the paramater is + no longer simply changed to argN, where N is the argument number. Instead the + parameter name is changed to the renaming rules for keywords that normally apply to + symbols such as classes/functions etc. Note that unlike other symbol renaming, + parameter renaming does not issue a warning when the parameter is renamed. This + change only affects languages where the parameter names are actually used, for example, + Java function parameter lists in the proxy class or Python documentation comments. + 2019-01-18: wsfulton #1420 Fix gdb debugger functions 'swigprint' and 'locswigprint' from swig.gdb to work with newer versions of gdb-8. Fixes errors when debugging SWIG source with gdb: diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index ec7307a35..76e6cfb24 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -149,10 +149,21 @@ bool is_python_builtin() { return false; } #endif %} -// Autodoc Python keywords -%warnfilter(SWIGWARN_PARSE_KEYWORD) process; -%feature(autodoc,0) process; +// Autodoc language keywords +%feature(autodoc,1) process; +%feature(autodoc,1) process2; %feature("compactdefaultargs") process; +%feature("compactdefaultargs") process2; %inline %{ -int process(int from) { return from; } +int process(int from, int in, int var) { return from; } +int process2(int from = 0, int _in = 1, int var = 2) { return from; } +%} + +%feature(autodoc,1) process3; +%feature(autodoc,1) process4; +%feature("kwargs") process3; +%feature("kwargs") process4; +%inline %{ +int process3(int from, int _in, int var) { return from; } +int process4(int from = 0, int _in = 1, int var = 2) { return from; } %} diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index ab963a748..d643d2247 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -203,4 +203,7 @@ check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >") check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip) check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger") -check(inspect.getdoc(process), "process(_from) -> int") +check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int") +check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int") +check(inspect.getdoc(process3), "process3(int _from, int _in, int var) -> int") +check(inspect.getdoc(process4), "process4(int _from=0, int _in=1, int var=2) -> int") From d305b8a3fca17065a9f53161766c76dd60e5148d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Jan 2019 19:45:51 +0000 Subject: [PATCH 1296/2031] update .gitignore for Python and OCaml --- .gitignore | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8aff2c699..1f1561475 100644 --- a/.gitignore +++ b/.gitignore @@ -161,7 +161,7 @@ Examples/test-suite/javascript/*/ # OCaml Examples/test-suite/ocaml/*.ml* Examples/test-suite/ocaml/*.cm* -Examples/test-suite/ocaml/runme +Examples/test-suite/ocaml/*_runme !Examples/test-suite/ocaml/*runme.ml Examples/ocaml/**/example.ml* Examples/ocaml/**/runme @@ -193,13 +193,15 @@ Examples/php/*/example.php /__pycache__/ Examples/test-suite/python/*.py !Examples/test-suite/python/*runme.py -Examples/python/**/example.py Examples/python/**/bar.py Examples/python/**/base.py +Examples/python/**/example.py Examples/python/**/foo.py -Examples/python/**/spam.py Examples/python/**/robin.py +Examples/python/**/runme3.py +Examples/python/**/spam.py Examples/python/import_packages/module_is_init/pkg1/__init__.py +Examples/python/import_packages/namespace_pkg/path4.zip Examples/python/doxygen/example.html # R From 8e1893f355f16bc426bc0a64a8766c49309883aa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Jan 2019 19:47:51 +0000 Subject: [PATCH 1297/2031] D warning suppressions in autodoc testcase --- Examples/test-suite/autodoc.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 76e6cfb24..a97a1634f 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -1,5 +1,7 @@ %module(docstring="hello.") autodoc +%warnfilter(SWIGWARN_PARSE_KEYWORD) inout; + %feature("autodoc"); // special typemap and its docs From 3b03f920e7ac69924e816c1951c9027514432bdd Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 20 Jan 2019 12:24:45 +1300 Subject: [PATCH 1298/2031] Suppress warnings about PyCFunction casts These remaining warnings are due to the design of Python's C API, so suppress them by casting via void(*)(void) (which GCC documents as the way to suppress this warning). Closes #1259. --- CHANGES.current | 7 +++---- Source/Modules/python.cxx | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 27eb7d1c5..18d694a16 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -468,10 +468,9 @@ Version 4.0.0 (in progress) 2018-06-11: olly [Python] Fix new GCC8 warnings in generated code by avoiding casts - between incompatible function types where possible (when keyword - args are in use, it is not possible to avoid such warnings as they - are inherent in the design of Python's C API in that particular - case). Fixes #1259. + between incompatible function types where possible, and by + suppressing the warning when it's due to the design of Python's C + API. Fixes #1259. 2018-06-08: philippkraft [Python] Stop exposing _swigregister to Python. It's not diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index d58e21ba7..fe681f768 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2343,7 +2343,10 @@ public: Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); } } else { - Printf(methods, "\t { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, ", name, function); + // Cast via void(*)(void) to suppress GCC -Wcast-function-type warning. + // Python should always call the function correctly, but the Python C API + // requires us to store it in function pointer of a different type. + Printf(methods, "\t { \"%s\", (PyCFunction)(void(*)(void))%s, METH_VARARGS|METH_KEYWORDS, ", name, function); } if (!n) { @@ -4503,7 +4506,11 @@ public: int argcount = Getattr(n, "python:argcount") ? atoi(Char(Getattr(n, "python:argcount"))) : 2; String *ds = have_docstring(n) ? cdocstring(n, AUTODOC_METHOD) : NewString(""); if (check_kwargs(n)) { - Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, METH_VARARGS|METH_KEYWORDS, \"%s\" },\n", symname, wname, ds); + // Cast via void(*)(void) to suppress GCC -Wcast-function-type + // warning. Python should always call the function correctly, but + // the Python C API requires us to store it in function pointer of a + // different type. + Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, METH_VARARGS|METH_KEYWORDS, \"%s\" },\n", symname, wname, ds); } else if (argcount == 0) { Printf(builtin_methods, " { \"%s\", %s, METH_NOARGS, \"%s\" },\n", symname, wname, ds); } else if (argcount == 1) { @@ -4603,12 +4610,15 @@ public: Append(pyflags, "METH_O"); else Append(pyflags, "METH_VARARGS"); + // Cast via void(*)(void) to suppress GCC -Wcast-function-type warning. + // Python should always call the function correctly, but the Python C + // API requires us to store it in function pointer of a different type. if (have_docstring(n)) { String *ds = cdocstring(n, AUTODOC_STATICFUNC); - Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"%s\" },\n", symname, wname, pyflags, ds); + Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"%s\" },\n", symname, wname, pyflags, ds); Delete(ds); } else { - Printf(builtin_methods, " { \"%s\", (PyCFunction)%s, %s, \"\" },\n", symname, wname, pyflags); + Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"\" },\n", symname, wname, pyflags); } Delete(fullname); Delete(wname); From 9149a9766ce7d6506bf4e20712252fc55bb92b82 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 19 Jan 2019 17:14:46 -0700 Subject: [PATCH 1299/2031] Fix compiler warnings when SWIGRUNTIME_DEBUG is defined --- Lib/swiginit.swg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/swiginit.swg b/Lib/swiginit.swg index cb72c36eb..33926b10f 100644 --- a/Lib/swiginit.swg +++ b/Lib/swiginit.swg @@ -98,7 +98,7 @@ SWIG_InitializeModule(void *clientdata) { /* Now work on filling in swig_module.types */ #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: size %d\n", swig_module.size); + printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size); #endif for (i = 0; i < swig_module.size; ++i) { swig_type_info *type = 0; @@ -106,7 +106,7 @@ SWIG_InitializeModule(void *clientdata) { swig_cast_info *cast; #ifdef SWIGRUNTIME_DEBUG - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); #endif /* if there is another module already loaded */ @@ -182,7 +182,7 @@ SWIG_InitializeModule(void *clientdata) { for (i = 0; i < swig_module.size; ++i) { int j = 0; swig_cast_info *cast = swig_module.cast_initial[i]; - printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name); while (cast->type) { printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); cast++; From 5c21de71c7c1c4187ed48049ac448cb5d189badc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Jan 2019 17:06:43 +0000 Subject: [PATCH 1300/2031] Fix configure.ac to work again with version 2.58 testing the D compiler Remove use of _AC_DO_STDERR which became available in autoconf 2.60. Closes #1405 --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ad06fd42a..deb537e81 100644 --- a/configure.ac +++ b/configure.ac @@ -2728,7 +2728,7 @@ void main() { _ACEOF rm -f conftest.$ac_objext AS_IF( - [_AC_DO_STDERR($D1COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext], + [$D1COMPILER conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD && test ! -s conftest.err && test -s conftest.$ac_objext], [AC_MSG_RESULT([yes])], [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no]) D1COMPILER=] @@ -2751,7 +2751,7 @@ void main() { _ACEOF rm -f conftest.$ac_objext AS_IF( - [_AC_DO_STDERR($D2COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext], + [$D2COMPILER conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD && test ! -s conftest.err && test -s conftest.$ac_objext], [AC_MSG_RESULT([yes])], [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no]) D2COMPILER=] From 1e22e791ef4ab6b4e40c1b587d441cb252dc0303 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Jan 2019 00:52:48 +0100 Subject: [PATCH 1301/2031] Always include default parameter values in Python autodoc strings One of side effects of 15b369028fbfcee559d9f4a8e37e2d71428add29 was that the default values were only included in Python doc strings if we could be sure that they could be interpreted as valid Python expressions, but this change was actually undesirable as it may be useful to see C++ expression for the default value in the doc string even when it isn't valid in Python. Undo this part of the change and extend autodoc unit test to check that this stays fixed. Closes #1271. --- Examples/test-suite/autodoc.i | 10 ++++++++++ Examples/test-suite/python/autodoc_runme.py | 2 ++ Source/Modules/python.cxx | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index a97a1634f..0e9356901 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -169,3 +169,13 @@ int process2(int from = 0, int _in = 1, int var = 2) { return from; } int process3(int from, int _in, int var) { return from; } int process4(int from = 0, int _in = 1, int var = 2) { return from; } %} + +// Autodoc for methods with default arguments not directly representable in +// target language. +%feature(autodoc,0) process_complex_defval; +%feature("compactdefaultargs") process_complex_defval; +%inline %{ +const int PROCESS_DEFAULT_VALUE = 17; +typedef long int some_type; +int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; } +%} diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index d643d2247..d866cb990 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -207,3 +207,5 @@ check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int") check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int") check(inspect.getdoc(process3), "process3(int _from, int _in, int var) -> int") check(inspect.getdoc(process4), "process4(int _from=0, int _in=1, int var=2) -> int") + +check(inspect.getdoc(process_complex_defval), "process_complex_defval(val=PROCESS_DEFAULT_VALUE, factor=some_type(-1)) -> int") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index fe681f768..f6aa4b869 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1715,9 +1715,19 @@ public: // Write default value if (value && !calling) { String *new_value = convertValue(value, Getattr(p, "type")); + if (new_value) { + value = new_value; + } else { + // Even if the value is not representable in the target language, still use it in the documentaiton, for compatibility with the previous SWIG versions + // and because it can still be useful to see the C++ expression there. + Node *lookup = Swig_symbol_clookup(value, 0); + if (lookup) + value = Getattr(lookup, "sym:name"); + } + Printf(doc, "=%s", value); + if (new_value) - Printf(doc, "=%s", new_value); - Delete(new_value); + Delete(new_value); } Delete(type_str); Delete(made_name); From cd526caed4144bd70e450af319a7e50d0dd72089 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Jan 2019 01:08:45 +0100 Subject: [PATCH 1302/2031] Harmonize parameters in autodoc in Ruby and Octave with Python Backport changes to Python version of make_autodocParmList() to Ruby and Octave modules, which use similar code. In particular, this improves handling of parameters clashing with the language keywords/reserved words for these languages as well. --- Source/Modules/octave.cxx | 22 ++++++++++++---------- Source/Modules/ruby.cxx | 22 ++++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index a1a40d8ea..1297d2445 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -418,13 +418,14 @@ public: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ - void addMissingParameterNames(ParmList *plist, int arg_offset) { + void addMissingParameterNames(Node* n, ParmList *plist, int arg_offset) { Parm *p = plist; int i = arg_offset; while (p) { if (!Getattr(p, "lname")) { - String *pname = Swig_cparm_name(p, i); - Delete(pname); + String *name = makeParameterName(n, p, i); + Setattr(p, "lname", name); + Delete(name); } i++; p = nextSibling(p); @@ -436,14 +437,14 @@ public: ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - int start_arg_num = is_wrapping_class() ? 1 : 0; + int arg_num = is_wrapping_class() ? 1 : 0; - addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms + addMissingParameterNames(n, plist, arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); - for (p = plist; p; p = pnext) { + for (p = plist; p; p = pnext, arg_num++) { String *tm = Getattr(p, "tmap:in"); if (tm) { @@ -465,9 +466,10 @@ public: value = Getattr(p, "tmap:doc:value"); } - name = name ? name : Getattr(p, "name"); - name = name ? name : Getattr(p, "lname"); - name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword + String *made_name = 0; + if (!name) { + name = made_name = makeParameterName(n, p, arg_num); + } type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); @@ -503,7 +505,7 @@ public: Delete(type_str); Delete(tex_name); - Delete(name); + Delete(made_name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 08ba4e2b3..6a1e16d5d 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -290,13 +290,14 @@ private: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ - void addMissingParameterNames(ParmList *plist, int arg_offset) { + void addMissingParameterNames(Node* n, ParmList *plist, int arg_offset) { Parm *p = plist; int i = arg_offset; while (p) { if (!Getattr(p, "lname")) { - String *pname = Swig_cparm_name(p, i); - Delete(pname); + String *name = makeParameterName(n, p, i); + Setattr(p, "lname", name); + Delete(name); } i++; p = nextSibling(p); @@ -315,10 +316,10 @@ private: Parm *p; Parm *pnext; int lines = 0; - int start_arg_num = is_wrapping_class() ? 1 : 0; + int arg_num = is_wrapping_class() ? 1 : 0; const int maxwidth = 80; - addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms + addMissingParameterNames(n, plist, arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); @@ -328,7 +329,7 @@ private: return doc; } - for (p = plist; p; p = pnext) { + for (p = plist; p; p = pnext, arg_num++) { String *tm = Getattr(p, "tmap:in"); if (tm) { @@ -351,9 +352,10 @@ private: } // Note: the generated name should be consistent with that in kwnames[] - name = name ? name : Getattr(p, "name"); - name = name ? name : Getattr(p, "lname"); - name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword + String *made_name = 0; + if (!name) { + name = made_name = makeParameterName(n, p, arg_num); + } type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); @@ -404,7 +406,7 @@ private: Printf(doc, "=%s", value); } Delete(type_str); - Delete(name); + Delete(made_name); } if (pdocs) Setattr(n, "feature:pdocs", pdocs); From 8b083b4284f72a286c20d7bf3ff4f4725fb88c22 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 20 Jan 2019 23:08:03 -0700 Subject: [PATCH 1303/2031] [OCaml] Runtime tests for overload_method, typedef_class and some others Add runtime tests for overload_method, typedef_class, typedef_inherit, typemap_arrays, typemap_delete, types_directive, and valuewrapper. --- Examples/test-suite/ocaml/overload_method_runme.ml | 11 +++++++++++ Examples/test-suite/ocaml/typedef_class_runme.ml | 13 +++++++++++++ Examples/test-suite/ocaml/typedef_inherit_runme.ml | 11 +++++++++++ Examples/test-suite/ocaml/typemap_arrays_runme.ml | 4 ++++ Examples/test-suite/ocaml/typemap_delete_runme.ml | 5 +++++ Examples/test-suite/ocaml/types_directive_runme.ml | 14 ++++++++++++++ Examples/test-suite/ocaml/valuewrapper_runme.ml | 8 ++++++++ 7 files changed, 66 insertions(+) create mode 100644 Examples/test-suite/ocaml/overload_method_runme.ml create mode 100644 Examples/test-suite/ocaml/typedef_class_runme.ml create mode 100644 Examples/test-suite/ocaml/typedef_inherit_runme.ml create mode 100644 Examples/test-suite/ocaml/typemap_arrays_runme.ml create mode 100644 Examples/test-suite/ocaml/typemap_delete_runme.ml create mode 100644 Examples/test-suite/ocaml/types_directive_runme.ml create mode 100644 Examples/test-suite/ocaml/valuewrapper_runme.ml diff --git a/Examples/test-suite/ocaml/overload_method_runme.ml b/Examples/test-suite/ocaml/overload_method_runme.ml new file mode 100644 index 000000000..0303ba2a3 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_method_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Overload_method + +let _ = + let b = new_Base '() in + assert (b -> "method" () as int = 42); + assert (b -> "overloaded_method" () as int = 42); + assert (b -> "overloaded_method" (5) = C_void); + assert (b -> "overloaded_method" () as int = 5); + assert (b -> "method" () as int = 5); +;; diff --git a/Examples/test-suite/ocaml/typedef_class_runme.ml b/Examples/test-suite/ocaml/typedef_class_runme.ml new file mode 100644 index 000000000..969c3e420 --- /dev/null +++ b/Examples/test-suite/ocaml/typedef_class_runme.ml @@ -0,0 +1,13 @@ +open Swig +open Typedef_class + +let a = new_RealA '() +let _ = a -> "[a]" (3) + +let b = new_B '() +let _ = assert (b -> testA (a) as int = 3) + +let bb = new_BB '() +let bb2 = new_BB '(2) +let _ = assert (bb -> aa_method (1.) as int = 0) +let bbb = new_BBB '() diff --git a/Examples/test-suite/ocaml/typedef_inherit_runme.ml b/Examples/test-suite/ocaml/typedef_inherit_runme.ml new file mode 100644 index 000000000..6352fd4ad --- /dev/null +++ b/Examples/test-suite/ocaml/typedef_inherit_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Typedef_inherit + +let _ = + let a = new_Foo '() and b = new_Bar '() in + assert (_do_blah (a) as string = "Foo::blah"); + assert (_do_blah (b) as string = "Bar::blah"); + let c = new_Spam '() and d = new_Grok '() in + assert (_do_blah2 (c) as string = "Spam::blah"); + assert (_do_blah2 (d) as string = "Grok::blah") +;; diff --git a/Examples/test-suite/ocaml/typemap_arrays_runme.ml b/Examples/test-suite/ocaml/typemap_arrays_runme.ml new file mode 100644 index 000000000..17a133c3c --- /dev/null +++ b/Examples/test-suite/ocaml/typemap_arrays_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Typemap_arrays + +let _ = assert (_sumA '() as int = 60) diff --git a/Examples/test-suite/ocaml/typemap_delete_runme.ml b/Examples/test-suite/ocaml/typemap_delete_runme.ml new file mode 100644 index 000000000..0cffb025b --- /dev/null +++ b/Examples/test-suite/ocaml/typemap_delete_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Typemap_delete + +let r = new_Rect '(123) +let _ = assert (r -> "[val]" () as int = 123) diff --git a/Examples/test-suite/ocaml/types_directive_runme.ml b/Examples/test-suite/ocaml/types_directive_runme.ml new file mode 100644 index 000000000..8503d00ff --- /dev/null +++ b/Examples/test-suite/ocaml/types_directive_runme.ml @@ -0,0 +1,14 @@ +open Swig +open Types_directive + +let _ = + (* Check that a Time1 instance is accepted where a Date instance is expected. *) + let d1 = new_Time1 '(2001, 2, 3, 60) in + let newDate = _add '(d1, 7) in + assert (newDate -> "[day]" () as int = 10); + + (* Check that a Time2 instance is accepted where a Date instance is expected. *) + let d2 = new_Time2 '(1999, 8, 7, 60) in + let newDate = _add '(d2, 7) in + assert (newDate -> "[day]" () as int = 14) +;; diff --git a/Examples/test-suite/ocaml/valuewrapper_runme.ml b/Examples/test-suite/ocaml/valuewrapper_runme.ml new file mode 100644 index 000000000..0e2d73136 --- /dev/null +++ b/Examples/test-suite/ocaml/valuewrapper_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Valuewrapper + +let _ = + let x1 = new_Xi '(5) and y1 = new_YXi '() in + assert (y1 -> spam (x1) as int = 0); + assert (y1 -> spam () as int = 0) +;; From d8478d671d526acc62944d3df949e3243cf9b41c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Jan 2019 07:50:48 +0000 Subject: [PATCH 1304/2031] Fix segfault using -python -noproxy and %pythonbegin --- Source/Modules/python.cxx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index fe681f768..5ec9cf3d7 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -5011,9 +5011,11 @@ public: Delete(pycode); } } else if (!ImportMode && (Cmp(section, "pythonbegin") == 0)) { - String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n), "%pythonbegin or %insert(\"pythonbegin\") block"); - Printv(f_shadow_begin, pycode, NIL); - Delete(pycode); + if (shadow) { + String *pycode = indent_pythoncode(code, "", Getfile(n), Getline(n), "%pythonbegin or %insert(\"pythonbegin\") block"); + Printv(f_shadow_begin, pycode, NIL); + Delete(pycode); + } } else { Language::insertDirective(n); } From 82513bbf8fa31e191a9291453939d9683c119633 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Jan 2019 18:08:30 +0000 Subject: [PATCH 1305/2031] Fix CCache test.sh when CC contains full path Fixes symbolic link creation. Also fixes test.sh when SWIG contains a full path. Closes #1212 --- CCache/test.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CCache/test.sh b/CCache/test.sh index 5b6f92a35..3c44e859c 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -451,14 +451,16 @@ swigtests if test -z "$NOSOFTLINKSTEST"; then testsuite="link" - ln -s $CCACHE $COMPILER - CCACHE_COMPILE="./$COMPILER" + compilername=`basename $COMPILER` + ln -s $CCACHE ./$compilername + CCACHE_COMPILE="./$compilername" basetests - rm "./$COMPILER" - ln -s $CCACHE $SWIG - CCACHE_COMPILE="./$SWIG" + rm "./$compilername" + compilername=`basename $SWIG` + ln -s $CCACHE ./$compilername + CCACHE_COMPILE="./$compilername" swigtests - rm "./$SWIG" + rm "./$compilername" else echo "skipping testsuite link" fi From d5afcab9a612470847a4c570fff99445d296accf Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 21 Jan 2019 23:17:43 -0700 Subject: [PATCH 1306/2031] [OCaml] Some %typecheck precedence tweaks Fix warnings in overload_numeric.i. ./../overload_numeric.i:36: Warning 509: Overloaded method Nums::over(short) effectively ignored, ./../overload_numeric.i:33: Warning 509: as it is shadowed by Nums::over(signed char). ./../overload_numeric.i:39: Warning 509: Overloaded method Nums::over(int) effectively ignored, ./../overload_numeric.i:33: Warning 509: as it is shadowed by Nums::over(signed char). Add overload_numeric_runme.ml. --- .../ocaml/overload_numeric_runme.ml | 14 +++++++++++++ Lib/ocaml/typecheck.i | 21 ++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/ocaml/overload_numeric_runme.ml diff --git a/Examples/test-suite/ocaml/overload_numeric_runme.ml b/Examples/test-suite/ocaml/overload_numeric_runme.ml new file mode 100644 index 000000000..0342d63e0 --- /dev/null +++ b/Examples/test-suite/ocaml/overload_numeric_runme.ml @@ -0,0 +1,14 @@ +open Swig +open Overload_numeric + +let _ = + let n = new_Nums '() in + let arg = C_char 'c' in + assert (n -> over (arg) as string = "signed char"); + let arg = C_short 2 in + assert (n -> over (arg) as string = "short"); + assert (n -> over (2) as string = "int"); + let arg = C_float 2. in + assert (n -> over (arg) as string = "float"); + assert (n -> over (2.) as string = "double") +;; diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 707302fff..416fd9495 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -4,7 +4,7 @@ * Typechecking rules * ----------------------------------------------------------------------------- */ -%typecheck(SWIG_TYPECHECK_INTEGER) char, signed char, const char &, const signed char & { +%typecheck(SWIG_TYPECHECK_INT8) char, signed char, const char &, const signed char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -14,7 +14,7 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) unsigned char, const unsigned char & { +%typecheck(SWIG_TYPECHECK_UINT8) unsigned char, const unsigned char & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -24,7 +24,7 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) short, signed short, const short &, const signed short &, wchar_t { +%typecheck(SWIG_TYPECHECK_INT16) short, signed short, const short &, const signed short &, wchar_t { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -34,7 +34,7 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) unsigned short, const unsigned short & { +%typecheck(SWIG_TYPECHECK_UINT16) unsigned short, const unsigned short & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -47,7 +47,7 @@ // XXX arty // Will move enum SWIGTYPE later when I figure out what to do with it... -%typecheck(SWIG_TYPECHECK_INTEGER) int, signed int, const int &, const signed int &, enum SWIGTYPE { +%typecheck(SWIG_TYPECHECK_INT32) int, signed int, const int &, const signed int &, enum SWIGTYPE { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -57,7 +57,7 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) unsigned int, const unsigned int & { +%typecheck(SWIG_TYPECHECK_UINT32) unsigned int, const unsigned int & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -68,7 +68,12 @@ } } -%typecheck(SWIG_TYPECHECK_INTEGER) long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, const long long &, const signed long long &, const unsigned long long & { +%typecheck(SWIG_TYPECHECK_INT64) + long, signed long, unsigned long, + long long, signed long long, unsigned long long, + const long &, const signed long &, const unsigned long &, + const long long &, const signed long long &, const unsigned long long & +{ if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { @@ -88,7 +93,7 @@ } } -%typecheck(SWIG_TYPECHECK_DOUBLE) float, const float & { +%typecheck(SWIG_TYPECHECK_FLOAT) float, const float & { if( !Is_block($input) ) $1 = 0; else { switch( SWIG_Tag_val($input) ) { From 0e0c4eecfea2a424d0f282443ffeece2454aa382 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Jan 2019 08:06:45 +0000 Subject: [PATCH 1307/2031] Changes file update --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 18d694a16..4e645c3bb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-22: vadz + [Ruby, Octave] #1424 Improve autodoc parameter naming. + +2019-01-22: vadz + [Python] #1423 Always include default parameter values in autodoc strings. + 2019-01-19: vadz #1272, #1421 When a function's parameter is a keyword, the name of the paramater is no longer simply changed to argN, where N is the argument number. Instead the From 7118e4ef1ef3ab9e4ccdf9273785480be8fd7905 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Jan 2019 08:18:09 +0000 Subject: [PATCH 1308/2031] Update changes file. [skip ci] --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 4e645c3bb..75dd2085d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -11,7 +11,7 @@ Version 4.0.0 (in progress) [Ruby, Octave] #1424 Improve autodoc parameter naming. 2019-01-22: vadz - [Python] #1423 Always include default parameter values in autodoc strings. + [Python] #1271 #1423 Always include default parameter values in autodoc strings. 2019-01-19: vadz #1272, #1421 When a function's parameter is a keyword, the name of the paramater is From 4074f788b343bfc1c9269b02ea7ab7e777b57b06 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 22 Jan 2019 07:51:45 -0700 Subject: [PATCH 1309/2031] [OCaml] Fix %allowexception OCaml's variableWrapper() wasn't calling emit_action_code() for in/out typemaps, which meant that %allowexception was being ignored. In addition, remove all comments in the typemaps in Lib/ocaml. In the case of the allowexcept test, one of the typemap comments caused compilation to fail because it became nested within another comment in an %exception block. Re-enable the allowexcept test. Add allowexcept_runme.ml. --- Examples/test-suite/ocaml/Makefile.in | 1 - .../test-suite/ocaml/allowexcept_runme.ml | 7 ++++++ Lib/ocaml/carray.i | 5 ---- Lib/ocaml/ocaml.swg | 4 ++-- Lib/ocaml/ocamldec.swg | 2 +- Lib/ocaml/std_string.i | 8 ------- Lib/ocaml/typemaps.i | 19 --------------- Source/Modules/ocaml.cxx | 24 ++++++++----------- 8 files changed, 20 insertions(+), 50 deletions(-) create mode 100644 Examples/test-suite/ocaml/allowexcept_runme.ml diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 14fe02646..80b73bf1c 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -14,7 +14,6 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ FAILING_CPP_TESTS = \ -allowexcept \ allprotected \ apply_signed_char \ apply_strings \ diff --git a/Examples/test-suite/ocaml/allowexcept_runme.ml b/Examples/test-suite/ocaml/allowexcept_runme.ml new file mode 100644 index 000000000..9c8c9de7f --- /dev/null +++ b/Examples/test-suite/ocaml/allowexcept_runme.ml @@ -0,0 +1,7 @@ +open Swig +open Allowexcept + +let _ = + assert (_global_variable '() = C_void); + assert (_Foo_static_member_variable '() = C_void) +;; diff --git a/Lib/ocaml/carray.i b/Lib/ocaml/carray.i index f968edfff..5e74c3da1 100644 --- a/Lib/ocaml/carray.i +++ b/Lib/ocaml/carray.i @@ -9,7 +9,6 @@ type _value = c_obj %define %array_tmap_out(type,what,out_f) %typemap(type) what [ANY] { int i; - /* $*1_type */ $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { caml_array_set($result,i,out_f($1[i])); @@ -20,7 +19,6 @@ type _value = c_obj %define %array_tmap_in(type,what,in_f) %typemap(type) what [ANY] { int i; - /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = in_f(caml_array_nth($input,i)); @@ -57,7 +55,6 @@ type _value = c_obj %typemap(in) SWIGTYPE [] { int i; - /* $*1_type */ $1 = new $*1_type [$1_dim0]; for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype *) @@ -69,7 +66,6 @@ type _value = c_obj %typemap(in) SWIGTYPE [] { int i; - /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = *(($*1_ltype) @@ -102,7 +98,6 @@ type _value = c_obj %typemap(in) enum SWIGTYPE [] { int i; - /* $*1_type */ $1 = ($*1_type *)malloc( $1_size ); for( i = 0; i < $1_dim0 && i < caml_array_len($input); i++ ) { $1[i] = ($type) diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index d0007f856..838941e98 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -35,8 +35,8 @@ extern "C" { SWIG_Cast (void *source, swig_type_info *source_type, void **ptr, swig_type_info *dest_type) { - if( !source ) { // Special case for NULL. This is a popular question - // for other modules on the list, so I want an easy way out... + if( !source ) { /* Special case for NULL. This is a popular question + for other modules on the list, so I want an easy way out... */ *ptr = 0; return 0; } diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index aea0ec9e5..5714bc210 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -33,7 +33,7 @@ SWIGEXT { #define caml_array_set swig_caml_array_set -// Adapted from memory.h and mlvalues.h +/* Adapted from memory.h and mlvalues.h */ #define SWIG_CAMLlocal1(x) \ caml_value_t x = 0; \ diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index b70b895f6..770353052 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -29,7 +29,6 @@ class wstring; /* Overloading check */ %typemap(in) string { - /* %typemap(in) string */ if (caml_ptr_check($input)) $1.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); else @@ -37,7 +36,6 @@ class wstring; } %typemap(in) const string & ($*1_ltype temp) { - /* %typemap(in) const string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; @@ -47,7 +45,6 @@ class wstring; } %typemap(in) string & ($*1_ltype temp) { - /* %typemap(in) string & */ if (caml_ptr_check($input)) { temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = &temp; @@ -57,7 +54,6 @@ class wstring; } %typemap(in) string * ($*1_ltype *temp) { - /* %typemap(in) string * */ if (caml_ptr_check($input)) { temp = new $*1_ltype((char *)caml_ptr_val($input,0), caml_string_len($input)); $1 = temp; @@ -71,22 +67,18 @@ class wstring; } %typemap(argout) string & { - /* %typemap(argout) string & */ swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size())); } %typemap(directorout) string { - /* %typemap(directorout) string */ $result.assign((char *)caml_ptr_val($input,0), caml_string_len($input)); } %typemap(out) string { - /* %typemap(out) string */ $result = caml_val_string_len($1.c_str(),$1.size()); } %typemap(out) string * { - /* %typemap(out) string * */ $result = caml_val_string_len((*$1).c_str(),(*$1).size()); } } diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 2bf456a46..5a1d50c6f 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -28,38 +28,31 @@ } %typemap(in) char *& (char *temp) { - /* %typemap(in) char *& */ temp = (char*)caml_val_ptr($1,$descriptor); $1 = &temp; } %typemap(argout) char *& { - /* %typemap(argout) char *& */ swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); } %typemap(in) SWIGTYPE & { - /* %typemap(in) SWIGTYPE & */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(in) SWIGTYPE && { - /* %typemap(in) SWIGTYPE && */ $1 = ($ltype) caml_ptr_val($input,$1_descriptor); } %typemap(varin) SWIGTYPE & { - /* %typemap(varin) SWIGTYPE & */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(varin) SWIGTYPE && { - /* %typemap(varin) SWIGTYPE && */ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } %typemap(out) SWIGTYPE & { - /* %typemap(out) SWIGTYPE & */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); @@ -69,7 +62,6 @@ } %typemap(out) SWIGTYPE && { - /* %typemap(out) SWIGTYPE && */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); @@ -117,7 +109,6 @@ #ifdef __cplusplus %typemap(out) SWIGTYPE { - /* %typemap(out) SWIGTYPE */ $&1_ltype temp = new $ltype((const $1_ltype &) $1); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { @@ -130,7 +121,6 @@ #else %typemap(out) SWIGTYPE { - /* %typemap(out) SWIGTYPE */ void *temp = calloc(1,sizeof($ltype)); CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); memmove( temp, &$1, sizeof( $1_type ) ); @@ -179,14 +169,12 @@ $result = C_TO_MZ($1); } %typemap(varout) C_NAME & { - /* %typemap(varout) C_NAME & (generic) */ $result = C_TO_MZ($1); } %typemap(argout) C_NAME *OUTPUT { swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); } %typemap(out) C_NAME & { - /* %typemap(out) C_NAME & (generic) */ $result = C_TO_MZ(*$1); } %typemap(argout) C_NAME & { @@ -247,15 +235,12 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %define %char_ptr_in(how) %typemap(how) char *, signed char *, unsigned char * { - /* %typemap(how) char * ... */ $1 = ($ltype)caml_string_val($input); } /* Again work around the empty array bound bug */ %typemap(how) char [ANY], signed char [ANY], unsigned char [ANY] { - /* %typemap(how) char [ANY] ... */ char *temp = caml_string_val($input); strcpy((char *)$1,temp); - /* strncpy would be better but we might not have an array size */ } %enddef @@ -283,11 +268,9 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %define %swigtype_ptr_in(how) %typemap(how) SWIGTYPE * { - /* %typemap(how) SWIGTYPE * */ $1 = ($ltype)caml_ptr_val($input,$1_descriptor); } %typemap(how) SWIGTYPE (CLASS::*) { - /* %typemap(how) SWIGTYPE (CLASS::*) */ void *v = caml_ptr_val($input,$1_descriptor); memcpy(& $1, &v, sizeof(v)); } @@ -295,7 +278,6 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %define %swigtype_ptr_out(how) %typemap(out) SWIGTYPE * { - /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { $result = caml_callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); @@ -304,7 +286,6 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); } } %typemap(how) SWIGTYPE (CLASS::*) { - /* %typemap(how) SWIGTYPE *, SWIGTYPE (CLASS::*) */ void *v; memcpy(&v,& $1, sizeof(void *)); $result = caml_val_ptr (v,$1_descriptor); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index fe44b1657..02b7847dc 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -768,10 +768,11 @@ public: * variableWrapper() * * Create a link to a C variable. - * This creates a single function _wrap_swig_var_varname(). + * This creates a single function _wrap_varname(). * This function takes a single optional argument. If supplied, it means * we are setting this variable to some value. If omitted, it means we are - * simply evaluating this variable. In the set case we return C_void. + * simply evaluating this variable. We return the value of the variable + * in both cases. * * symname is the name of the variable with respect to C. This * may need to differ from the original name in the case of enums. @@ -787,9 +788,6 @@ public: String *proc_name = NewString(""); String *tm; - String *tm2 = NewString(""); - String *argnum = NewString("0"); - String *arg = NewString("SWIG_Field(args,0)"); Wrapper *f; if (!name) { @@ -809,14 +807,16 @@ public: // evaluation function names String *var_name = Swig_name_wrapper(iname); - // Build the name for scheme. + // Build the name for OCaml. Printv(proc_name, iname, NIL); Setattr(n, "wrap:name", proc_name); Printf(f->def, "SWIGEXT CAML_VALUE %s(CAML_VALUE args) {\n", var_name); // Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL); - Wrapper_add_local(f, "swig_result", "CAML_VALUE swig_result"); + Wrapper_add_local(f, "args", "CAMLparam1(args)"); + Wrapper_add_local(f, "swig_result", "SWIG_CAMLlocal1(swig_result)"); + Printf(f->code, "swig_result = Val_unit;\n"); if (!GetFlag(n, "feature:immutable")) { /* Check for a setting of the variable value */ @@ -825,13 +825,12 @@ public: Replaceall(tm, "$source", "args"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "args"); - /* Printv(f->code, tm, "\n",NIL); */ emit_action_code(n, f->code, tm); } else if ((tm = Swig_typemap_lookup("in", n, name, 0))) { Replaceall(tm, "$source", "args"); Replaceall(tm, "$target", name); Replaceall(tm, "$input", "args"); - Printv(f->code, tm, "\n", NIL); + emit_action_code(n, f->code, tm); } else { throw_unhandled_ocaml_type_error(t, "varin/in"); } @@ -849,12 +848,12 @@ public: Replaceall(tm, "$source", name); Replaceall(tm, "$target", "swig_result"); Replaceall(tm, "$result", "swig_result"); - Printf(f->code, "%s\n", tm); + emit_action_code(n, f->code, tm); } else { throw_unhandled_ocaml_type_error(t, "varout/out"); } - Printf(f->code, "\nreturn swig_result;\n"); + Printf(f->code, "\nCAMLreturn(swig_result);\n"); Printf(f->code, "}\n"); Wrapper_print(f, f_wrappers); @@ -875,9 +874,6 @@ public: Delete(var_name); Delete(proc_name); - Delete(argnum); - Delete(arg); - Delete(tm2); DelWrapper(f); return SWIG_OK; } From 4d54d305fc11e8eab6c5bd7f3bb49a189589f4d3 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 22 Jan 2019 22:50:40 -0700 Subject: [PATCH 1310/2031] [OCaml] Runtime tests for inctest, li_cpointer_cpp and some others Add runtime tests for inctest, li_cpointer_cpp, newobject2, special_variables, special_variable_macros, template_extend1, and template_extend2. --- Examples/test-suite/ocaml/inctest_runme.ml | 7 ++++ .../test-suite/ocaml/li_cpointer_cpp_runme.ml | 10 ++++++ Examples/test-suite/ocaml/newobject2_runme.ml | 16 +++++++++ .../ocaml/special_variable_macros_runme.ml | 14 ++++++++ .../ocaml/special_variables_runme.ml | 36 +++++++++++++++++++ .../ocaml/template_extend1_runme.ml | 8 +++++ .../ocaml/template_extend2_runme.ml | 8 +++++ 7 files changed, 99 insertions(+) create mode 100644 Examples/test-suite/ocaml/inctest_runme.ml create mode 100644 Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml create mode 100644 Examples/test-suite/ocaml/newobject2_runme.ml create mode 100644 Examples/test-suite/ocaml/special_variable_macros_runme.ml create mode 100644 Examples/test-suite/ocaml/special_variables_runme.ml create mode 100644 Examples/test-suite/ocaml/template_extend1_runme.ml create mode 100644 Examples/test-suite/ocaml/template_extend2_runme.ml diff --git a/Examples/test-suite/ocaml/inctest_runme.ml b/Examples/test-suite/ocaml/inctest_runme.ml new file mode 100644 index 000000000..886751109 --- /dev/null +++ b/Examples/test-suite/ocaml/inctest_runme.ml @@ -0,0 +1,7 @@ +open Swig +open Inctest + +let _ = new_A '() +let _ = new_B '() +let _ = assert (_importtest1 '(5) as int = 15) +let _ = assert (_importtest2 '("black") as string = "white") diff --git a/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml b/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml new file mode 100644 index 000000000..1daf6b5bd --- /dev/null +++ b/Examples/test-suite/ocaml/li_cpointer_cpp_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Li_cpointer_cpp + +let _ = + let p = _new_intp '() in + assert (_intp_value '(p) as int = 0); + assert (_intp_assign '(p, 3) = C_void); + assert (_intp_value '(p) as int = 3); + assert (_delete_intp '(p) = C_void) +;; diff --git a/Examples/test-suite/ocaml/newobject2_runme.ml b/Examples/test-suite/ocaml/newobject2_runme.ml new file mode 100644 index 000000000..eb9a191bc --- /dev/null +++ b/Examples/test-suite/ocaml/newobject2_runme.ml @@ -0,0 +1,16 @@ +open Swig +open Newobject2 + +let _ = + assert (_fooCount '() as int = 0); + let foo1 = _makeFoo '() in + assert (_fooCount '() as int = 1); + assert (_do_stuff '(foo1) = C_void); + let foo2 = _makeFoo '() in + assert (_fooCount '() as int = 2); + assert (_do_stuff '(foo2) = C_void); + ignore (foo1 -> "~" ()); + assert (_fooCount '() as int = 1); + ignore (foo2 -> "~" ()); + assert (_fooCount '() as int = 0) +;; diff --git a/Examples/test-suite/ocaml/special_variable_macros_runme.ml b/Examples/test-suite/ocaml/special_variable_macros_runme.ml new file mode 100644 index 000000000..7f4980ea3 --- /dev/null +++ b/Examples/test-suite/ocaml/special_variable_macros_runme.ml @@ -0,0 +1,14 @@ +open Swig +open Special_variable_macros + +let _ = + let name = new_Name '() in + assert (_testFred '(name) as string = "none"); + assert (_testJack '(name) as string = "$specialname"); + assert (_testJill '(name) as string = "jilly"); + assert (_testMary '(name) as string = "SWIGTYPE_p_NameWrap"); + assert (_testJames '(name) as string = "SWIGTYPE_Name"); + assert (_testJim '(name) as string = "multiname num"); + let arg = new_PairIntBool '(10, false) in + assert (_testJohn '(arg) as int = 123); +;; diff --git a/Examples/test-suite/ocaml/special_variables_runme.ml b/Examples/test-suite/ocaml/special_variables_runme.ml new file mode 100644 index 000000000..b569a54be --- /dev/null +++ b/Examples/test-suite/ocaml/special_variables_runme.ml @@ -0,0 +1,36 @@ +open Swig +open Special_variables + +let _ = + assert (_ExceptionVars '(1.0, 2.0) as string = + "result = Space::exceptionvars(arg1,arg2); Space::exceptionvars ExceptionVars _wrap_ExceptionVarsspecial_variables "); + assert (_overloadedmethod '() as string = + "result = Space::overloadedmethod(); Space::overloadedmethod overloadedmethod __SWIG_1 _wrap_overloadedmethod__SWIG_1special_variables "); + assert (_overloadedmethod '(10.0) as string = + "result = Space::overloadedmethod(arg1); Space::overloadedmethod overloadedmethod __SWIG_0 _wrap_overloadedmethod__SWIG_0special_variables "); + + let _ = new_ABC '(0, 0.0) in + assert (_declaration '() as string = "SpaceNamespace::ABC::ABC(int,double) SpaceNamespace::ABC::ABC(int,double)"); + let a = new_ABC '() in + assert (_declaration '() as string = "SpaceNamespace::ABC::ABC() SpaceNamespace::ABC::ABC()"); + ignore (a -> instancemethod (1)); + assert (_declaration '() as string = "short * SpaceNamespace::ABC::instancemethod(int) SpaceNamespace::ABC::instancemethod(int)"); + ignore (a -> instancemethod (1, false)); + assert (_declaration '() as string = "short * SpaceNamespace::ABC::instancemethod(int,bool) SpaceNamespace::ABC::instancemethod(int,bool)"); + ignore (a -> constmethod (1)); + assert (_declaration '() as string = "short * SpaceNamespace::ABC::constmethod(int) const SpaceNamespace::ABC::constmethod(int) const"); + ignore (_ABC_staticmethod '(0, false)); + assert (_declaration '() as string = "short * SpaceNamespace::ABC::staticmethod(int,bool) SpaceNamespace::ABC::staticmethod(int,bool)"); + ignore (a -> "~" ()); + assert (_declaration '() as string = "SpaceNamespace::ABC::~ABC() SpaceNamespace::ABC::~ABC()"); + let abc = new_TemplateABC '() in + assert (_declaration '() as string = "SpaceNamespace::Template< SpaceNamespace::ABC >::Template() SpaceNamespace::Template< SpaceNamespace::ABC >::Template()"); + let arg = new_ABC '() in + ignore (abc -> tmethod (arg)); + assert (_declaration '() as string = "std::string SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC) SpaceNamespace::Template< SpaceNamespace::ABC >::tmethod(SpaceNamespace::ABC)"); + ignore (abc -> "~" ()); + assert (_declaration '() as string = "SpaceNamespace::Template< SpaceNamespace::ABC >::~Template() SpaceNamespace::Template< SpaceNamespace::ABC >::~Template()"); + let arg = new_TemplateABC '() in + ignore (_globtemplate (arg)); + assert (_declaration '() as string = "void SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >) SpaceNamespace::globtemplate(SpaceNamespace::Template< SpaceNamespace::ABC >)"); +;; diff --git a/Examples/test-suite/ocaml/template_extend1_runme.ml b/Examples/test-suite/ocaml/template_extend1_runme.ml new file mode 100644 index 000000000..b9b5a67d6 --- /dev/null +++ b/Examples/test-suite/ocaml/template_extend1_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Template_extend1 + +let _ = + let a = new_lBaz '() and b = new_dBaz '() in + assert (a -> foo () as string = "lBaz::foo"); + assert (b -> foo () as string = "dBaz::foo") +;; diff --git a/Examples/test-suite/ocaml/template_extend2_runme.ml b/Examples/test-suite/ocaml/template_extend2_runme.ml new file mode 100644 index 000000000..67f260f87 --- /dev/null +++ b/Examples/test-suite/ocaml/template_extend2_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Template_extend2 + +let _ = + let a = new_lBaz '() and b = new_dBaz '() in + assert (a -> foo () as string = "lBaz::foo"); + assert (b -> foo () as string = "dBaz::foo") +;; From 5185ce67b59045e20c1975319527b1ffbe705b20 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Wed, 23 Jan 2019 15:12:45 -0500 Subject: [PATCH 1311/2031] Python: Init container owner attribute in thread-safe way --- Lib/python/pycontainer.swg | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index f77c7cb34..b90068466 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -36,8 +36,17 @@ %include -%fragment("reference_container_owner", "header") { +%fragment("container_owner_attribute_init", "init") { + // thread safe initialization + swig::container_owner_attribute(); +} +%fragment("reference_container_owner", "header", fragment="container_owner_attribute_init") { namespace swig { + PyObject* container_owner_attribute() { + static PyObject* attr = SWIG_Python_str_FromChar("__owner"); + return attr; + } + /** * Call to add a back-reference to the owning object when returning a * reference from a container. Will only set the reference if child @@ -46,10 +55,9 @@ namespace swig { * @return if the reference was set or not */ bool reference_container_owner(PyObject* child, PyObject* owner) { - static PyObject* attr = SWIG_Python_str_FromChar("__owner"); SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - PyObject_SetAttr(child, attr, owner); + PyObject_SetAttr(child, container_owner_attribute(), owner); return true; } return false; From 40e327d742fa579a81573f900c0b8a9dcb9f5038 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Wed, 23 Jan 2019 16:10:26 -0500 Subject: [PATCH 1312/2031] Python: Avoid container owner check for value types --- Lib/python/pycontainer.swg | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index b90068466..34bf3c110 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -40,6 +40,7 @@ // thread safe initialization swig::container_owner_attribute(); } + %fragment("reference_container_owner", "header", fragment="container_owner_attribute_init") { namespace swig { PyObject* container_owner_attribute() { @@ -47,6 +48,12 @@ namespace swig { return attr; } + // By default, do not add the back-reference (for value types) + // Specialization below will check the reference for pointer types. + template + bool reference_container_owner(PyObject* child, PyObject* owner) + { return false; } + /** * Call to add a back-reference to the owning object when returning a * reference from a container. Will only set the reference if child @@ -54,7 +61,8 @@ namespace swig { * * @return if the reference was set or not */ - bool reference_container_owner(PyObject* child, PyObject* owner) { + template <> + bool reference_container_owner(PyObject* child, PyObject* owner) { SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { PyObject_SetAttr(child, container_owner_attribute(), owner); @@ -797,7 +805,7 @@ namespace swig } %typemap(ret, fragment="reference_container_owner") value_type& { - swig::reference_container_owner($result, $self); + swig::reference_container_owner::category>($result, $self); } } %enddef From 4ca7cd7b27bf23c33b755ac986ae236a85aeac41 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 24 Jan 2019 05:32:35 -0700 Subject: [PATCH 1313/2031] [OCaml] Eliminate use of -Wno-write-strings Don't convert string literals to char * in the strings_test example. In constantWrapper(), use SwigType_str() instead of SwigType_lstr() in order to keep const qualifiers. --- Examples/Makefile.in | 12 ++++++------ Examples/ocaml/stl/Makefile | 6 ------ Examples/ocaml/string_from_ptr/Makefile | 13 ++++++------- Examples/ocaml/strings_test/example.h | 6 +++--- Examples/ocaml/strings_test/runme.ml | 6 +++--- Lib/ocaml/ocaml.swg | 2 +- Source/Modules/ocaml.cxx | 2 +- 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5181de3f7..b11eda2cd 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -945,34 +945,34 @@ ocaml_static_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) + $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX)' ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) + $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX)' ocaml_dynamic_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) - $(OCC) -cc '$(CXX) -Wno-write-strings $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC + $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(INTERFACE:%.i=%@SO@) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(CPP_DLLIBS) $(LIBS) $(OCAMLDLGEN) $(INTERFACE:%.i=%.ml) $(INTERFACE:%.i=%@SO@) > $(INTERFACE:%.i=%_dynamic.ml) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(RUNME) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' + $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(RUNME) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)' # ----------------------------------------------------------------- # Run ocaml example diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index 912dd9f8d..683d34c36 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -17,12 +17,6 @@ static: PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -director: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - ocaml_static_cpp_director - dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 64df2df41..35bc4da38 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -1,7 +1,6 @@ TOP = ../.. SWIGEXE = $(TOP)/../swig SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -SWIGOPT = -c++ SRCS = TARGET = example INTERFACE = example.i @@ -16,23 +15,23 @@ build: static static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ - ocaml_static_cpp + ocaml_static static_top: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ - ocaml_static_cpp_toplevel + ocaml_static_toplevel dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ - ocaml_dynamic_cpp + ocaml_dynamic clean: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_clean diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h index 959404b5d..9dbc881a8 100644 --- a/Examples/ocaml/strings_test/example.h +++ b/Examples/ocaml/strings_test/example.h @@ -19,7 +19,7 @@ void takes_char_ptr( char *p ) { cout << "takes_char_ptr( \"" << p << "\" );" << endl; } -char *gives_char_ptr() { +const char *gives_const_char_ptr() { return "foo"; } @@ -28,8 +28,8 @@ void takes_and_gives_std_string( std::string &inout ) { inout.insert( inout.end(), ']' ); } -void takes_and_gives_char_ptr( char *&inout ) { - char *pout = strchr( inout, '.' ); +void takes_and_gives_const_char_ptr( const char *&inout ) { + const char *pout = strchr( inout, '.' ); if( pout ) inout = pout + 1; else inout = "foo"; } diff --git a/Examples/ocaml/strings_test/runme.ml b/Examples/ocaml/strings_test/runme.ml index 0eb56379c..727bc025e 100644 --- a/Examples/ocaml/strings_test/runme.ml +++ b/Examples/ocaml/strings_test/runme.ml @@ -8,10 +8,10 @@ let _ = print_endline ("_gives_std_string <<" ^ (get_string (_gives_std_string C_void)) ^ " >>") let _ = _takes_char_ptr (C_string "bar") let _ = print_endline - ("_gives_char_ptr << " ^ (get_string (_gives_char_ptr C_void)) ^ " >>") + ("_gives_const_char_ptr << " ^ (get_string (_gives_const_char_ptr C_void)) ^ " >>") let _ = print_endline ("_takes_and_gives_std_string << " ^ (get_string (_takes_and_gives_std_string (C_string "foo"))) ^ " >>") let _ = print_endline - ("_takes_and_gives_char_ptr << " ^ - (get_string (_takes_and_gives_char_ptr (C_string "bar.bar"))) ^ " >>") + ("_takes_and_gives_const_char_ptr << " ^ + (get_string (_takes_and_gives_const_char_ptr (C_string "bar.bar"))) ^ " >>") diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index d0007f856..728bec72f 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -381,7 +381,7 @@ extern "C" { caml_copy_string(name))); } - SWIGINTERN long caml_long_val_full( CAML_VALUE v, char *name ) { + SWIGINTERN long caml_long_val_full( CAML_VALUE v, const char *name ) { CAMLparam1(v); if( !Is_block(v) ) return 0; diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index fe44b1657..4952d060c 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -920,7 +920,7 @@ public: // See if there's a typemap // Create variable and assign it a value - Printf(f_header, "static %s = %s;\n", SwigType_lstr(type, name), value); + Printf(f_header, "static %s = %s;\n", SwigType_str(type, name), value); SetFlag(n, "feature:immutable"); variableWrapper(n); return SWIG_OK; From 25e650e7d8ce8973f4d94b3cbfe727d8b1371702 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 25 Jan 2019 01:58:48 -0700 Subject: [PATCH 1314/2031] [OCaml] Fix toplevel creation for ocamlmktop versions >= 4.04.0 The -o and -c options of ocamlc/ocamlopt were modified to be stricter in 4.04.0. https://github.com/ocaml/ocaml/commit/da56cf6dfdc13c09905c2e07f1d4849c8346eec8 The changes in Examples/Makefile.in are compatible with earlier OCaml versions (at least back to 3.12.0). --- Examples/Makefile.in | 6 +++--- Examples/ocaml/callback/Makefile | 2 +- Examples/ocaml/class/Makefile | 2 +- Examples/ocaml/shapes/Makefile | 4 ++-- Examples/ocaml/string_from_ptr/Makefile | 4 ++-- Examples/ocaml/strings_test/Makefile | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b11eda2cd..e0f1ce20d 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -899,7 +899,7 @@ mzscheme_clean: OCC=$(COMPILETOOL) @OCAMLC@ OCAMLDLGEN=$(COMPILETOOL) @OCAMLDLGEN@ OCAMLFIND=$(COMPILETOOL) @OCAMLFIND@ -OCAMLMKTOP=$(COMPILETOOL) @OCAMLMKTOP@ $(SWIGWHERE) +OCAMLMKTOP=$(COMPILETOOL) @OCAMLMKTOP@ NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where` @@ -939,7 +939,7 @@ ocaml_static_toplevel: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" + $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) ocaml_static_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -959,7 +959,7 @@ ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) - $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX)' + $(NOLINK) || $(OCAMLMKTOP) -cc '$(CXX) $(CPPFLAGS)' swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) ocaml_dynamic_cpp: $(SRCDIR_SRCS) $(OCAMLCORE) diff --git a/Examples/ocaml/callback/Makefile b/Examples/ocaml/callback/Makefile index 4cb4ef3dd..7344485f6 100644 --- a/Examples/ocaml/callback/Makefile +++ b/Examples/ocaml/callback/Makefile @@ -20,7 +20,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/class/Makefile b/Examples/ocaml/class/Makefile index 4cb4ef3dd..7344485f6 100644 --- a/Examples/ocaml/class/Makefile +++ b/Examples/ocaml/class/Makefile @@ -20,7 +20,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index a98c6a8e6..bc269d6d0 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -11,7 +11,7 @@ OBJS = example.o check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static +build: static toplevel static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ @@ -20,7 +20,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -static_top: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 35bc4da38..0d3163e36 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -10,7 +10,7 @@ OBJS = check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static +build: static toplevel static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ @@ -19,7 +19,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -static_top: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 2ddbe5f61..bed86841b 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -9,7 +9,7 @@ PROGFILE = runme.ml check: build $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' ocaml_run -build: static +build: static toplevel static: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ @@ -23,7 +23,7 @@ dynamic: PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -top: +toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ From f1a29ef6ecb3af468c5ac78b46d0e534e68570a3 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 25 Jan 2019 08:45:59 -0700 Subject: [PATCH 1315/2031] [OCaml] Don't generate duplicate declarations for overloaded functions The OCaml module was generating duplicate declarations in the ml and mli files for overloaded functions. For every wrapper function created for an overloaded function, it would generate a duplicate of the dispatch function in the ml and mli files. In addition, add the SWIG banner to generated ml and mli files. --- Source/Modules/ocaml.cxx | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index fe44b1657..07771f815 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -167,6 +167,12 @@ public: return declaration; } + void emitBanner(File *f) { + Printf(f, "(* ----------------------------------------------------------------------------\n"); + Swig_banner_target_lang(f, " *"); + Printf(f, " * ---------------------------------------------------------------------------- *)\n\n"); + } + /* ------------------------------------------------------------ * top() * @@ -310,6 +316,8 @@ public: FileErrorDisplay(mlifilen); SWIG_exit(EXIT_FAILURE); } + emitBanner(f_mlout); + emitBanner(f_mliout); Language::top(n); @@ -470,6 +478,8 @@ public: int destructor = (!Cmp(nodeType, "destructor")); String *overname = 0; bool isOverloaded = Getattr(n, "sym:overloaded") ? true : false; + // For overloaded functions, only the dispatch function needs to be exposed in the ml and mli files. + bool expose_func = !isOverloaded || !Getattr(n, "sym:nextSibling"); // Make a wrapper name for this String *wname = Swig_name_wrapper(iname); @@ -493,7 +503,7 @@ public: Printv(proc_name, "_", iname, NIL); String *mangled_name = mangleNameForCaml(proc_name); - if (classmode && in_constructor) { // Emit constructor for object + if (classmode && in_constructor && expose_func) { // Emit constructor for object String *mangled_name_nounder = NewString((char *) (Char(mangled_name)) + 1); Printf(f_class_ctors_end, "let %s clst = _%s clst\n", mangled_name_nounder, mangled_name_nounder); Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name_nounder); @@ -501,7 +511,7 @@ public: } else if (classmode && in_destructor) { Printf(f_class_ctors, " \"~\", %s ;\n", mangled_name); } else if (classmode && !in_constructor && !in_destructor && !static_member_function && - !Getattr(n, "membervariableHandler:sym:name")) { + !Getattr(n, "membervariableHandler:sym:name") && expose_func) { String *opname = Copy(Getattr(n, "memberfunctionHandler:sym:name")); Replaceall(opname, "operator ", ""); @@ -742,15 +752,16 @@ public: } } - Printf(f_mlbody, - "external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n" - "let %s arg = match %s_f (fnhelper arg) with\n" - " [] -> C_void\n" - "| [x] -> (if %s then Gc.finalise \n" - " (fun x -> ignore ((invoke x) \"~\" C_void)) x) ; x\n" - "| lst -> C_list lst ;;\n", mangled_name, wname, mangled_name, mangled_name, newobj ? "true" : "false"); + if (expose_func) + Printf(f_mlbody, + "external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n" + "let %s arg = match %s_f (fnhelper arg) with\n" + " [] -> C_void\n" + "| [x] -> (if %s then Gc.finalise \n" + " (fun x -> ignore ((invoke x) \"~\" C_void)) x) ; x\n" + "| lst -> C_list lst ;;\n", mangled_name, wname, mangled_name, mangled_name, newobj ? "true" : "false"); - if (!classmode || in_constructor || in_destructor || static_member_function) + if ((!classmode || in_constructor || in_destructor || static_member_function) && expose_func) Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name); Delete(proc_name); From 35663b16222623d3028d59d61297de43af1c5ef4 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 26 Jan 2019 05:58:38 -0700 Subject: [PATCH 1316/2031] [OCaml] Fix handling of exception specifications for director classes The OCaml module was generating invalid code for director classes which contain methods with exception specifications. The fix is based on some of the code in python.cxx's classDirectorMethod(). This commit fixes compilation failures for a number of director unit tests. Add director_exception_catches_runme.ml, director_exception_nothrow_runme.ml, and director_ignore_runme.ml. --- Examples/test-suite/ocaml/Makefile.in | 7 ---- .../ocaml/director_exception_catches_runme.ml | 15 ++++++++ .../ocaml/director_exception_nothrow_runme.ml | 12 +++++++ .../test-suite/ocaml/director_ignore_runme.ml | 18 ++++++++++ Source/Modules/ocaml.cxx | 36 +++++++++++++++++-- 5 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 Examples/test-suite/ocaml/director_exception_catches_runme.ml create mode 100644 Examples/test-suite/ocaml/director_exception_nothrow_runme.ml create mode 100644 Examples/test-suite/ocaml/director_ignore_runme.ml diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 14fe02646..3439d1d9f 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -22,20 +22,13 @@ cpp_enum \ default_constructor \ director_binary_string \ director_enum \ -director_exception \ -director_exception_nothrow \ -director_ignore \ -director_nested \ director_pass_by_value \ director_primitives \ -director_protected \ director_redefined \ director_string \ -director_using \ enum_thorough \ li_windows \ member_pointer_const \ -nested_directors \ preproc_constants \ smart_pointer_inherit \ typedef_mptr \ diff --git a/Examples/test-suite/ocaml/director_exception_catches_runme.ml b/Examples/test-suite/ocaml/director_exception_catches_runme.ml new file mode 100644 index 000000000..322cdda45 --- /dev/null +++ b/Examples/test-suite/ocaml/director_exception_catches_runme.ml @@ -0,0 +1,15 @@ +open Swig +open Director_exception_catches + +exception CustomException of string + +let new_MyClass ob meth args = + match meth with + | "description" -> raise (CustomException "CustomException thrown in description().") + | _ -> (invoke ob) meth args + +let b = new_derived_object new_BaseClass (new_MyClass) '() +try + ignore (_BaseClass_call_description (b)); assert false +with CustomException s -> + assert (s = "CustomException thrown in description().") diff --git a/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml b/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml new file mode 100644 index 000000000..5b2b4b3d2 --- /dev/null +++ b/Examples/test-suite/ocaml/director_exception_nothrow_runme.ml @@ -0,0 +1,12 @@ +open Swig +open Director_exception_nothrow + +let _MyBar ob meth args = + match meth with + | "pang" -> C_string "_MyBar::pang()" + | _ -> (invoke ob) meth args + +let a = new_derived_object new_Bar (_MyBar) '() +let _ = assert (_MyBar a "pang" '() as string = "_MyBar::pang()") +let b = new_Bar '() +let _ = assert (b -> pang () as string = "Bar::pang()") diff --git a/Examples/test-suite/ocaml/director_ignore_runme.ml b/Examples/test-suite/ocaml/director_ignore_runme.ml new file mode 100644 index 000000000..b0d3b1451 --- /dev/null +++ b/Examples/test-suite/ocaml/director_ignore_runme.ml @@ -0,0 +1,18 @@ +open Swig +open Director_ignore + +let _DIgnoresDerived ob meth args = + match meth with + | "OverloadedMethod" -> C_int 0 + | _ -> (invoke ob) meth args + +let a =new_derived_object new_DIgnores (_DIgnoresDerived) '() +let _ = assert (a -> Triple (5) as int = 15) + +let _DAbstractIgnoresDerived ob meth args = + match meth with + | "OverloadedMethod" -> C_int 0 + | _ -> (invoke ob) meth args + +let a = new_derived_object new_DAbstractIgnores (_DAbstractIgnoresDerived) '() +let _ = assert (a -> Quadruple (5) as int = 20) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index fe44b1657..71ea69fe7 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1400,14 +1400,46 @@ public: String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); target = Swig_method_decl(rtype, decl, qualified_name, l, 0); - Printf(w->def, "%s {", target); + Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ target = Swig_method_decl(rtype, decl, name, l, 1); - Printf(declaration, " virtual %s;", target); + Printf(declaration, " virtual %s", target); Delete(target); + // Get any exception classes in the throws typemap + if (Getattr(n, "noexcept")) { + Append(w->def, " noexcept"); + Append(declaration, " noexcept"); + } + ParmList *throw_parm_list = 0; + if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { + Parm *p; + int gencomma = 0; + + Append(w->def, " throw("); + Append(declaration, " throw("); + + if (throw_parm_list) + Swig_typemap_attach_parms("throws", throw_parm_list, 0); + for (p = throw_parm_list; p; p = nextSibling(p)) { + if (Getattr(p, "tmap:throws")) { + if (gencomma++) { + Append(w->def, ", "); + Append(declaration, ", "); + } + String *str = SwigType_str(Getattr(p, "type"), 0); + Append(w->def, str); + Append(declaration, str); + Delete(str); + } + } + Append(w->def, ")"); + Append(declaration, ")"); + } + Append(w->def, " {"); + Append(declaration, ";\n"); /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). From 591a70378ebf6cf0ba74030892087634e86c153f Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Mon, 12 Nov 2018 10:13:13 -0500 Subject: [PATCH 1317/2031] Fixing python docstring handling for -fastproxy --- CHANGES.current | 3 + Examples/test-suite/python/autodoc_runme.py | 106 ++++---------------- Source/Modules/lang.cxx | 6 ++ Source/Modules/python.cxx | 96 +++++++++++++----- 4 files changed, 101 insertions(+), 110 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 75dd2085d..b9b68176e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-13: ahnolds + [Python] #728 Fixed the handling of autodoc when using -fastproxy + 2019-01-22: vadz [Ruby, Octave] #1424 Improve autodoc parameter naming. diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index d866cb990..652a5afff 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -10,19 +10,6 @@ def check(got, expected, expected_builtin=None, skip=False): expect = expected_builtin comment_verifier.check(got, expect) -def is_fastproxy(): - fastproxy = True - try: - from autodoc import _swig_new_instance_method - except ImportError: - fastproxy = False - return fastproxy - -if is_fastproxy(): - # Detect when -fastproxy is specified and skip test as it changes the function names making it - # hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved - sys.exit(0) - # skip builtin check - the autodoc is missing, but it probably should not be skip = True @@ -48,11 +35,9 @@ check(inspect.getdoc(A.func3), "hello: int tuple[2]") check(inspect.getdoc(A.func0default), - "func0default(self, e, arg3, hello, f=2) -> int\n" - "func0default(self, e, arg3, hello) -> int") + "func0default(self, e, arg3, hello, f=2) -> int") check(inspect.getdoc(A.func1default), - "func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" - "func1default(A self, A e, short arg3, Tuple hello) -> int") + "func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") check(inspect.getdoc(A.func2default), "func2default(self, e, arg3, hello, f=2) -> int\n" "\n" @@ -61,15 +46,7 @@ check(inspect.getdoc(A.func2default), "e: A *\n" "arg3: short\n" "hello: int tuple[2]\n" - "f: double\n" - "\n" - "func2default(self, e, arg3, hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg3: short\n" - "hello: int tuple[2]") + "f: double") check(inspect.getdoc(A.func3default), "func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" @@ -78,22 +55,12 @@ check(inspect.getdoc(A.func3default), "e: A *\n" "arg3: short\n" "hello: int tuple[2]\n" - "f: double\n" - "\n" - "func3default(A self, A e, short arg3, Tuple hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg3: short\n" - "hello: int tuple[2]") + "f: double") check(inspect.getdoc(A.func0static), - "func0static(e, arg2, hello, f=2) -> int\n" - "func0static(e, arg2, hello) -> int") + "func0static(e, arg2, hello, f=2) -> int") check(inspect.getdoc(A.func1static), - "func1static(A e, short arg2, Tuple hello, double f=2) -> int\n" - "func1static(A e, short arg2, Tuple hello) -> int") + "func1static(A e, short arg2, Tuple hello, double f=2) -> int") check(inspect.getdoc(A.func2static), "func2static(e, arg2, hello, f=2) -> int\n" "\n" @@ -102,15 +69,7 @@ check(inspect.getdoc(A.func2static), "e: A *\n" "arg2: short\n" "hello: int tuple[2]\n" - "f: double\n" - "\n" - "func2static(e, arg2, hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg2: short\n" - "hello: int tuple[2]") + "f: double") check(inspect.getdoc(A.func3static), "func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" "\n" @@ -119,42 +78,20 @@ check(inspect.getdoc(A.func3static), "e: A *\n" "arg2: short\n" "hello: int tuple[2]\n" - "f: double\n" - "\n" - "func3static(A e, short arg2, Tuple hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg2: short\n" - "hello: int tuple[2]") + "f: double") -if sys.version_info[0:2] > (2, 4): - # Python 2.4 does not seem to work - check(inspect.getdoc(A.variable_a), - "A_variable_a_get(self) -> int", - "A.variable_a" - ) - check(inspect.getdoc(A.variable_b), - "A_variable_b_get(A self) -> int", - "A.variable_b" - ) - check(inspect.getdoc(A.variable_c), - "A_variable_c_get(self) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "self: A *", - "A.variable_c" - ) - check(inspect.getdoc(A.variable_d), - "A_variable_d_get(A self) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "self: A *", - "A.variable_d" - ) +check(inspect.getdoc(A.variable_a), + "A.variable_a" + ) +check(inspect.getdoc(A.variable_b), + "A.variable_b : int" + ) +check(inspect.getdoc(A.variable_c), + "A.variable_c" + ) +check(inspect.getdoc(A.variable_d), + "A.variable_d : int" + ) check(inspect.getdoc(B), "Proxy of C++ B class.", @@ -190,8 +127,7 @@ check(inspect.getdoc(B.funk), "funk(B self, int c, int d) -> int") check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int") check(inspect.getdoc(funkdefaults), - "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" - "funkdefaults(A e, short arg2, int c, int d) -> int") + "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int") check(inspect.getdoc(func_input), "func_input(int * INPUT) -> int") check(inspect.getdoc(func_output), "func_output() -> int") diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 92445dc3f..451274743 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1081,6 +1081,8 @@ int Language::functionHandler(Node *n) { globalfunctionHandler(n); InClass = oldInClass; } else { + // This is a member function, set a flag so the documentation type is correct + SetFlag(n, "memberfunction"); Node *explicit_n = 0; if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) { bool virtual_but_not_pure_virtual = (!(Cmp(storage, "virtual")) && (Cmp(Getattr(n, "value"), "0") != 0)); @@ -1270,6 +1272,8 @@ int Language::memberfunctionHandler(Node *n) { int flags = Getattr(n, "template") ? extendmember | SmartPointer : Extend | SmartPointer | DirectorExtraCall; Swig_MethodToFunction(n, NSpace, ClassType, flags, director_type, is_member_director(CurrentClass, n)); Setattr(n, "sym:name", fname); + // Save the original name for use in documentation + Setattr(n, "doc:name", symname); functionWrapper(n); @@ -1330,6 +1334,8 @@ int Language::staticmemberfunctionHandler(Node *n) { Setattr(n, "name", cname); Setattr(n, "sym:name", mrename); + // Save the original name for use in documentation + Setattr(n, "doc:name", symname); if (cb) { String *cbname = NewStringf(cb, symname); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 86f3a38e2..572013ab8 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -100,7 +100,8 @@ enum autodoc_t { AUTODOC_STATICFUNC, AUTODOC_FUNC, AUTODOC_METHOD, - AUTODOC_CONST + AUTODOC_CONST, + AUTODOC_VAR }; @@ -1598,14 +1599,14 @@ public: * * Inputs: * plist - entire parameter list - * arg_offset - argument number for first parameter + * arg_num - the number to start from when naming arguments * Side effects: * The "lname" attribute in each parameter in plist will be contain a parameter name * ----------------------------------------------------------------------------- */ - void addMissingParameterNames(Node *n, ParmList *plist, int arg_offset) { + void addMissingParameterNames(Node *n, ParmList *plist, int arg_num) { Parm *p = plist; - int i = arg_offset; + int i = arg_num; while (p) { if (!Getattr(p, "lname")) { String *name = makeParameterName(n, p, i); @@ -1622,10 +1623,11 @@ public: * * Generate the documentation for the function parameters * Parameters: + * arg_num: The number to start assigning unnamed arguments from * 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, int arg_num = 1, bool calling = false, bool func_annotation = false) { String *doc = NewString(""); String *pdocs = 0; @@ -1633,15 +1635,6 @@ public: Parm *p; Parm *pnext; - - // Normally we start counting auto-generated argument names from 1, but we should do it from 2 - // if the first argument is "self", i.e. if we're handling a non-static member function. - int arg_num = 1; - if (is_wrapping_class()) { - if (Cmp(Getattr(n, "storage"), "static") != 0) - arg_num++; - } - if (calling) func_annotation = false; @@ -1654,8 +1647,7 @@ public: return doc; } - for (p = plist; p; p = pnext, arg_num++) { - + for (p = plist; p; p = pnext) { String *tm = Getattr(p, "tmap:in"); if (tm) { pnext = Getattr(p, "tmap:in:next"); @@ -1676,12 +1668,21 @@ public: value = Getattr(p, "tmap:doc:value"); } + // Skip the "self" argument - it is added to the parameter list automatically + // and shouldn't be included in the Parameters block + if (Getattr(p, "self")) { + continue; + } + // Note: the generated name should be consistent with that in kwnames[] String *made_name = 0; if (!name) { name = made_name = makeParameterName(n, p, arg_num); } + // Increment the argument number once we are sure this is a real argument to count + arg_num++; + type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); @@ -1787,10 +1788,19 @@ public: } if (!skipAuto) { - String *symname = Getattr(n, "sym:name"); + // Use the documentation-specific symbol name if available + String *symname = Getattr(n, "doc:name"); + if (!symname) + symname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *type_str = NULL; + // If the function has default arguments, then that documentation covers this version too + if (Getattr(n, "defaultargs") != NULL) { + n = Getattr(n, "sym:nextSibling"); + continue; + } + if (type) { if (Strcmp(type, "void") == 0) { type_str = NULL; @@ -1823,7 +1833,7 @@ public: break; case AUTODOC_CTOR: if (Strcmp(class_name, symname) == 0) { - String *paramList = make_autodocParmList(n, showTypes); + String *paramList = make_autodocParmList(n, showTypes, 2); Printf(doc, "__init__("); if (showTypes) Printf(doc, "%s ", class_name); @@ -1856,7 +1866,7 @@ public: case AUTODOC_METHOD: { - String *paramList = make_autodocParmList(n, showTypes); + String *paramList = make_autodocParmList(n, showTypes, 2); Printf(doc, "%s(", symname); if (showTypes) Printf(doc, "%s ", class_name); @@ -1873,10 +1883,21 @@ public: // There is no autodoc support for constants currently, this enum // element only exists to allow calling docstring() with it. return NULL; + case AUTODOC_VAR: + // Variables can also be documented (e.g. through the property() function in python) + Printf(doc, "%s.%s", class_name, symname); + String *type = Getattr(n, "tmap:doc:type"); + if (! type) + type = Getattr(n, "membervariableHandler:type"); + if (! type) + type = Getattr(n, "type"); + if (showTypes) + Printf(doc, " : %s", type); + break; } Delete(type_str); } - if (extended) { + if (extended && ad_type != AUTODOC_VAR) { String *pdocs = Getattr(n, "feature:pdocs"); if (pdocs) { Printv(doc, "\n", pdocs, NULL); @@ -2165,7 +2186,7 @@ public: bool funcanno = py3 ? true : false; String *params = NewString(""); - String *_params = make_autodocParmList(n, false, is_calling, funcanno); + String *_params = make_autodocParmList(n, false, (in_class? 2 : 1), is_calling, funcanno); if (in_class) { Printf(params, "self"); @@ -2244,7 +2265,7 @@ public: * ------------------------------------------------------------ */ bool have_addtofunc(Node *n) { - return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n); + return have_pythonappend(n) || have_pythonprepend(n); } @@ -2362,7 +2383,8 @@ public: if (!n) { Append(methods, "NULL"); } else if (have_docstring(n)) { - String *ds = cdocstring(n, AUTODOC_FUNC); + // The format for the documentation differs based on whether this is a member function or a free function + String *ds = cdocstring(n, Getattr(n, "memberfunction") ? AUTODOC_METHOD : AUTODOC_FUNC); Printf(methods, "\"%s\"", ds); Delete(ds); } else if (Getattr(n, "feature:callback")) { @@ -3187,6 +3209,10 @@ public: Delete(h); } Setattr(h, "getter", "SwigPyObject_get___dict__"); + if (! Getattr(h, "doc")) { + Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); + } } if (builtin_getter) { @@ -3201,6 +3227,10 @@ public: } Setattr(h, "getter", wrapper_name); Delattr(n, "memberget"); + if (! Getattr(h, "doc")) { + Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); + } } if (builtin_setter) { String *memname = Getattr(n, "membervariableHandler:sym:name"); @@ -3214,6 +3244,10 @@ public: } Setattr(h, "setter", wrapper_name); Delattr(n, "memberset"); + if (! Getattr(h, "doc")) { + Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); + } } if (in_class && builtin) { @@ -3888,9 +3922,15 @@ public: const char *setter_closure = setter ? funpack ? "SwigPyBuiltin_FunpackSetterClosure" : "SwigPyBuiltin_SetterClosure" : "0"; String *gspair = NewStringf("%s_%s_getset", symname, memname); Printf(f, "static SwigPyGetSet %s = { %s, %s };\n", gspair, getter ? getter : "0", setter ? setter : "0"); + String *doc; + if (Getattr(mgetset, "doc")) { + doc = Getattr(mgetset, "doc"); + } else { + doc = NewStringf("%s.%s", name, memname); + } String *entry = - NewStringf("{ (char *)\"%s\", (getter)%s, (setter)%s, (char *)\"%s.%s\", (void *)&%s }\n", memname, getter_closure, - setter_closure, name, memname, gspair); + NewStringf("{ (char *)\"%s\", (getter)%s, (setter)%s, (char *)\"%s\", (void *)&%s }\n", memname, getter_closure, + setter_closure, doc, gspair); if (GetFlag(mgetset, "static")) { Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry); Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair); @@ -4559,6 +4599,8 @@ public: if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { Printv(f_shadow, "\n", tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); + if (have_docstring(n)) + Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL); } } else { @@ -4881,6 +4923,8 @@ public: Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); + if (have_docstring(n)) + Printv(f_shadow, ", doc=", docstring(n, AUTODOC_VAR, tab4), NIL); Printv(f_shadow, ")\n", NIL); Delete(mname); Delete(setname); @@ -4946,6 +4990,8 @@ public: Printv(f_shadow, tab4, symname, " = property(", module, ".", getname, NIL); if (assignable) Printv(f_shadow, ", ", module, ".", setname, NIL); + if (have_docstring(n)) + Printv(f_shadow, ", doc=", docstring(n, AUTODOC_VAR, tab4), NIL); Printv(f_shadow, ")\n", NIL); } String *getter = Getattr(n, "pybuiltin:getter"); From 97a624f360f001267d7255ec3e7506e75b8eca05 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Sun, 13 Jan 2019 10:49:58 -0500 Subject: [PATCH 1318/2031] Fix a bug where anonymous arguments were misnumbered when used in constructors --- Source/Modules/python.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 572013ab8..85da53973 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2153,7 +2153,7 @@ public: * 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) { + String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw, bool has_self_for_count = false) { /* Get the original function for a defaultargs copy, * see default_arguments() in parser.y. */ Node *nn = Getattr(n, "defaultargs"); @@ -2186,7 +2186,7 @@ public: bool funcanno = py3 ? true : false; String *params = NewString(""); - String *_params = make_autodocParmList(n, false, (in_class? 2 : 1), is_calling, funcanno); + String *_params = make_autodocParmList(n, false, ((in_class || has_self_for_count)? 2 : 1), is_calling, funcanno); if (in_class) { Printf(params, "self"); @@ -4785,7 +4785,7 @@ public: String *parms = make_pyParmList(n, true, false, allow_kwargs); /* Pass 'self' only if using director */ - String *callParms = make_pyParmList(n, false, true, allow_kwargs); + String *callParms = make_pyParmList(n, false, true, allow_kwargs, true); if (use_director) { Insert(callParms, 0, "_self, "); From fb58727135533e52c832d8e5f0fafe105a2cd3c4 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Sat, 19 Jan 2019 08:54:50 -0500 Subject: [PATCH 1319/2031] Also check documentation on the low-level API --- Examples/test-suite/python/autodoc_runme.py | 165 +++++++++++++++++++- 1 file changed, 158 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 652a5afff..cb30eedf6 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -1,10 +1,14 @@ from autodoc import * +import _autodoc import comment_verifier import inspect import sys def check(got, expected, expected_builtin=None, skip=False): - if not skip: + if is_python_builtin() and skip: + # Only skip for builtins + pass + else: expect = expected if is_python_builtin() and expected_builtin != None: expect = expected_builtin @@ -15,10 +19,15 @@ skip = True check(inspect.getdoc(A), "Proxy of C++ A class.", "::A") check(inspect.getdoc(A.funk), "just a string.") +check(inspect.getdoc(_autodoc.A_funk), "just a string.") check(inspect.getdoc(A.func0), "func0(self, arg2, hello) -> int") +check(inspect.getdoc(_autodoc.A_func0), + "A_func0(self, arg2, hello) -> int") check(inspect.getdoc(A.func1), "func1(A self, short arg2, Tuple hello) -> int") +check(inspect.getdoc(_autodoc.A_func1), + "A_func1(A self, short arg2, Tuple hello) -> int") check(inspect.getdoc(A.func2), "func2(self, arg2, hello) -> int\n" "\n" @@ -26,6 +35,13 @@ check(inspect.getdoc(A.func2), "----------\n" "arg2: short\n" "hello: int tuple[2]") +check(inspect.getdoc(_autodoc.A_func2), + "A_func2(self, arg2, hello) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]") check(inspect.getdoc(A.func3), "func3(A self, short arg2, Tuple hello) -> int\n" "\n" @@ -33,11 +49,22 @@ check(inspect.getdoc(A.func3), "----------\n" "arg2: short\n" "hello: int tuple[2]") +check(inspect.getdoc(_autodoc.A_func3), + "A_func3(A self, short arg2, Tuple hello) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]") check(inspect.getdoc(A.func0default), "func0default(self, e, arg3, hello, f=2) -> int") +check(inspect.getdoc(_autodoc.A_func0default), + "A_func0default(self, e, arg3, hello, f=2) -> int") check(inspect.getdoc(A.func1default), "func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") +check(inspect.getdoc(_autodoc.A_func1default), + "A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") check(inspect.getdoc(A.func2default), "func2default(self, e, arg3, hello, f=2) -> int\n" "\n" @@ -47,6 +74,15 @@ check(inspect.getdoc(A.func2default), "arg3: short\n" "hello: int tuple[2]\n" "f: double") +check(inspect.getdoc(_autodoc.A_func2default), + "A_func2default(self, e, arg3, hello, f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double") check(inspect.getdoc(A.func3default), "func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" @@ -56,11 +92,28 @@ check(inspect.getdoc(A.func3default), "arg3: short\n" "hello: int tuple[2]\n" "f: double") +check(inspect.getdoc(_autodoc.A_func3default), + "A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double") check(inspect.getdoc(A.func0static), "func0static(e, arg2, hello, f=2) -> int") +check(inspect.getdoc(_autodoc.A_func0static), + "A_func0static(e, arg2, hello, f=2) -> int") +check(inspect.getdoc(A_func0static), + "A_func0static(e, arg2, hello, f=2) -> int") check(inspect.getdoc(A.func1static), "func1static(A e, short arg2, Tuple hello, double f=2) -> int") +check(inspect.getdoc(_autodoc.A_func1static), + "A_func1static(A e, short arg2, Tuple hello, double f=2) -> int") +check(inspect.getdoc(A_func1static), + "A_func1static(A e, short arg2, Tuple hello, double f=2) -> int") check(inspect.getdoc(A.func2static), "func2static(e, arg2, hello, f=2) -> int\n" "\n" @@ -70,6 +123,24 @@ check(inspect.getdoc(A.func2static), "arg2: short\n" "hello: int tuple[2]\n" "f: double") +check(inspect.getdoc(_autodoc.A_func2static), + "A_func2static(e, arg2, hello, f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double") +check(inspect.getdoc(A_func2static), + "A_func2static(e, arg2, hello, f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double") check(inspect.getdoc(A.func3static), "func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" "\n" @@ -79,30 +150,91 @@ check(inspect.getdoc(A.func3static), "arg2: short\n" "hello: int tuple[2]\n" "f: double") +check(inspect.getdoc(_autodoc.A_func3static), + "A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double") +check(inspect.getdoc(A_func3static), + "A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg2: short\n" + "hello: int tuple[2]\n" + "f: double") check(inspect.getdoc(A.variable_a), "A.variable_a" ) +check(inspect.getdoc(_autodoc.A_variable_a_set), + "A_variable_a_set(self, variable_a)" + ) +check(inspect.getdoc(_autodoc.A_variable_a_get), + "A_variable_a_get(self) -> int" + ) check(inspect.getdoc(A.variable_b), "A.variable_b : int" ) +check(inspect.getdoc(_autodoc.A_variable_b_set), + "A_variable_b_set(A self, int variable_b)" + ) +check(inspect.getdoc(_autodoc.A_variable_b_get), + "A_variable_b_get(A self) -> int" + ) check(inspect.getdoc(A.variable_c), "A.variable_c" - ) + ) +check(inspect.getdoc(_autodoc.A_variable_c_set), + "A_variable_c_set(self, variable_c) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "self: A *\n" + "variable_c: int" + ) +check(inspect.getdoc(_autodoc.A_variable_c_get), + "A_variable_c_get(self) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "self: A *" + ) check(inspect.getdoc(A.variable_d), "A.variable_d : int" - ) + ) +check(inspect.getdoc(_autodoc.A_variable_d_set), + "A_variable_d_set(A self, int variable_d) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "self: A *\n" + "variable_d: int" + ) +check(inspect.getdoc(_autodoc.A_variable_d_get), + "A_variable_d_get(self) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "self: A *" + ) check(inspect.getdoc(B), "Proxy of C++ B class.", "::B" ) check(inspect.getdoc(C.__init__), "__init__(self, a, b, h) -> C", None, skip) +check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C") check(inspect.getdoc(D.__init__), "__init__(D self, int a, int b, Hola h) -> D", None, skip) +check(inspect.getdoc(_autodoc.new_D), + "new_D(int a, int b, Hola h) -> D") check(inspect.getdoc(E.__init__), - "__init__(self, a, b, h) -> E\n" - "\n" "__init__(self, a, b, h) -> E\n" "\n" "Parameters\n" @@ -111,9 +243,16 @@ check(inspect.getdoc(E.__init__), "b: another special comment for parameter b\n" "h: enum Hola", None, skip ) +check(inspect.getdoc(_autodoc.new_E), + "new_E(a, b, h) -> E\n" + "\n" + "Parameters\n" + "----------\n" + "a: special comment for parameter a\n" + "b: another special comment for parameter b\n" + "h: enum Hola" + ) check(inspect.getdoc(F.__init__), - "__init__(F self, int a, int b, Hola h) -> F\n" - "\n" "__init__(F self, int a, int b, Hola h) -> F\n" "\n" "Parameters\n" @@ -122,9 +261,20 @@ check(inspect.getdoc(F.__init__), "b: another special comment for parameter b\n" "h: enum Hola", None, skip ) +check(inspect.getdoc(_autodoc.new_F), + "new_F(int a, int b, Hola h) -> F\n" + "\n" + "Parameters\n" + "----------\n" + "a: special comment for parameter a\n" + "b: another special comment for parameter b\n" + "h: enum Hola" + ) check(inspect.getdoc(B.funk), "funk(B self, int c, int d) -> int") +check(inspect.getdoc(_autodoc.B_funk), + "B_funk(B self, int c, int d) -> int") check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int") check(inspect.getdoc(funkdefaults), "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int") @@ -138,6 +288,7 @@ check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)") check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >") check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip) check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger") +check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger") check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int") check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int") From 645f0d61925b5dd33f01e6ad7d79c50eff9eb04a Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Sat, 19 Jan 2019 08:55:06 -0500 Subject: [PATCH 1320/2031] Updating the changelog --- CHANGES.current | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index b9b68176e..e8a1fdbf4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,7 +8,15 @@ Version 4.0.0 (in progress) =========================== 2019-01-13: ahnolds - [Python] #728 Fixed the handling of autodoc when using -fastproxy + [Python] Documentation enhancements for Python: + + #728 Fixed the handling of autodoc when using -fastproxy. + + Added documentation to wrapped member variables using the propery(... doc="...") + construct. + + Only show a single documentation entry for functions with default arguments when + using autodoc. 2019-01-22: vadz [Ruby, Octave] #1424 Improve autodoc parameter naming. From 86e08c8e34ba18e87ed11dd4a156ce7f59581b90 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Fri, 25 Jan 2019 08:06:17 -0500 Subject: [PATCH 1321/2031] Fixes so that fastproxy and autodoc work correctly with both low-level C API and high-level Python Shadow API --- CHANGES.current | 4 +- Examples/test-suite/python/autodoc_runme.py | 18 +-- Lib/python/pyapi.swg | 36 +++++ Source/Modules/lang.cxx | 10 +- Source/Modules/python.cxx | 137 ++++++++++++++++---- 5 files changed, 163 insertions(+), 42 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e8a1fdbf4..2b41c50c6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -12,8 +12,8 @@ Version 4.0.0 (in progress) #728 Fixed the handling of autodoc when using -fastproxy. - Added documentation to wrapped member variables using the propery(... doc="...") - construct. + #1367 Added documentation to wrapped member variables using the + propery(... doc="...") construct. Only show a single documentation entry for functions with default arguments when using autodoc. diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index cb30eedf6..9dadccf23 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -191,37 +191,27 @@ check(inspect.getdoc(A.variable_c), "A.variable_c" ) check(inspect.getdoc(_autodoc.A_variable_c_set), - "A_variable_c_set(self, variable_c) -> int\n" + "A_variable_c_set(self, variable_c)\n" "\n" "Parameters\n" "----------\n" - "self: A *\n" "variable_c: int" ) check(inspect.getdoc(_autodoc.A_variable_c_get), - "A_variable_c_get(self) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "self: A *" + "A_variable_c_get(self) -> int" ) check(inspect.getdoc(A.variable_d), "A.variable_d : int" ) check(inspect.getdoc(_autodoc.A_variable_d_set), - "A_variable_d_set(A self, int variable_d) -> int\n" + "A_variable_d_set(A self, int variable_d)\n" "\n" "Parameters\n" "----------\n" - "self: A *\n" "variable_d: int" ) check(inspect.getdoc(_autodoc.A_variable_d_get), - "A_variable_d_get(self) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "self: A *" + "A_variable_d_get(A self) -> int" ) check(inspect.getdoc(B), diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index 89f57fc83..5c2c65c45 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -24,6 +24,11 @@ typedef struct swig_const_info { swig_type_info **ptype; } swig_const_info; +/* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ +PyMethodDef* getProxyDoc(const char* name); /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 @@ -31,6 +36,17 @@ typedef struct swig_const_info { * ----------------------------------------------------------------------------- */ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + /* Unpack the existing PyCFunction */ + PyMethodDef* ml = ((PyCFunctionObject*) func)->m_ml; + PyObject* self = ((PyCFunctionObject*) func)->m_self; + PyObject* module = ((PyCFunctionObject*) func)->m_module; + /* Use the copy with the modified docstring if available */ + ml = getProxyDoc(ml->ml_name); + if (ml != NULL) { + func = PyCFunction_NewEx(ml, self, module); + } + } #if PY_VERSION_HEX >= 0x03000000 return PyInstanceMethod_New(func); #else @@ -38,6 +54,26 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), #endif } +/* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +SWIGRUNTIME PyObject* SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + if (PyCFunction_Check(func)) { + /* Unpack the existing PyCFunction */ + PyMethodDef* ml = ((PyCFunctionObject*) func)->m_ml; + PyObject* self = ((PyCFunctionObject*) func)->m_self; + PyObject* module = ((PyCFunctionObject*) func)->m_module; + /* Use the copy with the modified docstring if available */ + ml = getProxyDoc(ml->ml_name); + if (ml != NULL) { + func = PyCFunction_NewEx(ml, self, module); + } + } + return PyStaticMethod_New(func); +} + #ifdef __cplusplus } #endif diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 451274743..f9af9723a 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1272,8 +1272,9 @@ int Language::memberfunctionHandler(Node *n) { int flags = Getattr(n, "template") ? extendmember | SmartPointer : Extend | SmartPointer | DirectorExtraCall; Swig_MethodToFunction(n, NSpace, ClassType, flags, director_type, is_member_director(CurrentClass, n)); Setattr(n, "sym:name", fname); - // Save the original name for use in documentation - Setattr(n, "doc:name", symname); + /* Explicitly save low-level and high-level documentation names */ + Setattr(n, "doc:low:name", fname); + Setattr(n, "doc:high:name", symname); functionWrapper(n); @@ -1334,8 +1335,9 @@ int Language::staticmemberfunctionHandler(Node *n) { Setattr(n, "name", cname); Setattr(n, "sym:name", mrename); - // Save the original name for use in documentation - Setattr(n, "doc:name", symname); + /* Explicitly save low-level and high-level documentation names */ + Setattr(n, "doc:low:name", mrename); + Setattr(n, "doc:high:name", symname); if (cb) { String *cbname = NewStringf(cb, symname); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 85da53973..8fcc0d48b 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -62,6 +62,7 @@ static String *builtin_default_unref = 0; static String *builtin_closures_code = 0; static String *methods; +static String *methods_proxydocs; static String *class_name; static String *shadow_indent = 0; static int in_class = 0; @@ -572,6 +573,7 @@ public: const_code = NewString(""); methods = NewString(""); + methods_proxydocs = NewString(""); Swig_banner(f_begin); @@ -702,6 +704,7 @@ public: if (!builtin && fastproxy) { Printf(f_shadow, "\n"); Printf(f_shadow, "_swig_new_instance_method = %s.SWIG_PyInstanceMethod_New\n", module); + Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module); } { @@ -801,9 +804,11 @@ public: Printf(f_wrappers, "#endif\n"); Append(const_code, "static swig_const_info swig_const_table[] = {\n"); Append(methods, "static PyMethodDef SwigMethods[] = {\n"); + Append(methods_proxydocs, "static PyMethodDef SwigMethods_proxydocs[] = {\n"); /* the method exported for replacement of new.instancemethod in Python 3 */ add_pyinstancemethod_new(); + add_pystaticmethod_new(); if (builtin) { SwigType *s = NewString("SwigPyObject"); @@ -825,6 +830,30 @@ public: Append(methods, "\t { NULL, NULL, 0, NULL }\n"); Append(methods, "};\n"); Printf(f_wrappers, "%s\n", methods); + Append(methods_proxydocs, "\t { NULL, NULL, 0, NULL }\n"); + Append(methods_proxydocs, "};\n"); + Printf(f_wrappers, "%s\n", methods_proxydocs); + + /* Need to define the function to find the proxy documentation after the proxy docs themselves */ + Printv(f_wrappers, "PyMethodDef* getProxyDoc(const char* name)\n", + "{\n", + " /* Find the function in the modified method table */\n", + " size_t offset = 0;\n", + " bool found = false;\n", + " while (SwigMethods_proxydocs[offset].ml_meth != NULL) {\n", + " if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {\n", + " found = true;\n", + " break;\n", + " }\n", + " offset++;\n", + " }\n", + " /* Use the copy with the modified docstring if available */\n", + " if (found) {\n", + " return &SwigMethods_proxydocs[offset];\n", + " } else {\n", + " return NULL;\n", + " }\n", + "}\n", NIL); if (builtin) { Dump(f_builtins, f_wrappers); @@ -926,11 +955,35 @@ public: * ------------------------------------------------------------ */ int add_pyinstancemethod_new() { String *name = NewString("SWIG_PyInstanceMethod_New"); - Printf(methods, "\t { \"%s\", %s, METH_O, NULL},\n", name, name); + String *line = NewString(""); + Printf(line, "\t { \"%s\", %s, METH_O, NULL},\n", name, name); + Append(methods, line); + if (fastproxy) { + Append(methods_proxydocs, line); + } + Delete(line); Delete(name); return 0; } + /* ------------------------------------------------------------ + * Emit the wrapper for PyStaticMethod_New to MethodDef array. + * This wrapper is used to ensure the correct documentation is + * generated for static methods when using -fastproxy + * ------------------------------------------------------------ */ + int add_pystaticmethod_new() { + if (fastproxy) { + String *name = NewString("SWIG_PyStaticMethod_New"); + String *line = NewString(""); + Printf(line, "\t { \"%s\", %s, METH_O, NULL},\n", name, name); + Append(methods, line); + Append(methods_proxydocs, line); + Delete(line); + Delete(name); + } + return 0; + } + /* ------------------------------------------------------------ * subpkg_tail() * @@ -1478,7 +1531,7 @@ public: * may be empty if there is no docstring). * ------------------------------------------------------------ */ - String *build_combined_docstring(Node *n, autodoc_t ad_type, const String *indent = "") { + String *build_combined_docstring(Node *n, autodoc_t ad_type, const String *indent = "", bool low_level = false) { String *docstr = Getattr(n, "feature:docstring"); if (docstr && Len(docstr)) { docstr = Copy(docstr); @@ -1490,7 +1543,7 @@ public: } if (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) { - String *autodoc = make_autodoc(n, ad_type); + String *autodoc = make_autodoc(n, ad_type, low_level); if (autodoc && Len(autodoc) > 0) { if (docstr && Len(docstr)) { Append(autodoc, "\n"); @@ -1583,9 +1636,9 @@ public: * source code (but without quotes around it). * ------------------------------------------------------------ */ - String *cdocstring(Node *n, autodoc_t ad_type) + String *cdocstring(Node *n, autodoc_t ad_type, bool low_level = false) { - String *ds = build_combined_docstring(n, ad_type); + String *ds = build_combined_docstring(n, ad_type, "", low_level); Replaceall(ds, "\\", "\\\\"); Replaceall(ds, "\"", "\\\""); Replaceall(ds, "\n", "\\n\"\n\t\t\""); @@ -1750,7 +1803,7 @@ public: * and use it directly. * ------------------------------------------------------------ */ - String *make_autodoc(Node *n, autodoc_t ad_type) { + String *make_autodoc(Node *n, autodoc_t ad_type, bool low_level = false) { int extended = 0; // If the function is overloaded then this function is called // for the last one. Rewind to the first so the docstrings are @@ -1788,10 +1841,12 @@ public: } if (!skipAuto) { - // Use the documentation-specific symbol name if available - String *symname = Getattr(n, "doc:name"); - if (!symname) + /* Check if a documentation name was given for either the low-level C API or high-level Python shadow API */ + String *symname = Getattr(n, low_level? "doc:low:name" : "doc:high:name"); + if (!symname) { symname = Getattr(n, "sym:name"); + } + SwigType *type = Getattr(n, "type"); String *type_str = NULL; @@ -1810,6 +1865,14 @@ public: } } + /* Treat the low-level C API functions for getting/setting variables as methods for documentation purposes */ + String *kind = Getattr(n, "kind"); + if (kind && Strcmp(kind, "variable") == 0) { + if (ad_type == AUTODOC_FUNC) { + ad_type = AUTODOC_METHOD; + } + } + switch (ad_type) { case AUTODOC_CLASS: { @@ -1896,11 +1959,16 @@ public: break; } Delete(type_str); - } - if (extended && ad_type != AUTODOC_VAR) { - String *pdocs = Getattr(n, "feature:pdocs"); - if (pdocs) { - Printv(doc, "\n", pdocs, NULL); + + // Special case: wrapper functions to get a variable should have no parameters. + // Because the node is re-used for the setter and getter, the feature:pdocs field will + // exist for the getter function, so explicitly avoid printing parameters in this case. + bool variable_getter = kind && Strcmp(kind, "variable") == 0 && Getattr(n, "memberget"); + if (extended && ad_type != AUTODOC_VAR && !variable_getter) { + String *pdocs = Getattr(n, "feature:pdocs"); + if (pdocs) { + Printv(doc, "\n", pdocs, NULL); + } } } // if it's overloaded then get the next decl and loop around again @@ -2361,39 +2429,62 @@ public: * ------------------------------------------------------------ */ void add_method(String *name, String *function, int kw, Node *n = 0, int funpack = 0, int num_required = -1, int num_arguments = -1) { + String * meth_str = NewString(""); if (!kw) { if (n && funpack) { if (num_required == 0 && num_arguments == 0) { - Printf(methods, "\t { \"%s\", %s, METH_NOARGS, ", name, function); + Printf(meth_str, "\t { \"%s\", %s, METH_NOARGS, ", name, function); } else if (num_required == 1 && num_arguments == 1) { - Printf(methods, "\t { \"%s\", %s, METH_O, ", name, function); + Printf(meth_str, "\t { \"%s\", %s, METH_O, ", name, function); } else { - Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); + Printf(meth_str, "\t { \"%s\", %s, METH_VARARGS, ", name, function); } } else { - Printf(methods, "\t { \"%s\", %s, METH_VARARGS, ", name, function); + Printf(meth_str, "\t { \"%s\", %s, METH_VARARGS, ", name, function); } } else { // Cast via void(*)(void) to suppress GCC -Wcast-function-type warning. // Python should always call the function correctly, but the Python C API // requires us to store it in function pointer of a different type. - Printf(methods, "\t { \"%s\", (PyCFunction)(void(*)(void))%s, METH_VARARGS|METH_KEYWORDS, ", name, function); + Printf(meth_str, "\t { \"%s\", (PyCFunction)(void(*)(void))%s, METH_VARARGS|METH_KEYWORDS, ", name, function); } + Append(methods, meth_str); + if (fastproxy) { + Append(methods_proxydocs, meth_str); + } + Delete(meth_str); if (!n) { Append(methods, "NULL"); + if (fastproxy) { + Append(methods_proxydocs, "NULL"); + } } else if (have_docstring(n)) { - // The format for the documentation differs based on whether this is a member function or a free function - String *ds = cdocstring(n, Getattr(n, "memberfunction") ? AUTODOC_METHOD : AUTODOC_FUNC); + /* Use the low-level docstring here since this is the docstring that will be used for the C API */ + String *ds = cdocstring(n, Getattr(n, "memberfunction") ? AUTODOC_METHOD : AUTODOC_FUNC, true); Printf(methods, "\"%s\"", ds); + if (fastproxy) { + /* In the fastproxy case, we must also record the high-level docstring for use in the Python shadow API */ + ds = cdocstring(n, Getattr(n, "memberfunction") ? AUTODOC_METHOD : AUTODOC_FUNC); + Printf(methods_proxydocs, "\"%s\"", ds); + } Delete(ds); } else if (Getattr(n, "feature:callback")) { Printf(methods, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); + if (fastproxy) { + Printf(methods_proxydocs, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name")); + } } else { Append(methods, "NULL"); + if (fastproxy) { + Append(methods_proxydocs, "NULL"); + } } Append(methods, "},\n"); + if (fastproxy) { + Append(methods_proxydocs, "},\n"); + } } /* ------------------------------------------------------------ @@ -4684,6 +4775,7 @@ public: } if (shadow) { + String *staticfunc_name = NewString(fastproxy ? "_swig_new_static_method" : "staticmethod"); bool fast = (fastproxy && !have_addtofunc(n)) || Getattr(n, "feature:callback"); if (!fast || olddefs) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; @@ -4706,9 +4798,10 @@ public: // Below may result in a 2nd definition of the method when -olddefs is used. The Python interpreter will use the second definition as it overwrites the first. if (fast) { - Printv(f_shadow, tab4, symname, " = staticmethod(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), + Printv(f_shadow, tab4, symname, " = ", staticfunc_name, "(", module, ".", Swig_name_member(NSPACE_TODO, class_name, symname), ")\n", NIL); } + Delete(staticfunc_name); } return SWIG_OK; } From 5106573b298177bce16219719f69883dd580e03e Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Fri, 25 Jan 2019 18:27:14 -0500 Subject: [PATCH 1322/2031] Fixing docstrings for variables and static functions for consistency --- Examples/test-suite/python/autodoc_runme.py | 191 +++++++++----------- Source/Modules/python.cxx | 27 +-- 2 files changed, 104 insertions(+), 114 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 9dadccf23..011323c10 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -19,15 +19,10 @@ skip = True check(inspect.getdoc(A), "Proxy of C++ A class.", "::A") check(inspect.getdoc(A.funk), "just a string.") -check(inspect.getdoc(_autodoc.A_funk), "just a string.") check(inspect.getdoc(A.func0), "func0(self, arg2, hello) -> int") -check(inspect.getdoc(_autodoc.A_func0), - "A_func0(self, arg2, hello) -> int") check(inspect.getdoc(A.func1), "func1(A self, short arg2, Tuple hello) -> int") -check(inspect.getdoc(_autodoc.A_func1), - "A_func1(A self, short arg2, Tuple hello) -> int") check(inspect.getdoc(A.func2), "func2(self, arg2, hello) -> int\n" "\n" @@ -35,13 +30,6 @@ check(inspect.getdoc(A.func2), "----------\n" "arg2: short\n" "hello: int tuple[2]") -check(inspect.getdoc(_autodoc.A_func2), - "A_func2(self, arg2, hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "arg2: short\n" - "hello: int tuple[2]") check(inspect.getdoc(A.func3), "func3(A self, short arg2, Tuple hello) -> int\n" "\n" @@ -49,22 +37,11 @@ check(inspect.getdoc(A.func3), "----------\n" "arg2: short\n" "hello: int tuple[2]") -check(inspect.getdoc(_autodoc.A_func3), - "A_func3(A self, short arg2, Tuple hello) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "arg2: short\n" - "hello: int tuple[2]") check(inspect.getdoc(A.func0default), "func0default(self, e, arg3, hello, f=2) -> int") -check(inspect.getdoc(_autodoc.A_func0default), - "A_func0default(self, e, arg3, hello, f=2) -> int") check(inspect.getdoc(A.func1default), "func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") -check(inspect.getdoc(_autodoc.A_func1default), - "A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") check(inspect.getdoc(A.func2default), "func2default(self, e, arg3, hello, f=2) -> int\n" "\n" @@ -74,15 +51,6 @@ check(inspect.getdoc(A.func2default), "arg3: short\n" "hello: int tuple[2]\n" "f: double") -check(inspect.getdoc(_autodoc.A_func2default), - "A_func2default(self, e, arg3, hello, f=2) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg3: short\n" - "hello: int tuple[2]\n" - "f: double") check(inspect.getdoc(A.func3default), "func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" "\n" @@ -92,15 +60,6 @@ check(inspect.getdoc(A.func3default), "arg3: short\n" "hello: int tuple[2]\n" "f: double") -check(inspect.getdoc(_autodoc.A_func3default), - "A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" - "\n" - "Parameters\n" - "----------\n" - "e: A *\n" - "arg3: short\n" - "hello: int tuple[2]\n" - "f: double") check(inspect.getdoc(A.func0static), "func0static(e, arg2, hello, f=2) -> int") @@ -170,60 +129,111 @@ check(inspect.getdoc(A_func3static), "f: double") check(inspect.getdoc(A.variable_a), - "A.variable_a" - ) -check(inspect.getdoc(_autodoc.A_variable_a_set), - "A_variable_a_set(self, variable_a)" - ) -check(inspect.getdoc(_autodoc.A_variable_a_get), - "A_variable_a_get(self) -> int" + "variable_a" ) check(inspect.getdoc(A.variable_b), - "A.variable_b : int" - ) -check(inspect.getdoc(_autodoc.A_variable_b_set), - "A_variable_b_set(A self, int variable_b)" - ) -check(inspect.getdoc(_autodoc.A_variable_b_get), - "A_variable_b_get(A self) -> int" + "variable_b : int" ) check(inspect.getdoc(A.variable_c), - "A.variable_c" - ) -check(inspect.getdoc(_autodoc.A_variable_c_set), - "A_variable_c_set(self, variable_c)\n" - "\n" - "Parameters\n" - "----------\n" - "variable_c: int" - ) -check(inspect.getdoc(_autodoc.A_variable_c_get), - "A_variable_c_get(self) -> int" + "variable_c" ) check(inspect.getdoc(A.variable_d), - "A.variable_d : int" - ) -check(inspect.getdoc(_autodoc.A_variable_d_set), - "A_variable_d_set(A self, int variable_d)\n" - "\n" - "Parameters\n" - "----------\n" - "variable_d: int" - ) -check(inspect.getdoc(_autodoc.A_variable_d_get), - "A_variable_d_get(A self) -> int" + "variable_d : int" ) +# Check the low-level functions (not present when using -builtin except for the static ones) +if not is_python_builtin(): + check(inspect.getdoc(_autodoc.A_funk), "just a string.") + check(inspect.getdoc(_autodoc.A_func0), + "A_func0(self, arg2, hello) -> int") + check(inspect.getdoc(_autodoc.A_func1), + "A_func1(A self, short arg2, Tuple hello) -> int") + check(inspect.getdoc(_autodoc.A_func2), + "A_func2(self, arg2, hello) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]") + check(inspect.getdoc(_autodoc.A_func3), + "A_func3(A self, short arg2, Tuple hello) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "arg2: short\n" + "hello: int tuple[2]") + check(inspect.getdoc(_autodoc.A_func0default), + "A_func0default(self, e, arg3, hello, f=2) -> int") + check(inspect.getdoc(_autodoc.A_func1default), + "A_func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int") + check(inspect.getdoc(_autodoc.A_func2default), + "A_func2default(self, e, arg3, hello, f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double") + check(inspect.getdoc(_autodoc.A_func3default), + "A_func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n" + "\n" + "Parameters\n" + "----------\n" + "e: A *\n" + "arg3: short\n" + "hello: int tuple[2]\n" + "f: double") + check(inspect.getdoc(_autodoc.A_variable_a_set), "A_variable_a_set(self, variable_a)") + check(inspect.getdoc(_autodoc.A_variable_a_get), "A_variable_a_get(self) -> int" ) + check(inspect.getdoc(_autodoc.A_variable_b_set), "A_variable_b_set(A self, int variable_b)") + check(inspect.getdoc(_autodoc.A_variable_b_get), "A_variable_b_get(A self) -> int") + check(inspect.getdoc(_autodoc.A_variable_c_set), + "A_variable_c_set(self, variable_c)\n" + "\n" + "Parameters\n" + "----------\n" + "variable_c: int" + ) + check(inspect.getdoc(_autodoc.A_variable_c_get), "A_variable_c_get(self) -> int") + check(inspect.getdoc(_autodoc.A_variable_d_set), + "A_variable_d_set(A self, int variable_d)\n" + "\n" + "Parameters\n" + "----------\n" + "variable_d: int" + ) + check(inspect.getdoc(_autodoc.A_variable_d_get), "A_variable_d_get(A self) -> int") + check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C") + check(inspect.getdoc(_autodoc.new_D), "new_D(int a, int b, Hola h) -> D") + check(inspect.getdoc(_autodoc.new_E), + "new_E(a, b, h) -> E\n" + "\n" + "Parameters\n" + "----------\n" + "a: special comment for parameter a\n" + "b: another special comment for parameter b\n" + "h: enum Hola" + ) + check(inspect.getdoc(_autodoc.new_F), + "new_F(int a, int b, Hola h) -> F\n" + "\n" + "Parameters\n" + "----------\n" + "a: special comment for parameter a\n" + "b: another special comment for parameter b\n" + "h: enum Hola" + ) + check(inspect.getdoc(_autodoc.B_funk), "B_funk(B self, int c, int d) -> int") + check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger") + check(inspect.getdoc(B), "Proxy of C++ B class.", "::B" ) check(inspect.getdoc(C.__init__), "__init__(self, a, b, h) -> C", None, skip) -check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C") check(inspect.getdoc(D.__init__), "__init__(D self, int a, int b, Hola h) -> D", None, skip) -check(inspect.getdoc(_autodoc.new_D), - "new_D(int a, int b, Hola h) -> D") check(inspect.getdoc(E.__init__), "__init__(self, a, b, h) -> E\n" "\n" @@ -233,15 +243,6 @@ check(inspect.getdoc(E.__init__), "b: another special comment for parameter b\n" "h: enum Hola", None, skip ) -check(inspect.getdoc(_autodoc.new_E), - "new_E(a, b, h) -> E\n" - "\n" - "Parameters\n" - "----------\n" - "a: special comment for parameter a\n" - "b: another special comment for parameter b\n" - "h: enum Hola" - ) check(inspect.getdoc(F.__init__), "__init__(F self, int a, int b, Hola h) -> F\n" "\n" @@ -251,20 +252,9 @@ check(inspect.getdoc(F.__init__), "b: another special comment for parameter b\n" "h: enum Hola", None, skip ) -check(inspect.getdoc(_autodoc.new_F), - "new_F(int a, int b, Hola h) -> F\n" - "\n" - "Parameters\n" - "----------\n" - "a: special comment for parameter a\n" - "b: another special comment for parameter b\n" - "h: enum Hola" - ) check(inspect.getdoc(B.funk), "funk(B self, int c, int d) -> int") -check(inspect.getdoc(_autodoc.B_funk), - "B_funk(B self, int c, int d) -> int") check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int") check(inspect.getdoc(funkdefaults), "funkdefaults(A e, short arg2, int c, int d, double f=2) -> int") @@ -278,7 +268,6 @@ check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)") check(inspect.getdoc(TInteger), "Proxy of C++ T< int > class.", "::T< int >") check(inspect.getdoc(TInteger.__init__), "__init__(TInteger self) -> TInteger", None, skip) check(inspect.getdoc(TInteger.inout), "inout(TInteger self, TInteger t) -> TInteger") -check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger") check(inspect.getdoc(process), "process(int _from, int _in, int var) -> int") check(inspect.getdoc(process2), "process2(int _from=0, int _in=1, int var=2) -> int") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 8fcc0d48b..e2206b067 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1606,8 +1606,8 @@ public: * set then it will build a combined docstring. * ------------------------------------------------------------ */ - String *docstring(Node *n, autodoc_t ad_type, const String *indent) { - String *docstr = build_combined_docstring(n, ad_type, indent); + String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool low_level = false) { + String *docstr = build_combined_docstring(n, ad_type, indent, low_level); if (!Len(docstr)) return docstr; @@ -1948,14 +1948,15 @@ public: return NULL; case AUTODOC_VAR: // Variables can also be documented (e.g. through the property() function in python) - Printf(doc, "%s.%s", class_name, symname); - String *type = Getattr(n, "tmap:doc:type"); - if (! type) - type = Getattr(n, "membervariableHandler:type"); - if (! type) - type = Getattr(n, "type"); - if (showTypes) + Printf(doc, "%s", symname); + if (showTypes) { + String *type = Getattr(n, "tmap:doc:type"); + if (! type) + type = Getattr(n, "membervariableHandler:type"); + if (! type) + type = Getattr(n, "type"); Printf(doc, " : %s", type); + } break; } Delete(type_str); @@ -2391,7 +2392,7 @@ public: /* Make a wrapper function to insert the code into */ Printv(f_dest, "\n", "def ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); if (have_docstring(n)) - Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4, true), "\n", NIL); if (have_pythonprepend(n)) Printv(f_dest, indent_pythoncode(pythonprepend(n), tab4, Getfile(n), Getline(n), "%pythonprepend or %feature(\"pythonprepend\")"), "\n", NIL); if (have_pythonappend(n)) { @@ -3301,7 +3302,7 @@ public: } Setattr(h, "getter", "SwigPyObject_get___dict__"); if (! Getattr(h, "doc")) { - Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } } @@ -3319,7 +3320,7 @@ public: Setattr(h, "getter", wrapper_name); Delattr(n, "memberget"); if (! Getattr(h, "doc")) { - Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } } @@ -3336,7 +3337,7 @@ public: Setattr(h, "setter", wrapper_name); Delattr(n, "memberset"); if (! Getattr(h, "doc")) { - Setattr(n, "doc:name", Getattr(n, "name")); + Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } } From e150d58092b24b4191a1db39febf7b1ff5363633 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Fri, 25 Jan 2019 20:07:57 -0500 Subject: [PATCH 1323/2031] Fixing a bug where the cached doxygen docstring could be deleted while still in use, causing swig to segfault --- CHANGES.current | 3 +++ Source/Modules/python.cxx | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2b41c50c6..6edffb78b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -18,6 +18,9 @@ Version 4.0.0 (in progress) Only show a single documentation entry for functions with default arguments when using autodoc. + Fixed a bug where a cached doxygen docstring could be deleted while still in use, + causing swig to segfault. + 2019-01-22: vadz [Ruby, Octave] #1424 Improve autodoc parameter naming. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e2206b067..b6a8e5d79 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1571,6 +1571,11 @@ public: // depends on the comment which is not going to change, so we can // safely cache it. Setattr(n, "python:docstring", Copy(docstr)); + } else { + // Must copy here since if the docstring is multi-line, the String* + // here will get Deleted below, which is bad if it is a pointer to + // the cached object! + docstr = Copy(docstr); } } } From 98023054c62e2d2c93d86e197da6932a9cb7ef65 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Fri, 25 Jan 2019 22:00:57 -0500 Subject: [PATCH 1324/2031] Properly handle destructors as methods for autodoc and fix some stray newlines --- Examples/test-suite/autodoc.i | 4 ++++ Examples/test-suite/python/autodoc_runme.py | 4 ++++ Source/Modules/python.cxx | 13 ++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 0e9356901..9f4365ee1 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -76,6 +76,10 @@ %feature("autodoc","1") D::D(int a, int b, Hola h); // names + types %feature("autodoc","2") E::E(int a, int b, Hola h); // extended %feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types +%feature("autodoc","0") C::~C(); // names +%feature("autodoc","1") D::~D(); // names + types +%feature("autodoc","2") E::~E(); // extended +%feature("autodoc","3") F::~F(); // extended + types %inline { diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 011323c10..6002d49fe 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -205,7 +205,9 @@ if not is_python_builtin(): ) check(inspect.getdoc(_autodoc.A_variable_d_get), "A_variable_d_get(A self) -> int") check(inspect.getdoc(_autodoc.new_C), "new_C(a, b, h) -> C") + check(inspect.getdoc(_autodoc.delete_C), "delete_C(self)") check(inspect.getdoc(_autodoc.new_D), "new_D(int a, int b, Hola h) -> D") + check(inspect.getdoc(_autodoc.delete_D), "delete_D(D self)") check(inspect.getdoc(_autodoc.new_E), "new_E(a, b, h) -> E\n" "\n" @@ -215,6 +217,7 @@ if not is_python_builtin(): "b: another special comment for parameter b\n" "h: enum Hola" ) + check(inspect.getdoc(_autodoc.delete_E), "delete_E(self)") check(inspect.getdoc(_autodoc.new_F), "new_F(int a, int b, Hola h) -> F\n" "\n" @@ -224,6 +227,7 @@ if not is_python_builtin(): "b: another special comment for parameter b\n" "h: enum Hola" ) + check(inspect.getdoc(_autodoc.delete_F), "delete_F(F self)") check(inspect.getdoc(_autodoc.B_funk), "B_funk(B self, int c, int d) -> int") check(inspect.getdoc(_autodoc.TInteger_inout), "TInteger_inout(TInteger self, TInteger t) -> TInteger") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b6a8e5d79..7610fca7e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1810,6 +1810,7 @@ public: String *make_autodoc(Node *n, autodoc_t ad_type, bool low_level = false) { int extended = 0; + bool first_func = true; // If the function is overloaded then this function is called // for the last one. Rewind to the first so the docstrings are // in order. @@ -1861,6 +1862,9 @@ public: continue; } + if (! first_func) + Append(doc, "\n"); + if (type) { if (Strcmp(type, "void") == 0) { type_str = NULL; @@ -1877,6 +1881,13 @@ public: ad_type = AUTODOC_METHOD; } } + /* Treat destructors as methods for documentation purposes */ + String *nodeType = Getattr(n, "nodeType"); + if (nodeType && Strcmp(nodeType, "destructor") == 0) { + if (ad_type == AUTODOC_FUNC) { + ad_type = AUTODOC_METHOD; + } + } switch (ad_type) { case AUTODOC_CLASS: @@ -1980,7 +1991,7 @@ public: // if it's overloaded then get the next decl and loop around again n = Getattr(n, "sym:nextSibling"); if (n) - Append(doc, "\n"); + first_func = false; } return doc; From ed81f8ac7355e9a59475c9dbaef18692fb98220f Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Sat, 26 Jan 2019 09:06:23 -0500 Subject: [PATCH 1325/2031] Don't use bool in the generated files for C compatability --- Source/Modules/python.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7610fca7e..3427e310b 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -839,16 +839,16 @@ public: "{\n", " /* Find the function in the modified method table */\n", " size_t offset = 0;\n", - " bool found = false;\n", + " int found = 0;\n", " while (SwigMethods_proxydocs[offset].ml_meth != NULL) {\n", " if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {\n", - " found = true;\n", + " found = 1;\n", " break;\n", " }\n", " offset++;\n", " }\n", " /* Use the copy with the modified docstring if available */\n", - " if (found) {\n", + " if (found == 1) {\n", " return &SwigMethods_proxydocs[offset];\n", " } else {\n", " return NULL;\n", From 120a6df838089b86751737615955674f1c4dd853 Mon Sep 17 00:00:00 2001 From: Alec Woods Date: Sat, 26 Jan 2019 13:39:50 -0500 Subject: [PATCH 1326/2031] Apparently nicely lining things up violates pep8, so don't try --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3427e310b..b93aa6c86 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -704,7 +704,7 @@ public: if (!builtin && fastproxy) { Printf(f_shadow, "\n"); Printf(f_shadow, "_swig_new_instance_method = %s.SWIG_PyInstanceMethod_New\n", module); - Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module); + Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module); } { From fba77056de241136cbe39e650af4d21564ef400c Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 27 Jan 2019 04:00:31 -0700 Subject: [PATCH 1327/2031] [OCaml] Some OCaml documentation fixes Fix some typos. Update some filenames after 8f7bc4cc1078cd2223c051c8db12559d3d3d031e (replace example_prog.ml with runme.ml). [skip ci] --- Doc/Manual/Ocaml.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 70504cf15..c83e5e575 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -142,7 +142,7 @@ Use ocamlc or ocamlopt to compile your SWIG interface like:
      -% swig -ocaml -co swig.mli ; swig -ocaml co swig.ml
      +% swig -ocaml -co swig.mli ; swig -ocaml -co swig.ml
       % ocamlc -c swig.mli ; ocamlc -c swig.ml
       % ocamlc -c -ccopt "-I/usr/include/foo" example_wrap.c
       % ocamlc -c example.mli
      @@ -336,7 +336,7 @@ appended.  Upon return to caml space, the fnhelper function
       beautifies the result.  A list containing a single item degrades to
       only that item (i.e. [ C_int 3 ] -> C_int 3), and a list
       containing more than one item is wrapped in C_list (i.e. [ C_char
      -'a' ; C_char 'b' -> C_list [ C_char 'a' ; C_char b
      +'a' ; C_char 'b' ] -> C_list [ C_char 'a' ; C_char 'b'
       ]).  This is in order to make return values easier to handle
       when functions have only one return value, such as constructors,
       and operators.  In addition, string, pointer, and object
      @@ -660,7 +660,7 @@ module.
       

      -bash-2.05a$ ./example_top
      +bash-2.05a$ ./runme_top
               Objective Caml version 3.06
       
               Camlp4 Parsing version 3.06
      @@ -835,7 +835,7 @@ an overloaded class.  This example is contained in Examples/ocaml/shapes.
       
       
       
      -
      example_prog.ml
      +
      runme.ml
       open Swig
      @@ -854,13 +854,15 @@ let triangle_class pts ob meth args =
                  | _ -> raise (Failure "cover needs two double arguments."))
           | _ -> (invoke ob) meth args ;;
       
      +...
      +
       let triangle =
         new_derived_object
           new_shape
      -    (triangle_class ((0.0, 0.0), (0.5, 1.0), (1.0, 0.0)))
      +    (triangle_class ((0.0, 0.0), (0.5, 1.0), (1.0, 0.6)))
           '() ;;
       
      -let _ = _draw_shape_coverage '(triangle, C_int 60, C_int 20) ;;
      +let _ = _draw_shape_coverage '(triangle, 60, 20) ;;
       
      From f78358d9aa33db9a900f648ba706d5f5d04310b4 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 27 Jan 2019 06:50:51 -0700 Subject: [PATCH 1328/2031] [OCaml] Runtime tests for template_opaque, using_extend and some others Add runtime tests for namespace_virtual_method, template_opaque, using_extend, using_inherit, using_pointers, using_private, and varargs_overload. --- .../ocaml/namespace_virtual_method_runme.ml | 4 ++++ .../test-suite/ocaml/template_opaque_runme.ml | 5 ++++ .../test-suite/ocaml/using_extend_runme.ml | 12 ++++++++++ .../test-suite/ocaml/using_inherit_runme.ml | 24 +++++++++++++++++++ .../test-suite/ocaml/using_pointers_runme.ml | 10 ++++++++ .../test-suite/ocaml/using_private_runme.ml | 10 ++++++++ .../ocaml/varargs_overload_runme.ml | 15 ++++++++++++ 7 files changed, 80 insertions(+) create mode 100644 Examples/test-suite/ocaml/namespace_virtual_method_runme.ml create mode 100644 Examples/test-suite/ocaml/template_opaque_runme.ml create mode 100644 Examples/test-suite/ocaml/using_extend_runme.ml create mode 100644 Examples/test-suite/ocaml/using_inherit_runme.ml create mode 100644 Examples/test-suite/ocaml/using_pointers_runme.ml create mode 100644 Examples/test-suite/ocaml/using_private_runme.ml create mode 100644 Examples/test-suite/ocaml/varargs_overload_runme.ml diff --git a/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml b/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml new file mode 100644 index 000000000..3c5b2cf34 --- /dev/null +++ b/Examples/test-suite/ocaml/namespace_virtual_method_runme.ml @@ -0,0 +1,4 @@ +open Swig +open Namespace_virtual_method + +let x = new_Spam '() diff --git a/Examples/test-suite/ocaml/template_opaque_runme.ml b/Examples/test-suite/ocaml/template_opaque_runme.ml new file mode 100644 index 000000000..cb9e18905 --- /dev/null +++ b/Examples/test-suite/ocaml/template_opaque_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Template_opaque + +let v = new_OpaqueVectorType (C_uint 10l) +let _ = _FillVector '(v) diff --git a/Examples/test-suite/ocaml/using_extend_runme.ml b/Examples/test-suite/ocaml/using_extend_runme.ml new file mode 100644 index 000000000..0b7c57f65 --- /dev/null +++ b/Examples/test-suite/ocaml/using_extend_runme.ml @@ -0,0 +1,12 @@ +open Swig +open Using_extend + +let _ = + let f = new_FooBar '() in + assert (f -> blah (3) as int = 3); + assert (f -> blah (3.5) as float = 3.5); + assert (f -> blah ("hello") as string = "hello"); + assert (f -> blah (3, 4) as int = 7); + assert (f -> blah (3.5, 7.5) as float = 11.); + assert (f -> duh (3) as int = 3) +;; diff --git a/Examples/test-suite/ocaml/using_inherit_runme.ml b/Examples/test-suite/ocaml/using_inherit_runme.ml new file mode 100644 index 000000000..2c49c5e6f --- /dev/null +++ b/Examples/test-suite/ocaml/using_inherit_runme.ml @@ -0,0 +1,24 @@ +open Swig +open Using_inherit + +let _ = + let b = new_Bar '() in + assert (b -> test (3) as int = 3); + assert (b -> test (3.5) as float = 3.5); + let b = new_Bar2 '() in + assert (b -> test (3) as int = 6); + assert (b -> test (3.5) as float = 7.0); + let b = new_Bar3 '() in + assert (b -> test (3) as int = 6); + assert (b -> test (3.5) as float = 7.0); + let b = new_Bar4 '() in + assert (b -> test (3) as int = 6); + assert (b -> test (3.5) as float = 7.0); + + let f = new_Fred1 '() in + assert (f -> test (3) as int = 3); + assert (f -> test (3.5) as float = 7.0); + let f = new_Fred2 '() in + assert (f -> test (3) as int = 3); + assert (f -> test (3.5) as float = 7.0) +;; diff --git a/Examples/test-suite/ocaml/using_pointers_runme.ml b/Examples/test-suite/ocaml/using_pointers_runme.ml new file mode 100644 index 000000000..98fd3fb48 --- /dev/null +++ b/Examples/test-suite/ocaml/using_pointers_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Using_pointers + +let f = new_FooBar '() +try + ignore (f -> exception_spec (1)); assert false +with Failure _ -> () +try + ignore (f -> exception_spec (2)); assert false +with Failure _ -> () diff --git a/Examples/test-suite/ocaml/using_private_runme.ml b/Examples/test-suite/ocaml/using_private_runme.ml new file mode 100644 index 000000000..026cbfd91 --- /dev/null +++ b/Examples/test-suite/ocaml/using_private_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Using_private + +let _ = + let f = new_FooBar '() in + let _ = f -> "[x]" (3) in + assert (f -> blah (4) as int = 4); + assert (f -> defaulted () as int = -1); + assert (f -> defaulted (222) as int = 222) +;; diff --git a/Examples/test-suite/ocaml/varargs_overload_runme.ml b/Examples/test-suite/ocaml/varargs_overload_runme.ml new file mode 100644 index 000000000..3085e6258 --- /dev/null +++ b/Examples/test-suite/ocaml/varargs_overload_runme.ml @@ -0,0 +1,15 @@ +open Swig +open Varargs_overload + +let _ = + assert (_vararg_over1 '("Hello") as string = "Hello"); + assert (_vararg_over1 '(2) as string = "2"); + assert (_vararg_over2 '("Hello") as string = "Hello"); + assert (_vararg_over2 '(2, 2.2) as string = "2 2.2"); + + assert (_vararg_over3 '("Hello") as string = "Hello"); + assert (_vararg_over3 '(2, 2.2, "hey") as string = "2 2.2 hey"); + assert (_vararg_over4 '("Hello") as string = "Hello"); + assert (_vararg_over4 '(123) as string = "123"); + assert (_vararg_over4 '("Hello", 123) as string = "Hello") +;; From c0059ae2cba0d470aaf2d3ab8f1a27e3db17ef3c Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 28 Jan 2019 02:16:15 -0700 Subject: [PATCH 1329/2031] [OCaml] Remove support for OCaml versions < 3.12.0 --- CHANGES.current | 5 +++++ Doc/Manual/Ocaml.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 75dd2085d..80c467a17 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-28: ZackerySpytz + [OCaml] #1429 Remove support for OCaml versions < 3.12.0. + + *** POTENTIAL INCOMPATIBILITY *** + 2019-01-22: vadz [Ruby, Octave] #1424 Improve autodoc parameter naming. diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 70504cf15..4ab532f2f 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -88,7 +88,7 @@ If you're not familiar with the Objective Caml language, you can visit

      -SWIG 3.0 works with Ocaml 3.08.3 and above. Given the choice, +SWIG is compatible with OCaml 3.12.0 and above. Given the choice, you should use the latest stable release. The SWIG Ocaml module has been tested on Linux (x86, PPC, Sparc) and Cygwin on Windows. The best way to determine whether your system will work is to compile the From 0b0b77f343f5e6c1788af1063edc5ba5eaebded5 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 28 Jan 2019 06:56:18 -0700 Subject: [PATCH 1330/2031] [OCaml] Define CAML_NAME_SPACE before including caml/ headers When this macro is not defined, the caml/ headers will define macros without the caml_ prefix as aliases for some functions in the OCaml C API. For example, caml/compatibility.h defines `invalid_argument` as an alias for `caml_invalid_argument` when CAML_NAME_SPACE is not defined, which breaks code that uses std::invalid_argument. Rename some functions that were missed in 05589508a6aca2866210dfda27e79d12abd8f5f6. --- Lib/ocaml/cstring.i | 2 +- Lib/ocaml/director.swg | 4 ++-- Lib/ocaml/ocaml.swg | 2 +- Lib/ocaml/ocamldec.swg | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/ocaml/cstring.i b/Lib/ocaml/cstring.i index 0d6aa4b69..f1190ad5c 100644 --- a/Lib/ocaml/cstring.i +++ b/Lib/ocaml/cstring.i @@ -108,7 +108,7 @@ %define %cstring_mutable(TYPEMAP,...) %typemap(in) TYPEMAP { char *t = String_val($input); - int n = string_length($input); + int n = caml_string_length($input); $1 = ($1_ltype) t; #if #__VA_ARGS__ == "" #ifdef __cplusplus diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index 86b2cd4e2..eb91aaf4b 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -74,12 +74,12 @@ namespace Swig { public: /* wrap a ocaml object. */ Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { - register_global_root(&swig_self); + caml_register_global_root(&swig_self); } /* discard our reference at destruction */ virtual ~Director() { - remove_global_root(&swig_self); + caml_remove_global_root(&swig_self); swig_disown(); // Disown is safe here because we're just divorcing a reference that points to us. } diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index d0007f856..d0a5819bb 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -507,7 +507,7 @@ extern "C" { SWIGINTERN int caml_string_len( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_string: - return string_length(SWIG_Field(v,0)); + return caml_string_length(SWIG_Field(v,0)); default: return strlen((char *)caml_ptr_val(v,0)); } diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index aea0ec9e5..f99624373 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -16,6 +16,7 @@ SWIGEXT { #endif #define value caml_value_t #define CAML_VALUE caml_value_t +#define CAML_NAME_SPACE #include #include #include From 85860c0a61c3be2a032a9fc935dffff66586f2a9 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 29 Jan 2019 09:18:30 -0700 Subject: [PATCH 1331/2031] [OCaml] Fix the char_binary test for OCaml Add %typemap(in) (char *STRING, size_t LENGTH). Fix warnings in char_binary.i. ./../char_binary.i:7: Warning 453: Can't apply (char *STRING,size_t LENGTH). No typemaps are defined. ./../char_binary.i:8: Warning 453: Can't apply (char *STRING,size_t LENGTH). No typemaps are defined. Add a runtime test (it is based on the Python and Go char_binary runtime tests). --- .../test-suite/ocaml/char_binary_runme.ml | 24 +++++++++++++++++++ Lib/ocaml/typemaps.i | 4 ++++ 2 files changed, 28 insertions(+) create mode 100644 Examples/test-suite/ocaml/char_binary_runme.ml diff --git a/Examples/test-suite/ocaml/char_binary_runme.ml b/Examples/test-suite/ocaml/char_binary_runme.ml new file mode 100644 index 000000000..2d3aba1b3 --- /dev/null +++ b/Examples/test-suite/ocaml/char_binary_runme.ml @@ -0,0 +1,24 @@ +open Swig +open Char_binary + +let _ = + let t = new_Test '() in + assert (t -> strlen ("hile") as int = 4); + assert (t -> ustrlen ("hile") as int = 4); + assert (t -> strlen ("hil\x00") as int = 4); + assert (t -> ustrlen ("hil\x00") as int = 4); + + let pc = _new_pchar '(5) in + assert (_pchar_setitem '(pc, 0, 'h') = C_void); + assert (_pchar_setitem '(pc, 1, 'o') = C_void); + assert (_pchar_setitem '(pc, 2, 'l') = C_void); + assert (_pchar_setitem '(pc, 3, 'a') = C_void); + assert (_pchar_setitem '(pc, 4, 0) = C_void); + assert (t -> strlen (pc) as int = 4); + assert (t -> ustrlen (pc) as int = 4); + ignore (_var_pchar '(pc)); + assert (_var_pchar '() as string = "hola"); + ignore (_var_namet '(pc)); + assert (_var_namet '() as string = "hola"); + _delete_pchar(pc) +;; diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 2bf456a46..6eebd7987 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -353,6 +353,10 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); %swig_enum_out(varout) %swig_enum_out(directorin) +%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) { + $1 = ($1_ltype) caml_string_val($input); + $2 = ($2_ltype) caml_string_len($input); +} /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } From b324d9d6bb9aed1e4d35e80bbd9594d3367c1a09 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Jan 2019 18:55:44 +0000 Subject: [PATCH 1332/2031] Add info about the Supported and Experimental language module status This is the result of an email discussion on the swig-devel mailing list back in March 2017 titled "Radical new approach to development and moving towards version 3.1 or version 4.0" A new section in the Introduction chapter has been added, titled "Target languages". The Extending chapter has the main details in a new section called "Target language status". --- Doc/Manual/Contents.html | 12 +- Doc/Manual/Extending.html | 252 +++++++++++++++++++++++++++-------- Doc/Manual/Introduction.html | 97 ++++++++++++-- Doc/Manual/Preface.html | 5 +- 4 files changed, 293 insertions(+), 73 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index f8a731fe2..22f6126de 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -46,6 +46,11 @@

    • Debugging Options
    • Guide to parse tree nodes diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 9d69ac2d1..53c2e68ae 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -64,8 +64,13 @@
    • Running the test-suite
  • Documentation -
  • Prerequisites for adding a new language module to the SWIG distribution
  • Coding style guidelines +
  • Target language status + +
  • Prerequisites for adding a new language module to the SWIG distribution
  • Debugging Options
  • Guide to parse tree nodes @@ -3531,64 +3536,7 @@ Some topics that you'll want to be sure to address include: if available. -

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

    - - -

    -If you wish for a new language module to be distributed with SWIG, -which we encourage for all popular languages, there are a few requirements. -While we appreciate that getting all aspects of a new language working -won't happen at the outset, there are a set of minimum requirements before -a module can be committed into the official Github repository for distribution with future -versions of SWIG. The following are really a summary of this whole section with -details being outlined earlier on. -

    - -
      -
    1. - Demonstrate basic C code working by porting the "simple" example including - a runtime test, see for example Examples/python/simple. -
    2. -
    3. - Demonstrate basic C++ code working by porting the "class" example including - a runtime test, see for example Examples/python/class. -
    4. -
    5. - Modify configure.ac, Makefile.in and Examples/Makefile.in to run - these examples. Please make sure that if the new language is not - installed properly on a box, make -k check should still work by - skipping the tests and examples for the new language module. -
    6. -
    7. - Get the test-suite running for the new language (make check-[lang]-test-suite). - While the test-suite tests many corner cases, - we'd expect the majority of it to work by compiling the generated code - correctly as most of the corner cases are covered in the SWIG core. Get - at least one C and one C++ runtime test running in the test-suite. -
    8. -
    9. - Provide a chapter in the html documentation on the basics of using - the language module. -
    10. -
    11. - Ensure your source code is formatted according to the coding style guidelines. -
    12. -
    13. - Finally, email the SWIG developers with a patch and a demonstration of - commitment to maintaining the language module, - certainly in the short term and ideally long term. -
    14. -
    - -

    -Once accepted into the official Git repository, development efforts should concentrate on -getting the entire test-suite to work with plenty of runtime tests. -Runtime tests should be for existing testcases and new test cases -should be added should there be an area not already covered by -the existing tests. -

    - -

    43.10.15 Coding style guidelines

    +

    43.10.14 Coding style guidelines

    @@ -3612,6 +3560,192 @@ 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.

    + +

    43.10.15 Target language status

    + + +

    +Target languages are given a status of either 'Supported' or 'Experimental' depending on their maturity as broadly outlined in +the Target language introduction. +This section provides more details on how this status is given. +

    + +

    43.10.15.1 Supported status

    + + +

    +A target language is given the 'Supported' status when +

    + +
      +
    • + It is in a mature, well functioning state. +
    • +
    • + It has its own comprehensive chapter in the documentation. + The level of documentation should be comprehensive and match the standard of the other mature modules. + Python and Java are good references.
    • +
    • + It passes all of the main SWIG test-suite. + The main test-suite is defined by the tests in the C_TEST_CASES, CPP_TEST_CASES and MULTI_CPP_TEST_CASES lists in Examples/test-suite/common.mk. + The tests in CPP11_TEST_CASES will also be required in the near future. +
    • +
    • + The test-suite must also include at least twenty wide-ranging runtime tests. + The most mature languages have a few hundred runtime tests. + Note that porting runtime tests from another language module is a quick and easy way to achieve this. +
    • +
    • + It supports the vast majority of SWIG features. + Some more advanced features, such as, directors, full nested class support and target language namespaces (nspace) may be unimplemented. + A few support libraries may be missing, for example, a small number of STL libraries.
    • +
    • + It provides strong backwards compatibility between releases. + Each point release must aim to be fully backwards compatible. + A point release version is the 3rd version digit, so each of the x.y.* versions should be backwards compatible. + Backwards compatibility breakages can occur in a new major or minor version if absolutely necessary and if documented. + A major or minor version is the first or second digit in the three digit version. +
    • +
    • + Fixing unintended regressions in the Supported languages will be given higher priority over experimental languages by the core SWIG developers. +
    • +
    • + Examples must be available and run successfully. +
    • +
    • + The examples and test-suite must be fully functioning on the Travis Continuous Integration platform. +
    • +
    + +

    43.10.15.2 Experimental status

    + + +

    +A target language is given the 'Experimental' status when +

    + +
      +
    • + It is of sub-standard quality, failing to meet the above 'Standard' status. +
    • +
    • + It is somewhere between the mid to mature stage of development. +
    • +
    • + It is in need of help to finish development. +
    • +
    + +

    +Some minimum requirements and notes about languages with the 'Experimental' status: +

    + +
      +
    • + Will at least implement basic functionality - support wrapping C functions and simple C++ classes and templates. +
    • +
    • + Have its own documentation chapter containing a reasonable level of detail. + The documentation must provide enough basic functionality for a user to get started. +
    • +
    • + Have fully functional examples of basic functionality (the simple and class examples). +
    • +
    • + The test-suite must be implemented and include some runtime tests for wrapped C and C++ tests. +
    • +
    • + Failing tests must be put into one of the FAILING_CPP_TESTS or FAILING_C_TESTS lists in the test-suite. + This will ensure the test-suite can be superficially made to pass by ignoring failing tests. + The number of tests in these lists should be no greater than half of the number of tests in the full test-suite. +
    • +
    • + The examples and test-suite must also be fully functioning on the Travis Continuous Integration platform. + However, experimental languages will be set as 'allow_failures'. + This means that pull requests and normal development commits will not break the entire Travis build should an experimental language fail. +
    • +
    • + Any new failed tests will be fixed on a 'best effort' basis by core developers with no promises made. +
    • +
    • + If a language module has an official maintainer, then the maintainer will be requested to focus on fixing test-suite regressions and commit to migrating the module to become a 'Standard' module. +
    • +
    • + If a module does not have an official maintainer, then, as maintenance will be on a 'best efforts' basis by the core maintainers, no guarantees will be provided from one release to the next and regressions may creep in. +
    • +
    • + Experimental target languages will have a (suppressible) warning explaining the Experimental sub-standard status and encourage users to help improve it. +
    • +
    • + No backwards compatibility is guaranteed as the module is effectively 'in development'. + If a language module has an official maintainer, then a backwards compatibility guarantee may be provided at the maintainer's discretion and should be documented as such. +
    • +
    + +

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

    + + +

    +New target language modules can be included in SWIG and contributions are encouraged for popular languages. +In order to be considered for inclusion, a language must at a minimum fit the 'Experimental' status described above. +

    + +

    +Below are some practical steps that should help meet these requirements. +

    + +
      +
    1. + The "simple" example needs to be working to demonstrate basic C code wrappers. + Port the example from another language, such as from Examples/python/simple. +
    2. +
    3. + The "class" example needs to be working to demonstrate basic C++ code wrappers. + Port the example from another language, such as from Examples/python/class. +
    4. +
    5. + Modify configure.ac, Makefile.in and Examples/Makefile.in to run + these examples. Please make sure that if the new language is not + installed properly on a box, make -k check should still work by + skipping the tests and examples for the new language module. +
    6. +
    7. + Copying an existing language module and adapting the source for it is likely to be the most efficient + approach to fully developing a new module as a numbe of corner cases are covered in the existing implementations. + The most advanced scripting languages are Python and Ruby. + The most advanced compiled target languages are Java and C#. +
    8. +
    9. + Get the test-suite running for the new language (make check-[lang]-test-suite). + While the test-suite tests many corner cases, + we'd expect the majority of it to work without much effort once the generated code is compiling + correctly for basic functionality as most of the corner cases are covered in the SWIG core. Aim to first get + one C and one C++ runtime test running in the test-suite. + Adding further runtime tests should be a lot easier afterwards by porting existing runtime tests from another language module. +
    10. +
    11. + The structure and contents of the html documentation chapter can be copied and adapted from one of the other language modules. +
    12. +
    13. + Source code can be formatted correctly using the info in the coding style guidelines section. +
    14. +
    15. + When ready, post a patch on Github, join the swig-devel mailing list and email the SWIG developers with a demonstration of + commitment to maintaining the language module, + certainly in the short term and ideally long term. +
    16. +
    + +

    +Once accepted into the official Git repository, development efforts should concentrate on +getting the entire test-suite to work +in order to migrate the language module to the 'Supported' status. +Runtime tests should be added for existing testcases and new test cases +can be added should there be an area not already covered by +the existing tests. +

    + +

    43.11 Debugging Options

    diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index ad6e34ed7..b7e12aada 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -13,6 +13,11 @@
    • What is SWIG?
    • Why use SWIG? +
    • Target languages +
    • A SWIG example
      • SWIG interface file @@ -144,7 +149,75 @@ it provides a wide variety of customization features that let you change almost every aspect of the language bindings. This is the main reason why SWIG has such a large user manual ;-). -

        2.3 A SWIG example

        +

        2.3 Target languages

        + + +

        +SWIG in essence is a tool to generate code for making C/C++ code available to various other programming languages. +These higher level programming languages are the target languages for the SWIG code generator and C or C++ are the input languages. +A single target language must be specified when SWIG is run. +This results in generating code for C/C++ and the specified target language to interface with each other. +SWIG can be invoked multiple times, but with a different target language specified on each invocation. +This ability to interface C/C++ to many different target languages is one of SWIG's core strengths and features. +

        + +

        +SWIG is very broadly composed of two components. +A core component creates a parse tree from the input C/C++ and SWIG directives (extensions to C/C++). +The parse tree is then passed to a second component, one of the target language modules for generating code specific to a higher level language. +SWIG supports many different target languages. +These target languages are given a status of either Supported or Experimental. +This status is provided to indicate the level of maturity to expect when using a particular target language as not all target languages are fully developed. +

        + +

        +The second part of the SWIG documentation contains a chapter for each target level language. +Each chapter will state the status (Supported or Experimental) for that language. +

        + +

        2.3.1 Supported status

        + + +

        +A target language is given the 'Supported' status when +

        + +
          +
        • It is in a mature, well functioning state.
        • +
        • It has its own comprehensive chapter in the documentation.
        • +
        • It passes all of the main SWIG test-suite and has a range of working examples.
        • +
        • It supports the vast majority of SWIG features.
        • +
        • It provides strong backwards compatibility between releases.
        • +
        + +

        +The above is a short summary and further details are outlined in the Supported status section in the Extending chapter. +The good news is that all the well-known and most popular languages have this status. +

        + +

        2.3.2 Experimental status

        + + +

        +A target language is given the 'Experimental' status when +

        + +
          +
        • It is of sub-standard quality, failing to meet the above 'Supported' status.
        • +
        • It is somewhere between the mid to mature stage of development.
        • +
        • It does not guarantee any backwards compatibility between releases.
        • +
        • It is in need of help to finish development.
        • +
        + +

        +Anyone using an experimental target language is strongly urged to assist with development of the target language module if they wish to use it. +

        + +

        +The above is a short summary and further details are outlined in the Experimental status section in the Extending chapter. +

        + +

        2.4 A SWIG example

        @@ -155,7 +228,7 @@ following C code:

         /* File : example.c */
         
        -double  My_variable  = 3.0;
        +double My_variable = 3.0;
         
         /* Compute factorial of n */
         int fact(int n) {
        @@ -177,7 +250,7 @@ variable My_variable from Tcl.  You start by making a SWIG
         interface file as shown below (by convention, these files carry a .i
         suffix) :
         
        -

        2.3.1 SWIG interface file

        +

        2.4.1 SWIG interface file

        @@ -202,7 +275,7 @@ module that will be created by SWIG.  The %{ %} block
         provides a location for inserting additional code, such as C header
         files or additional C declarations, into the generated C wrapper code.
         
        -

        2.3.2 The swig command

        +

        2.4.2 The swig command

        @@ -235,7 +308,7 @@ and variables declared in the SWIG interface. A look at the file example_wrap.c reveals a hideous mess. However, you almost never need to worry about it. -

        2.3.3 Building a Perl5 module

        +

        2.4.3 Building a Perl5 module

        @@ -261,7 +334,7 @@ unix >

        -

        2.3.4 Building a Python module

        +

        2.4.4 Building a Python module

        @@ -285,7 +358,7 @@ Type "copyright", "credits" or "license" for more information. 7.5

        -

        2.3.5 Shortcuts

        +

        2.4.5 Shortcuts

        @@ -311,7 +384,7 @@ print $example::My_variable + 4.5, "\n"; 7.5 -

        2.4 Supported C/C++ language features

        +

        2.5 Supported C/C++ language features

        @@ -351,7 +424,7 @@ wrapping simple C++ code. In fact, SWIG is able to handle C++ code that stresses the very limits of many C++ compilers. -

        2.5 Non-intrusive interface building

        +

        2.6 Non-intrusive interface building

        @@ -363,7 +436,7 @@ interface and reuse the code in other applications. It is also possible to support different types of interfaces depending on the application.

        -

        2.6 Incorporating SWIG into a build system

        +

        2.7 Incorporating SWIG into a build system

        @@ -421,7 +494,7 @@ which will invoke SWIG and compile the generated C++ files into _example.so (UNI For other target languages on Windows a dll, instead of a .pyd file, is usually generated.

        -

        2.7 Hands off code generation

        +

        2.8 Hands off code generation

        @@ -434,7 +507,7 @@ it allows others to forget about the low-level implementation details.

        -

        2.8 SWIG and freedom

        +

        2.9 SWIG and freedom

        diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 78e2a1ab0..36a99bd1f 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -69,6 +69,9 @@ over a period of 10 years starting from the year 2000. The final version in the series was 1.3.40, but in truth the 1.3.x series had been stable for many years. An official stable version was released along with the decision to make SWIG license changes and this gave rise to version 2.0.0 in 2010. +Version 3.0.0 was released in 2014 focusing on adding C++11 support and C++ nested classes. +Version 4.0.0 was released in 2019 to add in Doxygen support. +Some target languages were disabled as part of a clean up and others were given a new status of either 'Supported' or 'Experimental'.

        1.3 SWIG License

        @@ -435,7 +438,7 @@ don't intend to use these features in your own programs.

        -Note: The test-suite currently contains over 500 tests. If you +Note: The test-suite currently contains over 600 tests. If you have many different target languages installed and a slow machine, it might take more than an hour to run the test-suite.

        From 12b8d70d97dae9be7afeb64bfe3f90f80e792427 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 29 Jan 2019 19:06:57 +0000 Subject: [PATCH 1333/2031] Add placeholder for Experimental documentation section [skip ci] --- Doc/Manual/Sections.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 547faf0cf..d103f42a5 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -36,7 +36,7 @@ Last update : SWIG-4.0.0 (in progress)
      • Using SWIG with ccache
      -

      Language Module Documentation

      +

      Supported Language Modules Documentation

      +

      Experimental Language Modules Documentation

      + +
        +
      +

      Developer Documentation

        From 08029e6642c817f4878964e7a489d18c5c55f966 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 31 Jan 2019 15:32:38 -0700 Subject: [PATCH 1334/2031] [OCaml] Add support for the docstring option in the module directive If given, the OCaml module will place the docstring at the very beginning of the generated mli file, where it can be read by the OCamldoc tool. The implementation is based on the equivalent features in the Python and Ruby modules. --- Doc/Manual/Contents.html | 4 ++++ Doc/Manual/Ocaml.html | 45 ++++++++++++++++++++++++++++++++++++++++ Source/Modules/ocaml.cxx | 10 +++++++++ 3 files changed, 59 insertions(+) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 22f6126de..06dd91ae6 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1397,6 +1397,10 @@
    • Exceptions
    +
  • Documentation Features + diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 62b5f926e..a3c60db02 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -53,6 +53,10 @@
  • Exceptions +
  • Documentation Features + @@ -992,5 +996,46 @@ but not too useful example is provided by the throw_exception testcase in Examples/test-suite. You can provide your own exceptions, too.

    +

    33.3 Documentation Features

    + + +

    +The features described in this section can be used to generate documentation +comments (colloquially referred to as "docstrings") that can be read by +OCamldoc. +

    + +

    33.3.1 Module docstring

    + + +

    +The first documentation comment of an mli file is the comment +associated with the entire module. SWIG supports this by setting an +option of the %module directive. For example: +

    + +
    +
    +%module(docstring="This is the example module's docstring") example
    +
    +
    + +

    +When you have more than just a line or so, you can retain the +readability of the %module directive by using a macro. For +example: +

    + +
    +
    +%define DOCSTRING
    +"The `XmlResource` class allows program resources defining menus,
    +controls on a panel, etc. to be loaded from an XML file."
    +%enddef
    +
    +%module(docstring=DOCSTRING) xrc
    +
    +
    + diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 99f2a98d7..1ab99705c 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -202,6 +202,7 @@ public: * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ + String *mod_docstring = NULL; { Node *module = Getattr(n, "module"); if (module) { @@ -216,6 +217,7 @@ public: if (Getattr(options, "sizeof")) { generate_sizeof = 1; } + mod_docstring = Getattr(options, "docstring"); } } } @@ -321,6 +323,14 @@ public: Language::top(n); + if (mod_docstring) { + if (Len(mod_docstring)) { + Printv(f_mliout, "(** ", mod_docstring, " *)\n", NIL); + } + Delete(mod_docstring); + mod_docstring = NULL; + } + Printf(f_enum_to_int, ") | _ -> (C_int (get_int v))\n" "let _ = Callback.register \"%s_enum_to_int\" enum_to_int\n", module); Printf(f_mlibody, "val enum_to_int : c_enum_type -> c_obj -> Swig.c_obj\n"); From 50a80e6ee35fb0a45c17bf63afbbe450c9783174 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 31 Jan 2019 23:01:42 +0000 Subject: [PATCH 1335/2031] Add a testcase for testing %native --- Examples/test-suite/common.mk | 1 + .../java/native_directive_runme.java | 22 ++++++++++ Examples/test-suite/native_directive.i | 43 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 Examples/test-suite/java/native_directive_runme.java create mode 100644 Examples/test-suite/native_directive.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 96c9c4b14..d3b617f21 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -314,6 +314,7 @@ CPP_TEST_CASES += \ namespace_virtual_method \ nspace \ nspace_extend \ + native_directive \ naturalvar \ naturalvar_more \ naturalvar_onoff \ diff --git a/Examples/test-suite/java/native_directive_runme.java b/Examples/test-suite/java/native_directive_runme.java new file mode 100644 index 000000000..fc83ba2d0 --- /dev/null +++ b/Examples/test-suite/java/native_directive_runme.java @@ -0,0 +1,22 @@ +import native_directive.*; + +public class native_directive_runme { + + static { + try { + System.loadLibrary("native_directive"); + } 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[]) { + String s = "abc.DEF-123"; + if (native_directive.CountAlphas(s) != 6) + throw new RuntimeException("CountAlphas failed"); + if (native_directive.CountAlphaCharacters(s) != 6) + throw new RuntimeException("CountAlphaCharacters failed"); + } +} + diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i new file mode 100644 index 000000000..d08c9a954 --- /dev/null +++ b/Examples/test-suite/native_directive.i @@ -0,0 +1,43 @@ +%module native_directive + +%{ +#include +int alpha_count(const char *instring) { + int count = 0; + const char *s = instring; + while (s && *s) { + if (isalpha((int)*s)) + count++; + s++; + }; + return count; +} +%} + +%inline %{ +int CountAlphas(const char *instring) { + return alpha_count(instring); +} +%} + +// Languages that support %native should code up language specific implementations below + +#if defined(SWIGJAVA) +%native(CountAlphaCharacters) int alpha_count(const char *inputString); +%{ +extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_CountAlphaCharacters(JNIEnv *jenv, jclass jcls, jstring instring) { + jint jresult = 0 ; + (void)jcls; + + if (instring) { + const char *s = (char *)jenv->GetStringUTFChars(instring, 0); + if (s) { + jresult = (jint)alpha_count(s); + jenv->ReleaseStringUTFChars(instring, s); + } + } + return jresult; +} +%} +#endif + From ec72026285729f5b73f85505a1fd44263816d739 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 31 Jan 2019 11:46:29 +1300 Subject: [PATCH 1336/2031] Stop defaulting to Tcl SWIG now requires a target language to be specified instead of defaulting to wrapping for Tcl. Specifying swig --help without a target language now just shows the generic help. The -nolang option has been removed. --- CHANGES.current | 6 ++++++ Source/Modules/main.cxx | 13 ++++++++++--- Source/Modules/swigmain.cxx | 13 ------------- configure.ac | 3 --- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 80c467a17..8965355de 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-01-31: olly + SWIG now requires a target language to be specified instead of + defaulting to wrapping for Tcl. Specifying swig --help without + a target language now just shows the generic help. The -nolang + option has been removed. + 2019-01-28: ZackerySpytz [OCaml] #1429 Remove support for OCaml versions < 3.12.0. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 063275e3b..e94e36cac 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -890,7 +890,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Initialize the preprocessor Preprocessor_init(); - lang = l; + // Set lang to a dummy value if no target language was specified so we + // can process options enough to handle -version, etc. + lang = l ? l : new Language; // Set up some default symbols (available in both SWIG interface files // and C files) @@ -923,9 +925,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { Wrapper_director_protected_mode_set(1); // Inform the parser if the nested classes should be ignored unless explicitly told otherwise via feature:flatnested - ignore_nested_classes = l->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; + ignore_nested_classes = lang->nestedClassesSupport() == Language::NCS_Unknown ? 1 : 0; - kwargs_supported = l->kwargsSupport() ? 1 : 0; + kwargs_supported = lang->kwargsSupport() ? 1 : 0; // Create Library search directories @@ -960,6 +962,11 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); + if (!l) { + Printf(stderr, "No target language specified\n"); + return 1; + } + // Parse language dependent options lang->main(argc, argv); diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 0f5f07b4e..aaf6de7a8 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -106,10 +106,6 @@ static swig_module modules[] = { #include #endif -#ifndef SWIG_LANG -#define SWIG_LANG "-python" -#endif - //----------------------------------------------------------------- // main() // @@ -262,9 +258,6 @@ int main(int margc, char **margv) { if (fac) { dl = (fac) (); Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nolang") == 0) { - dl = new Language; - Swig_mark_arg(i); } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) { if (strcmp(argv[i], "--help") == 0) strcpy(argv[i], "-help"); @@ -278,12 +271,6 @@ int main(int margc, char **margv) { } } } - if (!dl) { - fac = Swig_find_module(SWIG_LANG); - if (fac) { - dl = (fac) (); - } - } int res = SWIG_main(argc, argv, dl); diff --git a/configure.ac b/configure.ac index deb537e81..b2644762a 100644 --- a/configure.ac +++ b/configure.ac @@ -16,9 +16,6 @@ AM_INIT_AUTOMAKE dnl Some extra defines for the config file AH_BOTTOM([ -/* Default language */ -#define SWIG_LANG "-tcl" - /* Deal with attempt by Microsoft to deprecate C standard runtime functions */ #if defined(_MSC_VER) # define _CRT_SECURE_NO_DEPRECATE From 35e417a4dbdde579d752cba7ccb3ca0d7b1a0647 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 1 Feb 2019 12:59:29 -0700 Subject: [PATCH 1337/2031] [OCaml] Runtime tests for default_arg_values, inherit_missing and some others Add runtime tests for default_arg_values, inherit_missing, memberin_extend, rename_predicates, template_inherit, template_tbase_template, and typedef_classforward_same_name. --- .../ocaml/default_arg_values_runme.ml | 17 ++++++++ .../test-suite/ocaml/inherit_missing_runme.ml | 10 +++++ .../test-suite/ocaml/memberin_extend_runme.ml | 10 +++++ .../ocaml/rename_predicates_runme.ml | 40 +++++++++++++++++++ .../ocaml/template_inherit_runme.ml | 22 ++++++++++ .../ocaml/template_tbase_template_runme.ml | 5 +++ .../typedef_classforward_same_name_runme.ml | 11 +++++ 7 files changed, 115 insertions(+) create mode 100644 Examples/test-suite/ocaml/default_arg_values_runme.ml create mode 100644 Examples/test-suite/ocaml/inherit_missing_runme.ml create mode 100644 Examples/test-suite/ocaml/memberin_extend_runme.ml create mode 100644 Examples/test-suite/ocaml/rename_predicates_runme.ml create mode 100644 Examples/test-suite/ocaml/template_inherit_runme.ml create mode 100644 Examples/test-suite/ocaml/template_tbase_template_runme.ml create mode 100644 Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml diff --git a/Examples/test-suite/ocaml/default_arg_values_runme.ml b/Examples/test-suite/ocaml/default_arg_values_runme.ml new file mode 100644 index 000000000..e9edcb9d9 --- /dev/null +++ b/Examples/test-suite/ocaml/default_arg_values_runme.ml @@ -0,0 +1,17 @@ +open Swig +open Default_arg_values + +let _ = + let d = new_Display '() in + assert (d -> draw1 () as float = 0.); + let arg = C_float 12. in + assert (d -> draw1 (arg) as float = 12.); + let arg = C_float 123. in + let p = _createPtr '(arg) in + assert (d -> draw2 () as float = 0.); + assert (d -> draw2 (p) as float = 123.); + assert (d -> bool0 () as bool = false); + assert (d -> bool1 () as bool = true); + assert (d -> mybool0 () as bool = false); + assert (d -> mybool1 () as bool = true) +;; diff --git a/Examples/test-suite/ocaml/inherit_missing_runme.ml b/Examples/test-suite/ocaml/inherit_missing_runme.ml new file mode 100644 index 000000000..3d1901356 --- /dev/null +++ b/Examples/test-suite/ocaml/inherit_missing_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Inherit_missing + +let _ = + let a = _new_Foo '() and b = new_Bar '() and c = new_Spam '() in + assert (_do_blah '(a) as string = "Foo::blah"); + assert (_do_blah '(b) as string = "Bar::blah"); + assert (_do_blah '(c) as string = "Spam::blah"); + assert (_delete_Foo '(a) = C_void) +;; diff --git a/Examples/test-suite/ocaml/memberin_extend_runme.ml b/Examples/test-suite/ocaml/memberin_extend_runme.ml new file mode 100644 index 000000000..e2cca2275 --- /dev/null +++ b/Examples/test-suite/ocaml/memberin_extend_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Memberin_extend + +let _ = + let em1 = new_ExtendMe '() and em2 = new_ExtendMe '() in + assert (em1 -> "[thing]" ("em1thing") = C_void); + assert (em2 -> "[thing]" ("em2thing") = C_void); + assert (em1 -> "[thing]" () as string = "em1thing"); + assert (em2 -> "[thing]" () as string = "em2thing"); +;; diff --git a/Examples/test-suite/ocaml/rename_predicates_runme.ml b/Examples/test-suite/ocaml/rename_predicates_runme.ml new file mode 100644 index 000000000..984600207 --- /dev/null +++ b/Examples/test-suite/ocaml/rename_predicates_runme.ml @@ -0,0 +1,40 @@ +open Swig +open Rename_predicates + +let _ = + let r = new_RenamePredicates '(123) in + assert (r -> MF_member_function () = C_void); + assert (_RenamePredicates_MF_static_member_function '() = C_void); + assert (r -> MF_member_function () = C_void); + assert (r -> MF_extend_function_before () = C_void); + assert (r -> MF_extend_function_after () = C_void); + assert (_GF_global_function '() = C_void); + + assert (r -> "[MV_member_variable]" () as int = 123); + assert (r -> "[MV_member_variable]" (1234) = C_void); + assert (r -> "[MV_member_variable]" () as int = 1234); + + assert (_RenamePredicates_MV_static_member_variable '() as int = 456); + assert (_RenamePredicates_MV_static_member_variable '(4567) as int = 4567); + assert (_RenamePredicates_MV_static_member_variable '() as int = 4567); + + assert (_GV_global_variable '() as int = 789); + assert (_GV_global_variable '(7890) as int = 7890); + assert (_GV_global_variable '() as int = 7890); + + assert (_UC_UPPERCASE '() = C_void); + assert (_LC_lowercase '() = C_void); + assert (_TI_Title '() = C_void); + assert (_FU_FirstUpperCase '() = C_void); + assert (_FL_firstLowerCase '() = C_void); + assert (_CA_CamelCase '() = C_void); + assert (_LC_lowerCamelCase '() = C_void); + assert (_UC_under_case_it '() = C_void); + + let ex = new_ExtendCheck '() in + assert (ex -> MF_real_member1 () = C_void); + assert (ex -> MF_real_member2 () = C_void); + assert (ex -> EX_EXTENDMETHOD1 () = C_void); + assert (ex -> EX_EXTENDMETHOD2 () = C_void); + assert (ex -> EX_EXTENDMETHOD3 () = C_void) +;; diff --git a/Examples/test-suite/ocaml/template_inherit_runme.ml b/Examples/test-suite/ocaml/template_inherit_runme.ml new file mode 100644 index 000000000..1f3761cd2 --- /dev/null +++ b/Examples/test-suite/ocaml/template_inherit_runme.ml @@ -0,0 +1,22 @@ +open Swig +open Template_inherit + +let _ = + let a = new_FooInt '() and b = new_FooDouble '() and c = new_BarInt '() + and d = new_BarDouble '() and e = new_FooUInt '() and f = new_BarUInt '() in + assert (a -> blah () as string = "Foo"); + assert (b -> blah () as string = "Foo"); + assert (e -> blah () as string = "Foo"); + assert (c -> blah () as string = "Bar"); + assert (d -> blah () as string = "Bar"); + assert (f -> blah () as string = "Bar"); + assert (c -> foomethod () as string = "foomethod"); + assert (d -> foomethod () as string = "foomethod"); + assert (f -> foomethod () as string = "foomethod"); + assert (_invoke_blah_int '(a) as string = "Foo"); + assert (_invoke_blah_int '(c) as string = "Bar"); + assert (_invoke_blah_double '(b) as string = "Foo"); + assert (_invoke_blah_double '(d) as string = "Bar"); + assert (_invoke_blah_uint '(e) as string = "Foo"); + assert (_invoke_blah_uint '(f) as string = "Bar") +;; diff --git a/Examples/test-suite/ocaml/template_tbase_template_runme.ml b/Examples/test-suite/ocaml/template_tbase_template_runme.ml new file mode 100644 index 000000000..724776a24 --- /dev/null +++ b/Examples/test-suite/ocaml/template_tbase_template_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Template_tbase_template + +let a = _make_Class_dd '() +assert (a -> test () as string = "test") diff --git a/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml b/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml new file mode 100644 index 000000000..304f74b7a --- /dev/null +++ b/Examples/test-suite/ocaml/typedef_classforward_same_name_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Typedef_classforward_same_name + +let _ = + let foo = new_Foo '() in + ignore (foo -> "[x]" (5)); + assert (_extractFoo '(foo) as int = 5); + let boo = new_Boo '() in + ignore (boo -> "[x]" (5)); + assert (_extractBoo '(boo) as int = 5) +;; From fddaf3f814a0f70b4d7dd8cf6f9a62d6774cca71 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Feb 2019 21:42:47 +0000 Subject: [PATCH 1338/2031] Minor refactoring of Python autodoc related code --- Source/Modules/python.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b93aa6c86..acf1ecd57 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1848,7 +1848,7 @@ public: if (!skipAuto) { /* Check if a documentation name was given for either the low-level C API or high-level Python shadow API */ - String *symname = Getattr(n, low_level? "doc:low:name" : "doc:high:name"); + String *symname = Getattr(n, low_level ? "doc:low:name" : "doc:high:name"); if (!symname) { symname = Getattr(n, "sym:name"); } @@ -1862,7 +1862,7 @@ public: continue; } - if (! first_func) + if (!first_func) Append(doc, "\n"); if (type) { @@ -1967,9 +1967,9 @@ public: Printf(doc, "%s", symname); if (showTypes) { String *type = Getattr(n, "tmap:doc:type"); - if (! type) + if (!type) type = Getattr(n, "membervariableHandler:type"); - if (! type) + if (!type) type = Getattr(n, "type"); Printf(doc, " : %s", type); } @@ -3317,7 +3317,7 @@ public: Delete(h); } Setattr(h, "getter", "SwigPyObject_get___dict__"); - if (! Getattr(h, "doc")) { + if (!Getattr(h, "doc")) { Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } @@ -3335,7 +3335,7 @@ public: } Setattr(h, "getter", wrapper_name); Delattr(n, "memberget"); - if (! Getattr(h, "doc")) { + if (!Getattr(h, "doc")) { Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } @@ -3352,7 +3352,7 @@ public: } Setattr(h, "setter", wrapper_name); Delattr(n, "memberset"); - if (! Getattr(h, "doc")) { + if (!Getattr(h, "doc")) { Setattr(n, "doc:high:name", Getattr(n, "name")); Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); } @@ -4030,12 +4030,9 @@ public: const char *setter_closure = setter ? funpack ? "SwigPyBuiltin_FunpackSetterClosure" : "SwigPyBuiltin_SetterClosure" : "0"; String *gspair = NewStringf("%s_%s_getset", symname, memname); Printf(f, "static SwigPyGetSet %s = { %s, %s };\n", gspair, getter ? getter : "0", setter ? setter : "0"); - String *doc; - if (Getattr(mgetset, "doc")) { - doc = Getattr(mgetset, "doc"); - } else { + String *doc = Getattr(mgetset, "doc"); + if (!doc) doc = NewStringf("%s.%s", name, memname); - } String *entry = NewStringf("{ (char *)\"%s\", (getter)%s, (setter)%s, (char *)\"%s\", (void *)&%s }\n", memname, getter_closure, setter_closure, doc, gspair); From 62c5ca89a61c96df6abe5468354520ae16da805e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Feb 2019 23:15:25 +0000 Subject: [PATCH 1339/2031] Minor refactoring of generated Python code --- Lib/python/pyapi.swg | 34 +++++++++++----------------------- Source/Modules/python.cxx | 8 ++------ 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index 5c2c65c45..cb754db11 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -28,24 +28,18 @@ typedef struct swig_const_info { * Function to find the method definition with the correct docstring for the * proxy module as opposed to the low-level API * ----------------------------------------------------------------------------- */ -PyMethodDef* getProxyDoc(const char* name); +SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); /* ----------------------------------------------------------------------------- * Wrapper of PyInstanceMethod_New() used in Python 3 * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) -{ +SWIGRUNTIME PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { if (PyCFunction_Check(func)) { - /* Unpack the existing PyCFunction */ - PyMethodDef* ml = ((PyCFunctionObject*) func)->m_ml; - PyObject* self = ((PyCFunctionObject*) func)->m_self; - PyObject* module = ((PyCFunctionObject*) func)->m_module; - /* Use the copy with the modified docstring if available */ - ml = getProxyDoc(ml->ml_name); - if (ml != NULL) { - func = PyCFunction_NewEx(ml, self, module); - } + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); } #if PY_VERSION_HEX >= 0x03000000 return PyInstanceMethod_New(func); @@ -58,18 +52,12 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), * Wrapper of PyStaticMethod_New() * It is exported to the generated module, used for -fastproxy * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) -{ +SWIGRUNTIME PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { if (PyCFunction_Check(func)) { - /* Unpack the existing PyCFunction */ - PyMethodDef* ml = ((PyCFunctionObject*) func)->m_ml; - PyObject* self = ((PyCFunctionObject*) func)->m_self; - PyObject* module = ((PyCFunctionObject*) func)->m_module; - /* Use the copy with the modified docstring if available */ - ml = getProxyDoc(ml->ml_name); - if (ml != NULL) { - func = PyCFunction_NewEx(ml, self, module); - } + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); } return PyStaticMethod_New(func); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index acf1ecd57..271375362 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -835,7 +835,7 @@ public: Printf(f_wrappers, "%s\n", methods_proxydocs); /* Need to define the function to find the proxy documentation after the proxy docs themselves */ - Printv(f_wrappers, "PyMethodDef* getProxyDoc(const char* name)\n", + Printv(f_wrappers, "SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name)\n", "{\n", " /* Find the function in the modified method table */\n", " size_t offset = 0;\n", @@ -848,11 +848,7 @@ public: " offset++;\n", " }\n", " /* Use the copy with the modified docstring if available */\n", - " if (found == 1) {\n", - " return &SwigMethods_proxydocs[offset];\n", - " } else {\n", - " return NULL;\n", - " }\n", + " return found ? &SwigMethods_proxydocs[offset] : NULL;\n", "}\n", NIL); if (builtin) { From 64a7678759ae978222d5c8e87dfc308a7daf39d8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Feb 2019 23:48:52 +0000 Subject: [PATCH 1340/2031] Remove some unnecessary casts in Python builtin code --- Source/Modules/python.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 271375362..26301590e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4029,9 +4029,7 @@ public: String *doc = Getattr(mgetset, "doc"); if (!doc) doc = NewStringf("%s.%s", name, memname); - String *entry = - NewStringf("{ (char *)\"%s\", (getter)%s, (setter)%s, (char *)\"%s\", (void *)&%s }\n", memname, getter_closure, - setter_closure, doc, gspair); + String *entry = NewStringf("{ (char *)\"%s\", %s, %s, (char *)\"%s\", &%s }", memname, getter_closure, setter_closure, doc, gspair); if (GetFlag(mgetset, "static")) { Printf(f, "static PyGetSetDef %s_def = %s;\n", gspair, entry); Printf(f_init, "static_getset = SwigPyStaticVar_new_getset(metatype, &%s_def);\n", gspair); @@ -4043,7 +4041,7 @@ public: Delete(gspair); Delete(entry); } - Printv(f, getset_def, " {NULL, NULL, NULL, NULL, NULL} /* Sentinel */\n", "};\n\n", NIL); + Printv(f, getset_def, " { NULL, NULL, NULL, NULL, NULL } /* Sentinel */\n", "};\n\n", NIL); // Rich compare function Hash *richcompare = Getattr(n, "python:richcompare"); From 02c9990ff9c204c1b99e7493027f75fae2c88fca Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Feb 2019 23:57:47 +0000 Subject: [PATCH 1341/2031] Run multicpptests in alphabetical order --- Examples/test-suite/common.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index d3b617f21..7d4a441fb 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -722,12 +722,12 @@ C_TEST_CASES += \ # Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) MULTI_CPP_TEST_CASES += \ clientdata_prop \ - imports \ import_stl \ - packageoption \ + imports \ mod \ - template_typedef_import \ multi_import \ + packageoption \ + template_typedef_import \ # Custom tests - tests with additional commandline options wallkw.cpptest: SWIGOPT += -Wallkw From b50e5fac8e1d76e8810c552f533a43f67ff57837 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Feb 2019 00:11:10 +0000 Subject: [PATCH 1342/2031] Python docstring - add in missing Delete calls --- Source/Modules/python.cxx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 26301590e..9c3c0cac2 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1637,8 +1637,7 @@ public: * source code (but without quotes around it). * ------------------------------------------------------------ */ - String *cdocstring(Node *n, autodoc_t ad_type, bool low_level = false) - { + String *cdocstring(Node *n, autodoc_t ad_type, bool low_level = false) { String *ds = build_combined_docstring(n, ad_type, "", low_level); Replaceall(ds, "\\", "\\\\"); Replaceall(ds, "\"", "\\\""); @@ -2478,6 +2477,7 @@ public: Printf(methods, "\"%s\"", ds); if (fastproxy) { /* In the fastproxy case, we must also record the high-level docstring for use in the Python shadow API */ + Delete(ds); ds = cdocstring(n, Getattr(n, "memberfunction") ? AUTODOC_METHOD : AUTODOC_FUNC); Printf(methods_proxydocs, "\"%s\"", ds); } @@ -3333,7 +3333,9 @@ public: Delattr(n, "memberget"); if (!Getattr(h, "doc")) { Setattr(n, "doc:high:name", Getattr(n, "name")); - Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); + String *ds = cdocstring(n, AUTODOC_VAR); + Setattr(h, "doc", ds); + Delete(ds); } } if (builtin_setter) { @@ -3350,7 +3352,9 @@ public: Delattr(n, "memberset"); if (!Getattr(h, "doc")) { Setattr(n, "doc:high:name", Getattr(n, "name")); - Setattr(h, "doc", cdocstring(n, AUTODOC_VAR)); + String *ds = cdocstring(n, AUTODOC_VAR); + Setattr(h, "doc", ds); + Delete(ds); } } @@ -4448,9 +4452,9 @@ public: if (builtin) { if (have_docstring(n)) { - String *str = cdocstring(n, AUTODOC_CLASS); - Setattr(n, "feature:python:tp_doc", str); - Delete(str); + String *ds = cdocstring(n, AUTODOC_CLASS); + Setattr(n, "feature:python:tp_doc", ds); + Delete(ds); } else { String *name = Getattr(n, "name"); String *rname = add_explicit_scope(SwigType_namestr(name)); From bdc038b5780746d3659b8935bacd5ff89b1e4ffe Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 3 Feb 2019 17:37:46 -0700 Subject: [PATCH 1343/2031] [OCaml] Cache the result of caml_named_value() in some cases The result of caml_named_value() can be cached for (slightly) improved performance. This is mentioned in the OCaml reference manual. https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#sec453 In addition, fix incorrect use of CAMLreturn() in caml_ptr_val_internal(). --- Lib/ocaml/ocaml.swg | 21 +++++++++++---------- Source/Modules/ocaml.cxx | 6 ++++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 8d9877143..92a3637ce 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -451,27 +451,28 @@ extern "C" { CAMLparam1(v); void *outptr = NULL; swig_type_info *outdescr = NULL; + static CAML_VALUE *func_val = NULL; if( v == Val_unit ) { *out = 0; - CAMLreturn(0); + CAMLreturn_type(0); } if( !Is_block(v) ) return -1; switch( SWIG_Tag_val(v) ) { case C_int: if( !caml_long_val( v ) ) { *out = 0; - CAMLreturn(0); + CAMLreturn_type(0); } else { *out = 0; - CAMLreturn(1); + CAMLreturn_type(1); } break; case C_obj: - CAMLreturn - (caml_ptr_val_internal - (caml_callback(*caml_named_value("caml_obj_ptr"),v), - out,descriptor)); + if (!func_val) { + func_val = caml_named_value("caml_obj_ptr"); + } + CAMLreturn_type(caml_ptr_val_internal(caml_callback(*func_val, v), out, descriptor)); case C_string: outptr = (void *)String_val(SWIG_Field(v,0)); break; @@ -481,11 +482,11 @@ extern "C" { break; default: *out = 0; - CAMLreturn(1); + CAMLreturn_type(1); break; } - - CAMLreturn(SWIG_GetPtr(outptr,out,outdescr,descriptor)); + + CAMLreturn_type(SWIG_GetPtr(outptr, out, outdescr, descriptor)); } SWIGINTERN void *caml_ptr_val( CAML_VALUE v, swig_type_info *descriptor ) { diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 99f2a98d7..2f5e038bb 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1595,10 +1595,12 @@ public: /* wrap complex arguments to values */ Printv(w->code, wrap_args, NIL); - /* pass the method call on to the Python object */ + /* pass the method call on to the OCaml object */ Printv(w->code, "swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0); - Printf(w->code, "swig_result = " "caml_callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name")); + Printf(w->code, "static CAML_VALUE *swig_ocaml_func_val = NULL;\n" "if (!swig_ocaml_func_val) {\n"); + Printf(w->code, " swig_ocaml_func_val = caml_named_value(\"swig_runmethod\");\n }\n"); + Printf(w->code, "swig_result = caml_callback3(*swig_ocaml_func_val,swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name")); /* exception handling */ tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0); if (!tm) { From 5a28593818d9107007ef13eb32902ac0b0df74c9 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 4 Feb 2019 11:22:10 -0700 Subject: [PATCH 1344/2031] [OCaml] Reduce the duplication in typemaps.i Add a SWIG_Ocaml_ptr_to_val() function to reduce some of the duplication in the OCaml typemaps. Remove unused, useless `ArrayCarrier *` typemaps. --- Lib/ocaml/ocaml.swg | 13 +++++++++ Lib/ocaml/typemaps.i | 63 +++++++------------------------------------- 2 files changed, 23 insertions(+), 53 deletions(-) diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 8d9877143..1be368a51 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -578,6 +578,19 @@ extern "C" { } } + SWIGINTERN CAML_VALUE SWIG_Ocaml_ptr_to_val(const char *name, void *ptr, swig_type_info *descriptor) { + CAMLparam0(); + SWIG_CAMLlocal1(result); + + CAML_VALUE *fromval = caml_named_value(name); + if (fromval) { + result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor)); + } else { + result = caml_val_ptr(ptr, descriptor); + } + CAMLreturn(result); + } + static swig_module_info *SWIG_Ocaml_GetModule(void *SWIGUNUSEDPARM(clientdata)) { CAML_VALUE pointer; diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 38ec10066..4acd0b805 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -52,22 +52,8 @@ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } -%typemap(out) SWIGTYPE & { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); - } else { - $result = caml_val_ptr ((void *) &$1,$1_descriptor); - } -} - -%typemap(out) SWIGTYPE && { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor)); - } else { - $result = caml_val_ptr ((void *) &$1,$1_descriptor); - } +%typemap(out) SWIGTYPE &, SWIGTYPE && { + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)&$1, $1_descriptor); } #if 0 @@ -110,25 +96,15 @@ %typemap(out) SWIGTYPE { $&1_ltype temp = new $ltype((const $1_ltype &) $1); - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); - } else { - $result = caml_val_ptr ((void *)temp,$&1_descriptor); - } + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)temp, $&1_descriptor); } #else %typemap(out) SWIGTYPE { void *temp = calloc(1,sizeof($ltype)); - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - memmove( temp, &$1, sizeof( $1_type ) ); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *)temp,$&1_descriptor)); - } else { - $result = caml_val_ptr ((void *)temp,$&1_descriptor); - } + memmove(temp, &$1, sizeof($1_type)); + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", temp, $&1_descriptor); } #endif @@ -209,23 +185,8 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); /* Pass through value */ -%typemap (in) value,caml::value,CAML_VALUE "$1=$input;"; -%typemap (out) value,caml::value,CAML_VALUE "$result=$1;"; - -/* Arrays */ - -%typemap(in) ArrayCarrier * { - $1 = ($ltype)caml_ptr_val($input,$1_descriptor); -} - -%typemap(out) ArrayCarrier * { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); - } else { - $result = caml_val_ptr ((void *)$1,$1_descriptor); - } -} +%typemap (in) CAML_VALUE "$1=$input;"; +%typemap (out) CAML_VALUE "$result=$1;"; #if 0 %include @@ -276,15 +237,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); } %enddef -%define %swigtype_ptr_out(how) %typemap(out) SWIGTYPE * { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); - if( fromval ) { - $result = caml_callback(*fromval,caml_val_ptr((void *)$1,$1_descriptor)); - } else { - $result = caml_val_ptr ((void *)$1,$1_descriptor); - } + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor); } + +%define %swigtype_ptr_out(how) %typemap(how) SWIGTYPE (CLASS::*) { void *v; memcpy(&v,& $1, sizeof(void *)); From 9942e6a5822e1ba8c8f9d642c14fda3cb298baec Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 4 Feb 2019 11:29:54 -0700 Subject: [PATCH 1345/2031] [OCaml] Fix director_pass_by_value Add a directorin typemap for SWIGTYPE. Add director_frob_runme.ml, director_pass_by_value_runme.ml, and director_unroll_runme.ml. This commit fixes most of the director-related warnings in the OCaml test suite. Of the director tests that are currently included in the OCaml test suite, director_basic and director_property are the only ones which give warnings (due to issues with typecheck typemaps). --- Examples/test-suite/ocaml/Makefile.in | 1 - .../test-suite/ocaml/director_frob_runme.ml | 5 ++++ .../ocaml/director_pass_by_value_runme.ml | 24 +++++++++++++++++++ .../test-suite/ocaml/director_unroll_runme.ml | 19 +++++++++++++++ Lib/ocaml/typemaps.i | 11 +++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/ocaml/director_frob_runme.ml create mode 100644 Examples/test-suite/ocaml/director_pass_by_value_runme.ml create mode 100644 Examples/test-suite/ocaml/director_unroll_runme.ml diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 650849815..ccdb9a17b 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -21,7 +21,6 @@ cpp_enum \ default_constructor \ director_binary_string \ director_enum \ -director_pass_by_value \ director_primitives \ director_redefined \ director_string \ diff --git a/Examples/test-suite/ocaml/director_frob_runme.ml b/Examples/test-suite/ocaml/director_frob_runme.ml new file mode 100644 index 000000000..137a88ef3 --- /dev/null +++ b/Examples/test-suite/ocaml/director_frob_runme.ml @@ -0,0 +1,5 @@ +open Swig +open Director_frob + +let foo = new_Bravo '() +assert (foo -> abs_method () as string = "Bravo::abs_method()") diff --git a/Examples/test-suite/ocaml/director_pass_by_value_runme.ml b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml new file mode 100644 index 000000000..af862f189 --- /dev/null +++ b/Examples/test-suite/ocaml/director_pass_by_value_runme.ml @@ -0,0 +1,24 @@ +open Swig +open Director_pass_by_value + +let passByVal = ref [| |] + +let director_pass_by_value_Derived ob meth args = + match meth with + | "virtualMethod" -> passByVal := Array.append !passByVal [|args|]; C_void + | _ -> (invoke ob) meth args + +let d = + new_derived_object + new_DirectorPassByValueAbstractBase + (director_pass_by_value_Derived) + '() + +let _ = + let caller = new_Caller '() in + assert (caller -> call_virtualMethod (d) = C_void); + assert (Array.length !passByVal = 1); + let a = List.hd (fnhelper (!passByVal.(0))) in + assert (a -> getVal () as int = 0x12345678); + assert (a -> "~" () = C_void); +;; diff --git a/Examples/test-suite/ocaml/director_unroll_runme.ml b/Examples/test-suite/ocaml/director_unroll_runme.ml new file mode 100644 index 000000000..ebd7d02c5 --- /dev/null +++ b/Examples/test-suite/ocaml/director_unroll_runme.ml @@ -0,0 +1,19 @@ +open Swig +open Director_unroll + +let director_unroll_MyFoo ob meth args = + match meth with + | "ping" -> C_string "director_unroll_MyFoo::ping()" + | _ -> (invoke ob) meth args + +let a = + new_derived_object + new_Foo (director_unroll_MyFoo) '() + +let _ = + let b = new_Bar '() in + let _ = b -> set (a) in + let c = b -> get () in + assert (director_unroll_MyFoo c "ping" '() as string = + "director_unroll_MyFoo::ping()"); +;; diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 4acd0b805..4475707d6 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -109,6 +109,17 @@ #endif +%typemap(directorin) SWIGTYPE { + $<ype temp = new $ltype((const $ltype &)$1); + swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)temp, $&1_descriptor); + args = caml_list_append(args, swig_result); +} + +%typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE &, SWIGTYPE && { + swig_result = SWIG_Ocaml_ptr_to_val("create_$ltype_from_ptr", (void *)&$1, $&1_descriptor); + args = caml_list_append(args, swig_result); +} + /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ From 9defd8e0330ebd491b2102bb7dc6d6b43715c712 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Feb 2019 21:59:48 +0000 Subject: [PATCH 1346/2031] Add support for differentiating target language statuses Three status: Disabled, Experimental and Supported. Any target language classified as 'Experimental' will issue new warning 524 SWIGWARN_LANG_EXPERIMENTAL. Any target language classified as 'Disabled' will error out. Languages will be classified in forthcoming commits. Issue #1437 --- Doc/Manual/Introduction.html | 4 + Doc/Manual/Warnings.html | 1 + Makefile.in | 2 +- Source/Include/swigwarn.h | 3 + Source/Makefile.am | 5 +- Source/Modules/main.cxx | 17 ++-- Source/Modules/module.cxx | 59 -------------- Source/Modules/swigmain.cxx | 149 ++++++++++++++++++----------------- Source/Modules/swigmod.h | 24 +++--- 9 files changed, 116 insertions(+), 148 deletions(-) delete mode 100644 Source/Modules/module.cxx diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index b7e12aada..17514d021 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -212,6 +212,10 @@ A target language is given the 'Experimental' status when

    Anyone using an experimental target language is strongly urged to assist with development of the target language module if they wish to use it.

    +

    +SWIG displays a warning when an experimental target language is used in order to set expectations and emphasize the experimental status of the target language. +The usual warning suppression techniques can be used if required. +

    The above is a short summary and further details are outlined in the Experimental status section in the Extending chapter. diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 140090140..968bdbac8 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -534,6 +534,7 @@ example.i(4) : Syntax error in input(1).

  • 521. Illegal destructor name name. Ignored.
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'.
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'. +
  • 524. Experimental target language. Target language language specified by lang is an experimental language. Please read about SWIG experimental languages, htmllink.

    17.9.6 Doxygen comments (560-599)

    diff --git a/Makefile.in b/Makefile.in index 33b712d2c..3394f49dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -468,7 +468,7 @@ check-maintainer-clean: maintainer-clean $(srcdir)/Lib/swigwarn.swg: $(srcdir)/Source/Include/swigwarn.h mkdir -p Lib - echo "/* SWIG warning codes */" > $@ + echo "/* SWIG warning codes - generated from swigwarn.h - do not edit */" > $@ cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9][0-9]*\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ ##################################################################### diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 9f863f194..fde82bd96 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -18,6 +18,8 @@ * Even though symbolic constants are used in the SWIG source, this is * not always the case in SWIG interface files. Do not change the * numbers in this file. + * + * This file is used as the input for generating Lib/swigwarn.swg. * ----------------------------------------------------------------------------- */ #ifndef SWIGWARN_H_ @@ -208,6 +210,7 @@ #define WARN_LANG_ILLEGAL_DESTRUCTOR 521 #define WARN_LANG_EXTEND_CONSTRUCTOR 522 #define WARN_LANG_EXTEND_DESTRUCTOR 523 +#define WARN_LANG_EXPERIMENTAL 524 /* -- Doxygen comments -- */ diff --git a/Source/Makefile.am b/Source/Makefile.am index 74aff08c9..8b76694e8 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -65,9 +65,8 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ - Modules/module.cxx \ Modules/mzscheme.cxx \ - Modules/nested.cxx \ + Modules/nested.cxx \ Modules/ocaml.cxx \ Modules/octave.cxx \ Modules/overload.cxx \ @@ -132,7 +131,7 @@ distclean-local: # swig executable as a way of checking before and after the 'beautifying'. # Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c' -SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData +SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T TargetLanguageModule -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData INDENTBAKSDIR=../IndentBaks beautify: diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index e94e36cac..58cc4f7d3 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -459,7 +459,7 @@ static void SWIG_dump_runtime() { SWIG_exit(EXIT_SUCCESS); } -void SWIG_getoptions(int argc, char *argv[]) { +static void getoptions(int argc, char *argv[]) { int i; // Get options for (i = 1; i < argc; i++) { @@ -878,7 +878,7 @@ void SWIG_getoptions(int argc, char *argv[]) { } } -int SWIG_main(int argc, char *argv[], Language *l) { +int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { char *c; /* Initialize the SWIG core */ @@ -892,7 +892,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Set lang to a dummy value if no target language was specified so we // can process options enough to handle -version, etc. - lang = l ? l : new Language; + lang = tlm ? tlm->fac() : new Language; // Set up some default symbols (available in both SWIG interface files // and C files) @@ -956,13 +956,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { /* Check for SWIG_FEATURES environment variable */ - SWIG_getoptions(argc, argv); + getoptions(argc, argv); // Define the __cplusplus symbol if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); - if (!l) { + if (!tlm) { Printf(stderr, "No target language specified\n"); return 1; } @@ -1312,6 +1312,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Check the extension for a c/c++ file. If so, we're going to declare everything we see as "extern" ForceExtern = check_extension(input_file); + if (tlm->status == Experimental) { + Swig_warning(WARN_LANG_EXPERIMENTAL, "SWIG", 1, "Experimental target language. " + "Target language %s specified by %s is an experimental language. " + "Please read about SWIG experimental languages, http://swig.org/Doc4.0/Introduction.html#Introduction_experimental_status.\n", + tlm->help ? tlm->help : "", tlm->name); + } + lang->top(top); if (browse) { diff --git a/Source/Modules/module.cxx b/Source/Modules/module.cxx deleted file mode 100644 index aa48689ab..000000000 --- a/Source/Modules/module.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * module.cxx - * - * This file is responsible for the module system. - * ----------------------------------------------------------------------------- */ - -#include "swigmod.h" - -struct Module { - ModuleFactory fac; - char *name; - Module *next; - Module(const char *n, ModuleFactory f) { - fac = f; - name = new char[strlen(n) + 1]; - strcpy(name, n); - next = 0; - } ~Module() { - delete[]name; - } -}; - -static Module *modules = 0; - -/* ----------------------------------------------------------------------------- - * void Swig_register_module() - * - * Register a module. - * ----------------------------------------------------------------------------- */ - -void Swig_register_module(const char *n, ModuleFactory f) { - Module *m = new Module(n, f); - m->next = modules; - modules = m; -} - -/* ----------------------------------------------------------------------------- - * Language *Swig_find_module() - * - * Given a command line option, locates the factory function. - * ----------------------------------------------------------------------------- */ - -ModuleFactory Swig_find_module(const char *name) { - Module *m = modules; - while (m) { - if (strcmp(m->name, name) == 0) { - return m->fac; - } - m = m->next; - } - return 0; -} diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index aaf6de7a8..6f91c083e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -26,79 +26,73 @@ can be dynamically loaded in future versions. */ extern "C" { - Language *swig_tcl(void); - Language *swig_python(void); - Language *swig_perl5(void); - Language *swig_ruby(void); + Language *swig_allegrocl(void); + Language *swig_cffi(void); + Language *swig_chicken(void); + Language *swig_clisp(void); + Language *swig_csharp(void); + Language *swig_d(void); + Language *swig_go(void); Language *swig_guile(void); + Language *swig_java(void); + Language *swig_javascript(void); + Language *swig_lua(void); Language *swig_modula3(void); Language *swig_mzscheme(void); - Language *swig_java(void); + Language *swig_ocaml(void); + Language *swig_octave(void); + Language *swig_perl5(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); - Language *swig_sexp(void); - Language *swig_xml(void); - Language *swig_chicken(void); - Language *swig_csharp(void); - Language *swig_allegrocl(void); - Language *swig_lua(void); - Language *swig_clisp(void); - Language *swig_cffi(void); - Language *swig_uffi(void); + Language *swig_python(void); Language *swig_r(void); + Language *swig_ruby(void); Language *swig_scilab(void); - Language *swig_go(void); - Language *swig_d(void); - Language *swig_javascript(void); + Language *swig_sexp(void); + Language *swig_tcl(void); + Language *swig_uffi(void); + Language *swig_xml(void); } -struct swig_module { - const char *name; - ModuleFactory fac; - const char *help; -}; - /* Association of command line options to language modules. Place an entry for new language modules here, keeping the list sorted alphabetically. */ -static swig_module modules[] = { - {"-allegrocl", swig_allegrocl, "ALLEGROCL"}, - {"-chicken", swig_chicken, "CHICKEN"}, - {"-clisp", swig_clisp, "CLISP"}, - {"-cffi", swig_cffi, "CFFI"}, - {"-csharp", swig_csharp, "C#"}, - {"-d", swig_d, "D"}, - {"-go", swig_go, "Go"}, - {"-guile", swig_guile, "Guile"}, - {"-java", swig_java, "Java"}, - {"-javascript", swig_javascript, "Javascript"}, - {"-lua", swig_lua, "Lua"}, - {"-modula3", swig_modula3, "Modula 3"}, - {"-mzscheme", swig_mzscheme, "Mzscheme"}, - {"-ocaml", swig_ocaml, "Ocaml"}, - {"-octave", swig_octave, "Octave"}, - {"-perl", swig_perl5, "Perl"}, - {"-perl5", swig_perl5, 0}, - {"-php", swig_php, 0}, - {"-php4", swig_php4, 0}, - {"-php5", swig_php5, 0}, - {"-php7", swig_php, "PHP7"}, - {"-pike", swig_pike, "Pike"}, - {"-python", swig_python, "Python"}, - {"-r", swig_r, "R (aka GNU S)"}, - {"-ruby", swig_ruby, "Ruby"}, - {"-scilab", swig_scilab, "Scilab"}, - {"-sexp", swig_sexp, "Lisp S-Expressions"}, - {"-tcl", swig_tcl, "Tcl"}, - {"-tcl8", swig_tcl, 0}, - {"-uffi", swig_uffi, "Common Lisp / UFFI"}, - {"-xml", swig_xml, "XML"}, - {NULL, NULL, NULL} +static TargetLanguageModule modules[] = { + {"-allegrocl", swig_allegrocl, "ALLEGROCL", Supported}, + {"-chicken", swig_chicken, "CHICKEN", Supported}, + {"-clisp", swig_clisp, "CLISP", Supported}, + {"-cffi", swig_cffi, "CFFI", Supported}, + {"-csharp", swig_csharp, "C#", Supported}, + {"-d", swig_d, "D", Supported}, + {"-go", swig_go, "Go", Supported}, + {"-guile", swig_guile, "Guile", Supported}, + {"-java", swig_java, "Java", Supported}, + {"-javascript", swig_javascript, "Javascript", Supported}, + {"-lua", swig_lua, "Lua", Supported}, + {"-modula3", swig_modula3, "Modula 3", Supported}, + {"-mzscheme", swig_mzscheme, "Mzscheme", Supported}, + {"-ocaml", swig_ocaml, "Ocaml", Supported}, + {"-octave", swig_octave, "Octave", Supported}, + {"-perl", swig_perl5, "Perl", Supported}, + {"-perl5", swig_perl5, NULL, Supported}, + {"-php", swig_php, NULL, Supported}, + {"-php4", swig_php4, NULL, Supported}, + {"-php5", swig_php5, NULL, Supported}, + {"-php7", swig_php, "PHP7", Supported}, + {"-pike", swig_pike, "Pike", Supported}, + {"-python", swig_python, "Python", Supported}, + {"-r", swig_r, "R (aka GNU S)", Supported}, + {"-ruby", swig_ruby, "Ruby", Supported}, + {"-scilab", swig_scilab, "Scilab", Supported}, + {"-sexp", swig_sexp, "Lisp S-Expressions", Supported}, + {"-tcl", swig_tcl, "Tcl", Supported}, + {"-tcl8", swig_tcl, NULL, Supported}, + {"-uffi", swig_uffi, "Common Lisp / UFFI", Supported}, + {"-xml", swig_xml, "XML", Supported}, + {NULL, NULL, NULL, Disabled} }; #ifdef MACSWIG @@ -230,8 +224,7 @@ static void merge_options_files(int *argc, char ***argv) { int main(int margc, char **margv) { int i; - Language *dl = 0; - ModuleFactory fac = 0; + const TargetLanguageModule *language_module = 0; int argc; char **argv; @@ -244,26 +237,40 @@ int main(int margc, char **margv) { argc = ccommand(&argv); #endif - /* Register built-in modules */ - for (i = 0; modules[i].name; i++) { - Swig_register_module(modules[i].name, modules[i].fac); - } - Swig_init_args(argc, argv); /* Get options */ for (i = 1; i < argc; i++) { if (argv[i]) { - fac = Swig_find_module(argv[i]); - if (fac) { - dl = (fac) (); + bool is_target_language_module = false; + for (int j = 0; modules[j].name; j++) { + if (strcmp(modules[j].name, argv[i]) == 0) { + language_module = &modules[j]; + is_target_language_module = true; + break; + } + } + if (is_target_language_module) { Swig_mark_arg(i); + if (language_module->status == Disabled) { + if (language_module->help) + Printf(stderr, "Target language option %s (%s) is no longer supported.\n", language_module->name, language_module->help); + else + Printf(stderr, "Target language option %s is no longer supported.\n", language_module->name); + SWIG_exit(EXIT_FAILURE); + } } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) { if (strcmp(argv[i], "--help") == 0) strcpy(argv[i], "-help"); - Printf(stdout, "Target Language Options\n"); + Printf(stdout, "Supported Target Language Options\n"); for (int j = 0; modules[j].name; j++) { - if (modules[j].help) { + if (modules[j].help && modules[j].status == Supported) { + Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help); + } + } + Printf(stdout, "\nExperimental Target Language Options\n"); + for (int j = 0; modules[j].name; j++) { + if (modules[j].help && modules[j].status == Experimental) { Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help); } } @@ -272,7 +279,7 @@ int main(int margc, char **margv) { } } - int res = SWIG_main(argc, argv, dl); + int res = SWIG_main(argc, argv, language_module); return res; } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 9626166a6..ef49c5684 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -354,7 +354,21 @@ private: static Language *this_; }; -int SWIG_main(int, char **, Language *); +extern "C" { + void SWIG_typemap_lang(const char *); + typedef Language *(*ModuleFactory) (void); +} + +enum Status {Disabled, Experimental, Supported}; + +struct TargetLanguageModule { + const char *name; + ModuleFactory fac; + const char *help; + Status status; +}; + +int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm); 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} */ @@ -391,14 +405,6 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); void Swig_director_parms_fixup(ParmList *parms); /* directors.cxx end */ -extern "C" { - void SWIG_typemap_lang(const char *); - typedef Language *(*ModuleFactory) (void); -} - -void Swig_register_module(const char *name, ModuleFactory fac); -ModuleFactory Swig_find_module(const char *name); - /* Utilities */ int is_public(Node *n); From 849512f56568182f059ac71b3f0a508a38b83846 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 07:36:37 +0000 Subject: [PATCH 1347/2031] Add missing command line options to documentation Options were taken from the output of running swig -help. --- Doc/Manual/SWIG.html | 162 ++++++++++++++++++++++++++++------------ Source/Modules/main.cxx | 12 +-- 2 files changed, 121 insertions(+), 53 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 70fc694e3..bb1ac7dea 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -103,63 +103,131 @@ To run SWIG, use the swig command with options and a filename like this

    -swig [ options ] filename
    +swig [ options ] filename
     

    where filename is a SWIG interface file or a C/C++ header file. -Below is a subset of options that can be used. +Full help can be seen by running swig -help. +Below is the common set of options that can be used. Additional options are also defined for each target language. A full list -can be obtained by typing swig -help or swig --<lang> -help for language <lang> specific options. +can be obtained by running swig +-<lang> -help for language <lang> specific options, +for example, swig -ruby -help for Ruby.

    --allegrocl            Generate ALLEGROCL wrappers
    --chicken              Generate CHICKEN wrappers
    --clisp                Generate CLISP wrappers
    --cffi                 Generate CFFI wrappers
    --csharp               Generate C# wrappers
    --d                    Generate D wrappers
    --go                   Generate Go wrappers
    --guile                Generate Guile wrappers
    --java                 Generate Java wrappers
    --javascript           Generate Javascript wrappers
    --lua                  Generate Lua wrappers
    --modula3              Generate Modula 3 wrappers
    --mzscheme             Generate Mzscheme wrappers
    --ocaml                Generate Ocaml wrappers
    --octave               Generate Octave wrappers
    --perl                 Generate Perl wrappers
    --php7                 Generate PHP7 wrappers
    --pike                 Generate Pike wrappers
    --python               Generate Python wrappers
    --r                    Generate R (aka GNU S) wrappers
    --ruby                 Generate Ruby wrappers
    --scilab               Generate Scilab wrappers
    --sexp                 Generate Lisp S-Expressions wrappers
    --tcl                  Generate Tcl wrappers
    --uffi                 Generate Common Lisp / UFFI wrappers
    --xml                  Generate XML wrappers
    +Supported Target Language Options
    +     -allegrocl      - Generate ALLEGROCL wrappers
    +     -chicken        - Generate CHICKEN wrappers
    +     -clisp          - Generate CLISP wrappers
    +     -cffi           - Generate CFFI wrappers
    +     -csharp         - Generate C# wrappers
    +     -d              - Generate D wrappers
    +     -go             - Generate Go wrappers
    +     -guile          - Generate Guile wrappers
    +     -java           - Generate Java wrappers
    +     -javascript     - Generate Javascript wrappers
    +     -lua            - Generate Lua wrappers
    +     -modula3        - Generate Modula 3 wrappers
    +     -mzscheme       - Generate Mzscheme wrappers
    +     -ocaml          - Generate Ocaml wrappers
    +     -octave         - Generate Octave wrappers
    +     -perl           - Generate Perl wrappers
    +     -php7           - Generate PHP7 wrappers
    +     -pike           - Generate Pike wrappers
    +     -python         - Generate Python wrappers
    +     -r              - Generate R (aka GNU S) wrappers
    +     -ruby           - Generate Ruby wrappers
    +     -scilab         - Generate Scilab wrappers
    +     -sexp           - Generate Lisp S-Expressions wrappers
    +     -tcl            - Generate Tcl wrappers
    +     -uffi           - Generate Common Lisp / UFFI wrappers
    +     -xml            - Generate XML wrappers
     
    --c++                  Enable C++ processing
    --cppext ext           Change file extension of C++ generated files to ext
    -                      (default is cxx)
    --Dsymbol              Define a preprocessor symbol
    --Fmicrosoft           Display error/warning messages in Microsoft format
    --Fstandard            Display error/warning messages in commonly used format
    --help                 Display all options
    --Idir                 Add a directory to the file include path
    --lifile               Include SWIG library file <ifile>
    --module name          Set the name of the SWIG module
    --o outfile            Set name of C/C++ output file to <outfile>
    --oh headfile          Set name of C++ output header file for directors to <headfile>
    --outcurrentdir        Set default output dir to current dir instead of input file's path
    --outdir dir           Set language specific files output directory
    --pcreversion          Display PCRE version information
    --swiglib              Report location of SWIG library and exit
    --version              Display SWIG version number
    +Experimental Target Language Options
     
    +General Options
    +     -addextern      - Add extra extern declarations
    +     -c++            - Enable C++ processing
    +     -co <file>      - Check <file> out of the SWIG library
    +     -copyctor       - Automatically generate copy constructors wherever possible
    +     -cpperraswarn   - Treat the preprocessor #error statement as #warning (default)
    +     -cppext <ext>   - Change file extension of generated C++ files to <ext>
    +                       (default is cxx)
    +     -copyright      - Display copyright notices
    +     -debug-classes  - Display information about the classes found in the interface
    +     -debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages
    +     -debug-symtabs  - Display symbol tables information
    +     -debug-symbols  - Display target language symbols in the symbol tables
    +     -debug-csymbols - Display C symbols in the symbol tables
    +     -debug-lsymbols - Display target language layer symbols
    +     -debug-tags     - Display information about the tags found in the interface
    +     -debug-template - Display information for debugging templates
    +     -debug-top <n>  - Display entire parse tree at stages 1-4, <n> is a csv list of stages
    +     -debug-typedef  - Display information about the types and typedefs in the interface
    +     -debug-typemap  - Display typemap debugging information
    +     -debug-tmsearch - Display typemap search debugging information
    +     -debug-tmused   - Display typemaps used debugging information
    +     -directors      - Turn on director mode for all the classes, mainly for testing
    +     -dirprot        - Turn on wrapping of protected members for director classes (default)
    +     -D<symbol>      - Define a symbol <symbol> (for conditional compilation)
    +     -E              - Preprocess only, does not generate wrapper code
    +     -external-runtime [file] - Export the SWIG runtime stack
    +     -fakeversion <v>- Make SWIG fake the program version number to <v>
    +     -fcompact       - Compile in compact mode
    +     -features <list>- Set global features, where <list> is a comma separated list of
    +                       features, eg -features directors,autodoc=1
    +                       If no explicit value is given to the feature, a default of 1 is used
    +     -fastdispatch   - Enable fast dispatch mode to produce faster overload dispatcher code
    +     -Fmicrosoft     - Display error/warning messages in Microsoft format
    +     -Fstandard      - Display error/warning messages in commonly used format
    +     -fvirtual       - Compile in virtual elimination mode
    +     -help           - Display help
    +     -I-             - Don't search the current directory
    +     -I<dir>         - Look for SWIG files in directory <dir>
    +     -ignoremissing  - Ignore missing include files
    +     -importall      - Follow all #include statements as imports
    +     -includeall     - Follow all #include statements
    +     -l<ifile>       - Include SWIG library file <ifile>
    +     -macroerrors    - Report errors inside macros
    +     -makedefault    - Create default constructors/destructors (the default)
    +     -M              - List all dependencies
    +     -MD             - Is equivalent to `-M -MF <file>', except `-E' is not implied
    +     -MF <file>      - Generate dependencies into <file> and continue generating wrappers
    +     -MM             - List dependencies, but omit files in SWIG library
    +     -MMD            - Like `-MD', but omit files in SWIG library
    +     -module <name>  - Set module name to <name>
    +     -MP             - Generate phony targets for all dependencies
    +     -MT <target>    - Set the target of the rule emitted by dependency generation
    +     -nocontract     - Turn off contract checking
    +     -nocpperraswarn - Do not treat the preprocessor #error statement as #warning
    +     -nodefault      - Do not generate default constructors nor default destructors
    +     -nodefaultctor  - Do not generate implicit default constructors
    +     -nodefaultdtor  - Do not generate implicit default destructors
    +     -nodirprot      - Do not wrap director protected members
    +     -noexcept       - Do not wrap exception specifiers
    +     -nofastdispatch - Disable fast dispatch mode (default)
    +     -nopreprocess   - Skip the preprocessor step
    +     -notemplatereduce - Disable reduction of the typedefs in templates
    +     -O              - Enable the optimization options:
    +                        -fastdispatch -fvirtual
    +     -o <outfile>    - Set name of C/C++ output file to <outfile>
    +     -oh <headfile>  - Set name of C++ output header file for directors to <headfile>
    +     -outcurrentdir  - Set default output dir to current dir instead of input file's path
    +     -outdir <dir>   - Set language specific files output directory to <dir>
    +     -pcreversion    - Display PCRE version information
    +     -small          - Compile in virtual elimination and compact mode
    +     -swiglib        - Report location of SWIG library and exit
    +     -templatereduce - Reduce all the typedefs in templates
    +     -v              - Run in verbose mode
    +     -version        - Display SWIG version number
    +     -Wall           - Remove all warning suppression, also implies -Wextra
    +     -Wallkw         - Enable keyword warnings for all the supported languages
    +     -Werror         - Treat warnings as errors
    +     -Wextra         - Adds the following additional warnings: 202,309,403,405,512,321,322
    +     -w<list>        - Suppress/add warning messages, eg -w401,+321 - see Warnings.html
    +     -xmlout <file>  - Write XML version of the parse tree to <file> after normal processing
     

    diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 58cc4f7d3..e302241bd 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -97,7 +97,7 @@ static const char *usage2 = (const char *) "\ -Fmicrosoft - Display error/warning messages in Microsoft format\n\ -Fstandard - Display error/warning messages in commonly used format\n\ -fvirtual - Compile in virtual elimination mode\n\ - -help - This output\n\ + -help - Display help\n\ -I- - Don't search the current directory\n\ -I

    - Look for SWIG files in directory \n\ -ignoremissing - Ignore missing include files\n\ @@ -130,14 +130,14 @@ static const char *usage3 = (const char *) "\ "; static const char *usage4 = (const char *) "\ - -O - Enable the optimization options: \n\ - -fastdispatch -fvirtual \n\ + -O - Enable the optimization options:\n\ + -fastdispatch -fvirtual\n\ -o - Set name of C/C++ output file to \n\ -oh - Set name of C++ output header file for directors 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\ -pcreversion - Display PCRE version information\n\ - -small - Compile in virtual elimination & compact mode\n\ + -small - Compile in virtual elimination and compact mode\n\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ -v - Run in verbose mode\n\ @@ -155,9 +155,9 @@ Options can also be defined using the SWIG_FEATURES environment variable, for ex $ export SWIG_FEATURES\n\ $ swig -python interface.i\n\ \n\ -is equivalent to: \n\ +is equivalent to:\n\ \n\ - $ swig -Wall -python interface.i \n\ + $ swig -Wall -python interface.i\n\ \n\ Arguments may also be passed in a file, separated by whitespace. For example:\n\ \n\ From 30f16b913843fa7696544f1e61c3d4a00fb11bc2 Mon Sep 17 00:00:00 2001 From: Jake Cobb Date: Mon, 4 Feb 2019 13:48:52 -0500 Subject: [PATCH 1348/2031] Python - Struct spec. for container owner Use a struct with specialization to dispatch the container owner reference function instead of a function. Avoids possible future problems if overloading were introduced. --- Lib/python/pycontainer.swg | 46 +++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 34bf3c110..ec31bad0d 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -48,28 +48,32 @@ namespace swig { return attr; } - // By default, do not add the back-reference (for value types) - // Specialization below will check the reference for pointer types. - template - bool reference_container_owner(PyObject* child, PyObject* owner) - { return false; } + template + struct container_owner { + // By default, do not add the back-reference (for value types) + // Specialization below will check the reference for pointer types. + static bool reference(PyObject* child, PyObject* owner) + { return false; } + }; - /** - * Call to add a back-reference to the owning object when returning a - * reference from a container. Will only set the reference if child - * is a SWIG wrapper object that does not own the pointer. - * - * @return if the reference was set or not - */ template <> - bool reference_container_owner(PyObject* child, PyObject* owner) { - SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); - if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - PyObject_SetAttr(child, container_owner_attribute(), owner); - return true; + struct container_owner { + /** + * Call to add a back-reference to the owning object when returning a + * reference from a container. Will only set the reference if child + * is a SWIG wrapper object that does not own the pointer. + * + * @return if the reference was set or not + */ + static bool reference(PyObject* child, PyObject* owner) { + SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); + if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { + PyObject_SetAttr(child, container_owner_attribute(), owner); + return true; + } + return false; } - return false; - } + }; } } @@ -804,8 +808,8 @@ namespace swig return self->size(); } - %typemap(ret, fragment="reference_container_owner") value_type& { - swig::reference_container_owner::category>($result, $self); + %typemap(ret, fragment="reference_container_owner", noblock=1) value_type& { + (void)swig::container_owner::category>::reference($result, $self); } } %enddef From d06ffe1087c714d163c09e57f6f3c20ccbcd4922 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Mon, 4 Feb 2019 22:23:13 -0500 Subject: [PATCH 1349/2031] Legacy macros, protected iterator, typedefs --- Lib/java/std_map.i | 70 +++++++++++++++++++++++------------- Lib/java/std_set.i | 6 ++++ Lib/java/std_unordered_map.i | 54 +++++++++++++++------------- Lib/java/std_unordered_set.i | 6 ++++ 4 files changed, 87 insertions(+), 49 deletions(-) diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index d59ceb8fc..5b7517ad5 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -46,10 +46,10 @@ namespace std { -template > class map { +template > class map { -%typemap(javabase) std::map - "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>" +%typemap(javabase) std::map + "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>" %proxycode %{ @@ -65,7 +65,7 @@ template > return containsImpl(($typemap(jboxtype, KeyType))key); } - public $typemap(jboxtype, ValueType) get(Object key) { + public $typemap(jboxtype, MappedType) get(Object key) { if (!(key instanceof $typemap(jboxtype, KeyType))) { return null; } @@ -78,11 +78,11 @@ template > return null; } - public $typemap(jboxtype, ValueType) put($typemap(jboxtype, KeyType) key, - $typemap(jboxtype, ValueType) value) { + public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, + $typemap(jboxtype, MappedType) value) { Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { - $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + $typemap(jboxtype, MappedType) oldValue = itr.getValue(); itr.setValue(value); return oldValue; } else { @@ -91,14 +91,14 @@ template > } } - public $typemap(jboxtype, ValueType) remove(Object key) { + public $typemap(jboxtype, MappedType) remove(Object key) { if (!(key instanceof $typemap(jboxtype, KeyType))) { return null; } Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { - $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + $typemap(jboxtype, MappedType) oldValue = itr.getValue(); removeUnchecked(itr); return oldValue; } else { @@ -106,17 +106,17 @@ template > } } - public java.util.Set> entrySet() { - java.util.Set> setToReturn = - new java.util.HashSet>(); + public java.util.Set> entrySet() { + java.util.Set> setToReturn = + new java.util.HashSet>(); Iterator itr = begin(); final Iterator end = end(); while(itr.isNot(end)) { - setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>() { + setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { private Iterator iterator; - private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)> init(Iterator iterator) { + private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)> init(Iterator iterator) { this.iterator = iterator; return this; } @@ -125,12 +125,12 @@ template > return iterator.getKey(); } - public $typemap(jboxtype, ValueType) getValue() { + public $typemap(jboxtype, MappedType) getValue() { return iterator.getValue(); } - public $typemap(jboxtype, ValueType) setValue($typemap(jboxtype, ValueType) newValue) { - $typemap(jboxtype, ValueType) oldValue = iterator.getValue(); + public $typemap(jboxtype, MappedType) setValue($typemap(jboxtype, MappedType) newValue) { + $typemap(jboxtype, MappedType) oldValue = iterator.getValue(); iterator.setValue(newValue); return oldValue; } @@ -143,17 +143,24 @@ template > %} public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef KeyType key_type; + typedef MappedType mapped_type; + typedef Compare key_compare; + map(); - map(const map&); + map(const map&); struct iterator { + %typemap(javaclassmodifiers) iterator "protected class" %extend { - std::map::iterator getNextUnchecked() { - std::map::iterator copy = (*$self); + std::map::iterator getNextUnchecked() { + std::map::iterator copy = (*$self); return ++copy; } - bool isNot(const iterator other) const { + bool isNot(iterator other) const { return (*$self != other); } @@ -161,11 +168,11 @@ template > return (*$self)->first; } - ValueType getValue() const { + MappedType getValue() const { return (*$self)->second; } - void setValue(const ValueType& newValue) { + void setValue(const MappedType& newValue) { (*$self)->second = newValue; } } @@ -188,14 +195,27 @@ template > return (self->count(key) > 0); } - void putUnchecked(const KeyType& key, const ValueType& value) { + void putUnchecked(const KeyType& key, const MappedType& value) { (*self)[key] = value; } - void removeUnchecked(const std::map::iterator itr) { + void removeUnchecked(const std::map::iterator itr) { self->erase(itr); } } }; +// Legacy macros (deprecated) +%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) +#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary" +%enddef + +%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) +#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary" +%enddef + +%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) +#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary" +%enddef + } diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index de0c31fba..6f557f627 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -134,6 +134,7 @@ class set { public: struct iterator { + %typemap(javaclassmodifiers) iterator "protected class" %extend { void incrementUnchecked() { ++(*$self); @@ -149,6 +150,11 @@ class set { } }; + typedef KeyType key_type; + typedef KeyType value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + set(); set(const set&); diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index b0e8b3e40..405e0fba5 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -46,10 +46,10 @@ namespace std { -template class unordered_map { +template class unordered_map { -%typemap(javabase) std::unordered_map - "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>" +%typemap(javabase) std::unordered_map + "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>" %proxycode %{ @@ -65,7 +65,7 @@ template class unordered_map { return containsImpl(($typemap(jboxtype, KeyType))key); } - public $typemap(jboxtype, ValueType) get(Object key) { + public $typemap(jboxtype, MappedType) get(Object key) { if (!(key instanceof $typemap(jboxtype, KeyType))) { return null; } @@ -78,11 +78,11 @@ template class unordered_map { return null; } - public $typemap(jboxtype, ValueType) put($typemap(jboxtype, KeyType) key, - $typemap(jboxtype, ValueType) value) { + public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, + $typemap(jboxtype, MappedType) value) { Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { - $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + $typemap(jboxtype, MappedType) oldValue = itr.getValue(); itr.setValue(value); return oldValue; } else { @@ -91,14 +91,14 @@ template class unordered_map { } } - public $typemap(jboxtype, ValueType) remove(Object key) { + public $typemap(jboxtype, MappedType) remove(Object key) { if (!(key instanceof $typemap(jboxtype, KeyType))) { return null; } Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { - $typemap(jboxtype, ValueType) oldValue = itr.getValue(); + $typemap(jboxtype, MappedType) oldValue = itr.getValue(); removeUnchecked(itr); return oldValue; } else { @@ -106,17 +106,17 @@ template class unordered_map { } } - public java.util.Set> entrySet() { - java.util.Set> setToReturn = - new java.util.HashSet>(); + public java.util.Set> entrySet() { + java.util.Set> setToReturn = + new java.util.HashSet>(); Iterator itr = begin(); final Iterator end = end(); while(itr.isNot(end)) { - setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)>() { + setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { private Iterator iterator; - private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, ValueType)> init(Iterator iterator) { + private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)> init(Iterator iterator) { this.iterator = iterator; return this; } @@ -125,12 +125,12 @@ template class unordered_map { return iterator.getKey(); } - public $typemap(jboxtype, ValueType) getValue() { + public $typemap(jboxtype, MappedType) getValue() { return iterator.getValue(); } - public $typemap(jboxtype, ValueType) setValue($typemap(jboxtype, ValueType) newValue) { - $typemap(jboxtype, ValueType) oldValue = iterator.getValue(); + public $typemap(jboxtype, MappedType) setValue($typemap(jboxtype, MappedType) newValue) { + $typemap(jboxtype, MappedType) oldValue = iterator.getValue(); iterator.setValue(newValue); return oldValue; } @@ -143,13 +143,19 @@ template class unordered_map { %} public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef KeyType key_type; + typedef MappedType mapped_type; + unordered_map(); - unordered_map(const unordered_map&); + unordered_map(const unordered_map&); struct iterator { + %typemap(javaclassmodifiers) iterator "protected class" %extend { - std::unordered_map::iterator getNextUnchecked() { - std::unordered_map::iterator copy = (*$self); + std::unordered_map::iterator getNextUnchecked() { + std::unordered_map::iterator copy = (*$self); return ++copy; } @@ -161,11 +167,11 @@ template class unordered_map { return (*$self)->first; } - ValueType getValue() const { + MappedType getValue() const { return (*$self)->second; } - void setValue(const ValueType& newValue) { + void setValue(const MappedType& newValue) { (*$self)->second = newValue; } } @@ -188,11 +194,11 @@ template class unordered_map { return (self->count(key) > 0); } - void putUnchecked(const KeyType& key, const ValueType& value) { + void putUnchecked(const KeyType& key, const MappedType& value) { (*self)[key] = value; } - void removeUnchecked(const std::unordered_map::iterator itr) { + void removeUnchecked(const std::unordered_map::iterator itr) { self->erase(itr); } } diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index ca9af0f19..b408c47de 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -134,6 +134,7 @@ class unordered_set { public: struct iterator { + %typemap(javaclassmodifiers) iterator "protected class" %extend { void incrementUnchecked() { ++(*$self); @@ -149,6 +150,11 @@ class unordered_set { } }; + typedef KeyType key_type; + typedef KeyType value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + unordered_set(); unordered_set(const unordered_set&); From ee3aeb81777084ec54a8c65a24d5967a654b382b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 19:29:39 +0000 Subject: [PATCH 1350/2031] Disable Modula3 target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++++ Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Doc/Manual/Sections.html | 1 - Doc/Manual/chapters | 1 - Examples/Makefile.in | 39 ------------------------------------ Makefile.in | 10 +-------- README | 2 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +-- configure.ac | 4 ---- 12 files changed, 8 insertions(+), 61 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 109cf9216..fccccb201 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -11,7 +11,7 @@ SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), -D, Ocaml, Pike, Modula-3, Octave, R, Scilab, Common Lisp (CLISP, +D, Ocaml, Pike, Octave, R, Scilab, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in the form of XML and Lisp s-expressions. Major applications of SWIG include generation of scripting language extension modules, rapid diff --git a/CHANGES.current b/CHANGES.current index 7b685b74a..9c95ba63f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [Modula3] #1447 Modula3 has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-02: ahnolds [Python] Documentation enhancements for Python: diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 83a17f2c4..7969f3e53 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -120,7 +120,6 @@ SWIGJAVASCRIPT Defined when using Javascript SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js 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 diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index bb1ac7dea..2296d6a81 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -129,7 +129,6 @@ Supported Target Language Options -java - Generate Java wrappers -javascript - Generate Javascript wrappers -lua - Generate Lua wrappers - -modula3 - Generate Modula 3 wrappers -mzscheme - Generate Mzscheme wrappers -ocaml - Generate Ocaml wrappers -octave - Generate Octave wrappers diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index d103f42a5..3eea38526 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -50,7 +50,6 @@ Last update : SWIG-4.0.0 (in progress)
  • Javascript support
  • Common Lisp support
  • Lua support
  • -
  • Modula3 support
  • MzScheme/Racket support
  • Ocaml support
  • Octave support
  • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 056f6136c..cfa504104 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -28,7 +28,6 @@ Java.html Javascript.html Lisp.html Lua.html -Modula3.html Mzscheme.html Ocaml.html Octave.html diff --git a/Examples/Makefile.in b/Examples/Makefile.in index e0f1ce20d..a5a0e9477 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -805,45 +805,6 @@ android_clean: rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` rm -rf obj -################################################################## -##### MODULA3 ###### -################################################################## - -MODULA3_INCLUDE= @MODULA3INC@ - -# ---------------------------------------------------------------- -# Build a modula3 dynamically loadable module (C) -# ---------------------------------------------------------------- - -modula3: $(SRCDIR_SRCS) - $(SWIG) -modula3 $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - -modula3_cpp: $(SRCDIR_SRCS) - $(SWIG) -modula3 -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - -# ----------------------------------------------------------------- -# Run modula3 example -# ----------------------------------------------------------------- - -modula3_run: - $(RUNTOOL) false $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -modula3_version: - echo "Unknown modula3 version" - -# ----------------------------------------------------------------- -# Cleaning the modula3 examples -# ----------------------------------------------------------------- - -modula3_clean: - rm -f *_wrap* *.i3 *.m3 - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *@SO@ - ################################################################## ##### MZSCHEME ###### ################################################################## diff --git a/Makefile.in b/Makefile.in index 3394f49dc..5e537715d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -72,7 +72,6 @@ skip-octave = test -n "@SKIP_OCTAVE@" skip-pike = test -n "@SKIP_PIKE@" skip-chicken = test -n "@SKIP_CHICKEN@" skip-csharp = test -n "@SKIP_CSHARP@" -skip-modula3 = test -n "@SKIP_MODULA3@" skip-lua = test -n "@SKIP_LUA@" skip-allegrocl = test -n "@SKIP_ALLEGROCL@" skip-clisp = test -n "@SKIP_CLISP@" @@ -120,7 +119,6 @@ check-aliveness: @$(skip-pike) || ./$(TARGET) -pike -help @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help - @$(skip-modula3) || ./$(TARGET) -modula3 -help @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help @$(skip-clisp) || ./$(TARGET) -clisp -help @$(skip-uffi) || ./$(TARGET) -uffi -help @@ -152,7 +150,6 @@ check-versions: \ check-pike-version \ check-chicken-version \ check-csharp-version \ - check-modula3-version \ check-lua-version \ check-allegrocl-version \ check-clisp-version \ @@ -192,7 +189,6 @@ check-examples: \ check-pike-examples \ check-chicken-examples \ check-csharp-examples \ - check-modula3-examples \ check-lua-examples \ check-allegrocl-examples \ check-clisp-examples \ @@ -218,7 +214,6 @@ php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/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) -modula3_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/modula3/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) allegrocl_examples := clisp_examples := @@ -265,7 +260,6 @@ check-test-suite: \ check-php-test-suite \ check-pike-test-suite \ check-csharp-test-suite \ - check-modula3-test-suite \ check-lua-test-suite \ check-allegrocl-test-suite \ check-clisp-test-suite \ @@ -319,7 +313,6 @@ all-test-suite: \ all-php-test-suite \ all-pike-test-suite \ all-csharp-test-suite \ - all-modula3-test-suite \ all-lua-test-suite \ all-allegrocl-test-suite \ all-clisp-test-suite \ @@ -349,7 +342,6 @@ broken-test-suite: \ broken-php-test-suite \ broken-pike-test-suite \ broken-csharp-test-suite \ - broken-modula3-test-suite \ broken-lua-test-suite \ broken-allegrocl-test-suite \ broken-clisp-test-suite \ @@ -492,7 +484,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ + pike chicken csharp allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index 649602048..5fcfc3fe3 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, - Ocaml, Modula-3, Common Lisp (CLISP, Allegro CL, CFFI, UFFI) + Ocaml, Common Lisp (CLISP, Allegro CL, CFFI, UFFI) and Pike. SWIG can also export its parse tree into XML and Lisp s-expressions. diff --git a/Source/Makefile.am b/Source/Makefile.am index 8b76694e8..78c580d35 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -64,7 +64,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/lang.cxx \ Modules/lua.cxx \ Modules/main.cxx \ - Modules/modula3.cxx \ Modules/mzscheme.cxx \ Modules/nested.cxx \ Modules/ocaml.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 6f91c083e..a916cf5d0 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -37,7 +37,6 @@ extern "C" { Language *swig_java(void); Language *swig_javascript(void); Language *swig_lua(void); - Language *swig_modula3(void); Language *swig_mzscheme(void); Language *swig_ocaml(void); Language *swig_octave(void); @@ -72,7 +71,7 @@ static TargetLanguageModule modules[] = { {"-java", swig_java, "Java", Supported}, {"-javascript", swig_javascript, "Javascript", Supported}, {"-lua", swig_lua, "Lua", Supported}, - {"-modula3", swig_modula3, "Modula 3", Supported}, + {"-modula3", NULL, "Modula 3", Disabled}, {"-mzscheme", swig_mzscheme, "Mzscheme", Supported}, {"-ocaml", swig_ocaml, "Ocaml", Supported}, {"-octave", swig_octave, "Octave", Supported}, diff --git a/configure.ac b/configure.ac index b2644762a..936895ef7 100644 --- a/configure.ac +++ b/configure.ac @@ -2888,9 +2888,6 @@ else fi AC_SUBST(SKIP_CSHARP) -SKIP_MODULA3="1" # Always skipped! -AC_SUBST(SKIP_MODULA3) - SKIP_LUA= # we need LUABIN & dynamic loading if test -z "$LUABIN" || test -z "$LUADYNAMICLOADLIB"; then @@ -3114,7 +3111,6 @@ test -n "$SKIP_GUILE" || langs="${langs}guile " test -n "$SKIP_JAVA" || langs="${langs}java " test -n "$SKIP_JAVASCRIPT" || langs="${langs}javascript " test -n "$SKIP_LUA" || langs="${langs}lua " -test -n "$SKIP_MODULA3" || langs="${langs}modula3 " test -n "$SKIP_MZSCHEME" || langs="${langs}mzscheme " test -n "$SKIP_OCAML" || langs="${langs}ocaml " test -n "$SKIP_OCTAVE" || langs="${langs}octave " From 8aa4086136f8bd1564fc9ce6082d81ce3168482e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 19:48:25 +0000 Subject: [PATCH 1351/2031] Disable Pike target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++ Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Doc/Manual/Sections.html | 1 - Doc/Manual/chapters | 1 - Examples/Makefile.in | 72 ---------------------------------- Lib/allkw.swg | 1 - Makefile.in | 10 +---- README | 4 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +- TODO | 12 ------ configure.ac | 75 ------------------------------------ 14 files changed, 9 insertions(+), 179 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index fccccb201..2caaaea71 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -11,7 +11,7 @@ SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), -D, Ocaml, Pike, Octave, R, Scilab, Common Lisp (CLISP, +D, Ocaml, Octave, R, Scilab, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in the form of XML and Lisp s-expressions. Major applications of SWIG include generation of scripting language extension modules, rapid diff --git a/CHANGES.current b/CHANGES.current index 9c95ba63f..e9a2ef895 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [Pike] #1447 Pike has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [Modula3] #1447 Modula3 has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 7969f3e53..68b6af862 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -126,7 +126,6 @@ SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl SWIGPHP Defined when using PHP (any version) SWIGPHP7 Defined when using PHP7 -SWIGPIKE Defined when using Pike SWIGPYTHON Defined when using Python SWIGR Defined when using R SWIGRUBY Defined when using Ruby diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 2296d6a81..0906836db 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -134,7 +134,6 @@ Supported Target Language Options -octave - Generate Octave wrappers -perl - Generate Perl wrappers -php7 - Generate PHP7 wrappers - -pike - Generate Pike wrappers -python - Generate Python wrappers -r - Generate R (aka GNU S) wrappers -ruby - Generate Ruby wrappers diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 3eea38526..f3844365e 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -55,7 +55,6 @@ Last update : SWIG-4.0.0 (in progress)
  • Octave support
  • Perl5 support
  • PHP support
  • -
  • Pike support
  • Python support
  • R support
  • Ruby support
  • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index cfa504104..cae1c5366 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -33,7 +33,6 @@ Ocaml.html Octave.html Perl5.html Php.html -Pike.html Python.html R.html Ruby.html diff --git a/Examples/Makefile.in b/Examples/Makefile.in index a5a0e9477..fff85f5f7 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1081,78 +1081,6 @@ php_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(PHP_SO) -################################################################## -##### Pike ###### -################################################################## - -# Make sure these locate your Pike installation -PIKE = pike -PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H -PIKE_INCLUDE = @PIKEINCLUDE@ -PIKE_LIB = @PIKELIB@ -PIKE_DLNK = @PIKEDYNAMICLINKING@ -PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) -PIKE_SCRIPT = $(RUNME).pike - -# ---------------------------------------------------------------- -# Build a C dynamically loadable module -# ---------------------------------------------------------------- - -pike: $(SRCDIR_SRCS) - $(SWIG) -pike $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(PIKE_INCLUDE) - $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - -# ----------------------------------------------------------------- -# Build a C++ dynamically loadable module -# ----------------------------------------------------------------- - -pike_cpp: $(SRCDIR_SRCS) - $(SWIG) -c++ -pike $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) - $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - -# ----------------------------------------------------------------- -# Build statically linked Pike interpreter -# -# These should only be used in conjunction with the %include embed.i -# library file -# ----------------------------------------------------------------- - -pike_static: $(SRCDIR_SRCS) - $(SWIG) -pike -lembed.i $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) \ - $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) - -pike_cpp_static: $(SRCDIR_SRCS) - $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) \ - $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) - -# ----------------------------------------------------------------- -# Run pike example -# ----------------------------------------------------------------- - -pike_run: - $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -pike_version: - $(PIKE) -v 2>&1 | head -n 1 - -# ----------------------------------------------------------------- -# Cleaning the Pike examples -# ----------------------------------------------------------------- - -pike_clean: - rm -f *_wrap* *~ .~* mypike@EXEEXT@ - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *@SO@ - - ################################################################## ##### Chicken ###### ################################################################## diff --git a/Lib/allkw.swg b/Lib/allkw.swg index 563190e19..2de1a12dd 100644 --- a/Lib/allkw.swg +++ b/Lib/allkw.swg @@ -25,7 +25,6 @@ %include %include %include -%include %include %include %include diff --git a/Makefile.in b/Makefile.in index 5e537715d..b9e926108 100644 --- a/Makefile.in +++ b/Makefile.in @@ -69,7 +69,6 @@ skip-ruby = test -n "@SKIP_RUBY@" skip-php = test -n "@SKIP_PHP@" skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" -skip-pike = test -n "@SKIP_PIKE@" skip-chicken = test -n "@SKIP_CHICKEN@" skip-csharp = test -n "@SKIP_CSHARP@" skip-lua = test -n "@SKIP_LUA@" @@ -116,7 +115,6 @@ check-aliveness: @$(skip-ocaml) || ./$(TARGET) -ocaml -help @$(skip-octave) || ./$(TARGET) -octave -help @$(skip-php) || ./$(TARGET) -php7 -help - @$(skip-pike) || ./$(TARGET) -pike -help @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help @@ -147,7 +145,6 @@ check-versions: \ check-ocaml-version \ check-octave-version \ check-php-version \ - check-pike-version \ check-chicken-version \ check-csharp-version \ check-lua-version \ @@ -186,7 +183,6 @@ check-examples: \ check-ocaml-examples \ check-octave-examples \ check-php-examples \ - check-pike-examples \ check-chicken-examples \ check-csharp-examples \ check-lua-examples \ @@ -211,7 +207,6 @@ 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) -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) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) @@ -258,7 +253,6 @@ check-test-suite: \ check-ocaml-test-suite \ check-octave-test-suite \ check-php-test-suite \ - check-pike-test-suite \ check-csharp-test-suite \ check-lua-test-suite \ check-allegrocl-test-suite \ @@ -311,7 +305,6 @@ all-test-suite: \ all-ocaml-test-suite \ all-octave-test-suite \ all-php-test-suite \ - all-pike-test-suite \ all-csharp-test-suite \ all-lua-test-suite \ all-allegrocl-test-suite \ @@ -340,7 +333,6 @@ broken-test-suite: \ broken-ocaml-test-suite \ broken-octave-test-suite \ broken-php-test-suite \ - broken-pike-test-suite \ broken-csharp-test-suite \ broken-lua-test-suite \ broken-allegrocl-test-suite \ @@ -484,7 +476,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - pike chicken csharp allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ + chicken csharp allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index 5fcfc3fe3..c0c3808d1 100644 --- a/README +++ b/README @@ -5,8 +5,8 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, - Ocaml, Common Lisp (CLISP, Allegro CL, CFFI, UFFI) - and Pike. SWIG can also export its parse tree into XML and + Ocaml, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). + SWIG can also export its parse tree into XML and Lisp s-expressions. SWIG reads annotated C/C++ header files and creates wrapper code (glue diff --git a/Source/Makefile.am b/Source/Makefile.am index 78c580d35..e9802c520 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -71,7 +71,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/overload.cxx \ Modules/perl5.cxx \ Modules/php.cxx \ - Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ Modules/ruby.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index a916cf5d0..8cc20f660 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -44,7 +44,6 @@ extern "C" { Language *swig_php(void); Language *swig_php4(void); Language *swig_php5(void); - Language *swig_pike(void); Language *swig_python(void); Language *swig_r(void); Language *swig_ruby(void); @@ -81,7 +80,7 @@ static TargetLanguageModule modules[] = { {"-php4", swig_php4, NULL, Supported}, {"-php5", swig_php5, NULL, Supported}, {"-php7", swig_php, "PHP7", Supported}, - {"-pike", swig_pike, "Pike", Supported}, + {"-pike", NULL, "Pike", Disabled}, {"-python", swig_python, "Python", Supported}, {"-r", swig_r, "R (aka GNU S)", Supported}, {"-ruby", swig_ruby, "Ruby", Supported}, diff --git a/TODO b/TODO index 01d9a8d78..97e5319dd 100644 --- a/TODO +++ b/TODO @@ -275,18 +275,6 @@ Mzscheme ** Add shadow class support for the Swindle system. -Pike ----- - -* Decide how to handle global variables (probably using something - like the Python module's cvar). Affects Examples/pike/simple. - -* Decide how to handle static class member functions and member - variables. - -* Should investigate the possibility of generating .cmod files - in addition to straight C/C++ code for extensions. - Common Lisp ----------- diff --git a/configure.ac b/configure.ac index 936895ef7..713b4b90f 100644 --- a/configure.ac +++ b/configure.ac @@ -2084,72 +2084,6 @@ AC_SUBST(OCAMLFIND) AC_SUBST(OCAMLMKTOP) AC_SUBST(CAMLP4) -#---------------------------------------------------------------- -# Look for Pike -#---------------------------------------------------------------- - -# Identify the name of the Pike executable -# Priority: configure option, automatic search -PIKEBIN= -AC_ARG_WITH(pike, AS_HELP_STRING([--without-pike], [Disable Pike]) -AS_HELP_STRING([--with-pike=path], [Set location of Pike executable]),[PIKEBIN="$withval"], [PIKEBIN="$alllang_default"]) - -# First, check for "--without-pike" or "--with-pike=no". -if test x"${PIKEBIN}" = xno; then - AC_MSG_NOTICE([Disabling Pike]) - PIKEBIN= -else - -if test "x$PIKEBIN" = xyes; then - AC_CHECK_PROGS(PIKE, pike pike7.8 pike7.6 pike7.4 pike7.2) -else - PIKE="$PIKEBIN" -fi - - -# Check for pike-config -# Priority: configure option, guessed from $PIKE, search from list -AC_ARG_WITH(pike-config, AS_HELP_STRING([--with-pike-config=path], - [Set location of pike-config script]), - [PIKECONFIG="$withval"], [PIKECONFIG=""]) - -if test -z "$PIKECONFIG" -a -n "$PIKE"; then - AC_CHECK_PROGS(PIKECONFIG, $PIKE-config pike-config \ - pike7.6-config pike7.4-config pike7.2-config) -fi - -# Check for a --with-pikeincl option to configure -# Priority: configure option, info from $PIKECONFIG, guessed by pike script -AC_ARG_WITH(pikeincl, AS_HELP_STRING([--with-pikeincl=path], - [Set location of Pike include directory]), - [PIKEINCLUDE="-I$withval"], [PIKEINCLUDE=]) - -if test -n "$PIKE"; then - AC_MSG_CHECKING([for Pike header files]) - if test -z "$PIKEINCLUDE" -a -n "$PIKECONFIG"; then - PIKEINCLUDE=`$PIKECONFIG --cflags` - fi - if test -z "$PIKEINCLUDE" -a -n "$PIKE"; then - PIKEINCLUDE=`$PIKE -x cflags` - if test -z "$PIKEINCLUDE"; then - PIKEPATH=`which $PIKE` - PIKEINCLUDE=`$PIKE Tools/check-include-path.pike $PIKEPATH` - PIKEINCLUDE="-I$PIKEINCLUDE" - fi - fi - - if test -z "$PIKEINCLUDE"; then - AC_MSG_RESULT(not found) - else - AC_MSG_RESULT($PIKEINCLUDE) - fi -fi -fi - -AC_SUBST(PIKEINCLUDE) -AC_SUBST(PIKECCDLFLAGS) dnl XXX: where is this used/defined? -AC_SUBST(PIKEDYNAMICLINKING) dnl XXX: where is this used/defined? - #---------------------------------------------------------------- # Look for CHICKEN #---------------------------------------------------------------- @@ -2864,13 +2798,6 @@ fi AC_SUBST(SKIP_OCAML) -SKIP_PIKE= -if test -z "$PIKE" || test -z "$PIKEINCLUDE" ; then - SKIP_PIKE="1" -fi -AC_SUBST(SKIP_PIKE) - - SKIP_CHICKEN= if test -z "$CHICKEN_CSC" || test -z "$CHICKEN"; then SKIP_CHICKEN="1" @@ -3043,7 +2970,6 @@ AC_CONFIG_FILES([ Examples/test-suite/octave/Makefile Examples/test-suite/perl5/Makefile Examples/test-suite/php/Makefile - Examples/test-suite/pike/Makefile Examples/test-suite/python/Makefile Examples/test-suite/ruby/Makefile Examples/test-suite/scilab/Makefile @@ -3116,7 +3042,6 @@ test -n "$SKIP_OCAML" || langs="${langs}ocaml " test -n "$SKIP_OCTAVE" || langs="${langs}octave " test -n "$SKIP_PERL5" || langs="${langs}perl5 " test -n "$SKIP_PHP" || langs="${langs}php " -test -n "$SKIP_PIKE" || langs="${langs}pike " test -n "$SKIP_PYTHON" || langs="${langs}python " test -n "$SKIP_R" || langs="${langs}r " test -n "$SKIP_RUBY" || langs="${langs}ruby " From f63d0db21b84629e5e7f3b5a5b5b3676235ed3de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 20:01:05 +0000 Subject: [PATCH 1352/2031] Disable Common Lisp / UFFI target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++++ Doc/Manual/Allegrocl.html | 2 +- Doc/Manual/Lisp.html | 10 +++----- Doc/Manual/SWIG.html | 1 - Examples/Makefile.in | 40 ------------------------------- Makefile.in | 10 +------- README | 2 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +-- TODO | 48 ------------------------------------- configure.ac | 8 ------- 12 files changed, 12 insertions(+), 119 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 2caaaea71..3fc3b3517 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -12,7 +12,7 @@ generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Octave, R, Scilab, Common Lisp (CLISP, -Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in +Allegro CL, CFFI). SWIG can also export its parse tree in the form of XML and Lisp s-expressions. Major applications of SWIG include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large diff --git a/CHANGES.current b/CHANGES.current index e9a2ef895..b6651d762 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [UFFI] #1447 Common Lisp UFFI has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [Pike] #1447 Pike has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index a3d631ec4..4069ecd8b 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -129,7 +129,7 @@ It is significant to note that, while this is a vendor-specific module, we would like to acknowledge the current and ongoing work by developers in the open source lisp community that are working on similar interfaces to implementation-independent -foreign function interfaces (UFFI or CFFI, for example). Such +foreign function interfaces (CFFI, for example). Such work can only benefit the lisp community, and we would not be unhappy to see some enterprising folk use this work to add to it. diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 2d65f883b..1e7996581 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -24,7 +24,6 @@
  • Additional Commandline Options
  • Details on CLISP bindings -
  • UFFI @@ -39,7 +38,7 @@ There are more than 9 different implementations of common lisp which are available, all have different foreign function interfaces. SWIG currently supports only the Allegro Common - Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI + Lisp, Common Foreign Function Interface(CFFI), CLisp foreign function interfaces.

    29.1 Allegro Common Lisp

    @@ -56,8 +55,8 @@

    CFFI, the Common Foreign Function Interface, is a portable foreign - function interface for ANSI Common Lisp systems, similar in - spirit to UFFI. Unlike UFFI, CFFI requires only a small set of + function interface for ANSI Common Lisp systems. + CFFI requires only a small set of low-level functionality from the Lisp implementation, such as calling a foreign function by name, allocating foreign memory, and dereferencing pointers. @@ -809,8 +808,5 @@ struct bar { -

    29.4 UFFI

    - - diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 0906836db..f1e441c8a 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -140,7 +140,6 @@ Supported Target Language Options -scilab - Generate Scilab wrappers -sexp - Generate Lisp S-Expressions wrappers -tcl - Generate Tcl wrappers - -uffi - Generate Common Lisp / UFFI wrappers -xml - Generate XML wrappers Experimental Target Language Options diff --git a/Examples/Makefile.in b/Examples/Makefile.in index fff85f5f7..d070e3c8e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1467,46 +1467,6 @@ cffi_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ -################################################################## -##### UFFI ###### -################################################################## - -UFFI = @UFFIBIN@ -UFFI_SCRIPT=$(RUNME).lisp - -uffi: $(SRCDIR_SRCS) - $(SWIG) -uffi $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) -# $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCDIR_SRCS) -# $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - -uffi_cpp: $(SRCDIR_SRCS) - $(SWIG) -c++ -uffi $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) -# $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) -# $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) - -# ----------------------------------------------------------------- -# Run UFFI example -# ----------------------------------------------------------------- - -uffi_run: - $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -uffi_version: - $(UFFI) --version - -# ----------------------------------------------------------------- -# Cleaning the UFFI examples -# ----------------------------------------------------------------- - -uffi_clean: - rm -f *_wrap* *~ .~* - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *@SO@ - ################################################################## ##### R ###### ################################################################## diff --git a/Makefile.in b/Makefile.in index b9e926108..a45684a1d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -75,7 +75,6 @@ skip-lua = test -n "@SKIP_LUA@" skip-allegrocl = test -n "@SKIP_ALLEGROCL@" skip-clisp = test -n "@SKIP_CLISP@" skip-cffi = test -n "@SKIP_CFFI@" -skip-uffi = test -n "@SKIP_UFFI@" skip-r = test -n "@SKIP_R@" skip-scilab = test -n "@SKIP_SCILAB@" skip-go = test -n "@SKIP_GO@" @@ -119,7 +118,6 @@ check-aliveness: @$(skip-csharp) || ./$(TARGET) -csharp -help @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help @$(skip-clisp) || ./$(TARGET) -clisp -help - @$(skip-uffi) || ./$(TARGET) -uffi -help @$(skip-cffi) || ./$(TARGET) -cffi -help @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help @@ -150,7 +148,6 @@ check-versions: \ check-lua-version \ check-allegrocl-version \ check-clisp-version \ - check-uffi-version \ check-cffi-version \ check-r-version \ check-scilab-version \ @@ -188,7 +185,6 @@ check-examples: \ check-lua-examples \ check-allegrocl-examples \ check-clisp-examples \ - check-uffi-examples \ check-cffi-examples \ check-r-examples \ check-scilab-examples \ @@ -212,7 +208,6 @@ csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) allegrocl_examples := clisp_examples := -uffi_examples := cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) scilab_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/scilab/check.list) @@ -257,7 +252,6 @@ check-test-suite: \ check-lua-test-suite \ check-allegrocl-test-suite \ check-clisp-test-suite \ - check-uffi-test-suite \ check-cffi-test-suite \ check-chicken-test-suite \ check-r-test-suite \ @@ -309,7 +303,6 @@ all-test-suite: \ all-lua-test-suite \ all-allegrocl-test-suite \ all-clisp-test-suite \ - all-uffi-test-suite \ all-cffi-test-suite \ all-chicken-test-suite \ all-r-test-suite \ @@ -337,7 +330,6 @@ broken-test-suite: \ broken-lua-test-suite \ broken-allegrocl-test-suite \ broken-clisp-test-suite \ - broken-uffi-test-suite \ broken-cffi-test-suite \ broken-chicken-test-suite \ broken-r-test-suite \ @@ -476,7 +468,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - chicken csharp allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \ + chicken csharp allegrocl clisp lua cffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index c0c3808d1..ea30d32f1 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, - Ocaml, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). + Ocaml, Common Lisp (CLISP, Allegro CL, CFFI). SWIG can also export its parse tree into XML and Lisp s-expressions. diff --git a/Source/Makefile.am b/Source/Makefile.am index e9802c520..820d50289 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -79,7 +79,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/swigmain.cxx \ Modules/tcl8.cxx \ Modules/typepass.cxx \ - Modules/uffi.cxx \ Modules/utils.cxx \ Modules/xml.cxx \ Preprocessor/cpp.c \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 8cc20f660..c56f73092 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -50,7 +50,6 @@ extern "C" { Language *swig_scilab(void); Language *swig_sexp(void); Language *swig_tcl(void); - Language *swig_uffi(void); Language *swig_xml(void); } @@ -88,7 +87,7 @@ static TargetLanguageModule modules[] = { {"-sexp", swig_sexp, "Lisp S-Expressions", Supported}, {"-tcl", swig_tcl, "Tcl", Supported}, {"-tcl8", swig_tcl, NULL, Supported}, - {"-uffi", swig_uffi, "Common Lisp / UFFI", Supported}, + {"-uffi", NULL, "Common Lisp / UFFI", Disabled}, {"-xml", swig_xml, "XML", Supported}, {NULL, NULL, NULL, Disabled} }; diff --git a/TODO b/TODO index 97e5319dd..bd573c652 100644 --- a/TODO +++ b/TODO @@ -275,54 +275,6 @@ Mzscheme ** Add shadow class support for the Swindle system. -Common Lisp ------------ - -* Random thoughts by mkoeppe on supporting Common Lisp implementations: - - There are many different Foreign Function Interfaces (FFI) for - the various CL implementations. Probably SWIG should interface - to UFFI, a least-common-denominator FFI that supports many - implementations. - - Via the s-expression SWIG module we can export SWIG's parse - tree and import it into CL. It remains to check if all - relevant information is dumped (for instance, the type - information). Experimental code is available to generate - low-level UFFI declarations from this parse tree. - - However, for wrapping C++, we also need to create C wrappers - because most FFIs cannot directly import C++. A CL SWIG module - could be exporting both these wrappers and UFFI declarations. - I have experimental code (not checked in yet) that does this. - - This is fine for generating low-level wrappers. But how do we - support user typemaps (like converting lists and vectors to C - arrays on input)? We have to generate Lisp code that does the - conversion and then calls the low-level wrapper. If we - generate Lisp code, it should be beautiful and readable. - Therefore, we need at least a Lisp pretty printer. A Lisp - pretty printer works best when the Lisp program is represented - not as text but as Lisp data. Moreover, typemap writers will - feel very much constrained by SWIG's capabilities for - generating wrapper code, when compared to writing Lisp macros. - Thus we would need half a re-implementation of Lisp in SWIG to - make users happy. - - The solution could be the following: - -** Build a SWIG library (again) and load it into a Common Lisp - implementation. - - The FFI declarations could be written manually, or this could - be bootstrapped via the s-expression module or the primitive - UFFI wrappers. This should be easy because SWIG's API is quite - simple. - - The embedded SWIG would be driven by a CL program. High-level - 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 diff --git a/configure.ac b/configure.ac index 713b4b90f..efdca9aea 100644 --- a/configure.ac +++ b/configure.ac @@ -2846,12 +2846,6 @@ SKIP_CFFI= #fi AC_SUBST(SKIP_CFFI) -SKIP_UFFI= -#if test -z "$UFFIBIN" ; then - SKIP_UFFI="1" -#fi -AC_SUBST(SKIP_UFFI) - SKIP_SCILAB= if test -z "$SCILAB"; then SKIP_SCILAB="1" @@ -2978,7 +2972,6 @@ AC_CONFIG_FILES([ Examples/test-suite/allegrocl/Makefile Examples/test-suite/clisp/Makefile Examples/test-suite/cffi/Makefile - Examples/test-suite/uffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile Source/Makefile @@ -3047,7 +3040,6 @@ test -n "$SKIP_R" || langs="${langs}r " test -n "$SKIP_RUBY" || langs="${langs}ruby " test -n "$SKIP_SCILAB" || langs="${langs}scilab " test -n "$SKIP_TCL" || langs="${langs}tcl " -test -n "$SKIP_UFFI" || langs="${langs}uffi " echo " The SWIG test-suite and examples are configured for the following languages: From df51dc8e8f70cc5c1d3609ff9eae4b9bc5e3b8a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 20:12:28 +0000 Subject: [PATCH 1353/2031] Disable Common Lisp / S-Exp target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++++ Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - README | 3 +-- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +-- swig.spec.in | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 3fc3b3517..0cfc1c1f1 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -13,7 +13,7 @@ from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Octave, R, Scilab, Common Lisp (CLISP, Allegro CL, CFFI). SWIG can also export its parse tree in -the form of XML and Lisp s-expressions. Major applications of SWIG +the form of XML. Major applications of SWIG include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large C/C++ systems. diff --git a/CHANGES.current b/CHANGES.current index b6651d762..fd39d0fa0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [S-EXP] #1447 Common Lisp S-Exp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [UFFI] #1447 Common Lisp UFFI has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 68b6af862..3f7970602 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -130,7 +130,6 @@ SWIGPYTHON Defined when using Python SWIGR Defined when using R SWIGRUBY Defined when using Ruby SWIGSCILAB Defined when using Scilab -SWIGSEXP Defined when using S-expressions SWIGTCL Defined when using Tcl SWIGXML Defined when using XML diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index f1e441c8a..7a68ad599 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -138,7 +138,6 @@ Supported Target Language Options -r - Generate R (aka GNU S) wrappers -ruby - Generate Ruby wrappers -scilab - Generate Scilab wrappers - -sexp - Generate Lisp S-Expressions wrappers -tcl - Generate Tcl wrappers -xml - Generate XML wrappers diff --git a/README b/README index ea30d32f1..f1721b95e 100644 --- a/README +++ b/README @@ -6,8 +6,7 @@ Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, Ocaml, Common Lisp (CLISP, Allegro CL, CFFI). - SWIG can also export its parse tree into XML and - Lisp s-expressions. + SWIG can also export its parse tree into XML. SWIG reads annotated C/C++ header files and creates wrapper code (glue code) in order to make the corresponding C/C++ libraries available to diff --git a/Source/Makefile.am b/Source/Makefile.am index 820d50289..a86507b76 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -74,7 +74,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/python.cxx \ Modules/r.cxx \ Modules/ruby.cxx \ - Modules/s-exp.cxx \ Modules/scilab.cxx \ Modules/swigmain.cxx \ Modules/tcl8.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index c56f73092..e665e690b 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -48,7 +48,6 @@ extern "C" { Language *swig_r(void); Language *swig_ruby(void); Language *swig_scilab(void); - Language *swig_sexp(void); Language *swig_tcl(void); Language *swig_xml(void); } @@ -84,7 +83,7 @@ static TargetLanguageModule modules[] = { {"-r", swig_r, "R (aka GNU S)", Supported}, {"-ruby", swig_ruby, "Ruby", Supported}, {"-scilab", swig_scilab, "Scilab", Supported}, - {"-sexp", swig_sexp, "Lisp S-Expressions", Supported}, + {"-sexp", NULL, "Lisp S-Expressions", Disabled}, {"-tcl", swig_tcl, "Tcl", Supported}, {"-tcl8", swig_tcl, NULL, Supported}, {"-uffi", NULL, "Common Lisp / UFFI", Disabled}, diff --git a/swig.spec.in b/swig.spec.in index 9229274c2..52d278cf7 100644 --- a/swig.spec.in +++ b/swig.spec.in @@ -30,7 +30,7 @@ OCAML and C#. Also several interpreted and compiled Scheme implementations (Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export -its parse tree in the form of XML and Lisp s-expressions. +its parse tree in the form of XML. %prep %setup -q -n %{name}-%{version} From cb4bd2642263ab74ecc334169556ac9d97c437e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 20:26:54 +0000 Subject: [PATCH 1354/2031] Disable Common Lisp / CLISP target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 4 +- CHANGES.current | 4 + Doc/Manual/Lisp.html | 201 +---------------------------------- Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Examples/Makefile.in | 36 ------- Makefile.in | 10 +- README | 2 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +- configure.ac | 31 ------ 11 files changed, 10 insertions(+), 284 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 0cfc1c1f1..c79917b56 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -11,8 +11,8 @@ SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), -D, Ocaml, Octave, R, Scilab, Common Lisp (CLISP, -Allegro CL, CFFI). SWIG can also export its parse tree in +D, Ocaml, Octave, R, Scilab, Common Lisp (Allegro CL, CFFI). +SWIG can also export its parse tree in the form of XML. Major applications of SWIG include generation of scripting language extension modules, rapid prototyping, testing, and user interface development for large diff --git a/CHANGES.current b/CHANGES.current index fd39d0fa0..772c7a98c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [CLISP] #1447 GNU Common Lisp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [S-EXP] #1447 Common Lisp S-Exp has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 1e7996581..f1dc3d17b 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -19,10 +19,8 @@
  • Generating CFFI bindings for C++ code
  • Inserting user code into generated files -
  • CLISP @@ -38,8 +36,7 @@ There are more than 9 different implementations of common lisp which are available, all have different foreign function interfaces. SWIG currently supports only the Allegro Common - Lisp, Common Foreign Function Interface(CFFI), CLisp - foreign function interfaces. + Lisp, Common Foreign Function Interface(CFFI).

    29.1 Allegro Common Lisp

    @@ -80,15 +77,6 @@ swig -cffi -module module-name file-name

    29.2.1 Additional Commandline Options

    -

    -The following table list the additional commandline options available for the CLISP module. They can also be seen by using: -

    - -
    -swig -cffi -help 
    -
    -
    - @@ -621,192 +609,5 @@ Note that the block %{ ... %} is effectively a shortcut for

    -

    29.3 CLISP

    - - -

    -CLISP is a feature-loaded - implementation of common lisp which is portable across most of the - operating system environments and hardware. CLISP includes an - interpreter, a compiler, a debugger, CLOS, MOP, a foreign - language interface, i18n, regular expressions, a socket - interface, and more. An X11 interface is available through CLX, - Garnet and CLUE/CLIO. Command line editing is provided by - readline. CLISP runs Maxima, ACL2 and many other Common Lisp - packages. -

    -

    - To run the clisp module of SWIG requires very little effort, you - just need to execute: -

    -
    -swig -clisp -module module-name   file-name 
    -
    -
    - -

    - Because of the high level nature of the CLISP FFI, the bindings - generated by SWIG may not be absolutely correct, and you may need - to modify them. The good thing is that you don't need to complex - interface file for the CLISP module. The CLISP module tries to - produce code which is both human readable and easily modifiable. -

    -

    29.3.1 Additional Commandline Options

    - - -

    -The following table list the additional commandline options available for the CLISP module. They can also be seen by using: -

    - -
    -swig -clisp -help 
    -
    -
    -
    CFFI specific options
    - - - - - - - - - - - - - - -
    CLISP specific options
    -extern-allIf this option is given then clisp definitions for all the functions
    -and global variables will be created otherwise only definitions for
    -externed functions and variables are created. -
    -generate-typedefIf this option is given then def-c-type will be used to generate
    -shortcuts according to the typedefs in the input. -
    - -

    29.3.2 Details on CLISP bindings

    - - -

    -As mentioned earlier the CLISP bindings generated by SWIG may need -some modifications. The clisp module creates a lisp file with -the same name as the module name. This -lisp file contains a 'defpackage' declaration, with the -package name same as the module name. This package uses the -'common-lisp' and 'ffi' packages. Also, package exports all -the functions, structures and variables for which an ffi -binding was generated.
    -After generating the defpackage statement, the clisp module also -sets the default language. - -

    -(defpackage :test
    -    (:use :common-lisp :ffi)
    -  (:export
    -   :make-bar
    -   :bar-x
    -   :bar-y
    -   :bar-a
    -   :bar-b
    -   :bar-z
    -   :bar-n
    -   :pointer_func
    -   :func123
    -   :make-cfunr
    -   :lispsort_double
    -   :test123))
    -
    -(in-package :test)
    -
    -(default-foreign-language :stdc)
    -
    -

    -The ffi wrappers for functions and variables are generated as shown - below. When functions have arguments of type "double * array", - SWIG doesn't knows whether it is an 'out' argument or it is - an array which will be passed, so SWIG plays it safe by - declaring it as an '(array (ffi:c-ptr DOUBLE-FLOAT))'. For - arguments of type "int **z[100]" where SWIG has more - information, i.e., it knows that 'z' is an array of pointers to - pointers of integers, SWIG defines it to be '(z (ffi:c-ptr - (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))' -

    -
    -extern "C" {
    -int pointer_func(void (*ClosureFun)( void* _fun, void* _data, void* _evt ), int y);
    -
    -int func123(div_t * x, int **z[100], int y[][1000][10]);
    -
    -void lispsort_double (int n, double * array);
    -
    -void test123(float x , double y);
    -
    -}
    -
    -
    -(ffi:def-call-out pointer_func
    -    (:name "pointer_func")
    -  (:arguments (ClosureFun (ffi:c-function (:arguments (arg0 (ffi:c-pointer NIL))
    -                                                      (arg1 (ffi:c-pointer NIL))
    -                                                      (arg2 (ffi:c-pointer NIL)))
    -                                          (:return-type NIL)))
    -              (y ffi:int))
    -  (:return-type ffi:int)
    -  (:library +library-name+))
    -
    -(ffi:def-call-out func123
    -    (:name "func123")
    -  (:arguments (x (ffi:c-pointer div_t))
    -              (z (ffi:c-ptr (ffi:c-array (ffi:c-ptr (ffi:c-ptr ffi:int)) 100)))
    -              (y (ffi:c-ptr (ffi:c-ptr (ffi:c-array ffi:int (1000 10))))))
    -  (:return-type ffi:int)
    -  (:library +library-name+))
    -
    -
    -(ffi:def-call-out lispsort_double
    -    (:name "lispsort_double")
    -  (:arguments (n ffi:int)
    -              (array (ffi:c-ptr DOUBLE-FLOAT)))
    -  (:return-type NIL)
    -  (:library +library-name+))
    -
    -(ffi:def-call-out test123
    -    (:name "test")
    -  (:arguments (x SINGLE-FLOAT)
    -              (y DOUBLE-FLOAT))
    -  (:return-type NIL)
    -  (:library +library-name+))
    -
    -
    - -

    -The module also handles strutcures and #define constants as shown - below. SWIG automatically adds the constructors and accessors - created for the struct to the list of symbols exported by the - package. -

    -
    -struct bar {
    -  short x, y;
    -  char a, b;
    -  int *z[1000];
    -  struct bar * n;
    -};
    -
    -#define max 1000
    -
    -
    -(ffi:def-c-struct bar
    -    (x :type ffi:short)
    -  (y :type ffi:short)
    -  (a :type character)
    -  (b :type character)
    -  (z :type (ffi:c-array (ffi:c-ptr ffi:int) 1000))
    -  (n :type (ffi:c-pointer bar)))
    -
    -(defconstant max 1000)
    -
    -
    - diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 3f7970602..5c94489c4 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -112,7 +112,6 @@ SWIG_VERSION Hexadecimal (binary-coded decimal) number contai 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 diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 7a68ad599..7dc8815c6 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -120,7 +120,6 @@ for example, swig -ruby -help for Ruby. Supported Target Language Options -allegrocl - Generate ALLEGROCL wrappers -chicken - Generate CHICKEN wrappers - -clisp - Generate CLISP wrappers -cffi - Generate CFFI wrappers -csharp - Generate C# wrappers -d - Generate D wrappers diff --git a/Examples/Makefile.in b/Examples/Makefile.in index d070e3c8e..0f722f0a9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1391,42 +1391,6 @@ allegrocl_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ -################################################################## -##### CLISP ###### -################################################################## - -CLISP = @CLISPBIN@ -CLISP_SCRIPT=$(RUNME).lisp - -clisp: $(SRCDIR_SRCS) - $(SWIG) -clisp $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - -clisp_cpp: $(SRCDIR_SRCS) - $(SWIG) -c++ -clisp $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - -# ----------------------------------------------------------------- -# Run CLISP example -# ----------------------------------------------------------------- - -clisp_run: - $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -clisp_version: - $(CLISP) --version | head -n 1 - -# ----------------------------------------------------------------- -# Cleaning the CLISP examples -# ----------------------------------------------------------------- - -clisp_clean: - rm -f *_wrap* *~ .~* - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *@SO@ - ################################################################## ##### CFFI ###### ################################################################## diff --git a/Makefile.in b/Makefile.in index a45684a1d..b87b777a2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -73,7 +73,6 @@ skip-chicken = test -n "@SKIP_CHICKEN@" skip-csharp = test -n "@SKIP_CSHARP@" skip-lua = test -n "@SKIP_LUA@" skip-allegrocl = test -n "@SKIP_ALLEGROCL@" -skip-clisp = test -n "@SKIP_CLISP@" skip-cffi = test -n "@SKIP_CFFI@" skip-r = test -n "@SKIP_R@" skip-scilab = test -n "@SKIP_SCILAB@" @@ -117,7 +116,6 @@ check-aliveness: @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help - @$(skip-clisp) || ./$(TARGET) -clisp -help @$(skip-cffi) || ./$(TARGET) -cffi -help @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help @@ -147,7 +145,6 @@ check-versions: \ check-csharp-version \ check-lua-version \ check-allegrocl-version \ - check-clisp-version \ check-cffi-version \ check-r-version \ check-scilab-version \ @@ -184,7 +181,6 @@ check-examples: \ check-csharp-examples \ check-lua-examples \ check-allegrocl-examples \ - check-clisp-examples \ check-cffi-examples \ check-r-examples \ check-scilab-examples \ @@ -207,7 +203,6 @@ chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) allegrocl_examples := -clisp_examples := cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) scilab_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/scilab/check.list) @@ -251,7 +246,6 @@ check-test-suite: \ check-csharp-test-suite \ check-lua-test-suite \ check-allegrocl-test-suite \ - check-clisp-test-suite \ check-cffi-test-suite \ check-chicken-test-suite \ check-r-test-suite \ @@ -302,7 +296,6 @@ all-test-suite: \ all-csharp-test-suite \ all-lua-test-suite \ all-allegrocl-test-suite \ - all-clisp-test-suite \ all-cffi-test-suite \ all-chicken-test-suite \ all-r-test-suite \ @@ -329,7 +322,6 @@ broken-test-suite: \ broken-csharp-test-suite \ broken-lua-test-suite \ broken-allegrocl-test-suite \ - broken-clisp-test-suite \ broken-cffi-test-suite \ broken-chicken-test-suite \ broken-r-test-suite \ @@ -468,7 +460,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - chicken csharp allegrocl clisp lua cffi r go d javascript javascript/jsc \ + chicken csharp allegrocl lua cffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index f1721b95e..70b786423 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, - Ocaml, Common Lisp (CLISP, Allegro CL, CFFI). + Ocaml, Common Lisp (Allegro CL, CFFI). SWIG can also export its parse tree into XML. SWIG reads annotated C/C++ header files and creates wrapper code (glue diff --git a/Source/Makefile.am b/Source/Makefile.am index a86507b76..c4c2bd888 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -50,7 +50,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/browser.cxx \ Modules/cffi.cxx \ Modules/chicken.cxx \ - Modules/clisp.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index e665e690b..767b01b4d 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -29,7 +29,6 @@ extern "C" { Language *swig_allegrocl(void); Language *swig_cffi(void); Language *swig_chicken(void); - Language *swig_clisp(void); Language *swig_csharp(void); Language *swig_d(void); Language *swig_go(void); @@ -59,7 +58,7 @@ extern "C" { static TargetLanguageModule modules[] = { {"-allegrocl", swig_allegrocl, "ALLEGROCL", Supported}, {"-chicken", swig_chicken, "CHICKEN", Supported}, - {"-clisp", swig_clisp, "CLISP", Supported}, + {"-clisp", NULL, "CLISP", Disabled}, {"-cffi", swig_cffi, "CFFI", Supported}, {"-csharp", swig_csharp, "C#", Supported}, {"-d", swig_d, "D", Supported}, diff --git a/configure.ac b/configure.ac index efdca9aea..5f231fbf6 100644 --- a/configure.ac +++ b/configure.ac @@ -2457,29 +2457,6 @@ fi AC_SUBST(ALLEGROCLBIN) -#---------------------------------------------------------------- -# Look for GNU CLISP -#---------------------------------------------------------------- - -CLISPBIN= - -AC_ARG_WITH(clisp, AS_HELP_STRING([--without-clisp], [Disable CLISP]) -AS_HELP_STRING([--with-clisp=path], [Set location of CLISP executable (clisp)]),[ CLISPBIN="$withval"], [CLISPBIN="$alllang_default"]) - -# First, check for "--without-clisp" or "--with-clisp=no". -if test x"${CLISPBIN}" = xno; then -AC_MSG_NOTICE([Disabling CLISP]) -CLISPBIN= -else - -# can we find clisp? -if test "x$CLISPBIN" = xyes; then - AC_PATH_PROG(CLISPBIN, clisp) -fi -fi - -AC_SUBST(CLISPBIN) - #---------------------------------------------------------------- # Look for GNU R #---------------------------------------------------------------- @@ -2828,12 +2805,6 @@ if test -z "$ALLEGROCLBIN" ; then fi AC_SUBST(SKIP_ALLEGROCL) -SKIP_CLISP= -if test -z "$CLISPBIN" ; then - SKIP_CLISP="1" -fi -AC_SUBST(SKIP_CLISP) - SKIP_R= if test -z "$RBIN" ; then SKIP_R="1" @@ -2970,7 +2941,6 @@ AC_CONFIG_FILES([ Examples/test-suite/tcl/Makefile Examples/test-suite/lua/Makefile Examples/test-suite/allegrocl/Makefile - Examples/test-suite/clisp/Makefile Examples/test-suite/cffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile @@ -3022,7 +2992,6 @@ langs="" test -n "$SKIP_ALLEGROCL" || langs="${langs}allegrocl " test -n "$SKIP_CFFI" || langs="${langs}cffi " test -n "$SKIP_CHICKEN" || langs="${langs}chicken " -test -n "$SKIP_CLISP" || langs="${langs}clisp " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " test -n "$SKIP_GO" || langs="${langs}go " From 09e0577d95dc39b158c68d02ecd54610bb009949 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 4 Feb 2019 21:41:11 +0000 Subject: [PATCH 1355/2031] Disable Chicken target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++ Doc/Devel/runtime.txt | 4 +- Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Doc/Manual/Sections.html | 1 - Doc/Manual/chapters | 1 - Examples/Makefile.in | 116 ----------------------------------- Lib/allkw.swg | 1 - Lib/cdata.i | 8 --- Lib/exception.i | 16 ----- Makefile.in | 10 +-- README | 2 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +- configure.ac | 111 --------------------------------- swig.spec.in | 2 +- 17 files changed, 11 insertions(+), 273 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index c79917b56..cd273f590 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -10,7 +10,7 @@ What is SWIG? SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, -PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN), +PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme), D, Ocaml, Octave, R, Scilab, Common Lisp (Allegro CL, CFFI). SWIG can also export its parse tree in the form of XML. Major applications of SWIG diff --git a/CHANGES.current b/CHANGES.current index 772c7a98c..8d1666a62 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [Chicken] #1447 CHICKEN has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [CLISP] #1447 GNU Common Lisp has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Devel/runtime.txt b/Doc/Devel/runtime.txt index f88edf767..ae9c83275 100644 --- a/Doc/Devel/runtime.txt +++ b/Doc/Devel/runtime.txt @@ -57,7 +57,7 @@ Alternatively, if the language supports modules, a module named named "type_table" SWIG_TYPE_TABLE_NAME can be created inside it. The most common approach is to store the mod pointer in some global variable in the target language, but if the language provides an alternative place to store data -(like the chicken module), then that is good too. +then that is good too. The way the code is set up, SetModule should only be called when GetModule returns NULL, and if SetModule is called a second time, the behavior is @@ -105,7 +105,7 @@ Standard Functions These functions are not required and their API is not formalized, but almost all language modules implement them for consistency across languages. Throughout this discussion, I will use LangType to represent the underlying language type -(C_word in chicken, Scheme_Object * in mzscheme, PyObject * in python, etc) +(Scheme_Object * in mzscheme, PyObject * in python, etc) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 5c94489c4..d5929b4f6 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -111,7 +111,6 @@ SWIG_VERSION Hexadecimal (binary-coded decimal) number contai SWIGALLEGROCL Defined when using Allegro CL SWIGCFFI Defined when using CFFI -SWIGCHICKEN Defined when using CHICKEN SWIGCSHARP Defined when using C# SWIGGUILE Defined when using Guile SWIGJAVA Defined when using Java diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 7dc8815c6..2a9674c5c 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -119,7 +119,6 @@ for example, swig -ruby -help for Ruby.
     Supported Target Language Options
          -allegrocl      - Generate ALLEGROCL wrappers
    -     -chicken        - Generate CHICKEN wrappers
          -cffi           - Generate CFFI wrappers
          -csharp         - Generate C# wrappers
          -d              - Generate D wrappers
    diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
    index f3844365e..405185e7c 100644
    --- a/Doc/Manual/Sections.html
    +++ b/Doc/Manual/Sections.html
    @@ -42,7 +42,6 @@ Last update : SWIG-4.0.0 (in progress)
     
  • Allegro Common Lisp support
  • Android support
  • C# support
  • -
  • Chicken support
  • D support
  • Go support
  • Guile support
  • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index cae1c5366..5e42d1d4b 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -20,7 +20,6 @@ CCache.html Allegrocl.html Android.html CSharp.html -Chicken.html D.html Go.html Guile.html diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 0f722f0a9..450824400 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1081,122 +1081,6 @@ php_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *$(PHP_SO) -################################################################## -##### Chicken ###### -################################################################## - -CHICKEN = @CHICKEN@ -CHICKEN_CSC = @CHICKEN_CSC@ -CHICKEN_CSI = @CHICKEN_CSI@ -CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) -CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) -CHICKEN_CFLAGS = @CHICKENOPTS@ -CHICKENOPTS = -quiet -CHICKEN_MAIN = -CHICKEN_SCRIPT = $(RUNME).scm - -# SWIG produces $(ISRCS) (the C wrapper file) -# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): -CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm) -CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c) -CHICKEN_COMPILED_OBJECT = $(CHICKEN_COMPILED_SCHEME:.c=.@OBJEXT@) - -# flags for the main chicken sources (only used when compiling statically) -CHICKEN_COMPILED_MAIN = $(CHICKEN_MAIN:.scm=_chicken.c) -CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@) - -# ----------------------------------------------------------------- -# Build a CHICKEN dynamically loadable module -# ----------------------------------------------------------------- - -# This is the old way to build chicken, but it does not work correctly with exceptions -chicken_direct: $(SRCDIR_SRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ - -dynamic -feature chicken-compile-shared \ - -output-file $(CHICKEN_COMPILED_SCHEME) - $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \ - $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) $(CHICKEN_COMPILED_SCHEME) - $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \ - $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) - -chicken_direct_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ - -dynamic -feature chicken-compile-shared \ - -output-file $(CHICKEN_COMPILED_SCHEME) - $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \ - $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CHICKEN_COMPILED_SCHEME) - $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(OBJS) $(IOBJS) \ - $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) - -# ----------------------------------------------------------------- -# Build statically linked CHICKEN interpreter -# ----------------------------------------------------------------- - -# The following two targets are also used by the test suite -chicken_static: $(SRCDIR_SRCS) $(CHICKSRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ - -output-file $(CHICKEN_COMPILED_SCHEME) - $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ - -output-file $(CHICKEN_MAIN:.scm=_chicken.c) - $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(CHICKEN_CFLAGS) \ - $(INCLUDES) $(CHICKEN_INCLUDE) $(ISRCS) $(SRCDIR_SRCS) \ - $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) - $(CC) $(CFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \ - $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) - -chicken_static_cpp: $(SRCDIR_CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ - -output-file $(CHICKEN_COMPILED_SCHEME) - $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ - -output-file $(CHICKEN_MAIN:.scm=_chicken.c) - $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(CHICKEN_CFLAGS) \ - $(INCLUDES) $(CHICKEN_INCLUDE) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) \ - $(CHICKEN_COMPILED_SCHEME) $(CHICKEN_COMPILED_MAIN) - $(CXX) $(CXXFLAGS) $(LDFLAGS) $(CHICKEN_COMPILED_OBJECT) $(CHICKEN_COMPILED_MAIN_OBJECT) \ - $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) - -# ---------------------------------------------------------------- -# Build a shared library using csc -# ---------------------------------------------------------------- - -chicken: - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ISRCS) -o $(TARGET)$(SO) - -chicken_cpp: - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) - $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCDIR_SRCS) $(ICXXSRCS) $(SRCDIR_CXXSRCS) -o $(TARGET)$(SO) - -chicken_externalhdr: - $(SWIG) -chicken -external-runtime $(TARGET) - -# ----------------------------------------------------------------- -# Run CHICKEN example -# ----------------------------------------------------------------- - -chicken_run: - env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) - -# ----------------------------------------------------------------- -# Version display -# ----------------------------------------------------------------- - -chicken_version: - $(CHICKEN) -version | grep -i version - -# ----------------------------------------------------------------- -# Cleaning the CHICKEN examples -# ----------------------------------------------------------------- - -chicken_clean: - rm -f *_wrap* *~ .~* *_chicken* - rm -f core @EXTRA_CLEAN@ - rm -f *.@OBJEXT@ *@SO@ - ################################################################## ##### CSHARP ###### ################################################################## diff --git a/Lib/allkw.swg b/Lib/allkw.swg index 2de1a12dd..2d3cf6ea9 100644 --- a/Lib/allkw.swg +++ b/Lib/allkw.swg @@ -16,7 +16,6 @@ */ -%include %include %include %include diff --git a/Lib/cdata.i b/Lib/cdata.i index 23b7211e7..f18ed4af5 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -21,14 +21,6 @@ typedef struct SWIGCDATA { } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); -#elif SWIGCHICKEN - -%typemap(out) SWIGCDATA { - C_word *string_space = C_alloc(C_SIZEOF_STRING($1.len)); - $result = C_string(&string_space, $1.len, $1.data); -} -%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); - #elif SWIGPHP7 %typemap(out) SWIGCDATA { diff --git a/Lib/exception.i b/Lib/exception.i index c75d71483..c79a76c37 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -138,22 +138,6 @@ SWIGINTERN void SWIG_exception_(int code, const char *msg) { #endif -#ifdef SWIGCHICKEN -%{ -SWIGINTERN void SWIG_exception_(int code, const char *msg) { - C_word *a; - C_word scmmsg; - C_word list; - - a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2)); - scmmsg = C_string2 (&a, (char *) msg); - list = C_list(&a, 2, C_fix(code), scmmsg); - SWIG_ThrowException(list); -} -#define SWIG_exception(a,b) SWIG_exception_((a),(b)) -%} -#endif - #ifdef SWIGCSHARP %{ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { diff --git a/Makefile.in b/Makefile.in index b87b777a2..0c8d5daf7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -69,7 +69,6 @@ skip-ruby = test -n "@SKIP_RUBY@" skip-php = test -n "@SKIP_PHP@" skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" -skip-chicken = test -n "@SKIP_CHICKEN@" skip-csharp = test -n "@SKIP_CSHARP@" skip-lua = test -n "@SKIP_LUA@" skip-allegrocl = test -n "@SKIP_ALLEGROCL@" @@ -113,7 +112,6 @@ check-aliveness: @$(skip-ocaml) || ./$(TARGET) -ocaml -help @$(skip-octave) || ./$(TARGET) -octave -help @$(skip-php) || ./$(TARGET) -php7 -help - @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help @$(skip-cffi) || ./$(TARGET) -cffi -help @@ -141,7 +139,6 @@ check-versions: \ check-ocaml-version \ check-octave-version \ check-php-version \ - check-chicken-version \ check-csharp-version \ check-lua-version \ check-allegrocl-version \ @@ -177,7 +174,6 @@ check-examples: \ check-ocaml-examples \ check-octave-examples \ check-php-examples \ - check-chicken-examples \ check-csharp-examples \ check-lua-examples \ check-allegrocl-examples \ @@ -199,7 +195,6 @@ 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) -chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) allegrocl_examples := @@ -247,7 +242,6 @@ check-test-suite: \ check-lua-test-suite \ check-allegrocl-test-suite \ check-cffi-test-suite \ - check-chicken-test-suite \ check-r-test-suite \ check-scilab-test-suite \ check-go-test-suite \ @@ -297,7 +291,6 @@ all-test-suite: \ all-lua-test-suite \ all-allegrocl-test-suite \ all-cffi-test-suite \ - all-chicken-test-suite \ all-r-test-suite \ all-scilab-test-suite \ all-go-test-suite \ @@ -323,7 +316,6 @@ broken-test-suite: \ broken-lua-test-suite \ broken-allegrocl-test-suite \ broken-cffi-test-suite \ - broken-chicken-test-suite \ broken-r-test-suite \ broken-scilab-test-suite \ broken-go-test-suite \ @@ -460,7 +452,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - chicken csharp allegrocl lua cffi r go d javascript javascript/jsc \ + csharp allegrocl lua cffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index 70b786423..8f720c9ed 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, - Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab, + Octave, R, Scheme (Guile, MzScheme/Racket), Scilab, Ocaml, Common Lisp (Allegro CL, CFFI). SWIG can also export its parse tree into XML. diff --git a/Source/Makefile.am b/Source/Makefile.am index c4c2bd888..026722d73 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -49,7 +49,6 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/allocate.cxx \ Modules/browser.cxx \ Modules/cffi.cxx \ - Modules/chicken.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 767b01b4d..2a687ef6c 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -28,7 +28,6 @@ extern "C" { Language *swig_allegrocl(void); Language *swig_cffi(void); - Language *swig_chicken(void); Language *swig_csharp(void); Language *swig_d(void); Language *swig_go(void); @@ -57,7 +56,7 @@ extern "C" { static TargetLanguageModule modules[] = { {"-allegrocl", swig_allegrocl, "ALLEGROCL", Supported}, - {"-chicken", swig_chicken, "CHICKEN", Supported}, + {"-chicken", NULL, "CHICKEN", Disabled}, {"-clisp", NULL, "CLISP", Disabled}, {"-cffi", swig_cffi, "CFFI", Supported}, {"-csharp", swig_csharp, "C#", Supported}, diff --git a/configure.ac b/configure.ac index 5f231fbf6..bf204bff3 100644 --- a/configure.ac +++ b/configure.ac @@ -2084,108 +2084,6 @@ AC_SUBST(OCAMLFIND) AC_SUBST(OCAMLMKTOP) AC_SUBST(CAMLP4) -#---------------------------------------------------------------- -# Look for CHICKEN -#---------------------------------------------------------------- - -CHICKEN= -CHICKEN_CONFIG= -CHICKENHOME= -CHICKENOPTS= -CHICKENLIB= - - -AC_ARG_WITH(chicken, AS_HELP_STRING([--without-chicken], [Disable CHICKEN]) -AS_HELP_STRING([--with-chicken=path], [Set location of CHICKEN executable]),[ CHICKENBIN="$withval"], [CHICKENBIN="$alllang_default"]) - -# First, check for "--without-chicken" or "--with-chicken=no". -if test x"${CHICKENBIN}" = xno; then -AC_MSG_NOTICE([Disabling CHICKEN]) -else - -if test "x$CHICKENBIN" = xyes; then -AC_CHECK_PROGS(CHICKEN, chicken) -else -CHICKEN="$CHICKENBIN" -fi - -AC_ARG_WITH(chickencsc,[ --with-chickencsc=path Set location of csc executable],[ CHICKEN_CSC="$withval"], [CHICKEN_CSC=]) - -if test -z "$CHICKEN_CSC"; then - AC_CHECK_PROGS(CHICKEN_CSC, csc) - # Both the Microsoft C# compiler and chicken have an executable called csc, so check that this csc is really the chicken one - if test -n "$CHICKEN_CSC" ; then - AC_MSG_CHECKING(whether csc is the chicken compiler) - $CHICKEN_CSC -version 2>/dev/null | grep "chicken" > /dev/null || CHICKEN_CSC="" - if test -z "$CHICKEN_CSC"; then - AC_MSG_RESULT(no) - else - AC_MSG_RESULT(yes) - fi - fi -fi - -AC_ARG_WITH(chickencsi,[ --with-chickencsi=path Set location of csi executable],[ CHICKEN_CSI="$withval"], [CHICKEN_CSI=]) - -if test -z "$CHICKEN_CSI"; then -AC_CHECK_PROGS(CHICKEN_CSI, csi) -fi - -if test -n "$CHICKEN_CSC" ; then - - AC_ARG_WITH(chickenopts,[ --with-chickenopts=args Set compiler options for static CHICKEN generated code],[ - CHICKENOPTS="$withval"], [CHICKENOPTS=]) - AC_ARG_WITH(chickensharedlib,[ --with-chickensharedlib=args Set linker options for shared CHICKEN generated code],[ - CHICKENSHAREDLIB="$withval"], [CHICKENSHAREDLIB=]) - AC_ARG_WITH(chickenlib,[ --with-chickenlib=args Set linker options for static CHICKEN generated code],[ - CHICKENLIB="$withval"], [CHICKENLIB=]) - - AC_MSG_CHECKING(for compiler options for static CHICKEN generated code) - if test -z "$CHICKENOPTS"; then - CHICKENOPTS="`$CHICKEN_CSC -cflags`" - else - CHICKENOPTS="`$CHICKEN_CSC -cflags` $CHICKENOPTS" - fi - if test -z "$CHICKENOPTS"; then - AC_MSG_RESULT(not found) - else - AC_MSG_RESULT($CHICKENOPTS) - fi - - AC_MSG_CHECKING(for linker options for shared CHICKEN generated code) - if test -z "$CHICKENSHAREDLIB"; then - CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs`" - else - CHICKENSHAREDLIB="`$CHICKEN_CSC -shared -libs` $CHICKENSHAREDLIB" - fi - if test -z "$CHICKENSHAREDLIB"; then - AC_MSG_RESULT(not found) - else - AC_MSG_RESULT($CHICKENSHAREDLIB) - fi - - AC_MSG_CHECKING(for linker options for static CHICKEN generated code) - if test -z "$CHICKENLIB"; then - CHICKENLIB="`$CHICKEN_CSC -libs`" - else - CHICKENLIB="`$CHICKEN_CSC -libs` $CHICKENLIB" - fi - if test -z "$CHICKENLIB"; then - AC_MSG_RESULT(not found) - else - AC_MSG_RESULT($CHICKENLIB) - fi - -fi # have CHICKEN_CONFIG -fi # Check for --without-chicken - -AC_SUBST(CHICKEN) -AC_SUBST(CHICKEN_CSC) -AC_SUBST(CHICKEN_CSI) -AC_SUBST(CHICKENOPTS) -AC_SUBST(CHICKENLIB) -AC_SUBST(CHICKENSHAREDLIB) - #---------------------------------------------------------------- # Look for C# #---------------------------------------------------------------- @@ -2775,13 +2673,6 @@ fi AC_SUBST(SKIP_OCAML) -SKIP_CHICKEN= -if test -z "$CHICKEN_CSC" || test -z "$CHICKEN"; then - SKIP_CHICKEN="1" -fi -AC_SUBST(SKIP_CHICKEN) - - SKIP_CSHARP= if test -z "$CSHARPCOMPILER" ; then SKIP_CSHARP="1" @@ -2924,7 +2815,6 @@ AC_CONFIG_FILES([ Examples/d/example.mk Examples/xml/Makefile Examples/test-suite/errors/Makefile - Examples/test-suite/chicken/Makefile Examples/test-suite/csharp/Makefile Examples/test-suite/d/Makefile Examples/test-suite/guile/Makefile @@ -2991,7 +2881,6 @@ AC_OUTPUT langs="" test -n "$SKIP_ALLEGROCL" || langs="${langs}allegrocl " test -n "$SKIP_CFFI" || langs="${langs}cffi " -test -n "$SKIP_CHICKEN" || langs="${langs}chicken " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " test -n "$SKIP_GO" || langs="${langs}go " diff --git a/swig.spec.in b/swig.spec.in index 52d278cf7..140b96206 100644 --- a/swig.spec.in +++ b/swig.spec.in @@ -27,7 +27,7 @@ with a variety of high-level programming languages. SWIG is primarily used with common scripting languages such as Perl, Python, Tcl/Tk, and Ruby, however the list of supported languages also includes non-scripting languages such as Java, OCAML and C#. Also several interpreted and compiled Scheme implementations -(Guile, MzScheme, Chicken) are supported. SWIG is most commonly used to create +(Guile, MzScheme) are supported. SWIG is most commonly used to create high-level interpreted or compiled programming environments, user interfaces, and as a tool for testing and prototyping C/C++ software. SWIG can also export its parse tree in the form of XML. From 6d7e3df54efd9a96164045512e41d6d7235a4c01 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Feb 2019 07:21:35 +0000 Subject: [PATCH 1356/2031] Disable Allegrcol target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++++ Doc/Manual/Lisp.html | 13 ++----------- Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Doc/Manual/Sections.html | 1 - Doc/Manual/chapters | 1 - Makefile.in | 10 +--------- README | 2 +- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +-- TODO | 8 -------- configure.ac | 31 ------------------------------- 13 files changed, 10 insertions(+), 68 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index cd273f590..2187b0f6b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -11,7 +11,7 @@ SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme), -D, Ocaml, Octave, R, Scilab, Common Lisp (Allegro CL, CFFI). +D, Ocaml, Octave, R, Scilab, Common Lisp (CFFI). SWIG can also export its parse tree in the form of XML. Major applications of SWIG include generation of scripting language extension modules, rapid diff --git a/CHANGES.current b/CHANGES.current index 8d1666a62..1505ac4e0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [Allegrocl] #1447 Allegro Common Lisp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [Chicken] #1447 CHICKEN has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index f1dc3d17b..6eb448a12 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -11,7 +11,6 @@
      -
    • Allegro Common Lisp
    • Common Foreign Function Interface(CFFI)
      • Additional Commandline Options @@ -35,16 +34,8 @@ finance, and also common in computer science education. There are more than 9 different implementations of common lisp which are available, all have different foreign function - interfaces. SWIG currently supports only the Allegro Common - Lisp, Common Foreign Function Interface(CFFI). -

        -

        29.1 Allegro Common Lisp

        - - -

        - Allegro Common Lisp support in SWIG has been updated to include - support for both C and C++. You can read about the interface - here + interfaces. SWIG currently supports the + Common Foreign Function Interface(CFFI).

        29.2 Common Foreign Function Interface(CFFI)

        diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index d5929b4f6..1043a87be 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -109,7 +109,6 @@ SWIGIMPORTED Defined when SWIG is importing a file with % SWIG_VERSION Hexadecimal (binary-coded decimal) number containing SWIG version, such as 0x010311 (corresponding to SWIG-1.3.11). -SWIGALLEGROCL Defined when using Allegro CL SWIGCFFI Defined when using CFFI SWIGCSHARP Defined when using C# SWIGGUILE Defined when using Guile diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 2a9674c5c..d55659d82 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -118,7 +118,6 @@ for example, swig -ruby -help for Ruby.
         Supported Target Language Options
        -     -allegrocl      - Generate ALLEGROCL wrappers
              -cffi           - Generate CFFI wrappers
              -csharp         - Generate C# wrappers
              -d              - Generate D wrappers
        diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
        index 405185e7c..3d5369995 100644
        --- a/Doc/Manual/Sections.html
        +++ b/Doc/Manual/Sections.html
        @@ -39,7 +39,6 @@ Last update : SWIG-4.0.0 (in progress)
         

        Supported Language Modules Documentation

          -
        • Allegro Common Lisp support
        • Android support
        • C# support
        • D support
        • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 5e42d1d4b..16e8f264b 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -17,7 +17,6 @@ Doxygen.html Warnings.html Modules.html CCache.html -Allegrocl.html Android.html CSharp.html D.html diff --git a/Makefile.in b/Makefile.in index 0c8d5daf7..f3e596f8c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,7 +71,6 @@ skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" skip-csharp = test -n "@SKIP_CSHARP@" skip-lua = test -n "@SKIP_LUA@" -skip-allegrocl = test -n "@SKIP_ALLEGROCL@" skip-cffi = test -n "@SKIP_CFFI@" skip-r = test -n "@SKIP_R@" skip-scilab = test -n "@SKIP_SCILAB@" @@ -113,7 +112,6 @@ check-aliveness: @$(skip-octave) || ./$(TARGET) -octave -help @$(skip-php) || ./$(TARGET) -php7 -help @$(skip-csharp) || ./$(TARGET) -csharp -help - @$(skip-allegrocl)|| ./$(TARGET) -allegrocl -help @$(skip-cffi) || ./$(TARGET) -cffi -help @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help @@ -141,7 +139,6 @@ check-versions: \ check-php-version \ check-csharp-version \ check-lua-version \ - check-allegrocl-version \ check-cffi-version \ check-r-version \ check-scilab-version \ @@ -176,7 +173,6 @@ check-examples: \ check-php-examples \ check-csharp-examples \ check-lua-examples \ - check-allegrocl-examples \ check-cffi-examples \ check-r-examples \ check-scilab-examples \ @@ -197,7 +193,6 @@ octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list) php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) -allegrocl_examples := cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) scilab_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/scilab/check.list) @@ -240,7 +235,6 @@ check-test-suite: \ check-php-test-suite \ check-csharp-test-suite \ check-lua-test-suite \ - check-allegrocl-test-suite \ check-cffi-test-suite \ check-r-test-suite \ check-scilab-test-suite \ @@ -289,7 +283,6 @@ all-test-suite: \ all-php-test-suite \ all-csharp-test-suite \ all-lua-test-suite \ - all-allegrocl-test-suite \ all-cffi-test-suite \ all-r-test-suite \ all-scilab-test-suite \ @@ -314,7 +307,6 @@ broken-test-suite: \ broken-php-test-suite \ broken-csharp-test-suite \ broken-lua-test-suite \ - broken-allegrocl-test-suite \ broken-cffi-test-suite \ broken-r-test-suite \ broken-scilab-test-suite \ @@ -452,7 +444,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - csharp allegrocl lua cffi r go d javascript javascript/jsc \ + csharp lua cffi r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index 8f720c9ed..925f79fe8 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, Octave, R, Scheme (Guile, MzScheme/Racket), Scilab, - Ocaml, Common Lisp (Allegro CL, CFFI). + Ocaml, Common Lisp (CFFI). SWIG can also export its parse tree into XML. SWIG reads annotated C/C++ header files and creates wrapper code (glue diff --git a/Source/Makefile.am b/Source/Makefile.am index 026722d73..189fa3c26 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -45,7 +45,6 @@ eswig_SOURCES = CParse/cscanner.c \ Doxygen/javadoc.h \ Doxygen/pydoc.cxx \ Doxygen/pydoc.h \ - Modules/allegrocl.cxx \ Modules/allocate.cxx \ Modules/browser.cxx \ Modules/cffi.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 2a687ef6c..9f8ba846a 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -26,7 +26,6 @@ can be dynamically loaded in future versions. */ extern "C" { - Language *swig_allegrocl(void); Language *swig_cffi(void); Language *swig_csharp(void); Language *swig_d(void); @@ -55,7 +54,7 @@ extern "C" { list sorted alphabetically. */ static TargetLanguageModule modules[] = { - {"-allegrocl", swig_allegrocl, "ALLEGROCL", Supported}, + {"-allegrocl", NULL, "ALLEGROCL", Disabled}, {"-chicken", NULL, "CHICKEN", Disabled}, {"-clisp", NULL, "CLISP", Disabled}, {"-cffi", swig_cffi, "CFFI", Supported}, diff --git a/TODO b/TODO index bd573c652..38ab4605d 100644 --- a/TODO +++ b/TODO @@ -275,14 +275,6 @@ Mzscheme ** Add shadow class support for the Swindle system. -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/configure.ac b/configure.ac index bf204bff3..8d6f004a6 100644 --- a/configure.ac +++ b/configure.ac @@ -2332,29 +2332,6 @@ AC_SUBST(LUAFLAGS) AC_SUBST(LUALINK) AC_SUBST(LUABIN) -#---------------------------------------------------------------- -# Look for Allegro Common Lisp -#---------------------------------------------------------------- - -ALLEGROCLBIN= - -AC_ARG_WITH(allegrocl, AS_HELP_STRING([--without-allegrocl], [Disable Allegro CL]) -AS_HELP_STRING([--with-allegrocl=path], [Set location of Allegro CL executable (alisp)]),[ ALLEGROCLBIN="$withval"], [ALLEGROCLBIN="$alllang_default"]) - -# First, check for "--without-allegrocl" or "--with-allegrocl=no". -if test x"${ALLEGROCLBIN}" = xno; then -AC_MSG_NOTICE([Disabling Allegro CL]) -ALLEGROCLBIN= -else - -# can we find allegrocl? -if test "x$ALLEGROCLBIN" = xyes; then - AC_PATH_PROG(ALLEGROCLBIN, alisp) -fi -fi - -AC_SUBST(ALLEGROCLBIN) - #---------------------------------------------------------------- # Look for GNU R #---------------------------------------------------------------- @@ -2690,12 +2667,6 @@ if test -z "$LUABIN" || test -z "$LUADYNAMICLOADLIB"; then fi AC_SUBST(SKIP_LUA) -SKIP_ALLEGROCL= -if test -z "$ALLEGROCLBIN" ; then - SKIP_ALLEGROCL="1" -fi -AC_SUBST(SKIP_ALLEGROCL) - SKIP_R= if test -z "$RBIN" ; then SKIP_R="1" @@ -2830,7 +2801,6 @@ AC_CONFIG_FILES([ Examples/test-suite/scilab/Makefile Examples/test-suite/tcl/Makefile Examples/test-suite/lua/Makefile - Examples/test-suite/allegrocl/Makefile Examples/test-suite/cffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile @@ -2879,7 +2849,6 @@ EOF AC_OUTPUT langs="" -test -n "$SKIP_ALLEGROCL" || langs="${langs}allegrocl " test -n "$SKIP_CFFI" || langs="${langs}cffi " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " From 264b39fd002563f8aa0f8ddd589e7aab26c835a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Feb 2019 07:36:13 +0000 Subject: [PATCH 1357/2031] Disable CFFI Common Lisp target language Clean up to disable target languages that have been neglected/not functional. Target language be fully deleted in SWIG 4.1 unless a new maintainer brings it up to an acceptable status (experimental or supported). Issue #1447 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++++ Doc/Manual/Preprocessor.html | 1 - Doc/Manual/SWIG.html | 1 - Doc/Manual/Sections.html | 1 - Doc/Manual/chapters | 1 - Makefile.in | 10 +--------- README | 3 +-- Source/Makefile.am | 1 - Source/Modules/swigmain.cxx | 3 +-- configure.ac | 8 -------- 11 files changed, 8 insertions(+), 27 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 2187b0f6b..764f39c92 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -11,7 +11,7 @@ SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme), -D, Ocaml, Octave, R, Scilab, Common Lisp (CFFI). +D, Ocaml, Octave, R, Scilab. SWIG can also export its parse tree in the form of XML. Major applications of SWIG include generation of scripting language extension modules, rapid diff --git a/CHANGES.current b/CHANGES.current index 1505ac4e0..c64d4cc3c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-04: wsfulton + [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + 2019-02-04: wsfulton [Allegrocl] #1447 Allegro Common Lisp has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 1043a87be..18629a4f3 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -109,7 +109,6 @@ SWIGIMPORTED Defined when SWIG is importing a file with % SWIG_VERSION Hexadecimal (binary-coded decimal) number containing SWIG version, such as 0x010311 (corresponding to SWIG-1.3.11). -SWIGCFFI Defined when using CFFI SWIGCSHARP Defined when using C# SWIGGUILE Defined when using Guile SWIGJAVA Defined when using Java diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d55659d82..0de819639 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -118,7 +118,6 @@ for example, swig -ruby -help for Ruby.
           Supported Target Language Options
          -     -cffi           - Generate CFFI wrappers
                -csharp         - Generate C# wrappers
                -d              - Generate D wrappers
                -go             - Generate Go wrappers
          diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
          index 3d5369995..6558cd1f5 100644
          --- a/Doc/Manual/Sections.html
          +++ b/Doc/Manual/Sections.html
          @@ -46,7 +46,6 @@ Last update : SWIG-4.0.0 (in progress)
           
        • Guile support
        • Java support
        • Javascript support
        • -
        • Common Lisp support
        • Lua support
        • MzScheme/Racket support
        • Ocaml support
        • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 16e8f264b..9d1e2d909 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -24,7 +24,6 @@ Go.html Guile.html Java.html Javascript.html -Lisp.html Lua.html Mzscheme.html Ocaml.html diff --git a/Makefile.in b/Makefile.in index f3e596f8c..39816bed5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -71,7 +71,6 @@ skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" skip-csharp = test -n "@SKIP_CSHARP@" skip-lua = test -n "@SKIP_LUA@" -skip-cffi = test -n "@SKIP_CFFI@" skip-r = test -n "@SKIP_R@" skip-scilab = test -n "@SKIP_SCILAB@" skip-go = test -n "@SKIP_GO@" @@ -112,7 +111,6 @@ check-aliveness: @$(skip-octave) || ./$(TARGET) -octave -help @$(skip-php) || ./$(TARGET) -php7 -help @$(skip-csharp) || ./$(TARGET) -csharp -help - @$(skip-cffi) || ./$(TARGET) -cffi -help @$(skip-lua) || ./$(TARGET) -lua -help @$(skip-r) || ./$(TARGET) -r -help @$(skip-scilab) || ./$(TARGET) -scilab -help @@ -139,7 +137,6 @@ check-versions: \ check-php-version \ check-csharp-version \ check-lua-version \ - check-cffi-version \ check-r-version \ check-scilab-version \ check-go-version \ @@ -173,7 +170,6 @@ check-examples: \ check-php-examples \ check-csharp-examples \ check-lua-examples \ - check-cffi-examples \ check-r-examples \ check-scilab-examples \ check-go-examples \ @@ -193,7 +189,6 @@ octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list) php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) lua_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/lua/check.list) -cffi_examples := r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list) scilab_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/scilab/check.list) go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list) @@ -235,7 +230,6 @@ check-test-suite: \ check-php-test-suite \ check-csharp-test-suite \ check-lua-test-suite \ - check-cffi-test-suite \ check-r-test-suite \ check-scilab-test-suite \ check-go-test-suite \ @@ -283,7 +277,6 @@ all-test-suite: \ all-php-test-suite \ all-csharp-test-suite \ all-lua-test-suite \ - all-cffi-test-suite \ all-r-test-suite \ all-scilab-test-suite \ all-go-test-suite \ @@ -307,7 +300,6 @@ broken-test-suite: \ broken-php-test-suite \ broken-csharp-test-suite \ broken-lua-test-suite \ - broken-cffi-test-suite \ broken-r-test-suite \ broken-scilab-test-suite \ broken-go-test-suite \ @@ -444,7 +436,7 @@ install-main: @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ lib-languages = typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ - csharp lua cffi r go d javascript javascript/jsc \ + csharp lua r go d javascript javascript/jsc \ javascript/v8 scilab xml lib-modules = std diff --git a/README b/README index 925f79fe8..db468d8d4 100644 --- a/README +++ b/README @@ -4,8 +4,7 @@ Version: 4.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, - Octave, R, Scheme (Guile, MzScheme/Racket), Scilab, - Ocaml, Common Lisp (CFFI). + Octave, R, Scheme (Guile, MzScheme/Racket), Scilab, Ocaml. SWIG can also export its parse tree into XML. SWIG reads annotated C/C++ header files and creates wrapper code (glue diff --git a/Source/Makefile.am b/Source/Makefile.am index 189fa3c26..5cfb88839 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -47,7 +47,6 @@ eswig_SOURCES = CParse/cscanner.c \ Doxygen/pydoc.h \ Modules/allocate.cxx \ Modules/browser.cxx \ - Modules/cffi.cxx \ Modules/contract.cxx \ Modules/csharp.cxx \ Modules/d.cxx \ diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 9f8ba846a..00693d874 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -26,7 +26,6 @@ can be dynamically loaded in future versions. */ extern "C" { - Language *swig_cffi(void); Language *swig_csharp(void); Language *swig_d(void); Language *swig_go(void); @@ -57,7 +56,7 @@ static TargetLanguageModule modules[] = { {"-allegrocl", NULL, "ALLEGROCL", Disabled}, {"-chicken", NULL, "CHICKEN", Disabled}, {"-clisp", NULL, "CLISP", Disabled}, - {"-cffi", swig_cffi, "CFFI", Supported}, + {"-cffi", NULL, "CFFI", Disabled}, {"-csharp", swig_csharp, "C#", Supported}, {"-d", swig_d, "D", Supported}, {"-go", swig_go, "Go", Supported}, diff --git a/configure.ac b/configure.ac index 8d6f004a6..2b7289193 100644 --- a/configure.ac +++ b/configure.ac @@ -2673,12 +2673,6 @@ if test -z "$RBIN" ; then fi AC_SUBST(SKIP_R) -SKIP_CFFI= -#if test -z "$CFFIBIN" ; then - SKIP_CFFI="1" -#fi -AC_SUBST(SKIP_CFFI) - SKIP_SCILAB= if test -z "$SCILAB"; then SKIP_SCILAB="1" @@ -2801,7 +2795,6 @@ AC_CONFIG_FILES([ Examples/test-suite/scilab/Makefile Examples/test-suite/tcl/Makefile Examples/test-suite/lua/Makefile - Examples/test-suite/cffi/Makefile Examples/test-suite/r/Makefile Examples/test-suite/go/Makefile Source/Makefile @@ -2849,7 +2842,6 @@ EOF AC_OUTPUT langs="" -test -n "$SKIP_CFFI" || langs="${langs}cffi " test -n "$SKIP_CSHARP" || langs="${langs}csharp " test -n "$SKIP_D" || langs="${langs}d " test -n "$SKIP_GO" || langs="${langs}go " From 29d30bd31922420618050684a835b9a2b420e03c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Feb 2019 19:04:59 +0000 Subject: [PATCH 1358/2031] Consistent implementation for disabled languages The deprecated php4 and php5 use the new Disabled language handling recently implemented for a consistent implementation --- Source/Modules/php.cxx | 14 -------------- Source/Modules/swigmain.cxx | 6 ++---- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2b89223fa..386e48b52 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2861,17 +2861,3 @@ static Language *new_swig_php() { extern "C" Language *swig_php(void) { return new_swig_php(); } - -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. -} - -extern "C" Language *swig_php5(void) { - Printf(stderr, "*** -php5 is no longer supported.\n" - "*** Either upgrade to PHP7 or use SWIG < 4.0.0.\n"); - SWIG_exit(EXIT_FAILURE); - return NULL; // To avoid compiler warnings. -} diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 00693d874..e1ccaf598 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -38,8 +38,6 @@ extern "C" { Language *swig_octave(void); Language *swig_perl5(void); Language *swig_php(void); - Language *swig_php4(void); - Language *swig_php5(void); Language *swig_python(void); Language *swig_r(void); Language *swig_ruby(void); @@ -71,8 +69,8 @@ static TargetLanguageModule modules[] = { {"-perl", swig_perl5, "Perl", Supported}, {"-perl5", swig_perl5, NULL, Supported}, {"-php", swig_php, NULL, Supported}, - {"-php4", swig_php4, NULL, Supported}, - {"-php5", swig_php5, NULL, Supported}, + {"-php4", NULL, "PHP4", Disabled}, + {"-php5", NULL, "PHP5", Disabled}, {"-php7", swig_php, "PHP7", Supported}, {"-pike", NULL, "Pike", Disabled}, {"-python", swig_python, "Python", Supported}, From df86ec5af6985fc1ada3945237dcf34113db6512 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Feb 2019 19:18:46 +0000 Subject: [PATCH 1359/2031] Consistent use of target language version of options If a version number is supported by the target language prefer to show it in the -help. For example, -perl5 instead of -perl. --- Doc/Manual/Perl5.html | 2 +- Doc/Manual/SWIG.html | 6 +++--- Doc/Manual/Tcl.html | 2 +- Source/Modules/perl5.cxx | 2 +- Source/Modules/php.cxx | 2 +- Source/Modules/swigmain.cxx | 14 +++++++------- Source/Modules/tcl8.cxx | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 8bb65ec66..a3efdf609 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -122,7 +122,7 @@ options are found near the end of the chapter.

          -To build a Perl5 module, run SWIG using the -perl option as +To build a Perl5 module, run SWIG using the -perl or -perl5 option as follows:

          diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 0de819639..365cd2940 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -128,13 +128,13 @@ Supported Target Language Options -mzscheme - Generate Mzscheme wrappers -ocaml - Generate Ocaml wrappers -octave - Generate Octave wrappers - -perl - Generate Perl wrappers - -php7 - Generate PHP7 wrappers + -perl5 - Generate Perl 5 wrappers + -php7 - Generate PHP 7 wrappers -python - Generate Python wrappers -r - Generate R (aka GNU S) wrappers -ruby - Generate Ruby wrappers -scilab - Generate Scilab wrappers - -tcl - Generate Tcl wrappers + -tcl8 - Generate Tcl 8 wrappers -xml - Generate XML wrappers Experimental Target Language Options diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 7e7cd5f87..2eb49bde9 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -88,7 +88,7 @@ this is no longer supported.

          -To build a Tcl module, run SWIG using the -tcl option : +To build a Tcl module, run SWIG using the -tcl or -tcl8 option :

          diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
          index 9fa301a21..dfa85f3c8 100644
          --- a/Source/Modules/perl5.cxx
          +++ b/Source/Modules/perl5.cxx
          @@ -16,7 +16,7 @@
           #include 
           
           static const char *usage = "\
          -Perl5 Options (available with -perl5)\n\
          +Perl 5 Options (available with -perl5)\n\
                -compat         - Compatibility mode\n\
                -const          - Wrap constants as constants and not variables (implies -proxy)\n\
                -nopm           - Do not generate the .pm file\n\
          diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
          index 386e48b52..a3ea8003e 100644
          --- a/Source/Modules/php.cxx
          +++ b/Source/Modules/php.cxx
          @@ -43,7 +43,7 @@
           #include 
           
           static const char *usage = "\
          -PHP Options (available with -php7)\n\
          +PHP 7 Options (available with -php7)\n\
                -noproxy         - Don't generate proxy classes.\n\
                -prefix  - Prepend  to all class names in PHP wrappers\n\
           \n";
          diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
          index e1ccaf598..472264c26 100644
          --- a/Source/Modules/swigmain.cxx
          +++ b/Source/Modules/swigmain.cxx
          @@ -66,20 +66,20 @@ static TargetLanguageModule modules[] = {
             {"-mzscheme", swig_mzscheme, "Mzscheme", Supported},
             {"-ocaml", swig_ocaml, "Ocaml", Supported},
             {"-octave", swig_octave, "Octave", Supported},
          -  {"-perl", swig_perl5, "Perl", Supported},
          -  {"-perl5", swig_perl5, NULL, Supported},
          +  {"-perl", swig_perl5, NULL, Supported},
          +  {"-perl5", swig_perl5, "Perl 5", Supported},
             {"-php", swig_php, NULL, Supported},
          -  {"-php4", NULL, "PHP4", Disabled},
          -  {"-php5", NULL, "PHP5", Disabled},
          -  {"-php7", swig_php, "PHP7", Supported},
          +  {"-php4", NULL, "PHP 4", Disabled},
          +  {"-php5", NULL, "PHP 5", Disabled},
          +  {"-php7", swig_php, "PHP 7", Supported},
             {"-pike", NULL, "Pike", Disabled},
             {"-python", swig_python, "Python", Supported},
             {"-r", swig_r, "R (aka GNU S)", Supported},
             {"-ruby", swig_ruby, "Ruby", Supported},
             {"-scilab", swig_scilab, "Scilab", Supported},
             {"-sexp", NULL, "Lisp S-Expressions", Disabled},
          -  {"-tcl", swig_tcl, "Tcl", Supported},
          -  {"-tcl8", swig_tcl, NULL, Supported},
          +  {"-tcl", swig_tcl, NULL, Supported},
          +  {"-tcl8", swig_tcl, "Tcl 8", Supported},
             {"-uffi", NULL, "Common Lisp / UFFI", Disabled},
             {"-xml", swig_xml, "XML", Supported},
             {NULL, NULL, NULL, Disabled}
          diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
          index 57ef3e97b..7a78ede9b 100644
          --- a/Source/Modules/tcl8.cxx
          +++ b/Source/Modules/tcl8.cxx
          @@ -15,7 +15,7 @@
           #include "cparse.h"
           
           static const char *usage = "\
          -Tcl 8 Options (available with -tcl)\n\
          +Tcl 8 Options (available with -tcl8)\n\
                -itcl           - Enable ITcl support\n\
                -nosafe         - Leave out SafeInit module function.\n\
                -prefix   - Set a prefix  to be prepended to all names\n\
          
          From 828ce477c8e7791f718cb01616e0bf80c2773e02 Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Tue, 5 Feb 2019 13:35:43 -0700
          Subject: [PATCH 1360/2031] [OCaml] Fix a bug in the ctors of director classes
          
          If a class was given the director feature, it was not possible
          to use ctors with multiple parameters.
          
          Add director_default_runme.ml (it is based on
          director_default_runme.java).
          ---
           .../ocaml/director_default_runme.ml           | 25 +++++++++++++++++++
           Lib/ocaml/std_string.i                        |  5 ++++
           Lib/ocaml/swig.ml                             |  7 ++++++
           Lib/ocaml/swig.mli                            |  1 +
           Source/Modules/ocaml.cxx                      | 13 +++++-----
           5 files changed, 45 insertions(+), 6 deletions(-)
           create mode 100644 Examples/test-suite/ocaml/director_default_runme.ml
          
          diff --git a/Examples/test-suite/ocaml/director_default_runme.ml b/Examples/test-suite/ocaml/director_default_runme.ml
          new file mode 100644
          index 000000000..4fd655a00
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/director_default_runme.ml
          @@ -0,0 +1,25 @@
          +open Swig
          +open Director_default
          +
          +let director_default_MyFoo ob meth args =
          +  match meth with
          +      "Msg" -> (match args with
          +                  | C_list [ msg ] -> C_string ("director_default_MyFoo-" ^ (msg as string))
          +                  | _ -> raise (Failure "director_default_MyFoo::Msg()"))
          +    | _ -> (invoke ob) meth args
          +
          +let _ =
          +  let a = new_derived_object new_Foo (director_default_MyFoo) '(10) in
          +  assert (a -> GetMsg () as string = "director_default_MyFoo-default");
          +  assert (a -> GetMsg ("boo") as string = "director_default_MyFoo-boo");
          +  let f = new_Foo '(10) in
          +  assert (f -> GetMsg () as string = "Foo-default");
          +  assert (f -> GetMsg ("boo") as string = "Foo-boo");
          +
          +  let b = new_Bar '(1) in
          +  assert (b -> GetMsg () as string = "Bar-default");
          +  assert (b -> GetMsg ("boo") as string = "Bar-boo");
          +  let b2 = new_Bar '() in
          +  assert (b2 -> GetMsg () as string = "Bar-default");
          +  assert (b2 -> GetMsg ("boo") as string = "Bar-boo");
          +;;
          diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i
          index 770353052..0ea9b4e2d 100644
          --- a/Lib/ocaml/std_string.i
          +++ b/Lib/ocaml/std_string.i
          @@ -70,6 +70,11 @@ class wstring;
             swig_result =	caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size()));
           }
           
          +%typemap(directorin) string {
          +    swig_result = caml_val_string_len($1.c_str(), $1.size());
          +    args = caml_list_append(args, swig_result);
          +}
          +
           %typemap(directorout) string {
           	$result.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
           }
          diff --git a/Lib/ocaml/swig.ml b/Lib/ocaml/swig.ml
          index 8ac301dc6..58a93347b 100644
          --- a/Lib/ocaml/swig.ml
          +++ b/Lib/ocaml/swig.ml
          @@ -44,6 +44,13 @@ let _ = Callback.register "swig_runmethod" invoke
           let fnhelper arg =
             match arg with C_list l -> l | C_void -> [] | _ -> [ arg ]
           
          +let director_core_helper fnargs =
          +  try
          +    match List.hd fnargs with
          +      | C_director_core (o,r) -> fnargs
          +      | _ -> C_void :: fnargs
          +  with Failure _ -> C_void :: fnargs
          +
           let rec get_int x = 
             match x with
                 C_bool b -> if b then 1 else 0
          diff --git a/Lib/ocaml/swig.mli b/Lib/ocaml/swig.mli
          index 3207b9e73..c5ffadb15 100644
          --- a/Lib/ocaml/swig.mli
          +++ b/Lib/ocaml/swig.mli
          @@ -30,6 +30,7 @@ exception NoSuchClass of string
           
           val invoke : ('a c_obj_t) -> (string -> 'a c_obj_t -> 'a c_obj_t)
           val fnhelper : 'a c_obj_t -> 'a c_obj_t list
          +val director_core_helper : 'a c_obj_t list -> 'a c_obj_t list
           
           val get_int : 'a c_obj_t -> int
           val get_float : 'a c_obj_t -> float
          diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
          index 99f2a98d7..752e6231f 100644
          --- a/Source/Modules/ocaml.cxx
          +++ b/Source/Modules/ocaml.cxx
          @@ -752,14 +752,15 @@ public:
                 }
               }
           
          -    if (expose_func)
          -      Printf(f_mlbody,
          -	     "external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n"
          -	     "let %s arg = match %s_f (fnhelper arg) with\n"
          -	     "  [] -> C_void\n"
          +    if (expose_func) {
          +      Printf(f_mlbody, "external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n", mangled_name, wname);
          +      Printf(f_mlbody, "let %s arg = match %s_f (%s(fnhelper arg)) with\n", mangled_name, mangled_name,
          +	     in_constructor && Swig_directorclass(getCurrentClass()) ? "director_core_helper " : "");
          +      Printf(f_mlbody, "  [] -> C_void\n"
           	     "| [x] -> (if %s then Gc.finalise \n"
           	     "  (fun x -> ignore ((invoke x) \"~\" C_void)) x) ; x\n"
          -	     "| lst -> C_list lst ;;\n", mangled_name, wname, mangled_name, mangled_name, newobj ? "true" : "false");
          +	     "| lst -> C_list lst ;;\n", newobj ? "true" : "false");
          +    }
           
               if ((!classmode || in_constructor || in_destructor || static_member_function) && expose_func)
                 Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name);
          
          From 8c2cb4e60454122f38f8f21ed81ad20ae98196b5 Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Tue, 5 Feb 2019 15:08:35 -0700
          Subject: [PATCH 1361/2031] Add support for the C++11 u and U encoding prefixes
           for char literals
          
          "u" and "U" are new in C11 and C++11 for char literals.
          ---
           Examples/test-suite/cpp11_raw_string_literals.i | 3 +++
           Source/Swig/scanner.c                           | 4 ++++
           2 files changed, 7 insertions(+)
          
          diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i
          index 195d0551f..7c43e32d0 100644
          --- a/Examples/test-suite/cpp11_raw_string_literals.i
          +++ b/Examples/test-suite/cpp11_raw_string_literals.i
          @@ -47,6 +47,9 @@ wstring         aa =  L"Wide string";
           const char     *bb = u8"UTF-8 string";
           const char16_t *cc =  u"UTF-16 string";
           const char32_t *dd =  U"UTF-32 string";
          +// New char literals
          +char16_t uchar = u'a';
          +char32_t Uchar = U'b';
           %}
           
           /* Raw string literals */
          diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
          index 057bd8676..19cf25fe2 100644
          --- a/Source/Swig/scanner.c
          +++ b/Source/Swig/scanner.c
          @@ -938,6 +938,10 @@ static int look(Scanner *s) {
           	retract(s, 1);
           	state = 1000;
                 }
          +      else if (c == '\'') { /* Definitely u, U or L char */
          +	retract(s, 1);
          +	state = 77;
          +      }
                 else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */
           	state = 73;
                 }
          
          From d3b1211a928f77e1d0084677904f21711dbdb356 Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Tue, 5 Feb 2019 20:10:06 -0700
          Subject: [PATCH 1362/2031] [OCaml] Fix and re-enable typedef_mptr_runme.ml
          
          typedef_mptr_runme.ml was attempting to pass OCaml functions to
          do_op().
          
          Remove unneeded prints.
          ---
           Examples/test-suite/ocaml/Makefile.in         |  1 -
           .../test-suite/ocaml/typedef_mptr_runme.ml    | 21 ++++++++-----------
           2 files changed, 9 insertions(+), 13 deletions(-)
          
          diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
          index 650849815..e21db4c4f 100644
          --- a/Examples/test-suite/ocaml/Makefile.in
          +++ b/Examples/test-suite/ocaml/Makefile.in
          @@ -30,7 +30,6 @@ li_windows \
           member_pointer_const \
           preproc_constants \
           smart_pointer_inherit \
          -typedef_mptr \
           
           FAILING_C_TESTS = \
           enums \
          diff --git a/Examples/test-suite/ocaml/typedef_mptr_runme.ml b/Examples/test-suite/ocaml/typedef_mptr_runme.ml
          index 3bdaac4ba..36aafe695 100644
          --- a/Examples/test-suite/ocaml/typedef_mptr_runme.ml
          +++ b/Examples/test-suite/ocaml/typedef_mptr_runme.ml
          @@ -1,16 +1,13 @@
           open Swig
           open Typedef_mptr
           
          -let soci x = (string_of_int (get_int x))
          -
          -let x = new_Foo C_void 
          -let add_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _add ])
          -and sub_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _sub ])
           let _ =
          -  if add_res <> (C_int 3) || sub_res <> (C_int 1) then
          -    raise (Failure ("Bad result:" ^
          -		    " (add " ^ (soci add_res) ^ ") " ^
          -		    " (sub " ^ (soci sub_res) ^ ")"))
          -let _ = Printf.printf "2 + 1 = %d, 2 - 1 = %d\n" 
          -	  (get_int add_res)
          -	  (get_int sub_res)
          +  let f = new_Foo '() in
          +  let args = C_list [ C_int 2 ; C_int 1 ; _add '() ] in
          +  assert (f -> do_op (args) as int = 3);
          +  let args = C_list [ C_int 2 ; C_int 1 ; _sub '() ] in
          +  assert (f -> do_op (args) as int = 1);
          +
          +  assert (_do_op (C_list [ f ; C_int 2 ; C_int 1 ; _add '() ]) = C_int 3);
          +  assert (_do_op (C_list [ f ; C_int 2 ; C_int 1 ; _sub '() ]) = C_int 1);
          +;;
          
          From 4824b56e59007701ef7fd2ecb0536963eed91b32 Mon Sep 17 00:00:00 2001
          From: Seth R Johnson 
          Date: Wed, 6 Feb 2019 08:40:21 -0500
          Subject: [PATCH 1363/2031] Add test showing typemap failure
          
          ---
           Examples/test-suite/typemap_template.i | 26 +++++++++++++++++++++++++-
           1 file changed, 25 insertions(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/typemap_template.i b/Examples/test-suite/typemap_template.i
          index 7ef77c79d..221f821d2 100644
          --- a/Examples/test-suite/typemap_template.i
          +++ b/Examples/test-suite/typemap_template.i
          @@ -27,7 +27,7 @@ template struct TemplateTest1 {
           %template(TTint) TemplateTest1< int >;
           
           %inline %{
          -  void extratest(const TemplateTest1< YY > &t, 
          +  void extratest(const TemplateTest1< YY > &t,
                            const TemplateTest1< ZZ > &tt,
                            const TemplateTest1< int > &ttt)
             {}
          @@ -38,3 +38,27 @@ template struct TemplateTest1 {
           %inline %{
             void wasbug(TemplateTest1< int >::Double wbug) {}
           %}
          +
          +/* Test bug where the %apply directive was ignored inside anonymous template
          + * instantiations */
          +
          +template
          +struct Foo {
          +  %typemap(in) Foo ""
          +  %apply Foo { const Foo & }
          +};
          +
          +%{
          +template struct Foo {};
          +%}
          +
          +%template(Foo_int) Foo;
          +%template() Foo;
          +
          +%inline %{
          +  void this_works(Foo f) {}
          +  void this_also_works(const Foo& f) {}
          +  void this_also_also_works(Foo f) {}
          +  void this_fails(const Foo& f) {}
          +%}
          +
          
          From 373a21aa3fe0a144d4bd917864b7455127ff1c1d Mon Sep 17 00:00:00 2001
          From: Seth R Johnson 
          Date: Wed, 6 Feb 2019 08:41:10 -0500
          Subject: [PATCH 1364/2031] Fix failure of %apply directive in anonymous
           templates
          
          ---
           Examples/test-suite/typemap_template.i | 2 +-
           Source/CParse/parser.y                 | 2 +-
           2 files changed, 2 insertions(+), 2 deletions(-)
          
          diff --git a/Examples/test-suite/typemap_template.i b/Examples/test-suite/typemap_template.i
          index 221f821d2..9f283105b 100644
          --- a/Examples/test-suite/typemap_template.i
          +++ b/Examples/test-suite/typemap_template.i
          @@ -59,6 +59,6 @@ template struct Foo {};
             void this_works(Foo f) {}
             void this_also_works(const Foo& f) {}
             void this_also_also_works(Foo f) {}
          -  void this_fails(const Foo& f) {}
          +  void this_used_to_fail(const Foo& f) {}
           %}
           
          diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
          index ee121abec..29e5705bf 100644
          --- a/Source/CParse/parser.y
          +++ b/Source/CParse/parser.y
          @@ -2962,7 +2962,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
                                       Swig_cparse_template_expand(templnode,nname,temparms,tscope);
                                       Setattr(templnode,"sym:name",nname);
           			    Delete(nname);
          -                            Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment");
          +                            Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment,apply");
           			    if ($3) {
           			      Swig_warning(WARN_PARSE_NESTED_TEMPLATE, cparse_file, cparse_line, "Named nested template instantiations not supported. Processing as if no name was given to %%template().\n");
           			    }
          
          From b00ee788a205a8c4e13fcc590109d3ae648d660d Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Wed, 6 Feb 2019 09:53:37 -0700
          Subject: [PATCH 1365/2031] Fix the Java tests
          
          "uchar" and "Uchar" will both generate a getUchar() getter.
          ---
           Examples/test-suite/cpp11_raw_string_literals.i | 4 ++--
           1 file changed, 2 insertions(+), 2 deletions(-)
          
          diff --git a/Examples/test-suite/cpp11_raw_string_literals.i b/Examples/test-suite/cpp11_raw_string_literals.i
          index 7c43e32d0..b50b768b9 100644
          --- a/Examples/test-suite/cpp11_raw_string_literals.i
          +++ b/Examples/test-suite/cpp11_raw_string_literals.i
          @@ -48,8 +48,8 @@ const char     *bb = u8"UTF-8 string";
           const char16_t *cc =  u"UTF-16 string";
           const char32_t *dd =  U"UTF-32 string";
           // New char literals
          -char16_t uchar = u'a';
          -char32_t Uchar = U'b';
          +char16_t char16_t_char = u'a';
          +char32_t char32_t_char = U'b';
           %}
           
           /* Raw string literals */
          
          From e5b8b5a164f6eb5373128c4aad883b062ee75cfc Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Thu, 7 Feb 2019 16:25:10 -0700
          Subject: [PATCH 1366/2031] [OCaml] Some exception improvements
          
          The OCaml module's exception handling code was poorly designed,
          gave confusing exception messages, and was vulnerable to buffer
          overflows.
          
          The OCaml module's SWIG_exception_() was adding a useless newline to
          the end of the exception message.
          
          In some cases, the integer value of f.e. SWIG_TypeError was being added
          to the exception message.
          
          The unneeded else in the OCaml module's SWIG_contract_assert() macro
          was causing -Wmisleading-indentation warnings.
          
          The OCaml module's exception handling code now mirrors that of the
          Java module.
          
          Add Lib/ocaml/std_except.i.
          Add multiple runtime tests.
          ---
           Examples/test-suite/ocaml/catches_runme.ml    | 39 ++++++++++++++++
           .../ocaml/director_exception_runme.ml         | 46 +++++++++++++++++++
           .../ocaml/exception_classname_runme.ml        |  5 ++
           .../test-suite/ocaml/exception_order_runme.ml | 17 +++++++
           .../test-suite/ocaml/li_std_except_runme.ml   | 18 ++++++++
           .../test-suite/ocaml/swig_exception_runme.ml  | 13 ++++++
           .../test-suite/ocaml/throw_exception_runme.ml | 45 +++++++++---------
           Lib/exception.i                               | 43 ++++++++++++++---
           Lib/ocaml/ocamldec.swg                        | 39 +++++++++++++++-
           Lib/ocaml/std_except.i                        | 23 ++++++++++
           Lib/ocaml/typecheck.i                         | 15 +++---
           Lib/std_except.i                              |  2 +-
           12 files changed, 264 insertions(+), 41 deletions(-)
           create mode 100644 Examples/test-suite/ocaml/catches_runme.ml
           create mode 100644 Examples/test-suite/ocaml/director_exception_runme.ml
           create mode 100644 Examples/test-suite/ocaml/exception_classname_runme.ml
           create mode 100644 Examples/test-suite/ocaml/exception_order_runme.ml
           create mode 100644 Examples/test-suite/ocaml/li_std_except_runme.ml
           create mode 100644 Examples/test-suite/ocaml/swig_exception_runme.ml
           create mode 100644 Lib/ocaml/std_except.i
          
          diff --git a/Examples/test-suite/ocaml/catches_runme.ml b/Examples/test-suite/ocaml/catches_runme.ml
          new file mode 100644
          index 000000000..ab38e635d
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/catches_runme.ml
          @@ -0,0 +1,39 @@
          +open Swig
          +open Catches
          +
          +let _  =
          +  try
          +    ignore (_test_catches '(1)); assert false
          +  with Failure s ->
          +    assert (s = "C++ int exception thrown, value: 1")
          +
          +  try
          +    ignore (_test_catches '(2)); assert false
          +  with Failure s ->
          +    assert (s = "two")
          +
          +  try
          +    ignore (_test_catches '(3)); assert false
          +  with Failure s ->
          +    assert (s = "C++ ThreeException const & exception thrown")
          +
          +  try
          +    ignore (_test_exception_specification '(1)); assert false
          +  with Failure s ->
          +    assert (s = "C++ int exception thrown, value: 1")
          +
          +  try
          +    ignore (_test_exception_specification '(2)); assert false
          +  with Failure s ->
          +    assert (s = "unknown exception")
          +
          +  try
          +    ignore (_test_exception_specification '(3)); assert false
          +  with Failure s ->
          +    assert (s = "unknown exception")
          +
          +  try
          +    ignore (_test_catches_all '(1)); assert false
          +  with Failure s ->
          +    assert (s = "unknown exception")
          +;;
          diff --git a/Examples/test-suite/ocaml/director_exception_runme.ml b/Examples/test-suite/ocaml/director_exception_runme.ml
          new file mode 100644
          index 000000000..1cd769b20
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/director_exception_runme.ml
          @@ -0,0 +1,46 @@
          +open Swig
          +open Director_exception
          +
          +exception MyException of string * string
          +
          +let director_exception_MyFoo ob meth args =
          +  match meth with
          +      "ping" -> raise (Failure "MyFoo::ping() EXCEPTION")
          +    | _ -> (invoke ob) meth args
          +
          +let director_exception_MyFoo2 ob meth args =
          +  match meth with
          +      "ping" -> (C_bool true)
          +    | _ -> (invoke ob) meth args
          +
          +let director_exception_MyFoo3 ob meth args =
          +  match meth with
          +      "ping" -> raise (MyException ("foo", "bar"))
          +    | _ -> (invoke ob) meth args
          +
          +(* Check that Failure is raised by MyFoo.ping() (via MyFoo.pong()). *)
          +let a =
          +  new_derived_object
          +    new_Foo (director_exception_MyFoo) '()
          +let a = _launder(a)
          +try
          +  let _ = a -> pong () in assert false
          +with Failure s -> assert(s = "MyFoo::ping() EXCEPTION")
          +
          +let a =
          +  new_derived_object
          +    new_Foo (director_exception_MyFoo2) '()
          +let a = _launder(a)
          +try
          +  let _ = a -> pong () in assert false
          +with Failure s -> assert(s = "No appropriate conversion found.")
          +
          +let a =
          +  new_derived_object
          +    new_Foo (director_exception_MyFoo3) '()
          +let a = _launder(a)
          +try
          +  let _ = a -> pong () in assert false
          +with MyException (s1, s2) ->
          +  assert (s1 = "foo");
          +  assert (s2 = "bar");
          diff --git a/Examples/test-suite/ocaml/exception_classname_runme.ml b/Examples/test-suite/ocaml/exception_classname_runme.ml
          new file mode 100644
          index 000000000..8467ed6e8
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/exception_classname_runme.ml
          @@ -0,0 +1,5 @@
          +open Swig
          +open Exception_classname
          +
          +let a = new_Exception '()
          +assert (a -> testfunc () as int = 42)
          diff --git a/Examples/test-suite/ocaml/exception_order_runme.ml b/Examples/test-suite/ocaml/exception_order_runme.ml
          new file mode 100644
          index 000000000..728c3c315
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/exception_order_runme.ml
          @@ -0,0 +1,17 @@
          +open Swig
          +open Exception_order
          +
          +let a = new_A '()
          +
          +let check meth args expected =
          +  try
          +    ignore ((invoke a) meth (C_list [ args ])); assert false
          +  with Failure msg -> assert (msg = expected)
          +
          +let _ =
          +  check "foo" '() "C++ E1 exception thrown";
          +  check "bar" '() "C++ E2 exception thrown";
          +  check "foobar" '() "postcatch unknown";
          +  check "barfoo" (C_int 1) "C++ E1 exception thrown";
          +  check "barfoo" (C_int 2) "C++ E2 * exception thrown";
          +;;
          diff --git a/Examples/test-suite/ocaml/li_std_except_runme.ml b/Examples/test-suite/ocaml/li_std_except_runme.ml
          new file mode 100644
          index 000000000..e6ad14dc3
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/li_std_except_runme.ml
          @@ -0,0 +1,18 @@
          +open Swig
          +open Li_std_except
          +
          +let _ =
          +  let t = new_Test '() in
          +  try let _ = t -> throw_bad_cast () in assert false with Failure s -> ();
          +  try let _ = t -> throw_bad_exception () in assert false with Failure s -> ();
          +  try let _ = t -> throw_domain_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_exception () in assert false with Failure s -> ();
          +  try let _ = t -> throw_invalid_argument () in assert false with Invalid_argument s -> assert (s = "oops");
          +  try let _ = t -> throw_length_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_logic_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_out_of_range () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_overflow_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_range_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_runtime_error () in assert false with Failure s -> assert (s = "oops");
          +  try let _ = t -> throw_underflow_error () in assert false with Failure s -> assert (s = "oops");
          +;;
          diff --git a/Examples/test-suite/ocaml/swig_exception_runme.ml b/Examples/test-suite/ocaml/swig_exception_runme.ml
          new file mode 100644
          index 000000000..5bf36c36f
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/swig_exception_runme.ml
          @@ -0,0 +1,13 @@
          +open Swig
          +open Swig_exception
          +
          +let _ =
          +  let c = new_Circle '(10) and s = new_Square '(10) in
          +  assert (_Shape_nshapes '() as int = 2);
          +  try
          +    ignore (c -> throwException ()); assert false
          +  with Sys_error msg -> assert (msg = "OK");
          +  let _ = c -> "~" () in
          +  let _ = s -> "~" () in
          +  assert (_Shape_nshapes '() as int = 0);
          +;;
          diff --git a/Examples/test-suite/ocaml/throw_exception_runme.ml b/Examples/test-suite/ocaml/throw_exception_runme.ml
          index 8781926b6..8c2606129 100644
          --- a/Examples/test-suite/ocaml/throw_exception_runme.ml
          +++ b/Examples/test-suite/ocaml/throw_exception_runme.ml
          @@ -1,28 +1,25 @@
          -(* Throw exception test *)
          -
           open Swig
           open Throw_exception
           
          -let x = new_Foo C_void ;;
          -let _ =
          -  try
          -    (invoke x) "test_int" C_void 
          -  with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
          -  try 
          -    (invoke x) "test_msg" C_void
          -  with (Failure "Exception(0): Dead\n") ->
          -  try
          -    (invoke x) "test_cls" C_void 
          -  with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
          -  try
          -    (invoke x) "test_multi" (C_int 1)
          -  with (Failure "Exception(37): Thrown exception from C++ (int)\n") ->
          -  try
          -    (invoke x) "test_multi" (C_int 2)
          -  with (Failure "Exception(0): Dead\n") ->
          -  try
          -    (invoke x) "test_multi" (C_int 3)
          -  with (Failure "Exception(0): Thrown exception from C++ (unknown)\n") ->
          -    exit 0
          +let x = new_Foo '()
           
          -let _ = exit 1
          +let check meth args expected =
          +  try
          +    let _ = ((invoke x) meth (C_list [ args ])) in assert false
          +  with Failure msg -> assert (msg = expected)
          +
          +let _ =
          +  check "test_int" '() "C++ int exception thrown, value: 37";
          +  check "test_msg" '() "Dead";
          +  check "test_cls" '() "C++ CError exception thrown";
          +  check "test_cls_ptr" '() "C++ CError * exception thrown";
          +  check "test_cls_ref" '() "C++ CError & exception thrown";
          +  check "test_cls_td" '() "C++ Namespace::ErrorTypedef exception thrown";
          +  check "test_cls_ptr_td" '() "C++ Namespace::ErrorPtr exception thrown";
          +  check "test_cls_ref_td" '() "C++ Namespace::ErrorRef exception thrown";
          +  check "test_array" '() "C++ int [10] exception thrown";
          +  check "test_enum" '() "C++ Namespace::EnumTest exception thrown";
          +  check "test_multi" '(1) "C++ int exception thrown, value: 37";
          +  check "test_multi" '(2) "Dead";
          +  check "test_multi" '(3) "C++ CError exception thrown";
          +;;
          diff --git a/Lib/exception.i b/Lib/exception.i
          index c79a76c37..ee9ce9bc6 100644
          --- a/Lib/exception.i
          +++ b/Lib/exception.i
          @@ -127,13 +127,44 @@ SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
           
           #ifdef SWIGOCAML
           %{
          -#define OCAML_MSG_BUF_LEN 1024
          -SWIGINTERN void SWIG_exception_(int code, const char *msg) {
          -  char msg_buf[OCAML_MSG_BUF_LEN];
          -  sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
          -  caml_failwith( msg_buf );
          +SWIGINTERN void SWIG_OCamlException(int code, const char *msg) {
          +  CAMLparam0();
          +
          +  SWIG_OCamlExceptionCodes exception_code = SWIG_OCamlUnknownError;
          +  switch (code) {
          +  case SWIG_DivisionByZero:
          +    exception_code = SWIG_OCamlArithmeticException;
          +    break;
          +  case SWIG_IndexError:
          +    exception_code = SWIG_OCamlIndexOutOfBoundsException;
          +    break;
          +  case SWIG_IOError:
          +  case SWIG_SystemError:
          +    exception_code = SWIG_OCamlSystemException;
          +    break;
          +  case SWIG_MemoryError:
          +    exception_code = SWIG_OCamlOutOfMemoryError;
          +    break;
          +  case SWIG_OverflowError:
          +    exception_code = SWIG_OCamlOverflowException;
          +    break;
          +  case SWIG_RuntimeError:
          +    exception_code = SWIG_OCamlRuntimeException;
          +    break;
          +  case SWIG_SyntaxError:
          +  case SWIG_TypeError:
          +  case SWIG_ValueError:
          +    exception_code = SWIG_OCamlIllegalArgumentException;
          +    break;
          +  case SWIG_UnknownError:
          +  default:
          +    exception_code = SWIG_OCamlUnknownError;
          +    break;
          +  }
          +  SWIG_OCamlThrowException(exception_code, msg);
          +  CAMLreturn0;
           }
          -#define SWIG_exception(a,b) SWIG_exception_((a),(b))
          +#define SWIG_exception(code, msg) SWIG_OCamlException(code, msg)
           %}
           #endif
           
          diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg
          index 5294ef0ef..0c2faf771 100644
          --- a/Lib/ocaml/ocamldec.swg
          +++ b/Lib/ocaml/ocamldec.swg
          @@ -127,7 +127,44 @@ CAMLextern int64 Int64_val(caml_value_t v);
           #define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule(clientdata)
           #define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer)
           
          -#define SWIG_contract_assert(expr, msg) if(!(expr)) {caml_failwith(msg);} else
          +typedef enum {
          +  SWIG_OCamlArithmeticException,
          +  SWIG_OCamlDirectorPureVirtual,
          +  SWIG_OCamlOutOfMemoryError,
          +  SWIG_OCamlOverflowException,
          +  SWIG_OCamlIllegalArgumentException,
          +  SWIG_OCamlIndexOutOfBoundsException,
          +  SWIG_OCamlRuntimeException,
          +  SWIG_OCamlSystemException,
          +  SWIG_OCamlUnknownError
          +} SWIG_OCamlExceptionCodes;
          +
          +SWIGINTERN void SWIG_OCamlThrowException(SWIG_OCamlExceptionCodes code, const char *msg) {
          +  CAMLparam0();
          +  SWIG_CAMLlocal1(str);
          +
          +  switch (code) {
          +  case SWIG_OCamlIllegalArgumentException:
          +    caml_invalid_argument(msg);
          +    break;
          +  case SWIG_OCamlSystemException:
          +    str = caml_copy_string(msg);
          +    caml_raise_sys_error(str);
          +    break;
          +  case SWIG_OCamlArithmeticException:
          +  case SWIG_OCamlIndexOutOfBoundsException:
          +  case SWIG_OCamlOutOfMemoryError:
          +  case SWIG_OCamlOverflowException:
          +  case SWIG_OCamlRuntimeException:
          +  case SWIG_OCamlUnknownError:
          +  default:
          +    caml_failwith(msg);
          +    break;
          +  }
          +  CAMLreturn0;
          +}
          +
          +#define SWIG_contract_assert(expr, msg) if(!(expr)) {SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, msg);}
           
               SWIGINTERN int
               SWIG_GetPtr(void *source, void **result, swig_type_info *type, swig_type_info *result_type);
          diff --git a/Lib/ocaml/std_except.i b/Lib/ocaml/std_except.i
          new file mode 100644
          index 000000000..74ddcb51d
          --- /dev/null
          +++ b/Lib/ocaml/std_except.i
          @@ -0,0 +1,23 @@
          +%{
          +#include 
          +#include 
          +%}
          +
          +namespace std
          +{
          +  %ignore exception;
          +  struct exception {};
          +}
          +
          +%typemap(throws) std::bad_cast          "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::bad_exception     "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::domain_error      "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::exception         "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::invalid_argument  "SWIG_OCamlThrowException(SWIG_OCamlIllegalArgumentException, $1.what());"
          +%typemap(throws) std::length_error      "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
          +%typemap(throws) std::logic_error       "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::out_of_range      "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
          +%typemap(throws) std::overflow_error    "SWIG_OCamlThrowException(SWIG_OCamlArithmeticException, $1.what());"
          +%typemap(throws) std::range_error       "SWIG_OCamlThrowException(SWIG_OCamlIndexOutOfBoundsException, $1.what());"
          +%typemap(throws) std::runtime_error     "SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1.what());"
          +%typemap(throws) std::underflow_error   "SWIG_OCamlThrowException(SWIG_OCamlArithmeticException, $1.what());"
          diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i
          index 416fd9495..2cc8dcbec 100644
          --- a/Lib/ocaml/typecheck.i
          +++ b/Lib/ocaml/typecheck.i
          @@ -163,19 +163,16 @@
                             unsigned int, 
                             unsigned long, 
                             unsigned short {
          -  SWIG_exception($1,"Thrown exception from C++ (int)");
          +  char error_msg[256];
          +  sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
          +  SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, error_msg);
           }
           
          -%typemap(throws) SWIGTYPE CLASS {
          -  $&1_ltype temp = new $1_ltype($1);
          -  SWIG_exception((int)temp,"Thrown exception from C++ (object)");
          -}
          -
          -%typemap(throws) SWIGTYPE {
          +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] {
             (void)$1;
          -  SWIG_exception(0,"Thrown exception from C++ (unknown)");
          +  SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, "C++ $1_type exception thrown");
           }
           
           %typemap(throws) char * {
          -  SWIG_exception(0,$1);
          +  SWIG_OCamlThrowException(SWIG_OCamlRuntimeException, $1);
           }
          diff --git a/Lib/std_except.i b/Lib/std_except.i
          index 50b5a88a2..0f8b23e70 100644
          --- a/Lib/std_except.i
          +++ b/Lib/std_except.i
          @@ -19,7 +19,7 @@
            * a new std_except.i file in the target library directory.
            * ----------------------------------------------------------------------------- */
           
          -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD)
          +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD) || defined(SWIGOCAML)
           #error "This version of std_except.i should not be used"
           #endif
           
          
          From c199b173f8dd2a058fa417b2373252dfbe7c176d Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 14:37:14 +1300
          Subject: [PATCH 1367/2031] configure: Look for php7.2 and php7.3
          
          ---
           configure.ac | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/configure.ac b/configure.ac
          index 2b7289193..6380260f1 100644
          --- a/configure.ac
          +++ b/configure.ac
          @@ -2002,7 +2002,7 @@ if test x"${PHPBIN}" = xno; then
               PHP=
           else
               if test "x$PHPBIN" = xyes; then
          -      AC_CHECK_PROGS(PHP, [php7.1 php7.0 php])
          +      AC_CHECK_PROGS(PHP, [php7.3 php7.2 php7.1 php7.0 php])
               else
                 PHP=$PHPBIN
               fi
          
          From ebc9e6ad9f0ec60d229dd5c3348d0b914fa0fd7a Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 14:37:44 +1300
          Subject: [PATCH 1368/2031] [php] Eliminate use of unset constants in example
          
          This generates a warning with PHP 7.3 which apparently will become
          an error in the future.  We're just checking that a constant that
          should not be define indeed isn't, which we can achieve more
          cleanly using get_defined_constants() instead.
          ---
           Examples/php/constants/runme.php | 14 +++++---------
           1 file changed, 5 insertions(+), 9 deletions(-)
          
          diff --git a/Examples/php/constants/runme.php b/Examples/php/constants/runme.php
          index cea06485f..91c597a40 100644
          --- a/Examples/php/constants/runme.php
          +++ b/Examples/php/constants/runme.php
          @@ -12,16 +12,12 @@ print "EXPR    = " . EXPR  . " (should be 48.5484)\n";
           print "iconst  = " . iconst . " (should be 37)\n";
           print "fconst  = " . fconst . " (should be 3.14)\n";
           
          -if (EXTERN!="EXTERN") {
          -    print "EXTERN = " . EXTERN . " (Arg! This shouldn't print anything)\n";
          -} else {
          -    print "EXTERN defaults to 'EXTERN', it probably isn't defined (good)\n";
          +$c = get_defined_constants();
          +if (array_key_exists("EXTERN", $c)) {
          +    print "EXTERN = " . $c["EXTERN"] . " (Arg! This shouldn't print anything)\n";
           }
          -
          -if (FOO!="FOO") {
          -    print "FOO    = " . FOO . "(Arg! This shouldn't print anything)\n";
          -} else {
          -    print "FOO defaults to 'FOO', it probably isn't defined (good)\n";
          +if (array_key_exists("FOO", $c)) {
          +    print "FOO    = " . $c["FOO"] . " (Arg! This shouldn't print anything)\n";
           }
           
           
          
          From 89c6c01c40ba24830204fe004ad9c25b97ab7754 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 14:49:23 +1300
          Subject: [PATCH 1369/2031] [php] Fix function constants for PHP 7.3
          
          The code we were generating no longer compiled.
          ---
           Lib/php/const.i    | 3 +--
           Lib/php/phprun.swg | 7 +++++++
           2 files changed, 8 insertions(+), 2 deletions(-)
          
          diff --git a/Lib/php/const.i b/Lib/php/const.i
          index d62f162c1..32b4b9b0b 100644
          --- a/Lib/php/const.i
          +++ b/Lib/php/const.i
          @@ -39,8 +39,7 @@
             SWIG_SetPointerZval(&c.value, (void*)$value, $1_descriptor, 0);
             zval_copy_ctor(&c.value);
             c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);
          -  c.flags = CONST_CS;
          -  c.module_number = module_number;
          +  SWIG_ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
             zend_register_constant(&c);
           }
           
          diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
          index 44276acc5..6418d0734 100644
          --- a/Lib/php/phprun.swg
          +++ b/Lib/php/phprun.swg
          @@ -32,6 +32,13 @@ extern "C" {
               REGISTER_STRINGL_CONSTANT(#N, &swig_char, 1, CONST_CS | CONST_PERSISTENT);\
           } while (0)
           
          +/* ZEND_CONSTANT_SET_FLAGS is new in PHP 7.3. */
          +#ifdef ZEND_CONSTANT_SET_FLAGS
          +# define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
          +#else
          +# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C).flags = (F); (C).module_number = (N); } while (0)
          +#endif
          +
           #ifdef __cplusplus
           }
           #endif
          
          From 21b3c06de664f3f29a24f4a0598bfc5f55115ff9 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 14:56:39 +1300
          Subject: [PATCH 1370/2031] [php] Fix test failures due to undefined GETSET
           constant
          
          Move the constant into the class - the definition outside the class
          doesn't seem to work with PHP 7.3.
          ---
           Examples/test-suite/php/tests.php | 18 +++++++++---------
           1 file changed, 9 insertions(+), 9 deletions(-)
          
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index 92939c71c..f1d5179c4 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -1,15 +1,15 @@
           
          Date: Fri, 8 Feb 2019 15:32:30 +1300
          Subject: [PATCH 1371/2031] [php] Fix widespread use of bare strings in
           testsuite
          
          These generate warnings with PHP 7.3, which will become errors in a
          future version.
          ---
           .../php/abstract_inherit_ok_runme.php          |  2 +-
           .../test-suite/php/abstract_inherit_runme.php  |  2 +-
           Examples/test-suite/php/add_link_runme.php     |  8 ++++----
           Examples/test-suite/php/argout_runme.php       |  2 +-
           Examples/test-suite/php/arrayptr_runme.php     |  2 +-
           .../test-suite/php/arrays_global_runme.php     | 18 +++++++++---------
           .../php/arrays_global_twodim_runme.php         |  8 ++++----
           Examples/test-suite/php/arrays_runme.php       |  6 +++---
           Examples/test-suite/php/arrays_scope_runme.php |  6 +++---
           Examples/test-suite/php/casts_runme.php        |  4 ++--
           Examples/test-suite/php/class_ignore_runme.php |  4 ++--
           Examples/test-suite/php/cpp_basic_runme.php    |  6 +++---
           Examples/test-suite/php/cpp_static_runme.php   |  6 +++---
           .../test-suite/php/director_abstract_runme.php |  4 ++--
           .../test-suite/php/director_basic_runme.php    |  6 +++---
           .../test-suite/php/director_classic_runme.php  |  4 ++--
           .../test-suite/php/director_default_runme.php  |  4 ++--
           .../test-suite/php/director_detect_runme.php   |  4 ++--
           .../test-suite/php/director_enum_runme.php     |  4 ++--
           .../php/director_exception_runme.php           |  4 ++--
           .../test-suite/php/director_extend_runme.php   |  4 ++--
           .../php/director_finalizer_runme.php           |  6 +++---
           .../test-suite/php/director_frob_runme.php     |  6 +++---
           .../test-suite/php/director_nested_runme.php   |  4 ++--
           .../test-suite/php/director_profile_runme.php  |  4 ++--
           .../php/director_protected_runme.php           |  6 +++---
           Examples/test-suite/php/director_stl_runme.php |  4 ++--
           .../test-suite/php/director_string_runme.php   |  6 +++---
           .../test-suite/php/director_thread_runme.php   |  6 +++---
           .../test-suite/php/director_unroll_runme.php   |  6 +++---
           .../test-suite/php/exception_order_runme.php   |  6 +++---
           Examples/test-suite/php/grouping_runme.php     |  6 +++---
           .../test-suite/php/ignore_parameter_runme.php  |  4 ++--
           .../test-suite/php/import_nomodule_runme.php   |  4 ++--
           .../test-suite/php/li_carrays_cpp_runme.php    |  6 +++---
           Examples/test-suite/php/li_carrays_runme.php   |  6 +++---
           Examples/test-suite/php/li_factory_runme.php   |  4 ++--
           Examples/test-suite/php/newobject1_runme.php   |  4 ++--
           .../test-suite/php/overload_rename_runme.php   |  2 +-
           Examples/test-suite/php/php_iterator_runme.php |  4 ++--
           Examples/test-suite/php/prefix_runme.php       |  4 ++--
           Examples/test-suite/php/sym_runme.php          |  2 +-
           .../php/template_arg_typename_runme.php        |  2 +-
           .../php/template_construct_runme.php           |  2 +-
           Examples/test-suite/php/tests.php              |  4 ++--
           .../test-suite/php/threads_exception_runme.php |  6 +++---
           .../test-suite/php/typedef_reference_runme.php |  2 +-
           47 files changed, 112 insertions(+), 112 deletions(-)
          
          diff --git a/Examples/test-suite/php/abstract_inherit_ok_runme.php b/Examples/test-suite/php/abstract_inherit_ok_runme.php
          index c2d86499b..c2c343dac 100644
          --- a/Examples/test-suite/php/abstract_inherit_ok_runme.php
          +++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php
          @@ -3,7 +3,7 @@
           require "tests.php";
           require "abstract_inherit_ok.php";
           
          -check::classes(array(Foo,Spam));
          +check::classes(array('Foo','Spam'));
           $spam=new Spam();
           
           check::equal(0,$spam->blah(),"spam object method");
          diff --git a/Examples/test-suite/php/abstract_inherit_runme.php b/Examples/test-suite/php/abstract_inherit_runme.php
          index 3554e6fd8..514bbc3b0 100644
          --- a/Examples/test-suite/php/abstract_inherit_runme.php
          +++ b/Examples/test-suite/php/abstract_inherit_runme.php
          @@ -3,7 +3,7 @@
           require "tests.php";
           require "abstract_inherit.php";
           
          -check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
          +check::classes(array('Foo','Bar','Spam','NRFilter_i','NRRCFilter_i','NRRCFilterpro_i','NRRCFilterpri_i'));
           // This constructor attempt should fail as there isn't one
           //$spam=new Spam();
           
          diff --git a/Examples/test-suite/php/add_link_runme.php b/Examples/test-suite/php/add_link_runme.php
          index 7523bd604..3e16fa1df 100644
          --- a/Examples/test-suite/php/add_link_runme.php
          +++ b/Examples/test-suite/php/add_link_runme.php
          @@ -4,15 +4,15 @@ require "tests.php";
           require "add_link.php";
           
           // No new functions, except the flat functions
          -check::functions(array(new_foo,foo_blah));
          +check::functions(array('new_foo','foo_blah'));
           
          -check::classes(array(Foo));
          +check::classes(array('Foo'));
           
           $foo=new foo();
          -check::is_a($foo,foo);
          +check::is_a($foo,'foo');
           
           $foo_blah=$foo->blah();
          -check::is_a($foo_blah,foo);
          +check::is_a($foo_blah,'foo');
           
           //fails, can't be called as a class method, should allow and make it nil?
           //$class_foo_blah=foo::blah();
          diff --git a/Examples/test-suite/php/argout_runme.php b/Examples/test-suite/php/argout_runme.php
          index 33fbd8129..baf4b164e 100644
          --- a/Examples/test-suite/php/argout_runme.php
          +++ b/Examples/test-suite/php/argout_runme.php
          @@ -3,7 +3,7 @@
           require "tests.php";
           require "argout.php";
           
          -check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
          +check::functions(array('incp','incr','inctr','new_intp','copy_intp','delete_intp','intp_assign','intp_value','voidhandle','handle'));
           
           $ip=copy_intp(42);
           check::equal(42,incp($ip),"42==incp($ip)");
          diff --git a/Examples/test-suite/php/arrayptr_runme.php b/Examples/test-suite/php/arrayptr_runme.php
          index 3b9baed05..86b7f8628 100644
          --- a/Examples/test-suite/php/arrayptr_runme.php
          +++ b/Examples/test-suite/php/arrayptr_runme.php
          @@ -4,7 +4,7 @@ require "tests.php";
           require "arrayptr.php";
           
           // No new functions
          -check::functions(array(foo));
          +check::functions(array('foo'));
           // No new classes
           check::classes(array());
           // now new vars
          diff --git a/Examples/test-suite/php/arrays_global_runme.php b/Examples/test-suite/php/arrays_global_runme.php
          index 12a7806c9..95a300775 100644
          --- a/Examples/test-suite/php/arrays_global_runme.php
          +++ b/Examples/test-suite/php/arrays_global_runme.php
          @@ -3,17 +3,17 @@
           require "tests.php";
           require "arrays_global.php";
           
          -check::functions(array(test_a,test_b,new_simplestruct,new_material));
          -check::classes(array(arrays_global,SimpleStruct,Material));
          -check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat,simplestruct_double_field));
          +check::functions(array('test_a','test_b','new_simplestruct','new_material'));
          +check::classes(array('arrays_global','SimpleStruct','Material'));
          +check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','beginstring_fix44a','beginstring_fix44b','beginstring_fix44c','beginstring_fix44d','beginstring_fix44e','beginstring_fix44f','chitmat','hitmat_val','hitmat','simplestruct_double_field'));
           // The size of array_c is 2, but the last byte is \0, so we can only store a
           // single byte string in it.
          -check::set(array_c,"Z");
          -check::equal("Z",check::get(array_c),"set array_c");
          -check::set(array_c,"xy");
          -check::equal("x",check::get(array_c),"set array_c");
          -check::set(array_c,"h");
          -check::equal("h",check::get(array_c),"set array_c");
          +check::set("array_c","Z");
          +check::equal("Z",check::get("array_c"),"set array_c");
          +check::set("array_c","xy");
          +check::equal("x",check::get("array_c"),"set array_c");
          +check::set("array_c","h");
          +check::equal("h",check::get("array_c"),"set array_c");
           
           check::done();
           ?>
          diff --git a/Examples/test-suite/php/arrays_global_twodim_runme.php b/Examples/test-suite/php/arrays_global_twodim_runme.php
          index 40ecf1719..d9f50a6de 100644
          --- a/Examples/test-suite/php/arrays_global_twodim_runme.php
          +++ b/Examples/test-suite/php/arrays_global_twodim_runme.php
          @@ -3,14 +3,14 @@
           require "tests.php";
           require "arrays_global_twodim.php";
           
          -check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
          -check::classes(array(arrays_global_twodim,SimpleStruct,Material));
          -check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat,simplestruct_double_field));
          +check::functions(array('fn_taking_arrays','get_2d_array','new_simplestruct','new_material'));
          +check::classes(array('arrays_global_twodim','SimpleStruct','Material'));
          +check::globals(array('array_c','array_sc','array_uc','array_s','array_us','array_i','array_ui','array_l','array_ul','array_ll','array_f','array_d','array_struct','array_structpointers','array_ipointers','array_enum','array_enumpointers','array_const_i','chitmat','hitmat_val','hitmat','simplestruct_double_field'));
           $a1=array(10,11,12,13);
           $a2=array(14,15,16,17);
           $a=array($a1,$a2);
           
          -$_a=check::get(array_const_i);
          +$_a=check::get('array_const_i');
           
           for($x=0;$xfunc_ptr = get_func1_ptr();
          diff --git a/Examples/test-suite/php/cpp_static_runme.php b/Examples/test-suite/php/cpp_static_runme.php
          index 9b436b87c..1d581bdb9 100644
          --- a/Examples/test-suite/php/cpp_static_runme.php
          +++ b/Examples/test-suite/php/cpp_static_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "cpp_static.php";
           
           // New functions
          -check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3,is_python_builtin));
          +check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin'));
           // New classes
          -check::classes(array(StaticMemberTest,StaticFunctionTest,cpp_static,StaticBase,StaticDerived));
          +check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived'));
           // New vars
          -check::globals(array(staticmembertest_static_int,staticbase_statty,staticderived_statty));
          +check::globals(array('staticmembertest_static_int','staticbase_statty','staticderived_statty'));
           
           check::done();
           ?>
          diff --git a/Examples/test-suite/php/director_abstract_runme.php b/Examples/test-suite/php/director_abstract_runme.php
          index ca3d676da..1a119cfd5 100644
          --- a/Examples/test-suite/php/director_abstract_runme.php
          +++ b/Examples/test-suite/php/director_abstract_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_abstract.php";
           
           // No new functions
          -check::functions(array(foo_ping,foo_pong,example0_getxsize,example0_color,example0_get_color,example1_getxsize,example1_color,example1_get_color,example2_getxsize,example2_color,example2_get_color,example4_getxsize,example4_color,example4_get_color,example3_i_color,example3_i_get_color,g,a_f));
          +check::functions(array('foo_ping','foo_pong','example0_getxsize','example0_color','example0_get_color','example1_getxsize','example1_color','example1_get_color','example2_getxsize','example2_color','example2_get_color','example4_getxsize','example4_color','example4_get_color','example3_i_color','example3_i_get_color','g','a_f'));
           // No new classes
          -check::classes(array(director_abstract,Foo,Example0,Example1,Example2,Example4,Example3_i,A));
          +check::classes(array('director_abstract','Foo','Example0','Example1','Example2','Example4','Example3_i','A'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_basic_runme.php b/Examples/test-suite/php/director_basic_runme.php
          index af6110103..478a36f80 100644
          --- a/Examples/test-suite/php/director_basic_runme.php
          +++ b/Examples/test-suite/php/director_basic_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "director_basic.php";
           
           // No new functions
          -check::functions(array(foo_ping,foo_pong,foo_get_self,a_f,a_rg,a1_ff,myclass_method,myclass_vmethod,myclass_pmethod,myclass_cmethod,myclass_get_self,myclass_call_pmethod,myclasst_i_method,myclass_nonvirtual,myclass_nonoverride,myclass_call_nonvirtual,myclass_call_nonoverride,myclass_connect));
          +check::functions(array('foo_ping','foo_pong','foo_get_self','a_f','a_rg','a1_ff','myclass_method','myclass_vmethod','myclass_pmethod','myclass_cmethod','myclass_get_self','myclass_call_pmethod','myclasst_i_method','myclass_nonvirtual','myclass_nonoverride','myclass_call_nonvirtual','myclass_call_nonoverride','myclass_connect'));
           // No new classes
          -check::classes(array(Foo,A,A1,Bar,MyClass,MyClassT_i));
          +check::classes(array('Foo','A','A1','Bar','MyClass','MyClassT_i'));
           // now new vars
          -check::globals(array(bar_x));
          +check::globals(array('bar_x'));
           
           class PhpFoo extends Foo {
             function ping() {
          diff --git a/Examples/test-suite/php/director_classic_runme.php b/Examples/test-suite/php/director_classic_runme.php
          index d2da1b1ba..a44881e04 100644
          --- a/Examples/test-suite/php/director_classic_runme.php
          +++ b/Examples/test-suite/php/director_classic_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_classic.php";
           
           // No new functions
          -check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
          +check::functions(array('being_id','person_id','child_id','grandchild_id','caller_delcallback','caller_setcallback','caller_resetcallback','caller_call','caller_baseclass'));
           // No new classes
          -check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
          +check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_default_runme.php b/Examples/test-suite/php/director_default_runme.php
          index f97fc7425..c459ce3ec 100644
          --- a/Examples/test-suite/php/director_default_runme.php
          +++ b/Examples/test-suite/php/director_default_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_default.php";
           
           // No new functions
          -check::functions(array(foo_msg,foo_getmsg,bar_msg,bar_getmsg,defaultsbase_defaultargs,defaultsderived_defaultargs));
          +check::functions(array('foo_msg','foo_getmsg','bar_msg','bar_getmsg','defaultsbase_defaultargs','defaultsderived_defaultargs'));
           // No new classes
          -check::classes(array(Foo,Bar,DefaultsBase,DefaultsDerived));
          +check::classes(array('Foo','Bar','DefaultsBase','DefaultsDerived'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_detect_runme.php b/Examples/test-suite/php/director_detect_runme.php
          index cc19c0302..a6d3aebd6 100644
          --- a/Examples/test-suite/php/director_detect_runme.php
          +++ b/Examples/test-suite/php/director_detect_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_detect.php";
           
           // No new functions
          -check::functions(array(foo_cloner,foo_get_value,foo_get_class,foo_just_do_it,bar_baseclass,bar_cloner,bar_get_value,bar_get_class,bar_just_do_it));
          +check::functions(array('foo_cloner','foo_get_value','foo_get_class','foo_just_do_it','bar_baseclass','bar_cloner','bar_get_value','bar_get_class','bar_just_do_it'));
           // No new classes
          -check::classes(array(A,Foo,Bar));
          +check::classes(array('A','Foo','Bar'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_enum_runme.php b/Examples/test-suite/php/director_enum_runme.php
          index 8f6487a28..0571ec0da 100644
          --- a/Examples/test-suite/php/director_enum_runme.php
          +++ b/Examples/test-suite/php/director_enum_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_enum.php";
           
           // No new functions
          -check::functions(array(foo_say_hello,foo_say_hi,foo_say_bye,foo_say_hi_ref,foo_ping,foo_ping_ref,foo_ping_member_enum,a_f,a2_f));
          +check::functions(array('foo_say_hello','foo_say_hi','foo_say_bye','foo_say_hi_ref','foo_ping','foo_ping_ref','foo_ping_member_enum','a_f','a2_f'));
           // No new classes
          -check::classes(array(director_enum,Foo,A,B,A2,B2));
          +check::classes(array('director_enum','Foo','A','B','A2','B2'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php
          index 47f645b07..dd2d04e8a 100644
          --- a/Examples/test-suite/php/director_exception_runme.php
          +++ b/Examples/test-suite/php/director_exception_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_exception.php";
           
           // No new functions
          -check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
          +check::functions(array('foo_ping','foo_pong','launder','bar_ping','bar_pong','returnalltypes_return_int','returnalltypes_return_double','returnalltypes_return_const_char_star','returnalltypes_return_std_string','returnalltypes_return_bar','returnalltypes_call_int','returnalltypes_call_double','returnalltypes_call_const_char_star','returnalltypes_call_std_string','returnalltypes_call_bar','is_python_builtin'));
           // No new classes
          -check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
          +check::classes(array('director_exception','Foo','Exception1','Exception2','Base','Bar','ReturnAllTypes'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_extend_runme.php b/Examples/test-suite/php/director_extend_runme.php
          index f283aefbe..7aa2e0f78 100644
          --- a/Examples/test-suite/php/director_extend_runme.php
          +++ b/Examples/test-suite/php/director_extend_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_extend.php";
           
           // No new functions
          -check::functions(array(spobject_getfoobar,spobject_dummy,spobject_exceptionmethod));
          +check::functions(array('spobject_getfoobar','spobject_dummy','spobject_exceptionmethod'));
           // No new classes
          -check::classes(array(SpObject));
          +check::classes(array('SpObject'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_finalizer_runme.php b/Examples/test-suite/php/director_finalizer_runme.php
          index 0fcddfd8b..96bb5c179 100644
          --- a/Examples/test-suite/php/director_finalizer_runme.php
          +++ b/Examples/test-suite/php/director_finalizer_runme.php
          @@ -4,16 +4,16 @@ require "tests.php";
           require "director_finalizer.php";
           
           // No new functions
          -check::functions(array(foo_orstatus,deletefoo,getstatus,launder,resetstatus));
          +check::functions(array('foo_orstatus','deletefoo','getstatus','launder','resetstatus'));
           // No new classes
          -check::classes(array(director_finalizer,Foo));
          +check::classes(array('director_finalizer','Foo'));
           // now new vars
           check::globals(array());
           
           class MyFoo extends Foo {
             function __destruct() {
               $this->orStatus(2);
          -    if (method_exists(parent, "__destruct")) {
          +    if (method_exists(get_parent_class(), "__destruct")) {
                 parent::__destruct();
               }
             }
          diff --git a/Examples/test-suite/php/director_frob_runme.php b/Examples/test-suite/php/director_frob_runme.php
          index 548b0b804..450a1234b 100644
          --- a/Examples/test-suite/php/director_frob_runme.php
          +++ b/Examples/test-suite/php/director_frob_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "director_frob.php";
           
           // No new functions
          -check::functions(array(alpha_abs_method,bravo_abs_method,charlie_abs_method,ops_opint,ops_opintstarstarconst,ops_opintamp,ops_opintstar,ops_opconstintintstar,prims_ull,prims_callull,corecallbacks_on3dengineredrawn,corecallbacks_on3dengineredrawn2));
          +check::functions(array('alpha_abs_method','bravo_abs_method','charlie_abs_method','ops_opint','ops_opintstarstarconst','ops_opintamp','ops_opintstar','ops_opconstintintstar','prims_ull','prims_callull','corecallbacks_on3dengineredrawn','corecallbacks_on3dengineredrawn2'));
           // No new classes
          -check::classes(array(Alpha,Bravo,Charlie,Delta,Ops,Prims,corePoint3d,coreCallbacks_On3dEngineRedrawnData,coreCallbacksOn3dEngineRedrawnData,coreCallbacks));
          +check::classes(array('Alpha','Bravo','Charlie','Delta','Ops','Prims','corePoint3d','coreCallbacks_On3dEngineRedrawnData','coreCallbacksOn3dEngineRedrawnData','coreCallbacks'));
           // now new vars
          -check::globals(array(corecallbacks_on3dengineredrawndata__eye,corecallbacks_on3dengineredrawndata__at,corecallbackson3dengineredrawndata__eye,corecallbackson3dengineredrawndata__at));
          +check::globals(array('corecallbacks_on3dengineredrawndata__eye','corecallbacks_on3dengineredrawndata__at','corecallbackson3dengineredrawndata__eye','corecallbackson3dengineredrawndata__at'));
           
           $foo = new Bravo();
           $s = $foo->abs_method();
          diff --git a/Examples/test-suite/php/director_nested_runme.php b/Examples/test-suite/php/director_nested_runme.php
          index 4965e94f7..9a094a182 100644
          --- a/Examples/test-suite/php/director_nested_runme.php
          +++ b/Examples/test-suite/php/director_nested_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_nested.php";
           
           // No new functions
          -check::functions(array(foo_int_advance,foo_int_do_advance,bar_step,bar_do_advance,bar_do_step,foobar_int_get_value,foobar_int_get_name,foobar_int_name,foobar_int_get_self,foobar_int_do_advance,foobar_int_do_step));
          +check::functions(array('foo_int_advance','foo_int_do_advance','bar_step','bar_do_advance','bar_do_step','foobar_int_get_value','foobar_int_get_name','foobar_int_name','foobar_int_get_self','foobar_int_do_advance','foobar_int_do_step'));
           // No new classes
          -check::classes(array(Foo_int,Bar,FooBar_int));
          +check::classes(array('Foo_int','Bar','FooBar_int'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_profile_runme.php b/Examples/test-suite/php/director_profile_runme.php
          index c72421341..c6f4c3c94 100644
          --- a/Examples/test-suite/php/director_profile_runme.php
          +++ b/Examples/test-suite/php/director_profile_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_profile.php";
           
           // No new functions
          -check::functions(array(b_fn,b_vfi,b_fi,b_fj,b_fk,b_fl,b_get_self,b_vfs,b_fs));
          +check::functions(array('b_fn','b_vfi','b_fi','b_fj','b_fk','b_fl','b_get_self','b_vfs','b_fs'));
           // No new classes
          -check::classes(array(A,B));
          +check::classes(array('A','B'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
          index 18586ca62..e759fed25 100644
          --- a/Examples/test-suite/php/director_protected_runme.php
          +++ b/Examples/test-suite/php/director_protected_runme.php
          @@ -3,9 +3,9 @@
           require "tests.php";
           require "director_protected.php";
           
          -check::functions(array(foo_pong,foo_s,foo_q,foo_ping,foo_pang,foo_used,foo_cheer,bar_create,bar_callping,bar_callcheer,bar_cheer,bar_pong,bar_used,bar_ping,bar_pang,a_draw,b_draw));
          -check::classes(array(Foo,Bar,PrivateFoo,A,B,AA,BB));
          -check::globals(array(bar_a));
          +check::functions(array('foo_pong','foo_s','foo_q','foo_ping','foo_pang','foo_used','foo_cheer','bar_create','bar_callping','bar_callcheer','bar_cheer','bar_pong','bar_used','bar_ping','bar_pang','a_draw','b_draw'));
          +check::classes(array('Foo','Bar','PrivateFoo','A','B','AA','BB'));
          +check::globals(array('bar_a'));
           
           class FooBar extends Bar {
             protected function ping() {
          diff --git a/Examples/test-suite/php/director_stl_runme.php b/Examples/test-suite/php/director_stl_runme.php
          index 29addd261..f7a5c0aa0 100644
          --- a/Examples/test-suite/php/director_stl_runme.php
          +++ b/Examples/test-suite/php/director_stl_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "director_stl.php";
           
           // No new functions
          -check::functions(array(foo_bar,foo_ping,foo_pong,foo_tping,foo_tpong,foo_pident,foo_vident,foo_vsecond,foo_tpident,foo_tvident,foo_tvsecond,foo_vidents,foo_tvidents));
          +check::functions(array('foo_bar','foo_ping','foo_pong','foo_tping','foo_tpong','foo_pident','foo_vident','foo_vsecond','foo_tpident','foo_tvident','foo_tvsecond','foo_vidents','foo_tvidents'));
           // No new classes
          -check::classes(array(Foo));
          +check::classes(array('Foo'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/director_string_runme.php b/Examples/test-suite/php/director_string_runme.php
          index 5ac583f78..77e84c9bf 100644
          --- a/Examples/test-suite/php/director_string_runme.php
          +++ b/Examples/test-suite/php/director_string_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "director_string.php";
           
           // No new functions
          -check::functions(array(a_get_first,a_call_get_first,a_string_length,a_process_text,a_call_process_func,stringvector_size,stringvector_is_empty,stringvector_clear,stringvector_push,stringvector_pop,stringvector_capacity,stringvector_reserve));
          +check::functions(array('a_get_first','a_call_get_first','a_string_length','a_process_text','a_call_process_func','stringvector_size','stringvector_is_empty','stringvector_clear','stringvector_push','stringvector_pop','stringvector_capacity','stringvector_reserve'));
           // No new classes
          -check::classes(array(A,StringVector));
          +check::classes(array('A','StringVector'));
           // now new vars
          -check::globals(array(a,a_call,a_m_strings,stringvector));
          +check::globals(array('a','a_call','a_m_strings','stringvector'));
           
           class B extends A {
             function get_first() {
          diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
          index ab0563213..2a640a022 100644
          --- a/Examples/test-suite/php/director_thread_runme.php
          +++ b/Examples/test-suite/php/director_thread_runme.php
          @@ -8,11 +8,11 @@ require "director_thread.php";
           exit(0);
           
           // No new functions
          -check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
          +check::functions(array('millisecondsleep','foo_stop','foo_run','foo_do_foo'));
           // No new classes
          -check::classes(array(director_thread,Foo));
          +check::classes(array('director_thread','Foo'));
           // now new vars
          -check::globals(array(foo_val));
          +check::globals(array('foo_val'));
           
           class Derived extends Foo {
             function do_foo() {
          diff --git a/Examples/test-suite/php/director_unroll_runme.php b/Examples/test-suite/php/director_unroll_runme.php
          index 626b1f07d..79d39f5ef 100644
          --- a/Examples/test-suite/php/director_unroll_runme.php
          +++ b/Examples/test-suite/php/director_unroll_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "director_unroll.php";
           
           // No new functions
          -check::functions(array(foo_ping,foo_pong));
          +check::functions(array('foo_ping','foo_pong'));
           // No new classes
          -check::classes(array(Foo,Bar));
          +check::classes(array('Foo','Bar'));
           // now new vars
          -check::globals(array(bar));
          +check::globals(array('bar'));
           
           class MyFoo extends Foo {
             function ping() {
          diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php
          index acb83561a..77f115fa1 100644
          --- a/Examples/test-suite/php/exception_order_runme.php
          +++ b/Examples/test-suite/php/exception_order_runme.php
          @@ -2,9 +2,9 @@
           require "tests.php";
           require "exception_order.php";
           
          -check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
          -check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
          -check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
          +check::functions(array('a_foo','a_bar','a_foobar','a_barfoo','is_python_builtin'));
          +check::classes(array('A','E1','E2','E3','exception_order','ET_i','ET_d'));
          +check::globals(array('efoovar','foovar','cfoovar','a_sfoovar','a_foovar','a_efoovar'));
           
           $a = new A();
           try {
          diff --git a/Examples/test-suite/php/grouping_runme.php b/Examples/test-suite/php/grouping_runme.php
          index 51446f473..8bad7cd4c 100644
          --- a/Examples/test-suite/php/grouping_runme.php
          +++ b/Examples/test-suite/php/grouping_runme.php
          @@ -6,14 +6,14 @@ require "grouping.php";
           check::functions(array("test1","test2","do_unary","negate"));
           check::equal(5,test1(5),"5==test1(5)");
           check::resource(test2(7),"_p_int","_p_int==test2(7)");
          -check::globals(array(test3));
          +check::globals(array('test3'));
           
           //check::equal(37,test3_get(),'37==test3_get()');
           check::equal(37,check::get("test3"),'37==get(test3)');
           //test3_set(38);
          -check::set(test3,38); 
          +check::set('test3',38);
           //check::equal(38,test3_get(),'38==test3_get() after test3_set(37)');
          -check::equal(38,check::get(test3),'38==get(test3) after set(test)');
          +check::equal(38,check::get('test3'),'38==get(test3) after set(test)');
           
           check::equal(-5,negate(5),"-5==negate(5)");
           check::equal(7,do_unary(-7,NEGATE),"7=do_unary(-7,NEGATE)");
          diff --git a/Examples/test-suite/php/ignore_parameter_runme.php b/Examples/test-suite/php/ignore_parameter_runme.php
          index 1c8c76ad4..f86a61169 100644
          --- a/Examples/test-suite/php/ignore_parameter_runme.php
          +++ b/Examples/test-suite/php/ignore_parameter_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "ignore_parameter.php";
           
           // New functions
          -check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
          +check::functions(array('jaguar','lotus','tvr','ferrari','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini'));
           // New classes
          -check::classes(array(ignore_parameter,SportsCars,MiniCooper,MorrisMinor,FordAnglia,AustinAllegro));
          +check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro'));
           // No new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php
          index 41836ba0f..e5ea761f7 100644
          --- a/Examples/test-suite/php/import_nomodule_runme.php
          +++ b/Examples/test-suite/php/import_nomodule_runme.php
          @@ -3,9 +3,9 @@ require "tests.php";
           require "import_nomodule.php";
           
           // No new functions
          -check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
          +check::functions(array('create_foo','delete_foo','test1','is_python_builtin'));
           // No new classes
          -check::classes(array(import_nomodule,Bar));
          +check::classes(array('import_nomodule','Bar'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/li_carrays_cpp_runme.php b/Examples/test-suite/php/li_carrays_cpp_runme.php
          index e0f9ffe92..3e8a443f6 100644
          --- a/Examples/test-suite/php/li_carrays_cpp_runme.php
          +++ b/Examples/test-suite/php/li_carrays_cpp_runme.php
          @@ -3,14 +3,14 @@ require "tests.php";
           require "li_carrays_cpp.php";
           
           // Check functions.
          -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
          +check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array'));
           
           // Check classes.
           // NB An "li_carrays_cpp" class is created as a mock namespace.
          -check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray));
          +check::classes(array('li_carrays_cpp','doubleArray','AB','XY','XYArray','shortArray'));
           
           // Check global variables.
          -check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
          +check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray'));
           
           $d = new doubleArray(10);
           
          diff --git a/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php
          index 40e82f9ea..abe358101 100644
          --- a/Examples/test-suite/php/li_carrays_runme.php
          +++ b/Examples/test-suite/php/li_carrays_runme.php
          @@ -3,14 +3,14 @@ require "tests.php";
           require "li_carrays.php";
           
           // Check functions.
          -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array));
          +check::functions(array('new_intarray','delete_intarray','intarray_getitem','intarray_setitem','doublearray_getitem','doublearray_setitem','doublearray_cast','doublearray_frompointer','xyarray_getitem','xyarray_setitem','xyarray_cast','xyarray_frompointer','delete_abarray','abarray_getitem','abarray_setitem','shortarray_getitem','shortarray_setitem','shortarray_cast','shortarray_frompointer','sum_array'));
           
           // Check classes.
           // NB An "li_carrays" class is created as a mock namespace.
          -check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray));
          +check::classes(array('li_carrays','doubleArray','AB','XY','XYArray','shortArray'));
           
           // Check global variables.
          -check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
          +check::globals(array('xy_x','xy_y','globalxyarray','ab_a','ab_b','globalabarray'));
           
           $d = new doubleArray(10);
           
          diff --git a/Examples/test-suite/php/li_factory_runme.php b/Examples/test-suite/php/li_factory_runme.php
          index 6623e2a8c..982d7b1fd 100644
          --- a/Examples/test-suite/php/li_factory_runme.php
          +++ b/Examples/test-suite/php/li_factory_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "li_factory.php";
           
           // No new functions
          -check::functions(array(geometry_draw,geometry_create,geometry_clone_,point_draw,point_width,point_clone_,circle_draw,circle_radius,circle_clone_));
          +check::functions(array('geometry_draw','geometry_create','geometry_clone_','point_draw','point_width','point_clone_','circle_draw','circle_radius','circle_clone_'));
           // No new classes
          -check::classes(array(Geometry,Point,Circle));
          +check::classes(array('Geometry','Point','Circle'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/newobject1_runme.php b/Examples/test-suite/php/newobject1_runme.php
          index 5853a72c0..863e3e423 100644
          --- a/Examples/test-suite/php/newobject1_runme.php
          +++ b/Examples/test-suite/php/newobject1_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "newobject1.php";
           
           // No new functions
          -check::functions(array(foo_makefoo,foo_makemore,foo_foocount));
          +check::functions(array('foo_makefoo','foo_makemore','foo_foocount'));
           // No new classes
          -check::classes(array(Foo));
          +check::classes(array('Foo'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/overload_rename_runme.php b/Examples/test-suite/php/overload_rename_runme.php
          index dce4c6cb3..0357f91a6 100644
          --- a/Examples/test-suite/php/overload_rename_runme.php
          +++ b/Examples/test-suite/php/overload_rename_runme.php
          @@ -6,7 +6,7 @@ require "overload_rename.php";
           // No new functions
           check::functions(array());
           // No new classes
          -check::classes(array(Foo));
          +check::classes(array('Foo'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/php_iterator_runme.php b/Examples/test-suite/php/php_iterator_runme.php
          index d69a5b385..fd645ccb2 100644
          --- a/Examples/test-suite/php/php_iterator_runme.php
          +++ b/Examples/test-suite/php/php_iterator_runme.php
          @@ -3,8 +3,8 @@
           require "tests.php";
           require "php_iterator.php";
           
          -check::functions(array(myiterator_rewind,myiterator_key,myiterator_current,myiterator_next,myiterator_valid));
          -check::classes(array(MyIterator));
          +check::functions(array('myiterator_rewind','myiterator_key','myiterator_current','myiterator_next','myiterator_valid'));
          +check::classes(array('MyIterator'));
           // No new global variables.
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/prefix_runme.php b/Examples/test-suite/php/prefix_runme.php
          index ead064f5b..fcf7c66f6 100644
          --- a/Examples/test-suite/php/prefix_runme.php
          +++ b/Examples/test-suite/php/prefix_runme.php
          @@ -4,9 +4,9 @@ require "tests.php";
           require "prefix.php";
           
           // No new functions
          -check::functions(array(foo_get_self));
          +check::functions(array('foo_get_self'));
           // No new classes
          -check::classes(array(ProjectFoo));
          +check::classes(array('ProjectFoo'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/sym_runme.php b/Examples/test-suite/php/sym_runme.php
          index 483aaa980..127d28fd9 100644
          --- a/Examples/test-suite/php/sym_runme.php
          +++ b/Examples/test-suite/php/sym_runme.php
          @@ -6,7 +6,7 @@ require "sym.php";
           // No new functions
           check::functions(array());
           // No new classes
          -check::classes(array(flim,flam));
          +check::classes(array('flim','flam'));
           // now new vars
           check::globals(array());
           
          diff --git a/Examples/test-suite/php/template_arg_typename_runme.php b/Examples/test-suite/php/template_arg_typename_runme.php
          index 7d60285e3..56ef2875d 100644
          --- a/Examples/test-suite/php/template_arg_typename_runme.php
          +++ b/Examples/test-suite/php/template_arg_typename_runme.php
          @@ -6,7 +6,7 @@ require "template_arg_typename.php";
           // No new functions
           check::functions(array());
           // No new classes
          -check::classes(array(UnaryFunction_bool_bool,BoolUnaryFunction_bool));
          +check::classes(array('UnaryFunction_bool_bool','BoolUnaryFunction_bool'));
           $ufbb=new unaryfunction_bool_bool();
           check::is_a($ufbb,"unaryfunction_bool_bool");
           
          diff --git a/Examples/test-suite/php/template_construct_runme.php b/Examples/test-suite/php/template_construct_runme.php
          index 3a3986f7e..b227d9fec 100644
          --- a/Examples/test-suite/php/template_construct_runme.php
          +++ b/Examples/test-suite/php/template_construct_runme.php
          @@ -3,7 +3,7 @@
           require "tests.php";
           require "template_construct.php";
           
          -check::classes(array(Foo_int));
          +check::classes(array('Foo_int'));
           $foo_int=new foo_int(3);
           check::is_a($foo_int,"foo_int","Made a foo_int");
           
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index f1d5179c4..5a779d79c 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -31,8 +31,8 @@ class check {
                 $extra=array();
                 $extrags=array();
                 $df=get_defined_functions();
          -      $df=array_flip($df[internal]);
          -      foreach($_original_functions[internal] as $func) unset($df[$func]);
          +      $df=array_flip($df['internal']);
          +      foreach($_original_functions['internal'] as $func) unset($df[$func]);
                 // Now chop out any get/set accessors
                 foreach(array_keys($df) as $func)
                   if ((self::GETSET && preg_match('/_[gs]et$/', $func)) ||
          diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
          index 78c6bf592..80717eb88 100644
          --- a/Examples/test-suite/php/threads_exception_runme.php
          +++ b/Examples/test-suite/php/threads_exception_runme.php
          @@ -4,11 +4,11 @@ require "tests.php";
           require "threads_exception.php";
           
           // Check functions
          -check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
          +check::functions(array('test_simple','test_message','test_hosed','test_unknown','test_multi','is_python_builtin'));
           // Check classes.
          -check::classes(array(Exc,Test,threads_exception));
          +check::classes(array('Exc','Test','threads_exception'));
           // Check globals.
          -check::globals(array(exc_code,exc_msg));
          +check::globals(array('exc_code','exc_msg'));
           
           $t = new Test();
           try {
          diff --git a/Examples/test-suite/php/typedef_reference_runme.php b/Examples/test-suite/php/typedef_reference_runme.php
          index 88a70f8d3..83e75fb66 100644
          --- a/Examples/test-suite/php/typedef_reference_runme.php
          +++ b/Examples/test-suite/php/typedef_reference_runme.php
          @@ -3,7 +3,7 @@
           require "tests.php";
           require "typedef_reference.php";
           
          -check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
          +check::functions(array('somefunc','otherfunc','new_intp','copy_intp','delete_intp','intp_assign','intp_value'));
           $int2=copy_intp(2);
           check::equal(2,somefunc($int2)," test passing intp to somefunc");
           $int3=copy_intp(3);
          
          From 75810c0bdc2439d752200c87e3d41b606ccf5e06 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 15:33:37 +1300
          Subject: [PATCH 1372/2031] [php] Fix comment typo in testsuite
          
          ---
           Examples/test-suite/php/casts_runme.php | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/php/casts_runme.php b/Examples/test-suite/php/casts_runme.php
          index 730333fc1..a9623a328 100644
          --- a/Examples/test-suite/php/casts_runme.php
          +++ b/Examples/test-suite/php/casts_runme.php
          @@ -10,7 +10,7 @@ check::classes(array('A','B'));
           // now new vars
           check::globals(array());
           
          -# Make sure $b inherites hello() from class A
          +# Make sure $b inherits hello() from class A
           $b=new B();
           $b->hello();
           
          
          From d5ec16e16ce61ba495dd1034499f3f58f7c09bcd Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 15:35:29 +1300
          Subject: [PATCH 1373/2031] Add CHANGES.current entry for PHP 7.3 fixes
          
          ---
           CHANGES.current | 4 ++++
           1 file changed, 4 insertions(+)
          
          diff --git a/CHANGES.current b/CHANGES.current
          index c64d4cc3c..88dcb1c9a 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2019-02-08: olly
          +	    [PHP] The generated code is now compatible with PHP 7.3, and the
          +	    testsuite now runs cleanly with this version too.
          +
           2019-02-04: wsfulton
           	    [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a
                       clean up to remove target languages that have been neglected/not functional.
          
          From f4c3948455ed0d5df2f17c8cbaca03d4022f4dd9 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 15:39:34 +1300
          Subject: [PATCH 1374/2031] [ci] Add CI jobs for PHP 7.2 and 7.3
          
          ---
           .travis.yml | 10 ++++++++++
           1 file changed, 10 insertions(+)
          
          diff --git a/.travis.yml b/.travis.yml
          index 7de1eb6c4..3368493ad 100644
          --- a/.travis.yml
          +++ b/.travis.yml
          @@ -134,6 +134,16 @@ matrix:
                 env: SWIGLANG=php VER=7.1
                 sudo: required
                 dist: trusty
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=php VER=7.2
          +      sudo: required
          +      dist: trusty
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=php VER=7.3
          +      sudo: required
          +      dist: trusty
               - compiler: gcc
                 os: linux
                 env: SWIGLANG=python # 2.7
          
          From ce1936eb5b07005e3022b177c02d610f56e695fe Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 16:58:22 +1300
          Subject: [PATCH 1375/2031] [php] Fix SWIG_ZEND_CONSTANT_SET_FLAGS for PHP <
           7.3
          
          ---
           Lib/php/phprun.swg | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
          index 6418d0734..b22ed6b58 100644
          --- a/Lib/php/phprun.swg
          +++ b/Lib/php/phprun.swg
          @@ -36,7 +36,7 @@ extern "C" {
           #ifdef ZEND_CONSTANT_SET_FLAGS
           # define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
           #else
          -# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C).flags = (F); (C).module_number = (N); } while (0)
          +# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C)->flags = (F); (C)->module_number = (N); } while (0)
           #endif
           
           #ifdef __cplusplus
          
          From 890617f5a507ebc0949dcad68f50934bbe00e14d Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 17:18:30 +1300
          Subject: [PATCH 1376/2031] Fix swig -help to exit with status 0
          
          Fixes #1453
          ---
           Source/Modules/main.cxx | 11 ++++++-----
           1 file changed, 6 insertions(+), 5 deletions(-)
          
          diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
          index e302241bd..0b615ce0a 100644
          --- a/Source/Modules/main.cxx
          +++ b/Source/Modules/main.cxx
          @@ -962,11 +962,6 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
             if (CPlusPlus)
               Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
           
          -  if (!tlm) {
          -    Printf(stderr, "No target language specified\n");
          -    return 1;
          -  }
          -
             // Parse language dependent options
             lang->main(argc, argv);
           
          @@ -974,6 +969,12 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
               Printf(stdout, "\nNote: 'swig - -help' displays options for a specific target language.\n\n");
               SWIG_exit(EXIT_SUCCESS);	// Exit if we're in help mode
             }
          +
          +  if (!tlm) {
          +    Printf(stderr, "No target language specified\n");
          +    return 1;
          +  }
          +
             // Check all of the options to make sure we're cool.
             // Don't check for an input file if -external-runtime is passed
             Swig_check_options(external_runtime ? 0 : 1);
          
          From 7345a33ccf0f9b2af1617e2d263723683e8d63be Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 18:03:08 +1300
          Subject: [PATCH 1377/2031] [php] Make test helper methods static
          
          We call them all statically so they ought to be static (PHP issues
          a diagnostic about this, but that seems to be hidden by default).
          ---
           Examples/test-suite/php/tests.php | 40 +++++++++++++++----------------
           1 file changed, 20 insertions(+), 20 deletions(-)
          
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index 5a779d79c..60f2c1c10 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -10,7 +10,7 @@ class check {
             // Used to filter out get/set global functions to fake vars...
             const GETSET = 1;
           
          -  function get_extra_classes($ref=FALSE) {
          +  static function get_extra_classes($ref=FALSE) {
               static $extra;
               global $_original_classes;
               if ($ref===FALSE) $f=$_original_classes;
          @@ -22,7 +22,7 @@ class check {
               return $extra;
             }
           
          -  function get_extra_functions($ref=FALSE,$gs=false) {
          +  static function get_extra_functions($ref=FALSE,$gs=false) {
               static $extra;
               static $extrags; // for get/setters
               global $_original_functions;
          @@ -46,7 +46,7 @@ class check {
               return $extra;
             }
           
          -  function get_extra_globals($ref=FALSE) {
          +  static function get_extra_globals($ref=FALSE) {
               static $extra;
               global $_original_globals;
               if (! is_array($extra)) {
          @@ -72,14 +72,14 @@ class check {
               return $extra;
             }
           
          -  function classname($string,$object) {
          +  static function classname($string,$object) {
               if (!is_object($object))
                 return check::fail("The second argument is a " . gettype($object) . ", not an object.");
               if (strtolower($string)!=strtolower($classname=get_class($object))) return check::fail("Object: \$object is of class %s not class %s",$classname,$string);
               return TRUE;
             }
           
          -  function classmethods($classname,$methods) {
          +  static function classmethods($classname,$methods) {
               if (is_object($classname)) $classname=get_class($classname);
               $classmethods=array_flip(get_class_methods($classname));
               $missing=array();
          @@ -98,19 +98,19 @@ class check {
               return TRUE;
             }
           
          -  function set($var,$value) {
          +  static function set($var,$value) {
               $func=$var."_set";
               if (self::GETSET) $func($value);
               else $_GLOBALS[$var]=$value;
             }
           
          -  function &get($var) {
          +  static function &get($var) {
               $func=$var."_get";
               if (self::GETSET) return $func();
               else return $_GLOBALS[$var];
             }
           
          -  function is_a($a,$b) {
          +  static function is_a($a,$b) {
               if (is_object($a)) $a=strtolower(get_class($a));
               if (is_object($b)) $a=strtolower(get_class($b));
               $parents=array();
          @@ -123,7 +123,7 @@ class check {
               return TRUE;
             }
           
          -  function classparent($a,$b) {
          +  static function classparent($a,$b) {
               if (is_object($a)) $a=get_class($a);
               if (is_object($b)) $a=get_class($b);
               $parent=get_parent_class($a);
          @@ -132,7 +132,7 @@ class check {
               return TRUE;
             }
           
          -  function classes($classes) {
          +  static function classes($classes) {
               if (! is_array($classes)) $classes=array($classes);
               $message=array();
               $missing=array();
          @@ -148,7 +148,7 @@ class check {
               return TRUE;    
             }
           
          -  function functions($functions) {
          +  static function functions($functions) {
               if (! is_array($functions)) $functions=array($functions);
               $message=array();
               $missing=array();
          @@ -165,7 +165,7 @@ class check {
               return TRUE;    
             }
           
          -  function globals($globals) {
          +  static function globals($globals) {
               if (! is_array($globals)) $globals=array($globals);
               $message=array();
               $missing=array();
          @@ -187,30 +187,30 @@ class check {
           
             }
           
          -  function functionref($a,$type,$message) {
          +  static function functionref($a,$type,$message) {
               if (! preg_match("/^_[a-f0-9]+$type$/i", $a))
                 return check::fail($message);
               return TRUE;
             }
           
          -  function equal($a,$b,$message) {
          +  static function equal($a,$b,$message) {
               if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
               return TRUE;
             }
           
          -  function resource($a,$b,$message) {
          +  static function resource($a,$b,$message) {
               $resource=trim(check::var_dump($a));
               if (! preg_match("/^resource\([0-9]+\) of type \($b\)/i", $resource))
                 return check::fail($message);
               return TRUE;
             }
           
          -  function isnull($a,$message) {
          +  static function isnull($a,$message) {
               $value=trim(check::var_dump($a));
               return check::equal($value,"NULL",$message);
             }
           
          -  function var_dump($arg) {
          +  static function var_dump($arg) {
               ob_start();
               var_dump($arg);
               $result=ob_get_contents();
          @@ -218,19 +218,19 @@ class check {
               return $result;
             }
           
          -  function fail($pattern) {
          +  static function fail($pattern) {
               $args=func_get_args();
               print("Failed on: ".call_user_func_array("sprintf",$args)."\n");
               exit(1);
             }
           
          -  function warn($pattern) {
          +  static function warn($pattern) {
               $args=func_get_args();
               print("Warning on: ".call_user_func_array("sprintf",$args)."\n");
               return FALSE;
             }
           
          -  function done() {
          +  static function done() {
           #    print $_SERVER[argv][0]." ok\n";
             }
           }
          
          From 28a846705f10e4d1c69277ff9d288b03998cf0c5 Mon Sep 17 00:00:00 2001
          From: Zackery Spytz 
          Date: Thu, 7 Feb 2019 22:08:10 -0700
          Subject: [PATCH 1378/2031] [OCaml] Fix possible GC issues in generated
           director code
          
          Make `classDirectorMethod()` generate `CAMLreturn_type()` or
          `CAMLreturn0` when there are local variables of type `value`.
          ---
           .../test-suite/ocaml/director_unroll_runme.ml     | 15 +++++++++++++++
           Source/Modules/ocaml.cxx                          | 13 ++++++++-----
           2 files changed, 23 insertions(+), 5 deletions(-)
           create mode 100644 Examples/test-suite/ocaml/director_unroll_runme.ml
          
          diff --git a/Examples/test-suite/ocaml/director_unroll_runme.ml b/Examples/test-suite/ocaml/director_unroll_runme.ml
          new file mode 100644
          index 000000000..747d9adf6
          --- /dev/null
          +++ b/Examples/test-suite/ocaml/director_unroll_runme.ml
          @@ -0,0 +1,15 @@
          +open Swig
          +open Director_unroll
          +
          +let director_unroll_MyFoo ob meth args =
          +  match meth with
          +    | "ping" -> C_string "MyFoo::ping()"
          +    | _ -> (invoke ob) meth args
          +
          +let a = new_derived_object
          +  new_Foo (director_unroll_MyFoo) '()
          +
          +let b = new_Bar '()
          +let _ = b -> set (a)
          +let c = b -> get ()
          +let _ = assert ((a -> "&" () as int) = (c -> "&" () as int))
          diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
          index 99f2a98d7..2d3e18ba6 100644
          --- a/Source/Modules/ocaml.cxx
          +++ b/Source/Modules/ocaml.cxx
          @@ -1394,8 +1394,7 @@ public:
           	pure_virtual = true;
                 }
               }
          -
          -    Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)");
          +    Printf(w->locals, "CAMLparam0();\n");
           
               /* determine if the method returns a pointer */
               is_pointer = SwigType_ispointer_return(decl);
          @@ -1469,16 +1468,18 @@ public:
           
               if (ignored_method) {
                 if (!pure_virtual) {
          -	if (!is_void)
          -	  Printf(w->code, "return ");
           	String *super_call = Swig_method_call(super, l);
          -	Printf(w->code, "%s;\n", super_call);
          +	if (is_void)
          +	  Printf(w->code, "%s;\n", super_call);
          +	else
          +	  Printf(w->code, "CAMLreturn_type(%s);\n", super_call);
           	Delete(super_call);
                 } else {
           	Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
           	       SwigType_namestr(name));
                 }
               } else {
          +      Wrapper_add_local(w, "swig_result", "SWIG_CAMLlocal2(swig_result, args)");
                 /* attach typemaps to arguments (C/C++ -> Ocaml) */
                 String *arglist = NewString("");
           
          @@ -1673,6 +1674,8 @@ public:
           	  Printf(w->code, "CAMLreturn_type(*c_result);\n");
           	}
                 }
          +    } else {
          +      Printf(w->code, "CAMLreturn0;\n");
               }
           
               Printf(w->code, "}\n");
          
          From 3f9ebb31b9ebb64809d4d944cbc67b81d92ce4e7 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 18:09:52 +1300
          Subject: [PATCH 1379/2031] [PHP] Don't generate code referencing undefined $r
          
          This could happen in overloaded methods which returned void and took at
          least one const std::string& parameter.
          ---
           CHANGES.current                                 |  5 +++++
           Examples/test-suite/li_std_string.i             |  6 ++++++
           Examples/test-suite/php/li_std_string_runme.php | 14 ++++++++++++++
           Source/Modules/php.cxx                          |  2 +-
           4 files changed, 26 insertions(+), 1 deletion(-)
          
          diff --git a/CHANGES.current b/CHANGES.current
          index 88dcb1c9a..7fdc7189d 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2019-02-08: olly
          +	    [PHP] Don't generate code which references $r when $r hasn't been
          +	    defined.  This could happen in overloaded methods which returned
          +	    void and took at least one const std::string& parameter.
          +
           2019-02-08: olly
           	    [PHP] The generated code is now compatible with PHP 7.3, and the
           	    testsuite now runs cleanly with this version too.
          diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i
          index 822368491..47a9090b7 100644
          --- a/Examples/test-suite/li_std_string.i
          +++ b/Examples/test-suite/li_std_string.i
          @@ -22,6 +22,12 @@ const std::string& test_const_reference(const std::string &x) {
              return x;
           }
           
          +void test_const_reference_returning_void(const std::string &) {
          +}
          +
          +void test_const_reference_returning_void(const std::string &, int) {
          +}
          +
           void test_pointer(std::string *x) {
           }
           
          diff --git a/Examples/test-suite/php/li_std_string_runme.php b/Examples/test-suite/php/li_std_string_runme.php
          index ad62247e1..dbf0228df 100644
          --- a/Examples/test-suite/php/li_std_string_runme.php
          +++ b/Examples/test-suite/php/li_std_string_runme.php
          @@ -3,6 +3,17 @@
           require "tests.php";
           require "li_std_string.php";
           
          +function die_on_error($errno, $errstr, $file, $line) {
          +    if ($file !== Null) {
          +        print $file;
          +        if ($line !== Null) print ":$line";
          +        print ": ";
          +    }
          +    print "$errstr\n";
          +    exit(1);
          +}
          +set_error_handler("die_on_error", -1);
          +
           // Global variables
           //$s="initial string";
           //check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
          @@ -27,5 +38,8 @@ check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2")
           // below broken ?
           //check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
           
          +// This used to give "Undefined variable: r"
          +li_std_string::test_const_reference_returning_void("foo");
          +
           check::done();
           ?>
          diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
          index a3ea8003e..fd1dedad7 100644
          --- a/Source/Modules/php.cxx
          +++ b/Source/Modules/php.cxx
          @@ -979,7 +979,7 @@ public:
               /* Insert argument output code */
               bool hasargout = false;
               for (i = 0, p = l; p; i++) {
          -      if ((tm = Getattr(p, "tmap:argout"))) {
          +      if ((tm = Getattr(p, "tmap:argout")) && Len(tm)) {
           	hasargout = true;
           	Replaceall(tm, "$source", Getattr(p, "lname"));
           	//      Replaceall(tm,"$input",Getattr(p,"lname"));
          
          From 8e4d135929be529e807aa26d869bd3f8fe34b588 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Fri, 8 Feb 2019 18:10:32 +1300
          Subject: [PATCH 1380/2031] [PHP] Add quotes to another bareword string
          
          Seems I missed one when I fixed all the others in the testsuite.
          ---
           Examples/test-suite/php/arrays_runme.php | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/php/arrays_runme.php b/Examples/test-suite/php/arrays_runme.php
          index 400beecea..c6e9e8f70 100644
          --- a/Examples/test-suite/php/arrays_runme.php
          +++ b/Examples/test-suite/php/arrays_runme.php
          @@ -7,7 +7,7 @@ check::classes(array('arrays','SimpleStruct','ArrayStruct','CartPoseData_t'));
           check::globals(array('simplestruct_double_field','arraystruct_array_c','arraystruct_array_sc','arraystruct_array_uc','arraystruct_array_s','arraystruct_array_us','arraystruct_array_i','arraystruct_array_ui','arraystruct_array_l','arraystruct_array_ul','arraystruct_array_ll','arraystruct_array_f','arraystruct_array_d','arraystruct_array_struct','arraystruct_array_structpointers','arraystruct_array_ipointers','arraystruct_array_enum','arraystruct_array_enumpointers','arraystruct_array_const_i','cartposedata_t_p'));
           
           $ss=new simplestruct();
          -check::classname(simplestruct,$ss);
          +check::classname('simplestruct',$ss);
           
           $as=new arraystruct();
           $as->array_c="abc";
          
          From 660d51c7cace8d0f31b35f419a9f04d880c7f2f5 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 09:00:31 +1300
          Subject: [PATCH 1381/2031] Remove blank line from end of php_pragma_runme.php
          
          Because this was after the closing ?> it was resulting in a blank
          line in the testcase output.
          ---
           Examples/test-suite/php/php_pragma_runme.php | 1 -
           1 file changed, 1 deletion(-)
          
          diff --git a/Examples/test-suite/php/php_pragma_runme.php b/Examples/test-suite/php/php_pragma_runme.php
          index ae92f6818..c76cfc9b5 100644
          --- a/Examples/test-suite/php/php_pragma_runme.php
          +++ b/Examples/test-suite/php/php_pragma_runme.php
          @@ -9,4 +9,3 @@ check::equal('1.5',(new ReflectionExtension('php_pragma'))->getVersion(),"1.5==v
           check::done();
           
           ?>
          -
          
          From aa7eb05071be6653abdcec69f82e062f4b33246e Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 11:30:39 +1300
          Subject: [PATCH 1382/2031] Disable broken 'this' check in
           director_unroll_runme.php
          
          This was comparing an unset property on two objects matched - they
          do, but the check we actually intend here is that they wrap the same C++
          object.  We don't seem to be able to accomplish the desired check for
          PHP, so just disable this for now.
          ---
           Examples/test-suite/php/director_unroll_runme.php | 5 ++++-
           1 file changed, 4 insertions(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/php/director_unroll_runme.php b/Examples/test-suite/php/director_unroll_runme.php
          index 79d39f5ef..e3101887d 100644
          --- a/Examples/test-suite/php/director_unroll_runme.php
          +++ b/Examples/test-suite/php/director_unroll_runme.php
          @@ -23,7 +23,10 @@ $b = new Bar();
           $b->set($a);
           $c = $b->get();
           
          -check::equal($a->this, $c->this, "this failed");
          +// FIXME: This doesn't work for checking that they wrap the same C++ object
          +// because the two objects have different PHP resources, and we can't easily
          +// look inside those resources to see which C++ objects they refer to.
          +//check::equal($a->_cPtr, $c->_cPtr, "_cPtr check failed");
           
           check::done();
           ?>
          
          From cf785d7071e946c943aafe3e8b1f8b80d8d74277 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 11:32:51 +1300
          Subject: [PATCH 1383/2031] Avoid uses of undeclared variables in PHP testsuite
          
          ---
           Examples/test-suite/php/argout_runme.php                | 2 +-
           Examples/test-suite/php/template_arg_typename_runme.php | 2 +-
           Examples/test-suite/php/tests.php                       | 1 +
           3 files changed, 3 insertions(+), 2 deletions(-)
          
          diff --git a/Examples/test-suite/php/argout_runme.php b/Examples/test-suite/php/argout_runme.php
          index baf4b164e..8b66613fd 100644
          --- a/Examples/test-suite/php/argout_runme.php
          +++ b/Examples/test-suite/php/argout_runme.php
          @@ -30,7 +30,7 @@ unset($handle);
           #$handledata=handle($handle);
           #check::equal($handledata,"Here it is","\$handledata != \"Here it is\"");
           
          -unset($handle);
          +$handle=NULL;
           voidhandle($handle);
           check::isnull($handle,'$handle not null');
           
          diff --git a/Examples/test-suite/php/template_arg_typename_runme.php b/Examples/test-suite/php/template_arg_typename_runme.php
          index 56ef2875d..e609240e7 100644
          --- a/Examples/test-suite/php/template_arg_typename_runme.php
          +++ b/Examples/test-suite/php/template_arg_typename_runme.php
          @@ -10,7 +10,7 @@ check::classes(array('UnaryFunction_bool_bool','BoolUnaryFunction_bool'));
           $ufbb=new unaryfunction_bool_bool();
           check::is_a($ufbb,"unaryfunction_bool_bool");
           
          -unset($whatisthis);
          +$whatisthis=NULL;
           $bufb=new boolunaryfunction_bool($whatisthis);
           check::is_a($bufb,"boolunaryfunction_bool");
           
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index 60f2c1c10..b18b109c2 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -82,6 +82,7 @@ class check {
             static function classmethods($classname,$methods) {
               if (is_object($classname)) $classname=get_class($classname);
               $classmethods=array_flip(get_class_methods($classname));
          +    $message=NULL;
               $missing=array();
               $extra=array();
               foreach($methods as $method) {
          
          From 785481cc6293da5de74454761547411e5f0ec81a Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 11:45:57 +1300
          Subject: [PATCH 1384/2031] Fix PHP testsuite check::get() helper
          
          This was trying to return a reference, but that doesn't actually work
          for all the things it's used for, and none of the uses require the
          return value to be a reference.
          ---
           Examples/test-suite/php/tests.php | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index b18b109c2..3e835128e 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -105,7 +105,7 @@ class check {
               else $_GLOBALS[$var]=$value;
             }
           
          -  static function &get($var) {
          +  static function get($var) {
               $func=$var."_get";
               if (self::GETSET) return $func();
               else return $_GLOBALS[$var];
          
          From 123eabf20088f7ab878c2859075427b07e83ebcc Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 11:48:33 +1300
          Subject: [PATCH 1385/2031] [PHP] Wrap renamed constructor as static method
          
          Previously it was wrapped as a non-static method, which results in
          a diagnostic from PHP if called as a static method.
          ---
           CHANGES.current        |  4 ++++
           Source/Modules/php.cxx | 31 ++++++++++++++++++++++---------
           2 files changed, 26 insertions(+), 9 deletions(-)
          
          diff --git a/CHANGES.current b/CHANGES.current
          index 7fdc7189d..179db9d65 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2019-02-09: olly
          +	    [PHP] A renamed constructor is now wrapped as a static method in
          +	    PHP.
          +
           2019-02-08: olly
           	    [PHP] Don't generate code which references $r when $r hasn't been
           	    defined.  This could happen in overloaded methods which returned
          diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
          index fd1dedad7..2151316bd 100644
          --- a/Source/Modules/php.cxx
          +++ b/Source/Modules/php.cxx
          @@ -1096,11 +1096,11 @@ public:
                 if (constructor) {
           	class_has_ctor = true;
           	// Skip the Foo:: prefix.
          -	char *ptr = strrchr(GetChar(Swig_methodclass(n), "sym:name"), ':');
          +	char *ptr = strrchr(GetChar(current_class, "sym:name"), ':');
           	if (ptr) {
           	  ptr++;
           	} else {
          -	  ptr = GetChar(Swig_methodclass(n), "sym:name");
          +	  ptr = GetChar(current_class, "sym:name");
           	}
           	if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) {
           	  methodname = "__construct";
          @@ -1509,7 +1509,7 @@ public:
           	      Replaceall(value, "$", "\\$");
           	    }
           	    Printf(args, "$%s=%s", arg_names[i], value);
          -	  } else if (constructor && i >= 1 && i < min_num_of_arguments) {
          +	  } else if (constructor && strcmp(methodname, "__construct") == 0 && i >= 1 && i < min_num_of_arguments) {
           	    // We need to be able to call __construct($resource).
           	    Printf(args, "$%s=null", arg_names[i]);
           	  } else {
          @@ -1667,20 +1667,33 @@ public:
           	}
           
           	if (constructor) {
          -	  const char * arg0;
          +	  // Discriminate between the PHP constructor and a C++ constructor
          +	  // renamed to become a factory function in PHP.
          +	  bool php_constructor = (strcmp(methodname, "__construct") == 0);
          +	  const char * arg0 = NULL;
           	  if (max_num_of_arguments > 0) {
           	    arg0 = Char(arg_names[0]);
          -	  } else {
          +	  } else if (php_constructor) {
          +	    // The PHP constructor needs to be able to wrap a resource, but a
          +	    // renamed constructor doesn't.
           	    arg0 = "res";
           	    Delete(args);
           	    args = NewString("$res=null");
           	  }
           	  String *mangled_type = SwigType_manglestr(Getattr(n, "type"));
          +	  if (!php_constructor) {
          +	    // A renamed constructor should be a static method.
          +	    Append(acc, "static ");
          +	  }
           	  Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args);
          -	  Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%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");
          +	  if (php_constructor) {
          +	    // The PHP constructor needs to be able to wrap a resource, but a
          +	    // renamed constructor doesn't.
          +	    Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%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, "\t%sfunction %s(%s) {\n", acc, methodname, args);
           	}
          
          From 6833bb7e0f76dff86d8921005dc72aef868247a2 Mon Sep 17 00:00:00 2001
          From: Olly Betts 
          Date: Sat, 9 Feb 2019 12:52:25 +1300
          Subject: [PATCH 1386/2031] [PHP] Make the testsuite fail on any PHP diagnostic
          
          ---
           Examples/test-suite/php/evil_diamond_prop_runme.php |  2 ++
           Examples/test-suite/php/li_std_string_runme.php     | 11 -----------
           Examples/test-suite/php/tests.php                   | 11 +++++++++++
           3 files changed, 13 insertions(+), 11 deletions(-)
          
          diff --git a/Examples/test-suite/php/evil_diamond_prop_runme.php b/Examples/test-suite/php/evil_diamond_prop_runme.php
          index 02d9944d6..9bdb7435f 100644
          --- a/Examples/test-suite/php/evil_diamond_prop_runme.php
          +++ b/Examples/test-suite/php/evil_diamond_prop_runme.php
          @@ -31,7 +31,9 @@ check::is_a($spam,"spam");
           check::equal(1,$spam->_foo,"1==spam->_foo");
           check::equal(2,$spam->_bar,"2==spam->_bar");
           // multiple inheritance not supported in PHP
          +set_error_handler(NULL, 0); // Don't complain that _baz is unknown.
           check::equal(null,$spam->_baz,"null==spam->_baz");
          +restore_error_handler();
           check::equal(4,$spam->_spam,"4==spam->_spam");
           
           check::done();
          diff --git a/Examples/test-suite/php/li_std_string_runme.php b/Examples/test-suite/php/li_std_string_runme.php
          index dbf0228df..04ee3fc86 100644
          --- a/Examples/test-suite/php/li_std_string_runme.php
          +++ b/Examples/test-suite/php/li_std_string_runme.php
          @@ -3,17 +3,6 @@
           require "tests.php";
           require "li_std_string.php";
           
          -function die_on_error($errno, $errstr, $file, $line) {
          -    if ($file !== Null) {
          -        print $file;
          -        if ($line !== Null) print ":$line";
          -        print ": ";
          -    }
          -    print "$errstr\n";
          -    exit(1);
          -}
          -set_error_handler("die_on_error", -1);
          -
           // Global variables
           //$s="initial string";
           //check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
          diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php
          index 3e835128e..20fa1ed98 100644
          --- a/Examples/test-suite/php/tests.php
          +++ b/Examples/test-suite/php/tests.php
          @@ -1,5 +1,16 @@
           
          Date: Sat, 9 Feb 2019 17:08:21 +1300
          Subject: [PATCH 1387/2031] [PHP] Fix access to already released memory
          MIME-Version: 1.0
          Content-Type: text/plain; charset=UTF-8
          Content-Transfer-Encoding: 8bit
          
          Fix access to already released memory during PHP module  shutdown, which
          often didn't cause visible problems, but could result in segmentation
          faults, bus errors, etc.  Fixes #1170, reported by Jitka Plesníková.
          ---
           CHANGES.current     | 6 ++++++
           Lib/php/phpinit.swg | 2 +-
           Lib/php/phprun.swg  | 8 ++++----
           3 files changed, 11 insertions(+), 5 deletions(-)
          
          diff --git a/CHANGES.current b/CHANGES.current
          index 179db9d65..56d3def2c 100644
          --- a/CHANGES.current
          +++ b/CHANGES.current
          @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
           Version 4.0.0 (in progress)
           ===========================
           
          +2019-02-09: olly
          +	    [PHP] Fix access to already released memory during PHP module
          +	    shutdown, which often didn't cause visible problems, but could
          +	    result in segmentation faults, bus errors, etc.  Fixes #1170,
          +	    reported by Jitka Plesníková.
          +
           2019-02-09: olly
           	    [PHP] A renamed constructor is now wrapped as a static method in
           	    PHP.
          diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg
          index 1f252d1ac..6c2363393 100644
          --- a/Lib/php/phpinit.swg
          +++ b/Lib/php/phpinit.swg
          @@ -7,7 +7,7 @@
           
           %init %{
           SWIG_php_minit {
          -    SWIG_InitializeModule(0);
          +    SWIG_InitializeModule((void*)&module_number);
           %}
           
           %fragment("swig_php_init_member_ptr2", "header") %{
          diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
          index b22ed6b58..a07a1b9f8 100644
          --- a/Lib/php/phprun.swg
          +++ b/Lib/php/phprun.swg
          @@ -57,7 +57,7 @@ static int default_error_code = E_ERROR;
           
           /* Standard SWIG API */
           #define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
          -#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
          +#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer, *(int*)clientdata)
           
           /* used to wrap returned objects in so we know whether they are newobject
              and need freeing, or not */
          @@ -230,7 +230,7 @@ SWIG_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags) {
             return -1;
           }
           
          -static char const_name[] = "swig_runtime_data_type_pointer";
          +static const char const_name[] = "swig_runtime_data_type_pointer";
           static swig_module_info *SWIG_Php_GetModule() {
             zval *pointer = zend_get_constant_str(const_name, sizeof(const_name) - 1);
             if (pointer) {
          @@ -241,6 +241,6 @@ static swig_module_info *SWIG_Php_GetModule() {
             return NULL;
           }
           
          -static void SWIG_Php_SetModule(swig_module_info *pointer) {
          -  REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, CONST_PERSISTENT | CONST_CS);
          +static void SWIG_Php_SetModule(swig_module_info *pointer, int module_number) {
          +  REGISTER_LONG_CONSTANT(const_name, (long) pointer, CONST_CS | CONST_PERSISTENT);
           }
          
          From 43bdffcbc1b99aa73243fd7d346cd4a5a19cf274 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Wed, 6 Feb 2019 22:13:10 +0000
          Subject: [PATCH 1388/2031] Skip failing MzScheme tests
          
          ---
           Examples/test-suite/mzscheme/Makefile.in | 82 ++++++++++++++++++++++++
           1 file changed, 82 insertions(+)
          
          diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
          index 3e15f8610..edd99a050 100644
          --- a/Examples/test-suite/mzscheme/Makefile.in
          +++ b/Examples/test-suite/mzscheme/Makefile.in
          @@ -10,6 +10,88 @@ srcdir       = @srcdir@
           top_srcdir   = @top_srcdir@
           top_builddir = @top_builddir@
           
          +FAILING_CPP_TESTS = \
          +allowexcept \
          +allprotected \
          +apply_strings \
          +arrays_dimensionless \
          +arrays_global \
          +char_strings \
          +class_scope_weird \
          +constant_pointers \
          +cpp_basic \
          +cpp_enum \
          +cpp_namespace \
          +cpp_static \
          +curiously_recurring_template_pattern \
          +default_arg_expressions \
          +default_args \
          +default_constructor \
          +derived_nested \
          +director_ignore \
          +enum_thorough \
          +enum_var \
          +exception_order \
          +extend \
          +extend_constructor_destructor \
          +extern_c \
          +friends \
          +global_scope_types \
          +global_vars \
          +grouping \
          +inherit_member \
          +li_attribute \
          +li_attribute_template \
          +li_boost_shared_ptr \
          +li_boost_shared_ptr_bits \
          +li_std_combinations \
          +li_std_map \
          +li_std_pair \
          +li_std_pair_using \
          +li_std_string \
          +li_std_vector \
          +li_swigtype_inout \
          +li_windows \
          +member_funcptr_galore \
          +member_pointer \
          +member_pointer_const \
          +memberin_extend \
          +namespace_class \
          +namespace_spaces \
          +naturalvar \
          +naturalvar_more \
          +nested_class \
          +nested_template_base \
          +ordering \
          +preproc_constants \
          +rename_predicates \
          +rename_simple \
          +samename \
          +smart_pointer_const_overload \
          +smart_pointer_member \
          +smart_pointer_template_const_overload \
          +static_const_member_2 \
          +swig_exception \
          +template_default2 \
          +template_specialization_defarg \
          +template_static \
          +template_typemaps \
          +typemap_variables \
          +valuewrapper_opaque \
          +
          +FAILING_C_TESTS = \
          +c_delete \
          +enum_missing \
          +enums \
          +integers \
          +name \
          +preproc_constants_c \
          +preproc_line_file \
          +unions \
          +
          +FAILING_MULTI_CPP_TESTS = \
          +multi_import \
          +
           include $(srcdir)/../common.mk
           
           # Overridden variables here
          
          From 80e9034425e7d249f3acec213b2414308ca89472 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Wed, 6 Feb 2019 22:52:24 +0000
          Subject: [PATCH 1389/2031] Fix mzscheme multimap example
          
          ---
           Examples/mzscheme/multimap/Makefile  | 1 +
           Examples/mzscheme/multimap/example.c | 2 +-
           Examples/mzscheme/multimap/example.i | 6 +++---
           Examples/mzscheme/multimap/runme.scm | 2 +-
           4 files changed, 6 insertions(+), 5 deletions(-)
          
          diff --git a/Examples/mzscheme/multimap/Makefile b/Examples/mzscheme/multimap/Makefile
          index 713ee43a7..eccd59d82 100644
          --- a/Examples/mzscheme/multimap/Makefile
          +++ b/Examples/mzscheme/multimap/Makefile
          @@ -13,5 +13,6 @@ build:
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
           	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
           	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
          +
           clean:
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
          diff --git a/Examples/mzscheme/multimap/example.c b/Examples/mzscheme/multimap/example.c
          index b8360fa8a..e945042ab 100644
          --- a/Examples/mzscheme/multimap/example.c
          +++ b/Examples/mzscheme/multimap/example.c
          @@ -27,7 +27,7 @@ int gcdmain(int argc, char *argv[]) {
             return 0;
           }
           
          -int count(char *bytes, int len, char c) {
          +int charcount(char *bytes, int len, char c) {
             int i;
             int count = 0;
             for (i = 0; i < len; i++) {
          diff --git a/Examples/mzscheme/multimap/example.i b/Examples/mzscheme/multimap/example.i
          index 515948abc..db4be3d16 100644
          --- a/Examples/mzscheme/multimap/example.i
          +++ b/Examples/mzscheme/multimap/example.i
          @@ -4,7 +4,7 @@
           %{
           extern int gcd(int x, int y);
           extern int gcdmain(int argc, char *argv[]);
          -extern int count(char *bytes, int len, char c);
          +extern int charcount(char *bytes, int len, char c);
           extern void capitalize (char *str, int len);
           extern void circle (double cx, double cy);
           extern int squareCubed (int n, int *OUTPUT);
          @@ -50,7 +50,7 @@ extern int gcdmain(int argc, char *argv[]);
             $2 = SCHEME_STRLEN_VAL($input);
           }
           
          -extern int count(char *bytes, int len, char c);
          +extern int charcount(char *bytes, int len, char c);
           
           
           /* This example shows how to wrap a function that mutates a string */
          @@ -68,7 +68,7 @@ extern int count(char *bytes, int len, char c);
           
           %typemap(argout) (char *str, int len) {
              Scheme_Object *s;
          -   s = scheme_make_sized_string($1,$2,1);
          +   s = scheme_make_sized_string($1,$2);
              SWIG_APPEND_VALUE(s);
              free($1);
           }   
          diff --git a/Examples/mzscheme/multimap/runme.scm b/Examples/mzscheme/multimap/runme.scm
          index f1e626f43..6d2c9cce3 100644
          --- a/Examples/mzscheme/multimap/runme.scm
          +++ b/Examples/mzscheme/multimap/runme.scm
          @@ -20,7 +20,7 @@
           (gcdmain #("gcdmain" "42" "105"))
           
           
          -(display (count "Hello World" #\l))
          +(display (charcount "Hello World" #\l))
           (newline)
           
           (display (capitalize "hello world"))
          
          From f6da155fda1d86660dc65e3ea65e8e88da0c5a6c Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Wed, 6 Feb 2019 22:55:15 +0000
          Subject: [PATCH 1390/2031] Fix mzscheme simple example
          
          ---
           Examples/mzscheme/simple/Makefile  | 1 +
           Examples/mzscheme/simple/runme.scm | 6 +++---
           2 files changed, 4 insertions(+), 3 deletions(-)
          
          diff --git a/Examples/mzscheme/simple/Makefile b/Examples/mzscheme/simple/Makefile
          index 713ee43a7..eccd59d82 100644
          --- a/Examples/mzscheme/simple/Makefile
          +++ b/Examples/mzscheme/simple/Makefile
          @@ -13,5 +13,6 @@ build:
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
           	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
           	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme
          +
           clean:
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
          diff --git a/Examples/mzscheme/simple/runme.scm b/Examples/mzscheme/simple/runme.scm
          index a98e31fd5..181635078 100644
          --- a/Examples/mzscheme/simple/runme.scm
          +++ b/Examples/mzscheme/simple/runme.scm
          @@ -4,7 +4,7 @@
           
           (display (get-time))
           
          -(printf "My-variable = ~a~n" (my-variable))
          +(printf "My-variable = ~a~n" (My-variable))
           
           (let loop ((i 0))
             (when (< i 14) (begin (display i)
          @@ -17,8 +17,8 @@
             (when (< i 250)
           	(begin
           	  (let loopi ((j 1))
          -	    (when (< j 250) (begin (my-variable (+ (my-variable) (mod i j)))
          +	    (when (< j 250) (begin (My-variable (+ (My-variable) (mod i j)))
           				   (loopi (+ j 1)))))
           	  (loop (+ i 1)))))
           
          -(printf "My-variable = ~a~n" (my-variable))
          +(printf "My-variable = ~a~n" (My-variable))
          
          From b21a28f26ae178ee59f857ab4e0e498dff509ad7 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Thu, 7 Feb 2019 07:45:49 +0000
          Subject: [PATCH 1391/2031] MzScheme missing destructor added in, std_vector
           example fixed
          
          ---
           Examples/mzscheme/std_vector/Makefile  | 11 ++++------
           Examples/mzscheme/std_vector/runme.scm | 30 +++++++++++++-------------
           Source/Modules/mzscheme.cxx            |  3 +--
           3 files changed, 20 insertions(+), 24 deletions(-)
          
          diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile
          index 96f5e80cf..4cf839a08 100644
          --- a/Examples/mzscheme/std_vector/Makefile
          +++ b/Examples/mzscheme/std_vector/Makefile
          @@ -1,21 +1,18 @@
           TOP        = ../..
           SWIGEXE    = $(TOP)/../swig
           SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
          -SRCS       =
          +CXXSRCS    =
           TARGET     = example
           INTERFACE  = example.i
           SWIGOPT    =
           
          -GPP        = `which g++`
          -MZC        = test -n "/usr/bin/mzc" && /usr/bin/mzc
          -
           check: build
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
           
           build:
          -	$(SWIGEXE) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
          -	$(MZC) --compiler $(GPP) ++ccf "-I." --cc example_wrap.cxx
          -	$(MZC) --linker $(GPP) --ld $(TARGET).so example_wrap.o
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
          +	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
          +	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
           
           clean:
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
          diff --git a/Examples/mzscheme/std_vector/runme.scm b/Examples/mzscheme/std_vector/runme.scm
          index 67351f128..7af9d168e 100644
          --- a/Examples/mzscheme/std_vector/runme.scm
          +++ b/Examples/mzscheme/std_vector/runme.scm
          @@ -9,16 +9,17 @@
                 (if (< i size)
                     (begin
                       (proc v i)
          -            (with-vector-item v (+ i 1)))))
          +            (with-vector-item v (+ i 1)))
          +          (void)))
               (with-vector-item v 0)))
           
          -(define (with-intvector v proc)
          -  (with-vector v proc intvector-length))
          -(define (with-doublevector v proc)
          -  (with-vector v proc doublevector-length))
          +(define (with-IntVector v proc)
          +  (with-vector v proc IntVector-length))
          +(define (with-DoubleVector v proc)
          +  (with-vector v proc DoubleVector-length))
           
          -(define (print-doublevector v)
          -  (with-doublevector v (lambda (v i) (display (doublevector-ref v i)) 
          +(define (print-DoubleVector v)
          +  (with-DoubleVector v (lambda (v i) (display (DoubleVector-ref v i))
                                                (display " ")))
             (newline))
           
          @@ -29,11 +30,11 @@
           (newline)
           
           ; ... or a wrapped std::vector
          -(define v (new-intvector 4))
          -(with-intvector v (lambda (v i) (intvector-set! v i (+ i 1))))
          +(define v (new-IntVector 4))
          +(with-IntVector v (lambda (v i) (IntVector-set! v i (+ i 1))))
           (display (average v))
           (newline)
          -(delete-intvector v)
          +(delete-IntVector v)
           
           ; half will return a Scheme vector.
           ; Call it with a Scheme vector...
          @@ -42,13 +43,12 @@
           (newline)
           
           ; ... or a wrapped std::vector
          -(define v (new-doublevector))
          -(map (lambda (i) (doublevector-push! v i)) '(1 2 3 4))
          +(define v (new-DoubleVector))
          +(map (lambda (i) (DoubleVector-push! v i)) '(1 2 3 4))
           (display (half v))
           (newline)
           
           ; now halve a wrapped std::vector in place
           (halve-in-place v)
          -(print-doublevector v)
          -(delete-doublevector v)
          -
          +(print-DoubleVector v)
          +(delete-DoubleVector v)
          diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
          index e826e6b3c..316b66678 100644
          --- a/Source/Modules/mzscheme.cxx
          +++ b/Source/Modules/mzscheme.cxx
          @@ -439,9 +439,8 @@ public:
                 sprintf(temp, "%d", numargs);
                 if (exporting_destructor) {
           	Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
          -      } else {
          -	Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
                 }
          +      Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
               } else {
                 if (!Getattr(n, "sym:nextSibling")) {
           	/* Emit overloading dispatch function */
          
          From 20344093efc8acc9da4fe77ce6b3601e10cc747d Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 13:15:32 +0000
          Subject: [PATCH 1392/2031] Fix mzscheme static variable wrappers
          
          $argnum needs to be expanded in the 'varin' typemap which shares
          code used by the 'in' typemap.
          Setting the static variable is also a function call (argnum=1).
          
          Added class examples - needs static variables to work
          Test newly working test cases with this fix
          ---
           Examples/mzscheme/check.list             |  1 +
           Examples/mzscheme/class/Makefile         | 18 +++++++
           Examples/mzscheme/class/example.cxx      | 28 +++++++++++
           Examples/mzscheme/class/example.h        | 34 ++++++++++++++
           Examples/mzscheme/class/example.i        |  9 ++++
           Examples/mzscheme/class/runme.scm        | 60 ++++++++++++++++++++++++
           Examples/test-suite/mzscheme/Makefile.in | 23 ---------
           Source/Modules/mzscheme.cxx              |  2 +-
           8 files changed, 151 insertions(+), 24 deletions(-)
           create mode 100644 Examples/mzscheme/class/Makefile
           create mode 100644 Examples/mzscheme/class/example.cxx
           create mode 100644 Examples/mzscheme/class/example.h
           create mode 100644 Examples/mzscheme/class/example.i
           create mode 100644 Examples/mzscheme/class/runme.scm
          
          diff --git a/Examples/mzscheme/check.list b/Examples/mzscheme/check.list
          index f9e4f11c7..d2554c41c 100644
          --- a/Examples/mzscheme/check.list
          +++ b/Examples/mzscheme/check.list
          @@ -1,4 +1,5 @@
           # see top-level Makefile.in
          +class
           multimap
           simple
           std_vector
          diff --git a/Examples/mzscheme/class/Makefile b/Examples/mzscheme/class/Makefile
          new file mode 100644
          index 000000000..ee92aa9f1
          --- /dev/null
          +++ b/Examples/mzscheme/class/Makefile
          @@ -0,0 +1,18 @@
          +TOP        = ../..
          +SWIGEXE    = $(TOP)/../swig
          +SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
          +CXXSRCS    = example.cxx
          +TARGET     = example
          +INTERFACE  = example.i
          +SWIGOPT    =
          +
          +check: build
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
          +
          +build:
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
          +	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
          +	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
          +
          +clean:
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_clean
          diff --git a/Examples/mzscheme/class/example.cxx b/Examples/mzscheme/class/example.cxx
          new file mode 100644
          index 000000000..046304519
          --- /dev/null
          +++ b/Examples/mzscheme/class/example.cxx
          @@ -0,0 +1,28 @@
          +/* File : example.cxx */
          +
          +#include "example.h"
          +#define M_PI 3.14159265358979323846
          +
          +/* Move the shape to a new location */
          +void Shape::move(double dx, double dy) {
          +  x += dx;
          +  y += dy;
          +}
          +
          +int Shape::nshapes = 0;
          +
          +double Circle::area() {
          +  return M_PI*radius*radius;
          +}
          +
          +double Circle::perimeter() {
          +  return 2*M_PI*radius;
          +}
          +
          +double Square::area() {
          +  return width*width;
          +}
          +
          +double Square::perimeter() {
          +  return 4*width;
          +}
          diff --git a/Examples/mzscheme/class/example.h b/Examples/mzscheme/class/example.h
          new file mode 100644
          index 000000000..0dff185b2
          --- /dev/null
          +++ b/Examples/mzscheme/class/example.h
          @@ -0,0 +1,34 @@
          +/* File : example.h */
          +
          +class Shape {
          +public:
          +  Shape() {
          +    nshapes++;
          +  }
          +  virtual ~Shape() {
          +    nshapes--;
          +  }
          +  double  x, y;
          +  void    move(double dx, double dy);
          +  virtual double area() = 0;
          +  virtual double perimeter() = 0;
          +  static  int nshapes;
          +};
          +
          +class Circle : public Shape {
          +private:
          +  double radius;
          +public:
          +  Circle(double r) : radius(r) { }
          +  virtual double area();
          +  virtual double perimeter();
          +};
          +
          +class Square : public Shape {
          +private:
          +  double width;
          +public:
          +  Square(double w) : width(w) { }
          +  virtual double area();
          +  virtual double perimeter();
          +};
          diff --git a/Examples/mzscheme/class/example.i b/Examples/mzscheme/class/example.i
          new file mode 100644
          index 000000000..fbdf7249f
          --- /dev/null
          +++ b/Examples/mzscheme/class/example.i
          @@ -0,0 +1,9 @@
          +/* File : example.i */
          +%module example
          +
          +%{
          +#include "example.h"
          +%}
          +
          +/* Let's just grab the original header file here */
          +%include "example.h"
          diff --git a/Examples/mzscheme/class/runme.scm b/Examples/mzscheme/class/runme.scm
          new file mode 100644
          index 000000000..dea0b75bc
          --- /dev/null
          +++ b/Examples/mzscheme/class/runme.scm
          @@ -0,0 +1,60 @@
          +; file: runme.scm
          +
          +; This file illustrates the proxy class C++ interface generated
          +; by SWIG.
          +
          +(load-extension "example.so")
          +
          +; Convenience wrapper around the display function
          +; (which only accepts one argument at the time)
          +
          +(define (mdisplay-newline . args)
          +  (for-each display args)
          +  (newline))
          +
          +; ----- Object creation -----
          +
          +(mdisplay-newline "Creating some objects:")
          +(define c (new-Circle 10))
          +(mdisplay-newline "    Created circle " c)
          +(define s (new-Square 10))
          +(mdisplay-newline "    Created square " s)
          +
          +; ----- Access a static member -----
          +
          +(mdisplay-newline "\nA total of " (Shape-nshapes) " shapes were created")
          +
          +; ----- Member data access -----
          +
          +; Set the location of the object
          +
          +(Shape-x-set c 20)
          +(Shape-y-set c 30)
          +
          +(Shape-x-set s -10)
          +(Shape-y-set s 5)
          +
          +(mdisplay-newline "\nHere is their current position:")
          +(mdisplay-newline "    Circle = (" (Shape-x-get c) "," (Shape-y-get c) ")")
          +(mdisplay-newline "    Square = (" (Shape-x-get s) "," (Shape-y-get s) ")")
          +
          +; ----- Call some methods -----
          +
          +(mdisplay-newline "\nHere are some properties of the shapes:")
          +(define (shape-props o)
          +  (mdisplay-newline "   " o)
          +  (mdisplay-newline "   area      = " (Shape-area o))
          +  (mdisplay-newline "   perimeter = " (Shape-perimeter o)))
          +(for-each  shape-props (list c s))
          +
          +(mdisplay-newline "\nGuess I'll clean up now")
          +
          +; Note: this invokes the virtual destructor
          +(delete-Shape c)
          +(delete-Shape s)
          +
          +(define s 3)
          +(mdisplay-newline (Shape-nshapes) " shapes remain")
          +(mdisplay-newline "Goodbye")
          +
          +(exit 0)
          diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
          index edd99a050..5eacb10e3 100644
          --- a/Examples/test-suite/mzscheme/Makefile.in
          +++ b/Examples/test-suite/mzscheme/Makefile.in
          @@ -12,7 +12,6 @@ top_builddir = @top_builddir@
           
           FAILING_CPP_TESTS = \
           allowexcept \
          -allprotected \
           apply_strings \
           arrays_dimensionless \
           arrays_global \
          @@ -21,42 +20,30 @@ class_scope_weird \
           constant_pointers \
           cpp_basic \
           cpp_enum \
          -cpp_namespace \
          -cpp_static \
           curiously_recurring_template_pattern \
           default_arg_expressions \
          -default_args \
           default_constructor \
           derived_nested \
           director_ignore \
           enum_thorough \
          -enum_var \
          -exception_order \
           extend \
          -extend_constructor_destructor \
          -extern_c \
           friends \
           global_scope_types \
          -global_vars \
          -grouping \
           inherit_member \
           li_attribute \
           li_attribute_template \
           li_boost_shared_ptr \
          -li_boost_shared_ptr_bits \
           li_std_combinations \
           li_std_map \
           li_std_pair \
           li_std_pair_using \
           li_std_string \
           li_std_vector \
          -li_swigtype_inout \
           li_windows \
           member_funcptr_galore \
           member_pointer \
           member_pointer_const \
           memberin_extend \
          -namespace_class \
           namespace_spaces \
           naturalvar \
           naturalvar_more \
          @@ -64,24 +51,14 @@ nested_class \
           nested_template_base \
           ordering \
           preproc_constants \
          -rename_predicates \
          -rename_simple \
           samename \
          -smart_pointer_const_overload \
          -smart_pointer_member \
          -smart_pointer_template_const_overload \
          -static_const_member_2 \
          -swig_exception \
           template_default2 \
           template_specialization_defarg \
          -template_static \
           template_typemaps \
           typemap_variables \
           valuewrapper_opaque \
           
           FAILING_C_TESTS = \
          -c_delete \
          -enum_missing \
           enums \
           integers \
           name \
          diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
          index 316b66678..1df5ae0fb 100644
          --- a/Source/Modules/mzscheme.cxx
          +++ b/Source/Modules/mzscheme.cxx
          @@ -527,7 +527,7 @@ public:
           	  Replaceall(tm, "$source", "argv[0]");
           	  Replaceall(tm, "$target", name);
           	  Replaceall(tm, "$input", "argv[0]");
          -	  /* Printv(f->code, tm, "\n",NIL); */
          +	  Replaceall(tm, "$argnum", "1");
           	  emit_action_code(n, f->code, tm);
           	} else {
           	  throw_unhandled_mzscheme_type_error(t);
          
          From de23343739a79331883cfd2bede0afc0504657c0 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 14:29:34 +0000
          Subject: [PATCH 1393/2031] Standardise Guile simple example
          
          Changes so that it works the same as other language modules
          ---
           Examples/guile/simple/example.c | 27 ++++++++++++---------------
           Examples/guile/simple/example.i |  6 ++----
           Examples/guile/simple/runme.scm | 28 ++++++++++++----------------
           3 files changed, 26 insertions(+), 35 deletions(-)
          
          diff --git a/Examples/guile/simple/example.c b/Examples/guile/simple/example.c
          index dcafc4dc4..1c2af789c 100644
          --- a/Examples/guile/simple/example.c
          +++ b/Examples/guile/simple/example.c
          @@ -1,21 +1,18 @@
          -/* Simple example from documentation */
           /* File : example.c */
           
          -#include 
          +/* A global variable */
          +double Foo = 3.0;
           
          -double My_variable = 3.0;
          -
          -int fact(int n) {
          -  if (n <= 1) return 1;
          -  else return n*fact(n-1);
          +/* Compute the greatest common divisor of positive integers */
          +int gcd(int x, int y) {
          +  int g;
          +  g = y;
          +  while (x > 0) {
          +    g = x;
          +    x = y % x;
          +    y = g;
          +  }
          +  return g;
           }
           
          -int mod(int n, int m) {
          -  return (n % m);
          -}
           
          -char *get_time() {
          -  long ltime;
          -  time(<ime);
          -  return ctime(<ime);
          -}
          diff --git a/Examples/guile/simple/example.i b/Examples/guile/simple/example.i
          index 1a9930a14..4fcea98b2 100644
          --- a/Examples/guile/simple/example.i
          +++ b/Examples/guile/simple/example.i
          @@ -5,10 +5,8 @@
           %}
           
           %inline %{
          -extern double My_variable;
          -extern int    fact(int);
          -extern int    mod(int n, int m);
          -extern char  *get_time();
          +extern int    gcd(int x, int y);
          +extern double Foo;
           %}
           
           %include guile/guilemain.i
          diff --git a/Examples/guile/simple/runme.scm b/Examples/guile/simple/runme.scm
          index c3fd0b41f..ccd755701 100644
          --- a/Examples/guile/simple/runme.scm
          +++ b/Examples/guile/simple/runme.scm
          @@ -3,24 +3,20 @@
             (for-each display args)
             (newline))
           
          -(mdisplay-newline (get-time) "My variable = " (My-variable))
          +; Call our gcd() function
           
          -(do ((i 0 (1+ i)))
          -    ((= 14 i))
          -  (mdisplay-newline i " factorial is " (fact i)))
          +(define x 42)
          +(define y 105)
          +(define g (gcd x y))
          +(mdisplay-newline "The gcd of " x " and " y " is " g)
           
          -(define (mods i imax j jmax)
          -  (if (< i imax)
          -      (if (< j jmax)
          -          (begin
          -            (My-variable (+ (My-variable) (mod i j)))
          -            (mods i imax (+ j 1) jmax))
          -          (mods (+ i 1) imax 1 jmax))))
          +; Manipulate the Foo global variable
           
          -(mods 1 150 1 150)
          +; Output its current value
          +(mdisplay-newline "Foo = " (Foo))
           
          -(mdisplay-newline "My-variable = " (My-variable))
          -
          -(exit (and (= 1932053504 (fact 13))
          -           (= 745470.0 (My-variable))))
          +; Change its value
          +(Foo 3.1415926)
           
          +; See if the change took effect
          +(mdisplay-newline "Foo = " (Foo))
          
          From 30d0c16ac0935fdc343c1e646ff6cae3bf03bcd8 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 14:43:27 +0000
          Subject: [PATCH 1394/2031] Standardise Mzscheme simple example
          
          Changes so that it works the same as other language modules
          ---
           Examples/mzscheme/simple/README    |  1 -
           Examples/mzscheme/simple/example.c | 30 +++++++++--------------
           Examples/mzscheme/simple/example.i | 13 ++--------
           Examples/mzscheme/simple/runme.scm | 39 ++++++++++++++++++------------
           4 files changed, 37 insertions(+), 46 deletions(-)
           delete mode 100644 Examples/mzscheme/simple/README
          
          diff --git a/Examples/mzscheme/simple/README b/Examples/mzscheme/simple/README
          deleted file mode 100644
          index 07e8da069..000000000
          --- a/Examples/mzscheme/simple/README
          +++ /dev/null
          @@ -1 +0,0 @@
          -Simple example from users manual.
          diff --git a/Examples/mzscheme/simple/example.c b/Examples/mzscheme/simple/example.c
          index f2b074781..1c2af789c 100644
          --- a/Examples/mzscheme/simple/example.c
          +++ b/Examples/mzscheme/simple/example.c
          @@ -1,24 +1,18 @@
          -/* Simple example from documentation */
           /* File : example.c */
           
          -#include 
          +/* A global variable */
          +double Foo = 3.0;
           
          -double My_variable = 3.0;
          -
          -/* Compute factorial of n */
          -int fact(int n) {
          -  if (n <= 1) return 1;
          -  else return n*fact(n-1);
          -}
          -
          -/* Compute n mod m */
          -int my_mod(int n, int m) {
          -  return (n % m);
          +/* Compute the greatest common divisor of positive integers */
          +int gcd(int x, int y) {
          +  int g;
          +  g = y;
          +  while (x > 0) {
          +    g = x;
          +    x = y % x;
          +    y = g;
          +  }
          +  return g;
           }
           
           
          -char *get_time() {
          -    long            ltime;
          -    time(<ime);
          -    return ctime(<ime);
          -}
          diff --git a/Examples/mzscheme/simple/example.i b/Examples/mzscheme/simple/example.i
          index 5b3e95580..24093b9bf 100644
          --- a/Examples/mzscheme/simple/example.i
          +++ b/Examples/mzscheme/simple/example.i
          @@ -1,16 +1,7 @@
           /* File : example.i */
           %module example
          -%{
          -/* Put headers and other declarations here */
          -%}
          -
          -%include typemaps.i
          -
          -%rename(mod) my_mod;
           
           %inline %{
          -extern double My_variable;
          -extern int    fact(int);
          -extern int    my_mod(int n, int m);
          -extern char   *get_time();
          +extern int    gcd(int x, int y);
          +extern double Foo;
           %}
          diff --git a/Examples/mzscheme/simple/runme.scm b/Examples/mzscheme/simple/runme.scm
          index 181635078..88d32d6fc 100644
          --- a/Examples/mzscheme/simple/runme.scm
          +++ b/Examples/mzscheme/simple/runme.scm
          @@ -2,23 +2,30 @@
           
           (load-extension "example.so")
           
          -(display (get-time))
          +; Call our gcd() function
           
          -(printf "My-variable = ~a~n" (My-variable))
          +(define x 42)
          +(define y 105)
          +(define g (gcd x y))
          +(display "The gcd of ")
          +(display x)
          +(display " and ")
          +(display y)
          +(display " is ")
          +(display g)
          +(newline)
           
          -(let loop ((i 0))
          -  (when (< i 14) (begin (display i)
          -			(display " factorial is ")
          -			(display (fact i))
          -			(newline)
          -			(loop (+ i 1)))))
          +; Manipulate the Foo global variable
           
          -(let loop ((i 1))
          -  (when (< i 250)
          -	(begin
          -	  (let loopi ((j 1))
          -	    (when (< j 250) (begin (My-variable (+ (My-variable) (mod i j)))
          -				   (loopi (+ j 1)))))
          -	  (loop (+ i 1)))))
          +; Output its current value
          +(display "Foo = ")
          +(display (Foo))
          +(newline)
           
          -(printf "My-variable = ~a~n" (My-variable))
          +; Change its value
          +(Foo 3.1415926)
          +
          +; See if the change took effect
          +(display "Foo = ")
          +(display (Foo))
          +(newline)
          
          From 4bb0b974c0e23c22e0882104b661ab97450ce171 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 17:14:46 +0000
          Subject: [PATCH 1395/2031] Mzscheme out of source examples fixes
          
          ---
           Examples/Makefile.in                  | 6 +++---
           Examples/mzscheme/class/Makefile      | 2 +-
           Examples/mzscheme/std_vector/Makefile | 2 +-
           3 files changed, 5 insertions(+), 5 deletions(-)
          
          diff --git a/Examples/Makefile.in b/Examples/Makefile.in
          index 450824400..c5dcb1ee1 100644
          --- a/Examples/Makefile.in
          +++ b/Examples/Makefile.in
          @@ -813,7 +813,7 @@ MZSCHEME = mzscheme
           MZC = @MZC@
           MZDYNOBJ = @MZDYNOBJ@
           MZSCHEME_SO = @MZSCHEME_SO@
          -MZSCHEME_SCRIPT = $(RUNME).scm
          +MZSCHEME_SCRIPT = $(SRCDIR)$(RUNME).scm
           
           # ----------------------------------------------------------------
           # Build a C/C++ dynamically loadable module
          @@ -821,12 +821,12 @@ MZSCHEME_SCRIPT = $(RUNME).scm
           
           mzscheme: $(SRCDIR_SRCS)
           	$(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
          -	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
          +	$(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS)
           	$(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
           
           mzscheme_cpp: $(SRCDIR_SRCS)
           	$(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
          -	$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
          +	$(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
           	$(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
           
           # -----------------------------------------------------------------
          diff --git a/Examples/mzscheme/class/Makefile b/Examples/mzscheme/class/Makefile
          index ee92aa9f1..0b36a60d7 100644
          --- a/Examples/mzscheme/class/Makefile
          +++ b/Examples/mzscheme/class/Makefile
          @@ -10,7 +10,7 @@ check: build
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
           
           build:
          -	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
           	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
           	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
           
          diff --git a/Examples/mzscheme/std_vector/Makefile b/Examples/mzscheme/std_vector/Makefile
          index 4cf839a08..8057465b3 100644
          --- a/Examples/mzscheme/std_vector/Makefile
          +++ b/Examples/mzscheme/std_vector/Makefile
          @@ -10,7 +10,7 @@ check: build
           	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' mzscheme_run
           
           build:
          -	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(CXXSRCDIR)' CXXSRCS='$(CXXSRCS)' \
          +	$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \
           	SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
           	SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' mzscheme_cpp
           
          
          From a2db2a6e27d87534db26addca330c769a10de1a3 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 17:34:02 +0000
          Subject: [PATCH 1396/2031] Format mzscheme help output
          
          Also simplify -dynamic-load option help as it does more than
          not emit scheme_initialize, scheme_reload, scheme_module_name.
          ---
           Source/Modules/mzscheme.cxx | 10 ++++------
           1 file changed, 4 insertions(+), 6 deletions(-)
          
          diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
          index 1df5ae0fb..23be87d0f 100644
          --- a/Source/Modules/mzscheme.cxx
          +++ b/Source/Modules/mzscheme.cxx
          @@ -17,12 +17,10 @@
           
           static const char *usage = "\
           Mzscheme Options (available with -mzscheme)\n\
          -     -declaremodule                         - Create extension that declares a module\n\
          -     -dynamic-load ,[library,...]  - Do not link with these libraries, dynamic load\n\
          -                                              them\n\
          -     -noinit                                - Do not emit scheme_initialize, scheme_reload,\n\
          -                                              scheme_module_name functions\n\
          -     -prefix                          - Set a prefix  to be prepended to all names\n\
          +     -declaremodule                - Create extension that declares a module\n\
          +     -dynamic-load ,[lib,...] - Do not link with these libraries, dynamic load them\n\
          +     -noinit                       - Do not emit module initialization code\n\
          +     -prefix                 - Set a prefix  to be prepended to all names\n\
           ";
           
           static String *fieldnames_tab = 0;
          
          From f7648051fd608c9fb5756e01ef5215673c34a1c5 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 17:45:59 +0000
          Subject: [PATCH 1397/2031] Add mzscheme to Travis testing
          
          This is an experimental language so needs to go under allow_failures.
          ---
           .travis.yml                   | 11 +++++++++++
           Tools/travis-linux-install.sh |  3 +++
           2 files changed, 14 insertions(+)
          
          diff --git a/.travis.yml b/.travis.yml
          index 3368493ad..c669f0b05 100644
          --- a/.travis.yml
          +++ b/.travis.yml
          @@ -94,6 +94,11 @@ matrix:
                 env: SWIGLANG=lua VER=5.3
                 sudo: required
                 dist: trusty
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=mzscheme
          +      sudo: required
          +      dist: trusty
               - compiler: gcc
                 os: linux
                 env: SWIGLANG=ocaml
          @@ -384,6 +389,12 @@ matrix:
                 env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1
                 sudo: required
                 dist: trusty
          +    # Experimental languages
          +    - compiler: gcc
          +      os: linux
          +      env: SWIGLANG=mzscheme
          +      sudo: required
          +      dist: trusty
           
           before_install:
             - date -u
          diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh
          index caf53dbc1..dc8526546 100755
          --- a/Tools/travis-linux-install.sh
          +++ b/Tools/travis-linux-install.sh
          @@ -72,6 +72,9 @@ case "$SWIGLANG" in
           			travis_retry sudo apt-get -qq install lua${VER} liblua${VER}-dev
           		fi
           		;;
          +	"mzscheme")
          +		travis_retry sudo apt-get -qq install racket
          +		;;
           	"ocaml")
           		# configure also looks for ocamldlgen, but this isn't packaged.  But it isn't used by default so this doesn't matter.
           		travis_retry sudo apt-get -qq install ocaml ocaml-findlib
          
          From b4257fb1f2dbbc609df031944d704b5ad6bb1a6c Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 17:58:06 +0000
          Subject: [PATCH 1398/2031] Mark MzScheme as an experimental language
          
          ---
           Doc/Manual/SWIG.html        | 2 +-
           Source/Modules/swigmain.cxx | 2 +-
           2 files changed, 2 insertions(+), 2 deletions(-)
          
          diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
          index 365cd2940..be6eda739 100644
          --- a/Doc/Manual/SWIG.html
          +++ b/Doc/Manual/SWIG.html
          @@ -125,7 +125,6 @@ Supported Target Language Options
                -java           - Generate Java wrappers
                -javascript     - Generate Javascript wrappers
                -lua            - Generate Lua wrappers
          -     -mzscheme       - Generate Mzscheme wrappers
                -ocaml          - Generate Ocaml wrappers
                -octave         - Generate Octave wrappers
                -perl5          - Generate Perl 5 wrappers
          @@ -138,6 +137,7 @@ Supported Target Language Options
                -xml            - Generate XML wrappers
           
           Experimental Target Language Options
          +     -mzscheme       - Generate MzScheme/Racket wrappers
           
           General Options
                -addextern      - Add extra extern declarations
          diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
          index 472264c26..a9916ad9a 100644
          --- a/Source/Modules/swigmain.cxx
          +++ b/Source/Modules/swigmain.cxx
          @@ -63,7 +63,7 @@ static TargetLanguageModule modules[] = {
             {"-javascript", swig_javascript, "Javascript", Supported},
             {"-lua", swig_lua, "Lua", Supported},
             {"-modula3", NULL, "Modula 3", Disabled},
          -  {"-mzscheme", swig_mzscheme, "Mzscheme", Supported},
          +  {"-mzscheme", swig_mzscheme, "MzScheme/Racket", Experimental},
             {"-ocaml", swig_ocaml, "Ocaml", Supported},
             {"-octave", swig_octave, "Octave", Supported},
             {"-perl", swig_perl5, NULL, Supported},
          
          From c06dba6b582e748b2be8065469b82c4e2a6e7b02 Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 20:31:27 +0000
          Subject: [PATCH 1399/2031] Suppress experimental language warning when running
           the test-suite
          
          ---
           Examples/test-suite/mzscheme/Makefile.in | 2 +-
           1 file changed, 1 insertion(+), 1 deletion(-)
          
          diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in
          index 5eacb10e3..e6e5662b3 100644
          --- a/Examples/test-suite/mzscheme/Makefile.in
          +++ b/Examples/test-suite/mzscheme/Makefile.in
          @@ -72,7 +72,7 @@ multi_import \
           include $(srcdir)/../common.mk
           
           # Overridden variables here
          -# none!
          +SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
           
           # Custom tests - tests with additional commandline options
           # none!
          
          From 3e4b0aace888af989e390cf5d6b81788583de7de Mon Sep 17 00:00:00 2001
          From: William S Fulton 
          Date: Sat, 9 Feb 2019 18:02:55 +0000
          Subject: [PATCH 1400/2031] Terminology correction in html docs
          
          ---
           Doc/Manual/Extending.html | 6 +++---
           1 file changed, 3 insertions(+), 3 deletions(-)
          
          diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
          index 53c2e68ae..7b2e61e21 100644
          --- a/Doc/Manual/Extending.html
          +++ b/Doc/Manual/Extending.html
          @@ -3626,7 +3626,7 @@ A target language is given the 'Experimental' status when
           
           
          • - It is of sub-standard quality, failing to meet the above 'Standard' status. + It is of sub-standard quality, failing to meet the above 'Supported' status.
          • It is somewhere between the mid to mature stage of development. @@ -3652,7 +3652,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat Have fully functional examples of basic functionality (the simple and class examples).
          • - The test-suite must be implemented and include some runtime tests for wrapped C and C++ tests. + The test-suite must be implemented and include a few runtime tests for both C and C++ test cases.
          • Failing tests must be put into one of the FAILING_CPP_TESTS or FAILING_C_TESTS lists in the test-suite. @@ -3668,7 +3668,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat Any new failed tests will be fixed on a 'best effort' basis by core developers with no promises made.
          • - If a language module has an official maintainer, then the maintainer will be requested to focus on fixing test-suite regressions and commit to migrating the module to become a 'Standard' module. + If a language module has an official maintainer, then the maintainer will be requested to focus on fixing test-suite regressions and commit to migrating the module to become a 'Supported' module.
          • If a module does not have an official maintainer, then, as maintenance will be on a 'best efforts' basis by the core maintainers, no guarantees will be provided from one release to the next and regressions may creep in. From 454c1f1aa4237265fa8d59b68c3b6aa31f180626 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Feb 2019 18:46:38 +0000 Subject: [PATCH 1401/2031] Fix mzscheme name and unions testcases --- Examples/test-suite/mzscheme/Makefile.in | 2 -- Examples/test-suite/mzscheme/name_runme.scm | 2 +- Examples/test-suite/mzscheme/unions_runme.scm | 6 ++++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index e6e5662b3..4338b9b1f 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -61,10 +61,8 @@ valuewrapper_opaque \ FAILING_C_TESTS = \ enums \ integers \ -name \ preproc_constants_c \ preproc_line_file \ -unions \ FAILING_MULTI_CPP_TESTS = \ multi_import \ diff --git a/Examples/test-suite/mzscheme/name_runme.scm b/Examples/test-suite/mzscheme/name_runme.scm index 1782c6481..94df9131d 100644 --- a/Examples/test-suite/mzscheme/name_runme.scm +++ b/Examples/test-suite/mzscheme/name_runme.scm @@ -1,7 +1,7 @@ ;; The SWIG modules have "passive" Linkage, i.e., they don't generate ;; Guile modules (namespaces) but simply put all the bindings into the ;; current module. That's enough for such a simple test. -(load-extension "./name.so") +(load-extension "name.so") (foo-2) bar-2 diff --git a/Examples/test-suite/mzscheme/unions_runme.scm b/Examples/test-suite/mzscheme/unions_runme.scm index c44847cfc..1c39cb94c 100644 --- a/Examples/test-suite/mzscheme/unions_runme.scm +++ b/Examples/test-suite/mzscheme/unions_runme.scm @@ -25,13 +25,15 @@ (if (not (= Jill1 200)) (begin (display "Runtime test 1 failed.") - (exit 1)))) + (exit 1)) + (void))) (let ((Num1 (EmbeddedUnionTest-number-get eut))) (if (not (= Num1 1)) (begin (display "Runtime test 2 failed.") - (exit 1)))) + (exit 1)) + (void))) ;; that should do From 6055722c6fe6ab731b92d1b32fcaba0cc6b40100 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 00:43:28 +0000 Subject: [PATCH 1402/2031] Changes file entry for %apply anonymous template instantiations --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 56d3def2c..4e5915f4d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-10: sethrj + #1452 Fix %apply for anonymous template instantiations + 2019-02-09: olly [PHP] Fix access to already released memory during PHP module shutdown, which often didn't cause visible problems, but could From 7f2ddebbcd84f5fcec7ed8e03cf45a376b5675e8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 00:57:39 +0000 Subject: [PATCH 1403/2031] Changes file entry for MzScheme improvements --- CHANGES.current | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 4e5915f4d..34e1af4ab 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,16 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-10: wsfulton + [MzScheme] #1437 MzScheme/Racket is now an 'Experimental' language. The examples work + and a large portion of the test-suite is also working. + +2019-02-10: wsfulton + [MzScheme] Destructor wrappers were not being generated. + +2019-02-10: wsfulton + [MzScheme] Static variable wrappers fixed - $argnum was not expanded. + 2019-02-10: sethrj #1452 Fix %apply for anonymous template instantiations @@ -623,7 +633,7 @@ Version 4.0.0 (in progress) [Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC -Wconversion-null warning (on by default with recent GCC). -2018-03-09: fultonwi +2018-03-09: wsfulton [Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression for non-director classes. Restores a dynamic_cast which was previously removed. From 24682a724302b70d3b363fbbe0125ab0c53384b6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 01:00:57 +0000 Subject: [PATCH 1404/2031] Move MzScheme documentation to experimental section Move MzScheme documentation to experimental section --- Doc/Manual/Sections.html | 2 +- Doc/Manual/chapters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 6558cd1f5..97338b0f4 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -47,7 +47,6 @@ Last update : SWIG-4.0.0 (in progress)
          • Java support
          • Javascript support
          • Lua support
          • -
          • MzScheme/Racket support
          • Ocaml support
          • Octave support
          • Perl5 support
          • @@ -62,6 +61,7 @@ Last update : SWIG-4.0.0 (in progress)

            Experimental Language Modules Documentation

            Developer Documentation

            diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 9d1e2d909..1d3f96d87 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -25,7 +25,6 @@ Guile.html Java.html Javascript.html Lua.html -Mzscheme.html Ocaml.html Octave.html Perl5.html @@ -35,4 +34,5 @@ R.html Ruby.html Scilab.html Tcl.html +Mzscheme.html Extending.html From 940e32477dba502a98477960d5a0d1385f7e2edb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 01:03:06 +0000 Subject: [PATCH 1405/2031] Update section numbering --- Doc/Manual/Android.html | 16 +-- Doc/Manual/CSharp.html | 60 ++++----- Doc/Manual/Contents.html | 267 +++++-------------------------------- Doc/Manual/D.html | 44 +++--- Doc/Manual/Extending.html | 106 +++++++-------- Doc/Manual/Go.html | 56 ++++---- Doc/Manual/Guile.html | 44 +++--- Doc/Manual/Java.html | 220 +++++++++++++++--------------- Doc/Manual/Javascript.html | 44 +++--- Doc/Manual/Lua.html | 88 ++++++------ Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 66 ++++----- Doc/Manual/Octave.html | 52 ++++---- Doc/Manual/Perl5.html | 108 +++++++-------- Doc/Manual/Php.html | 50 +++---- Doc/Manual/Python.html | 200 +++++++++++++-------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 +++++++++++++-------------- Doc/Manual/Scilab.html | 90 ++++++------- Doc/Manual/Tcl.html | 92 ++++++------- 20 files changed, 810 insertions(+), 1017 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 894724188..cc11ec26e 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

            21 SWIG and Android

            +

            20 SWIG and Android

          -

          22.4 C# Arrays

          +

          21.4 C# Arrays

          @@ -586,7 +586,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

          -

          22.4.1 The SWIG C arrays library

          +

          21.4.1 The SWIG C arrays library

          @@ -623,7 +623,7 @@ example.print_array(c.cast()); // Pass to C

          -

          22.4.2 Managed arrays using P/Invoke default array marshalling

          +

          21.4.2 Managed arrays using P/Invoke default array marshalling

          @@ -750,7 +750,7 @@ and intermediary class method

        -

        22.4.3 Managed arrays using pinning

        +

        21.4.3 Managed arrays using pinning

        @@ -845,7 +845,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

        22.5 C# Exceptions

        +

        21.5 C# Exceptions

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

        -

        22.5.1 C# exception example using "check" typemap

        +

        21.5.1 C# exception example using "check" typemap

        @@ -1124,7 +1124,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.

        -

        22.5.2 C# exception example using %exception

        +

        21.5.2 C# exception example using %exception

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

    -

    22.5.3 C# exception example using exception specifications

    +

    21.5.3 C# exception example using exception specifications

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

    -

    22.5.4 Custom C# ApplicationException example

    +

    21.5.4 Custom C# ApplicationException example

    @@ -1379,7 +1379,7 @@ try { -

    22.6 C# Directors

    +

    21.6 C# Directors

    @@ -1392,7 +1392,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.

    -

    22.6.1 Directors example

    +

    21.6.1 Directors example

    @@ -1513,7 +1513,7 @@ CSharpDerived - UIntMethod(123) -

    22.6.2 Directors implementation

    +

    21.6.2 Directors implementation

    @@ -1721,7 +1721,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    22.6.3 Director caveats

    +

    21.6.3 Director caveats

    @@ -1769,7 +1769,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.

    -

    22.7 Multiple modules

    +

    21.7 Multiple modules

    @@ -1804,7 +1804,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    22.8 C# Typemap examples

    +

    21.8 C# Typemap examples

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

    22.8.1 Memory management when returning references to member variables

    +

    21.8.1 Memory management when returning references to member variables

    @@ -1936,7 +1936,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

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

    +

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

    @@ -2068,7 +2068,7 @@ as mentioned earlier, setElement is actually: -

    22.8.3 Date marshalling using the csin typemap and associated attributes

    +

    21.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2354,7 +2354,7 @@ public class example { -

    22.8.4 A date example demonstrating marshalling of C# properties

    +

    21.8.4 A date example demonstrating marshalling of C# properties

    @@ -2454,7 +2454,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    21.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2516,7 +2516,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    22.8.6 Turning proxy classes into partial classes

    +

    21.8.6 Turning proxy classes into partial classes

    @@ -2616,7 +2616,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.

    -

    22.8.7 Turning proxy classes into sealed classes

    +

    21.8.7 Turning proxy classes into sealed classes

    @@ -2706,7 +2706,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    22.8.8 Extending proxy classes with additional C# code

    +

    21.8.8 Extending proxy classes with additional C# code

    @@ -2745,7 +2745,7 @@ public class ExtendMe : global::System.IDisposable { -

    22.8.9 Underlying type for enums

    +

    21.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 06dd91ae6..e0db363f7 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -711,91 +711,7 @@ -

    20 SWIG and Allegro Common Lisp

    - - - - - -

    21 SWIG and Android

    +

    20 SWIG and Android

    @@ -813,7 +729,7 @@
    -

    22 SWIG and C#

    +

    21 SWIG and C#

    @@ -861,45 +777,7 @@
    -

    23 SWIG and Chicken

    - - - - - -

    24 SWIG and D

    +

    22 SWIG and D

    @@ -933,7 +811,7 @@
    -

    25 SWIG and Go

    +

    23 SWIG and Go

    @@ -977,7 +855,7 @@
    -

    26 SWIG and Guile

    +

    24 SWIG and Guile

    @@ -1013,7 +891,7 @@
    -

    27 SWIG and Java

    +

    25 SWIG and Java

    @@ -1167,7 +1045,7 @@
    -

    28 SWIG and Javascript

    +

    26 SWIG and Javascript

    @@ -1209,30 +1087,7 @@
    -

    29 SWIG and Common Lisp

    - - - - - -

    30 SWIG and Lua

    +

    27 SWIG and Lua

    @@ -1300,57 +1155,7 @@
    -

    31 SWIG and Modula-3

    - - - - - -

    32 SWIG and MzScheme/Racket

    - - - - - -

    33 SWIG and Ocaml

    +

    28 SWIG and Ocaml

    @@ -1405,7 +1210,7 @@
    -

    34 SWIG and Octave

    +

    29 SWIG and Octave

    @@ -1445,7 +1250,7 @@
    -

    35 SWIG and Perl5

    +

    30 SWIG and Perl5

    @@ -1521,7 +1326,7 @@
    -

    36 SWIG and PHP

    +

    31 SWIG and PHP

    @@ -1562,31 +1367,7 @@
    -

    37 SWIG and Pike

    - - - - - -

    38 SWIG and Python

    +

    32 SWIG and Python

    @@ -1728,7 +1509,7 @@
    -

    39 SWIG and R

    +

    33 SWIG and R

    @@ -1744,7 +1525,7 @@
    -

    40 SWIG and Ruby

    +

    34 SWIG and Ruby

    @@ -1882,7 +1663,7 @@
    -

    41 SWIG and Scilab

    +

    35 SWIG and Scilab

    @@ -1951,7 +1732,7 @@
    -

    42 SWIG and Tcl

    +

    36 SWIG and Tcl

    @@ -2017,7 +1798,19 @@
    -

    43 Extending SWIG to support new languages

    +

    37 SWIG and MzScheme/Racket

    + + + + + +

    38 Extending SWIG to support new languages

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 5a6ee8f28..1a317a005 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    24 SWIG and D

    +

    22 SWIG and D

      @@ -41,7 +41,7 @@ -

      24.1 Introduction

      +

      22.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      24.2 Command line invocation

      +

      22.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      24.3 Typemaps

      +

      22.3 Typemaps

      -

      24.3.1 C# <-> D name comparison

      +

      22.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    24.3.2 ctype, imtype, dtype

    +

    22.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    24.3.3 in, out, directorin, directorout

    +

    22.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    24.3.4 din, dout, ddirectorin, ddirectorout

    +

    22.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a)
    -

    24.3.5 typecheck typemaps

    +

    22.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    24.3.6 Code injection typemaps

    +

    22.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    24.3.7 Special variable macros

    +

    22.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    24.4 D and %feature

    +

    22.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    24.5 Pragmas

    +

    22.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    24.6 D Exceptions

    +

    22.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    24.7 D Directors

    +

    22.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    24.8 Other features

    +

    22.8 Other features

    -

    24.8.1 Extended namespace support (nspace)

    +

    22.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    24.8.2 Native pointer support

    +

    22.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    24.8.3 Operator overloading

    +

    22.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    24.8.4 Running the test-suite

    +

    22.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    24.9 D Typemap examples

    +

    22.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    24.10 Work in progress and planned features

    +

    22.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 7b2e61e21..1d9fc83ac 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    43 Extending SWIG to support new languages

    +

    38 Extending SWIG to support new languages

    -

    43.4.4 Attribute namespaces

    +

    38.4.4 Attribute namespaces

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

    -

    43.4.5 Symbol Tables

    +

    38.4.5 Symbol Tables

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

    43.4.6 The %feature directive

    +

    38.4.6 The %feature directive

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

    -

    43.4.7 Code Generation

    +

    38.4.7 Code Generation

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

    -

    43.4.8 SWIG and XML

    +

    38.4.8 SWIG and XML

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

    -

    43.5 Primitive Data Structures

    +

    38.5 Primitive Data Structures

    @@ -993,7 +993,7 @@ typedef Hash Typetab; -

    43.5.1 Strings

    +

    38.5.1 Strings

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

    43.5.2 Hashes

    +

    38.5.2 Hashes

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

    43.5.3 Lists

    +

    38.5.3 Lists

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

    43.5.4 Common operations

    +

    38.5.4 Common operations

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

    43.5.5 Iterating over Lists and Hashes

    +

    38.5.5 Iterating over Lists and Hashes

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

    43.5.6 I/O

    +

    38.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1534,7 +1534,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    43.6 Navigating and manipulating parse trees

    +

    38.6 Navigating and manipulating parse trees

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

    43.7 Working with attributes

    +

    38.7 Working with attributes

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

    43.8 Type system

    +

    38.8 Type system

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

    -

    43.8.1 String encoding of types

    +

    38.8.1 String encoding of types

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

    -

    43.8.2 Type construction

    +

    38.8.2 Type construction

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

    43.8.3 Type tests

    +

    38.8.3 Type tests

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

    43.8.4 Typedef and inheritance

    +

    38.8.4 Typedef and inheritance

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

    43.8.5 Lvalues

    +

    38.8.5 Lvalues

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

    43.8.6 Output functions

    +

    38.8.6 Output functions

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

    43.9 Parameters

    +

    38.9 Parameters

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

    43.10 Writing a Language Module

    +

    38.10 Writing a Language Module

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

    -

    43.10.1 Execution model

    +

    38.10.1 Execution model

    @@ -2476,7 +2476,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.

    -

    43.10.2 Starting out

    +

    38.10.2 Starting out

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

    -

    43.10.3 Command line options

    +

    38.10.3 Command line options

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

    -

    43.10.4 Configuration and preprocessing

    +

    38.10.4 Configuration and preprocessing

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

    -

    43.10.5 Entry point to code generation

    +

    38.10.5 Entry point to code generation

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

    43.10.6 Module I/O and wrapper skeleton

    +

    38.10.6 Module I/O and wrapper skeleton

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

    43.10.7 Low-level code generators

    +

    38.10.7 Low-level code generators

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

    -

    43.10.8 Configuration files

    +

    38.10.8 Configuration files

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

    43.10.9 Runtime support

    +

    38.10.9 Runtime support

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

    -

    43.10.10 Standard library files

    +

    38.10.10 Standard library files

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

    -

    43.10.11 User examples

    +

    38.10.11 User examples

    @@ -3253,7 +3253,7 @@ during this process, see the section on .

    -

    43.10.12 Test driven development and the test-suite

    +

    38.10.12 Test driven development and the test-suite

    @@ -3312,7 +3312,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    43.10.12.1 Running the test-suite

    +

    38.10.12.1 Running the test-suite

    @@ -3504,7 +3504,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    43.10.13 Documentation

    +

    38.10.13 Documentation

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

    43.10.14 Coding style guidelines

    +

    38.10.14 Coding style guidelines

    @@ -3561,7 +3561,7 @@ should be avoided as unlike the SWIG developers, users will never have consisten

    -

    43.10.15 Target language status

    +

    38.10.15 Target language status

    @@ -3570,7 +3570,7 @@ the Target language in This section provides more details on how this status is given.

    -

    43.10.15.1 Supported status

    +

    38.10.15.1 Supported status

    @@ -3617,7 +3617,7 @@ A target language is given the 'Supported' status when

  • -

    43.10.15.2 Experimental status

    +

    38.10.15.2 Experimental status

    @@ -3682,7 +3682,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat

  • -

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

    +

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

    @@ -3746,7 +3746,7 @@ the existing tests.

    -

    43.11 Debugging Options

    +

    38.11 Debugging Options

    @@ -3773,7 +3773,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    43.12 Guide to parse tree nodes

    +

    38.12 Guide to parse tree nodes

    @@ -4181,7 +4181,7 @@ extern "X" { ... } declaration. -

    43.13 Further Development Information

    +

    38.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 3b8d872ae..8523f74aa 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    25 SWIG and Go

    +

    23 SWIG and Go

    -

    25.3.1 Go-specific Commandline Options

    +

    23.3.1 Go-specific Commandline Options

    @@ -264,7 +264,7 @@ swig -go -help -

    25.3.2 Generated Wrapper Files

    +

    23.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -308,7 +308,7 @@ combined with the compiled MODULE.go using go tool pack. -

    25.4 A tour of basic C/C++ wrapping

    +

    23.4 A tour of basic C/C++ wrapping

    @@ -318,7 +318,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    25.4.1 Go Package Name

    +

    23.4.1 Go Package Name

    @@ -328,7 +328,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    25.4.2 Go Names

    +

    23.4.2 Go Names

    @@ -360,7 +360,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    25.4.3 Go Constants

    +

    23.4.3 Go Constants

    @@ -368,7 +368,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    25.4.4 Go Enumerations

    +

    23.4.4 Go Enumerations

    @@ -378,7 +378,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    25.4.5 Go Classes

    +

    23.4.5 Go Classes

    @@ -456,7 +456,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    25.4.5.1 Go Class Memory Management

    +

    23.4.5.1 Go Class Memory Management

    @@ -578,7 +578,7 @@ func (o *GoClassName) Close() { -

    25.4.5.2 Go Class Inheritance

    +

    23.4.5.2 Go Class Inheritance

    @@ -590,7 +590,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    25.4.6 Go Templates

    +

    23.4.6 Go Templates

    @@ -599,7 +599,7 @@ wrappers for a particular template instantation. To do this, use the %template directive. -

    25.4.7 Go Director Classes

    +

    23.4.7 Go Director Classes

    @@ -617,7 +617,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    25.4.7.1 Example C++ code

    +

    23.4.7.1 Example C++ code

    @@ -689,7 +689,7 @@ be found in the end of the guide.

    -

    25.4.7.2 Enable director feature

    +

    23.4.7.2 Enable director feature

    @@ -724,7 +724,7 @@ documentation on directors.

    -

    25.4.7.3 Constructor and destructor

    +

    23.4.7.3 Constructor and destructor

    @@ -777,7 +777,7 @@ embedding.

    -

    25.4.7.4 Override virtual methods

    +

    23.4.7.4 Override virtual methods

    @@ -843,7 +843,7 @@ the Go methods.

    -

    25.4.7.5 Call base methods

    +

    23.4.7.5 Call base methods

    @@ -880,7 +880,7 @@ be found in the end of the guide.

    -

    25.4.7.6 Subclass via embedding

    +

    23.4.7.6 Subclass via embedding

    @@ -948,7 +948,7 @@ class.

    -

    25.4.7.7 Memory management with runtime.SetFinalizer

    +

    23.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1013,7 +1013,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    25.4.7.8 Complete FooBarGo example class

    +

    23.4.7.8 Complete FooBarGo example class

    @@ -1142,7 +1142,7 @@ SWIG/Examples/go/director/.

    -

    25.4.8 Default Go primitive type mappings

    +

    23.4.8 Default Go primitive type mappings

    @@ -1249,7 +1249,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    25.4.9 Output arguments

    +

    23.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1302,7 +1302,7 @@ void f(char *output); -

    25.4.10 Adding additional go code

    +

    23.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1397,7 +1397,7 @@ func bar() { -

    25.4.11 Go typemaps

    +

    23.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 9d55b632b..6acdd2dc3 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    26 SWIG and Guile

    +

    24 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      26.1 Supported Guile Versions

      +

      24.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      26.2 Meaning of "Module"

      +

      24.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      26.3 Old GH Guile API

      +

      24.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      26.4 Linkage

      +

      24.4 Linkage

      @@ -89,7 +89,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. -

      26.4.1 Simple Linkage

      +

      24.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      26.4.2 Passive Linkage

      +

      24.4.2 Passive Linkage

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

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

      26.4.3 Native Guile Module Linkage

      +

      24.4.3 Native Guile Module Linkage

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

    -

    26.4.4 Old Auto-Loading Guile Module Linkage

    +

    24.4.4 Old Auto-Loading Guile Module Linkage

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

    26.4.5 Hobbit4D Linkage

    +

    24.4.5 Hobbit4D Linkage

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

    -

    26.5 Underscore Folding

    +

    24.5 Underscore Folding

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

    26.6 Typemaps

    +

    24.6 Typemaps

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

    -

    26.7 Representation of pointers as smobs

    +

    24.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    26.7.1 Smobs

    +

    24.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    26.7.2 Garbage Collection

    +

    24.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 26.8 Native Guile pointers +

    24.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    26.9 Exception Handling

    +

    24.9 Exception Handling

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

    26.10 Procedure documentation

    +

    24.10 Procedure documentation

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

    26.11 Procedures with setters

    +

    24.11 Procedures with setters

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

    26.12 GOOPS Proxy Classes

    +

    24.12 GOOPS Proxy Classes

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

    -

    26.12.1 Naming Issues

    +

    24.12.1 Naming Issues

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

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    26.12.2 Linking

    +

    24.12.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index ac92252e0..77a81995e 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    27 SWIG and Java

    +

    25 SWIG and Java

    -

    27.3.3 Global variables

    +

    25.3.3 Global variables

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

    27.3.4 Constants

    +

    25.3.4 Constants

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

    -

    27.3.5 Enumerations

    +

    25.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    27.3.5.1 Anonymous enums

    +

    25.3.5.1 Anonymous enums

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

    -

    27.3.5.2 Typesafe enums

    +

    25.3.5.2 Typesafe enums

    @@ -1127,7 +1127,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.

    -

    27.3.5.3 Proper Java enums

    +

    25.3.5.3 Proper Java enums

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

    -

    27.3.5.4 Type unsafe enums

    +

    25.3.5.4 Type unsafe enums

    @@ -1228,7 +1228,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.

    -

    27.3.5.5 Simple enums

    +

    25.3.5.5 Simple enums

    @@ -1247,7 +1247,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.

    -

    27.3.6 Pointers

    +

    25.3.6 Pointers

    @@ -1335,7 +1335,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.

    -

    27.3.7 Structures

    +

    25.3.7 Structures

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

    27.3.8 C++ classes

    +

    25.3.8 C++ classes

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

    27.3.9 C++ inheritance

    +

    25.3.9 C++ inheritance

    @@ -1627,7 +1627,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.

    -

    27.3.10 Pointers, references, arrays and pass by value

    +

    25.3.10 Pointers, references, arrays and pass by value

    @@ -1682,7 +1682,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).

    -

    27.3.10.1 Null pointers

    +

    25.3.10.1 Null pointers

    @@ -1706,7 +1706,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.

    -

    27.3.11 C++ overloaded functions

    +

    25.3.11 C++ overloaded functions

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

    27.3.12 C++ default arguments

    +

    25.3.12 C++ default arguments

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

    -

    27.3.13 C++ namespaces

    +

    25.3.13 C++ namespaces

    @@ -1954,7 +1954,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    27.3.14 C++ templates

    +

    25.3.14 C++ templates

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

    -

    27.3.15 C++ Smart Pointers

    +

    25.3.15 C++ Smart Pointers

    -

    27.3.15.1 The shared_ptr Smart Pointer

    +

    25.3.15.1 The shared_ptr Smart Pointer

    @@ -2017,7 +2017,7 @@ in the shared_ptr smart pointer -

    27.3.15.2 Generic Smart Pointers

    +

    25.3.15.2 Generic Smart Pointers

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

    27.4 Further details on the generated Java classes

    +

    25.4 Further details on the generated Java classes

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

    -

    27.4.1 The intermediary JNI class

    +

    25.4.1 The intermediary JNI class

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

    -

    27.4.1.1 The intermediary JNI class pragmas

    +

    25.4.1.1 The intermediary JNI class pragmas

    @@ -2318,7 +2318,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    27.4.2 The Java module class

    +

    25.4.2 The Java module class

    @@ -2349,7 +2349,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.

    -

    27.4.2.1 The Java module class pragmas

    +

    25.4.2.1 The Java module class pragmas

    @@ -2400,7 +2400,7 @@ See The intermediary JNI class pragmas secti

    -

    27.4.3 Java proxy classes

    +

    25.4.3 Java proxy classes

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

    27.4.3.1 Memory management

    +

    25.4.3.1 Memory management

    @@ -2638,7 +2638,7 @@ and

    -

    27.4.3.2 Inheritance

    +

    25.4.3.2 Inheritance

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

    25.4.3.3 Proxy classes and garbage collection

    @@ -2837,7 +2837,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.

    -

    27.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2959,7 +2959,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    27.4.3.5 Single threaded applications and thread safety

    +

    25.4.3.5 Single threaded applications and thread safety

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

    27.4.4 Type wrapper classes

    +

    25.4.4 Type wrapper classes

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

    27.4.5 Enum classes

    +

    25.4.5 Enum classes

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

    -

    27.4.5.1 Typesafe enum classes

    +

    25.4.5.1 Typesafe enum classes

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

    -

    27.4.5.2 Proper Java enum classes

    +

    25.4.5.2 Proper Java enum classes

    @@ -3305,7 +3305,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.

    -

    27.4.5.3 Type unsafe enum classes

    +

    25.4.5.3 Type unsafe enum classes

    @@ -3336,7 +3336,7 @@ public final class Beverage { -

    27.4.6 Interfaces

    +

    25.4.6 Interfaces

    @@ -3581,7 +3581,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    27.5 Cross language polymorphism using directors

    +

    25.5 Cross language polymorphism using directors

    @@ -3603,7 +3603,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.

    -

    27.5.1 Enabling directors

    +

    25.5.1 Enabling directors

    @@ -3671,7 +3671,7 @@ public: -

    27.5.2 Director classes

    +

    25.5.2 Director classes

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

    -

    27.5.3 Overhead and code bloat

    +

    25.5.3 Overhead and code bloat

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

    -

    27.5.4 Simple directors example

    +

    25.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    27.5.5 Director threading issues

    +

    25.5.5 Director threading issues

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

    27.5.6 Director performance tuning

    +

    25.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    27.5.7 Java exceptions from directors

    +

    25.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    27.5.7.1 Customizing director exceptions

    +

    25.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    27.6 Accessing protected members

    +

    25.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    27.7 Common customization features

    +

    25.7 Common customization features

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

    -

    27.7.1 C/C++ helper functions

    +

    25.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    27.7.2 Class extension with %extend

    +

    25.7.2 Class extension with %extend

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

    -

    27.7.3 Class extension with %proxycode

    +

    25.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    27.7.4 Exception handling with %exception and %javaexception

    +

    25.7.4 Exception handling with %exception and %javaexception

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

    -

    27.7.5 Method access with %javamethodmodifiers

    +

    25.7.5 Method access with %javamethodmodifiers

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

    27.8 Tips and techniques

    +

    25.8 Tips and techniques

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

    -

    27.8.1 Input and output parameters using primitive pointers and references

    +

    25.8.1 Input and output parameters using primitive pointers and references

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

    -

    27.8.2 Simple pointers

    +

    25.8.2 Simple pointers

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

    -

    27.8.3 Wrapping C arrays with Java arrays

    +

    25.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    27.8.4 Unbounded C Arrays

    +

    25.8.4 Unbounded C Arrays

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

    -

    27.8.5 Binary data vs Strings

    +

    25.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    27.8.6 Overriding new and delete to allocate from Java heap

    +

    25.8.6 Overriding new and delete to allocate from Java heap

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

    -

    27.9 Java typemaps

    +

    25.9 Java typemaps

    @@ -5657,7 +5657,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. -

    27.9.1 Default primitive type mappings

    +

    25.9.1 Default primitive type mappings

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

    -

    27.9.2 Default typemaps for non-primitive types

    +

    25.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    27.9.3 Sixty four bit JVMs

    +

    25.9.3 Sixty four bit JVMs

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

    -

    27.9.4 What is a typemap?

    +

    25.9.4 What is a typemap?

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

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

    +

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

    @@ -6240,7 +6240,7 @@ These are listed below: -

    27.9.6 Java typemap attributes

    +

    25.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    27.9.7 Java special variables

    +

    25.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    27.9.8 Typemaps for both C and C++ compilation

    +

    25.9.8 Typemaps for both C and C++ compilation

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

    -

    27.9.9 Java code typemaps

    +

    25.9.9 Java code typemaps

    @@ -6801,7 +6801,7 @@ to make the method and constructor public: -

    27.9.10 Director specific typemaps

    +

    25.9.10 Director specific typemaps

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

    27.10 Typemap Examples

    +

    25.10 Typemap Examples

    @@ -7088,7 +7088,7 @@ the SWIG library.

    -

    27.10.1 Simpler Java enums for enums without initializers

    +

    25.10.1 Simpler Java enums for enums without initializers

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

    -

    27.10.2 Handling C++ exception specifications as Java exceptions

    +

    25.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    27.10.3 NaN Exception - exception handling for a particular type

    +

    25.10.3 NaN Exception - exception handling for a particular type

    @@ -7447,7 +7447,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.

    -

    27.10.4 Converting Java String arrays to char **

    +

    25.10.4 Converting Java String arrays to char **

    @@ -7591,7 +7591,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    27.10.5 Expanding a Java object to multiple arguments

    +

    25.10.5 Expanding a Java object to multiple arguments

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

    27.10.6 Using typemaps to return arguments

    +

    25.10.6 Using typemaps to return arguments

    @@ -7791,7 +7791,7 @@ $ java runme 1 12.0 340.0 -

    27.10.7 Adding Java downcasts to polymorphic return types

    +

    25.10.7 Adding Java downcasts to polymorphic return types

    @@ -7997,7 +7997,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.

    -

    27.10.8 Adding an equals method to the Java classes

    +

    25.10.8 Adding an equals method to the Java classes

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

    27.10.9 Void pointers and a common Java base class

    +

    25.10.9 Void pointers and a common Java base class

    @@ -8100,7 +8100,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. -

    27.10.10 Struct pointer to pointer

    +

    25.10.10 Struct pointer to pointer

    @@ -8280,7 +8280,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.

    -

    27.10.11 Memory management when returning references to member variables

    +

    25.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

    @@ -8531,7 +8531,7 @@ as mentioned earlier, setElement is actually: -

    27.10.13 Date marshalling using the javain typemap and associated attributes

    +

    25.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8708,7 +8708,7 @@ A few things to note: -

    27.11 Living with Java Directors

    +

    25.11 Living with Java Directors

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

  • -

    27.12 Odds and ends

    +

    25.12 Odds and ends

    -

    27.12.1 JavaDoc comments

    +

    25.12.1 JavaDoc comments

    @@ -8946,7 +8946,7 @@ public class Barmy { -

    27.12.2 Functional interface without proxy classes

    +

    25.12.2 Functional interface without proxy classes

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

    27.12.3 Using your own JNI functions

    +

    25.12.3 Using your own JNI functions

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

    -

    27.12.4 Performance concerns and hints

    +

    25.12.4 Performance concerns and hints

    @@ -9078,7 +9078,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.

    -

    27.12.5 Debugging

    +

    25.12.5 Debugging

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

    -

    27.13 Java Examples

    +

    25.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index ab7ee5157..8de528511 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    28 SWIG and Javascript

    +

    26 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      28.1 Overview

      +

      26.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      28.2 Preliminaries

      +

      26.2 Preliminaries

      -

      28.2.1 Running SWIG

      +

      26.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      28.2.2 Running Tests and Examples

      +

      26.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    28.2.3 Known Issues

    +

    26.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -170,12 +170,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    28.3 Integration

    +

    26.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    28.3.1 Creating node.js Extensions

    +

    26.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -221,7 +221,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    28.3.1.1 Troubleshooting

    +

    26.3.1.1 Troubleshooting

      @@ -233,12 +233,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      28.3.2 Embedded Webkit

      +

      26.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      28.3.2.1 Mac OS X

      +

      26.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -286,7 +286,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      28.3.2.2 GTK

      +

      26.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -331,7 +331,7 @@ int main(int argc, char* argv[]) } -

      28.3.3 Creating Applications with node-webkit

      +

      26.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -422,12 +422,12 @@ open new windows, and many more things. }; -

      28.4 Examples

      +

      26.4 Examples

      Some basic examples are shown here in more detail.

      -

      28.4.1 Simple

      +

      26.4.1 Simple

      The common example simple looks like this:

      @@ -477,7 +477,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      28.4.2 Class

      +

      26.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -607,12 +607,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      28.5 Implementation

      +

      26.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      28.5.1 Source Code

      +

      26.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -713,7 +713,7 @@ Template::Template(const String *code_) { ... } ... -

      28.5.2 Code Templates

      +

      26.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -752,7 +752,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      28.5.3 Emitter

      +

      26.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -871,7 +871,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      28.5.4 Emitter states

      +

      26.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -915,7 +915,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      28.5.5 Handling Exceptions in JavascriptCore

      +

      26.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 25d5e2cd5..90bcc5a00 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

      30 SWIG and Lua

      +

      27 SWIG and Lua

        @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

        -

        30.1 Preliminaries

        +

        27.1 Preliminaries

        The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

        -

        30.2 Running SWIG

        +

        27.2 Running SWIG

        @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

        -

        30.2.1 Additional command line options

        +

        27.2.1 Additional command line options

        @@ -179,7 +179,7 @@ swig -lua -help -

        30.2.2 Compiling and Linking and Interpreter

        +

        27.2.2 Compiling and Linking and Interpreter

        @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

        -

        30.2.3 Compiling a dynamic module

        +

        27.2.3 Compiling a dynamic module

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

        30.2.4 Using your module

        +

        27.2.4 Using your module

        @@ -336,19 +336,19 @@ $ ./my_lua >

      -

      30.3 A tour of basic C/C++ wrapping

      +

      27.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.

      -

      30.3.1 Modules

      +

      27.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.

      -

      30.3.2 Functions

      +

      27.3.2 Functions

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

      30.3.3 Global variables

      +

      27.3.3 Global variables

      @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

      -

      30.3.4 Constants and enums

      +

      27.3.4 Constants and enums

      @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

      30.3.4.1 Constants/enums and classes/structures

      +

      27.3.4.1 Constants/enums and classes/structures

      @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

      -

      30.3.5 Pointers

      +

      27.3.5 Pointers

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

      30.3.6 Structures

      +

      27.3.6 Structures

      @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

      -

      30.3.7 C++ classes

      +

      27.3.7 C++ classes

      @@ -785,7 +785,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

      -

      30.3.8 C++ inheritance

      +

      27.3.8 C++ inheritance

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

      It is safe to use multiple inheritance with SWIG.

      -

      30.3.9 Pointers, references, values, and arrays

      +

      27.3.9 Pointers, references, values, and arrays

      @@ -841,7 +841,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.

      -

      30.3.10 C++ overloaded functions

      +

      27.3.10 C++ overloaded functions

      @@ -927,7 +927,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.

      -

      30.3.11 C++ operators

      +

      27.3.11 C++ operators

      @@ -1059,7 +1059,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    30.3.12 Class extension with %extend

    +

    27.3.12 Class extension with %extend

    @@ -1116,7 +1116,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).

    -

    30.3.13 Using %newobject to release memory

    +

    27.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1140,7 +1140,7 @@ char *foo();

    This will release the allocated memory.

    -

    30.3.14 C++ templates

    +

    27.3.14 C++ templates

    @@ -1175,7 +1175,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.

    -

    30.3.15 C++ Smart Pointers

    +

    27.3.15 C++ Smart Pointers

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

    30.3.16 C++ Exceptions

    +

    27.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    30.3.17 Namespaces

    +

    27.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    30.3.17.1 Compatibility Note

    +

    27.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    30.3.17.2 Names

    +

    27.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    30.3.17.3 Inheritance

    +

    27.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    30.4 Typemaps

    +

    27.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    30.4.1 What is a typemap?

    +

    27.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:

    @@ -1555,7 +1555,7 @@ Received an integer : 6 720 -

    30.4.2 Using typemaps

    +

    27.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.

    @@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);

    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).

    -

    30.4.3 Typemaps and arrays

    +

    27.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 @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

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

    -

    30.4.4 Typemaps and pointer-pointer functions

    +

    27.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:

    @@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    30.5 Writing typemaps

    +

    27.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.

    @@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    30.5.1 Typemaps you can write

    +

    27.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.

    @@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    30.5.2 SWIG's Lua-C API

    +

    27.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.

    @@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    30.6 Customization of your Bindings

    +

    27.6 Customization of your Bindings

    @@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -

    30.6.1 Writing your own custom wrappers

    +

    27.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    30.6.2 Adding additional Lua code

    +

    27.6.2 Adding additional Lua code

    @@ -1843,7 +1843,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.

    -

    30.7 Details on the Lua binding

    +

    27.7 Details on the Lua binding

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

    -

    30.7.1 Binding global data into the module.

    +

    27.7.1 Binding global data into the module.

    @@ -1914,7 +1914,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)'.

    -

    30.7.2 Userdata and Metatables

    +

    27.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    30.7.3 Memory management

    +

    27.7.3 Memory management

    diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index c3af5c49e..860a5c412 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

    32 SWIG and MzScheme/Racket

    +

    37 SWIG and MzScheme/Racket

    -

    32.2 Simple example

    +

    37.2 Simple example

    @@ -166,7 +166,7 @@ Some points of interest:

  • The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it. -

    32.3 External documentation

    +

    37.3 External documentation

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index a3c60db02..9e0902bc8 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -7,7 +7,7 @@ -

    33 SWIG and Ocaml

    +

    28 SWIG and Ocaml

    -

    33.1.3 The camlp4 module

    +

    28.1.3 The camlp4 module

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

    33.1.4 Using your module

    +

    28.1.4 Using your module

    @@ -256,7 +256,7 @@ option to build your functions into the primitive list. This option is not needed when you build native code.

    -

    33.1.5 Compilation problems and compiling with C++

    +

    28.1.5 Compilation problems and compiling with C++

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

    -

    33.2 The low-level Ocaml/C interface

    +

    28.2 The low-level Ocaml/C interface

    @@ -367,7 +367,7 @@ value items pass through directly, but you must make your own type signature for a function that uses value in this way.

    -

    33.2.1 The generated module

    +

    28.2.1 The generated module

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

    33.2.2 Enums

    +

    28.2.2 Enums

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

    33.2.2.1 Enum typing in Ocaml

    +

    28.2.2.1 Enum typing in Ocaml

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

    -

    33.2.3 Arrays

    +

    28.2.3 Arrays

    -

    33.2.3.1 Simple types of bounded arrays

    +

    28.2.3.1 Simple types of bounded arrays

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

    -

    33.2.3.2 Complex and unbounded arrays

    +

    28.2.3.2 Complex and unbounded arrays

    @@ -514,7 +514,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.

    -

    33.2.3.3 Using an object

    +

    28.2.3.3 Using an object

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

    -

    33.2.3.4 Example typemap for a function taking float * and int

    +

    28.2.3.4 Example typemap for a function taking float * and int

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

    33.2.4 C++ Classes

    +

    28.2.4 C++ Classes

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

    -

    33.2.4.1 STL vector and string Example

    +

    28.2.4.1 STL vector and string Example

    @@ -702,7 +702,7 @@ baz # -

    33.2.4.2 C++ Class Example

    +

    28.2.4.2 C++ Class Example

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

    33.2.4.3 Compiling the example

    +

    28.2.4.3 Compiling the example

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

    33.2.4.4 Sample Session

    +

    28.2.4.4 Sample Session

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

    -

    33.2.5 Director Classes

    +

    28.2.5 Director Classes

    -

    33.2.5.1 Director Introduction

    +

    28.2.5.1 Director Introduction

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

    -

    33.2.5.2 Overriding Methods in Ocaml

    +

    28.2.5.2 Overriding Methods in Ocaml

    @@ -835,7 +835,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.

    -

    33.2.5.3 Director Usage Example

    +

    28.2.5.3 Director Usage Example

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

    -

    33.2.5.4 Creating director objects

    +

    28.2.5.4 Creating director objects

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

    -

    33.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    28.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -948,7 +948,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.

    -

    33.2.5.6 typemap

    +

    28.2.5.6 typemap

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

    -

    33.2.5.7 directorout typemap

    +

    28.2.5.7 directorout typemap

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

    -

    33.2.5.8 directorargout typemap

    +

    28.2.5.8 directorargout typemap

    @@ -987,7 +987,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.

    -

    33.2.6 Exceptions

    +

    28.2.6 Exceptions

    @@ -996,7 +996,7 @@ but not too useful example is provided by the throw_exception testcase in Examples/test-suite. You can provide your own exceptions, too.

    -

    33.3 Documentation Features

    +

    28.3 Documentation Features

    @@ -1005,7 +1005,7 @@ comments (colloquially referred to as "docstrings") that can be read by OCamldoc.

    -

    33.3.1 Module docstring

    +

    28.3.1 Module docstring

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 1295966bd..bd6b08ff9 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -9,7 +9,7 @@ -

    34 SWIG and Octave

    +

    29 SWIG and Octave

      @@ -60,7 +60,7 @@ This chapter is intended to give an introduction to using the module. You should 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).

      -

      34.1 Preliminaries

      +

      29.1 Preliminaries

      @@ -76,7 +76,7 @@ This cannot be guaranteed however, as in recent times new Octave releases have r The SWIG runtime exports the function swig_octave_prereq() for checking the version of Octave.

      -

      34.2 Running SWIG

      +

      29.2 Running SWIG

      @@ -108,7 +108,7 @@ The -c++ option is also required when wrapping C++ code: This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

      -

      34.2.1 Command-line options

      +

      29.2.1 Command-line options

      @@ -131,7 +131,7 @@ The special name "." loads C global variables into the module namespace, i.e. al The -opprefix options sets the prefix of the names of global/friend operator functions.

      -

      34.2.2 Compiling a dynamic module

      +

      29.2.2 Compiling a dynamic module

      @@ -158,7 +158,7 @@ $ mkoctfile example_wrap.cpp example.c

      octave:1> swigexample
      -

      34.2.3 Using your module

      +

      29.2.3 Using your module

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

    -

    34.3 A tour of basic C/C++ wrapping

    +

    29.3 A tour of basic C/C++ wrapping

    -

    34.3.1 Modules

    +

    29.3.1 Modules

    @@ -224,7 +224,7 @@ octave:4> swigexample.gcd(4, 6) ans = 2 -

    34.3.2 Functions

    +

    29.3.2 Functions

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

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

    34.3.3 Global variables

    +

    29.3.3 Global variables

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

    34.3.4 Constants and enums

    +

    29.3.4 Constants and enums

    @@ -316,7 +316,7 @@ swigexample.SCONST="Hello World" swigexample.SUNDAY=0 .... -

    34.3.5 Pointers

    +

    29.3.5 Pointers

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

    34.3.6 Structures and C++ classes

    +

    29.3.6 Structures and C++ classes

    @@ -498,7 +498,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.

    -

    34.3.7 C++ inheritance

    +

    29.3.7 C++ inheritance

    @@ -507,7 +507,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.

    -

    34.3.8 C++ overloaded functions

    +

    29.3.8 C++ overloaded functions

    @@ -517,7 +517,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.

    -

    34.3.9 C++ operators

    +

    29.3.9 C++ operators

    @@ -621,7 +621,7 @@ On the C++ side, the default mappings are as follows: Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

    -

    34.3.10 Class extension with %extend

    +

    29.3.10 Class extension with %extend

    @@ -660,7 +660,7 @@ Similarly, Octave can use the __float__ method to convert an object to Octave 3.8.0 and later versions will also map unary functions X() to the corresponding __X__ method, where X includes: abs(), acos(), acosh(), angle(), arg(), asin(), asinh(), atan(), atanh(), cbrt(), ceil(), conj(), cos(), cosh(), dawson(), erf(), erfc(), erfcinv(), erfcx(), erfi(), erfinv(), exp(), expm1(), finite(), fix(), floor(), gamma(), imag(), isalnum(), isalpha(), isascii(), iscntrl(), isdigit(), isgraph(), isinf(), islower(), isna(), isnan(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), lgamma(), log(), log10(), log1p(), log2(), real(), round(), roundb(), signbit(), signum(), sin(), sinh(), sqrt(), tan(), tanh(), toascii(), tolower(), toupper()

    -

    34.3.11 C++ templates

    +

    29.3.11 C++ templates

    @@ -737,10 +737,10 @@ ans = -

    34.3.12 C++ Smart Pointers

    +

    29.3.12 C++ Smart Pointers

    -

    34.3.12.1 The shared_ptr Smart Pointer

    +

    29.3.12.1 The shared_ptr Smart Pointer

    @@ -751,14 +751,14 @@ in the shared_ptr smart pointer -

    34.3.12.2 Generic Smart Pointers

    +

    29.3.12.2 Generic Smart Pointers

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

    -

    34.3.13 Directors (calling Octave from C++ code)

    +

    29.3.13 Directors (calling Octave from C++ code)

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

    34.3.14 Threads

    +

    29.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.

    -

    34.3.15 Memory management

    +

    29.3.15 Memory management

    @@ -880,14 +880,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).

    -

    34.3.16 STL support

    +

    29.3.16 STL support

    Various STL library files are provided for wrapping STL containers.

    -

    34.3.17 Matrix typemaps

    +

    29.3.17 Matrix typemaps

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index a3efdf609..f3ba75572 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -7,7 +7,7 @@ -

    35 SWIG and Perl5

    +

    30 SWIG and Perl5

    -

    35.2.2 Compiling a dynamic module

    +

    30.2.2 Compiling a dynamic module

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

    -

    35.2.3 Building a dynamic module with MakeMaker

    +

    30.2.3 Building a dynamic module with MakeMaker

    @@ -242,7 +242,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.

    -

    35.2.4 Building a static version of Perl

    +

    30.2.4 Building a static version of Perl

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

    -

    35.2.5 Using the module

    +

    30.2.5 Using the module

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

    -

    35.2.6 Compilation problems and compiling with C++

    +

    30.2.6 Compilation problems and compiling with C++

    @@ -607,7 +607,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.

    -

    35.2.7 Compiling for 64-bit platforms

    +

    30.2.7 Compiling for 64-bit platforms

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

    -

    35.3 Building Perl Extensions under Windows

    +

    30.3 Building Perl Extensions under Windows

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

    -

    35.3.1 Running SWIG from Developer Studio

    +

    30.3.1 Running SWIG from Developer Studio

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

    35.3.2 Using other compilers

    +

    30.3.2 Using other compilers

    @@ -716,7 +716,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.

    -

    35.4 The low-level interface

    +

    30.4 The low-level interface

    @@ -726,7 +726,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.

    -

    35.4.1 Functions

    +

    30.4.1 Functions

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

    35.4.2 Global variables

    +

    30.4.2 Global variables

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

    35.4.3 Constants

    +

    30.4.3 Constants

    @@ -859,7 +859,7 @@ print example::FOO, "\n"; -

    35.4.4 Pointers

    +

    30.4.4 Pointers

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

    -

    35.4.5 Structures

    +

    30.4.5 Structures

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

    35.4.6 C++ classes

    +

    30.4.6 C++ classes

    @@ -1167,7 +1167,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.

    -

    35.4.7 C++ classes and type-checking

    +

    30.4.7 C++ classes and type-checking

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

    -

    35.4.8 C++ overloaded functions

    +

    30.4.8 C++ overloaded functions

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

    -

    35.4.9 Operators

    +

    30.4.9 Operators

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

  • operator or
  • -

    35.4.10 Modules and packages

    +

    30.4.10 Modules and packages

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

    35.5 Input and output parameters

    +

    30.5 Input and output parameters

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

    -

    35.6 Exception handling

    +

    30.6 Exception handling

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

    -

    35.7 Remapping datatypes with typemaps

    +

    30.7 Remapping datatypes with typemaps

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

    -

    35.7.1 A simple typemap example

    +

    30.7.1 A simple typemap example

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

    35.7.2 Perl5 typemaps

    +

    30.7.2 Perl5 typemaps

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

    35.7.3 Typemap variables

    +

    30.7.3 Typemap variables

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

    35.7.4 Useful functions

    +

    30.7.4 Useful functions

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

    35.8 Typemap Examples

    +

    30.8 Typemap Examples

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

    -

    35.8.1 Converting a Perl5 array to a char **

    +

    30.8.1 Converting a Perl5 array to a char **

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

    35.8.2 Return values

    +

    30.8.2 Return values

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

    35.8.3 Returning values from arguments

    +

    30.8.3 Returning values from arguments

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

    35.8.4 Accessing array structure members

    +

    30.8.4 Accessing array structure members

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

    -

    35.8.5 Turning Perl references into C pointers

    +

    30.8.5 Turning Perl references into C pointers

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

    35.8.6 Pointer handling

    +

    30.8.6 Pointer handling

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

    35.9 Proxy classes

    +

    30.9 Proxy classes

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

    -

    35.9.1 Preliminaries

    +

    30.9.1 Preliminaries

    @@ -2553,7 +2553,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.

    -

    35.9.2 Structure and class wrappers

    +

    30.9.2 Structure and class wrappers

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

    35.9.3 Object Ownership

    +

    30.9.3 Object Ownership

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

    -

    35.9.4 Nested Objects

    +

    30.9.4 Nested Objects

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

    35.9.5 Proxy Functions

    +

    30.9.5 Proxy Functions

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

    -

    35.9.6 Inheritance

    +

    30.9.6 Inheritance

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

    -

    35.9.7 Modifying the proxy methods

    +

    30.9.7 Modifying the proxy methods

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

    35.10 Adding additional Perl code

    +

    30.10 Adding additional Perl code

    @@ -3009,7 +3009,7 @@ set_transform($im, $a); -

    35.11 Cross language polymorphism

    +

    30.11 Cross language polymorphism

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

    -

    35.11.1 Enabling directors

    +

    30.11.1 Enabling directors

    @@ -3133,7 +3133,7 @@ sub one { -

    35.11.2 Director classes

    +

    30.11.2 Director classes

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

    -

    35.11.3 Ownership and object destruction

    +

    30.11.3 Ownership and object destruction

    @@ -3262,7 +3262,7 @@ sub DESTROY { -

    35.11.4 Exception unrolling

    +

    30.11.4 Exception unrolling

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

    -

    35.11.5 Overhead and code bloat

    +

    30.11.5 Overhead and code bloat

    @@ -3352,7 +3352,7 @@ directive) for only those methods that are likely to be extended in Perl.

    -

    35.11.6 Typemaps

    +

    30.11.6 Typemaps

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index f224f19fb..85732fd33 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

    36 SWIG and PHP

    +

    31 SWIG and PHP

    -

    36.1.2 Using PHP Extensions

    +

    31.1.2 Using PHP Extensions

    @@ -182,7 +182,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll almost certainly want to include it anyway.

    -

    36.2 Basic PHP interface

    +

    31.2 Basic PHP interface

    @@ -194,7 +194,7 @@ SWIG doesn't have support for generating wrappers which make use of PHP's namespace feature.

    -

    36.2.1 Constants

    +

    31.2.1 Constants

    @@ -272,7 +272,7 @@ would be treated as false! Modern versions of PHP will at least issue a PHP notice by default when this happens.

    -

    36.2.2 Global Variables

    +

    31.2.2 Global Variables

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

    -

    36.2.3 Functions

    +

    31.2.3 Functions

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

    36.2.4 Overloading

    +

    31.2.4 Overloading

    @@ -429,7 +429,7 @@ taking the integer argument.

    --> -

    36.2.5 Pointers and References

    +

    31.2.5 Pointers and References

    @@ -567,7 +567,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

    -

    36.2.6 Structures and C++ classes

    +

    31.2.6 Structures and C++ classes

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

    -

    36.2.6.1 Using -noproxy

    +

    31.2.6.1 Using -noproxy

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

    36.2.6.2 Constructors and Destructors

    +

    31.2.6.2 Constructors and Destructors

    @@ -695,7 +695,7 @@ the programmer can either reassign the variable or call unset($v)

    -

    36.2.6.3 Static Member Variables

    +

    31.2.6.3 Static Member Variables

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

    36.2.6.4 Static Member Functions

    +

    31.2.6.4 Static Member Functions

    @@ -760,7 +760,7 @@ Ko::threats(); -

    36.2.6.5 Specifying Implemented Interfaces

    +

    31.2.6.5 Specifying Implemented Interfaces

    @@ -778,7 +778,7 @@ so: If there are multiple interfaces, just list them separated by commas.

    -

    36.2.7 PHP Pragmas, Startup and Shutdown code

    +

    31.2.7 PHP Pragmas, Startup and Shutdown code

    @@ -875,7 +875,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

    -

    36.3 Cross language polymorphism

    +

    31.3 Cross language polymorphism

    @@ -910,7 +910,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

    -

    36.3.1 Enabling directors

    +

    31.3.1 Enabling directors

    @@ -999,7 +999,7 @@ class MyFoo extends Foo { -

    36.3.2 Director classes

    +

    31.3.2 Director classes

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

    -

    36.3.3 Ownership and object destruction

    +

    31.3.3 Ownership and object destruction

    @@ -1135,7 +1135,7 @@ In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

    -

    36.3.4 Exception unrolling

    +

    31.3.4 Exception unrolling

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

    -

    36.3.5 Overhead and code bloat

    +

    31.3.5 Overhead and code bloat

    @@ -1235,7 +1235,7 @@ optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

    -

    36.3.6 Typemaps

    +

    31.3.6 Typemaps

    @@ -1249,7 +1249,7 @@ need to be supported.

    -

    36.3.7 Miscellaneous

    +

    31.3.7 Miscellaneous

    Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index e94d9d9cb..9d5d2a307 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -7,7 +7,7 @@ -

    38 SWIG and Python

    +

    32 SWIG and Python

    -

    38.3.3 Global variables

    +

    32.3.3 Global variables

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

    -

    38.3.4 Constants and enums

    +

    32.3.4 Constants and enums

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

    -

    38.3.5 Pointers

    +

    32.3.5 Pointers

    @@ -1339,7 +1339,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.

    -

    38.3.6 Structures

    +

    32.3.6 Structures

    @@ -1549,7 +1549,7 @@ memory and use of it results in a segfault or some sort of other undefined behav

    -

    38.3.7 C++ classes

    +

    32.3.7 C++ classes

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

    38.3.8 C++ inheritance

    +

    32.3.8 C++ inheritance

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

    -

    38.3.9 Pointers, references, values, and arrays

    +

    32.3.9 Pointers, references, values, and arrays

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

    -

    38.3.10 C++ overloaded functions

    +

    32.3.10 C++ overloaded functions

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

    -

    38.3.11 C++ operators

    +

    32.3.11 C++ operators

    @@ -1973,7 +1973,7 @@ instead of raising an exception when the comparison fails, that is, on any kind This follows the guidelines in PEP 207 - Rich Comparisons and NotImplemented Python constant.

    -

    38.3.12 C++ namespaces

    +

    32.3.12 C++ namespaces

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

    -

    38.3.13 C++ templates

    +

    32.3.13 C++ templates

    @@ -2094,10 +2094,10 @@ Some more complicated examples will appear later.

    -

    38.3.14 C++ Smart Pointers

    +

    32.3.14 C++ Smart Pointers

    -

    38.3.14.1 The shared_ptr Smart Pointer

    +

    32.3.14.1 The shared_ptr Smart Pointer

    @@ -2108,7 +2108,7 @@ in the shared_ptr smart pointer -

    38.3.14.2 Generic Smart Pointers

    +

    32.3.14.2 Generic Smart Pointers

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

    38.3.15 C++ reference counted objects

    +

    32.3.15 C++ reference counted objects

    @@ -2201,7 +2201,7 @@ Python examples of memory management using referencing counting.

    -

    38.4 Further details on the Python class interface

    +

    32.4 Further details on the Python class interface

    @@ -2224,7 +2224,7 @@ the -builtin option are in the Built-in section.

    -

    38.4.1 Proxy classes

    +

    32.4.1 Proxy classes

    @@ -2313,7 +2313,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).

    -

    38.4.2 Built-in Types

    +

    32.4.2 Built-in Types

    @@ -2357,7 +2357,7 @@ please refer to the Python documentation:

    http://docs.python.org/extending/newtypes.html

    -

    38.4.2.1 Limitations

    +

    32.4.2.1 Limitations

    Use of the -builtin option implies a couple of limitations: @@ -2518,7 +2518,7 @@ assert(issubclass(B.Derived, A.Base)) -

    38.4.2.2 Operator overloads and slots -- use them!

    +

    32.4.2.2 Operator overloads and slots -- use them!

    The entire justification for the -builtin option is improved @@ -2678,7 +2678,7 @@ in the file python/pyopers.swig in the SWIG library.

    -

    38.4.3 Memory management

    +

    32.4.3 Memory management

    NOTE: Although this section refers to proxy objects, everything here also applies @@ -2873,7 +2873,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

    -

    38.5 Cross language polymorphism

    +

    32.5 Cross language polymorphism

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

    -

    38.5.1 Enabling directors

    +

    32.5.1 Enabling directors

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

    38.5.2 Director classes

    +

    32.5.2 Director classes

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

    -

    38.5.3 Ownership and object destruction

    +

    32.5.3 Ownership and object destruction

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

    -

    38.5.4 Exception unrolling

    +

    32.5.4 Exception unrolling

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

    -

    38.5.5 Overhead and code bloat

    +

    32.5.5 Overhead and code bloat

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

    -

    38.5.6 Typemaps

    +

    32.5.6 Typemaps

    @@ -3252,7 +3252,7 @@ need to be supported.

    -

    38.5.7 Miscellaneous

    +

    32.5.7 Miscellaneous

    @@ -3299,7 +3299,7 @@ methods that return const references.

    -

    38.6 Common customization features

    +

    32.6 Common customization features

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

    -

    38.6.1 C/C++ helper functions

    +

    32.6.1 C/C++ helper functions

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

    -

    38.6.2 Adding additional Python code

    +

    32.6.2 Adding additional Python code

    @@ -3649,7 +3649,7 @@ The same applies for overloaded constructors.

    -

    38.6.3 Class extension with %extend

    +

    32.6.3 Class extension with %extend

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

    -

    38.6.4 Exception handling with %exception

    +

    32.6.4 Exception handling with %exception

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

    -

    38.6.5 Optimization options

    +

    32.6.5 Optimization options

    -

    38.6.5.1 -fastproxy

    +

    32.6.5.1 -fastproxy

    @@ -4008,7 +4008,7 @@ While this possibly provides the best of both worlds, the time to import the mod The command line options mentioned above also apply to wrapped C/C++ global functions, not just class methods.

    -

    38.7 Tips and techniques

    +

    32.7 Tips and techniques

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

    -

    38.7.1 Input and output parameters

    +

    32.7.1 Input and output parameters

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

    -

    38.7.2 Simple pointers

    +

    32.7.2 Simple pointers

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

    -

    38.7.3 Unbounded C Arrays

    +

    32.7.3 Unbounded C Arrays

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

    -

    38.7.4 String handling

    +

    32.7.4 String handling

    @@ -4432,7 +4432,7 @@ also be used to extra binary data from arbitrary pointers.

    -

    38.7.5 Default arguments

    +

    32.7.5 Default arguments

    @@ -4531,7 +4531,7 @@ Versions of SWIG prior to this varied in their ability to convert C++ default va equivalent Python default argument values.

    -

    38.8 Typemaps

    +

    32.8 Typemaps

    @@ -4548,7 +4548,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.

    -

    38.8.1 What is a typemap?

    +

    32.8.1 What is a typemap?

    @@ -4664,7 +4664,7 @@ parameter is omitted): -

    38.8.2 Python typemaps

    +

    32.8.2 Python typemaps

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

    -

    38.8.3 Typemap variables

    +

    32.8.3 Typemap variables

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

    38.8.4 Useful Python Functions

    +

    32.8.4 Useful Python Functions

    @@ -4904,7 +4904,7 @@ write me -

    38.9 Typemap Examples

    +

    32.9 Typemap Examples

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

    -

    38.9.1 Converting Python list to a char **

    +

    32.9.1 Converting Python list to a char **

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

    -

    38.9.2 Expanding a Python object into multiple arguments

    +

    32.9.2 Expanding a Python object into multiple arguments

    @@ -5112,7 +5112,7 @@ TypeError: Wrong number or type of arguments for overloaded function 'foo'. -

    38.9.3 Using typemaps to return arguments

    +

    32.9.3 Using typemaps to return arguments

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

    38.9.4 Mapping Python tuples into small arrays

    +

    32.9.4 Mapping Python tuples into small arrays

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

    -

    38.9.5 Mapping sequences to C arrays

    +

    32.9.5 Mapping sequences to C arrays

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

    38.9.6 Pointer handling

    +

    32.9.6 Pointer handling

    @@ -5435,7 +5435,7 @@ that has a this attribute. In addition, class object (if applicable).

    -

    38.9.7 Memory management when returning references to member variables

    +

    32.9.7 Memory management when returning references to member variables

    @@ -5596,7 +5596,7 @@ static PyObject *bike_reference() { -

    38.10 Docstring Features

    +

    32.10 Docstring Features

    @@ -5624,7 +5624,7 @@ of your users much simpler.

    -

    38.10.1 Module docstring

    +

    32.10.1 Module docstring

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

    38.10.2 %feature("autodoc")

    +

    32.10.2 %feature("autodoc")

    @@ -5686,7 +5686,7 @@ four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections. -

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

    +

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

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

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

    +

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

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

    38.10.2.3 %feature("autodoc", "2")

    +

    32.10.2.3 %feature("autodoc", "2")

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

    38.10.2.4 %feature("autodoc", "3")

    +

    32.10.2.4 %feature("autodoc", "3")

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

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

    +

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

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

    38.10.3 %feature("docstring")

    +

    32.10.3 %feature("docstring")

    @@ -5879,7 +5879,7 @@ with more than one line. -

    38.11 Python Packages

    +

    32.11 Python Packages

    Python has concepts of modules and packages. Modules are separate units of @@ -5953,7 +5953,7 @@ users may need to use special features such as the package option in th %module directive or import related command line options. These are explained in the following sections.

    -

    38.11.1 Setting the Python package

    +

    32.11.1 Setting the Python package

    @@ -6007,7 +6007,7 @@ pkg1/pkg2/_foo.so # (shared library built from C/C++ code generated by SWI -

    38.11.2 Absolute and relative imports

    +

    32.11.2 Absolute and relative imports

    Suppose, we have the following hierarchy of files:

    @@ -6144,7 +6144,7 @@ uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

    -

    38.11.3 Enforcing absolute import semantics

    +

    32.11.3 Enforcing absolute import semantics

    As you may know, there is an incompatibility in import semantics (for the @@ -6181,7 +6181,7 @@ from __future__ import absolute_import -

    38.11.4 Importing from __init__.py

    +

    32.11.4 Importing from __init__.py

    Imports in __init__.py are handy when you want to populate a @@ -6291,7 +6291,7 @@ class Bar(pkg3.foo.Foo): pass effect (note, that the Python 2 case also needs the -relativeimport workaround).

    -

    38.11.5 Implicit namespace packages

    +

    32.11.5 Implicit namespace packages

    Python 3.3 introduced @@ -6369,7 +6369,7 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

    -

    38.11.6 Location of modules

    +

    32.11.6 Location of modules

    @@ -6405,7 +6405,7 @@ The following sub-sections look more closely at the two default configurations a An input interface file, foo.i, results in the two modules foo.py and _foo.so for each of the configurations.

    -

    38.11.6.1 Both modules in the same package

    +

    32.11.6.1 Both modules in the same package

    @@ -6440,7 +6440,7 @@ from mypackage import foo -

    38.11.6.2 Both modules are global

    +

    32.11.6.2 Both modules are global

    @@ -6472,7 +6472,7 @@ import foo -

    38.11.6.3 Split modules custom configuration

    +

    32.11.6.3 Split modules custom configuration

    In this non-standard 'split module' configuration, the pure Python module is in a package and the low level C/C++ module is global. @@ -6522,7 +6522,7 @@ Using one of the two default configurations is the recommended approach now.

    -

    38.11.6.4 More on customizing the module import code

    +

    32.11.6.4 More on customizing the module import code

    @@ -6642,7 +6642,7 @@ The following will do this for the 38.11.6.5 Statically linked C modules +

    32.11.6.5 Statically linked C modules

    It is strongly recommended to use dynamically linked modules for the C @@ -6714,7 +6714,7 @@ module then you will either need to refer to the Python documentation on how to do this (remember you are now the Python importer) or use dynamic linking.

    -

    38.12 Python 3 Support

    +

    32.12 Python 3 Support

    @@ -6739,7 +6739,7 @@ The following are Python 3 new features that are currently supported by SWIG.

    -

    38.12.1 Function annotation

    +

    32.12.1 Function annotation

    @@ -6772,7 +6772,7 @@ For detailed usage of function annotation, see PEP 3107.

    -

    38.12.2 Buffer interface

    +

    32.12.2 Buffer interface

    @@ -6924,7 +6924,7 @@ modify the buffer. -

    38.12.3 Abstract base classes

    +

    32.12.3 Abstract base classes

    @@ -6974,7 +6974,7 @@ The collections.abc module was introduced in Python 3.3 and hence this requires Python 3.3 or later.

    -

    38.12.4 Byte string output conversion

    +

    32.12.4 Byte string output conversion

    @@ -7155,7 +7155,7 @@ overloads taking both std::string (as Python bytes) and std::wstring (as Python unicode).

    -

    38.12.5 Python 2 Unicode

    +

    32.12.5 Python 2 Unicode

    @@ -7227,7 +7227,7 @@ the first is allowing unicode conversion and the second is explicitly prohibiting it.

    -

    38.13 Support for Multithreaded Applications

    +

    32.13 Support for Multithreaded Applications

    By default, SWIG does not enable support for multithreaded Python applications. More @@ -7242,7 +7242,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai interface for this is described in the next section.

    -

    38.13.1 UI for Enabling Multithreading Support

    +

    32.13.1 UI for Enabling Multithreading Support

    The user interface is as follows:

    @@ -7285,7 +7285,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai -

    38.13.2 Multithread Performance

    +

    32.13.2 Multithread Performance

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 3a6aaeb3c..b9dba4f9c 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -7,7 +7,7 @@ -

    39 SWIG and R

    +

    33 SWIG and R

      @@ -34,7 +34,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++.

      -

      39.1 Bugs

      +

      33.1 Bugs

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

    • C Array wrappings
    -

    39.2 Using R and SWIG

    +

    33.2 Using R and SWIG

    @@ -137,7 +137,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

  • Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into -

    39.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 @@ -155,7 +155,7 @@ will save a large amount of loading time. -

    39.4 General policy

    +

    33.4 General policy

    @@ -164,7 +164,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

    -

    39.5 Language conventions

    +

    33.5 Language conventions

    @@ -173,7 +173,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    39.6 C++ classes

    +

    33.6 C++ classes

    @@ -185,7 +185,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

    -

    39.7 Enumerations

    +

    33.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 9b9b49d07..aa4212667 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -8,7 +8,7 @@ -

    40 SWIG and Ruby

    +

    34 SWIG and Ruby

      @@ -149,7 +149,7 @@

      This chapter describes SWIG's support of Ruby.

      -

      40.1 Preliminaries

      +

      34.1 Preliminaries

      SWIG 3.0 is known to work with Ruby versions 1.8 and later. @@ -164,7 +164,7 @@ read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

      -

      40.1.1 Running SWIG

      +

      34.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -188,7 +188,7 @@ if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      40.1.2 Getting the right header files

      +

      34.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -202,7 +202,7 @@ the compiler options needed to compile the code is to ask Ruby itself:

    -

    40.1.3 Compiling a dynamic module

    +

    34.1.3 Compiling a dynamic module

    Ruby extension modules are typically compiled into shared @@ -275,7 +275,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.

    -

    40.1.4 Using your module

    +

    34.1.4 Using your module

    Ruby module names must be capitalized, @@ -305,7 +305,7 @@ begins with:

    will result in an extension module using the feature name "example" and Ruby module name "Example".

    -

    40.1.5 Static linking

    +

    34.1.5 Static linking

    An alternative approach to dynamic linking is to rebuild the @@ -320,7 +320,7 @@ finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

    -

    40.1.6 Compilation of C++ extensions

    +

    34.1.6 Compilation of C++ extensions

    On most machines, C++ extension modules should be linked @@ -352,7 +352,7 @@ $libs = append_library($libs, "supc++") create_makefile('example')

  • -

    40.2 Building Ruby Extensions under Windows 95/NT

    +

    34.2 Building Ruby Extensions under Windows 95/NT

    Building a SWIG extension to Ruby under Windows 95/NT is @@ -377,7 +377,7 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

    -

    40.2.1 Running SWIG from Developer Studio

    +

    34.2.1 Running SWIG from Developer Studio

    If you are developing your application within Microsoft @@ -441,13 +441,13 @@ Foo = 3.0 -

    40.3 The Ruby-to-C/C++ Mapping

    +

    34.3 The Ruby-to-C/C++ Mapping

    This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

    -

    40.3.1 Modules

    +

    34.3.1 Modules

    The SWIG %module directive specifies @@ -519,7 +519,7 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

    -

    40.3.2 Functions

    +

    34.3.2 Functions

    Global functions are wrapped as Ruby module methods. For @@ -553,7 +553,7 @@ irb(main):002:0> Example.fact(4) 24 -

    40.3.3 Variable Linking

    +

    34.3.3 Variable Linking

    C/C++ global variables are wrapped as a pair of singleton @@ -615,7 +615,7 @@ directive. For example:

    effect until it is explicitly disabled using %mutable.

    -

    40.3.4 Constants

    +

    34.3.4 Constants

    C/C++ constants are wrapped as module constants initialized @@ -643,7 +643,7 @@ irb(main):002:0> Example::PI 3.14159 -

    40.3.5 Pointers

    +

    34.3.5 Pointers

    "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -667,7 +667,7 @@ returns an instance of an internally generated Ruby class:

    A NULL pointer is always represented by the Ruby nil object.

    -

    40.3.6 Structures

    +

    34.3.6 Structures

    C/C++ structs are wrapped as Ruby classes, with accessor @@ -772,7 +772,7 @@ void Bar_f_set(Bar *b, Foo *val) { } -

    40.3.7 C++ classes

    +

    34.3.7 C++ classes

    Like structs, C++ classes are wrapped by creating a new Ruby @@ -827,7 +827,7 @@ Ale 3 -

    40.3.8 C++ Inheritance

    +

    34.3.8 C++ Inheritance

    The SWIG type-checker is fully aware of C++ inheritance. @@ -980,7 +980,7 @@ inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

    -

    40.3.9 C++ Overloaded Functions

    +

    34.3.9 C++ Overloaded Functions

    C++ overloaded functions, methods, and constructors are @@ -1070,7 +1070,7 @@ arises--in this case, the first declaration takes precedence.

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    40.3.10 C++ Operators

    +

    34.3.10 C++ Operators

    For the most part, overloaded operators are handled @@ -1112,7 +1112,7 @@ c = Example.add_complex(a, b) is discussed in the section on operator overloading.

    -

    40.3.11 C++ namespaces

    +

    34.3.11 C++ namespaces

    SWIG is aware of C++ namespaces, but namespace names do not @@ -1169,7 +1169,7 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    40.3.12 C++ templates

    +

    34.3.12 C++ templates

    C++ templates don't present a huge problem for SWIG. However, @@ -1211,7 +1211,7 @@ irb(main):004:0> p.second 4 -

    40.3.13 C++ Standard Template Library (STL)

    +

    34.3.13 C++ Standard Template Library (STL)

    On a related note, the standard SWIG library contains a @@ -1304,7 +1304,7 @@ puts v shown in these examples. More details can be found in the SWIG and C++ chapter.

    -

    40.3.14 C++ STL Functors

    +

    34.3.14 C++ STL Functors

    Some containers in the STL allow you to modify their default @@ -1365,7 +1365,7 @@ b -

    40.3.15 C++ STL Iterators

    +

    34.3.15 C++ STL Iterators

    The STL is well known for the use of iterators. There @@ -1448,10 +1448,10 @@ i

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    -

    40.3.16 C++ Smart Pointers

    +

    34.3.16 C++ Smart Pointers

    -

    40.3.16.1 The shared_ptr Smart Pointer

    +

    34.3.16.1 The shared_ptr Smart Pointer

    @@ -1462,7 +1462,7 @@ in the shared_ptr smart pointer -

    40.3.16.2 Generic Smart Pointers

    +

    34.3.16.2 Generic Smart Pointers

    In certain C++ programs, it is common to use classes that @@ -1527,7 +1527,7 @@ method. For example:

    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    -

    40.3.17 Cross-Language Polymorphism

    +

    34.3.17 Cross-Language Polymorphism

    SWIG's Ruby module supports cross-language polymorphism @@ -1536,7 +1536,7 @@ module. Rather than duplicate the information presented in the 40.3.17.1 Exception Unrolling +

    34.3.17.1 Exception Unrolling

    Whenever a C++ director class routes one of its virtual @@ -1559,7 +1559,7 @@ method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    -

    40.4 Naming

    +

    34.4 Naming

    Ruby has several common naming conventions. Constants are @@ -1597,7 +1597,7 @@ generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    -

    40.4.1 Defining Aliases

    +

    34.4.1 Defining Aliases

    It's a fairly common practice in the Ruby built-ins and @@ -1667,7 +1667,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    40.4.2 Predicate Methods

    +

    34.4.2 Predicate Methods

    Ruby methods that return a boolean value and end in a @@ -1716,7 +1716,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    40.4.3 Bang Methods

    +

    34.4.3 Bang Methods

    Ruby methods that modify an object in-place and end in an @@ -1748,7 +1748,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    40.4.4 Getters and Setters

    +

    34.4.4 Getters and Setters

    Often times a C++ library will expose properties through @@ -1783,7 +1783,7 @@ irb(main):003:0> puts foo.value %rename("value=") Foo::setValue(int value); -

    40.5 Input and output parameters

    +

    34.5 Input and output parameters

    A common problem in some C programs is handling parameters @@ -1922,10 +1922,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);

    r, c = Example.get_dimensions(m)
    -

    40.6 Exception handling

    +

    34.6 Exception handling

    -

    40.6.1 Using the %exception directive

    +

    34.6.1 Using the %exception directive

    The SWIG %exception directive can be @@ -2034,7 +2034,7 @@ methods and functions named getitem and setitem. limited to C++ exception handling. See the chapter on Customization Features for more examples.

    -

    40.6.2 Handling Ruby Blocks

    +

    34.6.2 Handling Ruby Blocks

    One of the highlights of Ruby and most of its standard library @@ -2101,7 +2101,7 @@ a special in typemap, like:

    For more information on typemaps, see Typemaps.

    -

    40.6.3 Raising exceptions

    +

    34.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to @@ -2258,7 +2258,7 @@ function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    -

    40.6.4 Exception classes

    +

    34.6.4 Exception classes

    Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -2295,7 +2295,7 @@ end

    For another example look at swig/Examples/ruby/exception_class.

    -

    40.7 Typemaps

    +

    34.7 Typemaps

    This section describes how you can modify SWIG's default @@ -2310,7 +2310,7 @@ 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 primitive C-Ruby interface.

    -

    40.7.1 What is a typemap?

    +

    34.7.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is @@ -2467,7 +2467,7 @@ to be used as follows (notice how the length parameter is omitted):

    2 -

    40.7.2 Typemap scope

    +

    34.7.2 Typemap scope

    Once defined, a typemap remains in effect for all of the @@ -2513,7 +2513,7 @@ where the class itself is defined. For example:

    }; -

    40.7.3 Copying a typemap

    +

    34.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    @@ -2555,7 +2555,7 @@ rules as for %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments -

    40.7.4 Deleting a typemap

    +

    34.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For @@ -2580,7 +2580,7 @@ defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    -

    40.7.5 Placement of typemaps

    +

    34.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, @@ -2651,13 +2651,13 @@ In this example, this is done using the class declaration class string .

    -

    40.7.6 Ruby typemaps

    +

    34.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    -

    40.7.6.1 "in" typemap

    +

    34.7.6.1 "in" typemap

    Converts Ruby objects to input @@ -2724,7 +2724,7 @@ arguments to be specified. For example:

    At this time, only zero or one arguments may be converted.

    -

    40.7.6.2 "typecheck" typemap

    +

    34.7.6.2 "typecheck" typemap

    The "typecheck" typemap is used to support overloaded @@ -2746,7 +2746,7 @@ program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    -

    40.7.6.3 "out" typemap

    +

    34.7.6.3 "out" typemap

    Converts return value of a C function @@ -2797,7 +2797,7 @@ version of the C datatype matched by the typemap.

    -

    40.7.6.4 "arginit" typemap

    +

    34.7.6.4 "arginit" typemap

    The "arginit" typemap is used to set the initial value of a @@ -2812,7 +2812,7 @@ applications. For example:

    } -

    40.7.6.5 "default" typemap

    +

    34.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a @@ -2837,7 +2837,7 @@ arguments that follow must have default values. See the 40.7.6.6 "check" typemap +

    34.7.6.6 "check" typemap

    The "check" typemap is used to supply value checking code @@ -2852,7 +2852,7 @@ arguments have been converted. For example:

    } -

    40.7.6.7 "argout" typemap

    +

    34.7.6.7 "argout" typemap

    The "argout" typemap is used to return values from arguments. @@ -2906,7 +2906,7 @@ some function like SWIG_Ruby_AppendOutput.

    See the typemaps.i library for examples.

    -

    40.7.6.8 "freearg" typemap

    +

    34.7.6.8 "freearg" typemap

    The "freearg" typemap is used to cleanup argument data. It is @@ -2933,7 +2933,7 @@ This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    40.7.6.9 "newfree" typemap

    +

    34.7.6.9 "newfree" typemap

    The "newfree" typemap is used in conjunction with the %newobject @@ -2957,7 +2957,7 @@ string *foo();

    See Object ownership and %newobject for further details.

    -

    40.7.6.10 "memberin" typemap

    +

    34.7.6.10 "memberin" typemap

    The "memberin" typemap is used to copy data from an @@ -2975,21 +2975,21 @@ example:

    already provides a default implementation for arrays, strings, and other objects.

    -

    40.7.6.11 "varin" typemap

    +

    34.7.6.11 "varin" typemap

    The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    40.7.6.12 "varout" typemap

    +

    34.7.6.12 "varout" typemap

    The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

    -

    40.7.6.13 "throws" typemap

    +

    34.7.6.13 "throws" typemap

    The "throws" typemap is only used when SWIG parses a C++ @@ -3030,7 +3030,7 @@ specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    -

    40.7.6.14 directorin typemap

    +

    34.7.6.14 directorin typemap

    Converts C++ objects in director @@ -3089,7 +3089,7 @@ referring to the class itself. -

    40.7.6.15 directorout typemap

    +

    34.7.6.15 directorout typemap

    Converts Ruby objects in director @@ -3162,7 +3162,7 @@ exception.

    -

    40.7.6.16 directorargout typemap

    +

    34.7.6.16 directorargout typemap

    Output argument processing in director @@ -3220,19 +3220,19 @@ referring to the instance of the class itself -

    40.7.6.17 ret typemap

    +

    34.7.6.17 ret typemap

    Cleanup of function return values

    -

    40.7.6.18 globalin typemap

    +

    34.7.6.18 globalin typemap

    Setting of C global variables

    -

    40.7.7 Typemap variables

    +

    34.7.7 Typemap variables

    @@ -3282,7 +3282,7 @@ so that their values can be properly assigned.

    The Ruby name of the wrapper function being created.
    -

    40.7.8 Useful Functions

    +

    34.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -3297,7 +3297,7 @@ stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    -

    40.7.8.1 C Datatypes to Ruby Objects

    +

    34.7.8.1 C Datatypes to Ruby Objects

    @@ -3339,7 +3339,7 @@ SWIG_From_float(float)
    -

    40.7.8.2 Ruby Objects to C Datatypes

    +

    34.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -3407,7 +3407,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -

    40.7.8.3 Macros for VALUE

    +

    34.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -3430,7 +3430,7 @@ versions do not, but return a status value to indicate success (SWIG_OK
    pointer to array storage
    -

    40.7.8.4 Exceptions

    +

    34.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -3509,7 +3509,7 @@ message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf(). -

    40.7.8.5 Iterators

    +

    34.7.8.5 Iterators

    void rb_iter_break()

    @@ -3555,14 +3555,14 @@ VALUE), VALUE value)

    Equivalent to Ruby's throw.
    -

    40.7.9 Typemap Examples

    +

    34.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

    -

    40.7.10 Converting a Ruby array to a char **

    +

    34.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -3627,7 +3627,7 @@ array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    -

    40.7.11 Collecting arguments in a hash

    +

    34.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -3841,7 +3841,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:

    program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    -

    40.7.12 Pointer handling

    +

    34.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -3900,7 +3900,7 @@ For example:

    } -

    40.7.12.1 Ruby Datatype Wrapping

    +

    34.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -3927,7 +3927,7 @@ as above. type c-type from the data object obj and assigns that pointer to ptr. -

    40.7.13 Example: STL Vector to Ruby Array

    +

    34.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -4019,7 +4019,7 @@ STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library. -

    40.8 Docstring Features

    +

    34.8 Docstring Features

    @@ -4053,7 +4053,7 @@ generate ri documentation from a c wrap file, you could do:

    $ rdoc -r file_wrap.c -

    40.8.1 Module docstring

    +

    34.8.1 Module docstring

    @@ -4083,7 +4083,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -

    40.8.2 %feature("autodoc")

    +

    34.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -4104,7 +4104,7 @@ several options for autodoc controlled by the value given to the feature, described below.

    -

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

    +

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

    @@ -4128,7 +4128,7 @@ Then Ruby code like this will be generated: ... -

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

    +

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

    @@ -4148,7 +4148,7 @@ this: ... -

    40.8.2.3 %feature("autodoc", "2")

    +

    34.8.2.3 %feature("autodoc", "2")

    @@ -4160,7 +4160,7 @@ parameter types with the "2" option will result in Ruby code like this:

    -

    40.8.2.4 %feature("autodoc", "3")

    +

    34.8.2.4 %feature("autodoc", "3")

    @@ -4181,7 +4181,7 @@ Parameters: bar - Bar -

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

    +

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

    @@ -4197,7 +4197,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -

    40.8.3 %feature("docstring")

    +

    34.8.3 %feature("docstring")

    @@ -4208,10 +4208,10 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    -

    40.9 Advanced Topics

    +

    34.9 Advanced Topics

    -

    40.9.1 Operator overloading

    +

    34.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -4392,7 +4392,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    -

    40.9.2 Creating Multi-Module Packages

    +

    34.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -4518,7 +4518,7 @@ irb(main):005:0> c.getX() 5.0 -

    40.9.3 Specifying Mixin Modules

    +

    34.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -4585,7 +4585,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    40.10 Memory Management

    +

    34.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -4608,7 +4608,7 @@ to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    -

    40.10.1 Mark and Sweep Garbage Collector

    +

    34.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -4639,7 +4639,7 @@ any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    -

    40.10.2 Object Ownership

    +

    34.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -4784,7 +4784,7 @@ public:

    This code can be seen in swig/examples/ruby/tracking.

    -

    40.10.3 Object Tracking

    +

    34.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -5010,7 +5010,7 @@ However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    -

    40.10.4 Mark Functions

    +

    34.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -5139,7 +5139,7 @@ irb(main):016:0>

    This code can be seen in swig/examples/ruby/mark_function.

    -

    40.10.5 Free Functions

    +

    34.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -5307,7 +5307,7 @@ been freed, and thus raises a runtime exception.

    This code can be seen in swig/examples/ruby/free_function.

    -

    40.10.6 Embedded Ruby and the C++ Stack

    +

    34.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/Scilab.html b/Doc/Manual/Scilab.html index 3ea21a753..29c4eacf0 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -9,7 +9,7 @@ -

    41 SWIG and Scilab

    +

    35 SWIG and Scilab

    -

    41.3 A basic tour of C/C++ wrapping

    +

    35.3 A basic tour of C/C++ wrapping

    -

    41.3.1 Overview

    +

    35.3.1 Overview

    @@ -332,7 +332,7 @@ This means that functions, structs, classes, variables, etc... are interfaced th There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    -

    41.3.2 Identifiers

    +

    35.3.2 Identifiers

    @@ -347,7 +347,7 @@ In these cases, the %rename directive Note: truncations can be disabled by specifying the target version 6 of Scilab in the targetversion argument (i.e. -targetversion 6).

    -

    41.3.3 Functions

    +

    35.3.3 Functions

    @@ -378,7 +378,7 @@ ans = 24. -

    41.3.3.1 Argument passing

    +

    35.3.3.1 Argument passing

    @@ -431,7 +431,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are 7. -

    41.3.3.2 Multiple output arguments

    +

    35.3.3.2 Multiple output arguments

    @@ -480,7 +480,7 @@ int divide(int n, int d, int *OUTPUT, int *OUTPUT); -

    41.3.4 Global variables

    +

    35.3.4 Global variables

    @@ -549,10 +549,10 @@ It works the same:

    -

    41.3.5 Constants and enumerations

    +

    35.3.5 Constants and enumerations

    -

    41.3.5.1 Constants

    +

    35.3.5.1 Constants

    @@ -693,7 +693,7 @@ are mapped to Scilab variables, with the same name: 3.14 -

    41.3.5.2 Enumerations

    +

    35.3.5.2 Enumerations

    @@ -758,7 +758,7 @@ typedef enum { RED, BLUE, GREEN } color; -

    41.3.6 Pointers

    +

    35.3.6 Pointers

    @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE". The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    41.3.6.1 Utility functions

    +

    35.3.6.1 Utility functions

    @@ -861,7 +861,7 @@ ans = -

    41.3.6.2 Null pointers:

    +

    35.3.6.2 Null pointers:

    @@ -877,7 +877,7 @@ Using the previous SWIG_this() and SWIG_ptr(), it is possible -

    41.3.7 Structures

    +

    35.3.7 Structures

    @@ -986,7 +986,7 @@ Note: the pointer to the struct works as described in 41.3.8 C++ classes +

    35.3.8 C++ classes

    @@ -1054,7 +1054,7 @@ Note: like structs, class pointers are mapped as described in 41.3.9 C++ inheritance +

    35.3.9 C++ inheritance

    @@ -1129,7 +1129,7 @@ But we can use either use the get_perimeter() function of the parent cl 18.84 -

    41.3.10 C++ overloading

    +

    35.3.10 C++ overloading

    @@ -1169,7 +1169,7 @@ void magnify(Circle *circle, double factor) { -

    41.3.11 Pointers, references, values, and arrays

    +

    35.3.11 Pointers, references, values, and arrays

    @@ -1227,7 +1227,7 @@ All these functions will return a pointer to an instance of Foo. As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.

    -

    41.3.12 C++ templates

    +

    35.3.12 C++ templates

    @@ -1286,7 +1286,7 @@ Then in Scilab: More details on template support can be found in the templates documentation.

    -

    41.3.13 C++ operators

    +

    35.3.13 C++ operators

    @@ -1339,7 +1339,7 @@ private: -

    41.3.14 C++ namespaces

    +

    35.3.14 C++ namespaces

    @@ -1417,7 +1417,7 @@ Note: the nspace feature is not supp

    -

    41.3.15 C++ exceptions

    +

    35.3.15 C++ exceptions

    @@ -1500,17 +1500,17 @@ More complex or custom exception types require specific exception typemaps to be See the SWIG C++ documentation for more details.

    -

    41.3.16 C++ STL

    +

    35.3.16 C++ STL

    The Standard Template Library (STL) is partially supported. See STL for more details.

    -

    41.4 Type mappings and libraries

    +

    35.4 Type mappings and libraries

    -

    41.4.1 Default primitive type mappings

    +

    35.4.1 Default primitive type mappings

    @@ -1561,7 +1561,7 @@ The default behaviour is for SWIG to generate code that will give a runtime erro -

    41.4.2 Arrays

    +

    35.4.2 Arrays

    @@ -1616,7 +1616,7 @@ void printArray(int values[], int len) { [ 0 1 2 3 ] -

    41.4.3 Pointer-to-pointers

    +

    35.4.3 Pointer-to-pointers

    @@ -1689,7 +1689,7 @@ void print_matrix(double **M, int nbRows, int nbCols) { -

    41.4.4 Matrices

    +

    35.4.4 Matrices

    @@ -1782,7 +1782,7 @@ The remarks made earlier for arrays also apply here:

  • There is no control while converting double values to integers, double values are truncated without any checking or warning.
  • -

    41.4.5 STL

    +

    35.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    41.5 Module initialization

    +

    35.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    41.6 Building modes

    +

    35.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    41.6.1 No-builder mode

    +

    35.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    41.6.2 Builder mode

    +

    35.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    41.7 Generated scripts

    +

    35.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    41.7.1 Builder script

    +

    35.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    41.7.2 Loader script

    +

    35.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    41.8 Other resources

    +

    35.8 Other resources

      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 2eb49bde9..ba5ca3852 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -7,7 +7,7 @@ -

      42 SWIG and Tcl

      +

      36 SWIG and Tcl

      -

      42.2.2 Using NMAKE

      +

      36.2.2 Using NMAKE

      @@ -641,7 +641,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

      -

      42.3 A tour of basic C/C++ wrapping

      +

      36.3 A tour of basic C/C++ wrapping

      @@ -652,7 +652,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

      -

      42.3.1 Modules

      +

      36.3.1 Modules

      @@ -686,7 +686,7 @@ To fix this, supply an extra argument to load like this: -

      42.3.2 Functions

      +

      36.3.2 Functions

      @@ -711,7 +711,7 @@ like you think it does: % -

      42.3.3 Global variables

      +

      36.3.3 Global variables

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

      42.3.4 Constants and enums

      +

      36.3.4 Constants and enums

      @@ -875,7 +875,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.

      -

      42.3.5 Pointers

      +

      36.3.5 Pointers

      @@ -971,7 +971,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.

      -

      42.3.6 Structures

      +

      36.3.6 Structures

      @@ -1253,7 +1253,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

      -

      42.3.7 C++ classes

      +

      36.3.7 C++ classes

      @@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows: -

      42.3.8 C++ inheritance

      +

      36.3.8 C++ inheritance

      @@ -1368,7 +1368,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

      -

      42.3.9 Pointers, references, values, and arrays

      +

      36.3.9 Pointers, references, values, and arrays

      @@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

      -

      42.3.10 C++ overloaded functions

      +

      36.3.10 C++ overloaded functions

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

      -

      42.3.11 C++ operators

      +

      36.3.11 C++ operators

      @@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

      -

      42.3.12 C++ namespaces

      +

      36.3.12 C++ namespaces

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

      -

      42.3.13 C++ templates

      +

      36.3.13 C++ templates

      @@ -1763,7 +1763,7 @@ More details can be found in the SWIG and C++ -

      42.3.14 C++ Smart Pointers

      +

      36.3.14 C++ Smart Pointers

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

      42.4 Further details on the Tcl class interface

      +

      36.4 Further details on the Tcl class interface

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

      -

      42.4.1 Proxy classes

      +

      36.4.1 Proxy classes

      @@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

      -

      42.4.2 Memory management

      +

      36.4.2 Memory management

      @@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.

      -

      42.5 Input and output parameters

      +

      36.5 Input and output parameters

      @@ -2301,7 +2301,7 @@ set c [lindex $dim 1] -

      42.6 Exception handling

      +

      36.6 Exception handling

      @@ -2435,7 +2435,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.

      -

      42.7 Typemaps

      +

      36.7 Typemaps

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

      -

      42.7.1 What is a typemap?

      +

      36.7.1 What is a typemap?

      @@ -2572,7 +2572,7 @@ parameter is omitted): -

      42.7.2 Tcl typemaps

      +

      36.7.2 Tcl typemaps

      @@ -2710,7 +2710,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

      -

      42.7.3 Typemap variables

      +

      36.7.3 Typemap variables

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

      42.7.4 Converting a Tcl list to a char **

      +

      36.7.4 Converting a Tcl list to a char **

      @@ -2843,7 +2843,7 @@ argv[2] = Larry 3 -

      42.7.5 Returning values in arguments

      +

      36.7.5 Returning values in arguments

      @@ -2885,7 +2885,7 @@ result, a Tcl function using these typemaps will work like this : % -

      42.7.6 Useful functions

      +

      36.7.6 Useful functions

      @@ -2961,7 +2961,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

      42.7.7 Standard typemaps

      +

      36.7.7 Standard typemaps

      @@ -3045,7 +3045,7 @@ work) -

      42.7.8 Pointer handling

      +

      36.7.8 Pointer handling

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

      42.8 Turning a SWIG module into a Tcl Package.

      +

      36.8 Turning a SWIG module into a Tcl Package.

      @@ -3199,7 +3199,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

      -

      42.9 Building new kinds of Tcl interfaces (in Tcl)

      +

      36.9 Building new kinds of Tcl interfaces (in Tcl)

      @@ -3298,7 +3298,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

      -

      42.9.1 Proxy classes

      +

      36.9.1 Proxy classes

      @@ -3419,7 +3419,7 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

      -

      42.10 Tcl/Tk Stubs

      +

      36.10 Tcl/Tk Stubs

      From b2d93665fe293508f2e9970198e09c5fd8d4d949 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 9 Feb 2019 22:04:46 -0700 Subject: [PATCH 1406/2031] [OCaml] Don't use argout typemaps by default for some reference types The OCaml module's typemaps.i supplied argout typemaps for some reference types (e.g. int &) by default, which was unintuitive and inconsistent when compared with other modules. The argout_ref example depended on this, so add a typemap to argout_ref/example.i. Add multiple runtime tests that deal with references. --- Examples/ocaml/argout_ref/example.i | 5 ++ .../test-suite/ocaml/funcptr_cpp_runme.ml | 13 +++++ .../test-suite/ocaml/overload_bool_runme.ml | 11 ++++ .../test-suite/ocaml/primitive_ref_runme.ml | 20 +++++++ .../ocaml/reference_global_vars_runme.ml | 57 +++++++++++++++++++ .../ocaml/template_ref_type_runme.ml | 6 ++ Lib/ocaml/ocaml.swg | 9 --- Lib/ocaml/typemaps.i | 38 ++++++------- 8 files changed, 130 insertions(+), 29 deletions(-) create mode 100644 Examples/test-suite/ocaml/funcptr_cpp_runme.ml create mode 100644 Examples/test-suite/ocaml/primitive_ref_runme.ml create mode 100644 Examples/test-suite/ocaml/reference_global_vars_runme.ml create mode 100644 Examples/test-suite/ocaml/template_ref_type_runme.ml diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i index 5ea6777fb..472a83804 100644 --- a/Examples/ocaml/argout_ref/example.i +++ b/Examples/ocaml/argout_ref/example.i @@ -1,6 +1,11 @@ /* File : example.i */ %module example +%typemap(argout) (int &x, int &y) { + swig_result = caml_list_append(swig_result, caml_val_int(*$1)); + swig_result = caml_list_append(swig_result, caml_val_int(*$2)); +} + %{ extern "C" void factor(int &x, int &y); %} diff --git a/Examples/test-suite/ocaml/funcptr_cpp_runme.ml b/Examples/test-suite/ocaml/funcptr_cpp_runme.ml new file mode 100644 index 000000000..bdc077d4e --- /dev/null +++ b/Examples/test-suite/ocaml/funcptr_cpp_runme.ml @@ -0,0 +1,13 @@ +open Swig +open Funcptr_cpp + +let _ = + let fp = _ADD_BY_VALUE '() in + assert (_call1 '(fp, 10, 11) as int = 21); + let fp = _ADD_BY_POINTER '() in + assert (_call2 '(fp, 12, 13) as int = 25); + let fp = _ADD_BY_REFERENCE '() in + assert (_call3 '(fp, 14, 15) as int = 29); + let fp = _ADD_BY_VALUE_C '() in + assert (_call1 '(fp, 2, 3) as int = 5); +;; diff --git a/Examples/test-suite/ocaml/overload_bool_runme.ml b/Examples/test-suite/ocaml/overload_bool_runme.ml index ce0ce9e40..fefd07429 100644 --- a/Examples/test-suite/ocaml/overload_bool_runme.ml +++ b/Examples/test-suite/ocaml/overload_bool_runme.ml @@ -12,4 +12,15 @@ let _ = assert (_boolfunction '(false) as string = "false"); assert (_intfunction '(true) as string = "int"); assert (_intfunction '(false) as string = "int"); + + assert (_overloaded_ref '(true) as string = "bool"); + assert (_overloaded_ref '(false) as string = "bool"); + assert (_overloaded_ref '(0) as string = "int"); + assert (_overloaded_ref '(1) as string = "int"); + assert (_overloaded_ref '(2) as string = "int"); + assert (_overloaded_ref '("1234") as string = "string"); + assert (_boolfunction_ref '(true) as string = "true"); + assert (_boolfunction_ref '(false) as string = "false"); + assert (_intfunction_ref '(true) as string = "int"); + assert (_intfunction_ref '(false) as string = "int"); ;; diff --git a/Examples/test-suite/ocaml/primitive_ref_runme.ml b/Examples/test-suite/ocaml/primitive_ref_runme.ml new file mode 100644 index 000000000..7c96caac2 --- /dev/null +++ b/Examples/test-suite/ocaml/primitive_ref_runme.ml @@ -0,0 +1,20 @@ +open Swig +open Primitive_ref + +let _ = + assert (_ref_int '(3) as int = 3); + assert (_ref_short '(3) as int = 3); + assert (_ref_ushort '(3) as int = 3); + assert (_ref_long '(3) as int = 3); + assert (_ref_ulong '(3) as int = 3); + assert (_ref_schar '(3) as int = 3); + assert (_ref_uchar '(3) as int = 3); + assert (_ref_float '(3.5) as float = 3.5); + assert (_ref_double '(3.5) as float = 3.5); + assert (_ref_bool '(true) as bool = true); + let arg = C_char 'x' in + assert (_ref_char '(arg) as char = 'x'); + assert (_ref_over '(0) as int = 0); + let a = new_A '(12) in + assert (_ref_over '(a) as int = 12); +;; diff --git a/Examples/test-suite/ocaml/reference_global_vars_runme.ml b/Examples/test-suite/ocaml/reference_global_vars_runme.ml new file mode 100644 index 000000000..aa1708774 --- /dev/null +++ b/Examples/test-suite/ocaml/reference_global_vars_runme.ml @@ -0,0 +1,57 @@ +open Swig +open Reference_global_vars + +let _ = + let tc = _getconstTC '() in + assert (tc -> "[num]" () as int = 33); + + let _ = _var_bool (_createref_bool (C_bool false)) in + assert (_value_bool (_var_bool '()) as bool = false); + + let _ = _var_bool (_createref_bool (C_bool true)) in + assert (_value_bool (_var_bool '()) as bool = true); + + let _ = _var_char (_createref_char (C_char 'w')) in + assert (_value_char (_var_char '()) as char = 'w'); + + let _ = _var_unsigned_char (_createref_unsigned_char (C_uchar 'w')) in + assert (_value_unsigned_char (_var_unsigned_char '()) as char = 'w'); + + let _ = _var_signed_char (_createref_signed_char (C_uchar 'w')) in + assert (_value_signed_char (_var_signed_char '()) as char = 'w'); + + let _ = _var_short (_createref_short (C_short 10)) in + assert (_value_short (_var_short '()) as int = 10); + + let _ = _var_unsigned_short (_createref_unsigned_short (C_ushort 10)) in + assert (_value_unsigned_short (_var_unsigned_short '()) as int = 10); + + let _ = _var_int (_createref_int (C_int 10)) in + assert (_value_int (_var_int '()) as int = 10); + + let _ = _var_unsigned_int (_createref_unsigned_int (C_int 10)) in + assert (_value_unsigned_int (_var_unsigned_int '()) as int = 10); + + let _ = _var_long (_createref_long (C_int64 10L)) in + assert (_value_long (_var_long '()) as int = 10); + + let _ = _var_unsigned_long (_createref_unsigned_long (C_int64 10L)) in + assert (_value_unsigned_long (_var_unsigned_long '()) as int = 10); + + let _ = _var_long_long (_createref_long_long (C_int64 0x6FFFFFFFFFFFFFF8L)) in + assert (_value_long_long (_var_long_long '()) = C_int64 0x6FFFFFFFFFFFFFF8L); + + let _ = _var_unsigned_long_long (_createref_unsigned_long_long (C_int64 0x6FFFFFFFFFFFFFF8L)) in + assert (_value_unsigned_long_long (_var_unsigned_long_long '()) = C_int64 0x6FFFFFFFFFFFFFF8L); + + let _ = _var_float (_createref_float (C_float 10.)) in + assert (_value_float (_var_float '()) as float = 10.); + + let _ = _var_double (_createref_double (C_double 10.)) in + assert (_value_double (_var_double '()) as float = 10.); + + let tc = new_TestClass '(20) in + let _ = _var_TestClass (_createref_TestClass (tc)) in + let tc = _value_TestClass (_var_TestClass '()) in + assert (tc -> "[num]" () as int = 20); +;; diff --git a/Examples/test-suite/ocaml/template_ref_type_runme.ml b/Examples/test-suite/ocaml/template_ref_type_runme.ml new file mode 100644 index 000000000..2db2f9b28 --- /dev/null +++ b/Examples/test-suite/ocaml/template_ref_type_runme.ml @@ -0,0 +1,6 @@ +open Swig +open Template_ref_type + +let xr = new_XC '() +let y = new_Y '() +let _ = y -> find (xr) diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 192a181cf..2da3fb769 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -459,15 +459,6 @@ extern "C" { } if( !Is_block(v) ) return -1; switch( SWIG_Tag_val(v) ) { - case C_int: - if( !caml_long_val( v ) ) { - *out = 0; - CAMLreturn_type(0); - } else { - *out = 0; - CAMLreturn_type(1); - } - break; case C_obj: if (!func_val) { func_val = caml_named_value("caml_obj_ptr"); diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 4475707d6..af60d2422 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -52,10 +52,14 @@ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } -%typemap(out) SWIGTYPE &, SWIGTYPE && { +%typemap(varout) SWIGTYPE &, SWIGTYPE && { $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)&$1, $1_descriptor); } +%typemap(out) SWIGTYPE &, SWIGTYPE && { + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor); +} + #if 0 %typemap(argout) SWIGTYPE & { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); @@ -85,9 +89,6 @@ } #endif -%typemap(argout) const SWIGTYPE & { } -%typemap(argout) const SWIGTYPE && { } - %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } @@ -123,26 +124,26 @@ /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ -%define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) +%define SIMPLE_MAP(C_NAME, C_TO_OCAML, OCAML_TO_C) /* In */ %typemap(in) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(varin) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(in) C_NAME & ($*1_ltype temp) { - temp = ($*1_ltype) MZ_TO_C($input); + temp = ($*1_ltype) OCAML_TO_C($input); $1 = &temp; } %typemap(varin) C_NAME & { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(directorout) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(in) C_NAME *INPUT ($*1_ltype temp) { - temp = ($*1_ltype) MZ_TO_C($input); + temp = ($*1_ltype) OCAML_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { @@ -150,25 +151,22 @@ } /* Out */ %typemap(out) C_NAME { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(varout) C_NAME { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(varout) C_NAME & { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(argout) C_NAME *OUTPUT { - swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); + swig_result = caml_list_append(swig_result, C_TO_OCAML((long)*$1)); } %typemap(out) C_NAME & { - $result = C_TO_MZ(*$1); -} -%typemap(argout) C_NAME & { - swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); + $result = C_TO_OCAML(*$1); } %typemap(directorin) C_NAME { - args = caml_list_append(args,C_TO_MZ($1)); + args = caml_list_append(args, C_TO_OCAML($1)); } %enddef From e5a3c1e28cb862376bc441cee1dcef92a865e534 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 10:30:55 +0000 Subject: [PATCH 1407/2031] MzScheme and Travis CXXFLAGS/CFLAGS support mzc seems to use the CFLAGS, but not the CXXFLAGS env variables. Pass the CXXFLAGS as ++ccf options when compiling c++. --- Examples/Makefile.in | 4 ++-- Tools/testflags.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index c5dcb1ee1..7022166a0 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -821,12 +821,12 @@ MZSCHEME_SCRIPT = $(SRCDIR)$(RUNME).scm mzscheme: $(SRCDIR_SRCS) $(SWIG) -mzscheme $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - $(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCDIR_SRCS) + $(COMPILETOOL) $(MZC) `echo " $(CPPFLAGS) $(INCLUDES) $(CFLAGS)" | sed 's/ -/ ++ccf -/g'` --cc $(ISRCS) $(SRCDIR_SRCS) $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCDIR_SRCS) $(SWIG) -mzscheme -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(COMPILETOOL) $(MZC) `echo $(CPPFLAGS) $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) + env CFLAGS= $(COMPILETOOL) $(MZC) `echo " $(CPPFLAGS) $(INCLUDES) $(CXXFLAGS)" | sed 's/ -/ ++ccf -/g'` --cc $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- diff --git a/Tools/testflags.py b/Tools/testflags.py index ac8048e5f..bf85f5680 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -12,6 +12,7 @@ def get_cflags(language, std, compiler): "java":"-Werror " + c_common, "javascript":"-Werror " + c_common, "lua":"-Werror " + c_common, + "mzscheme":"-Werror " + c_common, "ocaml":"-Werror " + c_common, "octave":"-Werror " + c_common, "perl5":"-Werror " + c_common, @@ -42,6 +43,7 @@ def get_cxxflags(language, std, compiler): "java":"-Werror " + cxx_common, "javascript":"-Werror " + cxx_common + " -Wno-error=unused-function", # Until overload_rename is fixed for node "lua":"-Werror " + cxx_common, + "mzscheme":"-Werror " + cxx_common, "ocaml":"-Werror " + cxx_common, "octave":"-Werror " + cxx_common, "perl5":"-Werror " + cxx_common, From c7ff070cd75f99a31a6e46fdbd221aca6745aec2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 10:40:07 +0000 Subject: [PATCH 1408/2031] MzScheme - add missing return --- Source/Modules/mzscheme.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 23be87d0f..543874172 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -454,6 +454,7 @@ public: Printv(df->def, "static Scheme_Object *\n", dname, "(int argc, Scheme_Object **argv) {", NIL); Printv(df->code, dispatch, "\n", NIL); Printf(df->code, "scheme_signal_error(\"No matching function for overloaded '%s'\");\n", iname); + Printf(df->code, "return NULL;\n", iname); Printv(df->code, "}\n", NIL); Wrapper_print(df, f_wrappers); Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, dname, proc_name, 0, maxargs); From 424eebfb6a624cfd77d12c8b441f97c807eaebf2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 10:46:26 +0000 Subject: [PATCH 1409/2031] Disable broken mzscheme testcases Failing tests due to: -Werror=overflow -Werror=write-strings --- Examples/test-suite/mzscheme/Makefile.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index 4338b9b1f..6a8ef74e4 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -16,6 +16,7 @@ apply_strings \ arrays_dimensionless \ arrays_global \ char_strings \ +chartest \ class_scope_weird \ constant_pointers \ cpp_basic \ @@ -52,6 +53,8 @@ nested_template_base \ ordering \ preproc_constants \ samename \ +static_const_member \ +string_constants \ template_default2 \ template_specialization_defarg \ template_typemaps \ From 509b14ac6f32a8ac6a0abbc8266cc6d274ceb9db Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Feb 2019 13:31:54 +0100 Subject: [PATCH 1410/2031] Add Python run-time test for ignore_parameter.i This will allow to test the upcoming fix for wrongly handling "%ignore" for parameters in the test suite. --- .../python/ignore_parameter_runme.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Examples/test-suite/python/ignore_parameter_runme.py diff --git a/Examples/test-suite/python/ignore_parameter_runme.py b/Examples/test-suite/python/ignore_parameter_runme.py new file mode 100644 index 000000000..d804897e9 --- /dev/null +++ b/Examples/test-suite/python/ignore_parameter_runme.py @@ -0,0 +1,21 @@ +from ignore_parameter import * + +def check(a, b): + if a != b: + raise RuntimeError('"%s" != "%s"' % (a, b)) + +check(jaguar(200, 0), "hello") +check(lotus("foo", 1), 101) +check(tvr("bar", 2), 8.8) +check(ferrari(), 101) + +car = SportsCars() +check(car.daimler(200, 0), "hello") +check(car.astonmartin("foo", 1), 101) +check(car.bugatti("bar", 2), 8.8) +check(car.lamborghini(), 101) + +MiniCooper(200, 0) +MorrisMinor("baz", 0) +FordAnglia("quux", 200) +AustinAllegro() From 2517f5b05ed62f16d4da1a8045543cc553da732f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Feb 2019 13:40:12 +0100 Subject: [PATCH 1411/2031] Don't apply %ignore to parameters Fix regression introduced by 3f5c17824c5f20023bac58f7ebfc8de8532d6881 which resulted in using "$ignore" instead of the real parameter name in Python if an %ignore/%rename($ignore) for the parameter name was used (as could happen not necessarily intentionally when using wild card ignores with regex matches) by explicitly checking if we're dealing with a parameter node in apply_rename(), used by Swig_name_make(), and not renaming it to "$ignore" in this case. Extend the test suite to check for this case. Closes #1460. --- Examples/test-suite/ignore_parameter.i | 4 ++++ .../test-suite/python/ignore_parameter_runme.py | 2 ++ Source/Swig/naming.c | 13 ++++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/ignore_parameter.i b/Examples/test-suite/ignore_parameter.i index bc0892c3a..604ee3b84 100644 --- a/Examples/test-suite/ignore_parameter.i +++ b/Examples/test-suite/ignore_parameter.i @@ -8,12 +8,15 @@ %typemap(freearg) char* a ""; // ensure freearg is not generated (needed for Java at least) +%ignore unignorable; + %inline %{ // global function tests char* jaguar(char* a, int b, double c) { return a; } int lotus(char* aa, int bb, double cc) { return bb; } double tvr(char* aaa, int bbb, double ccc) { return ccc; } int ferrari(int bb) { return bb; } +int fiat(int unignorable) { return unignorable; } // member function tests struct SportsCars { @@ -21,6 +24,7 @@ struct SportsCars { int astonmartin(char* aa, int bb, double cc) { return bb; } double bugatti(char* aaa, int bbb, double ccc) { return ccc; } int lamborghini(int bb) { return bb; } + int maseratti(int unignorable) { return unignorable; } }; // constructor tests diff --git a/Examples/test-suite/python/ignore_parameter_runme.py b/Examples/test-suite/python/ignore_parameter_runme.py index d804897e9..5f1342e4a 100644 --- a/Examples/test-suite/python/ignore_parameter_runme.py +++ b/Examples/test-suite/python/ignore_parameter_runme.py @@ -8,12 +8,14 @@ check(jaguar(200, 0), "hello") check(lotus("foo", 1), 101) check(tvr("bar", 2), 8.8) check(ferrari(), 101) +check(fiat(17), 17) car = SportsCars() check(car.daimler(200, 0), "hello") check(car.astonmartin("foo", 1), 101) check(car.bugatti("bar", 2), 8.8) check(car.lamborghini(), 101) +check(car.maseratti(289), 289) MiniCooper(200, 0) MorrisMinor("baz", 0) diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 180e54774..136df1987 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1377,12 +1377,15 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne } -/* Create a name applying rename/namewarn if needed */ -static String *apply_rename(String *newname, int fullname, String *prefix, String *name) { +/* Create a name for the given node applying rename/namewarn if needed */ +static String *apply_rename(Node* n, String *newname, int fullname, String *prefix, String *name) { String *result = 0; if (newname && Len(newname)) { if (Strcmp(newname, "$ignore") == 0) { - result = Copy(newname); + /* $ignore doesn't apply to parameters and while it's rare to explicitly write %ignore directives for them they could be caught by a wildcard ignore using + regex match, just ignore the attempt to ignore them in this case */ + if (!Equal(nodeType(n), "parm")) + result = Copy(newname); } else { char *cnewname = Char(newname); if (cnewname) { @@ -1480,7 +1483,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, if (rn) { String *newname = Getattr(rn, "name"); int fullname = GetFlag(rn, "fullname"); - result = apply_rename(newname, fullname, prefix, name); + result = apply_rename(n, newname, fullname, prefix, name); } if (result && !Equal(result, name)) { /* operators in C++ allow aliases, we look for them */ @@ -1504,7 +1507,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, int fullname = GetFlag(wrn, "fullname"); if (result) Delete(result); - result = apply_rename(rename, fullname, prefix, name); + result = apply_rename(n, rename, fullname, prefix, name); if ((msg) && (Len(msg))) { if (!Getmeta(nname, "already_warned")) { if (n) { From e4759ae250d8a44fcb711ce292fa509403dbecb7 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 10 Feb 2019 15:53:42 +0000 Subject: [PATCH 1412/2031] C++17 u8 character literals testcase Issue #1450 --- Examples/test-suite/cpp17_u8_char_literals.i | 8 ++++++++ .../test-suite/python/cpp17_u8_char_literals_runme.py | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 Examples/test-suite/cpp17_u8_char_literals.i create mode 100644 Examples/test-suite/python/cpp17_u8_char_literals_runme.py diff --git a/Examples/test-suite/cpp17_u8_char_literals.i b/Examples/test-suite/cpp17_u8_char_literals.i new file mode 100644 index 000000000..4a0b4a094 --- /dev/null +++ b/Examples/test-suite/cpp17_u8_char_literals.i @@ -0,0 +1,8 @@ +%module cpp17_u8_char_literals + +%inline %{ +// UTF-8 character literals will (apparently) have type char8_t in C++20. +char a = u8'a'; +char u = u8'u'; +char u8 = u8'8'; +%} diff --git a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py new file mode 100644 index 000000000..81f34f193 --- /dev/null +++ b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py @@ -0,0 +1,10 @@ +from cpp17_u8_char_literals import * + +if cvar.a != 'a': + raise RuntimeError + +if cvar.u != 'u': + raise RuntimeError + +if cvar.u8 != '8': + raise RuntimeError From 8bf40596b85c8001cf9a529046b86dbcc0fa7475 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 10 Feb 2019 16:06:53 +0000 Subject: [PATCH 1413/2031] C++17 u8 character literals fix --- Source/Swig/scanner.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 19cf25fe2..f141037dd 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -945,7 +945,7 @@ static int look(Scanner *s) { else if (c == 'R') { /* Possibly CUSTOM DELIMITER u, U, L string */ state = 73; } - else if (c == '8') { /* Possibly u8 string */ + else if (c == '8') { /* Possibly u8 string/char */ state = 71; } else { @@ -965,7 +965,7 @@ static int look(Scanner *s) { } break; - case 71: /* Possibly u8 string */ + case 71: /* Possibly u8 string/char */ if ((c = nextchar(s)) == 0) { state = 76; } @@ -973,6 +973,10 @@ static int look(Scanner *s) { retract(s, 1); /* Definitely u8 string */ state = 1000; } + else if (c=='\'') { + retract(s, 1); /* Definitely u8 char */ + state = 77; + } else if (c=='R') { state = 74; /* Possibly CUSTOM DELIMITER u8 string */ } From 21c0d59ae20152eba94154670809559ed480fc30 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 16:45:03 +0000 Subject: [PATCH 1414/2031] c++17 u8 character literals testcase --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp17_u8_char_literals.i | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7d4a441fb..50a52441f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -164,6 +164,7 @@ CPP_TEST_CASES += \ cpp_typedef \ cpp17_nested_namespaces \ cpp17_nspace_nested_namespaces \ + cpp17_u8_char_literals \ curiously_recurring_template_pattern \ default_args \ default_arg_expressions \ diff --git a/Examples/test-suite/cpp17_u8_char_literals.i b/Examples/test-suite/cpp17_u8_char_literals.i index 4a0b4a094..1aae1b231 100644 --- a/Examples/test-suite/cpp17_u8_char_literals.i +++ b/Examples/test-suite/cpp17_u8_char_literals.i @@ -1,8 +1,26 @@ %module cpp17_u8_char_literals -%inline %{ +// Tests are designed so that code compiles with C++98 compilers + +%{ +#if __cplusplus >= 201703L +#define CPP17 1 +#endif +%} + // UTF-8 character literals will (apparently) have type char8_t in C++20. char a = u8'a'; char u = u8'u'; char u8 = u8'8'; + +%{ +#if defined(CPP17) +char a = u8'a'; +char u = u8'u'; +char u8 = u8'8'; +#else +char a = 'a'; +char u = 'u'; +char u8 = '8'; +#endif %} From 7bc928da6092ac2615eb2d5e7ec1171abaf1c0c9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 17:34:20 +0000 Subject: [PATCH 1415/2031] Document C++11 UCS-2 UCS-4 and C++17 UTF8 character literals support --- CHANGES.current | 4 ++++ Doc/Manual/CPlusPlus11.html | 16 ++++++++++++++++ Doc/Manual/CPlusPlus17.html | 16 +++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index c64d4cc3c..79412a0f8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-10: ZackerySpytz + #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also add support for + C++17 UTF8 character literals. + 2019-02-04: wsfulton [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index f9281bd56..bdcd49735 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -714,6 +714,22 @@ const int SIZE = sizeof...(ClassName<int, int>); In the above example SIZE is of course wrapped as a constant.

      +

      7.2.19 New character literals

      + +

      +C++11 adds support for UCS-2 and UCS-4 character literals. +These character literals are preceded by either 'u' or 'U'. +

      + +
      +char16_t a = u'a';
      +char32_t b = U'b';
      +
      + +

      +Compatibility note: SWIG-4.0.0 was the first version to support these Universal Coded Character Set (UCS) character literals. +

      +

      7.2.19 New string literals

      diff --git a/Doc/Manual/CPlusPlus17.html b/Doc/Manual/CPlusPlus17.html index 690173e6e..93d5b0ad2 100644 --- a/Doc/Manual/CPlusPlus17.html +++ b/Doc/Manual/CPlusPlus17.html @@ -32,6 +32,10 @@ There isn't much in C++17 that affects SWIG, however, work has only just begun o C++17 support.

      +

      +Compatibility note: SWIG-4.0.0 is the first version to support any C++17 features. +

      +

      8.2 Core language changes

      @@ -67,10 +71,20 @@ namespace A { +

      8.2.2 UTF-8 character literals

      +

      -Compatibility note: SWIG-4.0.0 was the first version to support nested namespace definitions. +C++17 added UTF-8 (u8) character literals. +These are of type char. +Example:

      +
      +
      +char a = u8'a';
      +
      +
      +

      8.3 Standard library changes

      From e0fb4b895618024d139669691850323c2b754ec9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 17:40:00 +0000 Subject: [PATCH 1416/2031] html section numbers updated --- Doc/Manual/CPlusPlus11.html | 24 +++++++++++++----------- Doc/Manual/CPlusPlus17.html | 2 ++ Doc/Manual/Contents.html | 2 ++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html index bdcd49735..11335a251 100644 --- a/Doc/Manual/CPlusPlus11.html +++ b/Doc/Manual/CPlusPlus11.html @@ -32,6 +32,7 @@
    • Type alias and alias templates
    • Unrestricted unions
    • Variadic templates +
    • New character literals
    • New string literals
    • User-defined literals
    • Thread-local storage @@ -716,6 +717,7 @@ In the above example SIZE is of course wrapped as a constant.

      7.2.19 New character literals

      +

      C++11 adds support for UCS-2 and UCS-4 character literals. These character literals are preceded by either 'u' or 'U'. @@ -730,7 +732,7 @@ char32_t b = U'b'; Compatibility note: SWIG-4.0.0 was the first version to support these Universal Coded Character Set (UCS) character literals.

      -

      7.2.19 New string literals

      +

      7.2.20 New string literals

      SWIG supports wide string and Unicode string constants and raw string literals.

      @@ -760,7 +762,7 @@ Note: There is a bug currently where SWIG's preprocessor incorrectly parses an o inside raw string literals.

      -

      7.2.20 User-defined literals

      +

      7.2.21 User-defined literals

      @@ -827,7 +829,7 @@ OutputType var2 = 1234_suffix; OutputType var3 = 3.1416_suffix; -

      7.2.21 Thread-local storage

      +

      7.2.22 Thread-local storage

      SWIG correctly parses the thread_local keyword. For example, variables @@ -847,7 +849,7 @@ A variable will be thread local if accessed from different threads from the targ same way that it will be thread local if accessed from C++ code.

      -

      7.2.22 Explicitly defaulted functions and deleted functions

      +

      7.2.23 Explicitly defaulted functions and deleted functions

      SWIG handles explicitly defaulted functions, that is, = default added to a function declaration. Deleted definitions, which are also called deleted functions, have = delete added to the function declaration. @@ -885,12 +887,12 @@ This is a C++ compile time check and SWIG does not make any attempt to detect if so in this case it is entirely possible to pass an int instead of a double to f from Java, Python etc.

      -

      7.2.23 Type long long int

      +

      7.2.24 Type long long int

      SWIG correctly parses and uses the new long long type already introduced in C99 some time ago.

      -

      7.2.24 Static assertions

      +

      7.2.25 Static assertions

      @@ -906,7 +908,7 @@ struct Check { }; -

      7.2.25 Allow sizeof to work on members of classes without an explicit object

      +

      7.2.26 Allow sizeof to work on members of classes without an explicit object

      @@ -927,7 +929,7 @@ const int SIZE = sizeof(A::member); // does not work with C++03. Okay with C++11 8 -

      7.2.26 Exception specifications and noexcept

      +

      7.2.27 Exception specifications and noexcept

      @@ -943,7 +945,7 @@ int noex2(int) noexcept(true); int noex3(int, bool) noexcept(false); -

      7.2.27 Control and query object alignment

      +

      7.2.28 Control and query object alignment

      @@ -975,7 +977,7 @@ Use the preprocessor to work around this for now: -

      7.2.28 Attributes

      +

      7.2.29 Attributes

      @@ -989,7 +991,7 @@ int [[attr1]] i [[attr2, attr3]]; -

      7.2.29 Methods with ref-qualifiers

      +

      7.2.30 Methods with ref-qualifiers

      diff --git a/Doc/Manual/CPlusPlus17.html b/Doc/Manual/CPlusPlus17.html index 93d5b0ad2..ea42bd6a2 100644 --- a/Doc/Manual/CPlusPlus17.html +++ b/Doc/Manual/CPlusPlus17.html @@ -15,6 +15,7 @@

    • Core language changes
    • Standard library changes
    @@ -73,6 +74,7 @@ namespace A {

    8.2.2 UTF-8 character literals

    +

    C++17 added UTF-8 (u8) character literals. These are of type char. diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e0db363f7..5218cc0d9 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -310,6 +310,7 @@

  • Type alias and alias templates
  • Unrestricted unions
  • Variadic templates +
  • New character literals
  • New string literals
  • User-defined literals
  • Thread-local storage @@ -348,6 +349,7 @@
  • Core language changes
  • Standard library changes From ce5a249878e6c8d84f01e20499a070e439fe70e1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 9 Feb 2019 23:52:41 +1300 Subject: [PATCH 1417/2031] Drop -php4 option completely SWIG's support for PHP4 was removed over a decade ago, and PHP4 itself went out of security support more than a decade ago too - nobody is realistically going to be trying to generate PHP4 bindings in 2019. --- Source/Modules/swigmain.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index a9916ad9a..0ff13a723 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -69,7 +69,6 @@ static TargetLanguageModule modules[] = { {"-perl", swig_perl5, NULL, Supported}, {"-perl5", swig_perl5, "Perl 5", Supported}, {"-php", swig_php, NULL, Supported}, - {"-php4", NULL, "PHP 4", Disabled}, {"-php5", NULL, "PHP 5", Disabled}, {"-php7", swig_php, "PHP 7", Supported}, {"-pike", NULL, "Pike", Disabled}, From 60eccff4b7ce9dc9016b92be81f2c88ec92f8e82 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 10 Feb 2019 13:51:51 +1300 Subject: [PATCH 1418/2031] [php] Fix typemap indentation (cosmetic) --- Lib/php/php.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 97cbf68c4..7deda4ca7 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -149,8 +149,8 @@ if (SWIG_ConvertPtr(&$input, (void **) &$1, 0, 0) < 0) { /* Allow NULL from php for void* */ if (Z_ISNULL($input)) $1=0; - else - SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + else + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor"); } %} From a0720885bd3423afcd7248d9ede77480d2bc8d93 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 10 Feb 2019 13:58:07 +1300 Subject: [PATCH 1419/2031] Remove PHP-specific avoidance of uninitialised variable This code is no longer needed since ebd37155a81fd0c9504522e43cbdaf38312a132c addressed this more generically. --- Lib/php/utils.i | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 8581646a2..ed6e08ff4 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -77,18 +77,12 @@ %{ if (!EG(exception)) { CONVERT_IN($result, $1_ltype, *$input); - } else { - typedef $1_ltype swig_result_typedef; - $result = swig_result_typedef(); } %} %typemap(directorout) const TYPE & ($*1_ltype temp) %{ if (!EG(exception)) { CONVERT_IN(temp, $*1_ltype, *$input); - } else { - typedef $*1_ltype swig_result_typedef; - temp = swig_result_typedef(); } $result = &temp; %} From 23d83cd9c10dce8d6b474f2adf2f89ca13ae7401 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 10 Feb 2019 15:38:49 -0700 Subject: [PATCH 1420/2031] Add support for C++14 binary integer literals Closes #1030. --- CHANGES.current | 3 ++ Examples/test-suite/common.mk | 1 + .../cpp14_binary_integer_literals.i | 31 +++++++++++++++++++ .../cpp14_binary_integer_literals_runme.py | 16 ++++++++++ Source/Swig/scanner.c | 17 ++++++++++ 5 files changed, 68 insertions(+) create mode 100644 Examples/test-suite/cpp14_binary_integer_literals.i create mode 100644 Examples/test-suite/python/cpp14_binary_integer_literals_runme.py diff --git a/CHANGES.current b/CHANGES.current index d25bd928c..9fe695297 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-10: ZackerySpytz + #1464 Add support for C++14 binary integer literals. + 2019-02-10: ZackerySpytz #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also add support for C++17 UTF8 character literals. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 50a52441f..e7e3dd07b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -162,6 +162,7 @@ CPP_TEST_CASES += \ cpp_nodefault \ cpp_static \ cpp_typedef \ + cpp14_binary_integer_literals \ cpp17_nested_namespaces \ cpp17_nspace_nested_namespaces \ cpp17_u8_char_literals \ diff --git a/Examples/test-suite/cpp14_binary_integer_literals.i b/Examples/test-suite/cpp14_binary_integer_literals.i new file mode 100644 index 000000000..9c696b5a5 --- /dev/null +++ b/Examples/test-suite/cpp14_binary_integer_literals.i @@ -0,0 +1,31 @@ +%module cpp14_binary_integer_literals + +// Tests are designed so that code compiles with C++98 compilers + +%{ +#if __cplusplus >= 201402L +#define CPP14 1 +#endif +%} + +int b1 = 0b1; +int b2 = 0b10; +long b3 = 0b11l; +unsigned long b4 = 0b100ul; +unsigned long b5 = 0B101UL; + +%{ +#if defined(CPP14) +int b1 = 0b1; +int b2 = 0b10; +long b3 = 0b11l; +unsigned long b4 = 0b100ul; +unsigned long b5 = 0B101UL; +#else +int b1 = 1; +int b2 = 2; +long b3 = 3; +unsigned long b4 = 4; +unsigned long b5 = 5; +#endif +%} diff --git a/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py b/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py new file mode 100644 index 000000000..8274ec6b5 --- /dev/null +++ b/Examples/test-suite/python/cpp14_binary_integer_literals_runme.py @@ -0,0 +1,16 @@ +from cpp14_binary_integer_literals import * + +if cvar.b1 != 1: + raise RuntimeError + +if cvar.b2 != 2: + raise RuntimeError + +if cvar.b3 != 3: + raise RuntimeError + +if cvar.b4 != 4: + raise RuntimeError + +if cvar.b5 != 5: + raise RuntimeError diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index f141037dd..24a07e68b 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1162,6 +1162,8 @@ static int look(Scanner *s) { state = 84; else if ((c == 'x') || (c == 'X')) state = 85; + else if ((c == 'b') || (c == 'B')) + state = 850; else if (c == '.') state = 81; else if ((c == 'l') || (c == 'L')) { @@ -1203,6 +1205,21 @@ static int look(Scanner *s) { return SWIG_TOKEN_INT; } break; + case 850: + /* This is a binary number */ + if ((c = nextchar(s)) == 0) + return SWIG_TOKEN_INT; + if ((c == '0') || (c == '1')) + state = 850; + else if ((c == 'l') || (c == 'L')) { + state = 87; + } else if ((c == 'u') || (c == 'U')) { + state = 88; + } else { + retract(s, 1); + return SWIG_TOKEN_INT; + } + break; case 86: /* Rest of floating point number */ From 43438b66abe11be3609ebb88cf0d3d998c0be145 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Feb 2019 19:42:36 +0000 Subject: [PATCH 1421/2031] Re-organise some generate Python code for method creation and docstring support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix ‘PyMethodDef* SWIG_PythonGetProxyDoc(const char*)’ declared ‘static’ but never defined [-Wunused-function] Closes #1448 --- Lib/python/pyapi.swg | 38 ------------------------- Lib/python/pyinit.swg | 58 +++++++++++++++++++++++++++++++++++++++ Lib/python/pyrun.swg | 6 ++++ Source/Modules/python.cxx | 17 ------------ 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index cb754db11..19e6979b5 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -24,44 +24,6 @@ typedef struct swig_const_info { swig_type_info **ptype; } swig_const_info; -/* ----------------------------------------------------------------------------- - * Function to find the method definition with the correct docstring for the - * proxy module as opposed to the low-level API - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return PyMethod_New(func, NULL, NULL); -#endif -} - -/* ----------------------------------------------------------------------------- - * Wrapper of PyStaticMethod_New() - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { - if (PyCFunction_Check(func)) { - PyCFunctionObject *funcobj = (PyCFunctionObject *)func; - PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); - if (ml) - func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); - } - return PyStaticMethod_New(func); -} - #ifdef __cplusplus } #endif diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 3409fbb4a..f5be6d599 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -298,6 +298,64 @@ SWIG_Python_FixMethods(PyMethodDef *methods, } } +/* ----------------------------------------------------------------------------- + * Method creation and docstring support functions + * ----------------------------------------------------------------------------- */ + +/* ----------------------------------------------------------------------------- + * Function to find the method definition with the correct docstring for the + * proxy module as opposed to the low-level API + * ----------------------------------------------------------------------------- */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name) { + /* Find the function in the modified method table */ + size_t offset = 0; + int found = 0; + while (SwigMethods_proxydocs[offset].ml_meth != NULL) { + if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) { + found = 1; + break; + } + offset++; + } + /* Use the copy with the modified docstring if available */ + return found ? &SwigMethods_proxydocs[offset] : NULL; +} + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } +#if PY_VERSION_HEX >= 0x03000000 + return PyInstanceMethod_New(func); +#else + return PyMethod_New(func, NULL, NULL); +#endif +} + +/* ----------------------------------------------------------------------------- + * Wrapper of PyStaticMethod_New() + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ + +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) { + if (PyCFunction_Check(func)) { + PyCFunctionObject *funcobj = (PyCFunctionObject *)func; + PyMethodDef *ml = SWIG_PythonGetProxyDoc(funcobj->m_ml->ml_name); + if (ml) + func = PyCFunction_NewEx(ml, funcobj->m_self, funcobj->m_module); + } + return PyStaticMethod_New(func); +} + #ifdef __cplusplus } #endif diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index ad1b81963..693cd6d46 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -213,6 +213,12 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi extern "C" { #endif +/* Method creation and docstring support functions */ + +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name); +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func); + /* The python void return value */ SWIGRUNTIMEINLINE PyObject * diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9c3c0cac2..3c1767d6f 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -834,23 +834,6 @@ public: Append(methods_proxydocs, "};\n"); Printf(f_wrappers, "%s\n", methods_proxydocs); - /* Need to define the function to find the proxy documentation after the proxy docs themselves */ - Printv(f_wrappers, "SWIGRUNTIME PyMethodDef *SWIG_PythonGetProxyDoc(const char *name)\n", - "{\n", - " /* Find the function in the modified method table */\n", - " size_t offset = 0;\n", - " int found = 0;\n", - " while (SwigMethods_proxydocs[offset].ml_meth != NULL) {\n", - " if (strcmp(SwigMethods_proxydocs[offset].ml_name, name) == 0) {\n", - " found = 1;\n", - " break;\n", - " }\n", - " offset++;\n", - " }\n", - " /* Use the copy with the modified docstring if available */\n", - " return found ? &SwigMethods_proxydocs[offset] : NULL;\n", - "}\n", NIL); - if (builtin) { Dump(f_builtins, f_wrappers); } From ad7f9cd8d7c563df90569e89bf6591b512e34b2e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 09:06:28 +0000 Subject: [PATCH 1422/2031] Mark and setup OCaml as an experimental target language. Issue #1437 --- .travis.yml | 5 +++++ CHANGES.current | 4 ++++ Doc/Manual/Ocaml.html | 2 +- Doc/Manual/Preprocessor.html | 2 +- Doc/Manual/SWIG.html | 2 +- Doc/Manual/Sections.html | 2 +- Doc/Manual/chapters | 2 +- Examples/test-suite/ocaml/Makefile.in | 2 +- Source/Modules/swigmain.cxx | 2 +- 9 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c669f0b05..b443ae07a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -395,6 +395,11 @@ matrix: env: SWIGLANG=mzscheme sudo: required dist: trusty + - compiler: gcc + os: linux + env: SWIGLANG=ocaml + sudo: required + dist: trusty before_install: - date -u diff --git a/CHANGES.current b/CHANGES.current index d25bd928c..50280fb91 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-11: wsfulton + [OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work + and most of the test-suite is also working, so it is quite close to being a 'Supported' language. + 2019-02-10: ZackerySpytz #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also add support for C++17 UTF8 character literals. diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 9e0902bc8..11d21ce1b 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -7,7 +7,7 @@ -

    28 SWIG and Ocaml

    +

    28 SWIG and OCaml

      diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 18629a4f3..10efe0c15 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -117,7 +117,7 @@ SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js SWIGLUA Defined when using Lua SWIGMZSCHEME Defined when using Mzscheme -SWIGOCAML Defined when using Ocaml +SWIGOCAML Defined when using OCaml SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl SWIGPHP Defined when using PHP (any version) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index be6eda739..79d52ef56 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -125,7 +125,6 @@ Supported Target Language Options -java - Generate Java wrappers -javascript - Generate Javascript wrappers -lua - Generate Lua wrappers - -ocaml - Generate Ocaml wrappers -octave - Generate Octave wrappers -perl5 - Generate Perl 5 wrappers -php7 - Generate PHP 7 wrappers @@ -138,6 +137,7 @@ Supported Target Language Options Experimental Target Language Options -mzscheme - Generate MzScheme/Racket wrappers + -ocaml - Generate OCaml wrappers General Options -addextern - Add extra extern declarations diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 97338b0f4..1756e8b6a 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -47,7 +47,6 @@ Last update : SWIG-4.0.0 (in progress)
    • Java support
    • Javascript support
    • Lua support
    • -
    • Ocaml support
    • Octave support
    • Perl5 support
    • PHP support
    • @@ -62,6 +61,7 @@ Last update : SWIG-4.0.0 (in progress)

      Developer Documentation

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 1d3f96d87..4735341b6 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -25,7 +25,6 @@ Guile.html Java.html Javascript.html Lua.html -Ocaml.html Octave.html Perl5.html Php.html @@ -35,4 +34,5 @@ Ruby.html Scilab.html Tcl.html Mzscheme.html +Ocaml.html Extending.html diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index f45f0859e..fd1daed15 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -52,7 +52,7 @@ run_testcase = \ include $(srcdir)/../common.mk # Overridden variables here -# none! +SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning # Custom tests - tests with additional commandline options # none! diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 0ff13a723..8d52af194 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -64,7 +64,7 @@ static TargetLanguageModule modules[] = { {"-lua", swig_lua, "Lua", Supported}, {"-modula3", NULL, "Modula 3", Disabled}, {"-mzscheme", swig_mzscheme, "MzScheme/Racket", Experimental}, - {"-ocaml", swig_ocaml, "Ocaml", Supported}, + {"-ocaml", swig_ocaml, "OCaml", Experimental}, {"-octave", swig_octave, "Octave", Supported}, {"-perl", swig_perl5, NULL, Supported}, {"-perl5", swig_perl5, "Perl 5", Supported}, From 857456b5f3093cd677ce06a620a022db1e3fb8f7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 09:11:57 +0000 Subject: [PATCH 1423/2031] Add changes entry about target language statuses --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 50280fb91..455f79128 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -47,6 +47,12 @@ Version 4.0.0 (in progress) [PHP] The generated code is now compatible with PHP 7.3, and the testsuite now runs cleanly with this version too. +2019-02-05: wsfulton + #1437 SWIG now classifies the status of target languages into either 'Experimental' or + 'Supported'. This status is provided to indicate the level of maturity to expect when using + a particular target language as not all target languages are fully developed. Details are + in the Introduction.html chapter of the documentation. + 2019-02-04: wsfulton [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a clean up to remove target languages that have been neglected/not functional. From a5b301ba83810f55da9947765dd249a78ec99855 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 18:59:16 +0000 Subject: [PATCH 1424/2031] Add a documentation chapter on C++14 --- Doc/Manual/CPlusPlus14.html | 59 ++++++++++++++++++++++++++++++++++++ Doc/Manual/Introduction.html | 5 +-- Doc/Manual/SWIGPlus.html | 6 ++-- Doc/Manual/Sections.html | 1 + Doc/Manual/chapters | 1 + 5 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 Doc/Manual/CPlusPlus14.html diff --git a/Doc/Manual/CPlusPlus14.html b/Doc/Manual/CPlusPlus14.html new file mode 100644 index 000000000..32798f302 --- /dev/null +++ b/Doc/Manual/CPlusPlus14.html @@ -0,0 +1,59 @@ + + + +SWIG and C++14 + + + + + +

      8 SWIG and C++14

      + + + + + + +

      8.1 Introduction

      + + +

      This chapter gives you a brief overview about the SWIG +implementation of the C++14 standard. +There isn't much in C++14 that affects SWIG, however, work has only just begun on adding +C++14 support. +

      + +

      +Compatibility note: SWIG-4.0.0 is the first version to support any C++14 features. +

      + +

      8.2 Core language changes

      + + +

      Binary integer literals

      + + +

      +C++14 added binary integer literals and SWIG supports these. +Example: +

      + +
      +
      +int b = 0b101011;
      +
      +
      + +

      8.3 Standard library changes

      + + + + diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 17514d021..1a2e26a6d 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -413,8 +413,9 @@ major features include:

    -Most of C++11 is also supported. Details are in the C++11 section. -C++17 support is covered in the C++17 section. +Most of C++11 is also supported. Details are in the C++11 chapter. +C++14 support is covered in the C++14 chapter. +C++17 support is covered in the C++17 chapter.

    diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 1b57860c0..a6cb93f63 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -87,8 +87,10 @@

    This chapter describes SWIG's support for wrapping C++. It is mostly concerned about C++ as defined by the C++ 98 and 03 standards. -For C++ 11 features please read the SWIG and C++11 chapter. -For C++ 17 features please read the SWIG and C++17 chapter. +For additions to the original C++ standard, please read the +SWIG and C++11, +SWIG and C++14 and +SWIG and C++17 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ANSI C. Support for C++ builds upon ANSI C diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 1756e8b6a..f57108535 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -22,6 +22,7 @@ Last update : SWIG-4.0.0 (in progress)

  • SWIG Basics (Read this!)
  • SWIG and C++
  • SWIG and C++11
  • +
  • SWIG and C++14
  • SWIG and C++17
  • The SWIG preprocessor
  • The SWIG library
  • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 4735341b6..2cb2b18a3 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -5,6 +5,7 @@ Scripting.html SWIG.html SWIGPlus.html CPlusPlus11.html +CPlusPlus14.html CPlusPlus17.html Preprocessor.html Library.html From d16d145787c45954c533c2208b9a0ae721df9002 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 19:02:03 +0000 Subject: [PATCH 1425/2031] Documentation section numbering update [skip ci] --- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CPlusPlus14.html | 3 +- Doc/Manual/CPlusPlus17.html | 12 +- Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Contents.html | 167 ++++++++++++++------------ Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Doxygen.html | 52 ++++---- Doc/Manual/Extending.html | 106 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 44 +++---- Doc/Manual/Java.html | 220 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 50 ++++---- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Ocaml.html | 66 +++++----- Doc/Manual/Preprocessor.html | 26 ++-- Doc/Manual/Typemaps.html | 132 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 38 +++--- 24 files changed, 688 insertions(+), 672 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index cc11ec26e..894724188 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

    20 SWIG and Android

    +

    21 SWIG and Android

    -

    11.1.3 Output parameters

    +

    12.1.3 Output parameters

    @@ -315,7 +315,7 @@ iresult, dresult = foo(3.5, 2) -

    11.1.4 Input/Output parameters

    +

    12.1.4 Input/Output parameters

    @@ -380,7 +380,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    11.1.5 Using different names

    +

    12.1.5 Using different names

    @@ -414,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    11.2 Applying constraints to input values

    +

    12.2 Applying constraints to input values

    @@ -424,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    11.2.1 Simple constraint example

    +

    12.2.1 Simple constraint example

    @@ -450,7 +450,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    11.2.2 Constraint methods

    +

    12.2.2 Constraint methods

    @@ -466,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only). -

    11.2.3 Applying constraints to new datatypes

    +

    12.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 6923b2e95..3a7db5c7b 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -7,7 +7,7 @@ -

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

    +

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

    -

    19.14 HISTORY

    +

    20.14 HISTORY

    @@ -423,7 +423,7 @@ 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.

    -

    19.15 DIFFERENCES FROM COMPILERCACHE

    +

    20.15 DIFFERENCES FROM COMPILERCACHE

    @@ -441,7 +441,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    19.16 CREDITS

    +

    20.16 CREDITS

    @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    19.17 AUTHOR

    +

    20.17 AUTHOR

    diff --git a/Doc/Manual/CPlusPlus14.html b/Doc/Manual/CPlusPlus14.html index 32798f302..b162c7818 100644 --- a/Doc/Manual/CPlusPlus14.html +++ b/Doc/Manual/CPlusPlus14.html @@ -14,6 +14,7 @@

  • Introduction
  • Core language changes
  • Standard library changes @@ -38,7 +39,7 @@ C++14 support.

    8.2 Core language changes

    -

    Binary integer literals

    +

    8.2.1 Binary integer literals

    diff --git a/Doc/Manual/CPlusPlus17.html b/Doc/Manual/CPlusPlus17.html index ea42bd6a2..ae3ca5c77 100644 --- a/Doc/Manual/CPlusPlus17.html +++ b/Doc/Manual/CPlusPlus17.html @@ -7,7 +7,7 @@ -

    8 SWIG and C++17

    +

    9 SWIG and C++17

    -

    8.2.2 UTF-8 character literals

    +

    9.2.2 UTF-8 character literals

    @@ -87,7 +87,7 @@ char a = u8'a';

  • -

    8.3 Standard library changes

    +

    9.3 Standard library changes

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 7a1326b54..a4e0be799 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

    21 SWIG and C#

    +

    22 SWIG and C#

    -

    21.4 C# Arrays

    +

    22.4 C# Arrays

    @@ -586,7 +586,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

    -

    21.4.1 The SWIG C arrays library

    +

    22.4.1 The SWIG C arrays library

    @@ -623,7 +623,7 @@ example.print_array(c.cast()); // Pass to C -

    21.4.2 Managed arrays using P/Invoke default array marshalling

    +

    22.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -750,7 +750,7 @@ and intermediary class method -

    21.4.3 Managed arrays using pinning

    +

    22.4.3 Managed arrays using pinning

    @@ -845,7 +845,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    21.5 C# Exceptions

    +

    22.5 C# Exceptions

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

    -

    21.5.1 C# exception example using "check" typemap

    +

    22.5.1 C# exception example using "check" typemap

    @@ -1124,7 +1124,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.

    -

    21.5.2 C# exception example using %exception

    +

    22.5.2 C# exception example using %exception

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

    21.5.3 C# exception example using exception specifications

    +

    22.5.3 C# exception example using exception specifications

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

    -

    21.5.4 Custom C# ApplicationException example

    +

    22.5.4 Custom C# ApplicationException example

    @@ -1379,7 +1379,7 @@ try { -

    21.6 C# Directors

    +

    22.6 C# Directors

    @@ -1392,7 +1392,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.

    -

    21.6.1 Directors example

    +

    22.6.1 Directors example

    @@ -1513,7 +1513,7 @@ CSharpDerived - UIntMethod(123) -

    21.6.2 Directors implementation

    +

    22.6.2 Directors implementation

    @@ -1721,7 +1721,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    21.6.3 Director caveats

    +

    22.6.3 Director caveats

    @@ -1769,7 +1769,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.

    -

    21.7 Multiple modules

    +

    22.7 Multiple modules

    @@ -1804,7 +1804,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    21.8 C# Typemap examples

    +

    22.8 C# Typemap examples

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

    21.8.1 Memory management when returning references to member variables

    +

    22.8.1 Memory management when returning references to member variables

    @@ -1936,7 +1936,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

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

    +

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

    @@ -2068,7 +2068,7 @@ as mentioned earlier, setElement is actually: -

    21.8.3 Date marshalling using the csin typemap and associated attributes

    +

    22.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2354,7 +2354,7 @@ public class example { -

    21.8.4 A date example demonstrating marshalling of C# properties

    +

    22.8.4 A date example demonstrating marshalling of C# properties

    @@ -2454,7 +2454,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    21.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2516,7 +2516,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    21.8.6 Turning proxy classes into partial classes

    +

    22.8.6 Turning proxy classes into partial classes

    @@ -2616,7 +2616,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.

    -

    21.8.7 Turning proxy classes into sealed classes

    +

    22.8.7 Turning proxy classes into sealed classes

    @@ -2706,7 +2706,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    21.8.8 Extending proxy classes with additional C# code

    +

    22.8.8 Extending proxy classes with additional C# code

    @@ -2745,7 +2745,7 @@ public class ExtendMe : global::System.IDisposable { -

    21.8.9 Underlying type for enums

    +

    22.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 5218cc0d9..fbfc7d751 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -340,7 +340,22 @@ -

    8 SWIG and C++17

    +

    8 SWIG and C++14

    + + + + + +

    9 SWIG and C++17

    @@ -356,7 +371,7 @@
    -

    9 Preprocessing

    +

    10 Preprocessing

    @@ -379,7 +394,7 @@
    -

    10 SWIG library

    +

    11 SWIG library

    @@ -422,7 +437,7 @@
    -

    11 Argument Handling

    +

    12 Argument Handling

    @@ -445,7 +460,7 @@
    -

    12 Typemaps

    +

    13 Typemaps

    @@ -539,7 +554,7 @@
    -

    13 Customization Features

    +

    14 Customization Features

    @@ -567,7 +582,7 @@
    -

    14 Contracts

    +

    15 Contracts

    @@ -580,7 +595,7 @@
    -

    15 Variable Length Arguments

    +

    16 Variable Length Arguments

    @@ -598,7 +613,7 @@
    -

    16 SWIG and Doxygen Translation

    +

    17 SWIG and Doxygen Translation

    @@ -642,7 +657,7 @@
    -

    17 Warning Messages

    +

    18 Warning Messages

    @@ -671,7 +686,7 @@
    -

    18 Working with Modules

    +

    19 Working with Modules

    @@ -687,7 +702,7 @@
    -

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

    +

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

    @@ -713,7 +728,7 @@
    -

    20 SWIG and Android

    +

    21 SWIG and Android

    @@ -731,7 +746,7 @@
    -

    21 SWIG and C#

    +

    22 SWIG and C#

    @@ -779,7 +794,7 @@
    -

    22 SWIG and D

    +

    23 SWIG and D

    @@ -813,7 +828,7 @@
    -

    23 SWIG and Go

    +

    24 SWIG and Go

    @@ -857,7 +872,7 @@
    -

    24 SWIG and Guile

    +

    25 SWIG and Guile

    @@ -893,7 +908,7 @@
    -

    25 SWIG and Java

    +

    26 SWIG and Java

    @@ -1047,7 +1062,7 @@
    -

    26 SWIG and Javascript

    +

    27 SWIG and Javascript

    @@ -1089,7 +1104,7 @@
    -

    27 SWIG and Lua

    +

    28 SWIG and Lua

    @@ -1157,61 +1172,6 @@
    -

    28 SWIG and Ocaml

    - - - - -

    29 SWIG and Octave

    @@ -1812,7 +1772,62 @@ -

    38 Extending SWIG to support new languages

    +

    38 SWIG and OCaml

    + + + + + +

    39 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index 2394db25e..93fb8c003 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -7,7 +7,7 @@ -

    14 Contracts

    +

    15 Contracts

      @@ -39,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      14.1 The %contract directive

      +

      15.1 The %contract directive

      @@ -95,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    14.2 %contract and classes

    +

    15.2 %contract and classes

    @@ -174,7 +174,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    14.3 Constant aggregation and %aggregate_check

    +

    15.3 Constant aggregation and %aggregate_check

    @@ -263,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    14.4 Notes

    +

    15.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 27a291d0c..328bc2391 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -7,7 +7,7 @@ -

    13 Customization Features

    +

    14 Customization Features

    -

    13.1.4 Exception handlers for variables

    +

    14.1.4 Exception handlers for variables

    @@ -305,7 +305,7 @@ The %allowexception feature works like any other feature and so can be

    -

    13.1.5 Defining different exception handlers

    +

    14.1.5 Defining different exception handlers

    @@ -442,7 +442,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    13.1.6 Special variables for %exception

    +

    14.1.6 Special variables for %exception

    @@ -545,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    13.1.7 Using The SWIG exception library

    +

    14.1.7 Using The SWIG exception library

    @@ -600,7 +600,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    13.2 Object ownership and %newobject

    +

    14.2 Object ownership and %newobject

    @@ -757,7 +757,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    13.3 Features and the %feature directive

    +

    14.3 Features and the %feature directive

    @@ -839,7 +839,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    13.3.1 Feature attributes

    +

    14.3.1 Feature attributes

    @@ -880,7 +880,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    13.3.2 Feature flags

    +

    14.3.2 Feature flags

    @@ -978,7 +978,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    13.3.3 Clearing features

    +

    14.3.3 Clearing features

    @@ -1071,7 +1071,7 @@ The three macros below show this for the "except" feature: -

    13.3.4 Features and default arguments

    +

    14.3.4 Features and default arguments

    @@ -1146,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    13.3.5 Feature example

    +

    14.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index 1a317a005..a252650ff 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    22 SWIG and D

    +

    23 SWIG and D

      @@ -41,7 +41,7 @@ -

      22.1 Introduction

      +

      23.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      22.2 Command line invocation

      +

      23.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      22.3 Typemaps

      +

      23.3 Typemaps

      -

      22.3.1 C# <-> D name comparison

      +

      23.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    22.3.2 ctype, imtype, dtype

    +

    23.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    22.3.3 in, out, directorin, directorout

    +

    23.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    22.3.4 din, dout, ddirectorin, ddirectorout

    +

    23.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

    22.3.5 typecheck typemaps

    +

    23.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    22.3.6 Code injection typemaps

    +

    23.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    22.3.7 Special variable macros

    +

    23.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    22.4 D and %feature

    +

    23.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    22.5 Pragmas

    +

    23.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    22.6 D Exceptions

    +

    23.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    22.7 D Directors

    +

    23.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    22.8 Other features

    +

    23.8 Other features

    -

    22.8.1 Extended namespace support (nspace)

    +

    23.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    22.8.2 Native pointer support

    +

    23.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    22.8.3 Operator overloading

    +

    23.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    22.8.4 Running the test-suite

    +

    23.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    22.9 D Typemap examples

    +

    23.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    22.10 Work in progress and planned features

    +

    23.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 1e9bbb977..b14b05ba3 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

    16 SWIG and Doxygen Translation

    +

    17 SWIG and Doxygen Translation

    -

    16.2.2.4 doxygen:nolinktranslate

    +

    17.2.2.4 doxygen:nolinktranslate

    @@ -425,7 +425,7 @@ This is only applicable to Java at the moment.

    -

    16.2.2.5 doxygen:nostripparams

    +

    17.2.2.5 doxygen:nostripparams

    @@ -435,14 +435,14 @@ This is only applicable to Java at the moment.

    -

    16.2.3 Additional command line options

    +

    17.2.3 Additional command line options

    ALSO TO BE ADDED (Javadoc auto brief?)

    -

    16.3 Doxygen to Javadoc

    +

    17.3 Doxygen to Javadoc

    @@ -451,7 +451,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

    -

    16.3.1 Basic example

    +

    17.3.1 Basic example

    @@ -558,7 +558,7 @@ Javadoc translator features summary directives):

    -

    16.3.2 Javadoc tags

    +

    17.3.2 Javadoc tags

    @@ -812,7 +812,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    16.3.3 Unsupported tags

    +

    17.3.3 Unsupported tags

    @@ -1048,14 +1048,14 @@ comment, the whole comment block is ignored: -

    16.3.4 Further details

    +

    17.3.4 Further details

    TO BE ADDED.

    -

    16.4 Doxygen to Pydoc

    +

    17.4 Doxygen to Pydoc

    @@ -1066,7 +1066,7 @@ Doxygen or Javadoc, so most of Doxygen commands are translated by merely copying the appropriate command text.

    -

    16.4.1 Basic example

    +

    17.4.1 Basic example

    @@ -1229,7 +1229,7 @@ docs), you may want to use some tool like doxypy to do the work.

    -

    16.4.2 Pydoc translator

    +

    17.4.2 Pydoc translator

    @@ -1443,7 +1443,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    16.4.3 Unsupported tags

    +

    17.4.3 Unsupported tags

    @@ -1627,21 +1627,21 @@ Here is the list of these tags: -

    16.4.4 Further details

    +

    17.4.4 Further details

    TO BE ADDED.

    -

    16.5 Developer information

    +

    17.5 Developer information

    This section contains information for developers enhancing the Doxygen translator.

    -

    16.5.1 Doxygen translator design

    +

    17.5.1 Doxygen translator design

    @@ -1667,7 +1667,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

    -

    16.5.2 Debugging the Doxygen parser and translator

    +

    17.5.2 Debugging the Doxygen parser and translator

    @@ -1680,7 +1680,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

    16.5.3 Tests

    +

    17.5.3 Tests

    @@ -1732,7 +1732,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

    -

    16.6 Extending to other languages

    +

    17.6 Extending to other languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 1d9fc83ac..1deb1cb12 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    38 Extending SWIG to support new languages

    +

    39 Extending SWIG to support new languages

    -

    38.4.4 Attribute namespaces

    +

    39.4.4 Attribute namespaces

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

    -

    38.4.5 Symbol Tables

    +

    39.4.5 Symbol Tables

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

    38.4.6 The %feature directive

    +

    39.4.6 The %feature directive

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

    -

    38.4.7 Code Generation

    +

    39.4.7 Code Generation

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

    -

    38.4.8 SWIG and XML

    +

    39.4.8 SWIG and XML

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

    -

    38.5 Primitive Data Structures

    +

    39.5 Primitive Data Structures

    @@ -993,7 +993,7 @@ typedef Hash Typetab; -

    38.5.1 Strings

    +

    39.5.1 Strings

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

    38.5.2 Hashes

    +

    39.5.2 Hashes

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

    38.5.3 Lists

    +

    39.5.3 Lists

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

    38.5.4 Common operations

    +

    39.5.4 Common operations

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

    38.5.5 Iterating over Lists and Hashes

    +

    39.5.5 Iterating over Lists and Hashes

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

    38.5.6 I/O

    +

    39.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1534,7 +1534,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    38.6 Navigating and manipulating parse trees

    +

    39.6 Navigating and manipulating parse trees

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

    38.7 Working with attributes

    +

    39.7 Working with attributes

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

    38.8 Type system

    +

    39.8 Type system

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

    -

    38.8.1 String encoding of types

    +

    39.8.1 String encoding of types

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

    -

    38.8.2 Type construction

    +

    39.8.2 Type construction

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

    38.8.3 Type tests

    +

    39.8.3 Type tests

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

    38.8.4 Typedef and inheritance

    +

    39.8.4 Typedef and inheritance

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

    38.8.5 Lvalues

    +

    39.8.5 Lvalues

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

    38.8.6 Output functions

    +

    39.8.6 Output functions

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

    38.9 Parameters

    +

    39.9 Parameters

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

    38.10 Writing a Language Module

    +

    39.10 Writing a Language Module

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

    -

    38.10.1 Execution model

    +

    39.10.1 Execution model

    @@ -2476,7 +2476,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.

    -

    38.10.2 Starting out

    +

    39.10.2 Starting out

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

    -

    38.10.3 Command line options

    +

    39.10.3 Command line options

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

    -

    38.10.4 Configuration and preprocessing

    +

    39.10.4 Configuration and preprocessing

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

    -

    38.10.5 Entry point to code generation

    +

    39.10.5 Entry point to code generation

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

    38.10.6 Module I/O and wrapper skeleton

    +

    39.10.6 Module I/O and wrapper skeleton

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

    38.10.7 Low-level code generators

    +

    39.10.7 Low-level code generators

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

    -

    38.10.8 Configuration files

    +

    39.10.8 Configuration files

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

    38.10.9 Runtime support

    +

    39.10.9 Runtime support

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

    -

    38.10.10 Standard library files

    +

    39.10.10 Standard library files

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

    -

    38.10.11 User examples

    +

    39.10.11 User examples

    @@ -3253,7 +3253,7 @@ during this process, see the section on .

    -

    38.10.12 Test driven development and the test-suite

    +

    39.10.12 Test driven development and the test-suite

    @@ -3312,7 +3312,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    38.10.12.1 Running the test-suite

    +

    39.10.12.1 Running the test-suite

    @@ -3504,7 +3504,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    38.10.13 Documentation

    +

    39.10.13 Documentation

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

    38.10.14 Coding style guidelines

    +

    39.10.14 Coding style guidelines

    @@ -3561,7 +3561,7 @@ should be avoided as unlike the SWIG developers, users will never have consisten

    -

    38.10.15 Target language status

    +

    39.10.15 Target language status

    @@ -3570,7 +3570,7 @@ the Target language in This section provides more details on how this status is given.

    -

    38.10.15.1 Supported status

    +

    39.10.15.1 Supported status

    @@ -3617,7 +3617,7 @@ A target language is given the 'Supported' status when

  • -

    38.10.15.2 Experimental status

    +

    39.10.15.2 Experimental status

    @@ -3682,7 +3682,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat -

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

    +

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

    @@ -3746,7 +3746,7 @@ the existing tests.

    -

    38.11 Debugging Options

    +

    39.11 Debugging Options

    @@ -3773,7 +3773,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    38.12 Guide to parse tree nodes

    +

    39.12 Guide to parse tree nodes

    @@ -4181,7 +4181,7 @@ extern "X" { ... } declaration. -

    38.13 Further Development Information

    +

    39.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 8523f74aa..4a60e45e0 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    23 SWIG and Go

    +

    24 SWIG and Go

    -

    23.3.1 Go-specific Commandline Options

    +

    24.3.1 Go-specific Commandline Options

    @@ -264,7 +264,7 @@ swig -go -help -

    23.3.2 Generated Wrapper Files

    +

    24.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -308,7 +308,7 @@ combined with the compiled MODULE.go using go tool pack. -

    23.4 A tour of basic C/C++ wrapping

    +

    24.4 A tour of basic C/C++ wrapping

    @@ -318,7 +318,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    23.4.1 Go Package Name

    +

    24.4.1 Go Package Name

    @@ -328,7 +328,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    23.4.2 Go Names

    +

    24.4.2 Go Names

    @@ -360,7 +360,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    23.4.3 Go Constants

    +

    24.4.3 Go Constants

    @@ -368,7 +368,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    23.4.4 Go Enumerations

    +

    24.4.4 Go Enumerations

    @@ -378,7 +378,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    23.4.5 Go Classes

    +

    24.4.5 Go Classes

    @@ -456,7 +456,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    23.4.5.1 Go Class Memory Management

    +

    24.4.5.1 Go Class Memory Management

    @@ -578,7 +578,7 @@ func (o *GoClassName) Close() { -

    23.4.5.2 Go Class Inheritance

    +

    24.4.5.2 Go Class Inheritance

    @@ -590,7 +590,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    23.4.6 Go Templates

    +

    24.4.6 Go Templates

    @@ -599,7 +599,7 @@ wrappers for a particular template instantation. To do this, use the %template directive. -

    23.4.7 Go Director Classes

    +

    24.4.7 Go Director Classes

    @@ -617,7 +617,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    23.4.7.1 Example C++ code

    +

    24.4.7.1 Example C++ code

    @@ -689,7 +689,7 @@ be found in the end of the guide.

    -

    23.4.7.2 Enable director feature

    +

    24.4.7.2 Enable director feature

    @@ -724,7 +724,7 @@ documentation on directors.

    -

    23.4.7.3 Constructor and destructor

    +

    24.4.7.3 Constructor and destructor

    @@ -777,7 +777,7 @@ embedding.

    -

    23.4.7.4 Override virtual methods

    +

    24.4.7.4 Override virtual methods

    @@ -843,7 +843,7 @@ the Go methods.

    -

    23.4.7.5 Call base methods

    +

    24.4.7.5 Call base methods

    @@ -880,7 +880,7 @@ be found in the end of the guide.

    -

    23.4.7.6 Subclass via embedding

    +

    24.4.7.6 Subclass via embedding

    @@ -948,7 +948,7 @@ class.

    -

    23.4.7.7 Memory management with runtime.SetFinalizer

    +

    24.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1013,7 +1013,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    23.4.7.8 Complete FooBarGo example class

    +

    24.4.7.8 Complete FooBarGo example class

    @@ -1142,7 +1142,7 @@ SWIG/Examples/go/director/.

    -

    23.4.8 Default Go primitive type mappings

    +

    24.4.8 Default Go primitive type mappings

    @@ -1249,7 +1249,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    23.4.9 Output arguments

    +

    24.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1302,7 +1302,7 @@ void f(char *output); -

    23.4.10 Adding additional go code

    +

    24.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1397,7 +1397,7 @@ func bar() { -

    23.4.11 Go typemaps

    +

    24.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 6acdd2dc3..31d822599 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    24 SWIG and Guile

    +

    25 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      24.1 Supported Guile Versions

      +

      25.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      24.2 Meaning of "Module"

      +

      25.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      24.3 Old GH Guile API

      +

      25.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      24.4 Linkage

      +

      25.4 Linkage

      @@ -89,7 +89,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. -

      24.4.1 Simple Linkage

      +

      25.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      24.4.2 Passive Linkage

      +

      25.4.2 Passive Linkage

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

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

      24.4.3 Native Guile Module Linkage

      +

      25.4.3 Native Guile Module Linkage

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

    -

    24.4.4 Old Auto-Loading Guile Module Linkage

    +

    25.4.4 Old Auto-Loading Guile Module Linkage

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

    24.4.5 Hobbit4D Linkage

    +

    25.4.5 Hobbit4D Linkage

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

    -

    24.5 Underscore Folding

    +

    25.5 Underscore Folding

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

    24.6 Typemaps

    +

    25.6 Typemaps

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

    -

    24.7 Representation of pointers as smobs

    +

    25.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    24.7.1 Smobs

    +

    25.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    24.7.2 Garbage Collection

    +

    25.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 24.8 Native Guile pointers +

    25.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    24.9 Exception Handling

    +

    25.9 Exception Handling

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

    24.10 Procedure documentation

    +

    25.10 Procedure documentation

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

    24.11 Procedures with setters

    +

    25.11 Procedures with setters

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

    24.12 GOOPS Proxy Classes

    +

    25.12 GOOPS Proxy Classes

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

    -

    24.12.1 Naming Issues

    +

    25.12.1 Naming Issues

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

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    24.12.2 Linking

    +

    25.12.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 77a81995e..4c7b6d058 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    25 SWIG and Java

    +

    26 SWIG and Java

    -

    25.3.3 Global variables

    +

    26.3.3 Global variables

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

    25.3.4 Constants

    +

    26.3.4 Constants

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

    -

    25.3.5 Enumerations

    +

    26.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    25.3.5.1 Anonymous enums

    +

    26.3.5.1 Anonymous enums

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

    -

    25.3.5.2 Typesafe enums

    +

    26.3.5.2 Typesafe enums

    @@ -1127,7 +1127,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.

    -

    25.3.5.3 Proper Java enums

    +

    26.3.5.3 Proper Java enums

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

    -

    25.3.5.4 Type unsafe enums

    +

    26.3.5.4 Type unsafe enums

    @@ -1228,7 +1228,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.

    -

    25.3.5.5 Simple enums

    +

    26.3.5.5 Simple enums

    @@ -1247,7 +1247,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.

    -

    25.3.6 Pointers

    +

    26.3.6 Pointers

    @@ -1335,7 +1335,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.

    -

    25.3.7 Structures

    +

    26.3.7 Structures

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

    25.3.8 C++ classes

    +

    26.3.8 C++ classes

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

    25.3.9 C++ inheritance

    +

    26.3.9 C++ inheritance

    @@ -1627,7 +1627,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.

    -

    25.3.10 Pointers, references, arrays and pass by value

    +

    26.3.10 Pointers, references, arrays and pass by value

    @@ -1682,7 +1682,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).

    -

    25.3.10.1 Null pointers

    +

    26.3.10.1 Null pointers

    @@ -1706,7 +1706,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.

    -

    25.3.11 C++ overloaded functions

    +

    26.3.11 C++ overloaded functions

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

    25.3.12 C++ default arguments

    +

    26.3.12 C++ default arguments

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

    -

    25.3.13 C++ namespaces

    +

    26.3.13 C++ namespaces

    @@ -1954,7 +1954,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    25.3.14 C++ templates

    +

    26.3.14 C++ templates

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

    -

    25.3.15 C++ Smart Pointers

    +

    26.3.15 C++ Smart Pointers

    -

    25.3.15.1 The shared_ptr Smart Pointer

    +

    26.3.15.1 The shared_ptr Smart Pointer

    @@ -2017,7 +2017,7 @@ in the shared_ptr smart pointer -

    25.3.15.2 Generic Smart Pointers

    +

    26.3.15.2 Generic Smart Pointers

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

    25.4 Further details on the generated Java classes

    +

    26.4 Further details on the generated Java classes

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

    -

    25.4.1 The intermediary JNI class

    +

    26.4.1 The intermediary JNI class

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

    -

    25.4.1.1 The intermediary JNI class pragmas

    +

    26.4.1.1 The intermediary JNI class pragmas

    @@ -2318,7 +2318,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    25.4.2 The Java module class

    +

    26.4.2 The Java module class

    @@ -2349,7 +2349,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.

    -

    25.4.2.1 The Java module class pragmas

    +

    26.4.2.1 The Java module class pragmas

    @@ -2400,7 +2400,7 @@ See The intermediary JNI class pragmas secti

    -

    25.4.3 Java proxy classes

    +

    26.4.3 Java proxy classes

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

    25.4.3.1 Memory management

    +

    26.4.3.1 Memory management

    @@ -2638,7 +2638,7 @@ and

    -

    25.4.3.2 Inheritance

    +

    26.4.3.2 Inheritance

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

    26.4.3.3 Proxy classes and garbage collection

    @@ -2837,7 +2837,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.

    -

    25.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2959,7 +2959,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    25.4.3.5 Single threaded applications and thread safety

    +

    26.4.3.5 Single threaded applications and thread safety

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

    25.4.4 Type wrapper classes

    +

    26.4.4 Type wrapper classes

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

    25.4.5 Enum classes

    +

    26.4.5 Enum classes

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

    -

    25.4.5.1 Typesafe enum classes

    +

    26.4.5.1 Typesafe enum classes

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

    -

    25.4.5.2 Proper Java enum classes

    +

    26.4.5.2 Proper Java enum classes

    @@ -3305,7 +3305,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.

    -

    25.4.5.3 Type unsafe enum classes

    +

    26.4.5.3 Type unsafe enum classes

    @@ -3336,7 +3336,7 @@ public final class Beverage { -

    25.4.6 Interfaces

    +

    26.4.6 Interfaces

    @@ -3581,7 +3581,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    25.5 Cross language polymorphism using directors

    +

    26.5 Cross language polymorphism using directors

    @@ -3603,7 +3603,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.

    -

    25.5.1 Enabling directors

    +

    26.5.1 Enabling directors

    @@ -3671,7 +3671,7 @@ public: -

    25.5.2 Director classes

    +

    26.5.2 Director classes

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

    -

    25.5.3 Overhead and code bloat

    +

    26.5.3 Overhead and code bloat

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

    -

    25.5.4 Simple directors example

    +

    26.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    25.5.5 Director threading issues

    +

    26.5.5 Director threading issues

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

    25.5.6 Director performance tuning

    +

    26.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    25.5.7 Java exceptions from directors

    +

    26.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    25.5.7.1 Customizing director exceptions

    +

    26.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    25.6 Accessing protected members

    +

    26.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    25.7 Common customization features

    +

    26.7 Common customization features

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

    -

    25.7.1 C/C++ helper functions

    +

    26.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    25.7.2 Class extension with %extend

    +

    26.7.2 Class extension with %extend

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

    -

    25.7.3 Class extension with %proxycode

    +

    26.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    25.7.4 Exception handling with %exception and %javaexception

    +

    26.7.4 Exception handling with %exception and %javaexception

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

    -

    25.7.5 Method access with %javamethodmodifiers

    +

    26.7.5 Method access with %javamethodmodifiers

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

    25.8 Tips and techniques

    +

    26.8 Tips and techniques

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

    -

    25.8.1 Input and output parameters using primitive pointers and references

    +

    26.8.1 Input and output parameters using primitive pointers and references

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

    -

    25.8.2 Simple pointers

    +

    26.8.2 Simple pointers

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

    -

    25.8.3 Wrapping C arrays with Java arrays

    +

    26.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    25.8.4 Unbounded C Arrays

    +

    26.8.4 Unbounded C Arrays

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

    -

    25.8.5 Binary data vs Strings

    +

    26.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    25.8.6 Overriding new and delete to allocate from Java heap

    +

    26.8.6 Overriding new and delete to allocate from Java heap

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

    -

    25.9 Java typemaps

    +

    26.9 Java typemaps

    @@ -5657,7 +5657,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. -

    25.9.1 Default primitive type mappings

    +

    26.9.1 Default primitive type mappings

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

    -

    25.9.2 Default typemaps for non-primitive types

    +

    26.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    25.9.3 Sixty four bit JVMs

    +

    26.9.3 Sixty four bit JVMs

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

    -

    25.9.4 What is a typemap?

    +

    26.9.4 What is a typemap?

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

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

    +

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

    @@ -6240,7 +6240,7 @@ These are listed below: -

    25.9.6 Java typemap attributes

    +

    26.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    25.9.7 Java special variables

    +

    26.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    25.9.8 Typemaps for both C and C++ compilation

    +

    26.9.8 Typemaps for both C and C++ compilation

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

    -

    25.9.9 Java code typemaps

    +

    26.9.9 Java code typemaps

    @@ -6801,7 +6801,7 @@ to make the method and constructor public: -

    25.9.10 Director specific typemaps

    +

    26.9.10 Director specific typemaps

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

    25.10 Typemap Examples

    +

    26.10 Typemap Examples

    @@ -7088,7 +7088,7 @@ the SWIG library.

    -

    25.10.1 Simpler Java enums for enums without initializers

    +

    26.10.1 Simpler Java enums for enums without initializers

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

    -

    25.10.2 Handling C++ exception specifications as Java exceptions

    +

    26.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    25.10.3 NaN Exception - exception handling for a particular type

    +

    26.10.3 NaN Exception - exception handling for a particular type

    @@ -7447,7 +7447,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.

    -

    25.10.4 Converting Java String arrays to char **

    +

    26.10.4 Converting Java String arrays to char **

    @@ -7591,7 +7591,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    25.10.5 Expanding a Java object to multiple arguments

    +

    26.10.5 Expanding a Java object to multiple arguments

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

    25.10.6 Using typemaps to return arguments

    +

    26.10.6 Using typemaps to return arguments

    @@ -7791,7 +7791,7 @@ $ java runme 1 12.0 340.0 -

    25.10.7 Adding Java downcasts to polymorphic return types

    +

    26.10.7 Adding Java downcasts to polymorphic return types

    @@ -7997,7 +7997,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.

    -

    25.10.8 Adding an equals method to the Java classes

    +

    26.10.8 Adding an equals method to the Java classes

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

    25.10.9 Void pointers and a common Java base class

    +

    26.10.9 Void pointers and a common Java base class

    @@ -8100,7 +8100,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. -

    25.10.10 Struct pointer to pointer

    +

    26.10.10 Struct pointer to pointer

    @@ -8280,7 +8280,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.

    -

    25.10.11 Memory management when returning references to member variables

    +

    26.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

    @@ -8531,7 +8531,7 @@ as mentioned earlier, setElement is actually: -

    25.10.13 Date marshalling using the javain typemap and associated attributes

    +

    26.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8708,7 +8708,7 @@ A few things to note: -

    25.11 Living with Java Directors

    +

    26.11 Living with Java Directors

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

  • -

    25.12 Odds and ends

    +

    26.12 Odds and ends

    -

    25.12.1 JavaDoc comments

    +

    26.12.1 JavaDoc comments

    @@ -8946,7 +8946,7 @@ public class Barmy { -

    25.12.2 Functional interface without proxy classes

    +

    26.12.2 Functional interface without proxy classes

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

    25.12.3 Using your own JNI functions

    +

    26.12.3 Using your own JNI functions

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

    -

    25.12.4 Performance concerns and hints

    +

    26.12.4 Performance concerns and hints

    @@ -9078,7 +9078,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.

    -

    25.12.5 Debugging

    +

    26.12.5 Debugging

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

    -

    25.13 Java Examples

    +

    26.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 8de528511..c328bbb6b 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    26 SWIG and Javascript

    +

    27 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      26.1 Overview

      +

      27.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      26.2 Preliminaries

      +

      27.2 Preliminaries

      -

      26.2.1 Running SWIG

      +

      27.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      26.2.2 Running Tests and Examples

      +

      27.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    26.2.3 Known Issues

    +

    27.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -170,12 +170,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    26.3 Integration

    +

    27.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    26.3.1 Creating node.js Extensions

    +

    27.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -221,7 +221,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    26.3.1.1 Troubleshooting

    +

    27.3.1.1 Troubleshooting

      @@ -233,12 +233,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      26.3.2 Embedded Webkit

      +

      27.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      26.3.2.1 Mac OS X

      +

      27.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -286,7 +286,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      26.3.2.2 GTK

      +

      27.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -331,7 +331,7 @@ int main(int argc, char* argv[]) } -

      26.3.3 Creating Applications with node-webkit

      +

      27.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -422,12 +422,12 @@ open new windows, and many more things. }; -

      26.4 Examples

      +

      27.4 Examples

      Some basic examples are shown here in more detail.

      -

      26.4.1 Simple

      +

      27.4.1 Simple

      The common example simple looks like this:

      @@ -477,7 +477,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      26.4.2 Class

      +

      27.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -607,12 +607,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      26.5 Implementation

      +

      27.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      26.5.1 Source Code

      +

      27.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -713,7 +713,7 @@ Template::Template(const String *code_) { ... } ... -

      26.5.2 Code Templates

      +

      27.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -752,7 +752,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      26.5.3 Emitter

      +

      27.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -871,7 +871,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      26.5.4 Emitter states

      +

      27.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -915,7 +915,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      26.5.5 Handling Exceptions in JavascriptCore

      +

      27.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index c2c02fc7d..4ef6aeb83 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -7,7 +7,7 @@ -

      10 SWIG library

      +

      11 SWIG library

      -

      10.2.4 cdata.i

      +

      11.2.4 cdata.i

      @@ -769,7 +769,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      10.3 C string handling

      +

      11.3 C string handling

      @@ -789,7 +789,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      10.3.1 Default string handling

      +

      11.3.1 Default string handling

      @@ -830,7 +830,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      10.3.2 Passing binary data

      +

      11.3.2 Passing binary data

      @@ -872,7 +872,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      10.3.3 Using %newobject to release memory

      +

      11.3.3 Using %newobject to release memory

      @@ -913,7 +913,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      10.3.4 cstring.i

      +

      11.3.4 cstring.i

      @@ -1373,7 +1373,7 @@ structure or class instead.

    -

    10.4 STL/C++ library

    +

    11.4 STL/C++ library

    @@ -1420,7 +1420,7 @@ Please look for the library files in the appropriate language library directory.

    -

    10.4.1 std::string

    +

    11.4.1 std::string

    @@ -1504,7 +1504,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    10.4.2 std::vector

    +

    11.4.2 std::vector

    @@ -1683,7 +1683,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    10.4.3 STL exceptions

    +

    11.4.3 STL exceptions

    @@ -1733,10 +1733,10 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    10.4.4 shared_ptr smart pointer

    +

    11.4.4 shared_ptr smart pointer

    -

    10.4.4.1 shared_ptr basics

    +

    11.4.4.1 shared_ptr basics

    @@ -1832,7 +1832,7 @@ System.out.println(val1 + " " + val2); -

    10.4.4.2 shared_ptr and inheritance

    +

    11.4.4.2 shared_ptr and inheritance

    @@ -1923,7 +1923,7 @@ Adding the missing %shared_ptr macros will fix this: -

    10.4.4.3 shared_ptr and method overloading

    +

    11.4.4.3 shared_ptr and method overloading

    @@ -1945,7 +1945,7 @@ SWIG will choose to wrap just the first method by default. For the interested reader, SWIG detects that they are equivalent types via the typecheck typemaps in the shared_ptr library.

    -

    10.4.4.4 shared_ptr and templates

    +

    11.4.4.4 shared_ptr and templates

    @@ -1987,7 +1987,7 @@ The SWIG code below shows the required ordering: -

    10.4.4.5 shared_ptr and directors

    +

    11.4.4.5 shared_ptr and directors

    @@ -1995,7 +1995,7 @@ The languages that support shared_ptr also have support for using shared_ptr wit

    -

    10.4.5 auto_ptr smart pointer

    +

    11.4.5 auto_ptr smart pointer

    @@ -2044,10 +2044,10 @@ int value = k.getValue(); -

    10.5 Utility Libraries

    +

    11.5 Utility Libraries

    -

    10.5.1 exception.i

    +

    11.5.1 exception.i

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 90bcc5a00..0fa1ecb13 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

    27 SWIG and Lua

    +

    28 SWIG and Lua

      @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      27.1 Preliminaries

      +

      28.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      27.2 Running SWIG

      +

      28.2 Running SWIG

      @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      27.2.1 Additional command line options

      +

      28.2.1 Additional command line options

      @@ -179,7 +179,7 @@ swig -lua -help -

      27.2.2 Compiling and Linking and Interpreter

      +

      28.2.2 Compiling and Linking and Interpreter

      @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      27.2.3 Compiling a dynamic module

      +

      28.2.3 Compiling a dynamic module

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

      27.2.4 Using your module

      +

      28.2.4 Using your module

      @@ -336,19 +336,19 @@ $ ./my_lua >

    -

    27.3 A tour of basic C/C++ wrapping

    +

    28.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.

    -

    27.3.1 Modules

    +

    28.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.

    -

    27.3.2 Functions

    +

    28.3.2 Functions

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

    27.3.3 Global variables

    +

    28.3.3 Global variables

    @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    27.3.4 Constants and enums

    +

    28.3.4 Constants and enums

    @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    27.3.4.1 Constants/enums and classes/structures

    +

    28.3.4.1 Constants/enums and classes/structures

    @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    27.3.5 Pointers

    +

    28.3.5 Pointers

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

    27.3.6 Structures

    +

    28.3.6 Structures

    @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    27.3.7 C++ classes

    +

    28.3.7 C++ classes

    @@ -785,7 +785,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    27.3.8 C++ inheritance

    +

    28.3.8 C++ inheritance

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

    It is safe to use multiple inheritance with SWIG.

    -

    27.3.9 Pointers, references, values, and arrays

    +

    28.3.9 Pointers, references, values, and arrays

    @@ -841,7 +841,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.

    -

    27.3.10 C++ overloaded functions

    +

    28.3.10 C++ overloaded functions

    @@ -927,7 +927,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.

    -

    27.3.11 C++ operators

    +

    28.3.11 C++ operators

    @@ -1059,7 +1059,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    27.3.12 Class extension with %extend

    +

    28.3.12 Class extension with %extend

    @@ -1116,7 +1116,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).

    -

    27.3.13 Using %newobject to release memory

    +

    28.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1140,7 +1140,7 @@ char *foo();

    This will release the allocated memory.

    -

    27.3.14 C++ templates

    +

    28.3.14 C++ templates

    @@ -1175,7 +1175,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.

    -

    27.3.15 C++ Smart Pointers

    +

    28.3.15 C++ Smart Pointers

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

    27.3.16 C++ Exceptions

    +

    28.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    27.3.17 Namespaces

    +

    28.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    27.3.17.1 Compatibility Note

    +

    28.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    27.3.17.2 Names

    +

    28.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    27.3.17.3 Inheritance

    +

    28.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    27.4 Typemaps

    +

    28.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    27.4.1 What is a typemap?

    +

    28.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:

    @@ -1555,7 +1555,7 @@ Received an integer : 6 720 -

    27.4.2 Using typemaps

    +

    28.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.

    @@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);

    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).

    -

    27.4.3 Typemaps and arrays

    +

    28.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 @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

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

    -

    27.4.4 Typemaps and pointer-pointer functions

    +

    28.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:

    @@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    27.5 Writing typemaps

    +

    28.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.

    @@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    27.5.1 Typemaps you can write

    +

    28.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.

    @@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    27.5.2 SWIG's Lua-C API

    +

    28.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.

    @@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    27.6 Customization of your Bindings

    +

    28.6 Customization of your Bindings

    @@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -

    27.6.1 Writing your own custom wrappers

    +

    28.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    27.6.2 Adding additional Lua code

    +

    28.6.2 Adding additional Lua code

    @@ -1843,7 +1843,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.

    -

    27.7 Details on the Lua binding

    +

    28.7 Details on the Lua binding

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

    -

    27.7.1 Binding global data into the module.

    +

    28.7.1 Binding global data into the module.

    @@ -1914,7 +1914,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)'.

    -

    27.7.2 Userdata and Metatables

    +

    28.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    27.7.3 Memory management

    +

    28.7.3 Memory management

    diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 19b69e5f4..7efd74e2b 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -7,7 +7,7 @@ -

    18 Working with Modules

    +

    19 Working with Modules

    -

    28.2.2.1 Enum typing in Ocaml

    +

    38.2.2.1 Enum typing in Ocaml

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

    -

    28.2.3 Arrays

    +

    38.2.3 Arrays

    -

    28.2.3.1 Simple types of bounded arrays

    +

    38.2.3.1 Simple types of bounded arrays

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

    -

    28.2.3.2 Complex and unbounded arrays

    +

    38.2.3.2 Complex and unbounded arrays

    @@ -514,7 +514,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.

    -

    28.2.3.3 Using an object

    +

    38.2.3.3 Using an object

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

    -

    28.2.3.4 Example typemap for a function taking float * and int

    +

    38.2.3.4 Example typemap for a function taking float * and int

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

    28.2.4 C++ Classes

    +

    38.2.4 C++ Classes

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

    -

    28.2.4.1 STL vector and string Example

    +

    38.2.4.1 STL vector and string Example

    @@ -702,7 +702,7 @@ baz # -

    28.2.4.2 C++ Class Example

    +

    38.2.4.2 C++ Class Example

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

    28.2.4.3 Compiling the example

    +

    38.2.4.3 Compiling the example

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

    28.2.4.4 Sample Session

    +

    38.2.4.4 Sample Session

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

    -

    28.2.5 Director Classes

    +

    38.2.5 Director Classes

    -

    28.2.5.1 Director Introduction

    +

    38.2.5.1 Director Introduction

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

    -

    28.2.5.2 Overriding Methods in Ocaml

    +

    38.2.5.2 Overriding Methods in Ocaml

    @@ -835,7 +835,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.

    -

    28.2.5.3 Director Usage Example

    +

    38.2.5.3 Director Usage Example

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

    -

    28.2.5.4 Creating director objects

    +

    38.2.5.4 Creating director objects

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

    -

    28.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    38.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -948,7 +948,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.

    -

    28.2.5.6 typemap

    +

    38.2.5.6 typemap

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

    -

    28.2.5.7 directorout typemap

    +

    38.2.5.7 directorout typemap

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

    -

    28.2.5.8 directorargout typemap

    +

    38.2.5.8 directorargout typemap

    @@ -987,7 +987,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.

    -

    28.2.6 Exceptions

    +

    38.2.6 Exceptions

    @@ -996,7 +996,7 @@ but not too useful example is provided by the throw_exception testcase in Examples/test-suite. You can provide your own exceptions, too.

    -

    28.3 Documentation Features

    +

    38.3 Documentation Features

    @@ -1005,7 +1005,7 @@ comments (colloquially referred to as "docstrings") that can be read by OCamldoc.

    -

    28.3.1 Module docstring

    +

    38.3.1 Module docstring

    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 10efe0c15..1bf59e238 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -7,7 +7,7 @@ -

    9 Preprocessing

    +

    10 Preprocessing

      @@ -38,7 +38,7 @@ However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

      -

      9.1 File inclusion

      +

      10.1 File inclusion

      @@ -64,7 +64,7 @@ By default, the #include is ignored unless you run SWIG with the is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files. -

      9.2 File imports

      +

      10.2 File imports

      @@ -93,7 +93,7 @@ The -importall directive tells SWIG to follow all #include sta as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers. -

      9.3 Conditional Compilation

      +

      10.3 Conditional Compilation

      @@ -151,7 +151,7 @@ SWIG (except for the symbol `SWIG' which is only defined within the SWIG compiler).

      -

      9.4 Macro Expansion

      +

      10.4 Macro Expansion

      @@ -206,7 +206,7 @@ like #x. This is a non-standard SWIG extension.

    -

    9.5 SWIG Macros

    +

    10.5 SWIG Macros

    @@ -252,7 +252,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s support).

    -

    9.6 C99 and GNU Extensions

    +

    10.6 C99 and GNU Extensions

    @@ -308,14 +308,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    9.7 Preprocessing and delimiters

    +

    10.7 Preprocessing and delimiters

    The preprocessor handles { }, " " and %{ %} delimiters differently.

    -

    9.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    +

    10.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -340,7 +340,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    9.7.2 Preprocessing and { ... } delimiters

    +

    10.7.2 Preprocessing and { ... } delimiters

    @@ -382,7 +382,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    9.8 Preprocessor and Typemaps

    +

    10.8 Preprocessor and Typemaps

    @@ -453,7 +453,7 @@ would generate

    -

    9.9 Viewing preprocessor output

    +

    10.9 Viewing preprocessor output

    @@ -463,7 +463,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    9.10 The #error and #warning directives

    +

    10.10 The #error and #warning directives

    diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 1639423af..d34bb2801 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -7,7 +7,7 @@ -

    12 Typemaps

    +

    13 Typemaps

    -

    12.1.7 Similarities to Aspect Oriented Programming

    +

    13.1.7 Similarities to Aspect Oriented Programming

    @@ -686,7 +686,7 @@ SWIG can also be viewed as has having a second set of aspects based around %exception are also cross-cutting concerns as they encapsulate code that can be used to add logging or exception handling to any function.

    -

    12.1.8 The rest of this chapter

    +

    13.1.8 The rest of this chapter

    @@ -706,14 +706,14 @@ of "The C Programming Language" by Kernighan and Ritchie or "The C++ Programming Language" by Stroustrup before going any further.

    -

    12.2 Typemap specifications

    +

    13.2 Typemap specifications

    This section describes the behavior of the %typemap directive itself.

    -

    12.2.1 Defining a typemap

    +

    13.2.1 Defining a typemap

    @@ -826,7 +826,7 @@ Admittedly, it's not the most readable syntax at first glance. However, the pur individual pieces will become clear.

    -

    12.2.2 Typemap scope

    +

    13.2.2 Typemap scope

    @@ -876,7 +876,7 @@ class Foo { -

    12.2.3 Copying a typemap

    +

    13.2.3 Copying a typemap

    @@ -934,7 +934,7 @@ The patterns for %apply follow the same rules as for %typemap. -

    12.2.4 Deleting a typemap

    +

    13.2.4 Deleting a typemap

    @@ -968,7 +968,7 @@ For example: after the clear operation.

    -

    12.2.5 Placement of typemaps

    +

    13.2.5 Placement of typemaps

    @@ -1048,7 +1048,7 @@ It should be noted that for scoping to work, SWIG has to know that stringclass string.

    -

    12.3 Pattern matching rules

    +

    13.3 Pattern matching rules

    @@ -1056,7 +1056,7 @@ The section describes the pattern matching rules by which C/C++ datatypes are as The matching rules can be observed in practice by using the debugging options also described.

    -

    12.3.1 Basic matching rules

    +

    13.3.1 Basic matching rules

    @@ -1155,7 +1155,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5) stripped all qualifiers in one step.

    -

    12.3.2 Typedef reductions matching

    +

    13.3.2 Typedef reductions matching

    @@ -1330,7 +1330,7 @@ void go(Struct aStruct); -

    12.3.3 Default typemap matching rules

    +

    13.3.3 Default typemap matching rules

    @@ -1468,7 +1468,7 @@ Finally the best way to view the typemap matching rules in action is via the -

    12.3.4 Multi-arguments typemaps

    +

    13.3.4 Multi-arguments typemaps

    @@ -1498,7 +1498,7 @@ but all subsequent arguments must match exactly.

    -

    12.3.5 Matching rules compared to C++ templates

    +

    13.3.5 Matching rules compared to C++ templates

    @@ -1657,7 +1657,7 @@ are similar to those for specialized template handling.

    -

    12.3.6 Debugging typemap pattern matching

    +

    13.3.6 Debugging typemap pattern matching

    @@ -1870,7 +1870,7 @@ Also the types may be displayed slightly differently - char const * and -

    12.4 Code generation rules

    +

    13.4 Code generation rules

    @@ -1878,7 +1878,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    12.4.1 Scope

    +

    13.4.1 Scope

    @@ -1956,7 +1956,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    12.4.2 Declaring new local variables

    +

    13.4.2 Declaring new local variables

    @@ -2123,7 +2123,7 @@ each type must have its own local variable declaration. -

    12.4.3 Special variables

    +

    13.4.3 Special variables

    @@ -2375,7 +2375,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    12.4.4 Special variable macros

    +

    13.4.4 Special variable macros

    @@ -2387,7 +2387,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    12.4.4.1 $descriptor(type)

    +

    13.4.4.1 $descriptor(type)

    @@ -2398,7 +2398,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    12.4.4.2 $typemap(method, typepattern)

    +

    13.4.4.2 $typemap(method, typepattern)

    @@ -2456,7 +2456,7 @@ The result is the following expansion -

    12.4.5 Special variables and typemap attributes

    +

    13.4.5 Special variables and typemap attributes

    @@ -2483,7 +2483,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    12.4.6 Special variables combined with special variable macros

    +

    13.4.6 Special variables combined with special variable macros

    @@ -2525,7 +2525,7 @@ which then expands to: -

    12.5 Common typemap methods

    +

    13.5 Common typemap methods

    @@ -2533,7 +2533,7 @@ The family of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    12.5.1 "in" typemap

    +

    13.5.1 "in" typemap

    @@ -2593,7 +2593,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    12.5.2 "typecheck" typemap

    +

    13.5.2 "typecheck" typemap

    @@ -2620,7 +2620,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    12.5.3 "out" typemap

    +

    13.5.3 "out" typemap

    @@ -2651,7 +2651,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    12.5.4 "arginit" typemap

    +

    13.5.4 "arginit" typemap

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

    12.5.5 "default" typemap

    +

    13.5.5 "default" typemap

    @@ -2703,7 +2703,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    12.5.6 "check" typemap

    +

    13.5.6 "check" typemap

    @@ -2722,7 +2722,7 @@ converted. For example: -

    12.5.7 "argout" typemap

    +

    13.5.7 "argout" typemap

    @@ -2768,7 +2768,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    12.5.8 "freearg" typemap

    +

    13.5.8 "freearg" typemap

    @@ -2801,7 +2801,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    12.5.9 "newfree" typemap

    +

    13.5.9 "newfree" typemap

    @@ -2830,7 +2830,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    12.5.10 "ret" typemap

    +

    13.5.10 "ret" typemap

    @@ -2869,7 +2869,7 @@ This approach is an alternative to using the "newfree" typemap and %newobjec is no need to list all the functions that require the memory cleanup, it is purely done on types.

    -

    12.5.11 "memberin" typemap

    +

    13.5.11 "memberin" typemap

    @@ -2891,7 +2891,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    -

    12.5.12 "varin" typemap

    +

    13.5.12 "varin" typemap

    @@ -2899,7 +2899,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    12.5.13 "varout" typemap

    +

    13.5.13 "varout" typemap

    @@ -2907,7 +2907,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    12.5.14 "throws" typemap

    +

    13.5.14 "throws" typemap

    @@ -2957,7 +2957,7 @@ Note that if your methods do not have an exception specification but they do thr Please also see the Exception handling with %exception section for another way to handle exceptions.

    -

    12.6 Some typemap examples

    +

    13.6 Some typemap examples

    @@ -2965,7 +2965,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    12.6.1 Typemaps for arrays

    +

    13.6.1 Typemaps for arrays

    @@ -3224,7 +3224,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    12.6.2 Implementing constraints with typemaps

    +

    13.6.2 Implementing constraints with typemaps

    @@ -3272,7 +3272,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    12.7 Typemaps for multiple target languages

    +

    13.7 Typemaps for multiple target languages

    @@ -3302,7 +3302,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby, in) int "$1 = NUM2INT($input);".

    -

    12.8 Optimal code generation when returning by value

    +

    13.8 Optimal code generation when returning by value

    @@ -3491,7 +3491,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    12.9 Multi-argument typemaps

    +

    13.9 Multi-argument typemaps

    @@ -3768,7 +3768,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    12.10 Typemap warnings

    +

    13.10 Typemap warnings

    @@ -3777,7 +3777,7 @@ See the information in the issuing warnings

    -

    12.11 Typemap fragments

    +

    13.11 Typemap fragments

    @@ -4113,7 +4113,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    12.11.1 Fragment type specialization

    +

    13.11.1 Fragment type specialization

    @@ -4146,7 +4146,7 @@ struct A { -

    12.11.2 Fragments and automatic typemap specialization

    +

    13.11.2 Fragments and automatic typemap specialization

    @@ -4192,7 +4192,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    12.12 The run-time type checker

    +

    13.12 The run-time type checker

    @@ -4218,7 +4218,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    12.12.1 Implementation

    +

    13.12.1 Implementation

    @@ -4412,7 +4412,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    12.12.2 Usage

    +

    13.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4508,7 +4508,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    12.13 Typemaps and overloading

    +

    13.13 Typemaps and overloading

    @@ -4815,7 +4815,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    12.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    +

    13.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    @@ -4917,7 +4917,7 @@ Otherwise both can be wrapped by removing the overloading name ambiguity by rena The 'equivalent' attribute is used in the implementation for the shared_ptr smart pointer library.

    -

    12.14 More about %apply and %clear

    +

    13.14 More about %apply and %clear

    @@ -5022,7 +5022,7 @@ will delete the typemaps for all the typemap methods; namely "in", "check" and " -

    12.15 Passing data between typemaps

    +

    13.15 Passing data between typemaps

    @@ -5059,7 +5059,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    12.16 C++ "this" pointer

    +

    13.16 C++ "this" pointer

    @@ -5119,7 +5119,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    12.17 Where to go for more information?

    +

    13.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index c6f0e8c63..9f20469d2 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -7,7 +7,7 @@ -

    15 Variable Length Arguments

    +

    16 Variable Length Arguments

      @@ -43,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      15.1 Introduction

      +

      16.1 Introduction

      @@ -140,7 +140,7 @@ List make_list(const char *s, ...) {

    -

    15.2 The Problem

    +

    16.2 The Problem

    @@ -233,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    15.3 Default varargs support

    +

    16.3 Default varargs support

    @@ -302,7 +302,7 @@ Read on for further solutions.

    -

    15.4 Argument replacement using %varargs

    +

    16.4 Argument replacement using %varargs

    @@ -413,7 +413,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    15.5 Varargs and typemaps

    +

    16.5 Varargs and typemaps

    @@ -593,7 +593,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    15.6 Varargs wrapping with libffi

    +

    16.6 Varargs wrapping with libffi

    @@ -845,7 +845,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    15.7 Wrapping of va_list

    +

    16.7 Wrapping of va_list

    @@ -899,7 +899,7 @@ int my_vprintf(const char *fmt, ...) { -

    15.8 C++ Issues

    +

    16.8 C++ Issues

    @@ -968,7 +968,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    15.9 Discussion

    +

    16.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 968bdbac8..bff20801e 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -7,7 +7,7 @@ -

    17 Warning Messages

    +

    18 Warning Messages

    -

    17.5 Symbolic symbols

    +

    18.5 Symbolic symbols

    @@ -311,7 +311,7 @@ or -

    17.6 Commentary

    +

    18.6 Commentary

    @@ -328,7 +328,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    17.7 Warnings as errors

    +

    18.7 Warnings as errors

    @@ -337,7 +337,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    17.8 Message output format

    +

    18.8 Message output format

    @@ -356,10 +356,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    17.9 Warning number reference

    +

    18.9 Warning number reference

    -

    17.9.1 Deprecated features (100-199)

    +

    18.9.1 Deprecated features (100-199)

      @@ -387,7 +387,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    17.9.2 Preprocessor (200-299)

    +

    18.9.2 Preprocessor (200-299)

      @@ -399,7 +399,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    17.9.3 C/C++ Parser (300-399)

    +

    18.9.3 C/C++ Parser (300-399)

      @@ -476,7 +476,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    17.9.4 Types and typemaps (400-499)

    +

    18.9.4 Types and typemaps (400-499)

      @@ -507,7 +507,7 @@ example.i(4) : Syntax error in input(1). -

      17.9.5 Code generation (500-559)

      +

      18.9.5 Code generation (500-559)

        @@ -537,7 +537,7 @@ example.i(4) : Syntax error in input(1).
      • 524. Experimental target language. Target language language specified by lang is an experimental language. Please read about SWIG experimental languages, htmllink.
      -

      17.9.6 Doxygen comments (560-599)

      +

      18.9.6 Doxygen comments (560-599)

        @@ -548,7 +548,7 @@ example.i(4) : Syntax error in input(1).
      • 564: Error parsing Doxygen command command: error text. Command ignored."
      -

      17.9.7 Language module specific (700-899)

      +

      18.9.7 Language module specific (700-899)

        @@ -599,14 +599,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      17.9.8 User defined (900-999)

      +

      18.9.8 User defined (900-999)

      These numbers can be used by your own application.

      -

      17.10 History

      +

      18.10 History

      From 3499675cb0e4d322e8bfb6c47fa9f587c37887c1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 11 Feb 2019 18:28:41 +1300 Subject: [PATCH 1426/2031] Fix hardcoded _v in PHP typecheck typemaps This should be $1, which ends up substituted with _v so this does not actually affect behaviour. --- Lib/php/php.swg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 7deda4ca7..4eba6be2a 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -471,7 +471,7 @@ %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { void *tmp; - _v = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, SWIG_POINTER_NO_NULL) >= 0); + $1 = (SWIG_ConvertPtr(&$input, (void **)&tmp, $&1_descriptor, SWIG_POINTER_NO_NULL) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) @@ -480,7 +480,7 @@ SWIGTYPE *const& { void *tmp; - _v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, 0) >= 0); + $1 = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) @@ -488,19 +488,19 @@ SWIGTYPE && { void *tmp; - _v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, SWIG_POINTER_NO_NULL) >= 0); + $1 = (SWIG_ConvertPtr(&$input, (void**)&tmp, $1_descriptor, SWIG_POINTER_NO_NULL) >= 0); } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const& { void *tmp; - _v = (SWIG_ConvertPtr(&$input, (void**)&tmp, $*1_descriptor, 0) >= 0); + $1 = (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); + $1 = (SWIG_ConvertPtr(&$input, (void**)&tmp, 0, 0) >= 0); } /* Exception handling */ From 950473d77e45641325672f058d9c2ddafc6c2f70 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 12 Feb 2019 10:14:25 +1300 Subject: [PATCH 1427/2031] [php] Whitespace improvements in generated C/C++ code --- Lib/php/globalvar.i | 21 ++++++++++----------- Lib/php/phpinit.swg | 6 +++--- Source/Modules/php.cxx | 28 ++++++++++++++-------------- 3 files changed, 27 insertions(+), 28 deletions(-) diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index a5fd779ab..6b31207a6 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -136,7 +136,7 @@ %typemap(varin) SWIGTYPE [] { - if($1) { + if ($1) { zval *z_var = zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1); SWIG_SetPointerZval(z_var, (void*)$1, $1_descriptor, $owner); } @@ -144,15 +144,15 @@ %typemap(varin) char [ANY] { - zval **z_var; - char *s1; + zval **z_var; + char *s1; - zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1, (void**)&z_var); - s1 = Z_STRVAL_P(z_var); - if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { - if (s1) - strncpy($1, s1, $1_dim0); - } + zend_hash_str_find(&EG(symbol_table), "$1", sizeof("$1") - 1, (void**)&z_var); + s1 = Z_STRVAL_P(z_var); + if ((s1 == NULL) || ($1 == NULL) || strcmp(s1, $1)) { + if (s1) + strncpy($1, s1, $1_dim0); + } } %typemap(varin) SWIGTYPE @@ -166,7 +166,6 @@ } $1 = *($&1_ltype)_temp; - } %typemap(varin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE && @@ -245,7 +244,7 @@ (z_var)->value.str.val = 0; (z_var)->value.str.len = 0; } - } + } } %typemap(varout) SWIGTYPE diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg index 6c2363393..1665f5dc4 100644 --- a/Lib/php/phpinit.swg +++ b/Lib/php/phpinit.swg @@ -1,13 +1,13 @@ /* ------------------------------------------------------------ - * The start of the PHP initialization function + * The start of the PHP initialization function * ------------------------------------------------------------ */ %insert(init) "swiginit.swg" %init %{ SWIG_php_minit { - SWIG_InitializeModule((void*)&module_number); + SWIG_InitializeModule((void*)&module_number); %} %fragment("swig_php_init_member_ptr2", "header") %{ @@ -21,5 +21,5 @@ static int swig_member_ptr = 0; %} %fragment("swig_php_init_member_ptr", "init", fragment="swig_php_init_member_ptr2") %{ - swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); + swig_member_ptr = zend_register_list_destructors_ex(swig_member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); %} diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2151316bd..994fbd7de 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -142,7 +142,7 @@ static void SwigPHP_emit_resource_registrations() { ki = First(zend_types); if (ki.key) - Printf(s_oinit, "\n/* Register resource destructors for pointer types */\n"); + Printf(s_oinit, "\n /* Register resource destructors for pointer types */\n"); while (ki.key) { DOH *key = ki.key; Node *class_node = ki.item; @@ -180,11 +180,11 @@ static void SwigPHP_emit_resource_registrations() { Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" + Printf(s_oinit, " le_swig_%s=zend_register_list_destructors_ex" "(%s, NULL, SWIGTYPE%s->name, module_number);\n", key, rsrc_dtor_name, key); // store php type in class struct - Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); + Printf(s_oinit, " SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); Delete(rsrc_dtor_name); @@ -272,8 +272,8 @@ public: /* subsections of the init section */ s_vinit = NewStringEmpty(); s_vdecl = NewString("/* vdecl subsection */\n"); - s_cinit = NewString("/* cinit subsection */\n"); - s_oinit = NewString("/* oinit subsection */\n"); + s_cinit = NewString(" /* cinit subsection */\n"); + s_oinit = NewString(" /* oinit subsection */\n"); pragma_phpinfo = NewStringEmpty(); s_phpclasses = NewString("/* PHP Proxy Classes */\n"); f_directors_h = NewStringEmpty(); @@ -364,7 +364,7 @@ public: /* Initialize the rest of the module */ - Printf(s_oinit, "ZEND_INIT_MODULE_GLOBALS(%s, %s_init_globals, NULL);\n", module, module); + Printf(s_oinit, " ZEND_INIT_MODULE_GLOBALS(%s, %s_init_globals, NULL);\n", module, module); /* start the header section */ Printf(s_header, "ZEND_BEGIN_MODULE_GLOBALS(%s)\n", module); @@ -549,17 +549,17 @@ public: // Printv(s_init,s_resourcetypes,NIL); /* We need this after all classes written out by ::top */ - Printf(s_oinit, "CG(active_class_entry) = NULL;\n"); - Printf(s_oinit, "/* end oinit subsection */\n"); + Printf(s_oinit, " CG(active_class_entry) = NULL;\n"); + Printf(s_oinit, " /* end oinit subsection */\n"); Printf(s_init, "%s\n", s_oinit); /* Constants generated during top call */ - Printf(s_cinit, "/* end cinit subsection */\n"); + Printf(s_cinit, " /* end cinit subsection */\n"); Printf(s_init, "%s\n", s_cinit); Clear(s_cinit); Delete(s_cinit); - Printf(s_init, " return SUCCESS;\n"); + Printf(s_init, " return SUCCESS;\n"); Printf(s_init, "}\n\n"); // Now do REQUEST init which holds any user specified %rinit, and also vinit @@ -577,15 +577,15 @@ public: if (Len(s_vinit) > 0) { /* finish our init section which will have been used by class wrappers */ Printv(s_init, - "/* vinit subsection */\n", + " /* vinit subsection */\n", s_vinit, "\n" - "/* end vinit subsection */\n", + " /* end vinit subsection */\n", NIL); Clear(s_vinit); } Delete(s_vinit); - Printf(s_init, " return SUCCESS;\n"); + Printf(s_init, " return SUCCESS;\n"); Printf(s_init, "}\n\n"); } @@ -598,7 +598,7 @@ public: "/* shutdown section */\n" "{\n", s_shutdown, - " return SUCCESS;\n" + " return SUCCESS;\n" "}\n\n", NIL); } From 9db02a1e6bd17898108f5c0dac7fa87c765371c6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 12 Feb 2019 10:27:31 +1300 Subject: [PATCH 1428/2031] Update PHP testsuite for vadz's new cars --- Examples/test-suite/php/ignore_parameter_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/ignore_parameter_runme.php b/Examples/test-suite/php/ignore_parameter_runme.php index f86a61169..b9c2b777d 100644 --- a/Examples/test-suite/php/ignore_parameter_runme.php +++ b/Examples/test-suite/php/ignore_parameter_runme.php @@ -4,7 +4,7 @@ require "tests.php"; require "ignore_parameter.php"; // New functions -check::functions(array('jaguar','lotus','tvr','ferrari','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini')); +check::functions(array('jaguar','lotus','tvr','ferrari','fiat','sportscars_daimler','sportscars_astonmartin','sportscars_bugatti','sportscars_lamborghini','sportscars_maseratti')); // New classes check::classes(array('ignore_parameter','SportsCars','MiniCooper','MorrisMinor','FordAnglia','AustinAllegro')); // No new vars From 6d2aae47181a82c4eba7f7fb3194abb0ecc2b513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Sun, 10 Feb 2019 23:18:05 +0100 Subject: [PATCH 1429/2031] Fixed typo in Perl5 docs. Fixed typo in section 33.7.2 "Perl5 typemaps". There is no function set_setiv() in the perl api, the correct name is sv_setiv(). --- Doc/Manual/Perl5.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index f3ba75572..5ce765c26 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -1888,7 +1888,7 @@ like this:

       %typemap(out) int {
         $result = sv_newmortal();
      -  set_setiv($result, (IV) $1);
      +  sv_setiv($result, (IV) $1);
         argvi++;
       }
       
      From 200984f0512627ffb48cbd6bcbaf2e0604fcc172 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 8 Feb 2019 13:32:38 -0700 Subject: [PATCH 1430/2031] [Python] Fix some errors in the documentation for -threads The documentation for -threads was added in f0f2fd2daee085021e8b76f823332d52f1982a06 [skip ci] --- Doc/Manual/Contents.html | 2 +- Doc/Manual/Ocaml.html | 4 ++-- Doc/Manual/Python.html | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index fbfc7d751..d30337058 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1813,7 +1813,7 @@
    • Director Usage Example
    • Creating director objects
    • Typemaps for directors, directorin, directorout, directorargout -
    • typemap +
    • directorin typemap
    • directorout typemap
    • directorargout typemap
    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 8e456b9e6..6da866157 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -47,7 +47,7 @@
  • Director Usage Example
  • Creating director objects
  • Typemaps for directors, directorin, directorout, directorargout -
  • typemap +
  • directorin typemap
  • directorout typemap
  • directorargout typemap @@ -948,7 +948,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.

    -

    38.2.5.6 typemap

    +

    38.2.5.6 directorin typemap

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 9d5d2a307..20e95775f 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -7259,12 +7259,12 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai

    The threads module option in the *.i template file:

    -
    %feature("nothread") method;
    +
    %module("threads"=1)
  • You can disable thread support for a given method:

    -
    %module("threads"=1)
    +
    %feature("nothread") method;
    or
    %nothread method;
  • From 437037a3e6ec0e64785ce084853ba406997466f3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 19:49:42 +0000 Subject: [PATCH 1431/2031] Replicate some cosmetic changes from std_map.i into std_set.i, std_unordered_map.i, std_unordered_set.i. --- Lib/java/std_map.i | 2 +- Lib/java/std_set.i | 46 ++++++++++++++++++------------------ Lib/java/std_unordered_map.i | 4 ++-- Lib/java/std_unordered_set.i | 46 ++++++++++++++++++------------------ 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 5b7517ad5..7df94b0b7 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -112,7 +112,7 @@ template Iterator itr = begin(); final Iterator end = end(); - while(itr.isNot(end)) { + while (itr.isNot(end)) { setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { private Iterator iterator; diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 6f557f627..020ab67f7 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -43,12 +43,12 @@ namespace std { -template +template class set { -%typemap(javabase) std::set "java.util.AbstractSet<$typemap(jboxtype, KeyType)>" +%typemap(javabase) std::set "java.util.AbstractSet<$typemap(jboxtype, T)>" %proxycode %{ - public $javaclassname(java.util.Collection collection) { + public $javaclassname(java.util.Collection collection) { this(); addAll(collection); } @@ -57,34 +57,34 @@ class set { return sizeImpl(); } - public boolean addAll(java.util.Collection collection) { + public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; for (Object object : collection) { - didAddElement |= add(($typemap(jboxtype, KeyType))object); + didAddElement |= add(($typemap(jboxtype, T))object); } return didAddElement; } - public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() { - return new java.util.Iterator<$typemap(jboxtype, KeyType)>() { + public java.util.Iterator<$typemap(jboxtype, T)> iterator() { + return new java.util.Iterator<$typemap(jboxtype, T)>() { private Iterator curr; private Iterator end; - private java.util.Iterator<$typemap(jboxtype, KeyType)> init() { + private java.util.Iterator<$typemap(jboxtype, T)> init() { curr = $javaclassname.this.begin(); end = $javaclassname.this.end(); return this; } - public $typemap(jboxtype, KeyType) next() { + public $typemap(jboxtype, T) next() { if (!hasNext()) { throw new java.util.NoSuchElementException(); } // Save the current position, increment it, // then return the value at the position before the increment. - final $typemap(jboxtype, KeyType) currValue = curr.derefUnchecked(); + final $typemap(jboxtype, T) currValue = curr.derefUnchecked(); curr.incrementUnchecked(); return currValue; } @@ -106,11 +106,11 @@ class set { } public boolean contains(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + if (!(object instanceof $typemap(jboxtype, T))) { return false; } - return containsImpl(($typemap(jboxtype, KeyType))object); + return containsImpl(($typemap(jboxtype, T))object); } public boolean removeAll(java.util.Collection collection) { @@ -123,11 +123,11 @@ class set { } public boolean remove(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + if (!(object instanceof $typemap(jboxtype, T))) { return false; } - return removeImpl(($typemap(jboxtype, KeyType))object); + return removeImpl(($typemap(jboxtype, T))object); } %} @@ -140,23 +140,23 @@ class set { ++(*$self); } - KeyType derefUnchecked() const { + T derefUnchecked() const { return **$self; } - bool isNot(const iterator other) const { + bool isNot(iterator other) const { return (*$self != other); } } }; - typedef KeyType key_type; - typedef KeyType value_type; + typedef T key_type; + typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; set(); - set(const set&); + set(const set&); %rename(isEmpty) empty; bool empty() const; @@ -168,17 +168,17 @@ class set { %fragment("SWIG_SetSize"); // Returns whether item was inserted. - bool add(const KeyType& key) { + bool add(const T& key) { return self->insert(key).second; } // Returns whether set contains key. - bool containsImpl(const KeyType& key) { + bool containsImpl(const T& key) { return (self->count(key) > 0); } // Returns whether the item was erased. - bool removeImpl(const KeyType& key) { + bool removeImpl(const T& key) { return (self->erase(key) > 0); } @@ -192,4 +192,4 @@ class set { } }; -} // namespace std +} diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 405e0fba5..3b926b0e6 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -112,7 +112,7 @@ template class unordered_map { Iterator itr = begin(); final Iterator end = end(); - while(itr.isNot(end)) { + while (itr.isNot(end)) { setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { private Iterator iterator; @@ -159,7 +159,7 @@ template class unordered_map { return ++copy; } - bool isNot(const iterator other) const { + bool isNot(iterator other) const { return (*$self != other); } diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index b408c47de..13d1fa4f9 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -43,12 +43,12 @@ namespace std { -template +template class unordered_set { -%typemap(javabase) std::unordered_set "java.util.AbstractSet<$typemap(jboxtype, KeyType)>" +%typemap(javabase) std::unordered_set "java.util.AbstractSet<$typemap(jboxtype, T)>" %proxycode %{ - public $javaclassname(java.util.Collection collection) { + public $javaclassname(java.util.Collection collection) { this(); addAll(collection); } @@ -57,34 +57,34 @@ class unordered_set { return sizeImpl(); } - public boolean addAll(java.util.Collection collection) { + public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; for (Object object : collection) { - didAddElement |= add(($typemap(jboxtype, KeyType))object); + didAddElement |= add(($typemap(jboxtype, T))object); } return didAddElement; } - public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() { - return new java.util.Iterator<$typemap(jboxtype, KeyType)>() { + public java.util.Iterator<$typemap(jboxtype, T)> iterator() { + return new java.util.Iterator<$typemap(jboxtype, T)>() { private Iterator curr; private Iterator end; - private java.util.Iterator<$typemap(jboxtype, KeyType)> init() { + private java.util.Iterator<$typemap(jboxtype, T)> init() { curr = $javaclassname.this.begin(); end = $javaclassname.this.end(); return this; } - public $typemap(jboxtype, KeyType) next() { + public $typemap(jboxtype, T) next() { if (!hasNext()) { throw new java.util.NoSuchElementException(); } // Save the current position, increment it, // then return the value at the position before the increment. - final $typemap(jboxtype, KeyType) currValue = curr.derefUnchecked(); + final $typemap(jboxtype, T) currValue = curr.derefUnchecked(); curr.incrementUnchecked(); return currValue; } @@ -106,11 +106,11 @@ class unordered_set { } public boolean contains(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + if (!(object instanceof $typemap(jboxtype, T))) { return false; } - return containsImpl(($typemap(jboxtype, KeyType))object); + return containsImpl(($typemap(jboxtype, T))object); } public boolean removeAll(java.util.Collection collection) { @@ -123,11 +123,11 @@ class unordered_set { } public boolean remove(Object object) { - if (!(object instanceof $typemap(jboxtype, KeyType))) { + if (!(object instanceof $typemap(jboxtype, T))) { return false; } - return removeImpl(($typemap(jboxtype, KeyType))object); + return removeImpl(($typemap(jboxtype, T))object); } %} @@ -140,23 +140,23 @@ class unordered_set { ++(*$self); } - KeyType derefUnchecked() const { + T derefUnchecked() const { return **$self; } - bool isNot(const iterator other) const { + bool isNot(iterator other) const { return (*$self != other); } } }; - typedef KeyType key_type; - typedef KeyType value_type; + typedef T key_type; + typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; unordered_set(); - unordered_set(const unordered_set&); + unordered_set(const unordered_set&); %rename(isEmpty) empty; bool empty() const; @@ -168,17 +168,17 @@ class unordered_set { %fragment("SWIG_UnorderedSetSize"); // Returns whether item was inserted. - bool add(const KeyType& key) { + bool add(const T& key) { return self->insert(key).second; } // Returns whether set contains key. - bool containsImpl(const KeyType& key) { + bool containsImpl(const T& key) { return (self->count(key) > 0); } // Returns whether the item was erased. - bool removeImpl(const KeyType& key) { + bool removeImpl(const T& key) { return (self->erase(key) > 0); } @@ -192,4 +192,4 @@ class unordered_set { } }; -} // namespace std +} From 9849174d936b717b37e35b39011b6640b3d36901 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Feb 2019 19:53:33 +0000 Subject: [PATCH 1432/2031] Nicer looking generated Java container code --- Lib/java/std_map.i | 3 +-- Lib/java/std_unordered_map.i | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 7df94b0b7..b177f9021 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -78,8 +78,7 @@ template return null; } - public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, - $typemap(jboxtype, MappedType) value) { + public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, $typemap(jboxtype, MappedType) value) { Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { $typemap(jboxtype, MappedType) oldValue = itr.getValue(); diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 3b926b0e6..05b72f409 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -78,8 +78,7 @@ template class unordered_map { return null; } - public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, - $typemap(jboxtype, MappedType) value) { + public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, $typemap(jboxtype, MappedType) value) { Iterator itr = find(($typemap(jboxtype, KeyType)) key); if (itr.isNot(end())) { $typemap(jboxtype, MappedType) oldValue = itr.getValue(); From 82d163207140935919faaa73a7fffa0db1c5888e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 06:36:01 +0000 Subject: [PATCH 1433/2031] Combine duplicate unordered_set unordered_map testcases Merge cpp11_li_std_unordered_map into cpp11_std_unordered_map Merge cpp11_li_std_unordered_set into cpp11_std_unordered_set --- Examples/test-suite/cpp11_li_std_unordered_map.i | 11 ----------- Examples/test-suite/cpp11_li_std_unordered_set.i | 10 ---------- Examples/test-suite/cpp11_std_unordered_map.i | 2 ++ Examples/test-suite/cpp11_std_unordered_set.i | 2 ++ Examples/test-suite/java/Makefile.in | 4 ++-- ..._runme.java => cpp11_std_unordered_map_runme.java} | 10 +++++----- ..._runme.java => cpp11_std_unordered_set_runme.java} | 10 +++++----- 7 files changed, 16 insertions(+), 33 deletions(-) delete mode 100644 Examples/test-suite/cpp11_li_std_unordered_map.i delete mode 100644 Examples/test-suite/cpp11_li_std_unordered_set.i rename Examples/test-suite/java/{cpp11_li_std_unordered_map_runme.java => cpp11_std_unordered_map_runme.java} (92%) rename Examples/test-suite/java/{cpp11_li_std_unordered_set_runme.java => cpp11_std_unordered_set_runme.java} (89%) diff --git a/Examples/test-suite/cpp11_li_std_unordered_map.i b/Examples/test-suite/cpp11_li_std_unordered_map.i deleted file mode 100644 index 5f40e76fd..000000000 --- a/Examples/test-suite/cpp11_li_std_unordered_map.i +++ /dev/null @@ -1,11 +0,0 @@ -/* - * A test of unordered_map containers. - */ - -%module cpp11_li_std_unordered_map - -%include -%include - -%template(IntIntUnorderedMap) std::unordered_map; -%template(StringIntUnorderedMap) std::unordered_map; diff --git a/Examples/test-suite/cpp11_li_std_unordered_set.i b/Examples/test-suite/cpp11_li_std_unordered_set.i deleted file mode 100644 index e9711ce60..000000000 --- a/Examples/test-suite/cpp11_li_std_unordered_set.i +++ /dev/null @@ -1,10 +0,0 @@ -/* - * A test of unordered_set containers. - */ - -%module cpp11_li_std_unordered_set - -%include -%include - -%template(StringUnorderedSet) std::unordered_set; diff --git a/Examples/test-suite/cpp11_std_unordered_map.i b/Examples/test-suite/cpp11_std_unordered_map.i index 56c4a5248..b11d8f275 100644 --- a/Examples/test-suite/cpp11_std_unordered_map.i +++ b/Examples/test-suite/cpp11_std_unordered_map.i @@ -1,5 +1,7 @@ %module cpp11_std_unordered_map +%include %include %template(UnorderedMapIntInt) std::unordered_map; +%template(UnorderedMapStringInt) std::unordered_map; diff --git a/Examples/test-suite/cpp11_std_unordered_set.i b/Examples/test-suite/cpp11_std_unordered_set.i index f5652cb88..c2b8174bb 100644 --- a/Examples/test-suite/cpp11_std_unordered_set.i +++ b/Examples/test-suite/cpp11_std_unordered_set.i @@ -1,5 +1,7 @@ %module cpp11_std_unordered_set +%include %include %template(UnorderedSetInt) std::unordered_set; +%template(UnorderedSetString) std::unordered_set; diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 3323f8a9c..2e788fa07 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -53,9 +53,9 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ cpp11_shared_ptr_upcast \ + cpp11_std_unordered_map \ + cpp11_std_unordered_set \ cpp11_strongly_typed_enumerations_simple \ - cpp11_li_std_unordered_map \ - cpp11_li_std_unordered_set \ DOXYGEN_TEST_CASES := \ doxygen_parsing_enums_simple \ diff --git a/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java b/Examples/test-suite/java/cpp11_std_unordered_map_runme.java similarity index 92% rename from Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java rename to Examples/test-suite/java/cpp11_std_unordered_map_runme.java index bb85eeadd..79f683378 100644 --- a/Examples/test-suite/java/cpp11_li_std_unordered_map_runme.java +++ b/Examples/test-suite/java/cpp11_std_unordered_map_runme.java @@ -1,10 +1,10 @@ -import cpp11_li_std_unordered_map.*; +import cpp11_std_unordered_map.*; -public class cpp11_li_std_unordered_map_runme { +public class cpp11_std_unordered_map_runme { static { try { - System.loadLibrary("cpp11_li_std_unordered_map"); + System.loadLibrary("cpp11_std_unordered_map"); } 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); @@ -20,8 +20,8 @@ public class cpp11_li_std_unordered_map_runme { public static void main(String argv[]) throws Throwable { - java.util.AbstractMap sim = new StringIntUnorderedMap(); - java.util.AbstractMap iim = new IntIntUnorderedMap(); + java.util.AbstractMap sim = new UnorderedMapStringInt(); + java.util.AbstractMap iim = new UnorderedMapIntInt(); checkThat(sim.isEmpty()); checkThat(iim.isEmpty()); diff --git a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java b/Examples/test-suite/java/cpp11_std_unordered_set_runme.java similarity index 89% rename from Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java rename to Examples/test-suite/java/cpp11_std_unordered_set_runme.java index dddf00307..9d64ab240 100644 --- a/Examples/test-suite/java/cpp11_li_std_unordered_set_runme.java +++ b/Examples/test-suite/java/cpp11_std_unordered_set_runme.java @@ -1,10 +1,10 @@ -import cpp11_li_std_unordered_set.*; +import cpp11_std_unordered_set.*; -public class cpp11_li_std_unordered_set_runme { +public class cpp11_std_unordered_set_runme { static { try { - System.loadLibrary("cpp11_li_std_unordered_set"); + System.loadLibrary("cpp11_std_unordered_set"); } 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); @@ -20,7 +20,7 @@ public class cpp11_li_std_unordered_set_runme { public static void main(String argv[]) throws Throwable { - java.util.AbstractSet ss = new StringUnorderedSet(); + java.util.AbstractSet ss = new UnorderedSetString(); checkThat(ss.isEmpty()); checkThat(!ss.contains("key")); @@ -63,7 +63,7 @@ public class cpp11_li_std_unordered_set_runme { checkThat(ss.containsAll(found)); checkThat(found.containsAll(ss)); - java.util.AbstractSet ss2 = new StringUnorderedSet(ss); + java.util.AbstractSet ss2 = new UnorderedSetString(ss); checkThat(ss2.containsAll(ss)); checkThat(ss.containsAll(ss2)); From e83e14a15e67205ba7d5b7bf32a0cababaf1569b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 07:15:51 +0000 Subject: [PATCH 1434/2031] Add missing typedefs to Java STL containers --- Lib/java/std_map.i | 5 +++++ Lib/java/std_set.i | 4 ++++ Lib/java/std_unordered_map.i | 5 +++++ Lib/java/std_unordered_set.i | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index b177f9021..e44a7e97a 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -146,7 +146,12 @@ template typedef ptrdiff_t difference_type; typedef KeyType key_type; typedef MappedType mapped_type; + typedef std::pair< const KeyType, MappedType > value_type; typedef Compare key_compare; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; map(); map(const map&); diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 020ab67f7..018d056cc 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -154,6 +154,10 @@ class set { typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; set(); set(const set&); diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 05b72f409..86992479e 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -146,6 +146,11 @@ template class unordered_map { typedef ptrdiff_t difference_type; typedef KeyType key_type; typedef MappedType mapped_type; + typedef std::pair< const KeyType, MappedType > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; unordered_map(); unordered_map(const unordered_map&); diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 13d1fa4f9..3cbdca639 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -154,6 +154,10 @@ class unordered_set { typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; unordered_set(); unordered_set(const unordered_set&); From 68e86614ff6e02396533228932b0eb87d34f324c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 18:46:05 +0000 Subject: [PATCH 1435/2031] Create a consistent stl.i library file Same file now for all languages except R which is still missing std_map.i. Recent Java changes adding in std_set.i removed. --- Lib/csharp/stl.i | 2 -- Lib/d/stl.i | 2 -- Lib/go/stl.i | 1 + Lib/guile/stl.i | 2 -- Lib/java/stl.i | 6 +++--- Lib/mzscheme/stl.i | 3 +-- Lib/ocaml/stl.i | 2 -- Lib/octave/stl.i | 6 +++++- Lib/perl5/stl.i | 3 +-- Lib/php/stl.i | 2 -- Lib/python/stl.i | 5 ++++- Lib/r/stl.i | 15 +++++++-------- Lib/ruby/stl.i | 2 -- Lib/scilab/stl.i | 6 +++++- Lib/tcl/stl.i | 1 - 15 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Lib/csharp/stl.i b/Lib/csharp/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/csharp/stl.i +++ b/Lib/csharp/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/d/stl.i b/Lib/d/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/d/stl.i +++ b/Lib/d/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/go/stl.i b/Lib/go/stl.i index 38aba67b8..04f86014f 100644 --- a/Lib/go/stl.i +++ b/Lib/go/stl.i @@ -7,3 +7,4 @@ %include %include %include + diff --git a/Lib/guile/stl.i b/Lib/guile/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/guile/stl.i +++ b/Lib/guile/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/java/stl.i b/Lib/java/stl.i index a04adf7b6..04f86014f 100644 --- a/Lib/java/stl.i +++ b/Lib/java/stl.i @@ -3,8 +3,8 @@ * ----------------------------------------------------------------------------- */ %include -%include -%include -%include %include %include +%include +%include + diff --git a/Lib/mzscheme/stl.i b/Lib/mzscheme/stl.i index b19eae58b..04f86014f 100644 --- a/Lib/mzscheme/stl.i +++ b/Lib/mzscheme/stl.i @@ -1,8 +1,7 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ + %include %include %include diff --git a/Lib/ocaml/stl.i b/Lib/ocaml/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/ocaml/stl.i +++ b/Lib/ocaml/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/octave/stl.i b/Lib/octave/stl.i index b29f7d84d..04f86014f 100644 --- a/Lib/octave/stl.i +++ b/Lib/octave/stl.i @@ -1,6 +1,10 @@ -/* initial STL definition. extended as needed in each language */ +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ + %include %include %include %include %include + diff --git a/Lib/perl5/stl.i b/Lib/perl5/stl.i index b19eae58b..04f86014f 100644 --- a/Lib/perl5/stl.i +++ b/Lib/perl5/stl.i @@ -1,8 +1,7 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ + %include %include %include diff --git a/Lib/php/stl.i b/Lib/php/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/php/stl.i +++ b/Lib/php/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/python/stl.i b/Lib/python/stl.i index a3566db5c..04f86014f 100644 --- a/Lib/python/stl.i +++ b/Lib/python/stl.i @@ -1,4 +1,7 @@ -/* initial STL definition. extended as needed in each language */ +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ + %include %include %include diff --git a/Lib/r/stl.i b/Lib/r/stl.i index 37e2ccbf4..91da6a2bf 100644 --- a/Lib/r/stl.i +++ b/Lib/r/stl.i @@ -1,10 +1,9 @@ -/* initial STL definition. extended as needed in each language */ -%include std_common.i -%include std_vector.i -%include std_pair.i -%include std_string.i - - - +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ +%include +%include +%include +%include diff --git a/Lib/ruby/stl.i b/Lib/ruby/stl.i index 9d2e91eee..04f86014f 100644 --- a/Lib/ruby/stl.i +++ b/Lib/ruby/stl.i @@ -1,7 +1,5 @@ /* ----------------------------------------------------------------------------- * stl.i - * - * Initial STL definition. extended as needed in each language * ----------------------------------------------------------------------------- */ %include diff --git a/Lib/scilab/stl.i b/Lib/scilab/stl.i index b29f7d84d..04f86014f 100644 --- a/Lib/scilab/stl.i +++ b/Lib/scilab/stl.i @@ -1,6 +1,10 @@ -/* initial STL definition. extended as needed in each language */ +/* ----------------------------------------------------------------------------- + * stl.i + * ----------------------------------------------------------------------------- */ + %include %include %include %include %include + diff --git a/Lib/tcl/stl.i b/Lib/tcl/stl.i index 40c7584ec..04f86014f 100644 --- a/Lib/tcl/stl.i +++ b/Lib/tcl/stl.i @@ -2,7 +2,6 @@ * stl.i * ----------------------------------------------------------------------------- */ -/* initial STL definition. extended as needed in each language */ %include %include %include From 506be0c28cb8360962b76de7246e4020c3fcd3e5 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 12 Feb 2019 19:43:55 -0700 Subject: [PATCH 1436/2031] [OCaml] Some documentation improvements for %exception Use the style of the Java and Python modules. Tweak some entries in CHANGES.current. [skip ci] --- CHANGES.current | 8 ++-- Doc/Manual/Ocaml.html | 85 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5bc2b4982..dd614d510 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -15,8 +15,8 @@ Version 4.0.0 (in progress) #1464 Add support for C++14 binary integer literals. 2019-02-10: ZackerySpytz - #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also add support for - C++17 UTF8 character literals. + #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also, add support for + C++17 UTF-8 character literals. 2019-02-10: wsfulton [MzScheme] #1437 MzScheme/Racket is now an 'Experimental' language. The examples work @@ -173,7 +173,7 @@ Version 4.0.0 (in progress) int64_t instead of int64. 2019-01-11: ZackerySpytz - [OCaml] #1400 Fix getters and setters. + [OCaml] #1400 Fix the getters and setters of non-static member variables. 2019-01-07: wsfulton #358 Add VOID to windows.i @@ -195,7 +195,7 @@ Version 4.0.0 (in progress) prevent accepting a conversion to a NULL pointer. 2019-01-03: ZackerySpytz - [OCaml] #1386 Fix OCaml out-of-source test-suite + [OCaml] #1386 Fix the OCaml examples and test suite for out-of-source builds. 2019-01-01: wsfulton [Python] #639 remove duplicate proxy method definitions for global function wrappers. diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 6da866157..92b5260fe 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -991,9 +991,88 @@ values will read zero, and struct or object returns have undefined results.

    -Catching exceptions is now supported using SWIG's %exception feature. A simple -but not too useful example is provided by the throw_exception testcase in -Examples/test-suite. You can provide your own exceptions, too. +If an error occurs in a C or C++ function, you may want to convert that error into an OCaml +exception. To do this, you can use the %exception directive. The %exception +directive simply lets you rewrite part of the generated wrapper code to include an error check. +It is detailed in full in the Exception handling with %exception section. +

    + +

    +In C, a function often indicates an error by returning a status code (e.g. a negative number +or a NULL pointer). Here is a simple example of how you might handle that: +

    + +
    +
    +%exception malloc {
    +  $action
    +  if (result == NULL) {
    +    caml_failwith("Not enough memory");
    +  }
    +}
    +void *malloc(size_t nbytes);
    +
    +
    + +

    +In OCaml: +

    + +
    +
    +# let a = _malloc (C_int 20000000000);;
    +Exception: Failure "Not enough memory".
    +#
    +
    +
    + +

    +If a library provides some kind of general error handling framework, you can also use +that. For example: +

    + +
    +
    +%exception {
    +  $action
    +  if (err_occurred()) {
    +    caml_failwith(err_message());
    +  }
    +}
    +
    +
    + +

    +If no declaration name is given to %exception, it is applied to all wrapper functions. +$action is a SWIG special variable and is replaced by the C/C++ function call being wrapped. +

    + +

    +C++ exceptions are also easy to handle. We can catch a C++ exception and rethrow it as +an OCaml exception like this: +

    + +
    +
    +%exception getitem {
    +  try {
    +    $action
    +  } catch (std::out_of_range &e) {
    +    caml_failwith(e.what());
    +  }
    +}
    +
    +class FooClass {
    +  public:
    +    int getitem(int index);      // Exception handling added
    +    ...
    +};
    +
    +
    + +

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

    38.3 Documentation Features

    From cf83adfcd1b069ced4ecada24ce89f211bcab0b7 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 13 Feb 2019 15:16:40 -0700 Subject: [PATCH 1437/2031] Add support for C++17 hexadecimal floating literals --- CHANGES.current | 3 ++ Doc/Manual/CPlusPlus17.html | 15 +++++++ Doc/Manual/Contents.html | 1 + Examples/test-suite/common.mk | 1 + .../test-suite/cpp17_hex_floating_literals.i | 43 +++++++++++++++++++ .../cpp17_hex_floating_literals_runme.py | 28 ++++++++++++ Source/Swig/scanner.c | 21 ++++++++- 7 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/cpp17_hex_floating_literals.i create mode 100644 Examples/test-suite/python/cpp17_hex_floating_literals_runme.py diff --git a/CHANGES.current b/CHANGES.current index 5bc2b4982..e49b7ee7f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-13: ZackerySpytz + #1469 Add support for C++17 hexadecimal floating literals. + 2019-02-11: wsfulton [OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work and most of the test-suite is also working, so it is quite close to being a 'Supported' language. diff --git a/Doc/Manual/CPlusPlus17.html b/Doc/Manual/CPlusPlus17.html index ae3ca5c77..a2346660a 100644 --- a/Doc/Manual/CPlusPlus17.html +++ b/Doc/Manual/CPlusPlus17.html @@ -16,6 +16,7 @@
  • Standard library changes @@ -87,6 +88,20 @@ char a = u8'a'; +

    9.2.3 Hexadecimal floating literals

    + + +

    +C++17 added hexadecimal floating literals. +For example: +

    + +
    +
    +double f = 0xF.68p2;
    +
    +
    +

    9.3 Standard library changes

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index d30337058..fa1ef9b5c 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -365,6 +365,7 @@
  • Standard library changes diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e7e3dd07b..4fb623724 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -163,6 +163,7 @@ CPP_TEST_CASES += \ cpp_static \ cpp_typedef \ cpp14_binary_integer_literals \ + cpp17_hex_floating_literals \ cpp17_nested_namespaces \ cpp17_nspace_nested_namespaces \ cpp17_u8_char_literals \ diff --git a/Examples/test-suite/cpp17_hex_floating_literals.i b/Examples/test-suite/cpp17_hex_floating_literals.i new file mode 100644 index 000000000..dfc1dc0cf --- /dev/null +++ b/Examples/test-suite/cpp17_hex_floating_literals.i @@ -0,0 +1,43 @@ +%module cpp17_hex_floating_literals + +// Tests are designed so that code compiles with C++98 compilers + +%{ +#if __cplusplus >= 201703L +#define CPP17 1 +#endif +%} + +double f1 = 0x.0p1; +double f2 = 0x0.p1; +double f3 = 0x0.0p-1; +double f4 = 0xf.p-1; +double f5 = 0xA.0p1; +double f6 = 0x0.10P+10; +double f7 = 0xb2F.p2; +float f8 = 0x1234AP1F; +float f9 = 0x45A1.D1A2p+10f; + +%{ +#if defined(CPP17) +double f1 = 0x.0p1; +double f2 = 0x0.p1; +double f3 = 0x0.0p-1; +double f4 = 0xf.p-1; +double f5 = 0xA.0p1; +double f6 = 0x0.10P+10; +double f7 = 0xb2F.p2; +float f8 = 0x1234AP1F; +float f9 = 0x45A1.D1A2p+10f; +#else +double f1 = 0.; +double f2 = 0.; +double f3 = 0.; +double f4 = 7.5; +double f5 = 20.; +double f6 = 64.; +double f7 = 11452.; +float f8 = 149140.f; +float f9 = 18253638.f; +#endif +%} diff --git a/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py b/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py new file mode 100644 index 000000000..ed9f4d26b --- /dev/null +++ b/Examples/test-suite/python/cpp17_hex_floating_literals_runme.py @@ -0,0 +1,28 @@ +from cpp17_hex_floating_literals import * + +if cvar.f1 != 0.: + raise RuntimeError + +if cvar.f2 != 0.: + raise RuntimeError + +if cvar.f3 != 0.: + raise RuntimeError + +if cvar.f4 != 7.5: + raise RuntimeError + +if cvar.f5 != 20.: + raise RuntimeError + +if cvar.f6 != 64.: + raise RuntimeError + +if cvar.f7 != 11452.: + raise RuntimeError + +if cvar.f8 != 149140.: + raise RuntimeError + +if cvar.f9 != 18253638.: + raise RuntimeError diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 24a07e68b..964336621 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1196,6 +1196,10 @@ static int look(Scanner *s) { return SWIG_TOKEN_INT; if (isxdigit(c)) state = 85; + else if (c == '.') /* hexadecimal float */ + state = 860; + else if ((c == 'p') || (c == 'P')) /* hexadecimal float */ + state = 820; else if ((c == 'l') || (c == 'L')) { state = 87; } else if ((c == 'u') || (c == 'U')) { @@ -1220,7 +1224,22 @@ static int look(Scanner *s) { return SWIG_TOKEN_INT; } break; - + case 860: + /* hexadecimal float */ + if ((c = nextchar(s)) == 0) { + Swig_error(cparse_file, cparse_start_line, "Hexadecimal floating literals require an exponent\n"); + return SWIG_TOKEN_ERROR; + } + if (isxdigit(c)) + state = 860; + else if ((c == 'p') || (c == 'P')) + state = 820; + else { + retract(s, 2); + Swig_error(cparse_file, cparse_start_line, "Hexadecimal floating literals require an exponent\n"); + return SWIG_TOKEN_ERROR; + } + break; case 86: /* Rest of floating point number */ From 6d0c495fd042a313e0a8d6a9d36209b92b9bf42b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 22:04:58 +0000 Subject: [PATCH 1438/2031] Add missing parameter names in STL container wrappers Mostly in STL copy constructors. Best to have parameter names as they make their way into the wrappers in some target languages. --- Lib/allegrocl/std_list.i | 2 +- Lib/d/std_map.i | 2 +- Lib/go/std_map.i | 2 +- Lib/guile/std_map.i | 8 ++++---- Lib/guile/std_vector.i | 4 ++-- Lib/java/std_map.i | 4 ++-- Lib/java/std_set.i | 2 +- Lib/java/std_unordered_map.i | 4 ++-- Lib/java/std_unordered_set.i | 2 +- Lib/javascript/jsc/std_map.i | 2 +- Lib/javascript/v8/std_map.i | 2 +- Lib/lua/std_map.i | 2 +- Lib/lua/std_pair.i | 2 +- Lib/lua/std_string.i | 2 -- Lib/lua/std_vector.i | 2 +- Lib/mzscheme/std_map.i | 8 ++++---- Lib/mzscheme/std_vector.i | 4 ++-- Lib/ocaml/std_list.i | 2 +- Lib/ocaml/std_map.i | 2 +- Lib/ocaml/std_vector.i | 2 +- Lib/octave/std_deque.i | 2 +- Lib/octave/std_list.i | 2 +- Lib/perl5/std_list.i | 4 ++-- Lib/perl5/std_map.i | 2 +- Lib/perl5/std_vector.i | 6 +++--- Lib/php/std_map.i | 2 +- Lib/python/std_deque.i | 2 +- Lib/python/std_list.i | 2 +- Lib/ruby/rubycontainer.swg | 4 ++-- Lib/ruby/rubycontainer_extended.swg | 2 +- Lib/ruby/std_deque.i | 2 +- Lib/ruby/std_list.i | 2 +- Lib/ruby/std_queue.i | 2 +- Lib/ruby/std_stack.i | 2 +- Lib/scilab/std_map.i | 2 +- Lib/std/std_alloc.i | 4 ++-- Lib/std/std_container.i | 2 +- Lib/std/std_ios.i | 8 ++++---- Lib/std/std_iostream.i | 6 +++--- Lib/std/std_map.i | 2 +- Lib/std/std_multimap.i | 2 +- Lib/std/std_multiset.i | 2 +- Lib/std/std_queue.i | 4 ++-- Lib/std/std_set.i | 4 ++-- Lib/std/std_stack.i | 4 ++-- Lib/std/std_streambuf.i | 2 +- Lib/std/std_unordered_set.i | 2 +- Lib/tcl/std_map.i | 2 +- Lib/tcl/std_vector.i | 4 ++-- 49 files changed, 72 insertions(+), 74 deletions(-) diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i index 4e260897f..332691de1 100644 --- a/Lib/allegrocl/std_list.i +++ b/Lib/allegrocl/std_list.i @@ -36,7 +36,7 @@ namespace std{ list(); list(unsigned int size, const T& value = T()); - list(const list &); + list(const list &other); ~list(); void assign(unsigned int n, const T& value); diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i index 968def214..b7da364cc 100644 --- a/Lib/d/std_map.i +++ b/Lib/d/std_map.i @@ -24,7 +24,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i index f514cf743..3077d157f 100644 --- a/Lib/go/std_map.i +++ b/Lib/go/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index ca9883688..4b8dd67c2 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -219,7 +219,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C> &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -435,7 +435,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -641,7 +641,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -849,7 +849,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C> &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index d7a7140c6..c144f879c 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -189,7 +189,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector&); + vector(const vector& other); %rename(length) size; unsigned int size() const; %rename("empty?") empty; @@ -353,7 +353,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector&); + vector(const vector& other); %rename(length) size; unsigned int size() const; %rename("empty?") empty; diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index e44a7e97a..0b0041fb8 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -154,7 +154,7 @@ template typedef const value_type& const_reference; map(); - map(const map&); + map(const map& other); struct iterator { %typemap(javaclassmodifiers) iterator "protected class" @@ -185,7 +185,7 @@ template %rename(isEmpty) empty; bool empty() const; void clear(); - iterator find(const KeyType&); + iterator find(const KeyType& key); iterator begin(); iterator end(); %extend { diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 018d056cc..4453d90bd 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -160,7 +160,7 @@ class set { typedef const value_type& const_reference; set(); - set(const set&); + set(const set& other); %rename(isEmpty) empty; bool empty() const; diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 86992479e..eecdf0bc4 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -153,7 +153,7 @@ template class unordered_map { typedef const value_type& const_reference; unordered_map(); - unordered_map(const unordered_map&); + unordered_map(const unordered_map& other); struct iterator { %typemap(javaclassmodifiers) iterator "protected class" @@ -184,7 +184,7 @@ template class unordered_map { %rename(isEmpty) empty; bool empty() const; void clear(); - iterator find(const KeyType&); + iterator find(const KeyType& key); iterator begin(); iterator end(); %extend { diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 3cbdca639..06c7a1123 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -160,7 +160,7 @@ class unordered_set { typedef const value_type& const_reference; unordered_set(); - unordered_set(const unordered_set&); + unordered_set(const unordered_set& other); %rename(isEmpty) empty; bool empty() const; diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i index 903f77aa5..cc9474abc 100644 --- a/Lib/javascript/jsc/std_map.i +++ b/Lib/javascript/jsc/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/javascript/v8/std_map.i b/Lib/javascript/v8/std_map.i index 903f77aa5..cc9474abc 100644 --- a/Lib/javascript/v8/std_map.i +++ b/Lib/javascript/v8/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index 8a203e133..3077d157f 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C> &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/lua/std_pair.i b/Lib/lua/std_pair.i index 06728533b..eee365c82 100644 --- a/Lib/lua/std_pair.i +++ b/Lib/lua/std_pair.i @@ -37,6 +37,6 @@ namespace std { }; template - pair make_pair(const T&,const U&); + pair make_pair(const T& t,const U& u); } diff --git a/Lib/lua/std_string.i b/Lib/lua/std_string.i index e9f326b52..b95a8a4a2 100644 --- a/Lib/lua/std_string.i +++ b/Lib/lua/std_string.i @@ -109,7 +109,6 @@ as this is overloaded by the const char* version public: string(); string(const char*); - //string(const string&); unsigned int size() const; unsigned int length() const; bool empty() const; @@ -119,7 +118,6 @@ as this is overloaded by the const char* version // assign does not return a copy of this object // (no point in a scripting language) void assign(const char*); - //void assign(const string&); // no support for all the other features // it's probably better to do it in lua }; diff --git a/Lib/lua/std_vector.i b/Lib/lua/std_vector.i index a4ea978db..3199a9dab 100644 --- a/Lib/lua/std_vector.i +++ b/Lib/lua/std_vector.i @@ -27,7 +27,7 @@ namespace std { public: vector(); vector(unsigned int); - vector(const vector&); + vector(const vector& other); vector(unsigned int,T); unsigned int size() const; unsigned int max_size() const; diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index 6a0cb2d36..68c7f7fb1 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -222,7 +222,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -442,7 +442,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -654,7 +654,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; @@ -866,7 +866,7 @@ namespace std { %rename("has-key?") has_key; public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/mzscheme/std_vector.i b/Lib/mzscheme/std_vector.i index 22e1fa96b..9fa2d5497 100644 --- a/Lib/mzscheme/std_vector.i +++ b/Lib/mzscheme/std_vector.i @@ -191,7 +191,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector&); + vector(const vector& other); %rename(length) size; unsigned int size() const; %rename("empty?") empty; @@ -367,7 +367,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector&); + vector(const vector& other); %rename(length) size; unsigned int size() const; %rename("empty?") empty; diff --git a/Lib/ocaml/std_list.i b/Lib/ocaml/std_list.i index 06181cca8..cb648d711 100644 --- a/Lib/ocaml/std_list.i +++ b/Lib/ocaml/std_list.i @@ -25,7 +25,7 @@ namespace std{ list(); list(unsigned int size, const T& value = T()); - list(const list &); + list(const list& other); ~list(); void assign(unsigned int n, const T& value); diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index 91756bec0..b50bc7fc0 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -27,7 +27,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index 6f82058b5..053b645f0 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -43,7 +43,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector&); + vector(const vector& other); unsigned int size() const; bool empty() const; void clear(); diff --git a/Lib/octave/std_deque.i b/Lib/octave/std_deque.i index 6866a610f..c40cfee12 100644 --- a/Lib/octave/std_deque.i +++ b/Lib/octave/std_deque.i @@ -12,7 +12,7 @@ template struct traits_from > { - static octave_value from(const std::deque & vec) { + static octave_value from(const std::deque& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/octave/std_list.i b/Lib/octave/std_list.i index 1421efaee..35f6c1321 100644 --- a/Lib/octave/std_list.i +++ b/Lib/octave/std_list.i @@ -12,7 +12,7 @@ template struct traits_from > { - static octave_value *from(const std::list & vec) { + static octave_value *from(const std::list& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index cd5a61120..8e2945fba 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -193,7 +193,7 @@ namespace std { typedef const value_type& const_reference; list(); - list(const list &); + list(const list& other); unsigned int size() const; bool empty() const; @@ -346,7 +346,7 @@ namespace std { typedef const value_type& const_reference; list(); - list(const list &); + list(const list& other); unsigned int size() const; bool empty() const; diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index ae7c26601..fe9b6f3f1 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index ec8449464..adfe95df6 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -185,7 +185,7 @@ namespace std { typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector &); + vector(const vector& other); unsigned int size() const; bool empty() const; @@ -357,7 +357,7 @@ namespace std { typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T *value); - vector(const vector &); + vector(const vector& other); unsigned int size() const; bool empty() const; @@ -528,7 +528,7 @@ namespace std { typedef const value_type& const_reference; vector(unsigned int size = 0); vector(unsigned int size, T value); - vector(const vector &); + vector(const vector& other); unsigned int size() const; bool empty() const; diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index 020c20153..4d93fa144 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -28,7 +28,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; void clear(); diff --git a/Lib/python/std_deque.i b/Lib/python/std_deque.i index b19375633..d9a174706 100644 --- a/Lib/python/std_deque.i +++ b/Lib/python/std_deque.i @@ -14,7 +14,7 @@ template struct traits_from > { - static PyObject *from(const std::deque & vec) { + static PyObject *from(const std::deque& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/python/std_list.i b/Lib/python/std_list.i index baf66d914..24d274b42 100644 --- a/Lib/python/std_list.i +++ b/Lib/python/std_list.i @@ -14,7 +14,7 @@ template struct traits_from > { - static PyObject *from(const std::list & vec) { + static PyObject *from(const std::list& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 4d0163f51..e8830a715 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -943,7 +943,7 @@ namespace swig } } - catch( const std::invalid_argument & ) + catch(const std::invalid_argument &) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", @@ -970,7 +970,7 @@ namespace swig Sequence::value_type val = swig::as( elem ); $self->insert( start, val ); } - catch( const std::invalid_argument & ) + catch(const std::invalid_argument &) { rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index 7514ba2c8..663dddb8c 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -69,7 +69,7 @@ *i = swig::as< Type >( r ); } } - catch ( const std::invalid_argument& ) + catch (const std::invalid_argument&) { rb_raise(rb_eTypeError, "Yield block did not return a valid element for " "Container"); diff --git a/Lib/ruby/std_deque.i b/Lib/ruby/std_deque.i index 38048aff7..b70f34ee3 100644 --- a/Lib/ruby/std_deque.i +++ b/Lib/ruby/std_deque.i @@ -14,7 +14,7 @@ template struct traits_from > { - static VALUE from(const std::deque & vec) { + static VALUE from(const std::deque& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/ruby/std_list.i b/Lib/ruby/std_list.i index 5f179cc69..b0b4928e4 100644 --- a/Lib/ruby/std_list.i +++ b/Lib/ruby/std_list.i @@ -14,7 +14,7 @@ template struct traits_from > { - static VALUE from(const std::list & vec) { + static VALUE from(const std::list& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/ruby/std_queue.i b/Lib/ruby/std_queue.i index a12936775..2a16d9cfd 100644 --- a/Lib/ruby/std_queue.i +++ b/Lib/ruby/std_queue.i @@ -14,7 +14,7 @@ template struct traits_from > { - static VALUE from(const std::queue & vec) { + static VALUE from(const std::queue& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/ruby/std_stack.i b/Lib/ruby/std_stack.i index 600c81c96..7df48ef1b 100644 --- a/Lib/ruby/std_stack.i +++ b/Lib/ruby/std_stack.i @@ -14,7 +14,7 @@ template struct traits_from > { - static VALUE from(const std::stack & vec) { + static VALUE from(const std::stack& vec) { return traits_from_stdseq >::from(vec); } }; diff --git a/Lib/scilab/std_map.i b/Lib/scilab/std_map.i index 0255e2f6a..aea1c7141 100644 --- a/Lib/scilab/std_map.i +++ b/Lib/scilab/std_map.i @@ -23,7 +23,7 @@ namespace std { // add typemaps here public: map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/std/std_alloc.i b/Lib/std/std_alloc.i index 44dc8dc3e..e460dc3ea 100644 --- a/Lib/std/std_alloc.i +++ b/Lib/std/std_alloc.i @@ -31,9 +31,9 @@ namespace std allocator() throw(); - allocator(const allocator&) throw(); + allocator(const allocator& other) throw(); template - allocator(const allocator<_Tp1>&) throw(); + allocator(const allocator<_Tp1>& other) throw(); ~allocator() throw(); diff --git a/Lib/std/std_container.i b/Lib/std/std_container.i index 000163f1e..570dfde48 100644 --- a/Lib/std/std_container.i +++ b/Lib/std/std_container.i @@ -11,7 +11,7 @@ %define %std_container_methods_non_resizable(container...) container(); - container(const container&); + container(const container& other); bool empty() const; size_type size() const; diff --git a/Lib/std/std_ios.i b/Lib/std/std_ios.i index db83c7abf..7c62ed690 100644 --- a/Lib/std/std_ios.i +++ b/Lib/std/std_ios.i @@ -153,10 +153,10 @@ namespace std { //50. Copy constructor and assignment operator of ios_base private: - ios_base(const ios_base&); + ios_base(const ios_base& other); ios_base& - operator=(const ios_base&); + operator=(const ios_base& other); }; template > @@ -242,10 +242,10 @@ namespace std { // 27.4.5.1 basic_ios constructors basic_ios(); private: - basic_ios(const basic_ios&); + basic_ios(const basic_ios& other); basic_ios& - operator=(const basic_ios&); + operator=(const basic_ios& other); }; } diff --git a/Lib/std/std_iostream.i b/Lib/std/std_iostream.i index 7a33afe39..38a22963f 100644 --- a/Lib/std/std_iostream.i +++ b/Lib/std/std_iostream.i @@ -306,15 +306,15 @@ namespace std template > std::basic_ostream<_CharT, _Traits>& - endl(std::basic_ostream<_CharT, _Traits>&); + endl(std::basic_ostream<_CharT, _Traits>& value); template > std::basic_ostream<_CharT, _Traits>& - ends(std::basic_ostream<_CharT, _Traits>&); + ends(std::basic_ostream<_CharT, _Traits>& value); template > std::basic_ostream<_CharT, _Traits>& - flush(std::basic_ostream<_CharT, _Traits>&); + flush(std::basic_ostream<_CharT, _Traits>& value); } namespace std { diff --git a/Lib/std/std_map.i b/Lib/std/std_map.i index 8043f924c..36c037860 100644 --- a/Lib/std/std_map.i +++ b/Lib/std/std_map.i @@ -113,7 +113,7 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map< _Key, _Tp, _Compare, _Alloc >); - map( const _Compare& ); + map(const _Compare& other); #ifdef %swig_map_methods // Add swig/language extra methods diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i index 7aa949907..983a5d8fd 100644 --- a/Lib/std/std_multimap.i +++ b/Lib/std/std_multimap.i @@ -89,7 +89,7 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap< _Key, _Tp, _Compare, _Alloc >); - multimap( const _Compare& ); + multimap(const _Compare& other); #ifdef %swig_multimap_methods // Add swig/language extra methods diff --git a/Lib/std/std_multiset.i b/Lib/std/std_multiset.i index 1aa7ccce8..a1d0db813 100644 --- a/Lib/std/std_multiset.i +++ b/Lib/std/std_multiset.i @@ -71,7 +71,7 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset< _Key, _Compare, _Alloc >); - multiset( const _Compare& ); + multiset(const _Compare& other); #ifdef %swig_multiset_methods // Add swig/language extra methods diff --git a/Lib/std/std_queue.i b/Lib/std/std_queue.i index b2c8d8d33..51bb04473 100644 --- a/Lib/std/std_queue.i +++ b/Lib/std/std_queue.i @@ -13,14 +13,14 @@ %define %std_queue_methods(queue...) queue(); - queue( const _Sequence& ); + queue(const _Sequence& other); bool empty() const; size_type size() const; const value_type& front() const; const value_type& back() const; void pop(); - void push( const value_type& ); + void push(const value_type& value); %enddef %define %std_queue_methods_val(queue...) diff --git a/Lib/std/std_set.i b/Lib/std/std_set.i index 107a23c71..0e05aca40 100644 --- a/Lib/std/std_set.i +++ b/Lib/std/std_set.i @@ -8,7 +8,7 @@ // Set %define %std_set_methods_common(set...) set(); - set( const set& ); + set(const set& other); bool empty() const; size_type size() const; @@ -110,7 +110,7 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set< _Key, _Compare, _Alloc >); - set( const _Compare& ); + set(const _Compare& other); #ifdef %swig_set_methods // Add swig/language extra methods diff --git a/Lib/std/std_stack.i b/Lib/std/std_stack.i index 5b624b571..ff714d099 100644 --- a/Lib/std/std_stack.i +++ b/Lib/std/std_stack.i @@ -13,13 +13,13 @@ %define %std_stack_methods(stack...) stack(); - stack( const _Sequence& ); + stack(const _Sequence& other); bool empty() const; size_type size() const; const value_type& top() const; void pop(); - void push( const value_type& ); + void push(const value_type& value); %enddef %define %std_stack_methods_val(stack...) diff --git a/Lib/std/std_streambuf.i b/Lib/std/std_streambuf.i index 7efb19c6c..e17249135 100644 --- a/Lib/std/std_streambuf.i +++ b/Lib/std/std_streambuf.i @@ -81,7 +81,7 @@ namespace std { basic_streambuf(); private: - basic_streambuf(const basic_streambuf&); + basic_streambuf(const basic_streambuf& other); }; } diff --git a/Lib/std/std_unordered_set.i b/Lib/std/std_unordered_set.i index 75e955c4b..133246da8 100644 --- a/Lib/std/std_unordered_set.i +++ b/Lib/std/std_unordered_set.i @@ -8,7 +8,7 @@ // Unordered Set %define %std_unordered_set_methods_common(unordered_set...) unordered_set(); - unordered_set( const unordered_set& ); + unordered_set(const unordered_set& other); bool empty() const; size_type size() const; diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index 96e7cae80..d59537922 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -27,7 +27,7 @@ namespace std { typedef K key_type; typedef T mapped_type; map(); - map(const map< K, T, C > &); + map(const map< K, T, C >& other); unsigned int size() const; bool empty() const; diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index 3fc0fd61d..71913f389 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -210,7 +210,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector< T > &); + vector(const vector< T >& other); unsigned int size() const; bool empty() const; @@ -361,7 +361,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector< T > &); + vector(const vector< T >& other); unsigned int size() const; bool empty() const; From 1f449973432d19a4c05987246dee372d1a503573 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 22:30:43 +0000 Subject: [PATCH 1439/2031] rename std::array testcase --- Examples/test-suite/common.mk | 2 +- ...cpp11_li_std_array.i => cpp11_std_array.i} | 2 +- ...rray_runme.cs => cpp11_std_array_runme.cs} | 20 ++++++++--------- ..._runme.java => cpp11_std_array_runme.java} | 22 +++++++++---------- ...rray_runme.py => cpp11_std_array_runme.py} | 2 +- ...rray_runme.rb => cpp11_std_array_runme.rb} | 4 ++-- 6 files changed, 26 insertions(+), 26 deletions(-) rename Examples/test-suite/{cpp11_li_std_array.i => cpp11_std_array.i} (97%) rename Examples/test-suite/csharp/{cpp11_li_std_array_runme.cs => cpp11_std_array_runme.cs} (75%) rename Examples/test-suite/java/{cpp11_li_std_array_runme.java => cpp11_std_array_runme.java} (75%) rename Examples/test-suite/python/{cpp11_li_std_array_runme.py => cpp11_std_array_runme.py} (99%) rename Examples/test-suite/ruby/{cpp11_li_std_array_runme.rb => cpp11_std_array_runme.rb} (98%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e7e3dd07b..944f682b0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -575,7 +575,7 @@ CPP11_TEST_CASES += \ cpp11_initializer_list \ cpp11_initializer_list_extend \ cpp11_lambda_functions \ - cpp11_li_std_array \ + cpp11_std_array \ cpp11_noexcept \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ diff --git a/Examples/test-suite/cpp11_li_std_array.i b/Examples/test-suite/cpp11_std_array.i similarity index 97% rename from Examples/test-suite/cpp11_li_std_array.i rename to Examples/test-suite/cpp11_std_array.i index dedd6483a..3d4771551 100644 --- a/Examples/test-suite/cpp11_li_std_array.i +++ b/Examples/test-suite/cpp11_std_array.i @@ -1,4 +1,4 @@ -%module cpp11_li_std_array +%module cpp11_std_array #if defined(SWIGPYTHON) || defined(SWIGRUBY) || defined(SWIGJAVA) || defined(SWIGCSHARP) diff --git a/Examples/test-suite/csharp/cpp11_li_std_array_runme.cs b/Examples/test-suite/csharp/cpp11_std_array_runme.cs similarity index 75% rename from Examples/test-suite/csharp/cpp11_li_std_array_runme.cs rename to Examples/test-suite/csharp/cpp11_std_array_runme.cs index d0c956ad3..ee7c5ee24 100644 --- a/Examples/test-suite/csharp/cpp11_li_std_array_runme.cs +++ b/Examples/test-suite/csharp/cpp11_std_array_runme.cs @@ -1,8 +1,8 @@ // This test tests all the methods in the C# collection wrapper using System; -using cpp11_li_std_arrayNamespace; +using cpp11_std_arrayNamespace; -public class cpp11_li_std_array_runme +public class cpp11_std_array_runme { private static ArrayInt6 ToArray6(int[] a) { @@ -37,24 +37,24 @@ public class cpp11_li_std_array_runme compareContainers(ai, vals); // Check return - compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 }); - compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 }); - compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 }); - compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 }); + compareContainers(cpp11_std_array.arrayOutVal(), new int[] { -2, -1, 0, 0, 1, 2 }); + compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] { -2, -1, 0, 0, 1, 2 }); + compareContainers(cpp11_std_array.arrayOutRef(), new int[] { -2, -1, 0, 0, 1, 2 }); + compareContainers(cpp11_std_array.arrayOutPtr(), new int[] { -2, -1, 0, 0, 1, 2 }); // Check passing arguments - ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); + ai = cpp11_std_array.arrayInVal(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 }); - ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); + ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 }); ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); - cpp11_li_std_array.arrayInRef(ai); + cpp11_std_array.arrayInRef(ai); compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 }); ai = new ArrayInt6(ToArray6(new int[] { 9, 8, 7, 6, 5, 4 })); - cpp11_li_std_array.arrayInPtr(ai); + cpp11_std_array.arrayInPtr(ai); compareContainers(ai, new int[] { 90, 80, 70, 60, 50, 40 }); // fill diff --git a/Examples/test-suite/java/cpp11_li_std_array_runme.java b/Examples/test-suite/java/cpp11_std_array_runme.java similarity index 75% rename from Examples/test-suite/java/cpp11_li_std_array_runme.java rename to Examples/test-suite/java/cpp11_std_array_runme.java index 2e2a20138..58fdc176b 100644 --- a/Examples/test-suite/java/cpp11_li_std_array_runme.java +++ b/Examples/test-suite/java/cpp11_std_array_runme.java @@ -1,10 +1,10 @@ -import cpp11_li_std_array.*; +import cpp11_std_array.*; -public class cpp11_li_std_array_runme { +public class cpp11_std_array_runme { static { try { - System.loadLibrary("cpp11_li_std_array"); + System.loadLibrary("cpp11_std_array"); } 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); @@ -43,24 +43,24 @@ public class cpp11_li_std_array_runme { compareContainers(ai, vals); // Check return - compareContainers(cpp11_li_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2}); - compareContainers(cpp11_li_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2}); - compareContainers(cpp11_li_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2}); - compareContainers(cpp11_li_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2}); + compareContainers(cpp11_std_array.arrayOutVal(), new int[] {-2, -1, 0, 0, 1, 2}); + compareContainers(cpp11_std_array.arrayOutConstRef(), new int[] {-2, -1, 0, 0, 1, 2}); + compareContainers(cpp11_std_array.arrayOutRef(), new int[] {-2, -1, 0, 0, 1, 2}); + compareContainers(cpp11_std_array.arrayOutPtr(), new int[] {-2, -1, 0, 0, 1, 2}); // Check passing arguments - ai = cpp11_li_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); + ai = cpp11_std_array.arrayInVal(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40}); - ai = cpp11_li_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); + ai = cpp11_std_array.arrayInConstRef(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40}); ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); - cpp11_li_std_array.arrayInRef(ai); + cpp11_std_array.arrayInRef(ai); compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40}); ai = new ArrayInt6(ToArray6(new int[] {9, 8, 7, 6, 5, 4})); - cpp11_li_std_array.arrayInPtr(ai); + cpp11_std_array.arrayInPtr(ai); compareContainers(ai, new int[] {90, 80, 70, 60, 50, 40}); // fill diff --git a/Examples/test-suite/python/cpp11_li_std_array_runme.py b/Examples/test-suite/python/cpp11_std_array_runme.py similarity index 99% rename from Examples/test-suite/python/cpp11_li_std_array_runme.py rename to Examples/test-suite/python/cpp11_std_array_runme.py index 3b1ceb2f8..e5e7373dd 100644 --- a/Examples/test-suite/python/cpp11_li_std_array_runme.py +++ b/Examples/test-suite/python/cpp11_std_array_runme.py @@ -1,4 +1,4 @@ -from cpp11_li_std_array import * +from cpp11_std_array import * import sys diff --git a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb b/Examples/test-suite/ruby/cpp11_std_array_runme.rb similarity index 98% rename from Examples/test-suite/ruby/cpp11_li_std_array_runme.rb rename to Examples/test-suite/ruby/cpp11_std_array_runme.rb index 770f37c0f..13c5efb84 100644 --- a/Examples/test-suite/ruby/cpp11_li_std_array_runme.rb +++ b/Examples/test-suite/ruby/cpp11_std_array_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'cpp11_li_std_array' +require 'cpp11_std_array' -include Cpp11_li_std_array +include Cpp11_std_array def failed(a, b, msg) From 9dd33e6367b59f65cc1ca04d46a34fbf2f9e35f1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 22:52:43 +0000 Subject: [PATCH 1440/2031] Add missing typedefs to std::map --- Lib/csharp/std_map.i | 5 +++++ Lib/d/std_map.i | 6 ++++++ Lib/go/std_map.i | 6 ++++++ Lib/guile/std_map.i | 36 ++++++++++++++++++++++++++++++++++++ Lib/java/std_map.i | 1 - Lib/javascript/jsc/std_map.i | 7 +++++++ Lib/javascript/v8/std_map.i | 6 ++++++ Lib/lua/std_map.i | 6 ++++++ Lib/mzscheme/std_map.i | 36 ++++++++++++++++++++++++++++++++++++ Lib/ocaml/std_map.i | 6 ++++++ Lib/perl5/std_map.i | 6 ++++++ Lib/php/std_map.i | 6 ++++++ Lib/scilab/std_map.i | 10 ++++++++++ Lib/std/std_map.i | 1 - Lib/tcl/std_map.i | 6 ++++++ 15 files changed, 142 insertions(+), 2 deletions(-) diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 9d07bc830..9884e29a5 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -214,6 +214,11 @@ typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; map(); map(const map< K, T, C > &other); diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i index b7da364cc..b869ac599 100644 --- a/Lib/d/std_map.i +++ b/Lib/d/std_map.i @@ -23,6 +23,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i index 3077d157f..5e21591e9 100644 --- a/Lib/go/std_map.i +++ b/Lib/go/std_map.i @@ -27,6 +27,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index 4b8dd67c2..4ac22c23d 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -218,6 +218,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -434,6 +440,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -640,6 +656,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -848,6 +874,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 0b0041fb8..7ba0b2fe5 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -147,7 +147,6 @@ template typedef KeyType key_type; typedef MappedType mapped_type; typedef std::pair< const KeyType, MappedType > value_type; - typedef Compare key_compare; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i index cc9474abc..17b56bd48 100644 --- a/Lib/javascript/jsc/std_map.i +++ b/Lib/javascript/jsc/std_map.i @@ -27,6 +27,13 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + map(); map(const map< K, T, C >& other); diff --git a/Lib/javascript/v8/std_map.i b/Lib/javascript/v8/std_map.i index cc9474abc..41ee1760e 100644 --- a/Lib/javascript/v8/std_map.i +++ b/Lib/javascript/v8/std_map.i @@ -27,6 +27,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index 3077d157f..5e21591e9 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -27,6 +27,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index 68c7f7fb1..80a16ced0 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -221,6 +221,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -441,6 +447,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -653,6 +669,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); @@ -865,6 +891,16 @@ namespace std { %rename("delete!") __delitem__; %rename("has-key?") has_key; public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index b50bc7fc0..9ce881699 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -26,6 +26,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index fe9b6f3f1..91a2acd06 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -27,6 +27,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index 4d93fa144..64c4ff18d 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -27,6 +27,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/scilab/std_map.i b/Lib/scilab/std_map.i index aea1c7141..de00534b0 100644 --- a/Lib/scilab/std_map.i +++ b/Lib/scilab/std_map.i @@ -22,6 +22,16 @@ namespace std { template > class map { // add typemaps here public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); diff --git a/Lib/std/std_map.i b/Lib/std/std_map.i index 36c037860..62f5cb37c 100644 --- a/Lib/std/std_map.i +++ b/Lib/std/std_map.i @@ -74,7 +74,6 @@ namespace std { typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; - typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index d59537922..ce1381f03 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -26,6 +26,12 @@ namespace std { typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; + typedef std::pair< const K, T > value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + map(); map(const map< K, T, C >& other); From a47c2553f512f8ad1e1c076a81e0baa84fc5f2a1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Feb 2019 23:02:38 +0000 Subject: [PATCH 1441/2031] Add missing typedefs to std::pair --- Lib/csharp/std_pair.i | 2 ++ Lib/d/std_pair.i | 2 ++ Lib/go/std_pair.i | 2 ++ Lib/guile/std_pair.i | 4 ++++ Lib/java/std_pair.i | 3 +++ Lib/javascript/jsc/std_pair.i | 2 ++ Lib/javascript/v8/std_pair.i | 2 ++ Lib/lua/std_pair.i | 16 ---------------- Lib/mzscheme/std_pair.i | 4 ++++ Lib/ocaml/std_pair.i | 2 ++ Lib/perl5/std_pair.i | 2 ++ Lib/php/std_pair.i | 2 ++ Lib/scilab/std_pair.i | 2 ++ Lib/tcl/std_pair.i | 2 ++ 14 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Lib/csharp/std_pair.i b/Lib/csharp/std_pair.i index 0712ad762..932849017 100644 --- a/Lib/csharp/std_pair.i +++ b/Lib/csharp/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T t, U u); diff --git a/Lib/d/std_pair.i b/Lib/d/std_pair.i index 0712ad762..932849017 100644 --- a/Lib/d/std_pair.i +++ b/Lib/d/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T t, U u); diff --git a/Lib/go/std_pair.i b/Lib/go/std_pair.i index fe45ee676..867bb2cd5 100644 --- a/Lib/go/std_pair.i +++ b/Lib/go/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index 92dec5fae..e738ecec9 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -113,6 +113,10 @@ namespace std { $1 = 0; } } + + typedef T first_type; + typedef U second_type; + pair(); pair(T first, U second); pair(const pair& p); diff --git a/Lib/java/std_pair.i b/Lib/java/std_pair.i index fe45ee676..1454eaa9c 100644 --- a/Lib/java/std_pair.i +++ b/Lib/java/std_pair.i @@ -18,6 +18,9 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; + pair(); pair(T first, U second); diff --git a/Lib/javascript/jsc/std_pair.i b/Lib/javascript/jsc/std_pair.i index fe45ee676..867bb2cd5 100644 --- a/Lib/javascript/jsc/std_pair.i +++ b/Lib/javascript/jsc/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/javascript/v8/std_pair.i b/Lib/javascript/v8/std_pair.i index 8d6057223..7530e374e 100644 --- a/Lib/javascript/v8/std_pair.i +++ b/Lib/javascript/v8/std_pair.i @@ -17,6 +17,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/lua/std_pair.i b/Lib/lua/std_pair.i index eee365c82..558887789 100644 --- a/Lib/lua/std_pair.i +++ b/Lib/lua/std_pair.i @@ -7,21 +7,6 @@ %{ #include %} -/* -A really cut down version of the pair class. - -this is not useful on its own - it needs a %template definition with it - -eg. -namespace std { - %template(IntPair) pair; - %template(make_IntPair) make_pair; -} - - -*/ - - namespace std { template struct pair { @@ -38,5 +23,4 @@ namespace std { template pair make_pair(const T& t,const U& u); - } diff --git a/Lib/mzscheme/std_pair.i b/Lib/mzscheme/std_pair.i index d5a65470d..52d2bdf87 100644 --- a/Lib/mzscheme/std_pair.i +++ b/Lib/mzscheme/std_pair.i @@ -115,6 +115,10 @@ namespace std { $1 = 0; } } + + typedef T first_type; + typedef U second_type; + pair(); pair(T first, U second); pair(const pair& p); diff --git a/Lib/ocaml/std_pair.i b/Lib/ocaml/std_pair.i index fe45ee676..867bb2cd5 100644 --- a/Lib/ocaml/std_pair.i +++ b/Lib/ocaml/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/perl5/std_pair.i b/Lib/perl5/std_pair.i index 0712ad762..932849017 100644 --- a/Lib/perl5/std_pair.i +++ b/Lib/perl5/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T t, U u); diff --git a/Lib/php/std_pair.i b/Lib/php/std_pair.i index fe45ee676..867bb2cd5 100644 --- a/Lib/php/std_pair.i +++ b/Lib/php/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/scilab/std_pair.i b/Lib/scilab/std_pair.i index 1448d6524..bd0eb53fe 100644 --- a/Lib/scilab/std_pair.i +++ b/Lib/scilab/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); diff --git a/Lib/tcl/std_pair.i b/Lib/tcl/std_pair.i index 1448d6524..bd0eb53fe 100644 --- a/Lib/tcl/std_pair.i +++ b/Lib/tcl/std_pair.i @@ -18,6 +18,8 @@ namespace std { template struct pair { + typedef T first_type; + typedef U second_type; pair(); pair(T first, U second); From e26f6bb4e21b7adc90fcd916ec3cbd39e583637e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 13 Feb 2019 00:04:26 +0000 Subject: [PATCH 1442/2031] Add missing typedefs to std::vector + typedef corrections Tests for std::vector of pointers added which check std::vector::const_reference and std::vector::reference usage which gave compilation errors in Python and Perl which had specialized these vectors incorrectly. --- Examples/test-suite/li_std_vector_extra.i | 1 + Examples/test-suite/li_std_vector_ptr.i | 13 +++++++++++ .../python/li_std_vector_extra_runme.py | 8 +++++++ .../python/li_std_vector_ptr_runme.py | 10 ++++++++- Lib/csharp/std_vector.i | 5 +++++ Lib/d/std_vector.i | 10 +++++++++ Lib/go/std_vector.i | 10 +++++++++ Lib/guile/std_vector.i | 16 ++++++++++++++ Lib/java/std_vector.i | 8 +++---- Lib/javascript/jsc/std_vector.i | 11 ++++++++++ Lib/javascript/v8/std_vector.i | 10 +++++++++ Lib/lua/std_vector.i | 8 +++++++ Lib/mzscheme/std_vector.i | 16 ++++++++++++++ Lib/ocaml/std_vector.i | 8 +++++++ Lib/perl5/std_vector.i | 17 +++++++++++++- Lib/php/std_vector.i | 10 +++++++++ Lib/std/std_vector.i | 22 +++++++++---------- Lib/tcl/std_vector.i | 16 ++++++++++++++ 18 files changed, 182 insertions(+), 17 deletions(-) diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 114de3f11..103242b24 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -129,6 +129,7 @@ std::vector vecStr(std::vector v) { double *makeDoublePtr(double v) { return new double(v); } int extractInt(int *p) { return *p; } short extractConstShort(const short *p) { return *p; } + short extractConstShort2(std::vector::value_type p) { return *p; } %} %template(pyvector) std::vector; diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i index 8c3b71e65..dcf1128e0 100644 --- a/Examples/test-suite/li_std_vector_ptr.i +++ b/Examples/test-suite/li_std_vector_ptr.i @@ -15,6 +15,19 @@ using namespace std; int* makeIntPtr(int v) { return new int(v); } +std::vector::value_type makeIntPtr2(int v) { + return new int(v); +} +int getIntValue(int *p) { + return *p; +} +int getIntValue2(std::vector::const_reference p) { + return *p; +} +int getIntValue3(std::vector::reference p) { + return *p; +} + double* makeDoublePtr(double v) { return new double(v); } diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index d541de6db..88105ea85 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -173,3 +173,11 @@ if extractConstShort(vcs[0]) != 111: if extractConstShort(vcs[1]) != 222: raise RuntimeError + +for p in vcs[0:1]: + if extractConstShort2(p) != 111: + raise RuntimeError + +for p in vcs[1:2]: + if extractConstShort2(p) != 222: + raise RuntimeError diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py index baa92cfee..875d1c9c9 100644 --- a/Examples/test-suite/python/li_std_vector_ptr_runme.py +++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py @@ -4,12 +4,20 @@ def check(val1, val2): if val1 != val2: raise RuntimeError("Values are not the same %s %s" % (val1, val2)) ip1 = makeIntPtr(11) -ip2 = makeIntPtr(22) +ip2 = makeIntPtr2(22) vi = IntPtrVector((ip1, ip2)) check(getValueFromVector(vi, 0), 11) check(getValueFromVector(vi, 1), 22) +check(getIntValue(vi[0]), 11) +check(getIntValue(vi[1]), 22) +check(getIntValue2(vi[0]), 11) +check(getIntValue2(vi[1]), 22) + +ipp = makeIntPtrPtr(vi[0]) +check(getIntValue3(ipp), 11) # Note: getIntValue3 takes int** + vA = APtrVector([makeA(33), makeA(34)]) check(getVectorValueA(vA, 0), 33) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index a69cb63ed..fa60a061d 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -201,8 +201,13 @@ public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef CTYPE value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef CONST_REFERENCE const_reference; + %rename(Clear) clear; void clear(); %rename(Add) push_back; diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i index c67057180..cba3cd4a6 100644 --- a/Lib/d/std_vector.i +++ b/Lib/d/std_vector.i @@ -104,8 +104,13 @@ public void capacity(size_t value) { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef CTYPE value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef CONST_REFERENCE const_reference; + void clear(); void push_back(CTYPE const& x); size_type size() const; @@ -442,8 +447,13 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef CTYPE value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef CONST_REFERENCE const_reference; + bool empty() const; void clear(); void push_back(CTYPE const& x); diff --git a/Lib/go/std_vector.i b/Lib/go/std_vector.i index 29bcd1391..708e5ee38 100644 --- a/Lib/go/std_vector.i +++ b/Lib/go/std_vector.i @@ -12,8 +12,13 @@ namespace std { template class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(); vector(size_type n); size_type size() const; @@ -46,8 +51,13 @@ namespace std { template<> class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef bool const_reference; + vector(); vector(size_type n); size_type size() const; diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index c144f879c..4f7538317 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -187,6 +187,14 @@ namespace std { } } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); @@ -351,6 +359,14 @@ namespace std { } } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index cb1752c69..6a66ec10a 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -23,7 +23,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } } -%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CREF_TYPE) +%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CTYPE, CONST_REFERENCE) %typemap(javabase) std::vector< CTYPE > "java.util.AbstractList<$typemap(jboxtype, CTYPE)>" %typemap(javainterfaces) std::vector< CTYPE > "java.util.RandomAccess" %proxycode %{ @@ -79,10 +79,10 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { typedef size_t size_type; typedef ptrdiff_t difference_type; typedef CTYPE value_type; - typedef CTYPE &reference; - typedef CREF_TYPE const_reference; typedef CTYPE *pointer; typedef CTYPE const *const_pointer; + typedef CTYPE &reference; + typedef CONST_REFERENCE const_reference; vector(); vector(const vector &other); @@ -133,7 +133,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } } - CREF_TYPE doGet(jint index) throw (std::out_of_range) { + CONST_REFERENCE doGet(jint index) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) return (*self)[index]; diff --git a/Lib/javascript/jsc/std_vector.i b/Lib/javascript/jsc/std_vector.i index 971b426a1..34e21a821 100644 --- a/Lib/javascript/jsc/std_vector.i +++ b/Lib/javascript/jsc/std_vector.i @@ -14,8 +14,13 @@ namespace std { template class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(); vector(size_type n); size_type size() const; @@ -48,8 +53,14 @@ namespace std { template<> class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef bool const_reference; + + vector(); vector(size_type n); size_type size() const; diff --git a/Lib/javascript/v8/std_vector.i b/Lib/javascript/v8/std_vector.i index 971b426a1..eef0f65ee 100644 --- a/Lib/javascript/v8/std_vector.i +++ b/Lib/javascript/v8/std_vector.i @@ -14,8 +14,13 @@ namespace std { template class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(); vector(size_type n); size_type size() const; @@ -48,8 +53,13 @@ namespace std { template<> class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef bool const_reference; + vector(); vector(size_type n); size_type size() const; diff --git a/Lib/lua/std_vector.i b/Lib/lua/std_vector.i index 3199a9dab..695862d66 100644 --- a/Lib/lua/std_vector.i +++ b/Lib/lua/std_vector.i @@ -25,6 +25,14 @@ namespace std { template class vector { public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(); vector(unsigned int); vector(const vector& other); diff --git a/Lib/mzscheme/std_vector.i b/Lib/mzscheme/std_vector.i index 9fa2d5497..012c32d32 100644 --- a/Lib/mzscheme/std_vector.i +++ b/Lib/mzscheme/std_vector.i @@ -189,6 +189,14 @@ namespace std { } } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); @@ -365,6 +373,14 @@ namespace std { } } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index 053b645f0..f15b26c66 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -41,6 +41,14 @@ namespace std { template class vector { public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index adfe95df6..a0c26192e 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -181,8 +181,13 @@ namespace std { } public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector& other); @@ -353,8 +358,13 @@ namespace std { } public: typedef size_t size_type; - typedef T value_type; + typedef ptrdiff_t difference_type; + typedef T* value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, T *value); vector(const vector& other); @@ -524,8 +534,13 @@ namespace std { } public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, T value); vector(const vector& other); diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index 9cc1486ef..fe2b8d07d 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -14,8 +14,13 @@ namespace std { template class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; + vector(); vector(size_type n); size_type size() const; @@ -56,8 +61,13 @@ namespace std { template<> class vector { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef bool value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef bool const_reference; + vector(); vector(size_type n); size_type size() const; diff --git a/Lib/std/std_vector.i b/Lib/std/std_vector.i index fae759a36..b35f03bea 100644 --- a/Lib/std/std_vector.i +++ b/Lib/std/std_vector.i @@ -64,8 +64,8 @@ namespace std { typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); @@ -101,13 +101,13 @@ namespace std { template class vector< _Tp*, _Alloc > { public: - typedef size_t size_type; + typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef value_type reference; - typedef value_type const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); @@ -141,13 +141,13 @@ namespace std { template class vector< _Tp const *, _Alloc > { public: - typedef size_t size_type; + typedef size_t size_type; typedef ptrdiff_t difference_type; typedef _Tp const * value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef value_type reference; - typedef value_type const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); @@ -182,13 +182,13 @@ namespace std { template class vector { public: - typedef size_t size_type; + typedef size_t size_type; typedef ptrdiff_t difference_type; typedef bool value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef value_type reference; - typedef value_type const_reference; + typedef value_type& reference; + typedef bool const_reference; typedef _Alloc allocator_type; %traits_swigtype(bool); diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index 71913f389..bb227cf3d 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -208,6 +208,14 @@ namespace std { } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T >& other); @@ -359,6 +367,14 @@ namespace std { } public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + vector(unsigned int size = 0); vector(unsigned int size, const T& value); vector(const vector< T >& other); From 440264e4797b0941f410dbfe6385285dd0daa20b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 07:31:21 +0000 Subject: [PATCH 1443/2031] Add missing typedefs to std::list + typedef corrections Numerous missing typedefs added. std::list::const_reference and std::list::reference specialization typedef fixes. --- Lib/allegrocl/std_list.i | 25 +++++++++++++------------ Lib/go/std_list.i | 5 ++--- Lib/java/std_list.i | 6 +++++- Lib/ocaml/std_list.i | 27 +++++++++++++-------------- Lib/perl5/std_list.i | 4 ++++ Lib/std/std_list.i | 4 ++-- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i index 332691de1..26472156f 100644 --- a/Lib/allegrocl/std_list.i +++ b/Lib/allegrocl/std_list.i @@ -28,12 +28,16 @@ namespace std{ template class list { public: - - typedef T &reference; - typedef const T& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; typedef T &iterator; typedef const T& const_iterator; - + list(); list(unsigned int size, const T& value = T()); list(const list &other); @@ -46,21 +50,20 @@ namespace std{ const_reference back(); const_iterator begin(); const_iterator end(); - + void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& INPUT); void push_back(const T& INPUT); - void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& INPUT); - + void remove(const T& INPUT); void unique(); void reverse(); @@ -153,7 +156,7 @@ namespace std{ if (j<0) j += size; if (i<0) i = 0; if (j>size) j = size; - + for (int k=0;ksize) j = size; - + for (int k=0;kinsert(self->end(),v.begin(),v.end()); } - } unsigned int __len__() { @@ -218,8 +220,7 @@ namespace std{ { self->pop_back(); } - - }; + } }; } diff --git a/Lib/go/std_list.i b/Lib/go/std_list.i index e0262331e..b6e9b6a5a 100644 --- a/Lib/go/std_list.i +++ b/Lib/go/std_list.i @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * std_vector.i + * std_list.i * ----------------------------------------------------------------------------- */ %{ @@ -9,7 +9,7 @@ namespace std { - template > + template class list { public: typedef size_t size_type; @@ -19,7 +19,6 @@ namespace std { typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; - typedef Alloc allocator_type; list(); size_type size() const; diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 595db8919..516a36ee3 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -130,8 +130,12 @@ namespace std { public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; - typedef T &reference; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; /* * We'd actually be better off having the nested class *not* be static in the wrapper diff --git a/Lib/ocaml/std_list.i b/Lib/ocaml/std_list.i index cb648d711..e173d8b1e 100644 --- a/Lib/ocaml/std_list.i +++ b/Lib/ocaml/std_list.i @@ -13,16 +13,20 @@ %} -namespace std{ +namespace std { template class list { public: - - typedef T &reference; - typedef const T& const_reference; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; typedef T &iterator; typedef const T& const_iterator; - + list(); list(unsigned int size, const T& value = T()); list(const list& other); @@ -35,28 +39,25 @@ namespace std{ const_reference back(); const_iterator begin(); const_iterator end(); - + void resize(unsigned int n, T c = T()); bool empty() const; void push_front(const T& x); void push_back(const T& x); - void pop_front(); void pop_back(); void clear(); unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, const T& value); - + void remove(const T& value); void unique(); void reverse(); void sort(); - - - + %extend { const_reference __getitem__(int i) throw (std::out_of_range) @@ -206,9 +207,7 @@ namespace std{ { self->pop_back(); } - - }; - + } }; } diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index 8e2945fba..d42e3d8ef 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -189,7 +189,11 @@ namespace std { } public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; typedef const value_type& const_reference; list(); diff --git a/Lib/std/std_list.i b/Lib/std/std_list.i index ebbafa22b..2cc2d97cf 100644 --- a/Lib/std/std_list.i +++ b/Lib/std/std_list.i @@ -106,8 +106,8 @@ namespace std { typedef _Tp* value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef value_type reference; - typedef value_type const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; typedef _Alloc allocator_type; %traits_swigtype(_Tp); From 40d7f4137e97b2814b2405bef6372b8edcc67454 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 07:38:49 +0000 Subject: [PATCH 1444/2031] typedef declaration corrections for std::array --- Lib/java/std_array.i | 10 ++++++---- Lib/std/std_array.i | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/java/std_array.i b/Lib/java/std_array.i index 0944d932f..f67b18d9b 100644 --- a/Lib/java/std_array.i +++ b/Lib/java/std_array.i @@ -11,12 +11,14 @@ namespace std { typedef size_t size_type; typedef ptrdiff_t difference_type; typedef T value_type; - typedef T &reference; - typedef const T &const_reference; - typedef T *pointer; - typedef const T *const_pointer; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + array(); array(const array& other); + size_type size() const; %rename(isEmpty) empty; bool empty() const; diff --git a/Lib/std/std_array.i b/Lib/std/std_array.i index aadc3b80c..3f70ef57c 100644 --- a/Lib/std/std_array.i +++ b/Lib/std/std_array.i @@ -53,8 +53,8 @@ namespace std { typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; - typedef _Tp& reference; - typedef const _Tp& const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; %traits_swigtype(_Tp); %traits_enum(_Tp); From dc34c39c533b76bf5d8fd13e47906f6a4de16800 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 08:16:16 +0000 Subject: [PATCH 1445/2031] Cosmetic STL typedef changes --- Lib/java/std_set.i | 4 ++-- Lib/java/std_unordered_set.i | 4 ++-- Lib/std/std_multimap.i | 1 - Lib/std/std_unordered_map.i | 1 - Lib/std/std_unordered_multimap.i | 1 - 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 4453d90bd..ddc0379cd 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -150,10 +150,10 @@ class set { } }; - typedef T key_type; - typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 06c7a1123..98bf3ebf1 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -150,10 +150,10 @@ class unordered_set { } }; - typedef T key_type; - typedef T value_type; typedef size_t size_type; typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/std/std_multimap.i b/Lib/std/std_multimap.i index 983a5d8fd..03e765341 100644 --- a/Lib/std/std_multimap.i +++ b/Lib/std/std_multimap.i @@ -50,7 +50,6 @@ namespace std { typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; - typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/std/std_unordered_map.i b/Lib/std/std_unordered_map.i index 0d6986497..723c0232d 100644 --- a/Lib/std/std_unordered_map.i +++ b/Lib/std/std_unordered_map.i @@ -71,7 +71,6 @@ namespace std { typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; - typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; diff --git a/Lib/std/std_unordered_multimap.i b/Lib/std/std_unordered_multimap.i index 6f1be9cfa..f2855343d 100644 --- a/Lib/std/std_unordered_multimap.i +++ b/Lib/std/std_unordered_multimap.i @@ -49,7 +49,6 @@ namespace std { typedef _Key key_type; typedef _Tp mapped_type; typedef std::pair< const _Key, _Tp > value_type; - typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; From a159a252dd98e50f91c835201acbb82941d5e4e4 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 14 Feb 2019 02:21:36 -0700 Subject: [PATCH 1446/2031] [OCaml] Fix the dynamic_cast test Add out typemaps for SWIGTYPE *DYNAMIC and SWIGTYPE &DYNAMIC. Add dynamic_cast_runme.ml. --- Examples/test-suite/ocaml/dynamic_cast_runme.ml | 9 +++++++++ Lib/ocaml/typemaps.i | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 Examples/test-suite/ocaml/dynamic_cast_runme.ml diff --git a/Examples/test-suite/ocaml/dynamic_cast_runme.ml b/Examples/test-suite/ocaml/dynamic_cast_runme.ml new file mode 100644 index 000000000..54391d9a0 --- /dev/null +++ b/Examples/test-suite/ocaml/dynamic_cast_runme.ml @@ -0,0 +1,9 @@ +open Swig +open Dynamic_cast + +let f = new_Foo '() +let b = new_Bar '() + +let x = f -> blah () +let y = b -> blah () +assert (_do_test '(y) as string = "Bar::test") diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 4475707d6..a781838ca 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -307,6 +307,11 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val); $2 = ($2_ltype) caml_string_len($input); } +%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **)&$1); + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, ty); +} + /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } %apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) } From 6d27ead9c0d42588794ff582ecfe9af904d823b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 18:53:05 +0000 Subject: [PATCH 1447/2031] Add STL container copy constructors where missing Also provide consistent copy constructor declarations. --- Lib/allegrocl/std_list.i | 3 +-- Lib/csharp/std_map.i | 2 +- Lib/csharp/std_vector.i | 2 ++ Lib/d/std_map.i | 2 +- Lib/d/std_vector.i | 4 ++++ Lib/go/std_list.i | 2 ++ Lib/go/std_map.i | 2 +- Lib/go/std_vector.i | 4 ++++ Lib/guile/std_map.i | 8 ++++---- Lib/guile/std_vector.i | 6 ++++-- Lib/java/std_list.i | 3 ++- Lib/java/std_map.i | 2 +- Lib/java/std_set.i | 2 +- Lib/java/std_unordered_map.i | 2 +- Lib/java/std_unordered_set.i | 2 +- Lib/java/std_vector.i | 1 + Lib/javascript/jsc/std_map.i | 2 +- Lib/javascript/jsc/std_vector.i | 5 ++++- Lib/javascript/v8/std_map.i | 2 +- Lib/javascript/v8/std_vector.i | 4 ++++ Lib/lua/std_map.i | 2 +- Lib/lua/std_vector.i | 1 + Lib/mzscheme/std_map.i | 8 ++++---- Lib/mzscheme/std_vector.i | 6 ++++-- Lib/ocaml/std_list.i | 3 +-- Lib/ocaml/std_map.i | 2 +- Lib/ocaml/std_vector.i | 3 ++- Lib/perl5/std_list.i | 4 ++-- Lib/perl5/std_map.i | 2 +- Lib/perl5/std_vector.i | 6 +++--- Lib/php/std_map.i | 2 +- Lib/php/std_vector.i | 4 ++++ Lib/scilab/std_map.i | 2 +- Lib/std/std_carray.swg | 4 ++-- Lib/tcl/std_map.i | 2 +- Lib/tcl/std_vector.i | 4 ++-- 36 files changed, 72 insertions(+), 43 deletions(-) diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i index 26472156f..a3660c9f7 100644 --- a/Lib/allegrocl/std_list.i +++ b/Lib/allegrocl/std_list.i @@ -40,9 +40,8 @@ namespace std{ list(); list(unsigned int size, const T& value = T()); - list(const list &other); + list(const list& other); - ~list(); void assign(unsigned int n, const T& value); void swap(list &x); diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 9884e29a5..e538a03a1 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -221,7 +221,7 @@ typedef const value_type& const_reference; map(); - map(const map< K, T, C > &other); + map(const map& other); size_type size() const; bool empty() const; %rename(Clear) clear; diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index fa60a061d..b1e8da963 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -217,8 +217,10 @@ void reserve(size_type n); %newobject GetRange(int index, int count); %newobject Repeat(CTYPE const& value, int count); + vector(); vector(const vector &other); + %extend { vector(int capacity) throw (std::out_of_range) { std::vector< CTYPE >* pv = 0; diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i index b869ac599..c5e03d06d 100644 --- a/Lib/d/std_map.i +++ b/Lib/d/std_map.i @@ -30,7 +30,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i index cba3cd4a6..9dcb184c6 100644 --- a/Lib/d/std_vector.i +++ b/Lib/d/std_vector.i @@ -116,8 +116,10 @@ public void capacity(size_t value) { size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); + vector(); vector(const vector &other); + %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; @@ -461,8 +463,10 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) size_type size() const; size_type capacity() const; void reserve(size_type n) throw (std::length_error); + vector(); vector(const vector &other); + %extend { vector(size_type capacity) throw (std::length_error) { std::vector< CTYPE >* pv = 0; diff --git a/Lib/go/std_list.i b/Lib/go/std_list.i index b6e9b6a5a..ff6f70013 100644 --- a/Lib/go/std_list.i +++ b/Lib/go/std_list.i @@ -21,6 +21,8 @@ namespace std { typedef const value_type& const_reference; list(); + list(const list& other); + size_type size() const; bool empty() const; %rename(isEmpty) empty; diff --git a/Lib/go/std_map.i b/Lib/go/std_map.i index 5e21591e9..773b6d0c3 100644 --- a/Lib/go/std_map.i +++ b/Lib/go/std_map.i @@ -34,7 +34,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/go/std_vector.i b/Lib/go/std_vector.i index 708e5ee38..679c70759 100644 --- a/Lib/go/std_vector.i +++ b/Lib/go/std_vector.i @@ -21,6 +21,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); @@ -60,6 +62,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index 4ac22c23d..f84e78bc3 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -225,7 +225,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -451,7 +451,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -667,7 +667,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -885,7 +885,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 4f7538317..42bad849d 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -197,7 +197,8 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); + %rename(length) size; unsigned int size() const; %rename("empty?") empty; @@ -369,7 +370,8 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); + %rename(length) size; unsigned int size() const; %rename("empty?") empty; diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 516a36ee3..3ad6511ce 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -177,7 +177,8 @@ namespace std { }; list(); - list(const list &other); + list(const list& other); + %rename(isEmpty) empty; bool empty() const; void clear(); diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 7ba0b2fe5..357401a4d 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -153,7 +153,7 @@ template typedef const value_type& const_reference; map(); - map(const map& other); + map(const map& other); struct iterator { %typemap(javaclassmodifiers) iterator "protected class" diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index ddc0379cd..06c5a63e7 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -160,7 +160,7 @@ class set { typedef const value_type& const_reference; set(); - set(const set& other); + set(const set& other); %rename(isEmpty) empty; bool empty() const; diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index eecdf0bc4..57ebe4e39 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -153,7 +153,7 @@ template class unordered_map { typedef const value_type& const_reference; unordered_map(); - unordered_map(const unordered_map& other); + unordered_map(const unordered_map& other); struct iterator { %typemap(javaclassmodifiers) iterator "protected class" diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 98bf3ebf1..cdc116e49 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -160,7 +160,7 @@ class unordered_set { typedef const value_type& const_reference; unordered_set(); - unordered_set(const unordered_set& other); + unordered_set(const unordered_set& other); %rename(isEmpty) empty; bool empty() const; diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 6a66ec10a..f621e8992 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -86,6 +86,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { vector(); vector(const vector &other); + size_type capacity() const; void reserve(size_type n) throw (std::length_error); %rename(isEmpty) empty; diff --git a/Lib/javascript/jsc/std_map.i b/Lib/javascript/jsc/std_map.i index 17b56bd48..9fa10880f 100644 --- a/Lib/javascript/jsc/std_map.i +++ b/Lib/javascript/jsc/std_map.i @@ -35,7 +35,7 @@ namespace std { map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/javascript/jsc/std_vector.i b/Lib/javascript/jsc/std_vector.i index 34e21a821..586ac5c60 100644 --- a/Lib/javascript/jsc/std_vector.i +++ b/Lib/javascript/jsc/std_vector.i @@ -23,6 +23,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); @@ -60,9 +62,10 @@ namespace std { typedef value_type& reference; typedef bool const_reference; - vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); diff --git a/Lib/javascript/v8/std_map.i b/Lib/javascript/v8/std_map.i index 41ee1760e..3b8b09369 100644 --- a/Lib/javascript/v8/std_map.i +++ b/Lib/javascript/v8/std_map.i @@ -34,7 +34,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/javascript/v8/std_vector.i b/Lib/javascript/v8/std_vector.i index eef0f65ee..586ac5c60 100644 --- a/Lib/javascript/v8/std_vector.i +++ b/Lib/javascript/v8/std_vector.i @@ -23,6 +23,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); @@ -62,6 +64,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index 5e21591e9..773b6d0c3 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -34,7 +34,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/lua/std_vector.i b/Lib/lua/std_vector.i index 695862d66..9eb85e9e6 100644 --- a/Lib/lua/std_vector.i +++ b/Lib/lua/std_vector.i @@ -37,6 +37,7 @@ namespace std { vector(unsigned int); vector(const vector& other); vector(unsigned int,T); + unsigned int size() const; unsigned int max_size() const; bool empty() const; diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index 80a16ced0..1d3eec241 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -228,7 +228,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -458,7 +458,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -680,7 +680,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; @@ -902,7 +902,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/mzscheme/std_vector.i b/Lib/mzscheme/std_vector.i index 012c32d32..0ef5edb15 100644 --- a/Lib/mzscheme/std_vector.i +++ b/Lib/mzscheme/std_vector.i @@ -199,7 +199,8 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); + %rename(length) size; unsigned int size() const; %rename("empty?") empty; @@ -383,7 +384,8 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); + %rename(length) size; unsigned int size() const; %rename("empty?") empty; diff --git a/Lib/ocaml/std_list.i b/Lib/ocaml/std_list.i index e173d8b1e..e0524aa40 100644 --- a/Lib/ocaml/std_list.i +++ b/Lib/ocaml/std_list.i @@ -29,9 +29,8 @@ namespace std { list(); list(unsigned int size, const T& value = T()); - list(const list& other); + list(const list& other); - ~list(); void assign(unsigned int n, const T& value); void swap(list &x); diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index 9ce881699..3f197baa6 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -33,7 +33,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index f15b26c66..891d038c9 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -51,7 +51,8 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); + unsigned int size() const; bool empty() const; void clear(); diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index d42e3d8ef..36678add2 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -197,7 +197,7 @@ namespace std { typedef const value_type& const_reference; list(); - list(const list& other); + list(const list& other); unsigned int size() const; bool empty() const; @@ -350,7 +350,7 @@ namespace std { typedef const value_type& const_reference; list(); - list(const list& other); + list(const list& other); unsigned int size() const; bool empty() const; diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index 91a2acd06..1b3731832 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -34,7 +34,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index a0c26192e..5bfd2c5ac 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -190,7 +190,7 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector& other); + vector(const vector& other); unsigned int size() const; bool empty() const; @@ -367,7 +367,7 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, T *value); - vector(const vector& other); + vector(const vector& other); unsigned int size() const; bool empty() const; @@ -543,7 +543,7 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, T value); - vector(const vector& other); + vector(const vector& other); unsigned int size() const; bool empty() const; diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index 64c4ff18d..7c0157353 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -34,7 +34,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; void clear(); diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index fe2b8d07d..e633bc3ad 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -23,6 +23,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); @@ -70,6 +72,8 @@ namespace std { vector(); vector(size_type n); + vector(const vector& other); + size_type size() const; size_type capacity() const; void reserve(size_type n); diff --git a/Lib/scilab/std_map.i b/Lib/scilab/std_map.i index de00534b0..07eb63fda 100644 --- a/Lib/scilab/std_map.i +++ b/Lib/scilab/std_map.i @@ -33,7 +33,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/std/std_carray.swg b/Lib/std/std_carray.swg index ebb20ce6a..de2a07627 100644 --- a/Lib/std/std_carray.swg +++ b/Lib/std/std_carray.swg @@ -28,8 +28,8 @@ namespace std { carray() { } - carray(const carray& c) { - std::copy(c.v, c.v + size(), v); + carray(const carray& other) { + std::copy(other.v, other.v + size(), v); } template diff --git a/Lib/tcl/std_map.i b/Lib/tcl/std_map.i index ce1381f03..2c7f40ac7 100644 --- a/Lib/tcl/std_map.i +++ b/Lib/tcl/std_map.i @@ -33,7 +33,7 @@ namespace std { typedef const value_type& const_reference; map(); - map(const map< K, T, C >& other); + map(const map& other); unsigned int size() const; bool empty() const; diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index bb227cf3d..5fba5379f 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -218,7 +218,7 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector< T >& other); + vector(const vector& other); unsigned int size() const; bool empty() const; @@ -377,7 +377,7 @@ namespace std { vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector< T >& other); + vector(const vector& other); unsigned int size() const; bool empty() const; From a6a50d60e170aeb7e1310c1ddf119fdff53560a6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 21:41:08 +0000 Subject: [PATCH 1448/2031] Restore original std::map template parameters for Java --- Lib/java/std_map.i | 72 ++++++++++++++++++------------------ Lib/java/std_unordered_map.i | 72 ++++++++++++++++++------------------ 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 357401a4d..4b891e74a 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -46,10 +46,10 @@ namespace std { -template > class map { +template > class map { -%typemap(javabase) std::map - "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>" +%typemap(javabase) std::map< K, T, C > + "java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>" %proxycode %{ @@ -58,19 +58,19 @@ template } public boolean containsKey(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + if (!(key instanceof $typemap(jboxtype, K))) { return false; } - return containsImpl(($typemap(jboxtype, KeyType))key); + return containsImpl(($typemap(jboxtype, K))key); } - public $typemap(jboxtype, MappedType) get(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + public $typemap(jboxtype, T) get(Object key) { + if (!(key instanceof $typemap(jboxtype, K))) { return null; } - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { return itr.getValue(); } @@ -78,10 +78,10 @@ template return null; } - public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, $typemap(jboxtype, MappedType) value) { - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) { + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { - $typemap(jboxtype, MappedType) oldValue = itr.getValue(); + $typemap(jboxtype, T) oldValue = itr.getValue(); itr.setValue(value); return oldValue; } else { @@ -90,14 +90,14 @@ template } } - public $typemap(jboxtype, MappedType) remove(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + public $typemap(jboxtype, T) remove(Object key) { + if (!(key instanceof $typemap(jboxtype, K))) { return null; } - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { - $typemap(jboxtype, MappedType) oldValue = itr.getValue(); + $typemap(jboxtype, T) oldValue = itr.getValue(); removeUnchecked(itr); return oldValue; } else { @@ -105,31 +105,31 @@ template } } - public java.util.Set> entrySet() { - java.util.Set> setToReturn = - new java.util.HashSet>(); + public java.util.Set> entrySet() { + java.util.Set> setToReturn = + new java.util.HashSet>(); Iterator itr = begin(); final Iterator end = end(); while (itr.isNot(end)) { - setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { + setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() { private Iterator iterator; - private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)> init(Iterator iterator) { + private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) { this.iterator = iterator; return this; } - public $typemap(jboxtype, KeyType) getKey() { + public $typemap(jboxtype, K) getKey() { return iterator.getKey(); } - public $typemap(jboxtype, MappedType) getValue() { + public $typemap(jboxtype, T) getValue() { return iterator.getValue(); } - public $typemap(jboxtype, MappedType) setValue($typemap(jboxtype, MappedType) newValue) { - $typemap(jboxtype, MappedType) oldValue = iterator.getValue(); + public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) { + $typemap(jboxtype, T) oldValue = iterator.getValue(); iterator.setValue(newValue); return oldValue; } @@ -144,9 +144,9 @@ template public: typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef KeyType key_type; - typedef MappedType mapped_type; - typedef std::pair< const KeyType, MappedType > value_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; @@ -158,8 +158,8 @@ template struct iterator { %typemap(javaclassmodifiers) iterator "protected class" %extend { - std::map::iterator getNextUnchecked() { - std::map::iterator copy = (*$self); + std::map< K, T, C >::iterator getNextUnchecked() { + std::map< K, T, C >::iterator copy = (*$self); return ++copy; } @@ -167,15 +167,15 @@ template return (*$self != other); } - KeyType getKey() const { + K getKey() const { return (*$self)->first; } - MappedType getValue() const { + T getValue() const { return (*$self)->second; } - void setValue(const MappedType& newValue) { + void setValue(const T& newValue) { (*$self)->second = newValue; } } @@ -184,7 +184,7 @@ template %rename(isEmpty) empty; bool empty() const; void clear(); - iterator find(const KeyType& key); + iterator find(const K& key); iterator begin(); iterator end(); %extend { @@ -194,15 +194,15 @@ template return SWIG_MapSize(self->size()); } - bool containsImpl(const KeyType& key) { + bool containsImpl(const K& key) { return (self->count(key) > 0); } - void putUnchecked(const KeyType& key, const MappedType& value) { + void putUnchecked(const K& key, const T& value) { (*self)[key] = value; } - void removeUnchecked(const std::map::iterator itr) { + void removeUnchecked(const std::map< K, T, C >::iterator itr) { self->erase(itr); } } diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 57ebe4e39..8f62d7290 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -46,10 +46,10 @@ namespace std { -template class unordered_map { +template class unordered_map { -%typemap(javabase) std::unordered_map - "java.util.AbstractMap<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>" +%typemap(javabase) std::unordered_map + "java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>" %proxycode %{ @@ -58,19 +58,19 @@ template class unordered_map { } public boolean containsKey(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + if (!(key instanceof $typemap(jboxtype, K))) { return false; } - return containsImpl(($typemap(jboxtype, KeyType))key); + return containsImpl(($typemap(jboxtype, K))key); } - public $typemap(jboxtype, MappedType) get(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + public $typemap(jboxtype, T) get(Object key) { + if (!(key instanceof $typemap(jboxtype, K))) { return null; } - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { return itr.getValue(); } @@ -78,10 +78,10 @@ template class unordered_map { return null; } - public $typemap(jboxtype, MappedType) put($typemap(jboxtype, KeyType) key, $typemap(jboxtype, MappedType) value) { - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + public $typemap(jboxtype, T) put($typemap(jboxtype, K) key, $typemap(jboxtype, T) value) { + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { - $typemap(jboxtype, MappedType) oldValue = itr.getValue(); + $typemap(jboxtype, T) oldValue = itr.getValue(); itr.setValue(value); return oldValue; } else { @@ -90,14 +90,14 @@ template class unordered_map { } } - public $typemap(jboxtype, MappedType) remove(Object key) { - if (!(key instanceof $typemap(jboxtype, KeyType))) { + public $typemap(jboxtype, T) remove(Object key) { + if (!(key instanceof $typemap(jboxtype, K))) { return null; } - Iterator itr = find(($typemap(jboxtype, KeyType)) key); + Iterator itr = find(($typemap(jboxtype, K)) key); if (itr.isNot(end())) { - $typemap(jboxtype, MappedType) oldValue = itr.getValue(); + $typemap(jboxtype, T) oldValue = itr.getValue(); removeUnchecked(itr); return oldValue; } else { @@ -105,31 +105,31 @@ template class unordered_map { } } - public java.util.Set> entrySet() { - java.util.Set> setToReturn = - new java.util.HashSet>(); + public java.util.Set> entrySet() { + java.util.Set> setToReturn = + new java.util.HashSet>(); Iterator itr = begin(); final Iterator end = end(); while (itr.isNot(end)) { - setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() { + setToReturn.add(new Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)>() { private Iterator iterator; - private Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)> init(Iterator iterator) { + private Entry<$typemap(jboxtype, K), $typemap(jboxtype, T)> init(Iterator iterator) { this.iterator = iterator; return this; } - public $typemap(jboxtype, KeyType) getKey() { + public $typemap(jboxtype, K) getKey() { return iterator.getKey(); } - public $typemap(jboxtype, MappedType) getValue() { + public $typemap(jboxtype, T) getValue() { return iterator.getValue(); } - public $typemap(jboxtype, MappedType) setValue($typemap(jboxtype, MappedType) newValue) { - $typemap(jboxtype, MappedType) oldValue = iterator.getValue(); + public $typemap(jboxtype, T) setValue($typemap(jboxtype, T) newValue) { + $typemap(jboxtype, T) oldValue = iterator.getValue(); iterator.setValue(newValue); return oldValue; } @@ -144,9 +144,9 @@ template class unordered_map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef KeyType key_type; - typedef MappedType mapped_type; - typedef std::pair< const KeyType, MappedType > value_type; + typedef K key_type; + typedef T mapped_type; + typedef std::pair< const K, T > value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; @@ -158,8 +158,8 @@ template class unordered_map { struct iterator { %typemap(javaclassmodifiers) iterator "protected class" %extend { - std::unordered_map::iterator getNextUnchecked() { - std::unordered_map::iterator copy = (*$self); + std::unordered_map< K, T >::iterator getNextUnchecked() { + std::unordered_map< K, T >::iterator copy = (*$self); return ++copy; } @@ -167,15 +167,15 @@ template class unordered_map { return (*$self != other); } - KeyType getKey() const { + K getKey() const { return (*$self)->first; } - MappedType getValue() const { + T getValue() const { return (*$self)->second; } - void setValue(const MappedType& newValue) { + void setValue(const T& newValue) { (*$self)->second = newValue; } } @@ -184,7 +184,7 @@ template class unordered_map { %rename(isEmpty) empty; bool empty() const; void clear(); - iterator find(const KeyType& key); + iterator find(const K& key); iterator begin(); iterator end(); %extend { @@ -194,15 +194,15 @@ template class unordered_map { return SWIG_MapSize(self->size()); } - bool containsImpl(const KeyType& key) { + bool containsImpl(const K& key) { return (self->count(key) > 0); } - void putUnchecked(const KeyType& key, const MappedType& value) { + void putUnchecked(const K& key, const T& value) { (*self)[key] = value; } - void removeUnchecked(const std::unordered_map::iterator itr) { + void removeUnchecked(const std::unordered_map< K, T >::iterator itr) { self->erase(itr); } } From 52063a732b0133a18819d866d8ecd5facdff1ede Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 21:57:26 +0000 Subject: [PATCH 1449/2031] Consistent parameter names for std::pair --- Lib/csharp/std_pair.i | 6 +++--- Lib/d/std_pair.i | 6 +++--- Lib/go/std_pair.i | 4 ++-- Lib/guile/std_pair.i | 16 ++++++++-------- Lib/java/std_pair.i | 4 ++-- Lib/javascript/jsc/std_pair.i | 4 ++-- Lib/javascript/v8/std_pair.i | 4 ++-- Lib/lua/std_pair.i | 4 ++-- Lib/mzscheme/std_pair.i | 16 ++++++++-------- Lib/ocaml/std_pair.i | 4 ++-- Lib/perl5/std_pair.i | 6 +++--- Lib/php/std_pair.i | 4 ++-- Lib/scilab/std_pair.i | 4 ++-- Lib/std/std_pair.i | 16 ++++++++-------- Lib/tcl/std_pair.i | 4 ++-- 15 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Lib/csharp/std_pair.i b/Lib/csharp/std_pair.i index 932849017..732347db5 100644 --- a/Lib/csharp/std_pair.i +++ b/Lib/csharp/std_pair.i @@ -22,10 +22,10 @@ namespace std { typedef U second_type; pair(); - pair(T t, U u); - pair(const pair& p); + pair(T first, U second); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/d/std_pair.i b/Lib/d/std_pair.i index 932849017..732347db5 100644 --- a/Lib/d/std_pair.i +++ b/Lib/d/std_pair.i @@ -22,10 +22,10 @@ namespace std { typedef U second_type; pair(); - pair(T t, U u); - pair(const pair& p); + pair(T first, U second); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/go/std_pair.i b/Lib/go/std_pair.i index 867bb2cd5..732347db5 100644 --- a/Lib/go/std_pair.i +++ b/Lib/go/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index e738ecec9..050d4880a 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -119,9 +119,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -221,9 +221,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -321,9 +321,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -412,9 +412,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/java/std_pair.i b/Lib/java/std_pair.i index 1454eaa9c..75ad30315 100644 --- a/Lib/java/std_pair.i +++ b/Lib/java/std_pair.i @@ -24,9 +24,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/javascript/jsc/std_pair.i b/Lib/javascript/jsc/std_pair.i index 867bb2cd5..732347db5 100644 --- a/Lib/javascript/jsc/std_pair.i +++ b/Lib/javascript/jsc/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/javascript/v8/std_pair.i b/Lib/javascript/v8/std_pair.i index 7530e374e..b72c50b99 100644 --- a/Lib/javascript/v8/std_pair.i +++ b/Lib/javascript/v8/std_pair.i @@ -22,9 +22,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/lua/std_pair.i b/Lib/lua/std_pair.i index 558887789..410da9223 100644 --- a/Lib/lua/std_pair.i +++ b/Lib/lua/std_pair.i @@ -15,12 +15,12 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); T first; U second; }; template - pair make_pair(const T& t,const U& u); + pair make_pair(const T& first, const U& second); } diff --git a/Lib/mzscheme/std_pair.i b/Lib/mzscheme/std_pair.i index 52d2bdf87..75f6751cc 100644 --- a/Lib/mzscheme/std_pair.i +++ b/Lib/mzscheme/std_pair.i @@ -121,9 +121,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -223,9 +223,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -324,9 +324,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; @@ -419,9 +419,9 @@ namespace std { } pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/ocaml/std_pair.i b/Lib/ocaml/std_pair.i index 867bb2cd5..732347db5 100644 --- a/Lib/ocaml/std_pair.i +++ b/Lib/ocaml/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/perl5/std_pair.i b/Lib/perl5/std_pair.i index 932849017..732347db5 100644 --- a/Lib/perl5/std_pair.i +++ b/Lib/perl5/std_pair.i @@ -22,10 +22,10 @@ namespace std { typedef U second_type; pair(); - pair(T t, U u); - pair(const pair& p); + pair(T first, U second); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/php/std_pair.i b/Lib/php/std_pair.i index 867bb2cd5..732347db5 100644 --- a/Lib/php/std_pair.i +++ b/Lib/php/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/scilab/std_pair.i b/Lib/scilab/std_pair.i index bd0eb53fe..39ef008d3 100644 --- a/Lib/scilab/std_pair.i +++ b/Lib/scilab/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; diff --git a/Lib/std/std_pair.i b/Lib/std/std_pair.i index 001cd6738..800155f21 100644 --- a/Lib/std/std_pair.i +++ b/Lib/std/std_pair.i @@ -35,9 +35,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair< U1, U2 > &p); + template pair(const pair< U1, U2 > &other); T first; U second; @@ -76,8 +76,8 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T, U* >); pair(); - pair(T __a, U* __b); - pair(const pair& __p); + pair(T first, U* second); + pair(const pair& other); T first; U* second; @@ -112,8 +112,8 @@ namespace std { %typemap_traits_ptr(SWIG_TYPECHECK_PAIR, std::pair< T*, U >); pair(); - pair(T* __a, U __b); - pair(const pair& __p); + pair(T* first, U second); + pair(const pair& other); T* first; U second; @@ -148,8 +148,8 @@ namespace std { %typemap_traits(SWIG_TYPECHECK_PAIR, std::pair< T*, U* >); pair(); - pair(T* __a, U* __b); - pair(const pair& __p); + pair(T* first, U* second); + pair(const pair& other); T* first; U* second; diff --git a/Lib/tcl/std_pair.i b/Lib/tcl/std_pair.i index bd0eb53fe..39ef008d3 100644 --- a/Lib/tcl/std_pair.i +++ b/Lib/tcl/std_pair.i @@ -23,9 +23,9 @@ namespace std { pair(); pair(T first, U second); - pair(const pair& p); + pair(const pair& other); - template pair(const pair &p); + template pair(const pair &other); T first; U second; From 7b0402f89bb034a60041c1330dcc62ff6b5cc95a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Feb 2019 22:46:20 +0000 Subject: [PATCH 1450/2031] Changes file entry for Java STL support --- CHANGES.current | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5bc2b4982..91f63e6da 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,44 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-14: wsfulton + Add some missing copy constructors into STL containers. + +2019-02-14: bkotzz + [Java] #1356 Add STL containers: + std::unordered_map + std::unordered_set + std::set + +2019-02-14: bkotzz + [Java] #1356 std::map wrappers have been modified. Now the Java proxy class + extends java.util.AbstractMap. The std::map container looks and feels much like + a java.util.HashMap from Java. + + A few members have changed their names. If the old method signatures are needed, + then copy std_map.i from swig-3.0.12 and use that instead. Alternatively, + add the old missing methods to the new methods by using the following %proxycode: + + %extend std::map { + %proxycode %{ + // Old API + public boolean empty() { + return isEmpty(); + } + public void set($typemap(jboxtype, K) key, $typemap(jboxtype, T) x) { + put(key, x); + } + public void del($typemap(jboxtype, K) key) { + remove(key); + } + public boolean has_key($typemap(jboxtype, K) key) { + return containsKey(key); + } + %} + } + + *** POTENTIAL INCOMPATIBILITY *** + 2019-02-11: wsfulton [OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work and most of the test-suite is also working, so it is quite close to being a 'Supported' language. From 071803f0009dae51ecc07c6b0b80a0bcea70c2aa Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 15 Feb 2019 01:17:15 -0700 Subject: [PATCH 1451/2031] [OCaml] Fix segfaults when too few arguments are passed to a function Prevent segfaults when too few arguments are passed to a function. Length checks are not needed for the wrappers of overloaded functions -- the generated dispatch function already checks. Add default_args_runme.ml. Fix minor errors in some runtime tests. Extra args were being passed in some cases. --- Examples/ocaml/callback/runme.ml | 4 +- .../test-suite/ocaml/cpp_nodefault_runme.ml | 3 +- .../test-suite/ocaml/default_args_runme.ml | 58 +++++++++++++++++++ .../test-suite/ocaml/exception_order_runme.ml | 2 +- .../test-suite/ocaml/global_ns_arg_runme.ml | 2 +- .../test-suite/ocaml/throw_exception_runme.ml | 2 +- .../test-suite/ocaml/typemap_arrays_runme.ml | 2 +- Source/Modules/ocaml.cxx | 13 ++++- 8 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 Examples/test-suite/ocaml/default_args_runme.ml diff --git a/Examples/ocaml/callback/runme.ml b/Examples/ocaml/callback/runme.ml index a7d705241..ddc974984 100644 --- a/Examples/ocaml/callback/runme.ml +++ b/Examples/ocaml/callback/runme.ml @@ -18,7 +18,7 @@ let _ = print_endline "----------------------------------------" let callback = new_Callback '() let _ = caller -> "setCallback" (callback) let _ = caller -> "call" () -let _ = caller -> "delCallback" (0) +let _ = caller -> "delCallback" () let _ = print_endline "\nAdding and calling an OCaml callback" let _ = print_endline "------------------------------------" @@ -26,5 +26,5 @@ let _ = print_endline "------------------------------------" let callback = new_derived_object new_Callback (new_OCamlCallback) '() let _ = caller -> "setCallback" (callback) let _ = caller -> "call" () -let _ = caller -> "delCallback" (0) +let _ = caller -> "delCallback" () let _ = print_endline "\nOCaml exit" diff --git a/Examples/test-suite/ocaml/cpp_nodefault_runme.ml b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml index 51809c2ef..a0bd84071 100644 --- a/Examples/test-suite/ocaml/cpp_nodefault_runme.ml +++ b/Examples/test-suite/ocaml/cpp_nodefault_runme.ml @@ -12,7 +12,6 @@ let bar1 = new_Bar '() let gvar = _gvar '() let args = (C_list [ gvar ; foo2 ]) let _ = bar1 -> "consume" (args) -let args = '(1, 2) -let foo3 = bar1 -> "create" (args) +let foo3 = bar1 -> "create" (1, 2) let _ = foo3 -> "[a]" (6) let _ = assert ((foo3 -> "[a]" () as int) = 6) diff --git a/Examples/test-suite/ocaml/default_args_runme.ml b/Examples/test-suite/ocaml/default_args_runme.ml new file mode 100644 index 000000000..1654b011f --- /dev/null +++ b/Examples/test-suite/ocaml/default_args_runme.ml @@ -0,0 +1,58 @@ +open Swig +open Default_args + +let _ = + assert (_anonymous '() as int = 7771); + assert (_anonymous '(1234) as int = 1234); + assert (_booltest '() as bool = true); + assert (_booltest '(true) as bool = true); + assert (_booltest '(false) as bool = false); + let ec = new_EnumClass '() in + assert (ec -> blah () as bool = true); + let de = new_DerivedEnumClass '() in + assert (de -> accelerate () = C_void); + let args = _SLOW '() in + assert (de -> accelerate (args) = C_void); + assert (_Statics_staticmethod '() as int = 60); + assert (_cfunc1 '(1) as float = 2.); + assert (_cfunc2 '(1) as float = 3.); + assert (_cfunc3 '(1) as float = 4.); + + let f = new_Foo '() in + assert (f -> newname () = C_void); + assert (f -> newname (1) = C_void); + (* TODO: There needs to be a more elegant way to pass NULL/nullptr. *) + let args = C_list [ C_int 2 ; C_ptr (0L, 0L) ] in + assert (f -> double_if_void_ptr_is_null (args) as int = 4); + assert (f -> double_if_void_ptr_is_null (3) as int = 6); + let args = C_list [ C_int 4 ; C_ptr (0L, 0L) ] in + assert (f -> double_if_handle_is_null (args) as int = 8); + assert (f -> double_if_handle_is_null (5) as int = 10); + let args = C_list [ C_int 6 ; C_ptr (0L, 0L) ] in + assert (f -> double_if_dbl_ptr_is_null (args) as int = 12); + assert (f -> double_if_dbl_ptr_is_null (7) as int = 14); + + let k = new_Klass '(22) in + let k2 = _Klass_inc (C_list [ C_int 100 ; k ]) in + assert (k2 -> "[val]" () as int = 122); + let k2 = _Klass_inc '(100) in + assert (k2 -> "[val]" () as int = 99); + let k2 = _Klass_inc '() in + assert (k2 -> "[val]" () as int = 0); + + assert (_seek '() = C_void); + assert (_seek (C_int64 10L) = C_void); + + assert (_slightly_off_square '(10) as int = 102); + assert (_slightly_off_square '() as int = 291); + + assert (_casts1 '() as char = '\x00'); + assert (_casts2 '() as string = "Hello"); + assert (_casts1 '("Ciao") as string = "Ciao"); + assert (_chartest1 '() as char = 'x'); + assert (_chartest2 '() as char = '\x00'); + assert (_chartest3 '() as char = '\x01'); + assert (_chartest4 '() as char = '\n'); + assert (_chartest5 '() as char = 'B'); + assert (_chartest6 '() as char = 'C'); +;; diff --git a/Examples/test-suite/ocaml/exception_order_runme.ml b/Examples/test-suite/ocaml/exception_order_runme.ml index 728c3c315..9e987c84b 100644 --- a/Examples/test-suite/ocaml/exception_order_runme.ml +++ b/Examples/test-suite/ocaml/exception_order_runme.ml @@ -5,7 +5,7 @@ let a = new_A '() let check meth args expected = try - ignore ((invoke a) meth (C_list [ args ])); assert false + ignore ((invoke a) meth (args)); assert false with Failure msg -> assert (msg = expected) let _ = diff --git a/Examples/test-suite/ocaml/global_ns_arg_runme.ml b/Examples/test-suite/ocaml/global_ns_arg_runme.ml index a78910db4..7717e52d9 100644 --- a/Examples/test-suite/ocaml/global_ns_arg_runme.ml +++ b/Examples/test-suite/ocaml/global_ns_arg_runme.ml @@ -2,4 +2,4 @@ open Swig open Global_ns_arg let _ = assert ((_foo '(1) as int) = 1) -let _ = assert ((_bar_fn '(1) as int) = 1) +let _ = assert ((_bar_fn '() as int) = 1) diff --git a/Examples/test-suite/ocaml/throw_exception_runme.ml b/Examples/test-suite/ocaml/throw_exception_runme.ml index 8c2606129..5c4c0922a 100644 --- a/Examples/test-suite/ocaml/throw_exception_runme.ml +++ b/Examples/test-suite/ocaml/throw_exception_runme.ml @@ -5,7 +5,7 @@ let x = new_Foo '() let check meth args expected = try - let _ = ((invoke x) meth (C_list [ args ])) in assert false + let _ = ((invoke x) meth (args)) in assert false with Failure msg -> assert (msg = expected) let _ = diff --git a/Examples/test-suite/ocaml/typemap_arrays_runme.ml b/Examples/test-suite/ocaml/typemap_arrays_runme.ml index 17a133c3c..611e1d338 100644 --- a/Examples/test-suite/ocaml/typemap_arrays_runme.ml +++ b/Examples/test-suite/ocaml/typemap_arrays_runme.ml @@ -1,4 +1,4 @@ open Swig open Typemap_arrays -let _ = assert (_sumA '() as int = 60) +let _ = assert (_sumA '(0) as int = 60) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 417454375..8b248bad2 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -553,7 +553,18 @@ public: numargs = emit_num_arguments(l); numreq = emit_num_required(l); - + if (!isOverloaded) { + if (numargs > 0) { + if (numreq > 0) { + Printf(f->code, "if (caml_list_length(args) < %d || caml_list_length(args) > %d) {\n", numreq, numargs); + } else { + Printf(f->code, "if (caml_list_length(args) > %d) {\n", numargs); + } + Printf(f->code, "caml_invalid_argument(\"Incorrect number of arguments passed to '%s'\");\n}\n", iname); + } else { + Printf(f->code, "if (caml_list_length(args) > 0) caml_invalid_argument(\"'%s' takes no arguments\");\n", iname); + } + } Printf(f->code, "swig_result = Val_unit;\n"); // Now write code to extract the parameters (this is super ugly) From 62417708fdb63c7eff0f2921adae898475d2f980 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Feb 2019 21:58:38 +0000 Subject: [PATCH 1452/2031] Better name for container back-reference attribute Mangle name with swig so as not to clash with any attribute names a user might use. Remove Doxygen style comments - we don't use Doxygen in SWIG. --- Lib/python/pycontainer.swg | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index ec31bad0d..a2ee9522c 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -44,7 +44,7 @@ %fragment("reference_container_owner", "header", fragment="container_owner_attribute_init") { namespace swig { PyObject* container_owner_attribute() { - static PyObject* attr = SWIG_Python_str_FromChar("__owner"); + static PyObject* attr = SWIG_Python_str_FromChar("__swig_container"); return attr; } @@ -52,18 +52,19 @@ namespace swig { struct container_owner { // By default, do not add the back-reference (for value types) // Specialization below will check the reference for pointer types. - static bool reference(PyObject* child, PyObject* owner) - { return false; } + static bool reference(PyObject* child, PyObject* owner) { + return false; + } }; template <> struct container_owner { - /** + /* * Call to add a back-reference to the owning object when returning a - * reference from a container. Will only set the reference if child + * reference from a container. Will only set the reference if child * is a SWIG wrapper object that does not own the pointer. * - * @return if the reference was set or not + * returns whether the reference was set or not */ static bool reference(PyObject* child, PyObject* owner) { SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); From b7a400f9914f658b1fe5c5905d60403edbbd7ca1 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 16 Feb 2019 01:07:31 -0700 Subject: [PATCH 1453/2031] [OCaml] Add a typecheck typemap for SWIGTYPE This fixes many of the remaining warnings in the OCaml test suite. Add multiple runtime tests. --- Doc/Manual/SWIGPlus.html | 2 +- .../ocaml/extend_placement_runme.ml | 53 ++++++++++++++++ .../ocaml/overload_template_runme.ml | 60 +++++++++++++++++++ ...ate_default_arg_overloaded_extend_runme.ml | 17 ++++++ .../ocaml/template_default_arg_runme.ml | 52 ++++++++++++++++ Lib/ocaml/ocaml.swg | 2 +- Lib/ocaml/std_string.i | 1 + Lib/ocaml/typecheck.i | 34 ++++++++--- 8 files changed, 211 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/ocaml/extend_placement_runme.ml create mode 100644 Examples/test-suite/ocaml/overload_template_runme.ml create mode 100644 Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml create mode 100644 Examples/test-suite/ocaml/template_default_arg_runme.ml diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index a6cb93f63..8ad9daedf 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4616,7 +4616,7 @@ except Error, e:

    Details of how to tailor code for handling the caught C++ exception and converting it into the target language's exception/error handling mechanism -is outlined in the "throws" typemap section. +is outlined in the "throws" typemap section.

    diff --git a/Examples/test-suite/ocaml/extend_placement_runme.ml b/Examples/test-suite/ocaml/extend_placement_runme.ml new file mode 100644 index 000000000..31d9ae671 --- /dev/null +++ b/Examples/test-suite/ocaml/extend_placement_runme.ml @@ -0,0 +1,53 @@ +open Swig +open Extend_placement + +let _ = + let f = new_Foo '() in + assert (f -> spam () as int = 1); + assert (new_Foo '(1) -> spam () as int = 1); + let f = new_Foo '(1, 1) in + assert (f -> spam () as int = 1); + assert (f -> spam ("hello") as int = 2); + assert (f -> spam (1) as int = 1); + assert (f -> spam (1, 2) as int = 3); + assert (f -> spam (2, 4, 6) as int = 6); + assert (f -> spam (f) as int = 0); + let arg = C_double 1. in + assert (f -> spam (f, arg) as int = 0); + + assert (new_Bar '() -> spam () as int = 1); + let b = new_Bar '(1) in + assert (b -> spam () as int = 1); + assert (b -> spam ("hello") as int = 2); + assert (b -> spam (1) as int = 1); + assert (b -> spam (1, 2) as int = 3); + assert (b -> spam (2, 4, 6) as int = 6); + assert (b -> spam (b) as int = 0); + let arg = C_double 1. in + assert (b -> spam (b, arg) as int = 0); + + assert (new_FooTi '() -> spam () as int = 1); + assert (new_FooTi '(1) -> spam () as int = 1); + let f = new_FooTi '(1, 1) in + assert (f -> spam () as int = 1); + assert (f -> spam ("hello") as int = 2); + assert (f -> spam (1) as int = 1); + assert (f -> spam (1, 2) as int = 3); + assert (f -> spam (2, 4, 6) as int = 6); + let foo = new_Foo '() in + assert (f -> spam (foo) as int = 0); + let arg = C_double 1. in + assert (f -> spam (foo, arg) as int = 0); + + assert (new_BarTi '() -> spam () as int = 1); + let b = new_BarTi '(1) in + assert (b -> spam () as int = 1); + assert (b -> spam ("hello") as int = 2); + assert (b -> spam (1) as int = 1); + assert (b -> spam (1, 2) as int = 3); + assert (b -> spam (2, 4, 6) as int = 6); + let bar = new_Bar '() in + assert (b -> spam (bar) as int = 0); + let arg = C_double 1. in + assert (b -> spam (bar, arg) as int = 0); +;; diff --git a/Examples/test-suite/ocaml/overload_template_runme.ml b/Examples/test-suite/ocaml/overload_template_runme.ml new file mode 100644 index 000000000..42a4a397a --- /dev/null +++ b/Examples/test-suite/ocaml/overload_template_runme.ml @@ -0,0 +1,60 @@ +open Swig +open Overload_template + +let _ = + assert (_foo '() as int = 3); + assert (_maximum '(3, 4) as int = 4); + assert (_maximum '(3.4, 5.2) as float > 5.); + assert (_mix1 '("hi") as int = 101); + assert (_mix1 '(1.0, 1.0) as int = 102); + assert (_mix1 '(1.0) as int = 103); + assert (_mix2 '("hi") as int = 101); + assert (_mix2 '(1.0, 1.0) as int = 102); + assert (_mix2 '(1.0) as int = 103); + assert (_mix3 '("hi") as int = 101); + assert (_mix3 '(1.0, 1.0) as int = 102); + assert (_mix3 '(1.0) as int = 103); + + assert (_overtparams1 '(100) as int = 10); + assert (_overtparams1 '(100.0, 100) as int = 20); + assert (_overtparams2 '(100.0, 100) as int = 40); + assert (_overloaded '() as int = 60); + assert (_overloaded '(100.0, 100) as int = 70); + assert (_overloadedagain '("hello") as int = 80); + assert (_overloadedagain '() as int = 90); + + assert (_specialization '(10) as int = 202); + assert (_specialization '(10.0) as int = 203); + assert (_specialization '(10, 10) as int = 204); + assert (_specialization '(10.0, 10.0) as int = 205); + assert (_specialization '("hi", "hi") as int = 201); + + assert (_xyz '() = C_void); + assert (_xyz_int '() = C_void); + assert (_xyz_double '() = C_void); + + assert (_overload '("hi") as int = 0); + assert (_overload '(1) as int = 10); + assert (_overload '(1, 1) as int = 20); + assert (_overload '(1, "hello") as int = 30); + let k = new_Klass '() in + assert (_overload '(k) as int = 10); + assert (_overload '(k, k) as int = 20); + assert (_overload '(k, "hello") as int = 30); + assert (_overload '(10.0, "hi") as int = 40); + assert (_overload '() as int = 50); + + assert (_nsoverload '("hi") as int = 1000); + assert (_nsoverload '(1) as int = 1010); + assert (_nsoverload '(1, 1) as int = 1020); + assert (_nsoverload '(1, "hello") as int = 1030); + assert (_nsoverload '(k) as int = 1010); + assert (_nsoverload '(k, k) as int = 1020); + assert (_nsoverload '(k, "hello") as int = 1030); + assert (_nsoverload '(10.0, "hi") as int = 1040); + assert (_nsoverload '() as int = 1050); + + assert (_A_foo '(1) = C_void); + let b = new_B '() in + assert (b -> foo(1) = C_void); +;; diff --git a/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml b/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml new file mode 100644 index 000000000..27fb9b543 --- /dev/null +++ b/Examples/test-suite/ocaml/template_default_arg_overloaded_extend_runme.ml @@ -0,0 +1,17 @@ +open Swig +open Template_default_arg_overloaded_extend + +let _ = + let rs = new_ResultSet '() and sp = new_SearchPoint '() in + assert (rs -> go_get_method (0, sp) as int = -1); + assert (rs -> go_get_method (0, sp, 100) as int = 100); + assert (rs -> go_get_template (0, sp) as int = -2); + assert (rs -> go_get_template (0, sp, 100) as int = 100); + + assert (rs -> over () as string = "over(int)"); + assert (rs -> over (10) as string = "over(int)"); + assert (rs -> over (sp) as string = "over(giai2::SearchPoint, int)"); + assert (rs -> over (sp, 10) as string = "over(giai2::SearchPoint, int)"); + assert (rs -> over (true, sp) as string = "over(bool, gaia2::SearchPoint, int)"); + assert (rs -> over (true, sp, 10) as string = "over(bool, gaia2::SearchPoint, int)"); +;; diff --git a/Examples/test-suite/ocaml/template_default_arg_runme.ml b/Examples/test-suite/ocaml/template_default_arg_runme.ml new file mode 100644 index 000000000..94f2291f1 --- /dev/null +++ b/Examples/test-suite/ocaml/template_default_arg_runme.ml @@ -0,0 +1,52 @@ +open Swig +open Template_default_arg + +let _ = + let helloInt = new_Hello_int '() and enumArg = _hi '() in + assert (helloInt -> foo (enumArg) = C_void); + assert (helloInt -> foo () = C_void); + + let x = new_X_int '() in + assert (x -> meth (20.0, 200) as int = 200); + assert (x -> meth (20) as int = 20); + assert (x -> meth () as int = 0); + + let x = new_Y_unsigned '() in + let args = C_list [ C_double 20.0 ; C_uint 200l ] in + assert (x -> meth (args) as int = 200); + let args = C_uint 20l in + assert (x -> meth (args) as int = 20); + assert (x -> meth () as int = 0); + + let x = new_X_longlong '() in + assert (x -> meth (20.0) as int = 0); + let x = new_X_longlong '(20.0) in + assert (x -> meth (20.0) as int = 0); + let args = C_list [ C_double 20.0 ; C_int64 200L ] in + let x = new_X_longlong '(args) in + assert (x -> meth (20.0) as int = 0); + + let x = new_X_int '() in + assert (x -> meth (20.0) as int = 0); + let x = new_X_int '(20.0) in + assert (x -> meth (20.0) as int = 0); + let x = new_X_int '(20.0, 200) in + assert (x -> meth (20.0) as int = 0); + + let arg = new_Foo_int '() in + assert (_ott '(arg) as int = 30); + assert (_ott '() as int = 10); + assert (_ott '(1) as int = 10); + assert (_ott '(1, 1) as int = 10); + assert (_ott '("hi") as int = 20); + assert (_ott '("hi", 1) as int = 20); + assert (_ott '("hi", 1, 1) as int = 20); + + let arg = new_Hello_int '() in + assert (_ottstring '(arg, "hi") as int = 40); + assert (_ottstring '(arg) as int = 40); + assert (_ottint '(arg, 1) as int = 50); + assert (_ottint '(arg) as int = 50); + assert (_ott '(arg, 1.0) as int = 60); + assert (_ott '(arg) as int = 60); +;; diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 2da3fb769..3d552cc50 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -62,7 +62,7 @@ extern "C" { SWIG_TypeCheckStruct(source_type, dest_type ); #ifdef TYPE_CAST_VERBOSE fprintf( stderr, "Typecheck -> %s\n", - tc ? tc->str : "" ); + tc ? tc->type->str : "" ); #endif if( tc ) { int newmemory = 0; diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index 0ea9b4e2d..712c3bb73 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -86,6 +86,7 @@ class wstring; %typemap(out) string * { $result = caml_val_string_len((*$1).c_str(),(*$1).size()); } +%typemap(typecheck) string, const string & = char *; } #ifdef ENABLE_CHARPTR_ARRAY diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 2cc8dcbec..fd1cb16ed 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -135,24 +135,42 @@ } %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] { - void *ptr; - $1 = !caml_ptr_val_internal($input, &ptr,$descriptor); + if (!Is_block($input) || !(SWIG_Tag_val($input) == C_obj || SWIG_Tag_val($input) == C_ptr)) { + $1 = 0; + } else { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, $descriptor); + } } -#if 0 - %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { - void *ptr; - $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); + swig_type_info *typeinfo; + if (!Is_block($input)) { + $1 = 0; + } else { + switch (SWIG_Tag_val($input)) { + case C_obj: { + void *ptr; + $1 = !caml_ptr_val_internal($input, &ptr, $&1_descriptor); + break; + } + case C_ptr: { + typeinfo = (swig_type_info *)SWIG_Int64_val(SWIG_Field($input, 1)); + $1 = SWIG_TypeCheck("$1_type", typeinfo) != NULL; + break; + } + default: $1 = 0; break; + } + } } -#endif - %typecheck(SWIG_TYPECHECK_VOIDPTR) void * { void *ptr; $1 = !caml_ptr_val_internal($input, &ptr, 0); } +%typecheck(SWIG_TYPECHECK_SWIGOBJECT) CAML_VALUE "$1 = 1;" + /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ From eb7b989c6173fd22911d69636e64f2e4a044c1d6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Feb 2019 08:09:56 +0000 Subject: [PATCH 1454/2031] Fix parser error containing multiple #define statements inside an enum. The second #define fails to parse: enum FooEnum { ENUM1 = 0, ENUM2 = 1, #define MACRO_DEF1 "Hello" #define MACRO_DEF2 "World!" ENUM3 = 2, ENUM4 = 3, }; Bug mentioned at https://sourceforge.net/p/swig/patches/333/ --- CHANGES.current | 18 ++++++++ Examples/test-suite/common.mk | 1 - Examples/test-suite/cpp_broken.i | 12 ------ Examples/test-suite/enum_macro.i | 42 +++++++++++++++++++ .../test-suite/java/enum_macro_runme.java | 24 +++++++++++ Source/CParse/parser.y | 12 ++++-- 6 files changed, 92 insertions(+), 17 deletions(-) delete mode 100644 Examples/test-suite/cpp_broken.i diff --git a/CHANGES.current b/CHANGES.current index 5c1f00f3f..d3e84c86d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,24 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-16: wsfulton + Fix parser error containing multiple #define statements inside an enum. + + The second #define fails to parse: + + enum FooEnum { + ENUM1 = 0, + ENUM2 = 1, + + #define MACRO_DEF1 "Hello" + #define MACRO_DEF2 "World!" + + ENUM3 = 2, + ENUM4 = 3, + }; + + Bug mentioned at https://sourceforge.net/p/swig/patches/333/ + 2019-02-14: wsfulton Add some missing copy constructors into STL containers. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 04b39e75f..6794c2e8b 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -83,7 +83,6 @@ Makefile: $(srcdir)/Makefile.in ../../../config.status # Broken C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_BROKEN += \ constants \ - cpp_broken \ director_nested_class \ exception_partial_info \ extend_variable \ diff --git a/Examples/test-suite/cpp_broken.i b/Examples/test-suite/cpp_broken.i deleted file mode 100644 index 84d6122e5..000000000 --- a/Examples/test-suite/cpp_broken.i +++ /dev/null @@ -1,12 +0,0 @@ -%module cpp_broken - - -// bug #940318 -%inline %{ -typedef enum { -eZero = 0 -#define ONE 1 -} EFoo; -%} - - diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i index c058cdf72..a5e8a2461 100644 --- a/Examples/test-suite/enum_macro.i +++ b/Examples/test-suite/enum_macro.i @@ -97,3 +97,45 @@ enum Greeks13 #define GREEK13 -13 }; +/* Multiple macros */ + +%inline %{ +enum Greeks14 +{ +#define GREEK14a -14 +#define GREEK14b -140 + theta14, +}; + +enum Greeks15 +{ + alpha15 = 150, + beta15 = 151, +#define GREEK15a -150 +#define GREEK15b -151 + theta15 = 152, + delta15 = 153 +}; + +enum Greeks16 +{ + alpha16 = 160, + beta16 = 161, +#define GREEK16a -160 +#define GREEK16b -161 +#define GREEK16c -162 + theta16 = 162, + delta16 = 163 +}; + +enum Greeks17 +{ + alpha17 = 170, + beta17 = 171, + theta17 = 172, + delta17 = 173 +#define GREEK17a -170 +#define GREEK17b -171 +#define GREEK17c -172 +}; +%} diff --git a/Examples/test-suite/java/enum_macro_runme.java b/Examples/test-suite/java/enum_macro_runme.java index 4ac7409ee..c05793347 100644 --- a/Examples/test-suite/java/enum_macro_runme.java +++ b/Examples/test-suite/java/enum_macro_runme.java @@ -88,6 +88,30 @@ public class enum_macro_runme { { Greeks13 a = null; } + { + Greeks15 a = Greeks15.alpha15; + a = Greeks15.beta15; + a = Greeks15.theta15; + a = Greeks15.delta15; + if (a.swigValue() != 153) + throw new RuntimeException("Greeks15"); + } + { + Greeks16 a = Greeks16.alpha16; + a = Greeks16.beta16; + a = Greeks16.theta16; + a = Greeks16.delta16; + if (a.swigValue() != 163) + throw new RuntimeException("Greeks16"); + } + { + Greeks17 a = Greeks17.alpha17; + a = Greeks17.beta17; + a = Greeks17.theta17; + a = Greeks17.delta17; + if (a.swigValue() != 173) + throw new RuntimeException("Greeks17"); + } } } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 29e5705bf..f20f1db2f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6342,8 +6342,12 @@ ename : identifier { $$ = $1; } | empty { $$ = (char *) 0;} ; -optional_ignored_define - : constant_directive +constant_directives : constant_directive + | constant_directive constant_directives + ; + +optional_ignored_defines + : constant_directives | empty ; @@ -6364,7 +6368,7 @@ enumlist : enumlist_item optional_ignored_define_after_comma { Setattr($2,"_last",NULL); $$ = $1; } - | optional_ignored_define { + | optional_ignored_defines { $$ = 0; } ; @@ -6380,7 +6384,7 @@ enumlist_tail : COMMA enumlist_item { } ; -enumlist_item : optional_ignored_define edecl_with_dox optional_ignored_define { +enumlist_item : optional_ignored_defines edecl_with_dox optional_ignored_defines { $$ = $2; } ; From de861bea6481f2b44f4ca908ea378b093e29924d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 16 Feb 2019 13:06:43 +0000 Subject: [PATCH 1455/2031] Memory leak fixes calling Swig_scopename_split --- Source/Swig/naming.c | 17 +++++++++-------- Source/Swig/symbol.c | 4 ++-- Source/Swig/typesys.c | 6 ++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 136df1987..1b6c963e7 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -439,8 +439,8 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType rn = name_object_get(namehash, name, decl, ncdecl); } if (!rn && Swig_scopename_check(name)) { - String *nprefix = NewStringEmpty(); - String *nlast = NewStringEmpty(); + String *nprefix = 0; + String *nlast = 0; Swig_scopename_split(name, &nprefix, &nlast); rn = name_object_get(namehash, nlast, decl, ncdecl); Delete(nlast); @@ -579,8 +579,8 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d if (name && SwigType_istemplate(name)) { String *nodetype = nodeType(node); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { - String *nprefix = NewStringEmpty(); - String *nlast = NewStringEmpty(); + String *nprefix = 0; + String *nlast = 0; String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); @@ -1434,8 +1434,8 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, if (name && n && SwigType_istemplate(name)) { String *nodetype = nodeType(n); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { - String *nprefix = NewStringEmpty(); - String *nlast = NewStringEmpty(); + String *nprefix = 0; + String *nlast = 0; String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); @@ -1659,12 +1659,13 @@ String *Swig_name_str(Node *n) { if (SwigType_istemplate(name)) { String *nodetype = nodeType(n); if (nodetype && (Equal(nodetype, "constructor") || Equal(nodetype, "destructor"))) { - String *nprefix = NewStringEmpty(); - String *nlast = NewStringEmpty(); + String *nprefix = 0; + String *nlast = 0; String *tprefix; Swig_scopename_split(name, &nprefix, &nlast); tprefix = SwigType_templateprefix(nlast); Delete(nlast); + Delete(nprefix); Delete(name); name = tprefix; } diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index ff704b87d..aacaf24be 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1039,8 +1039,8 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt return 0; if (!prefix) { Node *n; - String *bname; - String *prefix; + String *bname = 0; + String *prefix = 0; Swig_scopename_split(name, &prefix, &bname); n = symbol_lookup_qualified(bname, symtab, prefix, local, checkfunc); Delete(bname); diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index e3adce1e9..7564db1a6 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -839,10 +839,8 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) { newtype = 1; type = template_parameters_resolve(base); } - if (namebase) - Delete(namebase); - if (nameprefix) - Delete(nameprefix); + Delete(namebase); + Delete(nameprefix); } else { if (SwigType_isfunction(base)) { List *parms; From 10d62aecd5808bb5859f34cf1b2c0f9e6371045e Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 17 Feb 2019 01:41:59 -0700 Subject: [PATCH 1456/2031] [OCaml] Fix the wrapmacro test Add a typecheck typemap for size_t and const size_t &. Add the const qualifier to the typemaps for primitive reference types. Add multiple runtime tests. --- Doc/Manual/Extending.html | 2 +- Examples/ocaml/argout_ref/example.i | 6 +++--- Examples/test-suite/ocaml/global_vars_runme.ml | 15 +++++++++++++++ .../ocaml/reference_global_vars_runme.ml | 2 +- Examples/test-suite/ocaml/sizet_runme.ml | 10 ++++++++++ .../test-suite/ocaml/typedef_reference_runme.ml | 11 +++++++++++ Examples/test-suite/ocaml/wrapmacro_runme.ml | 10 ++++++++++ Lib/ocaml/std_common.i | 1 + Lib/ocaml/typecheck.i | 3 ++- Lib/ocaml/typemaps.i | 8 ++++---- 10 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/ocaml/global_vars_runme.ml create mode 100644 Examples/test-suite/ocaml/sizet_runme.ml create mode 100644 Examples/test-suite/ocaml/typedef_reference_runme.ml create mode 100644 Examples/test-suite/ocaml/wrapmacro_runme.ml diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 1deb1cb12..b01328380 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3711,7 +3711,7 @@ Below are some practical steps that should help meet these requirements.

  • Copying an existing language module and adapting the source for it is likely to be the most efficient - approach to fully developing a new module as a numbe of corner cases are covered in the existing implementations. + approach to fully developing a new module as a number of corner cases are covered in the existing implementations. The most advanced scripting languages are Python and Ruby. The most advanced compiled target languages are Java and C#.
  • diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i index 472a83804..a3e6bf8a6 100644 --- a/Examples/ocaml/argout_ref/example.i +++ b/Examples/ocaml/argout_ref/example.i @@ -1,13 +1,13 @@ /* File : example.i */ %module example -%typemap(argout) (int &x, int &y) { +%typemap(argout) (const int &x, const int &y) { swig_result = caml_list_append(swig_result, caml_val_int(*$1)); swig_result = caml_list_append(swig_result, caml_val_int(*$2)); } %{ -extern "C" void factor(int &x, int &y); +extern "C" void factor(const int &x, const int &y); %} -extern "C" void factor(int &x, int &y); +extern "C" void factor(const int &x, const int &y); diff --git a/Examples/test-suite/ocaml/global_vars_runme.ml b/Examples/test-suite/ocaml/global_vars_runme.ml new file mode 100644 index 000000000..75df89499 --- /dev/null +++ b/Examples/test-suite/ocaml/global_vars_runme.ml @@ -0,0 +1,15 @@ +open Swig +open Global_vars + +_init '() + +let _ = + assert (_b '() as string = "string b"); + assert (_b '("a string value") as string = "a string value"); + assert (_b '() as string = "a string value"); + assert (_x '() as int = 1234); + assert (_x '(9876) as int = 9876); + assert (_x '() as int = 9876); + assert (_Hi '() as int = 0); + assert (_Hola '() as int = 1); +;; diff --git a/Examples/test-suite/ocaml/reference_global_vars_runme.ml b/Examples/test-suite/ocaml/reference_global_vars_runme.ml index aa1708774..adde1b82e 100644 --- a/Examples/test-suite/ocaml/reference_global_vars_runme.ml +++ b/Examples/test-suite/ocaml/reference_global_vars_runme.ml @@ -22,7 +22,7 @@ let _ = let _ = _var_short (_createref_short (C_short 10)) in assert (_value_short (_var_short '()) as int = 10); - + let _ = _var_unsigned_short (_createref_unsigned_short (C_ushort 10)) in assert (_value_unsigned_short (_var_unsigned_short '()) as int = 10); diff --git a/Examples/test-suite/ocaml/sizet_runme.ml b/Examples/test-suite/ocaml/sizet_runme.ml new file mode 100644 index 000000000..5f72459c9 --- /dev/null +++ b/Examples/test-suite/ocaml/sizet_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Sizet + +let _ = + let s = C_int64 2000L in + assert (_test1 '(s) as int = 2000); + assert (_test2 '(s) as int = 2000); + assert (_test3 '(s) as int = 2000); + assert (_test4 '(s) as int = 2000); +;; diff --git a/Examples/test-suite/ocaml/typedef_reference_runme.ml b/Examples/test-suite/ocaml/typedef_reference_runme.ml new file mode 100644 index 000000000..4c9cc6fca --- /dev/null +++ b/Examples/test-suite/ocaml/typedef_reference_runme.ml @@ -0,0 +1,11 @@ +open Swig +open Typedef_reference + +let _ = + let i = _copy_intp '(2) in + assert (_somefunc '(i) as int = 2); + assert (_delete_intp '(i) = C_void); + let i = _copy_intp '(3) in + assert (_otherfunc '(i) as int = 3); + assert (_delete_intp '(i) = C_void); +;; diff --git a/Examples/test-suite/ocaml/wrapmacro_runme.ml b/Examples/test-suite/ocaml/wrapmacro_runme.ml new file mode 100644 index 000000000..f11136360 --- /dev/null +++ b/Examples/test-suite/ocaml/wrapmacro_runme.ml @@ -0,0 +1,10 @@ +open Swig +open Wrapmacro + +let _ = + let args = C_list [ C_int64 2L ; C_int64 1L ] in + assert (_maximum '(args) as int = 2); + let args = C_list [ C_double (2. /. 7.) ; C_double 256. ] in + assert (_maximum '(args) as float = 256.); + assert (_GUINT16_SWAP_LE_BE_CONSTANT '(0x1234) as int = 0x3412); +;; diff --git a/Lib/ocaml/std_common.i b/Lib/ocaml/std_common.i index 6523af0b5..7e64607d9 100644 --- a/Lib/ocaml/std_common.i +++ b/Lib/ocaml/std_common.i @@ -7,6 +7,7 @@ %include %apply size_t { std::size_t }; +%apply const size_t& { const std::size_t& }; %{ #include diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 2cc8dcbec..288a2f32a 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -72,7 +72,8 @@ long, signed long, unsigned long, long long, signed long long, unsigned long long, const long &, const signed long &, const unsigned long &, - const long long &, const signed long long &, const unsigned long long & + const long long &, const signed long long &, const unsigned long long &, + size_t, const size_t & { if( !Is_block($input) ) $1 = 0; else { diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index a6c7ef47c..23e2955fb 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -132,11 +132,11 @@ %typemap(varin) C_NAME { $1 = OCAML_TO_C($input); } -%typemap(in) C_NAME & ($*1_ltype temp) { +%typemap(in) const C_NAME & ($*1_ltype temp) { temp = ($*1_ltype) OCAML_TO_C($input); $1 = &temp; } -%typemap(varin) C_NAME & { +%typemap(varin) const C_NAME & { $1 = OCAML_TO_C($input); } %typemap(directorout) C_NAME { @@ -156,13 +156,13 @@ %typemap(varout) C_NAME { $result = C_TO_OCAML($1); } -%typemap(varout) C_NAME & { +%typemap(varout) const C_NAME & { $result = C_TO_OCAML($1); } %typemap(argout) C_NAME *OUTPUT { swig_result = caml_list_append(swig_result, C_TO_OCAML((long)*$1)); } -%typemap(out) C_NAME & { +%typemap(out) const C_NAME & { $result = C_TO_OCAML(*$1); } %typemap(directorin) C_NAME { From 629c881de507b29cb9be5b98ceb3a016aacd474a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Feb 2019 17:10:46 +0000 Subject: [PATCH 1457/2031] Template instantion fixes when template parameter is used twice in type For example T in: Y::YYY::value_type --- Examples/test-suite/common.mk | 3 +- .../cpp11_alias_nested_template_scoping.i | 45 +++++++++++++++++++ ...1_alias_nested_template_scoping_runme.java | 32 +++++++++++++ Source/Swig/stype.c | 24 +++++++--- 4 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/cpp11_alias_nested_template_scoping.i create mode 100644 Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 6794c2e8b..595ba4ae6 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -560,6 +560,7 @@ CPP_TEST_CASES += \ # C++11 test cases. CPP11_TEST_CASES += \ + cpp11_alias_nested_template_scoping \ cpp11_alignment \ cpp11_alternate_function_syntax \ cpp11_constexpr \ @@ -575,7 +576,6 @@ CPP11_TEST_CASES += \ cpp11_initializer_list \ cpp11_initializer_list_extend \ cpp11_lambda_functions \ - cpp11_std_array \ cpp11_noexcept \ cpp11_null_pointer_constant \ cpp11_raw_string_literals \ @@ -588,6 +588,7 @@ CPP11_TEST_CASES += \ cpp11_rvalue_reference3 \ cpp11_sizeof_object \ cpp11_static_assert \ + cpp11_std_array \ cpp11_strongly_typed_enumerations \ cpp11_thread_local \ cpp11_template_double_brackets \ diff --git a/Examples/test-suite/cpp11_alias_nested_template_scoping.i b/Examples/test-suite/cpp11_alias_nested_template_scoping.i new file mode 100644 index 000000000..0cf5ea35a --- /dev/null +++ b/Examples/test-suite/cpp11_alias_nested_template_scoping.i @@ -0,0 +1,45 @@ +%module cpp11_alias_nested_template_scoping + +// Test to check a template parameter type is expanded when the template parameter +// is used twice in a type name. Expansion was +// Y< short >::YYY< T >::value_type > +// instead of +// Y< short >::YYY< short >::value_type > + +#if !defined(SWIGCSHARP) && !defined(SWIGJAVA) +%feature("flatnested") ZZZ; +#endif + +%inline %{ +template struct Y { + typedef T value_type; + typedef Y YY; + template using YYY = Y; + template struct ZZZ { + typedef T2 another_type; + }; + value_type create1() const { return T(); } + Y::value_type create2() const { return T(); } + Y::value_type create3() const { return T(); } + YY::value_type create4() const { return T(); } + Y::YY::value_type create5() const { return T(); } + Y::YYY::value_type create6() const { return T(); } + typename Y::template ZZZ::another_type create7() const { return T(); } + + // With global scope prefix + ::Y::value_type create13() const { return T(); } + + ::Y::YY::value_type create15() const { return T(); } + ::Y::YYY::value_type create16() const { return T(); } + typename ::Y::template ZZZ::another_type create17() const { return T(); } +}; +%} + +%extend Y { +%template() YYY; +%template() ZZZ; +}; +// Use above workaround instead of below (which currently gives syntax error) +// %template() Y::YYY; + +%template(Yshort) Y; diff --git a/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java b/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java new file mode 100644 index 000000000..7afa83a0f --- /dev/null +++ b/Examples/test-suite/java/cpp11_alias_nested_template_scoping_runme.java @@ -0,0 +1,32 @@ + +import cpp11_alias_nested_template_scoping.*; + +public class cpp11_alias_nested_template_scoping_runme { + + static { + try { + System.loadLibrary("cpp11_alias_nested_template_scoping"); + } 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[]) { + Yshort ys = new Yshort(); + short val = 0; + val = ys.create1(); + val = ys.create2(); + val = ys.create3(); + val = ys.create4(); + val = ys.create5(); + val = ys.create6(); + val = ys.create7(); + + val = ys.create13(); + + val = ys.create15(); + val = ys.create16(); + val = ys.create17(); + } +} diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 364329d08..66518f50c 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -1310,6 +1310,7 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) { Putc(',', nt); } tsuffix = SwigType_templatesuffix(e); + SwigType_typename_replace(tsuffix, pat, rep); Printf(nt, ")>%s", tsuffix); Delete(tsuffix); Clear(e); @@ -1318,13 +1319,24 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) { Delete(tparms); } } else if (Swig_scopename_check(e)) { - String *first, *rest; - first = Swig_scopename_first(e); - rest = Swig_scopename_suffix(e); - SwigType_typename_replace(rest, pat, rep); - SwigType_typename_replace(first, pat, rep); + String *first = 0; + String *rest = 0; + Swig_scopename_split(e, &first, &rest); + + /* Swig_scopename_split doesn't handle :: prefix very well ... could do with a rework */ + if (Strncmp(rest, "::", 2) == 0) { + String *tmp = NewString(Char(rest) + 2); + Clear(rest); + Printv(rest, tmp, NIL); + Delete(tmp); + assert(!first); + } + Clear(e); - Printv(e, first, "::", rest, NIL); + if (first) + SwigType_typename_replace(first, pat, rep); + SwigType_typename_replace(rest, pat, rep); + Printv(e, first ? first : "", "::", rest, NIL); Delete(first); Delete(rest); } From 024eaeaacfc1055dd7e161b7b96b8b100f073a46 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Feb 2019 17:34:06 +0000 Subject: [PATCH 1458/2031] Improve debug display of parameters Debug display now displays parameters as strings for "kwargs", "pattern", "templateparms", "throw" elements in the parse tree (not just "parms" and "wrap:parms"). Add in single quotes when displaying these parameter lists as strings. --- Source/Swig/tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 78c04dc90..46571fc09 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -75,9 +75,11 @@ void Swig_print_node(Node *obj) { if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) || (Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) { /* Do nothing */ - } else if (Cmp(k, "parms") == 0 || Cmp(k, "wrap:parms") == 0) { + } else if (Cmp(k, "kwargs") == 0 || Cmp(k, "parms") == 0 || Cmp(k, "wrap:parms") == 0 || + Cmp(k, "pattern") == 0 || Cmp(k, "templateparms") == 0 || Cmp(k, "throws") == 0) { print_indent(2); - Printf(stdout, "%-12s - %s\n", k, ParmList_str_defaultargs(Getattr(obj, k))); + /* Differentiate parameter lists by displaying within single quotes */ + Printf(stdout, "%-12s - \'%s\'\n", k, ParmList_str_defaultargs(Getattr(obj, k))); } else { DOH *o; const char *trunc = ""; From b9350614b5956ffb8664b79ffeba38986b3678ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 17 Feb 2019 21:35:28 +0000 Subject: [PATCH 1459/2031] Fix typemap matching to expand template parameters when the name contains template parameters. In the %typemap below the type is T and the name is X::make which now expands correctly to X< int >::make template struct X { %typemap(out) T X::make "..." T make(); }; %template(Xint) X; --- CHANGES.current | 12 ++++++++ Examples/test-suite/common.mk | 1 + .../java/typemap_template_parms_runme.java | 23 +++++++++++++++ Examples/test-suite/typemap_template_parms.i | 28 +++++++++++++++++++ Source/CParse/templ.c | 2 ++ 5 files changed, 66 insertions(+) create mode 100644 Examples/test-suite/java/typemap_template_parms_runme.java create mode 100644 Examples/test-suite/typemap_template_parms.i diff --git a/CHANGES.current b/CHANGES.current index d3e84c86d..e26366a74 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,18 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-17: wsfulton + Fix typemap matching to expand template parameters when the name contains + template parameters. In the %typemap below the type is T and the name is X::make + and the name now expands correctly to X< int >::make + + template struct X { + %typemap(out) T X::make "..." + T make(); + }; + + %template(Xint) X; + 2019-02-16: wsfulton Fix parser error containing multiple #define statements inside an enum. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 595ba4ae6..11c537cbb 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -522,6 +522,7 @@ CPP_TEST_CASES += \ typemap_numinputs \ typemap_template \ typemap_template_parm_typedef \ + typemap_template_parms \ typemap_template_typedef \ typemap_out_optimal \ typemap_qualifier_strip \ diff --git a/Examples/test-suite/java/typemap_template_parms_runme.java b/Examples/test-suite/java/typemap_template_parms_runme.java new file mode 100644 index 000000000..3957ed6d3 --- /dev/null +++ b/Examples/test-suite/java/typemap_template_parms_runme.java @@ -0,0 +1,23 @@ +import typemap_template_parms.*; + +public class typemap_template_parms_runme { + + static { + try { + System.loadLibrary("typemap_template_parms"); + } 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[]) { + Xint xint = new Xint(); + int i = 0; + i = xint.bake(); + i = xint.make(); + i = xint.lake(); + i = xint.rake(); + i = xint.take(); + } +} diff --git a/Examples/test-suite/typemap_template_parms.i b/Examples/test-suite/typemap_template_parms.i new file mode 100644 index 000000000..fd0f7f51a --- /dev/null +++ b/Examples/test-suite/typemap_template_parms.i @@ -0,0 +1,28 @@ +%module typemap_template_parms + +%typemap(ret) int "_this_will_not_compile_int_$symname" + +%extend X { +%typemap(ret) T lake "/* ret lake X */" +%typemap(ret) T X::rake "/* ret rake X */" + +// Overrides below: %typemap(ret) T take +%typemap(ret) T X::take "/* ret take X */" +} + +%inline %{ +template struct X { +#if defined(SWIG) +%typemap(ret) T bake "/* ret bake X */" +%typemap(ret) T X::make "/* ret make X */" +%typemap(ret) T take "_rake_T_this_will_not_compile_" +#endif + T bake() { return T(); } + T make() { return T(); } + T lake() { return T(); } + T rake() { return T(); } + T take() { return T(); } +}; +%} + +%template(Xint) X; diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 93c5dec2c..6b1a27014 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -30,8 +30,10 @@ static void add_parms(ParmList *p, List *patchlist, List *typelist) { while (p) { SwigType *ty = Getattr(p, "type"); SwigType *val = Getattr(p, "value"); + SwigType *name = Getattr(p, "name"); Append(typelist, ty); Append(typelist, val); + Append(typelist, name); Append(patchlist, val); p = nextSibling(p); } From 470ce2dd3110d3d740d2632744b517d4f87a28fd Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 18 Feb 2019 04:23:40 -0700 Subject: [PATCH 1460/2031] [OCaml] Add missing INPUT, OUTPUT, and INOUT typemaps for primitives The typemaps are based on PHP's. --- Examples/test-suite/multivalue.i | 5 ++- Examples/test-suite/ocaml/Makefile.in | 6 +++ Examples/test-suite/ocaml/inout_runme.ml | 8 ++++ Examples/test-suite/ocaml/multivalue_runme.ml | 8 ++++ Lib/ocaml/ocaml.i | 4 -- Lib/ocaml/typecheck.i | 38 +++++++++++++++++++ Lib/ocaml/typemaps.i | 10 ----- 7 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 Examples/test-suite/ocaml/inout_runme.ml create mode 100644 Examples/test-suite/ocaml/multivalue_runme.ml diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i index f92e6c78b..d10613289 100644 --- a/Examples/test-suite/multivalue.i +++ b/Examples/test-suite/multivalue.i @@ -26,6 +26,10 @@ void divide_v(int a, int b, int *OUTPUT, int *OUTPUT); void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT); +#else +void divide_l(int a, int b, int *OUTPUT, int *OUTPUT); +void divide_v(int a, int b, int *OUTPUT, int *OUTPUT); +void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT); #endif %{ @@ -49,4 +53,3 @@ void divide_mv(int a, int b, int *quotient_p, int *remainder_p) } %} - diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index fd1daed15..775b1ea71 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -34,6 +34,12 @@ FAILING_C_TESTS = \ enums \ preproc_constants_c \ +CPP_TEST_CASES += \ + inout \ + +C_TEST_CASES += \ + multivalue \ + ml_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) run_testcase = \ diff --git a/Examples/test-suite/ocaml/inout_runme.ml b/Examples/test-suite/ocaml/inout_runme.ml new file mode 100644 index 000000000..767bb43e6 --- /dev/null +++ b/Examples/test-suite/ocaml/inout_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Inout + +let _ = + assert (_AddOne1 '(1.) as float = 2.); + assert (_AddOne3 '(1, 1, 1) = C_list ['2.;'2.;'2.]); + assert (_AddOne1r '(1.) as float = 2.); +;; diff --git a/Examples/test-suite/ocaml/multivalue_runme.ml b/Examples/test-suite/ocaml/multivalue_runme.ml new file mode 100644 index 000000000..d7e19e7d8 --- /dev/null +++ b/Examples/test-suite/ocaml/multivalue_runme.ml @@ -0,0 +1,8 @@ +open Swig +open Multivalue + +let _ = + assert (_divide_l '(37, 5) = C_list ['7;'2]); + assert (_divide_v '(41, 7) = C_list ['5;'6]); + assert (_divide_mv '(91, 13) = C_list ['7;'0]); +;; diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i index 96a36c8b2..0db48d348 100644 --- a/Lib/ocaml/ocaml.i +++ b/Lib/ocaml/ocaml.i @@ -33,10 +33,6 @@ %insert(classtemplate) "class.swg" -/* Definitions */ -#define SWIG_malloc(size) swig_malloc(size, FUNC_NAME) -#define SWIG_free(mem) free(mem) - /* Read in standard typemaps. */ %include %include diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 2cc8dcbec..538b694d3 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -153,6 +153,44 @@ $1 = !caml_ptr_val_internal($input, &ptr, 0); } +%define INPUT_OUTPUT_INOUT_TYPEMAPS(type, c_to_ocaml, ocaml_to_c) +%typemap(in) type *INPUT(type temp), type &INPUT(type temp) { + temp = (type)ocaml_to_c($input); + $1 = &temp; +} +%typemap(typecheck) type *INPUT = type; +%typemap(typecheck) type &INPUT = type; + +%typemap(in, numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;" +%typemap(argout) type *OUTPUT, type &OUTPUT { + swig_result = caml_list_append(swig_result, c_to_ocaml(*$1)); +} +%typemap(in) type *INOUT = type *INPUT; +%typemap(in) type &INOUT = type &INPUT; + +%typemap(argout) type *INOUT = type *OUTPUT; +%typemap(argout) type &INOUT = type &OUTPUT; + +%typemap(typecheck) type *INOUT = type; +%typemap(typecheck) type &INOUT = type; +%enddef + +INPUT_OUTPUT_INOUT_TYPEMAPS(bool, caml_val_bool, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(int, caml_val_int, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(long, caml_val_long, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(short, caml_val_int, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(char, caml_val_char, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(signed char, caml_val_char, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(float, caml_val_float, caml_double_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(double, caml_val_double, caml_double_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned int, caml_val_uint, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long, caml_val_ulong, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned short, caml_val_ushort, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned char, caml_val_uchar, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(long long, caml_val_long, caml_long_val); +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long long, caml_val_ulong, caml_long_val); +#undef INPUT_OUTPUT_INOUT_TYPEMAPS + /* ------------------------------------------------------------ * Exception handling * ------------------------------------------------------------ */ diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index a6c7ef47c..916b189d0 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -142,13 +142,6 @@ %typemap(directorout) C_NAME { $1 = OCAML_TO_C($input); } -%typemap(in) C_NAME *INPUT ($*1_ltype temp) { - temp = ($*1_ltype) OCAML_TO_C($input); - $1 = &temp; -} -%typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { - $1 = &temp; -} /* Out */ %typemap(out) C_NAME { $result = C_TO_OCAML($1); @@ -159,9 +152,6 @@ %typemap(varout) C_NAME & { $result = C_TO_OCAML($1); } -%typemap(argout) C_NAME *OUTPUT { - swig_result = caml_list_append(swig_result, C_TO_OCAML((long)*$1)); -} %typemap(out) C_NAME & { $result = C_TO_OCAML(*$1); } From a628bf9b6f5bf79cc28cfa09dbb76279b4d97f77 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Feb 2019 18:50:22 +0000 Subject: [PATCH 1461/2031] Python std::vector back-reference changes Give reference in container_owner a more unique name (back_reference). Change back-reference 'ret' typemap to have a function name so that they are less unwittingly be used elsewhere where not intended. Note that they can be overridden by users if needed using: %extend std::vector { %typemap(ret) value_type const& __getitem__, value_type const& front, value_type const& back { ... } } These override the SWIG supplied versions because the SWIG supplied typemaps use non-const value_type&, but the methods use const, so the above have a higher precedence in the typemap search algorithm. --- Lib/python/pycontainer.swg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index a2ee9522c..5c2a981ee 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -52,7 +52,7 @@ namespace swig { struct container_owner { // By default, do not add the back-reference (for value types) // Specialization below will check the reference for pointer types. - static bool reference(PyObject* child, PyObject* owner) { + static bool back_reference(PyObject* child, PyObject* owner) { return false; } }; @@ -66,7 +66,7 @@ namespace swig { * * returns whether the reference was set or not */ - static bool reference(PyObject* child, PyObject* owner) { + static bool back_reference(PyObject* child, PyObject* owner) { SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { PyObject_SetAttr(child, container_owner_attribute(), owner); @@ -809,8 +809,10 @@ namespace swig return self->size(); } - %typemap(ret, fragment="reference_container_owner", noblock=1) value_type& { - (void)swig::container_owner::category>::reference($result, $self); + // Although __getitem__, front, back actually use a const value_type& return type, the typemaps below + // use non-const so that they can be easily overridden by users if necessary. + %typemap(ret, fragment="reference_container_owner", noblock=1) value_type& __getitem__, value_type& front, value_type& back { + (void)swig::container_owner::category>::back_reference($result, $self); } } %enddef From be9d736597e359480dd98d05612e5dbc4747dd6d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Feb 2019 19:28:35 +0000 Subject: [PATCH 1462/2031] Add back-reference to changes file --- CHANGES.current | 9 +++++++++ Doc/Manual/CSharp.html | 2 +- Doc/Manual/Java.html | 2 +- Doc/Manual/Python.html | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e26366a74..6d7b0ca46 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-18: jakecobb + [Python] #945 #1234 Elements in std::vector memory access fix. + + Accessing an element in a std::vector obtains a reference to the element via an + iterator pointing to the element in the container. If the vector is garbage collected, + the SWIG wrapper containing the pointer to the element becomes invalid. The fix is + to obtain a back-reference to the container by the wrapper to the element in the Python + layer to prevent the garbage collector from destroying the underlying container. + 2019-02-17: wsfulton Fix typemap matching to expand template parameters when the name contains template parameters. In the %typemap below the type is T and the name is X::make diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index a4e0be799..7a9b7470b 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -1828,7 +1828,7 @@ Consider the following C++ code:
     struct Wheel {
       int size;
    -  Wheel(int sz) : size(sz) {}
    +  Wheel(int sz = 0) : size(sz) {}
     };
     
     class Bike {
    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
    index 4c7b6d058..bf77c1562 100644
    --- a/Doc/Manual/Java.html
    +++ b/Doc/Manual/Java.html
    @@ -8295,7 +8295,7 @@ Consider the following C++ code:
     
     struct Wheel {
       int size;
    -  Wheel(int sz) : size(sz) {}
    +  Wheel(int sz = 0) : size(sz) {}
     };
     
     class Bike {
    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
    index 20e95775f..6a174fddf 100644
    --- a/Doc/Manual/Python.html
    +++ b/Doc/Manual/Python.html
    @@ -5452,7 +5452,7 @@ Consider the following C++ code:
     #include <iostream>
     struct Wheel {
       int size;
    -  Wheel(int sz) : size(sz) {}
    +  Wheel(int sz = 0) : size(sz) {}
       ~Wheel() { std::cout << "~Wheel" << std::endl; }
     };
     
    
    From 9038a9987dc1440422a60aab8b943e42568be973 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Mon, 18 Feb 2019 21:39:09 +0000
    Subject: [PATCH 1463/2031] Add std::vector back reference test
    
    ---
     Examples/test-suite/common.mk                      |  1 +
     Examples/test-suite/li_std_vector_back_reference.i | 14 ++++++++++++++
     .../python/li_std_vector_back_reference_runme.py   | 10 ++++++++++
     3 files changed, 25 insertions(+)
     create mode 100644 Examples/test-suite/li_std_vector_back_reference.i
     create mode 100644 Examples/test-suite/python/li_std_vector_back_reference_runme.py
    
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 11c537cbb..5a72ba730 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -647,6 +647,7 @@ CPP_STD_TEST_CASES += \
     	li_std_pair_using \
     	li_std_string \
     	li_std_vector \
    +	li_std_vector_back_reference \
     	li_std_vector_enum \
     	li_std_vector_member_var\
     	li_std_vector_ptr \
    diff --git a/Examples/test-suite/li_std_vector_back_reference.i b/Examples/test-suite/li_std_vector_back_reference.i
    new file mode 100644
    index 000000000..be41f4740
    --- /dev/null
    +++ b/Examples/test-suite/li_std_vector_back_reference.i
    @@ -0,0 +1,14 @@
    +%module li_std_vector_back_reference
    +
    +%include 
    +
    +%inline %{
    +// #include 
    +struct Wheel {
    +  int size;
    +  Wheel(int sz = 0) : size(sz) {}
    +//  ~Wheel() { std::cout << "~Wheel" << std::endl; }
    +};
    +%}
    +
    +%template(VectorWheel) std::vector;
    diff --git a/Examples/test-suite/python/li_std_vector_back_reference_runme.py b/Examples/test-suite/python/li_std_vector_back_reference_runme.py
    new file mode 100644
    index 000000000..cec9e8cc4
    --- /dev/null
    +++ b/Examples/test-suite/python/li_std_vector_back_reference_runme.py
    @@ -0,0 +1,10 @@
    +from li_std_vector_back_reference import *
    +
    +def first_element():
    +    v = VectorWheel((Wheel(11), Wheel(22)))
    +    # v will be deleted after exit from this method
    +    return v[0]
    +
    +size = first_element().size
    +if size != 11:
    +    raise RuntimeError("Back reference not working {}".format(size))
    
    From b74b2189e6a3462a9dab0b299e82bc7086d2f077 Mon Sep 17 00:00:00 2001
    From: Zackery Spytz 
    Date: Mon, 18 Feb 2019 22:35:55 -0700
    Subject: [PATCH 1464/2031] [OCaml] Rename ocaml.swg to ocamlrun.swg
    
    Rename ocamldec.swg to ocamlrundec.swg.
    ---
     Lib/ocaml/ocaml.i                           | 4 ++--
     Lib/ocaml/{ocaml.swg => ocamlrun.swg}       | 0
     Lib/ocaml/{ocamldec.swg => ocamlrundec.swg} | 2 +-
     Source/Modules/ocaml.cxx                    | 4 ++--
     4 files changed, 5 insertions(+), 5 deletions(-)
     rename Lib/ocaml/{ocaml.swg => ocamlrun.swg} (100%)
     rename Lib/ocaml/{ocamldec.swg => ocamlrundec.swg} (99%)
    
    diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i
    index 0db48d348..581f84d04 100644
    --- a/Lib/ocaml/ocaml.i
    +++ b/Lib/ocaml/ocaml.i
    @@ -8,7 +8,7 @@
     %insert(runtime) "swigrun.swg"
     
     /* Include headers */
    -%insert(runtime) "ocamldec.swg"
    +%insert(runtime) "ocamlrundec.swg"
     
     /* Type registration */
     %insert(init) "swiginit.swg"
    @@ -28,7 +28,7 @@
     %}
     
     /*#ifndef SWIG_NOINCLUDE*/
    -%insert(runtime) "ocaml.swg"
    +%insert(runtime) "ocamlrun.swg"
     /*#endif*/
     
     %insert(classtemplate) "class.swg"
    diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocamlrun.swg
    similarity index 100%
    rename from Lib/ocaml/ocaml.swg
    rename to Lib/ocaml/ocamlrun.swg
    diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamlrundec.swg
    similarity index 99%
    rename from Lib/ocaml/ocamldec.swg
    rename to Lib/ocaml/ocamlrundec.swg
    index 0c2faf771..555f9a44f 100644
    --- a/Lib/ocaml/ocamldec.swg
    +++ b/Lib/ocaml/ocamlrundec.swg
    @@ -1,5 +1,5 @@
     /* -----------------------------------------------------------------------------
    - * ocamldec.swg
    + * ocamlrundec.swg
      *
      * Ocaml runtime code -- declarations
      * ----------------------------------------------------------------------------- */
    diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
    index 8b248bad2..27a001f85 100644
    --- a/Source/Modules/ocaml.cxx
    +++ b/Source/Modules/ocaml.cxx
    @@ -1866,9 +1866,9 @@ public:
       }
     
       String *runtimeCode() {
    -    String *s = Swig_include_sys("ocaml.swg");
    +    String *s = Swig_include_sys("ocamlrun.swg");
         if (!s) {
    -      Printf(stderr, "*** Unable to open 'ocaml.swg'\n");
    +      Printf(stderr, "*** Unable to open 'ocamlrun.swg'\n");
           s = NewString("");
         }
         return s;
    
    From 092c51c06e87a5b2a15efc1eb488414302a3e375 Mon Sep 17 00:00:00 2001
    From: Zackery Spytz 
    Date: Mon, 18 Feb 2019 22:42:20 -0700
    Subject: [PATCH 1465/2031] [OCaml] Rename typemaps.i to ocaml.swg
    
    ---
     Lib/ocaml/ocaml.i                   | 2 +-
     Lib/ocaml/{typemaps.i => ocaml.swg} | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
     rename Lib/ocaml/{typemaps.i => ocaml.swg} (99%)
    
    diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i
    index 581f84d04..cc26d1859 100644
    --- a/Lib/ocaml/ocaml.i
    +++ b/Lib/ocaml/ocaml.i
    @@ -35,7 +35,7 @@
     
     /* Read in standard typemaps. */
     %include 
    -%include 
    +%include 
     %include 
     %include 
     %include 
    diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/ocaml.swg
    similarity index 99%
    rename from Lib/ocaml/typemaps.i
    rename to Lib/ocaml/ocaml.swg
    index 08a0c97c9..ac496bdba 100644
    --- a/Lib/ocaml/typemaps.i
    +++ b/Lib/ocaml/ocaml.swg
    @@ -1,5 +1,5 @@
     /* -----------------------------------------------------------------------------
    - * typemaps.i
    + * ocaml.swg
      *
      * The Ocaml module handles all types uniformly via typemaps. Here
      * are the definitions.
    
    From 1eb9cd3211ef646aa4683dd976eb2d06d6826bcc Mon Sep 17 00:00:00 2001
    From: Zackery Spytz 
    Date: Mon, 18 Feb 2019 23:02:20 -0700
    Subject: [PATCH 1466/2031] [OCaml] Move INPUT, OUTPUT, and INOUT typemaps to
     typemaps.i
    
    ---
     Examples/test-suite/multivalue.i |  1 +
     Lib/ocaml/typecheck.i            | 38 ---------------------------
     Lib/ocaml/typemaps.i             | 44 ++++++++++++++++++++++++++++++++
     3 files changed, 45 insertions(+), 38 deletions(-)
     create mode 100644 Lib/ocaml/typemaps.i
    
    diff --git a/Examples/test-suite/multivalue.i b/Examples/test-suite/multivalue.i
    index d10613289..3bc3471a1 100644
    --- a/Examples/test-suite/multivalue.i
    +++ b/Examples/test-suite/multivalue.i
    @@ -27,6 +27,7 @@ void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
     void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
     
     #else
    +%include "typemaps.i"
     void divide_l(int a, int b, int *OUTPUT, int *OUTPUT);
     void divide_v(int a, int b, int *OUTPUT, int *OUTPUT);
     void divide_mv(int a, int b, int *OUTPUT, int *OUTPUT);
    diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i
    index 74d2727e1..0c0a600a0 100644
    --- a/Lib/ocaml/typecheck.i
    +++ b/Lib/ocaml/typecheck.i
    @@ -172,44 +172,6 @@
     
     %typecheck(SWIG_TYPECHECK_SWIGOBJECT) CAML_VALUE "$1 = 1;"
     
    -%define INPUT_OUTPUT_INOUT_TYPEMAPS(type, c_to_ocaml, ocaml_to_c)
    -%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
    -  temp = (type)ocaml_to_c($input);
    -  $1 = &temp;
    -}
    -%typemap(typecheck) type *INPUT = type;
    -%typemap(typecheck) type &INPUT = type;
    -
    -%typemap(in, numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"
    -%typemap(argout) type *OUTPUT, type &OUTPUT {
    -  swig_result = caml_list_append(swig_result, c_to_ocaml(*$1));
    -}
    -%typemap(in) type *INOUT = type *INPUT;
    -%typemap(in) type &INOUT = type &INPUT;
    -
    -%typemap(argout) type *INOUT = type *OUTPUT;
    -%typemap(argout) type &INOUT = type &OUTPUT;
    -
    -%typemap(typecheck) type *INOUT = type;
    -%typemap(typecheck) type &INOUT = type;
    -%enddef
    -
    -INPUT_OUTPUT_INOUT_TYPEMAPS(bool, caml_val_bool, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(int, caml_val_int, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(long, caml_val_long, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(short, caml_val_int, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(char, caml_val_char, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(signed char, caml_val_char, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(float, caml_val_float, caml_double_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(double, caml_val_double, caml_double_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned int, caml_val_uint, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long, caml_val_ulong, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned short, caml_val_ushort, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned char, caml_val_uchar, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(long long, caml_val_long, caml_long_val);
    -INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long long, caml_val_ulong, caml_long_val);
    -#undef INPUT_OUTPUT_INOUT_TYPEMAPS
    -
     /* ------------------------------------------------------------
      * Exception handling
      * ------------------------------------------------------------ */
    diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i
    new file mode 100644
    index 000000000..39231e221
    --- /dev/null
    +++ b/Lib/ocaml/typemaps.i
    @@ -0,0 +1,44 @@
    +/* ----------------------------------------------------------------------------
    + * typemaps.i
    + *
    + * These typemaps provide support for input/output arguments for C/C++ pointers
    + * and C++ references.
    +* ---------------------------------------------------------------------------- */
    +
    +%define INPUT_OUTPUT_INOUT_TYPEMAPS(type, c_to_ocaml, ocaml_to_c)
    +%typemap(in) type *INPUT(type temp), type &INPUT(type temp) {
    +  temp = (type)ocaml_to_c($input);
    +  $1 = &temp;
    +}
    +%typemap(typecheck) type *INPUT = type;
    +%typemap(typecheck) type &INPUT = type;
    +
    +%typemap(in, numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"
    +%typemap(argout) type *OUTPUT, type &OUTPUT {
    +  swig_result = caml_list_append(swig_result, c_to_ocaml(*$1));
    +}
    +%typemap(in) type *INOUT = type *INPUT;
    +%typemap(in) type &INOUT = type &INPUT;
    +
    +%typemap(argout) type *INOUT = type *OUTPUT;
    +%typemap(argout) type &INOUT = type &OUTPUT;
    +
    +%typemap(typecheck) type *INOUT = type;
    +%typemap(typecheck) type &INOUT = type;
    +%enddef
    +
    +INPUT_OUTPUT_INOUT_TYPEMAPS(bool, caml_val_bool, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(int, caml_val_int, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(long, caml_val_long, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(short, caml_val_int, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(char, caml_val_char, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(signed char, caml_val_char, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(float, caml_val_float, caml_double_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(double, caml_val_double, caml_double_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned int, caml_val_uint, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long, caml_val_ulong, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned short, caml_val_ushort, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned char, caml_val_uchar, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(long long, caml_val_long, caml_long_val);
    +INPUT_OUTPUT_INOUT_TYPEMAPS(unsigned long long, caml_val_ulong, caml_long_val);
    +#undef INPUT_OUTPUT_INOUT_TYPEMAPS
    
    From 1f46d9b7b9d6b0e22a23d54a2d6e5695e6d95e76 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 19 Feb 2019 21:23:16 +0000
    Subject: [PATCH 1467/2031] Fix regression parsing gcc preprocessor linemarkers
    
    These are preprocessor statement in the form:
    
     # linenum filename flags
    
    Closes #1475
    ---
     CHANGES.current                                 |  5 +++++
     Examples/test-suite/common.mk                   |  1 +
     .../test-suite/errors/pp_unknowndirective3.i    | 14 ++++++++++++++
     .../errors/pp_unknowndirective3.stderr          |  4 ++++
     Examples/test-suite/preproc_gcc_output.h        | 13 +++++++++++++
     Examples/test-suite/preproc_gcc_output.i        | 12 ++++++++++++
     .../python/preproc_gcc_output_runme.py          |  5 +++++
     Source/Preprocessor/cpp.c                       | 17 ++++++++++++++++-
     8 files changed, 70 insertions(+), 1 deletion(-)
     create mode 100644 Examples/test-suite/errors/pp_unknowndirective3.i
     create mode 100644 Examples/test-suite/errors/pp_unknowndirective3.stderr
     create mode 100644 Examples/test-suite/preproc_gcc_output.h
     create mode 100644 Examples/test-suite/preproc_gcc_output.i
     create mode 100644 Examples/test-suite/python/preproc_gcc_output_runme.py
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 6d7b0ca46..2d26fc4ff 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.0 (in progress)
     ===========================
     
    +2019-02-19: wsfulton
    +            #1475 Fix regression parsing gcc preprocessor linemarkers in the form:
    +
    +            # linenum filename flags 
    +
     2019-02-18: jakecobb
                 [Python] #945 #1234 Elements in std::vector memory access fix.
     
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 5a72ba730..3d4edd47b 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -707,6 +707,7 @@ C_TEST_CASES += \
     	preproc \
     	preproc_constants_c \
     	preproc_defined \
    +	preproc_gcc_output \
     	preproc_include \
     	preproc_line_file \
     	register_par \
    diff --git a/Examples/test-suite/errors/pp_unknowndirective3.i b/Examples/test-suite/errors/pp_unknowndirective3.i
    new file mode 100644
    index 000000000..77dfd5bb5
    --- /dev/null
    +++ b/Examples/test-suite/errors/pp_unknowndirective3.i
    @@ -0,0 +1,14 @@
    +%module xxx
    +
    +// Testing is_digits detecting gcc linemarkers
    +
    +// These are valid
    +# 1 "/usr/include/stdc-predef.h" 1 3 4
    +# 123 "header1.h"
    +
    +// These are invalid
    +#a1 'a.h'
    +#1b 'b.h'
    +#1c1 'c.h'
    +#d1d 'd.h'
    +
    diff --git a/Examples/test-suite/errors/pp_unknowndirective3.stderr b/Examples/test-suite/errors/pp_unknowndirective3.stderr
    new file mode 100644
    index 000000000..35bff8a80
    --- /dev/null
    +++ b/Examples/test-suite/errors/pp_unknowndirective3.stderr
    @@ -0,0 +1,4 @@
    +pp_unknowndirective3.i:10: Error: Unknown SWIG preprocessor directive: a1 (if this is a block of target language code, delimit it with %{ and %})
    +pp_unknowndirective3.i:11: Error: Unknown SWIG preprocessor directive: 1b (if this is a block of target language code, delimit it with %{ and %})
    +pp_unknowndirective3.i:12: Error: Unknown SWIG preprocessor directive: 1c1 (if this is a block of target language code, delimit it with %{ and %})
    +pp_unknowndirective3.i:13: Error: Unknown SWIG preprocessor directive: d1d (if this is a block of target language code, delimit it with %{ and %})
    diff --git a/Examples/test-suite/preproc_gcc_output.h b/Examples/test-suite/preproc_gcc_output.h
    new file mode 100644
    index 000000000..cc5065d12
    --- /dev/null
    +++ b/Examples/test-suite/preproc_gcc_output.h
    @@ -0,0 +1,13 @@
    +# 1 "header1.h"
    +# 1 ""
    +# 1 ""
    +# 1 "/usr/include/stdc-predef.h" 1 3 4
    +# 1 "" 2
    +# 1 "header1.h"
    +# 18 "header1.h"
    +void header1_function_a(int a);
    +# 1 "header2.h" 1
    +# 13 "header2.h"
    +void header2_function(int x);
    +# 20 "header1.h" 2
    +void header1_function_b(int b);
    diff --git a/Examples/test-suite/preproc_gcc_output.i b/Examples/test-suite/preproc_gcc_output.i
    new file mode 100644
    index 000000000..b4db9e70a
    --- /dev/null
    +++ b/Examples/test-suite/preproc_gcc_output.i
    @@ -0,0 +1,12 @@
    +%module preproc_gcc_output
    +// Testcase for Github issue #1475 using the output of gcc -E
    +
    +// The file below was generated using 'gcc -E header1.h'
    +// where header1.h included header2.h
    +%include "preproc_gcc_output.h"
    +
    +%{
    +void header1_function_a(int a) {}
    +void header2_function(int x) {}
    +void header1_function_b(int b) {}
    +%}
    diff --git a/Examples/test-suite/python/preproc_gcc_output_runme.py b/Examples/test-suite/python/preproc_gcc_output_runme.py
    new file mode 100644
    index 000000000..66ff7d21a
    --- /dev/null
    +++ b/Examples/test-suite/python/preproc_gcc_output_runme.py
    @@ -0,0 +1,5 @@
    +import preproc_gcc_output
    +
    +preproc_gcc_output.header1_function_a(99)
    +preproc_gcc_output.header1_function_b(99)
    +preproc_gcc_output.header2_function(99)
    diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
    index af1775007..557b5482b 100644
    --- a/Source/Preprocessor/cpp.c
    +++ b/Source/Preprocessor/cpp.c
    @@ -109,6 +109,19 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
       return s;
     }
     
    +static int is_digits(const String *str) {
    +  const char *s = Char(str);
    +  int isdigits = (*s != 0);
    +  while (*s) {
    +    if (!isdigit(*s)) {
    +      isdigits = 0;
    +      break;
    +    }
    +    s++;
    +  }
    +  return isdigits;
    +}
    +
     List *Preprocessor_depend(void) {
       return dependencies;
     }
    @@ -1484,7 +1497,7 @@ String *Preprocessor_parse(String *s) {
           Putc(c, id);
           break;
     
    -    case 42:			/* Strip any leading space before preprocessor value */
    +    case 42:			/* Strip any leading space after the preprocessor directive (before preprocessor value) */
           if (isspace(c)) {
     	if (c == '\n') {
     	  Ungetc(c, s);
    @@ -1804,6 +1817,8 @@ String *Preprocessor_parse(String *s) {
     	Swig_error(Getfile(s), Getline(id), "cpp debug: level = %d, startlevel = %d\n", level, start_level);
           } else if (Equal(id, "")) {
     	/* Null directive */
    +      } else if (is_digits(id)) {
    +	/* A gcc linemarker of the form '# linenum filename flags' (resulting from running gcc -E) */
           } else {
     	/* Ignore unknown preprocessor directives which are inside an inactive
     	 * conditional (github issue #394). */
    
    From 32b963ef1caccf7bc941e16c9a6fc7abe8c8fd8d Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 19 Feb 2019 22:54:08 +0000
    Subject: [PATCH 1468/2031] Re-organise Python method creation and docstring
     functions declarations
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Fix ‘PyMethodDef* SWIG_PythonGetProxyDoc(const char*)’ declared ‘static’ but
    never defined [-Wunused-function]
    
    Closes #1448 (again)
    ---
     Lib/python/pyinit.swg | 16 ++++++++++++++++
     Lib/python/pyrun.swg  |  6 ------
     2 files changed, 16 insertions(+), 6 deletions(-)
    
    diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
    index f5be6d599..dfbf40b34 100644
    --- a/Lib/python/pyinit.swg
    +++ b/Lib/python/pyinit.swg
    @@ -8,6 +8,22 @@
     %fragment(""); // For offsetof
     #endif
     
    +%insert(runtime) %{
    +#ifdef __cplusplus
    +extern "C" {
    +#endif
    +
    +/* Method creation and docstring support functions */
    +
    +SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
    +SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
    +SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
    +
    +#ifdef __cplusplus
    +}
    +#endif
    +%}
    +
     %init %{
     
     #ifdef __cplusplus
    diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
    index 693cd6d46..ad1b81963 100644
    --- a/Lib/python/pyrun.swg
    +++ b/Lib/python/pyrun.swg
    @@ -213,12 +213,6 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
     extern "C" {
     #endif
     
    -/* Method creation and docstring support functions */
    -
    -SWIGINTERN PyMethodDef *SWIG_PythonGetProxyDoc(const char *name);
    -SWIGINTERN PyObject *SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
    -SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func);
    -
     /* The python void return value */
     
     SWIGRUNTIMEINLINE PyObject * 
    
    From 1c03af9b96c5c3e2eb5afd2f2e93e4381bfa2261 Mon Sep 17 00:00:00 2001
    From: Zackery Spytz 
    Date: Thu, 21 Feb 2019 02:11:51 -0700
    Subject: [PATCH 1469/2031] Fix some rejections of valid floating-point
     literals
    
    Some valid floating-point literals were giving
    "Error: Syntax error in input(1)".
    ---
     CHANGES.current                       | 3 +++
     Examples/test-suite/primitive_types.i | 4 ++++
     Source/Swig/scanner.c                 | 6 ++++++
     3 files changed, 13 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 2d26fc4ff..5456429ef 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.0 (in progress)
     ===========================
     
    +2019-02-21: ZackerySpytz
    +            #1480 Fix some rejections of valid floating-point literals.
    +
     2019-02-19: wsfulton
                 #1475 Fix regression parsing gcc preprocessor linemarkers in the form:
     
    diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
    index 637934377..a71f62a4f 100644
    --- a/Examples/test-suite/primitive_types.i
    +++ b/Examples/test-suite/primitive_types.i
    @@ -630,6 +630,10 @@ macro(size_t,             pfx, sizet)
         float val_float(float x) {
           return x;
         } 
    +
    +    float val_float_3(float f = 0e1f, float f2 = 020e0f, float f3 = 0.3e4f) {
    +      return f + f2 + f3;
    +    }
     %}
     
     
    diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
    index 964336621..908bc747f 100644
    --- a/Source/Swig/scanner.c
    +++ b/Source/Swig/scanner.c
    @@ -1160,6 +1160,8 @@ static int look(Scanner *s) {
     	return SWIG_TOKEN_INT;
           if (isdigit(c))
     	state = 84;
    +      else if ((c == 'e') || (c == 'E'))
    +	state = 82;
           else if ((c == 'x') || (c == 'X'))
     	state = 85;
           else if ((c == 'b') || (c == 'B'))
    @@ -1181,6 +1183,10 @@ static int look(Scanner *s) {
     	return SWIG_TOKEN_INT;
           if (isdigit(c))
     	state = 84;
    +      else if (c == '.')
    +	state = 81;
    +      else if ((c == 'e') || (c == 'E'))
    +	state = 82;
           else if ((c == 'l') || (c == 'L')) {
     	state = 87;
           } else if ((c == 'u') || (c == 'U')) {
    
    From 1e571417b69df15dc928e2e39b2b404773c3386f Mon Sep 17 00:00:00 2001
    From: Zachary Hensley 
    Date: Thu, 21 Feb 2019 09:24:10 -0600
    Subject: [PATCH 1470/2031] Updated java std_map to support Obj derivatives by
     importing original for use in class
    
    ---
     Lib/java/std_map.i | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i
    index 4b891e74a..a7202bc06 100644
    --- a/Lib/java/std_map.i
    +++ b/Lib/java/std_map.i
    @@ -51,6 +51,9 @@ template > class map {
     %typemap(javabase) std::map< K, T, C >
         "java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>"
     
    +%typemap(javaimports) std::map< K, T, C >
    +    "import java.lang.Object;"
    +
     %proxycode %{
     
       public int size() {
    
    From 2786bf37a148090d98e5c9f3126148f10ec67f89 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 21 Feb 2019 17:57:11 +0000
    Subject: [PATCH 1471/2031] Fix multiple definitions of
     swig::container_owner_attribute
    
    ---
     Lib/python/pycontainer.swg | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
    index 5c2a981ee..ef2f725af 100644
    --- a/Lib/python/pycontainer.swg
    +++ b/Lib/python/pycontainer.swg
    @@ -43,7 +43,7 @@
     
     %fragment("reference_container_owner", "header", fragment="container_owner_attribute_init") {
     namespace swig {
    -  PyObject* container_owner_attribute() {
    +  static PyObject* container_owner_attribute() {
         static PyObject* attr = SWIG_Python_str_FromChar("__swig_container");
         return attr;
       }
    
    From e6035d625a4737de4c9406b1f5d16cdcf8d48b5f Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Wed, 20 Feb 2019 23:44:01 -0800
    Subject: [PATCH 1472/2031] Java 9 deprecation warning fixes for test-suite and
     examples
    
    ---
     Examples/java/variables/runme.java                | 2 +-
     Examples/test-suite/doxygen_translate.i           | 4 ++++
     Examples/test-suite/doxygen_translate_all_tags.i  | 4 ++++
     Examples/test-suite/java/li_std_list_runme.java   | 8 ++++----
     Examples/test-suite/java/li_std_vector_runme.java | 8 ++++----
     Examples/test-suite/java/long_long_runme.java     | 6 +++---
     6 files changed, 20 insertions(+), 12 deletions(-)
    
    diff --git a/Examples/java/variables/runme.java b/Examples/java/variables/runme.java
    index 361a30fa6..a53cc543c 100644
    --- a/Examples/java/variables/runme.java
    +++ b/Examples/java/variables/runme.java
    @@ -76,7 +76,7 @@ public class runme {
         System.out.println( "     Trying to set 'status'" );
         try {
             Method m = example.class.getDeclaredMethod("setStatus", new Class[] {Integer.class});
    -        m.invoke(example.class, new Object[] {new Integer(0)} );
    +        m.invoke(example.class, new Object[] {Integer.valueOf(0)} );
             System.out.println( "Hey, what's going on?!?! This shouldn't work" );
         }
         catch (NoSuchMethodException e) {
    diff --git a/Examples/test-suite/doxygen_translate.i b/Examples/test-suite/doxygen_translate.i
    index 348b2e9a8..bb0af1c14 100644
    --- a/Examples/test-suite/doxygen_translate.i
    +++ b/Examples/test-suite/doxygen_translate.i
    @@ -1,5 +1,9 @@
     %module doxygen_translate
     
    +#if defined(SWIGJAVA)
    +%javamethodmodifiers function "@Deprecated\npublic"
    +#endif
    +
     %inline %{
     
     /**
    diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i
    index ba348fd50..6e96a57c5 100644
    --- a/Examples/test-suite/doxygen_translate_all_tags.i
    +++ b/Examples/test-suite/doxygen_translate_all_tags.i
    @@ -1,5 +1,9 @@
     %module doxygen_translate_all_tags
     
    +#if defined(SWIGJAVA)
    +%javamethodmodifiers func02 "@Deprecated\npublic"
    +#endif
    +
     %inline %{
     
     /**
    diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java
    index e45b8968b..94bcada02 100644
    --- a/Examples/test-suite/java/li_std_list_runme.java
    +++ b/Examples/test-suite/java/li_std_list_runme.java
    @@ -47,11 +47,11 @@ public class li_std_list_runme {
         } catch (java.util.NoSuchElementException e) {
         }
     
    -    if (v1.remove(new Integer(123))) throw new RuntimeException("v1 test (13) failed");
    -    if (!v1.remove(new Integer(456))) throw new RuntimeException("v1 test (14) failed");
    +    if (v1.remove(Integer.valueOf(123))) throw new RuntimeException("v1 test (13) failed");
    +    if (!v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (14) failed");
         if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed");
         if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed");
    -    if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed");
    +    if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed");
     
         if (new IntList(3).size() != 3) throw new RuntimeException("constructor initial size test failed");
         for (int n : new IntList(10, 999))
    @@ -136,7 +136,7 @@ public class li_std_list_runme {
         v9.add(60);
         v9.add(70);
         if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed");
    -    if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed");
    +    if (!v9.remove(Integer.valueOf(60))) throw new RuntimeException("v9 test (2) failed");
         if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed");
         v9.addFirst(-10);
         v9.addLast(80);
    diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java
    index d23bbe7cd..ba0648562 100644
    --- a/Examples/test-suite/java/li_std_vector_runme.java
    +++ b/Examples/test-suite/java/li_std_vector_runme.java
    @@ -48,11 +48,11 @@ public class li_std_vector_runme {
         } catch (java.util.NoSuchElementException e) {
         }
     
    -    if (v1.remove(new Integer(123))) throw new RuntimeException("v1 test (13) failed");
    -    if (!v1.remove(new Integer(456))) throw new RuntimeException("v1 test (14) failed");
    +    if (v1.remove(Integer.valueOf(123))) throw new RuntimeException("v1 test (13) failed");
    +    if (!v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (14) failed");
         if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed");
         if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed");
    -    if (v1.remove(new Integer(456))) throw new RuntimeException("v1 test (17) failed");
    +    if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed");
     
         if (new IntVector(3).size() != 3) throw new RuntimeException("constructor initial size test failed");
         for (int n : new IntVector(10, 999))
    @@ -137,7 +137,7 @@ public class li_std_vector_runme {
         v9.add(60);
         v9.add(70);
         if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed");
    -    if (!v9.remove(new Integer(60))) throw new RuntimeException("v9 test (2) failed");
    +    if (!v9.remove(Integer.valueOf(60))) throw new RuntimeException("v9 test (2) failed");
         if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed");
     
         IntVector v10 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40, 50));
    diff --git a/Examples/test-suite/java/long_long_runme.java b/Examples/test-suite/java/long_long_runme.java
    index 76aa0705d..65a0e79b3 100644
    --- a/Examples/test-suite/java/long_long_runme.java
    +++ b/Examples/test-suite/java/long_long_runme.java
    @@ -84,14 +84,14 @@ public class long_long_runme {
     
         ArrayList bigIntegers = new ArrayList();
         for (int i=0; i
    Date: Thu, 21 Feb 2019 13:44:24 -0800
    Subject: [PATCH 1473/2031] Add changes entry for Java finalize suppression
    
    ---
     CHANGES.current | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 2d26fc4ff..492dffa6a 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.0 (in progress)
     ===========================
     
    +2019-02-21: wsfulton
    +            #1240 Suppress Java 9 deprecation warnings on finalize method.
    +
     2019-02-19: wsfulton
                 #1475 Fix regression parsing gcc preprocessor linemarkers in the form:
     
    
    From c3d652c785328e67d14141266e4ae6198124cc95 Mon Sep 17 00:00:00 2001
    From: Zackery Spytz 
    Date: Fri, 22 Feb 2019 06:28:53 -0700
    Subject: [PATCH 1474/2031] Fix the handling of director classes with final
     methods
    
    Generated SwigDirector_* classes were attempting to override
    methods marked as final.
    
    In addition, give a warning if the destructor of a director class is
    final.
    
    Closes #564.
    ---
     CHANGES.current                               |  3 ++
     Doc/Manual/Warnings.html                      |  1 +
     Examples/test-suite/cpp11_final_directors.i   | 18 +++++++
     .../python/cpp11_final_directors_runme.py     | 11 ++++
     Source/CParse/parser.y                        | 51 ++++++++++++++++---
     Source/Include/swigwarn.h                     |  1 +
     Source/Modules/lang.cxx                       |  9 +++-
     7 files changed, 87 insertions(+), 7 deletions(-)
     create mode 100644 Examples/test-suite/cpp11_final_directors.i
     create mode 100644 Examples/test-suite/python/cpp11_final_directors_runme.py
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 492dffa6a..5bf15a778 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.0 (in progress)
     ===========================
     
    +2019-02-22: ZackerySpytz
    +            #1483 Fix compilation failures when a director class has final methods.
    +
     2019-02-21: wsfulton
                 #1240 Suppress Java 9 deprecation warnings on finalize method.
     
    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
    index bff20801e..8b2ab2b95 100644
    --- a/Doc/Manual/Warnings.html
    +++ b/Doc/Manual/Warnings.html
    @@ -535,6 +535,7 @@ example.i(4) : Syntax error in input(1).
     
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'.
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.
  • 524. Experimental target language. Target language language specified by lang is an experimental language. Please read about SWIG experimental languages, htmllink. +
  • 525. The director base class 'name' or the destructor of director base class 'name' is marked as final.

    18.9.6 Doxygen comments (560-599)

    diff --git a/Examples/test-suite/cpp11_final_directors.i b/Examples/test-suite/cpp11_final_directors.i new file mode 100644 index 000000000..d724543ea --- /dev/null +++ b/Examples/test-suite/cpp11_final_directors.i @@ -0,0 +1,18 @@ +%module(directors="1") cpp11_final_directors + +%warnfilter(SWIGWARN_PARSE_KEYWORD) final; + +%director Derived; + +%inline %{ +struct Base { + virtual void basemeth() final {} + virtual ~Base() {} +}; + +struct Derived : Base { + virtual int derivedmeth() final { return 1; } + virtual int meth() { return 2; } + virtual ~Derived() {} +}; +%} diff --git a/Examples/test-suite/python/cpp11_final_directors_runme.py b/Examples/test-suite/python/cpp11_final_directors_runme.py new file mode 100644 index 000000000..2e5f8af96 --- /dev/null +++ b/Examples/test-suite/python/cpp11_final_directors_runme.py @@ -0,0 +1,11 @@ +import cpp11_final_directors + +class Derived2(cpp11_final_directors.Derived): + + def meth(self): + return 3 + + +b = Derived2() +if b.meth() != 3: + raise RuntimeError diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index f20f1db2f..4046e480e 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1552,6 +1552,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) Parm *throws; String *throwf; String *nexcept; + String *final; } dtype; struct { const char *type; @@ -1567,6 +1568,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) ParmList *throws; String *throwf; String *nexcept; + String *final; } decl; Parm *tparms; struct { @@ -3189,6 +3191,7 @@ c_decl : storage_class type declarator cpp_const initializer c_decl_tail { Setattr($$,"throws",$4.throws); Setattr($$,"throw",$4.throwf); Setattr($$,"noexcept",$4.nexcept); + Setattr($$,"final",$4.final); if ($5.val && $5.type) { /* store initializer type as it might be different to the declared type */ SwigType *valuetype = NewSwigType($5.type); @@ -3266,6 +3269,7 @@ c_decl : storage_class type declarator cpp_const initializer c_decl_tail { Setattr($$,"throws",$4.throws); Setattr($$,"throw",$4.throwf); Setattr($$,"noexcept",$4.nexcept); + Setattr($$,"final",$4.final); if (!$9) { if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); @@ -3330,6 +3334,7 @@ c_decl_tail : SEMI { Setattr($$,"throws",$3.throws); Setattr($$,"throw",$3.throwf); Setattr($$,"noexcept",$3.nexcept); + Setattr($$,"final",$3.final); if ($4.bitfield) { Setattr($$,"bitfield", $4.bitfield); } @@ -3638,6 +3643,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); + Setattr($$,"final",$6.final); err = 0; } } @@ -4704,6 +4710,7 @@ cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); + Setattr($$,"final",$6.final); if (Len(scanner_ccode)) { String *code = Copy(scanner_ccode); Setattr($$,"code",code); @@ -4740,6 +4747,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { Setattr($$,"throws",$6.throws); Setattr($$,"throw",$6.throwf); Setattr($$,"noexcept",$6.nexcept); + Setattr($$,"final",$6.final); if ($6.val) Setattr($$,"value",$6.val); if ($6.qualifier) @@ -4760,6 +4768,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end { Setattr($$,"throws",$7.throws); Setattr($$,"throw",$7.throwf); Setattr($$,"noexcept",$7.nexcept); + Setattr($$,"final",$7.final); if ($7.val) Setattr($$,"value",$7.val); if (Len(scanner_ccode)) { @@ -4941,6 +4950,7 @@ cpp_end : cpp_const SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; } | cpp_const EQUAL default_delete SEMI { Clear(scanner_ccode); @@ -4951,6 +4961,7 @@ cpp_end : cpp_const SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; } | cpp_const LBRACE { skip_balanced('{','}'); @@ -4961,6 +4972,7 @@ cpp_end : cpp_const SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; } ; @@ -4973,6 +4985,7 @@ cpp_vend : cpp_const SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; } | cpp_const EQUAL definetype SEMI { Clear(scanner_ccode); @@ -4982,7 +4995,8 @@ cpp_vend : cpp_const SEMI { $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; - $$.nexcept = $1.nexcept; + $$.nexcept = $1.nexcept; + $$.final = $1.final; } | cpp_const LBRACE { skip_balanced('{','}'); @@ -4992,7 +5006,8 @@ cpp_vend : cpp_const SEMI { $$.bitfield = 0; $$.throws = $1.throws; $$.throwf = $1.throwf; - $$.nexcept = $1.nexcept; + $$.nexcept = $1.nexcept; + $$.final = $1.final; } ; @@ -5210,6 +5225,7 @@ def_args : EQUAL definetype { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } } | EQUAL definetype LBRACKET expr RBRACKET { @@ -5223,6 +5239,7 @@ def_args : EQUAL definetype { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } else { $$.val = NewStringf("%s[%s]",$2.val,$4.val); } @@ -5236,6 +5253,7 @@ def_args : EQUAL definetype { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | COLON expr { $$.val = 0; @@ -5245,6 +5263,7 @@ def_args : EQUAL definetype { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | empty { $$.val = 0; @@ -5254,6 +5273,7 @@ def_args : EQUAL definetype { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } ; @@ -6293,6 +6313,7 @@ definetype : { /* scanner_check_typedef(); */ } expr { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; scanner_ignore_typedef(); } | default_delete { @@ -6319,6 +6340,7 @@ deleted_definition : DELETE_KW { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } ; @@ -6333,6 +6355,7 @@ explicit_default : DEFAULT { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } ; @@ -6525,6 +6548,7 @@ valexpr : exprnum { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | WCHARCONST { $$.val = NewString($1); @@ -6538,6 +6562,7 @@ valexpr : exprnum { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } /* grouping */ @@ -6892,18 +6917,18 @@ virt_specifier_seq : OVERRIDE { $$ = 0; } | FINAL { - $$ = 0; + $$ = NewString("1"); } | FINAL OVERRIDE { - $$ = 0; + $$ = NewString("1"); } | OVERRIDE FINAL { - $$ = 0; + $$ = NewString("1"); } ; virt_specifier_seq_opt : virt_specifier_seq { - $$ = 0; + $$ = $1; } | empty { $$ = 0; @@ -6914,31 +6939,37 @@ exception_specification : THROW LPAREN parms RPAREN { $$.throws = $3; $$.throwf = NewString("1"); $$.nexcept = 0; + $$.final = 0; } | NOEXCEPT { $$.throws = 0; $$.throwf = 0; $$.nexcept = NewString("true"); + $$.final = 0; } | virt_specifier_seq { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = $1; } | THROW LPAREN parms RPAREN virt_specifier_seq { $$.throws = $3; $$.throwf = NewString("1"); $$.nexcept = 0; + $$.final = $5; } | NOEXCEPT virt_specifier_seq { $$.throws = 0; $$.throwf = 0; $$.nexcept = NewString("true"); + $$.final = $2; } | NOEXCEPT LPAREN expr RPAREN { $$.throws = 0; $$.throwf = 0; $$.nexcept = $3.val; + $$.final = 0; } ; @@ -6946,6 +6977,7 @@ qualifiers_exception_specification : cv_ref_qualifier { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; $$.qualifier = $1.qualifier; $$.refqualifier = $1.refqualifier; } @@ -6968,6 +7000,7 @@ cpp_const : qualifiers_exception_specification { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; $$.qualifier = 0; $$.refqualifier = 0; } @@ -6980,6 +7013,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; if ($1.qualifier) Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n"); } @@ -6990,6 +7024,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; if ($1.qualifier) Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n"); } @@ -7001,6 +7036,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | LPAREN parms RPAREN LBRACE { skip_balanced('{','}'); @@ -7010,6 +7046,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | EQUAL definetype SEMI { $$.have_parms = 0; @@ -7017,6 +7054,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = 0; $$.throwf = 0; $$.nexcept = 0; + $$.final = 0; } | exception_specification EQUAL default_delete SEMI { $$.have_parms = 0; @@ -7024,6 +7062,7 @@ ctor_end : cpp_const ctor_initializer SEMI { $$.throws = $1.throws; $$.throwf = $1.throwf; $$.nexcept = $1.nexcept; + $$.final = $1.final; if ($1.qualifier) Swig_error(cparse_file, cparse_line, "Constructor cannot have a qualifier.\n"); } diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index fde82bd96..fbcea4dbd 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -211,6 +211,7 @@ #define WARN_LANG_EXTEND_CONSTRUCTOR 522 #define WARN_LANG_EXTEND_DESTRUCTOR 523 #define WARN_LANG_EXPERIMENTAL 524 +#define WARN_LANG_DIRECTOR_FINAL 525 /* -- Doxygen comments -- */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index f9af9723a..acb5e4348 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2109,7 +2109,7 @@ int Language::classDirectorMethods(Node *n) { Node *item = Getitem(vtable, i); String *method = Getattr(item, "methodNode"); String *fqdname = Getattr(item, "fqdname"); - if (GetFlag(method, "feature:nodirector")) + if (GetFlag(method, "feature:nodirector") || GetFlag(method, "final")) continue; String *wrn = Getattr(method, "feature:warnfilter"); @@ -2198,6 +2198,13 @@ int Language::classDirector(Node *n) { String *using_protected_members_code = NewString(""); for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) { Node *nodeType = Getattr(ni, "nodeType"); + if (Cmp(nodeType, "destructor") == 0 && GetFlag(ni, "final")) { + String *classtype = Getattr(n, "classtype"); + Swig_warning(WARN_LANG_DIRECTOR_FINAL, input_file, line_number, "Destructor of director base class %s is marked as final.\n", classtype); + Delete(vtable); + Delete(using_protected_members_code); + return SWIG_OK; + } bool cdeclaration = (Cmp(nodeType, "cdecl") == 0); if (cdeclaration && !GetFlag(ni, "feature:ignore")) { if (isNonVirtualProtectedAccess(ni)) { From d812a4291c0ae61b407aab705a26e9f14eb55a75 Mon Sep 17 00:00:00 2001 From: Zachary Hensley Date: Fri, 22 Feb 2019 10:55:20 -0600 Subject: [PATCH 1475/2031] Handle review comments --- Lib/java/std_list.i | 2 +- Lib/java/std_map.i | 9 +++------ Lib/java/std_set.i | 10 +++++----- Lib/java/std_unordered_map.i | 6 +++--- Lib/java/std_unordered_set.i | 10 +++++----- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 3ad6511ce..82ccde38b 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -43,7 +43,7 @@ namespace std { this(); java.util.ListIterator<$typemap(jboxtype, T)> it = listIterator(0); // Special case the "copy constructor" here to avoid lots of cross-language calls - for (Object o : c) { + for (java.lang.Object o : c) { it.add(($typemap(jboxtype, T))o); } } diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index a7202bc06..6d5ca1aac 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -51,16 +51,13 @@ template > class map { %typemap(javabase) std::map< K, T, C > "java.util.AbstractMap<$typemap(jboxtype, K), $typemap(jboxtype, T)>" -%typemap(javaimports) std::map< K, T, C > - "import java.lang.Object;" - %proxycode %{ public int size() { return sizeImpl(); } - public boolean containsKey(Object key) { + public boolean containsKey(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return false; } @@ -68,7 +65,7 @@ template > class map { return containsImpl(($typemap(jboxtype, K))key); } - public $typemap(jboxtype, T) get(Object key) { + public $typemap(jboxtype, T) get(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return null; } @@ -93,7 +90,7 @@ template > class map { } } - public $typemap(jboxtype, T) remove(Object key) { + public $typemap(jboxtype, T) remove(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return null; } diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 06c5a63e7..086d10c8a 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -59,7 +59,7 @@ class set { public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; - for (Object object : collection) { + for (java.lang.Object object : collection) { didAddElement |= add(($typemap(jboxtype, T))object); } @@ -96,7 +96,7 @@ class set { } public boolean containsAll(java.util.Collection collection) { - for (Object object : collection) { + for (java.lang.Object object : collection) { if (!contains(object)) { return false; } @@ -105,7 +105,7 @@ class set { return true; } - public boolean contains(Object object) { + public boolean contains(java.lang.Object object) { if (!(object instanceof $typemap(jboxtype, T))) { return false; } @@ -115,14 +115,14 @@ class set { public boolean removeAll(java.util.Collection collection) { boolean didRemoveElement = false; - for (Object object : collection) { + for (java.lang.Object object : collection) { didRemoveElement |= remove(object); } return didRemoveElement; } - public boolean remove(Object object) { + public boolean remove(java.lang.Object object) { if (!(object instanceof $typemap(jboxtype, T))) { return false; } diff --git a/Lib/java/std_unordered_map.i b/Lib/java/std_unordered_map.i index 8f62d7290..283a9b464 100644 --- a/Lib/java/std_unordered_map.i +++ b/Lib/java/std_unordered_map.i @@ -57,7 +57,7 @@ template class unordered_map { return sizeImpl(); } - public boolean containsKey(Object key) { + public boolean containsKey(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return false; } @@ -65,7 +65,7 @@ template class unordered_map { return containsImpl(($typemap(jboxtype, K))key); } - public $typemap(jboxtype, T) get(Object key) { + public $typemap(jboxtype, T) get(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return null; } @@ -90,7 +90,7 @@ template class unordered_map { } } - public $typemap(jboxtype, T) remove(Object key) { + public $typemap(jboxtype, T) remove(java.lang.Object key) { if (!(key instanceof $typemap(jboxtype, K))) { return null; } diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index cdc116e49..1a7b03688 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -59,7 +59,7 @@ class unordered_set { public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; - for (Object object : collection) { + for (java.lang.Object object : collection) { didAddElement |= add(($typemap(jboxtype, T))object); } @@ -96,7 +96,7 @@ class unordered_set { } public boolean containsAll(java.util.Collection collection) { - for (Object object : collection) { + for (java.lang.Object object : collection) { if (!contains(object)) { return false; } @@ -105,7 +105,7 @@ class unordered_set { return true; } - public boolean contains(Object object) { + public boolean contains(java.lang.Object object) { if (!(object instanceof $typemap(jboxtype, T))) { return false; } @@ -115,14 +115,14 @@ class unordered_set { public boolean removeAll(java.util.Collection collection) { boolean didRemoveElement = false; - for (Object object : collection) { + for (java.lang.Object object : collection) { didRemoveElement |= remove(object); } return didRemoveElement; } - public boolean remove(Object object) { + public boolean remove(java.lang.Object object) { if (!(object instanceof $typemap(jboxtype, T))) { return false; } From ff9e9f9f98e195764a1f7ec0c34d8c311a7fd6f8 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sat, 29 Apr 2017 21:55:21 +0900 Subject: [PATCH 1476/2031] [ruby] check whether object is of RTypedData using RTYPEDDATA_P. --- Examples/test-suite/ruby/Makefile.in | 1 + Examples/test-suite/ruby/ruby_rdata_runme.rb | 7 +++++++ Examples/test-suite/ruby_rdata.i | 20 ++++++++++++++++++++ Lib/ruby/rubyrun.swg | 4 ++-- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/ruby/ruby_rdata_runme.rb create mode 100644 Examples/test-suite/ruby_rdata.i diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index add65fe9f..6393026a4 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -26,6 +26,7 @@ CPP_TEST_CASES = \ ruby_keywords \ ruby_minherit_shared_ptr \ ruby_naming \ + ruby_rdata \ ruby_track_objects \ ruby_track_objects_directors \ std_containers \ diff --git a/Examples/test-suite/ruby/ruby_rdata_runme.rb b/Examples/test-suite/ruby/ruby_rdata_runme.rb new file mode 100644 index 000000000..b7f293077 --- /dev/null +++ b/Examples/test-suite/ruby/ruby_rdata_runme.rb @@ -0,0 +1,7 @@ +require 'swig_assert' +require 'ruby_rdata' + +include Ruby_rdata + +swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(Proc.new{})) +swig_assert_equal_simple(1, take_proc_or_cpp_obj_and_ret_1(C.new)) diff --git a/Examples/test-suite/ruby_rdata.i b/Examples/test-suite/ruby_rdata.i new file mode 100644 index 000000000..fb89f1276 --- /dev/null +++ b/Examples/test-suite/ruby_rdata.i @@ -0,0 +1,20 @@ +%module ruby_rdata + +%{ + + class C {}; + + int take_proc_or_cpp_obj_and_ret_1(VALUE obj) { + return 1; + } + + int take_proc_or_cpp_obj_and_ret_1(class C) { + return 1; + } + +%} + +class C {}; + +int take_proc_or_cpp_obj_and_ret_1(VALUE); +int take_proc_or_cpp_obj_and_ret_1(C); diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index b4dd9ddf0..4b2ffe4b4 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -247,7 +247,7 @@ typedef struct { SWIGRUNTIME swig_ruby_owntype SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) { swig_ruby_owntype oldown = {0, 0}; - if (TYPE(obj) == T_DATA) { + if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) { oldown.datafree = RDATA(obj)->dfree; RDATA(obj)->dfree = own.datafree; } @@ -268,7 +268,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, *ptr = 0; return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK; } else { - if (TYPE(obj) != T_DATA) { + if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) { return SWIG_ERROR; } Data_Get_Struct(obj, void, vptr); From 72723d354a830c461131f91e35b90e1d85b74e00 Mon Sep 17 00:00:00 2001 From: Takashi Tamura Date: Sat, 29 Apr 2017 22:48:07 +0900 Subject: [PATCH 1477/2031] minor edit --- Examples/test-suite/ruby_rdata.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/ruby_rdata.i b/Examples/test-suite/ruby_rdata.i index fb89f1276..06af06f36 100644 --- a/Examples/test-suite/ruby_rdata.i +++ b/Examples/test-suite/ruby_rdata.i @@ -8,7 +8,7 @@ return 1; } - int take_proc_or_cpp_obj_and_ret_1(class C) { + int take_proc_or_cpp_obj_and_ret_1(C c) { return 1; } From a006091b0f7cff98abc650e0364c0814aa976e8f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 Feb 2019 19:46:29 +0000 Subject: [PATCH 1478/2031] Add in a definition for RTYPEDDATA_P for Ruby<1.9.3 This definition ensures the SWIG wrappers keep compiling in older versions of Ruby given the previous change (which uses RTYPEDDATA_P and hence requires Ruby 1.9.3). The definition of RTYPEDDATA_P is such that the previous commit plus the definition should keep the behaviour the same as before. --- CHANGES.current | 3 +++ Lib/ruby/rubyhead.swg | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 492dffa6a..af7384dc1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-22: tamuratak + #984 Add support for RTypedData introduced in Ruby 1.9.3. + 2019-02-21: wsfulton #1240 Suppress Java 9 deprecation warnings on finalize method. diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 9960087c6..90f07cf68 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -91,6 +91,9 @@ #ifndef RSTRUCT_PTR # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr #endif +#ifndef RTYPEDDATA_P +# define RTYPEDDATA_P(x) (TYPE(x) != T_DATA) +#endif From 132359b01dc648960c5ed33f36924c80fd4e5772 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 23 Feb 2019 04:03:08 -0700 Subject: [PATCH 1479/2031] Update the COPYRIGHT file --- COPYRIGHT | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index baf15a5db..e6df73ff8 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -19,6 +19,7 @@ Active SWIG Developers: Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript) Neha Narang (narangneha03@gmail.com) (Javascript) Simon Marchetto (simon.marchetto@scilab-enterprises.com) (Scilab) + Zackery Spytz (zspytz@gmail.com) (OCaml, SWIG core) Past SWIG developers and major contributors include: Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) @@ -28,7 +29,7 @@ Past SWIG developers and major contributors include: Mikel Bancroft (mikel@franz.com) (Allegro CL) Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI) Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby]) - Art Yerkes (ayerkes@speakeasy.net) (Ocaml) + Art Yerkes (ayerkes@speakeasy.net) (OCaml) Lyle Johnson (lyle@users.sourceforge.net) (Ruby) Charlie Savage (cfis@interserv.com) (Ruby) Thien-Thi Nguyen (ttn@glug.org) (build/test/misc) From 17d0610d00a0b84640d06e470e4baffa4a176e25 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 23 Feb 2019 04:05:03 -0700 Subject: [PATCH 1480/2031] [OCaml] Fix possible memory leaks in generated dispatch functions All paths now free argv. --- Source/Modules/ocaml.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 8b248bad2..7e59def7f 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -752,7 +752,7 @@ public: Printv(df->code, "argv = (CAML_VALUE *)malloc( argc * sizeof( CAML_VALUE ) );\n" "for( i = 0; i < argc; i++ ) {\n" " argv[i] = caml_list_nth(args,i);\n" "}\n", NIL); - Printv(df->code, dispatch, "\n", NIL); + Printv(df->code, dispatch, "\nfree(argv);\n", NIL); Node *sibl = n; while (Getattr(sibl, "sym:previousSibling")) sibl = Getattr(sibl, "sym:previousSibling"); From 2bf5200242d190fd336b5fccc43c45eb71084550 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 23 Feb 2019 16:25:58 +0000 Subject: [PATCH 1481/2031] Changes file entry for Java (const char *STRING, size_t LENGTH) typemaps. --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index af7384dc1..56b311aa5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-23: gtbX + [Java] #1035 Add (const char *STRING, size_t LENGTH) typemaps in addition to the non-const + typemaps (char *STRING, size_t LENGTH) which does not attempt to write back to the const + string. + 2019-02-22: tamuratak #984 Add support for RTypedData introduced in Ruby 1.9.3. From 613ff08150e6264a5a4a964f2badeb6bba221398 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 23 Feb 2019 16:39:21 +0000 Subject: [PATCH 1482/2031] Java: more replace Object with java.lang.Object --- CHANGES.current | 4 ++++ Lib/java/java.swg | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 56b311aa5..3de7275ec 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-23: zphensley42 + Use fully qualified name 'java.lang.Object' instead of 'Object' in generated code to + avoid clashes with wrapped C++ classes called 'Object'. + 2019-02-23: gtbX [Java] #1035 Add (const char *STRING, size_t LENGTH) typemaps in addition to the non-const typemaps (char *STRING, size_t LENGTH) which does not attempt to write back to the const diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 6a6523eba..a5b7bbab1 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -160,7 +160,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { %typemap(jtype) jfloat "float" %typemap(jtype) jdouble "double" %typemap(jtype) jstring "String" -%typemap(jtype) jobject "Object" +%typemap(jtype) jobject "java.lang.Object" %typemap(jtype) jbooleanArray "boolean[]" %typemap(jtype) jcharArray "char[]" %typemap(jtype) jbyteArray "byte[]" @@ -169,7 +169,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { %typemap(jtype) jlongArray "long[]" %typemap(jtype) jfloatArray "float[]" %typemap(jtype) jdoubleArray "double[]" -%typemap(jtype) jobjectArray "Object[]" +%typemap(jtype) jobjectArray "java.lang.Object[]" %typemap(jstype) jboolean "boolean" %typemap(jstype) jchar "char" @@ -180,7 +180,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { %typemap(jstype) jfloat "float" %typemap(jstype) jdouble "double" %typemap(jstype) jstring "String" -%typemap(jstype) jobject "Object" +%typemap(jstype) jobject "java.lang.Object" %typemap(jstype) jbooleanArray "boolean[]" %typemap(jstype) jcharArray "char[]" %typemap(jstype) jbyteArray "byte[]" @@ -189,7 +189,7 @@ SWIGINTERN jint SWIG_JavaIntFromSize_t(size_t size) { %typemap(jstype) jlongArray "long[]" %typemap(jstype) jfloatArray "float[]" %typemap(jstype) jdoubleArray "double[]" -%typemap(jstype) jobjectArray "Object[]" +%typemap(jstype) jobjectArray "java.lang.Object[]" /* Non primitive types */ %typemap(jni) SWIGTYPE "jlong" From e8cc5929de91226f23ae3d4e31d35e6c53472e6a Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 24 Feb 2019 08:04:45 -0700 Subject: [PATCH 1483/2031] Remove a useless warning filter Add cpp11_final_directors to Examples/test-suite/common.mk. --- Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp11_final_directors.i | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3d4edd47b..7b4836a17 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -571,6 +571,7 @@ CPP11_TEST_CASES += \ cpp11_director_enums \ cpp11_directors \ cpp11_explicit_conversion_operators \ + cpp11_final_directors \ cpp11_final_override \ cpp11_function_objects \ cpp11_inheriting_constructors \ diff --git a/Examples/test-suite/cpp11_final_directors.i b/Examples/test-suite/cpp11_final_directors.i index d724543ea..2b001bd7b 100644 --- a/Examples/test-suite/cpp11_final_directors.i +++ b/Examples/test-suite/cpp11_final_directors.i @@ -1,7 +1,5 @@ %module(directors="1") cpp11_final_directors -%warnfilter(SWIGWARN_PARSE_KEYWORD) final; - %director Derived; %inline %{ From 83ea2280e2e99ecafa2e3d2e041548a2f02aa19b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Feb 2019 19:27:23 +0000 Subject: [PATCH 1484/2031] Fix Python compile errors with overloading and varargs Fixes wrapping overloaded functions/constructors where a vararg function is declared after a non-vararg function. This is a long standing bug in the Python layer exposed since fastunpack was turned on by default. --- CHANGES.current | 4 ++ .../test-suite/go/varargs_overload_runme.go | 36 +++++++++++++++ .../ocaml/varargs_overload_runme.ml | 16 ++++++- .../python/varargs_overload_runme.py | 32 ++++++++++++++ .../scilab/varargs_overload_runme.sci | 22 +++++++++- Examples/test-suite/varargs_overload.i | 44 +++++++++++++++++++ Source/Modules/emit.cxx | 27 +++++++++++- Source/Modules/python.cxx | 20 +-------- Source/Modules/swigmod.h | 3 +- Source/Swig/parms.c | 16 +++++++ Source/Swig/swigparm.h | 1 + 11 files changed, 199 insertions(+), 22 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3de7275ec..23455b289 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-25: wsfulton + [Python] Fix compile errors wrapping overloaded functions/constructors where a vararg + function is declared after a non-vararg function. + 2019-02-23: zphensley42 Use fully qualified name 'java.lang.Object' instead of 'Object' in generated code to avoid clashes with wrapped C++ classes called 'Object'. diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go index 52fc1b0e9..5978be005 100644 --- a/Examples/test-suite/go/varargs_overload_runme.go +++ b/Examples/test-suite/go/varargs_overload_runme.go @@ -35,4 +35,40 @@ func main() { if varargs_overload.Vararg_over4("Hello", 123) != "Hello" { panic(8) } + + + // Same as above but non-vararg function declared first + + if varargs_overload.Vararg_over6("Hello") != "Hello" { + panic(0) + } + if varargs_overload.Vararg_over6(2) != "2" { + panic(1) + } + + if varargs_overload.Vararg_over7("Hello") != "Hello" { + panic(2) + } + if varargs_overload.Vararg_over7(2, 2.2) != "2 2.2" { + panic(3) + } + + if varargs_overload.Vararg_over8("Hello") != "Hello" { + panic(4) + } + if varargs_overload.Vararg_over8(2, 2.2, "hey") != "2 2.2 hey" { + panic(5) + } + + if varargs_overload.Vararg_over9("Hello") != "Hello" { + panic(6) + } + + if varargs_overload.Vararg_over9(123) != "123" { + panic(7) + } + + if varargs_overload.Vararg_over9("Hello", 123) != "Hello" { + panic(8) + } } diff --git a/Examples/test-suite/ocaml/varargs_overload_runme.ml b/Examples/test-suite/ocaml/varargs_overload_runme.ml index 3085e6258..418f881e3 100644 --- a/Examples/test-suite/ocaml/varargs_overload_runme.ml +++ b/Examples/test-suite/ocaml/varargs_overload_runme.ml @@ -11,5 +11,19 @@ let _ = assert (_vararg_over3 '(2, 2.2, "hey") as string = "2 2.2 hey"); assert (_vararg_over4 '("Hello") as string = "Hello"); assert (_vararg_over4 '(123) as string = "123"); - assert (_vararg_over4 '("Hello", 123) as string = "Hello") + assert (_vararg_over4 '("Hello", 123) as string = "Hello"); + + + (* Same as above but non-vararg function declared first *) + + assert (_vararg_over6 '("Hello") as string = "Hello"); + assert (_vararg_over6 '(2) as string = "2"); + assert (_vararg_over7 '("Hello") as string = "Hello"); + assert (_vararg_over7 '(2, 2.2) as string = "2 2.2"); + + assert (_vararg_over8 '("Hello") as string = "Hello"); + assert (_vararg_over8 '(2, 2.2, "hey") as string = "2 2.2 hey"); + assert (_vararg_over9 '("Hello") as string = "Hello"); + assert (_vararg_over9 '(123) as string = "123"); + assert (_vararg_over9 '("Hello", 123) as string = "Hello"); ;; diff --git a/Examples/test-suite/python/varargs_overload_runme.py b/Examples/test-suite/python/varargs_overload_runme.py index 37958620c..6f5a70222 100644 --- a/Examples/test-suite/python/varargs_overload_runme.py +++ b/Examples/test-suite/python/varargs_overload_runme.py @@ -28,3 +28,35 @@ if varargs_overload.vararg_over4(123) != "123": if varargs_overload.vararg_over4("Hello", 123) != "Hello": raise RuntimeError, "Failed" + + +# Same as above but non-vararg function declared first + +if varargs_overload.vararg_over6("Hello") != "Hello": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over6(2) != "2": + raise RuntimeError, "Failed" + + +if varargs_overload.vararg_over7("Hello") != "Hello": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over7(2, 2.2) != "2 2.2": + raise RuntimeError, "Failed" + + +if varargs_overload.vararg_over8("Hello") != "Hello": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over8(2, 2.2, "hey") != "2 2.2 hey": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over9("Hello") != "Hello": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over9(123) != "123": + raise RuntimeError, "Failed" + +if varargs_overload.vararg_over9("Hello", 123) != "Hello": + raise RuntimeError, "Failed" diff --git a/Examples/test-suite/scilab/varargs_overload_runme.sci b/Examples/test-suite/scilab/varargs_overload_runme.sci index 7603b667c..7426e8165 100644 --- a/Examples/test-suite/scilab/varargs_overload_runme.sci +++ b/Examples/test-suite/scilab/varargs_overload_runme.sci @@ -4,7 +4,7 @@ checkequal(vararg_over1("Hello"), "Hello", "vararg_over1(""Hello"")"); checkequal(vararg_over1(2), "2", "vararg_over1(2)"); -checkequal(vararg_over2("Hello"), "Hello", "vararg_over1(""Hello"")"); +checkequal(vararg_over2("Hello"), "Hello", "vararg_over2(""Hello"")"); checkequal(vararg_over2(2, 2.2), "2 2.2", "vararg_over2(2, 2.2)") @@ -18,4 +18,24 @@ checkequal(vararg_over4(123), "123", "vararg_over4(123)"); checkequal(vararg_over4("Hello", 123), "Hello", "vararg_over4(""Hello"", 123)"); + +// Same as above but non-vararg function declared first + +checkequal(vararg_over6("Hello"), "Hello", "vararg_over6(""Hello"")"); + +checkequal(vararg_over6(2), "2", "vararg_over6(2)"); + +checkequal(vararg_over7("Hello"), "Hello", "vararg_over7(""Hello"")"); + +checkequal(vararg_over7(2, 2.2), "2 2.2", "vararg_over7(2, 2.2)") + +checkequal(vararg_over8("Hello"), "Hello", "vararg_over8(""Hello"")"); + +checkequal(vararg_over8(2, 2.2, "hey"), "2 2.2 hey", "vararg_over8(2, 2.2, ""hey"")"); + +checkequal(vararg_over9("Hello"), "Hello", "vararg_over9(""Hello"")"); + +checkequal(vararg_over9(123), "123", "vararg_over9(123)"); + +checkequal(vararg_over9("Hello", 123), "Hello", "vararg_over9(""Hello"", 123)"); exec("swigtest.quit", -1); diff --git a/Examples/test-suite/varargs_overload.i b/Examples/test-suite/varargs_overload.i index 9a24e15a8..eb9dcaab9 100644 --- a/Examples/test-suite/varargs_overload.i +++ b/Examples/test-suite/varargs_overload.i @@ -44,3 +44,47 @@ const char *vararg_over4(int i) { return buffer; } %} + + +// Same as above but non-vararg function declared first + +%inline %{ +const char *vararg_over6(int i) { + static char buffer[256]; + sprintf(buffer, "%d", i); + return buffer; +} +const char *vararg_over6(const char *fmt, ...) { + return fmt; +} + +const char *vararg_over7(int i, double j) { + static char buffer[256]; + sprintf(buffer, "%d %g", i, j); + return buffer; +} +const char *vararg_over7(const char *fmt, ...) { + return fmt; +} + +const char *vararg_over8(int i, double j, const char *s) { + static char buffer[256]; + sprintf(buffer, "%d %g %s", i, j, s); + return buffer; +} +const char *vararg_over8(const char *fmt, ...) { + return fmt; +} +%} + +%varargs(int mode = 0) vararg_over9; +%inline %{ +const char *vararg_over9(int i) { + static char buffer[256]; + sprintf(buffer, "%d", i); + return buffer; +} +const char *vararg_over9(const char *fmt, ...) { + return fmt; +} +%} diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 43f87db6f..7a4c2dcfb 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -188,7 +188,9 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) { p = lp; while (p) { if (SwigType_isvarargs(Getattr(p, "type"))) { + // Mark the head of the ParmList that it has varargs Setattr(l, "emit:varargs", lp); +//Printf(stdout, "setting emit:varargs %s ... %s +++ %s\n", Getattr(l, "emit:varargs"), Getattr(l, "type"), Getattr(p, "type")); break; } p = nextSibling(p); @@ -329,7 +331,8 @@ int emit_num_required(ParmList *parms) { /* ----------------------------------------------------------------------------- * emit_isvarargs() * - * Checks if a function is a varargs function + * Checks if a ParmList is a parameter list containing varargs. + * This function requires emit_attach_parmmaps to have been called beforehand. * ----------------------------------------------------------------------------- */ int emit_isvarargs(ParmList *p) { @@ -340,6 +343,28 @@ int emit_isvarargs(ParmList *p) { return 0; } +/* ----------------------------------------------------------------------------- + * emit_isvarargs_function() + * + * Checks for varargs in a function/constructor (can be overloaded) + * ----------------------------------------------------------------------------- */ + +bool emit_isvarargs_function(Node *n) { + bool has_varargs = false; + Node *over = Getattr(n, "sym:overloaded"); + if (over) { + for (Node *sibling = over; sibling; sibling = Getattr(sibling, "sym:nextSibling")) { + if (ParmList_has_varargs(Getattr(sibling, "parms"))) { + has_varargs = true; + break; + } + } + } else { + has_varargs = ParmList_has_varargs(Getattr(n, "parms")) ? true : false; + } + return has_varargs; +} + /* ----------------------------------------------------------------------------- * void emit_mark_vararg_parms() * diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3c1767d6f..9ffc00592 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2187,7 +2187,7 @@ public: * is_real_overloaded() * * Check if the function is overloaded, but not just have some - * siblings generated due to the original function have + * siblings generated due to the original function having * default arguments. * ------------------------------------------------------------ */ bool is_real_overloaded(Node *n) { @@ -2689,7 +2689,6 @@ public: bool add_self = builtin_self && (!builtin_ctor || director_class); bool builtin_getter = (builtin && GetFlag(n, "memberget")); bool builtin_setter = (builtin && GetFlag(n, "memberset") && !builtin_getter); - bool over_varargs = false; char const *self_param = builtin ? "self" : "SWIGUNUSEDPARM(self)"; char const *wrap_return = builtin_ctor ? "int " : "PyObject *"; String *linkage = NewString("SWIGINTERN "); @@ -2765,22 +2764,7 @@ public: } } - if (overname) { - String *over_varargs_attr = Getattr(n, "python:overvarargs"); - if (!over_varargs_attr) { - for (Node *sibling = n; sibling; sibling = Getattr(sibling, "sym:nextSibling")) { - if (emit_isvarargs(Getattr(sibling, "parms"))) { - over_varargs = true; - break; - } - } - over_varargs_attr = NewString(over_varargs ? "1" : "0"); - for (Node *sibling = n; sibling; sibling = Getattr(sibling, "sym:nextSibling")) - Setattr(sibling, "python:overvarargs", over_varargs_attr); - } - if (Strcmp(over_varargs_attr, "0") != 0) - over_varargs = true; - } + bool over_varargs = emit_isvarargs_function(n); int funpack = fastunpack && !varargs && !over_varargs && !allow_kwargs; int noargs = funpack && (tuple_required == 0 && tuple_arguments == 0); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index ef49c5684..583cb13fe 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -383,7 +383,8 @@ List *SWIG_output_files(); void SWIG_library_directory(const char *); int emit_num_arguments(ParmList *); int emit_num_required(ParmList *); -int emit_isvarargs(ParmList *); +int emit_isvarargs(ParmList *p); +bool emit_isvarargs_function(Node *n); void emit_attach_parmmaps(ParmList *, Wrapper *f); void emit_mark_varargs(ParmList *l); String *emit_action(Node *n); diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index bec1e63fa..3e832c361 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -254,3 +254,19 @@ int ParmList_has_defaultargs(ParmList *p) { } return 0; } + +/* --------------------------------------------------------------------- + * ParmList_has_varargs() + * + * Returns 1 if the parameter list passed in has varargs. + * Otherwise returns 0. + * ---------------------------------------------------------------------- */ + +int ParmList_has_varargs(ParmList *p) { + Parm *lp = 0; + while (p) { + lp = p; + p = nextSibling(p); + } + return lp ? SwigType_isvarargs(Getattr(lp, "type")) : 0; +} diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 368b4d26b..7b27df5f6 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -24,6 +24,7 @@ extern ParmList *CopyParmListMax(ParmList *, int count); extern int ParmList_len(ParmList *); extern int ParmList_numrequired(ParmList *); extern int ParmList_has_defaultargs(ParmList *p); +extern int ParmList_has_varargs(ParmList *p); /* Output functions */ extern String *ParmList_str(ParmList *); From 9e29ae16d2bb51e47b255867551c794a6e45817a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Mar 2019 08:15:03 +0000 Subject: [PATCH 1485/2031] Update template_opaque testcase --- Examples/test-suite/template_opaque.i | 3 --- 1 file changed, 3 deletions(-) diff --git a/Examples/test-suite/template_opaque.i b/Examples/test-suite/template_opaque.i index b910e47e3..7aafd62e8 100644 --- a/Examples/test-suite/template_opaque.i +++ b/Examples/test-suite/template_opaque.i @@ -36,7 +36,4 @@ namespace A { } } -#ifndef SWIGCSHARP -// C# vector typemaps only ready for simple cases right now %template(OpaqueVectorType) std::vector; -#endif From be491506a4036f627778b71641dff1fdf66b9a67 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Mar 2019 18:01:14 +0000 Subject: [PATCH 1486/2031] Java std::vector improvements for types that do not have a default constructor. The std::vector wrappers have been changed to work by default for elements that are not default insertable, i.e. have no default constructor. This has been achieved by not wrapping: vector(size_type n); Previously the above had to be ignored via %ignore. If the above constructor is still required it can be added back in again via %extend: %extend std::vector { vector(size_type count) { return new std::vector< T >(count); } } Alternatively, the following wrapped constructor could be used as it provides near-enough equivalent functionality: vector(jint count, const value_type& value); The equivalent change to std::list has also been made (std::list wrappers were not in the previous release [3.0.12] though). --- CHANGES.current | 24 +++++++++++++++++++ Examples/test-suite/common.mk | 1 + .../test-suite/java/li_std_list_runme.java | 2 +- .../test-suite/java/li_std_vector_runme.java | 2 +- .../test-suite/stl_no_default_constructor.i | 19 +++++++++++++++ Lib/java/std_list.i | 5 ---- Lib/java/std_vector.i | 5 ---- 7 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 Examples/test-suite/stl_no_default_constructor.i diff --git a/CHANGES.current b/CHANGES.current index 23455b289..43df38b2c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,30 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-02-28: wsfulton + [Java] std::vector improvements for types that do not have a default constructor. + + The std::vector wrappers have been changed to work by default for elements that are + not default insertable, i.e. have no default constructor. This has been achieved by + not wrapping: + + vector(size_type n); + + Previously the above had to be ignored via %ignore. + + If the above constructor is still required it can be added back in again via %extend: + + %extend std::vector { + vector(size_type count) { return new std::vector< T >(count); } + } + + Alternatively, the following wrapped constructor could be used as it provides near-enough + equivalent functionality: + + vector(jint count, const value_type& value); + + *** POTENTIAL INCOMPATIBILITY *** + 2019-02-25: wsfulton [Python] Fix compile errors wrapping overloaded functions/constructors where a vararg function is declared after a non-vararg function. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 3d4edd47b..60f6a9522 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -407,6 +407,7 @@ CPP_TEST_CASES += \ static_array_member \ static_const_member \ static_const_member_2 \ + stl_no_default_constructor \ string_constants \ struct_initialization_cpp \ struct_value \ diff --git a/Examples/test-suite/java/li_std_list_runme.java b/Examples/test-suite/java/li_std_list_runme.java index 94bcada02..96412fdaf 100644 --- a/Examples/test-suite/java/li_std_list_runme.java +++ b/Examples/test-suite/java/li_std_list_runme.java @@ -53,7 +53,7 @@ public class li_std_list_runme { if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed"); - if (new IntList(3).size() != 3) throw new RuntimeException("constructor initial size test failed"); + if (new IntList(3, 0).size() != 3) throw new RuntimeException("constructor initial size test failed"); for (int n : new IntList(10, 999)) if (n != 999) throw new RuntimeException("constructor initialization with value failed"); for (int n : new IntList(new IntList(10, 999))) diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index ba0648562..fc8ba0f6f 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -54,7 +54,7 @@ public class li_std_vector_runme { if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed"); - if (new IntVector(3).size() != 3) throw new RuntimeException("constructor initial size test failed"); + if (new IntVector(3, 0).size() != 3) throw new RuntimeException("constructor initial size test failed"); for (int n : new IntVector(10, 999)) if (n != 999) throw new RuntimeException("constructor initialization with value failed"); for (int n : new IntVector(new IntVector(10, 999))) diff --git a/Examples/test-suite/stl_no_default_constructor.i b/Examples/test-suite/stl_no_default_constructor.i new file mode 100644 index 000000000..164710bd5 --- /dev/null +++ b/Examples/test-suite/stl_no_default_constructor.i @@ -0,0 +1,19 @@ +%module stl_no_default_constructor + +%include + +%inline %{ +struct NoDefaultCtor { + int value; + NoDefaultCtor(int i) : value(i) {} +}; +%} + +#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD) +%template(VectorNoDefaultCtor) std::vector; +#endif + +#if defined(SWIGJAVA) +%include +%template(ListNoDefaultCtor) std::list; +#endif diff --git a/Lib/java/std_list.i b/Lib/java/std_list.i index 82ccde38b..1077bd0a0 100644 --- a/Lib/java/std_list.i +++ b/Lib/java/std_list.i @@ -198,11 +198,6 @@ namespace std { %extend { %fragment("SWIG_ListSize"); - list(jint count) throw (std::out_of_range) { - if (count < 0) - throw std::out_of_range("list count must be positive"); - return new std::list(static_cast::size_type>(count)); - } list(jint count, const T &value) throw (std::out_of_range) { if (count < 0) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index f621e8992..88de46f46 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -94,11 +94,6 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { void clear(); %extend { %fragment("SWIG_VectorSize"); - vector(jint count) throw (std::out_of_range) { - if (count < 0) - throw std::out_of_range("vector count must be positive"); - return new std::vector< CTYPE >(static_cast::size_type>(count)); - } vector(jint count, const CTYPE &value) throw (std::out_of_range) { if (count < 0) From cfdf65eb3414e1c0ffb7156de72afb280dc8fe0d Mon Sep 17 00:00:00 2001 From: John Wason Date: Fri, 1 Mar 2019 19:13:35 -0500 Subject: [PATCH 1487/2031] Include all template parameters for std_unordered_map macro --- Lib/python/std_unordered_map.i | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 79882b292..76acbb1ec 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -56,26 +56,26 @@ %fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { - typedef typename std::unordered_map::value_type value_type; + assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { + typedef typename std::unordered_map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_map->insert(value_type(it->first, it->second)); } } - template - struct traits_reserve > { - static void reserve(std::unordered_map &seq, typename std::unordered_map::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_map &seq, typename std::unordered_map::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - typedef std::unordered_map unordered_map_type; + template + struct traits_asptr > { + typedef std::unordered_map unordered_map_type; static int asptr(PyObject *obj, unordered_map_type **val) { int res = SWIG_ERROR; SWIG_PYTHON_THREAD_BEGIN_BLOCK; @@ -85,7 +85,7 @@ /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif - res = traits_asptr_stdseq, std::pair >::asptr(items, val); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_map_type *p; swig_type_info *descriptor = swig::type_info(); @@ -97,9 +97,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_map unordered_map_type; + template + struct traits_from > { + typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; typedef typename unordered_map_type::size_type size_type; From b9c4a84780157ab1812a4ba6cdb72020430f8385 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Mar 2019 19:02:35 +0000 Subject: [PATCH 1488/2031] Warning fix for final destructor in directors Fix suppression of final destructors used in director classes. Add testcase for final destructors in director classes. --- Examples/test-suite/cpp11_final_directors.i | 8 ++++++++ Examples/test-suite/errors/cpp_final_destructor.stderr | 1 + Source/Modules/lang.cxx | 2 ++ 3 files changed, 11 insertions(+) create mode 100644 Examples/test-suite/errors/cpp_final_destructor.stderr diff --git a/Examples/test-suite/cpp11_final_directors.i b/Examples/test-suite/cpp11_final_directors.i index 2b001bd7b..ccd5d1b20 100644 --- a/Examples/test-suite/cpp11_final_directors.i +++ b/Examples/test-suite/cpp11_final_directors.i @@ -1,6 +1,9 @@ %module(directors="1") cpp11_final_directors %director Derived; +%director BaseFinalDestructor; + +%warnfilter(SWIGWARN_LANG_DIRECTOR_FINAL) BaseFinalDestructor::~BaseFinalDestructor; %inline %{ struct Base { @@ -13,4 +16,9 @@ struct Derived : Base { virtual int meth() { return 2; } virtual ~Derived() {} }; + +struct BaseFinalDestructor { + virtual void basefinalmeth() final {} + virtual ~BaseFinalDestructor() final {} +}; %} diff --git a/Examples/test-suite/errors/cpp_final_destructor.stderr b/Examples/test-suite/errors/cpp_final_destructor.stderr new file mode 100644 index 000000000..924396341 --- /dev/null +++ b/Examples/test-suite/errors/cpp_final_destructor.stderr @@ -0,0 +1 @@ +cpp_final_destructor.i:7: Warning 525: Destructor of director base class BaseFinal is marked as final. diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index acb5e4348..d79e07f36 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2200,7 +2200,9 @@ int Language::classDirector(Node *n) { Node *nodeType = Getattr(ni, "nodeType"); if (Cmp(nodeType, "destructor") == 0 && GetFlag(ni, "final")) { String *classtype = Getattr(n, "classtype"); + SWIG_WARN_NODE_BEGIN(ni); Swig_warning(WARN_LANG_DIRECTOR_FINAL, input_file, line_number, "Destructor of director base class %s is marked as final.\n", classtype); + SWIG_WARN_NODE_END(ni); Delete(vtable); Delete(using_protected_members_code); return SWIG_OK; From 3b07cba74066ef3a95b1e66a8c7d869a9510d1b9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 2 Mar 2019 19:57:33 +0000 Subject: [PATCH 1489/2031] Fixes for final destructors in director classes A class marked as a director with a final destructor should not be a wrapped as a director class. Fix seg faults in this case. --- Examples/test-suite/cpp11_final_directors.i | 9 +++++++++ Source/Modules/lang.cxx | 3 +++ 2 files changed, 12 insertions(+) diff --git a/Examples/test-suite/cpp11_final_directors.i b/Examples/test-suite/cpp11_final_directors.i index ccd5d1b20..b58111adb 100644 --- a/Examples/test-suite/cpp11_final_directors.i +++ b/Examples/test-suite/cpp11_final_directors.i @@ -1,9 +1,13 @@ %module(directors="1") cpp11_final_directors %director Derived; + +// Check SWIG will not wrap these classes as directors where the destructors are final %director BaseFinalDestructor; +%director BaseFinalDestructor2; %warnfilter(SWIGWARN_LANG_DIRECTOR_FINAL) BaseFinalDestructor::~BaseFinalDestructor; +%warnfilter(SWIGWARN_LANG_DIRECTOR_FINAL) BaseFinalDestructor2::~BaseFinalDestructor2; %inline %{ struct Base { @@ -21,4 +25,9 @@ struct BaseFinalDestructor { virtual void basefinalmeth() final {} virtual ~BaseFinalDestructor() final {} }; + +struct BaseFinalDestructor2 { + virtual void basefinalmeth() {} + virtual ~BaseFinalDestructor2() final {} +}; %} diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index d79e07f36..272936e4e 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1894,6 +1894,8 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_ } if (!checkAttribute(nn, "storage", "virtual")) continue; + if (GetFlag(nn, "final")) + continue; /* we need to add methods(cdecl) and destructor (to check for throw decl) */ int is_destructor = (Cmp(nodeType, "destructor") == 0); if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) { @@ -2203,6 +2205,7 @@ int Language::classDirector(Node *n) { SWIG_WARN_NODE_BEGIN(ni); Swig_warning(WARN_LANG_DIRECTOR_FINAL, input_file, line_number, "Destructor of director base class %s is marked as final.\n", classtype); SWIG_WARN_NODE_END(ni); + SetFlag(n, "feature:nodirector"); Delete(vtable); Delete(using_protected_members_code); return SWIG_OK; From 34108deec7e89d9f7c70b337702cfffb1e34c006 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Mar 2019 14:26:43 +0000 Subject: [PATCH 1490/2031] Documentation for directors and virtual final methods --- Doc/Manual/Go.html | 4 +++- Doc/Manual/Java.html | 7 ++++--- Doc/Manual/Perl5.html | 7 ++++--- Doc/Manual/Php.html | 7 ++++--- Doc/Manual/Python.html | 7 ++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 4a60e45e0..047b46edf 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -785,7 +785,9 @@ In order to override virtual methods on a C++ class with Go methods the NewDirectorClassName constructor functions receives a DirectorInterface argument. The methods in the DirectorInterface are a subset of the public and protected virtual methods -of the C++ class. If the DirectorInterface contains a method with a +of the C++ class. +Virtual methods that have a final specifier are unsurprisingly excluded. +If the DirectorInterface contains a method with a matching signature to a virtual method of the C++ class then the virtual C++ method will be overwritten with the Go method. As Go doesn't support protected methods all overridden protected virtual C++ methods will be public in Go. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index bf77c1562..3a04b8a79 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -3629,7 +3629,7 @@ The %feature directive can be applied globally, to specific classes, and to spec // generate directors for all classes that have virtual methods %feature("director"); -// generate directors for all virtual methods in class Foo +// generate directors for the virtual methods in class Foo %feature("director") Foo;
  • @@ -3647,7 +3647,7 @@ So for example,

    -will generate directors for all virtual methods of class Foo except bar(). +will generate directors for the virtual methods of class Foo except bar().

    @@ -3683,7 +3683,8 @@ The director classes store a pointer to their underlying Java proxy classes.

    For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). -Thus all virtual method calls, whether they originate in C++ or in Java via proxy classes, eventually end up in at the implementation in the director class. +Virtual methods that have a final specifier are unsurprisingly excluded. +Thus the virtual method calls, whether they originate in C++ or in Java via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate place" we mean the method that would have been called if the C++ base class and its Java derived classes were seamlessly integrated. That seamless integration is exactly what the director classes provide, transparently skipping over all the messy JNI glue code that binds the two languages together. diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 5ce765c26..766ccaede 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -3070,7 +3070,7 @@ globally, to specific classes, and to specific methods, like this: // generate directors for all classes that have virtual methods %feature("director"); -// generate directors for all virtual methods in class Foo +// generate directors for the virtual methods in class Foo %feature("director") Foo;

    @@ -3088,7 +3088,7 @@ directors for specific classes or methods. So for example,

    -will generate directors for all virtual methods of class Foo except +will generate directors for the virtual methods of class Foo except bar().

    @@ -3153,7 +3153,8 @@ For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). -Thus all virtual method calls, whether they originate in C++ or in +Virtual methods that have a final specifier are unsurprisingly excluded. +Thus the virtual method calls, whether they originate in C++ or in Perl via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 85732fd33..1b8b2d468 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -937,7 +937,7 @@ globally, to specific classes, and to specific methods, like this: // generate directors for all classes that have virtual methods %feature("director"); -// generate directors for all virtual methods in class Foo +// generate directors for the virtual methods in class Foo %feature("director") Foo; @@ -955,7 +955,7 @@ directors for specific classes or methods. So for example,

    -will generate directors for all virtual methods of class Foo except +will generate directors for the virtual methods of class Foo except bar().

    @@ -1020,7 +1020,8 @@ For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). -Thus all virtual method calls, whether they originate in C++ or in +Virtual methods that have a final specifier are unsurprisingly excluded. +Thus the virtual method calls, whether they originate in C++ or in PHP via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By "appropriate diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 6a174fddf..2554e9da3 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2934,7 +2934,7 @@ globally, to specific classes, and to specific methods, like this: // generate directors for all classes that have virtual methods %feature("director"); -// generate directors for all virtual methods in class Foo +// generate directors for the virtual methods in class Foo %feature("director") Foo; @@ -2952,7 +2952,7 @@ directors for specific classes or methods. So for example,

    -will generate directors for all virtual methods of class Foo except +will generate directors for the virtual methods of class Foo except bar().

    @@ -3018,7 +3018,8 @@ For simplicity let's ignore the Swig::Director class and refer to the original C++ class as the director's base class. By default, a director class extends all virtual methods in the inheritance chain of its base class (see the preceding section for how to modify this behavior). -Thus all virtual method calls, whether they originate in C++ or in +Virtual methods that have a final specifier are unsurprisingly excluded. +Thus the virtual method calls, whether they originate in C++ or in Python via proxy classes, eventually end up in at the implementation in the director class. The job of the director methods is to route these method calls to the appropriate place in the inheritance chain. By From 39b44a377a785ac45d7de5cdf725fb10caef48d1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Mar 2019 15:12:29 +0000 Subject: [PATCH 1491/2031] Warning tweaks for destructors that are final in director classes --- Doc/Manual/Warnings.html | 2 +- Examples/test-suite/errors/cpp_final_destructor.stderr | 2 +- Source/Modules/lang.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 8b2ab2b95..c63d7de0c 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -535,7 +535,7 @@ example.i(4) : Syntax error in input(1).
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'.
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.
  • 524. Experimental target language. Target language language specified by lang is an experimental language. Please read about SWIG experimental languages, htmllink. -
  • 525. The director base class 'name' or the destructor of director base class 'name' is marked as final. +
  • 525. Destructor declaration is final, name cannot be a director class.

    18.9.6 Doxygen comments (560-599)

    diff --git a/Examples/test-suite/errors/cpp_final_destructor.stderr b/Examples/test-suite/errors/cpp_final_destructor.stderr index 924396341..d8c509d0c 100644 --- a/Examples/test-suite/errors/cpp_final_destructor.stderr +++ b/Examples/test-suite/errors/cpp_final_destructor.stderr @@ -1 +1 @@ -cpp_final_destructor.i:7: Warning 525: Destructor of director base class BaseFinal is marked as final. +cpp_final_destructor.i:7: Warning 525: Destructor BaseFinal::~BaseFinal() is final, BaseFinal cannot be a director class. diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 272936e4e..f7979b611 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -2203,7 +2203,7 @@ int Language::classDirector(Node *n) { if (Cmp(nodeType, "destructor") == 0 && GetFlag(ni, "final")) { String *classtype = Getattr(n, "classtype"); SWIG_WARN_NODE_BEGIN(ni); - Swig_warning(WARN_LANG_DIRECTOR_FINAL, input_file, line_number, "Destructor of director base class %s is marked as final.\n", classtype); + Swig_warning(WARN_LANG_DIRECTOR_FINAL, input_file, line_number, "Destructor %s is final, %s cannot be a director class.\n", Swig_name_decl(ni), classtype); SWIG_WARN_NODE_END(ni); SetFlag(n, "feature:nodirector"); Delete(vtable); From 412b113c0b93b2c209ec53265b35ff4d91db257e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 3 Mar 2019 16:00:02 +0000 Subject: [PATCH 1492/2031] Run errors test cases in predictable order --- Examples/test-suite/errors/Makefile.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index c66840997..10e5bdd8f 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -24,11 +24,11 @@ SWIG_LIB_SET = @SWIG_LIB_SET@ SWIGINVOKE = $(SWIG_LIB_SET) $(SWIGTOOL) $(SWIGEXE) # All .i files with prefix 'cpp_' will be treated as C++ input and remaining .i files as C input -ALL_ERROR_TEST_CASES := $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i))) -CPP_ERROR_TEST_CASES := $(filter cpp_%, $(ALL_ERROR_TEST_CASES)) -C_ERROR_TEST_CASES := $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES)) -DOXYGEN_ERROR_TEST_CASES := $(filter doxygen_%, $(C_ERROR_TEST_CASES)) -C_ERROR_TEST_CASES := $(filter-out $(DOXYGEN_ERROR_TEST_CASES), $(C_ERROR_TEST_CASES)) +ALL_ERROR_TEST_CASES := $(sort $(patsubst %.i,%, $(notdir $(wildcard $(srcdir)/*.i)))) +CPP_ERROR_TEST_CASES := $(sort $(filter cpp_%, $(ALL_ERROR_TEST_CASES))) +C_ERROR_TEST_CASES := $(sort $(filter-out $(CPP_ERROR_TEST_CASES), $(ALL_ERROR_TEST_CASES))) +DOXYGEN_ERROR_TEST_CASES := $(sort $(filter doxygen_%, $(C_ERROR_TEST_CASES))) +C_ERROR_TEST_CASES := $(sort $(filter-out $(DOXYGEN_ERROR_TEST_CASES), $(C_ERROR_TEST_CASES))) # Always use C++ for Doxygen tests, there doesn't seem to be any need to # distinguish between C and C++ Doxygen tests. From e5ae89403dd8b58737793aa3c32f0f90abcc213d Mon Sep 17 00:00:00 2001 From: Mizux Date: Tue, 5 Mar 2019 16:11:50 +0100 Subject: [PATCH 1493/2031] Fix "Default Marshaling for Arrays" Previous link is dead... --- Doc/Manual/CSharp.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 7a9b7470b..d485a9714 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -643,7 +643,7 @@ passing a direct reference as described in the next section.

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

    From a0b84f51807dbfd35f334bb9c266841f8d2ae111 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 7 Mar 2019 09:44:01 -0700 Subject: [PATCH 1494/2031] Fix some MSVC compiler warnings in the test suite nested_in_template_wrap.cxx(247): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data python_pybuffer_wrap.cxx(2788): warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data Modules\python.cxx(2227) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning) --- Examples/test-suite/nested_in_template.i | 2 +- Examples/test-suite/python_pybuffer.i | 2 +- Source/Modules/python.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/nested_in_template.i b/Examples/test-suite/nested_in_template.i index 2e79fa574..81d5b6289 100644 --- a/Examples/test-suite/nested_in_template.i +++ b/Examples/test-suite/nested_in_template.i @@ -19,7 +19,7 @@ struct OuterTemplate<1> struct ConcreteDerived : AbstractBase { - ConcreteDerived() : m_value(0.) {} + ConcreteDerived() : m_value(0) {} explicit ConcreteDerived(int value) : m_value(value) {} virtual bool IsSameAs(const AbstractBase& other) const { diff --git a/Examples/test-suite/python_pybuffer.i b/Examples/test-suite/python_pybuffer.i index b46d8c36a..bff72bfa2 100644 --- a/Examples/test-suite/python_pybuffer.i +++ b/Examples/test-suite/python_pybuffer.i @@ -28,7 +28,7 @@ ++count; return count; } - int func4(const char *buf4) + size_t func4(const char *buf4) { return strlen(buf4); } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9ffc00592..21392cc2e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2224,7 +2224,7 @@ public: n = nn; Parm *parms = Getattr(n, "parms"); - bool varargs = parms ? emit_isvarargs(parms) : 0; + int varargs = parms ? emit_isvarargs(parms) : 0; /* We prefer to explicitly list all parameters of the C function in the generated Python code as this makes the function more convenient to use, From e9b39797cc16842fff35e683623003b536cf96de Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 12 Sep 2018 17:30:04 +1000 Subject: [PATCH 1495/2031] Setting enum values with calls to the C code. --- Lib/r/srun.swg | 2 +- Source/Modules/r.cxx | 200 ++++++++++++++++++++++++++++++------------- 2 files changed, 142 insertions(+), 60 deletions(-) diff --git a/Lib/r/srun.swg b/Lib/r/srun.swg index d07218a77..2e8eda112 100644 --- a/Lib/r/srun.swg +++ b/Lib/r/srun.swg @@ -73,7 +73,7 @@ function(name, .values, where = topenv(parent.frame()), suffix = "Value") { # Mirror the class definitions via the E analogous to .__C__ defName = paste(".__E__", name, sep = "") - assign(defName, .values, envir = where) + delayedAssign(defName, .values, assign.env = where) if(nchar(suffix)) name = paste(name, suffix, sep = "") diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 019d5dd66..099251d0d 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -288,7 +288,8 @@ public: int classDeclaration(Node *n); int enumDeclaration(Node *n); - + String *enumValue(Node *n); + virtual int enumvalueDeclaration(Node *n); int membervariableHandler(Node *n); int typedefHandler(Node *n); @@ -392,6 +393,8 @@ protected: // Strings into which we cumulate the generated code that is to be written //vto the files. + String *enum_values; + String *enum_def_calls; String *sfile; String *f_init; String *s_classes; @@ -456,6 +459,8 @@ R::R() : copyStruct(false), memoryProfile(false), aggressiveGc(false), + enum_values(0), + enum_def_calls(0), sfile(0), f_init(0), s_classes(0), @@ -756,6 +761,7 @@ void R::init() { s_classes = NewString(""); s_init = NewString(""); s_init_routine = NewString(""); + enum_def_calls = NewString(""); } @@ -878,6 +884,7 @@ int R::DumpCode(Node *n) { Printf(scode, "%s\n\n", s_init); Printf(scode, "%s\n\n", s_classes); Printf(scode, "%s\n", sfile); + Printf(scode, "%s\n", enum_def_calls); Delete(scode); String *outfile = Getattr(n,"outfile"); @@ -1198,75 +1205,103 @@ int R::OutputArrayMethod(String *className, List *el, File *out) { tdname is the typedef of the enumeration, i.e. giving its name. *************************************************************/ int R::enumDeclaration(Node *n) { - if (getCurrentClass() && (cplus_mode != PUBLIC)) - return SWIG_NOWRAP; + if (!ImportMode) { + if (getCurrentClass() && (cplus_mode != PUBLIC)) + return SWIG_NOWRAP; - String *name = Getattr(n, "name"); - String *tdname = Getattr(n, "tdname"); + String *symname = Getattr(n, "sym:name"); - /* Using name if tdname is empty. */ + // TODO - deal with anonymous enumerations + // Previous enum code for R didn't wrap them + if (!symname || Getattr(n, "unnamedinstance")) + return SWIG_NOWRAP; - if(Len(tdname) == 0) - tdname = name; + // create mangled name for the enum + // This will have content if the %nspace feature is set on + // the input file + String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call + String * ename; - - if(!tdname || Strcmp(tdname, "") == 0) { + String *name = Getattr(n, "name"); + ename = getRClassName(name); + if (debugMode) { + Printf(stdout, "enumDeclaration: %s, %s, %s, %s\n", name, symname, nspace, ename); + } + Delete(name); + // set up a call to create the R enum structure. The list of + // individual elements will be built in enum_code + enum_values=0; + // Emit each enum item Language::enumDeclaration(n); - return SWIG_OK; + + Printf(enum_def_calls, "defineEnumeration(\"%s\",\n .values=c(%s))\n\n", + ename, enum_values); + Delete(enum_values); + Delete(ename); + //Delete(symname); + } + return SWIG_OK; +} +/************************************************************* +**************************************************************/ +int R::enumvalueDeclaration(Node *n) { + if (getCurrentClass() && (cplus_mode != PUBLIC)) { + Printf(stdout , "evd: Not public\n"); + return SWIG_NOWRAP; } - String *mangled_tdname = SwigType_manglestr(tdname); - String *scode = NewString(""); + Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL); + String *symname = Getattr(n, "sym:name"); + String *value = Getattr(n, "value"); + String *name = Getattr(n, "name"); + Node *parent = parentNode(n); + String *parent_name = Getattr(parent, "name"); + String *newsymname = 0; + String *tmpValue; - Printv(scode, "defineEnumeration('", mangled_tdname, "'", - ",\n", tab8, tab8, tab4, ".values = c(\n", NIL); - - Node *c; - int value = -1; // First number is zero - for (c = firstChild(n); c; c = nextSibling(c)) { - // const char *tag = Char(nodeType(c)); - // if (Strcmp(tag,"cdecl") == 0) { - name = Getattr(c, "name"); - String *val = Getattr(c, "enumvalue"); - if(val && Char(val)) { - int inval; - if (!getNumber(val, &inval)) { - // Conversion failed - use the string value in val. - } else { - val = NULL; - value = inval; - } - } else { - val = NULL; - value++; - } - - if (val != NULL) { - // This won't work in general, but will at least handle cases like (3) - // and 3+7, and when it doesn't work, it'll fail noisly rather than - // quietly using the wrong enum value like we used to. - if (!Strcmp(val, "true")) { - Printf(scode, "%s%s%s'%s' = %s%s\n", tab8, tab8, tab8, name, "TRUE", - nextSibling(c) ? ", " : ""); - } else if (!Strcmp(val, "false")) { - Printf(scode, "%s%s%s'%s' = %s%s\n", tab8, tab8, tab8, name, "FALSE", - nextSibling(c) ? ", " : ""); - } else { - Printf(scode, "%s%s%s'%s' = %s%s\n", tab8, tab8, tab8, name, val, - nextSibling(c) ? ", " : ""); - } - } else { - Printf(scode, "%s%s%s'%s' = %d%s\n", tab8, tab8, tab8, name, value, - nextSibling(c) ? ", " : ""); - } - // } + // Strange hack from parent method + if (value) + tmpValue = NewString(value); + else + tmpValue = NewString(name); + // Note that this is used in enumValue() amongst other places + Setattr(n, "value", tmpValue); + + // Deal with enum values that are not int + int swigtype = SwigType_type(Getattr(n, "type")); + if (swigtype == T_BOOL) { + const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0"; + Setattr(n, "enumvalue", val); + } else if (swigtype == T_CHAR) { + String *val = NewStringf("'%s'", Getattr(n, "enumvalue")); + Setattr(n, "enumvalue", val); + Delete(val); } - Printv(scode, "))", NIL); - Printf(sfile, "%s\n", scode); + if (GetFlag(parent, "scopedenum")) { + newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname); + symname = newsymname; + } - Delete(scode); - Delete(mangled_tdname); + { + // Wrap C/C++ enums with constant integers or use the typesafe enum pattern + SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); + Setattr(n, "type", typemap_lookup_type); + + // Simple integer constants + // Note these are always generated for anonymous enums, no matter what enum_feature is specified + // Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later + + String *value = enumValue(n); + if (enum_values) { + Printf(enum_values, ",\n\"%s\" = %s", name, value); + } else { + enum_values=NewString(""); + Printf(enum_values, "\"%s\" = %s", name, value); + } + + Delete(value); + } return SWIG_OK; } @@ -2853,3 +2888,50 @@ String * R::processType(SwigType *t, Node *n, int *nargs) { } /*************************************************************************************/ + /* ----------------------------------------------------------------------- + * enumValue() + * This method will return a string with an enum value to use in from R when + * setting up an enum variable + * ------------------------------------------------------------------------ */ + +String *R::enumValue(Node *n) { + String *symname = Getattr(n, "sym:name"); + String *value = Getattr(n, "value"); + String *newsymname = 0; + + Node *parent = parentNode(n); + symname = Getattr(n, "sym:name"); + + String *etype = Getattr(parent, "enumtype"); + // we have to directly call the c wrapper function, as the + // R wrapper to the enum is designed to be used after the enum + // structures have been created on the R side. This means + // that we'll need to construct a .Call expression + + // change the type for variableWrapper + Setattr(n, "type", etype); + + if (!getCurrentClass()) { + newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname); + + // Strange hack to change the name + Setattr(n, "name", Getattr(n, "value")); + Setattr(n, "sym:name", newsymname); + variableWrapper(n); + value = Swig_name_get(NSPACE_TODO, newsymname); + } else { + String *enumClassPrefix = getEnumClassPrefix(); + newsymname = Swig_name_member(0, enumClassPrefix, symname); + Setattr(n, "name", Getattr(n, "value")); + Setattr(n, "sym:name", newsymname); + variableWrapper(n); + value = Swig_name_get(NSPACE_TODO, newsymname); + } + value = Swig_name_wrapper(value); + Replace(value, "_wrap", "R_swig", DOH_REPLACE_FIRST); + + String *valuecall=NewString(""); + Printv(valuecall, ".Call('", value, "',FALSE, PACKAGE='", Rpackage, "')", NIL); + Delete(value); + return valuecall; +} From 06de7049382834f663ad963bbcd5bbdb2cc34695 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 19 Sep 2018 07:46:07 +1000 Subject: [PATCH 1496/2031] ENH: R Module: Enumerations with values set by calls to C code, allowing arbitarily complex value expressions. R-side initialization of the enumeration structure employs delayedAssign, which allows the initialization code to be sourced before loading the shared library, which is the usual behaviour for code in an R package. --- Source/Modules/r.cxx | 68 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 099251d0d..da87cbcca 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -256,6 +256,7 @@ static void replaceRClass(String *tm, SwigType *type) { String *tmp = getRClassName(type); String *tmp_base = getRClassName(type, 0); String *tmp_ref = getRClassName(type, 1, 1); + Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); @@ -579,7 +580,6 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { for (i = 0; p; p = nextSibling(p), ++i) { String *arg = Getattr(p, "name"); String *lname; - if (!arg && Cmp(Getattr(p, "type"), "void")) { lname = NewStringf("arg%d", i+1); Setattr(p, "name", lname); @@ -640,6 +640,9 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { } Replaceall(tm, "$1", name); Replaceall(tm, "$result", "r_tmp"); + if (debugMode) { + Printf(stdout, "Calling Replace A: %s\n", Getattr(p,"type")); + } replaceRClass(tm, Getattr(p,"type")); Replaceall(tm,"$owner", "0"); Delete(lstr); @@ -785,6 +788,11 @@ int R::cDeclaration(Node *n) { ***/ int R::top(Node *n) { String *module = Getattr(n, "name"); + + if (debugMode) { + Printf(stdout, " %s\n", module); + } + if(!Rpackage) Rpackage = Copy(module); if(!DllName) @@ -1225,7 +1233,12 @@ int R::enumDeclaration(Node *n) { String *name = Getattr(n, "name"); ename = getRClassName(name); if (debugMode) { - Printf(stdout, "enumDeclaration: %s, %s, %s, %s\n", name, symname, nspace, ename); + Node *N = getCurrentClass(); + String *cl = NewString(""); + if (N) { + cl=getEnumClassPrefix(); + } + Printf(stdout, "enumDeclaration: %s, %s, %s, %s, %s\n", name, symname, nspace, ename, cl); } Delete(name); // set up a call to create the R enum structure. The list of @@ -1286,6 +1299,9 @@ int R::enumvalueDeclaration(Node *n) { { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); + if (debugMode) { + Printf(stdout, "Setting type: %s\n", Copy(typemap_lookup_type)); + } Setattr(n, "type", typemap_lookup_type); // Simple integer constants @@ -1311,19 +1327,27 @@ int R::enumvalueDeclaration(Node *n) { **************************************************************/ int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); - + if (debugMode) { + Printf(stdout, "variableWrapper %s\n", n); + } processing_variable = 1; Language::variableWrapper(n); // Force the emission of the _set and _get function wrappers. processing_variable = 0; SwigType *ty = Getattr(n, "type"); + String *nodeType = nodeType(n); int addCopyParam = addCopyParameter(ty); //XXX processType(ty, n); - if(!SwigType_isconst(ty)) { + if (nodeType && !Strcmp(nodeType, "enumitem")) { + /* special wrapper for enums - don't want the R _set, _get functions*/ + if (debugMode) { + Printf(stdout, "variableWrapper enum branch\n"); + } + } else if(!SwigType_isconst(ty)) { Wrapper *f = NewWrapper(); Printf(f->def, "%s = \nfunction(value%s)\n{\n", name, addCopyParam ? ", .copy = FALSE" : ""); @@ -1341,6 +1365,8 @@ int R::variableWrapper(Node *n) { return SWIG_OK; } +/************************************************************* +**************************************************************/ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { @@ -1787,6 +1813,9 @@ int R::functionWrapper(Node *n) { SwigType *resolved = SwigType_typedef_resolve_all(resultType); if (expandTypedef(resolved)) { + if (debugMode) { + Printf(stdout, "Setting type: %s\n", resolved); + } Setattr(p, "type", Copy(resolved)); } } @@ -1799,6 +1828,9 @@ int R::functionWrapper(Node *n) { SwigType_istypedef(type)) { SwigType *resolved = SwigType_typedef_resolve_all(type); + if (debugMode) + Printf(stdout, " resolved %s\n", + Copy(unresolved_return_type)); if (expandTypedef(resolved)) { type = Copy(resolved); Setattr(n, "type", type); @@ -2102,14 +2134,12 @@ int R::functionWrapper(Node *n) { /* Deal with the explicit return value. */ if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) { SwigType *retType = Getattr(n, "type"); - //Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no"); - /* if(SwigType_isarray(retType)) { - defineArrayAccessors(retType); - } */ - - + Replaceall(tm,"$1", Swig_cresult_name()); Replaceall(tm,"$result", "r_ans"); + if (debugMode){ + Printf(stdout, "Calling replace D: %s, %s, %s\n", retType, n, tm); + } replaceRClass(tm, retType); if (GetFlag(n,"feature:new")) { @@ -2196,6 +2226,9 @@ int R::functionWrapper(Node *n) { Delete(smartname); } } + if (debugMode) { + Printf(stdout, "Calling replace B: %s, %s, %s\n", Getattr(n, "type"), Getattr(n, "sym:name"), getNSpace()); + } replaceRClass(tm, Getattr(n, "type")); Chop(tm); } @@ -2231,6 +2264,9 @@ int R::functionWrapper(Node *n) { tm = Swig_typemap_lookup("rtype", n, "", 0); if(tm) { SwigType *retType = Getattr(n, "type"); + if (debugMode) { + Printf(stdout, "Calling replace C: %s\n", Copy(retType)); + } replaceRClass(tm, retType); } @@ -2469,8 +2505,8 @@ int R::classDeclaration(Node *n) { } if (Getattr(n, "has_destructor")) { Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", - getRClassName(Getattr(n, "name")), - getRClassName(Getattr(n, "name"))); + getRClassName(name), + getRClassName(name)); } if(!opaque && !Strcmp(kind, "struct") && copyStruct) { @@ -2842,7 +2878,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) { SwigType *tmp = Getattr(n, "tdname"); if (debugMode) - Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp); + Printf(stdout, "processType %s (tdname = %s)(SwigType = %s)\n", Getattr(n, "name"), tmp, Copy(t)); SwigType *td = t; if (expandTypedef(t) && @@ -2902,6 +2938,7 @@ String *R::enumValue(Node *n) { Node *parent = parentNode(n); symname = Getattr(n, "sym:name"); + // parent enumtype has namespace mangled in String *etype = Getattr(parent, "enumtype"); // we have to directly call the c wrapper function, as the // R wrapper to the enum is designed to be used after the enum @@ -2909,11 +2946,14 @@ String *R::enumValue(Node *n) { // that we'll need to construct a .Call expression // change the type for variableWrapper + if (debugMode) { + Printf(stdout, " type set: %s\n", etype); + } + Setattr(n, "type", etype); if (!getCurrentClass()) { newsymname = Swig_name_member(0, Getattr(parent, "sym:name"), symname); - // Strange hack to change the name Setattr(n, "name", Getattr(n, "value")); Setattr(n, "sym:name", newsymname); From b5af07fd95f35f411c3f57b54ce001657cda83a8 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Mon, 4 Feb 2019 15:58:03 +1100 Subject: [PATCH 1497/2031] Code style changes post review --- Source/Modules/r.cxx | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index da87cbcca..3260dfaf8 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1228,38 +1228,38 @@ int R::enumDeclaration(Node *n) { // This will have content if the %nspace feature is set on // the input file String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call - String * ename; + String *ename; String *name = Getattr(n, "name"); ename = getRClassName(name); if (debugMode) { - Node *N = getCurrentClass(); + Node *current_class = getCurrentClass(); String *cl = NewString(""); - if (N) { - cl=getEnumClassPrefix(); + if (current_class) { + cl = getEnumClassPrefix(); } Printf(stdout, "enumDeclaration: %s, %s, %s, %s, %s\n", name, symname, nspace, ename, cl); } Delete(name); // set up a call to create the R enum structure. The list of // individual elements will be built in enum_code - enum_values=0; + enum_values = 0; // Emit each enum item Language::enumDeclaration(n); - Printf(enum_def_calls, "defineEnumeration(\"%s\",\n .values=c(%s))\n\n", - ename, enum_values); + Printf(enum_def_calls, "defineEnumeration(\"%s\",\n .values=c(%s))\n\n", ename, enum_values); Delete(enum_values); Delete(ename); //Delete(symname); } return SWIG_OK; } + /************************************************************* **************************************************************/ int R::enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) { - Printf(stdout , "evd: Not public\n"); + Printf(stdout, "evd: Not public\n"); return SWIG_NOWRAP; } @@ -1267,7 +1267,7 @@ int R::enumvalueDeclaration(Node *n) { String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); - Node *parent = parentNode(n); + Node *parent = parentNode(n); String *parent_name = Getattr(parent, "name"); String *newsymname = 0; String *tmpValue; @@ -1312,7 +1312,7 @@ int R::enumvalueDeclaration(Node *n) { if (enum_values) { Printf(enum_values, ",\n\"%s\" = %s", name, value); } else { - enum_values=NewString(""); + enum_values = NewString(""); Printf(enum_values, "\"%s\" = %s", name, value); } @@ -1324,6 +1324,9 @@ int R::enumvalueDeclaration(Node *n) { /************************************************************* +Create accessor functions for variables. +Does not create equivalent wrappers for enumerations, +which are handled differently **************************************************************/ int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); @@ -1366,6 +1369,10 @@ int R::variableWrapper(Node *n) { } /************************************************************* +Creates accessor functions for class members. + +ToDo - this version depends on naming conventions and needs +to be replaced. **************************************************************/ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, @@ -1829,20 +1836,17 @@ int R::functionWrapper(Node *n) { SwigType *resolved = SwigType_typedef_resolve_all(type); if (debugMode) - Printf(stdout, " resolved %s\n", - Copy(unresolved_return_type)); + Printf(stdout, " resolved %s\n", Copy(unresolved_return_type)); if (expandTypedef(resolved)) { type = Copy(resolved); Setattr(n, "type", type); } } if (debugMode) - Printf(stdout, " unresolved_return_type %s\n", - unresolved_return_type); + Printf(stdout, " unresolved_return_type %s\n", unresolved_return_type); if(processing_member_access_function) { if (debugMode) - Printf(stdout, " '%s' '%s' '%s' '%s'\n", - fname, iname, member_name, class_name); + Printf(stdout, " '%s' '%s' '%s' '%s'\n", fname, iname, member_name, class_name); if(opaqueClassDeclaration) return SWIG_OK; @@ -2504,9 +2508,7 @@ int R::classDeclaration(Node *n) { class_member_set_functions = NULL; } if (Getattr(n, "has_destructor")) { - Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", - getRClassName(name), - getRClassName(name)); + Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", getRClassName(name), getRClassName(name)); } if(!opaque && !Strcmp(kind, "struct") && copyStruct) { From 62594c611aa0b5ebddc7224ded61e4cb1294647f Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 6 Feb 2019 15:26:08 +1100 Subject: [PATCH 1498/2031] ENH: Run test for enum_thorough in R This test exercises many complex cases for enumerations in R. References to enums currently fail and will be addressed in the next patch. Anonymous enums are not supported. There are some strange corner cases that could be seen as doing strange things in R. enums are allowed to have the same underlying integer representation on the C side. This means that the R structure ends up with two names for the same integer, which in turn means that the reverse lookup isn't unique. I don't think this matters. I'll add some of these cases to the documentation. --- Examples/test-suite/r/Makefile.in | 1 - Examples/test-suite/r/enum_thorough_runme.R | 453 ++++++++++++++++++++ 2 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/r/enum_thorough_runme.R diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 13fd3654b..1616ffd3d 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -27,7 +27,6 @@ CPP_TEST_CASES += \ # arithmetic expressions FAILING_CPP_TESTS = \ - enum_thorough \ preproc_constants FAILING_C_TESTS = \ diff --git a/Examples/test-suite/r/enum_thorough_runme.R b/Examples/test-suite/r/enum_thorough_runme.R new file mode 100644 index 000000000..608abc71a --- /dev/null +++ b/Examples/test-suite/r/enum_thorough_runme.R @@ -0,0 +1,453 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("enum_thorough", .Platform$dynlib.ext, sep="")) +source("enum_thorough.R") +cacheMetaData(1) + +## Anonymous enums are not wrapped by the R module +## + +# Colours - string interface, various function signatures +unittest('red', colourTest1('red')) +unittest('blue', colourTest1('blue')) +unittest('green', colourTest1('green')) + + +unittest('red', colourTest2('red')) +unittest('blue', colourTest2('blue')) +unittest('green', colourTest2('green')) + +unittest('red', colourTest3('red')) +unittest('blue', colourTest3('blue')) +unittest('green', colourTest3('green')) + +unittest('red', colourTest4('red')) +unittest('blue', colourTest4('blue')) +unittest('green', colourTest4('green')) + +## Colours - underlying integers +unittest(-1, enumToInteger('red', '_colour')) +unittest(0, enumToInteger('blue', '_colour')) +unittest(10, enumToInteger('green', '_colour')) + +######## +## enum variable, wrapped as a function +## Is initialization to 0 a "standard" +myColour() + +## Test setting and retrieving +myColour('green') +unittest('green', myColour()) + +######## +## SpeedClass + +s <- SpeedClass() +v <- "medium" +unittest(v, s$speedTest1(v)) +unittest(v, s$speedTest2(v)) +unittest(v, s$speedTest3(v)) +unittest(v, s$speedTest4(v)) +unittest(v, s$speedTest5(v)) +unittest(v, s$speedTest6(v)) +# Not handling enum references - probably needs a typemap +# unittest(v, s$speedTest7(v)) +# unittest(v, s$speedTest8(v)) + +## speedTest methods not in the class + +unittest(v, speedTest1(v)) +unittest(v, speedTest2(v)) +unittest(v, speedTest3(v)) +unittest(v, speedTest4(v)) +# enum reference +# unittest(v, speedTest5(v)) + +## member access +s <- SpeedClass() +unittest("slow", s$mySpeedtd1) +# check integer value +unittest(10, enumToInteger(s$mySpeedtd1, "_SpeedClass__speed")) +# set and check +s$mySpeedtd1 <- "lightning" +unittest("lightning", s$mySpeedtd1) +unittest(31, enumToInteger(s$mySpeedtd1, "_SpeedClass__speed")) + +## Named anon - not wrapped nicely, but can be retrieved: + + +unittest("NamedAnon2", namedanon_NamedAnon2_get()) +unittest(0, enumToInteger(namedanon_NamedAnon1_get(), "_namedanon")) +unittest(1, enumToInteger(namedanon_NamedAnon2_get(), "_namedanon")) + +## Twonames +v <- "TwoNames1" +unittest(v, twonamesTest1(v)) +unittest(v, twonamesTest2(v)) +unittest(v, twonamesTest3(v)) +unittest(33, enumToInteger("TwoNames3", "_twonamestag")) + +tt <- TwoNamesStruct() +v <- "TwoNamesStruct1" +unittest(v, tt$twonamesTest1(v)) +unittest(v, tt$twonamesTest2(v)) +unittest(v, tt$twonamesTest3(v)) +## Try the wrong name +unittest(TRUE, is.na(tt$twonamesTest3("TwoNames1"))) + +## Namedanonspace +## can get the values + +v <- namedanonspace_NamedAnonSpace2_get() +unittest(v, namedanonspaceTest1(v)) +unittest(v, namedanonspaceTest2(v)) +unittest(v, namedanonspaceTest3(v)) +unittest(v, namedanonspaceTest4(v)) + +## scientists + +tt <- TemplateClassInt() + +g <- "galileo" +unittest(g, tt$scientistsTest1(g)) +unittest(g, tt$scientistsTest2(g)) +unittest(g, tt$scientistsTest3(g)) +unittest(g, tt$scientistsTest4(g)) +unittest(g, tt$scientistsTest5(g)) +unittest(g, tt$scientistsTest6(g)) +unittest(g, tt$scientistsTest7(g)) +unittest(g, tt$scientistsTest8(g)) +unittest(g, tt$scientistsTest9(g)) + +## This one is commented out in csharp too +## unittest(g, tt$scientistsTestA(g)) +unittest(g, tt$scientistsTestB(g)) +## This one is commented out in csharp too +## unittest(g, tt$scientistsTestC(g)) +unittest(g, tt$scientistsTestD(g)) +unittest(g, tt$scientistsTestE(g)) +unittest(g, tt$scientistsTestF(g)) +unittest(g, tt$scientistsTestG(g)) +unittest(g, tt$scientistsTestH(g)) +unittest(g, tt$scientistsTestI(g)) +# enum reference +#unittest(g, tt$scientistsTestJ(g)) + + +unittest(g, scientistsTest1(g)) +unittest(g, scientistsTest2(g)) +unittest(g, scientistsTest3(g)) +unittest(g, scientistsTest4(g)) +unittest(g, scientistsTest5(g)) +unittest(g, scientistsTest6(g)) +unittest(g, scientistsTest7(g)) +## enum reference +## unittest(g, scientistsTest8(g)) + +tt <- TClassInt() +b <- "bell" +unittest(b, tt$scientistsNameTest1(b)) +unittest(b, tt$scientistsNameTest2(b)) +unittest(b, tt$scientistsNameTest3(b)) +unittest(b, tt$scientistsNameTest4(b)) +unittest(b, tt$scientistsNameTest5(b)) +unittest(b, tt$scientistsNameTest6(b)) +unittest(b, tt$scientistsNameTest7(b)) +unittest(b, tt$scientistsNameTest8(b)) +unittest(b, tt$scientistsNameTest9(b)) + +## This one is commented out in csharp too +## unittest(b, tt$scientistsNameTestA(b)) +unittest(b, tt$scientistsNameTestB(b)) +## This one is commented out in csharp too +## unittest(b, tt$scientistsNameTestC(b)) +unittest(b, tt$scientistsNameTestD(b)) +unittest(b, tt$scientistsNameTestE(b)) +unittest(b, tt$scientistsNameTestF(b)) +unittest(b, tt$scientistsNameTestG(b)) +unittest(b, tt$scientistsNameTestH(b)) +unittest(b, tt$scientistsNameTestI(b)) + + +unittest(b, tt$scientistsNameSpaceTest1(b)) +unittest(b, tt$scientistsNameSpaceTest2(b)) +unittest(b, tt$scientistsNameSpaceTest3(b)) +unittest(b, tt$scientistsNameSpaceTest4(b)) +unittest(b, tt$scientistsNameSpaceTest5(b)) +unittest(b, tt$scientistsNameSpaceTest6(b)) +unittest(b, tt$scientistsNameSpaceTest7(b)) + +unittest(g, tt$scientistsOtherTest1(g)) +unittest(g, tt$scientistsOtherTest2(g)) +unittest(g, tt$scientistsOtherTest3(g)) +unittest(g, tt$scientistsOtherTest4(g)) +unittest(g, tt$scientistsOtherTest5(g)) +unittest(g, tt$scientistsOtherTest6(g)) +unittest(g, tt$scientistsOtherTest7(g)) + +## Global +unittest(b, scientistsNameTest1(b)) +unittest(b, scientistsNameTest2(b)) +unittest(b, scientistsNameTest3(b)) +unittest(b, scientistsNameTest4(b)) +unittest(b, scientistsNameTest5(b)) +unittest(b, scientistsNameTest6(b)) +unittest(b, scientistsNameTest7(b)) + +unittest(b, scientistsNameSpaceTest1(b)) +unittest(b, scientistsNameSpaceTest2(b)) +unittest(b, scientistsNameSpaceTest3(b)) +unittest(b, scientistsNameSpaceTest4(b)) +unittest(b, scientistsNameSpaceTest5(b)) +unittest(b, scientistsNameSpaceTest6(b)) +unittest(b, scientistsNameSpaceTest7(b)) + +unittest(b, scientistsNameSpaceTest8(b)) +unittest(b, scientistsNameSpaceTest9(b)) +unittest(b, scientistsNameSpaceTestA(b)) +unittest(b, scientistsNameSpaceTestB(b)) +unittest(b, scientistsNameSpaceTestC(b)) +unittest(b, scientistsNameSpaceTestD(b)) +unittest(b, scientistsNameSpaceTestE(b)) +unittest(b, scientistsNameSpaceTestF(b)) +unittest(b, scientistsNameSpaceTestG(b)) +unittest(b, scientistsNameSpaceTestH(b)) +unittest(b, scientistsNameSpaceTestI(b)) +unittest(b, scientistsNameSpaceTestJ(b)) +unittest(b, scientistsNameSpaceTestK(b)) +unittest(b, scientistsNameSpaceTestL(b)) + +## rename test +v <- "eek" +unittest(v, renameTest1(v)) +unittest(v, renameTest2(v)) + +## NewName +N <- NewNameStruct() +## Only half works: +unittest("kerboom", NewNameStruct_bang_get()) +## Can't put in "bang" in the call +## confirm with: +## get(".__E___OldNameStruct__enumeration") + +## TreeClass + +T <- TreesClass() +p <- "pine" + +unittest(p, T$treesTest1(p)) +unittest(p, T$treesTest2(p)) +unittest(p, T$treesTest3(p)) +unittest(p, T$treesTest4(p)) +unittest(p, T$treesTest5(p)) +unittest(p, T$treesTest6(p)) +unittest(p, T$treesTest7(p)) +unittest(p, T$treesTest8(p)) +unittest(p, T$treesTest9(p)) +unittest(p, T$treesTestA(p)) +unittest(p, T$treesTestB(p)) +unittest(p, T$treesTestC(p)) +unittest(p, T$treesTestD(p)) +unittest(p, T$treesTestE(p)) +unittest(p, T$treesTestF(p)) +unittest(p, T$treesTestG(p)) +unittest(p, T$treesTestH(p)) +unittest(p, T$treesTestI(p)) +unittest(p, T$treesTestJ(p)) +unittest(p, T$treesTestK(p)) +unittest(p, T$treesTestL(p)) +unittest(p, T$treesTestM(p)) +unittest(p, T$treesTestN(p)) +unittest(p, T$treesTestO(p)) + +unittest(p, treesTest1(p)) +unittest(p, treesTest2(p)) +unittest(p, treesTest3(p)) +unittest(p, treesTest4(p)) +unittest(p, treesTest5(p)) +unittest(p, treesTest6(p)) +unittest(p, treesTest7(p)) +unittest(p, treesTest8(p)) +unittest(p, treesTest9(p)) +unittest(p, treesTestA(p)) +unittest(p, treesTestB(p)) +unittest(p, treesTestC(p)) +unittest(p, treesTestD(p)) +unittest(p, treesTestE(p)) +unittest(p, treesTestF(p)) +unittest(p, treesTestG(p)) +unittest(p, treesTestH(p)) +unittest(p, treesTestI(p)) +unittest(p, treesTestJ(p)) +unittest(p, treesTestK(p)) +unittest(p, treesTestL(p)) +unittest(p, treesTestM(p)) +unittest(p, treesTestO(p)) +unittest(p, treesTestP(p)) +unittest(p, treesTestQ(p)) +unittest(p, treesTestR(p)) + +## Hair +h <- HairStruct() +g <- "ginger" +unittest(g, h$hairTest1(g)) +unittest(g, h$hairTest2(g)) +unittest(g, h$hairTest3(g)) +unittest(g, h$hairTest4(g)) +unittest(g, h$hairTest5(g)) +unittest(g, h$hairTest6(g)) +unittest(g, h$hairTest7(g)) +unittest(g, h$hairTest8(g)) +unittest(g, h$hairTest9(g)) +unittest(g, h$hairTestA(g)) +unittest(g, h$hairTestB(g)) + +r <- "red" +unittest(r, h$colourTest1(r)) +unittest(r, h$colourTest2(r)) + +nmA <- "NamedAnon1" +unittest(nmA, h$namedanonTest1(nmA)) +unittest("NamedAnonSpace2", h$namedanonspaceTest1("NamedAnonSpace2")) + +f <- "fir" + +unittest(f, h$treesGlobalTest1(f)) +unittest(f, h$treesGlobalTest2(f)) +unittest(f, h$treesGlobalTest3(f)) +unittest(f, h$treesGlobalTest4(f)) + +b <- "blonde" +unittest(b, hairTest1(b)) +unittest(b, hairTest2(b)) +unittest(b, hairTest3(b)) +unittest(b, hairTest4(b)) +unittest(b, hairTest5(b)) +unittest(b, hairTest6(b)) +unittest(b, hairTest7(b)) +unittest(b, hairTest8(b)) +unittest(b, hairTest9(b)) +unittest(b, hairTestA(b)) +unittest(b, hairTestB(b)) +## enum reference +##unittest(b, hairTestC(b)) +unittest(b, hairTestA1(b)) +unittest(b, hairTestA2(b)) +unittest(b, hairTestA3(b)) +unittest(b, hairTestA4(b)) +unittest(b, hairTestA5(b)) +unittest(b, hairTestA6(b)) +unittest(b, hairTestA7(b)) +unittest(b, hairTestA8(b)) +unittest(b, hairTestA9(b)) +unittest(b, hairTestAA(b)) +unittest(b, hairTestAB(b)) +## enum reference +## unittest(b, hairTestAC(b)) + +unittest(b, hairTestB1(b)) +unittest(b, hairTestB2(b)) +unittest(b, hairTestB3(b)) +unittest(b, hairTestB4(b)) +unittest(b, hairTestB5(b)) +unittest(b, hairTestB6(b)) +unittest(b, hairTestB7(b)) +unittest(b, hairTestB8(b)) +unittest(b, hairTestB9(b)) +unittest(b, hairTestBA(b)) +unittest(b, hairTestBB(b)) +## enum reference +## unittest(b, hairTestBC(b)) + +f <- FirStruct() +b <- "blonde" + +unittest(b, f$hairTestFir1(b)) +unittest(b, f$hairTestFir2(b)) +unittest(b, f$hairTestFir3(b)) +unittest(b, f$hairTestFir4(b)) +unittest(b, f$hairTestFir5(b)) +unittest(b, f$hairTestFir6(b)) +unittest(b, f$hairTestFir7(b)) +unittest(b, f$hairTestFir8(b)) +unittest(b, f$hairTestFir9(b)) +unittest(b, f$hairTestFirA(b)) + +## Unnamed enum instance doesn't work +## Wrapper set/get exists, but there's +## no mapping between strings and integers +GlobalInstance(1) +unittest(1, GlobalInstance()) + +ii <- Instances() +ii$MemberInstance <- 1 +unittest(1, ii$MemberInstance) + +ii <- IgnoreTest() + +## Testing integer values +unittest(0, enumToInteger(IgnoreTest_ignoreA_zero_get(), "_IgnoreTest__IgnoreA")) +unittest(3, enumToInteger(IgnoreTest_ignoreA_three_get(), "_IgnoreTest__IgnoreA")) +unittest(10, enumToInteger(IgnoreTest_ignoreA_ten_get(), "_IgnoreTest__IgnoreA")) + +unittest(11, enumToInteger(IgnoreTest_ignoreA_eleven_get(), "_IgnoreTest__IgnoreA")) +unittest(14, enumToInteger(IgnoreTest_ignoreA_fourteen_get(), "_IgnoreTest__IgnoreA")) +unittest(20, enumToInteger(IgnoreTest_ignoreA_twenty_get(), "_IgnoreTest__IgnoreA")) +unittest(30, enumToInteger(IgnoreTest_ignoreA_thirty_get(), "_IgnoreTest__IgnoreA")) +unittest(32, enumToInteger(IgnoreTest_ignoreA_thirty_two_get(), "_IgnoreTest__IgnoreA")) +unittest(33, enumToInteger(IgnoreTest_ignoreA_thirty_three_get(), "_IgnoreTest__IgnoreA")) + +unittest(11, enumToInteger(IgnoreTest_ignoreB_eleven_get(), "_IgnoreTest__IgnoreB")) +unittest(12, enumToInteger(IgnoreTest_ignoreB_twelve_get(), "_IgnoreTest__IgnoreB")) +unittest(31, enumToInteger(IgnoreTest_ignoreB_thirty_one_get(), "_IgnoreTest__IgnoreB")) +unittest(32, enumToInteger(IgnoreTest_ignoreB_thirty_two_get(), "_IgnoreTest__IgnoreB")) +unittest(41, enumToInteger(IgnoreTest_ignoreB_forty_one_get(), "_IgnoreTest__IgnoreB")) +unittest(42, enumToInteger(IgnoreTest_ignoreB_forty_two_get(), "_IgnoreTest__IgnoreB")) + +unittest(10, enumToInteger(IgnoreTest_ignoreC_ten_get(), "_IgnoreTest__IgnoreC")) +unittest(12, enumToInteger(IgnoreTest_ignoreC_twelve_get(), "_IgnoreTest__IgnoreC")) +unittest(30, enumToInteger(IgnoreTest_ignoreC_thirty_get(), "_IgnoreTest__IgnoreC")) +unittest(32, enumToInteger(IgnoreTest_ignoreC_thirty_two_get(), "_IgnoreTest__IgnoreC")) +unittest(40, enumToInteger(IgnoreTest_ignoreC_forty_get(), "_IgnoreTest__IgnoreC")) +unittest(42, enumToInteger(IgnoreTest_ignoreC_forty_two_get(), "_IgnoreTest__IgnoreC")) + +unittest(21, enumToInteger(IgnoreTest_ignoreD_twenty_one_get(), "_IgnoreTest__IgnoreD")) +unittest(22, enumToInteger(IgnoreTest_ignoreD_twenty_two_get(), "_IgnoreTest__IgnoreD")) + +unittest(0, enumToInteger(IgnoreTest_ignoreE_zero_get(), "_IgnoreTest__IgnoreE")) +unittest(21, enumToInteger(IgnoreTest_ignoreE_twenty_one_get(), "_IgnoreTest__IgnoreE")) +unittest(22, enumToInteger(IgnoreTest_ignoreE_twenty_two_get(), "_IgnoreTest__IgnoreE")) + +## confirm that an ignore directive is followed: +unittest(TRUE, is.na(ignoreCTest("ignoreC_eleven"))) + + +## repeat test +unittest(1, enumToInteger(repeatTest("one"), "_RepeatSpace__repeat")) +unittest(1, enumToInteger(repeatTest("initial"), "_RepeatSpace__repeat")) +unittest(2, enumToInteger(repeatTest("two"), "_RepeatSpace__repeat")) +unittest(3, enumToInteger(repeatTest("three"), "_RepeatSpace__repeat")) +unittest(3, enumToInteger(repeatTest("llast"), "_RepeatSpace__repeat")) +unittest(3, enumToInteger(repeatTest("end"), "_RepeatSpace__repeat")) + +## Macro test - nothing in csharp +## Note - this enum is set up with both entries the same +## This means that mapping back from the integer value to the +## string value isn't unique, so asking for "ABCD2" will return +## a string of "ABCD" +unittest("ABCD", enumWithMacroTest("ABCD")) + +## Different types +unittest(10, enumToInteger(differentTypesTest("typeint"), "_DifferentSpace__DifferentTypes")) +unittest(0, enumToInteger(differentTypesTest("typeboolfalse"), "_DifferentSpace__DifferentTypes")) +unittest(1, enumToInteger(differentTypesTest("typebooltrue"), "_DifferentSpace__DifferentTypes")) +unittest(2, enumToInteger(differentTypesTest("typebooltwo"), "_DifferentSpace__DifferentTypes")) +unittest(utf8ToInt('C'), enumToInteger(differentTypesTest("typechar"), "_DifferentSpace__DifferentTypes")) +unittest(utf8ToInt('D'), enumToInteger(differentTypesTest("typedefaultint"), "_DifferentSpace__DifferentTypes")) +unittest(utf8ToInt('A') + 1, enumToInteger(differentTypesTest("typecharcompound"), "_DifferentSpace__DifferentTypes")) + + +## Global different types +## Test uses an anonymous type so the string mapping +## framework doesn't exist. From 80cd2f5cd7de65706dc563a1720d5687b9603081 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Tue, 19 Feb 2019 10:09:06 +1100 Subject: [PATCH 1499/2031] Reformat comments in R module --- Source/Modules/r.cxx | 321 +++++++++++++++++++++++-------------------- 1 file changed, 170 insertions(+), 151 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 3260dfaf8..5ae138f93 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -65,11 +65,11 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { */ } -/********************* - Tries to get the name of the R class corresponding to the given type - e.g. struct A * is ARef, struct A** is ARefRef. - Now handles arrays, i.e. struct A[2] -****************/ +/* -------------------------------------------------------------- + * Tries to get the name of the R class corresponding to the given type + * e.g. struct A * is ARef, struct A** is ARefRef. + * Now handles arrays, i.e. struct A[2] + * --------------------------------------------------------------*/ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); @@ -131,11 +131,12 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { */ } -/********************* - Tries to get the name of the R class corresponding to the given type - e.g. struct A * is ARef, struct A** is ARefRef. - Now handles arrays, i.e. struct A[2] -****************/ +/* -------------------------------------------------------------- + * Tries to get the name of the R class corresponding to the given type + * e.g. struct A * is ARef, struct A** is ARefRef. + * Now handles arrays, i.e. struct A[2] + * --------------------------------------------------------------*/ + static String * getRClassNameCopyStruct(String *retType, int addRef) { String *tmp = NewString(""); @@ -188,12 +189,13 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) { } -/********************************* - Write the elements of a list to the File*, one element per line. - If quote is true, surround the element with "element". - This takes care of inserting a tab in front of each line and also - a comma after each element, except the last one. -**********************************/ +/* ------------------------------------------------------------- + * Write the elements of a list to the File*, one element per line. + * If quote is true, surround the element with "element". + * This takes care of inserting a tab in front of each line and also + * a comma after each element, except the last one. + * --------------------------------------------------------------*/ + static void writeListByLine(List *l, File *out, bool quote = 0) { int i, n = Len(l); @@ -222,9 +224,10 @@ R Options (available with -r)\n\ -/************ - Display the help for this module on the screen/console. -*************/ +/* ------------------------------------------------------------- + * Display the help for this module on the screen/console. + * --------------------------------------------------------------*/ + static void showUsage() { fputs(usage, stdout); } @@ -238,10 +241,11 @@ static bool expandTypedef(SwigType *t) { } -/***** - Determine whether we should add a .copy argument to the S function - that wraps/interfaces to the routine that returns the given type. -*****/ +/* ------------------------------------------------------------- + * Determine whether we should add a .copy argument to the S function + * that wraps/interfaces to the routine that returns the given type. + * --------------------------------------------------------------*/ + static int addCopyParameter(SwigType *type) { int ok = 0; ok = Strncmp(type, "struct ", 7) == 0 || Strncmp(type, "p.struct ", 9) == 0; @@ -541,9 +545,10 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) { } } -/* - Returns the name of the new routine. -*/ +/* ---------------------------------------- + * Returns the name of the new routine. + * ------------------------------------------ */ + String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { String *funName = SwigType_manglestr(t); @@ -780,12 +785,12 @@ int R::cDeclaration(Node *n) { #endif -/** - Method from Language that is called to start the entire - processing off, i.e. the generation of the code. - It is called after the input has been read and parsed. - Here we open the output streams and generate the code. -***/ +/* ------------------------------------------------------------- + * Method from Language that is called to start the entire + * processing off, i.e. the generation of the code. + * It is called after the input has been read and parsed. + * Here we open the output streams and generate the code. + * ------------------------------------------------------------- */ int R::top(Node *n) { String *module = Getattr(n, "name"); @@ -867,9 +872,9 @@ int R::top(Node *n) { } -/***************************************************** - Write the generated code to the .S and the .c files. -****************************************************/ +/* ------------------------------------------------------------- + * Write the generated code to the .S and the .c files. + * ------------------------------------------------------------- */ int R::DumpCode(Node *n) { String *output_filename = NewString(""); @@ -937,22 +942,23 @@ int R::DumpCode(Node *n) { -/* - We may need to do more.... so this is left as a - stub for the moment. -*/ +/* ------------------------------------------------------------- + * We may need to do more.... so this is left as a + * stub for the moment. + * -------------------------------------------------------------*/ int R::OutputClassAccessInfo(Hash *tb, File *out) { int n = OutputClassMemberTable(tb, out); OutputClassMethodsTable(out); return n; } -/************************************************************************ - Currently this just writes the information collected about the - different methods of the C++ classes that have been processed - to the console. - This will be used later to define S4 generics and methods. -**************************************************************************/ +/* ------------------------------------------------------------- + * Currently this just writes the information collected about the + * different methods of the C++ classes that have been processed + * to the console. + * This will be used later to define S4 generics and methods. + * --------------------------------------------------------------*/ + int R::OutputClassMethodsTable(File *) { Hash *tb = ClassMethodsTable; @@ -981,20 +987,21 @@ int R::OutputClassMethodsTable(File *) { } -/* - Iterate over the _set and <>_get - elements and generate the $ and $<- functions - that provide constrained access to the member - fields in these elements. +/* -------------------------------------------------------------- + * Iterate over the _set and <>_get + * elements and generate the $ and $<- functions + * that provide constrained access to the member + * fields in these elements. - tb - a hash table that is built up in functionWrapper - as we process each membervalueHandler. - The entries are indexed by _set and - _get. Each entry is a List *. + * tb - a hash table that is built up in functionWrapper + * as we process each membervalueHandler. + * The entries are indexed by _set and + * _get. Each entry is a List *. + + * out - the stram where the code is to be written. This is the S + * code stream as we generate only S code here. + * --------------------------------------------------------------*/ - out - the stram where the code is to be written. This is the S - code stream as we generate only S code here.. -*/ int R::OutputClassMemberTable(Hash *tb, File *out) { List *keys = Keys(tb), *el; @@ -1034,17 +1041,18 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { return n; } -/******************************************************************* - Write the methods for $ or $<- for accessing a member field in an - struct or union (or class). - className - the name of the struct or union (e.g. Bar for struct Bar) - isSet - a logical value indicating whether the method is for - modifying ($<-) or accessing ($) the member field. - el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. - The other pairs are member name and the name of the R function to access it. - out - the stream where we write the code. -********************************************************************/ +/* -------------------------------------------------------------- + * Write the methods for $ or $<- for accessing a member field in an + * struct or union (or class). + * className - the name of the struct or union (e.g. Bar for struct Bar) + * isSet - a logical value indicating whether the method is for + * modifying ($<-) or accessing ($) the member field. + * el - a list of length 2 * # accessible member elements + 1. + * The first element is the name of the class. + * The other pairs are member name and the name of the R function to access it. + * out - the stream where we write the code. + * --------------------------------------------------------------*/ + int R::OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out) { int numMems = Len(el), j; @@ -1168,15 +1176,16 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, return SWIG_OK; } -/******************************************************************* - Write the methods for [ or [<- for accessing a member field in an - struct or union (or class). - className - the name of the struct or union (e.g. Bar for struct Bar) - el - a list of length 2 * # accessible member elements + 1. - The first element is the name of the class. - The other pairs are member name and the name of the R function to access it. - out - the stream where we write the code. -********************************************************************/ +/* ------------------------------------------------------------- + * Write the methods for [ or [<- for accessing a member field in an + * struct or union (or class). + * className - the name of the struct or union (e.g. Bar for struct Bar) + * el - a list of length 2 * # accessible member elements + 1. + * The first element is the name of the class. + * The other pairs are member name and the name of the R function to access it. + * out - the stream where we write the code. + * --------------------------------------------------------------*/ + int R::OutputArrayMethod(String *className, List *el, File *out) { int numMems = Len(el), j; @@ -1207,11 +1216,12 @@ int R::OutputArrayMethod(String *className, List *el, File *out) { } -/************************************************************ - Called when a enumeration is to be processed. - We want to call the R function defineEnumeration(). - tdname is the typedef of the enumeration, i.e. giving its name. -*************************************************************/ +/* ------------------------------------------------------------- + * Called when a enumeration is to be processed. + * We want to call the R function defineEnumeration(). + * tdname is the typedef of the enumeration, i.e. giving its name. + * --------------------------------------------------------------*/ + int R::enumDeclaration(Node *n) { if (!ImportMode) { if (getCurrentClass() && (cplus_mode != PUBLIC)) @@ -1255,8 +1265,9 @@ int R::enumDeclaration(Node *n) { return SWIG_OK; } -/************************************************************* -**************************************************************/ +/* ------------------------------------------------------------- +* --------------------------------------------------------------*/ + int R::enumvalueDeclaration(Node *n) { if (getCurrentClass() && (cplus_mode != PUBLIC)) { Printf(stdout, "evd: Not public\n"); @@ -1323,11 +1334,12 @@ int R::enumvalueDeclaration(Node *n) { } -/************************************************************* -Create accessor functions for variables. -Does not create equivalent wrappers for enumerations, -which are handled differently -**************************************************************/ +/* ------------------------------------------------------------- + * Create accessor functions for variables. + * Does not create equivalent wrappers for enumerations, + * which are handled differently + * --------------------------------------------------------------*/ + int R::variableWrapper(Node *n) { String *name = Getattr(n, "sym:name"); if (debugMode) { @@ -1368,12 +1380,12 @@ int R::variableWrapper(Node *n) { return SWIG_OK; } -/************************************************************* -Creates accessor functions for class members. +/* ------------------------------------------------------------- + * Creates accessor functions for class members. -ToDo - this version depends on naming conventions and needs -to be replaced. -**************************************************************/ + * ToDo - this version depends on naming conventions and needs + * to be replaced. + * --------------------------------------------------------------*/ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { @@ -1776,9 +1788,10 @@ void R::dispatchFunction(Node *n) { DelWrapper(f); } -/****************************************************************** +/*-------------------------------------------------------------- + +* --------------------------------------------------------------*/ -*******************************************************************/ int R::functionWrapper(Node *n) { String *fname = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); @@ -2329,15 +2342,16 @@ int R::constantWrapper(Node *n) { return SWIG_OK; } -/***************************************************** - Add the specified routine name to the collection of - generated routines that are called from R functions. - This is used to register the routines with R for - resolving symbols. +/*-------------------------------------------------------------- + * Add the specified routine name to the collection of + * generated routines that are called from R functions. + * This is used to register the routines with R for + * resolving symbols. + + * rname - the name of the routine + * nargs - the number of arguments it expects. + * --------------------------------------------------------------*/ - rname - the name of the routine - nargs - the number of arguments it expects. -******************************************************/ int R::addRegistrationRoutine(String *rname, int nargs) { if(!registrationTable) registrationTable = NewHash(); @@ -2350,11 +2364,12 @@ int R::addRegistrationRoutine(String *rname, int nargs) { return SWIG_OK; } -/***************************************************** - Write the registration information to an array and - create the initialization routine for registering - these. -******************************************************/ +/* ------------------------------------------------------------- + * Write the registration information to an array and + * create the initialization routine for registering + * these. + * --------------------------------------------------------------*/ + int R::outputRegistrationRoutines(File *out) { int i, n; if(!registrationTable) @@ -2397,11 +2412,11 @@ int R::outputRegistrationRoutines(File *out) { -/**************************************************************************** - Process a struct, union or class declaration in the source code, - or an anonymous typedef struct +/* ------------------------------------------------------------- + * Process a struct, union or class declaration in the source code, + * or an anonymous typedef struct + * --------------------------------------------------------------*/ -*****************************************************************************/ //XXX What do we need to do here - // Define an S4 class to refer to this. @@ -2582,12 +2597,13 @@ int R::classDeclaration(Node *n) { -/*************************************************************** - Create the C routines that copy an S object of the class given - by the given struct definition in Node *n to the C value - and also the routine that goes from the C routine to an object - of this S class. -****************************************************************/ +/* ------------------------------------------------------------- + * Create the C routines that copy an S object of the class given + * by the given struct definition in Node *n to the C value + * and also the routine that goes from the C routine to an object + * of this S class. + * --------------------------------------------------------------*/ + /*XXX Clean up the toCRef - make certain the names are correct for the types, etc. in all cases. @@ -2682,13 +2698,14 @@ int R::generateCopyRoutines(Node *n) { -/***** - Called when there is a typedef to be invoked. +/* ------------------------------------------------------------- + * Called when there is a typedef to be invoked. + * + * XXX Needs to be enhanced or split to handle the case where we have a + * typedef within a classDeclaration emission because the struct/union/etc. + * is anonymous. + * --------------------------------------------------------------*/ - XXX Needs to be enhanced or split to handle the case where we have a - typedef within a classDeclaration emission because the struct/union/etc. - is anonymous. -******/ int R::typedefHandler(Node *n) { SwigType *tp = Getattr(n, "type"); String *type = Getattr(n, "type"); @@ -2712,12 +2729,13 @@ int R::typedefHandler(Node *n) { -/********************* - Called when processing a field in a "class", i.e. struct, union or - actual class. We set a state variable so that we can correctly - interpret the resulting functionWrapper() call and understand that - it is for a field element. -**********************/ +/* -------------------------------------------------------------- + * Called when processing a field in a "class", i.e. struct, union or + * actual class. We set a state variable so that we can correctly + * interpret the resulting functionWrapper() call and understand that + * it is for a field element. + * --------------------------------------------------------------*/ + int R::membervariableHandler(Node *n) { SwigType *t = Getattr(n, "type"); processType(t, n, NULL); @@ -2752,12 +2770,14 @@ String * R::runtimeCode() { } -/** - Called when SWIG wants to initialize this - We initialize anythin we want here. - Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module. - Use Swig_mark_arg() to tell SWIG that it is understood and not to throw an error. -**/ +/* ----------------------------------------------------------------------- + * Called when SWIG wants to initialize this + * We initialize anythin we want here. + * Most importantly, tell SWIG where to find the files (e.g. r.swg) for this module. + * Use Swig_mark_arg() to tell SWIG that it is understood and not to + * throw an error. + * --------------------------------------------------------------*/ + void R::main(int argc, char *argv[]) { init(); Preprocessor_define("SWIGR 1", 0); @@ -2840,10 +2860,10 @@ void R::main(int argc, char *argv[]) { } } -/* - Could make this work for String or File and then just store the resulting string - rather than the collection of arguments and argc. -*/ +/* ----------------------------------------------------------------------- + * Could make this work for String or File and then just store the resulting string + * rather than the collection of arguments and argc. + * ----------------------------------------------------------------------- */ int R::outputCommandLineArguments(File *out) { if(Argc < 1 || !Argv || !Argv[0]) @@ -2869,11 +2889,10 @@ Language *swig_r(void) { -/*************************************************************************************/ -/* - Needs to be reworked. -*/ +/* ----------------------------------------------------------------------- + * Needs to be reworked. + *----------------------------------------------------------------------- */ String * R::processType(SwigType *t, Node *n, int *nargs) { //XXX Need to handle typedefs, e.g. // a type which is a typedef to a function pointer. @@ -2925,12 +2944,12 @@ String * R::processType(SwigType *t, Node *n, int *nargs) { return NULL; } -/*************************************************************************************/ - /* ----------------------------------------------------------------------- - * enumValue() - * This method will return a string with an enum value to use in from R when - * setting up an enum variable - * ------------------------------------------------------------------------ */ + +/* ----------------------------------------------------------------------- + * enumValue() + * This method will return a string with an enum value to use in from R when + * setting up an enum variable + * ------------------------------------------------------------------------ */ String *R::enumValue(Node *n) { String *symname = Getattr(n, "sym:name"); From 4490d0ec2ca318d63aa40ac3ed07e751d539359a Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Thu, 21 Feb 2019 21:23:25 +1100 Subject: [PATCH 1500/2031] FIX: Corrected path to output from R tests Makefile was attempting to cat output files from the script source directory instead of the build directory. --- Examples/test-suite/r/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 1616ffd3d..33e9d90da 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -63,7 +63,7 @@ include $(srcdir)/../common.mk # check for syntactic correctness run_testcase = \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)out ; false); \ else \ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$*$(WRAPSUFFIX)out ; false); \ fi @@ -71,7 +71,7 @@ run_testcase = \ run_multitestcase = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) || (cat $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(SCRIPTDIR)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX)out ; false); \ else \ $(RUNTOOL) $(RUNR) ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX) || (cat ./$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX)out ; false); \ fi; \ From 4081521210deb5509a679ac0b59f7bd17a446f8d Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Thu, 21 Feb 2019 21:48:51 +1100 Subject: [PATCH 1501/2031] DOC: Extended documentation on enumeration support in R Touched on delayedAssign, use of character strings, function attributes, hidden environments and the lack of support for anonymous enumerations. --- Doc/Manual/R.html | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index b9dba4f9c..9fa27274b 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -189,9 +189,46 @@ of the proxy class baggage you see in other languages.

    -enumerations are characters which are then converted back and forth to -ints before calling the C routines. All of the enumeration code is -done in R. +R doesn't have a native enumeration type. Enumerations are represented +as character strings in R, with calls to R functions that convert back +and forth between integers. + +The details of enumeration names and contents are stored in hidden R +environments, which are named according the the enumeration name - for +example, an enumeration colour: +

    +enum colour { red=-1, blue, green = 10 };
    +
    + +will be initialized by the following call in R: +
    +defineEnumeration("_colour",
    + .values=c("red" = .Call('R_swig_colour_red_get',FALSE, PACKAGE='enum_thorough'),
    +"blue" = .Call('R_swig_colour_blue_get',FALSE, PACKAGE='enum_thorough'),
    +"green" = .Call('R_swig_colour_green_get',FALSE, PACKAGE='enum_thorough')))
    +
    +
    + +which will create an environment named .__E___colour. The enumeration +values are initialised via calls to C/C++ code, allowing complex +values for enumerations to be used. Calls to the C/C++ code require +the compiled library to be loaded, so a delayedAssign is employed +within defineEnumeration in order to allow the code to be easily used in R +packages. + +The user typically does not need to access the enumeration lookup +functions or know the name of the enumeration type used by +R. Attributes containing the type information are attached by swig to +functions requiring enumeration arguments or returning enumeration +values, and those attributes are used to identify and access the +appropriate environments and thus translate between characters +and integers. + +The relevant functions, for debugging purposes, are enumToInteger and +
    enumFromInteger
    . + +Anonymous enumerations are not supported. +

    From 43af20ab3bf7aa0a935bef8e74da5b44ad3bedca Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 6 Mar 2019 20:57:04 +1100 Subject: [PATCH 1502/2031] FIX: references to enums now functioning There is some consolidation work to be done. The core of the change is getRClassName2, which will probably eventually replace getRClassName. getRClassName seems to be in a funny state, with a middle argument that is commented out and never used. My next step is to verify whether the new version can replace it. --- Examples/test-suite/r/enum_thorough_runme.R | 17 ++-- Lib/r/r.swg | 5 ++ Lib/r/rtype.swg | 7 +- Source/Modules/r.cxx | 87 ++++++++------------- 4 files changed, 47 insertions(+), 69 deletions(-) diff --git a/Examples/test-suite/r/enum_thorough_runme.R b/Examples/test-suite/r/enum_thorough_runme.R index 608abc71a..a0f1270b7 100644 --- a/Examples/test-suite/r/enum_thorough_runme.R +++ b/Examples/test-suite/r/enum_thorough_runme.R @@ -51,9 +51,8 @@ unittest(v, s$speedTest3(v)) unittest(v, s$speedTest4(v)) unittest(v, s$speedTest5(v)) unittest(v, s$speedTest6(v)) -# Not handling enum references - probably needs a typemap -# unittest(v, s$speedTest7(v)) -# unittest(v, s$speedTest8(v)) +unittest(v, s$speedTest7(v)) +unittest(v, s$speedTest8(v)) ## speedTest methods not in the class @@ -62,7 +61,7 @@ unittest(v, speedTest2(v)) unittest(v, speedTest3(v)) unittest(v, speedTest4(v)) # enum reference -# unittest(v, speedTest5(v)) +unittest(v, speedTest5(v)) ## member access s <- SpeedClass() @@ -132,7 +131,7 @@ unittest(g, tt$scientistsTestG(g)) unittest(g, tt$scientistsTestH(g)) unittest(g, tt$scientistsTestI(g)) # enum reference -#unittest(g, tt$scientistsTestJ(g)) +unittest(g, tt$scientistsTestJ(g)) unittest(g, scientistsTest1(g)) @@ -143,7 +142,7 @@ unittest(g, scientistsTest5(g)) unittest(g, scientistsTest6(g)) unittest(g, scientistsTest7(g)) ## enum reference -## unittest(g, scientistsTest8(g)) +unittest(g, scientistsTest8(g)) tt <- TClassInt() b <- "bell" @@ -331,7 +330,7 @@ unittest(b, hairTest9(b)) unittest(b, hairTestA(b)) unittest(b, hairTestB(b)) ## enum reference -##unittest(b, hairTestC(b)) +unittest(b, hairTestC(b)) unittest(b, hairTestA1(b)) unittest(b, hairTestA2(b)) unittest(b, hairTestA3(b)) @@ -344,7 +343,7 @@ unittest(b, hairTestA9(b)) unittest(b, hairTestAA(b)) unittest(b, hairTestAB(b)) ## enum reference -## unittest(b, hairTestAC(b)) +unittest(b, hairTestAC(b)) unittest(b, hairTestB1(b)) unittest(b, hairTestB2(b)) @@ -358,7 +357,7 @@ unittest(b, hairTestB9(b)) unittest(b, hairTestBA(b)) unittest(b, hairTestBB(b)) ## enum reference -## unittest(b, hairTestBC(b)) +unittest(b, hairTestBC(b)) f <- FirStruct() b <- "blonde" diff --git a/Lib/r/r.swg b/Lib/r/r.swg index a9035331b..e6153892e 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -192,6 +192,11 @@ unsigned char *OUTPUT free($1); } +%typemap(in) const enum SWIGTYPE & ($*1_ltype temp) +%{ temp = ($*1_ltype)INTEGER($input)[0]; + $1 = &temp; %} + +%typemap(out) const enum SWIGTYPE & %{ $result = Rf_ScalarInteger(*$1); %} %typemap(memberin) char[] %{ if ($input) strcpy($1, $input); diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index c55c70377..bdc48c24e 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -16,6 +16,7 @@ %typemap("rtype") enum SWIGTYPE * "character"; %typemap("rtype") enum SWIGTYPE *const "character"; %typemap("rtype") enum SWIGTYPE & "character"; +%typemap("rtype") const enum SWIGTYPE & "character"; %typemap("rtype") enum SWIGTYPE && "character"; %typemap("rtype") SWIGTYPE * "$R_class"; %typemap("rtype") SWIGTYPE *const "$R_class"; @@ -86,9 +87,7 @@ %typemap(scoercein) enum SWIGTYPE %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE & - %{ $input = enumToInteger($input, "$R_class"); %} -%typemap(scoercein) enum SWIGTYPE && - %{ $input = enumToInteger($input, "$R_class"); %} + %{ $input = enumToInteger($input, "$*R_class"); %} %typemap(scoercein) enum SWIGTYPE * %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE *const @@ -138,7 +137,7 @@ string &, std::string & %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE & - %{ $result = enumFromInteger($result, "$R_class"); %} + %{ $result = enumFromInteger($result, "$*R_class"); %} %typemap(scoerceout) enum SWIGTYPE && %{ $result = enumFromInteger($result, "$R_class"); %} diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 5ae138f93..ff68b8cf4 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -74,61 +74,37 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { String *tmp = NewString(""); SwigType *resolved = SwigType_typedef_resolve_all(retType); - char *retName = Char(SwigType_manglestr(resolved)); if (upRef) { - Printf(tmp, "_p%s", retName); - } else{ - Insert(tmp, 0, retName); - } - - return tmp; -/* -#if 1 - List *l = SwigType_split(retType); - int n = Len(l); - if(!l || n == 0) { -#ifdef R_SWIG_VERBOSE - if (debugMode) - Printf(stdout, "SwigType_split return an empty list for %s\n", - retType); -#endif - return(tmp); - } - - - String *el = Getitem(l, n-1); - char *ptr = Char(el); - if(strncmp(ptr, "struct ", 7) == 0) - ptr += 7; - - Printf(tmp, "%s", ptr); - - if(addRef) { - for(int i = 0; i < n; i++) { - if(Strcmp(Getitem(l, i), "p.") == 0 || - Strncmp(Getitem(l, i), "a(", 2) == 0) - Printf(tmp, "Ref"); - } - } - -#else - char *retName = Char(SwigType_manglestr(retType)); - if(!retName) - return(tmp); - - if(addRef) { - while(retName && strlen(retName) > 1 && strncmp(retName, "_p", 2) == 0) { - retName += 2; - Printf(tmp, "Ref"); - } - } - if(retName[0] == '_') - retName ++; + SwigType_add_pointer(resolved); + } + char *retName = Char(SwigType_manglestr(resolved)); Insert(tmp, 0, retName); -#endif - return tmp; -*/ +} +/* -------------------------------------------------------------- + * Tries to get the resolved name, with options of adding + * or removing a layer of references. Take care not + * to request both + * --------------------------------------------------------------*/ + +static String *getRClassName2(String *retType, int deRef=0, int upRef=0) { + SwigType *resolved = SwigType_typedef_resolve_all(retType); + int ispointer = SwigType_ispointer(resolved); + int isreference = SwigType_isreference(resolved); + if (upRef) { + SwigType_add_pointer(resolved); + } + if (deRef) { + if (ispointer) { + SwigType_del_pointer(resolved); + } + if (isreference) { + SwigType_del_reference(resolved); + } + } + String *tmp = NewString(""); + Insert(tmp, 0, Char(SwigType_manglestr(resolved))); + return(tmp); } /* -------------------------------------------------------------- @@ -257,10 +233,9 @@ static int addCopyParameter(SwigType *type) { } static void replaceRClass(String *tm, SwigType *type) { - String *tmp = getRClassName(type); - String *tmp_base = getRClassName(type, 0); - String *tmp_ref = getRClassName(type, 1, 1); - + String *tmp = getRClassName2(type, 0, 0); + String *tmp_base = getRClassName2(type, 1, 0); + String *tmp_ref = getRClassName2(type, 0, 1); Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); From c38b7de6a120e6392abff50afd9bb919cc858cfc Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Sun, 10 Mar 2019 11:47:27 -0600 Subject: [PATCH 1503/2031] Fix format-security error with octave 5.1 --- Lib/octave/octrun.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 301233103..ff614e681 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -51,7 +51,7 @@ SWIGRUNTIME octave_value SWIG_Error(int code, const char *msg) { octave_value type(SWIG_ErrorType(code)); std::string r = msg; r += " (" + type.string_value() + ")"; - error(r.c_str()); + error("%s", r.c_str()); return octave_value(r); } @@ -840,7 +840,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); const std::string opname = std::string("__") + octave_base_value::get_umap_name(umap) + std::string("__"); octave_value ret; if (!dispatch_unary_op(opname, ret)) { - error((opname + std::string(" method not found")).c_str()); + error("%s", (opname + std::string(" method not found")).c_str()); return octave_value(); } return ret; From 6e3518c9b4b8cfd08c7e6d828053c7e3212adeb8 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Mon, 11 Mar 2019 21:17:03 +1100 Subject: [PATCH 1504/2031] ENH: Replaced the old getRClassName with the new one that uses the swig functions for detecting, adding and removing pointers andreferences. --- Source/Modules/r.cxx | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index ff68b8cf4..fde583ed6 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -65,29 +65,13 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { */ } -/* -------------------------------------------------------------- - * Tries to get the name of the R class corresponding to the given type - * e.g. struct A * is ARef, struct A** is ARefRef. - * Now handles arrays, i.e. struct A[2] - * --------------------------------------------------------------*/ - -static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) { - String *tmp = NewString(""); - SwigType *resolved = SwigType_typedef_resolve_all(retType); - if (upRef) { - SwigType_add_pointer(resolved); - } - char *retName = Char(SwigType_manglestr(resolved)); - Insert(tmp, 0, retName); - return tmp; -} /* -------------------------------------------------------------- * Tries to get the resolved name, with options of adding * or removing a layer of references. Take care not * to request both * --------------------------------------------------------------*/ -static String *getRClassName2(String *retType, int deRef=0, int upRef=0) { +static String *getRClassName(String *retType, int deRef=0, int upRef=0) { SwigType *resolved = SwigType_typedef_resolve_all(retType); int ispointer = SwigType_ispointer(resolved); int isreference = SwigType_isreference(resolved); @@ -233,9 +217,9 @@ static int addCopyParameter(SwigType *type) { } static void replaceRClass(String *tm, SwigType *type) { - String *tmp = getRClassName2(type, 0, 0); - String *tmp_base = getRClassName2(type, 1, 0); - String *tmp_ref = getRClassName2(type, 0, 1); + String *tmp = getRClassName(type, 0, 0); + String *tmp_base = getRClassName(type, 1, 0); + String *tmp_ref = getRClassName(type, 0, 1); Replaceall(tm, "$R_class", tmp); Replaceall(tm, "$*R_class", tmp_base); Replaceall(tm, "$&R_class", tmp_ref); From 38572f925136e6263d648eafb9fbec9211e03bc7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 11 Mar 2019 18:53:48 +0000 Subject: [PATCH 1505/2031] Add changes entry for Octave 5.1 format-security fix --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2b77e63f3..80230e964 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-11: dirteat,opoplawski + [Octave] Fix compilation errors in Octave 5.1. + + error: format not a string literal and no format arguments [-Werror=format-security] + 2019-02-28: wsfulton [Java] std::vector improvements for types that do not have a default constructor. From f0067b6bbfd1e43f01016a78428bc3d55434bc39 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 7 Mar 2019 02:25:49 +0100 Subject: [PATCH 1506/2031] Add std::set<> typemaps for C# Create new Lib/csharp/std_set.i based on the existing std_map.i and run li_std_set unit test for C# as well. Notice that the set operations defined by the base ISet<> interface are not implemented yet. --- CHANGES.current | 6 + .../test-suite/csharp/li_std_set_runme.cs | 55 ++++ Examples/test-suite/li_std_set.i | 6 +- Lib/csharp/std_set.i | 239 ++++++++++++++++++ 4 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/csharp/li_std_set_runme.cs create mode 100644 Lib/csharp/std_set.i diff --git a/CHANGES.current b/CHANGES.current index 80230e964..3e3da1099 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-12: vadz + [C#] Add std::set<> typemaps. + + Not all methods of System.Collections.Generic.ISet are implemented yet, but all the + basic methods, including elements access and iteration, are. + 2019-03-11: dirteat,opoplawski [Octave] Fix compilation errors in Octave 5.1. diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs new file mode 100644 index 000000000..c186c2f7a --- /dev/null +++ b/Examples/test-suite/csharp/li_std_set_runme.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using li_std_setNamespace; + +public class runme +{ + static void checkThat(bool mustBeTrue, string message) + { + if (!mustBeTrue) + throw new Exception("Test that the set " + message + " failed"); + } + + static void Main() + { + StringSet ss = new StringSet(); + + // Check the interface methods first. + ISet s = ss; + + checkThat(s.Count == 0, "is initially empty"); + checkThat(!s.Contains("key"), "doesn't contain inexistent element"); + checkThat(!s.Remove("key"), "returns false when removing inexistent element"); + + checkThat(s.Add("key"), "returns true when adding a new element"); + checkThat(!s.Add("key"), "returns false when adding an existing element"); + checkThat(s.Contains("key"), "contains the just added element"); + checkThat(s.Remove("key"), "returns true when removing an existing element"); + checkThat(s.Count == 0, "is empty again"); + + checkThat(s.Add("key1"), "Add(key1) returns true"); + checkThat(s.Add("key2"), "Add(key2) returns true"); + checkThat(s.Add("key3"), "Add(key3) returns true"); + + // Also check a different interface, providing a different Add() (sic!). + ICollection coll = ss; + coll.Add("key"); + checkThat(ss.Count == 4, "contains 4 elements"); + + // Now use object-specific methods, mimicking HashSet<>. + string val; + checkThat(ss.TryGetValue("key1", out val), "could retrieve existing item"); + checkThat(val.Equals("key1"), "value was returned correctly by TryGetValue()"); + checkThat(!ss.TryGetValue("no-such-key", out val), "couldn't retrieve inexistent item"); + checkThat(val == null, "value was reset after failed TryGetValue()"); + + IList list = new List(); + foreach (string str in ss) { + list.Add(str); + } + checkThat(list.Count == 4, "copy contains 4 elements"); + + ss.Clear(); + checkThat(ss.Count == 0, "is empty after Clear()"); + } +} diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index fc9db42a9..bb952cd85 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -15,15 +15,15 @@ %include %include -// Use language macros since Java doesn't have multiset support (yet) +// Use language macros since Java and C# don't have multiset support (yet) // and uses different naming conventions. #if defined(SWIGRUBY) || defined(SWIGPYTHON) %include %template(set_int) std::multiset; %template(v_int) std::vector; %template(set_string) std::set; -#elif defined(SWIGJAVA) - %template(StringSet) std::set; +#elif defined(SWIGJAVA) || defined(SWIGCSHARP) + %template(StringSet) std::set; #endif #if defined(SWIGRUBY) diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i new file mode 100644 index 000000000..b988d8d91 --- /dev/null +++ b/Lib/csharp/std_set.i @@ -0,0 +1,239 @@ +/* ----------------------------------------------------------------------------- + * std_map.i + * + * SWIG typemaps for std::set + * + * The C# wrapper is made to look and feel like a C# System.Collections.Generic.HashSet<>. + * ----------------------------------------------------------------------------- */ + +%{ +#include +#include +#include +%} + +%csmethodmodifiers std::set::size "private" +%csmethodmodifiers std::set::getitem "private" +%csmethodmodifiers std::set::create_iterator_begin "private" +%csmethodmodifiers std::set::get_next "private" +%csmethodmodifiers std::set::destroy_iterator "private" + +namespace std { + +// TODO: Add support for comparator and allocator template parameters. +template +class set { + +%typemap(csinterfaces) std::set "global::System.IDisposable, global::System.Collections.Generic.ISet<$typemap(cstype, T)>\n"; +%proxycode %{ + void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add(string item) { + ((global::System.Collections.Generic.ISet<$typemap(cstype, T)>)this).Add(item); + } + + public bool TryGetValue($typemap(cstype, T) equalValue, out $typemap(cstype, T) actualValue) { + try { + actualValue = getitem(equalValue); + return true; + } catch { + actualValue = default($typemap(cstype, T)); + return false; + } + } + + public int Count { + get { + return (int)size(); + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public void CopyTo($typemap(cstype, T)[] array) { + CopyTo(array, 0); + } + + public void CopyTo($typemap(cstype, T)[] array, int arrayIndex) { + if (array == null) + throw new global::System.ArgumentNullException("array"); + if (arrayIndex < 0) + throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero"); + if (array.Rank > 1) + throw new global::System.ArgumentException("Multi dimensional array.", "array"); + if (arrayIndex+this.Count > array.Length) + throw new global::System.ArgumentException("Number of elements to copy is too large."); + + foreach ($typemap(cstype, T) item in this) { + array.SetValue(item, arrayIndex++); + } + } + + public void ExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public void IntersectWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool IsProperSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool IsProperSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool IsSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool IsSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool Overlaps(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public bool SetEquals(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public void SymmetricExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public void UnionWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + + private global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Items { + get { + global::System.Collections.Generic.ICollection<$typemap(cstype, T)> items = new global::System.Collections.Generic.List<$typemap(cstype, T)>(); + int size = this.Count; + if (size > 0) { + global::System.IntPtr iter = create_iterator_begin(); + for (int i = 0; i < size; i++) { + items.Add(get_next(iter)); + } + destroy_iterator(iter); + } + return items; + } + } + + global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + public $csclassnameEnumerator GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + // Type-safe enumerator + /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown + /// 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 : global::System.Collections.IEnumerator, + global::System.Collections.Generic.IEnumerator<$typemap(cstype, T)> + { + private $csclassname collectionRef; + private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection; + private int currentIndex; + private $typemap(cstype, T) currentObject; + private int currentSize; + + public $csclassnameEnumerator($csclassname collection) { + collectionRef = collection; + ItemsCollection = new global::System.Collections.Generic.List<$typemap(cstype, T)>(collection.Items); + currentIndex = -1; + currentObject = null; + currentSize = collectionRef.Count; + } + + // Type-safe iterator Current + public $typemap(cstype, T) Current { + get { + if (currentIndex == -1) + throw new global::System.InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize - 1) + throw new global::System.InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new global::System.InvalidOperationException("Collection modified."); + return currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object global::System.Collections.IEnumerator.Current { + get { + return Current; + } + } + + public bool MoveNext() { + int size = collectionRef.Count; + bool moveOkay = (currentIndex+1 < size) && (size == currentSize); + if (moveOkay) { + currentIndex++; + currentObject = ItemsCollection[currentIndex]; + } else { + currentObject = null; + } + return moveOkay; + } + + public void Reset() { + currentIndex = -1; + currentObject = null; + if (collectionRef.Count != currentSize) { + throw new global::System.InvalidOperationException("Collection modified."); + } + } + + public void Dispose() { + currentIndex = -1; + currentObject = null; + } + } + +%} + + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T key_type; + typedef T value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + + set(); + set(const set& other); + size_type size() const; + bool empty() const; + %rename(Clear) clear; + void clear(); + %extend { + bool Add(const value_type& item) { + return $self->insert(item).second; + } + + bool Contains(const value_type& item) { + return $self->count(item) != 0; + } + + bool Remove(const value_type& item) { + return $self->erase(item) != 0; + } + + const value_type& getitem(const value_type& item) throw (std::out_of_range) { + std::set::iterator iter = $self->find(item); + if (iter == $self->end()) + throw std::out_of_range("item not found"); + + return *iter; + } + + // create_iterator_begin(), get_next() and destroy_iterator work together to provide a collection of items to C# + %apply void *VOID_INT_PTR { std::set::iterator *create_iterator_begin } + %apply void *VOID_INT_PTR { std::set::iterator *swigiterator } + + std::set::iterator *create_iterator_begin() { + return new std::set::iterator($self->begin()); + } + + const key_type& get_next(std::set::iterator *swigiterator) { + std::set::iterator iter = *swigiterator; + (*swigiterator)++; + return *iter; + } + + void destroy_iterator(std::set::iterator *swigiterator) { + delete swigiterator; + } + } +}; + +} From aaa12450c06d994900ae86fc7a1a9f8f2e25038d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 11 Mar 2019 23:05:10 +0100 Subject: [PATCH 1507/2031] Implement set-theoretic methods in std::set C# typemaps These implementations are not optimized, i.e. are done in a naive way in C#, rather than using C++ functions more efficiently, but are better than nothing. --- CHANGES.current | 3 - .../test-suite/csharp/li_std_set_runme.cs | 34 +++++++ Lib/csharp/std_set.i | 88 ++++++++++++++++--- 3 files changed, 112 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3e3da1099..3765a8273 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -10,9 +10,6 @@ Version 4.0.0 (in progress) 2019-03-12: vadz [C#] Add std::set<> typemaps. - Not all methods of System.Collections.Generic.ISet are implemented yet, but all the - basic methods, including elements access and iteration, are. - 2019-03-11: dirteat,opoplawski [Octave] Fix compilation errors in Octave 5.1. diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs index c186c2f7a..6519e8c8d 100644 --- a/Examples/test-suite/csharp/li_std_set_runme.cs +++ b/Examples/test-suite/csharp/li_std_set_runme.cs @@ -51,5 +51,39 @@ public class runme ss.Clear(); checkThat(ss.Count == 0, "is empty after Clear()"); + + // Check set-theoretic methods. + checkThat(new StringSet().SetEquals(new StringSet()), "SetEquals() works for empty sets"); + checkThat(new StringSet{"foo"}.SetEquals(new StringSet{"foo"}), "SetEquals() works for non-empty sets"); + checkThat(!new StringSet{"foo"}.SetEquals(new[] {"bar"}), "SetEquals() doesn't always return true"); + + ss = new StringSet{"foo", "bar", "baz"}; + ss.ExceptWith(new[] {"baz", "quux"}); + checkThat(ss.SetEquals(new[] {"foo", "bar"}), "ExceptWith works"); + + ss = new StringSet{"foo", "bar", "baz"}; + ss.IntersectWith(new[] {"baz", "quux"}); + checkThat(ss.SetEquals(new[] {"baz"}), "IntersectWith works"); + + checkThat(ss.IsProperSubsetOf(new[] {"bar", "baz"}), "IsProperSubsetOf works"); + checkThat(!ss.IsProperSubsetOf(new[] {"baz"}), "!IsProperSubsetOf works"); + checkThat(ss.IsSubsetOf(new[] {"bar", "baz"}), "IsSubsetOf works"); + checkThat(!ss.IsSubsetOf(new[] {"bar"}), "!IsSubsetOf works"); + + ss = new StringSet{"foo", "bar", "baz"}; + checkThat(ss.IsProperSupersetOf(new[] {"bar"}), "IsProperSupersetOf works"); + checkThat(!ss.IsProperSupersetOf(new[] {"quux"}), "IsProperSupersetOf works"); + checkThat(ss.IsSupersetOf(new[] {"foo", "bar", "baz"}), "IsProperSupersetOf works"); + checkThat(!ss.IsSupersetOf(new[] {"foo", "bar", "baz", "quux"}), "IsProperSupersetOf works"); + + checkThat(ss.Overlaps(new[] {"foo"}), "Overlaps works"); + checkThat(!ss.Overlaps(new[] {"moo"}), "!Overlaps works"); + + ss.SymmetricExceptWith(new[] {"baz", "quux"}); + checkThat(ss.SetEquals(new[] {"foo", "bar", "quux"}), "SymmetricExceptWith works"); + + ss = new StringSet{"foo", "bar", "baz"}; + ss.UnionWith(new[] {"baz", "quux"}); + checkThat(ss.SetEquals(new[] {"foo", "bar", "baz", "quux"}), "UnionWith works"); } } diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i index b988d8d91..c5dd09473 100644 --- a/Lib/csharp/std_set.i +++ b/Lib/csharp/std_set.i @@ -71,16 +71,84 @@ class set { } } - public void ExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public void IntersectWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool IsProperSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool IsProperSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool IsSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool IsSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool Overlaps(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public bool SetEquals(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public void SymmetricExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } - public void UnionWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { throw new global::System.Exception("TODO"); } + public void ExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + foreach ($typemap(cstype, T) item in other) { + Remove(item); + } + } + + public void IntersectWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + $csclassname old = new $csclassname(this); + + Clear(); + foreach ($typemap(cstype, T) item in other) { + if (old.Contains(item)) + Add(item); + } + } + + private static int count_enum(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + int count = 0; + foreach ($typemap(cstype, T) item in other) { + count++; + } + + return count; + } + + public bool IsProperSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + return IsSubsetOf(other) && Count < count_enum(other); + } + + public bool IsProperSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + return IsSupersetOf(other) && Count > count_enum(other); + } + + public bool IsSubsetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + int countContained = 0; + + foreach ($typemap(cstype, T) item in other) { + if (Contains(item)) + countContained++; + } + + return countContained == Count; + } + + public bool IsSupersetOf(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + foreach ($typemap(cstype, T) item in other) { + if (!Contains(item)) + return false; + } + + return true; + } + + public bool Overlaps(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + foreach ($typemap(cstype, T) item in other) { + if (Contains(item)) + return true; + } + + return false; + } + + public bool SetEquals(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + return IsSupersetOf(other) && Count == count_enum(other); + } + + public void SymmetricExceptWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + foreach ($typemap(cstype, T) item in other) { + if (!Remove(item)) + Add(item); + } + } + + public void UnionWith(global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)> other) { + foreach ($typemap(cstype, T) item in other) { + Add(item); + } + } private global::System.Collections.Generic.ICollection<$typemap(cstype, T)> Items { get { From 04c9a977873928ca341a06a931f197670562fe97 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 11 Mar 2019 23:08:19 +0100 Subject: [PATCH 1508/2031] Fix header comment in C# std_set typemaps Mention that these typemaps require .NET 4 or greater. --- Lib/csharp/std_set.i | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i index c5dd09473..3b2492e0e 100644 --- a/Lib/csharp/std_set.i +++ b/Lib/csharp/std_set.i @@ -1,9 +1,13 @@ /* ----------------------------------------------------------------------------- - * std_map.i + * std_set.i * - * SWIG typemaps for std::set + * SWIG typemaps for std::set. * - * The C# wrapper is made to look and feel like a C# System.Collections.Generic.HashSet<>. + * Note that ISet<> used here requires .NET 4 or later. + * + * The C# wrapper implements ISet<> interface and shares performance + * characteristics of C# System.Collections.Generic.SortedSet<> class, but + * doesn't provide quite all of its methods. * ----------------------------------------------------------------------------- */ %{ From 30f59ffe2286283fb01ae2418bf6464f78f18e05 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 20:03:14 +0000 Subject: [PATCH 1509/2031] Include all template parameters for std_unordered_multimap and std_unordered_map --- Examples/test-suite/cpp11_std_unordered_map.i | 4 +++ Lib/python/std_unordered_map.i | 6 ++-- Lib/python/std_unordered_multimap.i | 28 +++++++++---------- Lib/ruby/std_unordered_map.i | 20 ++++++------- Lib/ruby/std_unordered_multimap.i | 22 +++++++-------- 5 files changed, 42 insertions(+), 38 deletions(-) diff --git a/Examples/test-suite/cpp11_std_unordered_map.i b/Examples/test-suite/cpp11_std_unordered_map.i index b11d8f275..4bdec9c7c 100644 --- a/Examples/test-suite/cpp11_std_unordered_map.i +++ b/Examples/test-suite/cpp11_std_unordered_map.i @@ -5,3 +5,7 @@ %template(UnorderedMapIntInt) std::unordered_map; %template(UnorderedMapStringInt) std::unordered_map; + +%inline %{ +std::unordered_map,std::equal_to< std::string >,std::allocator< std::pair< std::string const,int > > > inout(std::unordered_map m) { return m; } +%} diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 76acbb1ec..042d5b671 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -56,9 +56,9 @@ %fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { + assign(const SwigPySeq& swigpyseq, std::unordered_map *unordered_map) { typedef typename std::unordered_map::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { @@ -97,7 +97,7 @@ } }; - template + template struct traits_from > { typedef std::unordered_map unordered_map_type; typedef typename unordered_map_type::const_iterator const_iterator; diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index aa29a7cff..281140445 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -6,27 +6,27 @@ %fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { - typedef typename std::unordered_multimap::value_type value_type; + assign(const SwigPySeq& swigpyseq, std::unordered_multimap *unordered_multimap) { + typedef typename std::unordered_multimap::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { unordered_multimap->insert(value_type(it->first, it->second)); } } - template - struct traits_reserve > { - static void reserve(std::unordered_multimap &seq, typename std::unordered_multimap::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_multimap &seq, typename std::unordered_multimap::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - typedef std::unordered_multimap unordered_multimap_type; - static int asptr(PyObject *obj, std::unordered_multimap **val) { + template + struct traits_asptr > { + typedef std::unordered_multimap unordered_multimap_type; + static int asptr(PyObject *obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); @@ -34,7 +34,7 @@ /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif - res = traits_asptr_stdseq, std::pair >::asptr(items, val); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { unordered_multimap_type *p; swig_type_info *descriptor = swig::type_info(); @@ -45,9 +45,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_multimap unordered_multimap_type; + template + struct traits_from > { + typedef std::unordered_multimap unordered_multimap_type; typedef typename unordered_multimap_type::const_iterator const_iterator; typedef typename unordered_multimap_type::size_type size_type; diff --git a/Lib/ruby/std_unordered_map.i b/Lib/ruby/std_unordered_map.i index c3f60bbba..48c875214 100644 --- a/Lib/ruby/std_unordered_map.i +++ b/Lib/ruby/std_unordered_map.i @@ -6,25 +6,25 @@ %fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits") { namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_map *map) { - typedef typename std::unordered_map::value_type value_type; + assign(const RubySeq& rubyseq, std::unordered_map *map) { + typedef typename std::unordered_map::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } - template - struct traits_asptr > { - typedef std::unordered_map map_type; + template + struct traits_asptr > { + typedef std::unordered_map map_type; static int asptr(VALUE obj, map_type **val) { int res = SWIG_ERROR; if (TYPE(obj) == T_HASH) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); - res = traits_asptr_stdseq, std::pair >::asptr(items, val); + res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; swig_type_info *descriptor = swig::type_info(); @@ -35,9 +35,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_map map_type; + template + struct traits_from > { + typedef std::unordered_map map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type; diff --git a/Lib/ruby/std_unordered_multimap.i b/Lib/ruby/std_unordered_multimap.i index b663c1298..ebc53b597 100644 --- a/Lib/ruby/std_unordered_multimap.i +++ b/Lib/ruby/std_unordered_multimap.i @@ -6,25 +6,25 @@ %fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits") { namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_multimap *multimap) { - typedef typename std::unordered_multimap::value_type value_type; + assign(const RubySeq& rubyseq, std::unordered_multimap *multimap) { + typedef typename std::unordered_multimap::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); for (;it != rubyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } - template - struct traits_asptr > { - typedef std::unordered_multimap multimap_type; - static int asptr(VALUE obj, std::unordered_multimap **val) { + template + struct traits_asptr > { + typedef std::unordered_multimap multimap_type; + static int asptr(VALUE obj, std::unordered_multimap **val) { int res = SWIG_ERROR; if ( TYPE(obj) == T_HASH ) { static ID id_to_a = rb_intern("to_a"); VALUE items = rb_funcall(obj, id_to_a, 0); - return traits_asptr_stdseq, std::pair >::asptr(items, val); + return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); @@ -34,9 +34,9 @@ } }; - template - struct traits_from > { - typedef std::unordered_multimap multimap_type; + template + struct traits_from > { + typedef std::unordered_multimap multimap_type; typedef typename multimap_type::const_iterator const_iterator; typedef typename multimap_type::size_type size_type; From 4a25ddbb97c5c1c793ae5552c40932e6684bb5ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 20:21:19 +0000 Subject: [PATCH 1510/2031] Correct unordered_set/unordered_multiset template Key parameter name --- Lib/java/std_unordered_set.i | 40 ++++++++++++++--------------- Lib/python/std_unordered_multiset.i | 26 +++++++++---------- Lib/python/std_unordered_set.i | 26 +++++++++---------- Lib/ruby/std_unordered_multiset.i | 20 +++++++-------- Lib/ruby/std_unordered_set.i | 20 +++++++-------- Lib/std/std_unordered_multiset.i | 14 +++++----- Lib/std/std_unordered_set.i | 14 +++++----- 7 files changed, 80 insertions(+), 80 deletions(-) diff --git a/Lib/java/std_unordered_set.i b/Lib/java/std_unordered_set.i index 1a7b03688..59726e94d 100644 --- a/Lib/java/std_unordered_set.i +++ b/Lib/java/std_unordered_set.i @@ -43,12 +43,12 @@ namespace std { -template +template class unordered_set { -%typemap(javabase) std::unordered_set "java.util.AbstractSet<$typemap(jboxtype, T)>" +%typemap(javabase) std::unordered_set "java.util.AbstractSet<$typemap(jboxtype, Key)>" %proxycode %{ - public $javaclassname(java.util.Collection collection) { + public $javaclassname(java.util.Collection collection) { this(); addAll(collection); } @@ -57,34 +57,34 @@ class unordered_set { return sizeImpl(); } - public boolean addAll(java.util.Collection collection) { + public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; for (java.lang.Object object : collection) { - didAddElement |= add(($typemap(jboxtype, T))object); + didAddElement |= add(($typemap(jboxtype, Key))object); } return didAddElement; } - public java.util.Iterator<$typemap(jboxtype, T)> iterator() { - return new java.util.Iterator<$typemap(jboxtype, T)>() { + public java.util.Iterator<$typemap(jboxtype, Key)> iterator() { + return new java.util.Iterator<$typemap(jboxtype, Key)>() { private Iterator curr; private Iterator end; - private java.util.Iterator<$typemap(jboxtype, T)> init() { + private java.util.Iterator<$typemap(jboxtype, Key)> init() { curr = $javaclassname.this.begin(); end = $javaclassname.this.end(); return this; } - public $typemap(jboxtype, T) next() { + public $typemap(jboxtype, Key) next() { if (!hasNext()) { throw new java.util.NoSuchElementException(); } // Save the current position, increment it, // then return the value at the position before the increment. - final $typemap(jboxtype, T) currValue = curr.derefUnchecked(); + final $typemap(jboxtype, Key) currValue = curr.derefUnchecked(); curr.incrementUnchecked(); return currValue; } @@ -106,11 +106,11 @@ class unordered_set { } public boolean contains(java.lang.Object object) { - if (!(object instanceof $typemap(jboxtype, T))) { + if (!(object instanceof $typemap(jboxtype, Key))) { return false; } - return containsImpl(($typemap(jboxtype, T))object); + return containsImpl(($typemap(jboxtype, Key))object); } public boolean removeAll(java.util.Collection collection) { @@ -123,11 +123,11 @@ class unordered_set { } public boolean remove(java.lang.Object object) { - if (!(object instanceof $typemap(jboxtype, T))) { + if (!(object instanceof $typemap(jboxtype, Key))) { return false; } - return removeImpl(($typemap(jboxtype, T))object); + return removeImpl(($typemap(jboxtype, Key))object); } %} @@ -140,7 +140,7 @@ class unordered_set { ++(*$self); } - T derefUnchecked() const { + Key derefUnchecked() const { return **$self; } @@ -152,8 +152,8 @@ class unordered_set { typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef T value_type; - typedef T key_type; + typedef Key value_type; + typedef Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; @@ -172,17 +172,17 @@ class unordered_set { %fragment("SWIG_UnorderedSetSize"); // Returns whether item was inserted. - bool add(const T& key) { + bool add(const Key& key) { return self->insert(key).second; } // Returns whether set contains key. - bool containsImpl(const T& key) { + bool containsImpl(const Key& key) { return (self->count(key) > 0); } // Returns whether the item was erased. - bool removeImpl(const T& key) { + bool removeImpl(const Key& key) { return (self->erase(key) > 0); } diff --git a/Lib/python/std_unordered_multiset.i b/Lib/python/std_unordered_multiset.i index d90a97bdc..4b67c7305 100644 --- a/Lib/python/std_unordered_multiset.i +++ b/Lib/python/std_unordered_multiset.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_multiset* seq) { + assign(const SwigPySeq& swigpyseq, std::unordered_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(); @@ -18,24 +18,24 @@ } } - template - struct traits_reserve > { - static void reserve(std::unordered_multiset &seq, typename std::unordered_multiset::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_multiset &seq, typename std::unordered_multiset::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - static int asptr(PyObject *obj, std::unordered_multiset **m) { - return traits_asptr_stdseq >::asptr(obj, m); + template + struct traits_asptr > { + static int asptr(PyObject *obj, std::unordered_multiset **m) { + return traits_asptr_stdseq >::asptr(obj, m); } }; - template - struct traits_from > { - static PyObject *from(const std::unordered_multiset& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static PyObject *from(const std::unordered_multiset& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 8736cb1b5..9eab62226 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -5,9 +5,9 @@ %fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_set* seq) { + assign(const SwigPySeq& swigpyseq, std::unordered_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(); @@ -16,24 +16,24 @@ } } - template - struct traits_reserve > { - static void reserve(std::unordered_set &seq, typename std::unordered_set::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_set &seq, typename std::unordered_set::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - static int asptr(PyObject *obj, std::unordered_set **s) { - return traits_asptr_stdseq >::asptr(obj, s); + template + struct traits_asptr > { + static int asptr(PyObject *obj, std::unordered_set **s) { + return traits_asptr_stdseq >::asptr(obj, s); } }; - template - struct traits_from > { - static PyObject *from(const std::unordered_set& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static PyObject *from(const std::unordered_set& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/ruby/std_unordered_multiset.i b/Lib/ruby/std_unordered_multiset.i index 181aa212d..4bc13790a 100644 --- a/Lib/ruby/std_unordered_multiset.i +++ b/Lib/ruby/std_unordered_multiset.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits") %{ namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_multiset* seq) { + assign(const RubySeq& rubyseq, std::unordered_multiset* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); @@ -18,17 +18,17 @@ } } - template - struct traits_asptr > { - static int asptr(VALUE obj, std::unordered_multiset **m) { - return traits_asptr_stdseq >::asptr(obj, m); + template + struct traits_asptr > { + static int asptr(VALUE obj, std::unordered_multiset **m) { + return traits_asptr_stdseq >::asptr(obj, m); } }; - template - struct traits_from > { - static VALUE from(const std::unordered_multiset& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static VALUE from(const std::unordered_multiset& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/ruby/std_unordered_set.i b/Lib/ruby/std_unordered_set.i index 3d4494351..84d3b4b09 100644 --- a/Lib/ruby/std_unordered_set.i +++ b/Lib/ruby/std_unordered_set.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedSetTraits","header",fragment="",fragment="StdSetTraits") %{ namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_set* seq) { + assign(const RubySeq& rubyseq, std::unordered_set* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); @@ -18,17 +18,17 @@ } } - template - struct traits_asptr > { - static int asptr(VALUE obj, std::unordered_set **s) { - return traits_asptr_stdseq >::asptr(obj, s); + template + struct traits_asptr > { + static int asptr(VALUE obj, std::unordered_set **s) { + return traits_asptr_stdseq >::asptr(obj, s); } }; - template - struct traits_from > { - static VALUE from(const std::unordered_set& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static VALUE from(const std::unordered_set& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/std/std_unordered_multiset.i b/Lib/std/std_unordered_multiset.i index 1817fc24a..8effa586e 100644 --- a/Lib/std/std_unordered_multiset.i +++ b/Lib/std/std_unordered_multiset.i @@ -17,19 +17,19 @@ // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // -// -- f(std::unordered_multiset), f(const std::unordered_multiset&): +// -- f(std::unordered_multiset), f(const std::unordered_multiset&): // the parameter being read-only, either a sequence or a -// previously wrapped std::unordered_multiset can be passed. -// -- f(std::unordered_multiset&), f(std::unordered_multiset*): +// previously wrapped std::unordered_multiset can be passed. +// -- f(std::unordered_multiset&), f(std::unordered_multiset*): // the parameter may be modified; therefore, only a wrapped std::unordered_multiset // can be passed. -// -- std::unordered_multiset f(), const std::unordered_multiset& f(): -// the set is returned by copy; therefore, a sequence of T:s +// -- std::unordered_multiset f(), const std::unordered_multiset& f(): +// the set is returned by copy; therefore, a sequence of Key:s // is returned which is most easily used in other functions -// -- std::unordered_multiset& f(), std::unordered_multiset* f(): +// -- std::unordered_multiset& f(), std::unordered_multiset* f(): // the set is returned by reference; therefore, a wrapped std::unordered_multiset // is returned -// -- const std::unordered_multiset* f(), f(const std::unordered_multiset*): +// -- const std::unordered_multiset* f(), f(const std::unordered_multiset*): // for consistency, they expect and return a plain set pointer. // ------------------------------------------------------------------------ diff --git a/Lib/std/std_unordered_set.i b/Lib/std/std_unordered_set.i index 133246da8..d7fc24a22 100644 --- a/Lib/std/std_unordered_set.i +++ b/Lib/std/std_unordered_set.i @@ -50,19 +50,19 @@ // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // -// -- f(std::unordered_set), f(const std::unordered_set&): +// -- f(std::unordered_set), f(const std::unordered_set&): // the parameter being read-only, either a sequence or a -// previously wrapped std::unordered_set can be passed. -// -- f(std::unordered_set&), f(std::unordered_set*): +// previously wrapped std::unordered_set can be passed. +// -- f(std::unordered_set&), f(std::unordered_set*): // the parameter may be modified; therefore, only a wrapped std::unordered_set // can be passed. -// -- std::unordered_set f(), const std::unordered_set& f(): -// the unordered_set is returned by copy; therefore, a sequence of T:s +// -- std::unordered_set f(), const std::unordered_set& f(): +// the unordered_set is returned by copy; therefore, a sequence of Key:s // is returned which is most easily used in other functions -// -- std::unordered_set& f(), std::unordered_set* f(): +// -- std::unordered_set& f(), std::unordered_set* f(): // the unordered_set is returned by reference; therefore, a wrapped std::unordered_set // is returned -// -- const std::unordered_set* f(), f(const std::unordered_set*): +// -- const std::unordered_set* f(), f(const std::unordered_set*): // for consistency, they expect and return a plain unordered_set pointer. // ------------------------------------------------------------------------ From f3e2ab91950f6b8e4ef387a9a3ea34f44bd3907b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 21:47:45 +0000 Subject: [PATCH 1511/2031] Include all template parameters for std_unordered_multiset and std_unordered_set --- Lib/python/std_unordered_multiset.i | 26 +++++++++++++------------- Lib/python/std_unordered_set.i | 26 +++++++++++++------------- Lib/ruby/std_unordered_multiset.i | 20 ++++++++++---------- Lib/ruby/std_unordered_set.i | 20 ++++++++++---------- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Lib/python/std_unordered_multiset.i b/Lib/python/std_unordered_multiset.i index 4b67c7305..b0f3f096b 100644 --- a/Lib/python/std_unordered_multiset.i +++ b/Lib/python/std_unordered_multiset.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_multiset* seq) { + assign(const SwigPySeq& swigpyseq, std::unordered_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(); @@ -18,24 +18,24 @@ } } - template - struct traits_reserve > { - static void reserve(std::unordered_multiset &seq, typename std::unordered_multiset::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_multiset &seq, typename std::unordered_multiset::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - static int asptr(PyObject *obj, std::unordered_multiset **m) { - return traits_asptr_stdseq >::asptr(obj, m); + template + struct traits_asptr > { + static int asptr(PyObject *obj, std::unordered_multiset **m) { + return traits_asptr_stdseq >::asptr(obj, m); } }; - template - struct traits_from > { - static PyObject *from(const std::unordered_multiset& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static PyObject *from(const std::unordered_multiset& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/python/std_unordered_set.i b/Lib/python/std_unordered_set.i index 9eab62226..79fca6c2f 100644 --- a/Lib/python/std_unordered_set.i +++ b/Lib/python/std_unordered_set.i @@ -5,9 +5,9 @@ %fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::unordered_set* seq) { + assign(const SwigPySeq& swigpyseq, std::unordered_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(); @@ -16,24 +16,24 @@ } } - template - struct traits_reserve > { - static void reserve(std::unordered_set &seq, typename std::unordered_set::size_type n) { + template + struct traits_reserve > { + static void reserve(std::unordered_set &seq, typename std::unordered_set::size_type n) { seq.reserve(n); } }; - template - struct traits_asptr > { - static int asptr(PyObject *obj, std::unordered_set **s) { - return traits_asptr_stdseq >::asptr(obj, s); + template + struct traits_asptr > { + static int asptr(PyObject *obj, std::unordered_set **s) { + return traits_asptr_stdseq >::asptr(obj, s); } }; - template - struct traits_from > { - static PyObject *from(const std::unordered_set& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static PyObject *from(const std::unordered_set& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/ruby/std_unordered_multiset.i b/Lib/ruby/std_unordered_multiset.i index 4bc13790a..dae13eef3 100644 --- a/Lib/ruby/std_unordered_multiset.i +++ b/Lib/ruby/std_unordered_multiset.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits") %{ namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_multiset* seq) { + assign(const RubySeq& rubyseq, std::unordered_multiset* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); @@ -18,17 +18,17 @@ } } - template - struct traits_asptr > { - static int asptr(VALUE obj, std::unordered_multiset **m) { - return traits_asptr_stdseq >::asptr(obj, m); + template + struct traits_asptr > { + static int asptr(VALUE obj, std::unordered_multiset **m) { + return traits_asptr_stdseq >::asptr(obj, m); } }; - template - struct traits_from > { - static VALUE from(const std::unordered_multiset& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static VALUE from(const std::unordered_multiset& vec) { + return traits_from_stdseq >::from(vec); } }; } diff --git a/Lib/ruby/std_unordered_set.i b/Lib/ruby/std_unordered_set.i index 84d3b4b09..e8e1b0872 100644 --- a/Lib/ruby/std_unordered_set.i +++ b/Lib/ruby/std_unordered_set.i @@ -7,9 +7,9 @@ %fragment("StdUnorderedSetTraits","header",fragment="",fragment="StdSetTraits") %{ namespace swig { - template + template inline void - assign(const RubySeq& rubyseq, std::unordered_set* seq) { + assign(const RubySeq& rubyseq, std::unordered_set* seq) { // seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented typedef typename RubySeq::value_type value_type; typename RubySeq::const_iterator it = rubyseq.begin(); @@ -18,17 +18,17 @@ } } - template - struct traits_asptr > { - static int asptr(VALUE obj, std::unordered_set **s) { - return traits_asptr_stdseq >::asptr(obj, s); + template + struct traits_asptr > { + static int asptr(VALUE obj, std::unordered_set **s) { + return traits_asptr_stdseq >::asptr(obj, s); } }; - template - struct traits_from > { - static VALUE from(const std::unordered_set& vec) { - return traits_from_stdseq >::from(vec); + template + struct traits_from > { + static VALUE from(const std::unordered_set& vec) { + return traits_from_stdseq >::from(vec); } }; } From f58a6dade3b0c13626af271d3d054dc6076d8e0d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 21:59:03 +0000 Subject: [PATCH 1512/2031] Add missing hasher and key_type typedefs to C++11 STL containers --- Lib/std/std_unordered_map.i | 2 ++ Lib/std/std_unordered_multimap.i | 2 ++ Lib/std/std_unordered_multiset.i | 7 +++++-- Lib/std/std_unordered_set.i | 8 +++++--- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Lib/std/std_unordered_map.i b/Lib/std/std_unordered_map.i index 723c0232d..1fd1eb980 100644 --- a/Lib/std/std_unordered_map.i +++ b/Lib/std/std_unordered_map.i @@ -75,6 +75,8 @@ namespace std { typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; + typedef _Hash hasher; + typedef _Compare key_equal; typedef _Alloc allocator_type; %traits_swigtype(_Key); diff --git a/Lib/std/std_unordered_multimap.i b/Lib/std/std_unordered_multimap.i index f2855343d..4be6aa492 100644 --- a/Lib/std/std_unordered_multimap.i +++ b/Lib/std/std_unordered_multimap.i @@ -53,6 +53,8 @@ namespace std { typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; + typedef _Hash hasher; + typedef _Compare key_equal; typedef _Alloc allocator_type; %traits_swigtype(_Key); diff --git a/Lib/std/std_unordered_multiset.i b/Lib/std/std_unordered_multiset.i index 8effa586e..2910fb6ff 100644 --- a/Lib/std/std_unordered_multiset.i +++ b/Lib/std/std_unordered_multiset.i @@ -40,9 +40,10 @@ namespace std { //unordered_multiset - template , + template , class _Compare = std::equal_to< _Key >, - class _Alloc = allocator< _Key > > + class _Alloc = allocator< _Key > > class unordered_multiset { public: typedef size_t size_type; @@ -53,6 +54,8 @@ namespace std { typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; + typedef _Hash hasher; + typedef _Compare key_equal; typedef _Alloc allocator_type; %traits_swigtype(_Key); diff --git a/Lib/std/std_unordered_set.i b/Lib/std/std_unordered_set.i index d7fc24a22..91e807423 100644 --- a/Lib/std/std_unordered_set.i +++ b/Lib/std/std_unordered_set.i @@ -74,20 +74,22 @@ namespace std { - template , + template , class _Compare = std::equal_to< _Key >, - class _Alloc = allocator< _Key > > + class _Alloc = allocator< _Key > > class unordered_set { public: typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef _Hash hasher; typedef _Key value_type; typedef _Key key_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; + typedef _Hash hasher; + typedef _Compare key_equal; typedef _Alloc allocator_type; %traits_swigtype(_Key); From d3ae85ee734ec701cea0f67f0ccf3d187199819c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 12 Mar 2019 22:47:11 +0000 Subject: [PATCH 1513/2031] Cosmetic tweaks for C# std::set support --- CHANGES.current | 2 +- Lib/java/std_set.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3765a8273..9e74e767e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,7 +8,7 @@ Version 4.0.0 (in progress) =========================== 2019-03-12: vadz - [C#] Add std::set<> typemaps. + [C#] #1495 Add std_set.i for std::set support. 2019-03-11: dirteat,opoplawski [Octave] Fix compilation errors in Octave 5.1. diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 086d10c8a..04658f765 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -152,8 +152,8 @@ class set { typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef T value_type; typedef T key_type; + typedef T value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; From 1e981dfc238cd255a5dc4ccdabf0803671607d2f Mon Sep 17 00:00:00 2001 From: mochizk Date: Wed, 13 Mar 2019 21:43:21 +0900 Subject: [PATCH 1514/2031] Fix node.js deprecated warnings >= v10.12.0 --- .travis.yml | 6 ---- Lib/javascript/v8/javascripthelpers.swg | 2 +- Lib/javascript/v8/javascriptprimtypes.swg | 14 ++++----- Lib/javascript/v8/javascriptrun.swg | 36 +++++++++++++++++++---- Lib/javascript/v8/javascriptruntime.swg | 2 ++ Lib/javascript/v8/javascriptstrings.swg | 8 ++--- 6 files changed, 45 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index b443ae07a..78d8883b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -377,12 +377,6 @@ matrix: env: SWIGLANG=tcl allow_failures: - # Deprecated functions causing build failure since upgrade from Node v10.11.0 to v10.12.0 - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 - sudo: required - dist: trusty # Sometimes hits the Travis 50 minute time limit - compiler: gcc os: linux diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 7b8a5ec23..80fbd7aa1 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -93,7 +93,7 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local property, v8::Local sproperty; if (property->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocal(&sproperty)) { - sproperty->WriteUtf8(buffer, 256); + SWIGV8_WRITE_UTF8(sproperty, buffer, 256); res = sprintf(msg, "Tried to write read-only variable: %s.", buffer); } else { diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg index c0055c48e..f76be983b 100644 --- a/Lib/javascript/v8/javascriptprimtypes.swg +++ b/Lib/javascript/v8/javascriptprimtypes.swg @@ -22,7 +22,7 @@ int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val) return SWIG_ERROR; } - if (val) *val = obj->BooleanValue(); + if (val) *val = SWIGV8_BOOLEAN_VALUE(obj); return SWIG_OK; } } @@ -44,7 +44,7 @@ int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val) if (!valRef->IsNumber()) { return SWIG_TypeError; } - if(val) *val = valRef->IntegerValue(); + if(val) *val = SWIGV8_INTEGER_VALUE(valRef); return SWIG_OK; } @@ -68,7 +68,7 @@ int SWIG_AsVal_dec(long)(v8::Handle obj, long* val) if (!obj->IsNumber()) { return SWIG_TypeError; } - if(val) *val = (long) obj->IntegerValue(); + if(val) *val = (long) SWIGV8_INTEGER_VALUE(obj); return SWIG_OK; } @@ -95,7 +95,7 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) return SWIG_TypeError; } - long longVal = (long) obj->NumberValue(); + long longVal = (long) SWIGV8_NUMBER_VALUE(obj); if(longVal < 0) { return SWIG_OverflowError; @@ -133,7 +133,7 @@ int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) if (!obj->IsNumber()) { return SWIG_TypeError; } - if(val) *val = (long long) obj->IntegerValue(); + if(val) *val = (long long) SWIGV8_INTEGER_VALUE(obj); return SWIG_OK; } @@ -168,7 +168,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long return SWIG_TypeError; } - long long longVal = (long long) obj->NumberValue(); + long long longVal = (long long) SWIGV8_NUMBER_VALUE(obj); if(longVal < 0) { return SWIG_OverflowError; @@ -198,7 +198,7 @@ int SWIG_AsVal_dec(double)(v8::Handle obj, double *val) if(!obj->IsNumber()) { return SWIG_TypeError; } - if(val) *val = obj->NumberValue(); + if(val) *val = SWIGV8_NUMBER_VALUE(obj); return SWIG_OK; } diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 84bd4cc67..2452f4040 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -91,6 +91,32 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class); #endif +#ifdef NODE_VERSION +#if NODE_VERSION_AT_LEAST(10, 12, 0) +#define SWIG_NODE_AT_LEAST_1012 +#endif +#endif + +//Necessary to check Node.js version because V8 API changes are backported in Node.js +#if (defined(NODE_VERSION) && !defined(SWIG_NODE_AT_LEAST_1012)) || \ + (!defined(NODE_VERSION) && (V8_MAJOR_VERSION-0) < 7) +#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject() +#define SWIGV8_TO_STRING(handle) (handle)->ToString() +#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue() +#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue() +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue() +#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len) +#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length() +#else +#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len) +#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) +#endif + /* --------------------------------------------------------------------------- * Error handling * @@ -258,7 +284,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle valRef, void **ptr) if(!valRef->IsObject()) { return SWIG_TypeError; } - v8::Handle objRef = valRef->ToObject(); + v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; @@ -352,7 +378,7 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle valRef, void **ptr, swi if(!valRef->IsObject()) { return SWIG_TypeError; } - v8::Handle objRef = valRef->ToObject(); + v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags); } @@ -479,7 +505,7 @@ SWIGRUNTIMEINLINE int SwigV8Packed_Check(v8::Handle valRef) { SWIGV8_HANDLESCOPE(); - v8::Handle objRef = valRef->ToObject(); + v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); if(objRef->InternalFieldCount() < 1) return false; #if (V8_MAJOR_VERSION-0) < 5 v8::Handle flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__")); @@ -489,7 +515,7 @@ int SwigV8Packed_Check(v8::Handle valRef) { if (!objRef->GetPrivate(SWIGV8_CURRENT_CONTEXT(), privateKey).ToLocal(&flag)) return false; #endif - return (flag->IsBoolean() && flag->BooleanValue()); + return (flag->IsBoolean() && SWIGV8_BOOLEAN_VALUE(flag)); } SWIGRUNTIME @@ -499,7 +525,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, SwigV8PackedData *sobj; - v8::Handle objRef = valRef->ToObject(); + v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); diff --git a/Lib/javascript/v8/javascriptruntime.swg b/Lib/javascript/v8/javascriptruntime.swg index 0e4059326..c78e04efb 100644 --- a/Lib/javascript/v8/javascriptruntime.swg +++ b/Lib/javascript/v8/javascriptruntime.swg @@ -44,6 +44,8 @@ #ifdef BUILDING_NODE_EXTENSION %insert("runtime") %{ #include +//Older version of node.h does not include this +#include %} #endif diff --git a/Lib/javascript/v8/javascriptstrings.swg b/Lib/javascript/v8/javascriptstrings.swg index 65ba20e5a..e767a6d66 100644 --- a/Lib/javascript/v8/javascriptstrings.swg +++ b/Lib/javascript/v8/javascriptstrings.swg @@ -7,11 +7,11 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, int *alloc) { if(valRef->IsString()) { - v8::Handle js_str = valRef->ToString(); + v8::Handle js_str = SWIGV8_TO_STRING(valRef); - size_t len = js_str->Utf8Length() + 1; + size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1; char* cstr = new char[len]; - js_str->WriteUtf8(cstr, len); + SWIGV8_WRITE_UTF8(js_str, cstr, len); if(alloc) *alloc = SWIG_NEWOBJ; if(psize) *psize = len; @@ -20,7 +20,7 @@ SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, return SWIG_OK; } else { if(valRef->IsObject()) { - v8::Handle obj = valRef->ToObject(); + v8::Handle obj = SWIGV8_TO_OBJECT(valRef); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { From 39d67aea8ea07bcd2744ff74e9fc82218561cd15 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 14 Mar 2019 20:32:42 +0000 Subject: [PATCH 1515/2031] Add changes entry for Node V8 api changes --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9e74e767e..3983829de 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-14: mochizk + [Javascript] #1500 Fix compilation errors due to deprecating V8 API in Node.js. + New V8 API is used if node.js >= v10.12, or if V8 >= v7.0. + 2019-03-12: vadz [C#] #1495 Add std_set.i for std::set support. From e60670ec45d64e2aac922c5e52b826204064e6f7 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Mon, 18 Mar 2019 21:33:25 +1100 Subject: [PATCH 1516/2031] extra doc on anonymous enums --- Doc/Manual/R.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 9fa27274b..9ca39c99f 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -227,7 +227,9 @@ and integers. The relevant functions, for debugging purposes, are enumToInteger and
    enumFromInteger. -Anonymous enumerations are not supported. +Anonymous enumerations are ignored by the binding generation process, +leaving no way of accessing the value of anonymous enumerations from R +code.

    From f5b53683f09aba885af2a48afdda073b3024219a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 15 Mar 2019 07:51:45 +0000 Subject: [PATCH 1517/2031] Remove unused code in r.cxx --- Source/Modules/r.cxx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index fde583ed6..bb43dad48 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -226,18 +226,6 @@ static void replaceRClass(String *tm, SwigType *type) { Delete(tmp); Delete(tmp_base); Delete(tmp_ref); } -static bool getNumber(String *value, int* result) { - if(Char(value)) { - // Check the conversion processed the whole of value by having %c at - // the end of the format, and checking that only the first value is - // converted. We don't want to convert "3+7" -> 3. - char dummy; - if (sscanf(Char(value), "%i%c", result, &dummy) == 1) - return true; - } - return false; -} - class R : public Language { public: R(); From 39e3c3b9d774a483fbec8f0fcf6c136833a79bf8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Mar 2019 17:49:24 +0000 Subject: [PATCH 1518/2031] Fix R return by C++11 const ref enum classes --- Lib/r/r.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/r/r.swg b/Lib/r/r.swg index e6153892e..8cf8cdf53 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -196,7 +196,7 @@ unsigned char *OUTPUT %{ temp = ($*1_ltype)INTEGER($input)[0]; $1 = &temp; %} -%typemap(out) const enum SWIGTYPE & %{ $result = Rf_ScalarInteger(*$1); %} +%typemap(out) const enum SWIGTYPE & %{ $result = Rf_ScalarInteger((int)*$1); %} %typemap(memberin) char[] %{ if ($input) strcpy($1, $input); From b2365f119e91eae698c29f3b8212510a40b9bb68 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 18 Mar 2019 18:10:20 +0000 Subject: [PATCH 1519/2031] Add changes entry for R enum fixes --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 3983829de..5022e3097 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-18: richardbeare + [R] #1328 Non-trivial enums are working now. The enum values are now obtained from + the C/C++ layer. const reference enums and C++11 enum classes are also now working. + 2019-03-14: mochizk [Javascript] #1500 Fix compilation errors due to deprecating V8 API in Node.js. New V8 API is used if node.js >= v10.12, or if V8 >= v7.0. From 1fa2d85dc0a02dbe88241f35923fe0ff998772f3 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 19 Mar 2019 16:23:56 -0600 Subject: [PATCH 1520/2031] [OCaml] Fix race conds when running the examples with parallel make Race conditions could occur when running the examples with parallel make. --- Examples/ocaml/shapes/Makefile | 2 +- Examples/ocaml/string_from_ptr/Makefile | 2 +- Examples/ocaml/strings_test/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index bc269d6d0..a9932793b 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -20,7 +20,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static_cpp -toplevel: +toplevel: static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 0d3163e36..6917e4638 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -19,7 +19,7 @@ static: PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \ ocaml_static -toplevel: +toplevel: static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index bed86841b..9474f5364 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -23,7 +23,7 @@ dynamic: PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ ocaml_static_cpp -toplevel: +toplevel: static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ From 2bb5eeef91c5d08ba5b631648015ab776620561e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Mar 2019 21:10:28 +0000 Subject: [PATCH 1521/2031] Improve Python static member variable testing Double check the values are being set in the C++ layer via a function call to C++ layer. --- Examples/test-suite/cpp_static.i | 3 +++ Examples/test-suite/python/cpp_static_runme.py | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Examples/test-suite/cpp_static.i b/Examples/test-suite/cpp_static.i index 1f8ca1282..9ffe55837 100644 --- a/Examples/test-suite/cpp_static.i +++ b/Examples/test-suite/cpp_static.i @@ -10,6 +10,7 @@ Tests Sourceforge bug #444748. class StaticMemberTest { public: static int static_int; + static int grab_int() { return static_int; } }; class StaticFunctionTest { @@ -28,10 +29,12 @@ int StaticMemberTest::static_int = 99; %inline %{ struct StaticBase { static int statty; + static int grab_statty_base() { return statty; } virtual ~StaticBase() {} }; struct StaticDerived : StaticBase { static int statty; + static int grab_statty_derived() { return statty; } }; %} diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py index e8c8cf615..760fb6791 100644 --- a/Examples/test-suite/python/cpp_static_runme.py +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -8,15 +8,21 @@ StaticFunctionTest.static_func_3(1, 2) if is_python_builtin(): if not StaticMemberTest.static_int == 99: raise RuntimeError("static_int not 99") + if not StaticMemberTest.grab_int() == 99: raise RuntimeError("static_int not 99") StaticMemberTest.static_int = 10 if not StaticMemberTest.static_int == 10: raise RuntimeError("static_int not 10") + if not StaticMemberTest.grab_int() == 10: raise RuntimeError("static_int not 10") if not StaticBase.statty == 11: raise RuntimeError("statty not 11") + if not StaticBase.grab_statty_base() == 11: raise RuntimeError("statty not 11") if not StaticDerived.statty == 111: raise RuntimeError("statty not 111") + if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("statty not 111") StaticBase.statty = 22 StaticDerived.statty = 222 if not StaticBase.statty == 22: raise RuntimeError("statty not 22") + if not StaticBase.grab_statty_base() == 22: raise RuntimeError("statty not 22") if not StaticDerived.statty == 222: raise RuntimeError("statty not 222") + if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("statty not 222") # Restore StaticMemberTest.static_int = 99 @@ -24,12 +30,18 @@ if is_python_builtin(): StaticDerived.statty = 111 if not cvar.StaticMemberTest_static_int == 99: raise RuntimeError("cvar static_int not 99") +if not StaticMemberTest.grab_int() == 99: raise RuntimeError("cvar static_int not 99") cvar.StaticMemberTest_static_int = 10 if not cvar.StaticMemberTest_static_int == 10: raise RuntimeError("cvar static_int not 10") +if not StaticMemberTest.grab_int() == 10: raise RuntimeError("cvar static_int not 10") if not cvar.StaticBase_statty == 11: raise RuntimeError("cvar statty not 11") +if not StaticBase.grab_statty_base() == 11: raise RuntimeError("cvar statty not 11") if not cvar.StaticDerived_statty == 111: raise RuntimeError("cvar statty not 111") +if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("cvar statty not 111") cvar.StaticBase_statty = 22 cvar.StaticDerived_statty = 222 if not cvar.StaticBase_statty == 22: raise RuntimeError("cvar statty not 22") +if not StaticBase.grab_statty_base() == 22: raise RuntimeError("cvar statty not 22") if not cvar.StaticDerived_statty == 222: raise RuntimeError("cvar statty not 222") +if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("cvar statty not 222") From 826f1448b838bc3efadf2f1cc93e614426e104dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Mar 2019 21:44:34 +0000 Subject: [PATCH 1522/2031] Fix Python low-level static member setters. The low-level API for setting static member variables stopped working when the fastunpack option was turned on by default. The PyMethodDef setup requires METH_O, not METH_VARARGS with fastunpack. --- .../test-suite/python/cpp_static_runme.py | 25 +++++++++++++++++++ Source/Modules/python.cxx | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py index 760fb6791..cd7398fbb 100644 --- a/Examples/test-suite/python/cpp_static_runme.py +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -45,3 +45,28 @@ if not cvar.StaticBase_statty == 22: raise RuntimeError("cvar statty not 22") if not StaticBase.grab_statty_base() == 22: raise RuntimeError("cvar statty not 22") if not cvar.StaticDerived_statty == 222: raise RuntimeError("cvar statty not 222") if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("cvar statty not 222") + +# Restore +cvar.StaticMemberTest_static_int = 99 +cvar.StaticBase_statty = 11 +cvar.StaticDerived_statty = 111 + +# Low-level layer testing +if not is_python_builtin(): + from cpp_static import _cpp_static + if not _cpp_static.StaticMemberTest_static_int_get() == 99: raise RuntimeError("low-level static_int not 99") + if not StaticMemberTest.grab_int() == 99: raise RuntimeError("low-level static_int not 99") + _cpp_static.StaticMemberTest_static_int_set(10) + if not _cpp_static.StaticMemberTest_static_int_get() == 10: raise RuntimeError("low-level static_int not 10") + if not StaticMemberTest.grab_int() == 10: raise RuntimeError("low-level static_int not 10") + + if not _cpp_static.StaticBase_statty_get() == 11: raise RuntimeError("low-level statty not 11") + if not StaticBase.grab_statty_base() == 11: raise RuntimeError("low-level statty not 11") + if not _cpp_static.StaticDerived_statty_get() == 111: raise RuntimeError("low-level statty not 111") + if not StaticDerived.grab_statty_derived() == 111: raise RuntimeError("low-level statty not 111") + _cpp_static.StaticBase_statty_set(22) + _cpp_static.StaticDerived_statty_set(222) + if not _cpp_static.StaticBase_statty_get() == 22: raise RuntimeError("low-level statty not 22") + if not StaticBase.grab_statty_base() == 22: raise RuntimeError("low-level statty not 22") + if not _cpp_static.StaticDerived_statty_get() == 222: raise RuntimeError("low-level statty not 222") + if not StaticDerived.grab_statty_derived() == 222: raise RuntimeError("low-level statty not 222") diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 21392cc2e..7c9603a3d 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2426,7 +2426,7 @@ public: void add_method(String *name, String *function, int kw, Node *n = 0, int funpack = 0, int num_required = -1, int num_arguments = -1) { String * meth_str = NewString(""); if (!kw) { - if (n && funpack) { + if (funpack) { if (num_required == 0 && num_arguments == 0) { Printf(meth_str, "\t { \"%s\", %s, METH_NOARGS, ", name, function); } else if (num_required == 1 && num_arguments == 1) { From 9f0b9da024696c19573f0566adceea277e36f0cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Mar 2019 20:59:54 +0000 Subject: [PATCH 1523/2031] Always use fastunpack for Python swigregister function --- Source/Modules/python.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 7c9603a3d..9eb233e9e 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4510,16 +4510,12 @@ public: } else { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); Printv(f_wrappers, " PyObject *obj;\n", NIL); - if (fastunpack) { - Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args, \"swigregister\", 1, 1, &obj)) return NULL;\n", NIL); - } else { - Printv(f_wrappers, " if (!PyArg_UnpackTuple(args, \"swigregister\", 1, 1, &obj)) return NULL;\n", NIL); - } + Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args, \"swigregister\", 1, 1, &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); String *cname = NewStringf("%s_swigregister", class_name); - add_method(cname, cname, 0); + add_method(cname, cname, 0, 0, 1, 1, 1); Delete(cname); } Delete(smart); From 39599f2112004dc1aff1df8d1ff15ededbecdb4c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 21 Mar 2019 21:17:21 +0000 Subject: [PATCH 1524/2031] Always use fastunpack for Python swigconstant wrappers --- Source/Modules/python.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9eb233e9e..b8493352c 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3592,11 +3592,7 @@ public: Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname); Printf(f_wrappers, tab2 "PyObject *module;\n", tm); Printf(f_wrappers, tab2 "PyObject *d;\n"); - if (fastunpack) { - Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); - } else { - Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); - } + Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args, \"swigconstant\", 1, 1, &module)) return NULL;\n"); Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n"); Printf(f_wrappers, tab2 "if (!d) return NULL;\n"); Printf(f_wrappers, tab2 "%s\n", tm); @@ -3605,7 +3601,7 @@ public: // Register the method in SwigMethods array String *cname = NewStringf("%s_swigconstant", iname); - add_method(cname, cname, 0); + add_method(cname, cname, 0, 0, 1, 1, 1); Delete(cname); } else { Printf(f_init, "%s\n", tm); From e7f9316e6037c97d005abd97cf7d12bb2582ccc4 Mon Sep 17 00:00:00 2001 From: Adrien JUND Date: Sat, 4 Nov 2017 16:09:33 +0100 Subject: [PATCH 1525/2031] C# - add std::list --- Examples/test-suite/csharp/Makefile.in | 3 +- .../test-suite/csharp/li_std_list_runme.cs | 402 +++++++++++++++ Examples/test-suite/li_std_list.i | 21 +- Lib/csharp/std_list.i | 483 ++++++++++++++++++ 4 files changed, 904 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/csharp/li_std_list_runme.cs create mode 100644 Lib/csharp/std_list.i diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index a4ae7131d..c9e48f804 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -26,7 +26,8 @@ CPP_TEST_CASES = \ enum_thorough_typesafe \ exception_partial_info \ intermediary_classname \ - li_boost_intrusive_ptr + li_boost_intrusive_ptr \ + li_std_list \ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ diff --git a/Examples/test-suite/csharp/li_std_list_runme.cs b/Examples/test-suite/csharp/li_std_list_runme.cs new file mode 100644 index 000000000..fdcd0d9ac --- /dev/null +++ b/Examples/test-suite/csharp/li_std_list_runme.cs @@ -0,0 +1,402 @@ +using System; +using li_std_listNamespace; + +public class li_std_list_runme { + private static readonly int collectionSize = 20; + + public static void Main() { + // Setup a list of int + IntList list = new IntList(); + IntList.IntListNode node; + + for (int i = 0; i < 20; i++) { + int nb = i * 10; + list.Add(nb); + } + + // Count property test + if (list.Count != collectionSize) + throw new Exception("Count test failed"); + + // IsReadOnly property test + if (list.IsReadOnly) + throw new Exception("IsReadOnly test failed"); + + // Contains method test + if (!list.Contains(0)) + throw new Exception("Contains method test 1 failed"); + if (!list.Contains(2 * 10)) + throw new Exception("Contains method test 2 failed"); + if (!list.Contains(19 * 10)) + throw new Exception("Contains method test 3 failed"); + if (list.Contains(20 * 10)) + throw new Exception("Contains method test 4 failed"); + + // Nodes comparison method overload + { + IntList.IntListNode temp = new IntList.IntListNode(3); + if (list.First == temp) + throw new Exception("== overload method test (1) failed"); + temp = new IntList.IntListNode(0); + if (list.First == temp) + throw new Exception("== overload method test (2) failed"); + IntList.IntListNode temp2 = new IntList.IntListNode(0); + if (temp == temp2) + throw new Exception("== overload method test (3) failed"); + if (!(list.First == list.First)) + throw new Exception("== overload method test (4) failed"); + if (list.First != list.First) + throw new Exception("!= overload method test (1) failed"); + if (!(temp != temp2)) + throw new Exception("!= overload method test (2) failed"); + if (list.First.Equals(temp)) + throw new Exception("Equals method test failed"); + if (list.First.GetHashCode() == temp.GetHashCode()) + throw new Exception("GetHashCode method test (1) failed"); + if (list.First.GetHashCode() == list.First.GetHashCode()) + throw new Exception("GetHashCode method test (2) failed"); + + } + + // Getter test + { + if (list.First == null) + throw new Exception("First getter test (1) failed"); + if (list.Last == null) + throw new Exception("Last getter test (1) failed"); + if (list.Last.Next != null) + throw new Exception("Next getter test (1) failed"); + if (list.First.Next == null) + throw new Exception("Next getter test (2) failed"); + if (list.First.Previous != null) + throw new Exception("Previous getter test (1) failed"); + if (list.Last.Previous == null) + throw new Exception("Previous getter test (2) failed"); + } + + // AddFirst method test + node = list.AddFirst(34); + if (list.First.Value != 34 || node.Value != 34 || node != list.First) + throw new Exception("AddFirst method test failed"); + try { + list.AddFirst(null); + } catch (ArgumentNullException) { + try { + list.AddFirst(list.First); + } catch (InvalidOperationException) { + } + } + + // RemoveFirst method test + int tmp = list.First.Value; + list.RemoveFirst(); + if (list.First.Value == tmp || list.First.Value != 0 * 10) + throw new Exception("RemoveFirst method test failed"); + + // AddLast method test + node = list.AddLast(8); + if (list.Last.Value != 8 || node.Value != 8 || node != list.Last) + throw new Exception("AddLast method test failed"); + try { + list.AddLast(null); + } catch (ArgumentNullException) { + try { + list.AddLast(list.First); + } catch (InvalidOperationException) { + } + } + + // RemoveLast method test + int tmp2 = list.Last.Value; + list.RemoveLast(); + if (list.Last.Value == tmp2 || list.Last.Value != (list.Count - 1) * 10) + throw new Exception("RemoveLast method test failed"); + + // AddBefore method test + node = list.AddBefore(list.Last, 17); + if (list.Last.Previous.Value != 17 || node.Value != 17 || node != list.Last.Previous) + throw new Exception("AddBefore method test (1) failed"); + try { + node = null; + list.AddBefore(list.Last, node); + throw new Exception("AddBefore method test (2) failed"); + } catch (ArgumentNullException) { + try { + node = new IntList.IntListNode(1); + list.AddBefore(null, node); + throw new Exception("AddBefore method test (3) failed"); + } catch (ArgumentNullException) { + try { + list.AddBefore(list.Last, list.First); + } catch (InvalidOperationException) { + } + } + } + + // AddAfter method test + node = list.AddAfter(list.First, 47); + if (list.First.Next.Value != 47 || node.Value != 47 || node != list.First.Next) + throw new Exception("AddAfter method test (1) failed"); + try { + node = null; + list.AddAfter(list.First.Next, node); + throw new Exception("AddAfter method test (2) failed"); + } catch (ArgumentNullException) { + try { + list.AddAfter(list.First, list.Last); + } catch (InvalidOperationException) { + } + } + + // Find method test + node = list.Find(0); + if (node == null || node.Value != 0) + throw new Exception("Find method test (1) failed"); + node = list.Find(47); + if (node == null || node.Value != 47) + throw new Exception("Find method test (2) failed"); + node = list.Find(190); + if (node == null || node.Value != 190) + throw new Exception("Find method test (3) failed"); + node = list.Find(-3); + if (node != null) + throw new Exception("Find method test (4) failed"); + + // Remove method test + if (!list.Remove(17) || list.Contains(17) || list.Last.Previous.Value == 17) + throw new Exception("Remove method test (1) failed"); + if (!list.Remove(47) || list.Contains(47) || list.First.Next.Value == 47) + throw new Exception("Remove method test (2) failed"); + if (!list.Remove(0) || list.Contains(0) || list.First.Value == 0) + throw new Exception("Remove method test (3) failed"); + if (!list.Remove(190) || list.Contains(190) || list.Last.Value == 190) + throw new Exception("Remove method test (4) failed"); + try { + node = null; + list.Remove(node); + throw new Exception("Remove method test (5) failed"); + } catch (ArgumentNullException) { + try { + node = new IntList.IntListNode(4); + list.Remove(node); + throw new Exception("Remove method test (5) failed"); + } catch (InvalidOperationException) { + } + } + + // ICollection constructor test + { + int[] intArray = new int[] { 0, 11, 22, 33, 44, 55, 33 }; + IntList il = new IntList(intArray); + if (intArray.Length != il.Count) + throw new Exception("ICollection constructor length check failed: " + intArray.Length + "-" + il.Count); + node = il.First; + for (int i = 0; i < intArray.Length; i++) { + if (intArray[i] != node.Value) + throw new Exception("ICollection constructor failed, index:" + i); + node = node.Next; + } + try { + new IntList((System.Collections.ICollection)null); + throw new Exception("ICollection constructor null test failed"); + } catch (ArgumentNullException) { + } + } + + // Enumerator test + { + node = list.First; + System.Collections.IEnumerator myEnumerator = list.GetEnumerator(); + while (myEnumerator.MoveNext()) { + if ((int)myEnumerator.Current != node.Value) + throw new Exception("Enumerator (1) test failed"); + node = node.Next; + } + } + { + node = list.First; + System.Collections.Generic.IEnumerator myEnumerator = list.GetEnumerator(); + while (myEnumerator.MoveNext()) { + if (myEnumerator.Current != node.Value) + throw new Exception("Enumerator (2) test failed"); + node = node.Next; + } + } + { + node = list.First; + IntList.IntListEnumerator myEnumerator = list.GetEnumerator(); + while (myEnumerator.MoveNext()) { + if (myEnumerator.Current != node.Value) + throw new Exception("Enumerator (3) test failed"); + node = node.Next; + } + } + { + node = list.First; + foreach (var elem in list) { + if (elem != node.Value) + throw new Exception("Enumerator (4) test failed"); + node = node.Next; + } + } + + // CopyTo method test + { + int[] outputarray = new int[collectionSize - 2]; + list.CopyTo(outputarray, 0); + int index = 0; + IntList.IntListNode temp = list.First; + foreach (int val in outputarray) { + if (temp.Value != val) { + throw new Exception("CopyTo method test (1) failed, index:" + index); + } + index++; + temp = temp.Next; + } + } + { + DoubleList inputlist = new DoubleList(); + int arrayLen = 10; + for (int i = 0; i < arrayLen; i++) { + double num = i * 10.1; + inputlist.Add(num); + } + double[] outputarray = new double[arrayLen]; + inputlist.CopyTo(outputarray, 0); + DoubleList.DoubleListNode temp = inputlist.First; + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i] != temp.Value) + throw new Exception("CopyTo method test (2) failed, index:" + i); + temp = temp.Next; + } + } + { + StructList inputlist = new StructList(); + int arrayLen = 10; + for (int i = 0; i < arrayLen; i++) + inputlist.Add(new Struct(i / 10.0)); + Struct[] outputarray = new Struct[arrayLen]; + inputlist.CopyTo(outputarray, 0); + StructList.StructListNode temp = inputlist.First; + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != temp.Value.num) + throw new Exception("CopyTo method test (3) failed, index:" + i); + temp = temp.Next; + } + foreach (Struct s in inputlist) { + s.num += 20.0; + } + temp = inputlist.First; + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != temp.Value.num) + throw new Exception("CopyTo method test (4) failed, index:" + i); + temp = temp.Next; + } + } + try { + list.CopyTo(null, 0); + throw new Exception("CopyTo method test (5) failed"); + } catch (ArgumentNullException) { + } + + // Clear() test + list.Clear(); + if (list.Count != 0) + throw new Exception("Clear method failed"); + + // Finally test the methods being wrapped + { + IntList il = new IntList(); + for (int i = 0; i < 4; i++) { + il.Add(i); + } + + double x = li_std_list.average(il); + x += li_std_list.average(new IntList(new int[] { 1, 2, 3, 4 })); + + DoubleList dlist = new DoubleList(); + for (int i = 0; i < 10; i++) { + dlist.Add(i / 2.0); + } + li_std_list.halve_in_place(dlist); + } + + // Dispose() + { + using (StructList ls = new StructList(new Struct[] { new Struct(0.0), new Struct(11.1) })) + using (DoubleList ld = new DoubleList(new double[] { 0.0, 11.1 })) { } + } + + // More wrapped methods + { + FloatList l0 = li_std_list.listreal(new FloatList()); + float flo = 123.456f; + l0.Add(flo); + flo = l0.First.Value; + + IntList l1 = li_std_list.listint(new IntList()); + IntPtrList l2 = li_std_list.listintptr(new IntPtrList()); + IntConstPtrList l3 = li_std_list.listintconstptr(new IntConstPtrList()); + + l1.Add(123); + l2.Clear(); + l3.Clear(); + + StructList l4 = li_std_list.liststruct(new StructList()); + StructPtrList l5 = li_std_list.liststructptr(new StructPtrList()); + StructConstPtrList l6 = li_std_list.liststructconstptr(new StructConstPtrList()); + + l4.Add(new Struct(123)); + l5.Add(new Struct(123)); + l6.Add(new Struct(123)); + } + + // Test lists of pointers + { + StructPtrList inputlist = new StructPtrList(); + int arrayLen = 10; + for (int i = 0; i < arrayLen; i++) { + inputlist.Add(new Struct(i / 10.0)); + } + Struct[] outputarray = new Struct[arrayLen]; + inputlist.CopyTo(outputarray, 0); + StructPtrList.StructPtrListNode temp = inputlist.First; + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != temp.Value.num) + throw new Exception("StructPtrList test (1) failed, i:" + i); + temp = temp.Next; + } + foreach (Struct s in inputlist) { + s.num += 20.0; + } + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != 20.0 + i / 10.0) + throw new Exception("StructPtrList test (2) failed (a deep copy was incorrectly made), i:" + i); + } + } + + // Test lists of const pointers + { + StructConstPtrList inputlist = new StructConstPtrList(); + int arrayLen = 10; + for (int i = 0; i < arrayLen; i++) { + inputlist.Add(new Struct(i / 10.0)); + } + Struct[] outputarray = new Struct[arrayLen]; + inputlist.CopyTo(outputarray, 0); + StructConstPtrList.StructConstPtrListNode temp = inputlist.First; + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != temp.Value.num) + throw new Exception("StructConstPtrList test (1) failed, i:" + i); + temp = temp.Next; + } + foreach (Struct s in inputlist) { + s.num += 20.0; + } + for (int i = 0; i < arrayLen; i++) { + if (outputarray[i].num != 20.0 + i / 10.0) + throw new Exception("StructConstPtrList test (2) failed (a deep copy was incorrectly made), i:" + i); + } + } + } +} \ No newline at end of file diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i index d1ec4e7e4..6a60f032c 100644 --- a/Examples/test-suite/li_std_list.i +++ b/Examples/test-suite/li_std_list.i @@ -38,13 +38,23 @@ struct Struct { double num; Struct() : num(0.0) {} Struct(double d) : num(d) {} -// bool operator==(const Struct &other) { return (num == other.num); } + bool operator==(const Struct &other) { return (num == other.num); } }; const std::list & CopyContainerStruct(const std::list & container) { return container; } const std::list & CopyContainerStructPtr(const std::list & container) { return container; } const std::list & CopyContainerStructConstPtr(const std::list & container) { return container; } +const std::list & listreal(const std::list & list) { return list; } + +const std::list & listint(const std::list & list) { return list; } +const std::list & listintptr(const std::list & list) { return list; } +const std::list & listintconstptr(const std::list & list) { return list; } + +const std::list & liststruct(const std::list & list) { return list; } +const std::list & liststructptr(const std::list & list) { return list; } +const std::list & liststructconstptr(const std::list & list) { return list; } + enum Fruit { APPLE, BANANNA, @@ -53,8 +63,11 @@ enum Fruit { }; %} +#if !defined(SWIGR) +%template(IntPtrList) std::list; +%template(IntConstPtrList) std::list; +#endif %template(StructList) std::list; -%template(StructPtrList) std::list; +%template(StructPtrList) std::list; %template(StructConstPtrList) std::list; - -%template(FruitList) std::list; +%template(FruitList) std::list; \ No newline at end of file diff --git a/Lib/csharp/std_list.i b/Lib/csharp/std_list.i new file mode 100644 index 000000000..6194f94ea --- /dev/null +++ b/Lib/csharp/std_list.i @@ -0,0 +1,483 @@ +/* ----------------------------------------------------------------------------- + * std_list.i + * + * SWIG typemaps for std::list + * C# implementation + * The C# wrapper is made to look and feel like a C# System.Collections.Generic.LinkedList<> collection. + * + * ----------------------------------------------------------------------------- */ + +%include +%define SWIG_STD_LIST_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...) +%typemap(csinterfaces) std::list< CTYPE > "global::System.Collections.Generic.ICollection<$typemap(cstype, CTYPE)>, global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>, global::System.Collections.IEnumerable, global::System.IDisposable" +%proxycode %{ + public $csclassname(global::System.Collections.IEnumerable c) : this() { + if (c == null) + throw new global::System.ArgumentNullException("c"); + foreach ($typemap(cstype, CTYPE) element in c) { + this.AddLast(element); + } + } + + public bool IsReadOnly { + get { + return false; + } + } + + public int Count { + get { + return (int)size(); + } + } + + public $csclassnameNode First { + get { + if (Count == 0) + return null; + return new $csclassnameNode(getFirstIter(), this); + } + } + + public $csclassnameNode Last { + get { + if (Count == 0) + return null; + return new $csclassnameNode(getLastIter(), this); + } + } + + public $csclassnameNode AddFirst($typemap(cstype, CTYPE) value) { + push_front(value); + return new $csclassnameNode(getFirstIter(), this); + } + + public void AddFirst($csclassnameNode newNode) { + ValidateNewNode(newNode); + if (!newNode.inlist) { + push_front(newNode.csharpvalue); + newNode.iter = getFirstIter(); + newNode.inlist = true; + } else { + throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name); + } + } + + public $csclassnameNode AddLast($typemap(cstype, CTYPE) value) { + push_back(value); + return new $csclassnameNode(getLastIter(), this); + } + + public void AddLast($csclassnameNode newNode) { + ValidateNewNode(newNode); + if (!newNode.inlist) { + push_back(newNode.csharpvalue); + newNode.iter = getLastIter(); + newNode.inlist = true; + } else { + throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name); + } + } + + public $csclassnameNode AddBefore($csclassnameNode node, $typemap(cstype, CTYPE) value) { + return new $csclassnameNode(insertNode(node.iter, value), this); + } + + public void AddBefore($csclassnameNode node, $csclassnameNode newNode) { + ValidateNode(node); + ValidateNewNode(newNode); + if (!newNode.inlist) { + newNode.iter = insertNode(node.iter, newNode.csharpvalue); + newNode.inlist = true; + } else { + throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name); + } + } + + public $csclassnameNode AddAfter($csclassnameNode node, $typemap(cstype, CTYPE) value) { + node = node.Next; + return new $csclassnameNode(insertNode(node.iter, value), this); + } + + public void AddAfter($csclassnameNode node, $csclassnameNode newNode) { + ValidateNode(node); + ValidateNewNode(newNode); + if (!newNode.inlist) { + if (node == this.Last) + AddLast(newNode); + else + { + node = node.Next; + newNode.iter = insertNode(node.iter, newNode.csharpvalue); + newNode.inlist = true; + } + } else { + throw new global::System.InvalidOperationException("The " + newNode.GetType().Name + " node already belongs to a " + this.GetType().Name); + } + } + + public void Add($typemap(cstype, CTYPE) value) { + AddLast(value); + } + + public bool Remove($typemap(cstype, CTYPE) value) { + var node = Find(value); + if (node == null) + return false; + Remove(node); + return true; + } + + public void Remove($csclassnameNode node) { + ValidateNode(node); + eraseIter(node.iter); + } + + public $csclassnameNode Find($typemap(cstype, CTYPE) value) { + System.IntPtr tmp = find(value); + if (tmp != System.IntPtr.Zero) { + return new $csclassnameNode(tmp, this); + } + return null; + } + + public void CopyTo($typemap(cstype, CTYPE)[] array, int index) { + if (array == null) + throw new global::System.ArgumentNullException("array"); + if (index < 0 || index > array.Length) + throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero"); + if (array.Rank > 1) + throw new global::System.ArgumentException("Multi dimensional array.", "array"); + $csclassnameNode node = this.First; + if (node != null) { + do { + array[index++] = node.Value; + node = node.Next; + } while (node != null); + } + } + + internal void ValidateNode($csclassnameNode node) { + if (node == null) { + throw new System.ArgumentNullException("node"); + } + if (!node.inlist || node.list != this) { + throw new System.InvalidOperationException("node"); + } + } + + internal void ValidateNewNode($csclassnameNode node) { + if (node == null) { + throw new System.ArgumentNullException("node"); + } + } + + global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + public $csclassnameEnumerator GetEnumerator() { + return new $csclassnameEnumerator(this); + } + + public sealed class $csclassnameEnumerator : global::System.Collections.IEnumerator, + global::System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> + { + private $csclassname collectionRef; + private $csclassnameNode currentNode; + private int currentIndex; + private object currentObject; + private int currentSize; + + public $csclassnameEnumerator($csclassname collection) { + collectionRef = collection; + currentNode = collection.First; + currentIndex = 0; + currentObject = null; + currentSize = collectionRef.Count; + } + + // Type-safe iterator Current + public $typemap(cstype, CTYPE) Current { + get { + if (currentIndex == -1) + throw new global::System.InvalidOperationException("Enumeration not started."); + if (currentIndex > currentSize) + throw new global::System.InvalidOperationException("Enumeration finished."); + if (currentObject == null) + throw new global::System.InvalidOperationException("Collection modified."); + return ($typemap(cstype, CTYPE))currentObject; + } + } + + // Type-unsafe IEnumerator.Current + object global::System.Collections.IEnumerator.Current { + get { + return Current; + } + } + + public bool MoveNext() { + if (currentNode == null) { + currentIndex = collectionRef.Count + 1; + return false; + } + ++currentIndex; + currentObject = currentNode.Value; + currentNode = currentNode.Next; + return true; + } + + public void Reset() { + currentIndex = -1; + currentObject = null; + if (collectionRef.Count != currentSize) { + throw new global::System.InvalidOperationException("Collection modified."); + } + } + + public void Dispose() { + currentIndex = -1; + currentObject = null; + } + } + + public sealed class $csclassnameNode { + internal $csclassname list; + internal System.IntPtr iter; + internal $typemap(cstype, CTYPE) csharpvalue; + internal bool inlist; + + public $csclassnameNode($typemap(cstype, CTYPE) value) { + csharpvalue = value; + inlist = false; + } + + internal $csclassnameNode(System.IntPtr _iter, $csclassname _list) { + list = _list; + iter = _iter; + inlist = true; + } + + public $csclassname List { + get { + return this.list; + } + } + + public $csclassnameNode Next { + get { + if (list.getNextIter(iter) == System.IntPtr.Zero) + return null; + return new $csclassnameNode(list.getNextIter(iter), list); + } + } + + public $csclassnameNode Previous { + get { + if (list.getPrevIter(iter) == System.IntPtr.Zero) + return null; + return new $csclassnameNode(list.getPrevIter(iter), list); + } + } + + public $typemap(cstype, CTYPE) Value { + get { + return list.getItem(this.iter); + } + set { + list.setItem(this.iter, value); + } + } + + public static bool operator== ($csclassnameNode node1, $csclassnameNode node2) { + if (object.ReferenceEquals(node1, null) && object.ReferenceEquals(node2, null)) + return true; + if (object.ReferenceEquals(node1, null) || object.ReferenceEquals(node2, null)) + return false; + return node1.Equals(node2); + } + + public static bool operator!= ($csclassnameNode node1, $csclassnameNode node2) { + if (node1 == null && node2 == null) + return false; + if (node1 == null || node2 == null) + return true; + return !node1.Equals(node2); + } + + public bool Equals($csclassnameNode node) { + if (node == null) + return false; + if (!node.inlist || !this.inlist) + return object.ReferenceEquals(this, node); + return list.equals(this.iter, node.iter); + } + + public override bool Equals(object node) { + return Equals(($csclassnameNode)node); + } + + public override int GetHashCode() { + int hash = 13; + if (inlist) { + hash = (hash * 7) + this.list.GetHashCode(); + hash = (hash * 7) + this.Value.GetHashCode(); + hash = (hash * 7) + this.list.getNextIter(this.iter).GetHashCode(); + hash = (hash * 7) + this.list.getPrevIter(this.iter).GetHashCode(); + } else { + hash = (hash * 7) + this.csharpvalue.GetHashCode(); + } + return hash; + } + + public void Dispose() { + list.deleteIter(this.iter); + } + } +%} + +public: + typedef size_t size_type; + typedef CTYPE value_type; + typedef CONST_REFERENCE const_reference; + void push_front(CTYPE const& x); + void push_back(CTYPE const& x); + %rename(RemoveFirst) pop_front; + void pop_front(); + %rename(RemoveLast) pop_back; + void pop_back(); + size_type size() const; + %rename(Clear) clear; + void clear(); + %extend { + CONST_REFERENCE getItem(void *iter) { + std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); + return *it; + } + + void setItem(void *iter, CTYPE const& val) { + std::list< CTYPE >::iterator* it = reinterpret_cast::iterator*>(iter); + *(*it) = val; + } + + void *getFirstIter() { + if ($self->size() == 0) + return NULL; + std::list< CTYPE >::iterator* it = new std::list< CTYPE >::iterator($self->begin()); + return reinterpret_cast(it); + } + + void *getLastIter() { + if ($self->size() == 0) + return NULL; + std::list< CTYPE >::iterator* it = new std::list< CTYPE >::iterator(--$self->end()); + return reinterpret_cast(it); + } + + void *getNextIter(void *iter) { + std::list< CTYPE >::iterator it = *(reinterpret_cast::iterator *>(iter)); + if (std::distance(it, --$self->end()) != 0) { + std::list< CTYPE >::iterator* itnext = new std::list< CTYPE >::iterator(++it); + return reinterpret_cast(itnext); + } + return NULL; + } + + void *getPrevIter(void *iter) { + std::list< CTYPE >::iterator it = *(reinterpret_cast::iterator *>(iter)); + if (std::distance($self->begin(), it) != 0) { + std::list< CTYPE >::iterator* itprev = new std::list< CTYPE >::iterator(--it); + return reinterpret_cast(itprev); + } + return NULL; + } + + void *insertNode(void *iter, CTYPE const& value) { + std::list< CTYPE >::iterator it = $self->insert(*(reinterpret_cast::iterator *>(iter)), value); + void* newit = reinterpret_cast(new std::list< CTYPE >::iterator(it)); + return newit; + } + + void *find(CTYPE const& value) { + if (std::find($self->begin(), $self->end(), value) != $self->end()) { + void* it = reinterpret_cast(new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value))); + return it; + } + return NULL; + } + + void eraseIter(void *iter) { + std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); + $self->erase(it); + } + + void deleteIter(void *iter) { + std::list< CTYPE >::iterator* it = reinterpret_cast::iterator*>(iter); + delete it; + } + + bool equals(void *iter1, void *iter2) { + if (iter1 == NULL && iter2 == NULL) + return true; + std::list< CTYPE >::iterator it1 = *reinterpret_cast::iterator*>(iter1); + std::list< CTYPE >::iterator it2 = *reinterpret_cast::iterator*>(iter2); + return it1 == it2; + } + + bool Contains(CTYPE const& value) { + return std::find($self->begin(), $self->end(), value) != $self->end(); + } + } +%enddef + +%apply void *VOID_INT_PTR { void *iter1, void *iter2, void *iter, void *find, void *insertNode, void *getPrevIter, void *getNextIter, void *getFirstIter, void *getLastIter } + +%define SWIG_STD_LIST_ENHANCED(CTYPE...) +namespace std { + template<> class list< CTYPE > { + SWIG_STD_LIST_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE)); + }; +} +%enddef + + + +%{ +#include +#include +#include +#include +%} + +%csmethodmodifiers std::list::size "private" +%csmethodmodifiers std::list::getItem "private" +%csmethodmodifiers std::list::setItem "private" +%csmethodmodifiers std::list::push_front "private" +%csmethodmodifiers std::list::push_back "private" +%csmethodmodifiers std::list::getFirstIter "private" +%csmethodmodifiers std::list::getNextIter "private" +%csmethodmodifiers std::list::getPrevIter "private" +%csmethodmodifiers std::list::getLastIter "private" +%csmethodmodifiers std::list::find "private" +%csmethodmodifiers std::list::deleteIter "private" + +namespace std { + template + class list { + SWIG_STD_LIST_MINIMUM_INTERNAL(T const&, T) + }; + template + class list + { + SWIG_STD_LIST_MINIMUM_INTERNAL(T *const&, T *) + }; + template<> + class list { + SWIG_STD_LIST_MINIMUM_INTERNAL(bool, bool) + }; +} From 78051fdd33b5dc5fca0ec5787821ce5f9030af93 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 Mar 2019 07:42:44 +0000 Subject: [PATCH 1526/2031] C# std::list changes to support types that are not assignable Assignable fixes are based on those used by C# std::vector where the default wrappers work if there is no operator== available in the template type. Enhanced wrappers are obtained via a macro: SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass) %template(ListKlass) std::list; Remove bool specialization (left over from the original std::vector wrappers). Add in missing typedefs. --- .../test-suite/csharp/li_std_list_runme.cs | 2 +- Examples/test-suite/li_std_list.i | 3 +- Lib/csharp/std_list.i | 124 ++++++++++++------ Lib/csharp/std_vector.i | 7 +- 4 files changed, 85 insertions(+), 51 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_list_runme.cs b/Examples/test-suite/csharp/li_std_list_runme.cs index fdcd0d9ac..1a5b1562d 100644 --- a/Examples/test-suite/csharp/li_std_list_runme.cs +++ b/Examples/test-suite/csharp/li_std_list_runme.cs @@ -399,4 +399,4 @@ public class li_std_list_runme { } } } -} \ No newline at end of file +} diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i index 6a60f032c..9cc6220d2 100644 --- a/Examples/test-suite/li_std_list.i +++ b/Examples/test-suite/li_std_list.i @@ -38,7 +38,6 @@ struct Struct { double num; Struct() : num(0.0) {} Struct(double d) : num(d) {} - bool operator==(const Struct &other) { return (num == other.num); } }; const std::list & CopyContainerStruct(const std::list & container) { return container; } @@ -70,4 +69,4 @@ enum Fruit { %template(StructList) std::list; %template(StructPtrList) std::list; %template(StructConstPtrList) std::list; -%template(FruitList) std::list; \ No newline at end of file +%template(FruitList) std::list; diff --git a/Lib/csharp/std_list.i b/Lib/csharp/std_list.i index 6194f94ea..e6e7fd260 100644 --- a/Lib/csharp/std_list.i +++ b/Lib/csharp/std_list.i @@ -5,11 +5,21 @@ * C# implementation * The C# wrapper is made to look and feel like a C# System.Collections.Generic.LinkedList<> collection. * + * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with + * C++ std::list wrappers. The ICollection<> interface is also implemented to provide enhanced functionality + * whenever we are confident that the required C++ operator== is available. This is the case for when + * T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_LIST_ENHANCED + * macro to obtain this enhanced functionality, for example: + * + * SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass) + * %template(ListKlass) std::list; * ----------------------------------------------------------------------------- */ %include -%define SWIG_STD_LIST_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...) -%typemap(csinterfaces) std::list< CTYPE > "global::System.Collections.Generic.ICollection<$typemap(cstype, CTYPE)>, global::System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>, global::System.Collections.IEnumerable, global::System.IDisposable" + +// MACRO for use within the std::list class body +%define SWIG_STD_LIST_MINIMUM_INTERNAL(CSINTERFACE, CTYPE...) +%typemap(csinterfaces) std::list< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; %proxycode %{ public $csclassname(global::System.Collections.IEnumerable c) : this() { if (c == null) @@ -120,27 +130,11 @@ AddLast(value); } - public bool Remove($typemap(cstype, CTYPE) value) { - var node = Find(value); - if (node == null) - return false; - Remove(node); - return true; - } - public void Remove($csclassnameNode node) { ValidateNode(node); eraseIter(node.iter); } - public $csclassnameNode Find($typemap(cstype, CTYPE) value) { - System.IntPtr tmp = find(value); - if (tmp != System.IntPtr.Zero) { - return new $csclassnameNode(tmp, this); - } - return null; - } - public void CopyTo($typemap(cstype, CTYPE)[] array, int index) { if (array == null) throw new global::System.ArgumentNullException("array"); @@ -257,9 +251,9 @@ inlist = false; } - internal $csclassnameNode(System.IntPtr _iter, $csclassname _list) { - list = _list; - iter = _iter; + internal $csclassnameNode(System.IntPtr iter, $csclassname list) { + this.list = list; + this.iter = iter; inlist = true; } @@ -343,8 +337,13 @@ public: typedef size_t size_type; + typedef ptrdiff_t difference_type; typedef CTYPE value_type; - typedef CONST_REFERENCE const_reference; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type& reference; + typedef const value_type& const_reference; + void push_front(CTYPE const& x); void push_back(CTYPE const& x); %rename(RemoveFirst) pop_front; @@ -355,7 +354,7 @@ public: %rename(Clear) clear; void clear(); %extend { - CONST_REFERENCE getItem(void *iter) { + const_reference getItem(void *iter) { std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); return *it; } @@ -403,14 +402,6 @@ public: return newit; } - void *find(CTYPE const& value) { - if (std::find($self->begin(), $self->end(), value) != $self->end()) { - void* it = reinterpret_cast(new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value))); - return it; - } - return NULL; - } - void eraseIter(void *iter) { std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); $self->erase(it); @@ -428,27 +419,59 @@ public: std::list< CTYPE >::iterator it2 = *reinterpret_cast::iterator*>(iter2); return it1 == it2; } + } +%enddef +// Extra methods added to the collection class if operator== is defined for the class being wrapped +// The class will then implement ICollection<>, which adds extra functionality +%define SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE...) + %extend { bool Contains(CTYPE const& value) { return std::find($self->begin(), $self->end(), value) != $self->end(); } + + bool Remove(CTYPE const& value) { + std::list< CTYPE >::iterator it = std::find($self->begin(), $self->end(), value); + if (it != $self->end()) { + $self->erase(it); + return true; + } + return false; + } + + void *find(CTYPE const& value) { + if (std::find($self->begin(), $self->end(), value) != $self->end()) { + void* it = reinterpret_cast(new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value))); + return it; + } + return NULL; + } } +%proxycode %{ + public $csclassnameNode Find($typemap(cstype, CTYPE) value) { + System.IntPtr tmp = find(value); + if (tmp != System.IntPtr.Zero) { + return new $csclassnameNode(tmp, this); + } + return null; + } +%} %enddef %apply void *VOID_INT_PTR { void *iter1, void *iter2, void *iter, void *find, void *insertNode, void *getPrevIter, void *getNextIter, void *getFirstIter, void *getLastIter } +// Macros for std::list class specializations/enhancements %define SWIG_STD_LIST_ENHANCED(CTYPE...) namespace std { template<> class list< CTYPE > { - SWIG_STD_LIST_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE)); + SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, %arg(CTYPE)); + SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef - %{ -#include #include #include #include @@ -467,17 +490,34 @@ namespace std { %csmethodmodifiers std::list::deleteIter "private" namespace std { + // primary (unspecialized) class template for std::list + // does not require operator== to be defined template class list { - SWIG_STD_LIST_MINIMUM_INTERNAL(T const&, T) + SWIG_STD_LIST_MINIMUM_INTERNAL(IEnumerable, T) }; + // specialization for pointers template - class list - { - SWIG_STD_LIST_MINIMUM_INTERNAL(T *const&, T *) - }; - template<> - class list { - SWIG_STD_LIST_MINIMUM_INTERNAL(bool, bool) + class list { + SWIG_STD_LIST_MINIMUM_INTERNAL(ICollection, T *) + SWIG_STD_LIST_EXTRA_OP_EQUALS_EQUALS(T *) }; } + +// template specializations for std::list +// these provide extra collections methods as operator== is defined +SWIG_STD_LIST_ENHANCED(char) +SWIG_STD_LIST_ENHANCED(signed char) +SWIG_STD_LIST_ENHANCED(unsigned char) +SWIG_STD_LIST_ENHANCED(short) +SWIG_STD_LIST_ENHANCED(unsigned short) +SWIG_STD_LIST_ENHANCED(int) +SWIG_STD_LIST_ENHANCED(unsigned int) +SWIG_STD_LIST_ENHANCED(long) +SWIG_STD_LIST_ENHANCED(unsigned long) +SWIG_STD_LIST_ENHANCED(long long) +SWIG_STD_LIST_ENHANCED(unsigned long long) +SWIG_STD_LIST_ENHANCED(float) +SWIG_STD_LIST_ENHANCED(double) +SWIG_STD_LIST_ENHANCED(std::string) // also requires a %include +SWIG_STD_LIST_ENHANCED(std::wstring) // also requires a %include diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index b1e8da963..e8eeb8411 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -13,18 +13,13 @@ * * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) * %template(VectKlass) std::vector; - * - * 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. - - %include // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...) -%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; +%typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; %proxycode %{ public $csclassname(global::System.Collections.IEnumerable c) : this() { if (c == null) From 59030cb3d22aaa3aa7cc4607b0e936de4aac5724 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Mar 2019 08:02:32 +0000 Subject: [PATCH 1527/2031] Replace void* with iterator* in C# std::list wrappers Better to use the actual type rather than void* in the implementaton. It also mean the %apply that was used in the implementation won't inadvertently affect users other use of void* types. --- CHANGES.current | 13 ++++++++ Lib/csharp/std_list.i | 70 ++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5022e3097..68657f562 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,19 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-25: Liryna + [C#] #1143 Add std_list.i for std::list support. + The C# std::list wrappers are made to look and feel like a C# + System.Collections.Generic.LinkedList<> collection. + The IEnumerable<> interface is implemented in the proxy class. + The ICollection<> interface can also be implemented to provide enhanced functionality + whenever a C++ operator== is available. This is the case for when T is a + primitive type or a pointer. If T does define an operator==, then use the + SWIG_STD_LIST_ENHANCED macro to obtain this enhanced functionality, for example: + + SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass) + %template(ListKlass) std::list; + 2019-03-18: richardbeare [R] #1328 Non-trivial enums are working now. The enum values are now obtained from the C/C++ layer. const reference enums and C++11 enum classes are also now working. diff --git a/Lib/csharp/std_list.i b/Lib/csharp/std_list.i index e6e7fd260..674aba0ab 100644 --- a/Lib/csharp/std_list.i +++ b/Lib/csharp/std_list.i @@ -20,6 +20,9 @@ // MACRO for use within the std::list class body %define SWIG_STD_LIST_MINIMUM_INTERNAL(CSINTERFACE, CTYPE...) %typemap(csinterfaces) std::list< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; + +%apply void *VOID_INT_PTR { std::list< CTYPE >::iterator * }; + %proxycode %{ public $csclassname(global::System.Collections.IEnumerable c) : this() { if (c == null) @@ -288,7 +291,7 @@ } } - public static bool operator== ($csclassnameNode node1, $csclassnameNode node2) { + public static bool operator==($csclassnameNode node1, $csclassnameNode node2) { if (object.ReferenceEquals(node1, null) && object.ReferenceEquals(node2, null)) return true; if (object.ReferenceEquals(node1, null) || object.ReferenceEquals(node2, null)) @@ -296,7 +299,7 @@ return node1.Equals(node2); } - public static bool operator!= ($csclassnameNode node1, $csclassnameNode node2) { + public static bool operator!=($csclassnameNode node1, $csclassnameNode node2) { if (node1 == null && node2 == null) return false; if (node1 == null || node2 == null) @@ -344,6 +347,8 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + class iterator; + void push_front(CTYPE const& x); void push_back(CTYPE const& x); %rename(RemoveFirst) pop_front; @@ -354,69 +359,63 @@ public: %rename(Clear) clear; void clear(); %extend { - const_reference getItem(void *iter) { - std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); - return *it; + const_reference getItem(iterator *iter) { + return **iter; } - void setItem(void *iter, CTYPE const& val) { - std::list< CTYPE >::iterator* it = reinterpret_cast::iterator*>(iter); - *(*it) = val; + void setItem(iterator *iter, CTYPE const& val) { + *(*iter) = val; } - void *getFirstIter() { + iterator *getFirstIter() { if ($self->size() == 0) return NULL; - std::list< CTYPE >::iterator* it = new std::list< CTYPE >::iterator($self->begin()); - return reinterpret_cast(it); + return new std::list< CTYPE >::iterator($self->begin()); } - void *getLastIter() { + iterator *getLastIter() { if ($self->size() == 0) return NULL; - std::list< CTYPE >::iterator* it = new std::list< CTYPE >::iterator(--$self->end()); - return reinterpret_cast(it); + return new std::list< CTYPE >::iterator(--$self->end()); } - void *getNextIter(void *iter) { - std::list< CTYPE >::iterator it = *(reinterpret_cast::iterator *>(iter)); + iterator *getNextIter(iterator *iter) { + std::list< CTYPE >::iterator it = *iter; if (std::distance(it, --$self->end()) != 0) { std::list< CTYPE >::iterator* itnext = new std::list< CTYPE >::iterator(++it); - return reinterpret_cast(itnext); + return itnext; } return NULL; } - void *getPrevIter(void *iter) { - std::list< CTYPE >::iterator it = *(reinterpret_cast::iterator *>(iter)); + iterator *getPrevIter(iterator *iter) { + std::list< CTYPE >::iterator it = *iter; if (std::distance($self->begin(), it) != 0) { std::list< CTYPE >::iterator* itprev = new std::list< CTYPE >::iterator(--it); - return reinterpret_cast(itprev); + return itprev; } return NULL; } - void *insertNode(void *iter, CTYPE const& value) { - std::list< CTYPE >::iterator it = $self->insert(*(reinterpret_cast::iterator *>(iter)), value); - void* newit = reinterpret_cast(new std::list< CTYPE >::iterator(it)); - return newit; + iterator *insertNode(iterator *iter, CTYPE const& value) { + std::list< CTYPE >::iterator it = $self->insert(*iter, value); + return new std::list< CTYPE >::iterator(it); } - void eraseIter(void *iter) { - std::list< CTYPE >::iterator it = *reinterpret_cast::iterator*>(iter); + void eraseIter(iterator *iter) { + std::list< CTYPE >::iterator it = *iter; $self->erase(it); } - void deleteIter(void *iter) { - std::list< CTYPE >::iterator* it = reinterpret_cast::iterator*>(iter); - delete it; + void deleteIter(iterator *iter) { + delete iter; } - bool equals(void *iter1, void *iter2) { + bool equals(iterator *iter1, iterator *iter2) { if (iter1 == NULL && iter2 == NULL) return true; - std::list< CTYPE >::iterator it1 = *reinterpret_cast::iterator*>(iter1); - std::list< CTYPE >::iterator it2 = *reinterpret_cast::iterator*>(iter2); + std::list< CTYPE >::iterator it1 = *iter1; + std::list< CTYPE >::iterator it2 = *iter2; return it1 == it2; } } @@ -439,10 +438,9 @@ public: return false; } - void *find(CTYPE const& value) { + iterator *find(CTYPE const& value) { if (std::find($self->begin(), $self->end(), value) != $self->end()) { - void* it = reinterpret_cast(new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value))); - return it; + return new std::list< CTYPE >::iterator(std::find($self->begin(), $self->end(), value)); } return NULL; } @@ -458,8 +456,6 @@ public: %} %enddef -%apply void *VOID_INT_PTR { void *iter1, void *iter2, void *iter, void *find, void *insertNode, void *getPrevIter, void *getNextIter, void *getFirstIter, void *getLastIter } - // Macros for std::list class specializations/enhancements %define SWIG_STD_LIST_ENHANCED(CTYPE...) namespace std { From c0e212b9cf6c0179689b763cf61659fd77c2b616 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Mar 2019 18:48:51 +0000 Subject: [PATCH 1528/2031] More C# std::list testing --- Examples/test-suite/stl_no_default_constructor.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/stl_no_default_constructor.i b/Examples/test-suite/stl_no_default_constructor.i index 164710bd5..32aff2b46 100644 --- a/Examples/test-suite/stl_no_default_constructor.i +++ b/Examples/test-suite/stl_no_default_constructor.i @@ -13,7 +13,7 @@ struct NoDefaultCtor { %template(VectorNoDefaultCtor) std::vector; #endif -#if defined(SWIGJAVA) +#if defined(SWIGJAVA) || defined(SWIGJAVA) %include %template(ListNoDefaultCtor) std::list; #endif From cedf4a2c2fddd5c6c45d7c12bb455db0458014b0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 25 Mar 2019 18:54:08 +0000 Subject: [PATCH 1529/2031] More python std::list testing --- Examples/test-suite/python/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 1402239b9..0151f5918 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -45,6 +45,7 @@ CPP_TEST_CASES += \ li_factory \ li_implicit \ li_std_containers_int \ + li_std_list \ li_std_map_member \ li_std_multimap \ li_std_pair_extra \ From b092055ca87a9e6f9d489d967d2ff27870687ce4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Mar 2019 07:48:33 +0000 Subject: [PATCH 1530/2031] Fix parallel 'make check-ocaml-examples' Some versions of ocamlc create a file of the same name in the tmp directory when invoking using ocalmc on swigp4.ml. The name is the same even from different example directories. TMPDIR is a workaround to make ocamlc use a different directory for this temp file. Parallel make (-j) broke because different instances of ocamlc tried to create the same temp file. Issue #1503 --- Examples/Makefile.in | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 7022166a0..2688b16f3 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -865,12 +865,15 @@ NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where` OCAMLCORE=\ - (test -f swig.mli || $(SWIG) -ocaml -co swig.mli 2>/dev/null) && \ - (test -f swig.ml || $(SWIG) -ocaml -co swig.ml 2>/dev/null) && \ - (test -f swigp4.ml || $(SWIG) -ocaml -co swigp4.ml 2>/dev/null) && \ - (test -f swig.cmi || $(OCC) -c swig.mli) && \ - (test -f swig.cmo || $(OCC) -c swig.ml) && \ - (test -f swigp4.cmi || $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml) + $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ + $(SWIG) -ocaml -co swig.ml 2>/dev/null && \ + $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ + $(OCC) -c swig.mli && \ + $(OCC) -c swig.ml && \ + mkdir -p ./localtmp && \ + env TMPDIR=./localtmp $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml && \ + rm -rf ./localtmp +# TMPDIR above is a workaround for some ocamlc versions, such as 4.05.0, which always create a temp file of the same name breaking parallel make ocaml_static: $(SRCDIR_SRCS) $(OCAMLCORE) @@ -957,6 +960,7 @@ ocaml_clean: rm -f *_wrap* *~ .~* *.cmo *.cmi *.mli $(TARGET).ml $(RUNME) $(RUNME)_top swig.ml swigp4.ml rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ + rm -rf ./localtmp ################################################################## ##### RUBY ###### From 166b683e8918c655dcfa9c9c3d99727bbf6288ef Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Mar 2019 19:51:09 +0000 Subject: [PATCH 1531/2031] More ocaml parallel make fixes The previous commit removed a pile of 'test -f' hacks which were sort of working for parallel builds and broke parallel test-suite builds. Now this is fixed properly - these files are safely created in the test-suite already. Now we create them safely in the examples. --- Examples/Makefile.in | 39 +++++++++++-------------- Examples/ocaml/argout_ref/Makefile | 4 +++ Examples/ocaml/callback/Makefile | 4 +++ Examples/ocaml/class/Makefile | 4 +++ Examples/ocaml/contract/Makefile | 4 +++ Examples/ocaml/scoped_enum/Makefile | 4 +++ Examples/ocaml/shapes/Makefile | 4 +++ Examples/ocaml/simple/Makefile | 4 +++ Examples/ocaml/std_string/Makefile | 4 +++ Examples/ocaml/std_vector/Makefile | 4 +++ Examples/ocaml/stl/Makefile | 4 +++ Examples/ocaml/string_from_ptr/Makefile | 4 +++ Examples/ocaml/strings_test/Makefile | 4 +++ 13 files changed, 65 insertions(+), 22 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 2688b16f3..5ffc0095e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -858,34 +858,33 @@ mzscheme_clean: ################################################################## OCC=$(COMPILETOOL) @OCAMLC@ +OCC_WITH_PP=env TMPDIR=./localtmp $(OCC) +# TMPDIR above is a workaround for some ocamlc versions, such as 4.05.0, which always create a temp file of the same name breaking parallel make (seemingly only when -pp is used) OCAMLDLGEN=$(COMPILETOOL) @OCAMLDLGEN@ OCAMLFIND=$(COMPILETOOL) @OCAMLFIND@ OCAMLMKTOP=$(COMPILETOOL) @OCAMLMKTOP@ NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" OCAMLP4WHERE=`$(COMPILETOOL) @CAMLP4@ -where` -OCAMLCORE=\ - $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ - $(SWIG) -ocaml -co swig.ml 2>/dev/null && \ - $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ - $(OCC) -c swig.mli && \ - $(OCC) -c swig.ml && \ - mkdir -p ./localtmp && \ - env TMPDIR=./localtmp $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml && \ - rm -rf ./localtmp -# TMPDIR above is a workaround for some ocamlc versions, such as 4.05.0, which always create a temp file of the same name breaking parallel make + +ocaml_core: + mkdir -p ./localtmp + $(SWIG) -ocaml -co swig.mli 2>/dev/null + $(SWIG) -ocaml -co swig.ml 2>/dev/null + $(SWIG) -ocaml -co swigp4.ml 2>/dev/null + $(OCC) -c swig.mli + $(OCC) -c swig.ml + $(OCC_WITH_PP) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml ocaml_static: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_dynamic: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(CXXSHARED) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(CCSHARED) -o $(INTERFACE:%.i=%@SO@) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS) @@ -893,40 +892,36 @@ ocaml_dynamic: $(SRCDIR_SRCS) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLFIND) $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) ocaml_static_toplevel: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCDIR_SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) ocaml_static_cpp: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCC) -g -ccopt -g -cclib -g -custom -o $(RUNME) swig.cmo $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" -cc '$(CXX)' ocaml_static_cpp_toplevel: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -w -U -g -c $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) -cc '$(CXX) $(CPPFLAGS)' swig.cmo -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo -cclib "$(LIBS)" -g -ccopt -g -cclib -g -custom -o $(RUNME)_top $(INTERFACE:%.i=%.cmo) $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) ocaml_dynamic_cpp: $(SRCDIR_SRCS) - $(OCAMLCORE) $(SWIG) -ocaml -c++ $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX) $(CPPFLAGS)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" $(ICXXSRCS:%.cxx=%.c) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) -ccopt -fPIC @@ -935,7 +930,7 @@ ocaml_dynamic_cpp: $(SRCDIR_SRCS) mv $(INTERFACE:%.i=%_dynamic.ml) $(INTERFACE:%.i=%.ml) rm $(INTERFACE:%.i=%.mli) $(OCAMLFIND) $(OCC) -g -c -package dl $(INTERFACE:%.i=%.ml) - test -z "$(PROGFILE)" || $(OCC) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) + test -z "$(PROGFILE)" || $(OCC_WITH_PP) -o $(PROGFILE:%.ml=%) $(OCAMLPP) -c $(SRCDIR)$(PROGFILE) $(NOLINK) || $(OCAMLFIND) swig.cmo $(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom -o $(RUNME) -package dl -linkpkg $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)' # ----------------------------------------------------------------- diff --git a/Examples/ocaml/argout_ref/Makefile b/Examples/ocaml/argout_ref/Makefile index 234713da5..09370940f 100644 --- a/Examples/ocaml/argout_ref/Makefile +++ b/Examples/ocaml/argout_ref/Makefile @@ -13,6 +13,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/callback/Makefile b/Examples/ocaml/callback/Makefile index 7344485f6..b81b5ac1b 100644 --- a/Examples/ocaml/callback/Makefile +++ b/Examples/ocaml/callback/Makefile @@ -14,6 +14,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/class/Makefile b/Examples/ocaml/class/Makefile index 7344485f6..b81b5ac1b 100644 --- a/Examples/ocaml/class/Makefile +++ b/Examples/ocaml/class/Makefile @@ -14,6 +14,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/contract/Makefile b/Examples/ocaml/contract/Makefile index 1f36642e4..8148de142 100644 --- a/Examples/ocaml/contract/Makefile +++ b/Examples/ocaml/contract/Makefile @@ -20,6 +20,10 @@ dynamic: ocaml_dynamic static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile index f0f53173f..cfed474ef 100644 --- a/Examples/ocaml/scoped_enum/Makefile +++ b/Examples/ocaml/scoped_enum/Makefile @@ -20,6 +20,10 @@ dynamic: ocaml_dynamic_cpp static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/shapes/Makefile b/Examples/ocaml/shapes/Makefile index a9932793b..eab86d298 100644 --- a/Examples/ocaml/shapes/Makefile +++ b/Examples/ocaml/shapes/Makefile @@ -14,6 +14,10 @@ check: build build: static toplevel static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/simple/Makefile b/Examples/ocaml/simple/Makefile index 3b24a6bcb..27fdb20f5 100644 --- a/Examples/ocaml/simple/Makefile +++ b/Examples/ocaml/simple/Makefile @@ -20,6 +20,10 @@ dynamic: ocaml_dynamic static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/std_string/Makefile b/Examples/ocaml/std_string/Makefile index 099b1fcee..655465692 100644 --- a/Examples/ocaml/std_string/Makefile +++ b/Examples/ocaml/std_string/Makefile @@ -12,6 +12,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/std_vector/Makefile b/Examples/ocaml/std_vector/Makefile index 099b1fcee..655465692 100644 --- a/Examples/ocaml/std_vector/Makefile +++ b/Examples/ocaml/std_vector/Makefile @@ -12,6 +12,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index 683d34c36..ceaa80d1d 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -12,6 +12,10 @@ check: build build: static static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/string_from_ptr/Makefile b/Examples/ocaml/string_from_ptr/Makefile index 6917e4638..5ab5c44a9 100644 --- a/Examples/ocaml/string_from_ptr/Makefile +++ b/Examples/ocaml/string_from_ptr/Makefile @@ -13,6 +13,10 @@ check: build build: static toplevel static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 9474f5364..7609b31c6 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -12,6 +12,10 @@ check: build build: static toplevel static: + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + ocaml_core $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ From 33f8c36813f731d54f6220b089248311d3134279 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Mar 2019 21:24:00 +0000 Subject: [PATCH 1532/2031] Correct ocaml dynamic targets --- Examples/ocaml/stl/Makefile | 2 +- Examples/ocaml/strings_test/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/ocaml/stl/Makefile b/Examples/ocaml/stl/Makefile index ceaa80d1d..363311d95 100644 --- a/Examples/ocaml/stl/Makefile +++ b/Examples/ocaml/stl/Makefile @@ -25,7 +25,7 @@ dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - ocaml_static_cpp + ocaml_dynamic_cpp toplevel: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ diff --git a/Examples/ocaml/strings_test/Makefile b/Examples/ocaml/strings_test/Makefile index 7609b31c6..38cf234da 100644 --- a/Examples/ocaml/strings_test/Makefile +++ b/Examples/ocaml/strings_test/Makefile @@ -25,7 +25,7 @@ dynamic: $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - ocaml_static_cpp + ocaml_dynamic_cpp toplevel: static $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ From 06462acdf9b7738a19dce5579d90b1c91b3f9cfb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Mar 2019 12:18:40 +0000 Subject: [PATCH 1533/2031] Fix C# CA1063 warning by implementing the recommended Dispose methods. Previously just the Dispose() method was generated. Now the Dispose() and Dispose(bool disposing) methods are generated. Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" typemaps are being used. Details in #421 on Github. SWIG will error out if one of the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example error message: foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps. Closes #421 --- CHANGES.current | 15 ++++ Doc/Manual/CSharp.html | 4 +- Examples/test-suite/allprotected.i | 4 + .../test-suite/csharp/allprotected_runme.cs | 14 ++++ Examples/test-suite/minherit2.i | 4 +- Lib/csharp/boost_intrusive_ptr.i | 16 ++-- Lib/csharp/boost_shared_ptr.i | 8 +- Lib/csharp/csharp.swg | 19 +++-- Source/Modules/csharp.cxx | 74 ++++++++++++++----- 9 files changed, 113 insertions(+), 45 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 68657f562..4cea8d91b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,21 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-30: wsfulton + [C#] #421 Fix CA1063 warning by implementing the recommended Dispose methods for + the IDisposable interface. Previously just the Dispose() method was generated. + Now the Dispose() and Dispose(bool disposing) methods are generated. + Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" + typemaps are being used. Details in #421 on Github. SWIG will error out if one of + the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example + error message: + + foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove + it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the + csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps. + + *** POTENTIAL INCOMPATIBILITY *** + 2019-03-25: Liryna [C#] #1143 Add std_list.i for std::list support. The C# std::list wrappers are made to look and feel like a C# diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index d485a9714..0526766b5 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -232,8 +232,8 @@ javacode -> cscode javaimports -> csimports javabody -> csbody javafinalize -> csfinalize -javadestruct -> csdestruct -javadestruct_derived -> csdestruct_derived +javadestruct -> csdisposing and csdispose +javadestruct_derived -> csdisposing_derived and csdispose_derived javainterfacecode -> csinterfacecode diff --git a/Examples/test-suite/allprotected.i b/Examples/test-suite/allprotected.i index 086cfb245..e9b4eb341 100644 --- a/Examples/test-suite/allprotected.i +++ b/Examples/test-suite/allprotected.i @@ -79,5 +79,9 @@ protected: }; int ProtectedBase::staticMemberVariable = 10; +class ProtectedDerived : public ProtectedBase { +public: + ProtectedDerived(const char *s) : ProtectedBase(s) {} +}; %} diff --git a/Examples/test-suite/csharp/allprotected_runme.cs b/Examples/test-suite/csharp/allprotected_runme.cs index 99a791d58..6b04feb25 100644 --- a/Examples/test-suite/csharp/allprotected_runme.cs +++ b/Examples/test-suite/csharp/allprotected_runme.cs @@ -13,6 +13,20 @@ public class runme { MyProtectedBase mpb = new MyProtectedBase("MyProtectedBase"); mpb.accessProtected(); + try { + // C++ destructor is protected + mpb.Dispose(); + throw new Exception("failed to catch MethodAccessException"); + } catch (MethodAccessException) { + // Exception message: C++ destructor does not have public access + } + ProtectedDerived pd = new ProtectedDerived("ProtectedDerived"); + // Destroying via the ProtectedDerived's destructor should work + pd.Dispose(); + + ProtectedBase pb = new ProtectedDerived("ProtectedDerived"); + // ProtectedDerived's destructor should be called via the Dispose(disposing) virtual call + pb.Dispose(); } } diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i index 7d470d30e..2baea6495 100644 --- a/Examples/test-suite/minherit2.i +++ b/Examples/test-suite/minherit2.i @@ -17,8 +17,8 @@ #if defined(SWIGCSHARP) #define javaclassmodifiers csclassmodifiers #define javabody csbody -#define javafinalize csfinalize -#define javadestruct csdestruct +#define javafinalize csdispose +#define javadestruct csdisposing #define javaout csout #define javainterfaces csinterfaces #define javabase csbase diff --git a/Lib/csharp/boost_intrusive_ptr.i b/Lib/csharp/boost_intrusive_ptr.i index 6b0392d3d..fa3f53a20 100644 --- a/Lib/csharp/boost_intrusive_ptr.i +++ b/Lib/csharp/boost_intrusive_ptr.i @@ -314,7 +314,7 @@ } %} -%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { @@ -323,11 +323,10 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); } } -%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { @@ -336,8 +335,7 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); - base.Dispose(); + base.Dispose(disposing); } } @@ -473,7 +471,7 @@ } %} -%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { @@ -482,11 +480,10 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); } } -%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { @@ -495,8 +492,7 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); - base.Dispose(); + base.Dispose(disposing); } } diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 73212dddc..508c0ec14 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -282,7 +282,7 @@ } %} -%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnBase) { @@ -291,11 +291,10 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); } } -%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { +%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") TYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwnDerived) { @@ -304,8 +303,7 @@ } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); - base.Dispose(); + base.Dispose(disposing); } } diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index e1554dcb8..832206386 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -959,17 +959,24 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE) SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) -%typemap(csfinalize) SWIGTYPE %{ +%typemap(csdispose) SWIGTYPE %{ ~$csclassname() { - Dispose(); + Dispose(false); + } + + public void Dispose() { + Dispose(true); + global::System.GC.SuppressFinalize(this); } %} +%typemap(csdispose_derived) SWIGTYPE "" + %typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect } %} -%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { +%typemap(csdisposing, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { @@ -978,11 +985,10 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); } } -%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { +%typemap(csdisposing_derived, methodname="Dispose", methodmodifiers="protected", parameters="bool disposing") SWIGTYPE { lock(this) { if (swigCPtr.Handle != global::System.IntPtr.Zero) { if (swigCMemOwn) { @@ -991,8 +997,7 @@ SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE) } swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); } - global::System.GC.SuppressFinalize(this); - base.Dispose(); + base.Dispose(disposing); } } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index bd00ffaf3..ff73c3075 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1873,38 +1873,56 @@ public: typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class NIL); - // C++ destructor is wrapped by the Dispose method - // Note that the method name is specified in a typemap attribute called methodname + // C++ destructor is wrapped by the Finalize and Dispose methods + + const char *tmap_method = derived ? "csdestruct_derived" : "csdestruct"; + const String *tm = typemapExists(n, tmap_method, typemap_lookup_type); + if (tm) { + Swig_error(Getfile(tm), Getline(tm), + "A deprecated %s typemap was found for %s, please remove it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.\n", + tmap_method, proxy_class_name); + } + tmap_method = "csfinalize"; + tm = typemapExists(n, tmap_method, typemap_lookup_type); + if (tm) { + Swig_error(Getfile(tm), Getline(tm), + "A deprecated %s typemap was found for %s, please remove it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps.\n", + tmap_method, proxy_class_name); + } + + tmap_method = derived ? "csdisposing_derived" : "csdisposing"; String *destruct = NewString(""); - const String *tm = NULL; attributes = NewHash(); - String *destruct_methodname = NULL; - String *destruct_methodmodifiers = NULL; + const String *destruct_methodname = NULL; + const String *destruct_methodmodifiers = NULL; + const String *destruct_parameters = NULL; if (derived) { - tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes); - destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname"); - destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers"); + tm = typemapLookup(n, "csdisposing_derived", typemap_lookup_type, WARN_NONE, attributes); + destruct_methodname = Getattr(attributes, "tmap:csdisposing_derived:methodname"); + destruct_methodmodifiers = Getattr(attributes, "tmap:csdisposing_derived:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:csdisposing_derived:parameters"); } else { - tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes); - destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname"); - destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers"); + tm = typemapLookup(n, "csdisposing", typemap_lookup_type, WARN_NONE, attributes); + destruct_methodname = Getattr(attributes, "tmap:csdisposing:methodname"); + destruct_methodmodifiers = Getattr(attributes, "tmap:csdisposing:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:csdisposing:parameters"); } if (tm && *Char(tm)) { if (!destruct_methodname) { - Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name); + Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in %s typemap for %s\n", tmap_method, proxy_class_name); } if (!destruct_methodmodifiers) { Swig_error(Getfile(n), Getline(n), - "No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); + "No methodmodifiers attribute defined in %s typemap for %s.\n", tmap_method, proxy_class_name); } + if (!destruct_parameters) + destruct_parameters = empty_string; } // Emit the Finalize and Dispose methods if (tm) { - // Finalize method - if (*Char(destructor_call)) { - Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL); - } - // Dispose method + // Finalize and Dispose methods + Printv(proxy_class_def, typemapLookup(n, derived ? "csdispose_derived" : "csdispose", typemap_lookup_type, WARN_NONE), NIL); + // Dispose(bool disposing) method Printv(destruct, tm, NIL); if (*Char(destructor_call)) Replaceall(destruct, "$imcall", destructor_call); @@ -1917,7 +1935,7 @@ public: Printv(proxy_class_def, methodmods, NIL); else Printv(proxy_class_def, destruct_methodmodifiers, " ", derived ? "override" : "virtual", NIL); - Printv(proxy_class_def, " void ", destruct_methodname, "() ", destruct, "\n", NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "(", destruct_parameters, ") ", destruct, "\n", NIL); } } if (*Char(interface_upcasts)) @@ -3552,6 +3570,24 @@ public: return tm; } + /* ----------------------------------------------------------------------------- + * typemapExists() + * n - for input only and must contain info for Getfile(n) and Getline(n) to work + * tmap_method - typemap method name + * type - typemap type to lookup + * returns found typemap or NULL if not found + * ----------------------------------------------------------------------------- */ + + const String *typemapExists(Node *n, const_String_or_char_ptr tmap_method, SwigType *type) { + Node *node = NewHash(); + Setattr(node, "type", type); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); + Delete(node); + return tm; + } + /* ----------------------------------------------------------------------------- * canThrow() * Determine whether the code in the typemap can throw a C# exception. From 831fae3c698fd6a690d06aac257c381e69d474ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 30 Mar 2019 12:34:06 +0000 Subject: [PATCH 1534/2031] Add the parameters typemap attribute to D and Java destructor wrapper typemaps Added to the javadestruct, javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided the contents are generated as the delete/dispose method's parameters declaration. --- CHANGES.current | 6 ++++++ Doc/Manual/D.html | 4 ++-- Doc/Manual/Java.html | 6 ++++-- Lib/d/dclassgen.swg | 4 ++-- Lib/java/java.swg | 4 ++-- Source/Modules/d.cxx | 11 ++++++++--- Source/Modules/java.cxx | 11 ++++++++--- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4cea8d91b..9e4b02d4d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-30: wsfulton + [Java, D] Add the parameters typemap attribute to the javadestruct, + javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced + flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided + the contents are generated as the delete/dispose method's parameters declaration. + 2019-03-30: wsfulton [C#] #421 Fix CA1063 warning by implementing the recommended Dispose methods for the IDisposable interface. Previously just the Dispose() method was generated. diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index a252650ff..f1b3404a6 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -107,8 +107,8 @@ csimports <-> dimports csbody <-> dbody csfinalize <-> ddestructor - csdestruct <-> ddispose - csdestruct_derived <-> ddispose_derived + csdisposing <-> ddispose + csdisposing_derived <-> ddispose_derived diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 3a04b8a79..cdefba6b4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6552,7 +6552,7 @@ As there can only be one "javacode" typemap per class, also consider using the and offers nearly identical functionality. -

    %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")

    +

    %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="")

    destructor wrapper - the delete() method (proxy classes only), used for all proxy classes except those which have a base class @@ -6563,9 +6563,10 @@ Note that the delete() method name is configurable and is specified by The method modifiers are also configurable via the methodmodifiers attribute. If a %javamethodmodifiers is attached to the class' destructor, it will be used in preference to the methodmodifiers typemap attribute for the class. +The delete method's parameters declaration can be provided in the optional parameters typemap attribute.
    -

    %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")

    +

    %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="")

    destructor wrapper - the delete() method (proxy classes only), same as "javadestruct" but only used for derived proxy classes @@ -6576,6 +6577,7 @@ Note that the delete() method name is configurable and is specified by The method modifiers are also configurable via the methodmodifiers attribute. If a %javamethodmodifiers is attached to the class' destructor, it will be used in preference to the methodmodifiers typemap attribute for the class. +The delete method's parameters declaration can be provided in the optional parameters typemap attribute.

    %typemap(javaimports)

    diff --git a/Lib/d/dclassgen.swg b/Lib/d/dclassgen.swg index 68910b412..84fa03a0b 100644 --- a/Lib/d/dclassgen.swg +++ b/Lib/d/dclassgen.swg @@ -33,7 +33,7 @@ // We do not use »override« attribute for generated dispose() methods to stay // somewhat compatible to Phobos and older Tango versions where Object.dispose() // does not exist. -%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE { +%typemap(ddispose, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { @@ -45,7 +45,7 @@ } } -%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE { +%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { diff --git a/Lib/java/java.swg b/Lib/java/java.swg index a5b7bbab1..e9309331a 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1313,7 +1313,7 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) // Set the default for SWIGTYPE: Java owns the C/C++ object. SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) -%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; @@ -1323,7 +1323,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } } -%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 4fa30dd60..5e82dfda3 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3274,17 +3274,20 @@ private: // attribute called »methodname«. const String *tm = NULL; - String *dispose_methodname; - String *dispose_methodmodifiers; + const String *dispose_methodname; + const String *dispose_methodmodifiers; + const String *dispose_parameters; attributes = NewHash(); if (derived) { tm = lookupCodeTypemap(n, "ddispose_derived", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose_derived:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose_derived:methodmodifiers"); + dispose_parameters = Getattr(attributes, "tmap:ddispose_derived:parameters"); } else { tm = lookupCodeTypemap(n, "ddispose", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose:methodmodifiers"); + dispose_parameters = Getattr(attributes, "tmap:ddispose:parameters"); } if (tm && *Char(tm)) { @@ -3298,6 +3301,8 @@ private: "No methodmodifiers attribute defined in ddispose%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } + if (!dispose_parameters) + dispose_parameters = empty_string; } if (tm) { @@ -3324,7 +3329,7 @@ private: Printv(body, methodmods, NIL); else Printv(body, dispose_methodmodifiers, (derived ? " override" : ""), NIL); - Printv(body, " void ", dispose_methodname, "() ", dispose_code, "\n", NIL); + Printv(body, " void ", dispose_methodname, "(", dispose_parameters, ") ", dispose_code, "\n", NIL); } } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ac845cb09..94087369a 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2035,16 +2035,19 @@ public: String *destruct = NewString(""); const String *tm = NULL; attributes = NewHash(); - String *destruct_methodname = NULL; - String *destruct_methodmodifiers = NULL; + const String *destruct_methodname = NULL; + const String *destruct_methodmodifiers = NULL; + const String *destruct_parameters = NULL; if (derived) { tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:javadestruct_derived:parameters"); } else { tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:javadestruct:parameters"); } if (tm && *Char(tm)) { if (!destruct_methodname) { @@ -2053,6 +2056,8 @@ public: if (!destruct_methodmodifiers) { Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } + if (!destruct_parameters) + destruct_parameters = empty_string; } // Emit the finalize and delete methods if (tm) { @@ -2073,7 +2078,7 @@ public: Printv(proxy_class_def, methodmods, NIL); else Printv(proxy_class_def, destruct_methodmodifiers, NIL); - Printv(proxy_class_def, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "(", destruct_parameters, ") ", destructor_throws_clause, " ", destruct, "\n", NIL); } } if (*Char(interface_upcasts)) From 3d99cc6b2f636796aadfbf037e8e4e9e54185a79 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 07:57:39 +0100 Subject: [PATCH 1535/2031] Add a few options to the mkdist.py script for building the distribution tarball --- Tools/mkdist.py | 78 +++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 11a0dd6cd..284e7de9b 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -9,27 +9,31 @@ import os import subprocess def failed(): - print "mkdist.py failed to complete" - sys.exit(2) + print "mkdist.py failed to complete" + sys.exit(2) +import argparse +parser = argparse.ArgumentParser(description="Build a SWIG distribution tarball swig-x.y.z.tar.gz") +parser.add_argument("version", help="version string in format x.y.z") +parser.add_argument("-b", "--branch", required=False, default="master", help="git branch name to create tarball from [master]") +parser.add_argument("-f", "--force-tag", required=False, action="store_true", help="force tag (replace git tag if it already exists)") +parser.add_argument("-s", "--skip-checks", required=False, action="store_true", help="skip checks (that local and remote repos are in sync)") +args = parser.parse_args() -try: - version = sys.argv[1] - dirname = "swig-" + version - branch = sys.argv[2] -except: - print "Usage: mkdist.py version branch, where version should be x.y.z and branch is normally 'master'" - sys.exit(1) +version = args.version +branch = args.branch +dirname = "swig-" + version +force_tag = args.force_tag +skip_checks = args.skip_checks if sys.version_info[0:2] < (2, 7): - print "Error: Python 2.7 is required" - sys.exit(3) - + print "Error: Python 2.7 is required" + sys.exit(3) # Check name matches normal unix conventions if string.lower(dirname) != dirname: - print "directory name ("+dirname+") should be in lowercase" - sys.exit(3) + print "directory name ("+dirname+") should be in lowercase" + sys.exit(3) # If directory and tarball exist, remove it print "Removing ", dirname @@ -43,36 +47,40 @@ os.system("rm -f "+dirname+".tar") # Grab the code from git -print "Checking git repository is in sync with remote repository" +print "Checking there are no local changes in git repo" os.system("git remote update origin") == 0 or failed() command = ["git", "status", "--porcelain", "-uno"] out = subprocess.check_output(command) if out.strip() != "": - print "Local git repository has modifications" - print " ".join(command) - print out - sys.exit(3) + print "Local git repository has modifications" + print " ".join(command) + print out + sys.exit(3) -command = ["git", "log", "--oneline", branch + "..origin/" + branch] -out = subprocess.check_output(command) -if out.strip() != "": - print "Remote repository has additional modifications to local repository" - print " ".join(command) - print out - sys.exit(3) +if not skip_checks: + print "Checking git repository is in sync with remote repository" + command = ["git", "log", "--oneline", branch + "..origin/" + branch] + out = subprocess.check_output(command) + if out.strip() != "": + print "Remote repository has additional modifications to local repository" + print " ".join(command) + print out + sys.exit(3) -command = ["git", "log", "--oneline", "origin/" + branch + ".." + branch] -out = subprocess.check_output(command) -if out.strip() != "": - print "Local repository has modifications not pushed to the remote repository" - print "These should be pushed and checked that they pass Continuous Integration testing before continuing" - print " ".join(command) - print out - sys.exit(3) + command = ["git", "log", "--oneline", "origin/" + branch + ".." + branch] + out = subprocess.check_output(command) + if out.strip() != "": + print "Local repository has modifications not pushed to the remote repository" + print "These should be pushed and checked that they pass Continuous Integration testing before continuing" + print " ".join(command) + print out + sys.exit(3) print "Tagging release" tag = "'rel-" + version + "'" -os.system("git tag -a -m " + tag + " " + tag) == 0 or failed() +force = "-f " if force_tag else "" +print("force {}".format(force)) +os.system("git tag -a -m " + tag + " " + force + tag) == 0 or failed() outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" print "Grabbing tagged release git repository using 'git archive' into " + outdir From 320254eb140f50dda2960a3b8fcf8f7bee5668cd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 18:35:32 +0100 Subject: [PATCH 1536/2031] Port mkdist.py to Python 3 --- Tools/mkdist.py | 73 +++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 284e7de9b..47cf8e765 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -1,15 +1,11 @@ #!/usr/bin/env python -# This script builds a swig-x.y.z distribution. -# Usage: mkdist.py version branch, where version should be x.y.z and branch is normally 'master' - import sys -import string import os import subprocess def failed(): - print "mkdist.py failed to complete" + print("mkdist.py failed to complete") sys.exit(2) import argparse @@ -27,82 +23,81 @@ force_tag = args.force_tag skip_checks = args.skip_checks if sys.version_info[0:2] < (2, 7): - print "Error: Python 2.7 is required" + print("Error: Python 2.7 or higher is required") sys.exit(3) # Check name matches normal unix conventions -if string.lower(dirname) != dirname: - print "directory name ("+dirname+") should be in lowercase" +if dirname.lower() != dirname: + print("directory name (" + dirname + ") should be in lowercase") sys.exit(3) # If directory and tarball exist, remove it -print "Removing ", dirname -os.system("rm -rf "+dirname) +print("Removing " + dirname) +os.system("rm -rf " + dirname) -print "Removing "+dirname+".tar if exists" -os.system("rm -f "+dirname+".tar.gz") +print("Removing " + dirname + ".tar if exists") +os.system("rm -f " + dirname + ".tar.gz") -print "Removing "+dirname+".tar.gz if exists" -os.system("rm -f "+dirname+".tar") +print("Removing " + dirname + ".tar.gz if exists") +os.system("rm -f " + dirname + ".tar") # Grab the code from git -print "Checking there are no local changes in git repo" +print("Checking there are no local changes in git repo") os.system("git remote update origin") == 0 or failed() command = ["git", "status", "--porcelain", "-uno"] out = subprocess.check_output(command) if out.strip() != "": - print "Local git repository has modifications" - print " ".join(command) - print out + print("Local git repository has modifications") + print(" ".join(command)) + print(out) sys.exit(3) if not skip_checks: - print "Checking git repository is in sync with remote repository" + print("Checking git repository is in sync with remote repository") command = ["git", "log", "--oneline", branch + "..origin/" + branch] out = subprocess.check_output(command) if out.strip() != "": - print "Remote repository has additional modifications to local repository" - print " ".join(command) - print out + print("Remote repository has additional modifications to local repository") + print(" ".join(command)) + print(out) sys.exit(3) command = ["git", "log", "--oneline", "origin/" + branch + ".." + branch] out = subprocess.check_output(command) if out.strip() != "": - print "Local repository has modifications not pushed to the remote repository" - print "These should be pushed and checked that they pass Continuous Integration testing before continuing" - print " ".join(command) - print out + print("Local repository has modifications not pushed to the remote repository") + print("These should be pushed and checked that they pass Continuous Integration testing before continuing") + print(" ".join(command)) + print(out) sys.exit(3) -print "Tagging release" +print("Tagging release") tag = "'rel-" + version + "'" force = "-f " if force_tag else "" -print("force {}".format(force)) os.system("git tag -a -m " + tag + " " + force + tag) == 0 or failed() outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" -print "Grabbing tagged release git repository using 'git archive' into " + outdir +print("Grabbing tagged release git repository using 'git archive' into " + outdir) os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed() # Go build the system -print "Building system" -os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed() -os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed() -os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed() +print("Building system") +os.system("cd " + dirname + " && ./autogen.sh") == 0 or failed() +os.system("cd " + dirname + "/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed() +os.system("cd " + dirname + " && make -f Makefile.in libfiles srcdir=./") == 0 or failed() # Remove autoconf files -os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") +os.system("find " + dirname + " -name autom4te.cache -exec rm -rf {} \\;") # Build documentation -print "Building html documentation" -os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() +print("Building html documentation") +os.system("cd " + dirname + "/Doc/Manual && make all clean-baks") == 0 or failed() # Build the tar-ball -os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() -os.system("gzip "+dirname+".tar") == 0 or failed() +os.system("tar -cf " + dirname + ".tar " + dirname) == 0 or failed() +os.system("gzip " + dirname + ".tar") == 0 or failed() -print "Finished building "+dirname+".tar.gz" +print("Finished building " + dirname + ".tar.gz") From 66d5d76a29f5323aeb1a3cb204d02c8385fe6bf6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:07:53 +0100 Subject: [PATCH 1537/2031] mkrelease.py improvements Make python3 compatible. Add optional command line arguments. --- Tools/mkrelease.py | 63 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index ec9a2b76a..014cef227 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -1,49 +1,56 @@ #!/usr/bin/env 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. Also uploaded are the release notes. import sys -import string import os def failed(message): if message == "": - print "mkrelease.py failed to complete" + print("mkrelease.py failed to complete") else: - print message + print(message) sys.exit(2) -try: - version = sys.argv[1] - branch = sys.argv[2] - username = sys.argv[3] -except: - print "Usage: python mkrelease.py version branch username" - print "where version should be x.y.z and username is your SF username" - sys.exit(1) +import argparse +parser = argparse.ArgumentParser(description="Build a SWIG distribution source tarball swig-x.y.z.tar.gz and the Windows zip package swigwin-x.y.z.zip.\nUpload them both to SourceForge ready for release.\nThe release notes are also uploaded.") +parser.add_argument("version", help="version string in format x.y.z") +parser.add_argument("-b", "--branch", required=False, default="master", help="git branch name to create tarball from [master]") +parser.add_argument("-f", "--force-tag", required=False, action="store_true", help="force tag (replace git tag if it already exists)") +parser.add_argument("-s", "--skip-checks", required=False, action="store_true", help="skip checks (that local and remote repos are in sync)") +parser.add_argument("-u", "--username", required=False, help="SourceForge username (upload to SourceForge will be skipped if not provided)") +args = parser.parse_args() -print "Looking for rsync" +version = args.version +branch = args.branch +dirname = "swig-" + version +force_tag = args.force_tag +skip_checks = args.skip_checks +username = args.username + +print("Looking for rsync") os.system("which rsync") and failed("rsync not installed/found. Please install.") -print "Making source tarball" -os.system("python ./mkdist.py " + version + " " + branch) and failed("") +print("Making source tarball") +force = "--force-tag" if force_tag else "" +skip = "--skip-checks" if skip_checks else "" +os.system("python ./mkdist.py {} {} --branch {} {}".format(force, skip, branch, version)) and failed("") -print "Build Windows package" +print("Build Windows package") os.system("./mkwindows.sh " + version) and failed("") -print "Uploading to SourceForge" +if username: + print("Uploading to SourceForge") -swig_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swig/swig-" + version + "/" -swigwin_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swigwin/swigwin-" + version + "/" + swig_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swig/swig-" + version + "/" + swigwin_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swigwin/swigwin-" + version + "/" -# If a file with 'readme' in the name exists in the same folder as the zip/tarball, it gets automatically displayed as the release notes by SF -full_readme_file = "readme-" + version + ".txt" -os.system("rm -f " + full_readme_file) -os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.current " + "swig-" + version + "/RELEASENOTES " + "> " + full_readme_file) + # If a file with 'readme' in the name exists in the same folder as the zip/tarball, it gets automatically displayed as the release notes by SF + full_readme_file = "readme-" + version + ".txt" + os.system("rm -f " + full_readme_file) + os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.current " + "swig-" + version + "/RELEASENOTES " + "> " + full_readme_file) -os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + full_readme_file + " " + swig_dir_sf) and failed("") -os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + full_readme_file + " " + swigwin_dir_sf) and failed("") + os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + full_readme_file + " " + swig_dir_sf) and failed("") + os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + full_readme_file + " " + swigwin_dir_sf) and failed("") -print "Finished" + print("Finished") -print "Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push --tags'." + print("Now log in to SourceForge and set the operating systems applicable to the newly uploaded tarball and zip file. Also remember to do a 'git push --tags'.") From ad60edef576683a94ebc288ff5b2066c32198a5c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:08:59 +0100 Subject: [PATCH 1538/2031] Make obs-buildlogs.py Python3 compatible --- Tools/obs-buildlogs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/obs-buildlogs.py b/Tools/obs-buildlogs.py index eaf0f613b..b97e7dba1 100755 --- a/Tools/obs-buildlogs.py +++ b/Tools/obs-buildlogs.py @@ -15,7 +15,7 @@ def download(): for line in repos.stdout: command = ['osc', 'buildlog', '--last'] + line.split() filename = "-".join(line.split()) + ".log" - print "Downloading logs using: {}".format(" ".join(command)) + print("Downloading logs using: {}".format(" ".join(command))) buildlog = subprocess.Popen(command, stdout=subprocess.PIPE) print("Writing log to {}".format(filename)) From 0303e821efad926f81888ff8fc2c24dadd0a82a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:11:44 +0100 Subject: [PATCH 1539/2031] html documentation fixes --- Doc/Manual/R.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 9ca39c99f..45e5541d0 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -209,6 +209,7 @@ defineEnumeration("_colour", +

    which will create an environment named .__E___colour. The enumeration values are initialised via calls to C/C++ code, allowing complex values for enumerations to be used. Calls to the C/C++ code require @@ -225,7 +226,7 @@ appropriate environments and thus translate between characters and integers. The relevant functions, for debugging purposes, are enumToInteger and -enumFromInteger. +enumFromInteger. Anonymous enumerations are ignored by the binding generation process, leaving no way of accessing the value of anonymous enumerations from R From bf9065395a977e2813403dd3040ee91e69141cd0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:33:59 +0100 Subject: [PATCH 1540/2031] C++11 test fixes for Visual Studio 2017 --- .../cpp11_alias_nested_template_scoping.i | 12 ++++++------ Examples/test-suite/cpp11_alignment.i | 3 ++- Examples/test-suite/cpp11_template_explicit.i | 15 +++++++++++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/cpp11_alias_nested_template_scoping.i b/Examples/test-suite/cpp11_alias_nested_template_scoping.i index 0cf5ea35a..72814aa88 100644 --- a/Examples/test-suite/cpp11_alias_nested_template_scoping.i +++ b/Examples/test-suite/cpp11_alias_nested_template_scoping.i @@ -19,17 +19,17 @@ template struct Y { typedef T2 another_type; }; value_type create1() const { return T(); } - Y::value_type create2() const { return T(); } - Y::value_type create3() const { return T(); } - YY::value_type create4() const { return T(); } - Y::YY::value_type create5() const { return T(); } + typename Y::value_type create2() const { return T(); } + typename Y::value_type create3() const { return T(); } + typename YY::value_type create4() const { return T(); } + typename Y::YY::value_type create5() const { return T(); } Y::YYY::value_type create6() const { return T(); } typename Y::template ZZZ::another_type create7() const { return T(); } // With global scope prefix - ::Y::value_type create13() const { return T(); } + typename ::Y::value_type create13() const { return T(); } - ::Y::YY::value_type create15() const { return T(); } + typename ::Y::YY::value_type create15() const { return T(); } ::Y::YYY::value_type create16() const { return T(); } typename ::Y::template ZZZ::another_type create17() const { return T(); } }; diff --git a/Examples/test-suite/cpp11_alignment.i b/Examples/test-suite/cpp11_alignment.i index fb25c4ebb..135f63641 100644 --- a/Examples/test-suite/cpp11_alignment.i +++ b/Examples/test-suite/cpp11_alignment.i @@ -4,7 +4,8 @@ struct A { int member; }; -const int align1 = alignof(A::member); +const int align1 = alignof(int); +const int align2 = alignof(int *); %} %{ diff --git a/Examples/test-suite/cpp11_template_explicit.i b/Examples/test-suite/cpp11_template_explicit.i index f8fca4fae..71752f822 100644 --- a/Examples/test-suite/cpp11_template_explicit.i +++ b/Examples/test-suite/cpp11_template_explicit.i @@ -8,7 +8,8 @@ %inline %{ -template struct Temper { +template class Temper { +public: T val; }; @@ -18,14 +19,20 @@ public: int memberFunction() { return 100; } }; +class B { +public: + short member; + short memberFunction() { return 100; } +}; + template class Temper; -extern template class Temper; +extern template class Temper; template class Temper; -extern template class Temper; +extern template class Temper; template class Temper; -extern template class Temper; +extern template class Temper; %} %template(TemperInt) Temper; From a8055b45d755360580b327fdecc393c66fc06061 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:37:00 +0100 Subject: [PATCH 1541/2031] Check Dispose is called in C# auto_ptr test --- Examples/test-suite/csharp/li_std_auto_ptr_runme.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs b/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs index 1f66042a6..863b86701 100644 --- a/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs +++ b/Examples/test-suite/csharp/li_std_auto_ptr_runme.cs @@ -19,6 +19,13 @@ public class li_std_auto_ptr_runme { if (Klass.getTotal_count() != 2) throw new Exception("number of objects should be 2"); + using (Klass k3 = li_std_auto_ptr.makeKlassAutoPtr("second")) { + if (Klass.getTotal_count() != 3) + throw new Exception("number of objects should be 3"); + } + if (Klass.getTotal_count() != 2) + throw new Exception("number of objects should be 2"); + k1 = null; { int countdown = 500; From be8061c7f58bb574450725aeba3151b6c9c9ae56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Apr 2019 19:44:10 +0100 Subject: [PATCH 1542/2031] Cosmetic C# Makefile tweak --- Examples/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 5ffc0095e..b2cbb65da 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1094,7 +1094,7 @@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPFLAGS = CSHARPOPTIONS = CSHARPSO = @CSHARPSO@ -CSHARP_RUNME = $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) ./$(RUNME).exe +CSHARP_RUNME = ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) @@ -1132,7 +1132,7 @@ csharp_compile: $(SRCDIR_SRCS) # ----------------------------------------------------------------- csharp_run: - env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE) + env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(CSHARPCILINTERPRETER) $(CSHARPCILINTERPRETER_FLAGS) $(CSHARP_RUNME) $(RUNPIPE) # ----------------------------------------------------------------- # Version display From d6746379a1d63b9c588d9642cd1d0d6608629e20 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Apr 2019 06:50:25 +0100 Subject: [PATCH 1543/2031] Use wine on Linux to test executable when building windows zip file --- Tools/mkwindows.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh index 0651bbd60..e6ae84350 100755 --- a/Tools/mkwindows.sh +++ b/Tools/mkwindows.sh @@ -9,6 +9,8 @@ # path to zip program zip= +wine= + # options for configure extraconfigureoptions= compileflags="-O2 -Wall -Wextra" @@ -41,6 +43,11 @@ else echo "Building native Windows executable on Linux" if test x$zip = x; then zip=zip + wine=$(which wine) + fi + if test x$wine = x; then + echo "Could not detect wine - please install wine-stable package." + exit 1; fi echo "Checking that mingw 32-bit gcc is installed/available" if test -n "`which i686-w64-mingw32-gcc`" ; then @@ -109,9 +116,9 @@ 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 + env LD_LIBRARY_PATH= PATH= $wine ./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= $wine ./CCache/ccache-swig.exe -V || exit 1 echo "Creating $swigwinbasename.zip..." cd .. cp $swigbasename/swig.exe $swigwinbasename From 00528a1ef68dc2adbe3c34c23e9841a0715c428b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Apr 2019 19:15:12 +0100 Subject: [PATCH 1544/2031] Fix C# wrappers FxCop warning CA2002 in SWIGPendingException Fixes two warnings in each wrapper: warning : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Retrieve()' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity. warning : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Set(Exception)' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity. Use lock statement advice not to use typeof for locks, see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement --- CHANGES.current | 4 ++++ Lib/csharp/csharphead.swg | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9e4b02d4d..6529ac87d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-04-09: wsfulton + [C#] Fix FxCop warning CA2002 in SWIGPendingException - a lock on a reference of + type 'Type'. + 2019-03-30: wsfulton [Java, D] Add the parameters typemap attribute to the javadestruct, javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 0b55635b3..7db4c0e3c 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -244,6 +244,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( [global::System.ThreadStatic] private static global::System.Exception pendingException = null; private static int numExceptionsPending = 0; + private static global::System.Object exceptionsLock = null; public static bool Pending { get { @@ -259,7 +260,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( if (pendingException != null) throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e); pendingException = e; - lock(typeof($imclassname)) { + lock(exceptionsLock) { numExceptionsPending++; } } @@ -270,13 +271,17 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module( if (pendingException != null) { e = pendingException; pendingException = null; - lock(typeof($imclassname)) { + lock(exceptionsLock) { numExceptionsPending--; } } } return e; } + + static SWIGPendingException() { + exceptionsLock = new global::System.Object(); + } } %} #endif // SWIG_CSHARP_NO_EXCEPTION_HELPER From 5fcb1c138b5b1e13807359c0afc517261854bf35 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Thu, 10 May 2018 13:31:16 +1000 Subject: [PATCH 1545/2031] trial changing member list processing --- Source/Modules/r.cxx | 85 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 15 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index bb43dad48..0181e8bce 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -15,6 +15,10 @@ #include "swigmod.h" #include "cparse.h" +#define R_MEMBER_NORMAL 0 +#define R_MEMBER_SET 1 +#define R_MEMBER_GET 2 + static String* replaceInitialDash(const String *name) { String *retval; @@ -369,9 +373,15 @@ protected: int processing_class_member_function; - List *class_member_functions; - List *class_member_set_functions; - + // List *class_member_functions; + // List *class_member_set_functions; + // Spread out the lists so that they are simpler to process + // by storing the type of the method (i.e. set, get or nothing) + // and having separate lists for name, membername and wrapper + List *class_member_function_types; + List *class_member_function_names; + List *class_member_function_membernames; + List *class_member_function_wrappernames; /* */ Hash *ClassMemberTable; Hash *ClassMethodsTable; @@ -430,8 +440,12 @@ R::R() : member_name(0), class_name(0), processing_class_member_function(0), - class_member_functions(0), - class_member_set_functions(0), + // class_member_functions(0), + // class_member_set_functions(0), + class_member_function_types(0), + class_member_function_names(0), + class_member_function_wrappernames(0), + class_member_function_membernames(0), ClassMemberTable(0), ClassMethodsTable(0), SClassDefs(0), @@ -988,6 +1002,7 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { return n; } + /* -------------------------------------------------------------- * Write the methods for $ or $<- for accessing a member field in an * struct or union (or class). @@ -1060,6 +1075,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, char *ptr = Char(dup); ptr = &ptr[Len(dup) - 3]; + // Check the type here instead of the name if (!strcmp(ptr, "get")) { Printf(f->code, "%s'%s'", first ? "" : ", ", item); first = 0; @@ -1336,6 +1352,7 @@ int R::variableWrapper(Node *n) { void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, int isSet) { +#if 0 if(isSet < 0) { int n = Len(name); char *ptr = Char(name); @@ -1343,7 +1360,7 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0; } } - +/// RJB List *l = isSet ? class_member_set_functions : class_member_functions; if(!l) { @@ -1360,6 +1377,20 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, String *tmp = NewString(""); Wrapper_print(wrapper, tmp); Append(l, tmp); +#endif + if (!class_member_function_names) { + class_member_function_names = NewList(); + class_member_function_membernames = NewList(); + class_member_function_wrappernames = NewList(); + class_member_function_types = NewList(); + } + Append(class_member_function_types, isSet); + Append(class_member_function_names, name); + Append(class_member_function_membernames, memberName); + + String *tmp = NewString(""); + Wrapper_print(wrapper, tmp); + Append(class_member_function_wrappernames, tmp); // if we could put the wrapper in directly: Append(l, Copy(sfun)); if (debugMode) Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp); @@ -2261,7 +2292,13 @@ int R::functionWrapper(Node *n) { Would like to be able to do this so that we can potentially insert */ if(processing_member_access_function || processing_class_member_function) { - addAccessor(member_name, sfun, iname); + int method_type(R_MEMBER_NORMAL); + if (GetFlag("memberset", n)) { + method_type = R_MEMBER_SET; + } else if (GetFlag("memberget", n)) { + method_type = R_MEMBER_GET; + } + addAccessor(member_name, sfun, iname, method_type); } if (Getattr(n, "sym:overloaded") && @@ -2456,19 +2493,37 @@ int R::classDeclaration(Node *n) { // OutputArrayMethod(name, class_member_functions, sfile); +#if 0 + // RJB - this bit will need to change if (class_member_functions) OutputMemberReferenceMethod(name, 0, class_member_functions, sfile); if (class_member_set_functions) OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); +#else + // filter the class_member_lists by type, then call + // OutputMemberReferenceMethod + +#endif + + // if(class_member_functions) { + // Delete(class_member_functions); + // class_member_functions = NULL; + // } + // if(class_member_set_functions) { + // Delete(class_member_set_functions); + // class_member_set_functions = NULL; + // } - if(class_member_functions) { - Delete(class_member_functions); - class_member_functions = NULL; - } - if(class_member_set_functions) { - Delete(class_member_set_functions); - class_member_set_functions = NULL; - } + if (class_member_function_types) { + Delete(class_member_function_types); + class_member_function_types = NULL; + Delete(class_member_function_names); + class_member_function_names = NULL; + Delete(class_member_function_membernames); + class_member_function_membernames = NULL; + Delete(class_member_function_wrappernames); + class_member_function_wrappernames = NULL; + } if (Getattr(n, "has_destructor")) { Printf(sfile, "setMethod('delete', '_p%s', function(obj) {delete%s(obj)})\n", getRClassName(name), getRClassName(name)); From c42fb730f4ff0a58a7ece60b5a6be9ba9b27fb50 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Thu, 10 May 2018 19:13:39 +1000 Subject: [PATCH 1546/2031] first pass at removing string comparisons for set/get methods --- Source/Modules/r.cxx | 93 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 0181e8bce..5668abfc4 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -15,10 +15,6 @@ #include "swigmod.h" #include "cparse.h" -#define R_MEMBER_NORMAL 0 -#define R_MEMBER_SET 1 -#define R_MEMBER_GET 2 - static String* replaceInitialDash(const String *name) { String *retval; @@ -289,7 +285,10 @@ protected: int generateCopyRoutines(Node *n); int DumpCode(Node *n); - int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); + //int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); + int OutputMemberReferenceMethod(String *className, int isSet, + List *memberList, List *nameList, + List *typeList, File *out); int OutputArrayMethod(String *className, List *el, File *out); int OutputClassMemberTable(Hash *tb, File *out); int OutputClassMethodsTable(File *out); @@ -338,7 +337,7 @@ protected: void addAccessor(String *memberName, Wrapper *f, - String *name, int isSet = -1); + String *name, String *methodSetGet); static int getFunctionPointerNumArgs(Node *n, SwigType *tt); @@ -371,6 +370,9 @@ protected: String *member_name; String *class_name; + String *R_MEMBER_NORMAL; + String *R_MEMBER_SET; + String *R_MEMBER_GET; int processing_class_member_function; // List *class_member_functions; @@ -439,13 +441,16 @@ R::R() : processing_member_access_function(0), member_name(0), class_name(0), + R_MEMBER_NORMAL(NewString("normal")), + R_MEMBER_SET(NewString("set")), + R_MEMBER_GET(NewString("get")), processing_class_member_function(0), // class_member_functions(0), // class_member_set_functions(0), class_member_function_types(0), class_member_function_names(0), - class_member_function_wrappernames(0), class_member_function_membernames(0), + class_member_function_wrappernames(0), ClassMemberTable(0), ClassMethodsTable(0), SClassDefs(0), @@ -990,7 +995,7 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { } // OutputArrayMethod(className, el, out); - OutputMemberReferenceMethod(className, isSet, el, out); + //OutputMemberReferenceMethod(className, isSet, el, out); if(outputNamespaceInfo) Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : ""); @@ -1002,7 +1007,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { return n; } - /* -------------------------------------------------------------- * Write the methods for $ or $<- for accessing a member field in an * struct or union (or class). @@ -1015,9 +1019,10 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { * out - the stream where we write the code. * --------------------------------------------------------------*/ -int R::OutputMemberReferenceMethod(String *className, int isSet, - List *el, File *out) { - int numMems = Len(el), j; +int R::OutputMemberReferenceMethod(String *className, int isSet, + List *memberList, List *nameList, + List *typeList, File *out) { + int numMems = Len(memberList), j; int varaccessor = 0; if (numMems == 0) return SWIG_OK; @@ -1032,13 +1037,20 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Node *itemList = NewHash(); bool has_prev = false; - for(j = 0; j < numMems; j+=3) { - String *item = Getitem(el, j); - String *dup = Getitem(el, j + 1); - char *ptr = Char(dup); - ptr = &ptr[Len(dup) - 3]; + for(j = 0; j < numMems; j++) { + String *item = Getitem(memberList, j); + String *dup = Getitem(nameList, j); + String *setgetmethod = Getitem(typeList, j); - if (!strcmp(ptr, "get")) + // skip this one if it isn't a set method but we're + // creating a modification method + if (isSet && (setgetmethod != R_MEMBER_SET)) + continue; + // skip the set methods when creating accessor methods + if ((!isSet) && (setgetmethod == R_MEMBER_SET)) + continue; + + if ((!isSet) && (setgetmethod == R_MEMBER_GET)) varaccessor++; if (Getattr(itemList, item)) @@ -1068,17 +1080,15 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, if (!isSet && varaccessor > 0) { Printf(f->code, "%svaccessors = c(", tab8); - int first = 1; - for(j = 0; j < numMems; j+=3) { - String *item = Getitem(el, j); - String *dup = Getitem(el, j + 1); - char *ptr = Char(dup); - ptr = &ptr[Len(dup) - 3]; + bool first = true; + for(j = 0; j < numMems; j++) { + String *item = Getitem(memberList, j); + String *setgetmethod = Getitem(typeList, j); // Check the type here instead of the name - if (!strcmp(ptr, "get")) { + if (setgetmethod == R_MEMBER_GET) { Printf(f->code, "%s'%s'", first ? "" : ", ", item); - first = 0; + first = false; } } Printf(f->code, ");\n"); @@ -1351,7 +1361,7 @@ int R::variableWrapper(Node *n) { * --------------------------------------------------------------*/ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, - int isSet) { + String *methodSetGet) { #if 0 if(isSet < 0) { int n = Len(name); @@ -1384,7 +1394,7 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, class_member_function_wrappernames = NewList(); class_member_function_types = NewList(); } - Append(class_member_function_types, isSet); + Append(class_member_function_types, methodSetGet); Append(class_member_function_names, name); Append(class_member_function_membernames, memberName); @@ -1846,10 +1856,10 @@ int R::functionWrapper(Node *n) { /* Add the name of this member to a list for this class_name. We will dump all these at the end. */ - int n = Len(iname); + int nlen = Len(iname); char *ptr = Char(iname); bool isSet(0); - if (n > 4) isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0; + if (nlen > 4) isSet = Strcmp(NewString(&ptr[nlen-4]), "_set") == 0; String *tmp = NewString(""); @@ -2292,10 +2302,10 @@ int R::functionWrapper(Node *n) { Would like to be able to do this so that we can potentially insert */ if(processing_member_access_function || processing_class_member_function) { - int method_type(R_MEMBER_NORMAL); - if (GetFlag("memberset", n)) { + String *method_type = R_MEMBER_NORMAL; + if (GetFlag(n, "memberset")) { method_type = R_MEMBER_SET; - } else if (GetFlag("memberget", n)) { + } else if (GetFlag(n, "memberget")) { method_type = R_MEMBER_GET; } addAccessor(member_name, sfun, iname, method_type); @@ -2500,9 +2510,20 @@ int R::classDeclaration(Node *n) { if (class_member_set_functions) OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); #else - // filter the class_member_lists by type, then call - // OutputMemberReferenceMethod - + if (class_member_function_types) { + // count the number of set methods + unsigned setcount = 0; + Iterator ItType; + for (ItType = First(class_member_function_types) ; ItType.item; ItType = Next(ItType)) { + if (ItType.item == R_MEMBER_SET) ++setcount; + } + if (Len(class_member_function_types) - setcount > 0) { + OutputMemberReferenceMethod(name, 0, class_member_function_membernames, class_member_function_names, class_member_function_types, sfile); + } + if (setcount > 0) { + OutputMemberReferenceMethod(name, 1, class_member_function_membernames, class_member_function_names, class_member_function_types, sfile); + } + } #endif // if(class_member_functions) { From 9affb871de64c8a0724ad7e296c0a29e4f3279ba Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 6 Jun 2018 08:50:05 +1000 Subject: [PATCH 1547/2031] commenting out unused code --- Source/Modules/r.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 5668abfc4..108bc2e5a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -289,10 +289,13 @@ protected: int OutputMemberReferenceMethod(String *className, int isSet, List *memberList, List *nameList, List *typeList, File *out); +#if 0 + // not used int OutputArrayMethod(String *className, List *el, File *out); int OutputClassMemberTable(Hash *tb, File *out); int OutputClassMethodsTable(File *out); int OutputClassAccessInfo(Hash *tb, File *out); +#endif int defineArrayAccessors(SwigType *type); @@ -908,6 +911,8 @@ int R::DumpCode(Node *n) { +# if 0 +// not called /* ------------------------------------------------------------- * We may need to do more.... so this is left as a * stub for the moment. @@ -1007,6 +1012,8 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { return n; } +// end not used +#endif /* -------------------------------------------------------------- * Write the methods for $ or $<- for accessing a member field in an * struct or union (or class). @@ -1149,6 +1156,8 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, return SWIG_OK; } +#if 0 +// not used /* ------------------------------------------------------------- * Write the methods for [ or [<- for accessing a member field in an * struct or union (or class). @@ -1188,6 +1197,7 @@ int R::OutputArrayMethod(String *className, List *el, File *out) { return SWIG_OK; } +#endif /* ------------------------------------------------------------- * Called when a enumeration is to be processed. From dd24a5dffbf499d37c8fe1022948238451887b84 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Wed, 6 Jun 2018 10:41:48 +1000 Subject: [PATCH 1548/2031] Alternative version of using memberlist processing. This clarifies the logic within OutputMemberReferenceMethod by filtering the lists into classes, rather than doing it internally. Code isn't any shorter. --- Source/Modules/r.cxx | 76 +++++++++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 19 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 108bc2e5a..60ee56916 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -344,6 +344,10 @@ protected: static int getFunctionPointerNumArgs(Node *n, SwigType *tt); + // filtering of class member lists by function type. Used in constructing accessors + // are we allowed to use stl style functors to customise this? + List* filterMemberList(List *class_member_function_types, List *class_member_other, String *R_MEMBER, bool equal); + protected: bool copyStruct; bool memoryProfile; @@ -910,6 +914,30 @@ int R::DumpCode(Node *n) { } +List *R::filterMemberList(List *class_member_types, + List *class_member_other, + String *R_MEMBER, bool equal) { + // filters class_member_other based on whether corresponding elements of + // class_member_function_types are equal or notequal to R_MEMBER + List *CM = NewList(); + Iterator ftype, other; + + for (ftype = First(class_member_types), other = First(class_member_other); + ftype.item; + ftype=Next(ftype), other=Next(other)) { + // verbose, clean up later if the overall structure works + if (equal) { + if (ftype.item == R_MEMBER) { + Append(CM, other.item); + } + } else { + if (ftype.item != R_MEMBER) { + Append(CM, other.item); + } + } + } + return(CM); +} # if 0 // not called @@ -1049,15 +1077,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, String *dup = Getitem(nameList, j); String *setgetmethod = Getitem(typeList, j); - // skip this one if it isn't a set method but we're - // creating a modification method - if (isSet && (setgetmethod != R_MEMBER_SET)) - continue; - // skip the set methods when creating accessor methods - if ((!isSet) && (setgetmethod == R_MEMBER_SET)) - continue; - - if ((!isSet) && (setgetmethod == R_MEMBER_GET)) + if (setgetmethod == R_MEMBER_GET) varaccessor++; if (Getattr(itemList, item)) @@ -2521,18 +2541,36 @@ int R::classDeclaration(Node *n) { OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); #else if (class_member_function_types) { - // count the number of set methods - unsigned setcount = 0; - Iterator ItType; - for (ItType = First(class_member_function_types) ; ItType.item; ItType = Next(ItType)) { - if (ItType.item == R_MEMBER_SET) ++setcount; + + // collect the "set" methods + List *class_set_membernames = filterMemberList(class_member_function_types, + class_member_function_membernames, R_MEMBER_SET, true); + List *class_set_functionnames = filterMemberList(class_member_function_types, + class_member_function_names, R_MEMBER_SET, true); + // this one isn't used - collecting to keep code simpler + List *class_set_functiontypes = filterMemberList(class_member_function_types, + class_member_function_types, R_MEMBER_SET, true); + + // collect the others + List *class_other_membernames = filterMemberList(class_member_function_types, + class_member_function_membernames, R_MEMBER_SET, false); + List *class_other_functionnames = filterMemberList(class_member_function_types, + class_member_function_names, R_MEMBER_SET, false); + List *class_other_functiontypes = filterMemberList(class_member_function_types, + class_member_function_types, R_MEMBER_SET, false); + + if (Len(class_other_membernames) > 0) { + OutputMemberReferenceMethod(name, 0, class_other_membernames, class_other_functionnames, class_other_functiontypes, sfile); } - if (Len(class_member_function_types) - setcount > 0) { - OutputMemberReferenceMethod(name, 0, class_member_function_membernames, class_member_function_names, class_member_function_types, sfile); - } - if (setcount > 0) { - OutputMemberReferenceMethod(name, 1, class_member_function_membernames, class_member_function_names, class_member_function_types, sfile); + if (Len(class_set_membernames) > 0) { + OutputMemberReferenceMethod(name, 1, class_set_membernames, class_set_functionnames, class_set_functiontypes, sfile); } + Delete(class_set_membernames); + Delete(class_set_functionnames); + Delete(class_set_functiontypes); + Delete(class_other_membernames); + Delete(class_other_functionnames); + Delete(class_other_functiontypes); } #endif From 504ef74948a329440d88de3467283ba2444debc3 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Mon, 10 Sep 2018 21:57:19 +1000 Subject: [PATCH 1549/2031] Removed last instance of using Strcmp to check for a set/get method. Replaced with check for flag. --- Source/Modules/r.cxx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 60ee56916..752135cf3 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1886,11 +1886,7 @@ int R::functionWrapper(Node *n) { /* Add the name of this member to a list for this class_name. We will dump all these at the end. */ - int nlen = Len(iname); - char *ptr = Char(iname); - bool isSet(0); - if (nlen > 4) isSet = Strcmp(NewString(&ptr[nlen-4]), "_set") == 0; - + bool isSet(GetFlag(n, "memberset")); String *tmp = NewString(""); Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get"); From 7b7e5b001212274e91633be3ed5a2e5ed8f164ce Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Tue, 11 Sep 2018 09:58:33 +1000 Subject: [PATCH 1550/2031] Used Swig_name_register so that Swig_name_wrapper produces the correct name without a separate replace call. --- Source/Modules/r.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 752135cf3..4d4f71079 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1906,7 +1906,7 @@ int R::functionWrapper(Node *n) { int nargs; String *wname = Swig_name_wrapper(iname); - Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST); + if(overname) Append(wname, overname); Setattr(n,"wrap:name", wname); @@ -2924,6 +2924,9 @@ void R::main(int argc, char *argv[]) { } /// copyToR copyToC functions. + // Register the naming functions + Swig_name_register("wrapper", "R_swig_%f"); + } } From 5f865bdc7e550b420bacb954edb10a67e107048a Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Tue, 11 Sep 2018 10:32:58 +1000 Subject: [PATCH 1551/2031] calling Swig_name_setget --- Source/Modules/r.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 4d4f71079..b09828fc9 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1888,8 +1888,11 @@ int R::functionWrapper(Node *n) { bool isSet(GetFlag(n, "memberset")); - String *tmp = NewString(""); - Printf(tmp, "%s_%s", class_name, isSet ? "set" : "get"); + String *tmp = NewString(isSet ? Swig_name_set(NSPACE_TODO, class_name) : Swig_name_get(NSPACE_TODO, class_name)); + + if (debugMode) { + Printf(stdout, "functionWrapper TMP: %s\n", tmp); + } List *memList = Getattr(ClassMemberTable, tmp); if(!memList) { From b4c02b3267c5a018d1363e99fc771a9bdf663388 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Tue, 11 Sep 2018 11:21:03 +1000 Subject: [PATCH 1552/2031] moved registration routine and use swig_name_get --- Source/Modules/r.cxx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index b09828fc9..e59ee54df 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -781,6 +781,8 @@ int R::top(Node *n) { Swig_register_filebyname("snamespace", s_namespace); Printf(s_namespace, "useDynLib(%s)\n", DllName); } + // Register the naming functions + Swig_name_register("wrapper", "R_swig_%f"); /* Associate the different streams with names so that they can be used in %insert directives by the typemap code. */ @@ -1890,10 +1892,6 @@ int R::functionWrapper(Node *n) { String *tmp = NewString(isSet ? Swig_name_set(NSPACE_TODO, class_name) : Swig_name_get(NSPACE_TODO, class_name)); - if (debugMode) { - Printf(stdout, "functionWrapper TMP: %s\n", tmp); - } - List *memList = Getattr(ClassMemberTable, tmp); if(!memList) { memList = NewList(); @@ -2927,9 +2925,6 @@ void R::main(int argc, char *argv[]) { } /// copyToR copyToC functions. - // Register the naming functions - Swig_name_register("wrapper", "R_swig_%f"); - } } From af97d8f29d8dcca1a11c10dbd0b416860d14ec19 Mon Sep 17 00:00:00 2001 From: Davy Durham Date: Wed, 10 Apr 2019 05:26:53 +0000 Subject: [PATCH 1553/2031] fixing memleak of shared_ptr objects in python with creating a [wrapped] vector> from a list of shared_ptr where Bar is derived from Foo. --- Lib/python/pystdcommon.swg | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 0242e4d35..57b26d7e8 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -45,13 +45,23 @@ namespace swig { template struct traits_asptr { static int asptr(PyObject *obj, Type **val) { - Type *p = 0; - swig_type_info *descriptor = type_info(); - int res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; - if (SWIG_IsOK(res)) { - if (val) *val = p; + if (val) { + Type *p = 0; + swig_type_info *descriptor = type_info(); + int newmem = 0; + int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR; + if (SWIG_IsOK(res)) { + if (newmem & SWIG_CAST_NEW_MEMORY) { + res |= SWIG_NEWOBJMASK; + } + *val = p; + } + return res; + } else { + swig_type_info *descriptor = type_info(); + int res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR; + return res; } - return res; } }; From 65056349cf436c9f2dc505cc9d51a51c309648b0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Apr 2019 19:13:10 +0100 Subject: [PATCH 1554/2031] Add release notes summary --- CHANGES.current | 18 ++++++++---------- RELEASENOTES | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6529ac87d..3c819bd88 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -18,7 +18,7 @@ Version 4.0.0 (in progress) the contents are generated as the delete/dispose method's parameters declaration. 2019-03-30: wsfulton - [C#] #421 Fix CA1063 warning by implementing the recommended Dispose methods for + [C#] #421 Fix FxCop warning CA1063 by implementing the recommended Dispose methods for the IDisposable interface. Previously just the Dispose() method was generated. Now the Dispose() and Dispose(bool disposing) methods are generated. Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" @@ -99,13 +99,13 @@ Version 4.0.0 (in progress) string. 2019-02-22: tamuratak - #984 Add support for RTypedData introduced in Ruby 1.9.3. + [Ruby] #984 Add support for RTypedData introduced in Ruby 1.9.3. 2019-02-22: ZackerySpytz #1483 Fix compilation failures when a director class has final methods. 2019-02-21: wsfulton - #1240 Suppress Java 9 deprecation warnings on finalize method. + [Java] #1240 Suppress Java 9 deprecation warnings on finalize method. 2019-02-21: ZackerySpytz #1480 Fix some rejections of valid floating-point literals. @@ -933,7 +933,7 @@ Version 4.0.0 (in progress) u"\udcff" to the C layer (Python 3). 2017-11-24: joequant - Fix #1124 and return R_NilValue for null pointers + [R] Fix #1124 and return R_NilValue for null pointers 2017-11-29: wsfulton [Java] director exception handling improvements. @@ -978,7 +978,7 @@ Version 4.0.0 (in progress) 2017-10-07: olly Fix preprocessor handling of empty macro arguments to match that of - C/C++ compilers. Fixes https://github.com/swig/swig/pull/1111 and + C/C++ compilers. Fixes issue #1111 and https://sourceforge.net/p/swig/bugs/826/ 2017-10-06: wsfulton @@ -999,7 +999,7 @@ Version 4.0.0 (in progress) 2017-10-01: joequant allow R package names with docs allowing multiple get accessors in R - fix smrt-pointer and NAMESPACE support + fix smart-pointer and NAMESPACE support constructors now returning smart pointers (if class declared as such) smart-pointer classes deriving from parent smart-pointers @@ -1259,8 +1259,7 @@ Version 4.0.0 (in progress) 2017-08-05: olly [C++11] Allow static_assert at the top level (and disallow it right - after template). Fixes https://github.com/swig/swig/issues/1031 - reported by Artem V L. + after template). Fixes issue 1031 reported by Artem V L. 2017-08-02: wsfulton Fix incorrectly shown warning when an empty template instantiation was used on a @@ -1364,8 +1363,7 @@ Version 4.0.0 (in progress) 2017-06-13: olly [Perl] Fix testsuite to work without . in @INC - it was removed in Perl 5.26 for security reasons, and has also been removed from - older versions in some distros. Fixes - https://github.com/swig/swig/issues/997 reported by lfam. + older versions in some distros. Fixes #997 reported by lfam. 2017-06-03: wsfulton Fix %import on a file containing a file scope %fragment forced inclusion to not diff --git a/RELEASENOTES b/RELEASENOTES index 5f6560c3c..3fe78f2e2 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -7,6 +7,35 @@ Release Notes Detailed release notes are available with the release and are also published on the SWIG web site at http://swig.org/release.html. +SWIG-4.0.0 summary: +- Support for Doxygen documentation comments which are parsed and + converted into JavaDoc or PyDoc comments. +- STL wrappers improved for C#, Java and Ruby. +- C++11 STL containers added for Java, Python and Ruby. +- Improved support for parsing C++11 and C++14 code. +- Various fixes for shared_ptr. +- Various C preprocessor corner case fixes. +- Corner case fixes for member function pointers. +- Python module overhaul by simplifying the generated code and turning + most optimizations on by default. +- %template improvements wrt scoping to align with C++ explicit + template instantiations. +- Added support for a command-line options file (sometimes called a + response file). +- Numerous enhancements and fixes for all supported target languages. +- SWIG now classifies the status of target languages into either + 'Experimental' or 'Supported' to indicate the expected maturity + level. +- Support for CFFI, Allegrocl, Chicken, CLISP, S-EXP, UFFI, Pike, + Modula3 has been removed. +- Octave 4.4-5.1 support added. +- PHP5 support removed, PHP7 is now the supported PHP version. +- Minimum Python version required is now 2.7, 3.2-3.7 are the only + other versions supported. +- Added support for Javascript NodeJS versions 2-10. +- OCaml support is much improved and updated, minimum OCaml version + required is now 3.12.0. + SWIG-3.0.12 summary: - Add support for Octave-4.2. - Enhance %extend to support template functions. From 892f0fdc6ba2260f058f97b1e5e989baf7c56112 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Apr 2019 19:42:40 +0100 Subject: [PATCH 1555/2031] Update ax_boost_base.m4 to latest from autoconf archive Updated to serial #45. This is in preparation to a possible fix for issue #1435. The use of AS_CASE requires autoconf-2.60 or later. --- Tools/config/ax_boost_base.m4 | 248 ++++++++++++++++++---------------- configure.ac | 10 +- 2 files changed, 133 insertions(+), 125 deletions(-) diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4 index 0e0f266dc..d54039576 100644 --- a/Tools/config/ax_boost_base.m4 +++ b/Tools/config/ax_boost_base.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html +# https://www.gnu.org/software/autoconf-archive/ax_boost_base.html # =========================================================================== # # SYNOPSIS @@ -10,7 +10,7 @@ # # Test for the Boost C++ libraries of a particular version (or newer) # -# If no path to the installed boost library is given the macro searches +# If no path to the installed boost library is given the macro searchs # under /usr, /usr/local, /opt and /opt/local and evaluates the # $BOOST_ROOT environment variable. Further documentation is available at # . @@ -33,7 +33,15 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 26 +#serial 45 + +# example boost program (need to pass version) +m4_define([_AX_BOOST_BASE_PROGRAM], + [AC_LANG_PROGRAM([[ +#include +]],[[ +(void) ((void)sizeof(char[1 - 2*!!((BOOST_VERSION) < ($1))])); +]])]) AC_DEFUN([AX_BOOST_BASE], [ @@ -44,104 +52,121 @@ AC_ARG_WITH([boost], or disable it (ARG=no) @<:@ARG=yes@:>@ ])], [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi + AS_CASE([$withval], + [no],[want_boost="no";_AX_BOOST_BASE_boost_path=""], + [yes],[want_boost="yes";_AX_BOOST_BASE_boost_path=""], + [want_boost="yes";_AX_BOOST_BASE_boost_path="$withval"]) ], [want_boost="yes"]) AC_ARG_WITH([boost-libdir], - AS_HELP_STRING([--with-boost-libdir=LIB_DIR], - [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), - [ - if test -d "$withval" - then - ac_boost_lib_path="$withval" - else - AC_MSG_ERROR(--with-boost-libdir expected directory name) - fi - ], - [ac_boost_lib_path=""] -) + [AS_HELP_STRING([--with-boost-libdir=LIB_DIR], + [Force given directory for boost libraries. + Note that this will override library path detection, + so use this parameter only if default library detection fails + and you know exactly where your boost libraries are located.])], + [ + AS_IF([test -d "$withval"], + [_AX_BOOST_BASE_boost_lib_path="$withval"], + [AC_MSG_ERROR([--with-boost-libdir expected directory name])]) + ], + [_AX_BOOST_BASE_boost_lib_path=""]) -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) +BOOST_LDFLAGS="" +BOOST_CPPFLAGS="" +AS_IF([test "x$want_boost" = "xyes"], + [_AX_BOOST_BASE_RUNDETECT([$1],[$2],[$3])]) +AC_SUBST(BOOST_CPPFLAGS) +AC_SUBST(BOOST_LDFLAGS) +]) + + +# convert a version string in $2 to numeric and affect to polymorphic var $1 +AC_DEFUN([_AX_BOOST_BASE_TONUMERICVERSION],[ + AS_IF([test "x$2" = "x"],[_AX_BOOST_BASE_TONUMERICVERSION_req="1.20.0"],[_AX_BOOST_BASE_TONUMERICVERSION_req="$2"]) + _AX_BOOST_BASE_TONUMERICVERSION_req_shorten=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\.[[0-9]]*\)'` + _AX_BOOST_BASE_TONUMERICVERSION_req_major=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '\([[0-9]]*\)'` + AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_major" = "x"], + [AC_MSG_ERROR([You should at least specify libboost major version])]) + _AX_BOOST_BASE_TONUMERICVERSION_req_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.\([[0-9]]*\)'` + AS_IF([test "x$_AX_BOOST_BASE_TONUMERICVERSION_req_minor" = "x"], + [_AX_BOOST_BASE_TONUMERICVERSION_req_minor="0"]) + _AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + AS_IF([test "X$_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor" = "X"], + [_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor="0"]) + _AX_BOOST_BASE_TONUMERICVERSION_RET=`expr $_AX_BOOST_BASE_TONUMERICVERSION_req_major \* 100000 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_minor \* 100 \+ $_AX_BOOST_BASE_TONUMERICVERSION_req_sub_minor` + AS_VAR_SET($1,$_AX_BOOST_BASE_TONUMERICVERSION_RET) +]) + +dnl Run the detection of boost should be run only if $want_boost +AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ + _AX_BOOST_BASE_TONUMERICVERSION(WANT_BOOST_VERSION,[$1]) succeeded=no + + AC_REQUIRE([AC_CANONICAL_HOST]) dnl On 64-bit systems check for system libraries in both lib64 and lib. dnl The former is specified by FHS, but e.g. Debian does not adhere to dnl this (as it rises problems for generic multi-arch support). dnl The last entry in the list is chosen by default when no libraries dnl are found, e.g. when only header-only libraries are installed! - libsubdirs="lib" - ax_arch=`uname -m` - case $ax_arch in - x86_64) - libsubdirs="lib64 libx32 lib lib64" - ;; - ppc64|s390x|sparc64|aarch64|ppc64le) - libsubdirs="lib64 lib lib64 ppc64le" - ;; - esac + AS_CASE([${host_cpu}], + [x86_64],[libsubdirs="lib64 libx32 lib lib64"], + [ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"], + [libsubdirs="lib"] + ) dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give dnl them priority over the other paths since, if libs are found there, they dnl are almost assuredly the ones desired. - AC_REQUIRE([AC_CANONICAL_HOST]) - libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs" - - case ${host_cpu} in - i?86) - libsubdirs="lib/i386-${host_os} $libsubdirs" - ;; - esac + AS_CASE([${host_cpu}], + [i?86],[multiarch_libsubdir="lib/i386-${host_os}"], + [multiarch_libsubdir="lib/${host_cpu}-${host_os}"] + ) dnl first we check the system location for boost libraries dnl this location ist chosen if boost libraries are installed with the --layout=system option dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_CPPFLAGS="-I$ac_boost_path/include" - for ac_boost_path_tmp in $libsubdirs; do - if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then - BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" - break - fi - done - elif test "$cross_compiling" != yes; then - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - for libsubdir in $libsubdirs ; do - if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[ + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"]) + AS_IF([test -d "$_AX_BOOST_BASE_boost_path/include" && test -r "$_AX_BOOST_BASE_boost_path/include"],[ + AC_MSG_RESULT([yes]) + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include" + for _AX_BOOST_BASE_boost_path_tmp in $multiarch_libsubdir $libsubdirs; do + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) lib path in "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"]) + AS_IF([test -d "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" && test -r "$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp" ],[ + AC_MSG_RESULT([yes]) + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$_AX_BOOST_BASE_boost_path_tmp"; + break; + ], + [AC_MSG_RESULT([no])]) + done],[ + AC_MSG_RESULT([no])]) + ],[ + if test X"$cross_compiling" = Xyes; then + search_libsubdirs=$multiarch_libsubdir + else + search_libsubdirs="$multiarch_libsubdir $libsubdirs" + fi + for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then + for libsubdir in $search_libsubdirs ; do + if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done - BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path_tmp/$libsubdir" + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path_tmp/include" break; fi done - fi + ]) dnl overwrite ld flags if we have required special directory with dnl --with-boost-libdir parameter - if test "$ac_boost_lib_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_lib_path" - fi + AS_IF([test "x$_AX_BOOST_BASE_boost_lib_path" != "x"], + [BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_lib_path"]) + AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION)]) CPPFLAGS_SAVED="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" export CPPFLAGS @@ -152,15 +177,7 @@ if test "x$want_boost" = "xyes"; then AC_REQUIRE([AC_PROG_CXX]) AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ + AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes @@ -172,40 +189,50 @@ if test "x$want_boost" = "xyes"; then dnl if we found no boost with system layout we search for boost libraries dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then + if test "x$succeeded" != "xyes" ; then CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" BOOST_CPPFLAGS= - BOOST_LDFLAGS= + if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then + BOOST_LDFLAGS= + fi _version=0 - if test "$ac_boost_path" != ""; then - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + if test -n "$_AX_BOOST_BASE_boost_path" ; then + if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path"; then + for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then + if test "x$V_CHECK" = "x1" ; then _version=$_version_tmp fi VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path/include/boost-$VERSION_UNDERSCORE" done dnl if nothing found search for layout used in Windows distributions if test -z "$BOOST_CPPFLAGS"; then - if test -d "$ac_boost_path/boost" && test -r "$ac_boost_path/boost"; then - BOOST_CPPFLAGS="-I$ac_boost_path" + if test -d "$_AX_BOOST_BASE_boost_path/boost" && test -r "$_AX_BOOST_BASE_boost_path/boost"; then + BOOST_CPPFLAGS="-I$_AX_BOOST_BASE_boost_path" fi fi + dnl if we found something and BOOST_LDFLAGS was unset before + dnl (because "$_AX_BOOST_BASE_boost_lib_path" = ""), set it here. + if test -n "$BOOST_CPPFLAGS" && test -z "$BOOST_LDFLAGS"; then + for libsubdir in $libsubdirs ; do + if ls "$_AX_BOOST_BASE_boost_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$_AX_BOOST_BASE_boost_path/$libsubdir" + fi fi else - if test "$cross_compiling" != yes; then - for ac_boost_path in /usr /usr/local /opt /opt/local ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + if test "x$cross_compiling" != "xyes" ; then + for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do + if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then + for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then + if test "x$V_CHECK" = "x1" ; then _version=$_version_tmp - best_path=$ac_boost_path + best_path=$_AX_BOOST_BASE_boost_path fi done fi @@ -213,7 +240,7 @@ if test "x$want_boost" = "xyes"; then VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - if test "$ac_boost_lib_path" = ""; then + if test -z "$_AX_BOOST_BASE_boost_lib_path" ; then for libsubdir in $libsubdirs ; do if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done @@ -221,7 +248,7 @@ if test "x$want_boost" = "xyes"; then fi fi - if test "x$BOOST_ROOT" != "x"; then + if test -n "$BOOST_ROOT" ; then for libsubdir in $libsubdirs ; do if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi done @@ -230,7 +257,7 @@ if test "x$want_boost" = "xyes"; then stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then + if test "x$V_CHECK" = "x1" && test -z "$_AX_BOOST_BASE_boost_lib_path" ; then AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) BOOST_CPPFLAGS="-I$BOOST_ROOT" BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" @@ -245,15 +272,7 @@ if test "x$want_boost" = "xyes"; then export LDFLAGS AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ + AC_COMPILE_IFELSE([_AX_BOOST_BASE_PROGRAM($WANT_BOOST_VERSION)],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes @@ -262,17 +281,15 @@ if test "x$want_boost" = "xyes"; then AC_LANG_POP([C++]) fi - if test "$succeeded" != "yes" ; then - if test "$_version" = "0" ; then - AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) + if test "x$succeeded" != "xyes" ; then + if test "x$_version" = "x0" ; then + AC_MSG_NOTICE([[We could not detect the boost libraries (version $1 or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) else AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) fi # execute ACTION-IF-NOT-FOUND (if present): ifelse([$3], , :, [$3]) else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) # execute ACTION-IF-FOUND (if present): ifelse([$2], , :, [$2]) @@ -280,6 +297,5 @@ if test "x$want_boost" = "xyes"; then CPPFLAGS="$CPPFLAGS_SAVED" LDFLAGS="$LDFLAGS_SAVED" -fi ]) diff --git a/configure.ac b/configure.ac index 6380260f1..1873797d6 100644 --- a/configure.ac +++ b/configure.ac @@ -3,10 +3,7 @@ dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. AC_INIT([swig],[4.0.0],[http://www.swig.org]) - -dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED -dnl definition below can be removed -AC_PREREQ(2.58) +AC_PREREQ(2.60) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) @@ -44,11 +41,6 @@ AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), A fi dnl PCRE - -dnl AX_PATH_GENERIC() relies on AC_PROG_SED() but it is defined only in -dnl autoconf 2.60 so trivially predefine it ourselves for the older versions -m4_ifdef([AC_PROG_SED],, [AC_DEFUN([AC_PROG_SED], [AC_PATH_PROG([SED], sed)])]) - AC_ARG_WITH([pcre], [AS_HELP_STRING([--without-pcre], [Disable support for regular expressions using PCRE])], From 1955758f276279d82916608aa49cb8456367844e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Apr 2019 19:51:23 +0100 Subject: [PATCH 1556/2031] Update ax_path_generic.m4 to latest from autoconf archive Purely cosmetic change Updated to serial #17. --- Tools/config/ax_path_generic.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/config/ax_path_generic.m4 b/Tools/config/ax_path_generic.m4 index f77fc78d6..87966890b 100644 --- a/Tools/config/ax_path_generic.m4 +++ b/Tools/config/ax_path_generic.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_path_generic.html +# https://www.gnu.org/software/autoconf-archive/ax_path_generic.html # =========================================================================== # # SYNOPSIS @@ -14,11 +14,11 @@ # The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION # is specified, the script must also support the `--version' arg. If the # `--with-library-[exec-]prefix' arguments to ./configure are given, it -# must also support `--prefix' and `--exec-prefix'. Prefereable use +# must also support `--prefix' and `--exec-prefix'. Preferably use # CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and # LIBS-ARG instead of `--libs`, if given. # -# The SED-EXPR-EXTRACTOR parameter representes the expression used in sed +# The SED-EXPR-EXTRACTOR parameter represents the expression used in sed # to extract the version number. Use it if your 'foo-config --version' # dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'. # @@ -69,7 +69,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 13 +#serial 17 AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC]) AC_DEFUN([AX_PATH_GENERIC],[ From e15c11248070169847f51feb2d2256a82502bec3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Apr 2019 19:56:30 +0100 Subject: [PATCH 1557/2031] Update ax_compare_version.m4 to latest from autoconf archive Purely cosmetic changes Updated to serial #13 --- Tools/config/ax_compare_version.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tools/config/ax_compare_version.m4 b/Tools/config/ax_compare_version.m4 index 74dc0fdd9..ffb4997e8 100644 --- a/Tools/config/ax_compare_version.m4 +++ b/Tools/config/ax_compare_version.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html +# https://www.gnu.org/software/autoconf-archive/ax_compare_version.html # =========================================================================== # # SYNOPSIS @@ -79,7 +79,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 11 +#serial 13 dnl ######################################################################### AC_DEFUN([AX_COMPARE_VERSION], [ @@ -146,7 +146,7 @@ x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` ], [.+],[ AC_WARNING( - [illegal OP numeric parameter: $2]) + [invalid OP numeric parameter: $2]) ],[]) # Pad zeros at end of numbers to make same length. @@ -162,7 +162,7 @@ x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` [ne],[ test "x$A" != "x$B" && ax_compare_version=true ],[ - AC_WARNING([illegal OP parameter: $2]) + AC_WARNING([invalid OP parameter: $2]) ]) ]) From dc4fb85d003ac6fa5402fe795aceffb76f5e2f3b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Apr 2019 20:13:44 +0100 Subject: [PATCH 1558/2031] cpp11_thread_local testcase fix for Visual C++ --- Examples/test-suite/cpp11_thread_local.i | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/cpp11_thread_local.i b/Examples/test-suite/cpp11_thread_local.i index 6a1019824..21f21859b 100644 --- a/Examples/test-suite/cpp11_thread_local.i +++ b/Examples/test-suite/cpp11_thread_local.i @@ -20,8 +20,10 @@ extern "C++" thread_local int ecpptval; thread_local int ThreadLocals::stval = 11; thread_local int ThreadLocals::tsval = 22; +#if !defined(_MSC_VER) thread_local const int ThreadLocals::stcval88; thread_local const int ThreadLocals::tscval99; +#endif %} %{ From bc615e8a6e4428db5736636dad0377e2f8301a31 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2019 19:01:52 +0100 Subject: [PATCH 1559/2031] Correct out of date html links --- Doc/Manual/Android.html | 4 ++-- Doc/Manual/CCache.html | 2 +- Doc/Manual/CSharp.html | 10 +++++----- Doc/Manual/Doxygen.html | 18 +++++++++--------- Doc/Manual/Go.html | 2 +- Doc/Manual/Introduction.html | 2 +- Doc/Manual/Java.html | 13 ++++++------- Doc/Manual/Javascript.html | 10 +++++----- Doc/Manual/Mzscheme.html | 2 +- Doc/Manual/Php.html | 2 +- Doc/Manual/Python.html | 6 +++--- Doc/Manual/Scilab.html | 4 ++-- Doc/Manual/Typemaps.html | 4 ++-- Doc/Manual/Windows.html | 2 +- 14 files changed, 40 insertions(+), 41 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 894724188..944a88d65 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -48,7 +48,7 @@ This chapter contains a few Android specific notes and examples.

    -The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. +The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places). Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):

    @@ -326,7 +326,7 @@ include $(BUILD_SHARED_LIBRARY)

    -See the Android NDK documentation for more on the NDK build system and getting started with the NDK. +See the Android NDK documentation for more on the NDK build system and getting started with the NDK. A simple invocation of ndk-build will compile the .c files and generate a shared object/system library. Output will be similar to:

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 3a7db5c7b..edd435fa1 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -458,7 +458,7 @@ Thanks to the following people for their contributions to ccache

    ccache was written by Andrew Tridgell -http://samba.org/~tridge/. +https://www.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 diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 0526766b5..1fc2d211e 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -64,15 +64,15 @@ The wrapper code implementation uses C# and the Platform Invoke (PInvoke) interf The PInvoke interface has been chosen over Microsoft's Managed C++ interface as it is portable to both Microsoft Windows and non-Microsoft platforms. PInvoke is part of the ECMA/ISO C# specification. It is also better suited for robust production environments due to the Managed C++ flaw called the -Mixed DLL Loading Problem. +Mixed DLL Loading Problem. SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using -Mono and Portable.NET. +Mono and Portable.NET.

    To get the most out of this chapter an understanding of interop is required. -The Microsoft Developer Network (MSDN) has a good reference guide in a section titled "Interop Marshaling". -Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries. +The Microsoft Developer Network (MSDN) has a good reference guide in a section titled "Interop Marshaling". +Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

    22.1.1 SWIG 2 Compatibility

    @@ -763,7 +763,7 @@ another thread may produce enough garbage to trigger garbage collection.

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

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index b14b05ba3..8a847bb7e 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -63,13 +63,13 @@ supported.

    The Doxygen Translation module of SWIG adds an extra layer of functionality to SWIG, allowing automated translation of Doxygen formatted comments +"http://www.doxygen.nl/manual/">Doxygen formatted comments from input files into a documentation language more suited for the target language. Currently this module only translates into Javadoc and Pydoc for the SWIG Java and Python modules. Other extensions could be added at a later date. The Doxygen Translation module originally started as -a Google Summer of +a Google Summer of Code proposal from Summer 2008.

    @@ -79,14 +79,14 @@ Code proposal from Summer 2008.

    To make use of the comment translation system, your documentation comments must be in properly formatted Doxygen. Doxygen comments can be +"http://www.doxygen.nl/manual/">Doxygen. Doxygen comments can be present in your main SWIG interface file or any header file that it imports. You are advised to be validate that your comments compile properly with Doxygen before you try to translate them. Doxygen itself is a more comprehensive tool and can provide you better feedback for correcting any syntax errors that may be present. Please look at Doxygen's Documenting the +"http://www.doxygen.nl/manual/docblocks.html"> Documenting the code for the full comment format specifications. However, SWIG's Doxygen parser will still report many errors and warnings found in comments (like unterminated strings or missing ending tags). @@ -94,7 +94,7 @@ in comments (like unterminated strings or missing ending tags).

    Currently, the whole subset of Doxygen comment styles is supported -(See +(See Documenting the code). Here they are:

    @@ -293,7 +293,7 @@ make much sense for the other languages without explicit ownership management.

    Doxygen syntax is rather rich and, in addition to simple commands such as @transferfull, it is also possible to define commands with arguments. -As explained in Doxygen documentation, +As explained in Doxygen documentation, the arguments can have a range of a single word, everything until the end of line or everything until the end of the next paragraph. Currently, only the "end of line" case is supported using the range="line" argument of the @@ -818,7 +818,7 @@ Here is the list of all Doxygen tags and the description of how they are transla

    Doxygen has a wealth of tags such as @latexonly that have no equivalent in Javadoc (all supported tags are listed in -Javadoc documentation). +Javadoc documentation). As a result several tags have no translation or particular use, such as some linking and section tags. These are suppressed with their content just printed out (if the tag has any @@ -1223,9 +1223,9 @@ completely (doxygen:notranslate feature). Then SWIG will just copy the comments to the proxy file and reformat them if needed, but all the comment content will be left as is. As Doxygen doesn't support special commands in Python comments -(see Doxygen +(see Doxygen docs), you may want to use some tool like doxypy -(http://code.foosel.org/doxypy) +(doxypy) to do the work.

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 047b46edf..b16c764fb 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -1291,7 +1291,7 @@ fraction := modulename.Modf(5.0, ptr)

    Since this is ugly, you may want to wrap the swig-generated API with -some additional functions written in go that +some additional functions written in go that hide the ugly details.

    There are no char *OUTPUT typemaps. However you can diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 1a2e26a6d..149e86877 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -464,7 +464,7 @@ for further information on this and other Autoconf macros.

    -There is growing support for SWIG in some build tools, for example CMake +There is growing support for SWIG in some build tools, for example CMake is a cross-platform, open-source build manager with built in support for SWIG. CMake can detect the SWIG executable and many of the target language libraries for linking against. CMake knows how to build shared libraries and loadable modules on many different operating systems. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index cdefba6b4..e0c6aed03 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1113,11 +1113,10 @@ Typesafe enums have their advantages over using plain integers in that they can However, there are limitations. For example, they cannot be used in switch statements and serialization is an issue. Please look at the following references for further information: -http://java.sun.com/developer/Books/shiftintojava/page1.html#replaceenums Replace Enums with Classes in Effective Java Programming on the Sun website, -Create enumerated constants in Java JavaWorld article, -Java Tip 133: More on typesafe enums and -Java Tip 122: Beware of Java typesafe enumerations JavaWorld tips. +Create enumerated constants in Java JavaWorld article, +Java Tip 133: More on typesafe enums and +Java Tip 122: Beware of Java typesafe enumerations JavaWorld tips.

    @@ -2763,7 +2762,7 @@ The finalize() method calls delete() which frees any malloc'd The idea is for delete() to be called when you have finished with the C/C++ object. Ideally you need not call delete(), but rather leave it to the garbage collector to call it from the finalizer. When a program exits, the garbage collector does not guarantee to call all finalizers. -An insight into the reasoning behind this can be obtained from Hans Boehm's Destructors, Finalizers, and Synchronization paper. +An insight into the reasoning behind this can be obtained from Hans Boehm's Destructors, Finalizers, and Synchronization paper. Depending on what the finalizers do and which operating system you use, this may or may not be a problem.

    @@ -2787,7 +2786,7 @@ Call the System.runFinalizersOnExit(true) or Runtime.getRuntime().r This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.

    In many cases you will be lucky and find that it works, but it is not to be advocated. -Have a look at Java web site and search for runFinalizersOnExit. +Have a look at Java web site and search for runFinalizersOnExit.

  • @@ -5645,7 +5644,7 @@ This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. You are advised to be familiar with the material in the "Typemaps" chapter. While not absolutely essential knowledge, this section assumes some familiarity with the Java Native Interface (JNI). -JNI documentation can be consulted either online at Sun's Java web site or from a good JNI book. +JNI documentation can be consulted either online at the Java web site or from a good JNI book. The following two books are recommended:

      diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index c328bbb6b..021d4e380 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -56,10 +56,10 @@

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. -Javascript has gone beyond being a browser-based scripting language and with node.js, it is also used as a backend development language.

      +Javascript has gone beyond being a browser-based scripting language and with node.js, it is also used as a backend development language.

      Native Javascript extensions can be used for applications that embed a web-browser view or that embed a Javascript engine (such as node.js). Extending a general purpose web-browser is not possible as this would be a severe security issue.

      -

      SWIG Javascript currently supports JavascriptCore, the Javascript engine used by Safari/Webkit, and v8, which is used by Chromium and node.js.

      -

      WebKit is a modern browser implementation available as open-source which can be embedded into an application. +

      SWIG Javascript currently supports JavascriptCore, the Javascript engine used by Safari/Webkit, and v8, which is used by Chromium and node.js.

      +

      WebKit is a modern browser implementation available as open-source which can be embedded into an application. With node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      @@ -289,7 +289,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports)

      27.3.2.2 GTK

      -

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      +

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      An integration of a native extension 'example' would look like this:

      @@ -604,7 +604,7 @@ at ReadStream.EventEmitter.emit (events.js:98:17)
       at emitKey (readline.js:1095:12)

      -Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance. +Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      27.5 Implementation

      diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 860a5c412..aae181ee9 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -170,7 +170,7 @@ Some points of interest:

      -See the C API for more description of using the mechanism for adding extensions. The main documentation is here. +See the C API for more description of using the mechanism for adding extensions. The main documentation is here.

      diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 1b8b2d468..d80731c5c 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -153,7 +153,7 @@ If the module is in PHP's default extension directory, you can omit the path.

      For some SAPIs (for example, the CLI SAPI) you can instead use the -dl() function to load +dl() function to load an extension at run time, by adding a line like this to the start of each PHP script which uses your extension:

      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 2554e9da3..5a3947d4d 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -301,7 +301,7 @@ how you might go about compiling and using the generated files.

      The preferred approach to building an extension module for Python is to compile it with distutils, which comes with all recent versions of Python -(Distutils Docs). +(Distutils Docs).

      @@ -2355,7 +2355,7 @@ wrapped class is turned into a new Python built-in type which inherits from from the wrapped methods. For more information about Python built-in extensions, please refer to the Python documentation:

      -

      http://docs.python.org/extending/newtypes.html

      +

      https://docs.python.org/3/extending/newtypes.html

      32.4.2.1 Limitations

      @@ -2574,7 +2574,7 @@ automatically converted to Python slot operators, refer to the file

      Read about all of the available Python slots here: -http://docs.python.org/c-api/typeobj.html

      +https://docs.python.org/3/c-api/typeobj.html

      There are two ways to define a Python slot function: dispatch to a diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 29c4eacf0..88ab8043e 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -973,7 +973,7 @@ ans =

      -Note: the pointer to the struct works as described in Pointers. For example, the type of the struct pointer can be get with typeof, as following: +Note: the pointer to the struct works as described in Pointers. For example, the type of the struct pointer can be get with typeof, as following:

      @@ -1037,7 +1037,7 @@ ans  =
       

      -Note: like structs, class pointers are mapped as described in Pointers. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through overloading) to implement a custom print for the Point class: +Note: like structs, class pointers are mapped as described in Pointers. Let's give an example which shows that each class pointer type is a new type in Scilab that can be used for example (through overloading) to implement a custom print for the Point class:

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
      index d34bb2801..8a31dbf10 100644
      --- a/Doc/Manual/Typemaps.html
      +++ b/Doc/Manual/Typemaps.html
      @@ -672,8 +672,8 @@ void wrap_foo(char *s, int x) {
       
       
       

      -SWIG has parallels to Aspect Oriented Software Development (AOP). -The AOP terminology with respect to SWIG typemaps can be viewed as follows: +SWIG has parallels to Aspect Oriented Software Development (AOP). +The AOP terminology with respect to SWIG typemaps can be viewed as follows:

      • Cross-cutting concerns: The cross-cutting concerns are the modularization of the functionality that the typemaps implement, which is primarily marshalling of types from/to the target language and C/C++. diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 01caf6c7f..faea8b4e7 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -249,7 +249,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
        1. Download the following packages from the MinGW download page - or MinGW SourceForge download page. + or MinGW SourceForge download page. Note that at the time of writing, the majority of these are in the Current release list and some are in the Snapshot or Previous release list.
            From 6791f8b769fd5a82392a3bd2b9d14daa78577a79 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2019 19:31:32 +0100 Subject: [PATCH 1560/2031] Add linkchecker3 make target to check internal links Make sure all internal links use # anchors which are needed for wkhtmltopdf --- Doc/Manual/Javascript.html | 2 +- Doc/Manual/Makefile | 6 ++++++ Doc/Manual/SWIG.html | 2 +- Doc/Manual/SWIGPlus.html | 6 +++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 021d4e380..417ee4585 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -1,7 +1,7 @@ - + diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index ee9a0af34..9505adb91 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -89,3 +89,9 @@ linkchecker2: cp *.png linkchecker-tmp (cd linkchecker-tmp && linkchecker --config=../linkchecker.config -F text --no-warnings SWIGDocumentation.html) +# Simple check for relative links (there shouldn't be any), they don't translate properly creating the .pdf doc +# with wkhtmltopdf. For example, href="SWIG.html" needs to be href="SWIG.html#SWIG" +linkchecker3: + @echo "The following list should just contain SWIGDocumentation.html and SWIGDocumentation.pdf," + @echo "as all links should have an anchor (with a #) or be a full url beginning http." + grep 'href="' *.html | sed -e 's/.*href="\(.*\)">.*$$/\1/' | grep -v "#" | grep -v "^http" | grep -v "^style.css" diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 79d52ef56..64db9c6c6 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -1826,7 +1826,7 @@ When wrapping C code, simple use of identifiers/symbols with %rename us When wrapping C++ code, simple use of simple identifiers/symbols with %rename might be too limiting when using C++ features such as function overloading, default arguments, namespaces, template specialization etc. If you are using the %rename directive and C++, make sure you read the -SWIG and C++ chapter and in particular the section on +SWIG and C++ chapter and in particular the section on Renaming and ambiguity resolution for method overloading and default arguments.

            diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 8ad9daedf..3a50cf8ce 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -88,9 +88,9 @@ This chapter describes SWIG's support for wrapping C++. It is mostly concerned about C++ as defined by the C++ 98 and 03 standards. For additions to the original C++ standard, please read the -SWIG and C++11, -SWIG and C++14 and -SWIG and C++17 chapters. +SWIG and C++11, +SWIG and C++14 and +SWIG and C++17 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ANSI C. Support for C++ builds upon ANSI C From 4e5d1891e6d5ce58d61a70a0c2be1305ce213e00 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2019 22:55:56 +0100 Subject: [PATCH 1561/2031] testcase fixes for gcc-9 --- Examples/test-suite/cpp11_lambda_functions.i | 13 ++++++++----- Examples/test-suite/java/rename1_runme.java | 4 ---- Examples/test-suite/java/rename2_runme.java | 4 ---- Examples/test-suite/java/rename3_runme.java | 4 ---- Examples/test-suite/java/rename4_runme.java | 4 ---- Examples/test-suite/javascript/rename1_runme.js | 4 ---- Examples/test-suite/javascript/rename2_runme.js | 4 ---- Examples/test-suite/javascript/rename3_runme.js | 4 ---- Examples/test-suite/javascript/rename4_runme.js | 4 ---- Examples/test-suite/rename.h | 6 +----- Examples/test-suite/rename1.i | 7 +------ Examples/test-suite/rename2.i | 2 +- Examples/test-suite/rename3.i | 2 +- Examples/test-suite/rename4.i | 12 ++---------- 14 files changed, 14 insertions(+), 60 deletions(-) diff --git a/Examples/test-suite/cpp11_lambda_functions.i b/Examples/test-suite/cpp11_lambda_functions.i index fc02aadb2..3d7d76d60 100644 --- a/Examples/test-suite/cpp11_lambda_functions.i +++ b/Examples/test-suite/cpp11_lambda_functions.i @@ -43,14 +43,17 @@ auto lambda1 = [](int x, int y) -> int { return x+y; }; single statement "return expr;". */ auto lambda2 = [](int x, int y) { return x+y; }; -auto lambda3 = [&](int x, int y) { return x+y; }; -auto lambda4 = [=](int x, int y) { return x+y; }; int thing = 0; #ifdef SWIG -// Not strictly correct as captured variables should have non-automatic storage duration, ie shouldn't capture globals. gcc-4.7 warns about this, but we check that SWIG can parse this anyway. +// This is not strictly legal: non-local lambda expression cannot have a capture-default +// gcc-4.7 warns about this and gcc-9 gives an error, but we check that SWIG can parse this anyway. +auto lambda3 = [&](int x, int y) { return x+y; }; +auto lambda4 = [=](int x, int y) { return x+y; }; auto lambda5 = [=,&thing]() { return thing; }; #else -auto lambda5 = [=]() { return thing; }; +auto lambda3 = [](int x, int y) { return x+y; }; +auto lambda4 = [](int x, int y) { return x+y; }; +auto lambda5 = []() { return thing; }; #endif void fn() { @@ -115,6 +118,6 @@ int runLambdaInline() { // TODO int(*lambda101notauto)(int, int) = [] (int a, int b) { return a + b; }; int lambda102 = [] (int a, int b) mutable { return a + b; }(1, 2); -void lambda_init(int = ([=]{ return 0; })()); +void lambda_init(int = ([]{ return 0; })()); %} diff --git a/Examples/test-suite/java/rename1_runme.java b/Examples/test-suite/java/rename1_runme.java index 058de41fd..c04baf81f 100644 --- a/Examples/test-suite/java/rename1_runme.java +++ b/Examples/test-suite/java/rename1_runme.java @@ -24,7 +24,6 @@ public class rename1_runme { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } { XYZDouble xyz = new XYZDouble(); @@ -36,7 +35,6 @@ public class rename1_runme { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } { XYZKlass xyz = new XYZKlass(); @@ -48,7 +46,6 @@ public class rename1_runme { xyz.tMethod3(new Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } { XYZEnu xyz = new XYZEnu(); @@ -60,7 +57,6 @@ public class rename1_runme { xyz.tMethod4(Enu.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } { ABC abc = new ABC(); diff --git a/Examples/test-suite/java/rename2_runme.java b/Examples/test-suite/java/rename2_runme.java index b6a62dd1e..b97cc59ed 100644 --- a/Examples/test-suite/java/rename2_runme.java +++ b/Examples/test-suite/java/rename2_runme.java @@ -24,7 +24,6 @@ public class rename2_runme { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } { XYZDouble xyz = new XYZDouble(); @@ -36,7 +35,6 @@ public class rename2_runme { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } { XYZKlass xyz = new XYZKlass(); @@ -48,7 +46,6 @@ public class rename2_runme { xyz.tMethod3(new Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } { XYZEnu xyz = new XYZEnu(); @@ -60,7 +57,6 @@ public class rename2_runme { xyz.tMethod4(Enu.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } { ABC abc = new ABC(); diff --git a/Examples/test-suite/java/rename3_runme.java b/Examples/test-suite/java/rename3_runme.java index e1b090af8..222d54899 100644 --- a/Examples/test-suite/java/rename3_runme.java +++ b/Examples/test-suite/java/rename3_runme.java @@ -24,7 +24,6 @@ public class rename3_runme { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } { XYZDouble xyz = new XYZDouble(); @@ -36,7 +35,6 @@ public class rename3_runme { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } { XYZKlass xyz = new XYZKlass(); @@ -48,7 +46,6 @@ public class rename3_runme { xyz.tMethod3(new Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } { XYZEnu xyz = new XYZEnu(); @@ -60,7 +57,6 @@ public class rename3_runme { xyz.tMethod4(Enu.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } { ABC abc = new ABC(); diff --git a/Examples/test-suite/java/rename4_runme.java b/Examples/test-suite/java/rename4_runme.java index 69f909e9e..ef92dd300 100644 --- a/Examples/test-suite/java/rename4_runme.java +++ b/Examples/test-suite/java/rename4_runme.java @@ -24,7 +24,6 @@ public class rename4_runme { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } { XYZDouble xyz = new XYZDouble(); @@ -36,7 +35,6 @@ public class rename4_runme { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } { XYZKlass xyz = new XYZKlass(); @@ -48,7 +46,6 @@ public class rename4_runme { xyz.tMethod3(new Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } { XYZEnu xyz = new XYZEnu(); @@ -60,7 +57,6 @@ public class rename4_runme { xyz.tMethod4(Enu.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } { ABC abc = new ABC(); diff --git a/Examples/test-suite/javascript/rename1_runme.js b/Examples/test-suite/javascript/rename1_runme.js index 68ecc11b6..7b2ac37b6 100644 --- a/Examples/test-suite/javascript/rename1_runme.js +++ b/Examples/test-suite/javascript/rename1_runme.js @@ -10,7 +10,6 @@ function part1() { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } function part2() { @@ -23,7 +22,6 @@ function part2() { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } function part3(){ @@ -36,7 +34,6 @@ function part3(){ xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } function part4() { @@ -49,7 +46,6 @@ function part4() { xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } function part5() { diff --git a/Examples/test-suite/javascript/rename2_runme.js b/Examples/test-suite/javascript/rename2_runme.js index 99f478596..040c798bb 100644 --- a/Examples/test-suite/javascript/rename2_runme.js +++ b/Examples/test-suite/javascript/rename2_runme.js @@ -10,7 +10,6 @@ function part1() { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } function part2() { @@ -23,7 +22,6 @@ function part2() { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } function part3(){ @@ -36,7 +34,6 @@ function part3(){ xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } function part4() { @@ -49,7 +46,6 @@ function part4() { xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } function part5() { diff --git a/Examples/test-suite/javascript/rename3_runme.js b/Examples/test-suite/javascript/rename3_runme.js index 237029fbb..fb9393b03 100644 --- a/Examples/test-suite/javascript/rename3_runme.js +++ b/Examples/test-suite/javascript/rename3_runme.js @@ -10,7 +10,6 @@ function part1() { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } function part2() { @@ -23,7 +22,6 @@ function part2() { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } function part3(){ @@ -36,7 +34,6 @@ function part3(){ xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } function part4() { @@ -49,7 +46,6 @@ function part4() { xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } function part5() { diff --git a/Examples/test-suite/javascript/rename4_runme.js b/Examples/test-suite/javascript/rename4_runme.js index fed50dceb..1c3d8e77f 100644 --- a/Examples/test-suite/javascript/rename4_runme.js +++ b/Examples/test-suite/javascript/rename4_runme.js @@ -10,7 +10,6 @@ function part1() { xyz.tMethod2(0); xyz.tMethodNotXYZ2(notxyz); xyz.opNotXYZ2(); - xyz.opXYZ2(); } function part2() { @@ -23,7 +22,6 @@ function part2() { xyz.tMethod1(0); xyz.tMethodNotXYZ1(notxyz); xyz.opNotXYZ1(); - xyz.opXYZ1(); } function part3(){ @@ -36,7 +34,6 @@ function part3(){ xyz.tMethod3(new rename.Klass()); xyz.tMethodNotXYZ3(notxyz); xyz.opNotXYZ3(); - xyz.opXYZ3(); } function part4() { @@ -49,7 +46,6 @@ function part4() { xyz.tMethod4(rename.En1); xyz.tMethodNotXYZ4(notxyz); xyz.opNotXYZ4(); - xyz.opXYZ4(); } function part5() { diff --git a/Examples/test-suite/rename.h b/Examples/test-suite/rename.h index c8199eeeb..3f10c5856 100644 --- a/Examples/test-suite/rename.h +++ b/Examples/test-suite/rename.h @@ -27,7 +27,6 @@ namespace Space { void templateXYZ(XYZ i) {} operator T() { return m_t; } operator NotXYZ() const { return m_notxyz; } - operator XYZ() const { XYZ xyz = XYZ(); return xyz; } }; } @@ -48,10 +47,7 @@ class ABC { public: void method(ABC a) const {} void method(Klass k) const {} -#if !defined(__clang__) - // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used - operator ABC() const { ABC a; return a; } -#endif + operator ABC*() const { return new ABC(); } operator Klass() const { Klass k; return k; } }; } diff --git a/Examples/test-suite/rename1.i b/Examples/test-suite/rename1.i index 38af2b3bd..92e6b3494 100644 --- a/Examples/test-suite/rename1.i +++ b/Examples/test-suite/rename1.i @@ -35,14 +35,9 @@ %rename(opNotXYZ3) Space::XYZ::operator NotXYZ() const; %rename(opNotXYZ4) Space::XYZ::operator NotXYZ() const; -%rename(opXYZ1) Space::XYZ::operator XYZ() const; -%rename(opXYZ2) Space::XYZ::operator XYZ() const; -%rename(opXYZ3) Space::XYZ::operator XYZ() const; -%rename(opXYZ4) Space::XYZ::operator XYZ() const; - %rename(methodABC) Space::ABC::method(ABC a) const; -%rename(opABC) Space::ABC::operator ABC() const; +%rename(opABC) Space::ABC::operator ABC*() const; %rename(methodKlass) Space::ABC::method(Klass k) const; %rename(opKlass) Space::ABC::operator Klass() const; diff --git a/Examples/test-suite/rename2.i b/Examples/test-suite/rename2.i index 6a9c22ecf..93b82ddc6 100644 --- a/Examples/test-suite/rename2.i +++ b/Examples/test-suite/rename2.i @@ -43,7 +43,7 @@ namespace Space { %rename(methodABC) ABC::method(ABC a) const; -%rename(opABC) ABC::operator ABC() const; +%rename(opABC) ABC::operator ABC*() const; %rename(methodKlass) ABC::method(Klass k) const; %rename(opKlass) ABC::operator Klass() const; } diff --git a/Examples/test-suite/rename3.i b/Examples/test-suite/rename3.i index b39979fdd..5b613d769 100644 --- a/Examples/test-suite/rename3.i +++ b/Examples/test-suite/rename3.i @@ -52,7 +52,7 @@ namespace Space { %extend ABC { %rename(methodABC) method(ABC a) const; - %rename(opABC) operator ABC() const; + %rename(opABC) operator ABC*() const; %rename(methodKlass) method(Klass k) const; %rename(opKlass) operator Klass() const; } diff --git a/Examples/test-suite/rename4.i b/Examples/test-suite/rename4.i index 9ddff362f..75f01ca5b 100644 --- a/Examples/test-suite/rename4.i +++ b/Examples/test-suite/rename4.i @@ -29,21 +29,18 @@ namespace Space { %rename(tMethodXYZ2) templateXYZ(XYZ); %rename(opT2) operator int(); %rename(opNotXYZ2) operator NotXYZ() const; -%rename(opXYZ2) operator XYZ() const; %rename(tMethod3) templateT(Space::Klass i); %rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ); %rename(tMethodXYZ3) templateXYZ(XYZ); %rename(opT3) operator Space::Klass(); %rename(opNotXYZ3) operator NotXYZ() const; -%rename(opXYZ3) operator XYZ() const; %rename(tMethod4) templateT(Space::Enu i); %rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ); %rename(tMethodXYZ4) templateXYZ(XYZ); %rename(opT4) operator Space::Enu(); %rename(opNotXYZ4) operator NotXYZ() const; -%rename(opXYZ4) operator XYZ() const; namespace Space { using namespace AnotherSpace; @@ -60,7 +57,6 @@ namespace Space { %rename(tMethodXYZ1) templateXYZ(XYZ); %rename(opT1) operator T(); %rename(opNotXYZ1) operator NotXYZ() const; - %rename(opXYZ1) operator XYZ() const; NotXYZ *m_int; T m_t; @@ -74,7 +70,6 @@ namespace Space { void templateXYZ(XYZ i) {} operator T() { return m_t; } operator NotXYZ() const { return m_notxyz; } - operator XYZ() const { XYZ xyz; return xyz; } }; } @@ -93,16 +88,13 @@ class ABC { public: %rename(methodABC) method(ABC a) const; - %rename(opABC) operator ABC() const; + %rename(opABC) operator ABC*() const; %rename(methodKlass) method(Klass k) const; %rename(opKlass) operator Klass() const; void method(ABC a) const {} void method(Klass k) const {} -#if !defined(__clang__) - // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used - operator ABC() const { ABC a; return a; } -#endif + operator ABC*() const { return new ABC(); } operator Klass() const { Klass k; return k; } }; } From 31b3b782a15bd4752b93193019dde85528443db5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 15 Apr 2019 23:28:25 +0100 Subject: [PATCH 1562/2031] Possible fix for MinGW MSYS configure script error from ax_boost_base.m4 Issue #1435 --- Tools/config/ax_boost_base.m4 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4 index d54039576..f5a935cd6 100644 --- a/Tools/config/ax_boost_base.m4 +++ b/Tools/config/ax_boost_base.m4 @@ -181,8 +181,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes - ],[ - ]) + ],[]) AC_LANG_POP([C++]) @@ -276,8 +275,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ AC_MSG_RESULT(yes) succeeded=yes found_system=yes - ],[ - ]) + ],[]) AC_LANG_POP([C++]) fi From 12a245183ffd9748a3111cfdd0d80a8c6797a520 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 20:04:20 +0100 Subject: [PATCH 1563/2031] Clear up some confusion over ANSI vs ISO C/C++ support Issue #890 --- Doc/Manual/Introduction.html | 8 ++++---- Doc/Manual/Library.html | 2 +- Doc/Manual/Lua.html | 2 +- Doc/Manual/Preprocessor.html | 6 +++--- Doc/Manual/SWIG.html | 12 ++++++------ Doc/Manual/SWIGPlus.html | 4 ++-- Doc/Manual/Windows.html | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 149e86877..8d161b73d 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -163,7 +163,7 @@ This ability to interface C/C++ to many different target languages is one of SWI

            SWIG is very broadly composed of two components. -A core component creates a parse tree from the input C/C++ and SWIG directives (extensions to C/C++). +A core component creates a parse tree from the input ISO C/C++ and SWIG directives (extensions to the C/C++ standards). The parse tree is then passed to a second component, one of the target language modules for generating code specific to a higher level language. SWIG supports many different target languages. These target languages are given a status of either Supported or Experimental. @@ -273,7 +273,7 @@ extern int my_mod(int n, int m);

      -The interface file contains ANSI C function prototypes and variable +The interface file contains ISO C function prototypes and variable declarations. The %module directive defines the name of the module that will be created by SWIG. The %{ %} block provides a location for inserting additional code, such as C header @@ -400,7 +400,7 @@ major features include:

      • Full C99 preprocessing. -
      • All ANSI C and C++ datatypes. +
      • All ISO C and C++ datatypes.
      • Functions, variables, and constants.
      • Classes.
      • Single and multiple inheritance. @@ -531,7 +531,7 @@ to work with complicated and unusual C/C++ applications. Ironically, the freedom that SWIG provides is countered by an extremely conservative approach to code generation. At its core, SWIG tries to distill even the most advanced C++ code down to a small -well-defined set of interface building techniques based on ANSI C +well-defined set of interface building techniques based on ISO C programming. Because of this, you will find that SWIG interfaces can be easily compiled by virtually every C/C++ compiler and that they can be used on any platform. Again, this is an important part of staying out diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 4ef6aeb83..eeb2e5a57 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1365,7 +1365,7 @@ to accomplish this in SWIG. This library provides support for a few common tech
      • If used in C++, this library uses new and delete [] for memory -allocation. If using ANSI C, the library uses malloc() and free(). +allocation. If using C, the library uses malloc() and free().
      • Rather than manipulating char * directly, you might consider using a special string diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 0fa1ecb13..6633eaa38 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -77,7 +77,7 @@

        -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++). It's 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 +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 ISO C and C++). It's 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

        eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 1bf59e238..f28f7b2be 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -138,7 +138,7 @@ In addition, SWIG defines the following set of standard C/C++ macros:

         __LINE__                        Current line number
         __FILE__                        Current file name
        -__STDC__                        Defined to indicate ANSI C
        +__STDC__                        Defined to indicate ISO C
         __cplusplus                     Defined when -c++ option used
         
        @@ -180,9 +180,9 @@ More complex macros can be defined in the standard way. For example:
         #define EXTERN extern
         #ifdef __STDC__
        -#define _ANSI(args)   (args)
        +#define ISOC_(args)   (args)
         #else
        -#define _ANSI(args) ()
        +#define ISOC_(args) ()
         #endif
         
        diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 64db9c6c6..d1492d30a 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -88,7 +88,7 @@

        This chapter describes the basic operation of SWIG, the structure of its -input files, and how it handles standard ANSI C declarations. C++ support is +input files, and how it handles standard ISO C declarations. C++ support is described in the next chapter. However, C++ programmers should still read this chapter to understand the basics. Specific details about each target language are described in later @@ -252,7 +252,7 @@ recursively.

        -As input, SWIG expects a file containing ANSI C/C++ declarations and +As input, SWIG expects a file containing ISO C/C++ declarations and special SWIG directives. More often than not, this is a special SWIG interface file which is usually denoted with a special .i or .swg suffix. In certain cases, SWIG can be used directly on @@ -270,7 +270,7 @@ The most common format of a SWIG interface is as follows: %{ #include "myheader.h" %} -// Now list ANSI C/C++ declarations +// Now list ISO C/C++ declarations int foo; int bar(int x); ... @@ -2242,7 +2242,7 @@ used in Tcl as follows :

        -Although the ANSI C standard does not allow default arguments, default +Although the ISO C standard does not allow default arguments, default arguments specified in a SWIG interface work with both C and C++.

        @@ -2415,7 +2415,7 @@ see Callbacks to the

        -This section describes the behavior of SWIG when processing ANSI C structures and union declarations. Extensions to +This section describes the behavior of SWIG when processing ISO C structures and union declarations. Extensions to handle C++ are described in the next section.

        @@ -3469,7 +3469,7 @@ interface to your program. SWIG's %include directive to process an entire C source/header file. -
      • Make sure everything in the interface file uses ANSI C/C++ syntax. +
      • Make sure everything in the interface file uses ISO C/C++ syntax.
      • Make sure all necessary `typedef' declarations and type-information is available in the interface file. diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 3a50cf8ce..dc9ae0f7e 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -93,7 +93,7 @@ For additions to the original C++ standard, please read the SWIG and C++17 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see -how SWIG wraps ANSI C. Support for C++ builds upon ANSI C +how SWIG wraps ISO C. Support for C++ builds upon ISO C wrapping and that material will be useful in understanding this chapter.

        @@ -144,7 +144,7 @@ yourself in the foot. You will just have to be careful.

        To wrap C++, SWIG uses a layered approach to code generation. -At the lowest level, SWIG generates a collection of procedural ANSI-C style +At the lowest level, SWIG generates a collection of procedural ISO C style wrappers. These wrappers take care of basic type conversion, type checking, error handling, and other low-level details of the C++ binding. These wrappers are also sufficient to bind C++ into any target language diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index faea8b4e7..301974b64 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -211,7 +211,7 @@ If you do not have access to Visual C++ you will have to set up project files /

        -SWIG can also be compiled and run using Cygwin or MinGW which provides a Unix like front end to Windows and comes free with gcc, an ANSI C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied. +SWIG can also be compiled and run using Cygwin or MinGW which provides a Unix like front end to Windows and comes free with gcc, an ISO C/C++ compiler. However, this is not a recommended approach as the prebuilt executable is supplied.

        3.3.1 Building swig.exe on Windows

        From 65a7fafd844b03f2d2fd719b996a1f4c0eae2b4d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 20:27:14 +0100 Subject: [PATCH 1564/2031] Fix minor whitespace regression in Java generated code --- Source/Modules/java.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 94087369a..cb41781dd 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2078,7 +2078,7 @@ public: Printv(proxy_class_def, methodmods, NIL); else Printv(proxy_class_def, destruct_methodmodifiers, NIL); - Printv(proxy_class_def, " void ", destruct_methodname, "(", destruct_parameters, ") ", destructor_throws_clause, " ", destruct, "\n", NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "(", destruct_parameters, ")", destructor_throws_clause, " ", destruct, "\n", NIL); } } if (*Char(interface_upcasts)) From b6a675cf1d471a2341258f9f56c783cf8e3b4768 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 23:22:01 +0100 Subject: [PATCH 1565/2031] Add potential incompatibility info for Java std::vector wrappers --- CHANGES.current | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 3c819bd88..9633d07e7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1390,6 +1390,35 @@ Version 4.0.0 (in progress) 2017-05-26: Volker Diels-Grabsch, vadz [Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way. + Note that boxed types are now used in the Java layer when wrapping vector of C primitive + types, for example. This may introduce some subtle incompatibilities due to some + differences in how Java converts boxed types and unboxed types. For example, + + int i=0; + double d1 = i; // ok + Double d2 = i; // error: incompatible types: int cannot be converted to Double + + This can be a problem when calling the add and set functions. A suggested backwards + compatible workaround is to use something like (shown for std::vector: + + #if defined(SWIGJAVA) + // Add in old api that uses non-boxed types + %extend std::vector { + %proxycode %{ + public void add(double x) { + add(Double.valueOf(x)); + } + public void set(int i, double val) { + set(i, Double.valueOf(val)); + } + %} + } + #endif + + %include "std_vector.i" + %template(VectorDouble) std::vector; + + *** POTENTIAL INCOMPATIBILITY *** 2017-05-30: davidcl [Scilab] #994 Undefined symbol error when loading in Scilab 6 From 05c8c972cc32c11bc4adbbfd45e73cd7bf97495f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 23:24:43 +0100 Subject: [PATCH 1566/2031] Improve backwards compatibility in Java std::vector wrappers For users who have typemaps for the parameters in the add and set methods (now called doAdd and doSet). Also for users who have typemaps for the get method - revert the return type for get (now called doGet) back to the same return type as std::vector::at. Correct definitions of const_reference to match the those in the (C++11) standard. --- Lib/java/std_vector.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 88de46f46..e33270238 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -105,14 +105,14 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { return SWIG_VectorSize(self->size()); } - void doAdd(const value_type& value) { - self->push_back(value); + void doAdd(const value_type& x) { + self->push_back(x); } - void doAdd(jint index, const value_type& value) throw (std::out_of_range) { + void doAdd(jint index, const value_type& x) throw (std::out_of_range) { jint size = static_cast(self->size()); if (0 <= index && index <= size) { - self->insert(self->begin() + index, value); + self->insert(self->begin() + index, x); } else { throw std::out_of_range("vector index out of range"); } @@ -129,7 +129,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } } - CONST_REFERENCE doGet(jint index) throw (std::out_of_range) { + const_reference doGet(jint index) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) return (*self)[index]; @@ -137,11 +137,11 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { throw std::out_of_range("vector index out of range"); } - value_type doSet(jint index, const value_type& value) throw (std::out_of_range) { + value_type doSet(jint index, const value_type& val) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) { CTYPE const old_value = (*self)[index]; - (*self)[index] = value; + (*self)[index] = val; return old_value; } else @@ -169,7 +169,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { namespace std { template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const T&) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const value_type&) }; // bool specialization From c79cf790853d6e6d65aa7379ccb2e472b704e456 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Apr 2019 00:11:22 +0100 Subject: [PATCH 1567/2031] Improve backwards compatibility in C# std::vector wrappers For users who have typemaps for the parameters in the setitem method. Correct definitions of const_reference to match the those in the (C++11) standard. --- Lib/csharp/std_vector.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index e8eeb8411..1e2603782 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -233,15 +233,15 @@ else throw std::out_of_range("index"); } - CONST_REFERENCE getitem(int index) throw (std::out_of_range) { + const_reference getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else throw std::out_of_range("index"); } - void setitem(int index, CTYPE const& value) throw (std::out_of_range) { + void setitem(int index, CTYPE const& val) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) - (*$self)[index] = value; + (*$self)[index] = val; else throw std::out_of_range("index"); } @@ -351,7 +351,7 @@ %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector< CTYPE > { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE)) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } @@ -384,11 +384,11 @@ namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, T) }; // specialization for pointers template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is specialized in the C++ standard - const_reference in particular From 592b97a8cd8b6e535011a2e611b64c1af8d2bfe0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Apr 2019 00:22:53 +0100 Subject: [PATCH 1568/2031] Improve backwards compatibility in D std::vector wrappers For users who have typemaps for the parameters in the setElement method. Correct definitions of const_reference to match the those in the (C++11) standard. --- Lib/d/std_vector.i | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i index 9dcb184c6..fb8f7d2e0 100644 --- a/Lib/d/std_vector.i +++ b/Lib/d/std_vector.i @@ -135,7 +135,7 @@ public void capacity(size_t value) { return $self->capacity() - $self->size(); } - CONST_REFERENCE remove() throw (std::out_of_range) { + const_reference remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } @@ -145,7 +145,7 @@ public void capacity(size_t value) { return value; } - CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { + const_reference remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } @@ -160,7 +160,7 @@ public void capacity(size_t value) { // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { - CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { + const_reference getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } @@ -172,11 +172,11 @@ public void capacity(size_t value) { // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { - void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) { + void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } - (*$self)[index] = value; + (*$self)[index] = val; } } @@ -478,7 +478,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) return pv; } - CONST_REFERENCE remove() throw (std::out_of_range) { + const_reference remove() throw (std::out_of_range) { if ($self->empty()) { throw std::out_of_range("Tried to remove last element from empty vector."); } @@ -488,7 +488,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) return value; } - CONST_REFERENCE remove(size_type index) throw (std::out_of_range) { + const_reference remove(size_type index) throw (std::out_of_range) { if (index >= $self->size()) { throw std::out_of_range("Tried to remove element with invalid index."); } @@ -520,7 +520,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) // Wrappers for setting/getting items with the possibly thrown exception // specified (important for SWIG wrapper generation). %extend { - CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) { + const_reference getElement(size_type index) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to get value of element with invalid index."); } @@ -531,11 +531,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) // generation issue when using const pointers as vector elements (like // std::vector< const int* >). %extend { - void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) { + void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) { if ((index < 0) || ($self->size() <= index)) { throw std::out_of_range("Tried to set value of element with invalid index."); } - (*$self)[index] = value; + (*$self)[index] = val; } } @@ -558,7 +558,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE)) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, %arg(CTYPE)) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } @@ -573,11 +573,11 @@ namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(T const&, T) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T) }; // specializations for pointers template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T *) SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *) }; // bool is a bit different in the C++ standard - const_reference in particular From f87182ad98de90f46d986617c1c942be8bdc9002 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Apr 2019 11:06:24 +0100 Subject: [PATCH 1569/2031] Improve backwards compatibility in C#/Java std::array wrappers For users who have typemaps for the parameters in the setitem or set methods. --- Lib/csharp/std_array.i | 4 ++-- Lib/java/std_array.i | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/csharp/std_array.i b/Lib/csharp/std_array.i index e7d392b85..a4f0f9640 100644 --- a/Lib/csharp/std_array.i +++ b/Lib/csharp/std_array.i @@ -192,9 +192,9 @@ else throw std::out_of_range("index"); } - void setitem(int index, const_reference value) throw (std::out_of_range) { + void setitem(int index, const_reference val) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) - (*$self)[index] = value; + (*$self)[index] = val; else throw std::out_of_range("index"); } diff --git a/Lib/java/std_array.i b/Lib/java/std_array.i index f67b18d9b..d3436cc66 100644 --- a/Lib/java/std_array.i +++ b/Lib/java/std_array.i @@ -31,10 +31,10 @@ namespace std { else throw std::out_of_range("array index out of range"); } - void set(int i, const value_type& value) throw (std::out_of_range) { + void set(int i, const value_type& val) throw (std::out_of_range) { int size = int(self->size()); if (i>=0 && i Date: Fri, 19 Apr 2019 11:33:02 +0100 Subject: [PATCH 1570/2031] Fix Visual Studio 2015 and later compilation errors due to snprintf macro definition. Closes #1508 --- CHANGES.current | 4 ++++ Lib/chicken/chickenrun.swg | 2 +- Lib/swigfragments.swg | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 9633d07e7..d36f43c41 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-04-19: pbecherer + [Tcl] Fix Visual Studio 2015 and later compilation errors due to snprintf macro + definition. + 2019-04-09: wsfulton [C#] Fix FxCop warning CA2002 in SWIGPendingException - a lock on a reference of type 'Type'. diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index d4255c365..bb14b4bc9 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -7,7 +7,7 @@ #include #include #include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif diff --git a/Lib/swigfragments.swg b/Lib/swigfragments.swg index 63bb6c8f4..2cbef7cce 100644 --- a/Lib/swigfragments.swg +++ b/Lib/swigfragments.swg @@ -35,7 +35,7 @@ %fragment("", "header") %{ #include -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__BORLANDC__) || defined(_WATCOM) # ifndef snprintf # define snprintf _snprintf # endif From 77f075b6e8196ea26aa32855a5ae1ada124a02b8 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 19 Apr 2019 12:49:56 -0700 Subject: [PATCH 1571/2031] When generating Go code, make -cgo the default. Add new -no-cgo option to disable the default. Keep -cgo as a no-op for existing users. --- Doc/Manual/Go.html | 53 +++++++++++++++++++++++-------------------- Examples/Makefile.in | 8 +++---- Source/Modules/go.cxx | 6 ++++- 3 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index b16c764fb..dbea7de96 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -125,16 +125,15 @@ Go distribution. To generate code for gccgo, you should also use the

        -When using the -cgo option, SWIG will generate files that can be used -directly by go build. Starting with the Go 1.5 distribution the --cgo option has to be given. Put your SWIG interface file in a -directory under GOPATH/src, and give it a name that does not end in the -.swig or .swigcxx extension. Typically the SWIG interface file extension is .i -in this case. +By default SWIG will generate files that can be used directly +by go build. This requires Go 1.2 or later. Put your SWIG +interface file in a directory under GOPATH/src, and give it a name +that does not end in the .swig or .swigcxx extension. +Typically the SWIG interface file extension is .i in this case.

        -% swig -go -cgo example.i
        +% swig -go example.i
         % go install
         
        @@ -144,15 +143,16 @@ usual.

        -To use SWIG without the -cgo option, more steps are required. Recall -that this only works with Go versions before 1.5. When using Go version 1.2 or -later, or when using gccgo, the code generated by SWIG can be linked directly -into the Go program. A typical command sequence when using the Go compiler of -the Go distribution would look like this: +SWIG can be used without cgo, via the -no-cgo option, but +more steps are required. This only works with Go versions before 1.5. +When using Go version 1.2 or later, or when using gccgo, the code +generated by SWIG can be linked directly into the Go program. A +typical command sequence when using the Go compiler of the Go +distribution would look like this:

        -% swig -go example.i
        +% swig -go -no-cgo example.i
         % gcc -c code.c    # The C library being wrapped.
         % gcc -c example_wrap.c
         % go tool 6g example.go
        @@ -169,7 +169,7 @@ sequence for this approach would look like this:
         

        -% swig -go -use-shlib example.i
        +% swig -go -no-cgo -use-shlib example.i
         % gcc -c -fpic example.c
         % gcc -c -fpic example_wrap.c
         % gcc -shared example.o example_wrap.o -o example.so
        @@ -200,10 +200,15 @@ swig -go -help
         
         
  • - + + + + + + @@ -268,11 +273,11 @@ swig -go -help

    There are two different approaches to generating wrapper files, - controlled by SWIG's -cgo option. The -cgo option - works with Go version 1.2 or later. It is required when using Go - version 1.5 or later.

    + controlled by SWIG's -no-cgo option. The -no-cgo + option only works with version of Go before 1.5. It is required + when using versions of Go before 1.2.

    -

    With or without the -cgo option, SWIG will generate the +

    With or without the -no-cgo option, SWIG will generate the following files when generating wrapper code:

      @@ -296,8 +301,8 @@ or C++ compiler.
    -

    When neither the -cgo nor the -gccgo option is - used, SWIG will also generate an additional file:

    +

    When the -no-cgo option is used, and the -gccgo + option is not used, SWIG will also generate an additional file:

    • diff --git a/Examples/Makefile.in b/Examples/Makefile.in index b2cbb65da..d7b71af2f 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1468,7 +1468,7 @@ GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) # ---------------------------------------------------------------- go_nocgo: $(SRCDIR_SRCS) - $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) + $(SWIG) -go -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \ $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \ else \ @@ -1504,7 +1504,7 @@ go_nocgo: $(SRCDIR_SRCS) fi go: $(SRCDIR_SRCS) - $(SWIG) -go -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) + $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true @mkdir gopath/src 2>/dev/null || true @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true @@ -1548,7 +1548,7 @@ go: $(SRCDIR_SRCS) # ---------------------------------------------------------------- go_cpp_nocgo: $(SRCDIR_SRCS) - $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) + $(SWIG) -go -c++ -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \ if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \ $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \ @@ -1596,7 +1596,7 @@ go_cpp_nocgo: $(SRCDIR_SRCS) fi go_cpp: $(SRCDIR_SRCS) - $(SWIG) -go -c++ -cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) + $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true @mkdir gopath/src 2>/dev/null || true @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 41e8f7d0a..9e8162b5d 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -199,7 +199,7 @@ class GO:public Language { public: GO():package(NULL), module(NULL), - cgo_flag(false), + cgo_flag(true), gccgo_flag(false), go_prefix(NULL), prefix_option(NULL), @@ -269,6 +269,9 @@ private: } else if (strcmp(argv[i], "-cgo") == 0) { Swig_mark_arg(i); cgo_flag = true; + } else if (strcmp(argv[i], "-no-cgo") == 0) { + Swig_mark_arg(i); + cgo_flag = false; } else if (strcmp(argv[i], "-gccgo") == 0) { Swig_mark_arg(i); gccgo_flag = true; @@ -6979,6 +6982,7 @@ extern "C" Language *swig_go(void) { const char * const GO::usage = "\ Go Options (available with -go)\n\ -cgo - Generate cgo input files\n\ + -no-cgo - Do not generate cgo input files\n\ -gccgo - Generate code for gccgo rather than 6g/8g\n\ -go-pkgpath

      - Like gccgo -fgo-pkgpath option\n\ -go-prefix

      - Like gccgo -fgo-prefix option\n\ From d67c133c4a85c72f77bce245b7db4ae047202396 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Apr 2019 11:20:24 +0100 Subject: [PATCH 1572/2031] Java/C# std::vector workarounds for clang Workaround clang++ 9.1.0 error not knowing std::vector::const_reference is actually typedef to bool: li_std_vector_wrap.cxx:1838:40: error: no matching constructor for initialization of 'std::vector::const_reference' Workaround is use const value_type& getitem(int index) throw (std::out_of_range) { ... // bool specialization: bool getitem(int index) throw (std::out_of_range) { ... instead of const_reference_type getitem(int index) throw (std::out_of_range) { ... Although the following would be better, it would require a more complicated implementation: const_reference_type getitem(int index) throw (std::out_of_range) { ... // bool specialization: bool getitem(int index) throw (std::out_of_range) { ... --- Lib/csharp/std_vector.i | 2 +- Lib/java/std_vector.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 1e2603782..e2811290c 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -233,7 +233,7 @@ else throw std::out_of_range("index"); } - const_reference getitem(int index) throw (std::out_of_range) { + CONST_REFERENCE getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)$self->size()) return (*$self)[index]; else diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index e33270238..955e20cac 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -129,7 +129,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } } - const_reference doGet(jint index) throw (std::out_of_range) { + CONST_REFERENCE doGet(jint index) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) return (*self)[index]; From 01a2cd27e7bd64f2788885eaa1d8f39310631f5f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 19 Apr 2019 18:48:35 +0200 Subject: [PATCH 1573/2031] Don't crash if type is not available in Python Doxygen code Fix crash if "@return" Doxygen tag was used on a node without any return type (such as a class, for example). Ignoring it might not be the best thing to do, but it's definitely better than crashing and it's not really clear what else could be done anyhow. Closes #1516. --- Examples/test-suite/doxygen_misc_constructs.i | 3 +++ .../test-suite/java/doxygen_misc_constructs_runme.java | 3 +++ Source/Doxygen/pydoc.cxx | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i index c95e85683..c1b3eea31 100644 --- a/Examples/test-suite/doxygen_misc_constructs.i +++ b/Examples/test-suite/doxygen_misc_constructs.i @@ -104,6 +104,9 @@ }; + /// @return This is a bad place for this tag, but it should be ignored. + struct StructWithReturnComment {}; + /** An example of a list in a documentation comment. diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java index 6d018b9d2..5d95bd565 100644 --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java @@ -117,6 +117,9 @@ public class doxygen_misc_constructs_runme { wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.THREE", " desc of three\n"); + wantedComments.put("doxygen_misc_constructs.StructWithReturnComment", + " @return This is a bad place for this tag, but it should be ignored."); + wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.showList()", " An example of a list in a documentation comment.
      \n" + "
      \n" + diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 8c3090035..fc3b0ea09 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -336,8 +336,13 @@ static std::string getPyDocType(Node *n, const_String_or_char_ptr lname = "") { std::string type; String *s = Swig_typemap_lookup("doctype", n, lname, 0); + if (!s) { + if (String *t = Getattr(n, "type")) + s = SwigType_str(t, ""); + } + if (!s) - s = SwigType_str(Getattr(n, "type"), ""); + return type; if (Language::classLookup(s)) { // In Python C++ namespaces are flattened, so remove all but last component From 74adaa5738368ce473870451422f4a7175b6a736 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 18 Apr 2019 17:46:13 +0200 Subject: [PATCH 1574/2031] Fix parsing of enums with trailing comma with -doxygen To correctly parse Doxygen post-comments after the trailing comma, switch to right recursion in "enumlist" production rule definition: this does consume more stack space when parsing, but makes the rules much easier to write and to understand and hopefully shouldn't result in any problems with real code (which shouldn't have thousands of enums items in it). Closes #1514. --- Examples/test-suite/doxygen_parsing_enums.i | 5 ++ .../doxygen_parsing_enums_proper_runme.java | 4 ++ .../doxygen_parsing_enums_simple_runme.java | 4 ++ .../doxygen_parsing_enums_typesafe_runme.java | 4 ++ ...oxygen_parsing_enums_typeunsafe_runme.java | 4 ++ Source/CParse/parser.y | 58 +++++++------------ 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/Examples/test-suite/doxygen_parsing_enums.i b/Examples/test-suite/doxygen_parsing_enums.i index 5c48f4801..b7a39871f 100644 --- a/Examples/test-suite/doxygen_parsing_enums.i +++ b/Examples/test-suite/doxygen_parsing_enums.i @@ -32,4 +32,9 @@ SOME_ITEM_30 ///< Post comment for the third item }; + enum SomeEnumWithTrailingComma + { + SOME_ITEM_100, ///< Post comment after comma. + SOME_ITEM_200, ///< Post comment after last comma. + }; %} diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index a8527e364..ef1f06af5 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_proper_runme { wantedComments.put("doxygen_parsing_enums_proper.SomeAnotherEnum2.SOME_ITEM_20", "Post comment for the second item \n" + ""); + wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_proper.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index f68fff151..85ec0cb55 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -47,6 +47,10 @@ public class doxygen_parsing_enums_simple_runme { " The comment for the first item \n" + " \n" + ""); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_simple.doxygen_parsing_enums_simpleConstants.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index 7c7f05ccc..4e5f4b489 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_typesafe_runme { wantedComments.put("doxygen_parsing_enums_typesafe.SomeAnotherEnum2.SOME_ITEM_30", "Post comment for the third item \n" + ""); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_typesafe.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index 8c7dfeda0..428649196 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -55,6 +55,10 @@ public class doxygen_parsing_enums_typeunsafe_runme { wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeAnotherEnum2.SOME_ITEM_10", "Post comment for the first item \n" + ""); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_100", + "Post comment after comma."); + wantedComments.put("doxygen_parsing_enums_typeunsafe.SomeEnumWithTrailingComma.SOME_ITEM_200", + "Post comment after last comma."); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4046e480e..b526da907 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1650,7 +1650,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier) /* C declarations */ %type c_declaration c_decl c_decl_tail c_enum_key c_enum_inherit c_enum_decl c_enum_forward_decl c_constructor_decl; -%type enumlist enumlist_tail enumlist_item edecl_with_dox edecl; +%type enumlist enumlist_item edecl_with_dox edecl; /* C++ declarations */ %type cpp_declaration cpp_class_decl cpp_forward_class_decl cpp_template_decl cpp_alternate_rettype; @@ -6374,21 +6374,31 @@ optional_ignored_defines | empty ; -optional_ignored_define_after_comma - : empty - | COMMA - | COMMA constant_directive - ; - /* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ -enumlist : enumlist_item optional_ignored_define_after_comma { +enumlist : enumlist_item { Setattr($1,"_last",$1); $$ = $1; } - | enumlist_item enumlist_tail optional_ignored_define_after_comma { - set_nextSibling($1, $2); - Setattr($1,"_last",Getattr($2,"_last")); - Setattr($2,"_last",NULL); + | enumlist_item DOXYGENPOSTSTRING { + Setattr($1,"_last",$1); + set_comment($1, $2); + $$ = $1; + } + | enumlist_item COMMA enumlist { + if ($3) { + set_nextSibling($1, $3); + Setattr($1,"_last",Getattr($3,"_last")); + Setattr($3,"_last",NULL); + } + $$ = $1; + } + | enumlist_item COMMA DOXYGENPOSTSTRING enumlist { + if ($4) { + set_nextSibling($1, $4); + Setattr($1,"_last",Getattr($4,"_last")); + Setattr($4,"_last",NULL); + } + set_comment($1, $3); $$ = $1; } | optional_ignored_defines { @@ -6396,17 +6406,6 @@ enumlist : enumlist_item optional_ignored_define_after_comma { } ; -enumlist_tail : COMMA enumlist_item { - Setattr($2,"_last",$2); - $$ = $2; - } - | enumlist_tail COMMA enumlist_item { - set_nextSibling(Getattr($1,"_last"), $3); - Setattr($1,"_last",$3); - $$ = $1; - } - ; - enumlist_item : optional_ignored_defines edecl_with_dox optional_ignored_defines { $$ = $2; } @@ -6419,19 +6418,6 @@ edecl_with_dox : edecl { $$ = $2; set_comment($2, $1); } - | edecl DOXYGENPOSTSTRING { - $$ = $1; - set_comment($1, $2); - } - | DOXYGENPOSTSTRING edecl { - $$ = $2; - set_comment(previousNode, $1); - } - | DOXYGENPOSTSTRING edecl DOXYGENPOSTSTRING { - $$ = $2; - set_comment(previousNode, $1); - set_comment($2, $3); - } ; edecl : identifier { From c3a2b7524e3c43e8be31e0ab100b5b00dd1fed71 Mon Sep 17 00:00:00 2001 From: Marko Klopcic Date: Tue, 23 Apr 2019 10:07:42 +0200 Subject: [PATCH 1575/2031] added section 'troubleshooting' --- Doc/Manual/Doxygen.html | 141 ++++++++++++++++++++++++++++++++++------ 1 file changed, 122 insertions(+), 19 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 8a847bb7e..75809e311 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -23,6 +23,7 @@

  • Additional command line options +
  • Troubleshooting
  • Doxygen to Javadoc
    • Basic example @@ -70,7 +71,7 @@ and Pydoc for the SWIG Java and Python modules. Other extensions could be added at a later date. The Doxygen Translation module originally started as a Google Summer of -Code proposal from Summer 2008. +Code proposal from Summer 2008.

      17.2 Preparations

      @@ -165,7 +166,7 @@ and in some special cases, like function parameter comments:
       void someFunction(
      -         int a ///< Some parameter 
      +         int a ///< Some parameter
            );
       
      @@ -442,6 +443,108 @@ This is only applicable to Java at the moment. ALSO TO BE ADDED (Javadoc auto brief?)

      + +

      17.3 Troubleshooting

      + + +

      +When running SWIG with command line switch -doxygen, it may happen +that SWIG will fail to parse the code, which is valid C++ code and +is parsed without problems without the switch. The problem is, +that Doxygen comments are not tokens (C/C++ compiler actually never +sees them) and that they can appear anywhere in the code. That's why it is +practically impossible to handle all corner cases with parser. +However, these problems can usually be avoided by minor changes in the +code or comment. Known problems and solutions are shown in this section. +

      + + +

      +Recommended approach is to first run SWIG without command line +switch -doxygen. When it successfully processes the code, +include the switch and fix problems with Doxygen comments. +

      + +

      17.3.1 Enums

      + + +

      +In C/C++ the comma after the last enum item is optional, but when +-doxygen switch is used the comma must not be present +if followed by Doxygen post-comment. For example, this snippet will +cause Error: Syntax error in input(3).: +

      + +
      +/**
      + * Comments after enum items.
      + */
      +enum SomeEnum
      +{
      +  SOME_ITEM_100, ///< Post comment for the first item
      +  SOME_ITEM_200, ///< Comma after enum item causes error.
      +};
      +
      + + +

      +Solution: remove the comma after the last enum item: +

      + +
      +/**
      + * Comments after enum items.
      + */
      +enum SomeEnum
      +{
      +  SOME_ITEM_100, ///< Post comment for the first item
      +  SOME_ITEM_200  ///< OK.
      +};
      +
      + + + + +

      17.3.2 Conditional compilation

      + + +

      + Inserting of conditional compilation preprocessor directive between + Doxygen comment and commented item may also break parsing: +

      + + +
      +class A {
      +  /**
      +   * Some func.
      +   */
      +  #ifndef SWIG
      +  void myfunc()
      +  {
      +  }
      +  #endif
      +};
      +
      + +

      + Solution is to move the directive above comment: +

      + +
      +class A {
      +  #ifndef SWIG
      +  /**
      +   * Some func.
      +   */
      +  void myfunc()
      +  {
      +  }
      +  #endif
      +};
      +
      + +

      17.3 Doxygen to Javadoc

      @@ -485,9 +588,9 @@ Simply running SWIG should result in the following code being present in Shapes.
       
       /**
      - * This is describing class Shape 
      - * @author Bob 
      - * 
      + * This is describing class Shape
      + * @author Bob
      + *
        */
       
       public class Shape {
      @@ -495,35 +598,35 @@ public class Shape {
       ...
       
       /**
      - * Important Variables 
      + * Important Variables
        */
         public void setX(double value) {
           ShapesJNI.Shape_x_set(swigCPtr, this, value);
         }
       
       /**
      - * Important Variables 
      + * Important Variables
        */
         public double getX() {
           return ShapesJNI.Shape_x_get(swigCPtr, this);
         }
       
       /**
      - * Moves the Shape 
      + * Moves the Shape
        */
         public void move(double dx, double dy) {
           ShapesJNI.Shape_move(swigCPtr, this, dx, dy);
         }
       
       /**
      - * @return the area 
      + * @return the area
        */
         public double area() {
           return ShapesJNI.Shape_area(swigCPtr, this);
         }
       
       /**
      - * @return the perimeter 
      + * @return the perimeter
        */
         public double perimeter() {
           return ShapesJNI.Shape_perimeter(swigCPtr, this);
      @@ -545,7 +648,7 @@ The Javadoc translator will handle most of the tags conversions (see the
       table below). It will also automatically translate link-objects
       params, in \see and \link...\endlink commands. For example,
       'someFunction(std::string)' will be converted to
      -'someFunction(String)'.  If 
      +'someFunction(String)'.  If
       you don't want such behaviour, you could turn this off by using the
       'doxygen:nolinktranslate' feature. Also all '\param' and '\tparam'
       commands are stripped out, if the specified parameter is not present in
      @@ -1103,31 +1206,31 @@ Simply running SWIG should result in the following code being present in Shapes.
       
       class Shape(_object):
           """
      -    This is describing class Shape 
      +    This is describing class Shape
           Authors:
      -    Bob 
      +    Bob
       
           """
      -    
      +
           ...
      -    
      +
           def move(self, *args):
               """
      -        Moves the Shape 
      +        Moves the Shape
               """
               return _Shapes.Shape_move(self, *args)
       
           def area(self):
               """
               Return:
      -        the area 
      +        the area
               """
               return _Shapes.Shape_area(self)
       
           def perimeter(self):
               """
               Return:
      -        the perimeter 
      +        the perimeter
               """
               return _Shapes.Shape_perimeter(self)
       
      @@ -1712,7 +1815,7 @@ tool, for example: Examples/test-suite/java $ kdiff3 expected.txt got.txt - +

      Runtime tests in Java are implemented using Javadoc doclets. To make that work, you should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME From 4c6f33b1c985a70b15121056e099a47a67888b04 Mon Sep 17 00:00:00 2001 From: Marko Klopcic Date: Tue, 23 Apr 2019 10:25:35 +0200 Subject: [PATCH 1576/2031] improved section 'troubleshooting', moved before 'Developr info' --- Doc/Manual/Doxygen.html | 165 +++++++++++++++------------------------- 1 file changed, 63 insertions(+), 102 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 75809e311..4e4ed421c 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -23,7 +23,6 @@

  • Additional command line options -
  • Troubleshooting
  • Doxygen to Javadoc +
  • Troubleshooting
  • Developer information
    • Doxygen translator design @@ -444,107 +444,6 @@ ALSO TO BE ADDED (Javadoc auto brief?)

      -

      17.3 Troubleshooting

      - - -

      -When running SWIG with command line switch -doxygen, it may happen -that SWIG will fail to parse the code, which is valid C++ code and -is parsed without problems without the switch. The problem is, -that Doxygen comments are not tokens (C/C++ compiler actually never -sees them) and that they can appear anywhere in the code. That's why it is -practically impossible to handle all corner cases with parser. -However, these problems can usually be avoided by minor changes in the -code or comment. Known problems and solutions are shown in this section. -

      - - -

      -Recommended approach is to first run SWIG without command line -switch -doxygen. When it successfully processes the code, -include the switch and fix problems with Doxygen comments. -

      - -

      17.3.1 Enums

      - - -

      -In C/C++ the comma after the last enum item is optional, but when --doxygen switch is used the comma must not be present -if followed by Doxygen post-comment. For example, this snippet will -cause Error: Syntax error in input(3).: -

      - -
      -/**
      - * Comments after enum items.
      - */
      -enum SomeEnum
      -{
      -  SOME_ITEM_100, ///< Post comment for the first item
      -  SOME_ITEM_200, ///< Comma after enum item causes error.
      -};
      -
      - - -

      -Solution: remove the comma after the last enum item: -

      - -
      -/**
      - * Comments after enum items.
      - */
      -enum SomeEnum
      -{
      -  SOME_ITEM_100, ///< Post comment for the first item
      -  SOME_ITEM_200  ///< OK.
      -};
      -
      - - - - -

      17.3.2 Conditional compilation

      - - -

      - Inserting of conditional compilation preprocessor directive between - Doxygen comment and commented item may also break parsing: -

      - - -
      -class A {
      -  /**
      -   * Some func.
      -   */
      -  #ifndef SWIG
      -  void myfunc()
      -  {
      -  }
      -  #endif
      -};
      -
      - -

      - Solution is to move the directive above comment: -

      - -
      -class A {
      -  #ifndef SWIG
      -  /**
      -   * Some func.
      -   */
      -  void myfunc()
      -  {
      -  }
      -  #endif
      -};
      -
      - -

      17.3 Doxygen to Javadoc

      @@ -1737,6 +1636,68 @@ Here is the list of these tags: TO BE ADDED.

      +

      17.4 Troubleshooting

      + + +

      +When running SWIG with command line switch -doxygen, it may happen +that SWIG will fail to parse the code, which is valid C++ code and +is parsed without problems without the switch. The problem is, +that Doxygen comments are not tokens (C/C++ compiler actually never +sees them) and that they can appear anywhere in the code. That's why it is +practically impossible to handle all corner cases with parser. +However, these problems can usually be avoided by minor changes in the +code or comment. Known problems and solutions are shown in this section. +

      + + +

      +Recommended approach is to first run SWIG without command line +switch -doxygen. When it successfully processes the code, +include the switch and fix problems with Doxygen comments. +

      + + +

      17.3.1 Problem with conditional compilation

      + + +

      + Inserting conditional compilation preprocessor directive between + Doxygen comment and commented item may break parsing: +

      + + +
      +class A {
      +  /**
      +   * Some func.
      +   */
      +  #ifndef SWIG
      +  void myfunc()
      +  {
      +  }
      +  #endif
      +};
      +
      + +

      + Solution is to move the directive above comment: +

      + +
      +class A {
      +  #ifndef SWIG
      +  /**
      +   * Some func.
      +   */
      +  void myfunc()
      +  {
      +  }
      +  #endif
      +};
      +
      + +

      17.5 Developer information

      From 57965e29f6bcafeefbb80cf600692accaeb112d3 Mon Sep 17 00:00:00 2001 From: Marko Klopcic Date: Tue, 23 Apr 2019 11:34:25 +0200 Subject: [PATCH 1577/2031] updated troubleshooting section --- Doc/Manual/Doxygen.html | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 4e4ed421c..67fe340d7 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -71,7 +71,7 @@ and Pydoc for the SWIG Java and Python modules. Other extensions could be added at a later date. The Doxygen Translation module originally started as a Google Summer of -Code proposal from Summer 2008. +Code proposal from Summer 2008.

      17.2 Preparations

      @@ -166,7 +166,7 @@ and in some special cases, like function parameter comments:
       void someFunction(
      -         int a ///< Some parameter
      +         int a ///< Some parameter 
            );
       
      @@ -443,7 +443,6 @@ This is only applicable to Java at the moment. ALSO TO BE ADDED (Javadoc auto brief?)

      -

      17.3 Doxygen to Javadoc

      @@ -487,9 +486,9 @@ Simply running SWIG should result in the following code being present in Shapes.
       
       /**
      - * This is describing class Shape
      - * @author Bob
      - *
      + * This is describing class Shape 
      + * @author Bob 
      + * 
        */
       
       public class Shape {
      @@ -497,35 +496,35 @@ public class Shape {
       ...
       
       /**
      - * Important Variables
      + * Important Variables 
        */
         public void setX(double value) {
           ShapesJNI.Shape_x_set(swigCPtr, this, value);
         }
       
       /**
      - * Important Variables
      + * Important Variables 
        */
         public double getX() {
           return ShapesJNI.Shape_x_get(swigCPtr, this);
         }
       
       /**
      - * Moves the Shape
      + * Moves the Shape 
        */
         public void move(double dx, double dy) {
           ShapesJNI.Shape_move(swigCPtr, this, dx, dy);
         }
       
       /**
      - * @return the area
      + * @return the area 
        */
         public double area() {
           return ShapesJNI.Shape_area(swigCPtr, this);
         }
       
       /**
      - * @return the perimeter
      + * @return the perimeter 
        */
         public double perimeter() {
           return ShapesJNI.Shape_perimeter(swigCPtr, this);
      @@ -547,7 +546,7 @@ The Javadoc translator will handle most of the tags conversions (see the
       table below). It will also automatically translate link-objects
       params, in \see and \link...\endlink commands. For example,
       'someFunction(std::string)' will be converted to
      -'someFunction(String)'.  If
      +'someFunction(String)'.  If 
       you don't want such behaviour, you could turn this off by using the
       'doxygen:nolinktranslate' feature. Also all '\param' and '\tparam'
       commands are stripped out, if the specified parameter is not present in
      @@ -1105,31 +1104,31 @@ Simply running SWIG should result in the following code being present in Shapes.
       
       class Shape(_object):
           """
      -    This is describing class Shape
      +    This is describing class Shape 
           Authors:
      -    Bob
      +    Bob 
       
           """
      -
      +    
           ...
      -
      +    
           def move(self, *args):
               """
      -        Moves the Shape
      +        Moves the Shape 
               """
               return _Shapes.Shape_move(self, *args)
       
           def area(self):
               """
               Return:
      -        the area
      +        the area 
               """
               return _Shapes.Shape_area(self)
       
           def perimeter(self):
               """
               Return:
      -        the perimeter
      +        the perimeter 
               """
               return _Shapes.Shape_perimeter(self)
       
      @@ -1776,7 +1775,7 @@ tool, for example: Examples/test-suite/java $ kdiff3 expected.txt got.txt - +

      Runtime tests in Java are implemented using Javadoc doclets. To make that work, you should have tools.jar from the JDK in your classpath. Or you should have JAVA_HOME From 453fe4cda84e99bb109c4a666c9ef2dd939ee371 Mon Sep 17 00:00:00 2001 From: Marko Klopcic Date: Tue, 23 Apr 2019 12:24:12 +0200 Subject: [PATCH 1578/2031] markok314: fixed section numbering because of inserted Doxygen troubleshooting section --- Doc/Manual/Doxygen.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 67fe340d7..3863aaa92 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -1635,7 +1635,7 @@ Here is the list of these tags: TO BE ADDED.

      -

      17.4 Troubleshooting

      +

      17.5 Troubleshooting

      @@ -1657,7 +1657,7 @@ include the switch and fix problems with Doxygen comments.

      -

      17.3.1 Problem with conditional compilation

      +

      17.5.1 Problem with conditional compilation

      @@ -1697,14 +1697,14 @@ class A { -

      17.5 Developer information

      +

      17.6 Developer information

      This section contains information for developers enhancing the Doxygen translator.

      -

      17.5.1 Doxygen translator design

      +

      17.6.1 Doxygen translator design

      @@ -1730,7 +1730,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

      -

      17.5.2 Debugging the Doxygen parser and translator

      +

      17.6.2 Debugging the Doxygen parser and translator

      @@ -1743,7 +1743,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

      17.5.3 Tests

      +

      17.6.3 Tests

      @@ -1795,7 +1795,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

      -

      17.6 Extending to other languages

      +

      17.7 Extending to other languages

      From 8212473b935b2e982a81028d40c3d1b83e8b3e8a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Apr 2019 11:34:48 +0100 Subject: [PATCH 1579/2031] Add missing issue number --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d36f43c41..5a86aea34 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,7 +8,7 @@ Version 4.0.0 (in progress) =========================== 2019-04-19: pbecherer - [Tcl] Fix Visual Studio 2015 and later compilation errors due to snprintf macro + [Tcl] #1508 Fix Visual Studio 2015 and later compilation errors due to snprintf macro definition. 2019-04-09: wsfulton From 03030e98a176e14e622bffd5d9542a64b05e1f9a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Apr 2019 07:32:50 +0100 Subject: [PATCH 1580/2031] Add -cgo as default to changes file --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5a86aea34..594bf7480 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-04-19: ianlancetaylor + [Go] #1055 When generating Go code, make -cgo the default. Add new -no-cgo option + to disable the default. + 2019-04-19: pbecherer [Tcl] #1508 Fix Visual Studio 2015 and later compilation errors due to snprintf macro definition. From fb0adb14c3be367fbb2ae69a1da644ec9d038b33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Apr 2019 08:04:15 +0100 Subject: [PATCH 1581/2031] Documentation: terminology consistency for command line options plus Doxygen tweaks. --- Doc/Manual/D.html | 8 ++++---- Doc/Manual/Doxygen.html | 22 +++++++++++----------- Doc/Manual/Java.html | 4 ++-- Doc/Manual/Preprocessor.html | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index f1b3404a6..d97267a5b 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -56,7 +56,7 @@

      23.2 Command line invocation

      -

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:

      +

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line options as with any other language module are available, plus the following D specific ones:

      -d2
      @@ -66,8 +66,8 @@
      -splitproxy
      -

      By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line switch), which contains all the proxy classes, functions, enums, etc., and the intermediary module (named like the proxy module, but suffixed with _im), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.

      -

      If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.

      +

      By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line option), which contains all the proxy classes, functions, enums, etc., and the intermediary module (named like the proxy module, but suffixed with _im), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.

      +

      If the split proxy mode is enabled by passing this option at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.

      -package <pkg>
      @@ -77,7 +77,7 @@
      -wrapperlibrary <wl>
      -

      The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called $module_wrap by default. With this switch, you can override the name of the file the wrapper code loads at runtime (the lib prefix and the suffix for shared libraries are appended automatically, depending on the OS).

      +

      The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called $module_wrap by default. With this option, you can override the name of the file the wrapper code loads at runtime (the lib prefix and the suffix for shared libraries are appended automatically, depending on the OS).

      This might especially be useful if you want to invoke SWIG several times on separate modules, but compile the resulting code into a single shared library.

      diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 3863aaa92..100d95ba4 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -195,7 +195,7 @@ These structural commands are stripped out by SWIG and are not assigned to anyth

      Doxygen comments translation is disabled by default and needs to be explicitly -enabled using the command line -doxygen switch for the languages that +enabled using the command line -doxygen option for the languages that do support it (currently Java and Python).

      @@ -1639,12 +1639,12 @@ TO BE ADDED.

      -When running SWIG with command line switch -doxygen, it may happen +When running SWIG with command line option -doxygen, it may happen that SWIG will fail to parse the code, which is valid C++ code and -is parsed without problems without the switch. The problem is, -that Doxygen comments are not tokens (C/C++ compiler actually never +is parsed without problems without the option. The problem is, +that Doxygen comments are not tokens (the C/C++ compiler actually never sees them) and that they can appear anywhere in the code. That's why it is -practically impossible to handle all corner cases with parser. +practically impossible to handle all corner cases with the parser. However, these problems can usually be avoided by minor changes in the code or comment. Known problems and solutions are shown in this section.

      @@ -1652,8 +1652,8 @@ code or comment. Known problems and solutions are shown in this section.

      Recommended approach is to first run SWIG without command line -switch -doxygen. When it successfully processes the code, -include the switch and fix problems with Doxygen comments. +option -doxygen. When it successfully processes the code, +include the option and fix problems with Doxygen comments.

      @@ -1661,8 +1661,8 @@ include the switch and fix problems with Doxygen comments.

      - Inserting conditional compilation preprocessor directive between - Doxygen comment and commented item may break parsing: + Inserting a conditional compilation preprocessor directive between a + Doxygen comment and a commented item may break parsing:

      @@ -1680,7 +1680,7 @@ class A {

      - Solution is to move the directive above comment: + The solution is to move the directive above the comment:

      @@ -1734,7 +1734,7 @@ example, JavaDocConverter is the Javadoc module class.
       
       
       

      -There are two handy command line switches, that enable lots of +There are two handy command line options, that enable lots of detailed debug information printing.

      diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index e0c6aed03..db5f041e4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -477,7 +477,7 @@ Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I

      where gcd is the missing JNI function that SWIG generated into the wrapper file. Also make sure you pass all of the required libraries to the linker. -The java -verbose:jni commandline switch is also a great way to get more information on unresolved symbols. +The java -verbose:jni commandline option is also a great way to get more information on unresolved symbols. One last piece of advice is to beware of the common faux pas of having more than one native library version in your path.

      @@ -645,7 +645,7 @@ java::

      To build the DLL and compile the java code, run NMAKE (you may need to run vcvars32 first). This is a pretty simplistic Makefile, but hopefully its enough to get you started. -Of course you may want to make changes for it to work for C++ by adding in the -c++ command line switch for swig and replacing .c with .cxx. +Of course you may want to make changes for it to work for C++ by adding in the -c++ command line option for swig and replacing .c with .cxx.

      diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index f28f7b2be..3d1bb453e 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -458,7 +458,7 @@ would generate

      Like many compilers, SWIG supports a -E command line option to display the output from the preprocessor. -When the -E switch is used, SWIG will not generate any wrappers. +When the -E option is used, SWIG will not generate any wrappers. Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

      From 8df627eab87efebbe0ee555d379e62dce2e00725 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Apr 2019 08:06:10 +0100 Subject: [PATCH 1582/2031] HTML section numbering update --- Doc/Manual/Contents.html | 4 ++++ Doc/Manual/Doxygen.html | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index fa1ef9b5c..57aef5b8a 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -647,6 +647,10 @@
    • Unsupported tags
    • Further details
    +
  • Troubleshooting +
  • Developer information
    • Doxygen translator design diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 100d95ba4..ff025c047 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -38,6 +38,9 @@
    • Further details
  • Troubleshooting +
  • Developer information
    • Doxygen translator design From b04cc850ab86091dae6923ca128a2ea491c6b2c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Apr 2019 08:13:19 +0100 Subject: [PATCH 1583/2031] Add recent doxygen fixes to changes file --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 594bf7480..fa13e9e48 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-04-24: vadz + #1517 Fix crash if "@return" Doxygen tag was used on a node without any return type. + +2019-04-24: vadz + #1515 Fix parsing of enums with trailing comma when using -doxygen. + 2019-04-19: ianlancetaylor [Go] #1055 When generating Go code, make -cgo the default. Add new -no-cgo option to disable the default. From 8a1c09e280e323ba48407a9a9ae86f19d1c7abbe Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 24 Apr 2019 21:43:38 -0700 Subject: [PATCH 1584/2031] Fix Go tests to run in module mode Stop using relative imports and add a go.mod file. Tested against Go 1.6 through Go pre-1.13, and gccgo. --- Doc/Manual/Go.html | 7 ++ Examples/Makefile.in | 57 ++++++++------ Examples/go/callback/runme.go | 3 +- Examples/go/class/runme.go | 3 +- Examples/go/constants/runme.go | 3 +- Examples/go/director/runme.go | 3 +- Examples/go/enum/runme.go | 3 +- Examples/go/extend/runme.go | 3 +- Examples/go/funcptr/runme.go | 3 +- Examples/go/multimap/runme.go | 3 +- Examples/go/pointer/runme.go | 3 +- Examples/go/reference/runme.go | 3 +- Examples/go/simple/runme.go | 3 +- Examples/go/template/runme.go | 3 +- Examples/go/variables/runme.go | 3 +- Examples/test-suite/go/Makefile.in | 78 ++++++++++++------- .../test-suite/go/abstract_access_runme.go | 2 +- .../test-suite/go/abstract_typedef2_runme.go | 2 +- .../test-suite/go/abstract_typedef_runme.go | 2 +- .../test-suite/go/abstract_virtual_runme.go | 2 +- Examples/test-suite/go/argout_runme.go | 2 +- Examples/test-suite/go/array_member_runme.go | 2 +- Examples/test-suite/go/arrays_global_runme.go | 2 +- Examples/test-suite/go/char_binary_runme.go | 2 +- Examples/test-suite/go/class_ignore_runme.go | 2 +- .../test-suite/go/class_scope_weird_runme.go | 2 +- .../test-suite/go/compactdefaultargs_runme.go | 2 +- Examples/test-suite/go/constover_runme.go | 3 +- .../test-suite/go/constructor_copy_runme.go | 2 +- Examples/test-suite/go/contract_runme.go | 2 +- ...cpp11_strongly_typed_enumerations_runme.go | 2 +- Examples/test-suite/go/cpp_enum_runme.go | 2 +- Examples/test-suite/go/cpp_namespace_runme.go | 2 +- Examples/test-suite/go/cpp_static_runme.go | 2 +- Examples/test-suite/go/default_args_runme.go | 2 +- .../go/default_constructor_runme.go | 2 +- .../go/director_alternating_runme.go | 2 +- .../test-suite/go/director_basic_runme.go | 2 +- .../test-suite/go/director_classic_runme.go | 2 +- .../test-suite/go/director_default_runme.go | 2 +- .../test-suite/go/director_detect_runme.go | 2 +- Examples/test-suite/go/director_enum_runme.go | 2 +- .../test-suite/go/director_exception_runme.go | 2 +- .../test-suite/go/director_extend_runme.go | 2 +- .../test-suite/go/director_finalizer_runme.go | 2 +- Examples/test-suite/go/director_frob_runme.go | 2 +- .../test-suite/go/director_nested_runme.go | 2 +- .../test-suite/go/director_profile_runme.go | 2 +- .../test-suite/go/director_protected_runme.go | 2 +- .../test-suite/go/director_string_runme.go | 2 +- .../test-suite/go/director_unroll_runme.go | 2 +- Examples/test-suite/go/disown_runme.go | 2 +- Examples/test-suite/go/dynamic_cast_runme.go | 2 +- Examples/test-suite/go/empty_c_runme.go | 2 +- Examples/test-suite/go/empty_runme.go | 2 +- Examples/test-suite/go/enum_template_runme.go | 2 +- Examples/test-suite/go/enums_runme.go | 2 +- .../test-suite/go/exception_order_runme.go | 2 +- .../test-suite/go/extend_placement_runme.go | 2 +- .../test-suite/go/extend_template_ns_runme.go | 2 +- .../test-suite/go/extend_template_runme.go | 2 +- .../test-suite/go/extend_variable_runme.go | 2 +- Examples/test-suite/go/extern_c_runme.go | 2 +- Examples/test-suite/go/friends_runme.go | 2 +- Examples/test-suite/go/fvirtual_runme.go | 2 +- Examples/test-suite/go/global_ns_arg_runme.go | 2 +- .../test-suite/go/go_director_inout_runme.go | 2 +- Examples/test-suite/go/go_inout_runme.go | 2 +- .../test-suite/go/go_subdir_import_runme.go | 6 +- Examples/test-suite/go/grouping_runme.go | 2 +- .../test-suite/go/import_nomodule_runme.go | 2 +- Examples/test-suite/go/imports_runme.go | 4 +- Examples/test-suite/go/inctest_runme.go | 2 +- .../test-suite/go/inherit_member_runme.go | 2 +- .../test-suite/go/inherit_missing_runme.go | 2 +- Examples/test-suite/go/input_runme.go | 2 +- .../test-suite/go/keyword_rename_c_runme.go | 2 +- .../test-suite/go/keyword_rename_runme.go | 2 +- Examples/test-suite/go/li_attribute_runme.go | 2 +- .../test-suite/go/li_carrays_cpp_runme.go | 2 +- Examples/test-suite/go/li_carrays_runme.go | 2 +- Examples/test-suite/go/li_cdata_cpp_runme.go | 2 +- Examples/test-suite/go/li_cdata_runme.go | 2 +- Examples/test-suite/go/li_cmalloc_runme.go | 2 +- .../test-suite/go/li_cpointer_cpp_runme.go | 2 +- Examples/test-suite/go/li_cpointer_runme.go | 2 +- Examples/test-suite/go/li_std_map_runme.go | 2 +- .../test-suite/go/li_std_vector_ptr_runme.go | 2 +- .../test-suite/go/member_pointer_runme.go | 2 +- .../test-suite/go/memberin_extend_c_runme.go | 2 +- Examples/test-suite/go/minherit_runme.go | 2 +- Examples/test-suite/go/mod_runme.go | 4 +- Examples/test-suite/go/multi_import_runme.go | 4 +- .../test-suite/go/namespace_class_runme.go | 2 +- .../test-suite/go/namespace_typemap_runme.go | 2 +- .../go/namespace_virtual_method_runme.go | 2 +- Examples/test-suite/go/naturalvar_runme.go | 2 +- .../test-suite/go/nested_workaround_runme.go | 2 +- .../go/overload_complicated_runme.go | 2 +- Examples/test-suite/go/overload_copy_runme.go | 2 +- .../test-suite/go/overload_extend2_runme.go | 2 +- .../test-suite/go/overload_extend_c_runme.go | 2 +- .../test-suite/go/overload_extend_runme.go | 2 +- .../go/overload_polymorphic_runme.go | 2 +- .../test-suite/go/overload_rename_runme.go | 2 +- .../test-suite/go/overload_simple_runme.go | 2 +- .../test-suite/go/overload_subtype_runme.go | 2 +- .../go/overload_template_fast_runme.go | 2 +- .../test-suite/go/overload_template_runme.go | 2 +- Examples/test-suite/go/preproc_runme.go | 2 +- Examples/test-suite/go/primitive_ref_runme.go | 2 +- Examples/test-suite/go/profiletest_runme.go | 2 +- Examples/test-suite/go/refcount_runme.go | 2 +- .../go/reference_global_vars_runme.go | 2 +- Examples/test-suite/go/rename_scope_runme.go | 2 +- Examples/test-suite/go/rename_simple_runme.go | 2 +- .../go/rename_strip_encoder_runme.go | 2 +- Examples/test-suite/go/ret_by_value_runme.go | 2 +- .../test-suite/go/return_const_value_runme.go | 2 +- .../go/smart_pointer_extend_runme.go | 2 +- .../go/smart_pointer_member_runme.go | 2 +- .../go/smart_pointer_multi_runme.go | 2 +- .../go/smart_pointer_multi_typedef_runme.go | 2 +- .../go/smart_pointer_overload_runme.go | 2 +- .../go/smart_pointer_rename_runme.go | 2 +- .../go/smart_pointer_simple_runme.go | 2 +- .../smart_pointer_templatevariables_runme.go | 2 +- .../go/smart_pointer_typedef_runme.go | 2 +- Examples/test-suite/go/sneaky1_runme.go | 2 +- .../go/special_variable_macros_runme.go | 2 +- .../go/static_const_member_2_runme.go | 2 +- .../go/struct_initialization_runme.go | 2 +- Examples/test-suite/go/struct_rename_runme.go | 2 +- Examples/test-suite/go/struct_value_runme.go | 2 +- .../go/template_default_arg_runme.go | 2 +- .../test-suite/go/template_extend1_runme.go | 2 +- .../test-suite/go/template_extend2_runme.go | 2 +- .../test-suite/go/template_inherit_runme.go | 2 +- Examples/test-suite/go/template_ns4_runme.go | 2 +- Examples/test-suite/go/template_ns_runme.go | 2 +- .../test-suite/go/template_opaque_runme.go | 2 +- .../test-suite/go/template_ref_type_runme.go | 2 +- .../test-suite/go/template_rename_runme.go | 2 +- .../test-suite/go/template_static_runme.go | 2 +- .../go/template_tbase_template_runme.go | 2 +- .../go/template_type_namespace_runme.go | 2 +- .../go/template_typedef_cplx3_runme.go | 2 +- .../go/template_typedef_cplx4_runme.go | 2 +- .../test-suite/go/threads_exception_runme.go | 2 +- Examples/test-suite/go/typedef_class_runme.go | 2 +- .../test-suite/go/typedef_funcptr_runme.go | 2 +- .../test-suite/go/typedef_inherit_runme.go | 2 +- Examples/test-suite/go/typedef_scope_runme.go | 2 +- .../test-suite/go/typemap_namespace_runme.go | 2 +- .../test-suite/go/typemap_ns_using_runme.go | 2 +- .../go/typemap_out_optimal_runme.go | 2 +- Examples/test-suite/go/typename_runme.go | 2 +- Examples/test-suite/go/unions_runme.go | 2 +- Examples/test-suite/go/using1_runme.go | 2 +- Examples/test-suite/go/using2_runme.go | 2 +- .../test-suite/go/using_composition_runme.go | 2 +- Examples/test-suite/go/using_extend_runme.go | 2 +- Examples/test-suite/go/using_inherit_runme.go | 2 +- Examples/test-suite/go/using_private_runme.go | 2 +- .../test-suite/go/using_protected_runme.go | 2 +- .../test-suite/go/varargs_overload_runme.go | 2 +- Examples/test-suite/go/varargs_runme.go | 2 +- .../test-suite/go/virtual_derivation_runme.go | 2 +- Examples/test-suite/go/virtual_poly_runme.go | 2 +- Examples/test-suite/go/voidtest_runme.go | 2 +- Examples/test-suite/go/wrapmacro_runme.go | 2 +- Examples/test-suite/go_subdir_import.list | 2 +- Source/Modules/go.cxx | 21 ++++- 173 files changed, 298 insertions(+), 227 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index dbea7de96..cfa56dbcf 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -266,6 +266,13 @@ swig -go -help ignored.
  • + + +
    -cgoGenerate files to be used as input for the Go cgo tool. This - option is required for Go 1.5 and later, and works for Go 1.2 and - later. In the future this option will likely become the - default.Generate files to be used as input for the Go cgo tool. This is + the default.
    -no-cgoGenerate files that can be used directly, rather than via the Go + cgo tool. This option does not work with Go 1.5 or later. It is + required for versions of Go before 1.2.
    -import-prefix <prefix>A prefix to add when turning a %import prefix in the SWIG + interface file into an import statement in the Go file. For + example, with -import-prefix mymodule, a SWIG + interface file %import mypackage will become a Go + import statement import "mymodule/mypackage".
    diff --git a/Examples/Makefile.in b/Examples/Makefile.in index d7b71af2f..98be7873f 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1457,7 +1457,8 @@ GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi` GOPACKAGE = $(notdir $(INTERFACE:.i=.a)) -GOPATHDIR = gopath/src/$(INTERFACE:.i=) +GOPATHPARENTDIR = gopath/$(GOMOD)/src +GOPATHDIR = $(GOPATHPARENTDIR)/$(INTERFACE:.i=) GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi` GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT)) @@ -1467,6 +1468,16 @@ GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) # Build a Go module (C) # ---------------------------------------------------------------- +$(GOPATHPARENTDIR)/go.mod: + @mkdir gopath 2>/dev/null || true + @mkdir gopath/$(GOMOD) 2>/dev/null || true + @mkdir gopath/$(GOMOD)/src 2>/dev/null || true + @mkdir $(GOPATHDIR) 2>/dev/null || true + echo "module swigtests" > $(GOPATHDIR)/go.mod + echo "" >> $(GOPATHDIR)/go.mod + echo "go 1.12" >> $(GOPATHDIR)/go.mod + mv -f $(GOPATHDIR)/go.mod $(GOPATHPARENTDIR)/go.mod + go_nocgo: $(SRCDIR_SRCS) $(SWIG) -go -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \ @@ -1503,11 +1514,12 @@ go_nocgo: $(SRCDIR_SRCS) fi; \ fi -go: $(SRCDIR_SRCS) - $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) +go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod + $(SWIG) -go -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true - @mkdir gopath/src 2>/dev/null || true - @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true + @mkdir gopath/$(GOMOD) 2>/dev/null || true + @mkdir gopath/$(GOMOD)/src 2>/dev/null || true + @mkdir $(GOPATHDIR) 2>/dev/null || true rm -f $(GOPATHDIR)/* cp $(ISRCS) $(GOPATHDIR)/ if test -f $(IWRAP:.i=.h); then \ @@ -1517,7 +1529,7 @@ go: $(SRCDIR_SRCS) cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \ fi cp $(GOSRCS) $(GOPATHDIR)/ - GOPATH=`pwd`/gopath; \ + GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ export CGO_CPPFLAGS; \ @@ -1526,17 +1538,16 @@ go: $(SRCDIR_SRCS) CGO_LDFLAGS="$(LDFLAGS) -lm"; \ export CGO_LDFLAGS; \ (cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)) - cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE) if $(GOGCC); then \ - cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \ + cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \ fi if test -f $(SRCDIR)$(RUNME).go; then \ if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE); \ + $(COMPILETOOL) $(GCCGO) -c -g -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \ + $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE); \ elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ + $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ + $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ @@ -1595,11 +1606,12 @@ go_cpp_nocgo: $(SRCDIR_SRCS) fi; \ fi -go_cpp: $(SRCDIR_SRCS) - $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) +go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod + $(SWIG) -go -c++ -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true - @mkdir gopath/src 2>/dev/null || true - @mkdir gopath/src/$(INTERFACE:.i=) 2>/dev/null || true + @mkdir gopath/$(GOMOD) 2>/dev/null || true + @mkdir gopath/$(GOMOD)/src 2>/dev/null || true + @mkdir $(GOPATHDIR) 2>/dev/null || true rm -f $(GOPATHDIR)/* cp $(ICXXSRCS) $(GOPATHDIR)/ if test -f $(IWRAP:.i=.h); then \ @@ -1612,7 +1624,7 @@ go_cpp: $(SRCDIR_SRCS) cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \ fi cp $(GOSRCS) $(GOPATHDIR)/ - GOPATH=`pwd`/gopath; \ + GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ export CGO_CPPFLAGS; \ @@ -1623,17 +1635,16 @@ go_cpp: $(SRCDIR_SRCS) CGO_LDFLAGS="$(LDFLAGS) -lm"; \ export CGO_LDFLAGS; \ (cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)) - cp $(GOPATHDIR)/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE) if $(GOGCC); then \ - cp $(dir $(INTERFACE))/$(GOPACKAGE) $(dir $(INTERFACE))/$(GOPACKAGE:.a=.gox); \ + cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \ fi if test -f $(SRCDIR)$(RUNME).go; then \ if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(dir $(INTERFACE))/$(GOPACKAGE) -lstdc++; \ + $(COMPILETOOL) $(GCCGO) -g -c -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \ + $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE) -lstdc++; \ elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ + $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ + $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go index 03ab0c5e2..2c1d81343 100644 --- a/Examples/go/callback/runme.go +++ b/Examples/go/callback/runme.go @@ -1,8 +1,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go index 8d68afb61..d2f292ed4 100644 --- a/Examples/go/class/runme.go +++ b/Examples/go/class/runme.go @@ -3,8 +3,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go index 1427997a0..d56fd62c8 100644 --- a/Examples/go/constants/runme.go +++ b/Examples/go/constants/runme.go @@ -1,8 +1,9 @@ package main import ( - "./example" "fmt" + + "example" ) func main() { diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go index 0d839bc88..0e0da07bd 100644 --- a/Examples/go/director/runme.go +++ b/Examples/go/director/runme.go @@ -1,9 +1,10 @@ package main import ( - "./example" "fmt" "os" + + "example" ) func Compare(name string, got string, exp string) error { diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go index 99d2651f4..50887056e 100644 --- a/Examples/go/enum/runme.go +++ b/Examples/go/enum/runme.go @@ -1,8 +1,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index a56968937..af64a6e5d 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -3,8 +3,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go index 44dae3c9e..4b20db4fb 100644 --- a/Examples/go/funcptr/runme.go +++ b/Examples/go/funcptr/runme.go @@ -1,8 +1,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go index 390205a80..571fac7c2 100644 --- a/Examples/go/multimap/runme.go +++ b/Examples/go/multimap/runme.go @@ -1,8 +1,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go index 1414d341e..0cf340f51 100644 --- a/Examples/go/pointer/runme.go +++ b/Examples/go/pointer/runme.go @@ -1,8 +1,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go index 004a04c2e..9999733b3 100644 --- a/Examples/go/reference/runme.go +++ b/Examples/go/reference/runme.go @@ -3,8 +3,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go index 9eb0ff454..0bd4657f9 100644 --- a/Examples/go/simple/runme.go +++ b/Examples/go/simple/runme.go @@ -1,8 +1,9 @@ package main import ( - "./example" "fmt" + + "example" ) func main() { diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go index fca2f1b75..347795377 100644 --- a/Examples/go/template/runme.go +++ b/Examples/go/template/runme.go @@ -3,8 +3,9 @@ package main import ( - . "./example" "fmt" + + . "example" ) func main() { diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go index 3d9737f5c..e2dd0c67f 100644 --- a/Examples/go/variables/runme.go +++ b/Examples/go/variables/runme.go @@ -3,8 +3,9 @@ package main import ( - "./example" "fmt" + + "example" ) func main() { diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index b7be554d7..d07a56bec 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -73,7 +73,18 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) %.multicpptest: $(setup) - +$(swig_and_compile_multi_cpp) + mkdir -p gopath/$*/src 2>/dev/null || true + if ! test -d gopath/$*/src/swigtests; then \ + (cd gopath/$*/src && ln -s . swigtests); \ + fi + +for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ + LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ + GOMOD="$*" \ + $(LANGUAGE)$(VARIANT)_cpp; \ + done $(run_multi_testcase) li_windows.cpptest: @@ -82,50 +93,55 @@ li_windows.cpptest: multi_import.multicpptest: $(setup) + mkdir -p gopath/multi_import/src 2>/dev/null || true + if ! test -d gopath/multi_import/src/swigtests; then \ + (cd gopath/multi_import/src && ln -s . swigtests); \ + fi for f in multi_import_b multi_import_a; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ + GOMOD="multi_import" \ $(LANGUAGE)$(VARIANT)_cpp; \ done $(run_multi_testcase) go_subdir_import.multicpptest: $(setup) - mkdir -p testdir/go_subdir_import/ - mkdir -p gopath/src/testdir/go_subdir_import/ + mkdir -p gopath/go_subdir_import/src 2>/dev/null || true + if ! test -d gopath/go_subdir_import/src/swigtests; then \ + (cd gopath/go_subdir_import/src && ln -s . swigtests); \ + fi + mkdir -p testdir/go_subdir_import 2>/dev/null || true + mkdir -p gopath/go_subdir_import/src/testdir/go_subdir_import 2>/dev/null || true $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ LIBS='$(LIBS)' INTERFACEPATH='$(SRCDIR)$(INTERFACEDIR)go_subdir_import_b.i' \ INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT) -outdir .' NOLINK=true \ TARGET='$(TARGETPREFIX)go_subdir_import_b$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' \ INTERFACE='testdir/go_subdir_import/go_subdir_import_b.i' \ + GOMOD="go_subdir_import" \ $(LANGUAGE)$(VARIANT)_cpp; for f in testdir/go_subdir_import/go_subdir_import_c go_subdir_import_a ; do \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ LIBS='$(LIBS)' INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR='$(INTERFACEDIR)' INTERFACE="$$f.i" \ + GOMOD="go_subdir_import" \ $(LANGUAGE)$(VARIANT)_cpp; \ done - if $(GOGCC); then \ - cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a gopath/src/testdir/go_subdir_import/go_subdir_import_b.gox; \ - cp gopath/src/testdir/go_subdir_import/go_subdir_import_b/go_subdir_import_b.a .; \ - cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a gopath/src/testdir/go_subdir_import/go_subdir_import_c.gox; \ - cp gopath/src/testdir/go_subdir_import/go_subdir_import_c/go_subdir_import_c.a testdir/go_subdir_import/; \ - fi $(run_multi_testcase) # Runs the testcase. run_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a; \ + $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a; \ elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ @@ -136,11 +152,11 @@ run_testcase = \ run_testcase_cpp = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.a -lstdc++; \ + $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a -lstdc++; \ elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ + $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ else \ $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ @@ -150,18 +166,24 @@ run_testcase_cpp = \ run_multi_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I . -I gopath/src $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + if $(GO15) || $(GOGCC); then \ files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ - $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.a; done` -lstdc++; \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - fi && \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ + mkdir gopath/$*/src/$* 2>/dev/null || true; \ + cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \ + GOPATH="`pwd`/gopath/$*"; \ + export GOPATH; \ + CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \ + export CGO_CPPFLAGS; \ + CGO_CFLAGS="$(CFLAGS)"; \ + export CGO_CFLAGS; \ + CGO_CXXFLAGS="$(CXXFLAGS)"; \ + export CGO_CXXFLAGS; \ + CGO_LDFLAGS="$(LDFLAGS) -lm"; \ + export CGO_LDFLAGS; \ + (cd gopath/$*/src/$* && \ + $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ + fi; \ fi %.clean: diff --git a/Examples/test-suite/go/abstract_access_runme.go b/Examples/test-suite/go/abstract_access_runme.go index a2cfeda92..5102236f9 100644 --- a/Examples/test-suite/go/abstract_access_runme.go +++ b/Examples/test-suite/go/abstract_access_runme.go @@ -1,6 +1,6 @@ package main -import "./abstract_access" +import "abstract_access" func main() { d := abstract_access.NewD() diff --git a/Examples/test-suite/go/abstract_typedef2_runme.go b/Examples/test-suite/go/abstract_typedef2_runme.go index ef760e45d..76a5fc8de 100644 --- a/Examples/test-suite/go/abstract_typedef2_runme.go +++ b/Examples/test-suite/go/abstract_typedef2_runme.go @@ -1,6 +1,6 @@ package main -import "./abstract_typedef2" +import "abstract_typedef2" func main() { abstract_typedef2.NewA_UF() diff --git a/Examples/test-suite/go/abstract_typedef_runme.go b/Examples/test-suite/go/abstract_typedef_runme.go index 99ff94ded..56aaa613f 100644 --- a/Examples/test-suite/go/abstract_typedef_runme.go +++ b/Examples/test-suite/go/abstract_typedef_runme.go @@ -1,6 +1,6 @@ package main -import "./abstract_typedef" +import "abstract_typedef" func main() { e := abstract_typedef.NewEngine() diff --git a/Examples/test-suite/go/abstract_virtual_runme.go b/Examples/test-suite/go/abstract_virtual_runme.go index b87cf9b5c..e19eac27d 100644 --- a/Examples/test-suite/go/abstract_virtual_runme.go +++ b/Examples/test-suite/go/abstract_virtual_runme.go @@ -1,6 +1,6 @@ package main -import "./abstract_virtual" +import "abstract_virtual" func main() { abstract_virtual.NewD() diff --git a/Examples/test-suite/go/argout_runme.go b/Examples/test-suite/go/argout_runme.go index 5f7017e73..bb8ab9ed2 100644 --- a/Examples/test-suite/go/argout_runme.go +++ b/Examples/test-suite/go/argout_runme.go @@ -1,6 +1,6 @@ package main -import wrap "./argout" +import wrap "argout" func main() { ip := wrap.New_intp() diff --git a/Examples/test-suite/go/array_member_runme.go b/Examples/test-suite/go/array_member_runme.go index d8a8fac2b..4f029db98 100644 --- a/Examples/test-suite/go/array_member_runme.go +++ b/Examples/test-suite/go/array_member_runme.go @@ -1,6 +1,6 @@ package main -import . "./array_member" +import . "array_member" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/arrays_global_runme.go b/Examples/test-suite/go/arrays_global_runme.go index 0ff40090c..35b049d9a 100644 --- a/Examples/test-suite/go/arrays_global_runme.go +++ b/Examples/test-suite/go/arrays_global_runme.go @@ -1,6 +1,6 @@ package main -import . "./arrays_global" +import . "arrays_global" func main() { SetArray_i(GetArray_const_i()) diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go index 50f2e121d..d47d616af 100644 --- a/Examples/test-suite/go/char_binary_runme.go +++ b/Examples/test-suite/go/char_binary_runme.go @@ -1,6 +1,6 @@ package main -import . "./char_binary" +import . "char_binary" func main() { t := NewTest() diff --git a/Examples/test-suite/go/class_ignore_runme.go b/Examples/test-suite/go/class_ignore_runme.go index 82e52eff5..24261c637 100644 --- a/Examples/test-suite/go/class_ignore_runme.go +++ b/Examples/test-suite/go/class_ignore_runme.go @@ -1,6 +1,6 @@ package main -import "./class_ignore" +import "class_ignore" func main() { a := class_ignore.NewBar() diff --git a/Examples/test-suite/go/class_scope_weird_runme.go b/Examples/test-suite/go/class_scope_weird_runme.go index 332586f31..a42bdad21 100644 --- a/Examples/test-suite/go/class_scope_weird_runme.go +++ b/Examples/test-suite/go/class_scope_weird_runme.go @@ -1,6 +1,6 @@ package main -import "./class_scope_weird" +import "class_scope_weird" func main() { f := class_scope_weird.NewFoo() diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go index 46f3ff3f9..fe6224ca2 100644 --- a/Examples/test-suite/go/compactdefaultargs_runme.go +++ b/Examples/test-suite/go/compactdefaultargs_runme.go @@ -1,6 +1,6 @@ package main -import . "./compactdefaultargs" +import . "compactdefaultargs" func main() { defaults1 := NewDefaults1(1000) diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go index f961e01b5..6c837095a 100644 --- a/Examples/test-suite/go/constover_runme.go +++ b/Examples/test-suite/go/constover_runme.go @@ -1,9 +1,10 @@ package main import ( - "./constover" "fmt" "os" + + "constover" ) func main() { diff --git a/Examples/test-suite/go/constructor_copy_runme.go b/Examples/test-suite/go/constructor_copy_runme.go index d9b77a9db..68c428853 100644 --- a/Examples/test-suite/go/constructor_copy_runme.go +++ b/Examples/test-suite/go/constructor_copy_runme.go @@ -1,6 +1,6 @@ package main -import . "./constructor_copy" +import . "constructor_copy" func main() { f1 := NewFoo1(3) diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go index b20a1a64f..b028855c3 100644 --- a/Examples/test-suite/go/contract_runme.go +++ b/Examples/test-suite/go/contract_runme.go @@ -1,6 +1,6 @@ package main -import "./contract" +import "contract" func main() { contract.Test_preassert(1, 2) diff --git a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go index f4b84b1ee..f9ca74a1e 100644 --- a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go +++ b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "./cpp11_strongly_typed_enumerations" +import . "cpp11_strongly_typed_enumerations" func enumCheck(actual int, expected int) int { if actual != expected { diff --git a/Examples/test-suite/go/cpp_enum_runme.go b/Examples/test-suite/go/cpp_enum_runme.go index 7d7db953d..8906dd4f1 100644 --- a/Examples/test-suite/go/cpp_enum_runme.go +++ b/Examples/test-suite/go/cpp_enum_runme.go @@ -1,6 +1,6 @@ package main -import "./cpp_enum" +import "cpp_enum" func main() { f := cpp_enum.NewFoo() diff --git a/Examples/test-suite/go/cpp_namespace_runme.go b/Examples/test-suite/go/cpp_namespace_runme.go index 8482b043f..aecdd9543 100644 --- a/Examples/test-suite/go/cpp_namespace_runme.go +++ b/Examples/test-suite/go/cpp_namespace_runme.go @@ -1,7 +1,7 @@ // Note: This example assumes that namespaces are flattened package main -import "./cpp_namespace" +import "cpp_namespace" func main() { n := cpp_namespace.Fact(4) diff --git a/Examples/test-suite/go/cpp_static_runme.go b/Examples/test-suite/go/cpp_static_runme.go index ead433466..1ad981a60 100644 --- a/Examples/test-suite/go/cpp_static_runme.go +++ b/Examples/test-suite/go/cpp_static_runme.go @@ -1,6 +1,6 @@ package main -import . "./cpp_static" +import . "cpp_static" func main() { StaticFunctionTestStatic_func() diff --git a/Examples/test-suite/go/default_args_runme.go b/Examples/test-suite/go/default_args_runme.go index 38243ac44..a39f95716 100644 --- a/Examples/test-suite/go/default_args_runme.go +++ b/Examples/test-suite/go/default_args_runme.go @@ -1,6 +1,6 @@ package main -import "./default_args" +import "default_args" func main() { if default_args.StaticsStaticmethod() != 60 { diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go index 40a5a6e49..eeac7eaf8 100644 --- a/Examples/test-suite/go/default_constructor_runme.go +++ b/Examples/test-suite/go/default_constructor_runme.go @@ -1,6 +1,6 @@ package main -import dc "./default_constructor" +import dc "default_constructor" func main() { a := dc.NewA() diff --git a/Examples/test-suite/go/director_alternating_runme.go b/Examples/test-suite/go/director_alternating_runme.go index 10f6774a3..b4793aa8f 100644 --- a/Examples/test-suite/go/director_alternating_runme.go +++ b/Examples/test-suite/go/director_alternating_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_alternating" +import . "director_alternating" func main() { id := GetBar().Id() diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go index 0ce780bbd..360424d9b 100644 --- a/Examples/test-suite/go/director_basic_runme.go +++ b/Examples/test-suite/go/director_basic_runme.go @@ -1,6 +1,6 @@ package main -import "./director_basic" +import "director_basic" type GoFoo struct{} diff --git a/Examples/test-suite/go/director_classic_runme.go b/Examples/test-suite/go/director_classic_runme.go index 45e89eac5..230c9638d 100644 --- a/Examples/test-suite/go/director_classic_runme.go +++ b/Examples/test-suite/go/director_classic_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "./director_classic" +import . "director_classic" type TargetLangPerson struct{} // From Person func (p *TargetLangPerson) Id() string { diff --git a/Examples/test-suite/go/director_default_runme.go b/Examples/test-suite/go/director_default_runme.go index 2f963b239..ac2aace1d 100644 --- a/Examples/test-suite/go/director_default_runme.go +++ b/Examples/test-suite/go/director_default_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_default" +import . "director_default" func main() { NewFoo() diff --git a/Examples/test-suite/go/director_detect_runme.go b/Examples/test-suite/go/director_detect_runme.go index 9f1ad94a9..0c3c95fdc 100644 --- a/Examples/test-suite/go/director_detect_runme.go +++ b/Examples/test-suite/go/director_detect_runme.go @@ -1,6 +1,6 @@ package main -import "./director_detect" +import "director_detect" type MyBar struct { val int diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go index 5653fda40..002d425d2 100644 --- a/Examples/test-suite/go/director_enum_runme.go +++ b/Examples/test-suite/go/director_enum_runme.go @@ -1,6 +1,6 @@ package main -import "./director_enum" +import "director_enum" type MyFoo struct{} // From director_enum.Foo func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello { diff --git a/Examples/test-suite/go/director_exception_runme.go b/Examples/test-suite/go/director_exception_runme.go index 29df3e40b..55231ff16 100644 --- a/Examples/test-suite/go/director_exception_runme.go +++ b/Examples/test-suite/go/director_exception_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_exception" +import . "director_exception" type Exception struct { msg string diff --git a/Examples/test-suite/go/director_extend_runme.go b/Examples/test-suite/go/director_extend_runme.go index 70e2ab41b..27e55b997 100644 --- a/Examples/test-suite/go/director_extend_runme.go +++ b/Examples/test-suite/go/director_extend_runme.go @@ -5,7 +5,7 @@ package main -import . "./director_extend" +import . "director_extend" func main() { m := NewSpObject() diff --git a/Examples/test-suite/go/director_finalizer_runme.go b/Examples/test-suite/go/director_finalizer_runme.go index 96fcf860e..d36a4ba33 100644 --- a/Examples/test-suite/go/director_finalizer_runme.go +++ b/Examples/test-suite/go/director_finalizer_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_finalizer" +import . "director_finalizer" type MyFoo struct{} // From Foo func DeleteMyFoo(p Foo) { diff --git a/Examples/test-suite/go/director_frob_runme.go b/Examples/test-suite/go/director_frob_runme.go index a6afedf69..3985eb14b 100644 --- a/Examples/test-suite/go/director_frob_runme.go +++ b/Examples/test-suite/go/director_frob_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_frob" +import . "director_frob" func main() { foo := NewBravo() diff --git a/Examples/test-suite/go/director_nested_runme.go b/Examples/test-suite/go/director_nested_runme.go index 2d3bc77e1..a1193ad59 100644 --- a/Examples/test-suite/go/director_nested_runme.go +++ b/Examples/test-suite/go/director_nested_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_nested" +import . "director_nested" type A struct{} // From FooBar_int func (p *A) Do_step() string { diff --git a/Examples/test-suite/go/director_profile_runme.go b/Examples/test-suite/go/director_profile_runme.go index 87edcbe26..a9bc7934b 100644 --- a/Examples/test-suite/go/director_profile_runme.go +++ b/Examples/test-suite/go/director_profile_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "./director_profile" +import "director_profile" type MyB struct{} // From director_profile.B func (p *MyB) Vfi(a int) int { diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go index 24adfe7bd..bfd50c6b2 100644 --- a/Examples/test-suite/go/director_protected_runme.go +++ b/Examples/test-suite/go/director_protected_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_protected" +import . "director_protected" type FooBar struct{} // From Bar func (p *FooBar) Ping() string { diff --git a/Examples/test-suite/go/director_string_runme.go b/Examples/test-suite/go/director_string_runme.go index c5201ab96..f4f9cc150 100644 --- a/Examples/test-suite/go/director_string_runme.go +++ b/Examples/test-suite/go/director_string_runme.go @@ -1,6 +1,6 @@ package main -import . "./director_string" +import . "director_string" type B struct { // From A abi A diff --git a/Examples/test-suite/go/director_unroll_runme.go b/Examples/test-suite/go/director_unroll_runme.go index 6d2894a72..6a919f656 100644 --- a/Examples/test-suite/go/director_unroll_runme.go +++ b/Examples/test-suite/go/director_unroll_runme.go @@ -1,6 +1,6 @@ package main -import "./director_unroll" +import "director_unroll" type MyFoo struct{} // From director_unroll.Foo func (p *MyFoo) Ping() string { diff --git a/Examples/test-suite/go/disown_runme.go b/Examples/test-suite/go/disown_runme.go index 3e853de59..4484515fd 100644 --- a/Examples/test-suite/go/disown_runme.go +++ b/Examples/test-suite/go/disown_runme.go @@ -1,6 +1,6 @@ package main -import . "./disown" +import . "disown" func main() { a := NewA() diff --git a/Examples/test-suite/go/dynamic_cast_runme.go b/Examples/test-suite/go/dynamic_cast_runme.go index 476734805..46ba23698 100644 --- a/Examples/test-suite/go/dynamic_cast_runme.go +++ b/Examples/test-suite/go/dynamic_cast_runme.go @@ -1,6 +1,6 @@ package main -import "./dynamic_cast" +import "dynamic_cast" func main() { f := dynamic_cast.NewFoo() diff --git a/Examples/test-suite/go/empty_c_runme.go b/Examples/test-suite/go/empty_c_runme.go index 831a56118..1a1bd9cc5 100644 --- a/Examples/test-suite/go/empty_c_runme.go +++ b/Examples/test-suite/go/empty_c_runme.go @@ -1,6 +1,6 @@ package main -import _ "./empty_c" +import _ "empty_c" func main() { } diff --git a/Examples/test-suite/go/empty_runme.go b/Examples/test-suite/go/empty_runme.go index f74285cb0..681a6f3ad 100644 --- a/Examples/test-suite/go/empty_runme.go +++ b/Examples/test-suite/go/empty_runme.go @@ -1,6 +1,6 @@ package main -import _ "./empty" +import _ "empty" func main() { } diff --git a/Examples/test-suite/go/enum_template_runme.go b/Examples/test-suite/go/enum_template_runme.go index 269fe7d5b..c60a452d7 100644 --- a/Examples/test-suite/go/enum_template_runme.go +++ b/Examples/test-suite/go/enum_template_runme.go @@ -1,6 +1,6 @@ package main -import "./enum_template" +import "enum_template" func main() { if enum_template.MakeETest() != 1 { diff --git a/Examples/test-suite/go/enums_runme.go b/Examples/test-suite/go/enums_runme.go index ab193f74b..7a528b3e2 100644 --- a/Examples/test-suite/go/enums_runme.go +++ b/Examples/test-suite/go/enums_runme.go @@ -1,6 +1,6 @@ package main -import "./enums" +import "enums" func main() { enums.Bar2(1) diff --git a/Examples/test-suite/go/exception_order_runme.go b/Examples/test-suite/go/exception_order_runme.go index 626a826f8..21dcff312 100644 --- a/Examples/test-suite/go/exception_order_runme.go +++ b/Examples/test-suite/go/exception_order_runme.go @@ -1,7 +1,7 @@ package main import "strings" -import . "./exception_order" +import . "exception_order" func main() { a := NewA() diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go index efa776e31..253ec6618 100644 --- a/Examples/test-suite/go/extend_placement_runme.go +++ b/Examples/test-suite/go/extend_placement_runme.go @@ -1,6 +1,6 @@ package main -import "./extend_placement" +import "extend_placement" func main() { foo := extend_placement.NewFoo() diff --git a/Examples/test-suite/go/extend_template_ns_runme.go b/Examples/test-suite/go/extend_template_ns_runme.go index 164a31b26..d005172a4 100644 --- a/Examples/test-suite/go/extend_template_ns_runme.go +++ b/Examples/test-suite/go/extend_template_ns_runme.go @@ -1,6 +1,6 @@ package main -import . "./extend_template_ns" +import . "extend_template_ns" func main() { f := NewFoo_One() diff --git a/Examples/test-suite/go/extend_template_runme.go b/Examples/test-suite/go/extend_template_runme.go index 5adb4b3c2..a5c4da4e1 100644 --- a/Examples/test-suite/go/extend_template_runme.go +++ b/Examples/test-suite/go/extend_template_runme.go @@ -1,6 +1,6 @@ package main -import "./extend_template" +import "extend_template" func main() { f := extend_template.NewFoo_0() diff --git a/Examples/test-suite/go/extend_variable_runme.go b/Examples/test-suite/go/extend_variable_runme.go index c6428c467..9425aee4d 100644 --- a/Examples/test-suite/go/extend_variable_runme.go +++ b/Examples/test-suite/go/extend_variable_runme.go @@ -1,6 +1,6 @@ package main -import . "./extend_variable" +import . "extend_variable" func main() { if FooBar != 42 { diff --git a/Examples/test-suite/go/extern_c_runme.go b/Examples/test-suite/go/extern_c_runme.go index 0fb5b21cc..9bc2cd0cc 100644 --- a/Examples/test-suite/go/extern_c_runme.go +++ b/Examples/test-suite/go/extern_c_runme.go @@ -1,6 +1,6 @@ package main -import "./extern_c" +import "extern_c" func main() { extern_c.RealFunction(2) diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go index 9f223fcac..2e34a4db0 100644 --- a/Examples/test-suite/go/friends_runme.go +++ b/Examples/test-suite/go/friends_runme.go @@ -1,6 +1,6 @@ package main -import "./friends" +import "friends" func main() { a := friends.NewA(2) diff --git a/Examples/test-suite/go/fvirtual_runme.go b/Examples/test-suite/go/fvirtual_runme.go index 8810d5cbb..86ef90f18 100644 --- a/Examples/test-suite/go/fvirtual_runme.go +++ b/Examples/test-suite/go/fvirtual_runme.go @@ -1,6 +1,6 @@ package main -import . "./fvirtual" +import . "fvirtual" func main() { sw := NewNodeSwitch() diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go index ece779c9c..e86aa6747 100644 --- a/Examples/test-suite/go/global_ns_arg_runme.go +++ b/Examples/test-suite/go/global_ns_arg_runme.go @@ -1,6 +1,6 @@ package main -import . "./global_ns_arg" +import . "global_ns_arg" func main() { Foo(1) diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go index 9b9df318e..e6768a465 100644 --- a/Examples/test-suite/go/go_director_inout_runme.go +++ b/Examples/test-suite/go/go_director_inout_runme.go @@ -1,7 +1,7 @@ package main import ( - wrap "./go_director_inout" + wrap "go_director_inout" ) type GoMyClass struct {} diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go index 9aa0cd0c5..4599aa104 100644 --- a/Examples/test-suite/go/go_inout_runme.go +++ b/Examples/test-suite/go/go_inout_runme.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "./go_inout" + "go_inout" ) type S struct { diff --git a/Examples/test-suite/go/go_subdir_import_runme.go b/Examples/test-suite/go/go_subdir_import_runme.go index f90a6eb54..a040c993f 100644 --- a/Examples/test-suite/go/go_subdir_import_runme.go +++ b/Examples/test-suite/go/go_subdir_import_runme.go @@ -1,9 +1,9 @@ package main import ( - "go_subdir_import_a" - "testdir/go_subdir_import/go_subdir_import_b" - "testdir/go_subdir_import/go_subdir_import_c" + "swigtests/go_subdir_import_a" + "swigtests/testdir/go_subdir_import/go_subdir_import_b" + "swigtests/testdir/go_subdir_import/go_subdir_import_c" ) func main() { diff --git a/Examples/test-suite/go/grouping_runme.go b/Examples/test-suite/go/grouping_runme.go index c63d6fb12..f808e1286 100644 --- a/Examples/test-suite/go/grouping_runme.go +++ b/Examples/test-suite/go/grouping_runme.go @@ -1,6 +1,6 @@ package main -import "./grouping" +import "grouping" func main() { x := grouping.Test1(42) diff --git a/Examples/test-suite/go/import_nomodule_runme.go b/Examples/test-suite/go/import_nomodule_runme.go index a6bbd7de5..48592df25 100644 --- a/Examples/test-suite/go/import_nomodule_runme.go +++ b/Examples/test-suite/go/import_nomodule_runme.go @@ -1,6 +1,6 @@ package main -import . "./import_nomodule" +import . "import_nomodule" func main() { f := Create_Foo() diff --git a/Examples/test-suite/go/imports_runme.go b/Examples/test-suite/go/imports_runme.go index 896036cbf..a67ae407b 100644 --- a/Examples/test-suite/go/imports_runme.go +++ b/Examples/test-suite/go/imports_runme.go @@ -2,8 +2,8 @@ package main -import "imports_b" -import "imports_a" +import "swigtests/imports_b" +import "swigtests/imports_a" func main() { x := imports_b.NewB() diff --git a/Examples/test-suite/go/inctest_runme.go b/Examples/test-suite/go/inctest_runme.go index f8a2c116c..3148abcd2 100644 --- a/Examples/test-suite/go/inctest_runme.go +++ b/Examples/test-suite/go/inctest_runme.go @@ -1,6 +1,6 @@ package main -import "./inctest" +import "inctest" func main() { inctest.NewA() diff --git a/Examples/test-suite/go/inherit_member_runme.go b/Examples/test-suite/go/inherit_member_runme.go index 599a0eb56..6fd70cf80 100644 --- a/Examples/test-suite/go/inherit_member_runme.go +++ b/Examples/test-suite/go/inherit_member_runme.go @@ -1,6 +1,6 @@ package main -import wrap "./inherit_member" +import wrap "inherit_member" func main() { s := wrap.NewChild() diff --git a/Examples/test-suite/go/inherit_missing_runme.go b/Examples/test-suite/go/inherit_missing_runme.go index ba9a2a516..c70c48306 100644 --- a/Examples/test-suite/go/inherit_missing_runme.go +++ b/Examples/test-suite/go/inherit_missing_runme.go @@ -1,6 +1,6 @@ package main -import "./inherit_missing" +import "inherit_missing" func main() { a := inherit_missing.New_Foo() diff --git a/Examples/test-suite/go/input_runme.go b/Examples/test-suite/go/input_runme.go index 207bdaa28..ddc2992fe 100644 --- a/Examples/test-suite/go/input_runme.go +++ b/Examples/test-suite/go/input_runme.go @@ -1,6 +1,6 @@ package main -import . "./input" +import . "input" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/keyword_rename_c_runme.go b/Examples/test-suite/go/keyword_rename_c_runme.go index 425e38a26..26f2ea42b 100644 --- a/Examples/test-suite/go/keyword_rename_c_runme.go +++ b/Examples/test-suite/go/keyword_rename_c_runme.go @@ -1,6 +1,6 @@ package main -import "./keyword_rename_c" +import "keyword_rename_c" func main() { keyword_rename_c.Xgo(1) diff --git a/Examples/test-suite/go/keyword_rename_runme.go b/Examples/test-suite/go/keyword_rename_runme.go index e36bc5968..7a40ff83d 100644 --- a/Examples/test-suite/go/keyword_rename_runme.go +++ b/Examples/test-suite/go/keyword_rename_runme.go @@ -1,6 +1,6 @@ package main -import "./keyword_rename" +import "keyword_rename" func main() { keyword_rename.Xgo(1) diff --git a/Examples/test-suite/go/li_attribute_runme.go b/Examples/test-suite/go/li_attribute_runme.go index 5d2c3d0c3..b502b8cea 100644 --- a/Examples/test-suite/go/li_attribute_runme.go +++ b/Examples/test-suite/go/li_attribute_runme.go @@ -1,6 +1,6 @@ package main -import "./li_attribute" +import "li_attribute" func main() { aa := li_attribute.NewA(1, 2, 3) diff --git a/Examples/test-suite/go/li_carrays_cpp_runme.go b/Examples/test-suite/go/li_carrays_cpp_runme.go index 7ee0a4103..cfc171284 100644 --- a/Examples/test-suite/go/li_carrays_cpp_runme.go +++ b/Examples/test-suite/go/li_carrays_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_carrays_cpp" +import . "li_carrays_cpp" func main() { d := NewDoubleArray(10) diff --git a/Examples/test-suite/go/li_carrays_runme.go b/Examples/test-suite/go/li_carrays_runme.go index 0cbe92cd8..9128bbfd1 100644 --- a/Examples/test-suite/go/li_carrays_runme.go +++ b/Examples/test-suite/go/li_carrays_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_carrays" +import . "li_carrays" func main() { d := NewDoubleArray(10) diff --git a/Examples/test-suite/go/li_cdata_cpp_runme.go b/Examples/test-suite/go/li_cdata_cpp_runme.go index 42a0ebd08..daa5384f7 100644 --- a/Examples/test-suite/go/li_cdata_cpp_runme.go +++ b/Examples/test-suite/go/li_cdata_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_cdata_cpp" +import . "li_cdata_cpp" func main() { s := "ABC abc" diff --git a/Examples/test-suite/go/li_cdata_runme.go b/Examples/test-suite/go/li_cdata_runme.go index f71a3a2c3..9458dab43 100644 --- a/Examples/test-suite/go/li_cdata_runme.go +++ b/Examples/test-suite/go/li_cdata_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_cdata" +import . "li_cdata" func main() { s := "ABC abc" diff --git a/Examples/test-suite/go/li_cmalloc_runme.go b/Examples/test-suite/go/li_cmalloc_runme.go index 45f47b45f..5b9f9704a 100644 --- a/Examples/test-suite/go/li_cmalloc_runme.go +++ b/Examples/test-suite/go/li_cmalloc_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_cmalloc" +import . "li_cmalloc" func main() { p := Malloc_int() diff --git a/Examples/test-suite/go/li_cpointer_cpp_runme.go b/Examples/test-suite/go/li_cpointer_cpp_runme.go index e2f5a59d1..0de57c624 100644 --- a/Examples/test-suite/go/li_cpointer_cpp_runme.go +++ b/Examples/test-suite/go/li_cpointer_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_cpointer_cpp" +import . "li_cpointer_cpp" func main() { p := New_intp() diff --git a/Examples/test-suite/go/li_cpointer_runme.go b/Examples/test-suite/go/li_cpointer_runme.go index 57493b122..0fe29e77d 100644 --- a/Examples/test-suite/go/li_cpointer_runme.go +++ b/Examples/test-suite/go/li_cpointer_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_cpointer" +import . "li_cpointer" func main() { p := New_intp() diff --git a/Examples/test-suite/go/li_std_map_runme.go b/Examples/test-suite/go/li_std_map_runme.go index 66e74dd60..5c5cc2e4c 100644 --- a/Examples/test-suite/go/li_std_map_runme.go +++ b/Examples/test-suite/go/li_std_map_runme.go @@ -1,6 +1,6 @@ package main -import "./li_std_map" +import "li_std_map" func main() { a1 := li_std_map.NewA(3) diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go index a9f7fe91c..d66ff19c6 100644 --- a/Examples/test-suite/go/li_std_vector_ptr_runme.go +++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go @@ -1,6 +1,6 @@ package main -import . "./li_std_vector_ptr" +import . "li_std_vector_ptr" import "fmt" func check(val1 int, val2 int) { diff --git a/Examples/test-suite/go/member_pointer_runme.go b/Examples/test-suite/go/member_pointer_runme.go index 9a55bc4b9..731526b75 100644 --- a/Examples/test-suite/go/member_pointer_runme.go +++ b/Examples/test-suite/go/member_pointer_runme.go @@ -3,7 +3,7 @@ package main import "fmt" -import . "./member_pointer" +import . "member_pointer" func check(what string, expected float64, actual float64) { if expected != actual { diff --git a/Examples/test-suite/go/memberin_extend_c_runme.go b/Examples/test-suite/go/memberin_extend_c_runme.go index ec8b11e60..0551acc90 100644 --- a/Examples/test-suite/go/memberin_extend_c_runme.go +++ b/Examples/test-suite/go/memberin_extend_c_runme.go @@ -1,6 +1,6 @@ package main -import "./memberin_extend_c" +import "memberin_extend_c" func main() { t := memberin_extend_c.NewPerson() diff --git a/Examples/test-suite/go/minherit_runme.go b/Examples/test-suite/go/minherit_runme.go index c69fe92c1..9b7873cb0 100644 --- a/Examples/test-suite/go/minherit_runme.go +++ b/Examples/test-suite/go/minherit_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "./minherit" +import "minherit" func main() { a := minherit.NewFoo() diff --git a/Examples/test-suite/go/mod_runme.go b/Examples/test-suite/go/mod_runme.go index 581c83918..8d894db8d 100644 --- a/Examples/test-suite/go/mod_runme.go +++ b/Examples/test-suite/go/mod_runme.go @@ -1,7 +1,7 @@ package main -import "mod_a" -import "mod_b" +import "swigtests/mod_a" +import "swigtests/mod_b" func main() { c := mod_b.NewC() diff --git a/Examples/test-suite/go/multi_import_runme.go b/Examples/test-suite/go/multi_import_runme.go index 973af1e7b..f30913c6d 100644 --- a/Examples/test-suite/go/multi_import_runme.go +++ b/Examples/test-suite/go/multi_import_runme.go @@ -1,7 +1,7 @@ package main -import "multi_import_a" -import "multi_import_b" +import "swigtests/multi_import_a" +import "swigtests/multi_import_b" func main() { x := multi_import_b.NewXXX() diff --git a/Examples/test-suite/go/namespace_class_runme.go b/Examples/test-suite/go/namespace_class_runme.go index 2ed5567f7..4c240b6a4 100644 --- a/Examples/test-suite/go/namespace_class_runme.go +++ b/Examples/test-suite/go/namespace_class_runme.go @@ -1,6 +1,6 @@ package main -import . "./namespace_class" +import . "namespace_class" func main() { EulerT3DToFrame(1, 1, 1) diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go index 056da1567..47e2b64f1 100644 --- a/Examples/test-suite/go/namespace_typemap_runme.go +++ b/Examples/test-suite/go/namespace_typemap_runme.go @@ -1,6 +1,6 @@ package main -import . "./namespace_typemap" +import . "namespace_typemap" func main() { if Stest1("hello") != "hello" { diff --git a/Examples/test-suite/go/namespace_virtual_method_runme.go b/Examples/test-suite/go/namespace_virtual_method_runme.go index 3f8e774c6..a8cb38bad 100644 --- a/Examples/test-suite/go/namespace_virtual_method_runme.go +++ b/Examples/test-suite/go/namespace_virtual_method_runme.go @@ -1,6 +1,6 @@ package main -import "./namespace_virtual_method" +import "namespace_virtual_method" func main() { _ = namespace_virtual_method.NewSpam() diff --git a/Examples/test-suite/go/naturalvar_runme.go b/Examples/test-suite/go/naturalvar_runme.go index e3723e6ab..ed47e9d2d 100644 --- a/Examples/test-suite/go/naturalvar_runme.go +++ b/Examples/test-suite/go/naturalvar_runme.go @@ -1,6 +1,6 @@ package main -import . "./naturalvar" +import . "naturalvar" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/nested_workaround_runme.go b/Examples/test-suite/go/nested_workaround_runme.go index 5737aaaf7..8b31a7f4b 100644 --- a/Examples/test-suite/go/nested_workaround_runme.go +++ b/Examples/test-suite/go/nested_workaround_runme.go @@ -1,6 +1,6 @@ package main -import . "./nested_workaround" +import . "nested_workaround" func main() { inner := NewInner(5) diff --git a/Examples/test-suite/go/overload_complicated_runme.go b/Examples/test-suite/go/overload_complicated_runme.go index e3911c218..ce9d124c8 100644 --- a/Examples/test-suite/go/overload_complicated_runme.go +++ b/Examples/test-suite/go/overload_complicated_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_complicated" +import . "overload_complicated" func main() { var pInt *int diff --git a/Examples/test-suite/go/overload_copy_runme.go b/Examples/test-suite/go/overload_copy_runme.go index d35ff70b1..55ec4a333 100644 --- a/Examples/test-suite/go/overload_copy_runme.go +++ b/Examples/test-suite/go/overload_copy_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_copy" +import . "overload_copy" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/overload_extend2_runme.go b/Examples/test-suite/go/overload_extend2_runme.go index 121506734..db790989c 100644 --- a/Examples/test-suite/go/overload_extend2_runme.go +++ b/Examples/test-suite/go/overload_extend2_runme.go @@ -1,6 +1,6 @@ package main -import "./overload_extend2" +import "overload_extend2" func main() { f := overload_extend2.NewFoo() diff --git a/Examples/test-suite/go/overload_extend_c_runme.go b/Examples/test-suite/go/overload_extend_c_runme.go index e00f0b945..4d3b2b6e1 100644 --- a/Examples/test-suite/go/overload_extend_c_runme.go +++ b/Examples/test-suite/go/overload_extend_c_runme.go @@ -1,6 +1,6 @@ package main -import "./overload_extend_c" +import "overload_extend_c" func main() { f := overload_extend_c.NewFoo() diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go index 1ba541f13..d73d6cf3c 100644 --- a/Examples/test-suite/go/overload_extend_runme.go +++ b/Examples/test-suite/go/overload_extend_runme.go @@ -1,6 +1,6 @@ package main -import "./overload_extend" +import "overload_extend" func main() { f := overload_extend.NewFoo() diff --git a/Examples/test-suite/go/overload_polymorphic_runme.go b/Examples/test-suite/go/overload_polymorphic_runme.go index 46f837f49..12b9777e6 100644 --- a/Examples/test-suite/go/overload_polymorphic_runme.go +++ b/Examples/test-suite/go/overload_polymorphic_runme.go @@ -1,6 +1,6 @@ package main -import "./overload_polymorphic" +import "overload_polymorphic" func main(){ t := overload_polymorphic.NewDerived() diff --git a/Examples/test-suite/go/overload_rename_runme.go b/Examples/test-suite/go/overload_rename_runme.go index dca5843c3..3bd4a69c5 100644 --- a/Examples/test-suite/go/overload_rename_runme.go +++ b/Examples/test-suite/go/overload_rename_runme.go @@ -1,6 +1,6 @@ package main -import "./overload_rename" +import "overload_rename" func main() { _ = overload_rename.NewFoo(float32(1)) diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go index 5f6d0558b..3eb859bac 100644 --- a/Examples/test-suite/go/overload_simple_runme.go +++ b/Examples/test-suite/go/overload_simple_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_simple" +import . "overload_simple" func main() { if Foo(3) != "foo:int" { diff --git a/Examples/test-suite/go/overload_subtype_runme.go b/Examples/test-suite/go/overload_subtype_runme.go index dc56d1ca7..45d5a025f 100644 --- a/Examples/test-suite/go/overload_subtype_runme.go +++ b/Examples/test-suite/go/overload_subtype_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_subtype" +import . "overload_subtype" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go index b80cb7dd4..63809c0ff 100644 --- a/Examples/test-suite/go/overload_template_fast_runme.go +++ b/Examples/test-suite/go/overload_template_fast_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_template_fast" +import . "overload_template_fast" func main() { _ = Foo() diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go index 53e1def1b..f3a08ecd6 100644 --- a/Examples/test-suite/go/overload_template_runme.go +++ b/Examples/test-suite/go/overload_template_runme.go @@ -1,6 +1,6 @@ package main -import . "./overload_template" +import . "overload_template" func main() { _ = Foo() diff --git a/Examples/test-suite/go/preproc_runme.go b/Examples/test-suite/go/preproc_runme.go index a15062241..3c55aae72 100644 --- a/Examples/test-suite/go/preproc_runme.go +++ b/Examples/test-suite/go/preproc_runme.go @@ -1,6 +1,6 @@ package main -import "./preproc" +import "preproc" func main() { if preproc.GetEndif() != 1 { diff --git a/Examples/test-suite/go/primitive_ref_runme.go b/Examples/test-suite/go/primitive_ref_runme.go index 973806955..a1de2f8a5 100644 --- a/Examples/test-suite/go/primitive_ref_runme.go +++ b/Examples/test-suite/go/primitive_ref_runme.go @@ -1,6 +1,6 @@ package main -import . "./primitive_ref" +import . "primitive_ref" func main() { if Ref_int(3) != 3 { diff --git a/Examples/test-suite/go/profiletest_runme.go b/Examples/test-suite/go/profiletest_runme.go index 30b6cee69..c2b922ba3 100644 --- a/Examples/test-suite/go/profiletest_runme.go +++ b/Examples/test-suite/go/profiletest_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "./profiletest" +import "profiletest" func main() { a := profiletest.NewA() diff --git a/Examples/test-suite/go/refcount_runme.go b/Examples/test-suite/go/refcount_runme.go index fdb271cc6..07d407273 100644 --- a/Examples/test-suite/go/refcount_runme.go +++ b/Examples/test-suite/go/refcount_runme.go @@ -1,6 +1,6 @@ package main -import . "./refcount" +import . "refcount" // very innocent example diff --git a/Examples/test-suite/go/reference_global_vars_runme.go b/Examples/test-suite/go/reference_global_vars_runme.go index b8cbb304a..908358f95 100644 --- a/Examples/test-suite/go/reference_global_vars_runme.go +++ b/Examples/test-suite/go/reference_global_vars_runme.go @@ -1,6 +1,6 @@ package main -import . "./reference_global_vars" +import . "reference_global_vars" func main() { // const class reference variable diff --git a/Examples/test-suite/go/rename_scope_runme.go b/Examples/test-suite/go/rename_scope_runme.go index 995f8c64d..13bd3f178 100644 --- a/Examples/test-suite/go/rename_scope_runme.go +++ b/Examples/test-suite/go/rename_scope_runme.go @@ -1,6 +1,6 @@ package main -import . "./rename_scope" +import . "rename_scope" func main() { a := NewNatural_UP() diff --git a/Examples/test-suite/go/rename_simple_runme.go b/Examples/test-suite/go/rename_simple_runme.go index a63023bd1..bd559ef27 100644 --- a/Examples/test-suite/go/rename_simple_runme.go +++ b/Examples/test-suite/go/rename_simple_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "./rename_simple" +import . "rename_simple" func main() { s := NewNewStruct() diff --git a/Examples/test-suite/go/rename_strip_encoder_runme.go b/Examples/test-suite/go/rename_strip_encoder_runme.go index 1d0bcb660..ae670600c 100644 --- a/Examples/test-suite/go/rename_strip_encoder_runme.go +++ b/Examples/test-suite/go/rename_strip_encoder_runme.go @@ -1,6 +1,6 @@ package main -import . "./rename_strip_encoder" +import . "rename_strip_encoder" func main() { _ = NewSomeWidget() diff --git a/Examples/test-suite/go/ret_by_value_runme.go b/Examples/test-suite/go/ret_by_value_runme.go index 44743d2b7..9659d21e9 100644 --- a/Examples/test-suite/go/ret_by_value_runme.go +++ b/Examples/test-suite/go/ret_by_value_runme.go @@ -1,6 +1,6 @@ package main -import "./ret_by_value" +import "ret_by_value" func main() { a := ret_by_value.Get_test() diff --git a/Examples/test-suite/go/return_const_value_runme.go b/Examples/test-suite/go/return_const_value_runme.go index 790921b74..aadb1265e 100644 --- a/Examples/test-suite/go/return_const_value_runme.go +++ b/Examples/test-suite/go/return_const_value_runme.go @@ -1,6 +1,6 @@ package main -import "./return_const_value" +import "return_const_value" func main() { p := return_const_value.Foo_ptrGetPtr() diff --git a/Examples/test-suite/go/smart_pointer_extend_runme.go b/Examples/test-suite/go/smart_pointer_extend_runme.go index ee5ce0538..a851e26b7 100644 --- a/Examples/test-suite/go/smart_pointer_extend_runme.go +++ b/Examples/test-suite/go/smart_pointer_extend_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_extend" +import . "smart_pointer_extend" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go index bf09fe5fc..e7fe7c4c2 100644 --- a/Examples/test-suite/go/smart_pointer_member_runme.go +++ b/Examples/test-suite/go/smart_pointer_member_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "./smart_pointer_member" +import . "smart_pointer_member" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_multi_runme.go b/Examples/test-suite/go/smart_pointer_multi_runme.go index d1a5f92f4..7c76061af 100644 --- a/Examples/test-suite/go/smart_pointer_multi_runme.go +++ b/Examples/test-suite/go/smart_pointer_multi_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_multi" +import . "smart_pointer_multi" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go index f71740bbb..e584cf7a2 100644 --- a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go +++ b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_multi_typedef" +import . "smart_pointer_multi_typedef" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go index 5ffeae17c..9481554f0 100644 --- a/Examples/test-suite/go/smart_pointer_overload_runme.go +++ b/Examples/test-suite/go/smart_pointer_overload_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_overload" +import . "smart_pointer_overload" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_rename_runme.go b/Examples/test-suite/go/smart_pointer_rename_runme.go index 678c305c8..44841f5e6 100644 --- a/Examples/test-suite/go/smart_pointer_rename_runme.go +++ b/Examples/test-suite/go/smart_pointer_rename_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_rename" +import . "smart_pointer_rename" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_simple_runme.go b/Examples/test-suite/go/smart_pointer_simple_runme.go index 328654225..b468bd2e5 100644 --- a/Examples/test-suite/go/smart_pointer_simple_runme.go +++ b/Examples/test-suite/go/smart_pointer_simple_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_simple" +import . "smart_pointer_simple" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go index bf58ba52c..6d4ea91de 100644 --- a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go +++ b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_templatevariables" +import . "smart_pointer_templatevariables" func main() { d := NewDiffImContainerPtr_D(Create(1234, 5678)) diff --git a/Examples/test-suite/go/smart_pointer_typedef_runme.go b/Examples/test-suite/go/smart_pointer_typedef_runme.go index a67a0ccda..e89a8b150 100644 --- a/Examples/test-suite/go/smart_pointer_typedef_runme.go +++ b/Examples/test-suite/go/smart_pointer_typedef_runme.go @@ -1,6 +1,6 @@ package main -import . "./smart_pointer_typedef" +import . "smart_pointer_typedef" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/sneaky1_runme.go b/Examples/test-suite/go/sneaky1_runme.go index ee38ae21b..57c779724 100644 --- a/Examples/test-suite/go/sneaky1_runme.go +++ b/Examples/test-suite/go/sneaky1_runme.go @@ -1,6 +1,6 @@ package main -import "./sneaky1" +import "sneaky1" func main() { _ = sneaky1.Add(3, 4) diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go index c4f687ea9..9338e6558 100644 --- a/Examples/test-suite/go/special_variable_macros_runme.go +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -1,6 +1,6 @@ package main -import "./special_variable_macros" +import "special_variable_macros" func main() { name := special_variable_macros.NewName() diff --git a/Examples/test-suite/go/static_const_member_2_runme.go b/Examples/test-suite/go/static_const_member_2_runme.go index 0d345c3d6..ff8cbbbcd 100644 --- a/Examples/test-suite/go/static_const_member_2_runme.go +++ b/Examples/test-suite/go/static_const_member_2_runme.go @@ -1,6 +1,6 @@ package main -import . "./static_const_member_2" +import . "static_const_member_2" func main() { _ = NewTest_int() diff --git a/Examples/test-suite/go/struct_initialization_runme.go b/Examples/test-suite/go/struct_initialization_runme.go index 58ac25010..a815bd3f5 100644 --- a/Examples/test-suite/go/struct_initialization_runme.go +++ b/Examples/test-suite/go/struct_initialization_runme.go @@ -1,6 +1,6 @@ package main -import . "./struct_initialization" +import . "struct_initialization" func main() { if GetInstanceC1().GetX() != 10 { diff --git a/Examples/test-suite/go/struct_rename_runme.go b/Examples/test-suite/go/struct_rename_runme.go index 845dac5be..de99fc320 100644 --- a/Examples/test-suite/go/struct_rename_runme.go +++ b/Examples/test-suite/go/struct_rename_runme.go @@ -1,6 +1,6 @@ package main -import "./struct_rename" +import "struct_rename" func main() { _ = struct_rename.NewBar() diff --git a/Examples/test-suite/go/struct_value_runme.go b/Examples/test-suite/go/struct_value_runme.go index d0b60bd23..3b5e5c1dc 100644 --- a/Examples/test-suite/go/struct_value_runme.go +++ b/Examples/test-suite/go/struct_value_runme.go @@ -1,6 +1,6 @@ package main -import "./struct_value" +import "struct_value" func main() { b := struct_value.NewBar() diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go index 3d9346b05..d67e63fa7 100644 --- a/Examples/test-suite/go/template_default_arg_runme.go +++ b/Examples/test-suite/go/template_default_arg_runme.go @@ -1,6 +1,6 @@ package main -import "./template_default_arg" +import "template_default_arg" func main() { helloInt := template_default_arg.NewHello_int() diff --git a/Examples/test-suite/go/template_extend1_runme.go b/Examples/test-suite/go/template_extend1_runme.go index 5d6d376f5..0912fa6ed 100644 --- a/Examples/test-suite/go/template_extend1_runme.go +++ b/Examples/test-suite/go/template_extend1_runme.go @@ -1,6 +1,6 @@ package main -import "./template_extend1" +import "template_extend1" func main() { a := template_extend1.NewLBaz() diff --git a/Examples/test-suite/go/template_extend2_runme.go b/Examples/test-suite/go/template_extend2_runme.go index 312410e27..ced3d93cc 100644 --- a/Examples/test-suite/go/template_extend2_runme.go +++ b/Examples/test-suite/go/template_extend2_runme.go @@ -1,6 +1,6 @@ package main -import "./template_extend2" +import "template_extend2" func main() { a := template_extend2.NewLBaz() diff --git a/Examples/test-suite/go/template_inherit_runme.go b/Examples/test-suite/go/template_inherit_runme.go index c0aca77c4..a8d5126dc 100644 --- a/Examples/test-suite/go/template_inherit_runme.go +++ b/Examples/test-suite/go/template_inherit_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_inherit" +import . "template_inherit" func main() { a := NewFooInt() diff --git a/Examples/test-suite/go/template_ns4_runme.go b/Examples/test-suite/go/template_ns4_runme.go index 4caf8f587..6c658ec97 100644 --- a/Examples/test-suite/go/template_ns4_runme.go +++ b/Examples/test-suite/go/template_ns4_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_ns4" +import . "template_ns4" func main() { d := Make_Class_DD() diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go index 6385eccf9..cfc56fa3c 100644 --- a/Examples/test-suite/go/template_ns_runme.go +++ b/Examples/test-suite/go/template_ns_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_ns" +import . "template_ns" func main() { p1 := NewPairii(2, 3) diff --git a/Examples/test-suite/go/template_opaque_runme.go b/Examples/test-suite/go/template_opaque_runme.go index 201f7ba16..71701df53 100644 --- a/Examples/test-suite/go/template_opaque_runme.go +++ b/Examples/test-suite/go/template_opaque_runme.go @@ -1,6 +1,6 @@ package main -import "./template_opaque" +import "template_opaque" func main() { v := template_opaque.NewOpaqueVectorType(int64(10)) diff --git a/Examples/test-suite/go/template_ref_type_runme.go b/Examples/test-suite/go/template_ref_type_runme.go index e4bf626fb..a01ce3d31 100644 --- a/Examples/test-suite/go/template_ref_type_runme.go +++ b/Examples/test-suite/go/template_ref_type_runme.go @@ -1,6 +1,6 @@ package main -import "./template_ref_type" +import "template_ref_type" func main() { xr := template_ref_type.NewXC() diff --git a/Examples/test-suite/go/template_rename_runme.go b/Examples/test-suite/go/template_rename_runme.go index 757ac7355..6e04f8845 100644 --- a/Examples/test-suite/go/template_rename_runme.go +++ b/Examples/test-suite/go/template_rename_runme.go @@ -1,6 +1,6 @@ package main -import "./template_rename" +import "template_rename" func main() { i := template_rename.NewIFoo() diff --git a/Examples/test-suite/go/template_static_runme.go b/Examples/test-suite/go/template_static_runme.go index 7fa50760a..f10ea78f7 100644 --- a/Examples/test-suite/go/template_static_runme.go +++ b/Examples/test-suite/go/template_static_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_static" +import . "template_static" func main() { FooBar_double(1) diff --git a/Examples/test-suite/go/template_tbase_template_runme.go b/Examples/test-suite/go/template_tbase_template_runme.go index 9a52e2fac..e1c46aaf7 100644 --- a/Examples/test-suite/go/template_tbase_template_runme.go +++ b/Examples/test-suite/go/template_tbase_template_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_tbase_template" +import . "template_tbase_template" func main() { a := Make_Class_dd() diff --git a/Examples/test-suite/go/template_type_namespace_runme.go b/Examples/test-suite/go/template_type_namespace_runme.go index a3712ff59..1356f9b08 100644 --- a/Examples/test-suite/go/template_type_namespace_runme.go +++ b/Examples/test-suite/go/template_type_namespace_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_type_namespace" +import . "template_type_namespace" func main() { if Foo().Get(0) == "" { diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go index d616777e0..0a2b31301 100644 --- a/Examples/test-suite/go/template_typedef_cplx3_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_typedef_cplx3" +import . "template_typedef_cplx3" func main() { // this is OK diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go index 3e536d6f2..d8952cfb6 100644 --- a/Examples/test-suite/go/template_typedef_cplx4_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go @@ -1,6 +1,6 @@ package main -import . "./template_typedef_cplx4" +import . "template_typedef_cplx4" func main() { // this is OK diff --git a/Examples/test-suite/go/threads_exception_runme.go b/Examples/test-suite/go/threads_exception_runme.go index 742a827bd..e3da1dc25 100644 --- a/Examples/test-suite/go/threads_exception_runme.go +++ b/Examples/test-suite/go/threads_exception_runme.go @@ -1,7 +1,7 @@ package main import "strings" -import "./threads_exception" +import "threads_exception" func main() { t := threads_exception.NewTest() diff --git a/Examples/test-suite/go/typedef_class_runme.go b/Examples/test-suite/go/typedef_class_runme.go index ec25162de..d94126d3b 100644 --- a/Examples/test-suite/go/typedef_class_runme.go +++ b/Examples/test-suite/go/typedef_class_runme.go @@ -1,6 +1,6 @@ package main -import "./typedef_class" +import "typedef_class" func main() { a := typedef_class.NewRealA() diff --git a/Examples/test-suite/go/typedef_funcptr_runme.go b/Examples/test-suite/go/typedef_funcptr_runme.go index 49d7086b1..9d55f3f04 100644 --- a/Examples/test-suite/go/typedef_funcptr_runme.go +++ b/Examples/test-suite/go/typedef_funcptr_runme.go @@ -1,6 +1,6 @@ package main -import . "./typedef_funcptr" +import . "typedef_funcptr" func main() { a := 100 diff --git a/Examples/test-suite/go/typedef_inherit_runme.go b/Examples/test-suite/go/typedef_inherit_runme.go index 49097999c..7a65569f2 100644 --- a/Examples/test-suite/go/typedef_inherit_runme.go +++ b/Examples/test-suite/go/typedef_inherit_runme.go @@ -1,6 +1,6 @@ package main -import "./typedef_inherit" +import "typedef_inherit" func main() { a := typedef_inherit.NewFoo() diff --git a/Examples/test-suite/go/typedef_scope_runme.go b/Examples/test-suite/go/typedef_scope_runme.go index 1c4314427..af282b16f 100644 --- a/Examples/test-suite/go/typedef_scope_runme.go +++ b/Examples/test-suite/go/typedef_scope_runme.go @@ -1,6 +1,6 @@ package main -import "./typedef_scope" +import "typedef_scope" func main() { b := typedef_scope.NewBar() diff --git a/Examples/test-suite/go/typemap_namespace_runme.go b/Examples/test-suite/go/typemap_namespace_runme.go index 45184fd1e..a2880d4a8 100644 --- a/Examples/test-suite/go/typemap_namespace_runme.go +++ b/Examples/test-suite/go/typemap_namespace_runme.go @@ -1,6 +1,6 @@ package main -import . "./typemap_namespace" +import . "typemap_namespace" func main() { if Test1("hello") != "hello" { diff --git a/Examples/test-suite/go/typemap_ns_using_runme.go b/Examples/test-suite/go/typemap_ns_using_runme.go index 877e44b3a..c4c21cf75 100644 --- a/Examples/test-suite/go/typemap_ns_using_runme.go +++ b/Examples/test-suite/go/typemap_ns_using_runme.go @@ -1,6 +1,6 @@ package main -import "./typemap_ns_using" +import "typemap_ns_using" func main() { if typemap_ns_using.Spam(37) != 37 { diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go index 7cbd0ad9b..7cc3b38e3 100644 --- a/Examples/test-suite/go/typemap_out_optimal_runme.go +++ b/Examples/test-suite/go/typemap_out_optimal_runme.go @@ -1,6 +1,6 @@ package main -import . "./typemap_out_optimal" +import . "typemap_out_optimal" func main() { SetXXDebug(false) diff --git a/Examples/test-suite/go/typename_runme.go b/Examples/test-suite/go/typename_runme.go index 0bc15f11a..d1665099c 100644 --- a/Examples/test-suite/go/typename_runme.go +++ b/Examples/test-suite/go/typename_runme.go @@ -1,6 +1,6 @@ package main -import "./typename" +import "typename" func main() { f := typename.NewFoo() diff --git a/Examples/test-suite/go/unions_runme.go b/Examples/test-suite/go/unions_runme.go index ba9c27b17..b76ca5c75 100644 --- a/Examples/test-suite/go/unions_runme.go +++ b/Examples/test-suite/go/unions_runme.go @@ -3,7 +3,7 @@ package main -import "./unions" +import "unions" func main() { // Create new instances of SmallStruct and BigStruct for later use diff --git a/Examples/test-suite/go/using1_runme.go b/Examples/test-suite/go/using1_runme.go index 8cc571288..a6a6fa738 100644 --- a/Examples/test-suite/go/using1_runme.go +++ b/Examples/test-suite/go/using1_runme.go @@ -1,6 +1,6 @@ package main -import "./using1" +import "using1" func main() { if using1.Spam(37) != 37 { diff --git a/Examples/test-suite/go/using2_runme.go b/Examples/test-suite/go/using2_runme.go index f679b0c40..f6b8d49b5 100644 --- a/Examples/test-suite/go/using2_runme.go +++ b/Examples/test-suite/go/using2_runme.go @@ -1,6 +1,6 @@ package main -import "./using2" +import "using2" func main() { if using2.Spam(37) != 37 { diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go index 47e245719..712d1fad5 100644 --- a/Examples/test-suite/go/using_composition_runme.go +++ b/Examples/test-suite/go/using_composition_runme.go @@ -1,6 +1,6 @@ package main -import . "./using_composition" +import . "using_composition" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go index 830c958e5..27d1ccc62 100644 --- a/Examples/test-suite/go/using_extend_runme.go +++ b/Examples/test-suite/go/using_extend_runme.go @@ -1,6 +1,6 @@ package main -import . "./using_extend" +import . "using_extend" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go index db29efb64..a88171817 100644 --- a/Examples/test-suite/go/using_inherit_runme.go +++ b/Examples/test-suite/go/using_inherit_runme.go @@ -1,6 +1,6 @@ package main -import . "./using_inherit" +import . "using_inherit" func main() { b := NewBar() diff --git a/Examples/test-suite/go/using_private_runme.go b/Examples/test-suite/go/using_private_runme.go index d683ef856..2da62dc2e 100644 --- a/Examples/test-suite/go/using_private_runme.go +++ b/Examples/test-suite/go/using_private_runme.go @@ -1,6 +1,6 @@ package main -import . "./using_private" +import . "using_private" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_protected_runme.go b/Examples/test-suite/go/using_protected_runme.go index 65edb5001..3fd5029f7 100644 --- a/Examples/test-suite/go/using_protected_runme.go +++ b/Examples/test-suite/go/using_protected_runme.go @@ -1,6 +1,6 @@ package main -import . "./using_protected" +import . "using_protected" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go index 5978be005..8ce580d65 100644 --- a/Examples/test-suite/go/varargs_overload_runme.go +++ b/Examples/test-suite/go/varargs_overload_runme.go @@ -1,6 +1,6 @@ package main -import "./varargs_overload" +import "varargs_overload" func main() { if varargs_overload.Vararg_over1("Hello") != "Hello" { diff --git a/Examples/test-suite/go/varargs_runme.go b/Examples/test-suite/go/varargs_runme.go index 4009c3ed3..60bd8829a 100644 --- a/Examples/test-suite/go/varargs_runme.go +++ b/Examples/test-suite/go/varargs_runme.go @@ -1,6 +1,6 @@ package main -import "./varargs" +import "varargs" func main() { if varargs.Test("Hello") != "Hello" { diff --git a/Examples/test-suite/go/virtual_derivation_runme.go b/Examples/test-suite/go/virtual_derivation_runme.go index 48a7033a2..4e2c6e585 100644 --- a/Examples/test-suite/go/virtual_derivation_runme.go +++ b/Examples/test-suite/go/virtual_derivation_runme.go @@ -1,6 +1,6 @@ package main -import . "./virtual_derivation" +import . "virtual_derivation" // very innocent example diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go index 487b371ba..32906b391 100644 --- a/Examples/test-suite/go/virtual_poly_runme.go +++ b/Examples/test-suite/go/virtual_poly_runme.go @@ -1,6 +1,6 @@ package main -import "./virtual_poly" +import "virtual_poly" func main() { d := virtual_poly.NewNDouble(3.5) diff --git a/Examples/test-suite/go/voidtest_runme.go b/Examples/test-suite/go/voidtest_runme.go index 0a685f081..133545cea 100644 --- a/Examples/test-suite/go/voidtest_runme.go +++ b/Examples/test-suite/go/voidtest_runme.go @@ -1,6 +1,6 @@ package main -import "./voidtest" +import "voidtest" func main() { voidtest.Globalfunc() diff --git a/Examples/test-suite/go/wrapmacro_runme.go b/Examples/test-suite/go/wrapmacro_runme.go index dc7e7bf5b..a251a05e8 100644 --- a/Examples/test-suite/go/wrapmacro_runme.go +++ b/Examples/test-suite/go/wrapmacro_runme.go @@ -1,6 +1,6 @@ package main -import "./wrapmacro" +import "wrapmacro" func main() { a := 2 diff --git a/Examples/test-suite/go_subdir_import.list b/Examples/test-suite/go_subdir_import.list index e117d32fa..074c795b3 100644 --- a/Examples/test-suite/go_subdir_import.list +++ b/Examples/test-suite/go_subdir_import.list @@ -1,3 +1,3 @@ testdir/go_subdir_import/go_subdir_import_c -go_subdir_import_b +testdir/go_subdir_import/go_subdir_import_b go_subdir_import_a diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 9e8162b5d..0163f71df 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -125,6 +125,8 @@ class GO:public Language { String *prefix_option; // -fgo-pkgpath option. String *pkgpath_option; + // Prefix for translating %import directive to import statements. + String *import_prefix; // Whether to use a shared library. bool use_shlib; // Name of shared library to import. @@ -204,6 +206,7 @@ public: go_prefix(NULL), prefix_option(NULL), pkgpath_option(NULL), + import_prefix(NULL), use_shlib(false), soname(NULL), intgo_type_size(0), @@ -293,6 +296,15 @@ private: } else { Swig_arg_error(); } + } else if (strcmp(argv[i], "-import-prefix") == 0) { + if (argv[i + 1]) { + import_prefix = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } } else if (strcmp(argv[i], "-use-shlib") == 0) { Swig_mark_arg(i); use_shlib = true; @@ -743,7 +755,11 @@ private: if (modname) { if (!Getattr(go_imports, modname)) { Setattr(go_imports, modname, modname); - Printv(f_go_imports, "import \"", modname, "\"\n", NULL); + Printv(f_go_imports, "import \"", NULL); + if (import_prefix) { + Printv(f_go_imports, import_prefix, "/", NULL); + } + Printv(f_go_imports, modname, "\"\n", NULL); } imported_package = modname; saw_import = true; @@ -6983,9 +6999,10 @@ const char * const GO::usage = "\ Go Options (available with -go)\n\ -cgo - Generate cgo input files\n\ -no-cgo - Do not generate cgo input files\n\ - -gccgo - Generate code for gccgo rather than 6g/8g\n\ + -gccgo - Generate code for gccgo rather than gc\n\ -go-pkgpath

    - Like gccgo -fgo-pkgpath option\n\ -go-prefix

    - Like gccgo -fgo-prefix option\n\ + -import-prefix

    - Prefix to add to %import directives\n\ -intgosize - Set size of Go int type--32 or 64 bits\n\ -package - Set name of the Go package to \n\ -use-shlib - Force use of a shared library\n\ From 83d1893cfd508a13d598a4484f9258b78babbbd9 Mon Sep 17 00:00:00 2001 From: Eric Tse Date: Thu, 25 Apr 2019 15:44:57 -0400 Subject: [PATCH 1585/2031] WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type --- Source/Modules/java.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index cb41781dd..0ad6cf6c0 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1893,18 +1893,32 @@ public: * ----------------------------------------------------------------------------- */ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { + Swig_warning(0, NULL, NULL, "******************************************\n"); + Swig_warning(0, NULL, NULL, "Smart: %s, Class name: '%s', baseclass: '%s' \n", smart, c_classname, c_baseclass); String *jniname = makeValidJniName(upcast_method_name); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name); if (smart) { - SwigType *bsmart = Copy(smart); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); + Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_classname(%s): '%s'\n", c_classname, rclassname); + SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); + Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_baseclass(%s): '%s'\n", c_baseclass, rbaseclass); + + Swig_warning(0, NULL, NULL, "Replaceall - PRE(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); + Replaceall(bsmartnamestr, rclassname, rbaseclass); + Swig_warning(0, NULL, NULL, "Replaceall - POST(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); + Delete(rclassname); Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); + //String *smartnamestr = SwigType_namestr(smart); + //String *bsmartnamestr = SwigType_namestr(bsmart); + Swig_warning(0, NULL, NULL, "bsmartnamestr: '%s', smartnamestr: '%s' \n", bsmartnamestr, smartnamestr); + + Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" @@ -1917,7 +1931,6 @@ public: "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); - Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1928,6 +1941,8 @@ public: " return baseptr;\n" "}\n", "\n", NIL); } + Swig_warning(0, NULL, NULL, "******************************************\n"); + Delete(wname); Delete(jniname); } From 11b54b0cbdac8707ee4c9ef4b32e51eebe7b669e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Apr 2019 23:12:23 +0100 Subject: [PATCH 1586/2031] Fix command line error handling to work like in 3.0.12 Output is once again: $ swig -versioon Unable to find option or file '-versioon', Use 'swig -help' for more information. instead of $ swig -versioon No target language specified --- Source/Modules/main.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 0b615ce0a..c6bd148e2 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -970,11 +970,6 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { SWIG_exit(EXIT_SUCCESS); // Exit if we're in help mode } - if (!tlm) { - Printf(stderr, "No target language specified\n"); - return 1; - } - // Check all of the options to make sure we're cool. // Don't check for an input file if -external-runtime is passed Swig_check_options(external_runtime ? 0 : 1); @@ -1070,7 +1065,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { 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"); + Printf(stderr, "Use 'swig -help' for more information.\n"); } else { Printf(stderr, "Unable to find file '%s'.\n", input_file); } @@ -1079,6 +1074,13 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { 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 } } + + if (!tlm) { + Printf(stderr, "No target language specified.\n"); + Printf(stderr, "Use 'swig -help' for more information.\n"); + SWIG_exit(EXIT_FAILURE); + } + if (!no_cpp) { fclose(df); Printf(fs, "%%include \n"); From 2937f0529615a6220418bc3bcdf18902ed8bb9a9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Apr 2019 19:21:40 +0100 Subject: [PATCH 1587/2031] Add 4.0.0 release date --- ANNOUNCE | 2 +- CHANGES.current | 2 +- Doc/Manual/Sections.html | 2 +- README | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 764f39c92..2ef6eb131 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 4.0.0 (in progress) *** +*** ANNOUNCE: SWIG 4.0.0 (27 Apr 2019) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index fa13e9e48..6ead3a621 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,7 +4,7 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.0 (in progress) +Version 4.0.0 (27 Apr 2019) =========================== 2019-04-24: vadz diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index f57108535..6db5c3cc1 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.0 (in progress) +Last update : SWIG-4.0.0 (27 Apr 2019)

    Sections

    diff --git a/README b/README index db468d8d4..ecf4f87fc 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.0 (in progress) +Version: 4.0.0 (27 Apr 2019) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, From 9c3faeb0ee6c588bc4772bd186554796cc1e446e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Apr 2019 19:48:33 +0100 Subject: [PATCH 1588/2031] Travis testing of Go changes Use gimme to install a version of Go to test. Travis already uses gimme to pre-install a version of Go. Switch some of the Go testing from travis to xenial. --- .travis.yml | 13 +++++++++---- Tools/travis-linux-install.sh | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78d8883b5..61021b4e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,14 +31,19 @@ matrix: dist: trusty - compiler: gcc os: linux - env: SWIGLANG=go + env: SWIGLANG=go VER=1.3 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux - env: SWIGLANG=go VER=1.5 + env: SWIGLANG=go VER=1.8 sudo: required - dist: trusty + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=go VER=1.12 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=guile diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index dc8526546..bfa7bf8eb 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -37,6 +37,9 @@ case "$SWIGLANG" in travis_retry sudo dpkg -i dmd_2.066.0-0_amd64.deb ;; "go") + if [[ "$VER" ]]; then + eval "$(gimme ${VER}.x)" + fi ;; "javascript") case "$ENGINE" in From 6a91723fcfeb413350d46908343de2eb5562e3b4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Apr 2019 21:01:21 +0100 Subject: [PATCH 1589/2031] Bump version to 4.0.1 --- ANNOUNCE | 20 +- CHANGES | 1535 ++++++++++++++++++++++++++++++++++++++ CHANGES.current | 1533 +------------------------------------ Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 1548 insertions(+), 1546 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 2ef6eb131..b83921cc4 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 4.0.0 (27 Apr 2019) *** +*** ANNOUNCE: SWIG 4.0.1 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-4.0.0, the latest SWIG release. +We're pleased to announce SWIG-4.0.1, the latest SWIG release. What is SWIG? ============= @@ -10,13 +10,11 @@ What is SWIG? SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible from other programming languages including Perl, Python, Tcl, Ruby, -PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme), -D, Ocaml, Octave, R, Scilab. -SWIG can also export its parse tree in -the form of XML. Major applications of SWIG -include generation of scripting language extension modules, rapid -prototyping, testing, and user interface development for large -C/C++ systems. +PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme), D, +Ocaml, Octave, R, Scilab. SWIG can also export its parse tree in +the form of XML. Major applications of SWIG include generation of +scripting language extension modules, rapid prototyping, testing, +and user interface development for large C/C++ systems. Release Notes ============= @@ -27,11 +25,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-4.0.0.tar.gz + http://prdownloads.sourceforge.net/swig/swig-4.0.1.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-4.0.0.zip + http://prdownloads.sourceforge.net/swig/swigwin-4.0.1.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 958e7cb0c..77d570ddb 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,1541 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ +Version 4.0.0 (27 Apr 2019) +=========================== + +2019-04-24: vadz + #1517 Fix crash if "@return" Doxygen tag was used on a node without any return type. + +2019-04-24: vadz + #1515 Fix parsing of enums with trailing comma when using -doxygen. + +2019-04-19: ianlancetaylor + [Go] #1055 When generating Go code, make -cgo the default. Add new -no-cgo option + to disable the default. + +2019-04-19: pbecherer + [Tcl] #1508 Fix Visual Studio 2015 and later compilation errors due to snprintf macro + definition. + +2019-04-09: wsfulton + [C#] Fix FxCop warning CA2002 in SWIGPendingException - a lock on a reference of + type 'Type'. + +2019-03-30: wsfulton + [Java, D] Add the parameters typemap attribute to the javadestruct, + javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced + flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided + the contents are generated as the delete/dispose method's parameters declaration. + +2019-03-30: wsfulton + [C#] #421 Fix FxCop warning CA1063 by implementing the recommended Dispose methods for + the IDisposable interface. Previously just the Dispose() method was generated. + Now the Dispose() and Dispose(bool disposing) methods are generated. + Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" + typemaps are being used. Details in #421 on Github. SWIG will error out if one of + the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example + error message: + + foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove + it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the + csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps. + + *** POTENTIAL INCOMPATIBILITY *** + +2019-03-25: Liryna + [C#] #1143 Add std_list.i for std::list support. + The C# std::list wrappers are made to look and feel like a C# + System.Collections.Generic.LinkedList<> collection. + The IEnumerable<> interface is implemented in the proxy class. + The ICollection<> interface can also be implemented to provide enhanced functionality + whenever a C++ operator== is available. This is the case for when T is a + primitive type or a pointer. If T does define an operator==, then use the + SWIG_STD_LIST_ENHANCED macro to obtain this enhanced functionality, for example: + + SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass) + %template(ListKlass) std::list; + +2019-03-18: richardbeare + [R] #1328 Non-trivial enums are working now. The enum values are now obtained from + the C/C++ layer. const reference enums and C++11 enum classes are also now working. + +2019-03-14: mochizk + [Javascript] #1500 Fix compilation errors due to deprecating V8 API in Node.js. + New V8 API is used if node.js >= v10.12, or if V8 >= v7.0. + +2019-03-12: vadz + [C#] #1495 Add std_set.i for std::set support. + +2019-03-11: dirteat,opoplawski + [Octave] Fix compilation errors in Octave 5.1. + + error: format not a string literal and no format arguments [-Werror=format-security] + +2019-02-28: wsfulton + [Java] std::vector improvements for types that do not have a default constructor. + + The std::vector wrappers have been changed to work by default for elements that are + not default insertable, i.e. have no default constructor. This has been achieved by + not wrapping: + + vector(size_type n); + + Previously the above had to be ignored via %ignore. + + If the above constructor is still required it can be added back in again via %extend: + + %extend std::vector { + vector(size_type count) { return new std::vector< T >(count); } + } + + Alternatively, the following wrapped constructor could be used as it provides near-enough + equivalent functionality: + + vector(jint count, const value_type& value); + + *** POTENTIAL INCOMPATIBILITY *** + +2019-02-25: wsfulton + [Python] Fix compile errors wrapping overloaded functions/constructors where a vararg + function is declared after a non-vararg function. + +2019-02-23: zphensley42 + Use fully qualified name 'java.lang.Object' instead of 'Object' in generated code to + avoid clashes with wrapped C++ classes called 'Object'. + +2019-02-23: gtbX + [Java] #1035 Add (const char *STRING, size_t LENGTH) typemaps in addition to the non-const + typemaps (char *STRING, size_t LENGTH) which does not attempt to write back to the const + string. + +2019-02-22: tamuratak + [Ruby] #984 Add support for RTypedData introduced in Ruby 1.9.3. + +2019-02-22: ZackerySpytz + #1483 Fix compilation failures when a director class has final methods. + +2019-02-21: wsfulton + [Java] #1240 Suppress Java 9 deprecation warnings on finalize method. + +2019-02-21: ZackerySpytz + #1480 Fix some rejections of valid floating-point literals. + +2019-02-19: wsfulton + #1475 Fix regression parsing gcc preprocessor linemarkers in the form: + + # linenum filename flags + +2019-02-18: jakecobb + [Python] #945 #1234 Elements in std::vector memory access fix. + + Accessing an element in a std::vector obtains a reference to the element via an + iterator pointing to the element in the container. If the vector is garbage collected, + the SWIG wrapper containing the pointer to the element becomes invalid. The fix is + to obtain a back-reference to the container by the wrapper to the element in the Python + layer to prevent the garbage collector from destroying the underlying container. + +2019-02-17: wsfulton + Fix typemap matching to expand template parameters when the name contains + template parameters. In the %typemap below the type is T and the name is X::make + and the name now expands correctly to X< int >::make + + template struct X { + %typemap(out) T X::make "..." + T make(); + }; + + %template(Xint) X; + +2019-02-16: wsfulton + Fix parser error containing multiple #define statements inside an enum. + + The second #define fails to parse: + + enum FooEnum { + ENUM1 = 0, + ENUM2 = 1, + + #define MACRO_DEF1 "Hello" + #define MACRO_DEF2 "World!" + + ENUM3 = 2, + ENUM4 = 3, + }; + + Bug mentioned at https://sourceforge.net/p/swig/patches/333/ + +2019-02-14: wsfulton + Add some missing copy constructors into STL containers. + +2019-02-14: bkotzz + [Java] #1356 Add STL containers: + std::unordered_map + std::unordered_set + std::set + +2019-02-14: bkotzz + [Java] #1356 std::map wrappers have been modified. Now the Java proxy class + extends java.util.AbstractMap. The std::map container looks and feels much like + a java.util.HashMap from Java. + + A few members have changed their names. If the old method signatures are needed, + then copy std_map.i from swig-3.0.12 and use that instead. Alternatively, + add the old missing methods to the new methods by using the following %proxycode: + + %extend std::map { + %proxycode %{ + // Old API + public boolean empty() { + return isEmpty(); + } + public void set($typemap(jboxtype, K) key, $typemap(jboxtype, T) x) { + put(key, x); + } + public void del($typemap(jboxtype, K) key) { + remove(key); + } + public boolean has_key($typemap(jboxtype, K) key) { + return containsKey(key); + } + %} + } + + *** POTENTIAL INCOMPATIBILITY *** + +2019-02-13: ZackerySpytz + #1469 Add support for C++17 hexadecimal floating literals. + +2019-02-11: wsfulton + [OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work + and most of the test-suite is also working, so it is quite close to being a 'Supported' language. + +2019-02-10: ZackerySpytz + #1464 Add support for C++14 binary integer literals. + +2019-02-10: ZackerySpytz + #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also, add support for + C++17 UTF-8 character literals. + +2019-02-10: wsfulton + [MzScheme] #1437 MzScheme/Racket is now an 'Experimental' language. The examples work + and a large portion of the test-suite is also working. + +2019-02-10: wsfulton + [MzScheme] Destructor wrappers were not being generated. + +2019-02-10: wsfulton + [MzScheme] Static variable wrappers fixed - $argnum was not expanded. + +2019-02-10: sethrj + #1452 Fix %apply for anonymous template instantiations + +2019-02-09: olly + [PHP] Fix access to already released memory during PHP module + shutdown, which often didn't cause visible problems, but could + result in segmentation faults, bus errors, etc. Fixes #1170, + reported by Jitka Plesníková. + +2019-02-09: olly + [PHP] A renamed constructor is now wrapped as a static method in + PHP. + +2019-02-08: olly + [PHP] Don't generate code which references $r when $r hasn't been + defined. This could happen in overloaded methods which returned + void and took at least one const std::string& parameter. + +2019-02-08: olly + [PHP] The generated code is now compatible with PHP 7.3, and the + testsuite now runs cleanly with this version too. + +2019-02-05: wsfulton + #1437 SWIG now classifies the status of target languages into either 'Experimental' or + 'Supported'. This status is provided to indicate the level of maturity to expect when using + a particular target language as not all target languages are fully developed. Details are + in the Introduction.html chapter of the documentation. + +2019-02-04: wsfulton + [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [Allegrocl] #1447 Allegro Common Lisp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [Chicken] #1447 CHICKEN has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [CLISP] #1447 GNU Common Lisp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [S-EXP] #1447 Common Lisp S-Exp has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [UFFI] #1447 Common Lisp UFFI has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [Pike] #1447 Pike has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-04: wsfulton + [Modula3] #1447 Modula3 has been disabled as a target language in SWIG as part of a + clean up to remove target languages that have been neglected/not functional. + +2019-02-02: ahnolds + [Python] Documentation enhancements for Python: + + #728 Fixed the handling of autodoc when using -fastproxy. + + #1367 Added documentation to wrapped member variables using the + property(... doc="...") construct. + + Only show a single documentation entry for functions with default arguments when + using autodoc. + + Fixed a bug where a cached doxygen docstring could be deleted while still in use, + causing swig to segfault. + +2019-01-31: olly + SWIG now requires a target language to be specified instead of + defaulting to wrapping for Tcl. Specifying swig --help without + a target language now just shows the generic help. The -nolang + option has been removed. + +2019-01-28: ZackerySpytz + [OCaml] #1429 Remove support for OCaml versions < 3.12.0. + + *** POTENTIAL INCOMPATIBILITY *** + +2019-01-22: vadz + [Ruby, Octave] #1424 Improve autodoc parameter naming. + +2019-01-22: vadz + [Python] #1271 #1423 Always include default parameter values in autodoc strings. + +2019-01-19: vadz + #1272, #1421 When a function's parameter is a keyword, the name of the paramater is + no longer simply changed to argN, where N is the argument number. Instead the + parameter name is changed to the renaming rules for keywords that normally apply to + symbols such as classes/functions etc. Note that unlike other symbol renaming, + parameter renaming does not issue a warning when the parameter is renamed. This + change only affects languages where the parameter names are actually used, for example, + Java function parameter lists in the proxy class or Python documentation comments. + +2019-01-18: wsfulton + #1420 Fix gdb debugger functions 'swigprint' and 'locswigprint' from swig.gdb to + work with newer versions of gdb-8. Fixes errors when debugging SWIG source with gdb: + + (gdb) swigprint n + Undefined command: "Printf". Try "help". + +2019-01-16: wsfulton + Python static method wrapper changes + + - Static method wrappers were using the 'fastproxy' approach by default. + This is inconsistent with instance method wrappers. The fastproxy approach + is now turned off by default to be consistent with instance methods. + Static method wrappers can now also be controlled using the -fastproxy and + -olddefs options. + + Example: + + struct Klass { + static int statmethod(int a = 2); + }; + + generates by default: + + class Klass(object): + ... + @staticmethod + def statmethod(a=2): + return _example.Klass_statmethod(a) + + instead of the following (which can be restored by using -fastproxy): + + class Klass(object): + ... + statmethod = staticmethod(_example.Klass_statmethod) + + - Modernise wrappers for static methods to use decorator syntax - @staticmethod. + + - Add missing runtime test for static class methods and using the actual class method. + +2019-01-12: ZackerySpytz + [OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using + int64_t instead of int64. + +2019-01-11: ZackerySpytz + [OCaml] #1400 Fix the getters and setters of non-static member variables. + +2019-01-07: wsfulton + #358 Add VOID to windows.i + +2019-01-05: wsfulton + #948 #1019 #1273 Fix for C++11 raw strings where the delimiters were mistakenly left + in the string contents in situations where the string was copied into generated code. + For example, %constant, the "docstring" feature and for C#/Java/D constants turned on + with %javaconst/%csconst/%dmanifestconst. + +2019-01-05: wsfulton + [Ruby] #538. Fix Ruby support for %feature("docstring"). + +2019-01-03: wsfulton + #1202 Fix overloading of non-pointer class types in scripting languages when overloaded + with a pointer and a NULL scripting language equivalent is used, eg None in Python. + + The implementation changes the SWIGTYPE, SWIGTYPE& and SWIGTYPE&& typecheck typemaps to + prevent accepting a conversion to a NULL pointer. + +2019-01-03: ZackerySpytz + [OCaml] #1386 Fix the OCaml examples and test suite for out-of-source builds. + +2019-01-01: wsfulton + [Python] #639 remove duplicate proxy method definitions for global function wrappers. + + Global functions previously generated two definitions, eg: + + def foo(): + return _example.foo() + foo = _example.foo + + The first definition is replaced by the second definition and so the second definition + is the one used when the method is actually called. Now just the first definition is + generated by default and if the -fastproxy command line option is used, just the second + definition is generated. The second definition is faster as it avoids the proxy Python + method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs + command line options will restore the previously generated code as it will generate both + method definitions. + + With this change, the wrappers for global C/C++ functions and C++ class methods now work + in the same way wrt to generating just a proxy method by default and control via + -fastproxy/-olddefs options. + +2018-12-20: hasinoff,wsfulton + [Java] #1334 Set Java thread name to native thread name when using directors. + + Default is to use name "Thread-XXX" and is still works like this by default. However, + adding the following will turn on the thread name setting (works for more recent + versions of Linux and MacOS): + + %begin %{ + #define SWIG_JAVA_USE_THREAD_NAME + %} + +2018-12-20: chlandsi + [Python] #1357. Fix overriding __new__ in Python 3.6. + + Fixes SystemError: Objects/tupleobject.c:81: bad argument to internal function" + +2018-12-16: wsfulton + [Python] #848 #1343 The module import logic has changed to stop obfuscating real ImportError + problems. Only one import of the low-level C/C++ module from the pure Python module is + attempted now. Previously a second import of the low-level C/C++ module was attempted + after an ImportError occurred and was done to support 'split modules'. A 'split module' is + a configuration where the pure Python module is a module within a Python package and the + low-level C/C++ module is a global Python module. Now a 'split module' configuration is + no longer supported by default. This configuration can be supported with a simple + customization, such as: + + %module(package="mypackage", moduleimport="import $module") foo + + or if using -builtin: + + %module(package="mypackage", moduleimport="from $module import *") foo + + instead of + + %module(package="mypackage") foo + + See the updated Python chapter titled "Location of modules" in the documentation. + +2018-12-11: tlby + [Perl] #1374 repair EXTEND() handling in typemaps + +2018-12-06: vadz + #1359 #1364 Add missing nested class destructor wrapper when the nested class is + inside a template. Removes associated bogus 'Illegal destructor name' warning. Only + occurred when the nested class' destructor is explicitly specified. + +2018-12-04: adr26 + [Python] #1368 #1369 Access Violation in tp_print caused by mismatched Python/extension + CRT usage + + Remove all use of tp_print, as this API uses a FILE*, which can be + mismatched when modules are built with different C libraries from + the main python executable. + + This change also brings consistent output between Python 2 and 3 for the 'cvar' SWIG + object (that contains the global variables) and SWIG packed objects (such as callback + constants). + +2018-12-04: wsfulton + [Python] #1282 Fix running 'python -m' when using 'swig -builtin' + + Similar to the earlier PEP 366 conforming fix for non-builtin. + +2018-11-29: adr26 + [Python] #1360 Leak of SWIG var link object + + Fix reference counting on _SWIG_globals to allow var link to be freed on module unload. + +2018-11-28: wsfulton + [Python] When using -builtin, the two step C-extension module import is now + one step and the wrapped API is only available once and not in an underlying + module attribute like it is without -builtin. To understand this, consider a + module named 'example' (using: %module example). The C-extension is compiled into + a Python module called '_example' and a pure Python module provides the actual + API from the module called 'example'. It was previously possible to additionally + access the API from the module attribute 'example._example'. The latter was an + implementation detail and is no longer available. It shouldn't have been used, but + if necessary it can be resurrected using the moduleimport attribute described in the + Python chapter of the documentation. If both modules are provided in a Python + package, try: + + %module(moduleimport="from . import _example\nfrom ._example import *") example + or more generically: + %module(moduleimport="from . import $module\nfrom .$module import *") example + + and if both are provided as global modules, try: + + %module(moduleimport="import _example\nfrom _example import *") example + or more generically: + %module(moduleimport="import $module\nfrom $module import *") example + + The module import code shown will appear in the example.py file. + +2018-11-24: vadz + #1358 Fix handling of abstract base classes nested inside templates + + Correct detecting of whether a derived class method overrides a pure virtual + base class method when both classes are nested inside a template class: this + notably didn't work correctly for methods taking parameters of the base class + type. + +2018-11-22: rupertnash + [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) + + Previously any SWIG generated modules in a package would fail with an ImportError + when using 'python -m' for example 'python -m mypkg.mymodule'. + + This fix also allows the SWIG generated module to be placed into a directory and + then renamed __init__.py to convert the module into a package again. This ability + stopped working in swig-3.0.9. However, only Python 2.7 or 3.3 and later work. If + Python 3.2 support is needed, use moduleimport in %module to customise the import + code. + +2018-11-13: wsfulton + #1340 Remove -cppcast and -nocppcast command line options (this was an option + available to the scripting language targets). + + The -cppcast option is still turned on by default. The -nocppcast option + to turn off the use of c++ casts (const_cast, static_cast etc) has been + removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts + instead of C++ casts for C++ wrappers. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-11-13: wsfulton + [Python] #1340 Remove -outputtuple and -nooutputtuple command line options. + + Both the command line and %module options of the same name have been + removed. These were undocumented. The -outputtuple option returned a + Python tuple instead of a list, mostly typically in the OUTPUT + typemap implementations. + + It unclear why a tuple instead of a list return type is needed and + hence this option has been removed as part of the simplification of + the SWIG Python command line options for SWIG 4. + +2018-11-13: wsfulton + [Python] #1340 Remove -noproxyimport command line option. + + This option turned off the insertion of Python import statements + derived from a %import directive. For example given: + + %module module_b + %import "module_a.i" + + then module_b.py will contain: + + import module_a + + *** POTENTIAL INCOMPATIBILITY *** + +2018-10-29: AlexanderGabriel + [PHP] The following PHP7 reserved keywords are now only renamed by + SWIG when used as function names in the API being wrapper: + __halt_compiler array die echo empty eval exit include include_once + isset list print require require_once return unset + +2018-10-22: olly,wsfulton + [Python] #1261 #1340 Turn on many optimisation options by default and rationalise the + number of command line options. + + There were an unnecessary number of command line options and many of these have now + been removed in a drive for simplification. Some were needed to support older versions + of Python (2.6 and earlier). + + Many of the options could be turned on individually and when using -O. Previously -O + resulted in turning on a set of options: + + -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel + -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone + + Now -O results in turning on this reduced set: + + -fastdispatch -fastproxy -fvirtual + + The following options are now on by default, a deprecated warning is displayed if they + are used: + -fastinit Class initialisation code done in C/C++ rather than in Python code. + -fastquery Python dictionary used for lookup of types. + -fastunpack Faster unpacking of function arguments in C/C++ wrappers. + -modern Use Python 2.3 features such as object and property. + -modernargs Use Python 2.3 C APIs for unpacking arguments in tuples. + -noproxydel Stop generating a proxy __del__ method for backwards compatiblity. + -safecstrings No discernable difference + + The following options have been removed altogether: + -aliasobj0 + -buildnone + -classptr + -new_repr + -newrepr + -noaliasobj0 + -nobuildnone + -nocastmode + -nodirvtable + -noextranative + -nofastinit + -nofastproxy + -nofastquery + -nomodern + -nomodernargs + -nooutputtuple + -nosafecstrings + -old_repr + -oldrepr + -proxydel + + -new_vwm is no longer supported. Use the -newvwm alias instead. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-10-22: olly + [Python] #1261 Remove command line option no longer needed as Python 2.3 and earlier + are no longer supported: + + -classic + +2018-10-09: wsfulton + [D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl] + Allow wrapping of std::map using non-default comparison function. + +2018-10-09: vadz + [Java] #1274 Allow wrapping of std::map using non-default comparison function. + +2018-10-04: wsfulton + [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. + Problem occurred when there is just one (defaulted) parameter in the parameter list. + +2018-09-24: wsfulton + [Python] #1319 C++11 hash tables implementation is finished now (including for -builtin): + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + +2018-09-21: wsfulton + [Python] Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or + std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL + container's find method. Without it, Python will do its own slower sequence search. + +2018-09-19: wsfulton + [Python] Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack. + +2018-09-02: andreas.gaeer,tkrasnukha + [Python] #1321 Fix assert in PyTuple_GET_SIZE in debug interpreter builds of python-3.7 + when calling tp_new. + +2018-09-01: ChristopherHogan + [Guile] #1288 Fix garbage collection for guile >= 2.0.12. + +2018-08-31: wsfulton + [Python] #1319 C++11 hash tables support: + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + is now compiling and working (sorting using -builtin not fully functional yet though). + +2018-08-20: wkalinin + #1305 Fix nested structure symbol tables in C mode to fix member name conflicts + in different structs with the same nested struct member name. + +2018-08-18: wsfulton + [Python] #688 Fix makefile recursion when running python test-suite. + +2018-08-18: wsfulton + [Python] #1310 Re-implement Python -fastproxy option. + + The previous implementation failed with Python 3 and abstract base clases. + The new implementation replaces the Python 2 implementation using + new.instancemethod with the C API PyMethod_New to match the equivalent Python 3 + implementation which uses PyInstanceMethod_New. + + The new approach runs slightly faster. See #1310. + +2018-08-12: gmazzamuto + [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. + +2018-08-12: brianhatwood,wsfulton + [Java] #1303 #1304 Fix crash in directors when using OUTPUT and INOUT typemaps in typemaps.i and + passing NULL pointers in C++ to director method overloaded and implemented in Java. + +2018-08-10: wsfulton + [Python] #1293 Improve TypeError message inconsistencies between default and fastdispatch + mode when handling overloaded C++ functions. Previously the error message did not always + display the possible C/C++ prototypes in fastdispatch mode. + +2018-08-02: furylynx,jacobwgillespie,p2k + [Javascript] #1290, #968. Add support for NodeJS versions 2-10. + +2018-07-31: wsfulton + [Python] #1293 Overloaded C++ function wrappers now raise a TypeError instead + of NotImplementedError when the types passed are incorrect. This change means + there is now consistency with non-overloaded function wrappers which have always + raised TypeError when the incorrect types are passed. The error message remains + the same and is for example now: + + TypeError: Wrong number or type of arguments for overloaded function 'f'. + Possible C/C++ prototypes are: + f(int) + f(char const *) + + instead of: + + NotImplementedError: Wrong number or type of arguments for overloaded function 'f'. + Possible C/C++ prototypes are: + f(int) + f(char const *) + + *** POTENTIAL INCOMPATIBILITY *** + +2018-06-23: wsfulton + [Python] #718 Fix pythonnondynamic feature for modern classes + + Fixes nondynamic mode when an instance variable is set with the same + name as a class variable in a class derived from a SWIG proxy class. + This corner case set an instance variable instead of raising an AttributeError. + + Also fix %pythonnondynamic in Python 3 with -modern. The metaclass + containing the implementation was previously not being applied in Python 3. + +2018-07-17: petrmitrichev,wsfulton + [Python] #1275 #1279 Initialize function-local statics (singletons) that call Python + code during Python module initialization in order to avoid deadlocks with subsequent + multi-threaded usage. + +2018-06-15: wsfulton + [Python] Fix seg fault using Python 2 when passing a Python string, containing + invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: + + %include + void instring(const std::wstring& s); + + instring(b"h\xe9llooo") # Python + +2018-06-15: wsfulton + [Python] Python 3.7 support: Replace use of deprecated PyUnicode_GetSize with + PyUnicode_GetLength to remove deprecated warnings compiling the C/C++ wrappers. + +2018-06-12: wsfulton + [Python] Python 3.7 support: The %pythonabc feature in pyabc.i now uses base classes + collections.abc.MutableSequence + collections.abc.MutableMapping + collections.abc.MutableSet + instead of + collections.MutableSequence + collections.MutableMapping + collections.MutableSet + as the latter are deprecated in Python 3.7 and are due to be removed in Python 3.8. + The classes in collections.abc.* are available from Python 3.3 onwards. If you + require support for Python 3.2, then copy the pyabc.i file and modify by removing + the few instances of the .abc sub-module. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-06-12: olly,wsfulton + [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-06-11: olly + [Python] Fix new GCC8 warnings in generated code by avoiding casts + between incompatible function types where possible, and by + suppressing the warning when it's due to the design of Python's C + API. Fixes #1259. + +2018-06-08: philippkraft + [Python] Stop exposing _swigregister to Python. It's not + useful for user Python code to call this, and it just clutters the + API unnecessarily. Fixes #1225. + +2018-06-07: cmfoil, kabbi, Jamie Kirkpatrick, markok314, vadz, wsfulton, Yann Diorcet + #170 Doxygen documentation support added. This allows translation of Doxygen comments + into JavaDoc and PyDoc documentation. It is enabled via the -doxygen command line + option. See the Doxygen.html chapter in the documentation for further information. + +2018-06-07: olly + [PHP] We've finally removed support for %pragma(php4) which was + deprecated back in 2008. Use %pragma(php) instead, which has been + supported since at least 2005. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-06-07: olly + [PHP5] Support for PHP5 has been removed. PHP5 is no longer + actively supported by the PHP developers and security support for + it ends completely at the end of 2018, so it doesn't make sense + to include support for it in the upcoming SWIG 4.0.0 release. + + *** POTENTIAL INCOMPATIBILITY *** + +2018-06-06: olly + [Lua] Improve configure probes for Lua headers and libs used in testsuite. + +2018-05-15: kwwette + [Octave] add support for version 4.4 + - Should not introduce any user-visible incompatibilities + +2018-05-15: wsfulton + [C#, D, Java] Fix lookup of csconstruct, dconstruct and javaconstruct typemaps. + The C++ namespace was previously ignored when looking up the typemap. + +2018-05-15: wsfulton + [Javascript] Fix generated C++ code when using %nspace on namespaces that are more + than two levels deep. + +2018-05-14: wsfulton + Issue #1251 Add support for C++17 nested namespace definitions, + for example: + namespace A::B { ... } + +2018-05-11: wsfulton + [C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers, + %javamethodmodifiers can modify the method modifiers for the destructor wrappers + in the proxy class: dispose, Dispose, delete. With this feature, it is now possible + to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers + can be removed using: + + %typemap(csclassmodifiers) X "public sealed class" + %csmethodmodifiers X::~X "public /*virtual*/"; + +2018-04-18: olly + [Python] Suppress new pycodestyle warning: + E252 missing whitespace around parameter equals + +2018-04-07: goatshriek + [Ruby] #1213 Fix ruby %alias directive for global C/C++ functions. + +2018-04-03: olly + [Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC + -Wconversion-null warning (on by default with recent GCC). + +2018-03-09: wsfulton + [Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression + for non-director classes. Restores a dynamic_cast which was previously removed. + +2018-03-07: llongi + Github PR #1166 - Fix preprocessor handling of macros with commas + in a // comment. + +2018-02-18: JPEWdev + Patch #1164 - Add support for a command-line options file, also sometimes + called a response file. This is useful if the command-line options exceed + the system command-line length limit. To use, put the command-line options + into a file, then provide the file name prefixed with @, for example using + a file called args.txt: + + swig @args.txt + +2018-02-11: wsfulton + [Javascript] #1187 Fix compilation error wrapping std::complex via + std_complex.i. + +2018-01-30: smarchetto + [Scilab] add type name argument in SWIG_ptr() function to cast from pointer address to typed pointers + +2018-01-16: wsfulton + Expressions following a preprocessor directive must now be separated by whitespace + or non-numeric characters. This syntax change makes the SWIG preprocessor work like + the C preprocessor in this area. + + For example, the following code used be accepted as valid syntax: + #if1 + #define ABC 123 + #endif + + Now you get an error: + example.h:1: Error: Unknown SWIG preprocessor directive: if1 (if this is a block of + target language code, delimit it with %{ and %}) + example.h:3: Error: Extraneous #endif. + + The following is the correct syntax: + #if 1 + #define ABC 123 + #endif + + The following of course also works: + #if(1) + #define ABC 123 + #endif + + *** POTENTIAL INCOMPATIBILITY *** + +2018-01-15: wsfulton + Fix issue #1183. Floating point exception evaluating preprocessor expressions + resulting in division by zero. + +2018-01-14: wsfulton + Fix issue #1172. Seg fault parsing invalid exponents in the preprocessor. + +2018-01-12: Liryna + [C#] Patch #1128. Add ToArray function to std::vector wrappers. + +2018-01-12: wsfulton + [Java] Fix issue #1156. Add missing throws clause for interfaces when using the + %interface family of macros. + +2018-01-05: wsfulton + Fix default arguments using expressions containing -> syntax error. Problem reported on + swig-user mailing list. + +2017-12-30: wsfulton + [Python] Replace pep8 with pycodestyle for checking the Python code style when + running Python tests. + +2017-12-30: davedissian + Fixed a symbol lookup issue when encountering a typedef of a symbol from the tag + namespace to the global namespace when the names are identical, such as 'typedef + struct Foo Foo;'. + +2017-12-13: wsfulton + [Perl] add missing support for directorfree typemaps. + +2017-12-13: wsfulton + Issue #1167 Fix directorout typemaps which were causing undefined behaviour when + returning pointers by reference. + +2017-12-08: olly + [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this + should make the generated code work with PHP 7.2.0. + +2017-12-04: wsfulton + [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a + seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing + u"\udcff" to the C layer (Python 3). + +2017-11-24: joequant + [R] Fix #1124 and return R_NilValue for null pointers + +2017-11-29: wsfulton + [Java] director exception handling improvements. + + When a director method throws an exception and it is caught by DirectorException + and passed back to Java using Swig::DirectorException::throwException, the Java + stack trace now contains the original source line that threw the exception. + + Deprecate Swig::DirectorException::raiseJavaException, please replace usage with + Swig::DirectorException::throwException. + + *** POTENTIAL INCOMPATIBILITY *** + +2017-10-26: wsfulton + Add support for C++11 ref-qualifiers when using directors. + +2017-10-26: wsfulton + Fix generated code when using directors and methods returning const ref pointers. + +2017-10-26: wsfulton + [C#, D, Java, Octave, R, Scilab] Port director typemaps to these additional languages. + Issue #700. + +2017-10-26: radarsat1 + [Ruby Python] Patch #1029 - Correct handling of null using directors and shared_ptr. + +2017-10-10: joequant + [R] pass enum expressions to R. This will generate + incorrect files when there is an arithmetic expression + in the enum, but this is better than silently generating + incorrect code + +2017-10-09: olly + [PHP] Fix incorrect wrapper code generated when there's a + combination of overloading, parameters with a default value + and %newobject. Fixes https://sourceforge.net/p/swig/bugs/1350/ + +2017-10-09: olly + Remove GCJ support. It isn't in a good state and doesn't seem to + be used, and GCC7 dropped GCJ. Closes + https://sourceforge.net/p/swig/bugs/823/ + +2017-10-07: olly + Fix preprocessor handling of empty macro arguments to match that of + C/C++ compilers. Fixes issue #1111 and + https://sourceforge.net/p/swig/bugs/826/ + +2017-10-06: wsfulton + [Python] Issue #1108. Fix platform inconsistency in Python default argument handling. + 32 bit and 64 bit compiled versions of SWIG generated different Python files + when default arguments were outside the range of 32 bit signed integers. + The default arguments specified in Python are now only those that are in the + range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code. + +2017-10-02: wsfulton + [C#] Fix std::complex types passed by value. + +2017-10-02: wsfulton + [Javascript, Python, Ruby] Issue #732 - Missing type information for std::complex + in std_complex.i meant that previously std::complex always had to be fully qualified + in order to be wrapped with the appropriate typemaps. + +2017-10-01: joequant + allow R package names with docs + allowing multiple get accessors in R + fix smart-pointer and NAMESPACE support + constructors now returning smart pointers (if class + declared as such) + smart-pointer classes deriving from parent smart-pointers + +2017-09-29: wsfulton + Issue #1100 - Allow an instantiated template to have the same name in the target + language as the C++ template name, for example, this is now possible: + + template struct X { ... }; + %template(X) X; + +2017-09-23: wsfulton + Issue #1098. Fix overloading of shared_ptr with underlying pointer types, eg: + + void m(std::shared_ptr p); + void m(T &p); + void m(T *p); + + Only the first method is wrapped and the others are ignored/shadowed. + The implementation is done via a new attribute in the 'typecheck' typemap called + 'equivalent'. If specified, it must contain the equivalent pointer type for overloading + and can only be used for the special SWIG_TYPECHECK_POINTER precedence level. + The shared_ptr 'typecheck' typemaps have been modified accordingly. + Here is a simplified version: + + %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="T *") + T, + T CONST &, + T CONST *, + T *CONST&, + std::shared_ptr< T >, + std::shared_ptr< T > &, + std::shared_ptr< T > *, + std::shared_ptr< T > *& + { ... } + + Overloading with any of these types will result in SWIG ignoring all but the first + overloaded method by default. Without the 'equivalent' attribute, wrapping the overloaded + methods resulted in types being shadowed (scripting languages) or code that did not + compile (statically typed languages). + +2017-09-19: futatuki + [Python] #1003 Add --with-2to3=/path/to/2to3 option to configure. + +2017-09-18: wsfulton + Fix type promotion wrapping constant expressions of the form: + # define EXPR_MIXED1 (0x80 + 11.1) - 1 + This was previously an integral type instead of a floating point type. + +2017-09-17: wsfulton + Fix generated code for constant expressions containing wchar_t L literals such as: + # define __WCHAR_MAX (0x7fffffff + L'\0') + # define __WCHAR_MIN (-__WCHAR_MAX - 1) + +2017-09-10: mlamarre + [Python] Patch #1083. Define_DEBUG to 1 to do exactly like Visual Studio + /LDd, /MDd or /MTd compiler options. + +2017-08-25: wsfulton + Issue #1059. Add support for C++11 ref-qualifiers on non-static member functions. + Members with lvalue ref-qualifiers such as: + + struct RQ { + void m1(int x) &; + void m2(int x) const &; + }; + + are wrapped like any other member function. Member functions with rvalue ref-qualifiers + are ignored by default, such as: + + struct RQ { + void m3(int x) &&; + void m4(int x) const &&; + }; + + example.i:7: Warning 405: Method with rvalue ref-qualifier m3(int) && ignored. + example.i:8: Warning 405: Method with rvalue ref-qualifier m4(int) const && ignored. + + These can be unignored and exposed to the target language, see further documentation in + CPlusPlus11.html. + +2017-08-16: wsfulton + Fix #1063. Add using declarations to templates into typedef table. + + Using declarations to templates were missing in SWIG's internal typedef tables. + This led to a few problems, such as, templates that did not instantiate and generated + C++ code that did not compile as SWIG did not know what scope the template was + in. This happened mostly when a using declaration was used on a template type in a + completely unrelated namespace. + +2017-08-16: wsfulton + Fix type lookup in the presence of using directives and using declarations. + + Fix some cases of type lookup failure via a combination of both using directives and + using declarations resulting in C++ code that did not compile as the generated type was + not fully qualified for use in the global namespace. Example below: + + namespace Space5 { + namespace SubSpace5 { + namespace SubSubSpace5 { + struct F {}; + } + } + using namespace SubSpace5; + using SubSubSpace5::F; + void func(SubSubSpace5::F f); + } + +2017-08-16: wsfulton + Issue #1051. %template scope enforcement and class definition fixes. + + The scoping rules around %template have been specified and enforced. + The %template directive for a class template is the equivalent to an + explicit instantiation of a C++ class template. The scope for a valid + %template instantiation is now the same as the scope required for a + valid explicit instantiation of a C++ template. A definition of the + template for the explicit instantiation must be in scope where the + instantiation is declared and must not be enclosed within a different + namespace. + + For example, a few %template and C++ explicit instantiations of std::vector + are shown below: + + // valid + namespace std { + %template(vin) vector; + template class vector; + } + + // valid + using namespace std; + %template(vin) vector; + template class vector; + + // valid + using std::vector; + %template(vin) vector; + template class vector; + + // ill-formed + namespace unrelated { + using std::vector; + %template(vin) vector; + template class vector; + } + + // ill-formed + namespace unrelated { + using namespace std; + %template(vin) vector; + template class vector; + } + + // ill-formed + namespace unrelated { + namespace std { + %template(vin) vector; + template class vector; + } + } + + // ill-formed + namespace unrelated { + %template(vin) std::vector; + template class std::vector; + } + + When the scope is incorrect, an error now occurs such as: + + cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and + was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'. + + Previously SWIG accepted the ill-formed examples above but this led to + numerous subtle template scope problems especially in the presence of + using declarations and using directives as well as with %feature and %typemap. + + Actually, a valid instantiation is one which conforms to the C++03 + standard as C++11 made a change to disallow using declarations and + using directives to find a template. + + // valid C++03, ill-formed C++11 + using std::vector; + template class vector; + + Similar fixes for defining classes using forward class references have + also been put in place. For example: + + namespace Space1 { + struct A; + } + namespace Space2 { + struct Space1::A { + void x(); + } + } + + will now error out with: + + cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and + was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'. + + Previously some symbols would have been instantiated in the wrong scope and led + to lots of scope problems involving SWIG typemaps, features, renames etc. + You will need to correct the scope used in other SWIG directives which do not + support 'using declarations' and 'using directives'. For example, if you previously had: + + %rename(Zap) vector::clear; + using namespace std; + %template(VectorInt) vector; + + Prior versions of SWIG incorrectly instantiated vector in the global namespace + and so the %rename matched. Now the template is instantiated in the correct namespace, + so is fully qualified as std::vector. The other SWIG directives need correcting as + they do not follow 'using declarations' and 'using directives'. Change it to: + + %rename(Zap) std::vector::clear; + using namespace std; + %template(vin) vector; + + + *** POTENTIAL INCOMPATIBILITY *** + +2017-08-16: wsfulton + Fix scope lookup for template parameters containing unary scope operators. + + Fixes cases like: + + namespace Alloc { + template struct Rebind { + typedef int Integer; + }; + } + %template(RebindBucket) Alloc::Rebind< Bucket >; + OR + %template(RebindBucket) Alloc::Rebind< ::Bucket >; + + Alloc::Rebind< Bucket >::Integer Bucket1(); + Alloc::Rebind< ::Bucket >::Integer Bucket2(); + Alloc::Rebind<::template TemplateBucket>::Integer Bucket3(); + +2017-08-16: wsfulton + For templates only, the template parameters are fully resolved when + handling typemaps. Without this, it is too hard to have decent rules + to apply typemaps when parameter types are typedef'd and template + parameters have default values. + + Fixes %clear for typedefs in templates, eg: + + %typemap("in") XXX::Long "..." + template typename struct XXX { + typedef long Long; + }; + %clear XXX::Long; + + as the typemap was previously incorrectly stored as a typemap for long + instead of XXX::Long. + +2017-08-05: olly + [C++11] Allow static_assert at the top level (and disallow it right + after template). Fixes issue 1031 reported by Artem V L. + +2017-08-02: wsfulton + Fix incorrectly shown warning when an empty template instantiation was used on a + class used as a base class and that base class was explicitly ignored with %ignore. + Example of the warning which will no longer appear: + + Warning 401: Base class 'Functor< int,int >' has no name as it is an empty + template instantiated with '%template()'. Ignored. + +2017-07-17: fflexo + [Java] #674 Add std_list.i to add support for std::list containers. The Java proxy + extends java.util.AbstractSequentialList and makes the C++ std::list container look + and feel much like a java.util.LinkedList from Java. + +2017-07-07: wsfulton + [Python] Fix display of documented template types when using the autodoc + feature. For example when wrapping: + + %feature("autodoc"); + template struct T {}; + %template(TInteger) T; + + the generated documentation contains: + """Proxy of C++ T< int > class.""" + instead of: + """Proxy of C++ T<(int)> class.""" + and + """__init__(TInteger self) -> TInteger""" + instead of + """__init__(T<(int)> self) -> TInteger""" + +2017-06-27: nihaln + [PHP] Update the OUTPUT Typemap to add return statement to the + PHP Wrapper. + +2017-06-27: nihaln + [PHP] Update the enum and value examples to use the OO wrappers + rather than the flat functions produced with -noproxy. There's + not been a good reason to use -noproxy for since PHP5 OO wrapping + was fixed back in 2005. + +2017-06-23: m7thon + [Python] fix and improve default argument handling: + + 1. Fix negative octals. Currently not handled correctly by `-py3` + (unusual case, but incorrect). + 2. Fix arguments of type "octal + something" (e.g. `0640 | 04`). + Currently drops everything after the first octal. Nasty! + 3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always + "False" (unusual case, but incorrect). + 4. Remove special handling of "TRUE" and "FALSE" from + `convertValue` since there's no reason these have to match + "true" and "false". + 5. Remove the Python 2 vs. Python 3 distinction based on the + `-py3` flag. Now the same python code is produced for default + arguments for Python 2 and Python 3. For this, octal default + arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This + is required, as Python 2 and Python 3 have incompatible syntax + for octal literals. + + Fixes #707 + +2017-06-21: futatuki + #1004 - Fix ccache-swig executable name to respect configure's --program-prefix and + --program-suffix values if used. + +2017-06-21: tamuratak + [Ruby] #911 - Add std::wstring support. + +2017-06-19: wsfulton + [Python] Fix handling of rich comparisons when wrapping overloaded operators: + + operator< operator<= operator> operator>= operator== operator!= + + Previously a TypeError was always thrown if the type was not correct. NotImplemented + is now returned from these wrapped functions if the type being compared with is + not correct. The subsequent behaviour varies between different versions of Python + and the comparison function being used, but is now consistent with normal Python + behaviour. For example, for the first 4 operator overloads above, a TypeError + 'unorderable types' is thrown in Python 3, but Python 2 will return True or False. + NotImplemented should be returned when the comparison cannot be done, see PEP 207 and + https://docs.python.org/3/library/constants.html#NotImplemented + + Note that the bug was only present when overloaded operators did not also have a + function overload. + + Fixes SF bug #1208 (3441262) and SF patch #303. + + *** POTENTIAL INCOMPATIBILITY *** + +2017-06-17: fabrice102 + [Go] Fix Go callback example. Fixes github #600, #955, #1000. + +2017-06-16: wsfulton + Make sure warning and error messages are not split up by other processes writing to + stdout at the same time. + +2017-06-16: wsfulton + [R] Fix wrapping function pointers containing rvalue and lvalue reference parameters. + +2017-06-13: olly + [Perl] Fix testsuite to work without . in @INC - it was removed in + Perl 5.26 for security reasons, and has also been removed from + older versions in some distros. Fixes #997 reported by lfam. + +2017-06-03: wsfulton + Fix %import on a file containing a file scope %fragment forced inclusion to not + generate the fragment contents as %import should not result in code being generated. + The behaviour is now the same as importing code insertion blocks. + Wrapping FileC.i in the following example will result in no generated code, whereas + previously "#include " was generated: + + // FileA.i + %fragment("", "header") %{ + #include + %} + + %{ + #include + %} + %fragment(""); + + // FileC.i + %import "FileA.i" + + *** POTENTIAL INCOMPATIBILITY *** + +2017-05-26: Volker Diels-Grabsch, vadz + [Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for + std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way. + Note that boxed types are now used in the Java layer when wrapping vector of C primitive + types, for example. This may introduce some subtle incompatibilities due to some + differences in how Java converts boxed types and unboxed types. For example, + + int i=0; + double d1 = i; // ok + Double d2 = i; // error: incompatible types: int cannot be converted to Double + + This can be a problem when calling the add and set functions. A suggested backwards + compatible workaround is to use something like (shown for std::vector: + + #if defined(SWIGJAVA) + // Add in old api that uses non-boxed types + %extend std::vector { + %proxycode %{ + public void add(double x) { + add(Double.valueOf(x)); + } + public void set(int i, double val) { + set(i, Double.valueOf(val)); + } + %} + } + #endif + + %include "std_vector.i" + %template(VectorDouble) std::vector; + + *** POTENTIAL INCOMPATIBILITY *** + +2017-05-30: davidcl + [Scilab] #994 Undefined symbol error when loading in Scilab 6 + +2017-05-25: asibross + [Java] #370 #417 Missing smart pointer handling in Java director extra methods + swigReleaseOwnership() and swigTakeOwnership(). + +2017-05-23: wsfulton + [Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation + error. + + For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying + the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other + methods for controlling memory ownership. + +2017-05-21: Sghirate + [Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable + non-RTTI compilation. + +2017-05-21: wsfulton + [Python] #993 Fix handling of default -ve unsigned values, such as: + void f(unsigned = -1U); + +2017-05-20: jschueller + [Python] #991 Fix E731 PEP8 warning: do not assign a lambda expression + +2017-05-16: nihal95 + [PHP] Add %pragma version directive to allow the version of the + extension to be set. Patch #970, fixes #360. + +2017-05-13: yag00 + Patch #975 - Add support for noexcept on director methods. + +2017-04-27: redbrain + Issue #974, Patch #976 - Fix preprocessor handling of macros with commas in a comment. + +2017-04-25: jleveque + [Lua] #959 - Fix Visual Studio C4244 conversion warnings in Lua wrappers. + +2017-04-21: tamuratak + [Ruby] #964 - Add shared_ptr director typemaps. + +2017-04-20: wsfulton + [Ruby] #586, #935 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj. + +2017-04-20: tamuratak + [Ruby] #930, #937 - Fix containers of std::shared_ptr. + Upcasting, const types (eg vector>) and NULL/nullptr support added. + +2017-04-12: smarchetto + [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation + With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) + +2017-03-24: tamuratak + [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks + on VALUE obj. + +2017-03-17: vadz + [C#] #947 Add support for std::complex + +2017-03-17: wsfulton + [Go] Fix handling of typedef'd function pointers and typedef'd member function pointers + such as: + + typedef int (*FnPtr_td)(int, int); + int do_op(int x, int y, FnPtr_td op); + +2017-03-16: wsfulton + Add support for member const function pointers such as: + + int fn(short (Funcs::* parm)(bool)) const; + + Also fix parsing of references/pointers and qualifiers to member + pointers such as: + + int fn(short (Funcs::* const parm)(bool)); + int fn(short (Funcs::* & parm)(bool)); + +2017-03-10: wsfulton + Extend C++11 alternate function syntax parsing to support const and noexcept, such as: + + auto sum1(int x, int y) const -> int { return x + y; } + auto sum2(int x, int y) noexcept -> int { return x + y; } + +2017-02-29: tamuratak + [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing + for std::list, std::multiset, std::unordered_multiset and std::unordered_map. + +2017-02-27: assambar + [C++11] Extend parser to support throw specifier in combination + with override and/or final. + +2017-02-10: tamuratak + [Ruby] #883 - Add support for C++11 hash tables: + std::unordered_map + std::unordered_set + std::unordered_multimap + std::unordered_multiset + +2017-02-08: jcsharp + [C#] #887 Improve std::vector wrapper constructors - + Replace constructor taking ICollection with IEnumerable and also add IEnumerable + constructor to avoid the boxing and unboxing overhead of the original constructor, + when the type parameter is a value type. + Version 3.0.12 (27 Jan 2017) ============================ diff --git a/CHANGES.current b/CHANGES.current index 6ead3a621..06373dbea 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,1537 +4,6 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.0 (27 Apr 2019) +Version 4.0.1 (in progress) =========================== -2019-04-24: vadz - #1517 Fix crash if "@return" Doxygen tag was used on a node without any return type. - -2019-04-24: vadz - #1515 Fix parsing of enums with trailing comma when using -doxygen. - -2019-04-19: ianlancetaylor - [Go] #1055 When generating Go code, make -cgo the default. Add new -no-cgo option - to disable the default. - -2019-04-19: pbecherer - [Tcl] #1508 Fix Visual Studio 2015 and later compilation errors due to snprintf macro - definition. - -2019-04-09: wsfulton - [C#] Fix FxCop warning CA2002 in SWIGPendingException - a lock on a reference of - type 'Type'. - -2019-03-30: wsfulton - [Java, D] Add the parameters typemap attribute to the javadestruct, - javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced - flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided - the contents are generated as the delete/dispose method's parameters declaration. - -2019-03-30: wsfulton - [C#] #421 Fix FxCop warning CA1063 by implementing the recommended Dispose methods for - the IDisposable interface. Previously just the Dispose() method was generated. - Now the Dispose() and Dispose(bool disposing) methods are generated. - Changes are required if custom "csfinalize", "csdestruct" or "csdestruct_derived" - typemaps are being used. Details in #421 on Github. SWIG will error out if one of - the "csfinalize, "csdestruct" or "csdestruct_derived" typemaps are found. Example - error message: - - foo.h:60: Error: A deprecated csfinalize typemap was found for Foo, please remove - it and replace all csdestruct, csdestruct_derived and csfinalize typemaps by the - csdispose, csdispose_derived, csdisposing and csdisposing_derived typemaps. - - *** POTENTIAL INCOMPATIBILITY *** - -2019-03-25: Liryna - [C#] #1143 Add std_list.i for std::list support. - The C# std::list wrappers are made to look and feel like a C# - System.Collections.Generic.LinkedList<> collection. - The IEnumerable<> interface is implemented in the proxy class. - The ICollection<> interface can also be implemented to provide enhanced functionality - whenever a C++ operator== is available. This is the case for when T is a - primitive type or a pointer. If T does define an operator==, then use the - SWIG_STD_LIST_ENHANCED macro to obtain this enhanced functionality, for example: - - SWIG_STD_LIST_ENHANCED(SomeNamespace::Klass) - %template(ListKlass) std::list; - -2019-03-18: richardbeare - [R] #1328 Non-trivial enums are working now. The enum values are now obtained from - the C/C++ layer. const reference enums and C++11 enum classes are also now working. - -2019-03-14: mochizk - [Javascript] #1500 Fix compilation errors due to deprecating V8 API in Node.js. - New V8 API is used if node.js >= v10.12, or if V8 >= v7.0. - -2019-03-12: vadz - [C#] #1495 Add std_set.i for std::set support. - -2019-03-11: dirteat,opoplawski - [Octave] Fix compilation errors in Octave 5.1. - - error: format not a string literal and no format arguments [-Werror=format-security] - -2019-02-28: wsfulton - [Java] std::vector improvements for types that do not have a default constructor. - - The std::vector wrappers have been changed to work by default for elements that are - not default insertable, i.e. have no default constructor. This has been achieved by - not wrapping: - - vector(size_type n); - - Previously the above had to be ignored via %ignore. - - If the above constructor is still required it can be added back in again via %extend: - - %extend std::vector { - vector(size_type count) { return new std::vector< T >(count); } - } - - Alternatively, the following wrapped constructor could be used as it provides near-enough - equivalent functionality: - - vector(jint count, const value_type& value); - - *** POTENTIAL INCOMPATIBILITY *** - -2019-02-25: wsfulton - [Python] Fix compile errors wrapping overloaded functions/constructors where a vararg - function is declared after a non-vararg function. - -2019-02-23: zphensley42 - Use fully qualified name 'java.lang.Object' instead of 'Object' in generated code to - avoid clashes with wrapped C++ classes called 'Object'. - -2019-02-23: gtbX - [Java] #1035 Add (const char *STRING, size_t LENGTH) typemaps in addition to the non-const - typemaps (char *STRING, size_t LENGTH) which does not attempt to write back to the const - string. - -2019-02-22: tamuratak - [Ruby] #984 Add support for RTypedData introduced in Ruby 1.9.3. - -2019-02-22: ZackerySpytz - #1483 Fix compilation failures when a director class has final methods. - -2019-02-21: wsfulton - [Java] #1240 Suppress Java 9 deprecation warnings on finalize method. - -2019-02-21: ZackerySpytz - #1480 Fix some rejections of valid floating-point literals. - -2019-02-19: wsfulton - #1475 Fix regression parsing gcc preprocessor linemarkers in the form: - - # linenum filename flags - -2019-02-18: jakecobb - [Python] #945 #1234 Elements in std::vector memory access fix. - - Accessing an element in a std::vector obtains a reference to the element via an - iterator pointing to the element in the container. If the vector is garbage collected, - the SWIG wrapper containing the pointer to the element becomes invalid. The fix is - to obtain a back-reference to the container by the wrapper to the element in the Python - layer to prevent the garbage collector from destroying the underlying container. - -2019-02-17: wsfulton - Fix typemap matching to expand template parameters when the name contains - template parameters. In the %typemap below the type is T and the name is X::make - and the name now expands correctly to X< int >::make - - template struct X { - %typemap(out) T X::make "..." - T make(); - }; - - %template(Xint) X; - -2019-02-16: wsfulton - Fix parser error containing multiple #define statements inside an enum. - - The second #define fails to parse: - - enum FooEnum { - ENUM1 = 0, - ENUM2 = 1, - - #define MACRO_DEF1 "Hello" - #define MACRO_DEF2 "World!" - - ENUM3 = 2, - ENUM4 = 3, - }; - - Bug mentioned at https://sourceforge.net/p/swig/patches/333/ - -2019-02-14: wsfulton - Add some missing copy constructors into STL containers. - -2019-02-14: bkotzz - [Java] #1356 Add STL containers: - std::unordered_map - std::unordered_set - std::set - -2019-02-14: bkotzz - [Java] #1356 std::map wrappers have been modified. Now the Java proxy class - extends java.util.AbstractMap. The std::map container looks and feels much like - a java.util.HashMap from Java. - - A few members have changed their names. If the old method signatures are needed, - then copy std_map.i from swig-3.0.12 and use that instead. Alternatively, - add the old missing methods to the new methods by using the following %proxycode: - - %extend std::map { - %proxycode %{ - // Old API - public boolean empty() { - return isEmpty(); - } - public void set($typemap(jboxtype, K) key, $typemap(jboxtype, T) x) { - put(key, x); - } - public void del($typemap(jboxtype, K) key) { - remove(key); - } - public boolean has_key($typemap(jboxtype, K) key) { - return containsKey(key); - } - %} - } - - *** POTENTIAL INCOMPATIBILITY *** - -2019-02-13: ZackerySpytz - #1469 Add support for C++17 hexadecimal floating literals. - -2019-02-11: wsfulton - [OCaml] #1437 OCaml has been give the 'Experimental' language status. The examples work - and most of the test-suite is also working, so it is quite close to being a 'Supported' language. - -2019-02-10: ZackerySpytz - #1464 Add support for C++14 binary integer literals. - -2019-02-10: ZackerySpytz - #1450 Add support for C++11 UCS-2 and UCS-4 character literals. Also, add support for - C++17 UTF-8 character literals. - -2019-02-10: wsfulton - [MzScheme] #1437 MzScheme/Racket is now an 'Experimental' language. The examples work - and a large portion of the test-suite is also working. - -2019-02-10: wsfulton - [MzScheme] Destructor wrappers were not being generated. - -2019-02-10: wsfulton - [MzScheme] Static variable wrappers fixed - $argnum was not expanded. - -2019-02-10: sethrj - #1452 Fix %apply for anonymous template instantiations - -2019-02-09: olly - [PHP] Fix access to already released memory during PHP module - shutdown, which often didn't cause visible problems, but could - result in segmentation faults, bus errors, etc. Fixes #1170, - reported by Jitka Plesníková. - -2019-02-09: olly - [PHP] A renamed constructor is now wrapped as a static method in - PHP. - -2019-02-08: olly - [PHP] Don't generate code which references $r when $r hasn't been - defined. This could happen in overloaded methods which returned - void and took at least one const std::string& parameter. - -2019-02-08: olly - [PHP] The generated code is now compatible with PHP 7.3, and the - testsuite now runs cleanly with this version too. - -2019-02-05: wsfulton - #1437 SWIG now classifies the status of target languages into either 'Experimental' or - 'Supported'. This status is provided to indicate the level of maturity to expect when using - a particular target language as not all target languages are fully developed. Details are - in the Introduction.html chapter of the documentation. - -2019-02-04: wsfulton - [CFFI] #1447 Common Lisp CFFI has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [Allegrocl] #1447 Allegro Common Lisp has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [Chicken] #1447 CHICKEN has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [CLISP] #1447 GNU Common Lisp has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [S-EXP] #1447 Common Lisp S-Exp has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [UFFI] #1447 Common Lisp UFFI has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [Pike] #1447 Pike has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-04: wsfulton - [Modula3] #1447 Modula3 has been disabled as a target language in SWIG as part of a - clean up to remove target languages that have been neglected/not functional. - -2019-02-02: ahnolds - [Python] Documentation enhancements for Python: - - #728 Fixed the handling of autodoc when using -fastproxy. - - #1367 Added documentation to wrapped member variables using the - property(... doc="...") construct. - - Only show a single documentation entry for functions with default arguments when - using autodoc. - - Fixed a bug where a cached doxygen docstring could be deleted while still in use, - causing swig to segfault. - -2019-01-31: olly - SWIG now requires a target language to be specified instead of - defaulting to wrapping for Tcl. Specifying swig --help without - a target language now just shows the generic help. The -nolang - option has been removed. - -2019-01-28: ZackerySpytz - [OCaml] #1429 Remove support for OCaml versions < 3.12.0. - - *** POTENTIAL INCOMPATIBILITY *** - -2019-01-22: vadz - [Ruby, Octave] #1424 Improve autodoc parameter naming. - -2019-01-22: vadz - [Python] #1271 #1423 Always include default parameter values in autodoc strings. - -2019-01-19: vadz - #1272, #1421 When a function's parameter is a keyword, the name of the paramater is - no longer simply changed to argN, where N is the argument number. Instead the - parameter name is changed to the renaming rules for keywords that normally apply to - symbols such as classes/functions etc. Note that unlike other symbol renaming, - parameter renaming does not issue a warning when the parameter is renamed. This - change only affects languages where the parameter names are actually used, for example, - Java function parameter lists in the proxy class or Python documentation comments. - -2019-01-18: wsfulton - #1420 Fix gdb debugger functions 'swigprint' and 'locswigprint' from swig.gdb to - work with newer versions of gdb-8. Fixes errors when debugging SWIG source with gdb: - - (gdb) swigprint n - Undefined command: "Printf". Try "help". - -2019-01-16: wsfulton - Python static method wrapper changes - - - Static method wrappers were using the 'fastproxy' approach by default. - This is inconsistent with instance method wrappers. The fastproxy approach - is now turned off by default to be consistent with instance methods. - Static method wrappers can now also be controlled using the -fastproxy and - -olddefs options. - - Example: - - struct Klass { - static int statmethod(int a = 2); - }; - - generates by default: - - class Klass(object): - ... - @staticmethod - def statmethod(a=2): - return _example.Klass_statmethod(a) - - instead of the following (which can be restored by using -fastproxy): - - class Klass(object): - ... - statmethod = staticmethod(_example.Klass_statmethod) - - - Modernise wrappers for static methods to use decorator syntax - @staticmethod. - - - Add missing runtime test for static class methods and using the actual class method. - -2019-01-12: ZackerySpytz - [OCaml] #1403 #1194 Fix compilation problems for OCaml >= 4.03.0 due to OCaml using - int64_t instead of int64. - -2019-01-11: ZackerySpytz - [OCaml] #1400 Fix the getters and setters of non-static member variables. - -2019-01-07: wsfulton - #358 Add VOID to windows.i - -2019-01-05: wsfulton - #948 #1019 #1273 Fix for C++11 raw strings where the delimiters were mistakenly left - in the string contents in situations where the string was copied into generated code. - For example, %constant, the "docstring" feature and for C#/Java/D constants turned on - with %javaconst/%csconst/%dmanifestconst. - -2019-01-05: wsfulton - [Ruby] #538. Fix Ruby support for %feature("docstring"). - -2019-01-03: wsfulton - #1202 Fix overloading of non-pointer class types in scripting languages when overloaded - with a pointer and a NULL scripting language equivalent is used, eg None in Python. - - The implementation changes the SWIGTYPE, SWIGTYPE& and SWIGTYPE&& typecheck typemaps to - prevent accepting a conversion to a NULL pointer. - -2019-01-03: ZackerySpytz - [OCaml] #1386 Fix the OCaml examples and test suite for out-of-source builds. - -2019-01-01: wsfulton - [Python] #639 remove duplicate proxy method definitions for global function wrappers. - - Global functions previously generated two definitions, eg: - - def foo(): - return _example.foo() - foo = _example.foo - - The first definition is replaced by the second definition and so the second definition - is the one used when the method is actually called. Now just the first definition is - generated by default and if the -fastproxy command line option is used, just the second - definition is generated. The second definition is faster as it avoids the proxy Python - method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs - command line options will restore the previously generated code as it will generate both - method definitions. - - With this change, the wrappers for global C/C++ functions and C++ class methods now work - in the same way wrt to generating just a proxy method by default and control via - -fastproxy/-olddefs options. - -2018-12-20: hasinoff,wsfulton - [Java] #1334 Set Java thread name to native thread name when using directors. - - Default is to use name "Thread-XXX" and is still works like this by default. However, - adding the following will turn on the thread name setting (works for more recent - versions of Linux and MacOS): - - %begin %{ - #define SWIG_JAVA_USE_THREAD_NAME - %} - -2018-12-20: chlandsi - [Python] #1357. Fix overriding __new__ in Python 3.6. - - Fixes SystemError: Objects/tupleobject.c:81: bad argument to internal function" - -2018-12-16: wsfulton - [Python] #848 #1343 The module import logic has changed to stop obfuscating real ImportError - problems. Only one import of the low-level C/C++ module from the pure Python module is - attempted now. Previously a second import of the low-level C/C++ module was attempted - after an ImportError occurred and was done to support 'split modules'. A 'split module' is - a configuration where the pure Python module is a module within a Python package and the - low-level C/C++ module is a global Python module. Now a 'split module' configuration is - no longer supported by default. This configuration can be supported with a simple - customization, such as: - - %module(package="mypackage", moduleimport="import $module") foo - - or if using -builtin: - - %module(package="mypackage", moduleimport="from $module import *") foo - - instead of - - %module(package="mypackage") foo - - See the updated Python chapter titled "Location of modules" in the documentation. - -2018-12-11: tlby - [Perl] #1374 repair EXTEND() handling in typemaps - -2018-12-06: vadz - #1359 #1364 Add missing nested class destructor wrapper when the nested class is - inside a template. Removes associated bogus 'Illegal destructor name' warning. Only - occurred when the nested class' destructor is explicitly specified. - -2018-12-04: adr26 - [Python] #1368 #1369 Access Violation in tp_print caused by mismatched Python/extension - CRT usage - - Remove all use of tp_print, as this API uses a FILE*, which can be - mismatched when modules are built with different C libraries from - the main python executable. - - This change also brings consistent output between Python 2 and 3 for the 'cvar' SWIG - object (that contains the global variables) and SWIG packed objects (such as callback - constants). - -2018-12-04: wsfulton - [Python] #1282 Fix running 'python -m' when using 'swig -builtin' - - Similar to the earlier PEP 366 conforming fix for non-builtin. - -2018-11-29: adr26 - [Python] #1360 Leak of SWIG var link object - - Fix reference counting on _SWIG_globals to allow var link to be freed on module unload. - -2018-11-28: wsfulton - [Python] When using -builtin, the two step C-extension module import is now - one step and the wrapped API is only available once and not in an underlying - module attribute like it is without -builtin. To understand this, consider a - module named 'example' (using: %module example). The C-extension is compiled into - a Python module called '_example' and a pure Python module provides the actual - API from the module called 'example'. It was previously possible to additionally - access the API from the module attribute 'example._example'. The latter was an - implementation detail and is no longer available. It shouldn't have been used, but - if necessary it can be resurrected using the moduleimport attribute described in the - Python chapter of the documentation. If both modules are provided in a Python - package, try: - - %module(moduleimport="from . import _example\nfrom ._example import *") example - or more generically: - %module(moduleimport="from . import $module\nfrom .$module import *") example - - and if both are provided as global modules, try: - - %module(moduleimport="import _example\nfrom _example import *") example - or more generically: - %module(moduleimport="import $module\nfrom $module import *") example - - The module import code shown will appear in the example.py file. - -2018-11-24: vadz - #1358 Fix handling of abstract base classes nested inside templates - - Correct detecting of whether a derived class method overrides a pure virtual - base class method when both classes are nested inside a template class: this - notably didn't work correctly for methods taking parameters of the base class - type. - -2018-11-22: rupertnash - [Python] #1282 Make generated module runnable via python -m (PEP 366 conforming) - - Previously any SWIG generated modules in a package would fail with an ImportError - when using 'python -m' for example 'python -m mypkg.mymodule'. - - This fix also allows the SWIG generated module to be placed into a directory and - then renamed __init__.py to convert the module into a package again. This ability - stopped working in swig-3.0.9. However, only Python 2.7 or 3.3 and later work. If - Python 3.2 support is needed, use moduleimport in %module to customise the import - code. - -2018-11-13: wsfulton - #1340 Remove -cppcast and -nocppcast command line options (this was an option - available to the scripting language targets). - - The -cppcast option is still turned on by default. The -nocppcast option - to turn off the use of c++ casts (const_cast, static_cast etc) has been - removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts - instead of C++ casts for C++ wrappers. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-11-13: wsfulton - [Python] #1340 Remove -outputtuple and -nooutputtuple command line options. - - Both the command line and %module options of the same name have been - removed. These were undocumented. The -outputtuple option returned a - Python tuple instead of a list, mostly typically in the OUTPUT - typemap implementations. - - It unclear why a tuple instead of a list return type is needed and - hence this option has been removed as part of the simplification of - the SWIG Python command line options for SWIG 4. - -2018-11-13: wsfulton - [Python] #1340 Remove -noproxyimport command line option. - - This option turned off the insertion of Python import statements - derived from a %import directive. For example given: - - %module module_b - %import "module_a.i" - - then module_b.py will contain: - - import module_a - - *** POTENTIAL INCOMPATIBILITY *** - -2018-10-29: AlexanderGabriel - [PHP] The following PHP7 reserved keywords are now only renamed by - SWIG when used as function names in the API being wrapper: - __halt_compiler array die echo empty eval exit include include_once - isset list print require require_once return unset - -2018-10-22: olly,wsfulton - [Python] #1261 #1340 Turn on many optimisation options by default and rationalise the - number of command line options. - - There were an unnecessary number of command line options and many of these have now - been removed in a drive for simplification. Some were needed to support older versions - of Python (2.6 and earlier). - - Many of the options could be turned on individually and when using -O. Previously -O - resulted in turning on a set of options: - - -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel - -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone - - Now -O results in turning on this reduced set: - - -fastdispatch -fastproxy -fvirtual - - The following options are now on by default, a deprecated warning is displayed if they - are used: - -fastinit Class initialisation code done in C/C++ rather than in Python code. - -fastquery Python dictionary used for lookup of types. - -fastunpack Faster unpacking of function arguments in C/C++ wrappers. - -modern Use Python 2.3 features such as object and property. - -modernargs Use Python 2.3 C APIs for unpacking arguments in tuples. - -noproxydel Stop generating a proxy __del__ method for backwards compatiblity. - -safecstrings No discernable difference - - The following options have been removed altogether: - -aliasobj0 - -buildnone - -classptr - -new_repr - -newrepr - -noaliasobj0 - -nobuildnone - -nocastmode - -nodirvtable - -noextranative - -nofastinit - -nofastproxy - -nofastquery - -nomodern - -nomodernargs - -nooutputtuple - -nosafecstrings - -old_repr - -oldrepr - -proxydel - - -new_vwm is no longer supported. Use the -newvwm alias instead. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-10-22: olly - [Python] #1261 Remove command line option no longer needed as Python 2.3 and earlier - are no longer supported: - - -classic - -2018-10-09: wsfulton - [D, Go, Guile, Lua, Mzscheme, Ocaml, Perl5, Php, Scilab, Tcl] - Allow wrapping of std::map using non-default comparison function. - -2018-10-09: vadz - [Java] #1274 Allow wrapping of std::map using non-default comparison function. - -2018-10-04: wsfulton - [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. - Problem occurred when there is just one (defaulted) parameter in the parameter list. - -2018-09-24: wsfulton - [Python] #1319 C++11 hash tables implementation is finished now (including for -builtin): - std::unordered_map - std::unordered_set - std::unordered_multimap - std::unordered_multiset - -2018-09-21: wsfulton - [Python] Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or - std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL - container's find method. Without it, Python will do its own slower sequence search. - -2018-09-19: wsfulton - [Python] Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack. - -2018-09-02: andreas.gaeer,tkrasnukha - [Python] #1321 Fix assert in PyTuple_GET_SIZE in debug interpreter builds of python-3.7 - when calling tp_new. - -2018-09-01: ChristopherHogan - [Guile] #1288 Fix garbage collection for guile >= 2.0.12. - -2018-08-31: wsfulton - [Python] #1319 C++11 hash tables support: - std::unordered_map - std::unordered_set - std::unordered_multimap - std::unordered_multiset - is now compiling and working (sorting using -builtin not fully functional yet though). - -2018-08-20: wkalinin - #1305 Fix nested structure symbol tables in C mode to fix member name conflicts - in different structs with the same nested struct member name. - -2018-08-18: wsfulton - [Python] #688 Fix makefile recursion when running python test-suite. - -2018-08-18: wsfulton - [Python] #1310 Re-implement Python -fastproxy option. - - The previous implementation failed with Python 3 and abstract base clases. - The new implementation replaces the Python 2 implementation using - new.instancemethod with the C API PyMethod_New to match the equivalent Python 3 - implementation which uses PyInstanceMethod_New. - - The new approach runs slightly faster. See #1310. - -2018-08-12: gmazzamuto - [Python] #1283 Update pybuffer.i library to use new-style Python buffer C API. - -2018-08-12: brianhatwood,wsfulton - [Java] #1303 #1304 Fix crash in directors when using OUTPUT and INOUT typemaps in typemaps.i and - passing NULL pointers in C++ to director method overloaded and implemented in Java. - -2018-08-10: wsfulton - [Python] #1293 Improve TypeError message inconsistencies between default and fastdispatch - mode when handling overloaded C++ functions. Previously the error message did not always - display the possible C/C++ prototypes in fastdispatch mode. - -2018-08-02: furylynx,jacobwgillespie,p2k - [Javascript] #1290, #968. Add support for NodeJS versions 2-10. - -2018-07-31: wsfulton - [Python] #1293 Overloaded C++ function wrappers now raise a TypeError instead - of NotImplementedError when the types passed are incorrect. This change means - there is now consistency with non-overloaded function wrappers which have always - raised TypeError when the incorrect types are passed. The error message remains - the same and is for example now: - - TypeError: Wrong number or type of arguments for overloaded function 'f'. - Possible C/C++ prototypes are: - f(int) - f(char const *) - - instead of: - - NotImplementedError: Wrong number or type of arguments for overloaded function 'f'. - Possible C/C++ prototypes are: - f(int) - f(char const *) - - *** POTENTIAL INCOMPATIBILITY *** - -2018-06-23: wsfulton - [Python] #718 Fix pythonnondynamic feature for modern classes - - Fixes nondynamic mode when an instance variable is set with the same - name as a class variable in a class derived from a SWIG proxy class. - This corner case set an instance variable instead of raising an AttributeError. - - Also fix %pythonnondynamic in Python 3 with -modern. The metaclass - containing the implementation was previously not being applied in Python 3. - -2018-07-17: petrmitrichev,wsfulton - [Python] #1275 #1279 Initialize function-local statics (singletons) that call Python - code during Python module initialization in order to avoid deadlocks with subsequent - multi-threaded usage. - -2018-06-15: wsfulton - [Python] Fix seg fault using Python 2 when passing a Python string, containing - invalid utf-8 content, to a wstring or wchar * parameter. A TypeError is thrown instead, eg: - - %include - void instring(const std::wstring& s); - - instring(b"h\xe9llooo") # Python - -2018-06-15: wsfulton - [Python] Python 3.7 support: Replace use of deprecated PyUnicode_GetSize with - PyUnicode_GetLength to remove deprecated warnings compiling the C/C++ wrappers. - -2018-06-12: wsfulton - [Python] Python 3.7 support: The %pythonabc feature in pyabc.i now uses base classes - collections.abc.MutableSequence - collections.abc.MutableMapping - collections.abc.MutableSet - instead of - collections.MutableSequence - collections.MutableMapping - collections.MutableSet - as the latter are deprecated in Python 3.7 and are due to be removed in Python 3.8. - The classes in collections.abc.* are available from Python 3.3 onwards. If you - require support for Python 3.2, then copy the pyabc.i file and modify by removing - the few instances of the .abc sub-module. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-06-12: olly,wsfulton - [Python] #701 Remove support for Python versions < 2.7 and 3.0 and 3.1. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-06-11: olly - [Python] Fix new GCC8 warnings in generated code by avoiding casts - between incompatible function types where possible, and by - suppressing the warning when it's due to the design of Python's C - API. Fixes #1259. - -2018-06-08: philippkraft - [Python] Stop exposing _swigregister to Python. It's not - useful for user Python code to call this, and it just clutters the - API unnecessarily. Fixes #1225. - -2018-06-07: cmfoil, kabbi, Jamie Kirkpatrick, markok314, vadz, wsfulton, Yann Diorcet - #170 Doxygen documentation support added. This allows translation of Doxygen comments - into JavaDoc and PyDoc documentation. It is enabled via the -doxygen command line - option. See the Doxygen.html chapter in the documentation for further information. - -2018-06-07: olly - [PHP] We've finally removed support for %pragma(php4) which was - deprecated back in 2008. Use %pragma(php) instead, which has been - supported since at least 2005. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-06-07: olly - [PHP5] Support for PHP5 has been removed. PHP5 is no longer - actively supported by the PHP developers and security support for - it ends completely at the end of 2018, so it doesn't make sense - to include support for it in the upcoming SWIG 4.0.0 release. - - *** POTENTIAL INCOMPATIBILITY *** - -2018-06-06: olly - [Lua] Improve configure probes for Lua headers and libs used in testsuite. - -2018-05-15: kwwette - [Octave] add support for version 4.4 - - Should not introduce any user-visible incompatibilities - -2018-05-15: wsfulton - [C#, D, Java] Fix lookup of csconstruct, dconstruct and javaconstruct typemaps. - The C++ namespace was previously ignored when looking up the typemap. - -2018-05-15: wsfulton - [Javascript] Fix generated C++ code when using %nspace on namespaces that are more - than two levels deep. - -2018-05-14: wsfulton - Issue #1251 Add support for C++17 nested namespace definitions, - for example: - namespace A::B { ... } - -2018-05-11: wsfulton - [C#, D, Java] Add support so that the %csmethodmodifiers, %dmethodmodifiers, - %javamethodmodifiers can modify the method modifiers for the destructor wrappers - in the proxy class: dispose, Dispose, delete. With this feature, it is now possible - to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers - can be removed using: - - %typemap(csclassmodifiers) X "public sealed class" - %csmethodmodifiers X::~X "public /*virtual*/"; - -2018-04-18: olly - [Python] Suppress new pycodestyle warning: - E252 missing whitespace around parameter equals - -2018-04-07: goatshriek - [Ruby] #1213 Fix ruby %alias directive for global C/C++ functions. - -2018-04-03: olly - [Ruby] Fix to pass Qnil instead of NULL to rb_funcall(), which silences GCC - -Wconversion-null warning (on by default with recent GCC). - -2018-03-09: wsfulton - [Java] #1184 Fix swigReleaseOwnership() and swigTakeOwnership() regression - for non-director classes. Restores a dynamic_cast which was previously removed. - -2018-03-07: llongi - Github PR #1166 - Fix preprocessor handling of macros with commas - in a // comment. - -2018-02-18: JPEWdev - Patch #1164 - Add support for a command-line options file, also sometimes - called a response file. This is useful if the command-line options exceed - the system command-line length limit. To use, put the command-line options - into a file, then provide the file name prefixed with @, for example using - a file called args.txt: - - swig @args.txt - -2018-02-11: wsfulton - [Javascript] #1187 Fix compilation error wrapping std::complex via - std_complex.i. - -2018-01-30: smarchetto - [Scilab] add type name argument in SWIG_ptr() function to cast from pointer address to typed pointers - -2018-01-16: wsfulton - Expressions following a preprocessor directive must now be separated by whitespace - or non-numeric characters. This syntax change makes the SWIG preprocessor work like - the C preprocessor in this area. - - For example, the following code used be accepted as valid syntax: - #if1 - #define ABC 123 - #endif - - Now you get an error: - example.h:1: Error: Unknown SWIG preprocessor directive: if1 (if this is a block of - target language code, delimit it with %{ and %}) - example.h:3: Error: Extraneous #endif. - - The following is the correct syntax: - #if 1 - #define ABC 123 - #endif - - The following of course also works: - #if(1) - #define ABC 123 - #endif - - *** POTENTIAL INCOMPATIBILITY *** - -2018-01-15: wsfulton - Fix issue #1183. Floating point exception evaluating preprocessor expressions - resulting in division by zero. - -2018-01-14: wsfulton - Fix issue #1172. Seg fault parsing invalid exponents in the preprocessor. - -2018-01-12: Liryna - [C#] Patch #1128. Add ToArray function to std::vector wrappers. - -2018-01-12: wsfulton - [Java] Fix issue #1156. Add missing throws clause for interfaces when using the - %interface family of macros. - -2018-01-05: wsfulton - Fix default arguments using expressions containing -> syntax error. Problem reported on - swig-user mailing list. - -2017-12-30: wsfulton - [Python] Replace pep8 with pycodestyle for checking the Python code style when - running Python tests. - -2017-12-30: davedissian - Fixed a symbol lookup issue when encountering a typedef of a symbol from the tag - namespace to the global namespace when the names are identical, such as 'typedef - struct Foo Foo;'. - -2017-12-13: wsfulton - [Perl] add missing support for directorfree typemaps. - -2017-12-13: wsfulton - Issue #1167 Fix directorout typemaps which were causing undefined behaviour when - returning pointers by reference. - -2017-12-08: olly - [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this - should make the generated code work with PHP 7.2.0. - -2017-12-04: wsfulton - [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a - seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing - u"\udcff" to the C layer (Python 3). - -2017-11-24: joequant - [R] Fix #1124 and return R_NilValue for null pointers - -2017-11-29: wsfulton - [Java] director exception handling improvements. - - When a director method throws an exception and it is caught by DirectorException - and passed back to Java using Swig::DirectorException::throwException, the Java - stack trace now contains the original source line that threw the exception. - - Deprecate Swig::DirectorException::raiseJavaException, please replace usage with - Swig::DirectorException::throwException. - - *** POTENTIAL INCOMPATIBILITY *** - -2017-10-26: wsfulton - Add support for C++11 ref-qualifiers when using directors. - -2017-10-26: wsfulton - Fix generated code when using directors and methods returning const ref pointers. - -2017-10-26: wsfulton - [C#, D, Java, Octave, R, Scilab] Port director typemaps to these additional languages. - Issue #700. - -2017-10-26: radarsat1 - [Ruby Python] Patch #1029 - Correct handling of null using directors and shared_ptr. - -2017-10-10: joequant - [R] pass enum expressions to R. This will generate - incorrect files when there is an arithmetic expression - in the enum, but this is better than silently generating - incorrect code - -2017-10-09: olly - [PHP] Fix incorrect wrapper code generated when there's a - combination of overloading, parameters with a default value - and %newobject. Fixes https://sourceforge.net/p/swig/bugs/1350/ - -2017-10-09: olly - Remove GCJ support. It isn't in a good state and doesn't seem to - be used, and GCC7 dropped GCJ. Closes - https://sourceforge.net/p/swig/bugs/823/ - -2017-10-07: olly - Fix preprocessor handling of empty macro arguments to match that of - C/C++ compilers. Fixes issue #1111 and - https://sourceforge.net/p/swig/bugs/826/ - -2017-10-06: wsfulton - [Python] Issue #1108. Fix platform inconsistency in Python default argument handling. - 32 bit and 64 bit compiled versions of SWIG generated different Python files - when default arguments were outside the range of 32 bit signed integers. - The default arguments specified in Python are now only those that are in the - range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code. - -2017-10-02: wsfulton - [C#] Fix std::complex types passed by value. - -2017-10-02: wsfulton - [Javascript, Python, Ruby] Issue #732 - Missing type information for std::complex - in std_complex.i meant that previously std::complex always had to be fully qualified - in order to be wrapped with the appropriate typemaps. - -2017-10-01: joequant - allow R package names with docs - allowing multiple get accessors in R - fix smart-pointer and NAMESPACE support - constructors now returning smart pointers (if class - declared as such) - smart-pointer classes deriving from parent smart-pointers - -2017-09-29: wsfulton - Issue #1100 - Allow an instantiated template to have the same name in the target - language as the C++ template name, for example, this is now possible: - - template struct X { ... }; - %template(X) X; - -2017-09-23: wsfulton - Issue #1098. Fix overloading of shared_ptr with underlying pointer types, eg: - - void m(std::shared_ptr p); - void m(T &p); - void m(T *p); - - Only the first method is wrapped and the others are ignored/shadowed. - The implementation is done via a new attribute in the 'typecheck' typemap called - 'equivalent'. If specified, it must contain the equivalent pointer type for overloading - and can only be used for the special SWIG_TYPECHECK_POINTER precedence level. - The shared_ptr 'typecheck' typemaps have been modified accordingly. - Here is a simplified version: - - %typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="T *") - T, - T CONST &, - T CONST *, - T *CONST&, - std::shared_ptr< T >, - std::shared_ptr< T > &, - std::shared_ptr< T > *, - std::shared_ptr< T > *& - { ... } - - Overloading with any of these types will result in SWIG ignoring all but the first - overloaded method by default. Without the 'equivalent' attribute, wrapping the overloaded - methods resulted in types being shadowed (scripting languages) or code that did not - compile (statically typed languages). - -2017-09-19: futatuki - [Python] #1003 Add --with-2to3=/path/to/2to3 option to configure. - -2017-09-18: wsfulton - Fix type promotion wrapping constant expressions of the form: - # define EXPR_MIXED1 (0x80 + 11.1) - 1 - This was previously an integral type instead of a floating point type. - -2017-09-17: wsfulton - Fix generated code for constant expressions containing wchar_t L literals such as: - # define __WCHAR_MAX (0x7fffffff + L'\0') - # define __WCHAR_MIN (-__WCHAR_MAX - 1) - -2017-09-10: mlamarre - [Python] Patch #1083. Define_DEBUG to 1 to do exactly like Visual Studio - /LDd, /MDd or /MTd compiler options. - -2017-08-25: wsfulton - Issue #1059. Add support for C++11 ref-qualifiers on non-static member functions. - Members with lvalue ref-qualifiers such as: - - struct RQ { - void m1(int x) &; - void m2(int x) const &; - }; - - are wrapped like any other member function. Member functions with rvalue ref-qualifiers - are ignored by default, such as: - - struct RQ { - void m3(int x) &&; - void m4(int x) const &&; - }; - - example.i:7: Warning 405: Method with rvalue ref-qualifier m3(int) && ignored. - example.i:8: Warning 405: Method with rvalue ref-qualifier m4(int) const && ignored. - - These can be unignored and exposed to the target language, see further documentation in - CPlusPlus11.html. - -2017-08-16: wsfulton - Fix #1063. Add using declarations to templates into typedef table. - - Using declarations to templates were missing in SWIG's internal typedef tables. - This led to a few problems, such as, templates that did not instantiate and generated - C++ code that did not compile as SWIG did not know what scope the template was - in. This happened mostly when a using declaration was used on a template type in a - completely unrelated namespace. - -2017-08-16: wsfulton - Fix type lookup in the presence of using directives and using declarations. - - Fix some cases of type lookup failure via a combination of both using directives and - using declarations resulting in C++ code that did not compile as the generated type was - not fully qualified for use in the global namespace. Example below: - - namespace Space5 { - namespace SubSpace5 { - namespace SubSubSpace5 { - struct F {}; - } - } - using namespace SubSpace5; - using SubSubSpace5::F; - void func(SubSubSpace5::F f); - } - -2017-08-16: wsfulton - Issue #1051. %template scope enforcement and class definition fixes. - - The scoping rules around %template have been specified and enforced. - The %template directive for a class template is the equivalent to an - explicit instantiation of a C++ class template. The scope for a valid - %template instantiation is now the same as the scope required for a - valid explicit instantiation of a C++ template. A definition of the - template for the explicit instantiation must be in scope where the - instantiation is declared and must not be enclosed within a different - namespace. - - For example, a few %template and C++ explicit instantiations of std::vector - are shown below: - - // valid - namespace std { - %template(vin) vector; - template class vector; - } - - // valid - using namespace std; - %template(vin) vector; - template class vector; - - // valid - using std::vector; - %template(vin) vector; - template class vector; - - // ill-formed - namespace unrelated { - using std::vector; - %template(vin) vector; - template class vector; - } - - // ill-formed - namespace unrelated { - using namespace std; - %template(vin) vector; - template class vector; - } - - // ill-formed - namespace unrelated { - namespace std { - %template(vin) vector; - template class vector; - } - } - - // ill-formed - namespace unrelated { - %template(vin) std::vector; - template class std::vector; - } - - When the scope is incorrect, an error now occurs such as: - - cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and - was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'. - - Previously SWIG accepted the ill-formed examples above but this led to - numerous subtle template scope problems especially in the presence of - using declarations and using directives as well as with %feature and %typemap. - - Actually, a valid instantiation is one which conforms to the C++03 - standard as C++11 made a change to disallow using declarations and - using directives to find a template. - - // valid C++03, ill-formed C++11 - using std::vector; - template class vector; - - Similar fixes for defining classes using forward class references have - also been put in place. For example: - - namespace Space1 { - struct A; - } - namespace Space2 { - struct Space1::A { - void x(); - } - } - - will now error out with: - - cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and - was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'. - - Previously some symbols would have been instantiated in the wrong scope and led - to lots of scope problems involving SWIG typemaps, features, renames etc. - You will need to correct the scope used in other SWIG directives which do not - support 'using declarations' and 'using directives'. For example, if you previously had: - - %rename(Zap) vector::clear; - using namespace std; - %template(VectorInt) vector; - - Prior versions of SWIG incorrectly instantiated vector in the global namespace - and so the %rename matched. Now the template is instantiated in the correct namespace, - so is fully qualified as std::vector. The other SWIG directives need correcting as - they do not follow 'using declarations' and 'using directives'. Change it to: - - %rename(Zap) std::vector::clear; - using namespace std; - %template(vin) vector; - - - *** POTENTIAL INCOMPATIBILITY *** - -2017-08-16: wsfulton - Fix scope lookup for template parameters containing unary scope operators. - - Fixes cases like: - - namespace Alloc { - template struct Rebind { - typedef int Integer; - }; - } - %template(RebindBucket) Alloc::Rebind< Bucket >; - OR - %template(RebindBucket) Alloc::Rebind< ::Bucket >; - - Alloc::Rebind< Bucket >::Integer Bucket1(); - Alloc::Rebind< ::Bucket >::Integer Bucket2(); - Alloc::Rebind<::template TemplateBucket>::Integer Bucket3(); - -2017-08-16: wsfulton - For templates only, the template parameters are fully resolved when - handling typemaps. Without this, it is too hard to have decent rules - to apply typemaps when parameter types are typedef'd and template - parameters have default values. - - Fixes %clear for typedefs in templates, eg: - - %typemap("in") XXX::Long "..." - template typename struct XXX { - typedef long Long; - }; - %clear XXX::Long; - - as the typemap was previously incorrectly stored as a typemap for long - instead of XXX::Long. - -2017-08-05: olly - [C++11] Allow static_assert at the top level (and disallow it right - after template). Fixes issue 1031 reported by Artem V L. - -2017-08-02: wsfulton - Fix incorrectly shown warning when an empty template instantiation was used on a - class used as a base class and that base class was explicitly ignored with %ignore. - Example of the warning which will no longer appear: - - Warning 401: Base class 'Functor< int,int >' has no name as it is an empty - template instantiated with '%template()'. Ignored. - -2017-07-17: fflexo - [Java] #674 Add std_list.i to add support for std::list containers. The Java proxy - extends java.util.AbstractSequentialList and makes the C++ std::list container look - and feel much like a java.util.LinkedList from Java. - -2017-07-07: wsfulton - [Python] Fix display of documented template types when using the autodoc - feature. For example when wrapping: - - %feature("autodoc"); - template struct T {}; - %template(TInteger) T; - - the generated documentation contains: - """Proxy of C++ T< int > class.""" - instead of: - """Proxy of C++ T<(int)> class.""" - and - """__init__(TInteger self) -> TInteger""" - instead of - """__init__(T<(int)> self) -> TInteger""" - -2017-06-27: nihaln - [PHP] Update the OUTPUT Typemap to add return statement to the - PHP Wrapper. - -2017-06-27: nihaln - [PHP] Update the enum and value examples to use the OO wrappers - rather than the flat functions produced with -noproxy. There's - not been a good reason to use -noproxy for since PHP5 OO wrapping - was fixed back in 2005. - -2017-06-23: m7thon - [Python] fix and improve default argument handling: - - 1. Fix negative octals. Currently not handled correctly by `-py3` - (unusual case, but incorrect). - 2. Fix arguments of type "octal + something" (e.g. `0640 | 04`). - Currently drops everything after the first octal. Nasty! - 3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always - "False" (unusual case, but incorrect). - 4. Remove special handling of "TRUE" and "FALSE" from - `convertValue` since there's no reason these have to match - "true" and "false". - 5. Remove the Python 2 vs. Python 3 distinction based on the - `-py3` flag. Now the same python code is produced for default - arguments for Python 2 and Python 3. For this, octal default - arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This - is required, as Python 2 and Python 3 have incompatible syntax - for octal literals. - - Fixes #707 - -2017-06-21: futatuki - #1004 - Fix ccache-swig executable name to respect configure's --program-prefix and - --program-suffix values if used. - -2017-06-21: tamuratak - [Ruby] #911 - Add std::wstring support. - -2017-06-19: wsfulton - [Python] Fix handling of rich comparisons when wrapping overloaded operators: - - operator< operator<= operator> operator>= operator== operator!= - - Previously a TypeError was always thrown if the type was not correct. NotImplemented - is now returned from these wrapped functions if the type being compared with is - not correct. The subsequent behaviour varies between different versions of Python - and the comparison function being used, but is now consistent with normal Python - behaviour. For example, for the first 4 operator overloads above, a TypeError - 'unorderable types' is thrown in Python 3, but Python 2 will return True or False. - NotImplemented should be returned when the comparison cannot be done, see PEP 207 and - https://docs.python.org/3/library/constants.html#NotImplemented - - Note that the bug was only present when overloaded operators did not also have a - function overload. - - Fixes SF bug #1208 (3441262) and SF patch #303. - - *** POTENTIAL INCOMPATIBILITY *** - -2017-06-17: fabrice102 - [Go] Fix Go callback example. Fixes github #600, #955, #1000. - -2017-06-16: wsfulton - Make sure warning and error messages are not split up by other processes writing to - stdout at the same time. - -2017-06-16: wsfulton - [R] Fix wrapping function pointers containing rvalue and lvalue reference parameters. - -2017-06-13: olly - [Perl] Fix testsuite to work without . in @INC - it was removed in - Perl 5.26 for security reasons, and has also been removed from - older versions in some distros. Fixes #997 reported by lfam. - -2017-06-03: wsfulton - Fix %import on a file containing a file scope %fragment forced inclusion to not - generate the fragment contents as %import should not result in code being generated. - The behaviour is now the same as importing code insertion blocks. - Wrapping FileC.i in the following example will result in no generated code, whereas - previously "#include " was generated: - - // FileA.i - %fragment("", "header") %{ - #include - %} - - %{ - #include - %} - %fragment(""); - - // FileC.i - %import "FileA.i" - - *** POTENTIAL INCOMPATIBILITY *** - -2017-05-26: Volker Diels-Grabsch, vadz - [Java] #842 Extend from java.util.AbstractList<> and implement java.util.RandomAccess for - std::vector wrappers. This notably allows to iterate over wrapped vectors in a natural way. - Note that boxed types are now used in the Java layer when wrapping vector of C primitive - types, for example. This may introduce some subtle incompatibilities due to some - differences in how Java converts boxed types and unboxed types. For example, - - int i=0; - double d1 = i; // ok - Double d2 = i; // error: incompatible types: int cannot be converted to Double - - This can be a problem when calling the add and set functions. A suggested backwards - compatible workaround is to use something like (shown for std::vector: - - #if defined(SWIGJAVA) - // Add in old api that uses non-boxed types - %extend std::vector { - %proxycode %{ - public void add(double x) { - add(Double.valueOf(x)); - } - public void set(int i, double val) { - set(i, Double.valueOf(val)); - } - %} - } - #endif - - %include "std_vector.i" - %template(VectorDouble) std::vector; - - *** POTENTIAL INCOMPATIBILITY *** - -2017-05-30: davidcl - [Scilab] #994 Undefined symbol error when loading in Scilab 6 - -2017-05-25: asibross - [Java] #370 #417 Missing smart pointer handling in Java director extra methods - swigReleaseOwnership() and swigTakeOwnership(). - -2017-05-23: wsfulton - [Java] #230 #759 Fix Java shared_ptr and directors for derived classes java compilation - error. - - For shared_ptr proxy proxy classes, add a protected method swigSetCMemOwn for modifying - the swigCMemOwn and swigCMemOwnDerived member variables which are used by various other - methods for controlling memory ownership. - -2017-05-21: Sghirate - [Java, C#, D] #449 Remove unnecessary use of dynamic_cast in directors to enable - non-RTTI compilation. - -2017-05-21: wsfulton - [Python] #993 Fix handling of default -ve unsigned values, such as: - void f(unsigned = -1U); - -2017-05-20: jschueller - [Python] #991 Fix E731 PEP8 warning: do not assign a lambda expression - -2017-05-16: nihal95 - [PHP] Add %pragma version directive to allow the version of the - extension to be set. Patch #970, fixes #360. - -2017-05-13: yag00 - Patch #975 - Add support for noexcept on director methods. - -2017-04-27: redbrain - Issue #974, Patch #976 - Fix preprocessor handling of macros with commas in a comment. - -2017-04-25: jleveque - [Lua] #959 - Fix Visual Studio C4244 conversion warnings in Lua wrappers. - -2017-04-21: tamuratak - [Ruby] #964 - Add shared_ptr director typemaps. - -2017-04-20: wsfulton - [Ruby] #586, #935 Add assert for invalid NULL type parameter when calling SWIG_Ruby_NewPointerObj. - -2017-04-20: tamuratak - [Ruby] #930, #937 - Fix containers of std::shared_ptr. - Upcasting, const types (eg vector>) and NULL/nullptr support added. - -2017-04-12: smarchetto - [Scilab] New parameter targetversion to specify the Scilab target version (5, 6, ..) for code generation - With Scilab 6 target specified, identifier names truncation is disabled (no longer necessary) - -2017-03-24: tamuratak - [Ruby] Fix #939 - Wrapping std::vector fix due to incorrect null checks - on VALUE obj. - -2017-03-17: vadz - [C#] #947 Add support for std::complex - -2017-03-17: wsfulton - [Go] Fix handling of typedef'd function pointers and typedef'd member function pointers - such as: - - typedef int (*FnPtr_td)(int, int); - int do_op(int x, int y, FnPtr_td op); - -2017-03-16: wsfulton - Add support for member const function pointers such as: - - int fn(short (Funcs::* parm)(bool)) const; - - Also fix parsing of references/pointers and qualifiers to member - pointers such as: - - int fn(short (Funcs::* const parm)(bool)); - int fn(short (Funcs::* & parm)(bool)); - -2017-03-10: wsfulton - Extend C++11 alternate function syntax parsing to support const and noexcept, such as: - - auto sum1(int x, int y) const -> int { return x + y; } - auto sum2(int x, int y) noexcept -> int { return x + y; } - -2017-02-29: tamuratak - [Ruby] #917 - Add Enumerable module to all container class wrappers. It was missing - for std::list, std::multiset, std::unordered_multiset and std::unordered_map. - -2017-02-27: assambar - [C++11] Extend parser to support throw specifier in combination - with override and/or final. - -2017-02-10: tamuratak - [Ruby] #883 - Add support for C++11 hash tables: - std::unordered_map - std::unordered_set - std::unordered_multimap - std::unordered_multiset - -2017-02-08: jcsharp - [C#] #887 Improve std::vector wrapper constructors - - Replace constructor taking ICollection with IEnumerable and also add IEnumerable - constructor to avoid the boxing and unboxing overhead of the original constructor, - when the type parameter is a value type. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 6db5c3cc1..2cb1d2be4 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.0 (27 Apr 2019) +Last update : SWIG-4.0.1 (in progress)

    Sections

    diff --git a/README b/README index ecf4f87fc..165098cb5 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.0 (27 Apr 2019) +Version: 4.0.1 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index 1873797d6..cc46a6521 100644 --- a/configure.ac +++ b/configure.ac @@ -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],[4.0.0],[http://www.swig.org]) +AC_INIT([swig],[4.0.1],[http://www.swig.org]) AC_PREREQ(2.60) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) From 6606a164f0624108b8075e847c5f2c213606ed72 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Apr 2019 19:10:31 +0100 Subject: [PATCH 1590/2031] Migrate Travis tests from trusty to xenial Ubuntu trusty 14.04 is end of life April 2019. Ubuntu xenial 16.04 is the main platform for Travis now. Some languages are not working on xenial, so I've left them on trusty for now. --- .travis.yml | 130 +++++++++++++++++----------------- Tools/travis-linux-install.sh | 20 +++--- 2 files changed, 74 insertions(+), 76 deletions(-) diff --git a/.travis.yml b/.travis.yml index 61021b4e4..07fc0efbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,30 +5,30 @@ matrix: os: linux env: SWIGLANG= sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG= sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG= SWIG_CC=gcc-6 SWIG_CXX=g++-6 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=csharp sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=d sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=go VER=1.3 @@ -48,72 +48,72 @@ matrix: os: linux env: SWIGLANG=guile sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=java sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux - env: SWIGLANG=javascript ENGINE=node + env: SWIGLANG=javascript ENGINE=node VER=0.10 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=8 CPP11=1 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=jsc sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=v8 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=lua sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=lua VER=5.3 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=mzscheme sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=ocaml sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=octave SWIGJOBS=-j2 # 3.8 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0 @@ -133,17 +133,17 @@ matrix: os: linux env: SWIGLANG=perl5 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=php VER=7.0 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=php VER=7.1 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=php VER=7.2 @@ -153,110 +153,110 @@ matrix: os: linux env: SWIGLANG=php VER=7.3 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python # 2.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.2 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.3 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.4 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.5 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.6 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES="-builtin -O" sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 SWIGOPTPY3= sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-O sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=r sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=ruby VER=1.9.3 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=ruby VER=2.0.0 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=ruby VER=2.3.0 @@ -271,11 +271,11 @@ matrix: os: linux env: SWIGLANG=tcl sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=go SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required @@ -283,27 +283,27 @@ matrix: - os: linux env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=r CPP11=1 # Note: making 'R CMD SHLIB' use a different compiler is non-trivial sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=tcl SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=csharp SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=go SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required @@ -311,39 +311,39 @@ matrix: - os: linux env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=ruby SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=tcl SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=java SWIG_CC=gcc-7 SWIG_CXX=g++-7 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_CC=gcc-7 SWIG_CXX=g++-7 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=csharp SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=java SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=python SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 PY3=3 VER=3.7 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: osx env: SWIGLANG= @@ -393,12 +393,12 @@ matrix: os: linux env: SWIGLANG=mzscheme sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=ocaml sudo: required - dist: trusty + dist: xenial before_install: - date -u diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index bfa7bf8eb..b801e2b00 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -44,14 +44,15 @@ case "$SWIGLANG" in "javascript") case "$ENGINE" in "node") - if [[ -z "$VER" ]]; then - travis_retry sudo apt-get install -qq nodejs node-gyp + travis_retry wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.10/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + travis_retry nvm install ${VER} + nvm use ${VER} + if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] ; then +# travis_retry sudo apt-get install -qq nodejs node-gyp + travis_retry npm install -g node-gyp@$VER else - travis_retry wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.10/install.sh | bash - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - travis_retry nvm install ${VER} - nvm use ${VER} travis_retry npm install -g node-gyp fi ;; @@ -70,8 +71,6 @@ case "$SWIGLANG" in if [[ -z "$VER" ]]; then travis_retry sudo apt-get -qq install lua5.2 liblua5.2-dev else - travis_retry sudo add-apt-repository -y ppa:ubuntu-cloud-archive/mitaka-staging - travis_retry sudo apt-get -qq update travis_retry sudo apt-get -qq install lua${VER} liblua${VER}-dev fi ;; @@ -79,8 +78,7 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install racket ;; "ocaml") - # configure also looks for ocamldlgen, but this isn't packaged. But it isn't used by default so this doesn't matter. - travis_retry sudo apt-get -qq install ocaml ocaml-findlib + travis_retry sudo apt-get -qq install ocaml camlp4 ;; "octave") if [[ -z "$VER" ]]; then From 9d0cf2ce61409975ecb1500a1b268f2acbd41d60 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Apr 2019 19:53:35 +0100 Subject: [PATCH 1591/2031] Remove duplicate Travis xenial Octave testing --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07fc0efbd..54805092c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -111,14 +111,9 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 # 3.8 + env: SWIGLANG=octave SWIGJOBS=-j2 sudo: required dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.0 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.2 CPP11=1 From 5d976b0ebe6e6644342c0768eea4f87401d592ad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Apr 2019 21:14:39 +0100 Subject: [PATCH 1592/2031] Fix php testcase warning --- Examples/test-suite/php/cpp_static_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/cpp_static_runme.php b/Examples/test-suite/php/cpp_static_runme.php index 1d581bdb9..20b50dd9e 100644 --- a/Examples/test-suite/php/cpp_static_runme.php +++ b/Examples/test-suite/php/cpp_static_runme.php @@ -4,7 +4,7 @@ require "tests.php"; require "cpp_static.php"; // New functions -check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin')); +check::functions(array('staticfunctiontest_static_func','staticfunctiontest_static_func_2','staticfunctiontest_static_func_3','is_python_builtin','staticmembertest_grab_int','staticbase_grab_statty_base','staticderived_grab_statty_derived')); // New classes check::classes(array('StaticMemberTest','StaticFunctionTest','cpp_static','StaticBase','StaticDerived')); // New vars From dbb5fdda01eb51b5c3757c95f4c4bff81d92c6bd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Apr 2019 21:34:07 +0100 Subject: [PATCH 1593/2031] Fix php pragmas example . is not always in the include_path by default --- Examples/php/pragmas/example.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/php/pragmas/example.i b/Examples/php/pragmas/example.i index f9307a663..b72828b0e 100644 --- a/Examples/php/pragmas/example.i +++ b/Examples/php/pragmas/example.i @@ -21,7 +21,7 @@ zend_printf("This was %%rshutdown\n"); } -%pragma(php) include="include.php"; +%pragma(php) include="./include.php"; %pragma(php) code=" # This code is inserted into example.php From 5f42bed04eacc61f45c113131afe280ad0cdfa8a Mon Sep 17 00:00:00 2001 From: etse Date: Wed, 1 May 2019 17:05:44 -0400 Subject: [PATCH 1594/2031] Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class --- .../cpp11_shared_ptr_template_upcast.i | 88 +++++++++++++++++++ Examples/test-suite/java/Makefile.in | 1 + ...pp11_shared_ptr_template_upcast_runme.java | 25 ++++++ 3 files changed, 114 insertions(+) create mode 100644 Examples/test-suite/cpp11_shared_ptr_template_upcast.i create mode 100644 Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java diff --git a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i new file mode 100644 index 000000000..69ffec5bf --- /dev/null +++ b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i @@ -0,0 +1,88 @@ +%module cpp11_shared_ptr_template_upcast + +%{ +#include +#include +%} + +%include +%include + +%{ +class Base { +public: + Base() : value(0) {} + Base(int v) : value(v) {} + virtual ~Base() {} + + virtual int GetResult() = 0; + + int value; +}; + +class Derived : public Base { +public: + Derived() : Base() {} + Derived(int v) : Base(v) {} + virtual ~Derived() {} + + int GetResult() { return value*2; } +}; + +template class Printable : virtual public T { +public: + Printable(int param) : T(param) {} + ~Printable() {} + + std::string GetFormatted() { return std::string("The formatted result is: ").append(std::to_string(this->GetResult())); } +}; + +std::shared_ptr > MakePrintableDerived(int param) { + return std::make_shared >(param); +} + +%} + +%shared_ptr(Base); +%shared_ptr(Derived); +%shared_ptr(Printable) + +class Base { +public: + Base(); + Base(int v); + virtual ~Base(); + + virtual int GetResult() = 0; + + int value; +}; + +class Derived : public Base { +public: + Derived(); + Derived(int v); + virtual ~Derived(); + + int GetResult(); +}; + +/* + Contrived for this case (but valid for others, such as if Printable was to be a interface/abstract base class). + Virtual inheritance exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - if the pointer type is incorrect, this will result in + a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access any member inherited from T through a shared_ptr >. +*/ +template class Printable : virtual public T { +public: + Printable(int param); + ~Printable(); + + std::string GetFormatted(); +}; + +std::shared_ptr > MakePrintableDerived(int param); + + +%template(PrintableDerived) Printable; + + diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 2e788fa07..3954b939a 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -52,6 +52,7 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ + cpp11_shared_ptr_template_upcast \ cpp11_shared_ptr_upcast \ cpp11_std_unordered_map \ cpp11_std_unordered_set \ diff --git a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java new file mode 100644 index 000000000..b367fef5e --- /dev/null +++ b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java @@ -0,0 +1,25 @@ + +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate, upcasted shared_ptr type for a template instantiation deriving from a base class. +// In this case, the expected behavior is that given a cptr (underlying type shared_ptr >), PrintableDerived_SWIGSmartPtrUpcast returns a cptr +// (underlying type std::shared_ptr< Derived >). + +import cpp11_shared_ptr_template_upcast.*; + +public class cpp11_shared_ptr_template_upcast_runme { + + static { + try { + System.loadLibrary("cpp11_shared_ptr_template_upcast"); + } 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[]) { + PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20); + pd.GetResult(); + pd.GetFormatted(); + } +} + From 78a1515f4651f032d153e8d4ea8f25c83e97fa0c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Apr 2019 19:39:04 +0100 Subject: [PATCH 1595/2031] OCaml testing requires camlp4 --- configure.ac | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index cc46a6521..133975f7e 100644 --- a/configure.ac +++ b/configure.ac @@ -2044,6 +2044,16 @@ if test x"${with_ocaml}" = xno; then AC_MSG_NOTICE([Disabling OCaml]) OCAMLC= else + # OCaml compiler + if test -z "$OCAMLC"; then + AC_CHECK_PROGS(OCAMLC, ocamlc) + fi + + # OCaml Pre-Processor-Pretty-Printer + if test -z "$CAMLP4"; then + AC_CHECK_PROGS(CAMLP4, camlp4) + fi + # OCaml DL load generator if test -z "$OCAMLDLGEN"; then AC_CHECK_PROGS(OCAMLDLGEN, ocamldlgen) @@ -2054,27 +2064,17 @@ else AC_CHECK_PROGS(OCAMLFIND, ocamlfind) fi - # OCaml compiler - if test -z "$OCAMLC"; then - AC_CHECK_PROGS(OCAMLC, ocamlc) - fi - # OCaml toplevel creator if test -z "$OCAMLMKTOP"; then AC_CHECK_PROGS(OCAMLMKTOP, ocamlmktop) fi - - # OCaml Pre-Processor-Pretty-Printer - if test -z "$CAMLP4"; then - AC_CHECK_PROGS(CAMLP4, camlp4) - fi fi AC_SUBST(OCAMLC) +AC_SUBST(CAMLP4) AC_SUBST(OCAMLDLGEN) AC_SUBST(OCAMLFIND) AC_SUBST(OCAMLMKTOP) -AC_SUBST(CAMLP4) #---------------------------------------------------------------- # Look for C# @@ -2636,7 +2636,7 @@ AC_SUBST(SKIP_PHP) SKIP_OCAML= -if test -z "$OCAMLC" ; then +if test -z "$OCAMLC" || test -z "$CAMLP4" ; then SKIP_OCAML="1" fi AC_SUBST(SKIP_OCAML) From ab7f526805b86726a3c23c853e0ab19458f2c7d9 Mon Sep 17 00:00:00 2001 From: etse Date: Thu, 2 May 2019 13:29:22 -0400 Subject: [PATCH 1596/2031] Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup --- Examples/test-suite/csharp/Makefile.in | 1 + .../cpp11_shared_ptr_template_upcast_runme.cs | 15 +++++++++++++++ .../cpp11_shared_ptr_template_upcast_runme.java | 7 +++---- Source/Modules/csharp.cxx | 11 ++++++----- Source/Modules/java.cxx | 12 ------------ 5 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index c9e48f804..dd87fb6d7 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -33,6 +33,7 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ + cpp11_shared_ptr_template_upcast \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ diff --git a/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs new file mode 100644 index 000000000..e76d2bada --- /dev/null +++ b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs @@ -0,0 +1,15 @@ +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class. +// For this case, the expected behavior is: given a cptr with underlying type shared_ptr >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with +// underlying type std::shared_ptr< Derived >, where Printable inherits from Derived. +using System; +using cpp11_shared_ptr_template_upcastNamespace; + +public class cpp11_shared_ptr_template_upcast_runme +{ + static void Main() + { + PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20); + pd.GetResult(); + pd.GetFormatted(); + } +} diff --git a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java index b367fef5e..2826f580d 100644 --- a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java +++ b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java @@ -1,7 +1,6 @@ - -// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate, upcasted shared_ptr type for a template instantiation deriving from a base class. -// In this case, the expected behavior is that given a cptr (underlying type shared_ptr >), PrintableDerived_SWIGSmartPtrUpcast returns a cptr -// (underlying type std::shared_ptr< Derived >). +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class. +// For this case, the expected behavior is: given a cptr with underlying type shared_ptr >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with +// underlying type std::shared_ptr< Derived >, where Printable inherits from Derived. import cpp11_shared_ptr_template_upcast.*; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ff73c3075..8522fb87c 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1758,21 +1758,22 @@ public: Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); if (smart) { - SwigType *bsmart = Copy(smart); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); + Replaceall(bsmartnamestr, rclassname, rbaseclass); + Delete(rclassname); Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); - Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0ad6cf6c0..da27214e3 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1893,8 +1893,6 @@ public: * ----------------------------------------------------------------------------- */ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { - Swig_warning(0, NULL, NULL, "******************************************\n"); - Swig_warning(0, NULL, NULL, "Smart: %s, Class name: '%s', baseclass: '%s' \n", smart, c_classname, c_baseclass); String *jniname = makeValidJniName(upcast_method_name); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name); @@ -1903,21 +1901,12 @@ public: String *bsmartnamestr = SwigType_namestr(smart); SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_classname(%s): '%s'\n", c_classname, rclassname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_baseclass(%s): '%s'\n", c_baseclass, rbaseclass); - Swig_warning(0, NULL, NULL, "Replaceall - PRE(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); Replaceall(bsmartnamestr, rclassname, rbaseclass); - Swig_warning(0, NULL, NULL, "Replaceall - POST(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); Delete(rclassname); Delete(rbaseclass); - //String *smartnamestr = SwigType_namestr(smart); - //String *bsmartnamestr = SwigType_namestr(bsmart); - Swig_warning(0, NULL, NULL, "bsmartnamestr: '%s', smartnamestr: '%s' \n", bsmartnamestr, smartnamestr); - Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1941,7 +1930,6 @@ public: " return baseptr;\n" "}\n", "\n", NIL); } - Swig_warning(0, NULL, NULL, "******************************************\n"); Delete(wname); Delete(jniname); From be019a03ce7df11a748718fb63d47f35a8c297ec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 19:15:20 +0100 Subject: [PATCH 1597/2031] Appveyor testing - make sure language tests are not mistakenly skipped --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 1eb7ae41d..10bf064df 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -118,6 +118,7 @@ test_script: - if not "%OSVARIANT%"=="" CCache\ccache-swig -V - bash -c "file ./swig.exe" - bash -c "make check-%SWIGLANG%-version" +- bash -c "make check-%SWIGLANG%-enabled" - bash -c "time make -k check-%SWIGLANG%-examples %CHECK_OPTIONS% %CHECK_OPTIONS2%" - bash -c "time make -k check-%SWIGLANG%-test-suite -j%MAKEJOBS% %CHECK_OPTIONS% %CHECK_OPTIONS2%" From 48e61eea1d377c4d45526410c486a81dc47a8c58 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 07:56:42 +0100 Subject: [PATCH 1598/2031] Travis gcc version refactor Use GCC env variable to hold gcc version to install instead of SWIG_CC and SWIG_CXX. --- .travis.yml | 47 +++++++++++++++++------------------ Tools/travis-linux-install.sh | 18 +++----------- Tools/travis-osx-install.sh | 2 ++ 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index 54805092c..9aea6aac0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,11 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG= SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG= GCC=5 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG= SWIG_CC=gcc-6 SWIG_CXX=g++-6 + env: SWIGLANG= GCC=6 sudo: required dist: xenial - compiler: gcc @@ -195,11 +195,11 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 + env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP11=1 PY3=3 VER=3.7 + env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.7 sudo: required dist: xenial - compiler: gcc @@ -268,19 +268,19 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=csharp SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=csharp GCC=5 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=go SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=go GCC=5 CPP11=1 sudo: required dist: trusty - os: linux - env: SWIGLANG=java SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=java GCC=5 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=python GCC=5 CPP11=1 sudo: required dist: xenial - os: linux @@ -288,55 +288,55 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=ruby SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=ruby GCC=5 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=tcl SWIG_CC=gcc-5 SWIG_CXX=g++-5 CPP11=1 + env: SWIGLANG=tcl GCC=5 CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=csharp SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=csharp GCC=6 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=go SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=go GCC=6 CPP14=1 sudo: required dist: trusty - os: linux - env: SWIGLANG=java SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=java GCC=6 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=python GCC=6 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=ruby SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=ruby GCC=6 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=tcl SWIG_CC=gcc-6 SWIG_CXX=g++-6 CPP14=1 + env: SWIGLANG=tcl GCC=6 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=java SWIG_CC=gcc-7 SWIG_CXX=g++-7 CPP14=1 + env: SWIGLANG=java GCC=7 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_CC=gcc-7 SWIG_CXX=g++-7 CPP14=1 + env: SWIGLANG=python GCC=7 CPP14=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=csharp SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 + env: SWIGLANG=csharp GCC=8 CPP17=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=java SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 + env: SWIGLANG=java GCC=8 CPP17=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_CC=gcc-8 SWIG_CXX=g++-8 CPP17=1 PY3=3 VER=3.7 + env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.7 sudo: required dist: xenial - compiler: gcc @@ -400,9 +400,8 @@ before_install: - uname -a - if test "$TRAVIS_OS_NAME" = "linux"; then lscpu && cat /proc/cpuinfo | grep "model name" && cat /proc/meminfo | grep MemTotal; fi - if test "$TRAVIS_OS_NAME" = "osx"; then sysctl -a | grep brand_string; fi - # Travis overrides CC environment with compiler predefined values - - if test -n "$SWIG_CC"; then export CC="$SWIG_CC"; fi - - if test -n "$SWIG_CXX"; then export CXX="$SWIG_CXX"; fi + # Travis overrides CC environment with compiler predefined values + - if test -n "$GCC"; then export CC="gcc-$GCC" && export CXX="g++-$GCC"; fi install: - if test "$TRAVIS_OS_NAME" = "linux"; then source Tools/travis-linux-install.sh; fi - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index b801e2b00..8795229bb 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -1,26 +1,16 @@ #!/bin/bash +# Install Linux packages where the version has been overidden in .travis.yml + set -e # exit on failure (same as -o errexit) lsb_release -a travis_retry sudo apt-get -qq update -if [[ "$CC" == gcc-5 ]]; then +if [[ -n "$GCC" ]]; then travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq g++-5 -elif [[ "$CC" == gcc-6 ]]; then - travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq g++-6 -elif [[ "$CC" == gcc-7 ]]; then - travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq g++-7 -elif [[ "$CC" == gcc-8 ]]; then - travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get install -qq g++-8 + travis_retry sudo apt-get install -qq g++-$GCC fi travis_retry sudo apt-get -qq install libboost-dev diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 6bfb2276a..63a11efa5 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Install MacOS packages where the version has been overidden in .travis.yml + set -e # exit on failure (same as -o errexit) sw_vers From 256446d29043c93e523eedee84b6ecd2b38f0b4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 08:08:05 +0100 Subject: [PATCH 1599/2031] Expand Travis testing of core SWIG compilation to include more gcc versions --- .travis.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9aea6aac0..643ad73ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,37 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG= GCC=5 CPP11=1 + env: SWIGLANG= GCC=4.4 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG= GCC=4.5 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG= GCC=4.6 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG= GCC=4.7 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG= GCC=4.8 sudo: required dist: xenial - os: linux env: SWIGLANG= GCC=6 sudo: required dist: xenial + - os: linux + env: SWIGLANG= GCC=7 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG= GCC=8 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=csharp From 25c0397ec455a62b72d5a09ef8409e9344fd1349 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 18:53:57 +0100 Subject: [PATCH 1600/2031] Travis testing gcc versions gcc-4.5 has package dependency problems Add gcc-4.9 --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 643ad73ab..3213e8b33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,10 +15,6 @@ matrix: env: SWIGLANG= GCC=4.4 sudo: required dist: xenial - - os: linux - env: SWIGLANG= GCC=4.5 - sudo: required - dist: xenial - os: linux env: SWIGLANG= GCC=4.6 sudo: required @@ -31,6 +27,10 @@ matrix: env: SWIGLANG= GCC=4.8 sudo: required dist: xenial + - os: linux + env: SWIGLANG= GCC=4.9 + sudo: required + dist: xenial - os: linux env: SWIGLANG= GCC=6 sudo: required From 00fb2e56292a851ba35299dc5f91fa171475e5ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 19:08:25 +0100 Subject: [PATCH 1601/2031] Travis output optimisation --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3213e8b33..5aa5d7006 100644 --- a/.travis.yml +++ b/.travis.yml @@ -432,10 +432,7 @@ install: - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++17 -Wall -Wextra" "CFLAGS=-std=c17 -Wall -Wextra") && export CSTD=c17 && export CPPSTD=c++17; fi - - ls -la $(which $CC) - - ls -la $(which $CXX) - - $CC --version - - $CXX --version + - ls -la $(which $CC) $(which $CXX) && $CC --version && $CXX --version script: - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi From 4539041c505eda94ac03055e5a6c073376e15f1f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 May 2019 19:16:44 +0100 Subject: [PATCH 1602/2031] Travis output optimisation during configure --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aa5d7006..c572f0f38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -429,12 +429,12 @@ before_install: install: - if test "$TRAVIS_OS_NAME" = "linux"; then source Tools/travis-linux-install.sh; fi - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi - - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++17 -Wall -Wextra" "CFLAGS=-std=c17 -Wall -Wextra") && export CSTD=c17 && export CPPSTD=c++17; fi - ls -la $(which $CC) $(which $CXX) && $CC --version && $CXX --version script: - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' + - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi + - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi + - if test -n "$CPP17"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++17 -Wall -Wextra" "CFLAGS=-std=c17 -Wall -Wextra") && export CSTD=c17 && export CPPSTD=c++17; fi - if test -n "$SWIGLANG"; then CONFIGOPTS+=(--without-alllang --with-$WITHLANG); fi - echo "${CONFIGOPTS[@]}" - ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure "${CONFIGOPTS[@]}" From 997c7a1570f35ecee7fcbe047699ea2cb0ce4efb Mon Sep 17 00:00:00 2001 From: etse Date: Thu, 2 May 2019 18:22:33 -0400 Subject: [PATCH 1603/2031] comments --- Examples/test-suite/cpp11_shared_ptr_template_upcast.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i index 69ffec5bf..38968bb60 100644 --- a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i +++ b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i @@ -68,9 +68,9 @@ public: }; /* - Contrived for this case (but valid for others, such as if Printable was to be a interface/abstract base class). - Virtual inheritance exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - if the pointer type is incorrect, this will result in - a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access any member inherited from T through a shared_ptr >. + Virtual inheritance is contrived for this case, but exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - + if the pointer type is incorrect, this will result in a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access members + inherited from T through a shared_ptr >. */ template class Printable : virtual public T { public: From 0cf01afc54f4435828a3e7901d862ba03c63f353 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Apr 2019 23:51:08 +0100 Subject: [PATCH 1604/2031] Windows documentation minor improvement --- Doc/Manual/Windows.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 301974b64..800e2e420 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -68,7 +68,7 @@ SWIG does not come with the usual Windows type installation program, however it

    -The swigwin distribution contains the SWIG Windows executable, swig.exe, which will run on 32 bit versions of Windows, ie Windows 95 and later. +The swigwin distribution contains the SWIG Windows 32-bit executable, swig.exe, which will run on both 32-bit and 64-bit versions of Windows. If you want to build your own swig.exe have a look at Building swig.exe on Windows.

    From 32c9e2ada8836806e02019a8f3d4e955861fc871 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 4 May 2019 22:31:48 +0100 Subject: [PATCH 1605/2031] Travis testing GCC=5 not needed for xenial. Default compiler is gcc 5 on xenial. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index c572f0f38..a8ccdce75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -292,19 +292,19 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=csharp GCC=5 CPP11=1 + env: SWIGLANG=csharp CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=go GCC=5 CPP11=1 + env: SWIGLANG=go CPP11=1 sudo: required dist: trusty - os: linux - env: SWIGLANG=java GCC=5 CPP11=1 + env: SWIGLANG=java CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=python GCC=5 CPP11=1 + env: SWIGLANG=python CPP11=1 sudo: required dist: xenial - os: linux @@ -312,11 +312,11 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=ruby GCC=5 CPP11=1 + env: SWIGLANG=ruby CPP11=1 sudo: required dist: xenial - os: linux - env: SWIGLANG=tcl GCC=5 CPP11=1 + env: SWIGLANG=tcl CPP11=1 sudo: required dist: xenial - os: linux From 49195c536122e8cd89ea34c7745911a5e7197181 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 4 May 2019 22:47:19 +0100 Subject: [PATCH 1606/2031] Specify Go version to test with c++11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Default version of Go 1.11.1 on Travis is broken for c++11 testing. gcc_libinit.c: In function ‘_cgo_try_pthread_create’: gcc_libinit.c:110:3: error: implicit declaration of function ‘nanosleep’ [-Werror=implicit-function-declaration] nanosleep(&ts, nil); --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a8ccdce75..45266e7fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -296,7 +296,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=go CPP11=1 + env: SWIGLANG=go VER=1.6 CPP11=1 sudo: required dist: trusty - os: linux From f9efe5b5bddc3bb50a8a709525f254e4dbc9820e Mon Sep 17 00:00:00 2001 From: Eric Tse Date: Thu, 25 Apr 2019 15:44:57 -0400 Subject: [PATCH 1607/2031] WIP - Use the non-encoded type string for upcasting a shared_ptr of a derived type to a shared_ptr of the base type --- Source/Modules/java.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index cb41781dd..0ad6cf6c0 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1893,18 +1893,32 @@ public: * ----------------------------------------------------------------------------- */ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { + Swig_warning(0, NULL, NULL, "******************************************\n"); + Swig_warning(0, NULL, NULL, "Smart: %s, Class name: '%s', baseclass: '%s' \n", smart, c_classname, c_baseclass); String *jniname = makeValidJniName(upcast_method_name); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name); if (smart) { - SwigType *bsmart = Copy(smart); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); + Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_classname(%s): '%s'\n", c_classname, rclassname); + SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); + Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_baseclass(%s): '%s'\n", c_baseclass, rbaseclass); + + Swig_warning(0, NULL, NULL, "Replaceall - PRE(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); + Replaceall(bsmartnamestr, rclassname, rbaseclass); + Swig_warning(0, NULL, NULL, "Replaceall - POST(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); + Delete(rclassname); Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); + //String *smartnamestr = SwigType_namestr(smart); + //String *bsmartnamestr = SwigType_namestr(bsmart); + Swig_warning(0, NULL, NULL, "bsmartnamestr: '%s', smartnamestr: '%s' \n", bsmartnamestr, smartnamestr); + + Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", " jlong baseptr = 0;\n" @@ -1917,7 +1931,6 @@ public: "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); - Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1928,6 +1941,8 @@ public: " return baseptr;\n" "}\n", "\n", NIL); } + Swig_warning(0, NULL, NULL, "******************************************\n"); + Delete(wname); Delete(jniname); } From 24f974bb0c4c2fc28f8a36f2050b74ccb857ef1d Mon Sep 17 00:00:00 2001 From: etse Date: Wed, 1 May 2019 17:05:44 -0400 Subject: [PATCH 1608/2031] Adding test case demonstrating issue where SWIG does not generate a correctly typed, upcasted shared_ptr for a template instantiation deriving from a base class --- .../cpp11_shared_ptr_template_upcast.i | 88 +++++++++++++++++++ Examples/test-suite/java/Makefile.in | 1 + ...pp11_shared_ptr_template_upcast_runme.java | 25 ++++++ 3 files changed, 114 insertions(+) create mode 100644 Examples/test-suite/cpp11_shared_ptr_template_upcast.i create mode 100644 Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java diff --git a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i new file mode 100644 index 000000000..69ffec5bf --- /dev/null +++ b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i @@ -0,0 +1,88 @@ +%module cpp11_shared_ptr_template_upcast + +%{ +#include +#include +%} + +%include +%include + +%{ +class Base { +public: + Base() : value(0) {} + Base(int v) : value(v) {} + virtual ~Base() {} + + virtual int GetResult() = 0; + + int value; +}; + +class Derived : public Base { +public: + Derived() : Base() {} + Derived(int v) : Base(v) {} + virtual ~Derived() {} + + int GetResult() { return value*2; } +}; + +template class Printable : virtual public T { +public: + Printable(int param) : T(param) {} + ~Printable() {} + + std::string GetFormatted() { return std::string("The formatted result is: ").append(std::to_string(this->GetResult())); } +}; + +std::shared_ptr > MakePrintableDerived(int param) { + return std::make_shared >(param); +} + +%} + +%shared_ptr(Base); +%shared_ptr(Derived); +%shared_ptr(Printable) + +class Base { +public: + Base(); + Base(int v); + virtual ~Base(); + + virtual int GetResult() = 0; + + int value; +}; + +class Derived : public Base { +public: + Derived(); + Derived(int v); + virtual ~Derived(); + + int GetResult(); +}; + +/* + Contrived for this case (but valid for others, such as if Printable was to be a interface/abstract base class). + Virtual inheritance exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - if the pointer type is incorrect, this will result in + a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access any member inherited from T through a shared_ptr >. +*/ +template class Printable : virtual public T { +public: + Printable(int param); + ~Printable(); + + std::string GetFormatted(); +}; + +std::shared_ptr > MakePrintableDerived(int param); + + +%template(PrintableDerived) Printable; + + diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 2e788fa07..3954b939a 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -52,6 +52,7 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ + cpp11_shared_ptr_template_upcast \ cpp11_shared_ptr_upcast \ cpp11_std_unordered_map \ cpp11_std_unordered_set \ diff --git a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java new file mode 100644 index 000000000..b367fef5e --- /dev/null +++ b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java @@ -0,0 +1,25 @@ + +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate, upcasted shared_ptr type for a template instantiation deriving from a base class. +// In this case, the expected behavior is that given a cptr (underlying type shared_ptr >), PrintableDerived_SWIGSmartPtrUpcast returns a cptr +// (underlying type std::shared_ptr< Derived >). + +import cpp11_shared_ptr_template_upcast.*; + +public class cpp11_shared_ptr_template_upcast_runme { + + static { + try { + System.loadLibrary("cpp11_shared_ptr_template_upcast"); + } 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[]) { + PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20); + pd.GetResult(); + pd.GetFormatted(); + } +} + From 3359b4ccab619c936f9b4adab3e487854bc13ca8 Mon Sep 17 00:00:00 2001 From: etse Date: Thu, 2 May 2019 13:29:22 -0400 Subject: [PATCH 1609/2031] Applying shared_ptr template upcast fix to CSharp, adding CSharp test, and cleanup --- Examples/test-suite/csharp/Makefile.in | 1 + .../cpp11_shared_ptr_template_upcast_runme.cs | 15 +++++++++++++++ .../cpp11_shared_ptr_template_upcast_runme.java | 7 +++---- Source/Modules/csharp.cxx | 11 ++++++----- Source/Modules/java.cxx | 12 ------------ 5 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index c9e48f804..dd87fb6d7 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -33,6 +33,7 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ + cpp11_shared_ptr_template_upcast \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ diff --git a/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs new file mode 100644 index 000000000..e76d2bada --- /dev/null +++ b/Examples/test-suite/csharp/cpp11_shared_ptr_template_upcast_runme.cs @@ -0,0 +1,15 @@ +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class. +// For this case, the expected behavior is: given a cptr with underlying type shared_ptr >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with +// underlying type std::shared_ptr< Derived >, where Printable inherits from Derived. +using System; +using cpp11_shared_ptr_template_upcastNamespace; + +public class cpp11_shared_ptr_template_upcast_runme +{ + static void Main() + { + PrintableDerived pd = cpp11_shared_ptr_template_upcast.MakePrintableDerived(20); + pd.GetResult(); + pd.GetFormatted(); + } +} diff --git a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java index b367fef5e..2826f580d 100644 --- a/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java +++ b/Examples/test-suite/java/cpp11_shared_ptr_template_upcast_runme.java @@ -1,7 +1,6 @@ - -// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate, upcasted shared_ptr type for a template instantiation deriving from a base class. -// In this case, the expected behavior is that given a cptr (underlying type shared_ptr >), PrintableDerived_SWIGSmartPtrUpcast returns a cptr -// (underlying type std::shared_ptr< Derived >). +// This is the cpp11_shared_ptr_template_upcast runtime testcase. It checks that SWIG generates the appropriate upcasted shared_ptr type for a template instantiation deriving from a base class. +// For this case, the expected behavior is: given a cptr with underlying type shared_ptr >, PrintableDerived_SWIGSmartPtrUpcast returns a cptr with +// underlying type std::shared_ptr< Derived >, where Printable inherits from Derived. import cpp11_shared_ptr_template_upcast.*; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ff73c3075..8522fb87c 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1758,21 +1758,22 @@ public: Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); if (smart) { - SwigType *bsmart = Copy(smart); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmart, rclassname, rbaseclass); + Replaceall(bsmartnamestr, rclassname, rbaseclass); + Delete(rclassname); Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" "}\n", "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); - Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0ad6cf6c0..da27214e3 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1893,8 +1893,6 @@ public: * ----------------------------------------------------------------------------- */ void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { - Swig_warning(0, NULL, NULL, "******************************************\n"); - Swig_warning(0, NULL, NULL, "Smart: %s, Class name: '%s', baseclass: '%s' \n", smart, c_classname, c_baseclass); String *jniname = makeValidJniName(upcast_method_name); String *wname = Swig_name_wrapper(jniname); Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name); @@ -1903,21 +1901,12 @@ public: String *bsmartnamestr = SwigType_namestr(smart); SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_classname(%s): '%s'\n", c_classname, rclassname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Swig_warning(0, NULL, NULL, "SwigType_typedef_resolve_all - c_baseclass(%s): '%s'\n", c_baseclass, rbaseclass); - Swig_warning(0, NULL, NULL, "Replaceall - PRE(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); Replaceall(bsmartnamestr, rclassname, rbaseclass); - Swig_warning(0, NULL, NULL, "Replaceall - POST(%s, %s, %s)\n", bsmartnamestr, rclassname, rbaseclass); Delete(rclassname); Delete(rbaseclass); - //String *smartnamestr = SwigType_namestr(smart); - //String *bsmartnamestr = SwigType_namestr(bsmart); - Swig_warning(0, NULL, NULL, "bsmartnamestr: '%s', smartnamestr: '%s' \n", bsmartnamestr, smartnamestr); - Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1941,7 +1930,6 @@ public: " return baseptr;\n" "}\n", "\n", NIL); } - Swig_warning(0, NULL, NULL, "******************************************\n"); Delete(wname); Delete(jniname); From 72097e95b873edfb5f5d4e95511e7addbcc2913b Mon Sep 17 00:00:00 2001 From: etse Date: Thu, 2 May 2019 18:22:33 -0400 Subject: [PATCH 1610/2031] comments --- Examples/test-suite/cpp11_shared_ptr_template_upcast.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i index 69ffec5bf..38968bb60 100644 --- a/Examples/test-suite/cpp11_shared_ptr_template_upcast.i +++ b/Examples/test-suite/cpp11_shared_ptr_template_upcast.i @@ -68,9 +68,9 @@ public: }; /* - Contrived for this case (but valid for others, such as if Printable was to be a interface/abstract base class). - Virtual inheritance exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - if the pointer type is incorrect, this will result in - a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access any member inherited from T through a shared_ptr >. + Virtual inheritance is contrived for this case, but exposes whether SWIGSmartPtrUpcast generated a correctly typed shared pointer of the upcasted class type - + if the pointer type is incorrect, this will result in a segmentation fault (on Windows, this could manifest as undefined behavior) when trying to access members + inherited from T through a shared_ptr >. */ template class Printable : virtual public T { public: From ccbc451c7c3d3ecfd0e2c1f59d184cc919d701e9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 May 2019 19:38:37 +0100 Subject: [PATCH 1611/2031] Disable Travis php 7.2 testing There is a certificate error on the unsupported Ubuntu Trusty machines. Php 7.2 is segfaulting on Ubuntu Xenial, so there is work to be done. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 45266e7fc..b44247baf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -401,6 +401,12 @@ matrix: env: SWIGLANG=tcl allow_failures: + # certificate error on trusty + - compiler: gcc + os: linux + env: SWIGLANG=php VER=7.2 + sudo: required + dist: trusty # Sometimes hits the Travis 50 minute time limit - compiler: gcc os: linux From ed1fabe867cdcf93b83fa6c1cc6e68e4e26db104 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 May 2019 19:42:07 +0100 Subject: [PATCH 1612/2031] Switch php 7.2 testing to xenial --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b44247baf..fc7714992 100644 --- a/.travis.yml +++ b/.travis.yml @@ -167,7 +167,7 @@ matrix: os: linux env: SWIGLANG=php VER=7.2 sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=php VER=7.3 @@ -401,12 +401,12 @@ matrix: env: SWIGLANG=tcl allow_failures: - # certificate error on trusty + # seg fault in director_basic testcase - compiler: gcc os: linux env: SWIGLANG=php VER=7.2 sudo: required - dist: trusty + dist: xenial # Sometimes hits the Travis 50 minute time limit - compiler: gcc os: linux From f06330e720b0867817679fbf67aa8705ce13bbcf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 May 2019 23:05:53 +0100 Subject: [PATCH 1613/2031] Move Scilab Travis testing from trusty to xenial --- .travis.yml | 2 +- Tools/travis-linux-install.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc7714992..bede4a0d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -285,7 +285,7 @@ matrix: os: linux env: SWIGLANG=scilab sudo: required - dist: trusty + dist: xenial - compiler: gcc os: linux env: SWIGLANG=tcl diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 8795229bb..d7d31505f 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -114,6 +114,10 @@ case "$SWIGLANG" in fi ;; "scilab") + # Travis has the wrong version of Java pre-installed resulting in error using scilab: + # /usr/bin/scilab-bin: error while loading shared libraries: libjava.so: cannot open shared object file: No such file or directory + echo "JAVA_HOME was set to $JAVA_HOME" + unset JAVA_HOME travis_retry sudo apt-get -qq install scilab ;; "tcl") From ff19363abf9f9faef2a716efe71b7ed6564e74ad Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Wed, 8 May 2019 15:36:46 -0600 Subject: [PATCH 1614/2031] Add JS Native Wrapper API --- Source/Modules/javascript.cxx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 8c87330b7..e36f31308 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -197,6 +197,11 @@ public: */ virtual int emitWrapperFunction(Node *n); + /** + * Invoked by nativeWrapper callback + */ + virtual int emitNativeFunction(Node *n); + /** * Invoked from constantWrapper after call to Language::constantWrapper. **/ @@ -311,6 +316,7 @@ public: virtual int classHandler(Node *n); virtual int functionWrapper(Node *n); virtual int constantWrapper(Node *n); + virtual int nativeWrapper(Node *n); virtual void main(int argc, char *argv[]); virtual int top(Node *n); @@ -441,6 +447,18 @@ int JAVASCRIPT::constantWrapper(Node *n) { return SWIG_OK; } +/* --------------------------------------------------------------------- + * nativeWrapper() + * + * Function wrapper for generating placeholders for native functions + * --------------------------------------------------------------------- */ + +int JAVASCRIPT::nativeWrapper(Node *n) { + emitter->emitNativeFunction(n); + + return SWIG_OK; +} + /* --------------------------------------------------------------------- * classHandler() * @@ -768,6 +786,17 @@ int JSEmitter::emitWrapperFunction(Node *n) { return ret; } +int JSEmitter::emitNativeFunction(Node *n) { + String *wrap_name = Getattr(n, "wrap:name"); + + Setattr(n, "feature:extend", "last"); + enterFunction(n); + state.function(WRAPPER_NAME, wrap_name); + exitFunction(n); + + return SWIG_OK; +} + int JSEmitter::enterClass(Node *n) { state.clazz(RESET); state.clazz(NAME, Getattr(n, "sym:name")); From 17218b74ef81b21baa703df4ce3149250d409c31 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Wed, 8 May 2019 15:51:08 -0600 Subject: [PATCH 1615/2031] Update JavaScript Documentation --- Doc/Manual/Javascript.html | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 417ee4585..0b301377c 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -163,7 +163,6 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
  • Multiple output arguments do not work for JSC

  • C89 incompatibility: the JSC generator might still generate C89 violating code

  • long long is not supported

  • -
  • %native is not supported

  • Javascript callbacks are not supported

  • instanceOf does not work under JSC

  • From f16350e774467d58bb31df42f626738fbaed0092 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Wed, 8 May 2019 17:45:05 -0600 Subject: [PATCH 1616/2031] Add Native Directive Example --- Examples/javascript/native/Makefile | 3 + Examples/javascript/native/binding.gyp.in | 9 +++ Examples/javascript/native/example.i | 92 +++++++++++++++++++++++ Examples/javascript/native/example.js | 1 + Examples/javascript/native/index.html | 31 ++++++++ Examples/javascript/native/runme.js | 5 ++ 6 files changed, 141 insertions(+) create mode 100644 Examples/javascript/native/Makefile create mode 100644 Examples/javascript/native/binding.gyp.in create mode 100644 Examples/javascript/native/example.i create mode 100644 Examples/javascript/native/example.js create mode 100644 Examples/javascript/native/index.html create mode 100644 Examples/javascript/native/runme.js diff --git a/Examples/javascript/native/Makefile b/Examples/javascript/native/Makefile new file mode 100644 index 000000000..0402f8d09 --- /dev/null +++ b/Examples/javascript/native/Makefile @@ -0,0 +1,3 @@ +SRCS = + +include $(SRCDIR)../example.mk diff --git a/Examples/javascript/native/binding.gyp.in b/Examples/javascript/native/binding.gyp.in new file mode 100644 index 000000000..59779aef4 --- /dev/null +++ b/Examples/javascript/native/binding.gyp.in @@ -0,0 +1,9 @@ +{ + "targets": [ + { + "target_name": "example", + "sources": [ "example_wrap.cxx" ], + "include_dirs": ["$srcdir"] + } + ] +} diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i new file mode 100644 index 000000000..73582462e --- /dev/null +++ b/Examples/javascript/native/example.i @@ -0,0 +1,92 @@ +/* File : example.i */ +%module example + + +%wrapper +%{ +#include +#include + +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) +# define V8_RETURN(val) return scope.Close(val) +#else +# define V8_RETURN(val) args.GetReturnValue().Set(val); return +#endif +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) +# define V8_UNDEFINED() v8::Undefined() +#else +# define V8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent()) +#endif + + +// 'unused' attribute only necessary for GNUC < v3.4 +static /* __attribute__ ((__unused__)) */ V8ErrorHandler V8_ErrorHandler; + + +typedef struct worker_packet { + // -- basic -- + uv_work_t request; + v8::Persistent callback; + // -- persistent variables -- + std::string result; + // -- async operation -- + void (*execute)(std::string&); +} worker_packet; + + +// async process - parallel with node thread +static void work_async(uv_work_t* request) { + worker_packet* packet = static_cast(request->data); + packet->execute(packet->result); + // add a delay for dramatic effect - not necessary +} + + +// send async result back to node's thread +static void work_complete(uv_work_t* request, int status) { + v8::Isolate* iso = v8::Isolate::GetCurrent(); + v8::HandleScope scope(iso); + worker_packet* packet = static_cast(request->data); + const int argc = 1; + v8::Handle argv[] = { + v8::String::NewFromUtf8(iso, packet->result.c_str()) + }; + v8::Local::New(iso, packet->callback)->Call + (iso->GetCurrentContext()->Global(), argc, argv); + packet->callback.Reset(); + delete work; +} + + +static void entry(const v8::FunctionCallbackInfo& args) { + v8::Isolate* iso = v8::Isolate::GetCurrent(); + v8::Local value = args[0]; + if (!value->IsFunction()) { + V8_ErrorHandler.error((-1), "Invalid parameter type."); + return; + } + worker_packet* packet = new worker_packet(); + packet->request.data = packet; + packet->execute = [](std::string& res) { res = "My delayed message."; }; + v8::Local callback = v8::Local::Cast(value); + packet->callback.Reset(iso, callback); + uv_queue_work(uv_default_loop(), &packet->request, + work_async, work_complete); + args.GetReturnValue().Set(Undefined(iso)); +} + + +void JavaScript_exampleV8_callback_function(const v8::Arguments& args) { + v8::HandleScope scope + if (args.Length() != 1) { + V8_ErrorHandler.error((-1), "Illegal number of arguments."); + V8_RETURN(V8_UNDEFINED()); + } + entry(args); + v8::Handle jsresult = V8_UNDEFINED(); + V8_RETURN(jsresult); +} +%} + + +%native(num_to_string) void JavaScript_exampleV8_callback_function(); diff --git a/Examples/javascript/native/example.js b/Examples/javascript/native/example.js new file mode 100644 index 000000000..2e7f83a06 --- /dev/null +++ b/Examples/javascript/native/example.js @@ -0,0 +1 @@ +module.exports = require("build/Release/example"); diff --git a/Examples/javascript/native/index.html b/Examples/javascript/native/index.html new file mode 100644 index 000000000..7c7d6b071 --- /dev/null +++ b/Examples/javascript/native/index.html @@ -0,0 +1,31 @@ + + +SWIG:Examples:javascript:native + + + + + +SWIG/Examples/javascript/native/ +
    + +

    Manually wrapped callback function in JavaScript

    + +

    +This example demonstrates how to manually add callback feature support to a SWIG module. +

    + +
      +
    • example.i. Interface file containing the API function and async behind-the-scenes functions. +
    • runme.js. Sample JavaScript program showing the API function being called with a callback function parameter. +
    + +

    Notes

    + +The V8 code queues the callback request for processing using the UV interface. An async function callback is invoked when the system is ready to process the next request. When the async function finishes, a completion function callback is invoked to finalize the request. Here the callback function parameter is invoked. +

    +UV request queueing is only necessary for operations that would take a really long or otherwise unpredictable amount of time (async operations). A callback parameter could also be invoked immediately within the API function. + +
    + + diff --git a/Examples/javascript/native/runme.js b/Examples/javascript/native/runme.js new file mode 100644 index 000000000..6577bb1fb --- /dev/null +++ b/Examples/javascript/native/runme.js @@ -0,0 +1,5 @@ +var example = require("example"); + +function callback(msg) { console.log(msg); } + +example.num_to_string(callback); From 3ccc904b066d669ab5a901bc74b0f08fee372c83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 May 2019 07:35:24 +0100 Subject: [PATCH 1617/2031] Fix php pragmas example include path Was not working for out of source builds --- Examples/php/pragmas/example.i | 4 ++-- Examples/php/pragmas/include.php | 2 +- Examples/php/pragmas/runme.php | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Examples/php/pragmas/example.i b/Examples/php/pragmas/example.i index b72828b0e..ea9590b6f 100644 --- a/Examples/php/pragmas/example.i +++ b/Examples/php/pragmas/example.i @@ -21,11 +21,11 @@ zend_printf("This was %%rshutdown\n"); } -%pragma(php) include="./include.php"; +%pragma(php) include="include.php"; %pragma(php) code=" # This code is inserted into example.php -echo \"this was php code\\n\"; +echo \"This was php code\\n\"; " %pragma(php) version="1.5" diff --git a/Examples/php/pragmas/include.php b/Examples/php/pragmas/include.php index e19880a06..11d985d66 100644 --- a/Examples/php/pragmas/include.php +++ b/Examples/php/pragmas/include.php @@ -1,7 +1,7 @@ diff --git a/Examples/php/pragmas/runme.php b/Examples/php/pragmas/runme.php index b99cf37a4..7b2c179cb 100644 --- a/Examples/php/pragmas/runme.php +++ b/Examples/php/pragmas/runme.php @@ -1,6 +1,9 @@ getVersion()); +echo "Version - " . ((new ReflectionExtension('example'))->getVersion()) . "\n"; ?> From 6a127b75f104567e33f57f24ea932d4d4ba19bd8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 May 2019 07:41:17 +0100 Subject: [PATCH 1618/2031] Travis Go testing moved to xenial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default Go 1.11 version on Travis doesn't work with C++11/C++14: gcc_libinit.c:110:3: error: implicit declaration of function ‘nanosleep’ so switch to another gimme version of Go. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bede4a0d1..6879e9b5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -298,7 +298,7 @@ matrix: - os: linux env: SWIGLANG=go VER=1.6 CPP11=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=java CPP11=1 sudo: required @@ -324,9 +324,9 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=go GCC=6 CPP14=1 + env: SWIGLANG=go VER=1.6 GCC=6 CPP14=1 sudo: required - dist: trusty + dist: xenial - os: linux env: SWIGLANG=java GCC=6 CPP14=1 sudo: required From 19d284a8966ac79c875771b038ae94592475fdd2 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Thu, 9 May 2019 11:54:12 -0600 Subject: [PATCH 1619/2031] JS Example Campatibility Update --- Examples/javascript/native/example.i | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i index 73582462e..1d0d2e808 100644 --- a/Examples/javascript/native/example.i +++ b/Examples/javascript/native/example.i @@ -7,16 +7,28 @@ #include #include + #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) -# define V8_RETURN(val) return scope.Close(val) + typedef v8::Handle V8ReturnValue; + typedef v8::Arguments V8Arguments; +# define V8_RETURN(val) return scope.Close(val) #else -# define V8_RETURN(val) args.GetReturnValue().Set(val); return + typedef void V8ReturnValue; + typedef v8::FunctionCallbackInfo V8Arguments; +# define V8_RETURN(val) args.GetReturnValue().Set(val); return #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) # define V8_UNDEFINED() v8::Undefined() #else # define V8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent()) #endif +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117) +# define V8_HANDLESCOPE() v8::HandleScope scope +#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224) +# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); +#else +# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); +#endif // 'unused' attribute only necessary for GNUC < v3.4 @@ -44,8 +56,8 @@ static void work_async(uv_work_t* request) { // send async result back to node's thread static void work_complete(uv_work_t* request, int status) { + V8_HANDLESCOPE(); v8::Isolate* iso = v8::Isolate::GetCurrent(); - v8::HandleScope scope(iso); worker_packet* packet = static_cast(request->data); const int argc = 1; v8::Handle argv[] = { @@ -58,7 +70,7 @@ static void work_complete(uv_work_t* request, int status) { } -static void entry(const v8::FunctionCallbackInfo& args) { +static void entry(const V8Arguments& args) { v8::Isolate* iso = v8::Isolate::GetCurrent(); v8::Local value = args[0]; if (!value->IsFunction()) { @@ -76,8 +88,8 @@ static void entry(const v8::FunctionCallbackInfo& args) { } -void JavaScript_exampleV8_callback_function(const v8::Arguments& args) { - v8::HandleScope scope +V8ReturnValue JavaScript_exampleV8_callback_function(const V8Arguments& args) { + V8_HANDLESCOPE(); if (args.Length() != 1) { V8_ErrorHandler.error((-1), "Illegal number of arguments."); V8_RETURN(V8_UNDEFINED()); From 2a8cb127ecea54f09d3a8607175ae9c5dd845537 Mon Sep 17 00:00:00 2001 From: TekuConcept Date: Thu, 9 May 2019 11:56:08 -0600 Subject: [PATCH 1620/2031] Add JS Native Directive Testcase --- Examples/test-suite/native_directive.i | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i index d08c9a954..39b9856a0 100644 --- a/Examples/test-suite/native_directive.i +++ b/Examples/test-suite/native_directive.i @@ -41,3 +41,33 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co %} #endif + +#if defined(SWIG_V8_VERSION) +%{ +static SwigV8ReturnValue wrap_alpha_count(const SwigV8Arguments &args) { + SWIGV8_HANDLESCOPE(); + v8::Handle jsresult; + char *arg1 = (char *) 0 ; + int res1 ; + char *buf1 = 0 ; + int alloc1 = 0 ; + int result; + if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, + "Illegal number of arguments for _wrap_count_characters."); + res1 = SWIG_AsCharPtrAndSize(args[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "count_characters" + "', argument " "1"" of type '" "char const *""'"); + } + arg1 = reinterpret_cast< char * >(buf1); + result = (int)count_characters((char const *)arg1); + jsresult = SWIG_From_int(static_cast< int >(result)); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + SWIGV8_RETURN(jsresult); +fail: + SWIGV8_RETURN(SWIGV8_UNDEFINED()); +} +%} +%native(CountAlphaCharacters) void wrap_alpha_count(); +#endif + From 1dd5d50c9992716a37bfd760f0e7706ce459fef1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 1 Mar 2019 23:11:13 +1300 Subject: [PATCH 1621/2031] Fix details of ZEND_MODULE_GLOBALS_ACCESSOR change This is actually needed when using a ZTS build of any PHP 7.x release, nothing specific to PHP 7.2 at all. --- CHANGES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 77d570ddb..7fd6b6da2 100644 --- a/CHANGES +++ b/CHANGES @@ -939,8 +939,8 @@ Version 4.0.0 (27 Apr 2019) returning pointers by reference. 2017-12-08: olly - [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this - should make the generated code work with PHP 7.2.0. + [PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals so the + generated code builds when PHP was built with ZTS enabled. 2017-12-04: wsfulton [Python] Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a From e87811223c39adb0daad7ccd441a550ebff3eef0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 22 May 2019 11:13:55 +1200 Subject: [PATCH 1622/2031] [php] Update docs about undefined constants PHP 7.2 made these a warning instead of just a notice, and apparently it will throw an Error in a future version of PHP. --- Doc/Manual/Php.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index d80731c5c..d0ec0df7f 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -231,10 +231,12 @@ echo "E = " . E . "\n";

    There's one peculiarity of how constants work in PHP which it is useful to note (this is not specific to SWIG though) - if you try to use an undeclared -constant, PHP will emit a notice and then expand the constant to a string -version of the constant's name. Unfortunately it is easy to miss the notice -if you're using PHP in a webserver, as it will probably end up in error.log or -similar. +constant, PHP will emit a warning (or a notice in PHP 7.1 and earlier) and then +expand the constant to a string version of the constant's name. Unfortunately +it is easy to miss the warning message if you're using PHP in a webserver as +it will probably end up in error.log or similar. Apparently this will throw +an Error in a future version of PHP, but until then it's something to be +aware of.

    @@ -268,8 +270,7 @@ if(EASY_TO_MISPEL) {

    The mis-spelled constant will become the string 'EASY_TO_MISPEL', which is treated as true by the if test, when the value of the intended constant -would be treated as false! Modern versions of PHP will at least issue -a PHP notice by default when this happens. +would be treated as false!

    31.2.2 Global Variables

    From b3a3c4f09e160432072f3dc770efe0443556da9a Mon Sep 17 00:00:00 2001 From: Frederik Schubert Date: Thu, 2 May 2019 17:43:09 +0200 Subject: [PATCH 1623/2031] Don't add a closing php-tag This PR removes the closing `?>` PHP tag from generated files. [PSR-2](https://www.php-fig.org/psr/psr-2/) states: > The closing `?>` tag MUST be omitted from files containing only PHP. A problem might occur if files with any character after the closing tag are used with `include` or `require`. It might trigger an output and disallow HTTP header manipulation. See the popular [_headers already sent_](https://stackoverflow.com/a/8028987/1847340) debate on SO. --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 994fbd7de..b192d6f6e 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -676,7 +676,7 @@ public: Delete(s_fakeoowrappers); s_fakeoowrappers = NULL; } - Printf(f_phpcode, "%s\n?>\n", s_phpclasses); + Printf(f_phpcode, "%s\n", s_phpclasses); Delete(f_phpcode); return SWIG_OK; From 8cae5989b2c94ec7c2c1b317c5f9627b576e9ab4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 22 May 2019 11:38:10 +1200 Subject: [PATCH 1624/2031] Add CHANGES entry for previous commit Closes https://github.com/swig/swig/pull/1528 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 06373dbea..5d60b48c3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,3 +7,6 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-05-22: ferdynator + [PHP] #1528 Don't add a closing '?>' PHP tag to generated files. + PSR-2 says it MUST be omitted for files containing only PHP. From e23ae76159745152898e634513ead6045d747240 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 May 2019 19:31:40 +0100 Subject: [PATCH 1625/2031] Ruby 1.9 and later testing on Travis xenial There were (a few) failures using 1.8.7, so document 1.9 and later as working in SWIG 4.0. Trusty failure in 2.3.0 was fixed in later versions of Ruby 2.3.x (expansion of RARRAY_PTR). --- .travis.yml | 33 +++++++++++++++++++++++++++++---- Doc/Manual/Ruby.html | 2 +- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6879e9b5d..f9c92b95a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -268,19 +268,44 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=ruby VER=1.9.3 + env: SWIGLANG=ruby VER=1.9 sudo: required dist: xenial - compiler: gcc os: linux - env: SWIGLANG=ruby VER=2.0.0 + env: SWIGLANG=ruby VER=2.0 sudo: required dist: xenial - compiler: gcc os: linux - env: SWIGLANG=ruby VER=2.3.0 + env: SWIGLANG=ruby VER=2.1 sudo: required - dist: trusty + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.2 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.3 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.4 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.5 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.6 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=scilab diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index aa4212667..3cfd1292c 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -152,7 +152,7 @@

    34.1 Preliminaries

    -

    SWIG 3.0 is known to work with Ruby versions 1.8 and later. +

    SWIG 4.0 is known to work with Ruby versions 1.9 and later. Given the choice, you should use the latest stable version of Ruby. You should also determine if your system supports shared libraries and dynamic loading. SWIG will work with or without dynamic loading, but From ae7c04e2048f0da858a6a1f806d37ff427bd980a Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Sat, 27 Apr 2019 08:46:19 -0600 Subject: [PATCH 1626/2031] Adapt OCTAVE_LDFLAGS for Octave 5.1 --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 133975f7e..2c9c338da 100644 --- a/configure.ac +++ b/configure.ac @@ -1114,7 +1114,10 @@ if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= - for var in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do + for var in OCTLIBDIR; do + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "-L`env - ${mkoctfile} -p ${var}` + done + for var in RDYNAMIC_FLAG RLD_FLAG OCTAVE_LIBS LIBS; do OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`env - ${mkoctfile} -p ${var}` done AC_MSG_RESULT([$OCTAVE_LDFLAGS]) From 6489730892ff376d64deb9c5dff09407a58284ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 11 May 2019 18:53:25 +0100 Subject: [PATCH 1627/2031] Fix Octave detection for non-GNU sed on MacOS --- configure.ac | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 2c9c338da..543274359 100644 --- a/configure.ac +++ b/configure.ac @@ -1058,23 +1058,33 @@ if test -n "$OCTAVE"; then AS_IF([test "x`${OCTAVE} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/Octave, version/p'`" != x],[ AC_MSG_RESULT([yes]) ],[ - AC_MSG_NOTICE([no, disabling Octave]) + AC_MSG_NOTICE([no]) OCTAVE= ]) fi # Check for required Octave helper program "mkoctfile" if test -n "$OCTAVE"; then - AC_MSG_CHECKING([for mkoctfile]) - mkoctfile=["`echo $OCTAVE | sed -e 's|[a-z][a-z-]*$|mkoctfile|;t;s|[a-z][a-z-]*\(-[0-9][0-9.+]*\)$|mkoctfile\1|;t'`"] - AC_MSG_RESULT([${mkoctfile}]) - AC_MSG_CHECKING([if ${mkoctfile} works]) - AS_IF([test "x`${mkoctfile} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/mkoctfile, version/p'`" != x],[ + AC_MSG_CHECKING([for mkoctfile]) + version_suffix=["`echo $OCTAVE | sed -e 's|.*\(-[0-9][0-9.]*\)$|\1|'`"] + case $version_suffix in + -*) ;; + *) version_suffix="" ;; + esac + octave_directory=`dirname $OCTAVE` + if test "$octave_directory" = "." ; then + mkoctfile="mkoctfile${version_suffix}" + else + mkoctfile="${octave_directory}/mkoctfile${version_suffix}" + fi + AC_MSG_RESULT([${mkoctfile}]) + AC_MSG_CHECKING([if ${mkoctfile} works]) + AS_IF([test "x`${mkoctfile} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/mkoctfile, version/p'`" != x],[ AC_MSG_RESULT([yes]) - ],[ - AC_MSG_NOTICE([no, disabling Octave]) + ],[ + AC_MSG_RESULT([no]) OCTAVE= - ]) + ]) fi # Check for Octave preprocessor/compiler/linker flags From 2cd59b636e6da442cf6bc9dc8c09aa9f33df2a51 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 May 2019 19:27:47 +0100 Subject: [PATCH 1628/2031] Travis Octave testing changes - Keep testing Octave 4.0 on Xenial, but the Octave headers break the C++11 tests, so just test C++98. - Drop Octave 4.2 testing on Trusty. - Keep Octave 4.4 testing on Trusty - it is the only C++11 Octave testing done and is just fast enough to beat the 50 minute limit. - Add latest Octave version (5.1) testing by using MacOS and brew. It takes about 49 minutes to run for C++98 testing. Unfortunately it takes longer than the Travis 50 minute limit to test C++11. I can't find a Xenial or MacOS solution for testing Octave and C++11, so we'll keep it on Travis for now. Octave is available as a Flatpak's, but Flatpak doesn't work on Travis as it requires a reboot after installing the flatpak package. --- .travis.yml | 26 +++++++++++--------------- Tools/travis-osx-install.sh | 3 +++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index f9c92b95a..fe9a615c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -138,16 +138,6 @@ matrix: env: SWIGLANG=octave SWIGJOBS=-j2 sudo: required dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.2 CPP11=1 - sudo: required - dist: trusty - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 - sudo: required - dist: trusty - compiler: gcc os: linux env: SWIGLANG=perl5 @@ -328,6 +318,11 @@ matrix: env: SWIGLANG=java CPP11=1 sudo: required dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 + sudo: required + dist: trusty - os: linux env: SWIGLANG=python CPP11=1 sudo: required @@ -409,6 +404,9 @@ matrix: - compiler: clang os: osx env: SWIGLANG=lua + - compiler: clang + os: osx + env: SWIGLANG=octave SWIGJOBS=-j2 - compiler: clang os: osx env: SWIGLANG=perl5 @@ -433,11 +431,9 @@ matrix: sudo: required dist: xenial # Sometimes hits the Travis 50 minute time limit - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 - sudo: required - dist: trusty + - compiler: clang + os: osx + env: SWIGLANG=octave SWIGJOBS=-j2 # Experimental languages - compiler: gcc os: linux diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 63a11efa5..1cf73c5c0 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -22,6 +22,9 @@ case "$SWIGLANG" in "lua") travis_retry brew install lua ;; + "octave") + travis_retry brew install octave + ;; "python") WITHLANG=$SWIGLANG$PY3 if [[ "$PY3" ]]; then From 9829bdf5b1c0eaae2f7b4941db5d33c35f461a63 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 May 2019 19:36:36 +0100 Subject: [PATCH 1629/2031] Add Octave detection fixes to changes file --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 5d60b48c3..80570a155 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-05-24: wsfulton + [Octave] Fix detection of Octave on MacOS. + +2019-05-24: opoplawski + [Octave] #1522 Adapt OCTAVE_LDFLAGS for Octave 5.1. + 2019-05-22: ferdynator [PHP] #1528 Don't add a closing '?>' PHP tag to generated files. PSR-2 says it MUST be omitted for files containing only PHP. From e62c88883fbc9f8c5b53bc98a9d8bb0d9def5ac4 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Thu, 23 May 2019 20:01:09 -0500 Subject: [PATCH 1630/2031] Fix python doxygen indentation for inline \code command If \code was used inline, it produced an extra indent versus block usage. This extra indent was also stored in the test output. This update resolves this by simply removing a space that was being added unnecessarily in handleTagVerbatim. Updating test case output accordingly. --- Examples/test-suite/python/doxygen_translate_all_tags_runme.py | 2 +- Examples/test-suite/python/doxygen_translate_runme.py | 2 +- Source/Doxygen/pydoc.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 53d087e69..e269b8c18 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -37,7 +37,7 @@ Not everything works right now... .. code-block:: c++ - some test code""") + some test code""") comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func02), r"""Conditional comment: SOMECONDITION diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 2d0840a1f..50292e30c 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -23,7 +23,7 @@ Author: Zubr .. code-block:: c++ - some test code + some test code Conditional comment: SOMECONDITION diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index fc3b0ea09..5dff07df2 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -519,7 +519,7 @@ void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translat } void PyDocConverter::handleTagVerbatim(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { - translatedComment += arg + " "; + translatedComment += arg; for (DoxygenEntityListCIt it = tag.entityList.begin(); it != tag.entityList.end(); it++) { translatedComment += it->data; } From 3d64a2c03760b0c955cfb6d4b3c17444bfd4c83a Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 13:14:14 -0500 Subject: [PATCH 1631/2031] Remove extra newline in beginning of doxygen python \code command If \code is used as a block command (probably the main use case), an extra newline was included in the translated Python comments. This is now removed and doxygen python test case output updated. --- Examples/test-suite/python/doxygen_basic_translate_runme.py | 1 - Source/Doxygen/pydoc.cxx | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index e664e06f6..585783d16 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -49,7 +49,6 @@ Warning: This may not work as expected .. code-block:: c++ - int main() { while(true); } }""" diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 5dff07df2..fe918b0ab 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -493,6 +493,11 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme std::string code; handleTagVerbatim(tag, code, arg); + // Try and remove leading newline, which is present for block \code + // command: + if (code[0] == '\n') + code.erase(code.begin()); + translatedComment += codeIndent; for (size_t n = 0; n < code.length(); n++) { if (code[n] == '\n') { From 321cb096a88d6cbb9a6709d7304b0134624d3181 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 13:40:59 -0500 Subject: [PATCH 1632/2031] Remove extra newline from end of doxygen python \code command Remove the extra newline at the end of translation of doxygen \code \endcode command for Python. Update test output accordingly. --- .../test-suite/python/doxygen_basic_translate_runme.py | 1 - Examples/test-suite/python/doxygen_translate_runme.py | 1 - Source/Doxygen/pydoc.cxx | 10 +++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 585783d16..b6023224d 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -50,7 +50,6 @@ Warning: This may not work as expected .. code-block:: c++ int main() { while(true); } - }""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5), diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 50292e30c..8af5953d1 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -25,7 +25,6 @@ Author: Zubr some test code - Conditional comment: SOMECONDITION Some conditional comment End of conditional comment. diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index fe918b0ab..736e09458 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -495,7 +495,7 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // Try and remove leading newline, which is present for block \code // command: - if (code[0] == '\n') + if ((! code.empty()) && code[0] == '\n') code.erase(code.begin()); translatedComment += codeIndent; @@ -515,8 +515,12 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme } trimWhitespace(translatedComment); - if (*translatedComment.rbegin() != '\n') - translatedComment += '\n'; + + // For block commands, the translator adds the newline after + // \endcode, so try and compensate by removing the last newline from + // the code text: + if ((! translatedComment.empty()) && translatedComment[translatedComment.size()-1] == '\n') + translatedComment = translatedComment.substr(0, translatedComment.size()-1); // use translatedComment.pop_back() in C++ 11 } void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { From c52bed2e668166ab661de20e2147e56d24ca3d2b Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 14:15:44 -0500 Subject: [PATCH 1633/2031] Eliminate extra newlines in doxygen python \verbatim blocks Eliminate extra leading and trailing newlines present in translated doxygen \verbatim comments for python. Updating doxygen python tests accordingly. --- .../python/doxygen_translate_all_tags_runme.py | 2 -- .../test-suite/python/doxygen_translate_runme.py | 2 -- Source/Doxygen/pydoc.cxx | 15 ++++++++++++++- Source/Doxygen/pydoc.h | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index e269b8c18..7cf09fb56 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -283,13 +283,11 @@ r"""TODO: Some very important task - very long text with tags - Version: 0.0.0.2 Warning: This is senseless! diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 8af5953d1..7d127454b 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -120,11 +120,9 @@ TODO: Some very important task :type b: float :param b: B is mentioned again... - very long text with tags - Version: 0.0.0.2 Warning: This is senseless! diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 736e09458..31ec972d6 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -219,7 +219,7 @@ void PyDocConverter::fillStaticTables() { tagHandlers["short"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["todo"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["version"] = make_handler(&PyDocConverter::handleParagraph); - tagHandlers["verbatim"] = make_handler(&PyDocConverter::handleParagraph); + tagHandlers["verbatim"] = make_handler(&PyDocConverter::handleVerbatimBlock); tagHandlers["warning"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["xmlonly"] = make_handler(&PyDocConverter::handleParagraph); // these commands have special handlers @@ -419,6 +419,19 @@ void PyDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translated translatedComment += translateSubtree(tag); } +void PyDocConverter::handleVerbatimBlock(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { + string verb = translateSubtree(tag); + + if ((! verb.empty()) && verb[0] == '\n') + verb.erase(verb.begin()); + + // Remove the last newline to prevent doubling the newline already present after \endverbatim + trimWhitespace(verb); // Needed to catch trailing newline below + if ((! verb.empty()) && verb[verb.size()-1] == '\n') + verb = verb.substr(0, verb.size()-1); + translatedComment += verb; +} + void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg) { IndentGuard indent; diff --git a/Source/Doxygen/pydoc.h b/Source/Doxygen/pydoc.h index 8f432fd18..df8997d76 100644 --- a/Source/Doxygen/pydoc.h +++ b/Source/Doxygen/pydoc.h @@ -79,6 +79,11 @@ protected: */ void handleParagraph(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string()); + /* + * Handle Doxygen verbatim tag + */ + void handleVerbatimBlock(DoxygenEntity &tag, std::string &translatedComment, const std::string &arg = std::string()); + /* * Handle one of the Doxygen formula-related tags. */ From 08fc4a02b4df7f4a53b375e37820c88b375fe9a8 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 14:33:41 -0500 Subject: [PATCH 1634/2031] Eliminate extra newlines around doxygen python block math Eliminate extra leading and trailing newlines around the \f[ and \f{ block math commands for doxygen comment translation for python. Update tests accordingly. --- .../test-suite/python/doxygen_translate_all_tags_runme.py | 4 ---- Source/Doxygen/pydoc.cxx | 3 --- 2 files changed, 7 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 7cf09fb56..78bf73870 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -90,13 +90,10 @@ r""":raises: SuperError :math:`\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}` - .. math:: \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} - - .. math:: \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} @@ -111,7 +108,6 @@ r""":raises: SuperError - This will only appear in hmtl""") comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func05), diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 31ec972d6..688318dd9 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -446,7 +446,6 @@ void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComme indent.Init(translatedComment, m_indent); trimWhitespace(translatedComment); - translatedComment += '\n'; const string formulaIndent = indent.getFirstLineIndent(); translatedComment += formulaIndent; @@ -480,8 +479,6 @@ void PyDocConverter::handleMath(DoxygenEntity &tag, std::string &translatedComme if (inlineFormula) { translatedComment += "`"; - } else { - translatedComment += '\n'; } } From 98ae66b6fcaaee19f62141bb3c30de0ae6ff7cca Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 15:12:05 -0500 Subject: [PATCH 1635/2031] Fix bug in doxygen python code block indent If a certain doxygen comment style was used that included an additional space, then translated Python comment code block indent was not correct (it included the extra space). This doxygen comment style was not previously represented in the test cases; a new test case will be added in a subsequent commit. --- Source/Doxygen/pydoc.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 688318dd9..3eb855058 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -498,7 +498,7 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme translatedComment += ".. code-block:: c++\n\n"; // For now on, use extra indent level for all the subsequent lines. - codeIndent += m_indent; + codeIndent = m_indent; std::string code; handleTagVerbatim(tag, code, arg); From 91a90b8d27e759d5504bc3be72a300fe4c68b8ad Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 11:34:15 -0500 Subject: [PATCH 1636/2031] Adding test for second doxygen comment style This style looks like: /** Line 1 * Line 2 */ This is needed to verify fixes to some of the indentation in the translated comments. The test is copied from doxygen_basic_translate.i. One adjustment was made to change the comment style on the last function that left out the intermediate "*" characters. This does not produce correct output when combined with this style of starting the text on the first comment line. Test results are copied directly from doxygen_basic_translate. A minor difference in the Python results will be updated in a subsequent commit. --- Examples/test-suite/common.mk | 1 + .../doxygen_basic_translate_style2.i | 105 ++++++++++++++++++ .../doxygen_basic_translate_style2_runme.java | 99 +++++++++++++++++ .../doxygen_basic_translate_style2_runme.py | 82 ++++++++++++++ 4 files changed, 287 insertions(+) create mode 100644 Examples/test-suite/doxygen_basic_translate_style2.i create mode 100644 Examples/test-suite/java/doxygen_basic_translate_style2_runme.java create mode 100644 Examples/test-suite/python/doxygen_basic_translate_style2_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 67a63287d..eece29b00 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -620,6 +620,7 @@ DOXYGEN_TEST_CASES += \ doxygen_alias \ doxygen_basic_notranslate \ doxygen_basic_translate \ + doxygen_basic_translate_style2 \ doxygen_ignore \ doxygen_misc_constructs \ doxygen_nested_class \ diff --git a/Examples/test-suite/doxygen_basic_translate_style2.i b/Examples/test-suite/doxygen_basic_translate_style2.i new file mode 100644 index 000000000..23e8de4f7 --- /dev/null +++ b/Examples/test-suite/doxygen_basic_translate_style2.i @@ -0,0 +1,105 @@ +%module doxygen_basic_translate_style2 + +%include "doxygen_basic_translate.h" + +// This test demonstrates a doxygen comment style that starts on the +// first line and so uses extra spacing in subsequent lines. + +%inline %{ + +/** \brief + * Brief description. + * + * The comment text. + * + * \author Some author + * + * \return Some number + * + * \sa function2 + */ +int function() +{ + return 0; +} + +/** A test of a very very very very very very very very very very very very very very very very + * very very very very very long comment string. + */ +void function2() +{ +} + +/** A test for overloaded functions + * This is function \b one + */ +void function3(int a) +{ +} + +/** A test for overloaded functions + * This is function \b two + */ +void function3(int a, int b) +{ +} + +/** A test of some mixed tag usage + * \if CONDITION + * This \a code fragment shows us something \. + * \par Minuses: + * \arg it's senseless + * \arg it's stupid + * \arg it's null + * + * \warning This may not work as expected + * \code + * int main() { while(true); } + * \endcode + * \endif + */ +void function4() +{ +} + + +void function5(int a) +{ +} +/**< This is a post comment. */ + +/** Test for default args + * @param a Some parameter, default is 42 + */ +void function6(int a=42) +{ +} + +class Shape +{ +public: + typedef Shape* superType; +}; + +/** Test for a parameter with difficult type + * (mostly for python) + * @param a Very strange param + */ +void function7(Shape::superType *a[10]) +{ +} + +/** Multiple parameters test. + * + * @param y Vertical coordinate. + * @param x Horizontal coordinate. + * @return Arc tangent of @c y/x. + */ +double Atan2(double y, double x) +{ + return 0; +} + +/** Comment at the end of file should be ignored. + */ +%} diff --git a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java new file mode 100644 index 000000000..aa015eeac --- /dev/null +++ b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java @@ -0,0 +1,99 @@ + +import doxygen_basic_translate_style2.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_basic_translate_style2_runme { + static { + try { + System.loadLibrary("doxygen_basic_translate_style2"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + CommentParser parser = new CommentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style2 runtime test", + "CommentParser", + new String[]{"-quiet", "doxygen_basic_translate_style2"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function()", + " \n" + + " Brief description.\n" + + " \n" + + " The comment text.\n" + + " @author Some author\n" + + " @return Some number\n" + + " @see function2\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function2()", + " A test of a very very very very very very very very very very very very very very very very \n" + + " very very very very very long comment string. \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function4()", + " A test of some mixed tag usage \n" + + " If: CONDITION {\n" + + " This code fragment shows us something . \n" + + "

    \n" + + "

  • it's senseless \n" + + "
  • it's stupid \n" + + "
  • it's null \n" + + " \n" + + "
  • Warning: This may not work as expected \n" + + " \n" + + " {@code \n" + + "int main() { while(true); } \n" + + " }\n" + + " }\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int)", + " A test for overloaded functions \n" + + " This is function one \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function5(int)", + " This is a post comment. \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6(int)", + " Test for default args \n" + + " @param a Some parameter, default is 42" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function6()", + " Test for default args \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function7(doxygen_basic_translate_style2.SWIGTYPE_p_p_p_Shape)", + " Test for a parameter with difficult type \n" + + " (mostly for python) \n" + + " @param a Very strange param \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.function3(int, int)", + " A test for overloaded functions \n" + + " This is function two \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style2.doxygen_basic_translate_style2.Atan2(double, double)", + " Multiple parameters test.\n" + + " \n" + + " @param y Vertical coordinate.\n" + + " @param x Horizontal coordinate.\n" + + " @return Arc tangent of y/x.\n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py new file mode 100644 index 000000000..c8d24ab72 --- /dev/null +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -0,0 +1,82 @@ +import doxygen_basic_translate_spaced +import inspect +import string +import sys +import comment_verifier + +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function), + """\ +Brief description. + +The comment text. + +Author: Some author + +:rtype: int +:return: Some number + +See also: function2""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function2), + """\ +A test of a very very very very very very very very very very very very very very very very +very very very very very long comment string.""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function3), + """*Overload 1:* + +A test for overloaded functions +This is function **one** + +| + +*Overload 2:* + +A test for overloaded functions +This is function **two**""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function4), + """\ +A test of some mixed tag usage +If: CONDITION { +This *code* fragment shows us something . +Title: Minuses: +* it\'s senseless +* it\'s stupid +* it\'s null + +Warning: This may not work as expected + +.. code-block:: c++ + + int main() { while(true); } +}""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function5), + """This is a post comment.""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function6), + """\ +Test for default args +:type a: int +:param a: Some parameter, default is 42""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function7), + """\ +Test for a parameter with difficult type +(mostly for python) +:type a: :py:class:`Shape` +:param a: Very strange param""" +) + +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.Atan2), + """\ +Multiple parameters test. + +:type y: float +:param y: Vertical coordinate. +:type x: float +:param x: Horizontal coordinate. +:rtype: float +:return: Arc tangent of ``y/x``.""" +) From 0395c48124a89ef69886d0ebaeb6a3c533ceb38b Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 25 May 2019 11:39:36 -0500 Subject: [PATCH 1637/2031] Adjust expected python output for doxygen style2 test Observed that with this second comment style, there is no line break after the function overload headings in the translated comments. Updating the test results accordingly. --- .../test-suite/python/doxygen_basic_translate_style2_runme.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index c8d24ab72..5d36d216d 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -24,14 +24,12 @@ very very very very very long comment string.""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function3), """*Overload 1:* - A test for overloaded functions This is function **one** | *Overload 2:* - A test for overloaded functions This is function **two**""" ) From 64b2113e66b88e9ac605e0691e062fd2d46fe2fe Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 26 May 2019 07:50:06 -0500 Subject: [PATCH 1638/2031] Correction to recently added doxygen python test case The _runme.py code for the recently added test case was using references to an old module name for the test case, which was later changed but not updated in the runme file. --- .../doxygen_basic_translate_style2_runme.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index 5d36d216d..2d62eecbd 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -1,10 +1,10 @@ -import doxygen_basic_translate_spaced +import doxygen_basic_translate_style2 import inspect import string import sys import comment_verifier -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function), """\ Brief description. @@ -17,12 +17,12 @@ Author: Some author See also: function2""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function2), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function2), """\ A test of a very very very very very very very very very very very very very very very very very very very very very long comment string.""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function3), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function3), """*Overload 1:* A test for overloaded functions This is function **one** @@ -33,7 +33,7 @@ This is function **one** A test for overloaded functions This is function **two**""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function4), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function4), """\ A test of some mixed tag usage If: CONDITION { @@ -50,16 +50,16 @@ Warning: This may not work as expected int main() { while(true); } }""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function5), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5), """This is a post comment.""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function6), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function6), """\ Test for default args :type a: int :param a: Some parameter, default is 42""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.function7), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function7), """\ Test for a parameter with difficult type (mostly for python) @@ -67,7 +67,7 @@ Test for a parameter with difficult type :param a: Very strange param""" ) -comment_verifier.check(inspect.getdoc(doxygen_basic_translate_spaced.Atan2), +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.Atan2), """\ Multiple parameters test. From 0c6930d96672775326ad658773ff80f66dc2abad Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 26 May 2019 07:40:19 -0500 Subject: [PATCH 1639/2031] Cleanup of pydoc translator newline trimming Simplify python doxygen translation code by using functions to erase leading and trailing newlines. No change to logic. --- Source/Doxygen/pydoc.cxx | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 3eb855058..ad304e28e 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -138,6 +138,18 @@ static void trimWhitespace(string &s) { s.erase(lastNonSpace + 1); } +// Erase the first character in the string if it is a newline +static void eraseLeadingNewLine(string &s) { + if ((! s.empty()) && s[0] == '\n') + s.erase(s.begin()); +} + +// Erase the last character in the string if it is a newline +static void eraseTrailingNewLine(string &s) { + if ((! s.empty()) && s[s.size() - 1] == '\n') + s.erase(s.size() - 1); +} + /* static */ PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) { return make_pair(handler, std::string()); @@ -422,13 +434,11 @@ void PyDocConverter::handleParagraph(DoxygenEntity &tag, std::string &translated void PyDocConverter::handleVerbatimBlock(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { string verb = translateSubtree(tag); - if ((! verb.empty()) && verb[0] == '\n') - verb.erase(verb.begin()); - + eraseLeadingNewLine(verb); + // Remove the last newline to prevent doubling the newline already present after \endverbatim trimWhitespace(verb); // Needed to catch trailing newline below - if ((! verb.empty()) && verb[verb.size()-1] == '\n') - verb = verb.substr(0, verb.size()-1); + eraseTrailingNewLine(verb); translatedComment += verb; } @@ -505,8 +515,7 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // Try and remove leading newline, which is present for block \code // command: - if ((! code.empty()) && code[0] == '\n') - code.erase(code.begin()); + eraseLeadingNewLine(code); translatedComment += codeIndent; for (size_t n = 0; n < code.length(); n++) { @@ -529,8 +538,7 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // For block commands, the translator adds the newline after // \endcode, so try and compensate by removing the last newline from // the code text: - if ((! translatedComment.empty()) && translatedComment[translatedComment.size()-1] == '\n') - translatedComment = translatedComment.substr(0, translatedComment.size()-1); // use translatedComment.pop_back() in C++ 11 + eraseTrailingNewLine(translatedComment); } void PyDocConverter::handlePlainString(DoxygenEntity &tag, std::string &translatedComment, const std::string &) { @@ -852,9 +860,7 @@ String *PyDocConverter::makeDocumentation(Node *n) { if (!pyDocString.empty()) { // remove the last '\n' since additional one is added during writing to file - if (pyDocString[pyDocString.size() - 1] == '\n') { - pyDocString.erase(pyDocString.size() - 1); - } + eraseTrailingNewLine(pyDocString); if (m_flags & debug_translator) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; From 08ac56b7f26b21b33426ca482c017f3a6f654855 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 26 May 2019 08:19:07 -0500 Subject: [PATCH 1640/2031] Clarify python doxygen code block indentation handling Clarify usage and comments for the codeIndent string, the intent of which was not clear after recent updates. --- Source/Doxygen/pydoc.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index ad304e28e..fc210f106 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -499,16 +499,18 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme translatedComment += '\n'; // Use the current indent for the code-block line itself. - string codeIndent = indent.getFirstLineIndent(); - translatedComment += codeIndent; + translatedComment += indent.getFirstLineIndent(); // Go out on a limb and assume that examples in the C or C++ sources use C++. // In the worst case, we'll highlight C code using C++ syntax which is not a // big deal (TODO: handle Doxygen code command language argument). translatedComment += ".. code-block:: c++\n\n"; - // For now on, use extra indent level for all the subsequent lines. - codeIndent = m_indent; + // Specify the level of extra indentation that will be used for + // subsequent lines within the code block. Note that the correct + // "starting indentation" is already present in the input, so we + // only need to add the desired code block indentation. + string codeIndent = m_indent; std::string code; handleTagVerbatim(tag, code, arg); From 347656566510344f4eb8a772d83afd17699d5f60 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Mon, 27 May 2019 13:04:15 -0500 Subject: [PATCH 1641/2031] Remove extra newline before code block in doxygen python output Remove a newline character that was added to the translated comments prior to the code block. This way the structure of the pydoc output more closely resembles that of the original doxygen comments. Updating tests accordingly. --- Examples/test-suite/python/doxygen_basic_translate_runme.py | 1 - .../test-suite/python/doxygen_basic_translate_style2_runme.py | 1 - Examples/test-suite/python/doxygen_translate_all_tags_runme.py | 1 - Examples/test-suite/python/doxygen_translate_runme.py | 1 - Source/Doxygen/pydoc.cxx | 1 - 5 files changed, 5 deletions(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index b6023224d..0690aa464 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -46,7 +46,6 @@ Title: Minuses: * it\'s null Warning: This may not work as expected - .. code-block:: c++ int main() { while(true); } diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index 2d62eecbd..f7d68f410 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -44,7 +44,6 @@ Title: Minuses: * it\'s null Warning: This may not work as expected - .. code-block:: c++ int main() { while(true); } diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 78bf73870..22aec872d 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -34,7 +34,6 @@ Not everything works right now... 'citationword' - .. code-block:: c++ some test code""") diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index 7d127454b..d698ba873 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -20,7 +20,6 @@ Author: Zubr 'citationword' - .. code-block:: c++ some test code diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index fc210f106..f40541b00 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -496,7 +496,6 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme IndentGuard indent(translatedComment, m_indent); trimWhitespace(translatedComment); - translatedComment += '\n'; // Use the current indent for the code-block line itself. translatedComment += indent.getFirstLineIndent(); From 87695dacb19edf603219580d8b44444be7c2034e Mon Sep 17 00:00:00 2001 From: "luz.paz" Date: Sat, 25 May 2019 07:44:02 -0400 Subject: [PATCH 1642/2031] Misc. documentation and source comment typo fixes Found via `codespell -q 3 -L uint,od,objext,ba,cmo,bae,ans,struc,fo,clos,goin,upto,thru` Revert changes in previous commit --- Doc/Manual/Extending.html | 2 +- Doc/Manual/Go.html | 2 +- Doc/Manual/Python.html | 2 +- Examples/ruby/exceptproxy/example.i | 2 +- Source/Doxygen/doxyparser.cxx | 2 +- Source/Modules/allegrocl.cxx | 2 +- Source/Modules/chicken.cxx | 4 ++-- Source/Modules/python.cxx | 2 +- Source/Modules/scilab.cxx | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index b01328380..5a640fbdc 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3031,7 +3031,7 @@ virtual int functionWrapper(Node *n) { /* Close the function(error) */ Printv(wrapper->code, "return ERROR;\n", "}\n", NIL); - /* final substititions if applicable */ + /* final substitutions if applicable */ ... /* Dump the function out */ diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index cfa56dbcf..c28cc03e1 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -607,7 +607,7 @@ be checked dynamically.

    In order to use C++ templates in Go, you must tell SWIG to create -wrappers for a particular template instantation. To do this, use +wrappers for a particular template instantiation. To do this, use the %template directive. diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 5a3947d4d..ee443be53 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -4002,7 +4002,7 @@ class Go(object):

    The class defines each method in two different ways. The first definition is replaced by the second definition and so the second definition is the one used when the method is called. -While this possibly provides the best of both worlds, the time to import the module will be slighly slower when the class is defined due to the additional method definitions. +While this possibly provides the best of both worlds, the time to import the module will be slightly slower when the class is defined due to the additional method definitions.

    diff --git a/Examples/ruby/exceptproxy/example.i b/Examples/ruby/exceptproxy/example.i index 8e00751b2..ad0c23acb 100644 --- a/Examples/ruby/exceptproxy/example.i +++ b/Examples/ruby/exceptproxy/example.i @@ -14,7 +14,7 @@ %} -/* The EmpytError doesn't appear in a throw declaration, and hence +/* The EmptyError doesn't appear in a throw declaration, and hence we need to tell SWIG that the dequeue method throws it. This can now be done via the %catchs feature. */ %catches(FullError) *::enqueue; diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 7286adeb0..3f413bcaa 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -1294,7 +1294,7 @@ void DoxygenParser::tokenizeDoxygenComment(const std::string &doxygenComment, co string lastLine = lines[lines.size() - 1]; if (trim(lastLine).empty()) { - lines.pop_back(); // remove trailing empy line + lines.pop_back(); // remove trailing empty line } } diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index f32d34976..97af186fe 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -471,7 +471,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, // a synonym type was found (held in variable 'match') // Printf(stderr, "setting primary synonym of %p to %p\n", new_node, match); if (new_node == match) - Printf(stderr, "Hey-4 * - '%s' is a synonym of iteself!\n", Getattr(new_node, "name")); + Printf(stderr, "Hey-4 * - '%s' is a synonym of itself!\n", Getattr(new_node, "name")); Setattr(new_node, "allegrocl:synonym-of", match); // Printf(stderr,"*** 4\n"); add_linked_type(new_node); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 68a42a29b..76b6455e2 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -547,7 +547,7 @@ int CHICKEN::functionWrapper(Node *n) { } emit_return_variable(n, d, f); - /* Insert the argumetn output code */ + /* Insert the argument output code */ Printv(f->code, argout, NIL); /* Output cleanup code */ @@ -1456,7 +1456,7 @@ String *CHICKEN::chickenPrimitiveName(String *name) { if (value) return value; else { - Swig_error(input_file, line_number, "Internal Error: attempting to reference non-existant primitive name %s\n", name); + Swig_error(input_file, line_number, "Internal Error: attempting to reference non-existent primitive name %s\n", name); return NewString("#f"); } } diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index b8493352c..e9852ddf9 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1755,7 +1755,7 @@ public: if (new_value) { value = new_value; } else { - // Even if the value is not representable in the target language, still use it in the documentaiton, for compatibility with the previous SWIG versions + // Even if the value is not representable in the target language, still use it in the documentation, for compatibility with the previous SWIG versions // and because it can still be useful to see the C++ expression there. Node *lookup = Swig_symbol_clookup(value, 0); if (lookup) diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 4fea0ce36..23e45f787 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -496,7 +496,7 @@ public: /* Add the failure cleanup code */ /* TODO */ - /* Final substititions if applicable */ + /* Final substitutions if applicable */ Replaceall(wrapper->code, "$symname", functionName); /* Set CheckInputArgument and CheckOutputArgument input arguments */ From c864546b4ab39838d59502a791854dab3817e38b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 3 Jun 2019 10:13:58 +1200 Subject: [PATCH 1643/2031] [Python] Fix implicit_conv tuple handling regression Introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre Duret-Lutz. --- CHANGES.current | 5 +++++ Lib/python/pyrun.swg | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 80570a155..7b473da7c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-06-03: olly + [Python] Fix regression in implicit_conv handling of tuples, + introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre + Duret-Lutz. + 2019-05-24: wsfulton [Octave] Fix detection of Octave on MacOS. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index ad1b81963..445a1e324 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -184,7 +184,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } /* A functor is a function object with one single object argument */ -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, (char *)"O", obj); +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); /* Helper for static pointer initialization for both C and C++ code, for example From 55e835e0ae2d67e0a60c8aed998faac7fa039ca4 Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Thu, 6 Jun 2019 19:21:44 +0100 Subject: [PATCH 1644/2031] Java std::vector constructor performance improvement Reserve before loop of push_back Refactor li_std_vector testcase This is a squash merge of #1552 --- CHANGES.current | 4 + .../test-suite/java/li_std_vector_runme.java | 124 ++++++++++-------- Lib/java/std_vector.i | 3 +- 3 files changed, 74 insertions(+), 57 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7b473da7c..99b31d5c9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-06-06: bkotzz + [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes + a native Java array as input. + 2019-06-03: olly [Python] Fix regression in implicit_conv handling of tuples, introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre diff --git a/Examples/test-suite/java/li_std_vector_runme.java b/Examples/test-suite/java/li_std_vector_runme.java index fc8ba0f6f..d4c0c95c7 100644 --- a/Examples/test-suite/java/li_std_vector_runme.java +++ b/Examples/test-suite/java/li_std_vector_runme.java @@ -11,54 +11,61 @@ public class li_std_vector_runme { } } + public static void checkThat(boolean mustBeTrue) throws Throwable { + if (!mustBeTrue) { + // Index [2], since this function is one hop away from main, and [1] is the current method. + throw new RuntimeException("Test failed at line number " + Thread.currentThread().getStackTrace()[2].getLineNumber()); + } + } + public static void main(String argv[]) throws Throwable { IntVector v1 = li_std_vector.vecintptr(new IntVector()); IntPtrVector v2 = li_std_vector.vecintptr(new IntPtrVector()); IntConstPtrVector v3 = li_std_vector.vecintconstptr(new IntConstPtrVector()); - if (!v1.isEmpty()) throw new RuntimeException("v1 test (1) failed"); - if (v1.size() != 0) throw new RuntimeException("v1 test (2) failed"); - if (!v1.add(123)) throw new RuntimeException("v1 test (3) failed"); - if (v1.size() != 1) throw new RuntimeException("v1 test (4) failed"); - if (v1.isEmpty()) throw new RuntimeException("v1 test (5) failed"); + checkThat(v1.isEmpty()); + checkThat(v1.size() == 0); + checkThat(v1.add(123)); + checkThat(v1.size() == 1); + checkThat(!v1.isEmpty()); int sum = 0; for (int n : v1) { - if (n != 123) throw new RuntimeException("v1 loop test failed"); + checkThat(n == 123); sum += n; } - if (sum != 123) throw new RuntimeException("v1 sum test failed"); - if (v1.get(0) != 123) throw new RuntimeException("v1 test failed"); + checkThat(sum == 123); + checkThat(v1.get(0) == 123); v1.clear(); - if (!v1.isEmpty()) throw new RuntimeException("v1 test clear failed"); + checkThat(v1.isEmpty()); v1.add(123); - if (v1.set(0, 456) != 123) throw new RuntimeException("v1 test (6) failed"); - if (v1.size() != 1) throw new RuntimeException("v1 test (7) failed"); - if (v1.get(0) != 456) throw new RuntimeException("v1 test (8) failed"); + checkThat(v1.set(0, 456) == 123); + checkThat(v1.size() == 1); + checkThat(v1.get(0) == 456); java.util.Iterator v1_iterator = v1.iterator(); - if (!v1_iterator.hasNext()) throw new RuntimeException("v1 test (9) failed"); - if (v1_iterator.next() != 456) throw new RuntimeException("v1 test (10) failed"); - if (v1_iterator.hasNext()) throw new RuntimeException("v1 test (11) failed"); + checkThat(v1_iterator.hasNext()); + checkThat(v1_iterator.next() == 456); + checkThat(!v1_iterator.hasNext()); try { v1_iterator.next(); - throw new RuntimeException("v1 test (12) failed"); + checkThat(false); } catch (java.util.NoSuchElementException e) { } - if (v1.remove(Integer.valueOf(123))) throw new RuntimeException("v1 test (13) failed"); - if (!v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (14) failed"); - if (!v1.isEmpty()) throw new RuntimeException("v1 test (15) failed"); - if (v1.size() != 0) throw new RuntimeException("v1 test (16) failed"); - if (v1.remove(Integer.valueOf(456))) throw new RuntimeException("v1 test (17) failed"); + checkThat(!v1.remove(Integer.valueOf(123))); + checkThat(v1.remove(Integer.valueOf(456))); + checkThat(v1.isEmpty()); + checkThat(v1.size() == 0); + checkThat(!v1.remove(Integer.valueOf(456))); - if (new IntVector(3, 0).size() != 3) throw new RuntimeException("constructor initial size test failed"); + checkThat(new IntVector(3, 0).size() == 3); for (int n : new IntVector(10, 999)) - if (n != 999) throw new RuntimeException("constructor initialization with value failed"); + checkThat(n == 999); for (int n : new IntVector(new IntVector(10, 999))) - if (n != 999) throw new RuntimeException("copy constructor initialization with value failed"); + checkThat(n == 999); StructVector v4 = li_std_vector.vecstruct(new StructVector()); StructPtrVector v5 = li_std_vector.vecstructptr(new StructPtrVector()); @@ -68,18 +75,18 @@ public class li_std_vector_runme { v5.add(new Struct(34)); v6.add(new Struct(56)); - if (v4.get(0).getNum() != 12) throw new RuntimeException("v4 test failed"); - if (v5.get(0).getNum() != 34) throw new RuntimeException("v5 test failed"); - if (v6.get(0).getNum() != 56) throw new RuntimeException("v6 test failed"); + checkThat(v4.get(0).getNum() == 12); + checkThat(v5.get(0).getNum() == 34); + checkThat(v6.get(0).getNum() == 56); for (Struct s : v4) { - if (s.getNum() != 12) throw new RuntimeException("v4 loop test failed"); + checkThat(s.getNum() == 12); } for (Struct s : v5) { - if (s.getNum() != 34) throw new RuntimeException("v5 loop test failed"); + checkThat(s.getNum() == 34); } for (Struct s : v6) { - if (s.getNum() != 56) throw new RuntimeException("v6 loop test failed"); + checkThat(s.getNum() == 56); } StructVector v7 = li_std_vector.vecstruct(new StructVector()); @@ -87,43 +94,43 @@ public class li_std_vector_runme { v7.add(new Struct(23)); v7.add(new Struct(456)); v7.add(new Struct(7890)); - if (v7.size() != 4) throw new RuntimeException("v7 test (1) failed"); + checkThat(v7.size() == 4); { double[] a7 = {1, 23, 456, 7890}; int i7 = 0; for (Struct s7 : v7) { - if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (2) failed"); + checkThat(s7.getNum() == a7[i7]); i7++; } - if (i7 != a7.length) throw new RuntimeException("v7 test (3) failed"); + checkThat(i7 == a7.length); } - if (v7.remove(2).getNum() != 456) throw new RuntimeException("v7 test (4) failed"); + checkThat(v7.remove(2).getNum() == 456); { double[] a7 = {1, 23, 7890}; int i7 = 0; for (Struct s7 : v7) { - if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (5) failed"); + checkThat(s7.getNum() == a7[i7]); i7++; } - if (i7 != a7.length) throw new RuntimeException("v7 test (6) failed"); + checkThat(i7 == a7.length); } v7.add(1, new Struct(123)); { double[] a7 = {1, 123, 23, 7890}; int i7 = 0; for (Struct s7 : v7) { - if (s7.getNum() != a7[i7]) throw new RuntimeException("v7 test (7) failed"); + checkThat(s7.getNum() == a7[i7]); i7++; } - if (i7 != a7.length) throw new RuntimeException("v7 test (8) failed"); + checkThat(i7 == a7.length); } BoolVector v8 = new BoolVector(); - if (!v8.add(true)) throw new RuntimeException("v8 test (1) failed");; - if (v8.get(0) != true) throw new RuntimeException("v8 test (2) failed");; - if (v8.set(0, false) != true) throw new RuntimeException("v8 test (3) failed");; - if (v8.set(0, false) != false) throw new RuntimeException("v8 test (4) failed");; - if (v8.size() != 1) throw new RuntimeException("v8 test (5) failed");; + checkThat(v8.add(true)); + checkThat(v8.get(0) == true); + checkThat(v8.set(0, false) == true); + checkThat(v8.set(0, false) == false); + checkThat(v8.size() == 1); java.util.ArrayList bl = new java.util.ArrayList(java.util.Arrays.asList(true, false, true, false)); BoolVector bv = new BoolVector(java.util.Arrays.asList(true, false, true, false)); @@ -136,36 +143,41 @@ public class li_std_vector_runme { v9.add(50); v9.add(60); v9.add(70); - if (v9.size() != 7) throw new RuntimeException("v9 test (1) failed"); - if (!v9.remove(Integer.valueOf(60))) throw new RuntimeException("v9 test (2) failed"); - if (v9.size() != 6) throw new RuntimeException("v9 test (3) failed"); + checkThat(v9.size() == 7); + checkThat(v9.remove(Integer.valueOf(60))); + checkThat(v9.size() == 6); IntVector v10 = new IntVector(java.util.Arrays.asList(10, 20, 30, 40, 50)); v10.subList(1, 4).clear(); // Recommended way to call protected method removeRange(1,3) - if (v10.size() != 2) throw new RuntimeException("v10 test (1) failed"); - if (v10.get(0) != 10) throw new RuntimeException("v10 test (2) failed"); - if (v10.get(1) != 50) throw new RuntimeException("v10 test (3) failed"); + checkThat(v10.size() == 2); + checkThat(v10.get(0) == 10); + checkThat(v10.get(1) == 50); v10.addAll(1, java.util.Arrays.asList(22, 33)); - if (v10.size() != 4) throw new RuntimeException("v10 test (4) failed"); - if (v10.get(1) != 22) throw new RuntimeException("v10 test (5) failed"); - if (v10.get(2) != 33) throw new RuntimeException("v10 test (6) failed"); + checkThat(v10.size() == 4); + checkThat(v10.get(1) == 22); + checkThat(v10.get(2) == 33); v10.add(v10.size(), 55); - if (v10.size() != 5) throw new RuntimeException("v10 test (7) failed"); - if (v10.get(4) != 55) throw new RuntimeException("v10 test (8) failed"); + checkThat(v10.size() == 5); + checkThat(v10.get(4) == 55); IntVector v11 = new IntVector(java.util.Arrays.asList(11, 22, 33, 44)); v11.listIterator(0); v11.listIterator(v11.size()); try { v11.listIterator(v11.size() + 1); - throw new RuntimeException("v11 test (1) failed"); + checkThat(false); } catch (IndexOutOfBoundsException e) { } try { v11.listIterator(-1); - throw new RuntimeException("v11 test (2) failed"); + checkThat(false); } catch (IndexOutOfBoundsException e) { } + + IntVector arrayInit = new IntVector(new int[]{1, 2, 3, 4, 5}); + checkThat(arrayInit.size() == 5); + checkThat(arrayInit.get(0) == 1); + checkThat(arrayInit.get(4) == 5); } } diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 955e20cac..60ee23ebb 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -29,6 +29,8 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { %proxycode %{ public $javaclassname($typemap(jstype, CTYPE)[] initialElements) { this(); + reserve(initialElements.length); + for ($typemap(jstype, CTYPE) element : initialElements) { add(element); } @@ -181,4 +183,3 @@ namespace std { %define specialize_std_vector(T) #warning "specialize_std_vector - specialization for type T no longer needed" %enddef - From 7231c2a0650a7aaa964021d47c0d55eff2c48173 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Jun 2019 19:45:24 +0100 Subject: [PATCH 1645/2031] Fix cpp11_rvalue_refrence3 testcase clang warning cpp11_rvalue_reference3_wrap.cxx:256:38: warning: binding reference member 'member_rvalue_ref_ptr1' to a temporary value [-Wdangling-field] Thing *&& member_rvalue_ref_ptr1 = 0; ^ --- Examples/test-suite/cpp11_rvalue_reference3.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/cpp11_rvalue_reference3.i b/Examples/test-suite/cpp11_rvalue_reference3.i index 6dfe4c098..8ebf45366 100644 --- a/Examples/test-suite/cpp11_rvalue_reference3.i +++ b/Examples/test-suite/cpp11_rvalue_reference3.i @@ -26,10 +26,10 @@ void takeit5(Thing const*const&& t) {} struct Containing { Thing && member_rvalue_ref; - Thing *&& member_rvalue_ref_ptr1 = 0; - Thing const*&& member_rvalue_ref_ptr2 = 0; - Thing *const&& member_rvalue_ref_ptr3 = 0; - Thing const*const &&member_rvalue_ref_ptr4 = 0; + Thing *&& member_rvalue_ref_ptr1; + Thing const*&& member_rvalue_ref_ptr2; + Thing *const&& member_rvalue_ref_ptr3; + Thing const*const &&member_rvalue_ref_ptr4; Containing(Thing&&r, Thing*&& r1, Thing const*&& r2, Thing *const&& r3, Thing const*const && r4) : member_rvalue_ref(std::move(r)), @@ -63,10 +63,10 @@ void int_takeit5(int const*const&& t) {} struct IntContaining { int && member_rvalue_ref; - int *&& member_rvalue_ref_ptr1 = 0; - int const*&& member_rvalue_ref_ptr2 = 0; - int *const&& member_rvalue_ref_ptr3 = 0; - int const*const &&member_rvalue_ref_ptr4 = 0; + int *&& member_rvalue_ref_ptr1; + int const*&& member_rvalue_ref_ptr2; + int *const&& member_rvalue_ref_ptr3; + int const*const &&member_rvalue_ref_ptr4; IntContaining(int&& r, int*&& r1, int const*&& r2, int *const&& r3, int const*const && r4) : member_rvalue_ref(std::move(r)), From d9cac176f6a03b9a57527ef5c1b5659b8857242a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Jun 2019 19:52:37 +0100 Subject: [PATCH 1646/2031] Suppress testcase clang warning for auto_ptr deprecation --- Examples/test-suite/li_std_auto_ptr.i | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i index 5fdc5fa35..7693a3118 100644 --- a/Examples/test-suite/li_std_auto_ptr.i +++ b/Examples/test-suite/li_std_auto_ptr.i @@ -4,6 +4,12 @@ #if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation #endif + +#if defined(__clang__) +#pragma clang diagnostic push +// Suppress 'auto_ptr<>' is deprecated +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif %} #if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON) From daad5d664d745c15657de19e6509f1e189e01109 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Tue, 4 Jun 2019 16:55:54 -0500 Subject: [PATCH 1647/2031] Ensure empty line before code and math blocks in doxygen pydoc Sphinx requires an empty line before code and math blocks, whereas doxygen does not. This update ensures that a blank line is included before generated code and math blocks in the pydoc output. This is done by post-processing the docstring line by line to check whether any newlines need to be added. This way, if the original doxygen source already includes an empty line before a block, an additional unnecessary empty line is not added. Updating the expected test output for doxygen_basic_translate, which now adds the necessary empty line before the code block. Adding further test cases to doxygen_translate_all_tags to explicitly verify that a newline is added in the pydoc output before both code and math blocks that appear within a paragraph. Additionally, empty lines previously appearing at the beginning of the generated docstrings are now removed. This does not alter the behavior of the tests. --- .../test-suite/doxygen_translate_all_tags.i | 10 +++++ .../doxygen_translate_all_tags_runme.java | 12 ++++-- .../python/doxygen_basic_translate_runme.py | 1 + .../doxygen_basic_translate_style2_runme.py | 1 + .../doxygen_translate_all_tags_runme.py | 16 +++++++- Source/Doxygen/pydoc.cxx | 41 ++++++++++++++++++- 6 files changed, 75 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i index 6e96a57c5..8da683d52 100644 --- a/Examples/test-suite/doxygen_translate_all_tags.i +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -38,6 +38,10 @@ * \cite citationword * \class someClass headerFile.h headerName * \code some test code \endcode + * + * Code immediately following text. Pydoc translation must add an + * empty line before: + * \code more test code \endcode */ void func01(int a) { @@ -121,6 +125,12 @@ void func03(int a) * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} * \f} * + * Math immediately following text. Pydoc translation must add an + * empty line before: + * \f[ + * \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} + * \f] + * * \file file.h * * \fn someFn diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index 8bd65224f..d5c533f4e 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -40,7 +40,10 @@ public class doxygen_translate_all_tags_runme { " Not everything works right now...\n" + " codeword\n\n\n\n\n\n" + " citationword\n" + - " {@code some test code }\n"); + " {@code some test code }\n\n" + + " Code immediately following text. Pydoc translation must add an\n" + + " empty line before:\n" + + " {@code more test code }"); wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func02(int)", " Conditional comment: SOMECONDITION \n" + @@ -63,8 +66,11 @@ public class doxygen_translate_all_tags_runme { " @exception SuperError \n" + " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" + " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" + - " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n" + - " This will only appear in hmtl \n"); + " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} \n\n" + + "Math immediately following text. Pydoc translation must add an\n" + + "empty line before:\n\n" + + " \\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\n" + + " This will only appear in hmtl \n"); wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func05(int)", " If: ANOTHERCONDITION {\n" + diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 0690aa464..b6023224d 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -46,6 +46,7 @@ Title: Minuses: * it\'s null Warning: This may not work as expected + .. code-block:: c++ int main() { while(true); } diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index f7d68f410..2d62eecbd 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -44,6 +44,7 @@ Title: Minuses: * it\'s null Warning: This may not work as expected + .. code-block:: c++ int main() { while(true); } diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 22aec872d..df1c0eba5 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -36,7 +36,14 @@ Not everything works right now... .. code-block:: c++ - some test code""") + some test code + +Code immediately following text. Pydoc translation must add an +empty line before: + +.. code-block:: c++ + + more test code""") comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func02), r"""Conditional comment: SOMECONDITION @@ -97,6 +104,13 @@ r""":raises: SuperError \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} +Math immediately following text. Pydoc translation must add an +empty line before: + +.. math:: + + \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} + diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index f40541b00..eb489932a 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -140,16 +140,50 @@ static void trimWhitespace(string &s) { // Erase the first character in the string if it is a newline static void eraseLeadingNewLine(string &s) { - if ((! s.empty()) && s[0] == '\n') + if (!s.empty() && s[0] == '\n') s.erase(s.begin()); } // Erase the last character in the string if it is a newline static void eraseTrailingNewLine(string &s) { - if ((! s.empty()) && s[s.size() - 1] == '\n') + if (!s.empty() && s[s.size() - 1] == '\n') s.erase(s.size() - 1); } +// Check the generated docstring line by line and make sure that any +// code and verbatim blocks have an empty line preceding them, which +// is necessary for Sphinx. Additionally, this strips any empty lines +// appearing at the beginning of the docstring. +static string padCodeAndVerbatimBlocks(const string &docString) { + std::string result; + + std::istringstream iss(docString); + + // Initialize to false because there is no previous line yet + bool lastLineWasNonBlank = false; + + for (string line; std::getline(iss, line); result += line) { + if (!result.empty()) { + // Terminate the previous line + result += '\n'; + } + + const size_t pos = line.find_first_not_of(" \t"); + if (pos == string::npos) { + lastLineWasNonBlank = false; + } else { + if (lastLineWasNonBlank && + (line.compare(pos, 13, ".. code-block") == 0 || + line.compare(pos, 7, ".. math") == 0)) { + // Must separate code or math blocks from the previous line + result += '\n'; + } + lastLineWasNonBlank = true; + } + } + return result; +} + /* static */ PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) { return make_pair(handler, std::string()); @@ -863,6 +897,9 @@ String *PyDocConverter::makeDocumentation(Node *n) { // remove the last '\n' since additional one is added during writing to file eraseTrailingNewLine(pyDocString); + // ensure that a blank line occurs before code or math blocks + pyDocString = padCodeAndVerbatimBlocks(pyDocString); + if (m_flags & debug_translator) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; std::cout << pyDocString; From e7993dca97516e1c68570617bdc325f4739127ff Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Tue, 25 Jun 2019 21:13:49 -0600 Subject: [PATCH 1648/2031] Dev Checkpoint 201906252113 --- Examples/javascript/native/example.i | 119 +++++------------- .../javascript/native_directive_runme.js | 9 ++ Examples/test-suite/native_directive.i | 58 ++++++--- 3 files changed, 79 insertions(+), 107 deletions(-) create mode 100644 Examples/test-suite/javascript/native_directive_runme.js diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i index 1d0d2e808..212765fa4 100644 --- a/Examples/javascript/native/example.i +++ b/Examples/javascript/native/example.i @@ -4,100 +4,37 @@ %wrapper %{ -#include -#include - - -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) - typedef v8::Handle V8ReturnValue; - typedef v8::Arguments V8Arguments; -# define V8_RETURN(val) return scope.Close(val) -#else - typedef void V8ReturnValue; - typedef v8::FunctionCallbackInfo V8Arguments; -# define V8_RETURN(val) args.GetReturnValue().Set(val); return -#endif -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) -# define V8_UNDEFINED() v8::Undefined() -#else -# define V8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent()) -#endif -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117) -# define V8_HANDLESCOPE() v8::HandleScope scope -#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224) -# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); -#else -# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent()); -#endif - - -// 'unused' attribute only necessary for GNUC < v3.4 -static /* __attribute__ ((__unused__)) */ V8ErrorHandler V8_ErrorHandler; - - -typedef struct worker_packet { - // -- basic -- - uv_work_t request; - v8::Persistent callback; - // -- persistent variables -- - std::string result; - // -- async operation -- - void (*execute)(std::string&); -} worker_packet; - - -// async process - parallel with node thread -static void work_async(uv_work_t* request) { - worker_packet* packet = static_cast(request->data); - packet->execute(packet->result); - // add a delay for dramatic effect - not necessary -} - - -// send async result back to node's thread -static void work_complete(uv_work_t* request, int status) { - V8_HANDLESCOPE(); - v8::Isolate* iso = v8::Isolate::GetCurrent(); - worker_packet* packet = static_cast(request->data); - const int argc = 1; - v8::Handle argv[] = { - v8::String::NewFromUtf8(iso, packet->result.c_str()) - }; - v8::Local::New(iso, packet->callback)->Call - (iso->GetCurrentContext()->Global(), argc, argv); - packet->callback.Reset(); - delete work; -} - - -static void entry(const V8Arguments& args) { - v8::Isolate* iso = v8::Isolate::GetCurrent(); - v8::Local value = args[0]; - if (!value->IsFunction()) { - V8_ErrorHandler.error((-1), "Invalid parameter type."); - return; +#ifdef SWIG_V8_VERSION /* Engine: Node || V8 */ + + static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) { + SWIGV8_HANDLESCOPE(); + const int MY_MAGIC_NUMBER = 5; + v8::Handle jsresult = + SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER)); + if (args.Length() != 0) + SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); + SWIGV8_RETURN(jsresult); + fail: + SWIGV8_RETURN(SWIGV8_UNDEFINED()); } - worker_packet* packet = new worker_packet(); - packet->request.data = packet; - packet->execute = [](std::string& res) { res = "My delayed message."; }; - v8::Local callback = v8::Local::Cast(value); - packet->callback.Reset(iso, callback); - uv_queue_work(uv_default_loop(), &packet->request, - work_async, work_complete); - args.GetReturnValue().Set(Undefined(iso)); -} +#else /* Engine: JavaScriptCore */ -V8ReturnValue JavaScript_exampleV8_callback_function(const V8Arguments& args) { - V8_HANDLESCOPE(); - if (args.Length() != 1) { - V8_ErrorHandler.error((-1), "Illegal number of arguments."); - V8_RETURN(V8_UNDEFINED()); - } - entry(args); - v8::Handle jsresult = V8_UNDEFINED(); - V8_RETURN(jsresult); -} + static JSValueRef JavaScript_do_work(JSContextRef context, + JSObjectRef function, JSObjectRef thisObject, size_t argc, + const JSValueRef argv[], JSValueRef* exception) { + const int MY_MAGIC_NUMBER = 5; + JSValueRef jsresult = + SWIG_From_int SWIG_JSC_FROM_CALL_ARGS( + static_cast< int >(MY_MAGIC_NUMBER)); + if (argc != 0) + SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); + return jsresult; + fail: + return JSValueMakeUndefined(context); + } + +#endif %} diff --git a/Examples/test-suite/javascript/native_directive_runme.js b/Examples/test-suite/javascript/native_directive_runme.js new file mode 100644 index 000000000..5c1d69cf1 --- /dev/null +++ b/Examples/test-suite/javascript/native_directive_runme.js @@ -0,0 +1,9 @@ +var native_directive = require("native_directive"); + +(function main() { + var s = "abc.DEF-123"; + if (native_directive.CountAlphas(s) !== 6) + throw "CountAlphas failed"; + if (native_directive.CountAlphaCharacters(s) !== 6) + throw "CountAlphaCharacters failed"; +})(); diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i index 39b9856a0..f2699c421 100644 --- a/Examples/test-suite/native_directive.i +++ b/Examples/test-suite/native_directive.i @@ -42,32 +42,58 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co #endif -#if defined(SWIG_V8_VERSION) + +#ifdef SWIGJAVASCRIPT +%native(CountAlphaCharacters) void JavaScript_alpha_count(); %{ -static SwigV8ReturnValue wrap_alpha_count(const SwigV8Arguments &args) { +#ifdef SWIG_V8_VERSION /* engine = node || v8 */ + +static SwigV8ReturnValue JavaScript_alpha_count(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); v8::Handle jsresult; - char *arg1 = (char *) 0 ; - int res1 ; - char *buf1 = 0 ; - int alloc1 = 0 ; + char *arg1 = (char *)0; + int res1; + char *buf1 = 0; + int alloc1 = 0; int result; - if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, - "Illegal number of arguments for _wrap_count_characters."); + if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_alpha_count."); res1 = SWIG_AsCharPtrAndSize(args[0], &buf1, NULL, &alloc1); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "count_characters" - "', argument " "1"" of type '" "char const *""'"); - } + if (!SWIG_IsOK(res1)) + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'"); arg1 = reinterpret_cast< char * >(buf1); - result = (int)count_characters((char const *)arg1); + result = (int)alpha_count((char const *)arg1); jsresult = SWIG_From_int(static_cast< int >(result)); if (alloc1 == SWIG_NEWOBJ) delete[] buf1; SWIGV8_RETURN(jsresult); fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); } -%} -%native(CountAlphaCharacters) void wrap_alpha_count(); -#endif + +#else /* engine = jsc */ + +static JSValueRef JavaScript_alpha_count(JSContextRef context, JSObjectRef function, + JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception) +{ + char *arg1 = (char *)0; + int res1; + char *buf1 = 0; + int alloc1 = 0; + int result; + JSValueRef jsresult; + if (argc != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); + res1 = SWIG_JSC_AsCharPtrAndSize(context, argv[0], &buf1, NULL, &alloc1); + if (!SWIG_IsOK(res1)) + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'"); + arg1 = reinterpret_cast< char * >(buf1); + result = (int)alpha_count((char const *)arg1); + jsresult = SWIG_From_int SWIG_JSC_FROM_CALL_ARGS(static_cast< int >(result)); + if (alloc1 == SWIG_NEWOBJ) delete[] buf1; + return jsresult; +fail: + return JSValueMakeUndefined(context); +} + +#endif /* engine */ +%} +#endif /* SWIGJAVASCRIPT */ From 2c2e638d893b440dc057688b300518cb3a4613cb Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Tue, 25 Jun 2019 22:10:46 -0600 Subject: [PATCH 1649/2031] Dev Checkpoint 201906252210 --- Examples/javascript/native/example.i | 8 +++++++- Examples/javascript/native/runme.js | 4 +--- Examples/test-suite/native_directive.i | 3 +++ Source/Modules/javascript.cxx | 15 ++++++++++----- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i index 212765fa4..740238413 100644 --- a/Examples/javascript/native/example.i +++ b/Examples/javascript/native/example.i @@ -1,7 +1,13 @@ /* File : example.i */ %module example +// placeholder() used to help SWIG generate "SWIG_From_int" call +%{ + int placeholder(); +%} +int placeholder() { return 0; } +// actual demo code %wrapper %{ #ifdef SWIG_V8_VERSION /* Engine: Node || V8 */ @@ -38,4 +44,4 @@ %} -%native(num_to_string) void JavaScript_exampleV8_callback_function(); +%native(magicNumber) void JavaScript_do_work(); diff --git a/Examples/javascript/native/runme.js b/Examples/javascript/native/runme.js index 6577bb1fb..8ea0a8bcc 100644 --- a/Examples/javascript/native/runme.js +++ b/Examples/javascript/native/runme.js @@ -1,5 +1,3 @@ var example = require("example"); -function callback(msg) { console.log(msg); } - -example.num_to_string(callback); +console.info("My magic number is: ", example.magicNumber()); diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i index f2699c421..9ae76e0b7 100644 --- a/Examples/test-suite/native_directive.i +++ b/Examples/test-suite/native_directive.i @@ -42,6 +42,9 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co #endif +// TODO: C# +// TODO: Python + #ifdef SWIGJAVASCRIPT %native(CountAlphaCharacters) void JavaScript_alpha_count(); diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index e36f31308..68c97e641 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -787,13 +787,18 @@ int JSEmitter::emitWrapperFunction(Node *n) { } int JSEmitter::emitNativeFunction(Node *n) { - String *wrap_name = Getattr(n, "wrap:name"); - - Setattr(n, "feature:extend", "last"); + String *wrapname = Getattr(n, "wrap:name"); + // ismember never seems to be the case; + // it is technically possible to add native member functions, + // just not at the moment? leaving this as an option for later; + // the code will automatically defaulting to static space + if (GetFlag(n, "ismember") != 0) + Setattr(n, "feature:extend", "1"); // member space + else + Setattr(n, "feature:extend", "0"); // static space enterFunction(n); - state.function(WRAPPER_NAME, wrap_name); + state.function(WRAPPER_NAME, wrapname); exitFunction(n); - return SWIG_OK; } From 4b3b5f2abbbcdc32ed4f791e67abb885c7b93c28 Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Tue, 25 Jun 2019 22:21:34 -0600 Subject: [PATCH 1650/2031] Dev Checkpoint 201906252221 --- Examples/javascript/native/example.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i index 740238413..8c6160060 100644 --- a/Examples/javascript/native/example.i +++ b/Examples/javascript/native/example.i @@ -16,9 +16,9 @@ int placeholder() { return 0; } SWIGV8_HANDLESCOPE(); const int MY_MAGIC_NUMBER = 5; v8::Handle jsresult = - SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER)); + SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER)); if (args.Length() != 0) - SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); + SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); SWIGV8_RETURN(jsresult); fail: SWIGV8_RETURN(SWIGV8_UNDEFINED()); @@ -26,15 +26,15 @@ int placeholder() { return 0; } #else /* Engine: JavaScriptCore */ - static JSValueRef JavaScript_do_work(JSContextRef context, - JSObjectRef function, JSObjectRef thisObject, size_t argc, - const JSValueRef argv[], JSValueRef* exception) { + static JSValueRef JavaScript_do_work(JSContextRef context, + JSObjectRef function, JSObjectRef thisObject, size_t argc, + const JSValueRef argv[], JSValueRef* exception) { const int MY_MAGIC_NUMBER = 5; JSValueRef jsresult = - SWIG_From_int SWIG_JSC_FROM_CALL_ARGS( - static_cast< int >(MY_MAGIC_NUMBER)); + SWIG_From_int SWIG_JSC_FROM_CALL_ARGS( + static_cast< int >(MY_MAGIC_NUMBER)); if (argc != 0) - SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); + SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); return jsresult; fail: return JSValueMakeUndefined(context); From df3ac2ba980057db21808688e38a40b3ffa0c9d1 Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Tue, 25 Jun 2019 22:27:08 -0600 Subject: [PATCH 1651/2031] Dev Checkpoint 201906252227 --- Examples/javascript/check.list | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/javascript/check.list b/Examples/javascript/check.list index 9707e77d4..977835755 100644 --- a/Examples/javascript/check.list +++ b/Examples/javascript/check.list @@ -3,6 +3,7 @@ constant enum exception functor +native nspace operator overload From 99b35b099a8b896047a8382b603a36f0a33bdf9d Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Wed, 26 Jun 2019 01:10:38 -0600 Subject: [PATCH 1652/2031] Fixes Travis CI Build Errors With Node-v4 --- Tools/travis-linux-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index d7d31505f..37ef841dd 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -39,7 +39,7 @@ case "$SWIGLANG" in [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" travis_retry nvm install ${VER} nvm use ${VER} - if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] ; then + if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] || [ "$VER" == "4" ] ; then # travis_retry sudo apt-get install -qq nodejs node-gyp travis_retry npm install -g node-gyp@$VER else From 1aa9e5c72297add2bda49cbb786e56b3cfd678f3 Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Wed, 26 Jun 2019 13:12:19 -0600 Subject: [PATCH 1653/2031] Dev Checkpoint 201906261312 --- Examples/javascript/native/runme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/javascript/native/runme.js b/Examples/javascript/native/runme.js index 8ea0a8bcc..b5e14d037 100644 --- a/Examples/javascript/native/runme.js +++ b/Examples/javascript/native/runme.js @@ -1,3 +1,3 @@ var example = require("example"); -console.info("My magic number is: ", example.magicNumber()); +console.log("My magic number is: ", example.magicNumber()); From 116b6b10284f0ec3f11f19c6bf56decc2e019798 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 07:18:17 +0100 Subject: [PATCH 1654/2031] Remove deprecated calls in Octave testcases Fixes warning using Octave 5.1: warning: findstr is obsolete; use strfind instead --- .../test-suite/octave/template_typedef_cplx2_runme.m | 12 ++++++------ .../test-suite/octave/template_typedef_cplx_runme.m | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Examples/test-suite/octave/template_typedef_cplx2_runme.m b/Examples/test-suite/octave/template_typedef_cplx2_runme.m index 94d3beb79..a72e0f1e0 100644 --- a/Examples/test-suite/octave/template_typedef_cplx2_runme.m +++ b/Examples/test-suite/octave/template_typedef_cplx2_runme.m @@ -12,7 +12,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(d)) != 1) +if (strfind('ArithUnaryFunction',swig_type(d)) != 1) d error("is not an ArithUnaryFunction") error @@ -26,7 +26,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(e)) != 1) +if (strfind('ArithUnaryFunction',swig_type(e)) != 1) e error("is not an ArithUnaryFunction") endif @@ -44,7 +44,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(c)) != 1) +if (strfind('ArithUnaryFunction',swig_type(c)) != 1) c error("is not an ArithUnaryFunction") endif @@ -57,7 +57,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(f)) != 1) +if (strfind('ArithUnaryFunction',swig_type(f)) != 1) f error("is not an ArithUnaryFunction") endif @@ -74,7 +74,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(g)) != 1) +if (strfind('ArithUnaryFunction',swig_type(g)) != 1) g error("is not an ArithUnaryFunction") error @@ -89,7 +89,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(h)) == -1) +if (strfind('ArithUnaryFunction',swig_type(h)) == -1) h error("is not an ArithUnaryFunction") endif diff --git a/Examples/test-suite/octave/template_typedef_cplx_runme.m b/Examples/test-suite/octave/template_typedef_cplx_runme.m index d00981cec..9e3e3888f 100644 --- a/Examples/test-suite/octave/template_typedef_cplx_runme.m +++ b/Examples/test-suite/octave/template_typedef_cplx_runme.m @@ -12,7 +12,7 @@ catch error("is not an instance") end_try_catch -if (findstr("ArithUnaryFunction",swig_type(d)) != 1) +if (strfind("ArithUnaryFunction",swig_type(d)) != 1) d error("is not an ArithUnaryFunction") endif @@ -24,7 +24,7 @@ catch error(e, "is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(e)) != 1); +if (strfind('ArithUnaryFunction',swig_type(e)) != 1); c error("is not an ArithUnaryFunction") endif @@ -42,7 +42,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(c)) != 1) +if (strfind('ArithUnaryFunction',swig_type(c)) != 1) c error("is not an ArithUnaryFunction") endif @@ -55,7 +55,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(f)) != 1) +if (strfind('ArithUnaryFunction',swig_type(f)) != 1) f error("is not an ArithUnaryFunction") endif @@ -72,7 +72,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(g)) != 1) +if (strfind('ArithUnaryFunction',swig_type(g)) != 1) g error("is not an ArithUnaryFunction") endif @@ -86,7 +86,7 @@ catch error("is not an instance") end_try_catch -if (findstr('ArithUnaryFunction',swig_type(h)) != 1) +if (strfind('ArithUnaryFunction',swig_type(h)) != 1) h error("is not an ArithUnaryFunction") endif From 4301fa548d1e4b9a53811d766e86301b9d473d9d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Jun 2019 19:32:06 +0100 Subject: [PATCH 1655/2031] Remove some legacy cruft from Python proxy class These methods are no longer used: _swig_getattr _swig_setattr _swig_setattr_nondynamic --- Source/Modules/python.cxx | 41 +++++++-------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index e9852ddf9..3d007d63f 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -707,40 +707,13 @@ public: Printf(f_shadow, "_swig_new_static_method = %s.SWIG_PyStaticMethod_New\n", module); } - { - // Python-2.2 object hack - Printv(f_shadow, - "\n", "def _swig_setattr_nondynamic(self, class_type, name, value, static=1):\n", - tab4, "if name == \"thisown\":\n", tab8, "return self.this.own(value)\n", - tab4, "if name == \"this\":\n", tab8, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", -#ifdef USE_THISOWN - tab4, tab8, "if hasattr(value,\"thisown\"):\n", tab8, tab8, "self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n", -#endif - tab4, tab8, "return\n", tab4, "method = class_type.__swig_setmethods__.get(name, None)\n", tab4, "if method:\n", tab4, tab4, "return method(self, value)\n", -#ifdef USE_THISOWN - tab4, "if not static or name == \"thisown\":\n", -#else - tab4, "if not static:\n", -#endif - NIL); - Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL); - Printv(f_shadow, - tab4, "else:\n", - tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n", - "\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL); - - Printv(f_shadow, - "\n", "def _swig_getattr(self, class_type, name):\n", - tab4, "if name == \"thisown\":\n", tab8, "return self.this.own()\n", - tab4, "method = class_type.__swig_getmethods__.get(name, None)\n", - tab4, "if method:\n", tab8, "return method(self)\n", - tab4, "raise AttributeError(\"'%s' object has no attribute '%s'\" % (class_type.__name__, name))\n\n", NIL); - - Printv(f_shadow, - "\n", "def _swig_repr(self):\n", - tab4, "try:\n", tab8, "strthis = \"proxy of \" + self.this.__repr__()\n", - tab4, "except __builtin__.Exception:\n", tab8, "strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); - } + Printv(f_shadow, "\n", + "def _swig_repr(self):\n", + tab4, "try:\n", + tab4, tab4, "strthis = \"proxy of \" + self.this.__repr__()\n", + tab4, "except __builtin__.Exception:\n", + tab4, tab4, "strthis = \"\"\n", + tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); Printv(f_shadow, "\n", "def _swig_setattr_nondynamic_instance_variable(set):\n", From 3045ba3532443dc1fa03035c5ac228af5aa5840d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 08:22:54 +0100 Subject: [PATCH 1656/2031] Warning suppression on testcase using clang --- Examples/test-suite/cpp11_constexpr.i | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i index 755efb0e0..420db4f83 100644 --- a/Examples/test-suite/cpp11_constexpr.i +++ b/Examples/test-suite/cpp11_constexpr.i @@ -4,6 +4,15 @@ %module cpp11_constexpr +%{ +#if defined(__clang__) +#pragma clang diagnostic push +// Suppress: 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior +// For MMM() and NNN() +#pragma clang diagnostic ignored "-Wconstexpr-not-const" +#endif +%} + %inline %{ #ifdef SWIG #define SWIGTESTCONST const From c8cef5c2f223062340bad0c983d475bf418b1907 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 08:24:25 +0100 Subject: [PATCH 1657/2031] Fix constexpr-not-const clang warning in testcase 'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior [-Werror,-Wconstexpr-not-const] --- Examples/test-suite/cpp11_template_typedefs.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/cpp11_template_typedefs.i b/Examples/test-suite/cpp11_template_typedefs.i index 02cb8ac30..5f1f2e6f9 100644 --- a/Examples/test-suite/cpp11_template_typedefs.i +++ b/Examples/test-suite/cpp11_template_typedefs.i @@ -15,7 +15,7 @@ public: using type2_t = T2; T1 a; T2 b; - constexpr int get_n() { return N; } + constexpr int get_n() const { return N; } }; // Specialization for T1=const char*, T2=bool @@ -26,7 +26,7 @@ public: using type2_t = bool; type1_t a; type2_t b; - constexpr int get_n() { return 3 * N; } + constexpr int get_n() const { return 3 * N; } }; // alias templates From f3357f1f5709f6008418f839cca336250c807841 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 19:05:46 +0100 Subject: [PATCH 1658/2031] Remove use of std::bind2nd which is removed in C++17 --- Doc/Manual/Library.html | 4 ++-- Examples/guile/std_vector/example.h | 5 ++--- Examples/mzscheme/std_vector/example.h | 5 ++--- Examples/ocaml/std_vector/example.h | 5 ++--- Examples/python/std_vector/example.h | 5 ++--- Examples/ruby/std_vector/example.h | 5 ++--- Examples/scilab/std_vector/example.h | 5 ++--- Examples/tcl/std_vector/example.h | 5 ++--- Examples/test-suite/li_std_deque.i | 4 ++-- Examples/test-suite/li_std_list.i | 4 ++-- Examples/test-suite/li_std_vector.i | 4 ++-- Examples/test-suite/li_std_vector_extra.i | 4 ++-- 12 files changed, 24 insertions(+), 31 deletions(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index eeb2e5a57..560859234 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -1581,8 +1581,8 @@ std::vector<double> half(const std::vector<double>& v) { } void halve_in_place(std::vector<double>& v) { - std::transform(v.begin(), v.end(), v.begin(), - std::bind2nd(std::divides<double>(), 2.0)); + for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/guile/std_vector/example.h b/Examples/guile/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/guile/std_vector/example.h +++ b/Examples/guile/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/mzscheme/std_vector/example.h b/Examples/mzscheme/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/mzscheme/std_vector/example.h +++ b/Examples/mzscheme/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/ocaml/std_vector/example.h b/Examples/ocaml/std_vector/example.h index b75359243..d968f6953 100644 --- a/Examples/ocaml/std_vector/example.h +++ b/Examples/ocaml/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/python/std_vector/example.h b/Examples/python/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/python/std_vector/example.h +++ b/Examples/python/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/ruby/std_vector/example.h b/Examples/ruby/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/ruby/std_vector/example.h +++ b/Examples/ruby/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/scilab/std_vector/example.h +++ b/Examples/scilab/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/tcl/std_vector/example.h b/Examples/tcl/std_vector/example.h index 4f0dac70d..52e260d6d 100644 --- a/Examples/tcl/std_vector/example.h +++ b/Examples/tcl/std_vector/example.h @@ -17,9 +17,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - // would you believe this is the same as the above? - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } diff --git a/Examples/test-suite/li_std_deque.i b/Examples/test-suite/li_std_deque.i index 152bc86c1..c2f4a7f45 100644 --- a/Examples/test-suite/li_std_deque.i +++ b/Examples/test-suite/li_std_deque.i @@ -36,8 +36,8 @@ std::deque half(const std::deque& v) { } void halve_in_place(std::deque& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::deque::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } %} diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/li_std_list.i index 9cc6220d2..2ed5b9ad7 100644 --- a/Examples/test-suite/li_std_list.i +++ b/Examples/test-suite/li_std_list.i @@ -30,8 +30,8 @@ double average(std::list v) { void halve_in_place(std::list& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::list::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } struct Struct { diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index ada146cc4..33fb79720 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -48,8 +48,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } struct Struct { diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 103242b24..70b776b37 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -62,8 +62,8 @@ std::vector half(const std::vector& v) { } void halve_in_place(std::vector& v) { - std::transform(v.begin(),v.end(),v.begin(), - std::bind2nd(std::divides(),2.0)); + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + *it /= 2.0; } %} From 5c1c69d14040bc5e04d4682f43ceeb45af93e1ca Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Jun 2019 19:55:15 +0100 Subject: [PATCH 1659/2031] Replace std::unexpected_handler with std::terminate_handler to be c++17 compliant Closes #1538 --- Lib/python/director.swg | 11 +++++------ Lib/ruby/director.swg | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 4bdc94dc2..36df302f1 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -219,7 +219,7 @@ namespace Swig { PyErr_Print(); std::cerr << std::endl; - std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl + std::cerr << "This exception was caught by the SWIG UnknownExceptionHandler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will likely abort/terminate." << std::endl; @@ -227,14 +227,13 @@ namespace Swig { } public: - - std::unexpected_handler old; - UnknownExceptionHandler(std::unexpected_handler nh = handler) { - old = std::set_unexpected(nh); + std::terminate_handler old; + UnknownExceptionHandler(std::terminate_handler nh = handler) { + old = std::set_terminate(nh); } ~UnknownExceptionHandler() { - std::set_unexpected(old); + std::set_terminate(old); } #endif }; diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index c6c53a343..a0569785f 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -170,7 +170,7 @@ namespace Swig { std::cerr << std::endl << "Ruby interpreter traceback:" << std::endl; std::cerr << std::endl; - std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl + std::cerr << "This exception was caught by the SWIG UnknownExceptionHandler." << std::endl << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl << std::endl << "Exception is being re-thrown, program will like abort/terminate." << std::endl; @@ -178,13 +178,13 @@ namespace Swig { } public: - std::unexpected_handler old; - UnknownExceptionHandler(std::unexpected_handler nh = handler) { - old = std::set_unexpected(nh); + std::terminate_handler old; + UnknownExceptionHandler(std::terminate_handler nh = handler) { + old = std::set_terminate(nh); } ~UnknownExceptionHandler() { - std::set_unexpected(old); + std::set_terminate(old); } #endif }; From d6ef11821944d697cc946f1c5d05999285785f5d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Jun 2019 18:44:05 +0100 Subject: [PATCH 1660/2031] std::auto_ptr replacement for testing with C++17 and later Keep suppressing deprecated warnings for C++11 and C++14 --- Examples/test-suite/li_std_auto_ptr.i | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i index 7693a3118..5bde387a3 100644 --- a/Examples/test-suite/li_std_auto_ptr.i +++ b/Examples/test-suite/li_std_auto_ptr.i @@ -18,11 +18,29 @@ %auto_ptr(Klass) -%inline %{ - +%{ +#if __cplusplus < 201703L #include +#else +// Simple std::auto_ptr implementation for testing after its removal in C++17 +namespace std { + template class auto_ptr { + T *ptr; + public: + auto_ptr(T *ptr = 0) : ptr(ptr) {} + auto_ptr(auto_ptr&& a) : ptr(a.ptr) { a.ptr = 0;} + ~auto_ptr() { delete ptr; } + T *release() { T *p = ptr; ptr = 0; return p; } + auto_ptr& operator=(auto_ptr&& a) { if (&a != this) { delete ptr; ptr = a.ptr; a.ptr = 0; } return *this; } + }; +} +#endif + #include #include "swig_examples_lock.h" +%} + +%inline %{ class Klass { public: From 06e5ab897561309dce7b8ecbaeb333bbe152f373 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Jun 2019 19:23:55 +0100 Subject: [PATCH 1661/2031] Workaround clang 10.0.1 C++17 linker errors in testcases Fixes: Undefined symbols for architecture x86_64: "___cxa_deleted_virtual" which clang issues when a class deletes a method (seems to be when the function is not one of the compiler's automatically added special member functions). --- Examples/test-suite/cpp11_default_delete.i | 6 ++++++ Examples/test-suite/cpp11_noexcept.i | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Examples/test-suite/cpp11_default_delete.i b/Examples/test-suite/cpp11_default_delete.i index b5e84ed51..0c20fb7ee 100644 --- a/Examples/test-suite/cpp11_default_delete.i +++ b/Examples/test-suite/cpp11_default_delete.i @@ -28,7 +28,13 @@ A1::A1(const A1&) = default; struct A2 { void funk(int i) {} + +// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python): +// Undefined symbols for architecture x86_64:"___cxa_deleted_virtual", referenced from: vtable for A2 +#if !(defined(__clang__) && __cplusplus >= 201703L) virtual void fff(int) = delete; +#endif + virtual ~A2() = default; template void funk(T) = delete; }; diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i index a77eb046f..8aa0baa5a 100644 --- a/Examples/test-suite/cpp11_noexcept.i +++ b/Examples/test-suite/cpp11_noexcept.i @@ -31,8 +31,13 @@ struct NoExceptClass { void noo1() const noexcept {} static void noo2() noexcept {} virtual void noo3() const noexcept {} + +// Workaround clang 10.0.1 -std=c++17 linker error (oddly for Java and not Python): +// Undefined symbols for architecture x86_64: "___cxa_deleted_virtual", referenced from: vtable for NoExceptClass +#if !(defined(__clang__) && __cplusplus >= 201703L) virtual void noo4() const noexcept = delete; virtual void noo5() const throw() = delete; +#endif }; struct NoExceptAbstract { From 959c2283818e76903901dddfea041d451eade686 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 Jun 2019 08:02:30 +0100 Subject: [PATCH 1662/2031] Test clang 10.0.1 C++17 - xcode 10.2 --- .travis.yml | 8 ++++++++ Tools/travis-osx-install.sh | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fe9a615c1..60196c3c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -422,6 +422,14 @@ matrix: - compiler: clang os: osx env: SWIGLANG=tcl + - compiler: clang + os: osx + env: SWIGLANG=java CPP17=1 + osx_image: xcode10.2 + - compiler: clang + os: osx + env: SWIGLANG=python PY3=3 CPP17=1 + osx_image: xcode10.2 allow_failures: # seg fault in director_basic testcase diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 1cf73c5c0..393d96e60 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -27,9 +27,6 @@ case "$SWIGLANG" in ;; "python") WITHLANG=$SWIGLANG$PY3 - if [[ "$PY3" ]]; then - travis_retry brew upgrade python - fi ;; esac From b655d3138b2dff046912041c036b2dd87a195a81 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 24 Jun 2019 08:37:29 +0100 Subject: [PATCH 1663/2031] Remove the UnknownExceptionHandler director error handling class Done in order to be C++17 compliant as it uses std::unexpected_handler which was removed in C++17. This class was intended for director exception handling but was never used by SWIG and was never documented. Closes #1538 --- CHANGES.current | 8 ++++++++ Lib/python/director.swg | 39 --------------------------------------- Lib/ruby/director.swg | 37 ------------------------------------- 3 files changed, 8 insertions(+), 76 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 99b31d5c9..e0b7f0897 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-06-24: wsfulton + [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be + C++17 compliant as it uses std::unexpected_handler which was removed in C++17. + This class was intended for director exception handling but was never used by + SWIG and was never documented. + + *** POTENTIAL INCOMPATIBILITY *** + 2019-06-06: bkotzz [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes a native Java array as input. diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 36df302f1..9694c6233 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -199,45 +199,6 @@ namespace Swig { } }; - /* unknown exception handler */ - class UnknownExceptionHandler { -#ifdef SWIG_DIRECTOR_UEH - static void handler() { - try { - throw; - } catch (DirectorException& e) { - std::cerr << "SWIG Director exception caught:" << std::endl - << e.what() << std::endl; - } catch (std::exception& e) { - std::cerr << "std::exception caught: "<< e.what() << std::endl; - } catch (...) { - std::cerr << "Unknown exception caught." << std::endl; - } - - std::cerr << std::endl - << "Python interpreter traceback:" << std::endl; - PyErr_Print(); - std::cerr << std::endl; - - std::cerr << "This exception was caught by the SWIG UnknownExceptionHandler." << std::endl - << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl - << std::endl - << "Exception is being re-thrown, program will likely abort/terminate." << std::endl; - throw; - } - - public: - std::terminate_handler old; - UnknownExceptionHandler(std::terminate_handler nh = handler) { - old = std::set_terminate(nh); - } - - ~UnknownExceptionHandler() { - std::set_terminate(old); - } -#endif - }; - /* type mismatch in the return value from a python method call */ class DirectorTypeMismatchException : public DirectorException { public: diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index a0569785f..9395b8183 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -153,43 +153,6 @@ namespace Swig { } }; - /* unknown exception handler */ - class UnknownExceptionHandler { -#ifdef SWIG_DIRECTOR_UEH - static void handler() { - try { - throw; - } catch (DirectorException& e) { - std::cerr << "SWIG Director exception caught:" << std::endl - << e.what() << std::endl; - } catch (std::exception& e) { - std::cerr << "std::exception caught: "<< e.what() << std::endl; - } catch (...) { - std::cerr << "Unknown exception caught." << std::endl; - } - std::cerr << std::endl - << "Ruby interpreter traceback:" << std::endl; - std::cerr << std::endl; - std::cerr << "This exception was caught by the SWIG UnknownExceptionHandler." << std::endl - << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl - << std::endl - << "Exception is being re-thrown, program will like abort/terminate." << std::endl; - throw; - } - - public: - std::terminate_handler old; - UnknownExceptionHandler(std::terminate_handler nh = handler) { - old = std::set_terminate(nh); - } - - ~UnknownExceptionHandler() { - std::set_terminate(old); - } -#endif - }; - - /* Type mismatch in the return value from a Ruby method call */ class DirectorTypeMismatchException : public DirectorException { public: From 22c27cf216c9c256960bf6e1b03c11ce08ddbf18 Mon Sep 17 00:00:00 2001 From: Isaac Pascual Monells Date: Thu, 27 Jun 2019 15:39:37 +0200 Subject: [PATCH 1664/2031] Fix class name for nested classes The feature %interface_impl from swiginterface.i differ on generated function name from JNI wrapper class when using nested classes without flatnested. --- Source/Modules/java.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index cb41781dd..259f23f8e 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1876,7 +1876,7 @@ public: Replaceall(cptr_method_name, ".", "_"); Replaceall(cptr_method_name, "$interfacename", interface_name); - String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name); + String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name); upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); Delete(upcast_method_name); Delete(cptr_method_name); From b58995c89e1bec1eaa0ac22ceb3a8202e910f0e4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Jun 2019 08:09:47 +0100 Subject: [PATCH 1665/2031] $arg and $input were incorrectly substituted in the argout typemap when two or more arguments were present. Closes #1559 --- CHANGES.current | 4 ++++ Source/Modules/mzscheme.cxx | 6 ++---- Source/Modules/ocaml.cxx | 6 ++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e0b7f0897..23c800f94 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-06-28: wsfulton + [MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the + argout typemap when two or more arguments were present. + 2019-06-24: wsfulton [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be C++17 compliant as it uses std::unexpected_handler which was removed in C++17. diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 543874172..788681330 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -221,7 +221,6 @@ public: Wrapper *f = NewWrapper(); String *proc_name = NewString(""); - String *source = NewString(""); String *target = NewString(""); String *arg = NewString(""); String *cleanup = NewString(""); @@ -312,10 +311,9 @@ public: String *ln = Getattr(p, "lname"); // Produce names of source and target - Clear(source); Clear(target); Clear(arg); - Printf(source, "argv[%d]", i); + String *source = NewStringf("argv[%d]", i); Printf(target, "%s", ln); Printv(arg, Getattr(p, "name"), NIL); @@ -339,6 +337,7 @@ public: if (i >= numreq) { Printf(f->code, "}\n"); } + Delete(source); } /* Insert constraint checking code */ @@ -465,7 +464,6 @@ public: } Delete(proc_name); - Delete(source); Delete(target); Delete(arg); Delete(outarg); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index ad9c94800..6f2a34962 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -473,7 +473,6 @@ public: Wrapper *f = NewWrapper(); String *proc_name = NewString(""); - String *source = NewString(""); String *target = NewString(""); String *arg = NewString(""); String *cleanup = NewString(""); @@ -580,10 +579,9 @@ public: pt = SwigType_typedef_qualified(pt); // Produce names of source and target - Clear(source); Clear(target); Clear(arg); - Printf(source, "caml_list_nth(args,%d)", i); + String *source = NewStringf("caml_list_nth(args,%d)", i); Printf(target, "%s", ln); Printv(arg, Getattr(p, "name"), NIL); @@ -607,6 +605,7 @@ public: if (i >= numreq) { Printf(f->code, "}\n"); } + Delete(source); } /* Insert constraint checking code */ @@ -787,7 +786,6 @@ public: Printf(f_mlibody, "val %s : c_obj -> c_obj\n", mangled_name); Delete(proc_name); - Delete(source); Delete(target); Delete(arg); Delete(outarg); From 84e310402ac72e890ce91e44a6a6fce1e2b6a796 Mon Sep 17 00:00:00 2001 From: Isaac Pascual Monells Date: Tue, 2 Jul 2019 12:57:16 +0200 Subject: [PATCH 1666/2031] Add nested_inheritance_interface test --- Examples/test-suite/common.mk | 1 + .../nested_inheritance_interface_runme.java | 28 +++++++++++++++++++ .../test-suite/nested_inheritance_interface.i | 15 ++++++++++ 3 files changed, 44 insertions(+) create mode 100644 Examples/test-suite/java/nested_inheritance_interface_runme.java create mode 100644 Examples/test-suite/nested_inheritance_interface.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 67a63287d..795dc6209 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -324,6 +324,7 @@ CPP_TEST_CASES += \ nested_directors \ nested_comment \ nested_ignore \ + nested_inheritance_interface \ nested_in_template \ nested_scope \ nested_template_base \ diff --git a/Examples/test-suite/java/nested_inheritance_interface_runme.java b/Examples/test-suite/java/nested_inheritance_interface_runme.java new file mode 100644 index 000000000..92f83ee22 --- /dev/null +++ b/Examples/test-suite/java/nested_inheritance_interface_runme.java @@ -0,0 +1,28 @@ +import nested_inheritance_interface.*; +import java.util.Arrays; + +public class nested_inheritance_interface_runme { + + static { + try { + System.loadLibrary("nested_inheritance_interface"); + } 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[]) { + Class[] BNInterfaces = B.N.class.getInterfaces(); + String expectedInterfacesString = "[interface nested_inheritance_interface.IASwigInterface]"; + String actualInterfacesString = Arrays.toString(BNInterfaces); + if (!expectedInterfacesString.equals(actualInterfacesString)) + throw new RuntimeException("Expected interfaces for " + B.N.class.getName() + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString); + + if (!IASwigInterface.class.isInterface()) + throw new RuntimeException(IASwigInterface.class.getName() + " should be an interface but is not"); + + // overloaded methods check + B.N d = new B.N(); + } +} diff --git a/Examples/test-suite/nested_inheritance_interface.i b/Examples/test-suite/nested_inheritance_interface.i new file mode 100644 index 000000000..2d144ff72 --- /dev/null +++ b/Examples/test-suite/nested_inheritance_interface.i @@ -0,0 +1,15 @@ +%module nested_inheritance_interface + +%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, + SWIGWARN_D_MULTIPLE_INHERITANCE, + SWIGWARN_PHP_MULTIPLE_INHERITANCE); /* languages not supporting multiple inheritance or %interface */ + +#if defined(SWIGJAVA) || defined(SWIGCSHARP) +%include "swiginterface.i" +%interface(IA) +#endif + +%inline %{ +struct IA {}; +struct B { struct N : IA {}; }; +%} From ce80fdf426ef0e2cdbfa858a51e18167b8bdbea3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jul 2019 07:58:28 +0100 Subject: [PATCH 1667/2031] Add Python whitespace pydoc improvements to changes file --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 23c800f94..da631bc1d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-05: wsfulton + [Python] #1547 Whitespace fixes in Doxygen translated comments into pydoc comments + for Sphinx compatibility. + 2019-06-28: wsfulton [MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the argout typemap when two or more arguments were present. From b55ce0cf847e363f9300be5372e705954c9e3a15 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jul 2019 21:56:25 +0100 Subject: [PATCH 1668/2031] Fix appveyor cygwin Python testing Cygwin python package that needs to be installed has changed from python-devel to python2-devel. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 10bf064df..42eaa36f4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -89,7 +89,7 @@ install: - if "%OSVARIANT%"=="" bash -c "cl.exe /? 2>&1 | head -n 1" - if "%OSVARIANT%"=="" bash -c "which csc.exe" - if "%OSVARIANT%"=="" bash -c "csc.exe /? | head -n 1" -- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt" +- if "%OSVARIANT%"=="cygwin" %CYGWINSETUP% --quiet-mode --packages python2-devel,libpcre-devel,libboost-devel > cygwin-install.txt || bash -c "cat cygwin-install.txt" - if "%OSVARIANT%"=="mingw" bash -c "pacman --noconfirm --sync mingw%MBITS%/mingw-w64-%MARCH%-pcre mingw%MBITS%/mingw-w64-%MARCH%-boost" - if not "%WITHLANG%"=="" set SWIGWITHLANG==%WITHLANG% - if not "%WITHLANG%"=="" where %WITHLANG% From 58863bba59b8314bf5f4a669c4133ac2135a2b2e Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Fri, 21 Jun 2019 16:55:30 +0100 Subject: [PATCH 1669/2031] Change C# bool[] typemaps to marshall as 1-byte Default marshalling for bool[] now uses 1-byte entries in the array, to ensure array contents is as expected in C++. When running under mono csharp_lib_arrays_bool testcase will fail due to an apparent bug in mono. Works correctly under Microsoft's runtime. See https://github.com/mono/mono/issues/15592 --- Examples/test-suite/csharp/Makefile.in | 5 ++ .../csharp/csharp_lib_arrays_bool_runme.cs | 78 +++++++++++++++++++ Examples/test-suite/csharp_lib_arrays_bool.i | 78 +++++++++++++++++++ Lib/csharp/arrays_csharp.i | 42 +++++++++- 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs create mode 100644 Examples/test-suite/csharp_lib_arrays_bool.i diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index c9e48f804..49608e809 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -19,6 +19,7 @@ CPP_TEST_CASES = \ csharp_exceptions \ csharp_features \ csharp_lib_arrays \ + csharp_lib_arrays_bool \ csharp_namespace_system_collision \ csharp_prepost \ csharp_typemaps \ @@ -36,6 +37,9 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ +# bool[] typemaps don't work correctly when running under mono +FAILING_CPP_TESTS = csharp_lib_arrays_bool + include $(srcdir)/../common.mk # Overridden variables here @@ -48,6 +52,7 @@ CSHARPFLAGSSPECIAL = intermediary_classname.cpptest: SWIGOPT += -dllimport intermediary_classname complextest.cpptest: CSHARPFLAGSSPECIAL = -r:System.Numerics.dll csharp_lib_arrays.cpptest: CSHARPFLAGSSPECIAL = -unsafe +csharp_lib_arrays_bool.cpptest: CSHARPFLAGSSPECIAL = -unsafe csharp_swig2_compatibility.cpptest: SWIGOPT += -DSWIG2_CSHARP # Rules for the different types of tests diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs new file mode 100644 index 000000000..25b7fe699 --- /dev/null +++ b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs @@ -0,0 +1,78 @@ +using System; +using csharp_lib_arrays_boolNamespace; + +public class runme +{ + static void Main() + { + { + bool[] source = { true, false, false, true, false, true, true, false }; + bool[] target = new bool[ source.Length ]; + + csharp_lib_arrays_bool.myArrayCopyUsingFixedArraysBool( source, target, target.Length ); + CompareArrays(source, target, "bool[] INPUT/OUTPUT Fixed"); + } + + { + bool[] source = { true, false, false, true, false, true, true, false }; + bool[] target = { false, true, true, false, true, false, false, true }; + + csharp_lib_arrays_bool.myArraySwapUsingFixedArraysBool( source, target, target.Length ); + + for (int i=0; i( T[] a, T[] b, string testName ) + { + if (a.Length != b.Length) + throw new Exception("size mismatch"); + + for(int i=0; i( T[] a ) + { + foreach ( T i in a ) + Console.Error.Write( "{0} ", i ); + Console.Error.WriteLine(); + } +} + diff --git a/Examples/test-suite/csharp_lib_arrays_bool.i b/Examples/test-suite/csharp_lib_arrays_bool.i new file mode 100644 index 000000000..58cee9d80 --- /dev/null +++ b/Examples/test-suite/csharp_lib_arrays_bool.i @@ -0,0 +1,78 @@ +%module csharp_lib_arrays_bool + +%include "arrays_csharp.i" + +%apply bool INPUT[] { bool* sourceArray } +%apply bool OUTPUT[] { bool* targetArray } + +%apply bool INOUT[] { bool* array1 } +%apply bool INOUT[] { bool* array2 } + +%inline %{ +#include + +/* copy the contents of the first array to the second */ +void myArrayCopyBool( bool* sourceArray, bool* targetArray, int nitems ) { + int i; + for ( i = 0; i < nitems; i++ ) { + targetArray[ i ] = sourceArray[ i ]; + } +} + +/* swap the contents of the two arrays */ +void myArraySwapBool( bool* array1, bool* array2, int nitems ) { + int i; + bool temp; + for ( i = 0; i < nitems; i++ ) { + temp = array1[ i ]; + array1[ i ] = array2[ i ]; + array2[ i ] = temp; + } +} + +bool checkBoolArrayCorrect( bool* sourceArray, int sourceArraySize ) { + if( sourceArraySize != 8 ) { + std::cout << "checkBoolArrayCorrect: Expected array with 8 elements" << std::endl; + return false; + } + return sourceArray[0] == true && + sourceArray[1] == false && + sourceArray[2] == false && + sourceArray[3] == true && + sourceArray[4] == false && + sourceArray[5] == true && + sourceArray[6] == true && + sourceArray[7] == false; +} +%} + +%clear bool* sourceArray; +%clear bool* targetArray; + +%clear bool* array1; +%clear bool* array2; + +// Below replicates the above array handling but this time using the pinned (fixed) array typemaps +%csmethodmodifiers myArrayCopyUsingFixedArraysBool "public unsafe"; +%csmethodmodifiers myArraySwapUsingFixedArraysBool "public unsafe"; + +%apply bool FIXED[] { bool* sourceArray } +%apply bool FIXED[] { bool* targetArray } + +%inline %{ +void myArrayCopyUsingFixedArraysBool( bool *sourceArray, bool* targetArray, int nitems ) { + myArrayCopyBool(sourceArray, targetArray, nitems); +} +%} + +%apply bool FIXED[] { bool* array1 } +%apply bool FIXED[] { bool* array2 } + +%inline %{ +void myArraySwapUsingFixedArraysBool( bool* array1, bool* array2, int nitems ) { + myArraySwapBool(array1, array2, nitems); +} +%} + + + diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i index 237067a88..861da8386 100644 --- a/Lib/csharp/arrays_csharp.i +++ b/Lib/csharp/arrays_csharp.i @@ -103,7 +103,47 @@ CSHARP_ARRAYS(long long, long) CSHARP_ARRAYS(unsigned long long, ulong) CSHARP_ARRAYS(float, float) CSHARP_ARRAYS(double, double) -CSHARP_ARRAYS(bool, bool) + +// By default C# will marshal bools as 4 bytes +// UnmanagedType.I1 will change this to 1 byte +// FIXME - When running on mono ArraySubType appears to be ignored and bools will be marshalled as 4-byte +// https://github.com/mono/mono/issues/15592 + +// input only arrays +%typemap(ctype) bool INPUT[] "bool*" +%typemap(cstype) bool INPUT[] "bool[]" +%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INPUT[] "bool[]" +%typemap(csin) bool INPUT[] "$csinput" + +%typemap(in) bool INPUT[] %{ +$1 = $input; +%} +%typemap(freearg) bool INPUT[] "" +%typemap(argout) bool INPUT[] "" + +// output only arrays +%typemap(ctype) bool OUTPUT[] "bool*" +%typemap(cstype) bool OUTPUT[] "bool[]" +%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool OUTPUT[] "bool[]" +%typemap(csin) bool OUTPUT[] "$csinput" + +%typemap(in) bool OUTPUT[] %{ +$1 = $input; +%} +%typemap(freearg) bool OUTPUT[] "" +%typemap(argout) bool OUTPUT[] "" + +// inout arrays +%typemap(ctype) bool INOUT[] "bool*" +%typemap(cstype) bool INOUT[] "bool[]" +%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.Out, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray,ArraySubType=System.Runtime.InteropServices.UnmanagedType.I1)]") bool INOUT[] "bool[]" +%typemap(csin) bool INOUT[] "$csinput" + +%typemap(in) bool INOUT[] %{ +$1 = $input; +%} +%typemap(freearg) bool INOUT[] "" +%typemap(argout) bool INOUT[] "" %define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE ) From 85a4c7ffc0baa9eb88e0e97997818eb3011086c0 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 1 Jun 2019 14:02:45 -0500 Subject: [PATCH 1670/2031] Doxygen comment parsing fix for empty lines in code/verbatim blocks Fix how end of paragraph is identified when parsing \code and \verbatim blocks that appear within a paragraph and contain an empty line. Previously this would generate a warning for unexpected end of doxygen comments, and it could generate a segfault due to dereferencing an invalid iterator value. The doxygen_basic_translate.i and doxygen_basic_translate_style2.i tests have been updated to serve as regression tests for this behavior. Prior to this fix, inclusion of the empty code block line in this context produced a segfault. --- Examples/test-suite/doxygen_basic_translate.i | 2 ++ Examples/test-suite/doxygen_basic_translate_style2.i | 2 ++ .../java/doxygen_basic_translate_runme.java | 2 ++ .../java/doxygen_basic_translate_style2_runme.java | 2 ++ .../python/doxygen_basic_translate_runme.py | 2 ++ .../python/doxygen_basic_translate_style2_runme.py | 2 ++ Source/Doxygen/doxyparser.cxx | 12 ++++++++++++ 7 files changed, 24 insertions(+) diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index 0a8b0474f..da4d80909 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -57,6 +57,8 @@ void function3(int a, int b) * \warning This may not work as expected * \code * int main() { while(true); } + * + * // Test blank line in code block * \endcode * \endif */ diff --git a/Examples/test-suite/doxygen_basic_translate_style2.i b/Examples/test-suite/doxygen_basic_translate_style2.i index 23e8de4f7..32e3cfcbe 100644 --- a/Examples/test-suite/doxygen_basic_translate_style2.i +++ b/Examples/test-suite/doxygen_basic_translate_style2.i @@ -55,6 +55,8 @@ void function3(int a, int b) * \warning This may not work as expected * \code * int main() { while(true); } + * + * // Test blank line in code block * \endcode * \endif */ diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index f307b3abc..ab343b560 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -54,6 +54,8 @@ public class doxygen_basic_translate_runme { " \n" + " {@code \n" + "int main() { while(true); } \n" + + "\n" + + "// Test blank line in code block \n" + " }\n" + " }\n" + " \n" + diff --git a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java index aa015eeac..05e51cff8 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java @@ -54,6 +54,8 @@ public class doxygen_basic_translate_style2_runme { " \n" + " {@code \n" + "int main() { while(true); } \n" + + "\n" + + "// Test blank line in code block \n" + " }\n" + " }\n" + " \n" + diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index b6023224d..9ef8dbd52 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -50,6 +50,8 @@ Warning: This may not work as expected .. code-block:: c++ int main() { while(true); } + + // Test blank line in code block }""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5), diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index 2d62eecbd..b75045d59 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -48,6 +48,8 @@ Warning: This may not work as expected .. code-block:: c++ int main() { while(true); } + + // Test blank line in code block }""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5), diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 3f413bcaa..cbad7c74d 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -289,6 +289,18 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &to TokenListCIt endOfParagraph = m_tokenListIt; while (endOfParagraph != tokList.end()) { + // If \code or \verbatim is encountered within a paragraph, then + // go all the way to the end of that command, since the content + // could contain empty lines that would appear to be paragraph + // ends: + if (endOfParagraph->m_tokenType == COMMAND && + (endOfParagraph->m_tokenString == "code" || + endOfParagraph->m_tokenString == "verbatim")) { + const string theCommand = endOfParagraph->m_tokenString; + endOfParagraph = getEndCommand("end" + theCommand, tokList); + endOfParagraph++; // Move after the end command + return endOfParagraph; + } if (endOfParagraph->m_tokenType == END_LINE) { endOfParagraph++; if (endOfParagraph != tokList.end() From 841d4b5fb9ca42e697faf28148abe2bcd7230da5 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 6 Jul 2019 11:07:50 -0500 Subject: [PATCH 1671/2031] Add iterator safety check in DoxygenParser::parse If the code called by DoxygenParser::parse does not behave correctly, it may move the iterator m_tokenListIt past the value endParsingIndex. This was not caught by the previous checks and could lead to dereferencing an invalid m_tokenListIt iterator value (and segfault). This is now protected against by using a less than check in the while loop instead of not equals. A warning is also printed if endParsingIndex is exceeded. --- Source/Doxygen/doxyparser.cxx | 8 +++++++- Source/Include/swigwarn.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index cbad7c74d..2e826b265 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -971,7 +971,9 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const Token std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string"; DoxygenEntityList aNewList; - while (m_tokenListIt != endParsingIndex) { + // Less than check (instead of not equal) is a safeguard in case the + // iterator is incremented past the end + while (m_tokenListIt < endParsingIndex) { Token currToken = *m_tokenListIt; @@ -988,6 +990,10 @@ DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex, const Token addCommand(currPlainstringCommandType, tokList, aNewList); } + // If addCommand above misbehaves, it can move the iterator past endParsingIndex + if (m_tokenListIt > endParsingIndex) + printListError(WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE, "Unexpected iterator value in DoxygenParser::parse"); + if (endParsingIndex != tokList.end() && m_tokenListIt == tokList.end()) { // this could happen if we can't reach the original endParsingIndex printListError(WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT, "Unexpected end of Doxygen comment encountered."); diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index fbcea4dbd..a08693ac8 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -221,6 +221,7 @@ #define WARN_DOXYGEN_HTML_ERROR 563 #define WARN_DOXYGEN_COMMAND_ERROR 564 #define WARN_DOXYGEN_UNKNOWN_CHARACTER 565 +#define WARN_DOXYGEN_UNEXPECTED_ITERATOR_VALUE 566 /* -- Reserved (600-799) -- */ From 63497c8d0eb9c5eefab0a5bc880f2801cb6cb595 Mon Sep 17 00:00:00 2001 From: Isaac Pascual Monells Date: Mon, 8 Jul 2019 12:49:00 +0200 Subject: [PATCH 1672/2031] Fix class name for nested classes --- Source/Modules/csharp.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ff73c3075..76ec6a4fb 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1732,7 +1732,7 @@ public: Replaceall(cptr_method_name, ".", "_"); Replaceall(cptr_method_name, "$interfacename", interface_name); - String *upcast_method_name = Swig_name_member(getNSpace(), proxy_class_name, cptr_method_name); + String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name); upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); Delete(upcast_method_name); From f1f98348b430c3e6c7083eb62158a79ca9a36869 Mon Sep 17 00:00:00 2001 From: Isaac Pascual Monells Date: Mon, 8 Jul 2019 12:49:28 +0200 Subject: [PATCH 1673/2031] Add nested_inheritance_interface test for csharp --- .../nested_inheritance_interface_runme.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Examples/test-suite/csharp/nested_inheritance_interface_runme.cs diff --git a/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs new file mode 100644 index 000000000..ca0f01595 --- /dev/null +++ b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using nested_inheritance_interfaceNamespace; + +public class nested_inheritance_interface_runme { + + static string SortArrayToString(string[] types) { + Array.Sort(types); + return string.Join(" ", types); + } + + static string SortArrayToString(Type[] types) { + List stypes = new List(); + foreach (Type t in types) + stypes.Add(t.Name); + return SortArrayToString(stypes.ToArray()); + } + + public static void Main() { + Type[] BNInterfaces = typeof(B.N).GetInterfaces(); + string expectedInterfacesString = "IASwigInterface IDisposable"; + string actualInterfacesString = SortArrayToString(BNInterfaces); + if (expectedInterfacesString != actualInterfacesString) + throw new Exception("Expected interfaces for " + typeof(B.N).Name + ": \n" + expectedInterfacesString + "\n" + "Actual interfaces: \n" + actualInterfacesString); + + if (!typeof(IASwigInterface).IsInterface) + throw new Exception(typeof(IASwigInterface).Name + " should be an interface but is not"); + + // overloaded methods check + B.N d = new B.N(); + } +} From 75c5cb74581227c0261e3451dd67828af5b2c125 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Jul 2019 08:06:18 +0100 Subject: [PATCH 1674/2031] gcc-9 testcase warning fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] --- Examples/test-suite/cpp11_initializer_list.i | 22 ++++++++++++++++--- .../java/cpp11_initializer_list_runme.java | 21 ++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/java/cpp11_initializer_list_runme.java diff --git a/Examples/test-suite/cpp11_initializer_list.i b/Examples/test-suite/cpp11_initializer_list.i index 58d2ecc50..b309576c1 100644 --- a/Examples/test-suite/cpp11_initializer_list.i +++ b/Examples/test-suite/cpp11_initializer_list.i @@ -6,12 +6,21 @@ %ignore A::A(std::initializer_list); %ignore B::method; -%typemap(in) std::initializer_list { +%typemap(in) std::initializer_list %{ $1 = {"Ab", "Fab"}; -} +%} + +%begin %{ +#if __GNUC__ >= 9 +/* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */ +/* incorrect warning for C::C(std::initializer_list) */ +#pragma GCC diagnostic ignored "-Winit-list-lifetime" +#endif +%} %inline %{ #include +#include class A { public: @@ -26,9 +35,16 @@ public: void method(std::initializer_list init) {} }; class C { + std::string joined; public: - C(std::initializer_list) {} + C(std::initializer_list init) { + for (auto& val : init) + joined += val; + } C() {} + const char * get_joined_string() { + return joined.c_str(); + } }; %} diff --git a/Examples/test-suite/java/cpp11_initializer_list_runme.java b/Examples/test-suite/java/cpp11_initializer_list_runme.java new file mode 100644 index 000000000..0318c9e90 --- /dev/null +++ b/Examples/test-suite/java/cpp11_initializer_list_runme.java @@ -0,0 +1,21 @@ + +import cpp11_initializer_list.*; + +public class cpp11_initializer_list_runme { + + static { + try { + System.loadLibrary("cpp11_initializer_list"); + } 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[]) { + C c = new C(null); + String joined = c.get_joined_string(); + if (!joined.equals("AbFab")) + throw new RuntimeException("Wrong joined string " + joined); + } +} From 35e24ebd668d2c2596c83183fa718709a5d175bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Jul 2019 08:12:05 +0100 Subject: [PATCH 1675/2031] Testcase warning fix for gcc-9 warning: returning reference to temporary [-Wreturn-local-addr] --- Examples/test-suite/cpp11_rvalue_reference2.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/cpp11_rvalue_reference2.i b/Examples/test-suite/cpp11_rvalue_reference2.i index 9aaf4accb..a2a0020f5 100644 --- a/Examples/test-suite/cpp11_rvalue_reference2.i +++ b/Examples/test-suite/cpp11_rvalue_reference2.i @@ -31,7 +31,7 @@ struct Thingy { // test both primitive and user defined rvalue reference default arguments and compactdefaultargs void compactDefaultArgs(const bool &&b = (const bool &&)PublicGlobalTrue, const UserDef &&u = (const UserDef &&)PublicUserDef) {} void privateDefaultArgs(const bool &&b = (const bool &&)PrivateTrue) {} - operator int &&() { return std::move(0); } + operator int &&() { return std::move(val); } Thingy(const Thingy& rhs) : val(rhs.val), lvalref(rhs.lvalref), rvalref(std::move(rhs.rvalref)) {} Thingy& operator=(const Thingy& rhs) { val = rhs.val; From 890cf9aaa3fbce02fa125a54968e76ab7b569ae7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Jul 2019 18:52:32 +0100 Subject: [PATCH 1676/2031] Add gcc-9 testing on Travis --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index 60196c3c5..bf9010973 100644 --- a/.travis.yml +++ b/.travis.yml @@ -383,6 +383,18 @@ matrix: env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.7 sudo: required dist: xenial + - os: linux + env: SWIGLANG=csharp GCC=9 CPP17=1 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG=java GCC=9 CPP17=1 + sudo: required + dist: xenial + - os: linux + env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.7 + sudo: required + dist: xenial - compiler: gcc os: osx env: SWIGLANG= From 20d96531e3a5fef442a13dee55020d53a452d7f8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Jul 2019 19:32:08 +0100 Subject: [PATCH 1677/2031] nested_inheritance_interface testcase enhancement Fixes unused variable reported by C# compiler and enhance test slightly --- CHANGES.current | 4 ++++ .../test-suite/csharp/nested_inheritance_interface_runme.cs | 4 ++++ .../test-suite/java/nested_inheritance_interface_runme.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e0b7f0897..8aef21f75 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-09: IsaacPascual + [C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros + in swiginterface.i when wrapping nested C++ classes. + 2019-06-24: wsfulton [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be C++17 compliant as it uses std::unexpected_handler which was removed in C++17. diff --git a/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs index ca0f01595..810b7db6d 100644 --- a/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs +++ b/Examples/test-suite/csharp/nested_inheritance_interface_runme.cs @@ -16,6 +16,9 @@ public class nested_inheritance_interface_runme { return SortArrayToString(stypes.ToArray()); } + private static void takeIA(IASwigInterface ia) { + } + public static void Main() { Type[] BNInterfaces = typeof(B.N).GetInterfaces(); string expectedInterfacesString = "IASwigInterface IDisposable"; @@ -28,5 +31,6 @@ public class nested_inheritance_interface_runme { // overloaded methods check B.N d = new B.N(); + takeIA(d); } } diff --git a/Examples/test-suite/java/nested_inheritance_interface_runme.java b/Examples/test-suite/java/nested_inheritance_interface_runme.java index 92f83ee22..8436ec294 100644 --- a/Examples/test-suite/java/nested_inheritance_interface_runme.java +++ b/Examples/test-suite/java/nested_inheritance_interface_runme.java @@ -12,6 +12,9 @@ public class nested_inheritance_interface_runme { } } + private static void takeIA(IASwigInterface ia) { + } + public static void main(String argv[]) { Class[] BNInterfaces = B.N.class.getInterfaces(); String expectedInterfacesString = "[interface nested_inheritance_interface.IASwigInterface]"; @@ -24,5 +27,6 @@ public class nested_inheritance_interface_runme { // overloaded methods check B.N d = new B.N(); + takeIA(d); } } From fdb6bab27312d18ee6fb6206248d3cb1a40415e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Jul 2019 19:38:31 +0100 Subject: [PATCH 1678/2031] Add gcc-9 testing with default flags --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index bf9010973..c9cbd7862 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,10 @@ matrix: env: SWIGLANG= GCC=8 sudo: required dist: xenial + - os: linux + env: SWIGLANG= GCC=9 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=csharp From 2db6b4271538626290ccaaaa73b97ef126d37191 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Jul 2019 07:14:00 +0100 Subject: [PATCH 1679/2031] Add doxygen parser fix to changes file --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 22f074616..2ed9d208a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-11: mcfarljm + #1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like + \code. + 2019-07-09: IsaacPascual [C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros in swiginterface.i when wrapping nested C++ classes. From 53d75dc133f9fb3fb36cb5bc53c0a2d2b135da9f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 26 Jun 2019 01:14:14 +0200 Subject: [PATCH 1680/2031] Replace leftover string with the proper type in C# set typemap This is just a mistake remaining from generalizing the old string-specific typemap to any type. Fix it now and update a unit test to test for sets of objects other than strings. --- Examples/test-suite/csharp/li_std_set_runme.cs | 7 +++++++ Examples/test-suite/java/li_std_set_runme.java | 6 ++++++ Examples/test-suite/li_std_set.i | 18 ++++++++++++++++++ Lib/csharp/std_set.i | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs index 6519e8c8d..0e353c46d 100644 --- a/Examples/test-suite/csharp/li_std_set_runme.cs +++ b/Examples/test-suite/csharp/li_std_set_runme.cs @@ -85,5 +85,12 @@ public class runme ss = new StringSet{"foo", "bar", "baz"}; ss.UnionWith(new[] {"baz", "quux"}); checkThat(ss.SetEquals(new[] {"foo", "bar", "baz", "quux"}), "UnionWith works"); + + // Check a set of another type. + FooSet fooSet = new FooSet(); + ISet fooISet = fooSet; + checkThat(fooISet.Count == 0, "is initially empty"); + checkThat(fooISet.Add(new Foo(17)), "added successfully"); + checkThat(fooISet.Count == 1, "is not empty any more"); } } diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java index 9763484c2..017908c21 100644 --- a/Examples/test-suite/java/li_std_set_runme.java +++ b/Examples/test-suite/java/li_std_set_runme.java @@ -71,5 +71,11 @@ public class li_std_set_runme { checkThat(ss.removeAll(found)); checkThat(ss.isEmpty()); checkThat(ss.size() == 0); + + // Check a set of another type. + java.util.AbstractSet fooSet = new FooSet(); + checkThat(fooSet.isEmpty()); + checkThat(fooSet.add(new Foo(17))); + checkThat(fooSet.size() == 1); } } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index bb952cd85..45eda51ff 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -23,7 +23,25 @@ %template(v_int) std::vector; %template(set_string) std::set; #elif defined(SWIGJAVA) || defined(SWIGCSHARP) + // This operator is only defined because it's needed to store objects of + // type Foo in std::set in C++, we don't need to wrap it. + %ignore operator<; + %inline %{ + struct Foo + { + explicit Foo(int n) : n(n) {} + + int n; + + friend bool operator<(Foo foo1, Foo foo2) + { + return foo1.n < foo2.n; + } + }; + %} + %template(StringSet) std::set; + %template(FooSet) std::set; #endif #if defined(SWIGRUBY) diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i index 3b2492e0e..1d946e644 100644 --- a/Lib/csharp/std_set.i +++ b/Lib/csharp/std_set.i @@ -30,7 +30,7 @@ class set { %typemap(csinterfaces) std::set "global::System.IDisposable, global::System.Collections.Generic.ISet<$typemap(cstype, T)>\n"; %proxycode %{ - void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add(string item) { + void global::System.Collections.Generic.ICollection<$typemap(cstype, T)>.Add($typemap(cstype, T) item) { ((global::System.Collections.Generic.ISet<$typemap(cstype, T)>)this).Add(item); } From 28c6140c56c8a16f9e562370b0b7451a3b760858 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Jul 2019 12:58:10 +0200 Subject: [PATCH 1681/2031] Allow std::set<> C# typemaps to work for non-nullable types too Notably make them work for primitive types, such as "int". Doing this requires using "object" instead of the actual C# type of the variable to store the current value in the iterator, as we don't currently have a "csnullabletype" typemap that would expand to "T" for nullable types and "T?" for the other ones. This is a bit ugly, but it shouldn't matter much for the generated code and is already done in std::vector<> typemaps. Also add a simple unit test verifying the basic functionality for such vectors. Closes #1568. --- Examples/test-suite/csharp/li_std_set_runme.cs | 9 +++++++++ Examples/test-suite/li_std_set.i | 4 ++++ Lib/csharp/std_set.i | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_set_runme.cs b/Examples/test-suite/csharp/li_std_set_runme.cs index 0e353c46d..e9cd2c271 100644 --- a/Examples/test-suite/csharp/li_std_set_runme.cs +++ b/Examples/test-suite/csharp/li_std_set_runme.cs @@ -92,5 +92,14 @@ public class runme checkThat(fooISet.Count == 0, "is initially empty"); checkThat(fooISet.Add(new Foo(17)), "added successfully"); checkThat(fooISet.Count == 1, "is not empty any more"); + + // And a set of primitive type. + IntSet intSet = new IntSet(); + checkThat(intSet.Count == 0, "is initially empty"); + checkThat(intSet.Add(17), "17 added successfully"); + checkThat(!intSet.Add(17), "17 not added again"); + checkThat(intSet.Count == 1, "not empty any more"); + checkThat(intSet.Add(289), "289 added successfully"); + checkThat(intSet.Count == 2, "even less empty now"); } } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 45eda51ff..5dbcc33e1 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -40,6 +40,10 @@ }; %} + // This one doesn't work in Java correctly yet. +#ifdef SWIGCSHARP + %template(IntSet) std::set; +#endif %template(StringSet) std::set; %template(FooSet) std::set; #endif diff --git a/Lib/csharp/std_set.i b/Lib/csharp/std_set.i index 1d946e644..82f010aff 100644 --- a/Lib/csharp/std_set.i +++ b/Lib/csharp/std_set.i @@ -192,7 +192,7 @@ class set { private $csclassname collectionRef; private global::System.Collections.Generic.IList<$typemap(cstype, T)> ItemsCollection; private int currentIndex; - private $typemap(cstype, T) currentObject; + private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { @@ -212,7 +212,7 @@ class set { throw new global::System.InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new global::System.InvalidOperationException("Collection modified."); - return currentObject; + return ($typemap(cstype, T))currentObject; } } From 2be293a647acf2fcab84a6dc20a7cf0a7f94ac90 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Jul 2019 13:07:10 +0200 Subject: [PATCH 1682/2031] Fix std::vector<> Java typemaps for primitive types For such types, the generated proxy class inherited from java.util.AbstractSet> (where BoxedType is "Integer", for example, when T is "int"), but defined an overloaded add() taking T, instead of overriding the base class virtual add() taking BoxedType, resulting in an exception being thrown whenever add() was called during run-time. Extend Java unit test to bring it to parity with C# one added in the previous commit. See #1568. --- Examples/test-suite/java/li_std_set_runme.java | 9 +++++++++ Examples/test-suite/li_std_set.i | 3 --- Lib/java/std_set.i | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/java/li_std_set_runme.java b/Examples/test-suite/java/li_std_set_runme.java index 017908c21..0e013eba1 100644 --- a/Examples/test-suite/java/li_std_set_runme.java +++ b/Examples/test-suite/java/li_std_set_runme.java @@ -77,5 +77,14 @@ public class li_std_set_runme { checkThat(fooSet.isEmpty()); checkThat(fooSet.add(new Foo(17))); checkThat(fooSet.size() == 1); + + // And a set of primitive type. + java.util.AbstractSet intSet = new IntSet(); + checkThat(intSet.isEmpty()); + checkThat(intSet.add(17)); + checkThat(!intSet.add(17)); + checkThat(intSet.size() == 1); + checkThat(intSet.add(289)); + checkThat(intSet.size() == 2); } } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 5dbcc33e1..507272d8d 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -40,10 +40,7 @@ }; %} - // This one doesn't work in Java correctly yet. -#ifdef SWIGCSHARP %template(IntSet) std::set; -#endif %template(StringSet) std::set; %template(FooSet) std::set; #endif diff --git a/Lib/java/std_set.i b/Lib/java/std_set.i index 04658f765..73e0c2cf9 100644 --- a/Lib/java/std_set.i +++ b/Lib/java/std_set.i @@ -57,6 +57,10 @@ class set { return sizeImpl(); } + public boolean add($typemap(jboxtype, T) key) { + return addImpl(key); + } + public boolean addAll(java.util.Collection collection) { boolean didAddElement = false; for (java.lang.Object object : collection) { @@ -172,7 +176,7 @@ class set { %fragment("SWIG_SetSize"); // Returns whether item was inserted. - bool add(const T& key) { + bool addImpl(const T& key) { return self->insert(key).second; } From c321aca2b46efba6fefeafa8eea505674a4e2b20 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 11 Jul 2019 17:15:38 +0200 Subject: [PATCH 1683/2031] Fix missing value for first item of enums with trailing comma The value of the first item of an enum with a trailing comma after its last item was not correctly initialized to 0 any more after the changes of 74adaa5738368ce473870451422f4a7175b6a736 (see #1515) because "_last" attribute was not set correctly in this case. Do set it for the last item when it's followed by a comma too and add more unit tests checking for this. Closes #1566. --- Examples/test-suite/java/java_enums_runme.java | 6 ++++++ Examples/test-suite/java_enums.i | 15 +++++++++++++++ Source/CParse/parser.y | 10 ++++++++++ 3 files changed, 31 insertions(+) diff --git a/Examples/test-suite/java/java_enums_runme.java b/Examples/test-suite/java/java_enums_runme.java index bc7d41636..754d391fa 100644 --- a/Examples/test-suite/java/java_enums_runme.java +++ b/Examples/test-suite/java/java_enums_runme.java @@ -13,6 +13,12 @@ public class java_enums_runme implements stuff { public static void main(String argv[]) { + if (WithTrailingComma.Second != 1) + throw new RuntimeException("Incorrect value for Second"); + + if (WithTrailingCommaAndIgnoredFirstItem.SecondNonIgnoredOne != 2) + throw new RuntimeException("Incorrect value for SecondNonIgnoredOne"); + int number = 200; // Switch statement will only compile if these enums are initialised diff --git a/Examples/test-suite/java_enums.i b/Examples/test-suite/java_enums.i index 855913d06..cad492652 100644 --- a/Examples/test-suite/java_enums.i +++ b/Examples/test-suite/java_enums.i @@ -18,6 +18,21 @@ import java.io.*; // For Serializable // Set default Java const code generation %javaconst(1); +// Test enums with trailing comma after the last item. +enum WithTrailingComma +{ + First, + Second, +}; + +%ignore ReallyFirstOneIsIgnored; +enum WithTrailingCommaAndIgnoredFirstItem +{ + ReallyFirstOneIsIgnored, + FirstNonIgnoredOne, + SecondNonIgnoredOne, +}; + // Change the default generation so that these enums are generated into an interface instead of a class %typemap(javaclassmodifiers) enum stuff "public interface" diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b526da907..08c92b9cf 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6375,6 +6375,12 @@ optional_ignored_defines ; /* Enum lists - any #define macros (constant directives) within the enum list are ignored. Trailing commas accepted. */ + +/* + Note that "_last" attribute is not supposed to be set on the last enum element, as might be expected from its name, but on the _first_ one, and _only_ on it, + so we propagate it back to the first item while parsing and reset it on all the subsequent ones. + */ + enumlist : enumlist_item { Setattr($1,"_last",$1); $$ = $1; @@ -6389,6 +6395,8 @@ enumlist : enumlist_item { set_nextSibling($1, $3); Setattr($1,"_last",Getattr($3,"_last")); Setattr($3,"_last",NULL); + } else { + Setattr($1,"_last",$1); } $$ = $1; } @@ -6397,6 +6405,8 @@ enumlist : enumlist_item { set_nextSibling($1, $4); Setattr($1,"_last",Getattr($4,"_last")); Setattr($4,"_last",NULL); + } else { + Setattr($1,"_last",$1); } set_comment($1, $3); $$ = $1; From eefbeb7505b176667ec1774fe7aaf1edde4895df Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jul 2019 07:44:31 +0100 Subject: [PATCH 1684/2031] Add changes entry for trailing enum fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2ed9d208a..6cd1c8ff2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-12: vadz + #1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with + trailing comma. + 2019-07-11: mcfarljm #1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like \code. From 7cc53071997a2fce5aae01c562271d8c8f224e2d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jul 2019 08:15:26 +0100 Subject: [PATCH 1685/2031] Add changes entry for std::set primitive types fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 6cd1c8ff2..6a8e150e5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-12: vadz + [C#, Java] #1568 #1583 Fix std::set<> typemaps for primitive types. + 2019-07-12: vadz #1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with trailing comma. From 1e11085d5ff48ada431ef4e112432aa128cd9104 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jul 2019 08:26:26 +0100 Subject: [PATCH 1686/2031] Fix testcase warning for languages that don't fully support nested classes --- Examples/test-suite/nested_inheritance_interface.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Examples/test-suite/nested_inheritance_interface.i b/Examples/test-suite/nested_inheritance_interface.i index 2d144ff72..f8335c0af 100644 --- a/Examples/test-suite/nested_inheritance_interface.i +++ b/Examples/test-suite/nested_inheritance_interface.i @@ -9,6 +9,11 @@ %interface(IA) #endif +#if !defined(SWIGCSHARP) && !defined(SWIGJAVA) +%feature ("flatnested"); +#endif + + %inline %{ struct IA {}; struct B { struct N : IA {}; }; From 9f79fb52165f85dbff693a3f717f256d08047eeb Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sun, 14 Jul 2019 11:02:37 +1000 Subject: [PATCH 1687/2031] Generator: Remove trailing whitespaces in the Python module --- Source/Modules/python.cxx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3d007d63f..f649da477 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 + * This file is part of SWIG, which is licensed as a whole under version 3 * (or any later version) of the GNU General Public License. Some additional * terms also apply to certain portions of SWIG. The full details of the SWIG * license and copyrights can be found in the LICENSE and COPYRIGHT files @@ -462,12 +462,12 @@ public: * ------------------------------------------------------------ */ virtual int top(Node *n) { - /* check if directors are enabled for this module. note: this + /* check if directors are enabled for this module. note: this * is a "master" switch, without which no director code will be * emitted. %feature("director") statements are also required * to enable directors for individual classes or methods. * - * use %module(directors="1") modulename at the start of the + * use %module(directors="1") modulename at the start of the * interface file to enable director generation. */ String *mod_docstring = NULL; @@ -1606,7 +1606,7 @@ public: * * For functions that have not had nameless parameters set in the Language class. * - * Inputs: + * Inputs: * plist - entire parameter list * arg_num - the number to start from when naming arguments * Side effects: @@ -2173,7 +2173,7 @@ public: while (i) { Node *nn = Getattr(i, "defaultargs"); if (nn != h) { - /* Check if overloaded function has defaultargs and + /* Check if overloaded function has defaultargs and * pointed to the first overloaded. */ return true; } @@ -2190,7 +2190,7 @@ public: * reuse make_autodocParmList() to do so. * ------------------------------------------------------------ */ String *make_pyParmList(Node *n, bool in_class, bool is_calling, int kw, bool has_self_for_count = false) { - /* Get the original function for a defaultargs copy, + /* Get the original function for a defaultargs copy, * see default_arguments() in parser.y. */ Node *nn = Getattr(n, "defaultargs"); if (nn) @@ -2972,9 +2972,9 @@ public: } /* if the object is a director, and the method call originated from its - * underlying python object, resolve the call by going up the c++ - * inheritance chain. otherwise try to resolve the method in python. - * without this check an infinite loop is set up between the director and + * underlying python object, resolve the call by going up the c++ + * inheritance chain. otherwise try to resolve the method in python. + * without this check an infinite loop is set up between the director and * shadow class method calls. */ @@ -3068,7 +3068,7 @@ public: // base class pointers! /* New addition to unwrap director return values so that the original - * python object is returned instead. + * python object is returned instead. */ #if 1 int unwrap = 0; @@ -3613,7 +3613,7 @@ public: } - /* ------------------------------------------------------------ + /* ------------------------------------------------------------ * nativeWrapper() * ------------------------------------------------------------ */ @@ -3648,7 +3648,7 @@ public: /* --------------------------------------------------------------- * classDirectorMethod() * - * Emit a virtual director method to pass a method call on to the + * Emit a virtual director method to pass a method call on to the * underlying Python object. * ** Moved down due to gcc-2.96 internal error ** * --------------------------------------------------------------- */ @@ -4759,7 +4759,7 @@ public: int oldshadow = shadow; int use_director = Swig_directorclass(n); - /* + /* * If we're wrapping the constructor of a C++ director class, prepend a new parameter * to receive the scripting language object (e.g. 'self') * @@ -5088,7 +5088,7 @@ public: /* ------------------------------------------------------------ * insertDirective() - * + * * Hook for %insert directive. We're going to look for special %shadow inserts * as a special case so we can do indenting correctly * ------------------------------------------------------------ */ @@ -5171,7 +5171,7 @@ public: /* --------------------------------------------------------------- * classDirectorMethod() * - * Emit a virtual director method to pass a method call on to the + * Emit a virtual director method to pass a method call on to the * underlying Python object. * * ** Moved it here due to internal error on gcc-2.96 ** @@ -5272,7 +5272,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Append(w->def, " {"); Append(declaration, ";\n"); - /* declare method return value + /* declare method return value * if the return value is a reference or const reference, a specialized typemap must * handle it, including declaration of c_result ($result). */ @@ -5432,7 +5432,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { } else { Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_InternalNewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); - //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", + //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); Printv(arglist, source, NIL); } From c20b6f5b0eb29f6cd44c8540d3f41c152c0c86b1 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sun, 14 Jul 2019 11:08:17 +1000 Subject: [PATCH 1688/2031] Generator: Unify string quoting in generated Python sources --- Source/Modules/python.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index f649da477..39308d4b8 100755 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -685,13 +685,13 @@ public: * same package, otherwise load it as a global module. */ Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL); - Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL); + Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL); Printv(default_import_code, tab4, "from . import ", module, "\n", NULL); Printv(default_import_code, "else:\n", NULL); Printv(default_import_code, tab4, "import ", module, "\n", NULL); } else { Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL); - Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL); + Printv(default_import_code, "if __package__ or \".\" in __name__:\n", NULL); Printv(default_import_code, tab4, "from .", module, " import *\n", NULL); Printv(default_import_code, "else:\n", NULL); Printv(default_import_code, tab4, "from ", module, " import *\n", NULL); @@ -848,7 +848,7 @@ public: Printv(f_shadow_py, "\nfrom sys import version_info as _swig_python_version_info\n", NULL); Printv(f_shadow_py, "if _swig_python_version_info < (2, 7, 0):\n", NULL); - Printv(f_shadow_py, tab4, "raise RuntimeError('Python 2.7 or later required')\n\n", NULL); + Printv(f_shadow_py, tab4, "raise RuntimeError(\"Python 2.7 or later required\")\n\n", NULL); if (Len(f_shadow_after_begin) > 0) Printv(f_shadow_py, f_shadow_after_begin, "\n", NIL); @@ -1720,7 +1720,7 @@ public: } // Write the function annotation if (func_annotation) - Printf(doc, ": '%s'", type_str); + Printf(doc, ": \"%s\"", type_str); // Write default value if (value && !calling) { @@ -2011,10 +2011,10 @@ public: // This must have been an octal number. This is the only case we // cannot use in Python directly, since Python 2 and 3 use non- // compatible representations. - result = NewString(*s == '-' ? "int('-" : "int('"); + result = NewString(*s == '-' ? "int(\"-" : "int(\""); String *octal_string = NewStringWithSize(p, (int) (end - p)); Append(result, octal_string); - Append(result, "', 8)"); + Append(result, "\", 8)"); Delete(octal_string); return result; } @@ -4425,7 +4425,7 @@ public: Printv(f_shadow, tab4, str, "\n\n", NIL); } - Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc='The membership flag')\n", NIL); + Printv(f_shadow, tab4, "thisown = property(lambda x: x.this.own(), ", "lambda x, v: x.this.own(v), doc=\"The membership flag\")\n", NIL); /* Add static attribute */ if (GetFlag(n, "feature:python:nondynamic")) { Printv(f_shadow_file, tab4, "__setattr__ = _swig_setattr_nondynamic_instance_variable(object.__setattr__)\n", NIL); From c4ad3480bdae23239d7feeaa10e8755133ff20b4 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sun, 14 Jul 2019 11:15:36 +1000 Subject: [PATCH 1689/2031] Tools: Unify string quoting in the Python sources --- Tools/obs-buildlogs.py | 4 ++-- Tools/testflags.py | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Tools/obs-buildlogs.py b/Tools/obs-buildlogs.py index b97e7dba1..1c77e80c4 100755 --- a/Tools/obs-buildlogs.py +++ b/Tools/obs-buildlogs.py @@ -11,9 +11,9 @@ def remove_old_files(): os.remove(file) def download(): - repos = subprocess.Popen(['osc', 'repositories'], stdout=subprocess.PIPE) + repos = subprocess.Popen(["osc", "repositories"], stdout=subprocess.PIPE) for line in repos.stdout: - command = ['osc', 'buildlog', '--last'] + line.split() + command = ["osc", "buildlog", "--last"] + line.split() filename = "-".join(line.split()) + ".log" print("Downloading logs using: {}".format(" ".join(command))) buildlog = subprocess.Popen(command, stdout=subprocess.PIPE) diff --git a/Tools/testflags.py b/Tools/testflags.py index bf85f5680..f3d216b59 100755 --- a/Tools/testflags.py +++ b/Tools/testflags.py @@ -23,7 +23,7 @@ def get_cflags(language, std, compiler): "scilab":"-Werror " + c_common, "tcl":"-Werror " + c_common, } - if compiler == 'clang': + if compiler == "clang": cflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile if language not in cflags: @@ -54,7 +54,7 @@ def get_cxxflags(language, std, compiler): "scilab":"-Werror " + cxx_common, "tcl":"-Werror " + cxx_common, } - if compiler == 'clang': + if compiler == "clang": cxxflags["guile"] += " -Wno-attributes" # -Wno-attributes is for clang LLVM 3.5 and bdw-gc < 7.5 used by guile if language not in cxxflags: @@ -64,12 +64,12 @@ def get_cxxflags(language, std, compiler): import argparse parser = argparse.ArgumentParser(description="Display CFLAGS or CXXFLAGS to use for testing the SWIG examples and test-suite.") -parser.add_argument('-l', '--language', required=True, help='set language to show flags for') +parser.add_argument("-l", "--language", required=True, help="set language to show flags for") flags = parser.add_mutually_exclusive_group(required=True) -flags.add_argument('-c', '--cflags', action='store_true', default=False, help='show CFLAGS') -flags.add_argument('-x', '--cxxflags', action='store_true', default=False, help='show CXXFLAGS') -parser.add_argument('-s', '--std', required=False, help='language standard flags for the -std= option') -parser.add_argument('-C', '--compiler', required=False, help='compiler used (clang or gcc)') +flags.add_argument("-c", "--cflags", action="store_true", default=False, help="show CFLAGS") +flags.add_argument("-x", "--cxxflags", action="store_true", default=False, help="show CXXFLAGS") +parser.add_argument("-s", "--std", required=False, help="language standard flags for the -std= option") +parser.add_argument("-C", "--compiler", required=False, help="compiler used (clang or gcc)") args = parser.parse_args() if args.cflags: From fa5f519bf9842b523a12cab0bc20f836d8a8a903 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sun, 14 Jul 2019 12:58:21 +1000 Subject: [PATCH 1690/2031] Test-suite: Unify string quoting in the Python sources --- .../test-suite/python/argcargvtest_runme.py | 12 +- .../test-suite/python/char_binary_runme.py | 20 +-- .../test-suite/python/comment_verifier.py | 4 +- .../python/cpp17_u8_char_literals_runme.py | 6 +- .../test-suite/python/default_args_runme.py | 14 +-- .../python/director_exception_runme.py | 2 +- .../python/doxygen_misc_constructs_runme.py | 4 +- .../python/ignore_parameter_runme.py | 2 +- .../test-suite/python/li_cstring_runme.py | 4 +- .../test-suite/python/li_cwstring_runme.py | 4 +- .../test-suite/python/li_std_set_runme.py | 2 +- .../python/li_std_string_extra_runme.py | 2 +- .../python/li_std_vector_extra_runme.py | 2 +- .../test-suite/python/primitive_ref_runme.py | 2 +- .../python/primitive_types_runme.py | 114 +++++++++--------- .../python/python_pybuffer_runme.py | 8 +- .../python/python_strict_unicode_runme.py | 14 +-- .../python/reference_global_vars_runme.py | 4 +- .../test-suite/python/std_containers_runme.py | 14 +-- .../test-suite/python/swigobject_runme.py | 4 +- .../python/template_typedef_cplx2_runme.py | 24 ++-- .../python/template_typedef_cplx_runme.py | 24 ++-- .../python/unicode_strings_runme.py | 6 +- 23 files changed, 146 insertions(+), 146 deletions(-) diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py index 38843b932..b0345746f 100644 --- a/Examples/test-suite/python/argcargvtest_runme.py +++ b/Examples/test-suite/python/argcargvtest_runme.py @@ -1,21 +1,21 @@ from argcargvtest import * -largs = ['hi', 'hola', 'hello'] +largs = ["hi", "hola", "hello"] if mainc(largs) != 3: raise RuntimeError("bad main typemap") -targs = ('hi', 'hola') -if mainv(targs, 1) != 'hola': +targs = ("hi", "hola") +if mainv(targs, 1) != "hola": print(mainv(targs, 1)) raise RuntimeError("bad main typemap") -targs = ('hi', 'hola') -if mainv(targs, 1) != 'hola': +targs = ("hi", "hola") +if mainv(targs, 1) != "hola": raise RuntimeError("bad main typemap") try: error = 0 - mainv('hello', 1) + mainv("hello", 1) error = 1 except TypeError: pass diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py index 34caa3208..0425fe1c9 100644 --- a/Examples/test-suite/python/char_binary_runme.py +++ b/Examples/test-suite/python/char_binary_runme.py @@ -1,26 +1,26 @@ from char_binary import * t = Test() -if t.strlen('hile') != 4: - print t.strlen('hile') +if t.strlen("hile") != 4: + print t.strlen("hile") raise RuntimeError, "bad multi-arg typemap" -if t.ustrlen('hile') != 4: - print t.ustrlen('hile') +if t.ustrlen("hile") != 4: + print t.ustrlen("hile") raise RuntimeError, "bad multi-arg typemap" -if t.strlen('hil\0') != 4: +if t.strlen("hil\0") != 4: raise RuntimeError, "bad multi-arg typemap" -if t.ustrlen('hil\0') != 4: +if t.ustrlen("hil\0") != 4: raise RuntimeError, "bad multi-arg typemap" # # creating a raw char* # pc = new_pchar(5) -pchar_setitem(pc, 0, 'h') -pchar_setitem(pc, 1, 'o') -pchar_setitem(pc, 2, 'l') -pchar_setitem(pc, 3, 'a') +pchar_setitem(pc, 0, "h") +pchar_setitem(pc, 1, "o") +pchar_setitem(pc, 2, "l") +pchar_setitem(pc, 3, "a") pchar_setitem(pc, 4, 0) diff --git a/Examples/test-suite/python/comment_verifier.py b/Examples/test-suite/python/comment_verifier.py index 57ac0b721..653cb4940 100644 --- a/Examples/test-suite/python/comment_verifier.py +++ b/Examples/test-suite/python/comment_verifier.py @@ -1,10 +1,10 @@ def check(got, expected, expected_builtin=None): if got is None: # Absence of comment is equivalent to empty comment. - got = '' + got = "" if got != expected: import re - p = re.compile(r'^[+-]([^+-].*\S)?(\s+)$', re.M) + p = re.compile(r"^[+-]([^+-].*\S)?(\s+)$", re.M) def make_trailing_spaces_visible(str): def replace_trailing_spaces(match): diff --git a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py index 81f34f193..e2f8897f3 100644 --- a/Examples/test-suite/python/cpp17_u8_char_literals_runme.py +++ b/Examples/test-suite/python/cpp17_u8_char_literals_runme.py @@ -1,10 +1,10 @@ from cpp17_u8_char_literals import * -if cvar.a != 'a': +if cvar.a != "a": raise RuntimeError -if cvar.u != 'u': +if cvar.u != "u": raise RuntimeError -if cvar.u8 != '8': +if cvar.u8 != "8": raise RuntimeError diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index 683314dfe..14ef8c594 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -170,23 +170,23 @@ def run(module_name): if default_args.CDA().cdefaultargs_test2() != 1: raise RuntimeError - if default_args.chartest1() != 'x': + if default_args.chartest1() != "x": raise RuntimeError - if default_args.chartest2() != '\0': + if default_args.chartest2() != "\0": raise RuntimeError - if default_args.chartest3() != '\1': + if default_args.chartest3() != "\1": raise RuntimeError - if default_args.chartest4() != '\n': + if default_args.chartest4() != "\n": raise RuntimeError - if default_args.chartest5() != 'B': + if default_args.chartest5() != "B": raise RuntimeError - if default_args.chartest6() != 'C': + if default_args.chartest6() != "C": raise RuntimeError if __name__ == "__main__": - run('default_args') + run("default_args") diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index aa9d490a3..06856f30a 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -75,7 +75,7 @@ b = launder(a) try: b.pong() except MyException, e: - if e.msg == 'foobar': + if e.msg == "foobar": ok = 1 else: print "Unexpected error message: %s" % str(e) diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py index c441c3dfe..11aa53ba3 100644 --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py @@ -44,7 +44,7 @@ comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getConnection), comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getFirstLetter), - r'' + r"" ) comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.ClassWithNestedEnum), @@ -73,7 +73,7 @@ comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidB), ) comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.isNoSpaceValidC), - r'' + r"" ) comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.backslashA), diff --git a/Examples/test-suite/python/ignore_parameter_runme.py b/Examples/test-suite/python/ignore_parameter_runme.py index 5f1342e4a..2b5c21235 100644 --- a/Examples/test-suite/python/ignore_parameter_runme.py +++ b/Examples/test-suite/python/ignore_parameter_runme.py @@ -2,7 +2,7 @@ from ignore_parameter import * def check(a, b): if a != b: - raise RuntimeError('"%s" != "%s"' % (a, b)) + raise RuntimeError("'%s' != '%s'" % (a, b)) check(jaguar(200, 0), "hello") check(lotus("foo", 1), 101) diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py index 6fec5362b..b718f1352 100644 --- a/Examples/test-suite/python/li_cstring_runme.py +++ b/Examples/test-suite/python/li_cstring_runme.py @@ -18,10 +18,10 @@ if test4("hello") != "hello-suffix": print test4("hello") raise RuntimeError -if test5(4) != 'xxxx': +if test5(4) != "xxxx": raise RuntimeError -if test6(10) != 'xxxxx': +if test6(10) != "xxxxx": raise RuntimeError if test7() != "Hello world!": diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py index b2b23a862..5dd7b9b20 100644 --- a/Examples/test-suite/python/li_cwstring_runme.py +++ b/Examples/test-suite/python/li_cwstring_runme.py @@ -15,10 +15,10 @@ if test3("hello") != u"hello-suffix": if test4("hello") != u"hello-suffix": raise RuntimeError -if test5(4) != u'xxxx': +if test5(4) != u"xxxx": raise RuntimeError -if test6(10) != u'xxxxx': +if test6(10) != u"xxxxx": raise RuntimeError if test7() != u"Hello world!": diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py index f6fad5561..5e5b72442 100644 --- a/Examples/test-suite/python/li_std_set_runme.py +++ b/Examples/test-suite/python/li_std_set_runme.py @@ -90,5 +90,5 @@ sum = () for i in s: sum = sum + (i,) -if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)): +if (len(sum) != 3 or (not 1 in sum) or (not "hello" in sum) or (not (1, 2) in sum)): raise RuntimeError diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index 53d2bdc75..087d92b19 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -19,7 +19,7 @@ if li_std_string_extra.test_const_reference(x) != x: s = li_std_string_extra.string("he") #s += "ll" -# s.append('o') +# s.append("o") s = s + "llo" if s != x: diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index 88105ea85..59e729a27 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -91,7 +91,7 @@ if v.size() != 0: v = vecStr(["hello ", "world"]) -if v[0] != 'hello world': +if v[0] != "hello world": raise RuntimeError, "bad std::string+std::vector" diff --git a/Examples/test-suite/python/primitive_ref_runme.py b/Examples/test-suite/python/primitive_ref_runme.py index f3a640389..2f1a5144c 100644 --- a/Examples/test-suite/python/primitive_ref_runme.py +++ b/Examples/test-suite/python/primitive_ref_runme.py @@ -33,7 +33,7 @@ if ref_double(3.5) != 3.5: if ref_bool(True) != True: raise RuntimeError -if ref_char('x') != 'x': +if ref_char("x") != "x": raise RuntimeError if ref_over(0) != 0: diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index c5009f640..04588ddf2 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -227,7 +227,7 @@ t.var_paramc = sct_paramc t.v_check() # this value contains a '0' char! -if def_namet != 'hola': +if def_namet != "hola": print "bad namet", def_namet raise RuntimeError @@ -236,54 +236,54 @@ if t.var_namet != def_namet: print "bad namet", t.var_namet, def_namet raise RuntimeError -t.var_namet = 'hola' +t.var_namet = "hola" -if t.var_namet != 'hola': +if t.var_namet != "hola": print "bad namet", t.var_namet raise RuntimeError -t.var_namet = 'hol' +t.var_namet = "hol" -if t.var_namet != 'hol': - # if t.var_namet != 'hol\0\0': +if t.var_namet != "hol": + # if t.var_namet != "hol\0\0": print "bad namet", t.var_namet raise RuntimeError -cvar.var_char = '\0' -if cvar.var_char != '\0': +cvar.var_char = "\0" +if cvar.var_char != "\0": raise RuntimeError, "bad char '0' case" cvar.var_char = 0 -if cvar.var_char != '\0': +if cvar.var_char != "\0": raise RuntimeError, "bad char '0' case" -cvar.var_namet = '\0' -# if cvar.var_namet != '\0\0\0\0\0': -if cvar.var_namet != '': - print 'hola', '', cvar.var_namet +cvar.var_namet = "\0" +# if cvar.var_namet != "\0\0\0\0\0": +if cvar.var_namet != "": + print "hola", "", cvar.var_namet raise RuntimeError, "bad char '\0' case" -cvar.var_namet = '' -# if cvar.var_namet != '\0\0\0\0\0': -if cvar.var_namet != '': +cvar.var_namet = "" +# if cvar.var_namet != "\0\0\0\0\0": +if cvar.var_namet != "": raise RuntimeError, "bad char empty case" cvar.var_pchar = None if cvar.var_pchar != None: raise RuntimeError, "bad None case" -cvar.var_pchar = '' -if cvar.var_pchar != '': - print '%c' % (cvar.var_pchar[0],) +cvar.var_pchar = "" +if cvar.var_pchar != "": + print "%c" % (cvar.var_pchar[0],) raise RuntimeError, "bad char empty case" cvar.var_pcharc = None if cvar.var_pcharc != None: raise RuntimeError, "bad None case" -cvar.var_pcharc = '' -if cvar.var_pcharc != '': +cvar.var_pcharc = "" +if cvar.var_pcharc != "": raise RuntimeError, "bad char empty case" @@ -291,10 +291,10 @@ if cvar.var_pcharc != '': # creating a raw char* # pc = new_pchar(5) -pchar_setitem(pc, 0, 'h') -pchar_setitem(pc, 1, 'o') -pchar_setitem(pc, 2, 'l') -pchar_setitem(pc, 3, 'a') +pchar_setitem(pc, 0, "h") +pchar_setitem(pc, 1, "o") +pchar_setitem(pc, 2, "l") +pchar_setitem(pc, 3, "a") pchar_setitem(pc, 4, 0) @@ -331,7 +331,7 @@ if error: try: error = 0 a = t.var_char - t.var_char = '23' + t.var_char = "23" error = 1 except TypeError: if a != t.var_char: @@ -393,7 +393,7 @@ if error: try: error = 0 a = t.var_namet - t.var_namet = '123456' + t.var_namet = "123456" error = 1 except TypeError: if a != t.var_namet: @@ -410,11 +410,11 @@ if t.var_namet != t2.var_namet: raise RuntimeError, "bad SWIGTYPE* typemap" -if cvar.fixsize != 'ho\0la\0\0\0': +if cvar.fixsize != "ho\0la\0\0\0": raise RuntimeError, "bad FIXSIZE typemap" -cvar.fixsize = 'ho' -if cvar.fixsize != 'ho\0\0\0\0\0\0': +cvar.fixsize = "ho" +if cvar.fixsize != "ho\0\0\0\0\0\0": raise RuntimeError, "bad FIXSIZE typemap" @@ -487,26 +487,26 @@ def checkType(t, e, val, delta): """t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min""" error = 0 # Set the extreme valid value for var_* - setattr(t, 'var_' + e, val) + setattr(t, "var_" + e, val) # Make sure it was set properly and works properly in the val_* and ref_* methods - if getattr(t, 'var_' + e) != val or getattr(t, 'val_' + e)(val) != val or getattr(t, 'ref_' + e)(val) != val: + if getattr(t, "var_" + e) != val or getattr(t, "val_" + e)(val) != val or getattr(t, "ref_" + e)(val) != val: error = 1 # Make sure setting a more extreme value fails without changing the value try: - a = getattr(t, 'var_' + e) - setattr(t, 'var_' + e, val + delta) + a = getattr(t, "var_" + e) + setattr(t, "var_" + e, val + delta) error = 1 except OverflowError: - if a != getattr(t, 'var_' + e): + if a != getattr(t, "var_" + e): error = 1 # Make sure the val_* and ref_* methods fail with a more extreme value try: - getattr(t, 'val_' + e)(val + delta) + getattr(t, "val_" + e)(val + delta) error = 1 except OverflowError: pass try: - getattr(t, 'ref_' + e)(val + delta) + getattr(t, "ref_" + e)(val + delta) error = 1 except OverflowError: pass @@ -518,16 +518,16 @@ def checkFull(t, e, maxval, minval): checkType(t, e, maxval, 1) checkType(t, e, minval, -1) -checkFull(t, 'llong', maxllong, minllong) -checkFull(t, 'long', maxlong, minlong) -checkFull(t, 'int', maxint, minint) -checkFull(t, 'short', maxshort, minshort) -checkFull(t, 'schar', maxchar, minchar) -checkFull(t, 'ullong', maxullong, 0) -checkFull(t, 'ulong', maxulong, 0) -checkFull(t, 'uint', maxuint, 0) -checkFull(t, 'ushort', maxushort, 0) -checkFull(t, 'uchar', maxuchar, 0) +checkFull(t, "llong", maxllong, minllong) +checkFull(t, "long", maxlong, minlong) +checkFull(t, "int", maxint, minint) +checkFull(t, "short", maxshort, minshort) +checkFull(t, "schar", maxchar, minchar) +checkFull(t, "ullong", maxullong, 0) +checkFull(t, "ulong", maxulong, 0) +checkFull(t, "uint", maxuint, 0) +checkFull(t, "ushort", maxushort, 0) +checkFull(t, "uchar", maxuchar, 0) def checkOverload(t, name, val, delta, prevval, limit): """ @@ -556,16 +556,16 @@ def checkOverload(t, name, val, delta, prevval, limit): raise RuntimeError, "bad " + name + " typemap" # Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong -checkOverload(t, 'uchar', maxuchar, +1, 0, maxullong) -checkOverload(t, 'ushort', maxushort, +1, maxuchar, maxullong) -checkOverload(t, 'uint', maxuint, +1, maxushort, maxullong) -checkOverload(t, 'ulong', maxulong, +1, maxuint, maxullong) -checkOverload(t, 'ullong', maxullong, +1, maxulong, maxullong) -checkOverload(t, 'schar', minchar, -1, 0, minllong) -checkOverload(t, 'short', minshort, -1, minchar, minllong) -checkOverload(t, 'int', minint, -1, minshort, minllong) -checkOverload(t, 'long', minlong, -1, minint, minllong) -checkOverload(t, 'llong', minllong, -1, minlong, minllong) +checkOverload(t, "uchar", maxuchar, +1, 0, maxullong) +checkOverload(t, "ushort", maxushort, +1, maxuchar, maxullong) +checkOverload(t, "uint", maxuint, +1, maxushort, maxullong) +checkOverload(t, "ulong", maxulong, +1, maxuint, maxullong) +checkOverload(t, "ullong", maxullong, +1, maxulong, maxullong) +checkOverload(t, "schar", minchar, -1, 0, minllong) +checkOverload(t, "short", minshort, -1, minchar, minllong) +checkOverload(t, "int", minint, -1, minshort, minllong) +checkOverload(t, "long", minlong, -1, minint, minllong) +checkOverload(t, "llong", minllong, -1, minlong, minllong) # Make sure that large ints can be converted to doubles properly if val_double(sys.maxint + 1) != float(sys.maxint + 1): diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py index 85cfb75d3..8ecdb523b 100644 --- a/Examples/test-suite/python/python_pybuffer_runme.py +++ b/Examples/test-suite/python/python_pybuffer_runme.py @@ -14,13 +14,13 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": k = 1000000 # number of times to execute the functions t = time.time() - a = bytearray(b'hello world') + a = bytearray(b"hello world") for i in range(k): python_pybuffer.title1(a) print "Time used by bytearray:", time.time() - t t = time.time() - b = 'hello world' + b = "hello world" for i in range(k): python_pybuffer.title2(b) print "Time used by string:", time.time() - t @@ -30,7 +30,7 @@ else: buf2 = bytearray(50) python_pybuffer.func1(buf1) - check(buf1 == b'a' * 10) + check(buf1 == b"a" * 10) python_pybuffer.func2(buf2) check(buf2.startswith(b"Hello world!\x00")) @@ -43,4 +43,4 @@ else: buf3 = bytearray(b"hello") python_pybuffer.title1(buf3) - check(buf3 == b'Hello') + check(buf3 == b"Hello") diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py index afb9e8988..e7fae2556 100644 --- a/Examples/test-suite/python/python_strict_unicode_runme.py +++ b/Examples/test-suite/python/python_strict_unicode_runme.py @@ -1,8 +1,8 @@ import python_strict_unicode -test_bytes = b'hello \x01world\x99' -BYTES = b'BYTES' -test_unicode = u'h\udce9llo w\u00f6rld' +test_bytes = b"hello \x01world\x99" +BYTES = b"BYTES" +test_unicode = u"h\udce9llo w\u00f6rld" # Test that byte string inputs and outputs work as expected bdbl = python_strict_unicode.double_str(test_bytes) @@ -20,12 +20,12 @@ if type(bout) != type(BYTES): udbl = python_strict_unicode.double_wstr(test_unicode) if udbl != test_unicode + test_unicode: raise RuntimeError("Failed to double wide string") -if type(udbl) != type(u''): +if type(udbl) != type(u""): raise RuntimeError("Wrong type output for wide string") uout = python_strict_unicode.same_wstr(test_unicode) if uout != test_unicode: raise RuntimeError("Failed to copy wchar_t*") -if type(uout) != type(u''): +if type(uout) != type(u""): raise RuntimeError("Wrong type output for wchar_t*") # Test that overloading is handled properly @@ -35,9 +35,9 @@ if bovr != BYTES: if type(bovr) != type(BYTES): raise RuntimeError("Wrong type output from overload") uovr = python_strict_unicode.overload(test_unicode) -if uovr != u'UNICODE': +if uovr != u"UNICODE": raise RuntimeError("Failed to return unicode from overload") -if type(uovr) != type(u''): +if type(uovr) != type(u""): raise RuntimeERror("Wrong type output from overload") # Test that bytes aren't accepted as wide strings and unicode isn't accepted as narrow strings diff --git a/Examples/test-suite/python/reference_global_vars_runme.py b/Examples/test-suite/python/reference_global_vars_runme.py index 6c2d181ac..6f86527b7 100644 --- a/Examples/test-suite/python/reference_global_vars_runme.py +++ b/Examples/test-suite/python/reference_global_vars_runme.py @@ -13,8 +13,8 @@ cvar.var_bool = createref_bool(True) if value_bool(cvar.var_bool) != True: raise RuntimeError -cvar.var_char = createref_char('w') -if value_char(cvar.var_char) != 'w': +cvar.var_char = createref_char("w") +if value_char(cvar.var_char) != "w": raise RuntimeError cvar.var_unsigned_char = createref_unsigned_char(10) diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py index 63ff74c2a..7404cd5f4 100644 --- a/Examples/test-suite/python/std_containers_runme.py +++ b/Examples/test-suite/python/std_containers_runme.py @@ -60,9 +60,9 @@ if mi[0][1] != mc[0][1]: map = {} -map['hello'] = 1 -map['hi'] = 2 -map['3'] = 2 +map["hello"] = 1 +map["hi"] = 2 +map["3"] = 2 imap = std_containers.mapident(map) for k in map: @@ -70,13 +70,13 @@ for k in map: raise RuntimeError, "bad map" # Test __contains__ (required for 'x in y' to work) -if not imap.__contains__('hello'): +if not imap.__contains__("hello"): raise RuntimeError("hello imap.__contains__") -if 'hello' not in imap: +if "hello" not in imap: raise RuntimeError("hello not in imap") -if imap.__contains__('oops'): +if imap.__contains__("oops"): raise RuntimeError("oops imap.__contains__") -if 'oops' in imap: +if "oops" in imap: raise RuntimeError("oops in imap") mapc = {} diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 346b05d40..de232f580 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -15,11 +15,11 @@ 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 = str.lstrip(xstr1, "0") xstr2 = pointer_str(a) xstr2 = str.replace(xstr2, "0x", "") xstr2 = str.replace(xstr2, "0X", "") -xstr2 = str.lstrip(xstr2, '0') +xstr2 = str.lstrip(xstr2, "0") xstr2 = str.upper(xstr2) if xstr1 != xstr2: diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 3043d4285..161bd51fc 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -11,8 +11,8 @@ except: print d, "is not an instance" raise RuntimeError -s = '%s' % d -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % d +if str.find(s, "ArithUnaryFunction") == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -23,8 +23,8 @@ except: print e, "is not an instance" raise RuntimeError -s = '%s' % e -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % e +if str.find(s, "ArithUnaryFunction") == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -40,8 +40,8 @@ except: print c, "is not an instance" raise RuntimeError -s = '%s' % c -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % c +if str.find(s, "ArithUnaryFunction") == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -52,8 +52,8 @@ except: print f, "is not an instance" raise RuntimeError -s = '%s' % f -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % f +if str.find(s, "ArithUnaryFunction") == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -68,8 +68,8 @@ except: print g, "is not an instance" raise RuntimeError -s = '%s' % g -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % g +if str.find(s, "ArithUnaryFunction") == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -81,8 +81,8 @@ except: print h, "is not an instance" raise RuntimeError -s = '%s' % h -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % h +if str.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 afb97d070..1846739eb 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -11,8 +11,8 @@ except: print d, "is not an instance" raise RuntimeError -s = '%s' % d -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % d +if str.find(s, "ArithUnaryFunction") == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -23,8 +23,8 @@ except: print e, "is not an instance" raise RuntimeError -s = '%s' % e -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % e +if str.find(s, "ArithUnaryFunction") == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -40,8 +40,8 @@ except: print c, "is not an instance" raise RuntimeError -s = '%s' % c -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % c +if str.find(s, "ArithUnaryFunction") == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -52,8 +52,8 @@ except: print f, "is not an instance" raise RuntimeError -s = '%s' % f -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % f +if str.find(s, "ArithUnaryFunction") == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -68,8 +68,8 @@ except: print g, "is not an instance" raise RuntimeError -s = '%s' % g -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % g +if str.find(s, "ArithUnaryFunction") == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -81,7 +81,7 @@ except: print h, "is not an instance" raise RuntimeError -s = '%s' % h -if str.find(s, 'ArithUnaryFunction') == -1: +s = "%s" % h +if str.find(s, "ArithUnaryFunction") == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 39e93b0fc..4e661f00e 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -5,13 +5,13 @@ import unicode_strings # The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant # in 3.3+. Since this file is run through 2to3 before testing, though, # mark this as a unicode string in 2.x so it'll become a str in 3.x. -test_string = u'h\udce9llo w\u00f6rld' +test_string = u"h\udce9llo w\u00f6rld" if sys.version_info[0:2] >= (3, 1): if unicode_strings.non_utf8_c_str() != test_string: - raise ValueError('Test comparison mismatch') + raise ValueError("Test comparison mismatch") if unicode_strings.non_utf8_std_string() != test_string: - raise ValueError('Test comparison mismatch') + raise ValueError("Test comparison mismatch") def check(s1, s2): if s1 != s2: From f88ba7c18250bce730e0caa5aa9e2a287acfa223 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Sun, 14 Jul 2019 14:12:23 +1000 Subject: [PATCH 1691/2031] Examples: Unify string quoting in the Python sources --- .../import_packages/namespace_pkg/normal.py | 2 +- .../import_packages/namespace_pkg/nstest.py | 16 ++++++++-------- .../import_packages/namespace_pkg/split.py | 4 ++-- .../import_packages/namespace_pkg/zipsplit.py | 4 ++-- Examples/python/performance/constructor/runme.py | 2 +- Examples/python/performance/func/runme.py | 2 +- Examples/python/performance/harness.py | 6 +++--- Examples/python/performance/hierarchy/runme.py | 2 +- .../performance/hierarchy_operator/runme.py | 2 +- Examples/python/performance/operator/runme.py | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Examples/python/import_packages/namespace_pkg/normal.py b/Examples/python/import_packages/namespace_pkg/normal.py index 924142f74..0eb8f517c 100644 --- a/Examples/python/import_packages/namespace_pkg/normal.py +++ b/Examples/python/import_packages/namespace_pkg/normal.py @@ -11,7 +11,7 @@ def run_except_on_windows(commandline, env=None): print(" Starting subtest " + os.path.basename(__file__)) # Package brave found under one path -sys.path.insert(0, 'path1') +sys.path.insert(0, "path1") from brave import robin print(" Finished from brave import robin") diff --git a/Examples/python/import_packages/namespace_pkg/nstest.py b/Examples/python/import_packages/namespace_pkg/nstest.py index e80289fb1..4d618a6ad 100644 --- a/Examples/python/import_packages/namespace_pkg/nstest.py +++ b/Examples/python/import_packages/namespace_pkg/nstest.py @@ -11,7 +11,7 @@ def run_except_on_windows(commandline, env=None): print(" Finished running: " + commandline) def copyMods(): - dirs = ['path1', 'path2', 'path3'] + dirs = ["path1", "path2", "path3"] # Clean out any old package paths for d in dirs: @@ -20,20 +20,20 @@ def copyMods(): for d in dirs: os.mkdir(d) - os.mkdir(os.path.join(d, 'brave')) + os.mkdir(os.path.join(d, "brave")) - shutil.copy('robin.py', os.path.join('path1', 'brave')) - subprocess.check_call('cp _robin.* ' + os.path.join('path1', 'brave'), shell=True) + shutil.copy("robin.py", os.path.join("path1", "brave")) + subprocess.check_call("cp _robin.* " + os.path.join("path1", "brave"), shell=True) - shutil.copy('robin.py', os.path.join('path2', 'brave')) - subprocess.check_call('cp _robin.* ' + os.path.join('path3', 'brave'), shell=True) + shutil.copy("robin.py", os.path.join("path2", "brave")) + subprocess.check_call("cp _robin.* " + os.path.join("path3", "brave"), shell=True) mkzip() def mkzip(): zf = zipfile.ZipFile("path4.zip", "w") - zf.writestr("brave/", b'') - zf.write('robin.py', 'brave/robin.py') + zf.writestr("brave/", b"") + zf.write("robin.py", "brave/robin.py") zf.close() diff --git a/Examples/python/import_packages/namespace_pkg/split.py b/Examples/python/import_packages/namespace_pkg/split.py index 8989954cc..9d786dc07 100644 --- a/Examples/python/import_packages/namespace_pkg/split.py +++ b/Examples/python/import_packages/namespace_pkg/split.py @@ -12,8 +12,8 @@ print(" Starting subtest " + os.path.basename(__file__)) # Package brave split into two paths. # path2/brave/robin.py and path3/brave/_robin.so -sys.path.insert(0, 'path2') -sys.path.insert(0, 'path3') +sys.path.insert(0, "path2") +sys.path.insert(0, "path3") from brave import robin print(" Finished from brave import robin") diff --git a/Examples/python/import_packages/namespace_pkg/zipsplit.py b/Examples/python/import_packages/namespace_pkg/zipsplit.py index 8af9cf025..30434f9c0 100644 --- a/Examples/python/import_packages/namespace_pkg/zipsplit.py +++ b/Examples/python/import_packages/namespace_pkg/zipsplit.py @@ -12,8 +12,8 @@ print(" Starting subtest " + os.path.basename(__file__)) # Package brave split into two paths. # brave/robin.py (in path4.zip) and path3/brave/_robin.so -sys.path.insert(0, 'path4.zip') -sys.path.insert(0, 'path3') +sys.path.insert(0, "path4.zip") +sys.path.insert(0, "path3") from brave import robin print(" Finished from brave import robin") diff --git a/Examples/python/performance/constructor/runme.py b/Examples/python/performance/constructor/runme.py index 1771fba7b..b00cd456c 100644 --- a/Examples/python/performance/constructor/runme.py +++ b/Examples/python/performance/constructor/runme.py @@ -1,5 +1,5 @@ import sys -sys.path.append('..') +sys.path.append("..") import harness diff --git a/Examples/python/performance/func/runme.py b/Examples/python/performance/func/runme.py index 760a8ab6d..3b142791c 100644 --- a/Examples/python/performance/func/runme.py +++ b/Examples/python/performance/func/runme.py @@ -1,5 +1,5 @@ import sys -sys.path.append('..') +sys.path.append("..") import harness diff --git a/Examples/python/performance/harness.py b/Examples/python/performance/harness.py index c3d38b4fb..3468faaad 100644 --- a/Examples/python/performance/harness.py +++ b/Examples/python/performance/harness.py @@ -17,16 +17,16 @@ def run(proc): except IndexError: proc = Popen( - [sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE) + [sys.executable, "runme.py", "Simple_baseline"], stdout=PIPE) (stdout, stderr) = proc.communicate() print stdout proc = Popen( - [sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE) + [sys.executable, "runme.py", "Simple_optimized"], stdout=PIPE) (stdout, stderr) = proc.communicate() print stdout proc = Popen( - [sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE) + [sys.executable, "runme.py", "Simple_builtin"], stdout=PIPE) (stdout, stderr) = proc.communicate() print stdout diff --git a/Examples/python/performance/hierarchy/runme.py b/Examples/python/performance/hierarchy/runme.py index 8255cdc86..389958284 100644 --- a/Examples/python/performance/hierarchy/runme.py +++ b/Examples/python/performance/hierarchy/runme.py @@ -1,5 +1,5 @@ import sys -sys.path.append('..') +sys.path.append("..") import harness diff --git a/Examples/python/performance/hierarchy_operator/runme.py b/Examples/python/performance/hierarchy_operator/runme.py index eabfae864..48241d48b 100644 --- a/Examples/python/performance/hierarchy_operator/runme.py +++ b/Examples/python/performance/hierarchy_operator/runme.py @@ -1,5 +1,5 @@ import sys -sys.path.append('..') +sys.path.append("..") import harness diff --git a/Examples/python/performance/operator/runme.py b/Examples/python/performance/operator/runme.py index d75ae404c..798dd8bf9 100644 --- a/Examples/python/performance/operator/runme.py +++ b/Examples/python/performance/operator/runme.py @@ -1,5 +1,5 @@ import sys -sys.path.append('..') +sys.path.append("..") import harness From 15ad67c37f8ddbb33e69a14ebaf97251dcfd4ee7 Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Mon, 15 Jul 2019 16:08:31 +0100 Subject: [PATCH 1692/2031] Skip failing bool[] test cases when running under mono --- Examples/test-suite/csharp/Makefile.in | 3 --- .../test-suite/csharp/csharp_lib_arrays_bool_runme.cs | 11 +++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 49608e809..8272864d5 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -37,9 +37,6 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_upcast \ cpp11_strongly_typed_enumerations_simple \ -# bool[] typemaps don't work correctly when running under mono -FAILING_CPP_TESTS = csharp_lib_arrays_bool - include $(srcdir)/../common.mk # Overridden variables here diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs index 25b7fe699..24ae8a73e 100644 --- a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs +++ b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs @@ -25,6 +25,12 @@ public class runme CompareArrays(source, target, "bool[] INOUT"); } + if( runtimeIsMono() ) + { + Console.Error.WriteLine("Tests are running on mono, failing bool[] tests skipped"); + return; + } + { bool[] source = { true, false, false, true, false, true, true, false }; bool[] target = new bool[ source.Length ]; @@ -74,5 +80,10 @@ public class runme Console.Error.Write( "{0} ", i ); Console.Error.WriteLine(); } + + static bool runtimeIsMono() + { + return Type.GetType ("Mono.Runtime") != null; + } } From fc9c37192b1c5793e6fb37378284db071bd77d9f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jul 2019 19:46:32 +0100 Subject: [PATCH 1693/2031] Quieten failing bool[] testcase message --- Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs index 24ae8a73e..3b19b576f 100644 --- a/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs +++ b/Examples/test-suite/csharp/csharp_lib_arrays_bool_runme.cs @@ -27,7 +27,8 @@ public class runme if( runtimeIsMono() ) { - Console.Error.WriteLine("Tests are running on mono, failing bool[] tests skipped"); +// Console.Error.WriteLine("Tests are running on mono, failing bool[] tests skipped"); +// See Mono bug report https://github.com/mono/mono/issues/15592 return; } From a7fa720c1f48662dd8fad3f9c068e1e9eed04393 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jul 2019 19:50:35 +0100 Subject: [PATCH 1694/2031] Add changes entry to fix C# bool[] --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 99b31d5c9..27351c834 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-16: geefr + [C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall + as 1-byte. + 2019-06-06: bkotzz [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes a native Java array as input. From db9822788e183b79457d6bedab8b9a5cabb4cd5e Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 12 Jul 2019 18:33:29 +0200 Subject: [PATCH 1695/2031] Use PyObject_GC_UnTrack in lieu of the old variant The _PyObject_GC_UNTRACK[1] macro got deprecated in 3.6 and finally removed in 3.8. Therefore use PyObject_GC_UnTrack instead. [1] https://docs.python.org/3/c-api/gcsupport.html#c._PyObject_GC_UNTRACK --- Lib/python/builtin.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 5062a8b42..28051e67b 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -117,7 +117,7 @@ SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) SWIGINTERN void SwigPyStaticVar_dealloc(PyDescrObject *descr) { - _PyObject_GC_UNTRACK(descr); + PyObject_GC_UnTrack(descr); Py_XDECREF(PyDescr_TYPE(descr)); Py_XDECREF(PyDescr_NAME(descr)); PyObject_GC_Del(descr); From d6ec7eb2789956f30b23bae0870c34c8fefc0094 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Jul 2019 07:59:34 +0100 Subject: [PATCH 1696/2031] Update changes file with recent Python improvements --- CHANGES.current | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e13875d8d..dca51c37f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-18: gicmo + [Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack. + +2019-07-18: cher-nov + [Python] #1573 Generated Python code uses consistent string quoting style - double + quotes. + 2019-07-16: geefr [C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall as 1-byte. From 5131096b8035891e241e954124a3f048163a188f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Jul 2019 19:49:50 +0100 Subject: [PATCH 1697/2031] li_std_wstring test rename to li_std_wstring_inherit This testcase was only run in Ruby and Python and implements an obscure feature where a C++ class inherits from a std::wstring. The li_std_wstring test is left in place to be modified in next commit for more regular wstring testing across all languages. --- Examples/test-suite/li_std_wstring_inherit.i | 113 ++++++++++++++++++ Examples/test-suite/python/Makefile.in | 2 +- .../python/li_std_wstring_inherit_runme.py | 106 ++++++++++++++++ Examples/test-suite/ruby/Makefile.in | 2 +- .../ruby/li_std_wstring_inherit_runme.rb | 42 +++++++ 5 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/li_std_wstring_inherit.i create mode 100644 Examples/test-suite/python/li_std_wstring_inherit_runme.py create mode 100644 Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb diff --git a/Examples/test-suite/li_std_wstring_inherit.i b/Examples/test-suite/li_std_wstring_inherit.i new file mode 100644 index 000000000..547c41a87 --- /dev/null +++ b/Examples/test-suite/li_std_wstring_inherit.i @@ -0,0 +1,113 @@ +%module li_std_wstring_inherit +%include +%include + + +// throw is invalid in C++17 and later, only SWIG to use it +#define TESTCASE_THROW1(T1) throw(T1) +%{ +#define TESTCASE_THROW1(T1) +%} + +%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; +} + + +wchar_t* test_wchar_overload() { + return 0; +} + +wchar_t* test_wchar_overload(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; +} + +bool test_equal_abc(const std::wstring &s) { + return L"abc" == s; +} + +void test_throw() TESTCASE_THROW1(std::wstring){ + static std::wstring x = L"x"; + + throw x; +} + +const char * non_utf8_c_str() { + return "h\xe9llo"; +} + +size_t size_wstring_size(const std::wstring& s) { + return s.size(); +} + +#ifdef SWIGPYTHON_BUILTIN +bool is_python_builtin() { return true; } +#else +bool is_python_builtin() { return false; } +#endif + +%} + + diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 0151f5918..be06f7e51 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -55,7 +55,7 @@ CPP_TEST_CASES += \ li_std_vectora \ li_std_vector_extra \ li_std_wstream \ - li_std_wstring \ + li_std_wstring_inherit \ primitive_types \ python_abstractbase \ python_append \ diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py new file mode 100644 index 000000000..0ede5b16b --- /dev/null +++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py @@ -0,0 +1,106 @@ +import li_std_wstring_inherit +import sys + +x = u"h" + +if li_std_wstring_inherit.test_wcvalue(x) != x: + print li_std_wstring_inherit.test_wcvalue(x) + raise RuntimeError("bad string mapping") + +x = u"hello" +if li_std_wstring_inherit.test_ccvalue(x) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_cvalue(x) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_wchar_overload(x) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_wchar_overload("not unicode") != "not unicode": + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_value(x) != x: + print x, li_std_wstring_inherit.test_value(x) + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_const_reference(x) != x: + raise RuntimeError("bad string mapping") + + +s = li_std_wstring_inherit.wstring(u"he") +s = s + u"llo" + +if s != x: + print s, x + raise RuntimeError("bad string mapping") + +if s[1:4] != x[1:4]: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_value(s) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_const_reference(s) != x: + raise RuntimeError("bad string mapping") + +a = li_std_wstring_inherit.A(s) + +if li_std_wstring_inherit.test_value(a) != x: + raise RuntimeError("bad string mapping") + +if li_std_wstring_inherit.test_const_reference(a) != x: + raise RuntimeError("bad string mapping") + +b = li_std_wstring_inherit.wstring(" world") + +if a + b != "hello world": + raise RuntimeError("bad string mapping") + +if a + " world" != "hello world": + raise RuntimeError("bad string mapping") + +# This is expected to fail if -builtin is used +# Reverse operators not supported in builtin types +if not li_std_wstring_inherit.is_python_builtin(): + if "hello" + b != "hello world": + raise RuntimeError("bad string mapping") + + c = "hello" + b + if c.find_last_of("l") != 9: + raise RuntimeError("bad string mapping") + +s = "hello world" + +b = li_std_wstring_inherit.B("hi") + +b.name = li_std_wstring_inherit.wstring(u"hello") +if b.name != "hello": + raise RuntimeError("bad string mapping") + + +b.a = li_std_wstring_inherit.A("hello") +if b.a != u"hello": + raise RuntimeError("bad string mapping") + +# Byte strings only converted in Python 2 +if sys.version_info[0:2] < (3, 0): + x = b"hello there" + if li_std_wstring_inherit.test_value(x) != x: + raise RuntimeError("bad string mapping") + +# Invalid utf-8 in a byte string fails in all versions +x = b"h\xe9llo" +try: + li_std_wstring_inherit.test_value(x) + raise RuntimeError("TypeError not thrown") +except TypeError: + pass + +# Check surrogateescape +if sys.version_info[0:2] > (3, 1): + x = u"h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo" + if li_std_wstring_inherit.non_utf8_c_str() != x: + raise RuntimeError("surrogateescape not working") + if li_std_wstring_inherit.size_wstring(x) != 5 and len(x) != 5: + raise RuntimeError("Unexpected length") diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 6393026a4..d75cdb058 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -20,7 +20,7 @@ CPP_TEST_CASES = \ li_std_queue \ li_std_set \ li_std_stack \ - li_std_wstring \ + li_std_wstring_inherit \ primitive_types \ ruby_alias_method \ ruby_keywords \ diff --git a/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb new file mode 100644 index 000000000..4a66e9fcf --- /dev/null +++ b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +require 'swig_assert' +require 'li_std_wstring_inherit' + +x = "abc" +swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", "x", binding) +swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", "x", binding) +swig_assert_equal("Li_std_wstring_inherit.test_value(Li_std_wstring_inherit::Wstring.new(x))", "x", binding) + +swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload()", "nil", binding) + +swig_assert_equal("Li_std_wstring_inherit.test_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) +swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) +swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) +swig_assert_equal("Li_std_wstring_inherit.test_reference(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) + +x = "y" +swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding) +a = Li_std_wstring_inherit::A.new(x) +swig_assert_equal("Li_std_wstring_inherit.test_value(a)", "x", binding) + +x = "hello" +swig_assert_equal("Li_std_wstring_inherit.test_const_reference(x)", "x", binding) + + +swig_assert_equal("Li_std_wstring_inherit.test_pointer_out", "'x'", binding) +swig_assert_equal("Li_std_wstring_inherit.test_const_pointer_out", "'x'", binding) +swig_assert_equal("Li_std_wstring_inherit.test_reference_out()", "'x'", binding) + +s = "abc" +swig_assert("Li_std_wstring_inherit.test_equal_abc(s)", binding) + +begin + Li_std_wstring_inherit.test_throw +rescue RuntimeError => e + swig_assert_equal("e.message", "'x'", binding) +end + +x = "abc\0def" +swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding) +swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", '"abc"', binding) +swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", '"abc"', binding) From 0c2b454eb3e8738201bbab24ee640c9e140d87a7 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sat, 20 Jul 2019 07:05:38 +0200 Subject: [PATCH 1698/2031] Lua userdata print pointing to wrapped memory This is actually a fix to some functionality that I submitted many years ago. :) At the time I set the string conversion to output the userdata address, but since that points to an internal SWIG structure, it's way more useful to the user to point to the actual memory being wrapped in that userdata. --- Lib/lua/luarun.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 9636cdc9b..ac0033ff6 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1040,7 +1040,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) /* there should be 1 param passed in (1) userdata (not the metatable) */ const char *className; - void* userData; + swig_lua_userdata* userData; assert(lua_isuserdata(L,1)); /* just in case */ userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ @@ -1049,7 +1049,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); - lua_pushfstring(L, "<%s userdata: %p>", className, userData); + lua_pushfstring(L, "<%s userdata: %p>", className, userData->ptr); return 1; } From ac47e4b76a4aa347121d628f887214d75457bbea Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sat, 20 Jul 2019 07:09:24 +0200 Subject: [PATCH 1699/2031] matching code conventions --- Lib/lua/luarun.swg | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index ac0033ff6..f39a7009d 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -289,7 +289,7 @@ to tell the two structures apart within SWIG, other than by looking at the type typedef struct { swig_type_info *type; int own; /* 1 if owned & must be destroyed */ - char data[1]; /* arbitrary amount of data */ + char data[1]; /* arbitrary amount of data */ } swig_lua_rawdata; /* Common SWIG API */ @@ -341,7 +341,7 @@ typedef struct { #define SWIG_isptrtype(L,I) (lua_isuserdata(L,I) || lua_isnil(L,I)) #ifdef __cplusplus -/* Special helper for member function pointers +/* Special helper for member function pointers it gets the address, casts it, then dereferences it */ /*#define SWIG_mem_fn_as_voidptr(a) (*((char**)&(a))) */ #endif @@ -444,7 +444,7 @@ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_ent lua_pop(L,1); /*remove nil */ lua_newtable(L); SWIG_Lua_elua_emulate_register(L,entry->value.value.table); - } + } if(is_metatable) { assert(lua_istable(L,-1)); lua_pushvalue(L,-1); @@ -453,11 +453,11 @@ SWIGINTERN void SWIG_Lua_elua_emulate_register(lua_State *L, const swig_elua_ent break; case LUA_TUSERDATA: - if(entry->value.value.userdata.member) + if(entry->value.value.userdata.member) SWIG_NewMemberObj(L,entry->value.value.userdata.pvalue, entry->value.value.userdata.lvalue, *(entry->value.value.userdata.ptype)); - else + else SWIG_NewPointerObj(L,entry->value.value.userdata.pvalue, *(entry->value.value.userdata.ptype),0); break; @@ -502,7 +502,7 @@ SWIGINTERN int SWIG_Lua_emulate_elua_getmetatable(lua_State *L) } assert(lua_gettop(L) == 2); return 1; - + fail: lua_error(L); return 0; @@ -520,7 +520,7 @@ SWIGINTERN void SWIG_Lua_emulate_elua_swap_getmetatable(lua_State *L) lua_pushcfunction(L, SWIG_Lua_emulate_elua_getmetatable); lua_rawset(L,-3); lua_pop(L,2); - + } /* END OF REMOVE */ @@ -1042,7 +1042,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) const char *className; swig_lua_userdata* userData; assert(lua_isuserdata(L,1)); /* just in case */ - userData = lua_touserdata(L,1); /* get the userdata address for later */ + userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ @@ -1061,7 +1061,7 @@ SWIGINTERN int SWIG_Lua_class_disown(lua_State *L) swig_lua_userdata *usr; assert(lua_isuserdata(L,-1)); /* just in case */ usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ - + usr->own = 0; /* clear our ownership */ return 0; } @@ -1170,7 +1170,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname) Each class structure has a list of pointers to the base class structures. This function fills them. It cannot be done at compile time, as this will not work with hireachies -spread over more than one swig file. +spread over more than one swig file. Therefore it must be done at runtime, querying the SWIG type system. */ SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss) @@ -1404,11 +1404,11 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) lua_checkstack(L,5); numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ - + /* Get upvalues from closure */ lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ metamethod_name_idx = lua_gettop(L); - + lua_pushvalue(L, lua_upvalueindex(2)); clss = (const swig_lua_class*)(lua_touserdata(L,-1)); lua_pop(L,1); /* remove lightuserdata with clss from stack */ @@ -1440,7 +1440,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * /* metamethod name - on the top of the stack */ assert(lua_isstring(L,-1)); - + key_index = lua_gettop(L); /* Check whether method is already defined in metatable */ @@ -1450,7 +1450,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * lua_pop(L,1); return -1; } - lua_pop(L,1); + lua_pop(L,1); /* Iterating over immediate bases */ for(i=0;clss->bases[i];i++) @@ -1460,13 +1460,13 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * lua_pushvalue(L, key_index); lua_rawget(L, -2); if( !lua_isnil(L,-1) ) { - lua_pushvalue(L, key_index); + lua_pushvalue(L, key_index); /* Add proxy function */ lua_pushvalue(L, key_index); /* first closure value is function name */ lua_pushlightuserdata(L, clss); /* second closure value is swig_lua_class structure */ lua_pushcclosure(L, SWIG_Lua_resolve_metamethod, 2); - + lua_rawset(L, metatable_index); success = 1; } @@ -1477,7 +1477,7 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * break; } - return success; + return success; } SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) @@ -1816,7 +1816,7 @@ SWIGRUNTIME void SWIG_Lua_NewPackedObj(lua_State *L,void *ptr,size_t size,swig_t memcpy(raw->data,ptr,size); /* copy the data */ SWIG_Lua_AddMetatable(L,type); /* add metatable */ } - + /* converts a packed userdata. user for member fn pointers only */ SWIGRUNTIME int SWIG_Lua_ConvertPacked(lua_State *L,int index,void *ptr,size_t size,swig_type_info *type) { @@ -1915,7 +1915,7 @@ Unfortunately lua keeps changing its APIs, so we need a conditional compile In lua 5.0.X it's lua_dostring() In lua 5.1.X it's luaL_dostring() */ -SWIGINTERN int +SWIGINTERN int SWIG_Lua_dostring(lua_State *L, const char *str) { int ok,top; if (str==0 || str[0]==0) return 0; /* nothing to do */ @@ -1930,7 +1930,7 @@ SWIG_Lua_dostring(lua_State *L, const char *str) { } lua_settop(L,top); /* restore the stack */ return ok; -} +} #ifdef __cplusplus } From a9a7b03ba6557a6f9c8c8b284d907d6a7017e989 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 22 Jul 2019 19:05:21 +0100 Subject: [PATCH 1700/2031] Split testcases li_std_wstring.i and li_std_wstring_inherit.i Not many languages have support for std_wstring.i, so disable testing for these languages until added. --- Examples/test-suite/common.mk | 1 + .../test-suite/csharp/li_std_wstring_runme.cs | 112 ++++++++--------- Examples/test-suite/li_std_wstring.i | 51 ++------ Examples/test-suite/li_std_wstring_inherit.i | 74 ------------ .../test-suite/octave/li_std_wstring_runme.m | 95 --------------- .../python/li_std_wstring_inherit_runme.py | 61 ---------- .../test-suite/python/li_std_wstring_runme.py | 113 +++++++----------- .../ruby/li_std_wstring_inherit_runme.rb | 30 ----- .../test-suite/ruby/li_std_wstring_runme.rb | 46 ++++--- 9 files changed, 135 insertions(+), 448 deletions(-) delete mode 100644 Examples/test-suite/octave/li_std_wstring_runme.m diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 742536201..7aa0e91d1 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -655,6 +655,7 @@ CPP_STD_TEST_CASES += \ li_std_vector_enum \ li_std_vector_member_var\ li_std_vector_ptr \ + li_std_wstring \ smart_pointer_inherit \ template_typedef_fnc \ template_type_namespace \ diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index fe663a3e0..501ab8496 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -3,74 +3,74 @@ using li_std_wstringNamespace; public class runme { + static private void check_equal(char a, char b) + { + if (a != b) + throw new Exception("failed " + a + " " + b); + } + + static private void check_equal(string a, string b) + { + if (a != b) + throw new Exception("failed " + a + " " + b); + } + static void Main() { - char y='h'; + char h = 'h'; + check_equal(li_std_wstring.test_wcvalue(h), h); - if (li_std_wstring.test_wcvalue(y) != y) - throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue(y)); + string x = "abc"; + check_equal(li_std_wstring.test_ccvalue(x), x); + check_equal(li_std_wstring.test_cvalue(x), x); - if (li_std_wstring.test_wcvalue_w() != 'W') - throw new Exception("bad string mapping:" + li_std_wstring.test_wcvalue_w()); + check_equal(li_std_wstring.test_wchar_overload(x), x); + check_equal(li_std_wstring.test_wchar_overload(), null); - string x="hello"; + li_std_wstring.test_pointer(null); + li_std_wstring.test_const_pointer(null); - if (li_std_wstring.test_ccvalue(x) != x) - throw new Exception("bad string mapping"); + try { + li_std_wstring.test_value(null); + throw new Exception("NULL check failed"); + } catch (ArgumentNullException) { + } - if (li_std_wstring.test_cvalue(x) != x) - throw new Exception("bad string mapping"); + try { + li_std_wstring.test_reference(null); + throw new Exception("NULL check failed"); + } catch (ArgumentNullException e) { + if (!e.Message.Contains("type is null")) + throw new Exception("Missing text " + e); + } + try { + li_std_wstring.test_const_reference(null); + throw new Exception("NULL check failed"); + } catch (ArgumentNullException e) { + if (!e.Message.Contains("null wstring")) + throw new Exception("Missing text " + e); + } + x = "hello"; + check_equal(li_std_wstring.test_const_reference(x), x); - if (li_std_wstring.test_value(x) != x) - throw new Exception("bad string mapping: " + x + li_std_wstring.test_value(x)); + /* TODO + string s = "abc"; + if (!li_std_wstring.test_equal_abc(s)) + throw new Exception("Not equal " + s); - if (li_std_wstring.test_const_reference(x) != x) - throw new Exception("bad string mapping"); + try { + li_std_wstring.test_throw(); + } catch (Exception e) { + check_equal(e.Message, "throwing test_throw"); + } + x = "abc\0def"; + check_equal(li_std_wstring.test_value(x), x); + check_equal(li_std_wstring.test_ccvalue(x), "abc"); + check_equal(li_std_wstring.test_wchar_overload(x), "abc"); + */ - string s = "he"; - s = s + "llo"; - - if (s != x) - throw new Exception("bad string mapping: " + s + x); - - if (li_std_wstring.test_value(s) != x) - throw new Exception("bad string mapping"); - - if (li_std_wstring.test_const_reference(s) != x) - throw new Exception("bad string mapping"); - - string a = s; - - if (li_std_wstring.test_value(a) != x) - throw new Exception("bad string mapping"); - - if (li_std_wstring.test_const_reference(a) != x) - throw new Exception("bad string mapping"); - - string b = " world"; - - if (a + b != "hello world") - throw new Exception("bad string mapping"); - - if (a + " world" != "hello world") - throw new Exception("bad string mapping"); - - if ("hello" + b != "hello world") - throw new Exception("bad string mapping"); - - s = "hello world"; - - B myB = new B("hi"); - - myB.name = "hello"; - if (myB.name != "hello") - throw new Exception("bad string mapping"); - - myB.a = "hello"; - if (myB.a != "hello") - throw new Exception("bad string mapping"); } } diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index b2b7305da..55d45383e 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -1,7 +1,9 @@ %module li_std_wstring -%include -%include +// The languages below are yet to provide std_wstring.i +#if !(defined(SWIGD) || defined(SWIGGO) || defined(SWIGGUILE) || defined(SWIGJAVASCRIPT) || defined(SWIGLUA) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGOCTAVE) || defined(SWIGPERL) || defined(SWIGPHP) || defined(SWIGR) || defined(SWIGSCILAB)) + +%include // throw is invalid in C++17 and later, only SWIG to use it #define TESTCASE_THROW1(T1) throw(T1) @@ -10,26 +12,7 @@ %} %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; - -}; - +#include wchar_t test_wcvalue(wchar_t x) { return x; @@ -63,33 +46,18 @@ const std::wstring& test_const_reference(const std::wstring &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; -} - bool test_equal_abc(const std::wstring &s) { return L"abc" == s; } void test_throw() TESTCASE_THROW1(std::wstring){ - static std::wstring x = L"x"; + static std::wstring x = L"throwing test_throw"; throw x; } @@ -102,12 +70,7 @@ size_t size_wstring(const std::wstring& s) { return s.size(); } -#ifdef SWIGPYTHON_BUILTIN -bool is_python_builtin() { return true; } -#else -bool is_python_builtin() { return false; } -#endif - %} +#endif diff --git a/Examples/test-suite/li_std_wstring_inherit.i b/Examples/test-suite/li_std_wstring_inherit.i index 547c41a87..54c6bd8c4 100644 --- a/Examples/test-suite/li_std_wstring_inherit.i +++ b/Examples/test-suite/li_std_wstring_inherit.i @@ -3,12 +3,6 @@ %include -// throw is invalid in C++17 and later, only SWIG to use it -#define TESTCASE_THROW1(T1) throw(T1) -%{ -#define TESTCASE_THROW1(T1) -%} - %inline %{ struct A : std::wstring @@ -30,78 +24,10 @@ struct B }; - -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; -} - - -wchar_t* test_wchar_overload() { - return 0; -} - -wchar_t* test_wchar_overload(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; -} - -bool test_equal_abc(const std::wstring &s) { - return L"abc" == s; -} - -void test_throw() TESTCASE_THROW1(std::wstring){ - static std::wstring x = L"x"; - - throw x; -} - -const char * non_utf8_c_str() { - return "h\xe9llo"; -} - -size_t size_wstring_size(const std::wstring& s) { - return s.size(); -} - #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } #else diff --git a/Examples/test-suite/octave/li_std_wstring_runme.m b/Examples/test-suite/octave/li_std_wstring_runme.m deleted file mode 100644 index cbccc0c12..000000000 --- a/Examples/test-suite/octave/li_std_wstring_runme.m +++ /dev/null @@ -1,95 +0,0 @@ -# do not dump Octave core -if exist("crash_dumps_octave_core", "builtin") - crash_dumps_octave_core(0); -endif - -li_std_wstring - -x="h"; - -if (li_std_wstring.test_wcvalue(x) != x) - error("bad string mapping") -endif - -x="hello"; -if (li_std_wstring.test_ccvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_wstring.test_cvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_wstring.test_value(x) != x) - error("bad string mapping") -endif - -if (li_std_wstring.test_const_reference(x) != x) - error("bad string mapping") -endif - - -s = li_std_wstring.wstring("he"); -s = s + "llo"; - -if (s != x) - error("bad string mapping") -endif - -if (s(1:4) != x(1:4)) - error("bad string mapping") -endif - -if (li_std_wstring.test_value(s) != x) - error("bad string mapping") -endif - -if (li_std_wstring.test_const_reference(s) != x) - error("bad string mapping") -endif - -a = li_std_wstring.A(s); - -if (li_std_wstring.test_value(a) != x) - error("bad string mapping") -endif - -if (li_std_wstring.test_const_reference(a) != x) - error("bad string mapping") -endif - -b = li_std_wstring.wstring(" world"); - -if (a + b != "hello world") - error("bad string mapping") -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_wstring.B("hi"); - -b.name = li_std_wstring.wstring("hello"); -if (b.name != "hello") - error("bad string mapping") -endif - - -b.a = li_std_wstring.A("hello"); -if (b.a != "hello") - error("bad string mapping") -endif - - diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py index 0ede5b16b..558914e7e 100644 --- a/Examples/test-suite/python/li_std_wstring_inherit_runme.py +++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py @@ -1,32 +1,7 @@ import li_std_wstring_inherit import sys -x = u"h" - -if li_std_wstring_inherit.test_wcvalue(x) != x: - print li_std_wstring_inherit.test_wcvalue(x) - raise RuntimeError("bad string mapping") - x = u"hello" -if li_std_wstring_inherit.test_ccvalue(x) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_cvalue(x) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_wchar_overload(x) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_wchar_overload("not unicode") != "not unicode": - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_value(x) != x: - print x, li_std_wstring_inherit.test_value(x) - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_const_reference(x) != x: - raise RuntimeError("bad string mapping") - s = li_std_wstring_inherit.wstring(u"he") s = s + u"llo" @@ -38,20 +13,7 @@ if s != x: if s[1:4] != x[1:4]: raise RuntimeError("bad string mapping") -if li_std_wstring_inherit.test_value(s) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_const_reference(s) != x: - raise RuntimeError("bad string mapping") - a = li_std_wstring_inherit.A(s) - -if li_std_wstring_inherit.test_value(a) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring_inherit.test_const_reference(a) != x: - raise RuntimeError("bad string mapping") - b = li_std_wstring_inherit.wstring(" world") if a + b != "hello world": @@ -70,8 +32,6 @@ if not li_std_wstring_inherit.is_python_builtin(): if c.find_last_of("l") != 9: raise RuntimeError("bad string mapping") -s = "hello world" - b = li_std_wstring_inherit.B("hi") b.name = li_std_wstring_inherit.wstring(u"hello") @@ -83,24 +43,3 @@ b.a = li_std_wstring_inherit.A("hello") if b.a != u"hello": raise RuntimeError("bad string mapping") -# Byte strings only converted in Python 2 -if sys.version_info[0:2] < (3, 0): - x = b"hello there" - if li_std_wstring_inherit.test_value(x) != x: - raise RuntimeError("bad string mapping") - -# Invalid utf-8 in a byte string fails in all versions -x = b"h\xe9llo" -try: - li_std_wstring_inherit.test_value(x) - raise RuntimeError("TypeError not thrown") -except TypeError: - pass - -# Check surrogateescape -if sys.version_info[0:2] > (3, 1): - x = u"h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo" - if li_std_wstring_inherit.non_utf8_c_str() != x: - raise RuntimeError("surrogateescape not working") - if li_std_wstring_inherit.size_wstring(x) != 5 and len(x) != 5: - raise RuntimeError("Unexpected length") diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index bd49a4371..c6210e2de 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -1,87 +1,60 @@ import li_std_wstring import sys -x = u"h" +def check_equal(a, b): + if a != b: + raise RuntimeError("failed {} {}".format(a, b)) -if li_std_wstring.test_wcvalue(x) != x: - print li_std_wstring.test_wcvalue(x) - raise RuntimeError("bad string mapping") +h = u"h" +check_equal(li_std_wstring.test_wcvalue(h), h) -x = u"hello" -if li_std_wstring.test_ccvalue(x) != x: - raise RuntimeError("bad string mapping") +x = u"abc" +check_equal(li_std_wstring.test_ccvalue(x), x) +check_equal(li_std_wstring.test_cvalue(x), x) -if li_std_wstring.test_cvalue(x) != x: - raise RuntimeError("bad string mapping") +check_equal(li_std_wstring.test_wchar_overload(x), x) +check_equal(li_std_wstring.test_wchar_overload(), None) -if li_std_wstring.test_wchar_overload(x) != x: - raise RuntimeError("bad string mapping") +li_std_wstring.test_pointer(None) +li_std_wstring.test_const_pointer(None) -if li_std_wstring.test_wchar_overload("not unicode") != "not unicode": - raise RuntimeError("bad string mapping") +try: + li_std_wstring.test_value(None) + raise RuntimeError("NULL check failed") +except TypeError as e: + pass -if li_std_wstring.test_value(x) != x: - print x, li_std_wstring.test_value(x) - raise RuntimeError("bad string mapping") +try: + li_std_wstring.test_reference(None) + raise RuntimeError("NULL check failed") +except ValueError as e: + if "invalid null reference" not in str(e): + raise RuntimeError("Missing text {}".format(e)) +try: + li_std_wstring.test_const_reference(None) + raise RuntimeError("NULL check failed") +except ValueError as e: + if "invalid null reference" not in str(e): + raise RuntimeError("Missing text {}".format(e)) -if li_std_wstring.test_const_reference(x) != x: - raise RuntimeError("bad string mapping") +x = "hello" +check_equal(li_std_wstring.test_const_reference(x), x) +s = "abc" +if not li_std_wstring.test_equal_abc(s): + raise RuntimeError("Not equal {}".format(s)) -s = li_std_wstring.wstring(u"he") -s = s + u"llo" +try: + li_std_wstring.test_throw +except RuntimeError as e: + check_equal(e.message, "throwing test_throw") -if s != x: - print s, x - raise RuntimeError("bad string mapping") +x = "abc\0def" +check_equal(li_std_wstring.test_value(x), x) +check_equal(li_std_wstring.test_ccvalue(x), "abc") +check_equal(li_std_wstring.test_wchar_overload(x), "abc") -if s[1:4] != x[1:4]: - raise RuntimeError("bad string mapping") - -if li_std_wstring.test_value(s) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring.test_const_reference(s) != x: - raise RuntimeError("bad string mapping") - -a = li_std_wstring.A(s) - -if li_std_wstring.test_value(a) != x: - raise RuntimeError("bad string mapping") - -if li_std_wstring.test_const_reference(a) != x: - raise RuntimeError("bad string mapping") - -b = li_std_wstring.wstring(" world") - -if a + b != "hello world": - raise RuntimeError("bad string mapping") - -if a + " world" != "hello world": - raise RuntimeError("bad string mapping") - -# This is expected to fail if -builtin is used -# Reverse operators not supported in builtin types -if not li_std_wstring.is_python_builtin(): - if "hello" + b != "hello world": - raise RuntimeError("bad string mapping") - - c = "hello" + b - if c.find_last_of("l") != 9: - raise RuntimeError("bad string mapping") - -s = "hello world" - -b = li_std_wstring.B("hi") - -b.name = li_std_wstring.wstring(u"hello") -if b.name != "hello": - raise RuntimeError("bad string mapping") - - -b.a = li_std_wstring.A("hello") -if b.a != u"hello": - raise RuntimeError("bad string mapping") +################### Python specific # Byte strings only converted in Python 2 if sys.version_info[0:2] < (3, 0): diff --git a/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb index 4a66e9fcf..b5a90d834 100644 --- a/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb +++ b/Examples/test-suite/ruby/li_std_wstring_inherit_runme.rb @@ -1,42 +1,12 @@ # -*- coding: utf-8 -*- require 'swig_assert' require 'li_std_wstring_inherit' - x = "abc" -swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", "x", binding) -swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", "x", binding) swig_assert_equal("Li_std_wstring_inherit.test_value(Li_std_wstring_inherit::Wstring.new(x))", "x", binding) -swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload()", "nil", binding) - -swig_assert_equal("Li_std_wstring_inherit.test_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring_inherit.test_const_pointer(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring_inherit.test_reference(Li_std_wstring_inherit::Wstring.new(x))", "nil", binding) x = "y" swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding) a = Li_std_wstring_inherit::A.new(x) swig_assert_equal("Li_std_wstring_inherit.test_value(a)", "x", binding) -x = "hello" -swig_assert_equal("Li_std_wstring_inherit.test_const_reference(x)", "x", binding) - - -swig_assert_equal("Li_std_wstring_inherit.test_pointer_out", "'x'", binding) -swig_assert_equal("Li_std_wstring_inherit.test_const_pointer_out", "'x'", binding) -swig_assert_equal("Li_std_wstring_inherit.test_reference_out()", "'x'", binding) - -s = "abc" -swig_assert("Li_std_wstring_inherit.test_equal_abc(s)", binding) - -begin - Li_std_wstring_inherit.test_throw -rescue RuntimeError => e - swig_assert_equal("e.message", "'x'", binding) -end - -x = "abc\0def" -swig_assert_equal("Li_std_wstring_inherit.test_value(x)", "x", binding) -swig_assert_equal("Li_std_wstring_inherit.test_ccvalue(x)", '"abc"', binding) -swig_assert_equal("Li_std_wstring_inherit.test_wchar_overload(x)", '"abc"', binding) diff --git a/Examples/test-suite/ruby/li_std_wstring_runme.rb b/Examples/test-suite/ruby/li_std_wstring_runme.rb index 0cf38ae4b..4922d8d90 100644 --- a/Examples/test-suite/ruby/li_std_wstring_runme.rb +++ b/Examples/test-suite/ruby/li_std_wstring_runme.rb @@ -2,38 +2,48 @@ require 'swig_assert' require 'li_std_wstring' -x = "abc" -swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding) -swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding) -swig_assert_equal("Li_std_wstring.test_value(Li_std_wstring::Wstring.new(x))", "x", binding) +h = "h" +swig_assert_equal("Li_std_wstring.test_wcvalue(h)", "h", binding) +x = "abc" +swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding) +swig_assert_equal("Li_std_wstring.test_cvalue(x)", "x", binding) + +swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding) swig_assert_equal("Li_std_wstring.test_wchar_overload()", "nil", binding) -swig_assert_equal("Li_std_wstring.test_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding) -swig_assert_equal("Li_std_wstring.test_reference(Li_std_wstring::Wstring.new(x))", "nil", binding) +Li_std_wstring.test_pointer(nil) +Li_std_wstring.test_const_pointer(nil) -x = "y" -swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding) -a = Li_std_wstring::A.new(x) -swig_assert_equal("Li_std_wstring.test_value(a)", "x", binding) +begin + Li_std_wstring.test_value(nil) + raise RuntimeError, "NULL check failed" +rescue TypeError => e +end + +begin + Li_std_wstring.test_reference(nil) + raise RuntimeError, "NULL check failed" +rescue ArgumentError => e + swig_assert_simple(e.message.include? "invalid null reference") +end +begin + Li_std_wstring.test_const_reference(nil) + raise RuntimeError, "NULL check failed" +rescue ArgumentError => e + swig_assert_simple(e.message.include? "invalid null reference") +end x = "hello" swig_assert_equal("Li_std_wstring.test_const_reference(x)", "x", binding) - -swig_assert_equal("Li_std_wstring.test_pointer_out", "'x'", binding) -swig_assert_equal("Li_std_wstring.test_const_pointer_out", "'x'", binding) -swig_assert_equal("Li_std_wstring.test_reference_out()", "'x'", binding) - s = "abc" swig_assert("Li_std_wstring.test_equal_abc(s)", binding) begin Li_std_wstring.test_throw rescue RuntimeError => e - swig_assert_equal("e.message", "'x'", binding) + swig_assert_equal("e.message", "'throwing test_throw'", binding) end x = "abc\0def" From 8f6d97ab8c97295fc74fac05f45f27c91884690a Mon Sep 17 00:00:00 2001 From: smithx Date: Fri, 17 May 2019 18:57:52 +0300 Subject: [PATCH 1701/2031] fix undesirable `wstring` encoding at return value marshalling for C# --- Lib/csharp/std_wstring.i | 5 ++++- Lib/csharp/wchar.i | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i index 09bdaaaa2..b18a2cca4 100644 --- a/Lib/csharp/std_wstring.i +++ b/Lib/csharp/std_wstring.i @@ -23,7 +23,10 @@ class wstring; // wstring %typemap(ctype, out="void *") wstring "wchar_t *" -%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") wstring "string" +%typemap(imtype, + inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]", + outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]" + ) wstring "string" %typemap(cstype) wstring "string" %typemap(csdirectorin) wstring "$iminput" %typemap(csdirectorout) wstring "$cscall" diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index 9361edf6f..79fb5a8cf 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -20,6 +20,7 @@ static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL; %pragma(csharp) imclasscode=%{ protected class SWIGWStringHelper { + [return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)] public delegate string SWIGWStringDelegate(global::System.IntPtr message); static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString); From 03f77453643e936575b4ed2e3b3539749d2c03b5 Mon Sep 17 00:00:00 2001 From: smithx Date: Sat, 18 May 2019 22:55:09 +0300 Subject: [PATCH 1702/2031] fix undesirable `wstring` encoding at return value marshalling for C# --- Lib/csharp/std_wstring.i | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i index b18a2cca4..162b90e80 100644 --- a/Lib/csharp/std_wstring.i +++ b/Lib/csharp/std_wstring.i @@ -63,7 +63,10 @@ class wstring; // const wstring & %typemap(ctype, out="void *") const wstring & "wchar_t *" -%typemap(imtype, inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]") const wstring & "string" +%typemap(imtype, + inattributes="[global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]", + outattributes="[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPWStr)]" + ) const wstring & "string" %typemap(cstype) const wstring & "string" %typemap(csdirectorin) const wstring & "$iminput" From eb6efdb60b1da8ec3341280ac79bb76373ad8bfc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Jul 2019 08:07:24 +0100 Subject: [PATCH 1703/2031] C# wstring testing Test code from issue #1530 --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index 501ab8496..a9bcf9b1e 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -71,6 +71,20 @@ public class runme check_equal(li_std_wstring.test_wchar_overload(x), "abc"); */ + { + // Unicode strings + string[] test_strings = { + "JP: 日本語", "DE: Kröpeliner Straße" , "RU: Война и мир", "EN: War and Peace" + }; + + foreach (string expected in test_strings) + { + string result = li_std_wstring.test_value(expected); + + if (result != expected) + throw new Exception("test_string failure '" + result + "' != '" + expected + "'"); + } + } } } From 2d36b3468a9d26a352a3d23e06aab012f6b7fb9f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Jul 2019 19:38:00 +0100 Subject: [PATCH 1704/2031] More C# wstring testing --- .../test-suite/csharp/li_std_wstring_runme.cs | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index a9bcf9b1e..b69d2c8bb 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -6,13 +6,13 @@ public class runme static private void check_equal(char a, char b) { if (a != b) - throw new Exception("failed " + a + " " + b); + throw new Exception("char failed '" + a + "' != '" + b + "'"); } static private void check_equal(string a, string b) { if (a != b) - throw new Exception("failed " + a + " " + b); + throw new Exception("string failed '" + a + "' != '" + b + "'"); } static void Main() @@ -58,6 +58,7 @@ public class runme string s = "abc"; if (!li_std_wstring.test_equal_abc(s)) throw new Exception("Not equal " + s); + */ try { li_std_wstring.test_throw(); @@ -65,6 +66,7 @@ public class runme check_equal(e.Message, "throwing test_throw"); } + /* TODO x = "abc\0def"; check_equal(li_std_wstring.test_value(x), x); check_equal(li_std_wstring.test_ccvalue(x), "abc"); @@ -79,10 +81,29 @@ public class runme foreach (string expected in test_strings) { - string result = li_std_wstring.test_value(expected); + string received = li_std_wstring.test_value(expected); + check_equal(received, expected); + } - if (result != expected) - throw new Exception("test_string failure '" + result + "' != '" + expected + "'"); + foreach (string expected in test_strings) + { + string received = li_std_wstring.test_const_reference(expected); + check_equal(received, expected); + } + + foreach (string expected in test_strings) + { + string received = li_std_wstring.test_ccvalue(expected); + check_equal(received, expected); + } + + foreach (string test_string in test_strings) + { + foreach (char expected in test_string) + { + char received = li_std_wstring.test_wcvalue(expected); + check_equal(received, expected); + } } } } From 55b5552a6aaa5df093ee66b381649c5ee5dcfc0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Jul 2019 19:57:06 +0100 Subject: [PATCH 1705/2031] More C# wstring testing --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index b69d2c8bb..316113f54 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -54,7 +54,9 @@ public class runme x = "hello"; check_equal(li_std_wstring.test_const_reference(x), x); - /* TODO + /* Postpone, tricky, std::wstring portability problem. + * std::wstring is 2 bytes on Windows, 4 bytes on Linux, LPWSTR is 2 bytes. + * .NET marshalling should work on Windows but not Linux. string s = "abc"; if (!li_std_wstring.test_equal_abc(s)) throw new Exception("Not equal " + s); @@ -66,12 +68,12 @@ public class runme check_equal(e.Message, "throwing test_throw"); } - /* TODO x = "abc\0def"; - check_equal(li_std_wstring.test_value(x), x); + // Unlike other languages, embedded NULL in std::string not supported + // check_equal(li_std_wstring.test_value(x), x); + check_equal(li_std_wstring.test_value(x), "abc"); check_equal(li_std_wstring.test_ccvalue(x), "abc"); check_equal(li_std_wstring.test_wchar_overload(x), "abc"); - */ { // Unicode strings From 10f0329e4bdaf0fa2df0399ba63623ec2e6c8dad Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Jul 2019 22:16:04 +0100 Subject: [PATCH 1706/2031] Add changes entry for C# std::wstring marshalling fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index dca51c37f..3b9634726 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-23: smithx + [C#] #1530 #1532 Fix marshalling of std::wstring to C#. + 2019-07-18: gicmo [Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack. From c7aae28a996fd4347bdb85bba801598b3151d081 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Jul 2019 08:35:13 +0100 Subject: [PATCH 1707/2031] Remove failing wchar c# test --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index 316113f54..ab013f923 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -99,6 +99,7 @@ public class runme check_equal(received, expected); } + /* Not working on Windows okay on Linux foreach (string test_string in test_strings) { foreach (char expected in test_string) @@ -107,6 +108,7 @@ public class runme check_equal(received, expected); } } + */ } } } From 0ff6893b2dc08b713db3ae71b125de15d629bb9a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Jul 2019 20:10:35 +0200 Subject: [PATCH 1708/2031] Make Python module source non-executable again 0f88f9997c78a937eb9afa122389caf9666e33dc (probably accidentally) changed this file to be executable, undo this as it doesn't make sense for a source file to have this mode. See #1242. --- Source/Modules/python.cxx | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 Source/Modules/python.cxx diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx old mode 100755 new mode 100644 From 15a0681b11977c965a720e3ae51ec26abdcc86a0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Jul 2019 21:51:52 +0100 Subject: [PATCH 1709/2031] Add note about wchar_t marshalling fix required for Windows --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 5 ++++- Lib/csharp/wchar.i | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index ab013f923..8b7ba1b30 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -99,7 +99,10 @@ public class runme check_equal(received, expected); } - /* Not working on Windows okay on Linux + /* Not working for Japanese and Russian characters on Windows, okay on Linux + * Is fixed by adding CharSet=CharSet.Unicode to the DllImport, so change to: + * [global::System.Runtime.InteropServices.DllImport("li_std_wstring", CharSet=global::System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="CSharp_li_std_wstringNamespace_test_wcvalue")] + * Needs a SWIG code change to support this foreach (string test_string in test_strings) { foreach (char expected in test_string) diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index 79fb5a8cf..798194114 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -53,7 +53,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStri // wchar_t %typemap(ctype) wchar_t "wchar_t" -%typemap(imtype) wchar_t "char" +%typemap(imtype) wchar_t "char" // Requires adding CharSet=CharSet.Unicode to the DllImport to correctly marshal Unicode characters %typemap(cstype) wchar_t "char" %typemap(csin) wchar_t "$csinput" From 753c50afd718851c6909b55d6a852728e56e81d7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Jul 2019 07:01:45 +0100 Subject: [PATCH 1710/2031] Update docs on %typecheck precedence levels --- Doc/Manual/Typemaps.html | 94 +++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 8a31dbf10..0bacd39f5 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -4630,37 +4630,69 @@ To support dynamic dispatch, SWIG first defines a general purpose type hierarchy

     Symbolic Name                   Precedence Value
     ------------------------------  ------------------
    -SWIG_TYPECHECK_POINTER           0  
    -SWIG_TYPECHECK_VOIDPTR           10 
    -SWIG_TYPECHECK_BOOL              15 
    -SWIG_TYPECHECK_UINT8             20 
    -SWIG_TYPECHECK_INT8              25 
    -SWIG_TYPECHECK_UINT16            30 
    -SWIG_TYPECHECK_INT16             35 
    -SWIG_TYPECHECK_UINT32            40 
    -SWIG_TYPECHECK_INT32             45 
    -SWIG_TYPECHECK_UINT64            50 
    -SWIG_TYPECHECK_INT64             55 
    -SWIG_TYPECHECK_UINT128           60 
    -SWIG_TYPECHECK_INT128            65 
    -SWIG_TYPECHECK_INTEGER           70 
    -SWIG_TYPECHECK_FLOAT             80 
    -SWIG_TYPECHECK_DOUBLE            90 
    -SWIG_TYPECHECK_COMPLEX           100 
    -SWIG_TYPECHECK_UNICHAR           110 
    -SWIG_TYPECHECK_UNISTRING         120 
    -SWIG_TYPECHECK_CHAR              130 
    -SWIG_TYPECHECK_STRING            140 
    -SWIG_TYPECHECK_BOOL_ARRAY        1015 
    -SWIG_TYPECHECK_INT8_ARRAY        1025 
    -SWIG_TYPECHECK_INT16_ARRAY       1035 
    -SWIG_TYPECHECK_INT32_ARRAY       1045 
    -SWIG_TYPECHECK_INT64_ARRAY       1055 
    -SWIG_TYPECHECK_INT128_ARRAY      1065 
    -SWIG_TYPECHECK_FLOAT_ARRAY       1080 
    -SWIG_TYPECHECK_DOUBLE_ARRAY      1090 
    -SWIG_TYPECHECK_CHAR_ARRAY        1130 
    -SWIG_TYPECHECK_STRING_ARRAY      1140 
    +SWIG_TYPECHECK_POINTER           0
    +SWIG_TYPECHECK_ITERATOR          5
    +SWIG_TYPECHECK_VOIDPTR           10
    +SWIG_TYPECHECK_BOOL              15
    +SWIG_TYPECHECK_UINT8             20
    +SWIG_TYPECHECK_INT8              25
    +SWIG_TYPECHECK_UINT16            30
    +SWIG_TYPECHECK_INT16             35
    +SWIG_TYPECHECK_UINT32            40
    +SWIG_TYPECHECK_INT32             45
    +SWIG_TYPECHECK_SIZE              47
    +SWIG_TYPECHECK_PTRDIFF           48
    +SWIG_TYPECHECK_UINT64            50
    +SWIG_TYPECHECK_INT64             55
    +SWIG_TYPECHECK_UINT128           60
    +SWIG_TYPECHECK_INT128            65
    +SWIG_TYPECHECK_INTEGER           70
    +SWIG_TYPECHECK_FLOAT             80
    +SWIG_TYPECHECK_DOUBLE            90
    +SWIG_TYPECHECK_CPLXFLT           95
    +SWIG_TYPECHECK_CPLXDBL           100
    +SWIG_TYPECHECK_COMPLEX           105
    +SWIG_TYPECHECK_UNICHAR           110
    +SWIG_TYPECHECK_STDUNISTRING      115
    +SWIG_TYPECHECK_UNISTRING         120
    +SWIG_TYPECHECK_CHAR              130
    +SWIG_TYPECHECK_STDSTRING         135
    +SWIG_TYPECHECK_STRING            140
    +SWIG_TYPECHECK_PAIR              150
    +SWIG_TYPECHECK_STDARRAY          155
    +SWIG_TYPECHECK_VECTOR            160
    +SWIG_TYPECHECK_DEQUE             170
    +SWIG_TYPECHECK_LIST              180
    +SWIG_TYPECHECK_SET               190
    +SWIG_TYPECHECK_MULTISET          200
    +SWIG_TYPECHECK_MAP               210
    +SWIG_TYPECHECK_MULTIMAP          220
    +SWIG_TYPECHECK_STACK             230
    +SWIG_TYPECHECK_QUEUE             240
    +SWIG_TYPECHECK_BOOL_ARRAY        1015
    +SWIG_TYPECHECK_INT8_ARRAY        1025
    +SWIG_TYPECHECK_INT16_ARRAY       1035
    +SWIG_TYPECHECK_INT32_ARRAY       1045
    +SWIG_TYPECHECK_INT64_ARRAY       1055
    +SWIG_TYPECHECK_INT128_ARRAY      1065
    +SWIG_TYPECHECK_FLOAT_ARRAY       1080
    +SWIG_TYPECHECK_DOUBLE_ARRAY      1090
    +SWIG_TYPECHECK_CHAR_ARRAY        1130
    +SWIG_TYPECHECK_STRING_ARRAY      1140
    +SWIG_TYPECHECK_OBJECT_ARRAY      1150
    +SWIG_TYPECHECK_BOOL_PTR          2015
    +SWIG_TYPECHECK_UINT8_PTR         2020
    +SWIG_TYPECHECK_INT8_PTR          2025
    +SWIG_TYPECHECK_UINT16_PTR        2030
    +SWIG_TYPECHECK_INT16_PTR         2035
    +SWIG_TYPECHECK_UINT32_PTR        2040
    +SWIG_TYPECHECK_INT32_PTR         2045
    +SWIG_TYPECHECK_UINT64_PTR        2050
    +SWIG_TYPECHECK_INT64_PTR         2055
    +SWIG_TYPECHECK_FLOAT_PTR         2080
    +SWIG_TYPECHECK_DOUBLE_PTR        2090
    +SWIG_TYPECHECK_CHAR_PTR          2130
    +SWIG_TYPECHECK_SWIGOBJECT        5000
     
    From b145c49375ff8b2847be17d6956c64a6d48a371d Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sat, 27 Jul 2019 20:47:18 +0200 Subject: [PATCH 1711/2031] actually seeing both is useful --- Lib/lua/luarun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index f39a7009d..a6959a65f 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1049,7 +1049,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); - lua_pushfstring(L, "<%s userdata: %p>", className, userData->ptr); + lua_pushfstring(L, "<%s userdata: %p::%p>", className, userdata, userData->ptr); return 1; } From 9c5b97ae366d32d8cd387d0fea900ea3911c855d Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sun, 28 Jul 2019 00:43:01 +0200 Subject: [PATCH 1712/2031] typo --- Lib/lua/luarun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index a6959a65f..5176f74cf 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1049,7 +1049,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); - lua_pushfstring(L, "<%s userdata: %p::%p>", className, userdata, userData->ptr); + lua_pushfstring(L, "<%s userdata: %p::%p>", className, userData, userData->ptr); return 1; } From a4432a68da2d85323f65f8205f18451c0979395e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 30 Jul 2019 21:12:04 +0200 Subject: [PATCH 1713/2031] Correct %init documentation for C#/Java For these languages, %init doesn't inject the code into the initialization function (because there is none), but just puts it into the global scope instead. [skip ci] --- Doc/Manual/SWIG.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d1492d30a..aec48ef03 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -3438,6 +3438,18 @@ initialization on module loading, you could write this: %} +

    +Please note that some language backends (e.g. C# or Java) don't have any +initialization function, hence you should define a global object performing +the necessary initialization for them instead: +

    + +
    +%init %{
    +  static struct MyInit { MyInit() { init_variables(); } } myInit;
    +%}
    +
    +

    5.7 An Interface Building Strategy

    From 98f29f8ad971da6e5d700f01b179c7ad87d5e0d4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Jul 2019 19:30:27 +0100 Subject: [PATCH 1714/2031] Remove deprecated DohClose in DOH --- Source/DOH/base.c | 19 ------------------- Source/DOH/doh.h | 7 ------- Source/DOH/dohint.h | 1 - Source/DOH/file.c | 22 ---------------------- Source/DOH/string.c | 1 - 5 files changed, 50 deletions(-) diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 12351dd09..f5e418893 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -755,25 +755,6 @@ int DohUngetc(int ch, DOH *obj) { return ungetc(ch, (FILE *) b); } -/* ----------------------------------------------------------------------------- - * DohClose() - * ----------------------------------------------------------------------------- */ - -/* -int DohClose(DOH *obj) { - DohBase *b = (DohBase *) obj; - DohObjInfo *objinfo; - if (DohCheck(obj)) { - objinfo = b->type; - if (objinfo->doh_file->doh_close) { - return (objinfo->doh_file->doh_close) (b); - } - return 0; - } - return fclose((FILE *) obj); -} -*/ - /* ----------------------------------------------------------------------------- * DohIsString() * ----------------------------------------------------------------------------- */ diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 5a9bae2b3..7cc279ebc 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -103,7 +103,6 @@ #define DohNewFileFromFile DOH_NAMESPACE(NewFileFromFile) #define DohNewFileFromFd DOH_NAMESPACE(NewFileFromFd) #define DohFileErrorDisplay DOH_NAMESPACE(FileErrorDisplay) -#define DohClose DOH_NAMESPACE(Close) #define DohCopyto DOH_NAMESPACE(Copyto) #define DohNewList DOH_NAMESPACE(NewList) #define DohNewHash DOH_NAMESPACE(NewHash) @@ -307,10 +306,6 @@ extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles); extern DOHFile *DohNewFileFromFile(FILE *f); extern DOHFile *DohNewFileFromFd(int fd); extern void DohFileErrorDisplay(DOHString * filename); -/* - Deprecated, just use DohDelete -extern int DohClose(DOH *file); -*/ extern int DohCopyto(DOHFile * input, DOHFile * output); @@ -392,7 +387,6 @@ extern void DohMemoryDebug(void); /* #define StringChar DohStringChar */ /* #define StringEqual DohStringEqual */ -#define Close DohClose #define vPrintf DohvPrintf #define GetInt DohGetInt #define GetDouble DohGetDouble @@ -424,7 +418,6 @@ extern void DohMemoryDebug(void); #define NewFileFromFile DohNewFileFromFile #define NewFileFromFd DohNewFileFromFd #define FileErrorDisplay DohFileErrorDisplay -#define Close DohClose #define NewVoid DohNewVoid #define Keys DohKeys #define Strcmp DohStrcmp diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h index c073bd95b..87def9d3d 100644 --- a/Source/DOH/dohint.h +++ b/Source/DOH/dohint.h @@ -49,7 +49,6 @@ typedef struct { int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */ int (*doh_seek) (DOH *obj, long offset, int whence); /* Seek */ long (*doh_tell) (DOH *obj); /* Tell */ - int (*doh_close) (DOH *obj); /* Close */ } DohFileMethods; /* String methods */ diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 5c56771d0..9fb661a36 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -166,27 +166,6 @@ static int File_ungetc(DOH *fo, int ch) { return -1; } -/* ----------------------------------------------------------------------------- - * File_close() - * - * Close the file - * ----------------------------------------------------------------------------- */ - -static int File_close(DOH *fo) { - int ret = 0; - DohFile *f = (DohFile *) ObjData(fo); - if (f->filep) { - ret = fclose(f->filep); - f->filep = 0; - } else if (f->fd) { -#ifdef DOH_INTFILE - ret = close(f->fd); - f->fd = 0; -#endif - } - return ret; -} - static DohFileMethods FileFileMethods = { File_read, File_write, @@ -195,7 +174,6 @@ static DohFileMethods FileFileMethods = { File_ungetc, File_seek, File_tell, - File_close, /* close */ }; static DohObjInfo DohFileType = { diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 94d2737fa..6c6728578 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -987,7 +987,6 @@ static DohFileMethods StringFileMethods = { String_ungetc, String_seek, String_tell, - 0, /* close */ }; static DohStringMethods StringStringMethods = { From f69da524f071a754744636dcadfba275d1b00d02 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Jul 2019 07:12:04 +0100 Subject: [PATCH 1715/2031] Exit code change when using -Werror Exit code is now sum of all errors, not just warnings as errors. I'm can't think why the exit code wasn't like this in the first place. --- Source/Modules/main.cxx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c6bd148e2..294455772 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1376,13 +1376,12 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { while (freeze) { } - if ((werror) && (Swig_warn_count())) { - return Swig_warn_count(); - } - delete lang; - return Swig_error_count(); + int error_count = werror ? Swig_warn_count() : 0; + error_count += Swig_error_count(); + + return error_count; } /* ----------------------------------------------------------------------------- From b36ae64185cc6d293d9350126f51ab23c0c7e36a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Jul 2019 19:03:30 +0100 Subject: [PATCH 1716/2031] Remove all generated files on error. Previously generated files were not removed, potentially breaking Makefiles using file dependencies, especially when -Werror (warnings as errors) was used. --- CHANGES.current | 5 +++ Source/DOH/doh.h | 4 ++- Source/DOH/file.c | 75 +++++++++++++++++++++++++++++++++++++++-- Source/Modules/main.cxx | 21 +++++++++++- 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3b9634726..b7d7fa3df 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-07-29: wsfulton + Remove all generated files on error. Previously generated files were not removed, + potentially breaking Makefiles using file dependencies, especially when -Werror + (warnings as errors) was used. + 2019-07-23: smithx [C#] #1530 #1532 Fix marshalling of std::wstring to C#. diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 7cc279ebc..7fb64c058 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -302,11 +302,12 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch); * Files * ----------------------------------------------------------------------------- */ -extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles); +extern DOHFile *DohNewFile(DOHString *filename, const char *mode, DOHList *outfiles); extern DOHFile *DohNewFileFromFile(FILE *f); extern DOHFile *DohNewFileFromFd(int fd); extern void DohFileErrorDisplay(DOHString * filename); extern int DohCopyto(DOHFile * input, DOHFile * output); +extern void DohCloseAllOpenFiles(void); /* ----------------------------------------------------------------------------- @@ -425,6 +426,7 @@ extern void DohMemoryDebug(void); #define Strstr DohStrstr #define Strchr DohStrchr #define Copyto DohCopyto +#define CloseAllOpenFiles DohCloseAllOpenFiles #define Split DohSplit #define SplitLines DohSplitLines #define Setmark DohSetmark diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 9fb661a36..570f84ed5 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -25,6 +25,73 @@ typedef struct { int closeondel; } DohFile; +/* ----------------------------------------------------------------------------- + * open_files_list_instance + * open_files_list_add + * open_files_list_remove + * + * Singleton list containing all the files that have been opened by DohNewFile. + * Open file pointers are held in the list as strings so as to not affect the + * reference count of the underlying DOH objects. + * ----------------------------------------------------------------------------- */ + +static DOHList *open_files_list_instance() { + static DOHList *all_open_files = 0; + if (!all_open_files) + all_open_files = DohNewList(); + return all_open_files; +} + +static void open_files_list_add(DohFile *f) { + DOHList *all_open_files = open_files_list_instance(); + DOHString *sf = NewStringf("%p", f); + Append(all_open_files, sf); + Delete(sf); +} + +static void open_files_list_remove(DohFile *f) { + int i; + int removed = 0; + DOHList *all_open_files = open_files_list_instance(); + DOHString *sf = NewStringf("%p", f); + for (i = 0; i < DohLen(all_open_files); i++) { + DOHString *sf_i = Getitem(all_open_files, i); + if (Strcmp(sf, sf_i) == 0) { + DohDelitem(all_open_files, i); + removed = 1; + break; + } + } + Delete(sf); + assert(removed); +} + +/* ----------------------------------------------------------------------------- + * DohCloseAllOpenFiles() + * + * Close all opened files, to be called on program termination + * ----------------------------------------------------------------------------- */ + +void DohCloseAllOpenFiles() { + int i; + DOHList *all_open_files = open_files_list_instance(); + for (i = 0; i < DohLen(all_open_files); i++) { + DohFile *f = 0; + DOHString *sf = Getitem(all_open_files, i); + int check = sscanf(Char(sf), "%p", (void **)&f); + assert(check == 1); + if (f->closeondel) { + if (f->filep) { + check = fclose(f->filep); + assert(check == 0); + } + f->closeondel = 0; + f->filep = 0; + } + } + DohClear(all_open_files); +} + /* ----------------------------------------------------------------------------- * DelFile() * ----------------------------------------------------------------------------- */ @@ -40,6 +107,7 @@ static void DelFile(DOH *fo) { close(f->fd); } #endif + open_files_list_remove(f); } DohFree(f); } @@ -209,8 +277,9 @@ static DohObjInfo DohFileType = { * 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(DOHString *filename, const char *mode, DOHList *newfiles) { DohFile *f; + DOH *obj; FILE *file; char *filen; @@ -229,7 +298,9 @@ DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) { f->filep = file; f->fd = 0; f->closeondel = 1; - return DohObjMalloc(&DohFileType, f); + obj = DohObjMalloc(&DohFileType, f); + open_files_list_add(f); + return obj; } /* ----------------------------------------------------------------------------- diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 294455772..72b765b40 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -23,6 +23,7 @@ #include "swigwarn.h" #include "cparse.h" #include +#include #include // for INT_MAX // Global variables @@ -1381,7 +1382,10 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { int error_count = werror ? Swig_warn_count() : 0; error_count += Swig_error_count(); - return error_count; + if (error_count != 0) + SWIG_exit(error_count); + + return 0; } /* ----------------------------------------------------------------------------- @@ -1393,5 +1397,20 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { void SWIG_exit(int exit_code) { while (freeze) { } + + if (exit_code > 0) { + CloseAllOpenFiles(); + + /* Remove all generated files */ + if (all_output_files) { + for (int i = 0; i < Len(all_output_files); i++) { + String *filename = Getitem(all_output_files, i); + int removed = remove(Char(filename)); + if (removed == -1) + fprintf(stderr, "On exit, could not delete file %s: %s\n", Char(filename), strerror(errno)); + } + } + } + exit(exit_code); } From 2cf075558ce27ee0d88b71441c8cd83aabbf8028 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 29 Jul 2019 19:35:54 +0100 Subject: [PATCH 1717/2031] Replace all exit() with SWIG_exit() For consistent cleanup on error --- Source/CParse/parser.y | 8 ++++---- Source/Modules/guile.cxx | 2 +- Source/Modules/php.cxx | 4 ++-- Source/Modules/python.cxx | 1 - Source/Modules/swigmod.h | 1 - Source/Modules/typepass.cxx | 4 ++-- Source/Swig/getopt.c | 7 +++---- Source/Swig/misc.c | 12 +++++++----- Source/Swig/naming.c | 6 +++--- Source/Swig/scanner.c | 2 +- Source/Swig/swig.h | 1 + 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 08c92b9cf..470b7d065 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1779,7 +1779,7 @@ declaration : swig_directive { $$ = $1; } } else { Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n"); } - exit(1); + SWIG_exit(EXIT_FAILURE); } /* Out of class constructor/destructor declarations */ | c_constructor_decl { @@ -3359,7 +3359,7 @@ c_decl_tail : SEMI { } else { Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n"); } - exit(1); + SWIG_exit(EXIT_FAILURE); } ; @@ -3649,7 +3649,7 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { } if (err) { Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } } ; @@ -4632,7 +4632,7 @@ cpp_members : cpp_member cpp_members { int start_line = cparse_line; skip_decl(); Swig_error(cparse_file,start_line,"Syntax error in input(3).\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } cpp_members { $$ = $3; } diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 7b42ff94f..461c69e50 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -255,7 +255,7 @@ public: if (goops) { if (linkage != GUILE_LSTYLE_PASSIVE && linkage != GUILE_LSTYLE_MODULE) { Printf(stderr, "guile: GOOPS support requires passive or module linkage\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index b192d6f6e..1edbd874c 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1223,7 +1223,7 @@ public: /* FIXME: How should this be handled? The rest of SWIG just seems * to not bother checking for malloc failing! */ fprintf(stderr, "Malloc failed!\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } for (i = 0; i < max_num_of_arguments; ++i) { arg_names[i] = NULL; @@ -1235,7 +1235,7 @@ public: /* FIXME: How should this be handled? The rest of SWIG just seems * to not bother checking for malloc failing! */ fprintf(stderr, "Malloc failed!\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } for (i = 0; i < max_num_of_arguments; ++i) { arg_values[i] = NULL; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 39308d4b8..ea31af029 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -16,7 +16,6 @@ #include "cparse.h" #include #include -#include #include "pydoc.h" #include diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 583cb13fe..bfb93d1a7 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -371,7 +371,6 @@ struct TargetLanguageModule { int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm); 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 ); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 57125fcbb..8dbf0865e 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -961,7 +961,7 @@ class TypePass:private Dispatcher { if (Getattr(c, "sym:overloaded") != checkoverloaded) { Printf(stdout, "sym:overloaded error c:%p checkoverloaded:%p\n", c, checkoverloaded); Swig_print_node(c); - exit (1); + SWIG_exit(EXIT_FAILURE); } String *decl = Strcmp(nodeType(c), "using") == 0 ? NewString("------") : Getattr(c, "decl"); @@ -969,7 +969,7 @@ class TypePass:private Dispatcher { if (!Getattr(c, "sym:overloaded")) { Printf(stdout, "sym:overloaded error.....%p\n", c); Swig_print_node(c); - exit (1); + SWIG_exit(EXIT_FAILURE); } c = Getattr(c, "sym:nextSibling"); } diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index 74076a5f0..6970dc177 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -16,7 +16,6 @@ * sure there are no unmarked options. * * TODO: - * - This module needs to be modified so that it doesn't call exit(). * Should have cleaner error handling in general. * ----------------------------------------------------------------------------- */ @@ -88,11 +87,11 @@ void Swig_check_options(int check_input) { } if (error) { Printf(stderr, "Use 'swig -help' for available options.\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } if (check_input && marked[numargs - 1]) { Printf(stderr, "Must specify an input file. Use -help for available options.\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } } @@ -105,5 +104,5 @@ void Swig_check_options(int check_input) { void Swig_arg_error(void) { Printf(stderr, "SWIG : Unable to parse command line options.\n"); Printf(stderr, "Use 'swig -help' for available options.\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 6b071185b..7b818478f 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1177,7 +1177,7 @@ String *Swig_string_command(String *s) { pclose(fp); } else { Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s); - exit(1); + SWIG_exit(EXIT_FAILURE); } } #endif @@ -1327,7 +1327,8 @@ static int split_regex_pattern_subst(String *s, String **pattern, String **subst err_out: Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s); - exit(1); + SWIG_exit(EXIT_FAILURE); + return 0; } /* This function copies len characters from src to dst, possibly applying case conversions to them: if convertCase is 1, to upper case and if it is -1, to lower @@ -1449,7 +1450,7 @@ String *Swig_string_regex(String *s) { if (!compiled_pat) { Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n", pcre_error, Char(pattern), pcre_errorpos); - exit(1); + SWIG_exit(EXIT_FAILURE); } rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30); if (rc >= 0) { @@ -1457,7 +1458,7 @@ String *Swig_string_regex(String *s) { } else if (rc != PCRE_ERROR_NOMATCH) { Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n", rc, Char(pattern), input); - exit(1); + SWIG_exit(EXIT_FAILURE); } } @@ -1475,7 +1476,8 @@ String *Swig_pcre_version(void) { String *Swig_string_regex(String *s) { Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); + return 0; } String *Swig_pcre_version(void) { diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 1b6c963e7..6689ceb7a 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1105,7 +1105,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) { Swig_error("SWIG", Getline(n), "Invalid regex \"%s\": compilation failed at %d: %s\n", Char(pattern), errpos, err); - exit(1); + SWIG_exit(EXIT_FAILURE); } rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0); @@ -1118,7 +1118,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) { Swig_error("SWIG", Getline(n), "Matching \"%s\" against regex \"%s\" failed: %d\n", Char(s), Char(pattern), rc); - exit(1); + SWIG_exit(EXIT_FAILURE); } return 1; @@ -1131,7 +1131,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) { (void)s; Swig_error("SWIG", Getline(n), "PCRE regex matching is not available in this SWIG build.\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } #endif /* HAVE_PCRE/!HAVE_PCRE */ diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 908bc747f..e5a267ae5 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -833,7 +833,7 @@ static int look(Scanner *s) { return SWIG_TOKEN_MODEQUAL; } else if (c == '}') { Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n"); - exit(1); + SWIG_exit(EXIT_FAILURE); } else { retract(s, 1); return SWIG_TOKEN_PERCENT; diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 1acd32d5d..e0783dae1 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -438,6 +438,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Language_replace_special_variables(String *method, String *tm, Parm *parm); extern void Swig_print(DOH *object, int count); extern void Swig_print_with_location(DOH *object, int count); + extern void SWIG_exit(int exit_code); /* -- template init -- */ From 0d76eb3b56b0e13b24e778b6e10b4bef8f36888d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 30 Jul 2019 07:27:32 +0100 Subject: [PATCH 1718/2031] The errors testcases use -module to obtain a unique module name Fixes parallel make where each invocation of swig was writing and deleting the same file resulting in lots of the newly introduced warning messages: On exit, could not delete file xxx.py: No such file or directory --- Examples/test-suite/errors/Makefile.in | 9 +++++++-- Examples/test-suite/errors/cpp_extra_brackets.i | 2 +- Examples/test-suite/errors/cpp_extra_brackets2.i | 2 +- Examples/test-suite/errors/cpp_invalid_qualifiers.i | 2 +- Examples/test-suite/errors/cpp_invalid_template.i | 2 +- Examples/test-suite/errors/cpp_namespace_template_bad.i | 2 +- Examples/test-suite/errors/cpp_nested_namespace_alias.i | 2 +- Examples/test-suite/errors/cpp_recursive_typedef.i | 2 +- Examples/test-suite/errors/cpp_refqualifier.i | 2 +- Examples/test-suite/errors/cpp_shared_ptr.i | 2 +- .../test-suite/errors/cpp_template_duplicate_names.i | 2 +- Examples/test-suite/errors/cpp_template_friend.i | 2 +- Examples/test-suite/errors/pp_missing_file.i | 2 +- 13 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Examples/test-suite/errors/Makefile.in b/Examples/test-suite/errors/Makefile.in index 10e5bdd8f..7137a6862 100644 --- a/Examples/test-suite/errors/Makefile.in +++ b/Examples/test-suite/errors/Makefile.in @@ -45,6 +45,11 @@ include $(srcdir)/../common.mk # whatever we do here. $(DOXYGEN_ERROR_TEST_CASES): SWIGOPT += -doxygen +# Unique module names are obtained from the .i file name (required for parallel make). +# Note: -module overrides %module in the .i file. +MODULE_OPTION=-module $* +nomodule.ctest: MODULE_OPTION = + # Portable dos2unix / todos for stripping CR TODOS = tr -d '\r' #TODOS = sed -e 's/\r$$//' # On Mac OS X behaves as if written 's/r$$//' @@ -55,12 +60,12 @@ STRIP_SRCDIR = sed -e 's|\\|/|g' -e 's|^$(SRCDIR)||' # Rules for the different types of tests %.cpptest: echo "$(ACTION)ing errors testcase $*" - -$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + -$(SWIGINVOKE) -c++ -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.ctest: echo "$(ACTION)ing errors testcase $*" - -$(SWIGINVOKE) -python -Wall -Fstandard $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) + -$(SWIGINVOKE) -python -Wall -Fstandard $(MODULE_OPTION) $(SWIGOPT) $(SRCDIR)$*.i 2>&1 | $(TODOS) | $(STRIP_SRCDIR) > $*.$(ERROR_EXT) $(COMPILETOOL) diff -c $(SRCDIR)$*.stderr $*.$(ERROR_EXT) %.clean: diff --git a/Examples/test-suite/errors/cpp_extra_brackets.i b/Examples/test-suite/errors/cpp_extra_brackets.i index 32cf7f72d..81fdb29c4 100644 --- a/Examples/test-suite/errors/cpp_extra_brackets.i +++ b/Examples/test-suite/errors/cpp_extra_brackets.i @@ -1,4 +1,4 @@ -%module cpp_extra_brackets +%module xxx // Extra brackets was segfaulting in SWIG-3.0.0 struct ABC { diff --git a/Examples/test-suite/errors/cpp_extra_brackets2.i b/Examples/test-suite/errors/cpp_extra_brackets2.i index 17a5d5918..194dea435 100644 --- a/Examples/test-suite/errors/cpp_extra_brackets2.i +++ b/Examples/test-suite/errors/cpp_extra_brackets2.i @@ -1,4 +1,4 @@ -%module cpp_extra_brackets +%module xxx // Extra brackets was segfaulting in SWIG-3.0.0 struct ABC { diff --git a/Examples/test-suite/errors/cpp_invalid_qualifiers.i b/Examples/test-suite/errors/cpp_invalid_qualifiers.i index fd3b36332..d0723dff6 100644 --- a/Examples/test-suite/errors/cpp_invalid_qualifiers.i +++ b/Examples/test-suite/errors/cpp_invalid_qualifiers.i @@ -1,4 +1,4 @@ -%module cpp_invalid_qualifiers +%module xxx // Constructors, destructors and static methods cannot have qualifiers struct A { diff --git a/Examples/test-suite/errors/cpp_invalid_template.i b/Examples/test-suite/errors/cpp_invalid_template.i index ea0d7beac..45ad73908 100644 --- a/Examples/test-suite/errors/cpp_invalid_template.i +++ b/Examples/test-suite/errors/cpp_invalid_template.i @@ -1,4 +1,4 @@ -%module cpp_invalid_scope +%module xxx %template(abc) SSS::AAA; diff --git a/Examples/test-suite/errors/cpp_namespace_template_bad.i b/Examples/test-suite/errors/cpp_namespace_template_bad.i index 5c42d6dcb..f41918f8e 100644 --- a/Examples/test-suite/errors/cpp_namespace_template_bad.i +++ b/Examples/test-suite/errors/cpp_namespace_template_bad.i @@ -1,4 +1,4 @@ -%module namespace_template +%module xxx namespace test { template T max(T a, T b) { return (a > b) ? a : b; } diff --git a/Examples/test-suite/errors/cpp_nested_namespace_alias.i b/Examples/test-suite/errors/cpp_nested_namespace_alias.i index b7cbceb71..058d34441 100644 --- a/Examples/test-suite/errors/cpp_nested_namespace_alias.i +++ b/Examples/test-suite/errors/cpp_nested_namespace_alias.i @@ -1,4 +1,4 @@ -%module cpp_nested_namespace_alias +%module xxx // C++17 nested namespaces diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i index 3d65a8817..82d9f7a4a 100644 --- a/Examples/test-suite/errors/cpp_recursive_typedef.i +++ b/Examples/test-suite/errors/cpp_recursive_typedef.i @@ -1,4 +1,4 @@ -%module cpp_recursive_typedef +%module xxx typedef std::set pds; diff --git a/Examples/test-suite/errors/cpp_refqualifier.i b/Examples/test-suite/errors/cpp_refqualifier.i index afd6632fc..3980a812c 100644 --- a/Examples/test-suite/errors/cpp_refqualifier.i +++ b/Examples/test-suite/errors/cpp_refqualifier.i @@ -1,4 +1,4 @@ -%module cpp_refqualifier +%module xxx %ignore Host::h_ignored; %ignore Host::i_ignored() &&; diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i index edbd0cf87..bdcd30f71 100644 --- a/Examples/test-suite/errors/cpp_shared_ptr.i +++ b/Examples/test-suite/errors/cpp_shared_ptr.i @@ -1,4 +1,4 @@ -%module cpp_shared_ptr +%module xxx %include diff --git a/Examples/test-suite/errors/cpp_template_duplicate_names.i b/Examples/test-suite/errors/cpp_template_duplicate_names.i index 67f21d7bb..96076967b 100644 --- a/Examples/test-suite/errors/cpp_template_duplicate_names.i +++ b/Examples/test-suite/errors/cpp_template_duplicate_names.i @@ -1,4 +1,4 @@ -%module cpp_template_duplicate_names +%module xxx // From test-suite/template_class_reuse.i test diff --git a/Examples/test-suite/errors/cpp_template_friend.i b/Examples/test-suite/errors/cpp_template_friend.i index c9d1c9d5d..3b8d85eff 100644 --- a/Examples/test-suite/errors/cpp_template_friend.i +++ b/Examples/test-suite/errors/cpp_template_friend.i @@ -1,4 +1,4 @@ -%module cpp_template_friend +%module xxx template T template_friend1(T); template T template_friend1(T); diff --git a/Examples/test-suite/errors/pp_missing_file.i b/Examples/test-suite/errors/pp_missing_file.i index 5e3f0ea27..366f159cc 100644 --- a/Examples/test-suite/errors/pp_missing_file.i +++ b/Examples/test-suite/errors/pp_missing_file.i @@ -1,3 +1,3 @@ -%module test +%module xxx %include "missing_filename.i" From 06345e2aa5724879df00edf9fa87fdd034a7c641 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Sun, 28 Jul 2019 15:58:03 +0300 Subject: [PATCH 1719/2031] Fix invalid code generated for "%constant enum EnumType ..." and add a test. --- Examples/test-suite/constant_directive.i | 6 ++++++ Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i index b102ffea2..3e4775df1 100644 --- a/Examples/test-suite/constant_directive.i +++ b/Examples/test-suite/constant_directive.i @@ -14,6 +14,11 @@ struct Type1 { Type1(int val = 0) : val(val) {} int val; }; +enum EnumType +{ + EnumValue +}; +EnumType enumValue = EnumValue; /* Typedefs for const Type and its pointer */ typedef const Type1 Type1Const; typedef const Type1* Type1Cptr; @@ -46,3 +51,4 @@ Type1 getType1Instance() { return Type1(111); } %constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance; /* Regular constant */ %constant int TYPE_INT = 0; +%constant enum EnumType newValue = enumValue; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 76ec6a4fb..17100b330 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1533,7 +1533,7 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 259f23f8e..fcc83819d 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1633,7 +1633,7 @@ public: if (classname_substituted_flag) { if (SwigType_isenum(t)) { // This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on) - Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname)); + Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); } else { // This handles function pointers using the %constant directive Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname)); From 3cc4b211630c271f2e127f5283c9a3340485b347 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Aug 2019 19:46:16 +0100 Subject: [PATCH 1720/2031] Parameter name expansion fix for template functions. Fix regression in 4.0.0 where a template function containing a parameter with the same name as the function name led to the parameter name used in the target language being incorrectly modified. Closes #1602 --- CHANGES.current | 5 ++++ Examples/test-suite/typemap_template_parms.i | 13 ++++++++++ Source/CParse/templ.c | 27 ++++++++++++-------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b7d7fa3df..6b38059b8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-01: wsfulton + #1602 Fix regression in 4.0.0 where a template function containing a parameter + with the same name as the function name led to the parameter name used in the + target language being incorrectly modified. + 2019-07-29: wsfulton Remove all generated files on error. Previously generated files were not removed, potentially breaking Makefiles using file dependencies, especially when -Werror diff --git a/Examples/test-suite/typemap_template_parms.i b/Examples/test-suite/typemap_template_parms.i index fd0f7f51a..90231e827 100644 --- a/Examples/test-suite/typemap_template_parms.i +++ b/Examples/test-suite/typemap_template_parms.i @@ -26,3 +26,16 @@ template struct X { %} %template(Xint) X; + + +// The function name and parameter name are both 'labels' +%inline %{ +template +void labels(T labels) {} +void voido(int vooo) {} +%} + +// TODO: R has a problem with parameter names clashing with the function name +#if !defined(SWIGR) +%template(ShortLabels) labels; +#endif diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 6b1a27014..22d49fac5 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -26,14 +26,19 @@ void SwigType_template_init() { } -static void add_parms(ParmList *p, List *patchlist, List *typelist) { +static void add_parms(ParmList *p, List *patchlist, List *typelist, int is_pattern) { while (p) { SwigType *ty = Getattr(p, "type"); SwigType *val = Getattr(p, "value"); - SwigType *name = Getattr(p, "name"); Append(typelist, ty); Append(typelist, val); - Append(typelist, name); + if (is_pattern) { + /* Typemap patterns are not simple parameter lists. + * Output style ("out", "ret" etc) typemap names can be + * qualified names and so may need template expansion */ + SwigType *name = Getattr(p, "name"); + Append(typelist, name); + } Append(patchlist, val); p = nextSibling(p); } @@ -108,8 +113,8 @@ static void cparse_template_expand(Node *templnode, Node *n, String *tname, Stri Append(typelist, Getattr(n, "name")); } - add_parms(Getattr(n, "parms"), cpatchlist, typelist); - add_parms(Getattr(n, "throws"), cpatchlist, typelist); + add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0); + add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0); } else if (Equal(nodeType, "class")) { /* Patch base classes */ @@ -175,8 +180,8 @@ static void cparse_template_expand(Node *templnode, Node *n, String *tname, Stri } Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "decl")); - add_parms(Getattr(n, "parms"), cpatchlist, typelist); - add_parms(Getattr(n, "throws"), cpatchlist, typelist); + add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0); + add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0); } else if (Equal(nodeType, "destructor")) { /* We only need to patch the dtor of the template itself, not the destructors of any nested classes, so check that the parent of this node is the root * template node, with the special exception for %extend which adds its methods under an intermediate node. */ @@ -217,10 +222,10 @@ static void cparse_template_expand(Node *templnode, Node *n, String *tname, Stri Append(cpatchlist, Getattr(n, "code")); Append(typelist, Getattr(n, "type")); Append(typelist, Getattr(n, "decl")); - add_parms(Getattr(n, "parms"), cpatchlist, typelist); - add_parms(Getattr(n, "kwargs"), cpatchlist, typelist); - add_parms(Getattr(n, "pattern"), cpatchlist, typelist); - add_parms(Getattr(n, "throws"), cpatchlist, typelist); + add_parms(Getattr(n, "parms"), cpatchlist, typelist, 0); + add_parms(Getattr(n, "kwargs"), cpatchlist, typelist, 0); + add_parms(Getattr(n, "pattern"), cpatchlist, typelist, 1); + add_parms(Getattr(n, "throws"), cpatchlist, typelist, 0); cn = firstChild(n); while (cn) { cparse_template_expand(templnode, cn, tname, rname, templateargs, patchlist, typelist, cpatchlist); From fe758f3e0577cedb12e5edd0f6219cb5f30134c2 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Fri, 2 Aug 2019 23:05:53 +0200 Subject: [PATCH 1721/2031] closer match to Python's output --- Lib/lua/luarun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 5176f74cf..9ce99f01e 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1049,7 +1049,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); - lua_pushfstring(L, "<%s userdata: %p::%p>", className, userData, userData->ptr); + lua_pushfstring(L, "", userData->type->str, userData->ptr); return 1; } From 49a8e28eb909c21a8b17cdfe2d9a19e7e0f8a82f Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Fri, 2 Aug 2019 23:10:19 +0200 Subject: [PATCH 1722/2031] removing unnecessary bits --- Lib/lua/luarun.swg | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 9ce99f01e..bd764d668 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1039,15 +1039,9 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) { /* there should be 1 param passed in (1) userdata (not the metatable) */ - const char *className; swig_lua_userdata* userData; assert(lua_isuserdata(L,1)); /* just in case */ - userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address for later */ - lua_getmetatable(L,1); /* get the meta table */ - assert(lua_istable(L,-1)); /* just in case */ - - lua_getfield(L, -1, ".type"); - className = lua_tostring(L, -1); + userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address */ lua_pushfstring(L, "", userData->type->str, userData->ptr); return 1; From 86cb3a953230c6c63bf38579a44955b2b5084eaf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 6 Aug 2019 19:36:14 +0100 Subject: [PATCH 1723/2031] Python STL container method overloading fix Fix method overloading of methods that take STL containers of different types. Due to some error handling that was not cleared during typehecking. --- CHANGES.current | 50 +++++++++++++++++++ Examples/test-suite/common.mk | 1 + .../test-suite/li_std_containers_overload.i | 33 ++++++++++++ .../octave/li_std_containers_overload_runme.m | 37 ++++++++++++++ .../li_std_containers_overload_runme.py | 29 +++++++++++ .../ruby/li_std_containers_overload_runme.rb | 44 ++++++++++++++++ Lib/octave/octcontainer.swg | 10 +--- Lib/python/pycontainer.swg | 10 +--- Lib/ruby/rubycontainer.swg | 10 +--- 9 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 Examples/test-suite/li_std_containers_overload.i create mode 100644 Examples/test-suite/octave/li_std_containers_overload_runme.m create mode 100644 Examples/test-suite/python/li_std_containers_overload_runme.py create mode 100644 Examples/test-suite/ruby/li_std_containers_overload_runme.rb diff --git a/CHANGES.current b/CHANGES.current index 6b38059b8..aeef3f57e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,56 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-07: wsfulton + [Python] Fix method overloading of methods that take STL containers of different + types. The following usage (using std::vector) would fail when using -builtin: + + %include + %include + + %inline %{ + struct X {}; + %} + + %template(VectorX) std::vector; + %template(VectorInt) std::vector; + + %inline %{ + using namespace std; + string VectorOverload(vector v); + string VectorOverload(vector v); + %} + + The following would incorrectly fail: + + s = VectorOverload([1, 2, 3]) + + With: + + Traceback (most recent call last): + File "runme3.py", line 20, in + ret = VectorOverload([1, 2, 3]) + TypeError: Wrong number or type of arguments for overloaded function 'VectorOverload'. + Possible C/C++ prototypes are: + VectorOverload(std::vector< Number,std::allocator< Number > >) + VectorOverload(std::vector< int,std::allocator< int > >) + + The problem was due to some error handling that was not cleared during typehecking. + In this case an error was not cleared when the elements in the list failed the + typecheck for converting to X. Only occurs in Python 3+. + + In some combinations of overloaded methods, the following type of error message would + occur: + + RuntimeError: in sequence element 0 + + The above exception was the direct cause of the following exception: + + Traceback (most recent call last): + File "runme3.py", line 23, in + check(VectorOverload(v), "vector") + SystemError: returned a result with an error set + 2019-08-01: wsfulton #1602 Fix regression in 4.0.0 where a template function containing a parameter with the same name as the function name led to the parameter name used in the diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7aa0e91d1..5f7792810 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -643,6 +643,7 @@ CPP_STD_TEST_CASES += \ director_string \ ignore_template_constructor \ li_std_combinations \ + li_std_containers_overload \ li_std_deque \ li_std_except \ li_std_except_as_class \ diff --git a/Examples/test-suite/li_std_containers_overload.i b/Examples/test-suite/li_std_containers_overload.i new file mode 100644 index 000000000..5e7c28e37 --- /dev/null +++ b/Examples/test-suite/li_std_containers_overload.i @@ -0,0 +1,33 @@ +%module li_std_containers_overload + +// Suppress warning that ought not to appear, but there is no easy fix +%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) VectorOverload; + +%include +%include + +%inline %{ +struct X {}; +struct Y {}; +%} + +%template(VectorX) std::vector; +%template(VectorY) std::vector; +%template(VectorString) std::vector; +%template(VectorInt) std::vector; + +%inline %{ +using namespace std; +string VectorOverload(vector v) { + return "vector"; +} +string VectorOverload(vector v) { + return "vector"; +} +string VectorOverload(vector v) { + return "vector"; +} +string VectorOverload(vector v) { + return "vector"; +} +%} diff --git a/Examples/test-suite/octave/li_std_containers_overload_runme.m b/Examples/test-suite/octave/li_std_containers_overload_runme.m new file mode 100644 index 000000000..786d63466 --- /dev/null +++ b/Examples/test-suite/octave/li_std_containers_overload_runme.m @@ -0,0 +1,37 @@ +# do not dump Octave core +if exist("crash_dumps_octave_core", "builtin") + crash_dumps_octave_core(0); +endif + +li_std_containers_overload + +function check(got, expected) + if (!strcmp(got, expected)) + error("Failed check. '%s' != '%s'", got, expected) + endif +end + +v = VectorX(); +check(VectorOverload(v), "vector"); + +v = VectorY(); +check(VectorOverload(v), "vector"); + +v = VectorInt(); +check(VectorOverload(v), "vector"); + +v = VectorString(); +check(VectorOverload(v), "vector"); + +# TODO: Conversion from an Octave sequence not implemented yet +# v = {X()}; +# check(VectorOverload(v), "vector"); + +# v = {Y()}; +# check(VectorOverload(v), "vector"); + +# v = {1, 2, 3}; +# check(VectorOverload(v), "vector"); + +# v = {"aaa", "bbb", "ccc"}; +# check(VectorOverload(v), "vector"); diff --git a/Examples/test-suite/python/li_std_containers_overload_runme.py b/Examples/test-suite/python/li_std_containers_overload_runme.py new file mode 100644 index 000000000..dcb383511 --- /dev/null +++ b/Examples/test-suite/python/li_std_containers_overload_runme.py @@ -0,0 +1,29 @@ +from li_std_containers_overload import * + +def check(got, expected): + if got != expected: + raise RuntimeError("Failed check. '{}' != '{}'".format(got, expected)) + +v = VectorX() +check(VectorOverload(v), "vector") + +v = VectorY() +check(VectorOverload(v), "vector") + +v = VectorInt() +check(VectorOverload(v), "vector") + +v = VectorString() +check(VectorOverload(v), "vector") + +v = [X()] +check(VectorOverload(v), "vector") + +v = [Y()] +check(VectorOverload(v), "vector") + +v = [1, 2, 3] +check(VectorOverload(v), "vector") + +v = ["aaa", "bbb", "ccc"] +check(VectorOverload(v), "vector") diff --git a/Examples/test-suite/ruby/li_std_containers_overload_runme.rb b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb new file mode 100644 index 000000000..913b6113a --- /dev/null +++ b/Examples/test-suite/ruby/li_std_containers_overload_runme.rb @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# +# Put description here +# +# +# +# +# + +require 'swig_assert' + +require 'li_std_containers_overload' + +include Li_std_containers_overload + +def check(got, expected) + if (got != expected) + raise RuntimeError, "Failed check. '#{got}' != '#{expected}'" + end +end + +v = VectorX.new() +check(VectorOverload(v), "vector") + +v = VectorY.new() +check(VectorOverload(v), "vector") + +v = VectorInt.new() +check(VectorOverload(v), "vector") + +v = VectorString.new() +check(VectorOverload(v), "vector") + +v = [X.new()] +check(VectorOverload(v), "vector") + +v = [Y.new()] +check(VectorOverload(v), "vector") + +v = [1, 2, 3] +check(VectorOverload(v), "vector") + +v = ["aaa", "bbb", "ccc"] +check(VectorOverload(v), "vector") diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 269ff7544..310a849d9 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -401,20 +401,14 @@ namespace swig return const_reference(_seq, n); } - bool check(bool set_err = true) const + bool check() const { int s = size(); for (int i = 0; i < s; ++i) { // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i); octave_value item; // * todo - if (!swig::check(item)) { - if (set_err) { - char msg[1024]; - sprintf(msg, "in sequence element %d", i); - SWIG_Error(SWIG_RuntimeError, msg); - } + if (!swig::check(item)) return false; - } } return true; } diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index ef2f725af..fef4e9b3b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -672,19 +672,13 @@ namespace swig return const_reference(_seq, n); } - bool check(bool set_err = true) const + bool check() const { Py_ssize_t s = size(); for (Py_ssize_t i = 0; i < s; ++i) { swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); - if (!swig::check(item)) { - if (set_err) { - char msg[1024]; - sprintf(msg, "in sequence element %d", (int)i); - SWIG_Error(SWIG_RuntimeError, msg); - } + if (!swig::check(item)) return false; - } } return true; } diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index e8830a715..9fa205bf5 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -395,19 +395,13 @@ namespace swig return const_reference(_seq, n); } - bool check(bool set_err = false) const + bool check() const { int s = (int) size(); for (int i = 0; i < s; ++i) { VALUE item = rb_ary_entry(_seq, i ); - if (!swig::check(item)) { - if (set_err) { - char msg[1024]; - sprintf(msg, "in sequence element %d", i); - SWIG_Error(SWIG_RuntimeError, msg); - } + if (!swig::check(item)) return false; - } } return true; } From eb11c025c7561f4879308bbae875509e0ee64d05 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 3 Aug 2019 10:22:30 -0500 Subject: [PATCH 1724/2031] Support doxygen \param[] commands Recognize \param[in], \param[out], and \param[in,out]. Currently they are all treated the same as \param, but the information is now available for inclusion in the translated comments. This is done using new utility functions getBaseCommand and getEndOfWordCommand, which will also generalize to treatment of code command options, e.g. \code{.py}. Preliminary treatment of the extended version of \code is already in place in these functions. Added examples of all three new \param commands to the doxygen_translate_all_tags test and updated the python and java expected output. --- .../test-suite/doxygen_translate_all_tags.i | 5 +++- .../doxygen_translate_all_tags_runme.java | 7 +++-- .../doxygen_translate_all_tags_runme.py | 8 ++++- Source/Doxygen/doxyparser.cxx | 30 +++++++++++++++++-- Source/Doxygen/doxyparser.h | 5 ++++ Source/Doxygen/javadoc.cxx | 2 +- Source/Doxygen/pydoc.cxx | 2 +- 7 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i index 8da683d52..6cefd8d4e 100644 --- a/Examples/test-suite/doxygen_translate_all_tags.i +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -262,6 +262,9 @@ void func06(int a) * \paragraph someParagraph Paragraph title * * \param a the first param + * \param[in] b parameter with intent(in) + * \param[out] c parameter with intent(out) + * \param[in,out] d parameter with intent(in,out) * * \post Some description * @@ -273,7 +276,7 @@ void func06(int a) * * \property someVar */ -void func07(int a) +void func07(int a, int b, int c, int d) { } diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index d5c533f4e..1d61608b7 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -104,7 +104,7 @@ public class doxygen_translate_all_tags_runme { " {@link someMember Some description follows }\n" + " This will only appear in man\n"); - wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func07(int)", + wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func07(int, int, int, int)", " Comment for func07().\n" + " Note: Here \n" + " is the note! \n" + @@ -115,7 +115,10 @@ public class doxygen_translate_all_tags_runme { " The paragraph text. \n" + " Maybe even multiline \n" + "

    \n" + - " @param a the first param\n"); + " @param a the first param\n" + + " @param b parameter with intent(in)\n" + + " @param c parameter with intent(out)\n" + + " @param d parameter with intent(in,out)\n"); wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func08(int)", "\n" + diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index df1c0eba5..0545661ce 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -209,7 +209,13 @@ Maybe even multiline :type a: int -:param a: the first param""") +:param a: the first param +:type b: int +:param b: parameter with intent(in) +:type c: int +:param c: parameter with intent(out) +:type d: int +:param d: parameter with intent(in,out)""") comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func08), r"""Text after anchor. diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 2e826b265..6d8c322d5 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -34,6 +34,30 @@ std::set DoxygenParser::doxygenSectionIndicators; const int TOKENSPERLINE = 8; //change this to change the printing behaviour of the token list const std::string END_HTML_TAG_MARK("/"); +std::string getBaseCommand(const std::string &cmd) { + if (cmd.substr(0,5) == "param") + return "param"; + else if (cmd.substr(0,4) == "code") + return "code"; + else + return cmd; +} + +// Find the first position beyond the word command. Extra logic is +// used to avoid putting the characters "," and "." in +// DOXYGEN_WORD_CHARS. +static size_t getEndOfWordCommand(const std::string &line, size_t pos) { + size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos); + if (line.substr(pos, 6) == "param[") + // include ",", which can appear in param[in,out] + endOfWordPos = line.find_first_not_of(string(DOXYGEN_WORD_CHARS)+ ",", pos); + else if (line.substr(pos, 5) == "code{") + // include ".", which can appear in e.g. code{.py} + endOfWordPos = line.find_first_not_of(string(DOXYGEN_WORD_CHARS)+ ".", pos); + return endOfWordPos; +} + + DoxygenParser::DoxygenParser(bool noisy) : noisy(noisy) { fillTables(); } @@ -118,7 +142,7 @@ void DoxygenParser::printTree(const DoxygenEntityList &rootList) { } DoxygenParser::DoxyCommandEnum DoxygenParser::commandBelongs(const std::string &theCommand) { - DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(theCommand)); + DoxyCommandsMapIt it = doxygenCommands.find(stringToLower(getBaseCommand(theCommand))); if (it != doxygenCommands.end()) { return it->second; @@ -312,7 +336,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndOfParagraph(const TokenList &to } else if (endOfParagraph->m_tokenType == COMMAND) { - if (isSectionIndicator(endOfParagraph->m_tokenString)) { + if (isSectionIndicator(getBaseCommand(endOfParagraph->m_tokenString))) { return endOfParagraph; } else { endOfParagraph++; @@ -1154,7 +1178,7 @@ bool DoxygenParser::processEscapedChars(size_t &pos, const std::string &line) { */ void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) { pos++; - size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos); + size_t endOfWordPos = getEndOfWordCommand(line, pos); string cmd = line.substr(pos, endOfWordPos - pos); addDoxyCommand(m_tokenList, cmd); diff --git a/Source/Doxygen/doxyparser.h b/Source/Doxygen/doxyparser.h index 96c71d22f..e692729ce 100644 --- a/Source/Doxygen/doxyparser.h +++ b/Source/Doxygen/doxyparser.h @@ -21,6 +21,11 @@ #include "doxyentity.h" +// Utility function to return the base part of a command that may +// include options, e.g. param[in] -> param +std::string getBaseCommand(const std::string &cmd); + + class DoxygenParser { private: diff --git a/Source/Doxygen/javadoc.cxx b/Source/Doxygen/javadoc.cxx index 72f84ab6c..d9313f981 100644 --- a/Source/Doxygen/javadoc.cxx +++ b/Source/Doxygen/javadoc.cxx @@ -334,7 +334,7 @@ std::string JavaDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) { void JavaDocConverter::translateEntity(DoxygenEntity &tag, std::string &translatedComment) { std::map >::iterator it; - it = tagHandlers.find(tag.typeOfEntity); + it = tagHandlers.find(getBaseCommand(tag.typeOfEntity)); if (it != tagHandlers.end()) { (this->*(it->second.first))(tag, translatedComment, it->second.second); diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index eb489932a..82f0d13fa 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -456,7 +456,7 @@ std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) { void PyDocConverter::translateEntity(DoxygenEntity &doxyEntity, std::string &translatedComment) { // check if we have needed handler and call it std::map >::iterator it; - it = tagHandlers.find(doxyEntity.typeOfEntity); + it = tagHandlers.find(getBaseCommand(doxyEntity.typeOfEntity)); if (it != tagHandlers.end()) (this->*(it->second.first)) (doxyEntity, translatedComment, it->second.second); } From 36f0e9919f0ba882ddd0208694b3b144b0beac26 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 3 Aug 2019 10:28:28 -0500 Subject: [PATCH 1725/2031] Add parameter direction to doxygen pydoc output For doxygen comments that specify parameter direction (i.e., \param[in], \param[out], and \param[in,out]), the direction is appended to the type definition in the generated Python documentation. Updated expected python output for doxygen test case. --- .../doxygen_translate_all_tags_runme.py | 6 ++-- Source/Doxygen/pydoc.cxx | 29 ++++++++++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 0545661ce..82ea375fd 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -210,11 +210,11 @@ Maybe even multiline :type a: int :param a: the first param -:type b: int +:type b: int, in :param b: parameter with intent(in) -:type c: int +:type c: int, out :param c: parameter with intent(out) -:type d: int +:type d: int, in/out :param d: parameter with intent(in,out)""") comment_verifier.check(inspect.getdoc(doxygen_translate_all_tags.func08), diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 82f0d13fa..0238cbfa4 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -184,6 +184,21 @@ static string padCodeAndVerbatimBlocks(const string &docString) { return result; } +// Helper function to extract the option value from a command, +// e.g. param[in] -> in +static std::string getCommandOption(const std::string &command) { + string option; + + size_t opt_begin, opt_end; + opt_begin = command.find('['); + opt_end = command.find(']'); + if (opt_begin != string::npos && opt_end != string::npos) + option = command.substr(opt_begin+1, opt_end-opt_begin-1); + + return option; +} + + /* static */ PyDocConverter::TagHandlersMap::mapped_type PyDocConverter::make_handler(tagHandler handler) { return make_pair(handler, std::string()); @@ -636,8 +651,19 @@ void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedC const std::string ¶mName = paramNameEntity.data; const std::string paramType = getParamType(paramName); + + // Get command option, e.g. "in", "out", or "in,out" + string commandOpt = getCommandOption(tag.typeOfEntity); + if (commandOpt == "in,out") commandOpt = "in/out"; + + // If provided, append the parameter direction to the type + // information via a suffix: + std::string suffix; + if (commandOpt.size() > 0) + suffix = ", " + commandOpt; + if (!paramType.empty()) { - translatedComment += ":type " + paramName + ": " + paramType + "\n"; + translatedComment += ":type " + paramName + ": " + paramType + suffix + "\n"; translatedComment += indent.getFirstLineIndent(); } @@ -909,3 +935,4 @@ String *PyDocConverter::makeDocumentation(Node *n) { return NewString(pyDocString.c_str()); } + From fd33bdf8a5cd8986297febb2676adb35d8acff90 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 3 Aug 2019 10:31:57 -0500 Subject: [PATCH 1726/2031] Flag optional arguments in doxygen pydoc output If the parameter has a default value, add the string ", optional" to the parameter type description in the translated python comments. Three examples with default values were already present in the test cases, so their expected python output has been updated accordingly. --- .../python/doxygen_basic_translate_runme.py | 2 +- .../doxygen_basic_translate_style2_runme.py | 2 +- .../python/doxygen_misc_constructs_runme.py | 2 +- Source/Doxygen/pydoc.cxx | 24 +++++++++++++++++++ Source/Doxygen/pydoc.h | 5 ++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 9ef8dbd52..90edda132 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -60,7 +60,7 @@ comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function5), comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function6), """\ Test for default args -:type a: int +:type a: int, optional :param a: Some parameter, default is 42""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function7), diff --git a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py index b75045d59..a24f5defc 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style2_runme.py @@ -58,7 +58,7 @@ comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function5), comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function6), """\ Test for default args -:type a: int +:type a: int, optional :param a: Some parameter, default is 42""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style2.function7), diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py index 11aa53ba3..c0b5c1620 100644 --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py @@ -12,7 +12,7 @@ comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.getAddress), :param fileName: name of the file, where the source line is located :type line: int :param line: line number -:type isGetSize: boolean +:type isGetSize: boolean, optional :param isGetSize: if set, for every object location both address and size are returned Connection::getId() """) diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 0238cbfa4..579b144ca 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -443,6 +443,23 @@ std::string PyDocConverter::getParamType(std::string param) { return type; } +std::string PyDocConverter::getParamValue(std::string param) { + std::string value; + + ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); + for (Parm *p = plist; p; p = nextSibling(p)) { + String *pname = Getattr(p, "name"); + if (Char(pname) != param) + continue; + + String *pval = Getattr(p, "value"); + if (pval) value = Char(pval); + break; + } + Delete(plist); + return value; +} + std::string PyDocConverter::translateSubtree(DoxygenEntity &doxygenEntity) { std::string translatedComment; @@ -651,6 +668,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedC const std::string ¶mName = paramNameEntity.data; const std::string paramType = getParamType(paramName); + const std::string paramValue = getParamValue(paramName); // Get command option, e.g. "in", "out", or "in,out" string commandOpt = getCommandOption(tag.typeOfEntity); @@ -661,6 +679,12 @@ void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedC std::string suffix; if (commandOpt.size() > 0) suffix = ", " + commandOpt; + + // If the parameter has a default value, flag it as optional in the + // generated type definition. Particularly helpful when the python + // call is generated with *args, **kwargs. + if (paramValue.size() > 0) + suffix += ", optional"; if (!paramType.empty()) { translatedComment += ":type " + paramName + ": " + paramType + suffix + "\n"; diff --git a/Source/Doxygen/pydoc.h b/Source/Doxygen/pydoc.h index df8997d76..07c5ce51e 100644 --- a/Source/Doxygen/pydoc.h +++ b/Source/Doxygen/pydoc.h @@ -178,6 +178,11 @@ protected: */ std::string getParamType(std::string name); + /* + * Simple helper function to retrieve the parameter value + */ + std::string getParamValue(std::string name); + private: // temporary thing, should be refactored somehow Node *currentNode; From fcf30940cd66cb6b54942d69b1b25b41fb61eacb Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 4 Aug 2019 16:59:25 -0500 Subject: [PATCH 1727/2031] Improve doxygen parser handling of \code content Set the m_isVerbatimText flag in the parser for code commands. This allows some additional special characters to appear within the code block (in particular, the ">" character). --- Source/Doxygen/doxycommands.h | 2 ++ Source/Doxygen/doxyparser.cxx | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/Doxygen/doxycommands.h b/Source/Doxygen/doxycommands.h index 1f7b5fa5b..b5d65af65 100644 --- a/Source/Doxygen/doxycommands.h +++ b/Source/Doxygen/doxycommands.h @@ -18,11 +18,13 @@ const char *CMD_HTML_ONLY = "htmlonly"; // doxy commands are not processed inside this block const char *CMD_VERBATIM = "verbatim"; +const char *CMD_CODE = "code"; const char *CMD_LATEX_1 = "f$"; const char *CMD_LATEX_2 = "f{"; const char *CMD_LATEX_3 = "f["; const char *CMD_END_HTML_ONLY = "endhtmlonly"; const char *CMD_END_VERBATIM = "endverbatim"; +const char *CMD_END_CODE = "endcode"; const char *CMD_END_LATEX_1 = "f$"; const char *CMD_END_LATEX_2 = "f}"; const char *CMD_END_LATEX_3 = "f]"; diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 6d8c322d5..577a4e013 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -1114,7 +1114,7 @@ size_t DoxygenParser::processVerbatimText(size_t pos, const std::string &line) { size_t endOfWordPos = line.find_first_not_of(DOXYGEN_WORD_CHARS, pos); string cmd = line.substr(pos, endOfWordPos - pos); - if (cmd == CMD_END_HTML_ONLY || cmd == CMD_END_VERBATIM || cmd == CMD_END_LATEX_1 || cmd == CMD_END_LATEX_2 || cmd == CMD_END_LATEX_3) { + if (cmd == CMD_END_HTML_ONLY || cmd == CMD_END_VERBATIM || cmd == CMD_END_LATEX_1 || cmd == CMD_END_LATEX_2 || cmd == CMD_END_LATEX_3 || cmd == CMD_END_CODE) { m_isVerbatimText = false; addDoxyCommand(m_tokenList, cmd); @@ -1183,17 +1183,29 @@ void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) { string cmd = line.substr(pos, endOfWordPos - pos); addDoxyCommand(m_tokenList, cmd); - if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM || cmd == CMD_LATEX_1 || cmd == CMD_LATEX_2 || cmd == CMD_LATEX_3) { + // A flag for whether we want to skip leading spaces after the command + bool skipLeadingSpace = true; + + if (cmd == CMD_HTML_ONLY || cmd == CMD_VERBATIM || cmd == CMD_LATEX_1 || cmd == CMD_LATEX_2 || cmd == CMD_LATEX_3 || getBaseCommand(cmd) == CMD_CODE) { m_isVerbatimText = true; - } else { + // Skipping leading space is necessary with inline \code command, + // and it won't hurt anything for block \code (TODO: are the other + // commands also compatible with skip leading space? If so, just + // do it every time.) + if (getBaseCommand(cmd) == CMD_CODE) skipLeadingSpace = true; + else skipLeadingSpace = false; + } + + if (skipLeadingSpace) { // skip any possible spaces after command, because some commands have parameters, // and spaces between command and parameter must be ignored. if (endOfWordPos != string::npos) { endOfWordPos = line.find_first_not_of(" \t", endOfWordPos); } } + pos = endOfWordPos; } From 569ac5ec4f8a099f5ffed866c5fa488da3c335dd Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 4 Aug 2019 17:03:15 -0500 Subject: [PATCH 1728/2031] Handle doxygen code command with language option Previously, code blocks were always written to the pydoc output with "code-block:: c++", and use of language options (e.g., \code{.py}) was not supported. Now the option provided to the doxygen code command is checked, and several basic cases are handled (python, java, and c), defaulting otherwise to C++ as before (handling for additional cases can easily be added). --- Source/Doxygen/doxyparser.cxx | 4 ++-- Source/Doxygen/pydoc.cxx | 37 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 577a4e013..6bda9d27c 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -690,7 +690,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL // \f{ ... \f} // \f{env}{ ... \f} // \f$ ... \f$ - else if (theCommand == "code" || theCommand == "verbatim" + else if (getBaseCommand(theCommand) == "code" || theCommand == "verbatim" || theCommand == "dot" || theCommand == "msc" || theCommand == "f[" || theCommand == "f{" || theCommand == "f$") { if (!endCommands.size()) { // fill in static table of end commands @@ -707,7 +707,7 @@ void DoxygenParser::addCommandUnique(const std::string &theCommand, const TokenL if (it != endCommands.end()) endCommand = it->second; else - endCommand = "end" + theCommand; + endCommand = "end" + getBaseCommand(theCommand); std::string content = getStringTilEndCommand(endCommand, tokList); aNewList.push_back(DoxygenEntity("plainstd::string", content)); diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 579b144ca..649d3a03d 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -186,12 +186,12 @@ static string padCodeAndVerbatimBlocks(const string &docString) { // Helper function to extract the option value from a command, // e.g. param[in] -> in -static std::string getCommandOption(const std::string &command) { +static std::string getCommandOption(const std::string &command, char openChar, char closeChar) { string option; size_t opt_begin, opt_end; - opt_begin = command.find('['); - opt_end = command.find(']'); + opt_begin = command.find(openChar); + opt_end = command.find(closeChar); if (opt_begin != string::npos && opt_end != string::npos) option = command.substr(opt_begin+1, opt_end-opt_begin-1); @@ -566,10 +566,31 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // Use the current indent for the code-block line itself. translatedComment += indent.getFirstLineIndent(); - // Go out on a limb and assume that examples in the C or C++ sources use C++. - // In the worst case, we'll highlight C code using C++ syntax which is not a - // big deal (TODO: handle Doxygen code command language argument). - translatedComment += ".. code-block:: c++\n\n"; + // Check for an option given to the code command (e.g. code{.py}), + // and try to set the code-block language accordingly. + string option = getCommandOption(tag.typeOfEntity, '{', '}'); + // Set up the language option to the code-block command, which can + // be any language supported by pygments: + string codeLanguage; + if (option == ".py") + // Other possibilities here are "default" or "python3". In Sphinx + // 2.1.2, basic syntax doesn't render quite the same in these as + // with "python", which for basic keywords seems to provide + // slightly richer formatting. Another option would be to leave + // the language empty, but testing with Sphinx 1.8.5 has produced + // an error "1 argument required". + codeLanguage = "python"; + else if (option == ".java") + codeLanguage = "java"; + else if (option == ".c") + codeLanguage = "c"; + else + // If there is not a match, or if no option was given, go out on a + // limb and assume that the examples in the C or C++ sources use + // C++. + codeLanguage = "c++"; + + translatedComment += ".. code-block:: " + codeLanguage + "\n\n"; // Specify the level of extra indentation that will be used for // subsequent lines within the code block. Note that the correct @@ -671,7 +692,7 @@ void PyDocConverter::handleTagParam(DoxygenEntity &tag, std::string &translatedC const std::string paramValue = getParamValue(paramName); // Get command option, e.g. "in", "out", or "in,out" - string commandOpt = getCommandOption(tag.typeOfEntity); + string commandOpt = getCommandOption(tag.typeOfEntity, '[', ']'); if (commandOpt == "in,out") commandOpt = "in/out"; // If provided, append the parameter direction to the type From 5230afb3e1ce626cfcb34dd720dbb277e025da6c Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 4 Aug 2019 17:32:53 -0500 Subject: [PATCH 1729/2031] Add new doxygen test doxygen_code_blocks This does somewhat more detailed testing of the code block parsing, and also exercises the language identification of python doctest features. For now, it is only tested by python (javadoc translation may not correctly handle some of the characters that are used here). --- Examples/test-suite/common.mk | 1 + Examples/test-suite/doxygen_code_blocks.i | 56 +++++++++++++++++++ .../python/doxygen_code_blocks_runme.py | 53 ++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 Examples/test-suite/doxygen_code_blocks.i create mode 100644 Examples/test-suite/python/doxygen_code_blocks_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7aa0e91d1..93128afd4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -630,6 +630,7 @@ DOXYGEN_TEST_CASES += \ doxygen_translate \ doxygen_translate_all_tags \ doxygen_translate_links \ + doxygen_code_blocks \ $(DOXYGEN_TEST_CASES:=.cpptest): SWIGOPT += -doxygen diff --git a/Examples/test-suite/doxygen_code_blocks.i b/Examples/test-suite/doxygen_code_blocks.i new file mode 100644 index 000000000..220ae13a3 --- /dev/null +++ b/Examples/test-suite/doxygen_code_blocks.i @@ -0,0 +1,56 @@ +%module doxygen_code_blocks + +// This test is only used with Python + +%inline %{ + +/** + * \brief Test for code blocks + * + * \code + * simple code block + * \endcode + * + * More advanced usage with C++ characters: + * \code + * std::vector first; // empty vector of ints + * std::vector second (4,100); // four ints with value 100 + * std::vector third (second.begin(),second.end()); // iterating through second + * std::vector fourth (third); // a copy of third + * // the iterator constructor can also be used to construct from arrays: + * int myints[] = {16,2,77,29}; + * std::vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); + * + * std::cout << "The contents of fifth are:"; + * for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) + * std::cout << ' ' << *it; + * std::cout << '\n'; + * \endcode + * + * A code block for C: + * \code{.c} + * printf("hello world"); + * \endcode + * + * A code block for Java: + * \code{.java} + * public class HelloWorld { + * public static void main(String[] args) { + * // Prints "Hello, World" to the terminal window. + * System.out.println("Hello, World"); + * } + * } + * \endcode + * + * A code block for python: + * \code{.py} + * print('hello world') + * \endcode + */ +int function() +{ + return 0; +} + + +%} diff --git a/Examples/test-suite/python/doxygen_code_blocks_runme.py b/Examples/test-suite/python/doxygen_code_blocks_runme.py new file mode 100644 index 000000000..a421c8267 --- /dev/null +++ b/Examples/test-suite/python/doxygen_code_blocks_runme.py @@ -0,0 +1,53 @@ +import doxygen_code_blocks +import inspect +import string +import sys +import comment_verifier + +comment_verifier.check(inspect.getdoc(doxygen_code_blocks.function), + """\ +Test for code blocks + +.. code-block:: c++ + + simple code block + +More advanced usage with C++ characters: + +.. code-block:: c++ + + std::vector first; // empty vector of ints + std::vector second (4,100); // four ints with value 100 + std::vector third (second.begin(),second.end()); // iterating through second + std::vector fourth (third); // a copy of third + // the iterator constructor can also be used to construct from arrays: + int myints[] = {16,2,77,29}; + std::vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); + + std::cout << "The contents of fifth are:"; + for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) + std::cout << ' ' << *it; + std::cout << '\\n'; + +A code block for C: + +.. code-block:: c + + printf("hello world"); + +A code block for Java: + +.. code-block:: java + + public class HelloWorld { + public static void main(String[] args) { + // Prints "Hello, World" to the terminal window. + System.out.println("Hello, World"); + } + } + +A code block for python: + +.. code-block:: python + + print('hello world')""") From 4a5a86ba91e08769f98af271be739744d682faea Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 4 Aug 2019 18:09:24 -0500 Subject: [PATCH 1730/2031] Special handling for python doctest code blocks A doctest code block begins with ">>>" and is not indented. Identify these in doxygen comments and treat them accordingly. Also add check to padCodeAndVerbatimBlocks for these because Sphinx requires an empty line before. Add test case to doxygen_code_blocks.i. --- Examples/test-suite/doxygen_code_blocks.i | 6 ++++ .../python/doxygen_code_blocks_runme.py | 7 +++- Source/Doxygen/pydoc.cxx | 35 ++++++++++++------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Examples/test-suite/doxygen_code_blocks.i b/Examples/test-suite/doxygen_code_blocks.i index 220ae13a3..900e8f9bb 100644 --- a/Examples/test-suite/doxygen_code_blocks.i +++ b/Examples/test-suite/doxygen_code_blocks.i @@ -46,6 +46,12 @@ * \code{.py} * print('hello world') * \endcode + * + * A python doctest example: + * \code{.py} + * >>> 1 + 1 + * 2 + * \endcode */ int function() { diff --git a/Examples/test-suite/python/doxygen_code_blocks_runme.py b/Examples/test-suite/python/doxygen_code_blocks_runme.py index a421c8267..46a0a3d84 100644 --- a/Examples/test-suite/python/doxygen_code_blocks_runme.py +++ b/Examples/test-suite/python/doxygen_code_blocks_runme.py @@ -50,4 +50,9 @@ A code block for python: .. code-block:: python - print('hello world')""") + print('hello world') + +A python doctest example: + +>>> 1 + 1 +2""") diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 649d3a03d..5216553dc 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -174,7 +174,8 @@ static string padCodeAndVerbatimBlocks(const string &docString) { } else { if (lastLineWasNonBlank && (line.compare(pos, 13, ".. code-block") == 0 || - line.compare(pos, 7, ".. math") == 0)) { + line.compare(pos, 7, ".. math") == 0 || + line.compare(pos, 3, ">>>") == 0)) { // Must separate code or math blocks from the previous line result += '\n'; } @@ -563,9 +564,6 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme trimWhitespace(translatedComment); - // Use the current indent for the code-block line itself. - translatedComment += indent.getFirstLineIndent(); - // Check for an option given to the code command (e.g. code{.py}), // and try to set the code-block language accordingly. string option = getCommandOption(tag.typeOfEntity, '{', '}'); @@ -589,14 +587,6 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // limb and assume that the examples in the C or C++ sources use // C++. codeLanguage = "c++"; - - translatedComment += ".. code-block:: " + codeLanguage + "\n\n"; - - // Specify the level of extra indentation that will be used for - // subsequent lines within the code block. Note that the correct - // "starting indentation" is already present in the input, so we - // only need to add the desired code block indentation. - string codeIndent = m_indent; std::string code; handleTagVerbatim(tag, code, arg); @@ -605,6 +595,27 @@ void PyDocConverter::handleCode(DoxygenEntity &tag, std::string &translatedComme // command: eraseLeadingNewLine(code); + // Check for python doctest blocks, and treat them specially: + bool isDocTestBlock = false; + size_t startPos; + // ">>>" would normally appear at the beginning, but doxygen comment + // style may have space in front, so skip leading whitespace + if ((startPos=code.find_first_not_of(" \t")) != string::npos && code.substr(startPos,3) == ">>>") + isDocTestBlock = true; + + string codeIndent; + if (! isDocTestBlock) { + // Use the current indent for the code-block line itself. + translatedComment += indent.getFirstLineIndent(); + translatedComment += ".. code-block:: " + codeLanguage + "\n\n"; + + // Specify the level of extra indentation that will be used for + // subsequent lines within the code block. Note that the correct + // "starting indentation" is already present in the input, so we + // only need to add the desired code block indentation. + codeIndent = m_indent; + } + translatedComment += codeIndent; for (size_t n = 0; n < code.length(); n++) { if (code[n] == '\n') { From bef1fab3e6c2198bc241698ae2341b6ce7d0043b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 8 Aug 2019 07:47:49 +0100 Subject: [PATCH 1731/2031] Add changes entry for %constant enum fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 6b38059b8..742035683 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-08: rokups + [C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType. + 2019-08-01: wsfulton #1602 Fix regression in 4.0.0 where a template function containing a parameter with the same name as the function name led to the parameter name used in the From 7aafe3d8b2c8b138c431d5fcc98a4d2a7c3270f9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 8 Aug 2019 14:30:50 -0700 Subject: [PATCH 1732/2031] Fix all Go tests to build with "go build" Tested against Go 1.6 through Go 1.13beta1, and gccgo. Fixes #1607 --- Examples/Makefile.in | 154 ++++-------------- Examples/go/callback/runme.go | 2 +- Examples/go/class/runme.go | 2 +- Examples/go/constants/runme.go | 2 +- Examples/go/director/runme.go | 2 +- Examples/go/enum/runme.go | 2 +- Examples/go/extend/runme.go | 2 +- Examples/go/funcptr/runme.go | 2 +- Examples/go/multimap/runme.go | 2 +- Examples/go/pointer/runme.go | 2 +- Examples/go/reference/runme.go | 2 +- Examples/go/simple/runme.go | 2 +- Examples/go/template/runme.go | 2 +- Examples/go/variables/runme.go | 2 +- Examples/test-suite/go/Makefile.in | 118 ++++++-------- .../test-suite/go/abstract_access_runme.go | 2 +- .../test-suite/go/abstract_typedef2_runme.go | 2 +- .../test-suite/go/abstract_typedef_runme.go | 2 +- .../test-suite/go/abstract_virtual_runme.go | 2 +- Examples/test-suite/go/argout_runme.go | 2 +- Examples/test-suite/go/array_member_runme.go | 2 +- Examples/test-suite/go/arrays_global_runme.go | 2 +- Examples/test-suite/go/char_binary_runme.go | 2 +- Examples/test-suite/go/class_ignore_runme.go | 2 +- .../test-suite/go/class_scope_weird_runme.go | 2 +- .../test-suite/go/compactdefaultargs_runme.go | 2 +- Examples/test-suite/go/constover_runme.go | 2 +- .../test-suite/go/constructor_copy_runme.go | 2 +- Examples/test-suite/go/contract_runme.go | 2 +- ...cpp11_strongly_typed_enumerations_runme.go | 2 +- Examples/test-suite/go/cpp_enum_runme.go | 2 +- Examples/test-suite/go/cpp_namespace_runme.go | 2 +- Examples/test-suite/go/cpp_static_runme.go | 2 +- Examples/test-suite/go/default_args_runme.go | 2 +- .../go/default_constructor_runme.go | 2 +- .../go/director_alternating_runme.go | 2 +- .../test-suite/go/director_basic_runme.go | 2 +- .../test-suite/go/director_classic_runme.go | 2 +- .../test-suite/go/director_default_runme.go | 2 +- .../test-suite/go/director_detect_runme.go | 2 +- Examples/test-suite/go/director_enum_runme.go | 2 +- .../test-suite/go/director_exception_runme.go | 2 +- .../test-suite/go/director_extend_runme.go | 2 +- .../test-suite/go/director_finalizer_runme.go | 2 +- Examples/test-suite/go/director_frob_runme.go | 2 +- .../test-suite/go/director_nested_runme.go | 2 +- .../test-suite/go/director_profile_runme.go | 2 +- .../test-suite/go/director_protected_runme.go | 2 +- .../test-suite/go/director_string_runme.go | 2 +- .../test-suite/go/director_unroll_runme.go | 2 +- Examples/test-suite/go/disown_runme.go | 2 +- Examples/test-suite/go/dynamic_cast_runme.go | 2 +- Examples/test-suite/go/empty_c_runme.go | 2 +- Examples/test-suite/go/empty_runme.go | 2 +- Examples/test-suite/go/enum_template_runme.go | 2 +- Examples/test-suite/go/enums_runme.go | 2 +- .../test-suite/go/exception_order_runme.go | 2 +- .../test-suite/go/extend_placement_runme.go | 2 +- .../test-suite/go/extend_template_ns_runme.go | 2 +- .../test-suite/go/extend_template_runme.go | 2 +- .../test-suite/go/extend_variable_runme.go | 2 +- Examples/test-suite/go/extern_c_runme.go | 2 +- Examples/test-suite/go/friends_runme.go | 2 +- Examples/test-suite/go/fvirtual_runme.go | 2 +- Examples/test-suite/go/global_ns_arg_runme.go | 2 +- .../test-suite/go/go_director_inout_runme.go | 2 +- Examples/test-suite/go/go_inout_runme.go | 2 +- Examples/test-suite/go/grouping_runme.go | 2 +- .../test-suite/go/import_nomodule_runme.go | 2 +- Examples/test-suite/go/inctest_runme.go | 2 +- .../test-suite/go/inherit_member_runme.go | 2 +- .../test-suite/go/inherit_missing_runme.go | 2 +- Examples/test-suite/go/input_runme.go | 2 +- .../test-suite/go/keyword_rename_c_runme.go | 2 +- .../test-suite/go/keyword_rename_runme.go | 2 +- Examples/test-suite/go/li_attribute_runme.go | 2 +- .../test-suite/go/li_carrays_cpp_runme.go | 2 +- Examples/test-suite/go/li_carrays_runme.go | 2 +- Examples/test-suite/go/li_cdata_cpp_runme.go | 2 +- Examples/test-suite/go/li_cdata_runme.go | 2 +- Examples/test-suite/go/li_cmalloc_runme.go | 2 +- .../test-suite/go/li_cpointer_cpp_runme.go | 2 +- Examples/test-suite/go/li_cpointer_runme.go | 2 +- Examples/test-suite/go/li_std_map_runme.go | 2 +- .../test-suite/go/li_std_vector_ptr_runme.go | 2 +- .../test-suite/go/member_pointer_runme.go | 2 +- .../test-suite/go/memberin_extend_c_runme.go | 2 +- Examples/test-suite/go/minherit_runme.go | 2 +- .../test-suite/go/namespace_class_runme.go | 2 +- .../test-suite/go/namespace_typemap_runme.go | 2 +- .../go/namespace_virtual_method_runme.go | 2 +- Examples/test-suite/go/naturalvar_runme.go | 2 +- .../test-suite/go/nested_workaround_runme.go | 2 +- .../go/overload_complicated_runme.go | 2 +- Examples/test-suite/go/overload_copy_runme.go | 2 +- .../test-suite/go/overload_extend2_runme.go | 2 +- .../test-suite/go/overload_extend_c_runme.go | 2 +- .../test-suite/go/overload_extend_runme.go | 2 +- .../go/overload_polymorphic_runme.go | 2 +- .../test-suite/go/overload_rename_runme.go | 2 +- .../test-suite/go/overload_simple_runme.go | 2 +- .../test-suite/go/overload_subtype_runme.go | 2 +- .../go/overload_template_fast_runme.go | 2 +- .../test-suite/go/overload_template_runme.go | 2 +- Examples/test-suite/go/preproc_runme.go | 2 +- Examples/test-suite/go/primitive_ref_runme.go | 2 +- Examples/test-suite/go/profiletest_runme.go | 2 +- Examples/test-suite/go/refcount_runme.go | 2 +- .../go/reference_global_vars_runme.go | 2 +- Examples/test-suite/go/rename_scope_runme.go | 2 +- Examples/test-suite/go/rename_simple_runme.go | 2 +- .../go/rename_strip_encoder_runme.go | 2 +- Examples/test-suite/go/ret_by_value_runme.go | 2 +- .../test-suite/go/return_const_value_runme.go | 2 +- .../go/smart_pointer_extend_runme.go | 2 +- .../go/smart_pointer_member_runme.go | 2 +- .../go/smart_pointer_multi_runme.go | 2 +- .../go/smart_pointer_multi_typedef_runme.go | 2 +- .../go/smart_pointer_overload_runme.go | 2 +- .../go/smart_pointer_rename_runme.go | 2 +- .../go/smart_pointer_simple_runme.go | 2 +- .../smart_pointer_templatevariables_runme.go | 2 +- .../go/smart_pointer_typedef_runme.go | 2 +- Examples/test-suite/go/sneaky1_runme.go | 2 +- .../go/special_variable_macros_runme.go | 2 +- .../go/static_const_member_2_runme.go | 2 +- .../go/struct_initialization_runme.go | 2 +- Examples/test-suite/go/struct_rename_runme.go | 2 +- Examples/test-suite/go/struct_value_runme.go | 2 +- .../go/template_default_arg_runme.go | 2 +- .../test-suite/go/template_extend1_runme.go | 2 +- .../test-suite/go/template_extend2_runme.go | 2 +- .../test-suite/go/template_inherit_runme.go | 2 +- Examples/test-suite/go/template_ns4_runme.go | 2 +- Examples/test-suite/go/template_ns_runme.go | 2 +- .../test-suite/go/template_opaque_runme.go | 2 +- .../test-suite/go/template_ref_type_runme.go | 2 +- .../test-suite/go/template_rename_runme.go | 2 +- .../test-suite/go/template_static_runme.go | 2 +- .../go/template_tbase_template_runme.go | 2 +- .../go/template_type_namespace_runme.go | 2 +- .../go/template_typedef_cplx3_runme.go | 2 +- .../go/template_typedef_cplx4_runme.go | 2 +- .../test-suite/go/threads_exception_runme.go | 2 +- Examples/test-suite/go/typedef_class_runme.go | 2 +- .../test-suite/go/typedef_funcptr_runme.go | 2 +- .../test-suite/go/typedef_inherit_runme.go | 2 +- Examples/test-suite/go/typedef_scope_runme.go | 2 +- .../test-suite/go/typemap_namespace_runme.go | 2 +- .../test-suite/go/typemap_ns_using_runme.go | 2 +- .../go/typemap_out_optimal_runme.go | 2 +- Examples/test-suite/go/typename_runme.go | 2 +- Examples/test-suite/go/unions_runme.go | 2 +- Examples/test-suite/go/using1_runme.go | 2 +- Examples/test-suite/go/using2_runme.go | 2 +- .../test-suite/go/using_composition_runme.go | 2 +- Examples/test-suite/go/using_extend_runme.go | 2 +- Examples/test-suite/go/using_inherit_runme.go | 2 +- Examples/test-suite/go/using_private_runme.go | 2 +- .../test-suite/go/using_protected_runme.go | 2 +- .../test-suite/go/varargs_overload_runme.go | 2 +- Examples/test-suite/go/varargs_runme.go | 2 +- .../test-suite/go/virtual_derivation_runme.go | 2 +- Examples/test-suite/go/virtual_poly_runme.go | 2 +- Examples/test-suite/go/voidtest_runme.go | 2 +- Examples/test-suite/go/wrapmacro_runme.go | 2 +- configure.ac | 38 +---- 167 files changed, 246 insertions(+), 392 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 98be7873f..9e05d2763 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1436,34 +1436,20 @@ scilab_clean: GO = @GO@ GOGCC = @GOGCC@ GCCGO = @GCCGO@ -GO1 = @GO1@ -GO12 = @GO12@ -GO13 = @GO13@ -GO15 = @GO15@ -GOC = @GOC@ GOOPT = @GOOPT@ GCCGOOPT = @GCCGOOPT@ GOVERSIONOPTION = @GOVERSIONOPTION@ GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi` -GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` `if $(GO13) || $(GO15); then echo -pack ; fi` GOSRCS = $(INTERFACE:.i=.go) GOCSRCS = $(INTERFACE:.i=_gc.c) -GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi` -GOTOOL = `if $(GO1) ; then echo go tool; fi` -GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi` - GOPACKAGE = $(notdir $(INTERFACE:.i=.a)) GOPATHPARENTDIR = gopath/$(GOMOD)/src GOPATHDIR = $(GOPATHPARENTDIR)/$(INTERFACE:.i=) -GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi` -GOGCOBJS = $(GOSRCS:.go=.$(GOOBJEXT)) -GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) - # ---------------------------------------------------------------- # Build a Go module (C) # ---------------------------------------------------------------- @@ -1478,49 +1464,13 @@ $(GOPATHPARENTDIR)/go.mod: echo "go 1.12" >> $(GOPATHDIR)/go.mod mv -f $(GOPATHDIR)/go.mod $(GOPATHPARENTDIR)/go.mod -go_nocgo: $(SRCDIR_SRCS) - $(SWIG) -go -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) - if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \ - $(CC) -g -c $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \ - else \ - $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(ISRCS) $(INCLUDES); \ - $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \ - fi - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -g -c -I . $(GOSRCS); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS); \ - $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} $(GOCSRCS); \ - rm -f $(GOPACKAGE); \ - if $(GO13) || $(GO15); then \ - cp $(GOGCOBJS) $(GOPACKAGE); \ - $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ - elif $(GO12); then \ - $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ - else \ - $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ - fi; \ - fi - if test -f $(SRCDIR)$(RUNME).go; then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS); \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - else \ - $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - fi; \ - fi - go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod $(SWIG) -go -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true @mkdir gopath/$(GOMOD) 2>/dev/null || true @mkdir gopath/$(GOMOD)/src 2>/dev/null || true @mkdir $(GOPATHDIR) 2>/dev/null || true - rm -f $(GOPATHDIR)/* + rm -rf $(GOPATHDIR)/* cp $(ISRCS) $(GOPATHDIR)/ if test -f $(IWRAP:.i=.h); then \ cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \ @@ -1529,6 +1479,13 @@ go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \ fi cp $(GOSRCS) $(GOPATHDIR)/ + @if test -f $(SRCDIR)$(RUNME).go; then \ + mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \ + rm -f gopath/$(GOMOD)/src/runme/*; \ + fi + if test -f $(SRCDIR)$(RUNME).go; then \ + cp $(SRCDIR)/$(RUNME).go gopath/$(GOMOD)/src/runme/; \ + fi GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ @@ -1537,82 +1494,29 @@ go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod export CGO_CFLAGS; \ CGO_LDFLAGS="$(LDFLAGS) -lm"; \ export CGO_LDFLAGS; \ - (cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)) + (cd $(GOPATHDIR)/ && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \ if $(GOGCC); then \ cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \ - fi + fi; \ if test -f $(SRCDIR)$(RUNME).go; then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE); \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CC)" -extldflags "$(CFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - fi; \ + mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \ + mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \ + cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \ + (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \ + cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \ fi # ---------------------------------------------------------------- # Build a Go module (C++) # ---------------------------------------------------------------- -go_cpp_nocgo: $(SRCDIR_SRCS) - $(SWIG) -go -c++ -no-cgo $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - if $(GO12) || $(GO13) || $(GO15) || $(GOGCC); then \ - if test -n "$(SRCDIR_CXXSRCS)$(SRCDIR_SRCS)"; then \ - $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_CXXSRCS) $(SRCDIR_SRCS) $(INCLUDES); \ - fi; \ - $(foreach f,$(ICXXSRCS), \ - $(CXX) -g -c $(CPPFLAGS) $(CXXFLAGS) -o $(addsuffix .@OBJEXT@,$(basename $f)) $f $(INCLUDES); \ - ) \ - else \ - $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(ICXXSRCS) $(INCLUDES); \ - $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO); \ - fi - if ! $(GOGCC) ; then \ - $(foreach f,$(GOSRCS), \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f \ - ); \ - $(foreach f,$(GOCSRCS), \ - $(COMPILETOOL) $(GOTOOL) $(GOC) -I $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`} \ - -o $(addsuffix .$(GOOBJEXT),$(basename $f)) $f; \ - ) \ - rm -f $(GOPACKAGE); \ - if $(GO13) || $(GO15); then \ - cp $(GOGCOBJS) $(GOPACKAGE); \ - $(COMPILETOOL) $(GOPACK) r $(GOPACKAGE) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ - elif $(GO12); then \ - $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)) $(OBJS) $(IOBJS); \ - else \ - $(COMPILETOOL) $(GOPACK) grc $(GOPACKAGE) $(GOGCOBJS) $(GOCSRCS:.c=.$(GOOBJEXT)); \ - fi; \ - else \ - $(foreach f,$(GOSRCS), \ - $(COMPILETOOL) $(GCCGO) -g -c -I . -o $(addsuffix .@OBJEXT@,$(basename $f)) $f \ - ); \ - fi - if test -f $(SRCDIR)$(RUNME).go; then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -g -c $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOGCCOBJS) $(OBJS) $(IOBJS) -lstdc++; \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - else \ - $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - fi; \ - fi - go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod $(SWIG) -go -c++ -import-prefix swigtests $(GOOPT) $(GOSWIGARG) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) @mkdir gopath 2>/dev/null || true @mkdir gopath/$(GOMOD) 2>/dev/null || true @mkdir gopath/$(GOMOD)/src 2>/dev/null || true @mkdir $(GOPATHDIR) 2>/dev/null || true - rm -f $(GOPATHDIR)/* + rm -rf $(GOPATHDIR)/* cp $(ICXXSRCS) $(GOPATHDIR)/ if test -f $(IWRAP:.i=.h); then \ cp $(IWRAP:.i=.h) $(GOPATHDIR)/; \ @@ -1624,6 +1528,13 @@ go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod cp $(SRCDIR_SRCS) $(GOPATHDIR)/; \ fi cp $(GOSRCS) $(GOPATHDIR)/ + @if test -f $(SRCDIR)$(RUNME).go; then \ + mkdir gopath/$(GOMOD)/src/runme 2>/dev/null || true; \ + rm -f gopath/$(GOMOD)/src/runme/*; \ + fi + if test -f $(SRCDIR)$(RUNME).go; then \ + cp $(SRCDIR)/$(RUNME).go gopath/$(GOMOD)/src/runme/; \ + fi GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ @@ -1634,21 +1545,16 @@ go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod export CGO_CXXFLAGS; \ CGO_LDFLAGS="$(LDFLAGS) -lm"; \ export CGO_LDFLAGS; \ - (cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)) + (cd $(GOPATHDIR) && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o $(GOPACKAGE)); \ if $(GOGCC); then \ cp $(GOPATHDIR)/$(GOPACKAGE) $(GOPATHDIR)/$(GOPACKAGE:.a=.gox); \ - fi + fi; \ if test -f $(SRCDIR)$(RUNME).go; then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -g -c -I $(GOPATHDIR) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GCCGO) -o $(RUNME) $(RUNME).@OBJEXT@ $(GOPATHDIR)/$(GOPACKAGE) -lstdc++; \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I $(GOPATHDIR) -o $(RUNME).$(GOOBJEXT) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L $(GOPATHDIR) -linkmode external -extld "$(CXX)" -extldflags "$(CXXFLAGS) $(LDFLAGS)" -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) $(SRCDIR)$(RUNME).go; \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $(RUNME) $(RUNME).$(GOOBJEXT); \ - fi; \ + mkdir gopath/$(GOMOD)/src/swigtests 2>/dev/null || true; \ + mkdir gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=) 2>/dev/null || true; \ + cp $(GOPATHDIR)/* gopath/$(GOMOD)/src/swigtests/$(INTERFACE:.i=)/; \ + (cd gopath/$(GOMOD)/src/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme $(RUNME).go); \ + cp gopath/$(GOMOD)/src/runme/runme $(RUNME); \ fi # ----------------------------------------------------------------- diff --git a/Examples/go/callback/runme.go b/Examples/go/callback/runme.go index 2c1d81343..7c9ffd681 100644 --- a/Examples/go/callback/runme.go +++ b/Examples/go/callback/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/class/runme.go b/Examples/go/class/runme.go index d2f292ed4..a09a18247 100644 --- a/Examples/go/class/runme.go +++ b/Examples/go/class/runme.go @@ -5,7 +5,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/constants/runme.go b/Examples/go/constants/runme.go index d56fd62c8..57ef21a8b 100644 --- a/Examples/go/constants/runme.go +++ b/Examples/go/constants/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "example" + "swigtests/example" ) func main() { diff --git a/Examples/go/director/runme.go b/Examples/go/director/runme.go index 0e0da07bd..e28eccba6 100644 --- a/Examples/go/director/runme.go +++ b/Examples/go/director/runme.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "example" + "swigtests/example" ) func Compare(name string, got string, exp string) error { diff --git a/Examples/go/enum/runme.go b/Examples/go/enum/runme.go index 50887056e..c0642e0b5 100644 --- a/Examples/go/enum/runme.go +++ b/Examples/go/enum/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go index af64a6e5d..716af52c5 100644 --- a/Examples/go/extend/runme.go +++ b/Examples/go/extend/runme.go @@ -5,7 +5,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/funcptr/runme.go b/Examples/go/funcptr/runme.go index 4b20db4fb..87ec7d495 100644 --- a/Examples/go/funcptr/runme.go +++ b/Examples/go/funcptr/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/multimap/runme.go b/Examples/go/multimap/runme.go index 571fac7c2..2f8b20568 100644 --- a/Examples/go/multimap/runme.go +++ b/Examples/go/multimap/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go index 0cf340f51..73c6b2b3c 100644 --- a/Examples/go/pointer/runme.go +++ b/Examples/go/pointer/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/reference/runme.go b/Examples/go/reference/runme.go index 9999733b3..7391d9c8b 100644 --- a/Examples/go/reference/runme.go +++ b/Examples/go/reference/runme.go @@ -5,7 +5,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/simple/runme.go b/Examples/go/simple/runme.go index 0bd4657f9..5bc055f2e 100644 --- a/Examples/go/simple/runme.go +++ b/Examples/go/simple/runme.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "example" + "swigtests/example" ) func main() { diff --git a/Examples/go/template/runme.go b/Examples/go/template/runme.go index 347795377..e000b1579 100644 --- a/Examples/go/template/runme.go +++ b/Examples/go/template/runme.go @@ -5,7 +5,7 @@ package main import ( "fmt" - . "example" + . "swigtests/example" ) func main() { diff --git a/Examples/go/variables/runme.go b/Examples/go/variables/runme.go index e2dd0c67f..85ca8c638 100644 --- a/Examples/go/variables/runme.go +++ b/Examples/go/variables/runme.go @@ -5,7 +5,7 @@ package main import ( "fmt" - "example" + "swigtests/example" ) func main() { diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in index d07a56bec..8283327d6 100644 --- a/Examples/test-suite/go/Makefile.in +++ b/Examples/test-suite/go/Makefile.in @@ -6,24 +6,10 @@ LANGUAGE = go GO = @GO@ GOGCC = @GOGCC@ GCCGO = @GCCGO@ -GO1 = @GO1@ -GO12 = @GO12@ -GO13 = @GO13@ -GO15 = @GO15@ -GOC = @GOC@ GOVERSIONOPTION = @GOVERSIONOPTION@ host = @host@ SCRIPTSUFFIX = _runme.go -GOCOMPILEARG = `if $(GO15); then echo tool compile; elif $(GO1); then echo tool $(GOC:c=g); fi` -GOLD = `if $(GO15); then echo link; else echo $(GOC:c=l); fi` -GOTOOL = `if $(GO1) ; then echo go tool; fi` -GOPACK = `if $(GO1) ; then echo go tool pack; else echo gopack; fi` - -GOOBJEXT = `if $(GO15); then echo o; else echo $(GOC:c=); fi` - -OSXOLDGOLINKFLAGS = `if [ -n "\`$(GO) $(GOVERSIONOPTION) | grep -E 'go1($|.0|.1|.2|.3)'\`" ] && [ -n "\`echo $(host) | grep darwin\`" ]; then echo "-Wl,-U,__cgo_topofstack"; fi` - SO = @SO@ srcdir = @srcdir@ @@ -49,27 +35,11 @@ INCLUDES = -I$(abs_top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) $(setup) +$(swig_and_compile_cpp) $(run_testcase_cpp) - if ! $(GO15); then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ - TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ - $(LANGUAGE)$(VARIANT)_cpp_nocgo && \ - $(run_testcase_cpp); \ - fi %.ctest: $(setup) +$(swig_and_compile_c) $(run_testcase) - if ! $(GO15); then \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' CSRCS='$(CSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - INCLUDES='$(INCLUDES)' SWIGOPT='$(SWIGOPT)' NOLINK=true \ - TARGET='$(TARGETPREFIX)$*$(TARGETSUFFIX)' INTERFACEDIR='$(INTERFACEDIR)' INTERFACE='$*.i' \ - $(LANGUAGE)$(VARIANT)_nocgo && \ - $(run_testcase); \ - fi %.multicpptest: $(setup) @@ -136,54 +106,66 @@ go_subdir_import.multicpptest: # Runs the testcase. run_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a; \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CC) -extldflags "$(CFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - fi && \ + GOPATH=`pwd`/gopath/; \ + export GOPATH; \ + CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ + export CGO_CPPFLAGS; \ + CGO_CFLAGS="$(CFLAGS)"; \ + export CGO_CFLAGS; \ + CGO_CXXFLAGS="$(CXXFLAGS)"; \ + export CGO_CXXFLAGS; \ + CGO_LDFLAGS="$(LDFLAGS) -lm"; \ + export CGO_LDFLAGS; \ + mkdir gopath/src/swigtests 2>/dev/null || true; \ + mkdir gopath/src/swigtests/$* 2>/dev/null || true; \ + cp gopath/src/$*/* gopath/src/swigtests/$*/; \ + mkdir gopath/src/$*/runme 2>/dev/null || true; \ + cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \ + (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \ + cp gopath/src/$*/runme/runme $*_runme; \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_testcase_cpp = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - if $(GOGCC) ; then \ - $(COMPILETOOL) $(GCCGO) -c -g -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GCCGO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ gopath/src/$*/$*.a -lstdc++; \ - elif $(GO12) || $(GO13) || $(GO15); then \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I gopath/src/$* $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L gopath/src/$* -linkmode external -extld $(CXX) -extldflags "$(CXXFLAGS) $(OSXOLDGOLINKFLAGS)" -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - else \ - $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - $(COMPILETOOL) $(GOTOOL) $(GOLD) -L . -r $${GOROOT:-`go env GOROOT`}/pkg/$${GOOS:-`go env GOOS`}_$${GOARCH:-`go env GOARCH`}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \ - fi && \ + GOPATH=`pwd`/gopath/; \ + export GOPATH; \ + CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) -I `cd $(SRCDIR) && pwd` -I `pwd`"; \ + export CGO_CPPFLAGS; \ + CGO_CFLAGS="$(CFLAGS)"; \ + export CGO_CFLAGS; \ + CGO_CXXFLAGS="$(CXXFLAGS)"; \ + export CGO_CXXFLAGS; \ + CGO_LDFLAGS="$(LDFLAGS) -lm"; \ + export CGO_LDFLAGS; \ + mkdir gopath/src/swigtests 2>/dev/null || true; \ + mkdir gopath/src/swigtests/$* 2>/dev/null || true; \ + cp gopath/src/$*/* gopath/src/swigtests/$*/; \ + mkdir gopath/src/$*/runme 2>/dev/null || true; \ + cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/src/$*/runme/runme.go; \ + (cd gopath/src/$*/runme && $(COMPILETOOL) $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o runme runme.go); \ + cp gopath/src/$*/runme/runme $*_runme; \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi run_multi_testcase = \ if test -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \ - if $(GO15) || $(GOGCC); then \ - files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ - mkdir gopath/$*/src/$* 2>/dev/null || true; \ - cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \ - GOPATH="`pwd`/gopath/$*"; \ - export GOPATH; \ - CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \ - export CGO_CPPFLAGS; \ - CGO_CFLAGS="$(CFLAGS)"; \ - export CGO_CFLAGS; \ - CGO_CXXFLAGS="$(CXXFLAGS)"; \ - export CGO_CXXFLAGS; \ - CGO_LDFLAGS="$(LDFLAGS) -lm"; \ - export CGO_LDFLAGS; \ - (cd gopath/$*/src/$* && \ - $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ - fi; \ + files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \ + mkdir gopath/$*/src/$* 2>/dev/null || true; \ + cp $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) gopath/$*/src/$*; \ + GOPATH="`pwd`/gopath/$*"; \ + export GOPATH; \ + CGO_CPPFLAGS="$(CPPFLAGS) $(INCLUDES) `for f in $$files; do echo -I ../$$f; done`"; \ + export CGO_CPPFLAGS; \ + CGO_CFLAGS="$(CFLAGS)"; \ + export CGO_CFLAGS; \ + CGO_CXXFLAGS="$(CXXFLAGS)"; \ + export CGO_CXXFLAGS; \ + CGO_LDFLAGS="$(LDFLAGS) -lm"; \ + export CGO_LDFLAGS; \ + (cd gopath/$*/src/$* && \ + $(GO) build `if $(GOGCC); then echo -compiler=gccgo; fi` -o ../../../../$*_runme) && \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \ fi %.clean: diff --git a/Examples/test-suite/go/abstract_access_runme.go b/Examples/test-suite/go/abstract_access_runme.go index 5102236f9..0a0e56fef 100644 --- a/Examples/test-suite/go/abstract_access_runme.go +++ b/Examples/test-suite/go/abstract_access_runme.go @@ -1,6 +1,6 @@ package main -import "abstract_access" +import "swigtests/abstract_access" func main() { d := abstract_access.NewD() diff --git a/Examples/test-suite/go/abstract_typedef2_runme.go b/Examples/test-suite/go/abstract_typedef2_runme.go index 76a5fc8de..5e2ed1e7a 100644 --- a/Examples/test-suite/go/abstract_typedef2_runme.go +++ b/Examples/test-suite/go/abstract_typedef2_runme.go @@ -1,6 +1,6 @@ package main -import "abstract_typedef2" +import "swigtests/abstract_typedef2" func main() { abstract_typedef2.NewA_UF() diff --git a/Examples/test-suite/go/abstract_typedef_runme.go b/Examples/test-suite/go/abstract_typedef_runme.go index 56aaa613f..1ad49f59d 100644 --- a/Examples/test-suite/go/abstract_typedef_runme.go +++ b/Examples/test-suite/go/abstract_typedef_runme.go @@ -1,6 +1,6 @@ package main -import "abstract_typedef" +import "swigtests/abstract_typedef" func main() { e := abstract_typedef.NewEngine() diff --git a/Examples/test-suite/go/abstract_virtual_runme.go b/Examples/test-suite/go/abstract_virtual_runme.go index e19eac27d..d333d50b3 100644 --- a/Examples/test-suite/go/abstract_virtual_runme.go +++ b/Examples/test-suite/go/abstract_virtual_runme.go @@ -1,6 +1,6 @@ package main -import "abstract_virtual" +import "swigtests/abstract_virtual" func main() { abstract_virtual.NewD() diff --git a/Examples/test-suite/go/argout_runme.go b/Examples/test-suite/go/argout_runme.go index bb8ab9ed2..b2edf54b6 100644 --- a/Examples/test-suite/go/argout_runme.go +++ b/Examples/test-suite/go/argout_runme.go @@ -1,6 +1,6 @@ package main -import wrap "argout" +import wrap "swigtests/argout" func main() { ip := wrap.New_intp() diff --git a/Examples/test-suite/go/array_member_runme.go b/Examples/test-suite/go/array_member_runme.go index 4f029db98..d8c3896ee 100644 --- a/Examples/test-suite/go/array_member_runme.go +++ b/Examples/test-suite/go/array_member_runme.go @@ -1,6 +1,6 @@ package main -import . "array_member" +import . "swigtests/array_member" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/arrays_global_runme.go b/Examples/test-suite/go/arrays_global_runme.go index 35b049d9a..9c4a9e57a 100644 --- a/Examples/test-suite/go/arrays_global_runme.go +++ b/Examples/test-suite/go/arrays_global_runme.go @@ -1,6 +1,6 @@ package main -import . "arrays_global" +import . "swigtests/arrays_global" func main() { SetArray_i(GetArray_const_i()) diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go index d47d616af..3c8c2d72d 100644 --- a/Examples/test-suite/go/char_binary_runme.go +++ b/Examples/test-suite/go/char_binary_runme.go @@ -1,6 +1,6 @@ package main -import . "char_binary" +import . "swigtests/char_binary" func main() { t := NewTest() diff --git a/Examples/test-suite/go/class_ignore_runme.go b/Examples/test-suite/go/class_ignore_runme.go index 24261c637..11cf81d91 100644 --- a/Examples/test-suite/go/class_ignore_runme.go +++ b/Examples/test-suite/go/class_ignore_runme.go @@ -1,6 +1,6 @@ package main -import "class_ignore" +import "swigtests/class_ignore" func main() { a := class_ignore.NewBar() diff --git a/Examples/test-suite/go/class_scope_weird_runme.go b/Examples/test-suite/go/class_scope_weird_runme.go index a42bdad21..477699061 100644 --- a/Examples/test-suite/go/class_scope_weird_runme.go +++ b/Examples/test-suite/go/class_scope_weird_runme.go @@ -1,6 +1,6 @@ package main -import "class_scope_weird" +import "swigtests/class_scope_weird" func main() { f := class_scope_weird.NewFoo() diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go index fe6224ca2..c9e90087f 100644 --- a/Examples/test-suite/go/compactdefaultargs_runme.go +++ b/Examples/test-suite/go/compactdefaultargs_runme.go @@ -1,6 +1,6 @@ package main -import . "compactdefaultargs" +import . "swigtests/compactdefaultargs" func main() { defaults1 := NewDefaults1(1000) diff --git a/Examples/test-suite/go/constover_runme.go b/Examples/test-suite/go/constover_runme.go index 6c837095a..51d965e7f 100644 --- a/Examples/test-suite/go/constover_runme.go +++ b/Examples/test-suite/go/constover_runme.go @@ -4,7 +4,7 @@ import ( "fmt" "os" - "constover" + "swigtests/constover" ) func main() { diff --git a/Examples/test-suite/go/constructor_copy_runme.go b/Examples/test-suite/go/constructor_copy_runme.go index 68c428853..ca4725549 100644 --- a/Examples/test-suite/go/constructor_copy_runme.go +++ b/Examples/test-suite/go/constructor_copy_runme.go @@ -1,6 +1,6 @@ package main -import . "constructor_copy" +import . "swigtests/constructor_copy" func main() { f1 := NewFoo1(3) diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go index b028855c3..7c9d0979e 100644 --- a/Examples/test-suite/go/contract_runme.go +++ b/Examples/test-suite/go/contract_runme.go @@ -1,6 +1,6 @@ package main -import "contract" +import "swigtests/contract" func main() { contract.Test_preassert(1, 2) diff --git a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go index f9ca74a1e..926b6f756 100644 --- a/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go +++ b/Examples/test-suite/go/cpp11_strongly_typed_enumerations_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "cpp11_strongly_typed_enumerations" +import . "swigtests/cpp11_strongly_typed_enumerations" func enumCheck(actual int, expected int) int { if actual != expected { diff --git a/Examples/test-suite/go/cpp_enum_runme.go b/Examples/test-suite/go/cpp_enum_runme.go index 8906dd4f1..9b8930a44 100644 --- a/Examples/test-suite/go/cpp_enum_runme.go +++ b/Examples/test-suite/go/cpp_enum_runme.go @@ -1,6 +1,6 @@ package main -import "cpp_enum" +import "swigtests/cpp_enum" func main() { f := cpp_enum.NewFoo() diff --git a/Examples/test-suite/go/cpp_namespace_runme.go b/Examples/test-suite/go/cpp_namespace_runme.go index aecdd9543..71affc57d 100644 --- a/Examples/test-suite/go/cpp_namespace_runme.go +++ b/Examples/test-suite/go/cpp_namespace_runme.go @@ -1,7 +1,7 @@ // Note: This example assumes that namespaces are flattened package main -import "cpp_namespace" +import "swigtests/cpp_namespace" func main() { n := cpp_namespace.Fact(4) diff --git a/Examples/test-suite/go/cpp_static_runme.go b/Examples/test-suite/go/cpp_static_runme.go index 1ad981a60..d482298eb 100644 --- a/Examples/test-suite/go/cpp_static_runme.go +++ b/Examples/test-suite/go/cpp_static_runme.go @@ -1,6 +1,6 @@ package main -import . "cpp_static" +import . "swigtests/cpp_static" func main() { StaticFunctionTestStatic_func() diff --git a/Examples/test-suite/go/default_args_runme.go b/Examples/test-suite/go/default_args_runme.go index a39f95716..5b6f404e3 100644 --- a/Examples/test-suite/go/default_args_runme.go +++ b/Examples/test-suite/go/default_args_runme.go @@ -1,6 +1,6 @@ package main -import "default_args" +import "swigtests/default_args" func main() { if default_args.StaticsStaticmethod() != 60 { diff --git a/Examples/test-suite/go/default_constructor_runme.go b/Examples/test-suite/go/default_constructor_runme.go index eeac7eaf8..90d960143 100644 --- a/Examples/test-suite/go/default_constructor_runme.go +++ b/Examples/test-suite/go/default_constructor_runme.go @@ -1,6 +1,6 @@ package main -import dc "default_constructor" +import dc "swigtests/default_constructor" func main() { a := dc.NewA() diff --git a/Examples/test-suite/go/director_alternating_runme.go b/Examples/test-suite/go/director_alternating_runme.go index b4793aa8f..2df31db82 100644 --- a/Examples/test-suite/go/director_alternating_runme.go +++ b/Examples/test-suite/go/director_alternating_runme.go @@ -1,6 +1,6 @@ package main -import . "director_alternating" +import . "swigtests/director_alternating" func main() { id := GetBar().Id() diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go index 360424d9b..c308f2520 100644 --- a/Examples/test-suite/go/director_basic_runme.go +++ b/Examples/test-suite/go/director_basic_runme.go @@ -1,6 +1,6 @@ package main -import "director_basic" +import "swigtests/director_basic" type GoFoo struct{} diff --git a/Examples/test-suite/go/director_classic_runme.go b/Examples/test-suite/go/director_classic_runme.go index 230c9638d..d8acc1337 100644 --- a/Examples/test-suite/go/director_classic_runme.go +++ b/Examples/test-suite/go/director_classic_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "director_classic" +import . "swigtests/director_classic" type TargetLangPerson struct{} // From Person func (p *TargetLangPerson) Id() string { diff --git a/Examples/test-suite/go/director_default_runme.go b/Examples/test-suite/go/director_default_runme.go index ac2aace1d..557d5c54b 100644 --- a/Examples/test-suite/go/director_default_runme.go +++ b/Examples/test-suite/go/director_default_runme.go @@ -1,6 +1,6 @@ package main -import . "director_default" +import . "swigtests/director_default" func main() { NewFoo() diff --git a/Examples/test-suite/go/director_detect_runme.go b/Examples/test-suite/go/director_detect_runme.go index 0c3c95fdc..f82a0c04a 100644 --- a/Examples/test-suite/go/director_detect_runme.go +++ b/Examples/test-suite/go/director_detect_runme.go @@ -1,6 +1,6 @@ package main -import "director_detect" +import "swigtests/director_detect" type MyBar struct { val int diff --git a/Examples/test-suite/go/director_enum_runme.go b/Examples/test-suite/go/director_enum_runme.go index 002d425d2..3e67417b2 100644 --- a/Examples/test-suite/go/director_enum_runme.go +++ b/Examples/test-suite/go/director_enum_runme.go @@ -1,6 +1,6 @@ package main -import "director_enum" +import "swigtests/director_enum" type MyFoo struct{} // From director_enum.Foo func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello { diff --git a/Examples/test-suite/go/director_exception_runme.go b/Examples/test-suite/go/director_exception_runme.go index 55231ff16..167d75193 100644 --- a/Examples/test-suite/go/director_exception_runme.go +++ b/Examples/test-suite/go/director_exception_runme.go @@ -1,6 +1,6 @@ package main -import . "director_exception" +import . "swigtests/director_exception" type Exception struct { msg string diff --git a/Examples/test-suite/go/director_extend_runme.go b/Examples/test-suite/go/director_extend_runme.go index 27e55b997..adfb6ddb7 100644 --- a/Examples/test-suite/go/director_extend_runme.go +++ b/Examples/test-suite/go/director_extend_runme.go @@ -5,7 +5,7 @@ package main -import . "director_extend" +import . "swigtests/director_extend" func main() { m := NewSpObject() diff --git a/Examples/test-suite/go/director_finalizer_runme.go b/Examples/test-suite/go/director_finalizer_runme.go index d36a4ba33..5cd9d95e0 100644 --- a/Examples/test-suite/go/director_finalizer_runme.go +++ b/Examples/test-suite/go/director_finalizer_runme.go @@ -1,6 +1,6 @@ package main -import . "director_finalizer" +import . "swigtests/director_finalizer" type MyFoo struct{} // From Foo func DeleteMyFoo(p Foo) { diff --git a/Examples/test-suite/go/director_frob_runme.go b/Examples/test-suite/go/director_frob_runme.go index 3985eb14b..7354fa76b 100644 --- a/Examples/test-suite/go/director_frob_runme.go +++ b/Examples/test-suite/go/director_frob_runme.go @@ -1,6 +1,6 @@ package main -import . "director_frob" +import . "swigtests/director_frob" func main() { foo := NewBravo() diff --git a/Examples/test-suite/go/director_nested_runme.go b/Examples/test-suite/go/director_nested_runme.go index a1193ad59..b04893582 100644 --- a/Examples/test-suite/go/director_nested_runme.go +++ b/Examples/test-suite/go/director_nested_runme.go @@ -1,6 +1,6 @@ package main -import . "director_nested" +import . "swigtests/director_nested" type A struct{} // From FooBar_int func (p *A) Do_step() string { diff --git a/Examples/test-suite/go/director_profile_runme.go b/Examples/test-suite/go/director_profile_runme.go index a9bc7934b..da0ea219b 100644 --- a/Examples/test-suite/go/director_profile_runme.go +++ b/Examples/test-suite/go/director_profile_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "director_profile" +import "swigtests/director_profile" type MyB struct{} // From director_profile.B func (p *MyB) Vfi(a int) int { diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go index bfd50c6b2..0012ccdb2 100644 --- a/Examples/test-suite/go/director_protected_runme.go +++ b/Examples/test-suite/go/director_protected_runme.go @@ -1,6 +1,6 @@ package main -import . "director_protected" +import . "swigtests/director_protected" type FooBar struct{} // From Bar func (p *FooBar) Ping() string { diff --git a/Examples/test-suite/go/director_string_runme.go b/Examples/test-suite/go/director_string_runme.go index f4f9cc150..0c73b6a29 100644 --- a/Examples/test-suite/go/director_string_runme.go +++ b/Examples/test-suite/go/director_string_runme.go @@ -1,6 +1,6 @@ package main -import . "director_string" +import . "swigtests/director_string" type B struct { // From A abi A diff --git a/Examples/test-suite/go/director_unroll_runme.go b/Examples/test-suite/go/director_unroll_runme.go index 6a919f656..560034c8a 100644 --- a/Examples/test-suite/go/director_unroll_runme.go +++ b/Examples/test-suite/go/director_unroll_runme.go @@ -1,6 +1,6 @@ package main -import "director_unroll" +import "swigtests/director_unroll" type MyFoo struct{} // From director_unroll.Foo func (p *MyFoo) Ping() string { diff --git a/Examples/test-suite/go/disown_runme.go b/Examples/test-suite/go/disown_runme.go index 4484515fd..ba072a888 100644 --- a/Examples/test-suite/go/disown_runme.go +++ b/Examples/test-suite/go/disown_runme.go @@ -1,6 +1,6 @@ package main -import . "disown" +import . "swigtests/disown" func main() { a := NewA() diff --git a/Examples/test-suite/go/dynamic_cast_runme.go b/Examples/test-suite/go/dynamic_cast_runme.go index 46ba23698..213bc0ce5 100644 --- a/Examples/test-suite/go/dynamic_cast_runme.go +++ b/Examples/test-suite/go/dynamic_cast_runme.go @@ -1,6 +1,6 @@ package main -import "dynamic_cast" +import "swigtests/dynamic_cast" func main() { f := dynamic_cast.NewFoo() diff --git a/Examples/test-suite/go/empty_c_runme.go b/Examples/test-suite/go/empty_c_runme.go index 1a1bd9cc5..f093103f6 100644 --- a/Examples/test-suite/go/empty_c_runme.go +++ b/Examples/test-suite/go/empty_c_runme.go @@ -1,6 +1,6 @@ package main -import _ "empty_c" +import _ "swigtests/empty_c" func main() { } diff --git a/Examples/test-suite/go/empty_runme.go b/Examples/test-suite/go/empty_runme.go index 681a6f3ad..03f423b8b 100644 --- a/Examples/test-suite/go/empty_runme.go +++ b/Examples/test-suite/go/empty_runme.go @@ -1,6 +1,6 @@ package main -import _ "empty" +import _ "swigtests/empty" func main() { } diff --git a/Examples/test-suite/go/enum_template_runme.go b/Examples/test-suite/go/enum_template_runme.go index c60a452d7..7f43eab68 100644 --- a/Examples/test-suite/go/enum_template_runme.go +++ b/Examples/test-suite/go/enum_template_runme.go @@ -1,6 +1,6 @@ package main -import "enum_template" +import "swigtests/enum_template" func main() { if enum_template.MakeETest() != 1 { diff --git a/Examples/test-suite/go/enums_runme.go b/Examples/test-suite/go/enums_runme.go index 7a528b3e2..4a879a048 100644 --- a/Examples/test-suite/go/enums_runme.go +++ b/Examples/test-suite/go/enums_runme.go @@ -1,6 +1,6 @@ package main -import "enums" +import "swigtests/enums" func main() { enums.Bar2(1) diff --git a/Examples/test-suite/go/exception_order_runme.go b/Examples/test-suite/go/exception_order_runme.go index 21dcff312..ee67712fc 100644 --- a/Examples/test-suite/go/exception_order_runme.go +++ b/Examples/test-suite/go/exception_order_runme.go @@ -1,7 +1,7 @@ package main import "strings" -import . "exception_order" +import . "swigtests/exception_order" func main() { a := NewA() diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go index 253ec6618..879589679 100644 --- a/Examples/test-suite/go/extend_placement_runme.go +++ b/Examples/test-suite/go/extend_placement_runme.go @@ -1,6 +1,6 @@ package main -import "extend_placement" +import "swigtests/extend_placement" func main() { foo := extend_placement.NewFoo() diff --git a/Examples/test-suite/go/extend_template_ns_runme.go b/Examples/test-suite/go/extend_template_ns_runme.go index d005172a4..b1dd43a78 100644 --- a/Examples/test-suite/go/extend_template_ns_runme.go +++ b/Examples/test-suite/go/extend_template_ns_runme.go @@ -1,6 +1,6 @@ package main -import . "extend_template_ns" +import . "swigtests/extend_template_ns" func main() { f := NewFoo_One() diff --git a/Examples/test-suite/go/extend_template_runme.go b/Examples/test-suite/go/extend_template_runme.go index a5c4da4e1..4a6b7099b 100644 --- a/Examples/test-suite/go/extend_template_runme.go +++ b/Examples/test-suite/go/extend_template_runme.go @@ -1,6 +1,6 @@ package main -import "extend_template" +import "swigtests/extend_template" func main() { f := extend_template.NewFoo_0() diff --git a/Examples/test-suite/go/extend_variable_runme.go b/Examples/test-suite/go/extend_variable_runme.go index 9425aee4d..278bffed6 100644 --- a/Examples/test-suite/go/extend_variable_runme.go +++ b/Examples/test-suite/go/extend_variable_runme.go @@ -1,6 +1,6 @@ package main -import . "extend_variable" +import . "swigtests/extend_variable" func main() { if FooBar != 42 { diff --git a/Examples/test-suite/go/extern_c_runme.go b/Examples/test-suite/go/extern_c_runme.go index 9bc2cd0cc..1cbfd9d80 100644 --- a/Examples/test-suite/go/extern_c_runme.go +++ b/Examples/test-suite/go/extern_c_runme.go @@ -1,6 +1,6 @@ package main -import "extern_c" +import "swigtests/extern_c" func main() { extern_c.RealFunction(2) diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go index 2e34a4db0..b6b9e93f3 100644 --- a/Examples/test-suite/go/friends_runme.go +++ b/Examples/test-suite/go/friends_runme.go @@ -1,6 +1,6 @@ package main -import "friends" +import "swigtests/friends" func main() { a := friends.NewA(2) diff --git a/Examples/test-suite/go/fvirtual_runme.go b/Examples/test-suite/go/fvirtual_runme.go index 86ef90f18..01b94f419 100644 --- a/Examples/test-suite/go/fvirtual_runme.go +++ b/Examples/test-suite/go/fvirtual_runme.go @@ -1,6 +1,6 @@ package main -import . "fvirtual" +import . "swigtests/fvirtual" func main() { sw := NewNodeSwitch() diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go index e86aa6747..aeacd91a3 100644 --- a/Examples/test-suite/go/global_ns_arg_runme.go +++ b/Examples/test-suite/go/global_ns_arg_runme.go @@ -1,6 +1,6 @@ package main -import . "global_ns_arg" +import . "swigtests/global_ns_arg" func main() { Foo(1) diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go index e6768a465..171b3c223 100644 --- a/Examples/test-suite/go/go_director_inout_runme.go +++ b/Examples/test-suite/go/go_director_inout_runme.go @@ -1,7 +1,7 @@ package main import ( - wrap "go_director_inout" + wrap "swigtests/go_director_inout" ) type GoMyClass struct {} diff --git a/Examples/test-suite/go/go_inout_runme.go b/Examples/test-suite/go/go_inout_runme.go index 4599aa104..2dc5b9908 100644 --- a/Examples/test-suite/go/go_inout_runme.go +++ b/Examples/test-suite/go/go_inout_runme.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "go_inout" + "swigtests/go_inout" ) type S struct { diff --git a/Examples/test-suite/go/grouping_runme.go b/Examples/test-suite/go/grouping_runme.go index f808e1286..d5f347579 100644 --- a/Examples/test-suite/go/grouping_runme.go +++ b/Examples/test-suite/go/grouping_runme.go @@ -1,6 +1,6 @@ package main -import "grouping" +import "swigtests/grouping" func main() { x := grouping.Test1(42) diff --git a/Examples/test-suite/go/import_nomodule_runme.go b/Examples/test-suite/go/import_nomodule_runme.go index 48592df25..23680159d 100644 --- a/Examples/test-suite/go/import_nomodule_runme.go +++ b/Examples/test-suite/go/import_nomodule_runme.go @@ -1,6 +1,6 @@ package main -import . "import_nomodule" +import . "swigtests/import_nomodule" func main() { f := Create_Foo() diff --git a/Examples/test-suite/go/inctest_runme.go b/Examples/test-suite/go/inctest_runme.go index 3148abcd2..490721e75 100644 --- a/Examples/test-suite/go/inctest_runme.go +++ b/Examples/test-suite/go/inctest_runme.go @@ -1,6 +1,6 @@ package main -import "inctest" +import "swigtests/inctest" func main() { inctest.NewA() diff --git a/Examples/test-suite/go/inherit_member_runme.go b/Examples/test-suite/go/inherit_member_runme.go index 6fd70cf80..10dabad96 100644 --- a/Examples/test-suite/go/inherit_member_runme.go +++ b/Examples/test-suite/go/inherit_member_runme.go @@ -1,6 +1,6 @@ package main -import wrap "inherit_member" +import wrap "swigtests/inherit_member" func main() { s := wrap.NewChild() diff --git a/Examples/test-suite/go/inherit_missing_runme.go b/Examples/test-suite/go/inherit_missing_runme.go index c70c48306..b4706e974 100644 --- a/Examples/test-suite/go/inherit_missing_runme.go +++ b/Examples/test-suite/go/inherit_missing_runme.go @@ -1,6 +1,6 @@ package main -import "inherit_missing" +import "swigtests/inherit_missing" func main() { a := inherit_missing.New_Foo() diff --git a/Examples/test-suite/go/input_runme.go b/Examples/test-suite/go/input_runme.go index ddc2992fe..c5eb9e45d 100644 --- a/Examples/test-suite/go/input_runme.go +++ b/Examples/test-suite/go/input_runme.go @@ -1,6 +1,6 @@ package main -import . "input" +import . "swigtests/input" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/keyword_rename_c_runme.go b/Examples/test-suite/go/keyword_rename_c_runme.go index 26f2ea42b..28f6ddd12 100644 --- a/Examples/test-suite/go/keyword_rename_c_runme.go +++ b/Examples/test-suite/go/keyword_rename_c_runme.go @@ -1,6 +1,6 @@ package main -import "keyword_rename_c" +import "swigtests/keyword_rename_c" func main() { keyword_rename_c.Xgo(1) diff --git a/Examples/test-suite/go/keyword_rename_runme.go b/Examples/test-suite/go/keyword_rename_runme.go index 7a40ff83d..f93c7ab14 100644 --- a/Examples/test-suite/go/keyword_rename_runme.go +++ b/Examples/test-suite/go/keyword_rename_runme.go @@ -1,6 +1,6 @@ package main -import "keyword_rename" +import "swigtests/keyword_rename" func main() { keyword_rename.Xgo(1) diff --git a/Examples/test-suite/go/li_attribute_runme.go b/Examples/test-suite/go/li_attribute_runme.go index b502b8cea..0702b898f 100644 --- a/Examples/test-suite/go/li_attribute_runme.go +++ b/Examples/test-suite/go/li_attribute_runme.go @@ -1,6 +1,6 @@ package main -import "li_attribute" +import "swigtests/li_attribute" func main() { aa := li_attribute.NewA(1, 2, 3) diff --git a/Examples/test-suite/go/li_carrays_cpp_runme.go b/Examples/test-suite/go/li_carrays_cpp_runme.go index cfc171284..a96291c7b 100644 --- a/Examples/test-suite/go/li_carrays_cpp_runme.go +++ b/Examples/test-suite/go/li_carrays_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "li_carrays_cpp" +import . "swigtests/li_carrays_cpp" func main() { d := NewDoubleArray(10) diff --git a/Examples/test-suite/go/li_carrays_runme.go b/Examples/test-suite/go/li_carrays_runme.go index 9128bbfd1..eefc6ad72 100644 --- a/Examples/test-suite/go/li_carrays_runme.go +++ b/Examples/test-suite/go/li_carrays_runme.go @@ -1,6 +1,6 @@ package main -import . "li_carrays" +import . "swigtests/li_carrays" func main() { d := NewDoubleArray(10) diff --git a/Examples/test-suite/go/li_cdata_cpp_runme.go b/Examples/test-suite/go/li_cdata_cpp_runme.go index daa5384f7..5849c50d4 100644 --- a/Examples/test-suite/go/li_cdata_cpp_runme.go +++ b/Examples/test-suite/go/li_cdata_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "li_cdata_cpp" +import . "swigtests/li_cdata_cpp" func main() { s := "ABC abc" diff --git a/Examples/test-suite/go/li_cdata_runme.go b/Examples/test-suite/go/li_cdata_runme.go index 9458dab43..0c3e591ce 100644 --- a/Examples/test-suite/go/li_cdata_runme.go +++ b/Examples/test-suite/go/li_cdata_runme.go @@ -1,6 +1,6 @@ package main -import . "li_cdata" +import . "swigtests/li_cdata" func main() { s := "ABC abc" diff --git a/Examples/test-suite/go/li_cmalloc_runme.go b/Examples/test-suite/go/li_cmalloc_runme.go index 5b9f9704a..fb1b009c3 100644 --- a/Examples/test-suite/go/li_cmalloc_runme.go +++ b/Examples/test-suite/go/li_cmalloc_runme.go @@ -1,6 +1,6 @@ package main -import . "li_cmalloc" +import . "swigtests/li_cmalloc" func main() { p := Malloc_int() diff --git a/Examples/test-suite/go/li_cpointer_cpp_runme.go b/Examples/test-suite/go/li_cpointer_cpp_runme.go index 0de57c624..f422b2310 100644 --- a/Examples/test-suite/go/li_cpointer_cpp_runme.go +++ b/Examples/test-suite/go/li_cpointer_cpp_runme.go @@ -1,6 +1,6 @@ package main -import . "li_cpointer_cpp" +import . "swigtests/li_cpointer_cpp" func main() { p := New_intp() diff --git a/Examples/test-suite/go/li_cpointer_runme.go b/Examples/test-suite/go/li_cpointer_runme.go index 0fe29e77d..1a83bc62f 100644 --- a/Examples/test-suite/go/li_cpointer_runme.go +++ b/Examples/test-suite/go/li_cpointer_runme.go @@ -1,6 +1,6 @@ package main -import . "li_cpointer" +import . "swigtests/li_cpointer" func main() { p := New_intp() diff --git a/Examples/test-suite/go/li_std_map_runme.go b/Examples/test-suite/go/li_std_map_runme.go index 5c5cc2e4c..019ac6e30 100644 --- a/Examples/test-suite/go/li_std_map_runme.go +++ b/Examples/test-suite/go/li_std_map_runme.go @@ -1,6 +1,6 @@ package main -import "li_std_map" +import "swigtests/li_std_map" func main() { a1 := li_std_map.NewA(3) diff --git a/Examples/test-suite/go/li_std_vector_ptr_runme.go b/Examples/test-suite/go/li_std_vector_ptr_runme.go index d66ff19c6..9a62d3796 100644 --- a/Examples/test-suite/go/li_std_vector_ptr_runme.go +++ b/Examples/test-suite/go/li_std_vector_ptr_runme.go @@ -1,6 +1,6 @@ package main -import . "li_std_vector_ptr" +import . "swigtests/li_std_vector_ptr" import "fmt" func check(val1 int, val2 int) { diff --git a/Examples/test-suite/go/member_pointer_runme.go b/Examples/test-suite/go/member_pointer_runme.go index 731526b75..02789382e 100644 --- a/Examples/test-suite/go/member_pointer_runme.go +++ b/Examples/test-suite/go/member_pointer_runme.go @@ -3,7 +3,7 @@ package main import "fmt" -import . "member_pointer" +import . "swigtests/member_pointer" func check(what string, expected float64, actual float64) { if expected != actual { diff --git a/Examples/test-suite/go/memberin_extend_c_runme.go b/Examples/test-suite/go/memberin_extend_c_runme.go index 0551acc90..696f08abb 100644 --- a/Examples/test-suite/go/memberin_extend_c_runme.go +++ b/Examples/test-suite/go/memberin_extend_c_runme.go @@ -1,6 +1,6 @@ package main -import "memberin_extend_c" +import "swigtests/memberin_extend_c" func main() { t := memberin_extend_c.NewPerson() diff --git a/Examples/test-suite/go/minherit_runme.go b/Examples/test-suite/go/minherit_runme.go index 9b7873cb0..f1504af31 100644 --- a/Examples/test-suite/go/minherit_runme.go +++ b/Examples/test-suite/go/minherit_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "minherit" +import "swigtests/minherit" func main() { a := minherit.NewFoo() diff --git a/Examples/test-suite/go/namespace_class_runme.go b/Examples/test-suite/go/namespace_class_runme.go index 4c240b6a4..435ee868a 100644 --- a/Examples/test-suite/go/namespace_class_runme.go +++ b/Examples/test-suite/go/namespace_class_runme.go @@ -1,6 +1,6 @@ package main -import . "namespace_class" +import . "swigtests/namespace_class" func main() { EulerT3DToFrame(1, 1, 1) diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go index 47e2b64f1..6da43331b 100644 --- a/Examples/test-suite/go/namespace_typemap_runme.go +++ b/Examples/test-suite/go/namespace_typemap_runme.go @@ -1,6 +1,6 @@ package main -import . "namespace_typemap" +import . "swigtests/namespace_typemap" func main() { if Stest1("hello") != "hello" { diff --git a/Examples/test-suite/go/namespace_virtual_method_runme.go b/Examples/test-suite/go/namespace_virtual_method_runme.go index a8cb38bad..7ac4d3304 100644 --- a/Examples/test-suite/go/namespace_virtual_method_runme.go +++ b/Examples/test-suite/go/namespace_virtual_method_runme.go @@ -1,6 +1,6 @@ package main -import "namespace_virtual_method" +import "swigtests/namespace_virtual_method" func main() { _ = namespace_virtual_method.NewSpam() diff --git a/Examples/test-suite/go/naturalvar_runme.go b/Examples/test-suite/go/naturalvar_runme.go index ed47e9d2d..458745ec4 100644 --- a/Examples/test-suite/go/naturalvar_runme.go +++ b/Examples/test-suite/go/naturalvar_runme.go @@ -1,6 +1,6 @@ package main -import . "naturalvar" +import . "swigtests/naturalvar" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/nested_workaround_runme.go b/Examples/test-suite/go/nested_workaround_runme.go index 8b31a7f4b..f42b48764 100644 --- a/Examples/test-suite/go/nested_workaround_runme.go +++ b/Examples/test-suite/go/nested_workaround_runme.go @@ -1,6 +1,6 @@ package main -import . "nested_workaround" +import . "swigtests/nested_workaround" func main() { inner := NewInner(5) diff --git a/Examples/test-suite/go/overload_complicated_runme.go b/Examples/test-suite/go/overload_complicated_runme.go index ce9d124c8..c238d974f 100644 --- a/Examples/test-suite/go/overload_complicated_runme.go +++ b/Examples/test-suite/go/overload_complicated_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_complicated" +import . "swigtests/overload_complicated" func main() { var pInt *int diff --git a/Examples/test-suite/go/overload_copy_runme.go b/Examples/test-suite/go/overload_copy_runme.go index 55ec4a333..9815d76ef 100644 --- a/Examples/test-suite/go/overload_copy_runme.go +++ b/Examples/test-suite/go/overload_copy_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_copy" +import . "swigtests/overload_copy" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/overload_extend2_runme.go b/Examples/test-suite/go/overload_extend2_runme.go index db790989c..d549098ba 100644 --- a/Examples/test-suite/go/overload_extend2_runme.go +++ b/Examples/test-suite/go/overload_extend2_runme.go @@ -1,6 +1,6 @@ package main -import "overload_extend2" +import "swigtests/overload_extend2" func main() { f := overload_extend2.NewFoo() diff --git a/Examples/test-suite/go/overload_extend_c_runme.go b/Examples/test-suite/go/overload_extend_c_runme.go index 4d3b2b6e1..93b91d9e1 100644 --- a/Examples/test-suite/go/overload_extend_c_runme.go +++ b/Examples/test-suite/go/overload_extend_c_runme.go @@ -1,6 +1,6 @@ package main -import "overload_extend_c" +import "swigtests/overload_extend_c" func main() { f := overload_extend_c.NewFoo() diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go index d73d6cf3c..c1435f376 100644 --- a/Examples/test-suite/go/overload_extend_runme.go +++ b/Examples/test-suite/go/overload_extend_runme.go @@ -1,6 +1,6 @@ package main -import "overload_extend" +import "swigtests/overload_extend" func main() { f := overload_extend.NewFoo() diff --git a/Examples/test-suite/go/overload_polymorphic_runme.go b/Examples/test-suite/go/overload_polymorphic_runme.go index 12b9777e6..6a4301f46 100644 --- a/Examples/test-suite/go/overload_polymorphic_runme.go +++ b/Examples/test-suite/go/overload_polymorphic_runme.go @@ -1,6 +1,6 @@ package main -import "overload_polymorphic" +import "swigtests/overload_polymorphic" func main(){ t := overload_polymorphic.NewDerived() diff --git a/Examples/test-suite/go/overload_rename_runme.go b/Examples/test-suite/go/overload_rename_runme.go index 3bd4a69c5..982b1786a 100644 --- a/Examples/test-suite/go/overload_rename_runme.go +++ b/Examples/test-suite/go/overload_rename_runme.go @@ -1,6 +1,6 @@ package main -import "overload_rename" +import "swigtests/overload_rename" func main() { _ = overload_rename.NewFoo(float32(1)) diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go index 3eb859bac..23a80bf69 100644 --- a/Examples/test-suite/go/overload_simple_runme.go +++ b/Examples/test-suite/go/overload_simple_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_simple" +import . "swigtests/overload_simple" func main() { if Foo(3) != "foo:int" { diff --git a/Examples/test-suite/go/overload_subtype_runme.go b/Examples/test-suite/go/overload_subtype_runme.go index 45d5a025f..09f7a83f4 100644 --- a/Examples/test-suite/go/overload_subtype_runme.go +++ b/Examples/test-suite/go/overload_subtype_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_subtype" +import . "swigtests/overload_subtype" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go index 63809c0ff..3b348f366 100644 --- a/Examples/test-suite/go/overload_template_fast_runme.go +++ b/Examples/test-suite/go/overload_template_fast_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_template_fast" +import . "swigtests/overload_template_fast" func main() { _ = Foo() diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go index f3a08ecd6..b85afb4d1 100644 --- a/Examples/test-suite/go/overload_template_runme.go +++ b/Examples/test-suite/go/overload_template_runme.go @@ -1,6 +1,6 @@ package main -import . "overload_template" +import . "swigtests/overload_template" func main() { _ = Foo() diff --git a/Examples/test-suite/go/preproc_runme.go b/Examples/test-suite/go/preproc_runme.go index 3c55aae72..878305463 100644 --- a/Examples/test-suite/go/preproc_runme.go +++ b/Examples/test-suite/go/preproc_runme.go @@ -1,6 +1,6 @@ package main -import "preproc" +import "swigtests/preproc" func main() { if preproc.GetEndif() != 1 { diff --git a/Examples/test-suite/go/primitive_ref_runme.go b/Examples/test-suite/go/primitive_ref_runme.go index a1de2f8a5..8dcf9f5a9 100644 --- a/Examples/test-suite/go/primitive_ref_runme.go +++ b/Examples/test-suite/go/primitive_ref_runme.go @@ -1,6 +1,6 @@ package main -import . "primitive_ref" +import . "swigtests/primitive_ref" func main() { if Ref_int(3) != 3 { diff --git a/Examples/test-suite/go/profiletest_runme.go b/Examples/test-suite/go/profiletest_runme.go index c2b922ba3..68509f550 100644 --- a/Examples/test-suite/go/profiletest_runme.go +++ b/Examples/test-suite/go/profiletest_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import "profiletest" +import "swigtests/profiletest" func main() { a := profiletest.NewA() diff --git a/Examples/test-suite/go/refcount_runme.go b/Examples/test-suite/go/refcount_runme.go index 07d407273..76e30dda3 100644 --- a/Examples/test-suite/go/refcount_runme.go +++ b/Examples/test-suite/go/refcount_runme.go @@ -1,6 +1,6 @@ package main -import . "refcount" +import . "swigtests/refcount" // very innocent example diff --git a/Examples/test-suite/go/reference_global_vars_runme.go b/Examples/test-suite/go/reference_global_vars_runme.go index 908358f95..f8c125854 100644 --- a/Examples/test-suite/go/reference_global_vars_runme.go +++ b/Examples/test-suite/go/reference_global_vars_runme.go @@ -1,6 +1,6 @@ package main -import . "reference_global_vars" +import . "swigtests/reference_global_vars" func main() { // const class reference variable diff --git a/Examples/test-suite/go/rename_scope_runme.go b/Examples/test-suite/go/rename_scope_runme.go index 13bd3f178..4ad7549ad 100644 --- a/Examples/test-suite/go/rename_scope_runme.go +++ b/Examples/test-suite/go/rename_scope_runme.go @@ -1,6 +1,6 @@ package main -import . "rename_scope" +import . "swigtests/rename_scope" func main() { a := NewNatural_UP() diff --git a/Examples/test-suite/go/rename_simple_runme.go b/Examples/test-suite/go/rename_simple_runme.go index bd559ef27..efe1edc7b 100644 --- a/Examples/test-suite/go/rename_simple_runme.go +++ b/Examples/test-suite/go/rename_simple_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "rename_simple" +import . "swigtests/rename_simple" func main() { s := NewNewStruct() diff --git a/Examples/test-suite/go/rename_strip_encoder_runme.go b/Examples/test-suite/go/rename_strip_encoder_runme.go index ae670600c..74a0dbaaf 100644 --- a/Examples/test-suite/go/rename_strip_encoder_runme.go +++ b/Examples/test-suite/go/rename_strip_encoder_runme.go @@ -1,6 +1,6 @@ package main -import . "rename_strip_encoder" +import . "swigtests/rename_strip_encoder" func main() { _ = NewSomeWidget() diff --git a/Examples/test-suite/go/ret_by_value_runme.go b/Examples/test-suite/go/ret_by_value_runme.go index 9659d21e9..345868dcd 100644 --- a/Examples/test-suite/go/ret_by_value_runme.go +++ b/Examples/test-suite/go/ret_by_value_runme.go @@ -1,6 +1,6 @@ package main -import "ret_by_value" +import "swigtests/ret_by_value" func main() { a := ret_by_value.Get_test() diff --git a/Examples/test-suite/go/return_const_value_runme.go b/Examples/test-suite/go/return_const_value_runme.go index aadb1265e..fc6baa240 100644 --- a/Examples/test-suite/go/return_const_value_runme.go +++ b/Examples/test-suite/go/return_const_value_runme.go @@ -1,6 +1,6 @@ package main -import "return_const_value" +import "swigtests/return_const_value" func main() { p := return_const_value.Foo_ptrGetPtr() diff --git a/Examples/test-suite/go/smart_pointer_extend_runme.go b/Examples/test-suite/go/smart_pointer_extend_runme.go index a851e26b7..f91c9ac99 100644 --- a/Examples/test-suite/go/smart_pointer_extend_runme.go +++ b/Examples/test-suite/go/smart_pointer_extend_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_extend" +import . "swigtests/smart_pointer_extend" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_member_runme.go b/Examples/test-suite/go/smart_pointer_member_runme.go index e7fe7c4c2..ca2ac2c76 100644 --- a/Examples/test-suite/go/smart_pointer_member_runme.go +++ b/Examples/test-suite/go/smart_pointer_member_runme.go @@ -1,7 +1,7 @@ package main import "fmt" -import . "smart_pointer_member" +import . "swigtests/smart_pointer_member" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_multi_runme.go b/Examples/test-suite/go/smart_pointer_multi_runme.go index 7c76061af..a8ec39f54 100644 --- a/Examples/test-suite/go/smart_pointer_multi_runme.go +++ b/Examples/test-suite/go/smart_pointer_multi_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_multi" +import . "swigtests/smart_pointer_multi" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go index e584cf7a2..6bfd21ef6 100644 --- a/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go +++ b/Examples/test-suite/go/smart_pointer_multi_typedef_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_multi_typedef" +import . "swigtests/smart_pointer_multi_typedef" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go index 9481554f0..c28ce6100 100644 --- a/Examples/test-suite/go/smart_pointer_overload_runme.go +++ b/Examples/test-suite/go/smart_pointer_overload_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_overload" +import . "swigtests/smart_pointer_overload" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_rename_runme.go b/Examples/test-suite/go/smart_pointer_rename_runme.go index 44841f5e6..22c0eb1e9 100644 --- a/Examples/test-suite/go/smart_pointer_rename_runme.go +++ b/Examples/test-suite/go/smart_pointer_rename_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_rename" +import . "swigtests/smart_pointer_rename" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_simple_runme.go b/Examples/test-suite/go/smart_pointer_simple_runme.go index b468bd2e5..8a14dcf9b 100644 --- a/Examples/test-suite/go/smart_pointer_simple_runme.go +++ b/Examples/test-suite/go/smart_pointer_simple_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_simple" +import . "swigtests/smart_pointer_simple" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go index 6d4ea91de..8f7102d43 100644 --- a/Examples/test-suite/go/smart_pointer_templatevariables_runme.go +++ b/Examples/test-suite/go/smart_pointer_templatevariables_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_templatevariables" +import . "swigtests/smart_pointer_templatevariables" func main() { d := NewDiffImContainerPtr_D(Create(1234, 5678)) diff --git a/Examples/test-suite/go/smart_pointer_typedef_runme.go b/Examples/test-suite/go/smart_pointer_typedef_runme.go index e89a8b150..5468a2926 100644 --- a/Examples/test-suite/go/smart_pointer_typedef_runme.go +++ b/Examples/test-suite/go/smart_pointer_typedef_runme.go @@ -1,6 +1,6 @@ package main -import . "smart_pointer_typedef" +import . "swigtests/smart_pointer_typedef" func main() { f := NewFoo() diff --git a/Examples/test-suite/go/sneaky1_runme.go b/Examples/test-suite/go/sneaky1_runme.go index 57c779724..c17f0ffc6 100644 --- a/Examples/test-suite/go/sneaky1_runme.go +++ b/Examples/test-suite/go/sneaky1_runme.go @@ -1,6 +1,6 @@ package main -import "sneaky1" +import "swigtests/sneaky1" func main() { _ = sneaky1.Add(3, 4) diff --git a/Examples/test-suite/go/special_variable_macros_runme.go b/Examples/test-suite/go/special_variable_macros_runme.go index 9338e6558..597c48748 100644 --- a/Examples/test-suite/go/special_variable_macros_runme.go +++ b/Examples/test-suite/go/special_variable_macros_runme.go @@ -1,6 +1,6 @@ package main -import "special_variable_macros" +import "swigtests/special_variable_macros" func main() { name := special_variable_macros.NewName() diff --git a/Examples/test-suite/go/static_const_member_2_runme.go b/Examples/test-suite/go/static_const_member_2_runme.go index ff8cbbbcd..7586eb404 100644 --- a/Examples/test-suite/go/static_const_member_2_runme.go +++ b/Examples/test-suite/go/static_const_member_2_runme.go @@ -1,6 +1,6 @@ package main -import . "static_const_member_2" +import . "swigtests/static_const_member_2" func main() { _ = NewTest_int() diff --git a/Examples/test-suite/go/struct_initialization_runme.go b/Examples/test-suite/go/struct_initialization_runme.go index a815bd3f5..d5eb4e968 100644 --- a/Examples/test-suite/go/struct_initialization_runme.go +++ b/Examples/test-suite/go/struct_initialization_runme.go @@ -1,6 +1,6 @@ package main -import . "struct_initialization" +import . "swigtests/struct_initialization" func main() { if GetInstanceC1().GetX() != 10 { diff --git a/Examples/test-suite/go/struct_rename_runme.go b/Examples/test-suite/go/struct_rename_runme.go index de99fc320..6d619e090 100644 --- a/Examples/test-suite/go/struct_rename_runme.go +++ b/Examples/test-suite/go/struct_rename_runme.go @@ -1,6 +1,6 @@ package main -import "struct_rename" +import "swigtests/struct_rename" func main() { _ = struct_rename.NewBar() diff --git a/Examples/test-suite/go/struct_value_runme.go b/Examples/test-suite/go/struct_value_runme.go index 3b5e5c1dc..c43a67a88 100644 --- a/Examples/test-suite/go/struct_value_runme.go +++ b/Examples/test-suite/go/struct_value_runme.go @@ -1,6 +1,6 @@ package main -import "struct_value" +import "swigtests/struct_value" func main() { b := struct_value.NewBar() diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go index d67e63fa7..9558c7496 100644 --- a/Examples/test-suite/go/template_default_arg_runme.go +++ b/Examples/test-suite/go/template_default_arg_runme.go @@ -1,6 +1,6 @@ package main -import "template_default_arg" +import "swigtests/template_default_arg" func main() { helloInt := template_default_arg.NewHello_int() diff --git a/Examples/test-suite/go/template_extend1_runme.go b/Examples/test-suite/go/template_extend1_runme.go index 0912fa6ed..f2469ab15 100644 --- a/Examples/test-suite/go/template_extend1_runme.go +++ b/Examples/test-suite/go/template_extend1_runme.go @@ -1,6 +1,6 @@ package main -import "template_extend1" +import "swigtests/template_extend1" func main() { a := template_extend1.NewLBaz() diff --git a/Examples/test-suite/go/template_extend2_runme.go b/Examples/test-suite/go/template_extend2_runme.go index ced3d93cc..c3669bc95 100644 --- a/Examples/test-suite/go/template_extend2_runme.go +++ b/Examples/test-suite/go/template_extend2_runme.go @@ -1,6 +1,6 @@ package main -import "template_extend2" +import "swigtests/template_extend2" func main() { a := template_extend2.NewLBaz() diff --git a/Examples/test-suite/go/template_inherit_runme.go b/Examples/test-suite/go/template_inherit_runme.go index a8d5126dc..10071b128 100644 --- a/Examples/test-suite/go/template_inherit_runme.go +++ b/Examples/test-suite/go/template_inherit_runme.go @@ -1,6 +1,6 @@ package main -import . "template_inherit" +import . "swigtests/template_inherit" func main() { a := NewFooInt() diff --git a/Examples/test-suite/go/template_ns4_runme.go b/Examples/test-suite/go/template_ns4_runme.go index 6c658ec97..c1b356b3f 100644 --- a/Examples/test-suite/go/template_ns4_runme.go +++ b/Examples/test-suite/go/template_ns4_runme.go @@ -1,6 +1,6 @@ package main -import . "template_ns4" +import . "swigtests/template_ns4" func main() { d := Make_Class_DD() diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go index cfc56fa3c..e77c17bf7 100644 --- a/Examples/test-suite/go/template_ns_runme.go +++ b/Examples/test-suite/go/template_ns_runme.go @@ -1,6 +1,6 @@ package main -import . "template_ns" +import . "swigtests/template_ns" func main() { p1 := NewPairii(2, 3) diff --git a/Examples/test-suite/go/template_opaque_runme.go b/Examples/test-suite/go/template_opaque_runme.go index 71701df53..b3bf61043 100644 --- a/Examples/test-suite/go/template_opaque_runme.go +++ b/Examples/test-suite/go/template_opaque_runme.go @@ -1,6 +1,6 @@ package main -import "template_opaque" +import "swigtests/template_opaque" func main() { v := template_opaque.NewOpaqueVectorType(int64(10)) diff --git a/Examples/test-suite/go/template_ref_type_runme.go b/Examples/test-suite/go/template_ref_type_runme.go index a01ce3d31..516b6c721 100644 --- a/Examples/test-suite/go/template_ref_type_runme.go +++ b/Examples/test-suite/go/template_ref_type_runme.go @@ -1,6 +1,6 @@ package main -import "template_ref_type" +import "swigtests/template_ref_type" func main() { xr := template_ref_type.NewXC() diff --git a/Examples/test-suite/go/template_rename_runme.go b/Examples/test-suite/go/template_rename_runme.go index 6e04f8845..08cf3fb48 100644 --- a/Examples/test-suite/go/template_rename_runme.go +++ b/Examples/test-suite/go/template_rename_runme.go @@ -1,6 +1,6 @@ package main -import "template_rename" +import "swigtests/template_rename" func main() { i := template_rename.NewIFoo() diff --git a/Examples/test-suite/go/template_static_runme.go b/Examples/test-suite/go/template_static_runme.go index f10ea78f7..205813dbf 100644 --- a/Examples/test-suite/go/template_static_runme.go +++ b/Examples/test-suite/go/template_static_runme.go @@ -1,6 +1,6 @@ package main -import . "template_static" +import . "swigtests/template_static" func main() { FooBar_double(1) diff --git a/Examples/test-suite/go/template_tbase_template_runme.go b/Examples/test-suite/go/template_tbase_template_runme.go index e1c46aaf7..a4832439f 100644 --- a/Examples/test-suite/go/template_tbase_template_runme.go +++ b/Examples/test-suite/go/template_tbase_template_runme.go @@ -1,6 +1,6 @@ package main -import . "template_tbase_template" +import . "swigtests/template_tbase_template" func main() { a := Make_Class_dd() diff --git a/Examples/test-suite/go/template_type_namespace_runme.go b/Examples/test-suite/go/template_type_namespace_runme.go index 1356f9b08..562fae78d 100644 --- a/Examples/test-suite/go/template_type_namespace_runme.go +++ b/Examples/test-suite/go/template_type_namespace_runme.go @@ -1,6 +1,6 @@ package main -import . "template_type_namespace" +import . "swigtests/template_type_namespace" func main() { if Foo().Get(0) == "" { diff --git a/Examples/test-suite/go/template_typedef_cplx3_runme.go b/Examples/test-suite/go/template_typedef_cplx3_runme.go index 0a2b31301..52a9bc7f6 100644 --- a/Examples/test-suite/go/template_typedef_cplx3_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx3_runme.go @@ -1,6 +1,6 @@ package main -import . "template_typedef_cplx3" +import . "swigtests/template_typedef_cplx3" func main() { // this is OK diff --git a/Examples/test-suite/go/template_typedef_cplx4_runme.go b/Examples/test-suite/go/template_typedef_cplx4_runme.go index d8952cfb6..84347e404 100644 --- a/Examples/test-suite/go/template_typedef_cplx4_runme.go +++ b/Examples/test-suite/go/template_typedef_cplx4_runme.go @@ -1,6 +1,6 @@ package main -import . "template_typedef_cplx4" +import . "swigtests/template_typedef_cplx4" func main() { // this is OK diff --git a/Examples/test-suite/go/threads_exception_runme.go b/Examples/test-suite/go/threads_exception_runme.go index e3da1dc25..b554f0e28 100644 --- a/Examples/test-suite/go/threads_exception_runme.go +++ b/Examples/test-suite/go/threads_exception_runme.go @@ -1,7 +1,7 @@ package main import "strings" -import "threads_exception" +import "swigtests/threads_exception" func main() { t := threads_exception.NewTest() diff --git a/Examples/test-suite/go/typedef_class_runme.go b/Examples/test-suite/go/typedef_class_runme.go index d94126d3b..157a91745 100644 --- a/Examples/test-suite/go/typedef_class_runme.go +++ b/Examples/test-suite/go/typedef_class_runme.go @@ -1,6 +1,6 @@ package main -import "typedef_class" +import "swigtests/typedef_class" func main() { a := typedef_class.NewRealA() diff --git a/Examples/test-suite/go/typedef_funcptr_runme.go b/Examples/test-suite/go/typedef_funcptr_runme.go index 9d55f3f04..f76f088af 100644 --- a/Examples/test-suite/go/typedef_funcptr_runme.go +++ b/Examples/test-suite/go/typedef_funcptr_runme.go @@ -1,6 +1,6 @@ package main -import . "typedef_funcptr" +import . "swigtests/typedef_funcptr" func main() { a := 100 diff --git a/Examples/test-suite/go/typedef_inherit_runme.go b/Examples/test-suite/go/typedef_inherit_runme.go index 7a65569f2..f2dbb3263 100644 --- a/Examples/test-suite/go/typedef_inherit_runme.go +++ b/Examples/test-suite/go/typedef_inherit_runme.go @@ -1,6 +1,6 @@ package main -import "typedef_inherit" +import "swigtests/typedef_inherit" func main() { a := typedef_inherit.NewFoo() diff --git a/Examples/test-suite/go/typedef_scope_runme.go b/Examples/test-suite/go/typedef_scope_runme.go index af282b16f..9c845bb69 100644 --- a/Examples/test-suite/go/typedef_scope_runme.go +++ b/Examples/test-suite/go/typedef_scope_runme.go @@ -1,6 +1,6 @@ package main -import "typedef_scope" +import "swigtests/typedef_scope" func main() { b := typedef_scope.NewBar() diff --git a/Examples/test-suite/go/typemap_namespace_runme.go b/Examples/test-suite/go/typemap_namespace_runme.go index a2880d4a8..f0860803e 100644 --- a/Examples/test-suite/go/typemap_namespace_runme.go +++ b/Examples/test-suite/go/typemap_namespace_runme.go @@ -1,6 +1,6 @@ package main -import . "typemap_namespace" +import . "swigtests/typemap_namespace" func main() { if Test1("hello") != "hello" { diff --git a/Examples/test-suite/go/typemap_ns_using_runme.go b/Examples/test-suite/go/typemap_ns_using_runme.go index c4c21cf75..00e1131d6 100644 --- a/Examples/test-suite/go/typemap_ns_using_runme.go +++ b/Examples/test-suite/go/typemap_ns_using_runme.go @@ -1,6 +1,6 @@ package main -import "typemap_ns_using" +import "swigtests/typemap_ns_using" func main() { if typemap_ns_using.Spam(37) != 37 { diff --git a/Examples/test-suite/go/typemap_out_optimal_runme.go b/Examples/test-suite/go/typemap_out_optimal_runme.go index 7cc3b38e3..0cccd97a6 100644 --- a/Examples/test-suite/go/typemap_out_optimal_runme.go +++ b/Examples/test-suite/go/typemap_out_optimal_runme.go @@ -1,6 +1,6 @@ package main -import . "typemap_out_optimal" +import . "swigtests/typemap_out_optimal" func main() { SetXXDebug(false) diff --git a/Examples/test-suite/go/typename_runme.go b/Examples/test-suite/go/typename_runme.go index d1665099c..1e1696d0a 100644 --- a/Examples/test-suite/go/typename_runme.go +++ b/Examples/test-suite/go/typename_runme.go @@ -1,6 +1,6 @@ package main -import "typename" +import "swigtests/typename" func main() { f := typename.NewFoo() diff --git a/Examples/test-suite/go/unions_runme.go b/Examples/test-suite/go/unions_runme.go index b76ca5c75..6e2981192 100644 --- a/Examples/test-suite/go/unions_runme.go +++ b/Examples/test-suite/go/unions_runme.go @@ -3,7 +3,7 @@ package main -import "unions" +import "swigtests/unions" func main() { // Create new instances of SmallStruct and BigStruct for later use diff --git a/Examples/test-suite/go/using1_runme.go b/Examples/test-suite/go/using1_runme.go index a6a6fa738..09cc381cc 100644 --- a/Examples/test-suite/go/using1_runme.go +++ b/Examples/test-suite/go/using1_runme.go @@ -1,6 +1,6 @@ package main -import "using1" +import "swigtests/using1" func main() { if using1.Spam(37) != 37 { diff --git a/Examples/test-suite/go/using2_runme.go b/Examples/test-suite/go/using2_runme.go index f6b8d49b5..8109037f9 100644 --- a/Examples/test-suite/go/using2_runme.go +++ b/Examples/test-suite/go/using2_runme.go @@ -1,6 +1,6 @@ package main -import "using2" +import "swigtests/using2" func main() { if using2.Spam(37) != 37 { diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go index 712d1fad5..7ef09fef9 100644 --- a/Examples/test-suite/go/using_composition_runme.go +++ b/Examples/test-suite/go/using_composition_runme.go @@ -1,6 +1,6 @@ package main -import . "using_composition" +import . "swigtests/using_composition" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go index 27d1ccc62..dac300ba4 100644 --- a/Examples/test-suite/go/using_extend_runme.go +++ b/Examples/test-suite/go/using_extend_runme.go @@ -1,6 +1,6 @@ package main -import . "using_extend" +import . "swigtests/using_extend" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go index a88171817..c8755902f 100644 --- a/Examples/test-suite/go/using_inherit_runme.go +++ b/Examples/test-suite/go/using_inherit_runme.go @@ -1,6 +1,6 @@ package main -import . "using_inherit" +import . "swigtests/using_inherit" func main() { b := NewBar() diff --git a/Examples/test-suite/go/using_private_runme.go b/Examples/test-suite/go/using_private_runme.go index 2da62dc2e..4c86ef514 100644 --- a/Examples/test-suite/go/using_private_runme.go +++ b/Examples/test-suite/go/using_private_runme.go @@ -1,6 +1,6 @@ package main -import . "using_private" +import . "swigtests/using_private" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/using_protected_runme.go b/Examples/test-suite/go/using_protected_runme.go index 3fd5029f7..431081827 100644 --- a/Examples/test-suite/go/using_protected_runme.go +++ b/Examples/test-suite/go/using_protected_runme.go @@ -1,6 +1,6 @@ package main -import . "using_protected" +import . "swigtests/using_protected" func main() { f := NewFooBar() diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go index 8ce580d65..50a430894 100644 --- a/Examples/test-suite/go/varargs_overload_runme.go +++ b/Examples/test-suite/go/varargs_overload_runme.go @@ -1,6 +1,6 @@ package main -import "varargs_overload" +import "swigtests/varargs_overload" func main() { if varargs_overload.Vararg_over1("Hello") != "Hello" { diff --git a/Examples/test-suite/go/varargs_runme.go b/Examples/test-suite/go/varargs_runme.go index 60bd8829a..eb2fa94aa 100644 --- a/Examples/test-suite/go/varargs_runme.go +++ b/Examples/test-suite/go/varargs_runme.go @@ -1,6 +1,6 @@ package main -import "varargs" +import "swigtests/varargs" func main() { if varargs.Test("Hello") != "Hello" { diff --git a/Examples/test-suite/go/virtual_derivation_runme.go b/Examples/test-suite/go/virtual_derivation_runme.go index 4e2c6e585..21135308c 100644 --- a/Examples/test-suite/go/virtual_derivation_runme.go +++ b/Examples/test-suite/go/virtual_derivation_runme.go @@ -1,6 +1,6 @@ package main -import . "virtual_derivation" +import . "swigtests/virtual_derivation" // very innocent example diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go index 32906b391..9973f24c7 100644 --- a/Examples/test-suite/go/virtual_poly_runme.go +++ b/Examples/test-suite/go/virtual_poly_runme.go @@ -1,6 +1,6 @@ package main -import "virtual_poly" +import "swigtests/virtual_poly" func main() { d := virtual_poly.NewNDouble(3.5) diff --git a/Examples/test-suite/go/voidtest_runme.go b/Examples/test-suite/go/voidtest_runme.go index 133545cea..35c5289fd 100644 --- a/Examples/test-suite/go/voidtest_runme.go +++ b/Examples/test-suite/go/voidtest_runme.go @@ -1,6 +1,6 @@ package main -import "voidtest" +import "swigtests/voidtest" func main() { voidtest.Globalfunc() diff --git a/Examples/test-suite/go/wrapmacro_runme.go b/Examples/test-suite/go/wrapmacro_runme.go index a251a05e8..d792d4ffe 100644 --- a/Examples/test-suite/go/wrapmacro_runme.go +++ b/Examples/test-suite/go/wrapmacro_runme.go @@ -1,6 +1,6 @@ package main -import "wrapmacro" +import "swigtests/wrapmacro" func main() { a := 2 diff --git a/configure.ac b/configure.ac index 543274359..a38e97d2a 100644 --- a/configure.ac +++ b/configure.ac @@ -2370,11 +2370,6 @@ AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval if test x"${GOBIN}" = xno; then AC_MSG_NOTICE([Disabling Go]) GO= - GOC= - GO1=false - GO12=false - GO13=false - GO15=false GOGCC=false GCCGO= GOOPT= @@ -2390,30 +2385,15 @@ else GOGCC=false GCCGO= - GO1=false - GO12=false - GO13=false - GO15=false GOOPT= GCCGOOPT= GOVERSIONOPTION= if test -n "$GO" ; then - GO1=true - GOVERSIONOPTION=version - go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') - case "$go_version" in - go1 | go1.[[01234]] | go1.[[01234]].*) - GOC=$(sh -c "$(go env) && echo \$GOCHAR")c - ;; - *) - GOC=compile - ;; - esac AC_MSG_CHECKING([whether go version is too old]) case $go_version in - go1.1.* | go1.1 | go1.0 | go1.0.* | go1 ) - AC_MSG_RESULT([yes - minimum version is 1.2]) + go1.[012345]*) + AC_MSG_RESULT([yes - minimum version is 1.6]) GO= GOOPT="-intgosize 32" ;; @@ -2429,20 +2409,6 @@ else esac ;; esac - case $go_version in - go1.0 | go1.0.* | go1 | go1.1 | go1.1.*) - GOOPT="$GOOPT -use-shlib" - ;; - go1.2 | go1.2.*) - GO12=true - ;; - go1.3 | go1.3.* | go1.4 | go1.4.*) - GO13=true - ;; - *) - GO15=true - ;; - esac fi AC_CHECK_PROGS(GCCGO, gccgo) From 6b108c19e1504c937e1a7d50147575dd8e624b73 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 8 Aug 2019 22:59:57 -0700 Subject: [PATCH 1733/2031] Restore setting of GOVERSIONOPTION Accidentally removed in last commit. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index a38e97d2a..73c38a72c 100644 --- a/configure.ac +++ b/configure.ac @@ -2390,6 +2390,7 @@ else GOVERSIONOPTION= if test -n "$GO" ; then + GOVERSIONOPTION=version AC_MSG_CHECKING([whether go version is too old]) case $go_version in go1.[012345]*) From 62136ff782e9bf6641970f716d7d40afcf6c49ea Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 9 Aug 2019 14:06:45 -0700 Subject: [PATCH 1734/2031] Fix Go version check and Go in-tree example tests Fixes #1607 --- Examples/Makefile.in | 4 ++-- configure.ac | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 9e05d2763..6fbca29db 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1484,7 +1484,7 @@ go: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod rm -f gopath/$(GOMOD)/src/runme/*; \ fi if test -f $(SRCDIR)$(RUNME).go; then \ - cp $(SRCDIR)/$(RUNME).go gopath/$(GOMOD)/src/runme/; \ + cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \ fi GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ @@ -1533,7 +1533,7 @@ go_cpp: $(SRCDIR_SRCS) $(GOPATHPARENTDIR)/go.mod rm -f gopath/$(GOMOD)/src/runme/*; \ fi if test -f $(SRCDIR)$(RUNME).go; then \ - cp $(SRCDIR)/$(RUNME).go gopath/$(GOMOD)/src/runme/; \ + cp $(SRCDIR)$(RUNME).go gopath/$(GOMOD)/src/runme/; \ fi GOPATH=`pwd`/gopath/$(GOMOD); \ export GOPATH; \ diff --git a/configure.ac b/configure.ac index 73c38a72c..63509cd66 100644 --- a/configure.ac +++ b/configure.ac @@ -2391,10 +2391,11 @@ else if test -n "$GO" ; then GOVERSIONOPTION=version + go_version=$($GO $GOVERSIONOPTION | sed -e 's/go version //') AC_MSG_CHECKING([whether go version is too old]) case $go_version in - go1.[012345]*) - AC_MSG_RESULT([yes - minimum version is 1.6]) + go1.[012]*) + AC_MSG_RESULT([yes - minimum version is 1.3]) GO= GOOPT="-intgosize 32" ;; From 85edc6de99af6649ac2d95495083750e7a44dc3b Mon Sep 17 00:00:00 2001 From: Brad Kotsopoulos Date: Sun, 18 Aug 2019 23:33:11 -0400 Subject: [PATCH 1735/2031] [Java] Add support for throwing IllegalStateException --- Lib/java/javahead.swg | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index 685bba198..2e10254f3 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -5,7 +5,7 @@ * ----------------------------------------------------------------------------- */ -/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so +/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so * that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand * the macros thereby generating the correct calling convention. It is thus essential that all typemaps that * use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */ @@ -50,15 +50,16 @@ %insert(runtime) %{ /* Support for throwing Java exceptions */ typedef enum { - SWIG_JavaOutOfMemoryError = 1, - SWIG_JavaIOException, - SWIG_JavaRuntimeException, + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, SWIG_JavaIndexOutOfBoundsException, SWIG_JavaArithmeticException, SWIG_JavaIllegalArgumentException, SWIG_JavaNullPointerException, SWIG_JavaDirectorPureVirtual, - SWIG_JavaUnknownError + SWIG_JavaUnknownError, + SWIG_JavaIllegalStateException, } SWIG_JavaExceptionCodes; typedef struct { @@ -80,6 +81,7 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { SWIG_JavaIllegalStateException, "java/lang/IllegalStateException" }, { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; const SWIG_JavaExceptions_t *except_ptr = java_exceptions; From 1e8dad2084888092ea0efa9a8ec7424fced215e9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 19 Aug 2019 07:57:17 +0100 Subject: [PATCH 1736/2031] Add note to changes file about Lua tostring change --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 53c409773..20272249f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-19: sjml + [Lua] #1596 tostring output changes to show the underlying C/C++ pointer. + 2019-08-08: rokups [C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType. From 5c2e0b2c5e07a91a79daeee7424ba3a601b42da0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Aug 2019 07:12:58 +0100 Subject: [PATCH 1737/2031] Add SWIG_JavaIllegalStateException to changes file --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 20272249f..6ae17df9c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-20: bkotzz + [Java] #1616 Add SWIG_JavaIllegalStateException to support throwing + java.lang.IllegalStateException from JNI code. + 2019-08-19: sjml [Lua] #1596 tostring output changes to show the underlying C/C++ pointer. From 025269f121832f8fe46d299faf426ff37d289699 Mon Sep 17 00:00:00 2001 From: Chris Walker Date: Tue, 20 Aug 2019 02:13:50 -0600 Subject: [PATCH 1738/2031] Dev Checkpoint 201908200213 --- Source/Modules/javascript.cxx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index 68c97e641..d2b33b1b4 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -788,14 +788,6 @@ int JSEmitter::emitWrapperFunction(Node *n) { int JSEmitter::emitNativeFunction(Node *n) { String *wrapname = Getattr(n, "wrap:name"); - // ismember never seems to be the case; - // it is technically possible to add native member functions, - // just not at the moment? leaving this as an option for later; - // the code will automatically defaulting to static space - if (GetFlag(n, "ismember") != 0) - Setattr(n, "feature:extend", "1"); // member space - else - Setattr(n, "feature:extend", "0"); // static space enterFunction(n); state.function(WRAPPER_NAME, wrapname); exitFunction(n); From dfcc11042fae445d88d7ff7b4d47af9f57a70ad3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Aug 2019 18:57:35 +0100 Subject: [PATCH 1739/2031] Add %native Javascript to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 6ae17df9c..08de31868 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (in progress) =========================== +2019-08-20: TekuConcept + [Javascript] #1535 Add %native support to Javascript. + 2019-08-20: bkotzz [Java] #1616 Add SWIG_JavaIllegalStateException to support throwing java.lang.IllegalStateException from JNI code. From f4208a0a418715ce5a72b564ef5bc994d42f820b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Aug 2019 19:37:32 +0100 Subject: [PATCH 1740/2031] R html docs formatting fixes. [skip-ci] --- Doc/Manual/R.html | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 45e5541d0..373cd7ed9 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -28,7 +28,9 @@ R is a GPL'ed open source statistical and plotting environment. Information about R can be found at www.r-project.org. +

    +

    The R bindings are under active development. They have been used to 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++. @@ -113,11 +115,10 @@ cacheMetaData(1) +

    The cacheMetaData(1) will cause R to refresh its object tables. Without it, inheritance of wrapped objects may fail. - -

    -These two files can be loaded in any order +These two files can be loaded in any order.

    @@ -140,18 +141,22 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

    33.3 Precompiling large R files

    +

    In cases where the R file is large, one make save a lot of loading time by precompiling the R wrapper. This can be done by creating the file makeRData.R which contains the following +

    -
    +
     source('BigFile.R')
     save(list=ls(all=TRUE), file="BigFile.RData", compress=TRUE)
     q(save="no")
    -
    +
    +

    This will generate a compiled R file called BigFile.RData that will save a large amount of loading time. +

    @@ -192,21 +197,27 @@ of the proxy class baggage you see in other languages. R doesn't have a native enumeration type. Enumerations are represented as character strings in R, with calls to R functions that convert back and forth between integers. +

    +

    The details of enumeration names and contents are stored in hidden R environments, which are named according the the enumeration name - for example, an enumeration colour: +

    +
     enum colour { red=-1, blue, green = 10 };
     
    +

    will be initialized by the following call in R: +

    +
     defineEnumeration("_colour",
      .values=c("red" = .Call('R_swig_colour_red_get',FALSE, PACKAGE='enum_thorough'),
     "blue" = .Call('R_swig_colour_blue_get',FALSE, PACKAGE='enum_thorough'),
     "green" = .Call('R_swig_colour_green_get',FALSE, PACKAGE='enum_thorough')))
    -
     

    @@ -216,7 +227,9 @@ values for enumerations to be used. Calls to the C/C++ code require the compiled library to be loaded, so a delayedAssign is employed within defineEnumeration in order to allow the code to be easily used in R packages. +

    +

    The user typically does not need to access the enumeration lookup functions or know the name of the enumeration type used by R. Attributes containing the type information are attached by swig to @@ -224,14 +237,17 @@ functions requiring enumeration arguments or returning enumeration values, and those attributes are used to identify and access the appropriate environments and thus translate between characters and integers. +

    +

    The relevant functions, for debugging purposes, are enumToInteger and enumFromInteger. +

    +

    Anonymous enumerations are ignored by the binding generation process, leaving no way of accessing the value of anonymous enumerations from R code. -

    From 2c1ff4e8ce76b3fb01d59aa614b0ce15fe4c53a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Aug 2019 19:47:57 +0100 Subject: [PATCH 1741/2031] Add swig-4.0.1 release date --- Doc/Manual/Sections.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 2cb1d2be4..cc5f05e82 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.1 (in progress) +Last update : SWIG-4.0.1 (21 Aug 2019)

    Sections

    From 1e36f51346d95f8b9848e682c2eb986e9cb9b4f4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Aug 2019 22:34:03 +0100 Subject: [PATCH 1742/2031] Add swig-4.0.1 summary to release notes --- ANNOUNCE | 2 +- CHANGES.current | 2 +- README | 2 +- RELEASENOTES | 10 ++++++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b83921cc4..495f101c7 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 4.0.1 (in progress) *** +*** ANNOUNCE: SWIG 4.0.1 (21 Aug 2019) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index 08de31868..ab69e0916 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,7 +4,7 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.1 (in progress) +Version 4.0.1 (21 Aug 2019) =========================== 2019-08-20: TekuConcept diff --git a/README b/README index 165098cb5..6d118335f 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.1 (in progress) +Version: 4.0.1 (21 Aug 2019) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index 3fe78f2e2..8633dadef 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -7,6 +7,16 @@ Release Notes Detailed release notes are available with the release and are also published on the SWIG web site at http://swig.org/release.html. +SWIG-4.0.1 summary: +- SWIG now cleans up on error by removing all generated files. +- Add Python 3.8 support. +- Python Sphinx compatibility added for Doxygen comments. +- Some minor regressions introduced in 4.0.0 were fixed. +- Fix some C++17 compatibility problems in Python and Ruby generated + code. +- Minor improvements/fixes for C#, Java, Javascript, Lua, MzScheme, + Ocaml, Octave and Python. + SWIG-4.0.0 summary: - Support for Doxygen documentation comments which are parsed and converted into JavaDoc or PyDoc comments. From 08ff05c14ceb9e20677a6619ed1f4ac8845204f4 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Wed, 21 Aug 2019 08:43:12 -0500 Subject: [PATCH 1743/2031] Add doxygen_code_blocks_runme.java The code blocks test is intended to test code block language options and python doctest translation that is supported for Python, but the doxygen constructs are still recognized when translating comments for Java (it is just that the code language option is not used). --- .../java/doxygen_code_blocks_runme.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Examples/test-suite/java/doxygen_code_blocks_runme.java diff --git a/Examples/test-suite/java/doxygen_code_blocks_runme.java b/Examples/test-suite/java/doxygen_code_blocks_runme.java new file mode 100644 index 000000000..ff0a16eab --- /dev/null +++ b/Examples/test-suite/java/doxygen_code_blocks_runme.java @@ -0,0 +1,83 @@ + +import doxygen_code_blocks.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_code_blocks_runme { + static { + try { + System.loadLibrary("doxygen_code_blocks"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + CommentParser parser = new CommentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_code_blocks runtime test", + "CommentParser", + new String[]{"-quiet", "doxygen_code_blocks"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("doxygen_code_blocks.doxygen_code_blocks.function()", + " Test for code blocks\n \n" + + " \n \n" + + " {@code \n" + + " simple code block \n" + + " }\n \n" + + " \n \n" + + " More advanced usage with C++ characters:\n \n" + + " {@code \n" + + " std::vector first; // empty vector of ints \n" + + " std::vector second (4,100); // four ints with value 100 \n" + + " std::vector third (second.begin(),second.end()); // iterating through second \n" + + " std::vector fourth (third); // a copy of third \n" + + " // the iterator constructor can also be used to construct from arrays: \n" + + " int myints[] = {16,2,77,29}; \n" + + " std::vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); \n" + + " \n" + + " std::cout << \"The contents of fifth are:\"; \n" + + " for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) \n" + + " std::cout << \' \' << *it; \n" + + " std::cout << \'\\n\'; \n" + + " }\n \n" + + " \n \n" + + " A code block for C:\n \n" + + " {@code \n" + + " printf(\"hello world\"); \n" + + " }\n \n" + + " \n \n" + + " A code block for Java:\n \n" + + " {@code \n" + + " public class HelloWorld { \n" + + " public static void main(String[] args) { \n" + + " // Prints \"Hello, World\" to the terminal window. \n" + + " System.out.println(\"Hello, World\"); \n" + + " } \n" + + " } \n" + + " }\n \n" + + " \n \n" + + " A code block for python:\n \n" + + " {@code \n" + + " print(\'hello world\') \n" + + " }\n \n" + + " \n \n" + + " A python doctest example:\n \n" + + " {@code \n" + + " >>> 1 + 1 \n" + + " 2 \n" + + " } \n" + + " \n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} From c48d11ac17f04038b617cc44c2a44c0d09041267 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 22 Aug 2019 06:55:39 +0100 Subject: [PATCH 1744/2031] Bump version to 4.0.2 --- ANNOUNCE | 8 +-- CHANGES | 139 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 138 +------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 147 insertions(+), 144 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 495f101c7..6709f1182 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 4.0.1 (21 Aug 2019) *** +*** ANNOUNCE: SWIG 4.0.2 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-4.0.1, the latest SWIG release. +We're pleased to announce SWIG-4.0.2, the latest SWIG release. What is SWIG? ============= @@ -25,11 +25,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-4.0.1.tar.gz + http://prdownloads.sourceforge.net/swig/swig-4.0.2.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-4.0.1.zip + http://prdownloads.sourceforge.net/swig/swigwin-4.0.2.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 7fd6b6da2..fe8696760 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,145 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ +Version 4.0.1 (21 Aug 2019) +=========================== + +2019-08-20: TekuConcept + [Javascript] #1535 Add %native support to Javascript. + +2019-08-20: bkotzz + [Java] #1616 Add SWIG_JavaIllegalStateException to support throwing + java.lang.IllegalStateException from JNI code. + +2019-08-19: sjml + [Lua] #1596 tostring output changes to show the underlying C/C++ pointer. + +2019-08-08: rokups + [C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType. + +2019-08-07: wsfulton + [Python] Fix method overloading of methods that take STL containers of different + types. The following usage (using std::vector) would fail when using -builtin: + + %include + %include + + %inline %{ + struct X {}; + %} + + %template(VectorX) std::vector; + %template(VectorInt) std::vector; + + %inline %{ + using namespace std; + string VectorOverload(vector v); + string VectorOverload(vector v); + %} + + The following would incorrectly fail: + + s = VectorOverload([1, 2, 3]) + + With: + + Traceback (most recent call last): + File "runme3.py", line 20, in + ret = VectorOverload([1, 2, 3]) + TypeError: Wrong number or type of arguments for overloaded function 'VectorOverload'. + Possible C/C++ prototypes are: + VectorOverload(std::vector< Number,std::allocator< Number > >) + VectorOverload(std::vector< int,std::allocator< int > >) + + The problem was due to some error handling that was not cleared during typehecking. + In this case an error was not cleared when the elements in the list failed the + typecheck for converting to X. Only occurs in Python 3+. + + In some combinations of overloaded methods, the following type of error message would + occur: + + RuntimeError: in sequence element 0 + + The above exception was the direct cause of the following exception: + + Traceback (most recent call last): + File "runme3.py", line 23, in + check(VectorOverload(v), "vector") + SystemError: returned a result with an error set + +2019-08-01: wsfulton + #1602 Fix regression in 4.0.0 where a template function containing a parameter + with the same name as the function name led to the parameter name used in the + target language being incorrectly modified. + +2019-07-29: wsfulton + Remove all generated files on error. Previously generated files were not removed, + potentially breaking Makefiles using file dependencies, especially when -Werror + (warnings as errors) was used. + +2019-07-23: smithx + [C#] #1530 #1532 Fix marshalling of std::wstring to C#. + +2019-07-18: gicmo + [Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack. + +2019-07-18: cher-nov + [Python] #1573 Generated Python code uses consistent string quoting style - double + quotes. + +2019-07-16: geefr + [C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall + as 1-byte. + +2019-07-12: vadz + [C#, Java] #1568 #1583 Fix std::set<> typemaps for primitive types. + +2019-07-12: vadz + #1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with + trailing comma. + +2019-07-11: mcfarljm + #1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like + \code. + +2019-07-09: IsaacPascual + [C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros + in swiginterface.i when wrapping nested C++ classes. + +2019-07-05: wsfulton + [Python] #1547 Whitespace fixes in Doxygen translated comments into pydoc comments + for Sphinx compatibility. + +2019-06-28: wsfulton + [MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the + argout typemap when two or more arguments were present. + +2019-06-24: wsfulton + [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be + C++17 compliant as it uses std::unexpected_handler which was removed in C++17. + This class was intended for director exception handling but was never used by + SWIG and was never documented. + + *** POTENTIAL INCOMPATIBILITY *** + +2019-06-06: bkotzz + [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes + a native Java array as input. + +2019-06-03: olly + [Python] Fix regression in implicit_conv handling of tuples, + introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre + Duret-Lutz. + +2019-05-24: wsfulton + [Octave] Fix detection of Octave on MacOS. + +2019-05-24: opoplawski + [Octave] #1522 Adapt OCTAVE_LDFLAGS for Octave 5.1. + +2019-05-22: ferdynator + [PHP] #1528 Don't add a closing '?>' PHP tag to generated files. + PSR-2 says it MUST be omitted for files containing only PHP. Version 4.0.0 (27 Apr 2019) =========================== diff --git a/CHANGES.current b/CHANGES.current index ab69e0916..3e650918b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,142 +4,6 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.1 (21 Aug 2019) +Version 4.0.2 (in progress) =========================== -2019-08-20: TekuConcept - [Javascript] #1535 Add %native support to Javascript. - -2019-08-20: bkotzz - [Java] #1616 Add SWIG_JavaIllegalStateException to support throwing - java.lang.IllegalStateException from JNI code. - -2019-08-19: sjml - [Lua] #1596 tostring output changes to show the underlying C/C++ pointer. - -2019-08-08: rokups - [C#, Java] #1601 Fix invalid code generated for "%constant enum EnumType. - -2019-08-07: wsfulton - [Python] Fix method overloading of methods that take STL containers of different - types. The following usage (using std::vector) would fail when using -builtin: - - %include - %include - - %inline %{ - struct X {}; - %} - - %template(VectorX) std::vector; - %template(VectorInt) std::vector; - - %inline %{ - using namespace std; - string VectorOverload(vector v); - string VectorOverload(vector v); - %} - - The following would incorrectly fail: - - s = VectorOverload([1, 2, 3]) - - With: - - Traceback (most recent call last): - File "runme3.py", line 20, in - ret = VectorOverload([1, 2, 3]) - TypeError: Wrong number or type of arguments for overloaded function 'VectorOverload'. - Possible C/C++ prototypes are: - VectorOverload(std::vector< Number,std::allocator< Number > >) - VectorOverload(std::vector< int,std::allocator< int > >) - - The problem was due to some error handling that was not cleared during typehecking. - In this case an error was not cleared when the elements in the list failed the - typecheck for converting to X. Only occurs in Python 3+. - - In some combinations of overloaded methods, the following type of error message would - occur: - - RuntimeError: in sequence element 0 - - The above exception was the direct cause of the following exception: - - Traceback (most recent call last): - File "runme3.py", line 23, in - check(VectorOverload(v), "vector") - SystemError: returned a result with an error set - -2019-08-01: wsfulton - #1602 Fix regression in 4.0.0 where a template function containing a parameter - with the same name as the function name led to the parameter name used in the - target language being incorrectly modified. - -2019-07-29: wsfulton - Remove all generated files on error. Previously generated files were not removed, - potentially breaking Makefiles using file dependencies, especially when -Werror - (warnings as errors) was used. - -2019-07-23: smithx - [C#] #1530 #1532 Fix marshalling of std::wstring to C#. - -2019-07-18: gicmo - [Python] #1587 Python 3.8 support - remove use of deprecated PyObject_GC_UnTrack. - -2019-07-18: cher-nov - [Python] #1573 Generated Python code uses consistent string quoting style - double - quotes. - -2019-07-16: geefr - [C#] #616 #1576 Fix C# bool INPUT[], bool OUTPUT[], bool INOUT[] typemaps to marshall - as 1-byte. - -2019-07-12: vadz - [C#, Java] #1568 #1583 Fix std::set<> typemaps for primitive types. - -2019-07-12: vadz - #1566 #1584 Regression in 4.0.0 - fix missing value for first item of enums with - trailing comma. - -2019-07-11: mcfarljm - #1548 #1578 Fix segfault in Doxygen parser parsing empty lines in some commands like - \code. - -2019-07-09: IsaacPascual - [C#, Java] #1570 Fix name of generated C#/Java classes for %interface macros - in swiginterface.i when wrapping nested C++ classes. - -2019-07-05: wsfulton - [Python] #1547 Whitespace fixes in Doxygen translated comments into pydoc comments - for Sphinx compatibility. - -2019-06-28: wsfulton - [MzScheme, OCaml] #1559 $arg and $input were incorrectly substituted in the - argout typemap when two or more arguments were present. - -2019-06-24: wsfulton - [Python, Ruby] #1538 Remove the UnknownExceptionHandler class in order to be - C++17 compliant as it uses std::unexpected_handler which was removed in C++17. - This class was intended for director exception handling but was never used by - SWIG and was never documented. - - *** POTENTIAL INCOMPATIBILITY *** - -2019-06-06: bkotzz - [Java] #1552 Improve performance in Java std::vector constructor wrapper that takes - a native Java array as input. - -2019-06-03: olly - [Python] Fix regression in implicit_conv handling of tuples, - introduced in SWIG 4.0.0. Fixes #1553, reported by Alexandre - Duret-Lutz. - -2019-05-24: wsfulton - [Octave] Fix detection of Octave on MacOS. - -2019-05-24: opoplawski - [Octave] #1522 Adapt OCTAVE_LDFLAGS for Octave 5.1. - -2019-05-22: ferdynator - [PHP] #1528 Don't add a closing '?>' PHP tag to generated files. - PSR-2 says it MUST be omitted for files containing only PHP. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index cc5f05e82..93194595e 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.1 (21 Aug 2019) +Last update : SWIG-4.0.2 (in progress)

    Sections

    diff --git a/README b/README index 6d118335f..1a1cda664 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.1 (21 Aug 2019) +Version: 4.0.2 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index 63509cd66..ea469c24e 100644 --- a/configure.ac +++ b/configure.ac @@ -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],[4.0.1],[http://www.swig.org]) +AC_INIT([swig],[4.0.2],[http://www.swig.org]) AC_PREREQ(2.60) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) From 9fc57f47bdf908c6f9546548acef8052c5a1bb89 Mon Sep 17 00:00:00 2001 From: Daniel Emminizer Date: Thu, 29 Aug 2019 09:10:41 -0400 Subject: [PATCH 1745/2031] Fix error in generated code for Python in MSVC 2019. Visual Studio 2019 release builds: error C4703: potentially uninitialized local pointer variable 'p' used --- Lib/python/std_map.i | 2 +- Lib/python/std_multimap.i | 2 +- Lib/python/std_pair.i | 4 ++-- Lib/python/std_unordered_map.i | 2 +- Lib/python/std_unordered_multimap.i | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index 8ae483cef..e0b7d69dc 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -101,7 +101,7 @@ %#endif res = traits_asptr_stdseq >::asptr(items, val); } else { - map_type *p; + map_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index f78a5277c..bbffb6bcd 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -29,7 +29,7 @@ %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { - multimap_type *p; + multimap_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i index 172572bff..cf463cb8f 100644 --- a/Lib/python/std_pair.i +++ b/Lib/python/std_pair.i @@ -47,7 +47,7 @@ res = get_pair(first, second, val); } } else { - value_type *p; + value_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = *p; @@ -104,7 +104,7 @@ res = get_pair(first, second, val); } } else { - value_type *p; + value_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; diff --git a/Lib/python/std_unordered_map.i b/Lib/python/std_unordered_map.i index 042d5b671..784be4c8f 100644 --- a/Lib/python/std_unordered_map.i +++ b/Lib/python/std_unordered_map.i @@ -87,7 +87,7 @@ %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { - unordered_map_type *p; + unordered_map_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; diff --git a/Lib/python/std_unordered_multimap.i b/Lib/python/std_unordered_multimap.i index 281140445..bc095ea48 100644 --- a/Lib/python/std_unordered_multimap.i +++ b/Lib/python/std_unordered_multimap.i @@ -36,7 +36,7 @@ %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { - unordered_multimap_type *p; + unordered_multimap_type *p = 0; swig_type_info *descriptor = swig::type_info(); res = descriptor ? SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0) : SWIG_ERROR; if (SWIG_IsOK(res) && val) *val = p; From aca44d9d3ae339c0d7355919de9b93ee27ee6c50 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Fri, 30 Aug 2019 21:23:07 +1000 Subject: [PATCH 1746/2031] Removed some remaining commented sections --- Source/Modules/r.cxx | 76 ++------------------------------------------ 1 file changed, 2 insertions(+), 74 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index e59ee54df..2ad377af1 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -36,11 +36,6 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { if(Strncmp(b, "struct ", 7) == 0) Replace(b, "struct ", "", DOH_REPLACE_FIRST); - /* Printf(stdout, " %s,base = %s\n", t, b); - for(i = 0; i < Len(els); i++) - Printf(stdout, "%d) %s, ", i, Getitem(els,i)); - Printf(stdout, "\n"); */ - for(i = 0; i < Len(els); i++) { String *el = Getitem(els, i); if(Strcmp(el, "p.") == 0 || Strncmp(el, "a(", 2) == 0) { @@ -56,13 +51,6 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { Insert(tmp, 0, retName); return tmp; - /* - if(count) - return(b); - - Delete(b); - return(NewString("")); - */ } /* -------------------------------------------------------------- @@ -285,7 +273,6 @@ protected: int generateCopyRoutines(Node *n); int DumpCode(Node *n); - //int OutputMemberReferenceMethod(String *className, int isSet, List *el, File *out); int OutputMemberReferenceMethod(String *className, int isSet, List *memberList, List *nameList, List *typeList, File *out); @@ -452,8 +439,6 @@ R::R() : R_MEMBER_SET(NewString("set")), R_MEMBER_GET(NewString("get")), processing_class_member_function(0), - // class_member_functions(0), - // class_member_set_functions(0), class_member_function_types(0), class_member_function_names(0), class_member_function_membernames(0), @@ -536,7 +521,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { SwigType *funcparams = SwigType_functionpointer_decompose(rettype); String *rtype = SwigType_str(rettype, 0); - // ParmList *parms = Getattr(n, "parms"); + // ParmList *parms = Getattr(n, "parms"); // memory leak ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n); @@ -1029,9 +1014,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) { isSet = strcmp(ptr, "_set") == 0; } - // OutputArrayMethod(className, el, out); - //OutputMemberReferenceMethod(className, isSet, el, out); - if(outputNamespaceInfo) Printf(s_namespace, "\"%s\"%s", className, i < n-1 ? "," : ""); } @@ -1123,15 +1105,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Printf(f->code, ");\n"); } - - /* Printv(f->code, tab8, - "idx = pmatch(name, names(accessorFuns))\n", - tab8, - "if(is.na(idx)) {\n", - tab8, tab4, - "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, - ": fields are \", paste(names(accessorFuns), sep = \", \")", - ")", "\n}\n", NIL); */ Printv(f->code, ";", tab8, "idx = pmatch(name, names(accessorFuns));\n", tab8, @@ -1265,7 +1238,6 @@ int R::enumDeclaration(Node *n) { Printf(enum_def_calls, "defineEnumeration(\"%s\",\n .values=c(%s))\n\n", ename, enum_values); Delete(enum_values); Delete(ename); - //Delete(symname); } return SWIG_OK; } @@ -1394,32 +1366,7 @@ int R::variableWrapper(Node *n) { void R::addAccessor(String *memberName, Wrapper *wrapper, String *name, String *methodSetGet) { -#if 0 - if(isSet < 0) { - int n = Len(name); - char *ptr = Char(name); - if (n>4) { - isSet = Strcmp(NewString(&ptr[n-4]), "_set") == 0; - } - } -/// RJB - List *l = isSet ? class_member_set_functions : class_member_functions; - if(!l) { - l = NewList(); - if(isSet) - class_member_set_functions = l; - else - class_member_functions = l; - } - - Append(l, memberName); - Append(l, name); - - String *tmp = NewString(""); - Wrapper_print(wrapper, tmp); - Append(l, tmp); -#endif if (!class_member_function_names) { class_member_function_names = NewList(); class_member_function_membernames = NewList(); @@ -1463,11 +1410,6 @@ List * R::Swig_overload_rank(Node *n, c = Getattr(c,"sym:nextSibling"); continue; } - /* if (SmartPointer && Getattr(c,"cplus:staticbase")) { - c = Getattr(c,"sym:nextSibling"); - continue; - } */ - /* Make a list of all the declarations (methods) that are overloaded with * this one particular method name */ @@ -1927,11 +1869,6 @@ int R::functionWrapper(Node *n) { if(!isVoidReturnType) addCopyParam = addCopyParameter(rtype); - - // Can we get the nodeType() of the type node! and see if it is a struct. - // int addCopyParam = SwigType_isclass(rtype); - - // if(addCopyParam) if (debugMode) Printf(stdout, "Adding a .copy argument to %s for %s = %s\n", iname, type, addCopyParam ? "yes" : "no"); @@ -2569,16 +2506,7 @@ int R::classDeclaration(Node *n) { Delete(class_other_functionnames); Delete(class_other_functiontypes); } -#endif - - // if(class_member_functions) { - // Delete(class_member_functions); - // class_member_functions = NULL; - // } - // if(class_member_set_functions) { - // Delete(class_member_set_functions); - // class_member_set_functions = NULL; - // } +#endif if (class_member_function_types) { Delete(class_member_function_types); From bb65049517f68a60c266cb05418c17cce21c636c Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Fri, 30 Aug 2019 22:31:46 +1000 Subject: [PATCH 1747/2031] ENH R accessor processing test Test of accessors generated via the new internal structures. This test confirms that the old incorrect accessors are not present and runs the correct version, confirming the values. --- Examples/test-suite/r/abstract_access_runme.R | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Examples/test-suite/r/abstract_access_runme.R diff --git a/Examples/test-suite/r/abstract_access_runme.R b/Examples/test-suite/r/abstract_access_runme.R new file mode 100644 index 000000000..1e73dcabf --- /dev/null +++ b/Examples/test-suite/r/abstract_access_runme.R @@ -0,0 +1,50 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("abstract_access", .Platform$dynlib.ext, sep="")) +source("abstract_access.R") + +dd <- D() +unittest(1, dd$z()) +unittest(1, dd$do_x()) + +## Original version allowed dd$z <- 2 +tryCatch({ + dd$z <- 2 +}, error = function(e) { + message("Correct - no dollar assignment method found") +} +) + +tryCatch({ + dd[["z"]] <- 2 +}, error = function(e) { + message("Correct - no dollar assignment method found") +} +) + +## The methods are attached to the parent class - see if we can get +## them +tryCatch({ + m1 <- getMethod('$', "_p_A") +}, error = function(e) { + stop("No $ method found - there should be one") +} +) + +## These methods should not be present +## They correspond to the tests that are expected +## to fail above. +tryCatch({ + m2 <- getMethod('$<-', "_p_A") +}, error = function(e) { + message("Correct - no dollar assignment method found") +} +) + +tryCatch({ + m3 <- getMethod('[[<-', "_p_A") +}, error = function(e) { + message("Correct - no list assignment method found") +} +) From 25a9e3552cb8a8e63d8f1d3e665aef718b824453 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Sat, 31 Aug 2019 17:02:46 +1000 Subject: [PATCH 1748/2031] ENH R abstract_access_runme Improved the exception handling components of test. --- Examples/test-suite/r/abstract_access_runme.R | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/r/abstract_access_runme.R b/Examples/test-suite/r/abstract_access_runme.R index 1e73dcabf..f6fb4099d 100644 --- a/Examples/test-suite/r/abstract_access_runme.R +++ b/Examples/test-suite/r/abstract_access_runme.R @@ -11,15 +11,27 @@ unittest(1, dd$do_x()) ## Original version allowed dd$z <- 2 tryCatch({ dd$z <- 2 + # force an error if the previous line doesn't raise an exception + stop("Test Failure A") }, error = function(e) { + if (e$message == "Test Failure A") { + # Raise the error again to cause a failed test + stop(e) + } message("Correct - no dollar assignment method found") } ) tryCatch({ dd[["z"]] <- 2 + # force an error if the previous line doesn't raise an exception + stop("Test Failure B") }, error = function(e) { - message("Correct - no dollar assignment method found") + if (e$message == "Test Failure B") { + # Raise the error again to cause a failed test + stop(e) + } + message("Correct - no dollar assignment method found") } ) @@ -37,14 +49,26 @@ tryCatch({ ## to fail above. tryCatch({ m2 <- getMethod('$<-', "_p_A") + # force an error if the previous line doesn't raise an exception + stop("Test Failure C") }, error = function(e) { - message("Correct - no dollar assignment method found") + if (e$message == "Test Failure C") { + # Raise the error again to cause a failed test + stop(e) + } + message("Correct - no dollar assignment method found") } ) tryCatch({ m3 <- getMethod('[[<-', "_p_A") + # force an error if the previous line doesn't raise an exception + stop("Test Failure D") }, error = function(e) { - message("Correct - no list assignment method found") + if (e$message == "Test Failure D") { + # Raise the error again to cause a failed test + stop(e) + } + message("Correct - no list assignment method found") } ) From 719eea090dd48e8866efc4d32b604ff35c7e0263 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Sep 2019 07:37:03 +0100 Subject: [PATCH 1749/2031] Improve error handling calling PyObject_SetAttr Less obscure error when setting 'this' on the SWIG proxy object attempting to override __setattr__ in C++ (swig-user mailing list query 19 Aug 2019). --- Lib/python/pycontainer.swg | 3 +-- Lib/python/pyrun.swg | 14 ++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index fef4e9b3b..a7cc605ce 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -69,8 +69,7 @@ namespace swig { static bool back_reference(PyObject* child, PyObject* owner) { SwigPyObject* swigThis = SWIG_Python_GetSwigThis(child); if (swigThis && (swigThis->own & SWIG_POINTER_OWN) != SWIG_POINTER_OWN) { - PyObject_SetAttr(child, container_owner_attribute(), owner); - return true; + return PyObject_SetAttr(child, container_owner_attribute(), owner) != -1; } return false; } diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 445a1e324..82859b887 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1183,8 +1183,10 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) } } #else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } #endif } } else { @@ -1196,8 +1198,12 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) inst = ((PyTypeObject *)data->newargs)->tp_new((PyTypeObject *)data->newargs, empty_args, empty_kwargs); Py_DECREF(empty_kwargs); if (inst) { - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + if (PyObject_SetAttr(inst, SWIG_This(), swig_this) == -1) { + Py_DECREF(inst); + inst = 0; + } else { + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; + } } } Py_DECREF(empty_args); From 1ac371369efecc0e9ea52e65e1201eb28c23f561 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 24 Aug 2019 10:23:02 -0500 Subject: [PATCH 1750/2031] Reformat tag lists in doxygen documentation Reformat the tables of unsupported and ignored tags. Previous table format was not maintainable. Changing to use multi-column lists, so that entries can be easily sorted and updated. The displayed order is now by row instead of by column, which is decidedly easier to read. Other than removing duplicates, no change to content. --- Doc/Manual/Doxygen.html | 631 ++++++++++++++++------------------------ Doc/Manual/style.css | 4 + 2 files changed, 257 insertions(+), 378 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index ff025c047..b51996fb6 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -829,155 +829,107 @@ These are suppressed with their content just printed out (if the tag has any sense, typically text content). Here is the list of these tags:

    +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Unsupported Doxygen tags
    \addindex\addtogroup\anchor\attention
    \brief\bug\callgraph\callergraph
    \class\copybrief\copydetails\copydoc
    \date\def\defgroup\details
    \dir\dontinclude\dot\dotfile
    \enddot\endhtmlonly\endinternal\endlatexonly
    \endmanonly\endmsc\endrtfonly\endxmlonly
    \enum\example\extends
    \file\fn\headerfile\hideinitializer
    \htmlinclude\htmlonly\implements\include
    \includelineno\ingroup\internal\invariant
    \interface\latexonly\line\mainpage
    \manonly\memberof\msc\mscfile
    \name\namespace\nosubgrouping\package
    \page\paragraph\post\pre
    \private\privatesection\property\protected
    \protectedsection\protocol\public\publicsection
    \ref\related\relates\relatedalso
    \relatesalso\retval\rtfonly\section
    \short\showinitializer\skip\skipline
    \snippet\struct\subpage\subsection
    \subsubsection\tableofcontents\test\typedef
    \union\until\var\verbinclude
    \weakgroup\xmlonly\xrefitem\category
    + Unsupported Doxygen tags + +
      +
    • \addindex
    • +
    • \addtogroup
    • +
    • \anchor
    • +
    • \attention
    • +
    • \brief
    • +
    • \bug
    • +
    • \callergraph
    • +
    • \callgraph
    • +
    • \category
    • +
    • \class
    • +
    • \copybrief
    • +
    • \copydetails
    • +
    • \copydoc
    • +
    • \date
    • +
    • \def
    • +
    • \defgroup
    • +
    • \details
    • +
    • \dir
    • +
    • \dontinclude
    • +
    • \dot
    • +
    • \dotfile
    • +
    • \enddot
    • +
    • \endhtmlonly
    • +
    • \endinternal
    • +
    • \endlatexonly
    • +
    • \endmanonly
    • +
    • \endmsc
    • +
    • \endrtfonly
    • +
    • \endxmlonly
    • +
    • \enum
    • +
    • \example
    • +
    • \extends
    • +
    • \file
    • +
    • \fn
    • +
    • \headerfile
    • +
    • \hideinitializer
    • +
    • \htmlinclude
    • +
    • \htmlonly
    • +
    • \implements
    • +
    • \include
    • +
    • \includelineno
    • +
    • \ingroup
    • +
    • \interface
    • +
    • \internal
    • +
    • \invariant
    • +
    • \latexonly
    • +
    • \line
    • +
    • \mainpage
    • +
    • \manonly
    • +
    • \memberof
    • +
    • \msc
    • +
    • \mscfile
    • +
    • \name
    • +
    • \namespace
    • +
    • \nosubgrouping
    • +
    • \package
    • +
    • \page
    • +
    • \paragraph
    • +
    • \post
    • +
    • \pre
    • +
    • \private
    • +
    • \privatesection
    • +
    • \property
    • +
    • \protected
    • +
    • \protectedsection
    • +
    • \protocol
    • +
    • \public
    • +
    • \publicsection
    • +
    • \ref
    • +
    • \related
    • +
    • \relatedalso
    • +
    • \relates
    • +
    • \relatesalso
    • +
    • \retval
    • +
    • \rtfonly
    • +
    • \section
    • +
    • \short
    • +
    • \showinitializer
    • +
    • \skip
    • +
    • \skipline
    • +
    • \snippet
    • +
    • \struct
    • +
    • \subpage
    • +
    • \subsection
    • +
    • \subsubsection
    • +
    • \tableofcontents
    • +
    • \test
    • +
    • \typedef
    • +
    • \union
    • +
    • \until
    • +
    • \var
    • +
    • \verbinclude
    • +
    • \weakgroup
    • +
    • \xmlonly
    • +
    • \xrefitem
    • +

    @@ -987,68 +939,47 @@ comment, the whole comment block is ignored:

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Ignored Doxygen tags
    \addtogroup\callgraph\callergraph\category
    \class\def\defgroup\dir
    \enum\example\file\fn
    \headerfile\hideinitializer\interface\internal
    \mainpage\name\namespace\nosubgrouping
    \overload\package\page\property
    \protocol\relates\relatesalso\showinitializer
    \struct\name\namespace\nosubgrouping
    \typedef\union\var\weakgroup
    +
    + Ignored Doxygen tags + +
      +
    • \addtogroup
    • +
    • \callergraph
    • +
    • \callgraph
    • +
    • \category
    • +
    • \class
    • +
    • \def
    • +
    • \defgroup
    • +
    • \dir
    • +
    • \enum
    • +
    • \example
    • +
    • \file
    • +
    • \fn
    • +
    • \headerfile
    • +
    • \hideinitializer
    • +
    • \interface
    • +
    • \internal
    • +
    • \mainpage
    • +
    • \name
    • +
    • \namespace
    • +
    • \nosubgrouping
    • +
    • \overload
    • +
    • \package
    • +
    • \page
    • +
    • \property
    • +
    • \protocol
    • +
    • \relates
    • +
    • \relatesalso
    • +
    • \showinitializer
    • +
    • \struct
    • +
    • \typedef
    • +
    • \union
    • +
    • \var
    • +
    • \weakgroup
    • +
    + @@ -1458,177 +1389,121 @@ are suppressed with their content just printed out (if it has any sense, typically text content). Here is the list of these tags:

    +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Unsupported Doxygen tags
    \addindex\addtogroup\anchor\attention
    \brief\bug\callgraph\callergraph
    \class\copybrief\copydetails\copydoc
    \date\def\defgroup\details
    \dir\dontinclude\dot\dotfile
    \code\endcode\endverbatim\endlink
    \enddot\endhtmlonly\endinternal\endlatexonly
    \endmanonly\endmsc\endrtfonly\endxmlonly
    \enum\example\extends\f$
    \f[\f]\f{\f}
    \file\fn\headerfile\hideinitializer
    \htmlinclude\htmlonly\implements\include
    \image\link\verbatim\p
    \includelineno\ingroup\internal\invariant
    \interface\latexonly\line\mainpage
    \manonly\memberof\msc\mscfile
    \name\namespace\nosubgrouping\package
    \page\paragraph\post\pre
    \private\privatesection\property\protected
    \protectedsection\protocol\public\publicsection
    \ref\related\relates\relatedalso
    \relatesalso\retval\rtfonly\section
    \short\showinitializer\skip\skipline
    \snippet\struct\subpage\subsection
    \subsubsection\tableofcontents\test\typedef
    \union\until\var\verbinclude
    \weakgroup\xmlonly\xrefitem\category
    \c
    + Unsupported Python Doxygen tags + +
      +
    • \addindex
    • +
    • \addtogroup
    • +
    • \anchor
    • +
    • \attention
    • +
    • \brief
    • +
    • \bug
    • +
    • \c
    • +
    • \callergraph
    • +
    • \callgraph
    • +
    • \category
    • +
    • \class
    • +
    • \code
    • +
    • \copybrief
    • +
    • \copydetails
    • +
    • \copydoc
    • +
    • \date
    • +
    • \def
    • +
    • \defgroup
    • +
    • \details
    • +
    • \dir
    • +
    • \dontinclude
    • +
    • \dot
    • +
    • \dotfile
    • +
    • \endcode
    • +
    • \enddot
    • +
    • \endhtmlonly
    • +
    • \endinternal
    • +
    • \endlatexonly
    • +
    • \endlink
    • +
    • \endmanonly
    • +
    • \endmsc
    • +
    • \endrtfonly
    • +
    • \endverbatim
    • +
    • \endxmlonly
    • +
    • \enum
    • +
    • \example
    • +
    • \extends
    • +
    • \f$
    • +
    • \f[
    • +
    • \f]
    • +
    • \file
    • +
    • \fn
    • +
    • \f{
    • +
    • \f}
    • +
    • \headerfile
    • +
    • \hideinitializer
    • +
    • \htmlinclude
    • +
    • \htmlonly
    • +
    • \image
    • +
    • \implements
    • +
    • \include
    • +
    • \includelineno
    • +
    • \ingroup
    • +
    • \interface
    • +
    • \internal
    • +
    • \invariant
    • +
    • \latexonly
    • +
    • \line
    • +
    • \link
    • +
    • \mainpage
    • +
    • \manonly
    • +
    • \memberof
    • +
    • \msc
    • +
    • \mscfile
    • +
    • \name
    • +
    • \namespace
    • +
    • \nosubgrouping
    • +
    • \p
    • +
    • \package
    • +
    • \page
    • +
    • \paragraph
    • +
    • \post
    • +
    • \pre
    • +
    • \private
    • +
    • \privatesection
    • +
    • \property
    • +
    • \protected
    • +
    • \protectedsection
    • +
    • \protocol
    • +
    • \public
    • +
    • \publicsection
    • +
    • \ref
    • +
    • \related
    • +
    • \relatedalso
    • +
    • \relates
    • +
    • \relatesalso
    • +
    • \retval
    • +
    • \rtfonly
    • +
    • \section
    • +
    • \short
    • +
    • \showinitializer
    • +
    • \skip
    • +
    • \skipline
    • +
    • \snippet
    • +
    • \struct
    • +
    • \subpage
    • +
    • \subsection
    • +
    • \subsubsection
    • +
    • \tableofcontents
    • +
    • \test
    • +
    • \typedef
    • +
    • \union
    • +
    • \until
    • +
    • \var
    • +
    • \verbatim
    • +
    • \verbinclude
    • +
    • \weakgroup
    • +
    • \xmlonly
    • +
    • \xrefitem
    • +

    17.4.4 Further details

    diff --git a/Doc/Manual/style.css b/Doc/Manual/style.css index 45e51e35b..ffadb87e2 100644 --- a/Doc/Manual/style.css +++ b/Doc/Manual/style.css @@ -65,6 +65,10 @@ div.diagram { font-family: "Courier New", Courier, "Courier 10 Pitch", monospace; } +div.diagram li { + margin-left: 0; +} + ul li p { margin-left: 0; margin-right: 0; From 4ebc3e05ad21cb7163260e46d04e631609737749 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 24 Aug 2019 10:29:11 -0500 Subject: [PATCH 1751/2031] Minor formatting updates to doxygen docs --- Doc/Manual/Doxygen.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index b51996fb6..d04140c53 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -117,14 +117,15 @@ Documenting the code). Here they are:

    -Also any of the above with '<' added after comment-starting symbol, -like /**<, /*!<, ///<, or //!< will be +Also any of the above with '<' added after comment-starting symbol, +like /**<, /*!<, ///<, or //!< will be treated as a post-comment and will be assigned to the code before the comment. -Any number of '*' or '/' within a Doxygen comment is considered to be a -separator and is not included in the final comment, so you may safely use -comments like /*********/ or //////////. +Any number of '*' or '/' within a Doxygen comment is +considered to be a separator and is not included in the final comment, +so you may safely use comments like /*********/ +or //////////.

    From c11172587c0126a3804fb1f2e8ddd8c014a943c7 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 24 Aug 2019 11:52:22 -0500 Subject: [PATCH 1752/2031] Fix doxygen handling of \em tag for python In doxygen, \em is used for italics, so it should be wrapped in "*". --- Examples/test-suite/python/doxygen_translate_all_tags_runme.py | 2 +- Source/Doxygen/pydoc.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 82ea375fd..34a3f7e48 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -82,7 +82,7 @@ r"""Comment for **func03()**. *italicword* -emphazedWord +*emphazedWord* diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 5216553dc..f9d833b5e 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -261,7 +261,7 @@ void PyDocConverter::fillStaticTables() { tagHandlers["date"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["deprecated"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["details"] = make_handler(&PyDocConverter::handleParagraph); - tagHandlers["em"] = make_handler(&PyDocConverter::handleParagraph, " "); + tagHandlers["em"] = make_handler(&PyDocConverter::handleTagWrap, "*"); tagHandlers["example"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["exception"] = tagHandlers["throw"] = tagHandlers["throws"] = make_handler(&PyDocConverter::handleTagException); tagHandlers["htmlonly"] = make_handler(&PyDocConverter::handleParagraph); From f8ed9d71a76db33dfd341e7749bbe958dfd276ec Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 24 Aug 2019 12:34:41 -0500 Subject: [PATCH 1753/2031] Fix doxygen translation of \p command for python Doxygen writes this using typewriter font, so wrap in `` for python --- Examples/test-suite/python/doxygen_translate_all_tags_runme.py | 2 +- Examples/test-suite/python/doxygen_translate_runme.py | 2 +- Source/Doxygen/pydoc.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 34a3f7e48..2b5b3b810 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -196,7 +196,7 @@ is the note! This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. -someword +``someword`` diff --git a/Examples/test-suite/python/doxygen_translate_runme.py b/Examples/test-suite/python/doxygen_translate_runme.py index d698ba873..38dca2ef9 100644 --- a/Examples/test-suite/python/doxygen_translate_runme.py +++ b/Examples/test-suite/python/doxygen_translate_runme.py @@ -80,7 +80,7 @@ is the note! This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. -someword +``someword`` diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index f9d833b5e..f2031f481 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -270,7 +270,7 @@ void PyDocConverter::fillStaticTables() { tagHandlers["link"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["manonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["note"] = make_handler(&PyDocConverter::handleParagraph); - tagHandlers["p"] = make_handler(&PyDocConverter::handleParagraph); + tagHandlers["p"] = make_handler(&PyDocConverter::handleTagWrap, "``"); tagHandlers["partofdescription"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["rtfonly"] = make_handler(&PyDocConverter::handleParagraph); tagHandlers["remark"] = make_handler(&PyDocConverter::handleParagraph); From ae709933805236a8bbf2cba82ed984d92c82ee9c Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 24 Aug 2019 18:12:01 -0500 Subject: [PATCH 1754/2031] Update documentation for doxygen tags Updates to supported/unsupported doxygen tags for both Java and Python. Document new support for \code and \param options. Also update documentation of various other tags as well as the list of unsupported tags for python. --- Doc/Manual/Doxygen.html | 93 ++++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 29 deletions(-) diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index d04140c53..93e1153d5 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -607,6 +607,10 @@ Here is the list of all Doxygen tags and the description of how they are transla translated to {@code ...} +\code{<ext>} +translated to {@code ...}; code language extension is ignored + + \cond translated to 'Conditional comment: <condition>' @@ -684,7 +688,7 @@ Here is the list of all Doxygen tags and the description of how they are transla \n -replaced with new line char +replaced with newline char \note @@ -707,6 +711,10 @@ Here is the list of all Doxygen tags and the description of how they are transla translated to @param +\param[<dir>] +translated to @param; parameter direction ('in'; 'out'; or 'in,out') is ignored + + \remark replaced with 'Remarks:' @@ -1178,11 +1186,11 @@ Here is the list of all Doxygen tags and the description of how they are transla \a -wrapped with '_' +wrapped with '*' \arg -prepended with ' --' +prepended with '* ' \author @@ -1190,17 +1198,28 @@ Here is the list of all Doxygen tags and the description of how they are transla \authors -prints 'Author:' +prints 'Authors:' \b -wrapped with '__' +wrapped with '**' + +\c +wrapped with '``' \cite wrapped with single quotes +\code +replaced with '.. code-block:: c++' + + +\code{<ext>} +replaced with '.. code-block:: <lang>', where the following doxygen code languages are recognized: .c -> C, .py -> python, .java > java + + \cond translated to 'Conditional comment: <condition>' @@ -1214,7 +1233,7 @@ Here is the list of all Doxygen tags and the description of how they are transla \e -wrapped with '_' +wrapped with '*' \else @@ -1226,7 +1245,7 @@ Here is the list of all Doxygen tags and the description of how they are transla \em -wrapped with '_' +wrapped with '*' \endcond @@ -1237,8 +1256,24 @@ Here is the list of all Doxygen tags and the description of how they are transla replaced with '}' +\example +replaced with 'Example:' + + \exception -replaced with 'Throws:' +replaced with ':raises:' + + +\f$ +rendered using ':math:``' + + +\f[ +rendered using '.. math::' + + +\f{ +rendered using '.. math::' \if @@ -1250,11 +1285,11 @@ Here is the list of all Doxygen tags and the description of how they are transla \li -prepended with ' --' +prepended with '* ' \n -replaced with new line char +replaced with newline char \note @@ -1264,13 +1299,21 @@ Here is the list of all Doxygen tags and the description of how they are transla \overload prints 'This is an overloaded ...' according to Doxygen docs + +\p +wrapped with '``' + \par replaced with 'Title: ...' \param -translated to 'Arguments:\n param(type) --description' +add ':type:' and ':param:' directives + + +\param[<dir>] +same as \param, but direction ('in'; 'out'; 'in,out') is included in ':type:' directive \remark @@ -1282,15 +1325,15 @@ Here is the list of all Doxygen tags and the description of how they are transla \result -replaced with 'Result:' +add ':rtype:' and ':return:' directives \return -replaced with 'Result:' +add ':rtype:' and ':return:' directives \returns -replaced with 'Result:' +add ':rtype:' and ':return:' directives \sa @@ -1306,11 +1349,11 @@ Here is the list of all Doxygen tags and the description of how they are transla \throw -replaced with 'Throws:' +replaced with ':raises:' \throws -replaced wih 'Throws:' +replaced wih ':raises:' \todo @@ -1318,7 +1361,11 @@ Here is the list of all Doxygen tags and the description of how they are transla \tparam -translated to 'Arguments:\n param(type) --description' +add ':type:' and ':param:' directives + + +\verbatim +content copied verbatim \version @@ -1401,12 +1448,10 @@ Here is the list of these tags:

  • \attention
  • \brief
  • \bug
  • -
  • \c
  • \callergraph
  • \callgraph
  • \category
  • \class
  • -
  • \code
  • \copybrief
  • \copydetails
  • \copydoc
  • @@ -1418,7 +1463,6 @@ Here is the list of these tags:
  • \dontinclude
  • \dot
  • \dotfile
  • -
  • \endcode
  • \enddot
  • \endhtmlonly
  • \endinternal
  • @@ -1427,18 +1471,11 @@ Here is the list of these tags:
  • \endmanonly
  • \endmsc
  • \endrtfonly
  • -
  • \endverbatim
  • \endxmlonly
  • \enum
  • -
  • \example
  • \extends
  • -
  • \f$
  • -
  • \f[
  • -
  • \f]
  • \file
  • \fn
  • -
  • \f{
  • -
  • \f}
  • \headerfile
  • \hideinitializer
  • \htmlinclude
  • @@ -1462,7 +1499,6 @@ Here is the list of these tags:
  • \name
  • \namespace
  • \nosubgrouping
  • -
  • \p
  • \package
  • \page
  • \paragraph
  • @@ -1499,7 +1535,6 @@ Here is the list of these tags:
  • \union
  • \until
  • \var
  • -
  • \verbatim
  • \verbinclude
  • \weakgroup
  • \xmlonly
  • From 4c86ed4980d0f277dc4b9194fa9178d7881a669c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Oct 2019 08:05:35 +0100 Subject: [PATCH 1755/2031] Macros wrapped as constants documentation improvements. Closes #1618 --- Doc/Manual/SWIG.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index aec48ef03..c54d117e0 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -826,6 +826,32 @@ However, for the same conservative reasons even a constant with a simple cast wi +

    +This logic can lead to false attempts at converting #define into %constant though. +For example the following case does not have any undefined symbols within the macro: +

    + +
    +
    +// For indicating pure virtual functions such as: virtual void f() PURE;
    +#define PURE = 0
    +
    +
    + +

    +A warning is issued: +

    + +
    +
    +pure.h:1: Warning 305: Bad constant value (ignored).
    +
    +
    + +

    +In such cases simply ignore the warning or suppress it using the normal warning suppression techniques. +

    +

    The use of constant expressions is allowed, but SWIG does not evaluate them. Rather, it passes them through to the output file and lets the C From e4c38f0f67a74ca146986d9e8df5efd439667139 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Wed, 18 Sep 2019 14:43:23 +1000 Subject: [PATCH 1756/2031] Octave: remove use of ppa:kwwette/octaves --- .travis.yml | 5 ----- Tools/travis-linux-install.sh | 16 +--------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9cbd7862..72ede27f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -322,11 +322,6 @@ matrix: env: SWIGLANG=java CPP11=1 sudo: required dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=octave SWIGJOBS=-j2 VER=4.4 CPP11=1 - sudo: required - dist: trusty - os: linux env: SWIGLANG=python CPP11=1 sudo: required diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 37ef841dd..e902137df 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -71,21 +71,7 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install ocaml camlp4 ;; "octave") - if [[ -z "$VER" ]]; then - travis_retry sudo apt-get -qq install liboctave-dev - else - # Travis adds external PPAs which contain newer versions of packages - # than in baseline trusty. These newer packages prevent some of the - # Octave packages in ppa:kwwette/octave, which rely on the older - # packages in trusty, from installing. To prevent these kind of - # interactions arising, clean out all external PPAs added by Travis - # before installing Octave - sudo rm -rf /etc/apt/sources.list.d/* - travis_retry sudo apt-get -qq update - travis_retry sudo add-apt-repository -y ppa:kwwette/octaves - travis_retry sudo apt-get -qq update - travis_retry sudo apt-get -qq install liboctave${VER}-dev - fi + travis_retry sudo apt-get -qq install liboctave-dev ;; "php") travis_retry sudo add-apt-repository -y ppa:ondrej/php From 18a3ef391121d7c4d819448c929721fd1708b40b Mon Sep 17 00:00:00 2001 From: Thomas Reitmayr Date: Sun, 27 Oct 2019 21:41:03 +0100 Subject: [PATCH 1757/2031] Fix code generated for Ruby global variables This commit fixes swig#1653 by creating a Ruby virtual variable for a C/c++ global variable when SWIG is invoked with the -globalmodule option. --- Doc/Manual/Ruby.html | 18 +++++++ Examples/test-suite/common.mk | 2 + Examples/test-suite/global_immutable_vars.i | 24 +++++++++ .../test-suite/global_immutable_vars_cpp.i | 24 +++++++++ Examples/test-suite/ruby/Makefile.in | 4 ++ .../ruby/global_immutable_vars_cpp_runme.rb | 47 +++++++++++++++++ .../ruby/global_immutable_vars_runme.rb | 51 +++++++++++++++++++ .../ruby_global_immutable_vars_cpp_runme.rb | 47 +++++++++++++++++ .../ruby/ruby_global_immutable_vars_runme.rb | 51 +++++++++++++++++++ .../test-suite/ruby_global_immutable_vars.i | 25 +++++++++ .../ruby_global_immutable_vars_cpp.i | 23 +++++++++ Source/Modules/ruby.cxx | 36 +++++++++---- 12 files changed, 342 insertions(+), 10 deletions(-) create mode 100644 Examples/test-suite/global_immutable_vars.i create mode 100644 Examples/test-suite/global_immutable_vars_cpp.i create mode 100644 Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb create mode 100644 Examples/test-suite/ruby/global_immutable_vars_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb create mode 100644 Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb create mode 100644 Examples/test-suite/ruby_global_immutable_vars.i create mode 100644 Examples/test-suite/ruby_global_immutable_vars_cpp.i diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 3cfd1292c..6939a8a18 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -615,6 +615,24 @@ directive. For example:

    effect until it is explicitly disabled using %mutable.

    +

    Note: When SWIG is invoked with the -globalmodule option in +effect, the C/C++ global variables will be translated into Ruby global +variables. Type-checking and the optional read-only characteristic are +available in the same way as described above. However the example would +then have to be modified and executed in the following way: + +

    +
    $ irb
    +irb(main):001:0> require 'Example'
    +true
    +irb(main):002:0> $variable1 = 2
    +2
    +irb(main):003:0> $Variable2 = 4 * 10.3
    +41.2
    +irb(main):004:0> $Variable2
    +41.2
    +
    +

    34.3.4 Constants

    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5f7792810..008916a56 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -250,6 +250,7 @@ CPP_TEST_CASES += \ funcptr_cpp \ functors \ fvirtual \ + global_immutable_vars_cpp \ global_namespace \ global_ns_arg \ global_scope_types \ @@ -689,6 +690,7 @@ C_TEST_CASES += \ funcptr \ function_typedef \ global_functions \ + global_immutable_vars \ immutable_values \ inctest \ infinity \ diff --git a/Examples/test-suite/global_immutable_vars.i b/Examples/test-suite/global_immutable_vars.i new file mode 100644 index 000000000..cd8cb184b --- /dev/null +++ b/Examples/test-suite/global_immutable_vars.i @@ -0,0 +1,24 @@ +%module global_immutable_vars + +// Test immutable and mutable global variables, +// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables + +%inline %{ + int default_mutable_var = 40; +%} + +%immutable; +%feature("immutable", "0") specific_mutable_var; + +%inline %{ + int global_immutable_var = 41; + int specific_mutable_var = 42; +%} + +%mutable; +%immutable specific_immutable_var; +%inline %{ + int global_mutable_var = 43; + int specific_immutable_var = 44; +%} + diff --git a/Examples/test-suite/global_immutable_vars_cpp.i b/Examples/test-suite/global_immutable_vars_cpp.i new file mode 100644 index 000000000..66eb8545d --- /dev/null +++ b/Examples/test-suite/global_immutable_vars_cpp.i @@ -0,0 +1,24 @@ +%module global_immutable_vars_cpp + +// Test immutable and mutable global variables, +// see http://www.swig.org/Doc4.0/SWIGDocumentation.html#SWIG_readonly_variables + +%inline %{ + int default_mutable_var = 40; +%} + +%immutable; +%feature("immutable", "0") specific_mutable_var; + +%inline %{ + int global_immutable_var = 41; + int specific_mutable_var = 42; +%} + +%mutable; +%immutable specific_immutable_var; +%inline %{ + int global_mutable_var = 43; + int specific_immutable_var = 44; +%} + diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index d75cdb058..2c59029ec 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -23,6 +23,7 @@ CPP_TEST_CASES = \ li_std_wstring_inherit \ primitive_types \ ruby_alias_method \ + ruby_global_immutable_vars_cpp \ ruby_keywords \ ruby_minherit_shared_ptr \ ruby_naming \ @@ -48,6 +49,7 @@ C_TEST_CASES += \ li_cstring \ ruby_alias_global_function \ ruby_alias_module_function \ + ruby_global_immutable_vars \ ruby_manual_proxy \ include $(srcdir)/../common.mk @@ -57,6 +59,8 @@ SWIGOPT += -w801 -noautorename -features autodoc=4 # Custom tests - tests with additional commandline options ruby_alias_global_function.ctest: SWIGOPT += -globalmodule +ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule +ruby_global_immutable_vars_cpp.cpptest: SWIGOPT += -globalmodule ruby_naming.cpptest: SWIGOPT += -autorename # Rules for the different types of tests diff --git a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb new file mode 100644 index 000000000..c40896a86 --- /dev/null +++ b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby +# +# C++ version of global_immutable_vars_runme.rb +# + +require 'swig_assert' + +require 'global_immutable_vars_cpp' + +# first check if all variables can be read +swig_assert_each_line( < e + had_exception = true +end +swig_assert(had_exception, nil, + "Global_immutable_vars_cpp::global_immutable_var is writable (expected to be immutable)") + +had_exception = false +begin + Global_immutable_vars_cpp::specific_immutable_var = 81 +rescue NoMethodError => e + had_exception = true +end +swig_assert(had_exception, nil, + "Global_immutable_vars_cpp::specific_immutable_var is writable (expected to be immutable)") + diff --git a/Examples/test-suite/ruby/global_immutable_vars_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_runme.rb new file mode 100644 index 000000000..af55cfeb3 --- /dev/null +++ b/Examples/test-suite/ruby/global_immutable_vars_runme.rb @@ -0,0 +1,51 @@ +#!/usr/bin/env ruby +# +# Here the proper generation of mutable and immutable variables is tested +# in the target language. +# Immutable variables do not have "=" methods generated by SWIG, +# therefore trying to assign these variables shall throw a NoMethodError +# exception. +# + +require 'swig_assert' + +require 'global_immutable_vars' + +# first check if all variables can be read +swig_assert_each_line( < e + had_exception = true +end +swig_assert(had_exception, nil, + "Global_immutable_vars::global_immutable_var is writable (expected to be immutable)") + +had_exception = false +begin + Global_immutable_vars::specific_immutable_var = 81 +rescue NoMethodError => e + had_exception = true +end +swig_assert(had_exception, nil, + "Global_immutable_vars::specific_immutable_var is writable (expected to be immutable)") + diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb new file mode 100644 index 000000000..8453254eb --- /dev/null +++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby +# +# C++ version of ruby_global_immutable_vars_runme.rb. +# + +require 'swig_assert' + +require 'ruby_global_immutable_vars_cpp' + +# first check if all variables can be read +swig_assert_each_line( < e + had_exception = true +end +swig_assert(had_exception, nil, + "$global_immutable_var is writable (expected to be immutable)") + +had_exception = false +begin + $specific_immutable_var = 81 +rescue NameError => e + had_exception = true +end +swig_assert(had_exception, nil, + "$specific_immutable_var is writable (expected to be immutable)") + diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb new file mode 100644 index 000000000..fda1ccf0f --- /dev/null +++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb @@ -0,0 +1,51 @@ +#!/usr/bin/env ruby +# +# This test program is similar to global_immutable_vars_runme.rb +# with the difference that the global variables to check are also +# Ruby global variables (SWIG Ruby option "-globalmodule"). +# +# Immutable global variables shall throw a NameError exception. +# + +require 'swig_assert' + +require 'ruby_global_immutable_vars' + +# first check if all variables can be read +swig_assert_each_line( < e + had_exception = true +end +swig_assert(had_exception, nil, + "$global_immutable_var is writable (expected to be immutable)") + +had_exception = false +begin + $specific_immutable_var = 81 +rescue NameError => e + had_exception = true +end +swig_assert(had_exception, nil, + "$specific_immutable_var is writable (expected to be immutable)") + diff --git a/Examples/test-suite/ruby_global_immutable_vars.i b/Examples/test-suite/ruby_global_immutable_vars.i new file mode 100644 index 000000000..dc49cd946 --- /dev/null +++ b/Examples/test-suite/ruby_global_immutable_vars.i @@ -0,0 +1,25 @@ +%module ruby_global_immutable_vars + +// This copy of global_immutable_vars.i shall be compiled with the +// SWIG Ruby option "-globalmodule" in order to check the code path +// for registering global methods (in contrast to module methods). + +%inline %{ + int default_mutable_var = 40; +%} + +%immutable; +%feature("immutable", "0") specific_mutable_var; + +%inline %{ + int global_immutable_var = 41; + int specific_mutable_var = 42; +%} + +%mutable; +%immutable specific_immutable_var; +%inline %{ + int global_mutable_var = 43; + int specific_immutable_var = 44; +%} + diff --git a/Examples/test-suite/ruby_global_immutable_vars_cpp.i b/Examples/test-suite/ruby_global_immutable_vars_cpp.i new file mode 100644 index 000000000..cf3145e80 --- /dev/null +++ b/Examples/test-suite/ruby_global_immutable_vars_cpp.i @@ -0,0 +1,23 @@ +%module ruby_global_immutable_vars_cpp + +// C++ version of ruby_global_immutable_vars.i + +%inline %{ + int default_mutable_var = 40; +%} + +%immutable; +%feature("immutable", "0") specific_mutable_var; + +%inline %{ + int global_immutable_var = 41; + int specific_mutable_var = 42; +%} + +%mutable; +%immutable specific_immutable_var; +%inline %{ + int global_mutable_var = 43; + int specific_immutable_var = 44; +%} + diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 6a1e16d5d..c8f582679 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2192,6 +2192,11 @@ public: String *getfname, *setfname; Wrapper *getf, *setf; + // Determine whether virtual global variables shall be used + // which have different getter and setter signatures, + // see https://docs.ruby-lang.org/en/2.6.0/extension_rdoc.html#label-Global+Variables+Shared+Between+C+and+Ruby + const bool use_virtual_var = (current == NO_CPP && useGlobalModule); + getf = NewWrapper(); setf = NewWrapper(); @@ -2201,7 +2206,7 @@ public: getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL); - Printf(getf->def, "VALUE self"); + Printf(getf->def, (use_virtual_var) ? "ID id" : "VALUE self"); Printf(getf->def, ") {"); Wrapper_add_local(getf, "_val", "VALUE _val"); @@ -2235,8 +2240,12 @@ public: String *setname = Swig_name_set(NSPACE_TODO, iname); setfname = Swig_name_wrapper(setname); Setattr(n, "wrap:name", setfname); - Printv(setf->def, "SWIGINTERN VALUE\n", setfname, "(VALUE self, ", NIL); - Printf(setf->def, "VALUE _val) {"); + Printf(setf->def, "SWIGINTERN "); + if (use_virtual_var) { + Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id) {", NIL); + } else { + Printv(setf->def, "VALUE\n", setfname, "(VALUE self, VALUE _val) {", NIL); + } tm = Swig_typemap_lookup("varin", n, name, 0); if (tm) { Replaceall(tm, "$input", "_val"); @@ -2247,9 +2256,14 @@ 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, tab4, "return _val;\n", NIL); - Printf(setf->code, "fail:\n"); - Printv(setf->code, tab4, "return Qnil;\n", NIL); + if (use_virtual_var) { + Printf(setf->code, "fail:\n"); + Printv(setf->code, tab4, "return;\n", NIL); + } else { + Printv(setf->code, tab4, "return _val;\n", NIL); + Printf(setf->code, "fail:\n"); + Printv(setf->code, tab4, "return Qnil;\n", NIL); + } Printf(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); Delete(setname); @@ -2259,7 +2273,7 @@ public: if (CPlusPlus) { Insert(getfname, 0, "VALUEFUNC("); Append(getfname, ")"); - Insert(setfname, 0, "VALUEFUNC("); + Insert(setfname, 0, (use_virtual_var) ? "(void (*)(ANYARGS))(" : "VALUEFUNC("); Append(setfname, ")"); } @@ -2283,9 +2297,11 @@ public: Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "=\", ", setfname, ", 1);\n", NIL); } } else { - Printv(s, tab4, "rb_define_global_method(\"", iname, "\", ", getfname, ", 0);\n", NIL); - if (!GetFlag(n, "feature:immutable")) { - Printv(s, tab4, "rb_define_global_method(\"", iname, "=\", ", setfname, ", 1);\n", NIL); + Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", NIL); + if (GetFlag(n, "feature:immutable")) { + Printv(s, tab4, "0);\n", NIL); + } else { + Printv(s, tab4, setfname, ");\n", NIL); } } Printv(f_init, s, NIL); From f99eb0058b590e29ed7b0264266fd2c2ca6c8faf Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sun, 27 Oct 2019 18:19:42 -0500 Subject: [PATCH 1758/2031] Fix pydoc null pointer dereference with missing arg type Processing doxygen @param comments for a parameter whose name did not appear in the function declaration would cause a segfault due to a null pointer dereference. Adding test cases for both variadic function (no specified arguments) and @param comment that references an argument that is not named in the function prototype. Both of these cases previously segfaulted. --- Examples/test-suite/doxygen_basic_translate.i | 14 ++++++++++++++ .../java/doxygen_basic_translate_runme.java | 7 +++++++ .../python/doxygen_basic_translate_runme.py | 10 ++++++++++ Source/Doxygen/pydoc.cxx | 9 ++++----- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index da4d80909..47c8e3db1 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -107,6 +107,20 @@ double Atan2(double y, double x) return 0; } +/** + * @brief Test variadic function + * @param ... extra args + */ +void function8(...) { +} + +/** + * @brief Test unnamed argument + * @param baz Description of baz + */ +void function9(int) { +} + /** * Comment at the end of file should be ignored. */ diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index ab343b560..b4aaf8c71 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -94,6 +94,13 @@ public class doxygen_basic_translate_runme { " @param x Horizontal coordinate.\n" + " @return Arc tangent of y/x.\n" + ""); + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function8()", + " Test variadic function\n" + + ""); + + wantedComments.put("doxygen_basic_translate.doxygen_basic_translate.function9(int)", + " Test unnamed argument\n" + + ""); // and ask the parser to check comments for us System.exit(parser.check(wantedComments)); diff --git a/Examples/test-suite/python/doxygen_basic_translate_runme.py b/Examples/test-suite/python/doxygen_basic_translate_runme.py index 9ef8dbd52..da31d800a 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_runme.py @@ -70,6 +70,16 @@ Test for a parameter with difficult type :type a: :py:class:`Shape` :param a: Very strange param""" ) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function8), + """\ +Test variadic function +:param ...: extra args""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate.function9), + """\ +Test unnamed argument +:param baz: Description of baz""" +) comment_verifier.check(inspect.getdoc(doxygen_basic_translate.Atan2), """\ diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index eb489932a..aecdcb746 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -418,11 +418,10 @@ std::string PyDocConverter::getParamType(std::string param) { ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); for (Parm *p = plist; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); - if (Char(pname) != param) - continue; - - type = getPyDocType(p, pname); - break; + if (pname && Char(pname) == param) { + type = getPyDocType(p, pname); + break; + } } Delete(plist); return type; From 0f07a8a08d2164f18d0a85b0a3b78ba934ab985f Mon Sep 17 00:00:00 2001 From: John McFarland Date: Wed, 30 Oct 2019 08:15:18 -0500 Subject: [PATCH 1759/2031] Fix doxygen crash with empty comment Parsing "/**/" with -doxygen would result in a crash due to calculation of comment start/end that does not work for an empty comment. Fixed by catching this case prior to processing. Added simple regression test to doxygen_basic_translate. --- Examples/test-suite/doxygen_basic_translate.i | 3 +++ Source/CParse/cscanner.c | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/doxygen_basic_translate.i b/Examples/test-suite/doxygen_basic_translate.i index da4d80909..232633f8d 100644 --- a/Examples/test-suite/doxygen_basic_translate.i +++ b/Examples/test-suite/doxygen_basic_translate.i @@ -107,6 +107,9 @@ double Atan2(double y, double x) return 0; } +/* Regression test for crash with empty comment: */ +/**/ + /** * Comment at the end of file should be ignored. */ diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 4566817a0..1acc037db 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -435,10 +435,11 @@ static int yylook(void) { if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/ /* Check for all possible Doxygen comment start markers while ignoring comments starting with a row of asterisks or slashes just as - Doxygen itself does. */ + Doxygen itself does. Also skip empty comment (slash-star-star-slash), + which causes a crash due to begin > end. */ if (Len(cmt) > 3 && loc[0] == '/' && ((loc[1] == '/' && ((loc[2] == '/' && loc[3] != '/') || loc[2] == '!')) || - (loc[1] == '*' && ((loc[2] == '*' && loc[3] != '*') || loc[2] == '!')))) { + (loc[1] == '*' && ((loc[2] == '*' && loc[3] != '*' && loc[3] != '/') || loc[2] == '!')))) { comment_kind_t this_comment = loc[3] == '<' ? DOX_COMMENT_POST : DOX_COMMENT_PRE; if (existing_comment != DOX_COMMENT_NONE && this_comment != existing_comment) { /* We can't concatenate together Doxygen pre- and post-comments. */ From cb5d7398b562e77436e5766fb17a40bfe8c4f973 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 1 Nov 2019 19:46:42 +0000 Subject: [PATCH 1760/2031] Fix bug in Python builtin support for keyword args The fix is when using kwargs feature or -keyword. The fix is in the argument error checking when wrapping zero argument constructors only. Supplied keyword args were silently ignored. Issue #1595 --- CHANGES.current | 4 ++ Examples/test-suite/kwargs_feature.i | 26 +++++++++++ .../test-suite/python/kwargs_feature_runme.py | 43 +++++++++++++++++++ Source/Modules/python.cxx | 20 ++++++--- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 3e650918b..15a2fc516 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,3 +7,7 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2019-11-01: wsfulton + [Python] #1595 Fix bug in support for keyword arguments (kwargs feature or -keyword) + when using -builtin. The fix is in the argument error checking when wrapping zero + argument constructors only. diff --git a/Examples/test-suite/kwargs_feature.i b/Examples/test-suite/kwargs_feature.i index a8d1c38d8..2b662caeb 100644 --- a/Examples/test-suite/kwargs_feature.i +++ b/Examples/test-suite/kwargs_feature.i @@ -100,3 +100,29 @@ int foo_mm(int min = 1, int max = 2) {return min + max; } %} + + +// Extended constructors +%extend Extending0 { + Extending0() { return new Extending0(); } +} +%extend Extending1 { + Extending1(int one) { return new Extending1(); } +} +%extend Extending2 { + Extending2(int one, const char *two) { return new Extending2(); } +} +%extend ExtendingOptArgs1 { + ExtendingOptArgs1(int one = 0) { return new ExtendingOptArgs1(); } +} +%extend ExtendingOptArgs2 { + ExtendingOptArgs2(int one = 0, const char* two = NULL) { return new ExtendingOptArgs2(); } +} + +%inline %{ +struct Extending0 {}; +struct Extending1 {}; +struct Extending2 {}; +struct ExtendingOptArgs1 {}; +struct ExtendingOptArgs2 {}; +%} diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py index a2d4731ab..31d49d221 100644 --- a/Examples/test-suite/python/kwargs_feature_runme.py +++ b/Examples/test-suite/python/kwargs_feature_runme.py @@ -79,3 +79,46 @@ if rfoo(n=11, x=22) != -11: if rfoo(x=11, n=22) != 11: raise RuntimeError + +# Extended constructors +e = Extending0() +e = Extending1(one=1) +e = Extending1(1) +e = Extending2(1, "two") +e = Extending2(1, two="two") +e = Extending2(two="two", one=1) +e = ExtendingOptArgs1() +e = ExtendingOptArgs1(1) +e = ExtendingOptArgs2(one=1) +e = ExtendingOptArgs2() +e = ExtendingOptArgs2(one=1) +e = ExtendingOptArgs2(two="two") +e = ExtendingOptArgs2(two="two", one=1) + +# Invalid kwargs test +h = Hello() +try: + h = Hello(nonexistent=10) + raise RuntimeError("missed exception") +except TypeError as e: + pass + +f = Foo(1) +f = Foo(a=1) +try: + f = Foo(nonexistent=10) + raise RuntimeError("missed exception") +except TypeError as e: + pass + +try: + f = Foo(a=1, nonexistent=10) + raise RuntimeError("missed exception") +except TypeError as e: + pass + +try: + f = Foo(1, nonexistent=10) + raise RuntimeError("missed exception") +except TypeError as e: + pass diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ea31af029..4792090ea 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2700,8 +2700,12 @@ public: --tuple_required; } num_fixed_arguments = tuple_required; + + // builtin handles/checks kwargs by default except in constructor wrappers so we need to explicitly handle them in the C constructor wrapper + // The check below is for zero arguments. Sometimes (eg directors) self is the first argument for a method with zero arguments. if (((num_arguments == 0) && (num_required == 0)) || ((num_arguments == 1) && (num_required == 1) && Getattr(l, "self"))) - allow_kwargs = 0; + if (!builtin_ctor) + allow_kwargs = 0; varargs = emit_isvarargs(l); String *wname = Copy(wrapper_name); @@ -2727,7 +2731,7 @@ public: } Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args, PyObject *kwargs) {", NIL); } - if (!builtin || !in_class || tuple_arguments > 0) { + if (!builtin || !in_class || tuple_arguments > 0 || builtin_ctor) { if (!allow_kwargs) { Append(parse_args, " if (!PyArg_ParseTuple(args, \""); } else { @@ -2876,9 +2880,7 @@ public: Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); } - if (builtin && !funpack && in_class && tuple_arguments == 0) { - Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname); - } else if (use_parse || allow_kwargs) { + if (use_parse || allow_kwargs) { Printf(parse_args, ":%s\"", iname); Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); funpack = 0; @@ -2906,8 +2908,12 @@ public: } } } else { - Printf(parse_args, "if (!PyArg_UnpackTuple(args, \"%s\", %d, %d", iname, num_fixed_arguments, tuple_arguments); - Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); + if (builtin && in_class && tuple_arguments == 0) { + Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname); + } else { + Printf(parse_args, "if (!PyArg_UnpackTuple(args, \"%s\", %d, %d", iname, num_fixed_arguments, tuple_arguments); + Printv(parse_args, arglist, ")) SWIG_fail;\n", NIL); + } } } From b93597b63b2331e60a0b22eaf18a3bdc23ae1312 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Wed, 30 Oct 2019 19:21:10 -0500 Subject: [PATCH 1761/2031] Fix for newline handling in doxygen "///" style comments Previously, the newlines in "///" doxygen comments were being stripped out, resulting in incorrect translation of the comments for Python and Java. During scanning, "///" comments are processed line by line, whereas "/*" style get processed as a block with newlines intact. The fix checks for the "///" style in scanner.c and manually adds a newline at the end of each comment line. Some extra logic is also added to properly handle empty "///" comments and ensure that a newline gets added for those, which would otherwise be skipped. --- Source/CParse/cscanner.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 4566817a0..ee3270b18 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -433,6 +433,19 @@ static int yylook(void) { Scanner_locator(scan, cmt); } if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/ + + int slashStyle = 0; /* Flag for "///" style doxygen comments */ + if (strncmp(loc, "///", 3) == 0) { + slashStyle = 1; + if (Len(cmt) == 3) { + /* Modify to make length=4 to ensure that the empty comment does + get processed to preserve the newlines in the original + comments. */ + cmt = NewStringf("%s ", cmt); + loc = Char(cmt); + } + } + /* Check for all possible Doxygen comment start markers while ignoring comments starting with a row of asterisks or slashes just as Doxygen itself does. */ @@ -461,6 +474,13 @@ static int yylook(void) { Setline(yylval.str, Scanner_start_line(scan)); Setfile(yylval.str, Scanner_file(scan)); } else { + if (slashStyle) { + /* Add a newline to the end of each doxygen "///" comment, + since they are processed individually, unlike the + slash-star style, which gets processed as a block with + newlines included. */ + Append(yylval.str, "\n"); + } Append(yylval.str, str); } From feea39f3524470a2c28d425332bf4e921f9c435e Mon Sep 17 00:00:00 2001 From: John McFarland Date: Wed, 30 Oct 2019 18:39:23 -0500 Subject: [PATCH 1762/2031] Add new test doxygen_basic_translate_style3.i This is used to test the "///" style of doxygen comments. Previously, newlines in these doxygen comments were not handled correctly. --- Examples/test-suite/common.mk | 1 + .../doxygen_basic_translate_style3.i | 95 ++++++++++++++++ .../doxygen_basic_translate_style3_runme.java | 101 ++++++++++++++++++ .../doxygen_basic_translate_style3_runme.py | 82 ++++++++++++++ 4 files changed, 279 insertions(+) create mode 100644 Examples/test-suite/doxygen_basic_translate_style3.i create mode 100644 Examples/test-suite/java/doxygen_basic_translate_style3_runme.java create mode 100644 Examples/test-suite/python/doxygen_basic_translate_style3_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5f7792810..25a0d8e08 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -622,6 +622,7 @@ DOXYGEN_TEST_CASES += \ doxygen_basic_notranslate \ doxygen_basic_translate \ doxygen_basic_translate_style2 \ + doxygen_basic_translate_style3 \ doxygen_ignore \ doxygen_misc_constructs \ doxygen_nested_class \ diff --git a/Examples/test-suite/doxygen_basic_translate_style3.i b/Examples/test-suite/doxygen_basic_translate_style3.i new file mode 100644 index 000000000..5222cfb6f --- /dev/null +++ b/Examples/test-suite/doxygen_basic_translate_style3.i @@ -0,0 +1,95 @@ +%module doxygen_basic_translate_style3 + +%include "doxygen_basic_translate.h" + +%inline %{ + +/// \brief +/// Brief description. +/// +/// The comment text. +/// +/// \author Some author +/// +/// \return Some number +/// +/// \sa function2 +int function() +{ + return 0; +} + +/// A test of a very very very very very very very very very very very very very very very very +/// very very very very very long comment string. +void function2() +{ +} + +/// A test for overloaded functions +/// This is function \b one +void function3(int a) +{ +} + +/// A test for overloaded functions +/// This is function \b two +void function3(int a, int b) +{ +} + +/// A test of some mixed tag usage +/// \if CONDITION +/// This \a code fragment shows us something \. +/// \par Minuses: +/// \arg it's senseless +/// \arg it's stupid +/// \arg it's null +/// +/// \warning This may not work as expected +/// \code +/// int main() { while(true); } +/// +/// // Test blank line in code block +/// \endcode +/// \endif +void function4() +{ +} + + +void function5(int a) +{ +} +///< This is a post comment. + +/// Test for default args +/// @param a Some parameter, default is 42 +void function6(int a=42) +{ +} + +class Shape +{ +public: + typedef Shape* superType; +}; + +/// Test for a parameter with difficult type +/// (mostly for python) +/// @param a Very strange param +void function7(Shape::superType *a[10]) +{ +} + +/// Multiple parameters test. +/// +/// @param y Vertical coordinate. +/// @param x Horizontal coordinate. +/// @return Arc tangent of @c y/x. +double Atan2(double y, double x) +{ + return 0; +} + +/// Comment at the end of file should be ignored. +%} diff --git a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java new file mode 100644 index 000000000..af74c4f03 --- /dev/null +++ b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java @@ -0,0 +1,101 @@ + +import doxygen_basic_translate_style3.*; +import com.sun.javadoc.*; +import java.util.HashMap; + +public class doxygen_basic_translate_style3_runme { + static { + try { + System.loadLibrary("doxygen_basic_translate_style3"); + } 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[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + CommentParser parser = new CommentParser(); + com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style3 runtime test", + "CommentParser", + new String[]{"-quiet", "doxygen_basic_translate_style3"}); + + HashMap wantedComments = new HashMap(); + + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function()", + " \n" + + " Brief description.\n" + + " \n" + + " The comment text.\n" + + " @author Some author\n" + + " @return Some number\n" + + " @see function2\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function2()", + " A test of a very very very very very very very very very very very very very very very very \n" + + " very very very very very long comment string. \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function4()", + " A test of some mixed tag usage \n" + + " If: CONDITION {\n" + + " This code fragment shows us something . \n" + + "

    \n" + + "

  • it's senseless \n" + + "
  • it's stupid \n" + + "
  • it's null \n" + + " \n" + + "
  • Warning: This may not work as expected \n" + + " \n" + + " {@code \n" + + "int main() { while(true); } \n" + + "\n" + + "// Test blank line in code block \n" + + " }\n" + + " }\n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int)", + " A test for overloaded functions \n" + + " This is function one \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function5(int)", + " This is a post comment. \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6(int)", + " Test for default args \n" + + " @param a Some parameter, default is 42" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function6()", + " Test for default args \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function7(doxygen_basic_translate_style3.SWIGTYPE_p_p_p_Shape)", + " Test for a parameter with difficult type \n" + + " (mostly for python) \n" + + " @param a Very strange param \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.function3(int, int)", + " A test for overloaded functions \n" + + " This is function two \n" + + " \n" + + ""); + wantedComments.put("doxygen_basic_translate_style3.doxygen_basic_translate_style3.Atan2(double, double)", + " Multiple parameters test.\n" + + " \n" + + " @param y Vertical coordinate.\n" + + " @param x Horizontal coordinate.\n" + + " @return Arc tangent of y/x.\n" + + ""); + + // and ask the parser to check comments for us + System.exit(parser.check(wantedComments)); + } +} diff --git a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py new file mode 100644 index 000000000..dc513d2e0 --- /dev/null +++ b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py @@ -0,0 +1,82 @@ +import doxygen_basic_translate_style3 +import inspect +import string +import sys +import comment_verifier + +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function), + """\ +Brief description. + +The comment text. + +Author: Some author + +:rtype: int +:return: Some number + +See also: function2""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function2), + """\ +A test of a very very very very very very very very very very very very very very very very +very very very very very long comment string.""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function3), + """*Overload 1:* +A test for overloaded functions +This is function **one** + +| + +*Overload 2:* +A test for overloaded functions +This is function **two**""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function4), + """\ +A test of some mixed tag usage +If: CONDITION { +This *code* fragment shows us something . +Title: Minuses: +* it\'s senseless +* it\'s stupid +* it\'s null + +Warning: This may not work as expected + +.. code-block:: c++ + + int main() { while(true); } + + // Test blank line in code block +}""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function5), + """This is a post comment.""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function6), + """\ +Test for default args +:type a: int +:param a: Some parameter, default is 42""" +) +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function7), + """\ +Test for a parameter with difficult type +(mostly for python) +:type a: :py:class:`Shape` +:param a: Very strange param""" +) + +comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.Atan2), + """\ +Multiple parameters test. + +:type y: float +:param y: Vertical coordinate. +:type x: float +:param x: Horizontal coordinate. +:rtype: float +:return: Arc tangent of ``y/x``.""" +) From e46e1655cd592658b6738b10d3ee1a1a82022dc2 Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 2 Nov 2019 10:29:25 -0500 Subject: [PATCH 1763/2031] Minor workaround in doxygen_basic_translate_style3 test With the "///" doxygen comment style, comments within a code block do not get handled correctly. Modifying the test to remove this case and adding a note about it for future reference. --- Examples/test-suite/doxygen_basic_translate_style3.i | 9 ++++++++- .../java/doxygen_basic_translate_style3_runme.java | 2 +- .../python/doxygen_basic_translate_style3_runme.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/doxygen_basic_translate_style3.i b/Examples/test-suite/doxygen_basic_translate_style3.i index 5222cfb6f..e364b164f 100644 --- a/Examples/test-suite/doxygen_basic_translate_style3.i +++ b/Examples/test-suite/doxygen_basic_translate_style3.i @@ -49,11 +49,18 @@ void function3(int a, int b) /// \code /// int main() { while(true); } /// -/// // Test blank line in code block +/// int testBlankLine() {} /// \endcode /// \endif void function4() { + // Note: a comment in the above code block will not get processed + // correctly with this doxygen comment style, because + // DoxygenParser::tokenizeDoxygenComment strips out the leading + // comment characters. Whereas it works in the other doxygen + // comment styles (as shown in the other variations of + // doxygen_basic_translate), this test is modified to remove the + // comment within the code block. } diff --git a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java index af74c4f03..e450eb757 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java @@ -55,7 +55,7 @@ public class doxygen_basic_translate_style3_runme { " {@code \n" + "int main() { while(true); } \n" + "\n" + - "// Test blank line in code block \n" + + "int testBlankLine() {} \n" + " }\n" + " }\n" + " \n" + diff --git a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py index dc513d2e0..aa9b6ca4e 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py @@ -49,7 +49,7 @@ Warning: This may not work as expected int main() { while(true); } - // Test blank line in code block + int testBlankLine() {} }""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function5), From b536702c01c86da6d2daeeaed995ee912f67701b Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Wed, 20 Nov 2019 15:40:14 +0100 Subject: [PATCH 1764/2031] Fix missing-field-initializers warning with Py3.8 Python 3.8 adds tp_vectorcall, tp_print is added for compat just for 3.8 https://github.com/python/cpython/pull/13185/files#diff-b5db2632fa7acaf3b44abb56f18b9615 --- Lib/python/builtin.swg | 12 ++++++++++++ Lib/python/pyinit.swg | 6 ++++++ Lib/python/pyrun.swg | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 28051e67b..5308748b7 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -256,6 +256,12 @@ SwigPyStaticVar_Type(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -334,6 +340,12 @@ SwigPyObjectType(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index dfbf40b34..a6d609d56 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -186,6 +186,12 @@ swig_varlink_type(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 82859b887..ba8097cb7 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -696,6 +696,12 @@ SwigPyObject_TypeOnce(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -857,6 +863,12 @@ SwigPyPacked_TypeOnce(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif +#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000) + 0, /* tp_print */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ From 6fb345feb26d331814ce7111682a4b3b809c6d16 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Nov 2019 19:32:34 +0000 Subject: [PATCH 1765/2031] 'out' or 'ref' usage in a cstype typemap in directors 'out' / 'ref' was not always stripped out in parts of the director code generation. Issue #1628 --- CHANGES.current | 4 ++ Examples/test-suite/csharp/Makefile.in | 1 + .../csharp/csharp_director_typemaps_runme.cs | 53 +++++++++++++++++++ .../test-suite/csharp_director_typemaps.i | 37 +++++++++++++ Source/Modules/csharp.cxx | 7 ++- 5 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/csharp/csharp_director_typemaps_runme.cs create mode 100644 Examples/test-suite/csharp_director_typemaps.i diff --git a/CHANGES.current b/CHANGES.current index 15a2fc516..39ec98e09 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2019-11-26: wsfulton + [C#] #1628 'out' or 'ref' used in a cstype typemap was not always stripped out in parts + of director code generation. + 2019-11-01: wsfulton [Python] #1595 Fix bug in support for keyword arguments (kwargs feature or -keyword) when using -builtin. The fix is in the argument error checking when wrapping zero diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 8272864d5..57a81e357 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -16,6 +16,7 @@ CPP_TEST_CASES = \ complextest \ csharp_attributes \ csharp_swig2_compatibility \ + csharp_director_typemaps \ csharp_exceptions \ csharp_features \ csharp_lib_arrays \ diff --git a/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs b/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs new file mode 100644 index 000000000..6143332db --- /dev/null +++ b/Examples/test-suite/csharp/csharp_director_typemaps_runme.cs @@ -0,0 +1,53 @@ + +using System; +using System.Reflection; +using csharp_director_typemapsNamespace; + +public class csharp_director_typemaps_runme { + + class CSharpDirectorTypemaps_InStreamDerived : InStream + { + private int constant; + public CSharpDirectorTypemaps_InStreamDerived(int constant) { this.constant = constant; } + public override int Read(global::System.IntPtr buf, int len, out int readLen) { + readLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant; + return readLen; + } + public override int Write(global::System.IntPtr buf, int len, out int writeLen) { + writeLen = (buf == global::System.IntPtr.Zero) ? -len - constant : len + constant; + return writeLen; + } + } + public static void Main() { + int outLen = -1; + int k = 100; + int j = 23; + InStream instream = new CSharpDirectorTypemaps_InStreamDerived(k); + + { + int ret = csharp_director_typemaps.callRead(instream, InStream.getCPtr(instream).Handle, j, out outLen); + Assert(outLen, j + k); + Assert(ret, j + k); + } + { + int ret = csharp_director_typemaps.callRead(instream, global::System.IntPtr.Zero, j, out outLen); + Assert(outLen, -j - k); + Assert(ret, -j - k); + } + + { + int ret = csharp_director_typemaps.callWrite(instream, InStream.getCPtr(instream).Handle, j, out outLen); + Assert(outLen, j + k); + Assert(ret, j + k); + } + { + int ret = csharp_director_typemaps.callWrite(instream, global::System.IntPtr.Zero, j, out outLen); + Assert(outLen, -j - k); + Assert(ret, -j - k); + } + } + private static void Assert(int i1, int i2) { + if (i1 != i2) + throw new Exception("assertion failure. " + i1 + " != " + i2); + } +} diff --git a/Examples/test-suite/csharp_director_typemaps.i b/Examples/test-suite/csharp_director_typemaps.i new file mode 100644 index 000000000..2bc0281ee --- /dev/null +++ b/Examples/test-suite/csharp_director_typemaps.i @@ -0,0 +1,37 @@ +%module (directors="1") csharp_director_typemaps + +// This tests that the csout typemap is handled correctly in the director code. +// The 'out' needs stripping in some parts of the generated director code. + +%feature("director") InStream; + +%apply void *VOID_INT_PTR { void * } + +%typemap(ctype) int* readLen, int* writeLen "/*ctype*/ int*" +%typemap(imtype) int* readLen, int* writeLen "/*imtype*/ out int" +%typemap(cstype) int* readLen "/*cstype*/ out int" +//%typemap(cstype) int* writeLen "/*out cstype out*/ out int" +%apply int *readLen { int* writeLen } // Replaced above - 'out' in a comment is not working yet +%typemap(csin) int* readLen, int* writeLen "/*csin*/ out $csinput" +%typemap(in) int* readLen, int* writeLen %{/*in*/ $1 = ($1_ltype)$input; %} +%typemap(out) int* readLen, int* writeLen %{/*out*/ $result = (void *)$1; %} +%typemap(csdirectorin) int* readLen, int* writeLen "/*csdirectorin*/ out $iminput" +%typemap(csdirectorout) int* readLen, int* writeLen "/*csdirectorout*/ $cscall" +%typemap(directorin) int* readLen, int* writeLen "/*directorin*/ $input = $1;" +%typemap(directorout) int* readLen, int* writeLen %{/*directorout*/ $result = ($1_ltype)$input; %} + +%inline %{ +class InStream +{ +public: + virtual int Read(void* buf, int len, int* readLen) = 0; + virtual int Write(void* buf, int len, int* writeLen) = 0; + virtual ~InStream() {} +}; +int callRead(InStream* stream, void* buf, int len, int* readLen) { + return stream->Read(buf, len, readLen); +} +int callWrite(InStream* stream, void* buf, int len, int* writeLen) { + return stream->Write(buf, len, writeLen); +} +%} diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 17100b330..27dbd6427 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4064,11 +4064,10 @@ public: /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); - if (Strncmp(tm, "ref ", 4) == 0) { - Replace(tm, "ref ", "", DOH_REPLACE_FIRST); + int flags = DOH_REPLACE_FIRST | DOH_REPLACE_ID_BEGIN; + if (Replace(tm, "ref ", "", flags) || Replace(tm, "ref\t", "", flags)) { Printf(proxy_method_types, "typeof(%s).MakeByRefType()", tm); - } else if (Strncmp(tm, "out ", 4) == 0) { - Replace(tm, "out ", "", DOH_REPLACE_FIRST); + } else if (Replace(tm, "out ", "", flags) || Replace(tm, "out\t", "", flags)) { Printf(proxy_method_types, "typeof(%s).MakeByRefType()", tm); } else { Printf(proxy_method_types, "typeof(%s)", tm); From 18b2dcd2220b13296e12bb729741542750faab31 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Nov 2019 19:39:28 +0000 Subject: [PATCH 1766/2031] C# 'out' or 'ref' removal improvements in director typemaps. - Add support to DOH Replace for not replacing inside C comments - Fix removing 'out' or 'ref' when these are present in C comments in cstype typemaps. Closes #1628 --- .../test-suite/csharp_director_typemaps.i | 4 +- Source/DOH/README | 16 ++- Source/DOH/doh.h | 11 +- Source/DOH/string.c | 106 ++++++++++++++++++ Source/Modules/csharp.cxx | 2 +- 5 files changed, 126 insertions(+), 13 deletions(-) diff --git a/Examples/test-suite/csharp_director_typemaps.i b/Examples/test-suite/csharp_director_typemaps.i index 2bc0281ee..614bdbf23 100644 --- a/Examples/test-suite/csharp_director_typemaps.i +++ b/Examples/test-suite/csharp_director_typemaps.i @@ -10,8 +10,8 @@ %typemap(ctype) int* readLen, int* writeLen "/*ctype*/ int*" %typemap(imtype) int* readLen, int* writeLen "/*imtype*/ out int" %typemap(cstype) int* readLen "/*cstype*/ out int" -//%typemap(cstype) int* writeLen "/*out cstype out*/ out int" -%apply int *readLen { int* writeLen } // Replaced above - 'out' in a comment is not working yet +// Note for below: 'out' used in typemap comment +%typemap(cstype) int* writeLen "/*out cstype out*/ out int" %typemap(csin) int* readLen, int* writeLen "/*csin*/ out $csinput" %typemap(in) int* readLen, int* writeLen %{/*in*/ $1 = ($1_ltype)$input; %} %typemap(out) int* readLen, int* writeLen %{/*out*/ $result = (void *)$1; %} diff --git a/Source/DOH/README b/Source/DOH/README index 8be5f652a..be90f25b4 100644 --- a/Source/DOH/README +++ b/Source/DOH/README @@ -73,11 +73,17 @@ Replace(obj, orig, rep, flags) Replace occurrences of orig with rep. Chop(obj) Remove trailing whitespace flags is one of the following: - DOH_REPLACE_ANY - DOH_REPLACE_NOQUOTE - DOH_REPLACE_ID - DOH_REPLACE_FIRST - + DOH_REPLACE_ID + DOH_REPLACE_ID_BEGIN + DOH_REPLACE_ID_END + DOH_REPLACE_NUMBER_END + +and can be combined with one or more of the following: + DOH_REPLACE_ANY + DOH_REPLACE_NOQUOTE + DOH_REPLACE_NOCOMMENT + DOH_REPLACE_FIRST + Callable Operations ------------------- Call(obj, args) Perform a function call with arguments args. diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 7fb64c058..fd0530e9c 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -289,11 +289,12 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch); #define DOH_REPLACE_ANY 0x01 #define DOH_REPLACE_NOQUOTE 0x02 -#define DOH_REPLACE_ID 0x04 -#define DOH_REPLACE_FIRST 0x08 -#define DOH_REPLACE_ID_BEGIN 0x10 -#define DOH_REPLACE_ID_END 0x20 -#define DOH_REPLACE_NUMBER_END 0x40 +#define DOH_REPLACE_NOCOMMENT 0x04 +#define DOH_REPLACE_ID 0x08 +#define DOH_REPLACE_FIRST 0x10 +#define DOH_REPLACE_ID_BEGIN 0x20 +#define DOH_REPLACE_ID_END 0x40 +#define DOH_REPLACE_NUMBER_END 0x80 #define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY) #define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID) diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 6c6728578..3689f4ffe 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -595,6 +595,13 @@ static char *end_quote(char *s) { } } +static char *end_comment(char *s) { + char *substring = strstr(s, "*/"); + if (substring) + ++substring; + return substring; +} + static char *match_simple(char *base, char *s, char *token, int tokenlen) { (void) base; (void) tokenlen; @@ -677,6 +684,7 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co int ic; int rcount = 0; int noquote = 0; + int nocomment = 0; char *c, *s, *t, *first; char *q, *q2; char *base; @@ -698,6 +706,11 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co if (flags & DOH_REPLACE_NOQUOTE) noquote = 1; + if (flags & DOH_REPLACE_NOCOMMENT) + nocomment = 1; + + assert(!(noquote && nocomment)); /* quote and comment combination not implemented */ + /* If we are not replacing inside quotes, we need to do a little extra work */ if (noquote) { q = strpbrk(base, "\"\'"); @@ -723,6 +736,31 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co } } + /* If we are not replacing inside comments, we need to do a little extra work */ + if (nocomment) { + q = strstr(base, "/*"); + if (!q) { + nocomment = 0; /* Well, no comments to worry about. Oh well */ + } else { + while (q && (q < s)) { + /* First match was found inside a comment. Try to find another match */ + q2 = end_comment(q); + if (!q2) { + return 0; + } + if (q2 > s) { + /* Find next match */ + s = (*match) (base, q2 + 1, token, tokenlen); + } + if (!s) + return 0; /* Oh well, no matches */ + q = strstr(q2 + 1, "/*"); + if (!q) + nocomment = 0; /* No more comments */ + } + } + } + first = s; replen = (int)strlen(rep); @@ -768,6 +806,28 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co } } } + if (nocomment) { + q = strstr(s, "/*"); + if (!q) { + nocomment = 0; + } else { + while (q && (q < c)) { + /* First match was found inside a comment. Try to find another match */ + q2 = end_comment(q); + if (!q2) { + c = 0; + break; + } + if (q2 > c) + c = (*match) (base, q2 + 1, token, tokenlen); + if (!c) + break; + q = strstr(q2 + 1, "/*"); + if (!q) + nocomment = 0; /* No more comments */ + } + } + } if (delta) { if (c) { memmove(t, s, c - s); @@ -823,6 +883,29 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co } } } + if (nocomment) { + q = strstr(s, "/*"); + if (!q) { + break; + } else { + while (q && (q < c)) { + /* First match was found inside a comment. Try to find another match */ + q2 = end_comment(q); + if (!q2) { + c = 0; + break; + } + if (q2 > c) { + c = (*match) (base, q2 + 1, token, tokenlen); + if (!c) + break; + } + q = strstr(q2 + 1, "/*"); + if (!q) + nocomment = 0; + } + } + } if (c) { rcount++; ic--; @@ -875,6 +958,29 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co } } } + if (nocomment) { + q = strstr(s, "/*"); + if (!q) { + nocomment = 0; + } else { + while (q && (q < c)) { + /* First match was found inside a comment. Try to find another match */ + q2 = end_comment(q); + if (!q2) { + c = 0; + break; + } + if (q2 > c) { + c = (*match) (base, q2 + 1, token, tokenlen); + if (!c) + break; + } + q = strstr(q2 + 1, "/*"); + if (!q) + nocomment = 0; /* No more comments */ + } + } + } if (i < (rcount - 1)) { memcpy(t, s, c - s); t += (c - s); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 27dbd6427..d08884b0f 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4064,7 +4064,7 @@ public: /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { substituteClassname(pt, tm); - int flags = DOH_REPLACE_FIRST | DOH_REPLACE_ID_BEGIN; + int flags = DOH_REPLACE_FIRST | DOH_REPLACE_ID_BEGIN | DOH_REPLACE_NOCOMMENT; if (Replace(tm, "ref ", "", flags) || Replace(tm, "ref\t", "", flags)) { Printf(proxy_method_types, "typeof(%s).MakeByRefType()", tm); } else if (Replace(tm, "out ", "", flags) || Replace(tm, "out\t", "", flags)) { From 3d98179fd3b38d86e7f689dd7e19f11b53449a2f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 26 Nov 2019 19:45:08 +0000 Subject: [PATCH 1767/2031] Temporarily remove broken Appveyor Python3 testing --- appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 42eaa36f4..f87cefd0f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,10 +16,10 @@ environment: - SWIGLANG: python VSVER: 14 VER: 27 - - SWIGLANG: python - VSVER: 14 - VER: 36 - PY3: 3 +# - SWIGLANG: python +# VSVER: 14 +# VER: 36 +# PY3: 3 - SWIGLANG: python OSVARIANT: cygwin - SWIGLANG: python From 8122929ba95c34132b9cb9c5cbeaf4eeb7c300e0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 3 Dec 2019 22:07:49 +0000 Subject: [PATCH 1768/2031] Improve .NET docs. Add minimum .NET version required Issue #1623 [skip-ci] --- Doc/Manual/CSharp.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 1fc2d211e..d041bf5dd 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -66,7 +66,16 @@ PInvoke is part of the ECMA/ISO C# specification. It is also better suited for robust production environments due to the Managed C++ flaw called the Mixed DLL Loading Problem. SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using -Mono and Portable.NET. +Mono. +

    + +

    +SWIG 3 and later requires .NET 2.0 at a minimum. +There are some minor exceptions, where the minimum required is .NET 4.0. +This is when using the std::complex and std::list STL containers. +

    + +

    From 66752cde4858a780fecba47793f99ba49ce8b15e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 4 Dec 2019 20:08:41 +0000 Subject: [PATCH 1769/2031] Remove Travis osx java testing Removed until doxygen testing is ported to something that doesn't use com.sun.javadoc which was remoed in jdk 13 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 72ede27f9..e0d8ac74a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -449,6 +449,11 @@ matrix: env: SWIGLANG=php VER=7.2 sudo: required dist: xenial + # jdk 13 has removed tools.jar resulting in: CommentParser.java:2: error: package com.sun.javadoc does not exist + - compiler: clang + os: osx + env: SWIGLANG=java CPP17=1 + osx_image: xcode10.2 # Sometimes hits the Travis 50 minute time limit - compiler: clang os: osx From aa47b4c438421595b2764044b54502ad378cd7e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 10 Dec 2019 19:26:05 +0000 Subject: [PATCH 1770/2031] Fix some C++11 identifiers with special meaning parsing problems Fix parsing of C++11 identifiers with special meaning (final and override) when they are used as part of the scope name of an identifier, such as a namespace name. Closes #1679 --- CHANGES.current | 4 ++++ Examples/test-suite/cpp11_final_override.i | 28 ++++++++++++++++++++++ Source/CParse/cscanner.c | 8 +++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 39ec98e09..09facd90b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2019-12-10: wsfulton + #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when + they are used as part of the scope name of an identifier, such as a namespace name. + 2019-11-26: wsfulton [C#] #1628 'out' or 'ref' used in a cstype typemap was not always stripped out in parts of director code generation. diff --git a/Examples/test-suite/cpp11_final_override.i b/Examples/test-suite/cpp11_final_override.i index 8d275b322..c31ae73b6 100644 --- a/Examples/test-suite/cpp11_final_override.i +++ b/Examples/test-suite/cpp11_final_override.i @@ -138,3 +138,31 @@ void DerivedNoVirtualStruct::ef() {} DerivedNoVirtualStruct::~DerivedNoVirtualStruct() {} %} +%inline %{ +namespace Outer { + namespace final { + template struct smart_ptr { + typedef T type; + }; + } + namespace override { + template struct dumb_ptr { + typedef T type; + }; + } +} +%} + +%template(SmartPtrBaseStruct) Outer::final::smart_ptr; + +%inline %{ +class ObjectDB +{ +public: + static void smart1(typename Outer::final::smart_ptr::type *objectT) {} + static void smart2(Outer::final::smart_ptr::type *objectT) {} + static void dumb1(typename Outer::override::dumb_ptr::type *objectT) {} + static void dumb2(Outer::override::dumb_ptr::type *objectT) {} + static Outer::final::smart_ptr::type get() { return DerivedStruct(); } +}; +%} diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 4566817a0..7a9c05c95 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -873,10 +873,14 @@ int yylex(void) { return (USING); if (strcmp(yytext, "namespace") == 0) return (NAMESPACE); - if (strcmp(yytext, "override") == 0) + if (strcmp(yytext, "override") == 0) { + last_id = 1; return (OVERRIDE); - if (strcmp(yytext, "final") == 0) + } + if (strcmp(yytext, "final") == 0) { + last_id = 1; return (FINAL); + } } else { if (strcmp(yytext, "class") == 0) { Swig_warning(WARN_PARSE_CLASS_KEYWORD, cparse_file, cparse_line, "class keyword used, but not in C++ mode.\n"); From fe6968e5e2dfc365ca009e9bcd2d4ed3f6d8d6a6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2019 02:24:01 +0100 Subject: [PATCH 1771/2031] Reuse existing variable in CommentParser code used in Java tests No real changes, just a tiny simplification. --- Examples/test-suite/java/CommentParser.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/java/CommentParser.java b/Examples/test-suite/java/CommentParser.java index 7dc6d591d..f202c1384 100644 --- a/Examples/test-suite/java/CommentParser.java +++ b/Examples/test-suite/java/CommentParser.java @@ -93,13 +93,13 @@ public class CommentParser { System.out.println("Output is also saved to files '" + expectedFileName + "' and '" + gotFileName + "'"); // here we print original strings, for nicer output - System.out.println("\n\n---\nexpected:\n" + wantedComments.get(e.getKey())); + System.out.println("\n\n---\nexpected:\n" + wantedStr); System.out.println("\n\n---\ngot:\n" + e.getValue()); try { // write expected string to file BufferedWriter expectedFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(expectedFileName))); - expectedFile.write(wantedComments.get(e.getKey())); + expectedFile.write(wantedStr); expectedFile.close(); // write translated string to file From 5a8875ca9da7046b2b3b7fea3f1e056f289c5be1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2019 02:25:08 +0100 Subject: [PATCH 1772/2031] Don't crash if unexpected comment is found in Java Doxygen tests Don't pass null pointer to BufferedWriter.write(), as this results in NullPointerException. --- Examples/test-suite/java/CommentParser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/java/CommentParser.java b/Examples/test-suite/java/CommentParser.java index f202c1384..7d5740b51 100644 --- a/Examples/test-suite/java/CommentParser.java +++ b/Examples/test-suite/java/CommentParser.java @@ -99,7 +99,8 @@ public class CommentParser { try { // write expected string to file BufferedWriter expectedFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(expectedFileName))); - expectedFile.write(wantedStr); + if (wantedStr != null) + expectedFile.write(wantedStr); expectedFile.close(); // write translated string to file From 66a78261924174791a4952d05b58d52c16a36a57 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2019 02:42:12 +0100 Subject: [PATCH 1773/2031] Rewrite Doxygen unit tests for Java using Java 9 API In particular, do not use com.sun.javadoc deprecated since Java 9 and finally removed in Java 13, to allow the tests to run under modern JRE. They don't run under Java 8 and earlier any more, but this shouldn't be a huge problem nowadays and as SWIG output is independent from the Java version used, it's enough to test it with modern Java versions. Note that the tests themselves were changed only in the most minimal way, to adapt them to the new way of running javadoc (which is now also integrated into CommentParser itself instead of being duplicated in every test). --- Examples/test-suite/java/CommentParser.java | 134 ++++++++++++++---- Examples/test-suite/java/Makefile.in | 4 +- .../test-suite/java/doxygen_alias_runme.java | 8 +- .../java/doxygen_basic_notranslate_runme.java | 12 +- .../java/doxygen_basic_translate_runme.java | 12 +- .../doxygen_basic_translate_style2_runme.java | 12 +- .../test-suite/java/doxygen_ignore_runme.java | 8 +- .../java/doxygen_misc_constructs_runme.java | 12 +- .../java/doxygen_nested_class_runme.java | 12 +- .../doxygen_parsing_enums_proper_runme.java | 12 +- .../doxygen_parsing_enums_simple_runme.java | 12 +- .../doxygen_parsing_enums_typesafe_runme.java | 12 +- ...oxygen_parsing_enums_typeunsafe_runme.java | 12 +- .../java/doxygen_parsing_runme.java | 12 +- .../doxygen_translate_all_tags_runme.java | 12 +- .../java/doxygen_translate_links_runme.java | 12 +- .../java/doxygen_translate_runme.java | 12 +- configure.ac | 10 -- 18 files changed, 140 insertions(+), 180 deletions(-) diff --git a/Examples/test-suite/java/CommentParser.java b/Examples/test-suite/java/CommentParser.java index 7d5740b51..1fc6f646a 100644 --- a/Examples/test-suite/java/CommentParser.java +++ b/Examples/test-suite/java/CommentParser.java @@ -1,5 +1,6 @@ -import com.sun.javadoc.*; +import com.sun.source.doctree.*; +import com.sun.source.util.DocTrees; import java.util.HashMap; import java.util.Map.Entry; import java.util.Map; @@ -9,45 +10,120 @@ import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.FileOutputStream; import java.io.IOException; +import java.util.*; +import java.util.spi.ToolProvider; +import javax.lang.model.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; +import jdk.javadoc.doclet.*; -public class CommentParser { +public class CommentParser implements Doclet { private static Map m_parsedComments = new HashMap(); - public static boolean start(RootDoc root) { + // We need to implement these base class pure virtual methods. + @Override + public void init(Locale locale, Reporter reporter) { + } + + @Override + public Set getSupportedOptions() { + return new HashSet<>(); + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + @Override + public String getName() { + return "CommentParser"; + } + + // Element name must be the fully qualified name of the element. + // + // If there is no comment associated with this element, simply do nothing. + private void storeCommentFor(DocTrees docTrees, String fullName, Element e) { + DocCommentTree docCommentTree = docTrees.getDocCommentTree(e); + if (docCommentTree == null) + return; + + StringBuilder name = new StringBuilder(fullName); + + // We must use signature in the key for methods for compatibility with + // the existing tests and to allow distinguishing between overloaded + // methods. + if (e instanceof ExecutableElement) { + ExecutableElement ex = (ExecutableElement)e; + name.append("("); + + boolean firstParam = true; + for (VariableElement p : ex.getParameters()) { + if (firstParam) { + firstParam = false; + } else { + name.append(", "); + } + + name.append(p.asType().toString()); + } + + name.append(")"); + } + + // For some reason the comment in the source is split into "body" and + // "block tags" parts, so we need to concatenate them back together. + StringBuilder comment = new StringBuilder(); + for (DocTree d : docCommentTree.getFullBody()) { + comment.append(d.toString()); + comment.append("\n"); + } + + boolean firstBlockTag = true; + for (DocTree d : docCommentTree.getBlockTags()) { + if (firstBlockTag) { + firstBlockTag = false; + comment.append("\n"); + } + + comment.append(d.toString()); + comment.append("\n"); + } + + m_parsedComments.put(name.toString(), comment.toString()); + } + + @Override + public boolean run(DocletEnvironment docEnv) { /* * This method is called by 'javadoc' and gets the whole parsed java * file, we get comments and store them */ + DocTrees docTrees = docEnv.getDocTrees(); + for (TypeElement t : ElementFilter.typesIn(docEnv.getIncludedElements())) { + String typeName = t.getQualifiedName().toString(); - for (ClassDoc classDoc : root.classes()) { + storeCommentFor(docTrees, typeName, t); - if (classDoc.getRawCommentText().length() > 0) - m_parsedComments.put(classDoc.qualifiedName(), classDoc.getRawCommentText()); + for (Element e : t.getEnclosedElements()) { + // Omit the method name for ctors: this is a bit weird, but + // this is what the existing tests expect. + String fullName = typeName; + if (e.getKind() != ElementKind.CONSTRUCTOR) { + fullName = fullName + "." + e.getSimpleName(); + } - for (FieldDoc f : classDoc.enumConstants()) { - if (f.getRawCommentText().length() > 0) - m_parsedComments.put(f.qualifiedName(), f.getRawCommentText()); - } - for (FieldDoc f : classDoc.fields()) { - if (f.getRawCommentText().length() > 0) - m_parsedComments.put(f.qualifiedName(), f.getRawCommentText()); - } - for (ConstructorDoc c : classDoc.constructors()) { - if (c.getRawCommentText().length() > 0) - m_parsedComments.put(c.toString(), c.getRawCommentText()); - } - for (MethodDoc m : classDoc.methods()) { - if (m.getRawCommentText().length() > 0) - m_parsedComments.put(m.toString(), m.getRawCommentText()); + storeCommentFor(docTrees, fullName, e); } } + return true; } - public int check(Map wantedComments) { + public static int check(Map wantedComments) { int errorCount=0; Iterator> it = m_parsedComments.entrySet().iterator(); @@ -131,7 +207,7 @@ public class CommentParser { } - private void printKeys(Map map) { + private static void printKeys(Map map) { Set keys = map.keySet(); for (String key : keys) { @@ -155,6 +231,15 @@ public class CommentParser { } } + public static void parse(String sourcefile) { + ToolProvider javadoc = ToolProvider.findFirst("javadoc").orElseThrow(); + int result = javadoc.run(System.out, System.err, new String[]{"-quiet", "-doclet", "CommentParser", sourcefile}); + if (result != 0) { + System.err.println("Executing javadoc failed."); + System.exit(result); + } + } + public static void main(String argv[]) { @@ -163,8 +248,7 @@ public class CommentParser { System.exit(1); } - com.sun.tools.javadoc.Main.execute("The comment parser program", - "CommentParser", new String[]{"-quiet", argv[0]}); + parse(argv[0]); // if we are run as standalone app, print the list of found comments as it would appear in java source diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 2e788fa07..3f4a71711 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -108,13 +108,11 @@ setup = \ mkdir $(JAVA_PACKAGE); \ fi -# Doxygen test cases need to be compiled together with the CommentParser class -# which depends on com.sun.javadoc package which is located in this JAR. +# Doxygen test cases need to be compiled together with the CommentParser class. CommentParser.class: $(COMPILETOOL) $(JAVAC) -classpath $(JAVA_CLASSPATH) -d . $(srcdir)/CommentParser.java JAVA_CLASSPATH := . -$(DOXYGEN_TEST_CASES:=.cpptest): JAVA_CLASSPATH := "$(JAVA_TOOLS_JAR)$(JAVA_CLASSPATH_SEP)." $(DOXYGEN_TEST_CASES:=.cpptest): CommentParser.class # Compiles java files then runs the testcase. A testcase is only run if diff --git a/Examples/test-suite/java/doxygen_alias_runme.java b/Examples/test-suite/java/doxygen_alias_runme.java index e21ed6d19..98cd97752 100644 --- a/Examples/test-suite/java/doxygen_alias_runme.java +++ b/Examples/test-suite/java/doxygen_alias_runme.java @@ -1,6 +1,5 @@ import doxygen_alias.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_alias_runme { @@ -15,10 +14,7 @@ public class doxygen_alias_runme { public static void main(String argv[]) { - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_alias runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_alias"}); + CommentParser.parse("doxygen_alias"); HashMap wantedComments = new HashMap(); wantedComments.put("doxygen_alias.doxygen_alias.make_something()", @@ -27,6 +23,6 @@ public class doxygen_alias_runme { " @return A new object which may be null.\n" + ""); - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java index e3d9b0279..621cc9eef 100644 --- a/Examples/test-suite/java/doxygen_basic_notranslate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_notranslate_runme.java @@ -1,6 +1,5 @@ import doxygen_basic_notranslate.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_basic_notranslate_runme { @@ -15,14 +14,7 @@ public class doxygen_basic_notranslate_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_basic_notranslate runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_basic_notranslate"}); + CommentParser.parse("doxygen_basic_notranslate"); HashMap wantedComments = new HashMap(); wantedComments.put("doxygen_basic_notranslate.doxygen_basic_notranslate.function3(int)", @@ -97,6 +89,6 @@ public class doxygen_basic_notranslate_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_basic_translate_runme.java b/Examples/test-suite/java/doxygen_basic_translate_runme.java index ab343b560..f0b1efb6b 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_runme.java @@ -1,6 +1,5 @@ import doxygen_basic_translate.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_basic_translate_runme { @@ -15,14 +14,7 @@ public class doxygen_basic_translate_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_basic_translate runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_basic_translate"}); + CommentParser.parse("doxygen_basic_translate"); HashMap wantedComments = new HashMap(); @@ -96,6 +88,6 @@ public class doxygen_basic_translate_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java index 05e51cff8..28cf2daba 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_style2_runme.java @@ -1,6 +1,5 @@ import doxygen_basic_translate_style2.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_basic_translate_style2_runme { @@ -15,14 +14,7 @@ public class doxygen_basic_translate_style2_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style2 runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_basic_translate_style2"}); + CommentParser.parse("doxygen_basic_translate_style2"); HashMap wantedComments = new HashMap(); @@ -96,6 +88,6 @@ public class doxygen_basic_translate_style2_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_ignore_runme.java b/Examples/test-suite/java/doxygen_ignore_runme.java index 6250ce525..29b6e0640 100644 --- a/Examples/test-suite/java/doxygen_ignore_runme.java +++ b/Examples/test-suite/java/doxygen_ignore_runme.java @@ -1,6 +1,5 @@ import doxygen_ignore.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_ignore_runme { @@ -15,10 +14,7 @@ public class doxygen_ignore_runme { public static void main(String argv[]) { - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_ignore runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_ignore"}); + CommentParser.parse("doxygen_ignore"); HashMap wantedComments = new HashMap(); wantedComments.put("doxygen_ignore.doxygen_ignore.func()", @@ -39,6 +35,6 @@ public class doxygen_ignore_runme { "\n" + ""); - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java index 5d95bd565..b1f4e2ef5 100644 --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java @@ -1,6 +1,5 @@ import doxygen_misc_constructs.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_misc_constructs_runme { @@ -15,14 +14,7 @@ public class doxygen_misc_constructs_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_misc_constructs runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_misc_constructs"}); + CommentParser.parse("doxygen_misc_constructs"); HashMap wantedComments = new HashMap(); @@ -195,6 +187,6 @@ public class doxygen_misc_constructs_runme { // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_nested_class_runme.java b/Examples/test-suite/java/doxygen_nested_class_runme.java index 3ffa796f0..e9d1a068e 100644 --- a/Examples/test-suite/java/doxygen_nested_class_runme.java +++ b/Examples/test-suite/java/doxygen_nested_class_runme.java @@ -1,5 +1,4 @@ import doxygen_nested_class.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_nested_class_runme { @@ -14,14 +13,7 @@ public class doxygen_nested_class_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_nested_class runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_nested_class"}); + CommentParser.parse("doxygen_nested_class"); HashMap wantedComments = new HashMap(); @@ -43,6 +35,6 @@ public class doxygen_nested_class_runme { " doxShort const variable "); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java index ef1f06af5..6b1e2b08e 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java @@ -1,6 +1,5 @@ import doxygen_parsing_enums_proper.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_parsing_enums_proper_runme { @@ -15,14 +14,7 @@ public class doxygen_parsing_enums_proper_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_parsing_enums_proper"}); + CommentParser.parse("doxygen_parsing_enums_proper"); HashMap wantedComments = new HashMap(); @@ -61,6 +53,6 @@ public class doxygen_parsing_enums_proper_runme { "Post comment after last comma."); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java index 85ec0cb55..1e0dd74ee 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java @@ -1,6 +1,5 @@ import doxygen_parsing_enums_simple.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_parsing_enums_simple_runme { @@ -15,14 +14,7 @@ public class doxygen_parsing_enums_simple_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_parsing_enums_simple"}); + CommentParser.parse("doxygen_parsing_enums_simple"); HashMap wantedComments = new HashMap(); @@ -53,6 +45,6 @@ public class doxygen_parsing_enums_simple_runme { "Post comment after last comma."); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java index 4e5f4b489..7cf3b17ef 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java @@ -1,6 +1,5 @@ import doxygen_parsing_enums_typesafe.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_parsing_enums_typesafe_runme { @@ -15,14 +14,7 @@ public class doxygen_parsing_enums_typesafe_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_parsing_enums_typesafe"}); + CommentParser.parse("doxygen_parsing_enums_typesafe"); HashMap wantedComments = new HashMap(); @@ -62,6 +54,6 @@ public class doxygen_parsing_enums_typesafe_runme { // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java index 428649196..3a41fe56f 100644 --- a/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java @@ -1,6 +1,5 @@ import doxygen_parsing_enums_typeunsafe.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_parsing_enums_typeunsafe_runme { @@ -15,14 +14,7 @@ public class doxygen_parsing_enums_typeunsafe_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"}); + CommentParser.parse("doxygen_parsing_enums_typeunsafe"); HashMap wantedComments = new HashMap(); @@ -61,6 +53,6 @@ public class doxygen_parsing_enums_typeunsafe_runme { "Post comment after last comma."); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index d58b1f486..10d65fca8 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -1,6 +1,5 @@ import doxygen_parsing.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_parsing_runme { @@ -15,14 +14,7 @@ public class doxygen_parsing_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_parsing runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_parsing"}); + CommentParser.parse("doxygen_parsing"); HashMap wantedComments = new HashMap(); @@ -136,6 +128,6 @@ public class doxygen_parsing_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index d5c533f4e..40702bdff 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -1,6 +1,5 @@ import doxygen_translate_all_tags.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_translate_all_tags_runme { @@ -15,14 +14,7 @@ public class doxygen_translate_all_tags_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_translate_all_tags runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_translate_all_tags"}); + CommentParser.parse("doxygen_translate_all_tags"); HashMap wantedComments = new HashMap(); @@ -154,6 +146,6 @@ public class doxygen_translate_all_tags_runme { " And here goes simple text \n" + ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/Examples/test-suite/java/doxygen_translate_links_runme.java b/Examples/test-suite/java/doxygen_translate_links_runme.java index 6d74e16fe..afee4eac6 100644 --- a/Examples/test-suite/java/doxygen_translate_links_runme.java +++ b/Examples/test-suite/java/doxygen_translate_links_runme.java @@ -1,6 +1,5 @@ import doxygen_translate_links.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_translate_links_runme { @@ -15,14 +14,7 @@ public class doxygen_translate_links_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_translate_links runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_translate_links"}); + CommentParser.parse("doxygen_translate_links"); HashMap wantedComments = new HashMap(); @@ -64,6 +56,6 @@ public class doxygen_translate_links_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } \ No newline at end of file diff --git a/Examples/test-suite/java/doxygen_translate_runme.java b/Examples/test-suite/java/doxygen_translate_runme.java index 55e5d23d3..b049a6466 100644 --- a/Examples/test-suite/java/doxygen_translate_runme.java +++ b/Examples/test-suite/java/doxygen_translate_runme.java @@ -1,6 +1,5 @@ import doxygen_translate.*; -import com.sun.javadoc.*; import java.util.HashMap; import java.util.Map; @@ -16,14 +15,7 @@ public class doxygen_translate_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_translate runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_translate"}); + CommentParser.parse("doxygen_translate"); Map wantedComments = new HashMap(); @@ -274,6 +266,6 @@ public class doxygen_translate_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } diff --git a/configure.ac b/configure.ac index ea469c24e..809a216e0 100644 --- a/configure.ac +++ b/configure.ac @@ -1408,15 +1408,6 @@ if test -z "$JAVA_HOME" && test -n "$JAVA_HOME_MAYBE" ; then fi fi -# Javadoc support required for the Java test-suite is available by default in jdk9+ and in tools.jar in earlier jdk versions -AC_MSG_CHECKING(for java tools.jar) -if test -n "$JAVA_HOME" && test -r "$JAVA_HOME/lib/tools.jar" ; then - JAVA_TOOLS_JAR="$JAVA_HOME/lib/tools.jar" - AC_MSG_RESULT([$JAVA_TOOLS_JAR]) -else - AC_MSG_RESULT(not found) -fi - case $host in *-*-cygwin*) # TODO: Only use this flag if the compiler supports it, later versions of gcc no longer have it @@ -1483,7 +1474,6 @@ AC_SUBST(JAVA) AC_SUBST(JAVAC) AC_SUBST(JAVAINC) AC_SUBST(JAVA_CLASSPATH_SEP) -AC_SUBST(JAVA_TOOLS_JAR) AC_SUBST(JAVADYNAMICLINKING) AC_SUBST(JAVALIBRARYPREFIX) AC_SUBST(JAVASO) From a271785f1a77a17c5c436bae4d1f9407b720db44 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2019 02:41:49 +0100 Subject: [PATCH 1774/2031] Revert "Remove Travis osx java testing" This reverts commit 66752cde4858a780fecba47793f99ba49ce8b15e as Doxygen tests do pass with Java 13 now. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e0d8ac74a..72ede27f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -449,11 +449,6 @@ matrix: env: SWIGLANG=php VER=7.2 sudo: required dist: xenial - # jdk 13 has removed tools.jar resulting in: CommentParser.java:2: error: package com.sun.javadoc does not exist - - compiler: clang - os: osx - env: SWIGLANG=java CPP17=1 - osx_image: xcode10.2 # Sometimes hits the Travis 50 minute time limit - compiler: clang os: osx From b52af4039856cce3dc924d970572350b85f2652d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2019 16:24:28 +0100 Subject: [PATCH 1775/2031] Disable Doxygen tests when using Java 8 or older Check Java version in configure and define SKIP_DOXYGEN_TEST_CASES if it's less than 9, which is required by the new implementation of CommentParser used in the Doxygen tests. --- Examples/test-suite/common.mk | 5 ++++- Examples/test-suite/java/Makefile.in | 1 + configure.ac | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5f7792810..c817bdf80 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -610,11 +610,14 @@ CPP11_TEST_BROKEN = \ # cpp11_reference_wrapper \ # No typemaps # Doxygen support test cases: can only be used with languages supporting -# Doxygen comment translation, currently only Python and Java. +# Doxygen comment translation (currently Python and Java) and only if not +# disabled by configure via SKIP_DOXYGEN_TEST_CASES. +ifneq ($(SKIP_DOXYGEN_TEST_CASES),1) python_HAS_DOXYGEN := 1 java_HAS_DOXYGEN := 1 $(eval HAS_DOXYGEN := $($(LANGUAGE)_HAS_DOXYGEN)) +endif ifdef HAS_DOXYGEN DOXYGEN_TEST_CASES += \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 3f4a71711..f8e290ee3 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -9,6 +9,7 @@ JAVAFLAGS = @JAVAFLAGS@ JAVA_CLASSPATH_SEP = @JAVA_CLASSPATH_SEP@ JAVA_TOOLS_JAR = @JAVA_TOOLS_JAR@ SCRIPTSUFFIX = _runme.java +SKIP_DOXYGEN_TEST_CASES = @JAVA_SKIP_DOXYGEN_TEST_CASES@ srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ diff --git a/configure.ac b/configure.ac index 809a216e0..13b37d4ad 100644 --- a/configure.ac +++ b/configure.ac @@ -1348,6 +1348,33 @@ else JAVAC="$JAVACBIN" fi +# Check Java version: we require Java 9 or later for Doxygen tests. +if test -n "$JAVAC"; then + AC_MSG_CHECKING(if java version is 9 or greater) + javac_version=`$JAVAC -version 2>&1` + java_version_num=`echo $javac_version | sed -n 's/^javac //p'` + if test -z "$java_version_num"; then + AC_MSG_WARN([unknown format for Java version returned by $JAVAC ($javac_version)]) + JAVA_SKIP_DOXYGEN_TEST_CASES=1 + AC_MSG_RESULT(unknown) + else + dnl Until Java 8 version number was in format "1.x", starting from + dnl Java 9 it's just "x". + case $java_version_num in + 1.*) + JAVA_SKIP_DOXYGEN_TEST_CASES=1 + AC_MSG_RESULT([no, disabling Doxygen tests]) + ;; + + *) + AC_MSG_RESULT(yes) + ;; + esac + fi + + AC_SUBST(JAVA_SKIP_DOXYGEN_TEST_CASES) +fi + AC_MSG_CHECKING(for java include file jni.h) AC_ARG_WITH(javaincl, [ --with-javaincl=path Set location of Java include directory], [JAVAINCDIR="$withval"], [JAVAINCDIR=]) From e7d0533a6feebbfce9813998f9d059a99aaed6dd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 19 Dec 2019 16:17:24 +0100 Subject: [PATCH 1776/2031] Quote JAVAC expansion in configure to deal with spaces This avoids errors about unknown Java version format when JAVAC is in a path with spaces in it (as is often the case under Windows). --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 13b37d4ad..b4cadefd0 100644 --- a/configure.ac +++ b/configure.ac @@ -1351,10 +1351,10 @@ fi # Check Java version: we require Java 9 or later for Doxygen tests. if test -n "$JAVAC"; then AC_MSG_CHECKING(if java version is 9 or greater) - javac_version=`$JAVAC -version 2>&1` + javac_version=`"$JAVAC" -version 2>&1` java_version_num=`echo $javac_version | sed -n 's/^javac //p'` if test -z "$java_version_num"; then - AC_MSG_WARN([unknown format for Java version returned by $JAVAC ($javac_version)]) + AC_MSG_WARN([unknown format for Java version returned by "$JAVAC" ($javac_version)]) JAVA_SKIP_DOXYGEN_TEST_CASES=1 AC_MSG_RESULT(unknown) else From a2d9a24f4da36a454e116c03f710f62e3ae1c9f8 Mon Sep 17 00:00:00 2001 From: Markus Friedrich Date: Tue, 24 Dec 2019 14:06:25 +0100 Subject: [PATCH 1777/2031] Changed return type of swig_this() to size_t. The type long may be 4 bytes but swig_this() must return the address of the object as an integer. Using size_t ensures that the return type can store a pointer. --- Lib/octave/octrun.swg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index ff614e681..325a4cca3 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -507,10 +507,10 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); delete this; } - long swig_this() const { + size_t swig_this() const { if (!types.size()) - return (long) this; - return (long) types[0].second.ptr; + return (size_t) this; + return (size_t) types[0].second.ptr; } const char* help_text() const { if (!types.size()) From 02862fb278a8d772e1f0480adc935c33b9625da4 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 29 Dec 2019 22:41:43 -0700 Subject: [PATCH 1778/2031] [OCaml] Fix compilation errors with OCaml 4.09.0 caml_named_value() was modified to return a const value* in OCaml 4.09.0. Closes #1686. --- CHANGES.current | 3 +++ Lib/ocaml/carray.i | 2 +- Lib/ocaml/ocaml.swg | 4 ++-- Lib/ocaml/ocamlrun.swg | 6 +++--- Source/Modules/ocaml.cxx | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 09facd90b..9c1e8a2b3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2019-12-29: ZackerySpytz + [OCaml] #1686 Fix compilation errors with OCaml 4.09.0. + 2019-12-10: wsfulton #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when they are used as part of the scope name of an identifier, such as a namespace name. diff --git a/Lib/ocaml/carray.i b/Lib/ocaml/carray.i index 5e74c3da1..4378f7333 100644 --- a/Lib/ocaml/carray.i +++ b/Lib/ocaml/carray.i @@ -77,7 +77,7 @@ type _value = c_obj %typemap(out) SWIGTYPE [] { int i; - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); $result = caml_array_new($1_dim0); for( i = 0; i < $1_dim0; i++ ) { diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index ac496bdba..afb01daea 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -62,7 +62,7 @@ #if 0 %typemap(argout) SWIGTYPE & { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, @@ -75,7 +75,7 @@ } } %typemap(argout) SWIGTYPE && { - CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); + const CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); if( fromval ) { swig_result = caml_list_append(swig_result, diff --git a/Lib/ocaml/ocamlrun.swg b/Lib/ocaml/ocamlrun.swg index 3d552cc50..5a923c5fe 100644 --- a/Lib/ocaml/ocamlrun.swg +++ b/Lib/ocaml/ocamlrun.swg @@ -407,7 +407,7 @@ extern "C" { CAMLreturn((long)SWIG_Int64_val(SWIG_Field(SWIG_Field(v,0),0))); case C_enum: { SWIG_CAMLlocal1(ret); - CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); + const CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); if( !name ) caml_failwith( "Not an enum conversion" ); ret = caml_callback2(*enum_to_int,*caml_named_value(name),v); CAMLreturn(caml_long_val(ret)); @@ -451,7 +451,7 @@ extern "C" { CAMLparam1(v); void *outptr = NULL; swig_type_info *outdescr = NULL; - static CAML_VALUE *func_val = NULL; + static const CAML_VALUE *func_val = NULL; if( v == Val_unit ) { *out = 0; @@ -574,7 +574,7 @@ extern "C" { CAMLparam0(); SWIG_CAMLlocal1(result); - CAML_VALUE *fromval = caml_named_value(name); + const CAML_VALUE *fromval = caml_named_value(name); if (fromval) { result = caml_callback(*fromval, caml_val_ptr(ptr, descriptor)); } else { diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 6f2a34962..9f7504b87 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1619,7 +1619,7 @@ public: /* pass the method call on to the OCaml object */ Printv(w->code, "swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0); - Printf(w->code, "static CAML_VALUE *swig_ocaml_func_val = NULL;\n" "if (!swig_ocaml_func_val) {\n"); + Printf(w->code, "static const CAML_VALUE *swig_ocaml_func_val = NULL;\n" "if (!swig_ocaml_func_val) {\n"); Printf(w->code, " swig_ocaml_func_val = caml_named_value(\"swig_runmethod\");\n }\n"); Printf(w->code, "swig_result = caml_callback3(*swig_ocaml_func_val,swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name")); /* exception handling */ From 5259082cb175737ffc1712587571927711855773 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 30 Dec 2019 23:17:35 +0000 Subject: [PATCH 1779/2031] Test Ruby 2.7 on Travis Generated code does not yet compile, so set as allow_failure for now rvm master currently needs to be installed when testing ruby-2.7 on Travis --- .travis.yml | 11 +++++++++++ Tools/travis-linux-install.sh | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/.travis.yml b/.travis.yml index 72ede27f9..b7a0866ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -300,6 +300,11 @@ matrix: env: SWIGLANG=ruby VER=2.6 sudo: required dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.7 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=scilab @@ -449,6 +454,12 @@ matrix: env: SWIGLANG=php VER=7.2 sudo: required dist: xenial + # Not yet supported + - compiler: gcc + os: linux + env: SWIGLANG=ruby VER=2.7 + sudo: required + dist: xenial # Sometimes hits the Travis 50 minute time limit - compiler: clang os: osx diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index e902137df..27703a378 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -95,6 +95,12 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install r-base ;; "ruby") + if [[ "$VER" == "2.7" ]]; then + # Ruby 2.7 support is currently only rvm master (30 Dec 2019) + travis_retry rvm get master + rvm reload + rvm list known + fi if [[ "$VER" ]]; then travis_retry rvm install $VER fi From 558f0ba485702d2c2146640e345ba39da3847deb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Dec 2019 07:29:11 +0000 Subject: [PATCH 1780/2031] Ruby globalmodule variables test enhancement Check that the variables values are as expected in C++. Note that the check_values global function is global in Ruby when using -globalmodule. --- Examples/test-suite/global_immutable_vars.i | 9 +++++++++ Examples/test-suite/global_immutable_vars_cpp.i | 9 +++++++++ .../test-suite/ruby/global_immutable_vars_cpp_runme.rb | 1 + Examples/test-suite/ruby/global_immutable_vars_runme.rb | 1 + .../ruby/ruby_global_immutable_vars_cpp_runme.rb | 1 + .../test-suite/ruby/ruby_global_immutable_vars_runme.rb | 1 + Examples/test-suite/ruby_global_immutable_vars.i | 9 +++++++++ Examples/test-suite/ruby_global_immutable_vars_cpp.i | 9 +++++++++ 8 files changed, 40 insertions(+) diff --git a/Examples/test-suite/global_immutable_vars.i b/Examples/test-suite/global_immutable_vars.i index cd8cb184b..ab0d4f7a8 100644 --- a/Examples/test-suite/global_immutable_vars.i +++ b/Examples/test-suite/global_immutable_vars.i @@ -20,5 +20,14 @@ %inline %{ int global_mutable_var = 43; int specific_immutable_var = 44; + + int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) { + return + default_mutable == default_mutable_var && + global_immutable == global_immutable_var && + specific_mutable == specific_mutable_var && + global_mutable == global_mutable_var && + specific_immutable == specific_immutable_var; + } %} diff --git a/Examples/test-suite/global_immutable_vars_cpp.i b/Examples/test-suite/global_immutable_vars_cpp.i index 66eb8545d..40cc08e54 100644 --- a/Examples/test-suite/global_immutable_vars_cpp.i +++ b/Examples/test-suite/global_immutable_vars_cpp.i @@ -20,5 +20,14 @@ %inline %{ int global_mutable_var = 43; int specific_immutable_var = 44; + + int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) { + return + default_mutable == default_mutable_var && + global_immutable == global_immutable_var && + specific_mutable == specific_mutable_var && + global_mutable == global_mutable_var && + specific_immutable == specific_immutable_var; + } %} diff --git a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb index c40896a86..7897f7da5 100644 --- a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb +++ b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb @@ -45,3 +45,4 @@ end swig_assert(had_exception, nil, "Global_immutable_vars_cpp::specific_immutable_var is writable (expected to be immutable)") +swig_assert(Global_immutable_vars_cpp::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed") diff --git a/Examples/test-suite/ruby/global_immutable_vars_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_runme.rb index af55cfeb3..ffbea270f 100644 --- a/Examples/test-suite/ruby/global_immutable_vars_runme.rb +++ b/Examples/test-suite/ruby/global_immutable_vars_runme.rb @@ -49,3 +49,4 @@ end swig_assert(had_exception, nil, "Global_immutable_vars::specific_immutable_var is writable (expected to be immutable)") +swig_assert(Global_immutable_vars::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed") diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb index 8453254eb..5523b59f4 100644 --- a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb +++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb @@ -45,3 +45,4 @@ end swig_assert(had_exception, nil, "$specific_immutable_var is writable (expected to be immutable)") +swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed") diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb index fda1ccf0f..45a8506ba 100644 --- a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb +++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb @@ -49,3 +49,4 @@ end swig_assert(had_exception, nil, "$specific_immutable_var is writable (expected to be immutable)") +swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed") diff --git a/Examples/test-suite/ruby_global_immutable_vars.i b/Examples/test-suite/ruby_global_immutable_vars.i index dc49cd946..6f067d269 100644 --- a/Examples/test-suite/ruby_global_immutable_vars.i +++ b/Examples/test-suite/ruby_global_immutable_vars.i @@ -21,5 +21,14 @@ %inline %{ int global_mutable_var = 43; int specific_immutable_var = 44; + + int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) { + return + default_mutable == default_mutable_var && + global_immutable == global_immutable_var && + specific_mutable == specific_mutable_var && + global_mutable == global_mutable_var && + specific_immutable == specific_immutable_var; + } %} diff --git a/Examples/test-suite/ruby_global_immutable_vars_cpp.i b/Examples/test-suite/ruby_global_immutable_vars_cpp.i index cf3145e80..511390e20 100644 --- a/Examples/test-suite/ruby_global_immutable_vars_cpp.i +++ b/Examples/test-suite/ruby_global_immutable_vars_cpp.i @@ -19,5 +19,14 @@ %inline %{ int global_mutable_var = 43; int specific_immutable_var = 44; + + int check_values(int default_mutable, int global_immutable, int specific_mutable, int global_mutable, int specific_immutable) { + return + default_mutable == default_mutable_var && + global_immutable == global_immutable_var && + specific_mutable == specific_mutable_var && + global_mutable == global_mutable_var && + specific_immutable == specific_immutable_var; + } %} From 9d1244c712c0345aae246f2e3c3da4ebbbcc2567 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 30 Dec 2019 23:52:39 +0000 Subject: [PATCH 1781/2031] Add changes entry for Ruby -globamodule fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 09facd90b..d6bc68dab 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2019-12-30: treitmayr + [Ruby] #1653 #1668 Fix code generated when using -globalmodule option. + 2019-12-10: wsfulton #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when they are used as part of the scope name of an identifier, such as a namespace name. From 00e291b319bd6b58bf061feee3721a58c9c6be32 Mon Sep 17 00:00:00 2001 From: Thomas Reitmayr Date: Mon, 30 Dec 2019 20:11:03 +0100 Subject: [PATCH 1782/2031] Add support for Ruby 2.7 This commit fixes the signatures of various callback methods and cleans up the macro definitions used for casting callbacks. Note that the transparent version of the macro RUBY_METHOD_FUNC is currently masked behind RUBY_DEVEL, see commit https://github.com/ruby/ruby/commit/1d91feaf13e0ffe04b2dabc6e77e4101b6d0bb07 In order to still support strict signature checking and prevent nasty deprecation warnings, the use of RUBY_METHOD_FUNC had to be replaced with VALUEFUNC. --- Lib/ruby/rubyclasses.swg | 14 +++++++------- Lib/ruby/rubyhead.swg | 26 +++++++++----------------- Lib/ruby/rubyprimtypes.swg | 15 ++++++++------- Lib/ruby/rubytracking.swg | 10 +++++----- Source/Modules/ruby.cxx | 22 +++++++++------------- 5 files changed, 38 insertions(+), 49 deletions(-) diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg index f7b51bdcc..b345fcebe 100644 --- a/Lib/ruby/rubyclasses.swg +++ b/Lib/ruby/rubyclasses.swg @@ -174,7 +174,7 @@ namespace swig { return rb_inspect(_obj); } - static VALUE swig_rescue_swallow(VALUE) + static VALUE swig_rescue_swallow(VALUE, VALUE) { /* VALUE errstr = rb_obj_as_string(rb_errinfo()); @@ -203,8 +203,8 @@ namespace swig { args.id = op_id; args.nargs = 1; args.target = VALUE(other); - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args), + (VALUEFUNC(swig_rescue_swallow)), Qnil); } if (ret == Qnil) { VALUE a = rb_funcall( _obj, hash_id, 0 ); @@ -243,8 +243,8 @@ namespace swig { args.id = op_id; args.nargs = 0; args.target = Qnil; - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args), + (VALUEFUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return ret; } @@ -262,8 +262,8 @@ namespace swig { args.id = op_id; args.nargs = 1; args.target = VALUE(other); - ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args), - (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil); + ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args), + (VALUEFUNC(swig_rescue_swallow)), Qnil); SWIG_RUBY_THREAD_END_BLOCK; return GC_VALUE(ret); } diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 90f07cf68..9a0400eea 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -110,26 +110,18 @@ * can be passed as an argument to API functions like Data_Wrap_Struct() * and Data_Make_Struct(). */ - -#ifdef __cplusplus -# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((void (*)()) f) -# else -# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */ -# define PROTECTFUNC(f) ((VALUE (*)()) f) -# define VALUEFUNC(f) ((VALUE (*)()) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# else /* These definitions should work for Ruby 1.7+ */ -# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) -# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) -# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# endif -# endif +#if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) +# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) +# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) +# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) +# define VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else +# define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) +# define VOID_ANYARGS_FUNC(f) (f) +# define INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg index 3a848191c..4b078deea 100644 --- a/Lib/ruby/rubyprimtypes.swg +++ b/Lib/ruby/rubyprimtypes.swg @@ -10,15 +10,16 @@ %fragment("SWIG_ruby_failed","header") { SWIGINTERN VALUE -SWIG_ruby_failed(void) +SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2)) { return Qnil; } } %define %ruby_aux_method(Type, Method, Action) -SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args) +SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE arg) { + VALUE *args = (VALUE *)arg; VALUE obj = args[0]; VALUE type = TYPE(obj); Type *res = (Type *)(args[1]); @@ -79,7 +80,7 @@ SWIG_AsVal_dec(long)(VALUE obj, long* val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -111,7 +112,7 @@ SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -149,7 +150,7 @@ SWIG_AsVal_dec(long long)(VALUE obj, long long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -187,7 +188,7 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } @@ -215,7 +216,7 @@ SWIG_AsVal_dec(double)(VALUE obj, double *val) VALUE a[2]; a[0] = obj; a[1] = (VALUE)(&v); - if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) { + if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) { if (val) *val = v; return SWIG_OK; } diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index b9fb249d8..221a68193 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -32,7 +32,7 @@ extern "C" { */ static st_table* swig_ruby_trackings = NULL; -static VALUE swig_ruby_trackings_count(ANYARGS) { +static VALUE swig_ruby_trackings_count(ID id, VALUE *var) { return SWIG2NUM(swig_ruby_trackings->num_entries); } @@ -69,7 +69,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); } - rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", VALUEFUNC(swig_ruby_trackings_count), VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ @@ -118,13 +118,13 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) { to the passed callback function. */ /* Proxy method to abstract the internal trackings datatype */ -static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) { - (*meth)(ptr, obj); +static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) { + ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj); return ST_CONTINUE; } SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { - st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth); + st_foreach(swig_ruby_trackings, INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), (st_data_t)meth); } #ifdef __cplusplus diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index c8f582679..01b75befa 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2191,6 +2191,7 @@ public: String *tm; String *getfname, *setfname; Wrapper *getf, *setf; + const int assignable = is_assignable(n); // Determine whether virtual global variables shall be used // which have different getter and setter signatures, @@ -2206,7 +2207,7 @@ public: getfname = Swig_name_wrapper(getname); Setattr(n, "wrap:name", getfname); Printv(getf->def, "SWIGINTERN VALUE\n", getfname, "(", NIL); - Printf(getf->def, (use_virtual_var) ? "ID id" : "VALUE self"); + Printf(getf->def, (use_virtual_var) ? "ID id, VALUE *data" : "VALUE self"); Printf(getf->def, ") {"); Wrapper_add_local(getf, "_val", "VALUE _val"); @@ -2229,8 +2230,8 @@ public: Wrapper_print(getf, f_wrappers); - if (!is_assignable(n)) { - setfname = NewString("NULL"); + if (!assignable) { + setfname = NewString("(rb_gvar_setter_t *)NULL"); } else { /* create setter */ String* docs = docstring(n, AUTODOC_SETTER); @@ -2242,7 +2243,7 @@ public: Setattr(n, "wrap:name", setfname); Printf(setf->def, "SWIGINTERN "); if (use_virtual_var) { - Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id) {", NIL); + Printv(setf->def, "void\n", setfname, "(VALUE _val, ID id, VALUE *data) {", NIL); } else { Printv(setf->def, "VALUE\n", setfname, "(VALUE self, VALUE _val) {", NIL); } @@ -2273,7 +2274,7 @@ public: if (CPlusPlus) { Insert(getfname, 0, "VALUEFUNC("); Append(getfname, ")"); - Insert(setfname, 0, (use_virtual_var) ? "(void (*)(ANYARGS))(" : "VALUEFUNC("); + Insert(setfname, 0, (use_virtual_var) ? "VOID_ANYARGS_FUNC(" : "VALUEFUNC("); Append(setfname, ")"); } @@ -2282,7 +2283,7 @@ public: case STATIC_VAR: /* C++ class variable */ Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "\", ", getfname, ", 0);\n", NIL); - if (!GetFlag(n, "feature:immutable")) { + if (assignable) { Printv(s, tab4, "rb_define_singleton_method(", klass->vname, ", \"", klass->strip(iname), "=\", ", setfname, ", 1);\n", NIL); } Printv(klass->init, s, NIL); @@ -2293,16 +2294,11 @@ public: assert(current == NO_CPP); if (!useGlobalModule) { Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "\", ", getfname, ", 0);\n", NIL); - if (!GetFlag(n, "feature:immutable")) { + if (assignable) { Printv(s, tab4, "rb_define_singleton_method(", modvar, ", \"", iname, "=\", ", setfname, ", 1);\n", NIL); } } else { - Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", NIL); - if (GetFlag(n, "feature:immutable")) { - Printv(s, tab4, "0);\n", NIL); - } else { - Printv(s, tab4, setfname, ");\n", NIL); - } + Printv(s, tab4, "rb_define_virtual_variable(\"$", iname, "\", ", getfname, ", ", setfname, ");\n", NIL); } Printv(f_init, s, NIL); Delete(s); From 5542cc228ad10bdc5c91107afb77c808c43bf2a4 Mon Sep 17 00:00:00 2001 From: Thomas Reitmayr Date: Fri, 3 Jan 2020 21:45:53 +0100 Subject: [PATCH 1783/2031] Move new macros for Ruby to their dedicated namespace --- Lib/ruby/rubyhead.swg | 8 ++++---- Lib/ruby/rubytracking.swg | 8 ++++++-- Source/Modules/ruby.cxx | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 9a0400eea..89d6f1466 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -114,14 +114,14 @@ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f) # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f) -# define VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) -# define INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f)) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f)) #else # define PROTECTFUNC(f) (f) # define VALUEFUNC(f) (f) # define VOIDFUNC(f) (f) -# define VOID_ANYARGS_FUNC(f) (f) -# define INT_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f) +# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f) #endif /* Don't use for expressions have side effect */ diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 221a68193..1edcc5681 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -69,7 +69,9 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) { swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value); } - rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", VALUEFUNC(swig_ruby_trackings_count), VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); + rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", + VALUEFUNC(swig_ruby_trackings_count), + SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL)); } /* Add a Tracking from a C/C++ struct to a Ruby object */ @@ -124,7 +126,9 @@ static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_ } SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) { - st_foreach(swig_ruby_trackings, INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), (st_data_t)meth); + st_foreach(swig_ruby_trackings, + SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback), + (st_data_t)meth); } #ifdef __cplusplus diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 01b75befa..fcbcb7a5c 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2274,7 +2274,7 @@ public: if (CPlusPlus) { Insert(getfname, 0, "VALUEFUNC("); Append(getfname, ")"); - Insert(setfname, 0, (use_virtual_var) ? "VOID_ANYARGS_FUNC(" : "VALUEFUNC("); + Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC("); Append(setfname, ")"); } From f5908eca7638b786acda58306ba96ff70094e98b Mon Sep 17 00:00:00 2001 From: Thomas Reitmayr Date: Sat, 4 Jan 2020 18:21:10 +0100 Subject: [PATCH 1784/2031] Improve description of cast macros for Ruby The macros for casting function pointers are now fully described and also clarify why the macros act transparently for C even before Ruby 2.7. In addition, an "if (CPlusPlus)" was removed in the code generator for global variables in order to keep the distinction between C and C++ in one place, which is at the definition of said macros. --- Lib/ruby/rubyhead.swg | 32 ++++++++++++++++++++++++-------- Source/Modules/ruby.cxx | 12 +++++------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 89d6f1466..bf4e36248 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -98,17 +98,33 @@ /* - * Need to be very careful about how these macros are defined, especially - * when compiling C++ code or C code with an ANSI C compiler. + * The following macros are used for providing the correct type of a + * function pointer to the Ruby C API. + * Starting with Ruby 2.7 (corresponding to RB_METHOD_DEFINITION_DECL being + * defined) these macros act transparently due to Ruby's moving away from + * ANYARGS and instead employing strict function signatures. * - * VALUEFUNC(f) is a macro used to typecast a C function that implements - * a Ruby method so that it can be passed as an argument to API functions - * like rb_define_method() and rb_define_singleton_method(). + * Note: In case of C (not C++) the macros are transparent even before + * Ruby 2.7 due to the fact that the Ruby C API used function declarators + * with empty parentheses, which allows for an unspecified number of + * arguments. * - * VOIDFUNC(f) is a macro used to typecast a C function that implements - * either the "mark" or "free" stuff for a Ruby Data object, so that it - * can be passed as an argument to API functions like Data_Wrap_Struct() + * PROTECTFUNC(f) is used for the function pointer argument of the Ruby + * C API function rb_protect(). + * + * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API + * functions like rb_define_method() and rb_define_singleton_method(). + * + * VOIDFUNC(f) is used to typecast a C function that implements either + * the "mark" or "free" stuff for a Ruby Data object, so that it can be + * passed as an argument to Ruby C API functions like Data_Wrap_Struct() * and Data_Make_Struct(). + * + * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like rb_define_virtual_variable(). + * + * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer + * argument(s) of Ruby C API functions like st_foreach(). */ #if defined(__cplusplus) && !defined(RB_METHOD_DEFINITION_DECL) # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f) diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index fcbcb7a5c..48b0efab3 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2270,13 +2270,11 @@ public: Delete(setname); } - /* define accessor method */ - if (CPlusPlus) { - Insert(getfname, 0, "VALUEFUNC("); - Append(getfname, ")"); - Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC("); - Append(setfname, ")"); - } + /* define accessor methods */ + Insert(getfname, 0, "VALUEFUNC("); + Append(getfname, ")"); + Insert(setfname, 0, (use_virtual_var) ? "SWIG_RUBY_VOID_ANYARGS_FUNC(" : "VALUEFUNC("); + Append(setfname, ")"); String *s = NewString(""); switch (current) { From eaa16914d1686002d33cb3f61875832977146805 Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Sun, 5 Jan 2020 03:32:10 +0300 Subject: [PATCH 1785/2031] Adding tp_vectorcall field to PyTypeObject for Python version 3.8 --- Lib/python/builtin.swg | 6 ++++++ Lib/python/pyinit.swg | 3 +++ Lib/python/pyrun.swg | 6 ++++++ Source/Modules/python.cxx | 3 +++ 4 files changed, 18 insertions(+) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 28051e67b..dbaf20d76 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -256,6 +256,9 @@ SwigPyStaticVar_Type(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -334,6 +337,9 @@ SwigPyObjectType(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index dfbf40b34..129e38480 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -186,6 +186,9 @@ swig_varlink_type(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 82859b887..5dec384d3 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -696,6 +696,9 @@ SwigPyObject_TypeOnce(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ @@ -857,6 +860,9 @@ SwigPyPacked_TypeOnce(void) { #if PY_VERSION_HEX >= 0x03040000 0, /* tp_finalize */ #endif +#if PY_VERSION_HEX >= 0x03080000 + 0, /* tp_vectorcall */ +#endif #ifdef COUNT_ALLOCS 0, /* tp_allocs */ 0, /* tp_frees */ diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 4792090ea..bc7119614 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4134,6 +4134,9 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x03040000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_finalize"), "tp_finalize", "destructor"); Printv(f, "#endif\n", NIL); + Printv(f, "#if PY_VERSION_HEX >= 0x03080000\n", NIL); + printSlot(f, getSlot(n, "feature:python:tp_vectorcall"), "tp_vectorcall", "vectorcallfunc"); + Printv(f, "#endif\n", NIL); Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_allocs"), "tp_allocs", "Py_ssize_t"); printSlot(f, getSlot(n, "feature:python:tp_frees"), "tp_frees", "Py_ssize_t"); From 6c476ba3cf5099058f5162969103027399ec39e0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 10:38:15 +0000 Subject: [PATCH 1786/2031] Ruby 2.7 support --- .travis.yml | 6 ------ CHANGES.current | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7a0866ea..0c8efe39e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -454,12 +454,6 @@ matrix: env: SWIGLANG=php VER=7.2 sudo: required dist: xenial - # Not yet supported - - compiler: gcc - os: linux - env: SWIGLANG=ruby VER=2.7 - sudo: required - dist: xenial # Sometimes hits the Travis 50 minute time limit - compiler: clang os: osx diff --git a/CHANGES.current b/CHANGES.current index d6bc68dab..54e86f7c9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-05: treitmayr + [Ruby] #1692 #1689 Add support for Ruby 2.7 + 2019-12-30: treitmayr [Ruby] #1653 #1668 Fix code generated when using -globalmodule option. From dca59bb5f716fa264fb3ed46c6ca7043769f0690 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 11:14:16 +0000 Subject: [PATCH 1787/2031] Add changes entry for Octave swig_this() fix for Windows 64bit --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 54e86f7c9..3d68b9d89 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-05: friedrichatgc + [Octave] #1688 Change swig_this() to use size_t instead of long for compatibility + with Windows 64 bit. + 2020-01-05: treitmayr [Ruby] #1692 #1689 Add support for Ruby 2.7 From 489629fd532593cbf856a22990b520f770561984 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 22:40:41 +0000 Subject: [PATCH 1788/2031] Python 3.8 builtin tp_print initializer Add missing initializer for tp_print added in python-3.8 when using -builtin Issue #1670 --- Source/Modules/python.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bc7119614..4569c2d8a 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4137,6 +4137,10 @@ public: Printv(f, "#if PY_VERSION_HEX >= 0x03080000\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_vectorcall"), "tp_vectorcall", "vectorcallfunc"); Printv(f, "#endif\n", NIL); + Printv(f, "#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)\n", NIL); + printSlot(f, getSlot(), "tp_print"); + Printv(f, "#endif\n", NIL); + Printv(f, "#ifdef COUNT_ALLOCS\n", NIL); printSlot(f, getSlot(n, "feature:python:tp_allocs"), "tp_allocs", "Py_ssize_t"); printSlot(f, getSlot(n, "feature:python:tp_frees"), "tp_frees", "Py_ssize_t"); From bc39311cc967e2565aa6381c0c98a16c3ce9ef7d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 22:45:16 +0000 Subject: [PATCH 1789/2031] Add changes entry for missing python 3.8 field initializers --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 3d68b9d89..887667b0b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-05: jschueller shadchin + [Python] #1670 #1696 Add missing field initializers introduced in python 3.8: + tp_vectorcall and tp_print. + 2020-01-05: friedrichatgc [Octave] #1688 Change swig_this() to use size_t instead of long for compatibility with Windows 64 bit. From 37997e26ce0928c7b09d4fed4645e0bc904068e3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 15:05:53 +0000 Subject: [PATCH 1790/2031] Test Python 3.8 on Travis --- .travis.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c8efe39e..d40304fd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -202,6 +202,11 @@ matrix: env: SWIGLANG=python PY3=3 VER=3.7 sudo: required dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.8 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin @@ -217,7 +222,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.7 + env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.8 sudo: required dist: xenial - compiler: gcc @@ -237,12 +242,17 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.7 + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.8 sudo: required dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7 SWIGOPTPY3= + env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.8 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.8 SWIGOPTPY3= sudo: required dist: xenial - compiler: gcc @@ -252,7 +262,7 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.7 + env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.8 sudo: required dist: xenial - compiler: gcc @@ -384,7 +394,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.7 + env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.8 sudo: required dist: xenial - os: linux @@ -396,7 +406,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.7 + env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.8 sudo: required dist: xenial - compiler: gcc From 666752d521347f5632444d962f3701d2ba73c249 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 7 Jan 2020 18:59:17 +0000 Subject: [PATCH 1791/2031] Test multiple versions of D on Travis. 2.081 is reportedly broken and 2.086 was tested and fixed in #1594. --- .travis.yml | 13 ++++++++++++- Tools/travis-linux-install.sh | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d40304fd6..32c6656dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,12 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=d + env: SWIGLANG=d VER=2.066.0 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=d VER=2.086.1 sudo: required dist: xenial - compiler: gcc @@ -458,6 +463,12 @@ matrix: osx_image: xcode10.2 allow_failures: + # Newer version of D not yet working/supported + - compiler: gcc + os: linux + env: SWIGLANG=d VER=2.086.1 + sudo: required + dist: xenial # seg fault in director_basic testcase - compiler: gcc os: linux diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index 27703a378..c8347d27a 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -23,8 +23,8 @@ case "$SWIGLANG" in travis_retry sudo apt-get -qq install mono-devel ;; "d") - travis_retry wget http://downloads.dlang.org/releases/2014/dmd_2.066.0-0_amd64.deb - travis_retry sudo dpkg -i dmd_2.066.0-0_amd64.deb + travis_retry wget http://downloads.dlang.org/releases/2.x/${VER}/dmd_${VER}-0_amd64.deb + travis_retry sudo dpkg -i dmd_${VER}-0_amd64.deb ;; "go") if [[ "$VER" ]]; then From 6adf19b52fe2e16b2786961d4cd2b2967f96849d Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 9 Jan 2020 21:14:12 -0700 Subject: [PATCH 1792/2031] Check Py{Bytes,String}_AsStringAndSize() for failure PyBytes_AsStringAndSize() and PyString_AsStringAndSize() were not being checked for failure. Closes #1349. --- Lib/python/pyhead.swg | 5 ++++- Lib/python/pystrings.swg | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index c820f9016..da8207ad7 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -43,8 +43,11 @@ SWIG_Python_str_AsChar(PyObject *str) if (str) { char *cstr; Py_ssize_t len; - PyBytes_AsStringAndSize(str, &cstr, &len); + if (PyBytes_AsStringAndSize(str, &cstr, &len) == -1) + return NULL; newstr = (char *) malloc(len+1); + if (!newstr) + return NULL; memcpy(newstr, cstr, len+1); Py_XDECREF(str); } diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 93f48acfa..64ed685e8 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -32,9 +32,11 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) if (alloc) *alloc = SWIG_NEWOBJ; %#endif - PyBytes_AsStringAndSize(obj, &cstr, &len); + if (PyBytes_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; %#else - PyString_AsStringAndSize(obj, &cstr, &len); + if (PyString_AsStringAndSize(obj, &cstr, &len) == -1) + return SWIG_TypeError; %#endif if (cptr) { if (alloc) { From 67e8334ac82a0aa80667abeea8f68960824e1019 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 5 Jan 2020 14:06:03 +0000 Subject: [PATCH 1793/2031] Python -builtin constructors silently ignored keyword arguments. Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" exception is thrown if keyword arguments are used. Hence constructors and normal methods/functions behave in the same way. Closes issue #1595 --- CHANGES.current | 7 + Examples/test-suite/common.mk | 1 + Examples/test-suite/cpp_parameters.i | 46 +++ .../test-suite/python/cpp_parameters_runme.py | 296 ++++++++++++++++++ Lib/python/pyrun.swg | 13 + Source/Modules/python.cxx | 17 +- 6 files changed, 376 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/cpp_parameters.i create mode 100644 Examples/test-suite/python/cpp_parameters_runme.py diff --git a/CHANGES.current b/CHANGES.current index 09facd90b..e4f18ca41 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-13: wsfulton + [Python] #1595 Python -builtin constructors silently ignored keyword arguments. + Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" + exception is thrown if keyword arguments are used. Hence constructors and normal methods/ + functions behave in the same way. Note, -keyword should be used with -builtin to obtain + keyword argument support. + 2019-12-10: wsfulton #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when they are used as part of the scope name of an identifier, such as a namespace name. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c817bdf80..00aa4922d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -159,6 +159,7 @@ CPP_TEST_CASES += \ cpp_enum \ cpp_namespace \ cpp_nodefault \ + cpp_parameters \ cpp_static \ cpp_typedef \ cpp14_binary_integer_literals \ diff --git a/Examples/test-suite/cpp_parameters.i b/Examples/test-suite/cpp_parameters.i new file mode 100644 index 000000000..e8a4c94fd --- /dev/null +++ b/Examples/test-suite/cpp_parameters.i @@ -0,0 +1,46 @@ +%module cpp_parameters + +%{ +// For Perl +#ifdef Zero +#undef Zero +#endif +%} +%inline %{ + +// Zero arguments +struct Zero { + Zero() {} + int zero() { return 0; } + static int stat_zero() { return 0; } +}; +// One mandatory argument +struct One { + One(int a) {} + int one(int a) { return a; } + static int stat_one(int a) { return a; } +}; +// Two mandatory arguments +struct Two { + Two(int a, int b) {} + int two(int a, int b) { return a + b; } + static int stat_two(int a, int b) { return a + b; } +}; +// Single optional argument +struct Single { + Single(int a=0) {} + int single(int a=0) { return a; } + static int stat_single(int a=0) { return a; } +}; + +int global_zero() { return 0; } +int global_one(int a) { return a; } +int global_two(int a, int b) { return a + b; } +int global_single(int a=0) { return a; } + +#ifdef SWIGPYTHON_BUILTIN +bool is_python_builtin() { return true; } +#else +bool is_python_builtin() { return false; } +#endif +%} diff --git a/Examples/test-suite/python/cpp_parameters_runme.py b/Examples/test-suite/python/cpp_parameters_runme.py new file mode 100644 index 000000000..99d14ad74 --- /dev/null +++ b/Examples/test-suite/python/cpp_parameters_runme.py @@ -0,0 +1,296 @@ +from cpp_parameters import * + +# Testing correct and incorrect parameter counts being passed (kwargs and non-kwargs) +# Note that the implementation depends a lot on whether zero, one, two or more args are being wrapped + +def is_python_fastproxy(): + """Return True if SWIG is generating Python code using -fastproxy.""" + import cpp_parameters + # Note: _swig_new_instance_method is only generated when using -fastproxy + return hasattr(cpp_parameters, "_swig_new_instance_method") + +# Zero parameters expected +x = Zero() +try: + x = Zero(z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x = Zero(0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + x.zero(z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x.zero(0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + Zero.stat_zero(z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + Zero.stat_zero(0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + global_zero(z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + global_zero(0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +# One mandatory parameter expected +x = One(1) +try: + x = One(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x = One(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + x.one(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x.one(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + One.stat_one(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + One.stat_one(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + global_one(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + global_one(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +# Two mandatory parameters expected +x = Two(1, 2) +try: + x = Two(a=1, b=2, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x = Two(1, 2, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + x.two(a=1, b=2, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x.two(1, 2, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + Two.stat_two(a=1, b=2, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + Two.stat_two(1, 2, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + global_two(a=1, b=2, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + global_two(1, 2, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +# Single optional parameter expected +x = Single(1) +try: + x = Single(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x = Single(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + x.single(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + x.single(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + Single.stat_single(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + Single.stat_single(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +try: + global_single(a=1, z=0) + raise RuntimeError("Missed throw") +except TypeError: + pass +try: + global_single(1, 0) + raise RuntimeError("Missed throw") +except TypeError: + pass + +# Test that -builtin option throws TypeError if kwargs are used even when they look like they should work, kwargs are not supported unless using -keyword. +# Also same for -fastproxy option except that kwargs are supported by default for constructors. TODO: Fix inconsistency. + +if is_python_builtin() or is_python_fastproxy(): + # One mandatory parameter in API + x = One(1) + if is_python_fastproxy(): + x = One(a=1) + else: + try: + x = One(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + x.one(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + One.stat_one(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + global_one(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + + # Two mandatory parameters in API + x = Two(1, 2) + if is_python_fastproxy(): + x = Two(a=1, b=2) + else: + try: + x = Two(a=1, b=2) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + x.two(a=1, b=2) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + Two.stat_two(a=1, b=2) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + global_two(a=1, b=2) + raise RuntimeError("Missed throw") + except TypeError: + pass + + # Single optional parameter in API + x = Single(1) + if is_python_fastproxy(): + x = Single(a=1) + else: + try: + x = Single(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + x.single(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + Single.stat_single(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + try: + global_single(a=1) + raise RuntimeError("Missed throw") + except TypeError: + pass + +else: + # Non-builtin should work as expected + # One mandatory parameter in API + x = One(a=1) + x.one(a=1) + One.stat_one(a=1) + global_one(a=1) + + # Two mandatory parameters in API + x = Two(a=1, b=2) + x.two(a=1, b=2) + Two.stat_two(a=1, b=2) + global_two(a=1, b=2) + + # Single optional parameter in API + x = Single(a=1) + x.single(a=1) + Single.stat_single(a=1) + global_single(a=1) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 82859b887..218018177 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -183,6 +183,19 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi } } +SWIGINTERN int +SWIG_Python_CheckNoKeywords(PyObject *kwargs, const char *name) { + int no_kwargs = 1; + if (kwargs) { + assert(PyDict_Check(kwargs)); + if (PyDict_Size(kwargs) > 0) { + PyErr_Format(PyExc_TypeError, "%s() does not take keyword arguments", name); + no_kwargs = 0; + } + } + return no_kwargs; +} + /* A functor is a function object with one single object argument */ #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 4792090ea..1e211fb8b 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2493,7 +2493,7 @@ public: String *symname = Getattr(n, "sym:name"); String *wname = Swig_name_wrapper(symname); - const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : ""; + const char *builtin_kwargs = builtin_ctor ? ", PyObject *kwargs" : ""; Printv(f->def, linkage, builtin_ctor ? "int " : "PyObject *", wname, "(PyObject *self, PyObject *args", builtin_kwargs, ") {", NIL); Wrapper_add_local(f, "argc", "Py_ssize_t argc"); @@ -2503,6 +2503,9 @@ public: if (!fastunpack) { Wrapper_add_local(f, "ii", "Py_ssize_t ii"); + if (builtin_ctor) + Printf(f->code, "if (!SWIG_Python_CheckNoKeywords(kwargs, \"%s\")) SWIG_fail;\n", symname); + if (maxargs - (add_self ? 1 : 0) > 0) { Append(f->code, "if (!PyTuple_Check(args)) SWIG_fail;\n"); Append(f->code, "argc = PyObject_Length(args);\n"); @@ -2518,8 +2521,9 @@ public: if (add_self) Append(f->code, "argc++;\n"); } else { - String *iname = Getattr(n, "sym:name"); - Printf(f->code, "if (!(argc = SWIG_Python_UnpackTuple(args, \"%s\", 0, %d, argv%s))) SWIG_fail;\n", iname, maxargs, add_self ? "+1" : ""); + if (builtin_ctor) + Printf(f->code, "if (!SWIG_Python_CheckNoKeywords(kwargs, \"%s\")) SWIG_fail;\n", symname); + Printf(f->code, "if (!(argc = SWIG_Python_UnpackTuple(args, \"%s\", 0, %d, argv%s))) SWIG_fail;\n", symname, maxargs, add_self ? "+1" : ""); if (add_self) Append(f->code, "argv[0] = self;\n"); else @@ -2713,7 +2717,7 @@ public: Append(wname, overname); } - const char *builtin_kwargs = builtin_ctor ? ", PyObject *SWIGUNUSEDPARM(kwargs)" : ""; + const char *builtin_kwargs = builtin_ctor ? ", PyObject *kwargs" : ""; if (!allow_kwargs || overname) { if (!varargs) { Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL); @@ -2886,6 +2890,7 @@ public: funpack = 0; } else { Clear(parse_args); + if (funpack) { Clear(f->def); if (overname) { @@ -2898,6 +2903,8 @@ public: } else { int is_tp_call = Equal(Getattr(n, "feature:python:slot"), "tp_call"); Printv(f->def, linkage, wrap_return, wname, "(PyObject *", self_param, ", PyObject *args", builtin_kwargs, ") {", NIL); + if (builtin_ctor) + Printf(parse_args, "if (!SWIG_Python_CheckNoKeywords(kwargs, \"%s\")) SWIG_fail;\n", iname); if (onearg && !builtin_ctor && !is_tp_call) { Printf(parse_args, "if (!args) SWIG_fail;\n"); Append(parse_args, "swig_obj[0] = args;\n"); @@ -2908,6 +2915,8 @@ public: } } } else { + if (builtin_ctor) + Printf(parse_args, "if (!SWIG_Python_CheckNoKeywords(kwargs, \"%s\")) SWIG_fail;\n", iname); if (builtin && in_class && tuple_arguments == 0) { Printf(parse_args, " if (args && PyTuple_Check(args) && PyTuple_GET_SIZE(args) > 0) SWIG_exception_fail(SWIG_TypeError, \"%s takes no arguments\");\n", iname); } else { From af504ccdddb5379c88585c5b54a31afef3686b03 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Jan 2020 18:43:58 +0000 Subject: [PATCH 1794/2031] Update newly merged doxygen Java test for Java 9 API See 66a78261924174791a4952d05b58d52c16a36a57 --- .../test-suite/java/doxygen_code_blocks_runme.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/java/doxygen_code_blocks_runme.java b/Examples/test-suite/java/doxygen_code_blocks_runme.java index ff0a16eab..2af47bf50 100644 --- a/Examples/test-suite/java/doxygen_code_blocks_runme.java +++ b/Examples/test-suite/java/doxygen_code_blocks_runme.java @@ -15,14 +15,7 @@ public class doxygen_code_blocks_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_code_blocks runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_code_blocks"}); + CommentParser.parse("doxygen_code_blocks"); HashMap wantedComments = new HashMap(); @@ -78,6 +71,6 @@ public class doxygen_code_blocks_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } From 0b57b60aecc035c7d718d6e00613d8fe0dd5a93c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Jan 2020 18:56:38 +0000 Subject: [PATCH 1795/2031] Add changes entry for improved doxygen support --- CHANGES.current | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 4180d2cb4..06f214c52 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== + +2020-01-14: mcfarljm + #1608 Improve doxygen support. + - Add support for \param[] commands such as: \param[in]. + - Optional arguments are marked as 'optional' in pydoc. + - Improve support for \code commands so that other languages are supported as code blocks. + Support added for java, c and py. For example Python: \code{.py} ... \endcode + - Fix doxygen handling of \em and \p tags for Python. + 2020-01-13: wsfulton [Python] #1595 Python -builtin constructors silently ignored keyword arguments. Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" From d1a4174bf32f5a3285d13e7fd4618dca438c205a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 14 Jan 2020 20:02:15 +0000 Subject: [PATCH 1796/2031] Fix deprecation warning in java testcase Fixes: ./director_string_runme.java:53: warning: [deprecation] Integer(int) in Integer has been deprecated --- Examples/test-suite/java/director_string_runme.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/java/director_string_runme.java b/Examples/test-suite/java/director_string_runme.java index a6ed67100..67cb0fe60 100644 --- a/Examples/test-suite/java/director_string_runme.java +++ b/Examples/test-suite/java/director_string_runme.java @@ -19,7 +19,7 @@ public class director_string_runme { director_string_A c = new director_string_A("hi"); for (int i=0; i<3; i++) { s = c.call_get(i); - if (!s.equals(new Integer(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s); + if (!s.equals(Integer.valueOf(i).toString())) throw new RuntimeException("director_string_A.get(" + i + ") failed. Got:" + s); } director_string_B b = new director_string_B("hello"); @@ -50,7 +50,7 @@ class director_string_A extends A { super(first); } public String get(int n) { - return new Integer(n).toString(); + return Integer.valueOf(n).toString(); } } From 9cfeb592edc39dbe702cb56b571ed9e29b3a8276 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 15 Jan 2020 22:17:18 +0000 Subject: [PATCH 1797/2031] Remove unused import in java testcase --- Examples/test-suite/java/doxygen_code_blocks_runme.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/java/doxygen_code_blocks_runme.java b/Examples/test-suite/java/doxygen_code_blocks_runme.java index 2af47bf50..8e8373b78 100644 --- a/Examples/test-suite/java/doxygen_code_blocks_runme.java +++ b/Examples/test-suite/java/doxygen_code_blocks_runme.java @@ -1,6 +1,5 @@ import doxygen_code_blocks.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_code_blocks_runme { From ae1e736c1b2aaefa7664a6d64829dba0c2ca72e2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 07:47:53 +0000 Subject: [PATCH 1798/2031] Memory leak fix handling empty /// doxygen comments --- CHANGES.current | 2 ++ Source/CParse/cscanner.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 06f214c52..db2d8a918 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,8 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-16: mcfarljm + #1632 #1659 Fix newline handling for doxygen "///" comments 2020-01-14: mcfarljm #1608 Improve doxygen support. diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 4c1a038fb..19a013803 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -428,6 +428,7 @@ static int yylook(void) { /* Concatenate or skip all consecutive comments at once. */ do { String *cmt = Scanner_text(scan); + String *cmt_modified = 0; char *loc = Char(cmt); if ((strncmp(loc, "/*@SWIG", 7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); @@ -439,9 +440,9 @@ static int yylook(void) { slashStyle = 1; if (Len(cmt) == 3) { /* Modify to make length=4 to ensure that the empty comment does - get processed to preserve the newlines in the original - comments. */ - cmt = NewStringf("%s ", cmt); + get processed to preserve the newlines in the original comments. */ + cmt_modified = NewStringf("%s ", cmt); + cmt = cmt_modified; loc = Char(cmt); } } @@ -492,6 +493,7 @@ static int yylook(void) { do { tok = Scanner_token(scan); } while (tok == SWIG_TOKEN_ENDLINE); + Delete(cmt_modified); } while (tok == SWIG_TOKEN_COMMENT); Scanner_pushtoken(scan, tok, Scanner_text(scan)); From 19e7648d25ad6bae54b004dd4d08c347259e7572 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 07:51:06 +0000 Subject: [PATCH 1799/2031] Add changes entries for recent doxygen improvements --- CHANGES.current | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index db2d8a918..84697f61d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,7 +8,10 @@ Version 4.0.2 (in progress) =========================== 2020-01-16: mcfarljm - #1632 #1659 Fix newline handling for doxygen "///" comments + #1632 #1659 Fix newline handling for doxygen "///" comments. + +2020-01-14: mcfarljm + #1647 #1656 Fix crash handling empty doxygen comments. 2020-01-14: mcfarljm #1608 Improve doxygen support. From 6e240e8fba8ef45f88a21fc9833a8228e19c2e3d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 19:12:10 +0000 Subject: [PATCH 1800/2031] Fix segfault parsing varargs with -doxygen Closes #1643 --- CHANGES.current | 4 ++++ Source/Doxygen/pydoc.cxx | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 84697f61d..d6e9af61f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-16: mcfarljm + #1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters + are used. + 2020-01-16: mcfarljm #1632 #1659 Fix newline handling for doxygen "///" comments. diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx index 9f00d5548..c84095b8f 100644 --- a/Source/Doxygen/pydoc.cxx +++ b/Source/Doxygen/pydoc.cxx @@ -449,12 +449,12 @@ std::string PyDocConverter::getParamValue(std::string param) { ParmList *plist = CopyParmList(Getattr(currentNode, "parms")); for (Parm *p = plist; p; p = nextSibling(p)) { String *pname = Getattr(p, "name"); - if (Char(pname) != param) - continue; - - String *pval = Getattr(p, "value"); - if (pval) value = Char(pval); - break; + if (pname && Char(pname) == param) { + String *pval = Getattr(p, "value"); + if (pval) + value = Char(pval); + break; + } } Delete(plist); return value; From bdc9aa0038c39bdf8cc85b0aaa26921c94960b71 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 19:30:44 +0000 Subject: [PATCH 1801/2031] Update anther newly merged doxygen Java test for Java 9 API See 66a78261924174791a4952d05b58d52c16a36a57 --- .../java/doxygen_basic_translate_style3_runme.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java index e450eb757..a0953644a 100644 --- a/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java +++ b/Examples/test-suite/java/doxygen_basic_translate_style3_runme.java @@ -1,6 +1,5 @@ import doxygen_basic_translate_style3.*; -import com.sun.javadoc.*; import java.util.HashMap; public class doxygen_basic_translate_style3_runme { @@ -15,14 +14,7 @@ public class doxygen_basic_translate_style3_runme { public static void main(String argv[]) { - /* - Here we are using internal javadoc tool, it accepts the name of the class as paramterer, - and calls the start() method of that class with parsed information. - */ - CommentParser parser = new CommentParser(); - com.sun.tools.javadoc.Main.execute("doxygen_basic_translate_style3 runtime test", - "CommentParser", - new String[]{"-quiet", "doxygen_basic_translate_style3"}); + CommentParser.parse("doxygen_basic_translate_style3"); HashMap wantedComments = new HashMap(); @@ -96,6 +88,6 @@ public class doxygen_basic_translate_style3_runme { ""); // and ask the parser to check comments for us - System.exit(parser.check(wantedComments)); + System.exit(CommentParser.check(wantedComments)); } } From 3585ee23cf978b208d202aeb8705ab52bc88ba62 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 19:37:07 +0000 Subject: [PATCH 1802/2031] Fix sort order of doxygen testcases --- Examples/test-suite/common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 43fb45bd1..115747e97 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -628,6 +628,7 @@ DOXYGEN_TEST_CASES += \ doxygen_basic_translate \ doxygen_basic_translate_style2 \ doxygen_basic_translate_style3 \ + doxygen_code_blocks \ doxygen_ignore \ doxygen_misc_constructs \ doxygen_nested_class \ @@ -636,7 +637,6 @@ DOXYGEN_TEST_CASES += \ doxygen_translate \ doxygen_translate_all_tags \ doxygen_translate_links \ - doxygen_code_blocks \ $(DOXYGEN_TEST_CASES:=.cpptest): SWIGOPT += -doxygen From 7051753fdfb7d74bb1a8e419eb450bbbc6e79141 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 16 Jan 2020 19:49:16 +0000 Subject: [PATCH 1803/2031] Correct recently expanded testcase from a merge for doxygen default parameter support --- .../test-suite/python/doxygen_basic_translate_style3_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py index aa9b6ca4e..687270351 100644 --- a/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py +++ b/Examples/test-suite/python/doxygen_basic_translate_style3_runme.py @@ -58,7 +58,7 @@ comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function5), comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function6), """\ Test for default args -:type a: int +:type a: int, optional :param a: Some parameter, default is 42""" ) comment_verifier.check(inspect.getdoc(doxygen_basic_translate_style3.function7), From 96c6bf4cc2b7262c633f8218b9cb5814f3fc936d Mon Sep 17 00:00:00 2001 From: Julien Schueller Date: Wed, 6 Nov 2019 17:00:47 +0100 Subject: [PATCH 1804/2031] Fix unused-parameter warning in pycontainer.swg --- Lib/python/pycontainer.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index a7cc605ce..2ddf4c375 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -52,7 +52,7 @@ namespace swig { struct container_owner { // By default, do not add the back-reference (for value types) // Specialization below will check the reference for pointer types. - static bool back_reference(PyObject* child, PyObject* owner) { + static bool back_reference(PyObject* /*child*/, PyObject* /*owner*/) { return false; } }; From 7cc94808b6ee645247051157ad3bee20a50d47ba Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 10 Sep 2019 01:02:23 +0200 Subject: [PATCH 1805/2031] Extend std::auto_ptr<> support to Ruby This is trivial as exactly the same typemap as for Python can be used for Ruby too, all the differenced are abstracted by the unified typemap library. --- CHANGES | 3 ++ Examples/test-suite/li_std_auto_ptr.i | 2 +- .../test-suite/ruby/li_std_auto_ptr_runme.rb | 43 +++++++++++++++++++ Lib/ruby/std_auto_ptr.i | 17 ++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/ruby/li_std_auto_ptr_runme.rb create mode 100644 Lib/ruby/std_auto_ptr.i diff --git a/CHANGES b/CHANGES index fe8696760..4a38b1fd6 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (21 Aug 2019) =========================== +2019-09-09: vadz + [Ruby] Add std::auto_ptr<> typemaps. + 2019-08-20: TekuConcept [Javascript] #1535 Add %native support to Javascript. diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i index 5bde387a3..d83732af0 100644 --- a/Examples/test-suite/li_std_auto_ptr.i +++ b/Examples/test-suite/li_std_auto_ptr.i @@ -12,7 +12,7 @@ #endif %} -#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON) +#if defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGPYTHON) || defined(SWIGRUBY) %include "std_auto_ptr.i" diff --git a/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb new file mode 100644 index 000000000..a7f3a13ac --- /dev/null +++ b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby + +require 'swig_assert' + +require 'li_std_auto_ptr' + +k1 = Li_std_auto_ptr::makeKlassAutoPtr("first") +k2 = Li_std_auto_ptr::makeKlassAutoPtr("second") +swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 2) + +k1 = nil +GC.start + +# GC can need a few runs to actually collect the object. +100.times do || + next if Li_std_auto_ptr::Klass::getTotal_count() == 2 + + swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 1) + break +end + +swig_assert_equal_simple(k2.getLabel(), "second") + +if Li_std_auto_ptr::Klass::getTotal_count() != 1 + STDERR.puts "GC failed to collect the first object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}" + + # Skip the rest of the test as it's not going to work correctly anyhow. + exit +end + +k2 = nil +GC.start + +100.times do || + next if Li_std_auto_ptr::Klass::getTotal_count() == 1 + + swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 0) + break +end + +if Li_std_auto_ptr::Klass::getTotal_count() != 0 + STDERR.puts "GC failed to collect the second object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}" +end diff --git a/Lib/ruby/std_auto_ptr.i b/Lib/ruby/std_auto_ptr.i new file mode 100644 index 000000000..3a415b942 --- /dev/null +++ b/Lib/ruby/std_auto_ptr.i @@ -0,0 +1,17 @@ +/* + The typemaps here allow to handle functions returning std::auto_ptr<>, + which is the most common use of this type. If you have functions taking it + as parameter, these typemaps can't be used for them and you need to do + something else (e.g. use shared_ptr<> which SWIG supports fully). + */ + +%define %auto_ptr(TYPE) +%typemap (out) std::auto_ptr %{ + %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags)); +%} +%template() std::auto_ptr; +%enddef + +namespace std { + template class auto_ptr {}; +} From bf2e50f09f286680f2060236aa8ce453b5fb6f4a Mon Sep 17 00:00:00 2001 From: Ryan Mast Date: Mon, 20 Jan 2020 15:01:22 -0800 Subject: [PATCH 1806/2031] Add missing preprocessor defines to the docs list --- Doc/Manual/Preprocessor.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 3d1bb453e..f09067b78 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -110,11 +110,18 @@ SWIG_VERSION Hexadecimal (binary-coded decimal) number contai such as 0x010311 (corresponding to SWIG-1.3.11). SWIGCSHARP Defined when using C# +SWIGD Defined when using D +SWIG_D_VERSION Unsigned integer target version when using D +SWIGGO Defined when using Go +SWIGGO_CGO Defined when using Go for cgo +SWIGGO_GCCGO Defined when using Go for gccgo +SWIGGO_INTGO_SIZE Size of the Go type int when using Go (32 or 64) SWIGGUILE Defined when using Guile SWIGJAVA Defined when using Java SWIGJAVASCRIPT Defined when using Javascript SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore -SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js +SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js +BUILDING_NODE_EXTENSION Defined when using Javascript for node.js SWIGLUA Defined when using Lua SWIGMZSCHEME Defined when using Mzscheme SWIGOCAML Defined when using OCaml @@ -123,8 +130,11 @@ SWIGPERL Defined when using Perl SWIGPHP Defined when using PHP (any version) SWIGPHP7 Defined when using PHP7 SWIGPYTHON Defined when using Python +SWIGPYTHON_PY3 Defined when using Python with -py3 +SWIGPYTHON_BUILTIN Defined when using Python with -builtin SWIGR Defined when using R SWIGRUBY Defined when using Ruby +SWIG_RUBY_AUTORENAME Defined when using Ruby with -autorename SWIGSCILAB Defined when using Scilab SWIGTCL Defined when using Tcl SWIGXML Defined when using XML From 0425a61fa8b53aa25f360c045bc737202d82aea8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 23 Jan 2020 18:03:22 +0000 Subject: [PATCH 1807/2031] shared_ptr upcast fixes for D Same changes that were applied to Java/C# in ab7f526805b86726a3c23c853e0ab19458f2c7d9 --- Source/Modules/d.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 5e82dfda3..af850ebbd 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3378,14 +3378,16 @@ private: upcast_wrapper_name); if (smart) { - SwigType *bsmart = Copy(smart); + String *smartnamestr = SwigType_namestr(smart); + String *bsmartnamestr = SwigType_namestr(smart); + SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name); SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name); - Replaceall(bsmart, rclassname, rbaseclass); + Replaceall(bsmartnamestr, rclassname, rbaseclass); + Delete(rclassname); Delete(rbaseclass); - String *smartnamestr = SwigType_namestr(smart); - String *bsmartnamestr = SwigType_namestr(bsmart); + Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name, "(", smartnamestr, " *objectRef) {\n", @@ -3394,7 +3396,6 @@ private: "\n", NIL); Delete(bsmartnamestr); Delete(smartnamestr); - Delete(bsmart); } else { Printv(upcasts_code, "SWIGEXPORT ", c_base_name, " * ", upcast_wrapper_name, From 564a91864a84046609bedcfc7cb5e5560fd62377 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 23 Jan 2020 19:30:03 +0000 Subject: [PATCH 1808/2031] Refactor upcasts code In preparation for possible improvement in usage of SwigType_typedef_resolve_all - a SwigType* should be used, not a readable name in a String*. --- Source/Modules/csharp.cxx | 52 +++++++++++++++++---------------- Source/Modules/d.cxx | 60 ++++++++++++++++++++------------------- Source/Modules/java.cxx | 53 ++++++++++++++++++---------------- 3 files changed, 86 insertions(+), 79 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index a5c236dac..aa0fece36 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1709,11 +1709,11 @@ public: * addInterfaceNameAndUpcasts() * ----------------------------------------------------------------------------- */ - void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) { + void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) { List *keys = Keys(base_list); for (Iterator it = First(keys); it.item; it = Next(it)) { Node *base = Getattr(base_list, it.item); - String *c_baseclass = SwigType_namestr(Getattr(base, "name")); + SwigType *c_baseclassname = Getattr(base, "name"); String *interface_name = Getattr(base, "interface:name"); if (Len(interface_list)) Append(interface_list, ", "); @@ -1733,12 +1733,11 @@ public: Replaceall(cptr_method_name, "$interfacename", interface_name); String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name); - upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); + upcastsCode(smart, upcast_method_name, c_classname, c_baseclassname); Delete(upcast_method_name); Delete(cptr_method_name); Delete(interface_code); - Delete(c_baseclass); } Delete(keys); } @@ -1749,7 +1748,7 @@ public: * Add code for C++ casting to base class * ----------------------------------------------------------------------------- */ - void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { + void upcastsCode(SwigType *smart, String *upcast_method_name, SwigType *c_classname, SwigType *c_baseclassname) { String *wname = Swig_name_wrapper(upcast_method_name); Printv(imclass_cppcasts_code, "\n [global::System.Runtime.InteropServices.DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL); @@ -1757,29 +1756,34 @@ public: Replaceall(imclass_cppcasts_code, "$csclassname", proxy_class_name); + String *classname = SwigType_namestr(c_classname); + String *baseclassname = SwigType_namestr(c_baseclassname); if (smart) { String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - Replaceall(bsmartnamestr, rclassname, rbaseclass); - - Delete(rclassname); - Delete(rbaseclass); + SwigType *rclassname = SwigType_typedef_resolve_all(classname); + SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); + Replaceall(bsmartnamestr, rclassname, rbaseclassname); Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * SWIGSTDCALL ", wname, "(", smartnamestr, " *jarg1) {\n", " return jarg1 ? new ", bsmartnamestr, "(*jarg1) : 0;\n" "}\n", "\n", NIL); + + Delete(rbaseclassname); + Delete(rclassname); Delete(bsmartnamestr); Delete(smartnamestr); } else { Printv(upcasts_code, - "SWIGEXPORT ", c_baseclass, " * SWIGSTDCALL ", wname, "(", c_classname, " *jarg1) {\n", - " return (", c_baseclass, " *)jarg1;\n" + "SWIGEXPORT ", baseclassname, " * SWIGSTDCALL ", wname, "(", classname, " *jarg1) {\n", + " return (", baseclassname, " *)jarg1;\n" "}\n", "\n", NIL); } + + Delete(baseclassname); + Delete(classname); Delete(wname); } @@ -1788,10 +1792,9 @@ public: * ----------------------------------------------------------------------------- */ void emitProxyClassDefAndCPPCasts(Node *n) { - String *c_classname = SwigType_namestr(Getattr(n, "name")); - String *c_baseclass = NULL; + SwigType *c_classname = Getattr(n, "name"); + SwigType *c_baseclassname = NULL; String *baseclass = NULL; - String *c_baseclassname = NULL; String *interface_list = NewStringEmpty(); String *interface_upcasts = NewStringEmpty(); SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); @@ -1813,12 +1816,13 @@ public: Iterator base = First(baselist); while (base.item) { if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) { - String *baseclassname = Getattr(base.item, "name"); + SwigType *baseclassname = Getattr(base.item, "name"); if (!c_baseclassname) { - c_baseclassname = baseclassname; - baseclass = Copy(getProxyName(baseclassname)); - if (baseclass) - c_baseclass = SwigType_namestr(baseclassname); + String *name = getProxyName(baseclassname); + if (name) { + c_baseclassname = baseclassname; + baseclass = name; + } } else { /* Warn about multiple inheritance for additional base class(es) */ String *proxyclassname = Getattr(n, "classtypeobj"); @@ -1834,7 +1838,7 @@ public: if (interface_bases) addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname); - bool derived = baseclass && getProxyName(c_baseclassname); + bool derived = baseclass != 0; if (derived && purebase_notderived) pure_baseclass = empty_string; const String *wanted_base = baseclass ? baseclass : pure_baseclass; @@ -1842,7 +1846,6 @@ public: if (purebase_replace) { wanted_base = pure_baseclass; derived = false; - Delete(baseclass); baseclass = NULL; if (purebase_notderived) Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); @@ -2033,12 +2036,11 @@ public: if (derived) { String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); - upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); + upcastsCode(smart, upcast_method_name, c_classname, c_baseclassname); Delete(upcast_method_name); } Delete(smart); - Delete(baseclass); } /* ---------------------------------------------------------------------- diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index af850ebbd..683686ea1 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3140,11 +3140,10 @@ private: * Handle inheriting from D and C++ classes. */ - String *c_classname = SwigType_namestr(Getattr(n, "name")); - String *c_baseclass = NULL; - Node *basenode = NULL; - String *basename = NULL; + String *c_classname = Getattr(n, "name"); String *c_baseclassname = NULL; + Node *basenode = NULL; + String *baseclass = NULL; // Inheritance from pure D classes. Node *attributes = NewHash(); @@ -3161,13 +3160,14 @@ private: Iterator base = First(baselist); while (base.item) { if (!GetFlag(base.item, "feature:ignore")) { - String *baseclassname = Getattr(base.item, "name"); + SwigType *baseclassname = Getattr(base.item, "name"); if (!c_baseclassname) { basenode = base.item; - c_baseclassname = baseclassname; - basename = createProxyName(c_baseclassname); - if (basename) - c_baseclass = SwigType_namestr(baseclassname); + String *name = createProxyName(baseclassname); + if (name) { + c_baseclassname = baseclassname; + baseclass = name; + } } else { /* Warn about multiple inheritance for additional base class(es) */ String *proxyclassname = Getattr(n, "classtypeobj"); @@ -3180,25 +3180,24 @@ private: } } - bool derived = (basename != NULL); + bool derived = baseclass != NULL; if (derived && purebase_notderived) { pure_baseclass = empty_string; } - const String *wanted_base = basename ? basename : pure_baseclass; + const String *wanted_base = baseclass ? baseclass : pure_baseclass; if (purebase_replace) { wanted_base = pure_baseclass; derived = false; basenode = NULL; - Delete(basename); - basename = NULL; + baseclass = NULL; if (purebase_notderived) { Swig_error(Getfile(n), Getline(n), "The dbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); } - } else if (basename && Len(pure_baseclass) > 0) { + } else if (baseclass && Len(pure_baseclass) > 0) { Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n), "Warning for %s, base class %s ignored. Multiple inheritance is not supported in D. " "Perhaps you need one of the 'replace' or 'notderived' attributes in the dbase typemap?\n", typemap_lookup_type, pure_baseclass); @@ -3206,7 +3205,7 @@ private: // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy) if (derived) { - writeClassUpcast(n, proxy_class_name, c_classname, c_baseclass); + writeClassUpcast(n, proxy_class_name, c_classname, c_baseclassname); } /* @@ -3354,8 +3353,7 @@ private: // Write the class body and the curly bracket closing the class definition // to the proxy module. indentCode(body); - Replaceall(body, "$dbaseclass", basename); - Delete(basename); + Replaceall(body, "$dbaseclass", baseclass); Printv(proxy_class_code, body, "\n}\n", NIL); Delete(body); @@ -3368,7 +3366,7 @@ private: /* --------------------------------------------------------------------------- * D::writeClassUpcast() * --------------------------------------------------------------------------- */ - void writeClassUpcast(Node *n, const String* d_class_name, String* c_class_name, String* c_base_name) { + void writeClassUpcast(Node *n, const String* d_class_name, SwigType* c_classname, SwigType* c_baseclassname) { SwigType *smart = Swig_cparse_smartptr(n); String *upcast_name = Swig_name_member(getNSpace(), d_class_name, (smart != 0 ? "SmartPtrUpcast" : "Upcast")); @@ -3377,16 +3375,15 @@ private: writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)", upcast_wrapper_name); + String *classname = SwigType_namestr(c_classname); + String *baseclassname = SwigType_namestr(c_baseclassname); if (smart) { String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name); - Replaceall(bsmartnamestr, rclassname, rbaseclass); - - Delete(rclassname); - Delete(rbaseclass); + SwigType *rclassname = SwigType_typedef_resolve_all(classname); + SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); + Replaceall(bsmartnamestr, rclassname, rbaseclassname); Printv(upcasts_code, "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name, @@ -3394,20 +3391,25 @@ private: " return objectRef ? new ", bsmartnamestr, "(*objectRef) : 0;\n" "}\n", "\n", NIL); + + Delete(rbaseclassname); + Delete(rclassname); Delete(bsmartnamestr); Delete(smartnamestr); } else { Printv(upcasts_code, - "SWIGEXPORT ", c_base_name, " * ", upcast_wrapper_name, - "(", c_base_name, " *objectRef) {\n", - " return (", c_base_name, " *)objectRef;\n" + "SWIGEXPORT ", baseclassname, " * ", upcast_wrapper_name, + "(", baseclassname, " *objectRef) {\n", + " return (", baseclassname, " *)objectRef;\n" "}\n", "\n", NIL); } - Replaceall(upcasts_code, "$cclass", c_class_name); - Replaceall(upcasts_code, "$cbaseclass", c_base_name); + Replaceall(upcasts_code, "$cclass", classname); + Replaceall(upcasts_code, "$cbaseclass", baseclassname); + Delete(baseclassname); + Delete(classname); Delete(upcast_name); Delete(upcast_wrapper_name); Delete(smart); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 14d4d50ad..0c3b5bf3c 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1853,11 +1853,11 @@ public: * addInterfaceNameAndUpcasts() * ----------------------------------------------------------------------------- */ - void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, String *c_classname) { + void addInterfaceNameAndUpcasts(SwigType *smart, String *interface_list, String *interface_upcasts, Hash *base_list, SwigType *c_classname) { List *keys = Keys(base_list); for (Iterator it = First(keys); it.item; it = Next(it)) { Node *base = Getattr(base_list, it.item); - String *c_baseclass = SwigType_namestr(Getattr(base, "name")); + SwigType *c_baseclassname = Getattr(base, "name"); String *interface_name = Getattr(base, "interface:name"); if (Len(interface_list)) Append(interface_list, ", "); @@ -1877,11 +1877,11 @@ public: Replaceall(cptr_method_name, "$interfacename", interface_name); String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), cptr_method_name); - upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); + upcastsCode(smart, upcast_method_name, c_classname, c_baseclassname); + Delete(upcast_method_name); Delete(cptr_method_name); Delete(interface_code); - Delete(c_baseclass); } Delete(keys); } @@ -1892,21 +1892,21 @@ public: * Add code for C++ casting to base class * ----------------------------------------------------------------------------- */ - void upcastsCode(SwigType *smart, String *upcast_method_name, String *c_classname, String *c_baseclass) { + void upcastsCode(SwigType *smart, String *upcast_method_name, SwigType *c_classname, SwigType *c_baseclassname) { String *jniname = makeValidJniName(upcast_method_name); String *wname = Swig_name_wrapper(jniname); + Printf(imclass_cppcasts_code, " public final static native long %s(long jarg1);\n", upcast_method_name); + + String *classname = SwigType_namestr(c_classname); + String *baseclassname = SwigType_namestr(c_baseclassname); if (smart) { String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); - SwigType *rclassname = SwigType_typedef_resolve_all(c_classname); - SwigType *rbaseclass = SwigType_typedef_resolve_all(c_baseclass); - - Replaceall(bsmartnamestr, rclassname, rbaseclass); - - Delete(rclassname); - Delete(rbaseclass); + SwigType *rclassname = SwigType_typedef_resolve_all(classname); + SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); + Replaceall(bsmartnamestr, rclassname, rbaseclassname); Printv(upcasts_code, "SWIGEXPORT jlong JNICALL ", wname, "(JNIEnv *jenv, jclass jcls, jlong jarg1) {\n", @@ -1918,6 +1918,9 @@ public: " *(", bsmartnamestr, " **)&baseptr = argp1 ? new ", bsmartnamestr, "(*argp1) : 0;\n" " return baseptr;\n" "}\n", "\n", NIL); + + Delete(rbaseclassname); + Delete(rclassname); Delete(bsmartnamestr); Delete(smartnamestr); } else { @@ -1926,11 +1929,13 @@ public: " jlong baseptr = 0;\n" " (void)jenv;\n" " (void)jcls;\n" - " *(", c_baseclass, " **)&baseptr = *(", c_classname, " **)&jarg1;\n" + " *(", baseclassname, " **)&baseptr = *(", classname, " **)&jarg1;\n" " return baseptr;\n" "}\n", "\n", NIL); } + Delete(baseclassname); + Delete(classname); Delete(wname); Delete(jniname); } @@ -1940,10 +1945,9 @@ public: * ----------------------------------------------------------------------------- */ void emitProxyClassDefAndCPPCasts(Node *n) { - String *c_classname = SwigType_namestr(Getattr(n, "name")); - String *c_baseclass = NULL; + SwigType *c_classname = Getattr(n, "name"); + SwigType *c_baseclassname = NULL; String *baseclass = NULL; - String *c_baseclassname = NULL; String *interface_list = NewStringEmpty(); String *interface_upcasts = NewStringEmpty(); SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); @@ -1965,12 +1969,13 @@ public: Iterator base = First(baselist); while (base.item) { if (!(GetFlag(base.item, "feature:ignore") || Getattr(base.item, "feature:interface"))) { - String *baseclassname = Getattr(base.item, "name"); + SwigType *baseclassname = Getattr(base.item, "name"); if (!c_baseclassname) { - c_baseclassname = baseclassname; - baseclass = Copy(getProxyName(baseclassname)); - if (baseclass) - c_baseclass = SwigType_namestr(baseclassname); + String *name = getProxyName(baseclassname); + if (name) { + c_baseclassname = baseclassname; + baseclass = name; + } } else { /* Warn about multiple inheritance for additional base class(es) */ String *proxyclassname = Getattr(n, "classtypeobj"); @@ -1987,7 +1992,7 @@ public: if (interface_bases) addInterfaceNameAndUpcasts(smart, interface_list, interface_upcasts, interface_bases, c_classname); - bool derived = baseclass && getProxyName(c_baseclassname); + bool derived = baseclass != 0; if (derived && purebase_notderived) pure_baseclass = empty_string; const String *wanted_base = baseclass ? baseclass : pure_baseclass; @@ -1995,7 +2000,6 @@ public: if (purebase_replace) { wanted_base = pure_baseclass; derived = false; - Delete(baseclass); baseclass = NULL; if (purebase_notderived) Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type); @@ -2118,12 +2122,11 @@ public: if (derived) { String *upcast_method_name = Swig_name_member(getNSpace(), getClassPrefix(), smart != 0 ? "SWIGSmartPtrUpcast" : "SWIGUpcast"); - upcastsCode(smart, upcast_method_name, c_classname, c_baseclass); + upcastsCode(smart, upcast_method_name, c_classname, c_baseclassname); Delete(upcast_method_name); } Delete(smart); - Delete(baseclass); } /* ---------------------------------------------------------------------- From b3da344765625f22847bd56ee22b392dd16c4c84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Jan 2020 19:46:39 +0000 Subject: [PATCH 1809/2031] Add some comments about shared_ptr upcast code --- Source/Modules/csharp.cxx | 1 + Source/Modules/d.cxx | 1 + Source/Modules/java.cxx | 1 + Source/Modules/typepass.cxx | 8 ++++++++ 4 files changed, 11 insertions(+) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index aa0fece36..27cc65b32 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1762,6 +1762,7 @@ public: String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); + // TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates SwigType *rclassname = SwigType_typedef_resolve_all(classname); SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); Replaceall(bsmartnamestr, rclassname, rbaseclassname); diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 683686ea1..b7283eac2 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3381,6 +3381,7 @@ private: String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); + // TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates SwigType *rclassname = SwigType_typedef_resolve_all(classname); SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); Replaceall(bsmartnamestr, rclassname, rbaseclassname); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 0c3b5bf3c..7734c6471 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1904,6 +1904,7 @@ public: String *smartnamestr = SwigType_namestr(smart); String *bsmartnamestr = SwigType_namestr(smart); + // TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates SwigType *rclassname = SwigType_typedef_resolve_all(classname); SwigType *rbaseclassname = SwigType_typedef_resolve_all(baseclassname); Replaceall(bsmartnamestr, rclassname, rbaseclassname); diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 8dbf0865e..dc84cf94a 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -267,6 +267,8 @@ class TypePass:private Dispatcher { and smart pointer to base class, so that smart pointer upcasts are automatically generated. */ SwigType *bsmart = Copy(smart); + + // TODO: SwigType_typedef_resolve_all on a String instead of SwigType is incorrect for templates SwigType *rclsname = SwigType_typedef_resolve_all(clsname); SwigType *rbname = SwigType_typedef_resolve_all(bname); int replace_count = Replaceall(bsmart, rclsname, rbname); @@ -276,6 +278,12 @@ class TypePass:private Dispatcher { String *firstname = Getattr(first, "name"); Replaceall(bsmart, firstname, rbname); } + // The code above currently creates a smartptr of the base class by substitution, replacing Derived + // with Base resulting in something like: 'smartptr< Derived >' from 'smartptr< Base >'. Instead + // the feature:smartptr should be used as it also contains 'smartptr< Base >' as specified by the user. + // A similar fix should also be done in upcastsCode in java.cxx, csharp.cxx and writeClassUpcast in d.cxx. + // Printf(stdout, "smartcomparison %s <=> %s\n", SwigType_namestr(bsmart), Getattr(bclass, "feature:smartptr")); + Delete(rclsname); Delete(rbname); String *smartnamestr = SwigType_namestr(smart); From 45963937d572b293e5e8a07daed4ea8c00e1c75a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Jan 2020 19:54:29 +0000 Subject: [PATCH 1810/2031] Test shared_ptr upcasts in Python --- .../python/cpp11_shared_ptr_template_upcast_runme.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py diff --git a/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py b/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py new file mode 100644 index 000000000..08a95c2ce --- /dev/null +++ b/Examples/test-suite/python/cpp11_shared_ptr_template_upcast_runme.py @@ -0,0 +1,5 @@ +from cpp11_shared_ptr_template_upcast import * + +pd = MakePrintableDerived(20) +pd.GetResult() +pd.GetFormatted() From f971bbffc8194e66113eb5d5e88562d4fabd9cdd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 24 Jan 2020 19:54:52 +0000 Subject: [PATCH 1811/2031] Add changes entry for upcasting of shared_ptr's --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index d6e9af61f..587d91ee4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-24: etse-dignitas, wsfulton + #1533 [C#, D, Java] Fix upcasting for shared_ptr's of templated types. + 2020-01-16: mcfarljm #1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters are used. From 36e8d521de110ab9956f60c3cb296352316e847c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Jan 2020 20:31:15 +0000 Subject: [PATCH 1812/2031] Add C++20 documentation chapter [skip-ci] --- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Contents.html | 72 ++++++----- Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Doxygen.html | 56 ++++----- Doc/Manual/Extending.html | 106 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 44 +++---- Doc/Manual/Introduction.html | 1 + Doc/Manual/Java.html | 220 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 50 ++++---- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 66 +++++----- Doc/Manual/Octave.html | 52 ++++---- Doc/Manual/Perl5.html | 108 ++++++++--------- Doc/Manual/Php.html | 50 ++++---- Doc/Manual/Preprocessor.html | 26 ++-- Doc/Manual/Python.html | 200 +++++++++++++++---------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 +++++++++++++++---------------- Doc/Manual/SWIGPlus.html | 1 + Doc/Manual/Scilab.html | 90 +++++++------- Doc/Manual/Sections.html | 1 + Doc/Manual/Tcl.html | 92 +++++++------- Doc/Manual/Typemaps.html | 132 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 38 +++--- Doc/Manual/chapters | 1 + 35 files changed, 1045 insertions(+), 1029 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 944a88d65..da475e9a4 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

    21 SWIG and Android

    +

    22 SWIG and Android

    -

    12.1.3 Output parameters

    +

    13.1.3 Output parameters

    @@ -315,7 +315,7 @@ iresult, dresult = foo(3.5, 2) -

    12.1.4 Input/Output parameters

    +

    13.1.4 Input/Output parameters

    @@ -380,7 +380,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    12.1.5 Using different names

    +

    13.1.5 Using different names

    @@ -414,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    12.2 Applying constraints to input values

    +

    13.2 Applying constraints to input values

    @@ -424,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    12.2.1 Simple constraint example

    +

    13.2.1 Simple constraint example

    @@ -450,7 +450,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    12.2.2 Constraint methods

    +

    13.2.2 Constraint methods

    @@ -466,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only). -

    12.2.3 Applying constraints to new datatypes

    +

    13.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index edd435fa1..1a94709ae 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -7,7 +7,7 @@ -

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

    +

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

    -

    20.14 HISTORY

    +

    21.14 HISTORY

    @@ -423,7 +423,7 @@ 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.

    -

    20.15 DIFFERENCES FROM COMPILERCACHE

    +

    21.15 DIFFERENCES FROM COMPILERCACHE

    @@ -441,7 +441,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    20.16 CREDITS

    +

    21.16 CREDITS

    @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    20.17 AUTHOR

    +

    21.17 AUTHOR

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index d041bf5dd..ca568876a 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

    22 SWIG and C#

    +

    23 SWIG and C#

    -

    22.4 C# Arrays

    +

    23.4 C# Arrays

    @@ -595,7 +595,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

    -

    22.4.1 The SWIG C arrays library

    +

    23.4.1 The SWIG C arrays library

    @@ -632,7 +632,7 @@ example.print_array(c.cast()); // Pass to C

  • -

    22.4.2 Managed arrays using P/Invoke default array marshalling

    +

    23.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -759,7 +759,7 @@ and intermediary class method -

    22.4.3 Managed arrays using pinning

    +

    23.4.3 Managed arrays using pinning

    @@ -854,7 +854,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    22.5 C# Exceptions

    +

    23.5 C# Exceptions

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

    -

    22.5.1 C# exception example using "check" typemap

    +

    23.5.1 C# exception example using "check" typemap

    @@ -1133,7 +1133,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.

    -

    22.5.2 C# exception example using %exception

    +

    23.5.2 C# exception example using %exception

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

    22.5.3 C# exception example using exception specifications

    +

    23.5.3 C# exception example using exception specifications

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

    -

    22.5.4 Custom C# ApplicationException example

    +

    23.5.4 Custom C# ApplicationException example

    @@ -1388,7 +1388,7 @@ try { -

    22.6 C# Directors

    +

    23.6 C# Directors

    @@ -1401,7 +1401,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.

    -

    22.6.1 Directors example

    +

    23.6.1 Directors example

    @@ -1522,7 +1522,7 @@ CSharpDerived - UIntMethod(123) -

    22.6.2 Directors implementation

    +

    23.6.2 Directors implementation

    @@ -1730,7 +1730,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    22.6.3 Director caveats

    +

    23.6.3 Director caveats

    @@ -1778,7 +1778,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.

    -

    22.7 Multiple modules

    +

    23.7 Multiple modules

    @@ -1813,7 +1813,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    22.8 C# Typemap examples

    +

    23.8 C# Typemap examples

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

    22.8.1 Memory management when returning references to member variables

    +

    23.8.1 Memory management when returning references to member variables

    @@ -1945,7 +1945,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

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

    +

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

    @@ -2077,7 +2077,7 @@ as mentioned earlier, setElement is actually: -

    22.8.3 Date marshalling using the csin typemap and associated attributes

    +

    23.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2363,7 +2363,7 @@ public class example { -

    22.8.4 A date example demonstrating marshalling of C# properties

    +

    23.8.4 A date example demonstrating marshalling of C# properties

    @@ -2463,7 +2463,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    23.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2525,7 +2525,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    22.8.6 Turning proxy classes into partial classes

    +

    23.8.6 Turning proxy classes into partial classes

    @@ -2625,7 +2625,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.

    -

    22.8.7 Turning proxy classes into sealed classes

    +

    23.8.7 Turning proxy classes into sealed classes

    @@ -2715,7 +2715,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    22.8.8 Extending proxy classes with additional C# code

    +

    23.8.8 Extending proxy classes with additional C# code

    @@ -2754,7 +2754,7 @@ public class ExtendMe : global::System.IDisposable { -

    22.8.9 Underlying type for enums

    +

    23.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 57aef5b8a..0d0c977cc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -372,7 +372,19 @@ -

    10 Preprocessing

    +

    10 SWIG and C++20

    + + + + + +

    11 Preprocessing

    @@ -395,7 +407,7 @@
    -

    11 SWIG library

    +

    12 SWIG library

    @@ -438,7 +450,7 @@
    -

    12 Argument Handling

    +

    13 Argument Handling

    @@ -461,7 +473,7 @@
    -

    13 Typemaps

    +

    14 Typemaps

    @@ -555,7 +567,7 @@
    -

    14 Customization Features

    +

    15 Customization Features

    @@ -583,7 +595,7 @@
    -

    15 Contracts

    +

    16 Contracts

    @@ -596,7 +608,7 @@
    -

    16 Variable Length Arguments

    +

    17 Variable Length Arguments

    @@ -614,7 +626,7 @@
    -

    17 SWIG and Doxygen Translation

    +

    18 SWIG and Doxygen Translation

    @@ -662,7 +674,7 @@
    -

    18 Warning Messages

    +

    19 Warning Messages

    @@ -691,7 +703,7 @@
    -

    19 Working with Modules

    +

    20 Working with Modules

    @@ -707,7 +719,7 @@
    -

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

    +

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

    @@ -733,7 +745,7 @@
    -

    21 SWIG and Android

    +

    22 SWIG and Android

    @@ -751,7 +763,7 @@
    -

    22 SWIG and C#

    +

    23 SWIG and C#

    @@ -799,7 +811,7 @@
    -

    23 SWIG and D

    +

    24 SWIG and D

    @@ -833,7 +845,7 @@
    -

    24 SWIG and Go

    +

    25 SWIG and Go

    @@ -877,7 +889,7 @@
    -

    25 SWIG and Guile

    +

    26 SWIG and Guile

    @@ -913,7 +925,7 @@
    -

    26 SWIG and Java

    +

    27 SWIG and Java

    @@ -1067,7 +1079,7 @@
    -

    27 SWIG and Javascript

    +

    28 SWIG and Javascript

    @@ -1109,7 +1121,7 @@
    -

    28 SWIG and Lua

    +

    29 SWIG and Lua

    @@ -1177,7 +1189,7 @@
    -

    29 SWIG and Octave

    +

    30 SWIG and Octave

    @@ -1217,7 +1229,7 @@
    -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

    @@ -1293,7 +1305,7 @@
    -

    31 SWIG and PHP

    +

    32 SWIG and PHP

    @@ -1334,7 +1346,7 @@
    -

    32 SWIG and Python

    +

    33 SWIG and Python

    @@ -1476,7 +1488,7 @@
    -

    33 SWIG and R

    +

    34 SWIG and R

    @@ -1492,7 +1504,7 @@
    -

    34 SWIG and Ruby

    +

    35 SWIG and Ruby

    @@ -1630,7 +1642,7 @@
    -

    35 SWIG and Scilab

    +

    36 SWIG and Scilab

    @@ -1699,7 +1711,7 @@
    -

    36 SWIG and Tcl

    +

    37 SWIG and Tcl

    @@ -1765,7 +1777,7 @@
    -

    37 SWIG and MzScheme/Racket

    +

    38 SWIG and MzScheme/Racket

    @@ -1777,7 +1789,7 @@
    -

    38 SWIG and OCaml

    +

    39 SWIG and OCaml

    @@ -1832,7 +1844,7 @@
    -

    39 Extending SWIG to support new languages

    +

    40 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index 93fb8c003..f7acbba3e 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -7,7 +7,7 @@ -

    15 Contracts

    +

    16 Contracts

      @@ -39,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      15.1 The %contract directive

      +

      16.1 The %contract directive

      @@ -95,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    15.2 %contract and classes

    +

    16.2 %contract and classes

    @@ -174,7 +174,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    15.3 Constant aggregation and %aggregate_check

    +

    16.3 Constant aggregation and %aggregate_check

    @@ -263,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    15.4 Notes

    +

    16.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 328bc2391..5fe0f5b52 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -7,7 +7,7 @@ -

    14 Customization Features

    +

    15 Customization Features

    -

    14.1.4 Exception handlers for variables

    +

    15.1.4 Exception handlers for variables

    @@ -305,7 +305,7 @@ The %allowexception feature works like any other feature and so can be

    -

    14.1.5 Defining different exception handlers

    +

    15.1.5 Defining different exception handlers

    @@ -442,7 +442,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    14.1.6 Special variables for %exception

    +

    15.1.6 Special variables for %exception

    @@ -545,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    14.1.7 Using The SWIG exception library

    +

    15.1.7 Using The SWIG exception library

    @@ -600,7 +600,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    14.2 Object ownership and %newobject

    +

    15.2 Object ownership and %newobject

    @@ -757,7 +757,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    14.3 Features and the %feature directive

    +

    15.3 Features and the %feature directive

    @@ -839,7 +839,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    14.3.1 Feature attributes

    +

    15.3.1 Feature attributes

    @@ -880,7 +880,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    14.3.2 Feature flags

    +

    15.3.2 Feature flags

    @@ -978,7 +978,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    14.3.3 Clearing features

    +

    15.3.3 Clearing features

    @@ -1071,7 +1071,7 @@ The three macros below show this for the "except" feature: -

    14.3.4 Features and default arguments

    +

    15.3.4 Features and default arguments

    @@ -1146,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    14.3.5 Feature example

    +

    15.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index d97267a5b..f9f2d53ca 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    23 SWIG and D

    +

    24 SWIG and D

      @@ -41,7 +41,7 @@ -

      23.1 Introduction

      +

      24.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      23.2 Command line invocation

      +

      24.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line options as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      23.3 Typemaps

      +

      24.3 Typemaps

      -

      23.3.1 C# <-> D name comparison

      +

      24.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    23.3.2 ctype, imtype, dtype

    +

    24.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    23.3.3 in, out, directorin, directorout

    +

    24.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    23.3.4 din, dout, ddirectorin, ddirectorout

    +

    24.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

    23.3.5 typecheck typemaps

    +

    24.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    23.3.6 Code injection typemaps

    +

    24.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    23.3.7 Special variable macros

    +

    24.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    23.4 D and %feature

    +

    24.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    23.5 Pragmas

    +

    24.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    23.6 D Exceptions

    +

    24.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    23.7 D Directors

    +

    24.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    23.8 Other features

    +

    24.8 Other features

    -

    23.8.1 Extended namespace support (nspace)

    +

    24.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    23.8.2 Native pointer support

    +

    24.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    23.8.3 Operator overloading

    +

    24.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    23.8.4 Running the test-suite

    +

    24.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    23.9 D Typemap examples

    +

    24.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    23.10 Work in progress and planned features

    +

    24.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 93e1153d5..40faa2014 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

    17 SWIG and Doxygen Translation

    +

    18 SWIG and Doxygen Translation

    -

    17.2.2.4 doxygen:nolinktranslate

    +

    18.2.2.4 doxygen:nolinktranslate

    @@ -430,7 +430,7 @@ This is only applicable to Java at the moment.

    -

    17.2.2.5 doxygen:nostripparams

    +

    18.2.2.5 doxygen:nostripparams

    @@ -440,14 +440,14 @@ This is only applicable to Java at the moment.

    -

    17.2.3 Additional command line options

    +

    18.2.3 Additional command line options

    ALSO TO BE ADDED (Javadoc auto brief?)

    -

    17.3 Doxygen to Javadoc

    +

    18.3 Doxygen to Javadoc

    @@ -456,7 +456,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

    -

    17.3.1 Basic example

    +

    18.3.1 Basic example

    @@ -563,7 +563,7 @@ Javadoc translator features summary directives):

    -

    17.3.2 Javadoc tags

    +

    18.3.2 Javadoc tags

    @@ -825,7 +825,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    17.3.3 Unsupported tags

    +

    18.3.3 Unsupported tags

    @@ -992,14 +992,14 @@ comment, the whole comment block is ignored: -

    17.3.4 Further details

    +

    18.3.4 Further details

    TO BE ADDED.

    -

    17.4 Doxygen to Pydoc

    +

    18.4 Doxygen to Pydoc

    @@ -1010,7 +1010,7 @@ Doxygen or Javadoc, so most of Doxygen commands are translated by merely copying the appropriate command text.

    -

    17.4.1 Basic example

    +

    18.4.1 Basic example

    @@ -1173,7 +1173,7 @@ docs), you may want to use some tool like doxypy to do the work.

    -

    17.4.2 Pydoc translator

    +

    18.4.2 Pydoc translator

    @@ -1426,7 +1426,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    17.4.3 Unsupported tags

    +

    18.4.3 Unsupported tags

    @@ -1542,14 +1542,14 @@ Here is the list of these tags: -

    17.4.4 Further details

    +

    18.4.4 Further details

    TO BE ADDED.

    -

    17.5 Troubleshooting

    +

    18.5 Troubleshooting

    @@ -1571,7 +1571,7 @@ include the option and fix problems with Doxygen comments.

    -

    17.5.1 Problem with conditional compilation

    +

    18.5.1 Problem with conditional compilation

    @@ -1611,14 +1611,14 @@ class A { -

    17.6 Developer information

    +

    18.6 Developer information

    This section contains information for developers enhancing the Doxygen translator.

    -

    17.6.1 Doxygen translator design

    +

    18.6.1 Doxygen translator design

    @@ -1644,7 +1644,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

    -

    17.6.2 Debugging the Doxygen parser and translator

    +

    18.6.2 Debugging the Doxygen parser and translator

    @@ -1657,7 +1657,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

    17.6.3 Tests

    +

    18.6.3 Tests

    @@ -1709,7 +1709,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

    -

    17.7 Extending to other languages

    +

    18.7 Extending to other languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 5a640fbdc..7c2a6c66c 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    39 Extending SWIG to support new languages

    +

    40 Extending SWIG to support new languages

    -

    39.4.4 Attribute namespaces

    +

    40.4.4 Attribute namespaces

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

    -

    39.4.5 Symbol Tables

    +

    40.4.5 Symbol Tables

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

    39.4.6 The %feature directive

    +

    40.4.6 The %feature directive

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

    -

    39.4.7 Code Generation

    +

    40.4.7 Code Generation

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

    -

    39.4.8 SWIG and XML

    +

    40.4.8 SWIG and XML

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

    -

    39.5 Primitive Data Structures

    +

    40.5 Primitive Data Structures

    @@ -993,7 +993,7 @@ typedef Hash Typetab; -

    39.5.1 Strings

    +

    40.5.1 Strings

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

    39.5.2 Hashes

    +

    40.5.2 Hashes

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

    39.5.3 Lists

    +

    40.5.3 Lists

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

    39.5.4 Common operations

    +

    40.5.4 Common operations

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

    39.5.5 Iterating over Lists and Hashes

    +

    40.5.5 Iterating over Lists and Hashes

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

    39.5.6 I/O

    +

    40.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1534,7 +1534,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    39.6 Navigating and manipulating parse trees

    +

    40.6 Navigating and manipulating parse trees

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

    39.7 Working with attributes

    +

    40.7 Working with attributes

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

    39.8 Type system

    +

    40.8 Type system

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

    -

    39.8.1 String encoding of types

    +

    40.8.1 String encoding of types

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

    -

    39.8.2 Type construction

    +

    40.8.2 Type construction

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

    39.8.3 Type tests

    +

    40.8.3 Type tests

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

    39.8.4 Typedef and inheritance

    +

    40.8.4 Typedef and inheritance

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

    39.8.5 Lvalues

    +

    40.8.5 Lvalues

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

    39.8.6 Output functions

    +

    40.8.6 Output functions

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

    39.9 Parameters

    +

    40.9 Parameters

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

    39.10 Writing a Language Module

    +

    40.10 Writing a Language Module

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

    -

    39.10.1 Execution model

    +

    40.10.1 Execution model

    @@ -2476,7 +2476,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.

    -

    39.10.2 Starting out

    +

    40.10.2 Starting out

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

    -

    39.10.3 Command line options

    +

    40.10.3 Command line options

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

    -

    39.10.4 Configuration and preprocessing

    +

    40.10.4 Configuration and preprocessing

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

    -

    39.10.5 Entry point to code generation

    +

    40.10.5 Entry point to code generation

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

    39.10.6 Module I/O and wrapper skeleton

    +

    40.10.6 Module I/O and wrapper skeleton

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

    39.10.7 Low-level code generators

    +

    40.10.7 Low-level code generators

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

    -

    39.10.8 Configuration files

    +

    40.10.8 Configuration files

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

    39.10.9 Runtime support

    +

    40.10.9 Runtime support

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

    -

    39.10.10 Standard library files

    +

    40.10.10 Standard library files

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

    -

    39.10.11 User examples

    +

    40.10.11 User examples

    @@ -3253,7 +3253,7 @@ during this process, see the section on .

    -

    39.10.12 Test driven development and the test-suite

    +

    40.10.12 Test driven development and the test-suite

    @@ -3312,7 +3312,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    39.10.12.1 Running the test-suite

    +

    40.10.12.1 Running the test-suite

    @@ -3504,7 +3504,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    39.10.13 Documentation

    +

    40.10.13 Documentation

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

    39.10.14 Coding style guidelines

    +

    40.10.14 Coding style guidelines

    @@ -3561,7 +3561,7 @@ should be avoided as unlike the SWIG developers, users will never have consisten

    -

    39.10.15 Target language status

    +

    40.10.15 Target language status

    @@ -3570,7 +3570,7 @@ the Target language in This section provides more details on how this status is given.

    -

    39.10.15.1 Supported status

    +

    40.10.15.1 Supported status

    @@ -3617,7 +3617,7 @@ A target language is given the 'Supported' status when

  • -

    39.10.15.2 Experimental status

    +

    40.10.15.2 Experimental status

    @@ -3682,7 +3682,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat -

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

    +

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

    @@ -3746,7 +3746,7 @@ the existing tests.

    -

    39.11 Debugging Options

    +

    40.11 Debugging Options

    @@ -3773,7 +3773,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    39.12 Guide to parse tree nodes

    +

    40.12 Guide to parse tree nodes

    @@ -4181,7 +4181,7 @@ extern "X" { ... } declaration. -

    39.13 Further Development Information

    +

    40.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index c28cc03e1..1a5bb08c7 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    24 SWIG and Go

    +

    25 SWIG and Go

    -

    24.3.1 Go-specific Commandline Options

    +

    25.3.1 Go-specific Commandline Options

    @@ -276,7 +276,7 @@ swig -go -help -

    24.3.2 Generated Wrapper Files

    +

    25.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -320,7 +320,7 @@ combined with the compiled MODULE.go using go tool pack. -

    24.4 A tour of basic C/C++ wrapping

    +

    25.4 A tour of basic C/C++ wrapping

    @@ -330,7 +330,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    24.4.1 Go Package Name

    +

    25.4.1 Go Package Name

    @@ -340,7 +340,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    24.4.2 Go Names

    +

    25.4.2 Go Names

    @@ -372,7 +372,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    24.4.3 Go Constants

    +

    25.4.3 Go Constants

    @@ -380,7 +380,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    24.4.4 Go Enumerations

    +

    25.4.4 Go Enumerations

    @@ -390,7 +390,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    24.4.5 Go Classes

    +

    25.4.5 Go Classes

    @@ -468,7 +468,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    24.4.5.1 Go Class Memory Management

    +

    25.4.5.1 Go Class Memory Management

    @@ -590,7 +590,7 @@ func (o *GoClassName) Close() { -

    24.4.5.2 Go Class Inheritance

    +

    25.4.5.2 Go Class Inheritance

    @@ -602,7 +602,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    24.4.6 Go Templates

    +

    25.4.6 Go Templates

    @@ -611,7 +611,7 @@ wrappers for a particular template instantiation. To do this, use the %template directive. -

    24.4.7 Go Director Classes

    +

    25.4.7 Go Director Classes

    @@ -629,7 +629,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    24.4.7.1 Example C++ code

    +

    25.4.7.1 Example C++ code

    @@ -701,7 +701,7 @@ be found in the end of the guide.

    -

    24.4.7.2 Enable director feature

    +

    25.4.7.2 Enable director feature

    @@ -736,7 +736,7 @@ documentation on directors.

    -

    24.4.7.3 Constructor and destructor

    +

    25.4.7.3 Constructor and destructor

    @@ -789,7 +789,7 @@ embedding.

    -

    24.4.7.4 Override virtual methods

    +

    25.4.7.4 Override virtual methods

    @@ -857,7 +857,7 @@ the Go methods.

    -

    24.4.7.5 Call base methods

    +

    25.4.7.5 Call base methods

    @@ -894,7 +894,7 @@ be found in the end of the guide.

    -

    24.4.7.6 Subclass via embedding

    +

    25.4.7.6 Subclass via embedding

    @@ -962,7 +962,7 @@ class.

    -

    24.4.7.7 Memory management with runtime.SetFinalizer

    +

    25.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1027,7 +1027,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    24.4.7.8 Complete FooBarGo example class

    +

    25.4.7.8 Complete FooBarGo example class

    @@ -1156,7 +1156,7 @@ SWIG/Examples/go/director/.

    -

    24.4.8 Default Go primitive type mappings

    +

    25.4.8 Default Go primitive type mappings

    @@ -1263,7 +1263,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    24.4.9 Output arguments

    +

    25.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1316,7 +1316,7 @@ void f(char *output); -

    24.4.10 Adding additional go code

    +

    25.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1411,7 +1411,7 @@ func bar() { -

    24.4.11 Go typemaps

    +

    25.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 31d822599..9d55b632b 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    25 SWIG and Guile

    +

    26 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      25.1 Supported Guile Versions

      +

      26.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      25.2 Meaning of "Module"

      +

      26.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      25.3 Old GH Guile API

      +

      26.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      25.4 Linkage

      +

      26.4 Linkage

      @@ -89,7 +89,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. -

      25.4.1 Simple Linkage

      +

      26.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      25.4.2 Passive Linkage

      +

      26.4.2 Passive Linkage

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

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

      25.4.3 Native Guile Module Linkage

      +

      26.4.3 Native Guile Module Linkage

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

    -

    25.4.4 Old Auto-Loading Guile Module Linkage

    +

    26.4.4 Old Auto-Loading Guile Module Linkage

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

    25.4.5 Hobbit4D Linkage

    +

    26.4.5 Hobbit4D Linkage

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

    -

    25.5 Underscore Folding

    +

    26.5 Underscore Folding

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

    25.6 Typemaps

    +

    26.6 Typemaps

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

    -

    25.7 Representation of pointers as smobs

    +

    26.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    25.7.1 Smobs

    +

    26.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    25.7.2 Garbage Collection

    +

    26.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 25.8 Native Guile pointers +

    26.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    25.9 Exception Handling

    +

    26.9 Exception Handling

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

    25.10 Procedure documentation

    +

    26.10 Procedure documentation

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

    25.11 Procedures with setters

    +

    26.11 Procedures with setters

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

    25.12 GOOPS Proxy Classes

    +

    26.12 GOOPS Proxy Classes

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

    -

    25.12.1 Naming Issues

    +

    26.12.1 Naming Issues

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

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    25.12.2 Linking

    +

    26.12.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 8d161b73d..facfc7dd1 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -416,6 +416,7 @@ major features include: Most of C++11 is also supported. Details are in the C++11 chapter. C++14 support is covered in the C++14 chapter. C++17 support is covered in the C++17 chapter. +C++20 support is covered in the C++20 chapter.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index db5f041e4..b9234b24f 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    26 SWIG and Java

    +

    27 SWIG and Java

    -

    26.3.3 Global variables

    +

    27.3.3 Global variables

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

    26.3.4 Constants

    +

    27.3.4 Constants

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

    -

    26.3.5 Enumerations

    +

    27.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    26.3.5.1 Anonymous enums

    +

    27.3.5.1 Anonymous enums

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

    -

    26.3.5.2 Typesafe enums

    +

    27.3.5.2 Typesafe enums

    @@ -1126,7 +1126,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.

    -

    26.3.5.3 Proper Java enums

    +

    27.3.5.3 Proper Java enums

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

    -

    26.3.5.4 Type unsafe enums

    +

    27.3.5.4 Type unsafe enums

    @@ -1227,7 +1227,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.

    -

    26.3.5.5 Simple enums

    +

    27.3.5.5 Simple enums

    @@ -1246,7 +1246,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.

    -

    26.3.6 Pointers

    +

    27.3.6 Pointers

    @@ -1334,7 +1334,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.

    -

    26.3.7 Structures

    +

    27.3.7 Structures

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

    26.3.8 C++ classes

    +

    27.3.8 C++ classes

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

    26.3.9 C++ inheritance

    +

    27.3.9 C++ inheritance

    @@ -1626,7 +1626,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.

    -

    26.3.10 Pointers, references, arrays and pass by value

    +

    27.3.10 Pointers, references, arrays and pass by value

    @@ -1681,7 +1681,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).

    -

    26.3.10.1 Null pointers

    +

    27.3.10.1 Null pointers

    @@ -1705,7 +1705,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.

    -

    26.3.11 C++ overloaded functions

    +

    27.3.11 C++ overloaded functions

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

    26.3.12 C++ default arguments

    +

    27.3.12 C++ default arguments

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

    -

    26.3.13 C++ namespaces

    +

    27.3.13 C++ namespaces

    @@ -1953,7 +1953,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    26.3.14 C++ templates

    +

    27.3.14 C++ templates

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

    -

    26.3.15 C++ Smart Pointers

    +

    27.3.15 C++ Smart Pointers

    -

    26.3.15.1 The shared_ptr Smart Pointer

    +

    27.3.15.1 The shared_ptr Smart Pointer

    @@ -2016,7 +2016,7 @@ in the shared_ptr smart pointer -

    26.3.15.2 Generic Smart Pointers

    +

    27.3.15.2 Generic Smart Pointers

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

    26.4 Further details on the generated Java classes

    +

    27.4 Further details on the generated Java classes

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

    -

    26.4.1 The intermediary JNI class

    +

    27.4.1 The intermediary JNI class

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

    -

    26.4.1.1 The intermediary JNI class pragmas

    +

    27.4.1.1 The intermediary JNI class pragmas

    @@ -2317,7 +2317,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    26.4.2 The Java module class

    +

    27.4.2 The Java module class

    @@ -2348,7 +2348,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.

    -

    26.4.2.1 The Java module class pragmas

    +

    27.4.2.1 The Java module class pragmas

    @@ -2399,7 +2399,7 @@ See The intermediary JNI class pragmas secti

    -

    26.4.3 Java proxy classes

    +

    27.4.3 Java proxy classes

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

    26.4.3.1 Memory management

    +

    27.4.3.1 Memory management

    @@ -2637,7 +2637,7 @@ and

    -

    26.4.3.2 Inheritance

    +

    27.4.3.2 Inheritance

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

    27.4.3.3 Proxy classes and garbage collection

    @@ -2836,7 +2836,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.

    -

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    27.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2958,7 +2958,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    26.4.3.5 Single threaded applications and thread safety

    +

    27.4.3.5 Single threaded applications and thread safety

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

    26.4.4 Type wrapper classes

    +

    27.4.4 Type wrapper classes

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

    26.4.5 Enum classes

    +

    27.4.5 Enum classes

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

    -

    26.4.5.1 Typesafe enum classes

    +

    27.4.5.1 Typesafe enum classes

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

    -

    26.4.5.2 Proper Java enum classes

    +

    27.4.5.2 Proper Java enum classes

    @@ -3304,7 +3304,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.

    -

    26.4.5.3 Type unsafe enum classes

    +

    27.4.5.3 Type unsafe enum classes

    @@ -3335,7 +3335,7 @@ public final class Beverage { -

    26.4.6 Interfaces

    +

    27.4.6 Interfaces

    @@ -3580,7 +3580,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    26.5 Cross language polymorphism using directors

    +

    27.5 Cross language polymorphism using directors

    @@ -3602,7 +3602,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.

    -

    26.5.1 Enabling directors

    +

    27.5.1 Enabling directors

    @@ -3670,7 +3670,7 @@ public: -

    26.5.2 Director classes

    +

    27.5.2 Director classes

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

    -

    26.5.3 Overhead and code bloat

    +

    27.5.3 Overhead and code bloat

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

    -

    26.5.4 Simple directors example

    +

    27.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    26.5.5 Director threading issues

    +

    27.5.5 Director threading issues

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

    26.5.6 Director performance tuning

    +

    27.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    26.5.7 Java exceptions from directors

    +

    27.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    26.5.7.1 Customizing director exceptions

    +

    27.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    26.6 Accessing protected members

    +

    27.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    26.7 Common customization features

    +

    27.7 Common customization features

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

    -

    26.7.1 C/C++ helper functions

    +

    27.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    26.7.2 Class extension with %extend

    +

    27.7.2 Class extension with %extend

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

    -

    26.7.3 Class extension with %proxycode

    +

    27.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    26.7.4 Exception handling with %exception and %javaexception

    +

    27.7.4 Exception handling with %exception and %javaexception

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

    -

    26.7.5 Method access with %javamethodmodifiers

    +

    27.7.5 Method access with %javamethodmodifiers

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

    26.8 Tips and techniques

    +

    27.8 Tips and techniques

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

    -

    26.8.1 Input and output parameters using primitive pointers and references

    +

    27.8.1 Input and output parameters using primitive pointers and references

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

    -

    26.8.2 Simple pointers

    +

    27.8.2 Simple pointers

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

    -

    26.8.3 Wrapping C arrays with Java arrays

    +

    27.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    26.8.4 Unbounded C Arrays

    +

    27.8.4 Unbounded C Arrays

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

    -

    26.8.5 Binary data vs Strings

    +

    27.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    26.8.6 Overriding new and delete to allocate from Java heap

    +

    27.8.6 Overriding new and delete to allocate from Java heap

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

    -

    26.9 Java typemaps

    +

    27.9 Java typemaps

    @@ -5657,7 +5657,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. -

    26.9.1 Default primitive type mappings

    +

    27.9.1 Default primitive type mappings

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

    -

    26.9.2 Default typemaps for non-primitive types

    +

    27.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    26.9.3 Sixty four bit JVMs

    +

    27.9.3 Sixty four bit JVMs

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

    -

    26.9.4 What is a typemap?

    +

    27.9.4 What is a typemap?

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

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

    +

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

    @@ -6240,7 +6240,7 @@ These are listed below: -

    26.9.6 Java typemap attributes

    +

    27.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    26.9.7 Java special variables

    +

    27.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    26.9.8 Typemaps for both C and C++ compilation

    +

    27.9.8 Typemaps for both C and C++ compilation

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

    -

    26.9.9 Java code typemaps

    +

    27.9.9 Java code typemaps

    @@ -6803,7 +6803,7 @@ to make the method and constructor public: -

    26.9.10 Director specific typemaps

    +

    27.9.10 Director specific typemaps

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

    26.10 Typemap Examples

    +

    27.10 Typemap Examples

    @@ -7090,7 +7090,7 @@ the SWIG library.

    -

    26.10.1 Simpler Java enums for enums without initializers

    +

    27.10.1 Simpler Java enums for enums without initializers

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

    -

    26.10.2 Handling C++ exception specifications as Java exceptions

    +

    27.10.2 Handling C++ exception specifications as Java exceptions

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

    -

    26.10.3 NaN Exception - exception handling for a particular type

    +

    27.10.3 NaN Exception - exception handling for a particular type

    @@ -7449,7 +7449,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.

    -

    26.10.4 Converting Java String arrays to char **

    +

    27.10.4 Converting Java String arrays to char **

    @@ -7593,7 +7593,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    26.10.5 Expanding a Java object to multiple arguments

    +

    27.10.5 Expanding a Java object to multiple arguments

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

    26.10.6 Using typemaps to return arguments

    +

    27.10.6 Using typemaps to return arguments

    @@ -7793,7 +7793,7 @@ $ java runme 1 12.0 340.0 -

    26.10.7 Adding Java downcasts to polymorphic return types

    +

    27.10.7 Adding Java downcasts to polymorphic return types

    @@ -7999,7 +7999,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.

    -

    26.10.8 Adding an equals method to the Java classes

    +

    27.10.8 Adding an equals method to the Java classes

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

    26.10.9 Void pointers and a common Java base class

    +

    27.10.9 Void pointers and a common Java base class

    @@ -8102,7 +8102,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. -

    26.10.10 Struct pointer to pointer

    +

    27.10.10 Struct pointer to pointer

    @@ -8282,7 +8282,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.

    -

    26.10.11 Memory management when returning references to member variables

    +

    27.10.11 Memory management when returning references to member variables

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

    -

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

    +

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

    @@ -8533,7 +8533,7 @@ as mentioned earlier, setElement is actually: -

    26.10.13 Date marshalling using the javain typemap and associated attributes

    +

    27.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8710,7 +8710,7 @@ A few things to note: -

    26.11 Living with Java Directors

    +

    27.11 Living with Java Directors

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

  • -

    26.12 Odds and ends

    +

    27.12 Odds and ends

    -

    26.12.1 JavaDoc comments

    +

    27.12.1 JavaDoc comments

    @@ -8948,7 +8948,7 @@ public class Barmy { -

    26.12.2 Functional interface without proxy classes

    +

    27.12.2 Functional interface without proxy classes

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

    26.12.3 Using your own JNI functions

    +

    27.12.3 Using your own JNI functions

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

    -

    26.12.4 Performance concerns and hints

    +

    27.12.4 Performance concerns and hints

    @@ -9080,7 +9080,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.

    -

    26.12.5 Debugging

    +

    27.12.5 Debugging

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

    -

    26.13 Java Examples

    +

    27.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 0b301377c..cce5b5e2e 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    27 SWIG and Javascript

    +

    28 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      27.1 Overview

      +

      28.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      27.2 Preliminaries

      +

      28.2 Preliminaries

      -

      27.2.1 Running SWIG

      +

      28.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      27.2.2 Running Tests and Examples

      +

      28.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    27.2.3 Known Issues

    +

    28.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -169,12 +169,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    27.3 Integration

    +

    28.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    27.3.1 Creating node.js Extensions

    +

    28.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -220,7 +220,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    27.3.1.1 Troubleshooting

    +

    28.3.1.1 Troubleshooting

      @@ -232,12 +232,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      27.3.2 Embedded Webkit

      +

      28.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      27.3.2.1 Mac OS X

      +

      28.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -285,7 +285,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      27.3.2.2 GTK

      +

      28.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -330,7 +330,7 @@ int main(int argc, char* argv[]) } -

      27.3.3 Creating Applications with node-webkit

      +

      28.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -421,12 +421,12 @@ open new windows, and many more things. }; -

      27.4 Examples

      +

      28.4 Examples

      Some basic examples are shown here in more detail.

      -

      27.4.1 Simple

      +

      28.4.1 Simple

      The common example simple looks like this:

      @@ -476,7 +476,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      27.4.2 Class

      +

      28.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -606,12 +606,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      27.5 Implementation

      +

      28.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      27.5.1 Source Code

      +

      28.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -712,7 +712,7 @@ Template::Template(const String *code_) { ... } ... -

      27.5.2 Code Templates

      +

      28.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -751,7 +751,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      27.5.3 Emitter

      +

      28.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -870,7 +870,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      27.5.4 Emitter states

      +

      28.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -914,7 +914,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      27.5.5 Handling Exceptions in JavascriptCore

      +

      28.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 560859234..5f72b557d 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -7,7 +7,7 @@ -

      11 SWIG library

      +

      12 SWIG library

      -

      11.2.4 cdata.i

      +

      12.2.4 cdata.i

      @@ -769,7 +769,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      11.3 C string handling

      +

      12.3 C string handling

      @@ -789,7 +789,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      11.3.1 Default string handling

      +

      12.3.1 Default string handling

      @@ -830,7 +830,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      11.3.2 Passing binary data

      +

      12.3.2 Passing binary data

      @@ -872,7 +872,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      11.3.3 Using %newobject to release memory

      +

      12.3.3 Using %newobject to release memory

      @@ -913,7 +913,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      11.3.4 cstring.i

      +

      12.3.4 cstring.i

      @@ -1373,7 +1373,7 @@ structure or class instead.

    -

    11.4 STL/C++ library

    +

    12.4 STL/C++ library

    @@ -1420,7 +1420,7 @@ Please look for the library files in the appropriate language library directory.

    -

    11.4.1 std::string

    +

    12.4.1 std::string

    @@ -1504,7 +1504,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    11.4.2 std::vector

    +

    12.4.2 std::vector

    @@ -1683,7 +1683,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    11.4.3 STL exceptions

    +

    12.4.3 STL exceptions

    @@ -1733,10 +1733,10 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    11.4.4 shared_ptr smart pointer

    +

    12.4.4 shared_ptr smart pointer

    -

    11.4.4.1 shared_ptr basics

    +

    12.4.4.1 shared_ptr basics

    @@ -1832,7 +1832,7 @@ System.out.println(val1 + " " + val2); -

    11.4.4.2 shared_ptr and inheritance

    +

    12.4.4.2 shared_ptr and inheritance

    @@ -1923,7 +1923,7 @@ Adding the missing %shared_ptr macros will fix this: -

    11.4.4.3 shared_ptr and method overloading

    +

    12.4.4.3 shared_ptr and method overloading

    @@ -1945,7 +1945,7 @@ SWIG will choose to wrap just the first method by default. For the interested reader, SWIG detects that they are equivalent types via the typecheck typemaps in the shared_ptr library.

    -

    11.4.4.4 shared_ptr and templates

    +

    12.4.4.4 shared_ptr and templates

    @@ -1987,7 +1987,7 @@ The SWIG code below shows the required ordering: -

    11.4.4.5 shared_ptr and directors

    +

    12.4.4.5 shared_ptr and directors

    @@ -1995,7 +1995,7 @@ The languages that support shared_ptr also have support for using shared_ptr wit

    -

    11.4.5 auto_ptr smart pointer

    +

    12.4.5 auto_ptr smart pointer

    @@ -2044,10 +2044,10 @@ int value = k.getValue(); -

    11.5 Utility Libraries

    +

    12.5 Utility Libraries

    -

    11.5.1 exception.i

    +

    12.5.1 exception.i

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 6633eaa38..60f7e1775 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

    28 SWIG and Lua

    +

    29 SWIG and Lua

      @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      28.1 Preliminaries

      +

      29.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      28.2 Running SWIG

      +

      29.2 Running SWIG

      @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      28.2.1 Additional command line options

      +

      29.2.1 Additional command line options

      @@ -179,7 +179,7 @@ swig -lua -help -

      28.2.2 Compiling and Linking and Interpreter

      +

      29.2.2 Compiling and Linking and Interpreter

      @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      28.2.3 Compiling a dynamic module

      +

      29.2.3 Compiling a dynamic module

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

      28.2.4 Using your module

      +

      29.2.4 Using your module

      @@ -336,19 +336,19 @@ $ ./my_lua >

    -

    28.3 A tour of basic C/C++ wrapping

    +

    29.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.

    -

    28.3.1 Modules

    +

    29.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.

    -

    28.3.2 Functions

    +

    29.3.2 Functions

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

    28.3.3 Global variables

    +

    29.3.3 Global variables

    @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    28.3.4 Constants and enums

    +

    29.3.4 Constants and enums

    @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    28.3.4.1 Constants/enums and classes/structures

    +

    29.3.4.1 Constants/enums and classes/structures

    @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    28.3.5 Pointers

    +

    29.3.5 Pointers

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

    28.3.6 Structures

    +

    29.3.6 Structures

    @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    28.3.7 C++ classes

    +

    29.3.7 C++ classes

    @@ -785,7 +785,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    28.3.8 C++ inheritance

    +

    29.3.8 C++ inheritance

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

    It is safe to use multiple inheritance with SWIG.

    -

    28.3.9 Pointers, references, values, and arrays

    +

    29.3.9 Pointers, references, values, and arrays

    @@ -841,7 +841,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.

    -

    28.3.10 C++ overloaded functions

    +

    29.3.10 C++ overloaded functions

    @@ -927,7 +927,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.

    -

    28.3.11 C++ operators

    +

    29.3.11 C++ operators

    @@ -1059,7 +1059,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    28.3.12 Class extension with %extend

    +

    29.3.12 Class extension with %extend

    @@ -1116,7 +1116,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).

    -

    28.3.13 Using %newobject to release memory

    +

    29.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1140,7 +1140,7 @@ char *foo();

    This will release the allocated memory.

    -

    28.3.14 C++ templates

    +

    29.3.14 C++ templates

    @@ -1175,7 +1175,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.

    -

    28.3.15 C++ Smart Pointers

    +

    29.3.15 C++ Smart Pointers

    @@ -1227,7 +1227,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    28.3.16 C++ Exceptions

    +

    29.3.16 C++ Exceptions

    @@ -1370,7 +1370,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    28.3.17 Namespaces

    +

    29.3.17 Namespaces

    @@ -1421,7 +1421,7 @@ Now, from Lua usage is as follows: 19 > -

    28.3.17.1 Compatibility Note

    +

    29.3.17.1 Compatibility Note

    @@ -1437,7 +1437,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    28.3.17.2 Names

    +

    29.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1481,7 +1481,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    28.3.17.3 Inheritance

    +

    29.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1522,12 +1522,12 @@ function > -

    28.4 Typemaps

    +

    29.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    28.4.1 What is a typemap?

    +

    29.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:

    @@ -1555,7 +1555,7 @@ Received an integer : 6 720 -

    28.4.2 Using typemaps

    +

    29.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.

    @@ -1608,7 +1608,7 @@ void swap(int *sx, int *sy);

    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).

    -

    28.4.3 Typemaps and arrays

    +

    29.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 @@ -1672,7 +1672,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

    Note: SWIG also can support arrays of pointers in a similar manner.

    -

    28.4.4 Typemaps and pointer-pointer functions

    +

    29.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:

    @@ -1706,7 +1706,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    28.5 Writing typemaps

    +

    29.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.

    @@ -1715,7 +1715,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    28.5.1 Typemaps you can write

    +

    29.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.

    @@ -1728,7 +1728,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    28.5.2 SWIG's Lua-C API

    +

    29.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.

    @@ -1777,7 +1777,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    28.6 Customization of your Bindings

    +

    29.6 Customization of your Bindings

    @@ -1786,7 +1786,7 @@ This section covers adding of some small extra bits to your module to add the la -

    28.6.1 Writing your own custom wrappers

    +

    29.6.1 Writing your own custom wrappers

    @@ -1805,7 +1805,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    28.6.2 Adding additional Lua code

    +

    29.6.2 Adding additional Lua code

    @@ -1843,7 +1843,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.

    -

    28.7 Details on the Lua binding

    +

    29.7 Details on the Lua binding

    @@ -1854,7 +1854,7 @@ See Examples/lua/arrays for an example of this code.

    -

    28.7.1 Binding global data into the module.

    +

    29.7.1 Binding global data into the module.

    @@ -1914,7 +1914,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)'.

    -

    28.7.2 Userdata and Metatables

    +

    29.7.2 Userdata and Metatables

    @@ -1994,7 +1994,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    28.7.3 Memory management

    +

    29.7.3 Memory management

    diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 7efd74e2b..b9b7b2b94 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -7,7 +7,7 @@ -

    19 Working with Modules

    +

    20 Working with Modules

    -

    37.3 External documentation

    +

    38.3 External documentation

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 92b5260fe..4ae07e969 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -7,7 +7,7 @@ -

    38 SWIG and OCaml

    +

    39 SWIG and OCaml

    -

    38.1.3 The camlp4 module

    +

    39.1.3 The camlp4 module

    @@ -242,7 +242,7 @@ let b = C_string (getenv "PATH") -

    38.1.4 Using your module

    +

    39.1.4 Using your module

    @@ -256,7 +256,7 @@ option to build your functions into the primitive list. This option is not needed when you build native code.

    -

    38.1.5 Compilation problems and compiling with C++

    +

    39.1.5 Compilation problems and compiling with C++

    @@ -267,7 +267,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

    -

    38.2 The low-level Ocaml/C interface

    +

    39.2 The low-level Ocaml/C interface

    @@ -367,7 +367,7 @@ value items pass through directly, but you must make your own type signature for a function that uses value in this way.

    -

    38.2.1 The generated module

    +

    39.2.1 The generated module

    @@ -401,7 +401,7 @@ it describes the output SWIG will generate for class definitions. -

    38.2.2 Enums

    +

    39.2.2 Enums

    @@ -464,7 +464,7 @@ val x : Enum_test.c_obj = C_enum `a

    -

    38.2.2.1 Enum typing in Ocaml

    +

    39.2.2.1 Enum typing in Ocaml

    @@ -477,10 +477,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

    -

    38.2.3 Arrays

    +

    39.2.3 Arrays

    -

    38.2.3.1 Simple types of bounded arrays

    +

    39.2.3.1 Simple types of bounded arrays

    @@ -501,7 +501,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

    -

    38.2.3.2 Complex and unbounded arrays

    +

    39.2.3.2 Complex and unbounded arrays

    @@ -514,7 +514,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.

    -

    38.2.3.3 Using an object

    +

    39.2.3.3 Using an object

    @@ -528,7 +528,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

    -

    38.2.3.4 Example typemap for a function taking float * and int

    +

    39.2.3.4 Example typemap for a function taking float * and int

    @@ -579,7 +579,7 @@ void printfloats( float *tab, int len ); -

    38.2.4 C++ Classes

    +

    39.2.4 C++ Classes

    @@ -622,7 +622,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

    -

    38.2.4.1 STL vector and string Example

    +

    39.2.4.1 STL vector and string Example

    @@ -702,7 +702,7 @@ baz # -

    38.2.4.2 C++ Class Example

    +

    39.2.4.2 C++ Class Example

    @@ -732,7 +732,7 @@ public: }; -

    38.2.4.3 Compiling the example

    +

    39.2.4.3 Compiling the example

    @@ -750,7 +750,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
       -L$QTPATH/lib -cclib -lqt
     
    -

    38.2.4.4 Sample Session

    +

    39.2.4.4 Sample Session

    @@ -777,10 +777,10 @@ Assuming you have a working installation of QT, you will see a window
     containing the string "hi" in a button.
     

    -

    38.2.5 Director Classes

    +

    39.2.5 Director Classes

    -

    38.2.5.1 Director Introduction

    +

    39.2.5.1 Director Introduction

    @@ -807,7 +807,7 @@ class foo { };

    -

    38.2.5.2 Overriding Methods in Ocaml

    +

    39.2.5.2 Overriding Methods in Ocaml

    @@ -835,7 +835,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.

    -

    38.2.5.3 Director Usage Example

    +

    39.2.5.3 Director Usage Example

    @@ -896,7 +896,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

    -

    38.2.5.4 Creating director objects

    +

    39.2.5.4 Creating director objects

    @@ -937,7 +937,7 @@ object from causing a core dump, as long as the object is destroyed properly.

    -

    38.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    39.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -948,7 +948,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.

    -

    38.2.5.6 directorin typemap

    +

    39.2.5.6 directorin typemap

    @@ -959,7 +959,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

    -

    38.2.5.7 directorout typemap

    +

    39.2.5.7 directorout typemap

    @@ -970,7 +970,7 @@ for the same type, except when there are special requirements for object ownership, etc.

    -

    38.2.5.8 directorargout typemap

    +

    39.2.5.8 directorargout typemap

    @@ -987,7 +987,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.

    -

    38.2.6 Exceptions

    +

    39.2.6 Exceptions

    @@ -1075,7 +1075,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    38.3 Documentation Features

    +

    39.3 Documentation Features

    @@ -1084,7 +1084,7 @@ comments (colloquially referred to as "docstrings") that can be read by OCamldoc.

    -

    38.3.1 Module docstring

    +

    39.3.1 Module docstring

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index bd6b08ff9..bdef5db7c 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -9,7 +9,7 @@ -

    29 SWIG and Octave

    +

    30 SWIG and Octave

      @@ -60,7 +60,7 @@ This chapter is intended to give an introduction to using the module. You should 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).

      -

      29.1 Preliminaries

      +

      30.1 Preliminaries

      @@ -76,7 +76,7 @@ This cannot be guaranteed however, as in recent times new Octave releases have r The SWIG runtime exports the function swig_octave_prereq() for checking the version of Octave.

      -

      29.2 Running SWIG

      +

      30.2 Running SWIG

      @@ -108,7 +108,7 @@ The -c++ option is also required when wrapping C++ code: This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

      -

      29.2.1 Command-line options

      +

      30.2.1 Command-line options

      @@ -131,7 +131,7 @@ The special name "." loads C global variables into the module namespace, i.e. al The -opprefix options sets the prefix of the names of global/friend operator functions.

      -

      29.2.2 Compiling a dynamic module

      +

      30.2.2 Compiling a dynamic module

      @@ -158,7 +158,7 @@ $ mkoctfile example_wrap.cpp example.c

      octave:1> swigexample
      -

      29.2.3 Using your module

      +

      30.2.3 Using your module

      @@ -176,10 +176,10 @@ octave:4> swigexample.cvar.Foo=4; octave:5> swigexample.cvar.Foo ans = 4

    -

    29.3 A tour of basic C/C++ wrapping

    +

    30.3 A tour of basic C/C++ wrapping

    -

    29.3.1 Modules

    +

    30.3.1 Modules

    @@ -224,7 +224,7 @@ octave:4> swigexample.gcd(4, 6) ans = 2 -

    29.3.2 Functions

    +

    30.3.2 Functions

    @@ -241,7 +241,7 @@ int fact(int n);

    octave:1> swigexample.fact(4)
     24 
    -

    29.3.3 Global variables

    +

    30.3.3 Global variables

    @@ -294,7 +294,7 @@ octave:2> swigexample.PI=3.142; octave:3> swigexample.PI ans = 3.1420 -

    29.3.4 Constants and enums

    +

    30.3.4 Constants and enums

    @@ -316,7 +316,7 @@ swigexample.SCONST="Hello World" swigexample.SUNDAY=0 .... -

    29.3.5 Pointers

    +

    30.3.5 Pointers

    @@ -363,7 +363,7 @@ octave:2> f=swigexample.fopen("not there", "r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

    29.3.6 Structures and C++ classes

    +

    30.3.6 Structures and C++ classes

    @@ -498,7 +498,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.

    -

    29.3.7 C++ inheritance

    +

    30.3.7 C++ inheritance

    @@ -507,7 +507,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.

    -

    29.3.8 C++ overloaded functions

    +

    30.3.8 C++ overloaded functions

    @@ -517,7 +517,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.

    -

    29.3.9 C++ operators

    +

    30.3.9 C++ operators

    @@ -621,7 +621,7 @@ On the C++ side, the default mappings are as follows: Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

    -

    29.3.10 Class extension with %extend

    +

    30.3.10 Class extension with %extend

    @@ -660,7 +660,7 @@ Similarly, Octave can use the __float__ method to convert an object to Octave 3.8.0 and later versions will also map unary functions X() to the corresponding __X__ method, where X includes: abs(), acos(), acosh(), angle(), arg(), asin(), asinh(), atan(), atanh(), cbrt(), ceil(), conj(), cos(), cosh(), dawson(), erf(), erfc(), erfcinv(), erfcx(), erfi(), erfinv(), exp(), expm1(), finite(), fix(), floor(), gamma(), imag(), isalnum(), isalpha(), isascii(), iscntrl(), isdigit(), isgraph(), isinf(), islower(), isna(), isnan(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), lgamma(), log(), log10(), log1p(), log2(), real(), round(), roundb(), signbit(), signum(), sin(), sinh(), sqrt(), tan(), tanh(), toascii(), tolower(), toupper()

    -

    29.3.11 C++ templates

    +

    30.3.11 C++ templates

    @@ -737,10 +737,10 @@ ans = -

    29.3.12 C++ Smart Pointers

    +

    30.3.12 C++ Smart Pointers

    -

    29.3.12.1 The shared_ptr Smart Pointer

    +

    30.3.12.1 The shared_ptr Smart Pointer

    @@ -751,14 +751,14 @@ in the shared_ptr smart pointer -

    29.3.12.2 Generic Smart Pointers

    +

    30.3.12.2 Generic Smart Pointers

    C++ smart pointers are fully supported as in other modules.

    -

    29.3.13 Directors (calling Octave from C++ code)

    +

    30.3.13 Directors (calling Octave from C++ code)

    @@ -839,14 +839,14 @@ c-side routine called octave-side routine called -

    29.3.14 Threads

    +

    30.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.

    -

    29.3.15 Memory management

    +

    30.3.15 Memory management

    @@ -880,14 +880,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).

    -

    29.3.16 STL support

    +

    30.3.16 STL support

    Various STL library files are provided for wrapping STL containers.

    -

    29.3.17 Matrix typemaps

    +

    30.3.17 Matrix typemaps

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 766ccaede..1e7bd9f86 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -7,7 +7,7 @@ -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

    -

    30.2.2 Compiling a dynamic module

    +

    31.2.2 Compiling a dynamic module

    @@ -208,7 +208,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

    -

    30.2.3 Building a dynamic module with MakeMaker

    +

    31.2.3 Building a dynamic module with MakeMaker

    @@ -242,7 +242,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.

    -

    30.2.4 Building a static version of Perl

    +

    31.2.4 Building a static version of Perl

    @@ -311,7 +311,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

    -

    30.2.5 Using the module

    +

    31.2.5 Using the module

    @@ -464,7 +464,7 @@ system configuration (this requires root access and you will need to read the man pages).

    -

    30.2.6 Compilation problems and compiling with C++

    +

    31.2.6 Compilation problems and compiling with C++

    @@ -607,7 +607,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.

    -

    30.2.7 Compiling for 64-bit platforms

    +

    31.2.7 Compiling for 64-bit platforms

    @@ -634,7 +634,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

    -

    30.3 Building Perl Extensions under Windows

    +

    31.3 Building Perl Extensions under Windows

    @@ -645,7 +645,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

    -

    30.3.1 Running SWIG from Developer Studio

    +

    31.3.1 Running SWIG from Developer Studio

    @@ -708,7 +708,7 @@ print "$a\n"; -

    30.3.2 Using other compilers

    +

    31.3.2 Using other compilers

    @@ -716,7 +716,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.

    -

    30.4 The low-level interface

    +

    31.4 The low-level interface

    @@ -726,7 +726,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.

    -

    30.4.1 Functions

    +

    31.4.1 Functions

    @@ -749,7 +749,7 @@ use example; $a = &example::fact(2); -

    30.4.2 Global variables

    +

    31.4.2 Global variables

    @@ -819,7 +819,7 @@ extern char *path; // Declared later in the input -

    30.4.3 Constants

    +

    31.4.3 Constants

    @@ -859,7 +859,7 @@ print example::FOO, "\n"; -

    30.4.4 Pointers

    +

    31.4.4 Pointers

    @@ -968,7 +968,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

    -

    30.4.5 Structures

    +

    31.4.5 Structures

    @@ -1102,7 +1102,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

    30.4.6 C++ classes

    +

    31.4.6 C++ classes

    @@ -1167,7 +1167,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.

    -

    30.4.7 C++ classes and type-checking

    +

    31.4.7 C++ classes and type-checking

    @@ -1203,7 +1203,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

    -

    30.4.8 C++ overloaded functions

    +

    31.4.8 C++ overloaded functions

    @@ -1247,7 +1247,7 @@ example::Spam_foo_d($s, 3.14); Please refer to the "SWIG Basics" chapter for more information.

    -

    30.4.9 Operators

    +

    31.4.9 Operators

    @@ -1274,7 +1274,7 @@ The following C++ operators are currently supported by the Perl module:

  • operator or
  • -

    30.4.10 Modules and packages

    +

    31.4.10 Modules and packages

    @@ -1369,7 +1369,7 @@ print Foo::fact(4), "\n"; # Call a function in package FooBar --> -

    30.5 Input and output parameters

    +

    31.5 Input and output parameters

    @@ -1588,7 +1588,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

    -

    30.6 Exception handling

    +

    31.6 Exception handling

    @@ -1752,7 +1752,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

    -

    30.7 Remapping datatypes with typemaps

    +

    31.7 Remapping datatypes with typemaps

    @@ -1769,7 +1769,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

    -

    30.7.1 A simple typemap example

    +

    31.7.1 A simple typemap example

    @@ -1873,7 +1873,7 @@ example::count("e", "Hello World"); -

    30.7.2 Perl5 typemaps

    +

    31.7.2 Perl5 typemaps

    @@ -1978,7 +1978,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

    30.7.3 Typemap variables

    +

    31.7.3 Typemap variables

    @@ -2049,7 +2049,7 @@ properly assigned. The Perl name of the wrapper function being created. -

    30.7.4 Useful functions

    +

    31.7.4 Useful functions

    @@ -2118,7 +2118,7 @@ int sv_isa(SV *, char *0; -

    30.8 Typemap Examples

    +

    31.8 Typemap Examples

    @@ -2127,7 +2127,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

    -

    30.8.1 Converting a Perl5 array to a char **

    +

    31.8.1 Converting a Perl5 array to a char **

    @@ -2219,7 +2219,7 @@ print @$b, "\n"; # Print it out -

    30.8.2 Return values

    +

    31.8.2 Return values

    @@ -2248,7 +2248,7 @@ can be done using the EXTEND() macro as in: } -

    30.8.3 Returning values from arguments

    +

    31.8.3 Returning values from arguments

    @@ -2302,7 +2302,7 @@ print "multout(7, 13) = @r\n"; ($x, $y) = multout(7, 13); -

    30.8.4 Accessing array structure members

    +

    31.8.4 Accessing array structure members

    @@ -2365,7 +2365,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

    -

    30.8.5 Turning Perl references into C pointers

    +

    31.8.5 Turning Perl references into C pointers

    @@ -2430,7 +2430,7 @@ print "$c\n"; -

    30.8.6 Pointer handling

    +

    31.8.6 Pointer handling

    @@ -2515,7 +2515,7 @@ For example: -

    30.9 Proxy classes

    +

    31.9 Proxy classes

    @@ -2531,7 +2531,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

    -

    30.9.1 Preliminaries

    +

    31.9.1 Preliminaries

    @@ -2553,7 +2553,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.

    -

    30.9.2 Structure and class wrappers

    +

    31.9.2 Structure and class wrappers

    @@ -2680,7 +2680,7 @@ $v->DESTROY(); -

    30.9.3 Object Ownership

    +

    31.9.3 Object Ownership

    @@ -2767,7 +2767,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

    -

    30.9.4 Nested Objects

    +

    31.9.4 Nested Objects

    @@ -2820,7 +2820,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

    30.9.5 Proxy Functions

    +

    31.9.5 Proxy Functions

    @@ -2854,7 +2854,7 @@ This function replaces the original function, but operates in an identical manner.

    -

    30.9.6 Inheritance

    +

    31.9.6 Inheritance

    @@ -2930,7 +2930,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

    -

    30.9.7 Modifying the proxy methods

    +

    31.9.7 Modifying the proxy methods

    @@ -2958,7 +2958,7 @@ public: }; -

    30.10 Adding additional Perl code

    +

    31.10 Adding additional Perl code

    @@ -3009,7 +3009,7 @@ set_transform($im, $a); -

    30.11 Cross language polymorphism

    +

    31.11 Cross language polymorphism

    @@ -3043,7 +3043,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    30.11.1 Enabling directors

    +

    31.11.1 Enabling directors

    @@ -3133,7 +3133,7 @@ sub one { -

    30.11.2 Director classes

    +

    31.11.2 Director classes

    @@ -3214,7 +3214,7 @@ so there is no need for the extra overhead involved with routing the calls through Perl.

    -

    30.11.3 Ownership and object destruction

    +

    31.11.3 Ownership and object destruction

    @@ -3263,7 +3263,7 @@ sub DESTROY { -

    30.11.4 Exception unrolling

    +

    31.11.4 Exception unrolling

    @@ -3319,7 +3319,7 @@ Swig::DirectorMethodException is thrown, Perl will register the exception as soon as the C wrapper function returns.

    -

    30.11.5 Overhead and code bloat

    +

    31.11.5 Overhead and code bloat

    @@ -3353,7 +3353,7 @@ directive) for only those methods that are likely to be extended in Perl.

    -

    30.11.6 Typemaps

    +

    31.11.6 Typemaps

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index d0ec0df7f..09c514e94 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

    31 SWIG and PHP

    +

    32 SWIG and PHP

    -

    31.1.2 Using PHP Extensions

    +

    32.1.2 Using PHP Extensions

    @@ -182,7 +182,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll almost certainly want to include it anyway.

    -

    31.2 Basic PHP interface

    +

    32.2 Basic PHP interface

    @@ -194,7 +194,7 @@ SWIG doesn't have support for generating wrappers which make use of PHP's namespace feature.

    -

    31.2.1 Constants

    +

    32.2.1 Constants

    @@ -273,7 +273,7 @@ is treated as true by the if test, when the value of the intended constant would be treated as false!

    -

    31.2.2 Global Variables

    +

    32.2.2 Global Variables

    @@ -322,7 +322,7 @@ undefined. At this time SWIG does not support custom accessor methods.

    -

    31.2.3 Functions

    +

    32.2.3 Functions

    @@ -375,7 +375,7 @@ print $s; # The value of $s was not changed. --> -

    31.2.4 Overloading

    +

    32.2.4 Overloading

    @@ -430,7 +430,7 @@ taking the integer argument.

    --> -

    31.2.5 Pointers and References

    +

    32.2.5 Pointers and References

    @@ -568,7 +568,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

    -

    31.2.6 Structures and C++ classes

    +

    32.2.6 Structures and C++ classes

    @@ -629,7 +629,7 @@ Would be used in the following way from PHP: Member variables and methods are accessed using the -> operator.

    -

    31.2.6.1 Using -noproxy

    +

    32.2.6.1 Using -noproxy

    @@ -655,7 +655,7 @@ Complex_im_set($obj, $d); Complex_im_get($obj); -

    31.2.6.2 Constructors and Destructors

    +

    32.2.6.2 Constructors and Destructors

    @@ -696,7 +696,7 @@ the programmer can either reassign the variable or call unset($v)

    -

    31.2.6.3 Static Member Variables

    +

    32.2.6.3 Static Member Variables

    @@ -739,7 +739,7 @@ Ko::threats(10); echo "There have now been " . Ko::threats() . " threats\n"; -

    31.2.6.4 Static Member Functions

    +

    32.2.6.4 Static Member Functions

    @@ -761,7 +761,7 @@ Ko::threats(); -

    31.2.6.5 Specifying Implemented Interfaces

    +

    32.2.6.5 Specifying Implemented Interfaces

    @@ -779,7 +779,7 @@ so: If there are multiple interfaces, just list them separated by commas.

    -

    31.2.7 PHP Pragmas, Startup and Shutdown code

    +

    32.2.7 PHP Pragmas, Startup and Shutdown code

    @@ -876,7 +876,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

    -

    31.3 Cross language polymorphism

    +

    32.3 Cross language polymorphism

    @@ -911,7 +911,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

    -

    31.3.1 Enabling directors

    +

    32.3.1 Enabling directors

    @@ -1000,7 +1000,7 @@ class MyFoo extends Foo { -

    31.3.2 Director classes

    +

    32.3.2 Director classes

    @@ -1081,7 +1081,7 @@ so there is no need for the extra overhead involved with routing the calls through PHP.

    -

    31.3.3 Ownership and object destruction

    +

    32.3.3 Ownership and object destruction

    @@ -1137,7 +1137,7 @@ In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

    -

    31.3.4 Exception unrolling

    +

    32.3.4 Exception unrolling

    @@ -1204,7 +1204,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

    -

    31.3.5 Overhead and code bloat

    +

    32.3.5 Overhead and code bloat

    @@ -1237,7 +1237,7 @@ optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

    -

    31.3.6 Typemaps

    +

    32.3.6 Typemaps

    @@ -1251,7 +1251,7 @@ need to be supported.

    -

    31.3.7 Miscellaneous

    +

    32.3.7 Miscellaneous

    Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 3d1bb453e..63ee2c2d6 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -7,7 +7,7 @@ -

    10 Preprocessing

    +

    11 Preprocessing

      @@ -38,7 +38,7 @@ However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

      -

      10.1 File inclusion

      +

      11.1 File inclusion

      @@ -64,7 +64,7 @@ By default, the #include is ignored unless you run SWIG with the is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files. -

      10.2 File imports

      +

      11.2 File imports

      @@ -93,7 +93,7 @@ The -importall directive tells SWIG to follow all #include sta as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers. -

      10.3 Conditional Compilation

      +

      11.3 Conditional Compilation

      @@ -151,7 +151,7 @@ SWIG (except for the symbol `SWIG' which is only defined within the SWIG compiler).

      -

      10.4 Macro Expansion

      +

      11.4 Macro Expansion

      @@ -206,7 +206,7 @@ like #x. This is a non-standard SWIG extension.

    -

    10.5 SWIG Macros

    +

    11.5 SWIG Macros

    @@ -252,7 +252,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s support).

    -

    10.6 C99 and GNU Extensions

    +

    11.6 C99 and GNU Extensions

    @@ -308,14 +308,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    10.7 Preprocessing and delimiters

    +

    11.7 Preprocessing and delimiters

    The preprocessor handles { }, " " and %{ %} delimiters differently.

    -

    10.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    +

    11.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -340,7 +340,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    10.7.2 Preprocessing and { ... } delimiters

    +

    11.7.2 Preprocessing and { ... } delimiters

    @@ -382,7 +382,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    10.8 Preprocessor and Typemaps

    +

    11.8 Preprocessor and Typemaps

    @@ -453,7 +453,7 @@ would generate

    -

    10.9 Viewing preprocessor output

    +

    11.9 Viewing preprocessor output

    @@ -463,7 +463,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    10.10 The #error and #warning directives

    +

    11.10 The #error and #warning directives

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index ee443be53..fd07301d4 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -7,7 +7,7 @@ -

    32 SWIG and Python

    +

    33 SWIG and Python

    -

    32.3.3 Global variables

    +

    33.3.3 Global variables

    @@ -1158,7 +1158,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

    -

    32.3.4 Constants and enums

    +

    33.3.4 Constants and enums

    @@ -1198,7 +1198,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    32.3.5 Pointers

    +

    33.3.5 Pointers

    @@ -1339,7 +1339,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.

    -

    32.3.6 Structures

    +

    33.3.6 Structures

    @@ -1549,7 +1549,7 @@ memory and use of it results in a segfault or some sort of other undefined behav

    -

    32.3.7 C++ classes

    +

    33.3.7 C++ classes

    @@ -1637,7 +1637,7 @@ they are accessed through cvar like this: -

    32.3.8 C++ inheritance

    +

    33.3.8 C++ inheritance

    @@ -1692,7 +1692,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

    -

    32.3.9 Pointers, references, values, and arrays

    +

    33.3.9 Pointers, references, values, and arrays

    @@ -1753,7 +1753,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

    -

    32.3.10 C++ overloaded functions

    +

    33.3.10 C++ overloaded functions

    @@ -1876,7 +1876,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    32.3.11 C++ operators

    +

    33.3.11 C++ operators

    @@ -1973,7 +1973,7 @@ instead of raising an exception when the comparison fails, that is, on any kind This follows the guidelines in PEP 207 - Rich Comparisons and NotImplemented Python constant.

    -

    32.3.12 C++ namespaces

    +

    33.3.12 C++ namespaces

    @@ -2040,7 +2040,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    32.3.13 C++ templates

    +

    33.3.13 C++ templates

    @@ -2094,10 +2094,10 @@ Some more complicated examples will appear later.

    -

    32.3.14 C++ Smart Pointers

    +

    33.3.14 C++ Smart Pointers

    -

    32.3.14.1 The shared_ptr Smart Pointer

    +

    33.3.14.1 The shared_ptr Smart Pointer

    @@ -2108,7 +2108,7 @@ in the shared_ptr smart pointer -

    32.3.14.2 Generic Smart Pointers

    +

    33.3.14.2 Generic Smart Pointers

    @@ -2192,7 +2192,7 @@ simply use the __deref__() method. For example: -

    32.3.15 C++ reference counted objects

    +

    33.3.15 C++ reference counted objects

    @@ -2201,7 +2201,7 @@ Python examples of memory management using referencing counting.

    -

    32.4 Further details on the Python class interface

    +

    33.4 Further details on the Python class interface

    @@ -2224,7 +2224,7 @@ the -builtin option are in the Built-in section.

    -

    32.4.1 Proxy classes

    +

    33.4.1 Proxy classes

    @@ -2313,7 +2313,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).

    -

    32.4.2 Built-in Types

    +

    33.4.2 Built-in Types

    @@ -2357,7 +2357,7 @@ please refer to the Python documentation:

    https://docs.python.org/3/extending/newtypes.html

    -

    32.4.2.1 Limitations

    +

    33.4.2.1 Limitations

    Use of the -builtin option implies a couple of limitations: @@ -2518,7 +2518,7 @@ assert(issubclass(B.Derived, A.Base)) -

    32.4.2.2 Operator overloads and slots -- use them!

    +

    33.4.2.2 Operator overloads and slots -- use them!

    The entire justification for the -builtin option is improved @@ -2678,7 +2678,7 @@ in the file python/pyopers.swig in the SWIG library.

    -

    32.4.3 Memory management

    +

    33.4.3 Memory management

    NOTE: Although this section refers to proxy objects, everything here also applies @@ -2873,7 +2873,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

    -

    32.5 Cross language polymorphism

    +

    33.5 Cross language polymorphism

    @@ -2907,7 +2907,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    32.5.1 Enabling directors

    +

    33.5.1 Enabling directors

    @@ -2999,7 +2999,7 @@ class MyFoo(mymodule.Foo): -

    32.5.2 Director classes

    +

    33.5.2 Director classes

    @@ -3079,7 +3079,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

    -

    32.5.3 Ownership and object destruction

    +

    33.5.3 Ownership and object destruction

    @@ -3146,7 +3146,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

    -

    32.5.4 Exception unrolling

    +

    33.5.4 Exception unrolling

    @@ -3205,7 +3205,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

    -

    32.5.5 Overhead and code bloat

    +

    33.5.5 Overhead and code bloat

    @@ -3239,7 +3239,7 @@ directive) for only those methods that are likely to be extended in Python.

    -

    32.5.6 Typemaps

    +

    33.5.6 Typemaps

    @@ -3253,7 +3253,7 @@ need to be supported.

    -

    32.5.7 Miscellaneous

    +

    33.5.7 Miscellaneous

    @@ -3300,7 +3300,7 @@ methods that return const references.

    -

    32.6 Common customization features

    +

    33.6 Common customization features

    @@ -3313,7 +3313,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

    -

    32.6.1 C/C++ helper functions

    +

    33.6.1 C/C++ helper functions

    @@ -3394,7 +3394,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

    -

    32.6.2 Adding additional Python code

    +

    33.6.2 Adding additional Python code

    @@ -3650,7 +3650,7 @@ The same applies for overloaded constructors.

    -

    32.6.3 Class extension with %extend

    +

    33.6.3 Class extension with %extend

    @@ -3739,7 +3739,7 @@ Vector(12, 14, 16) in any way---the extensions only show up in the Python interface.

    -

    32.6.4 Exception handling with %exception

    +

    33.6.4 Exception handling with %exception

    @@ -3873,10 +3873,10 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    32.6.5 Optimization options

    +

    33.6.5 Optimization options

    -

    32.6.5.1 -fastproxy

    +

    33.6.5.1 -fastproxy

    @@ -4009,7 +4009,7 @@ While this possibly provides the best of both worlds, the time to import the mod The command line options mentioned above also apply to wrapped C/C++ global functions, not just class methods.

    -

    32.7 Tips and techniques

    +

    33.7 Tips and techniques

    @@ -4019,7 +4019,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

    -

    32.7.1 Input and output parameters

    +

    33.7.1 Input and output parameters

    @@ -4232,7 +4232,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    32.7.2 Simple pointers

    +

    33.7.2 Simple pointers

    @@ -4301,7 +4301,7 @@ If you replace %pointer_functions() by %pointer_class(type, name)SWIG Library chapter for further details.

    -

    32.7.3 Unbounded C Arrays

    +

    33.7.3 Unbounded C Arrays

    @@ -4363,7 +4363,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    32.7.4 String handling

    +

    33.7.4 String handling

    @@ -4433,7 +4433,7 @@ also be used to extra binary data from arbitrary pointers.

    -

    32.7.5 Default arguments

    +

    33.7.5 Default arguments

    @@ -4532,7 +4532,7 @@ Versions of SWIG prior to this varied in their ability to convert C++ default va equivalent Python default argument values.

    -

    32.8 Typemaps

    +

    33.8 Typemaps

    @@ -4549,7 +4549,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.

    -

    32.8.1 What is a typemap?

    +

    33.8.1 What is a typemap?

    @@ -4665,7 +4665,7 @@ parameter is omitted): -

    32.8.2 Python typemaps

    +

    33.8.2 Python typemaps

    @@ -4706,7 +4706,7 @@ a look at the SWIG library version 1.3.20 or so.

    -

    32.8.3 Typemap variables

    +

    33.8.3 Typemap variables

    @@ -4777,7 +4777,7 @@ properly assigned. The Python name of the wrapper function being created. -

    32.8.4 Useful Python Functions

    +

    33.8.4 Useful Python Functions

    @@ -4905,7 +4905,7 @@ write me -

    32.9 Typemap Examples

    +

    33.9 Typemap Examples

    @@ -4914,7 +4914,7 @@ might look at the files "python.swg" and "typemaps.i" in the SWIG library.

    -

    32.9.1 Converting Python list to a char **

    +

    33.9.1 Converting Python list to a char **

    @@ -4994,7 +4994,7 @@ memory allocation is used to allocate memory for the array, the the C function.

    -

    32.9.2 Expanding a Python object into multiple arguments

    +

    33.9.2 Expanding a Python object into multiple arguments

    @@ -5113,7 +5113,7 @@ TypeError: Wrong number or type of arguments for overloaded function 'foo'. -

    32.9.3 Using typemaps to return arguments

    +

    33.9.3 Using typemaps to return arguments

    @@ -5201,7 +5201,7 @@ function can now be used as follows: >>> -

    32.9.4 Mapping Python tuples into small arrays

    +

    33.9.4 Mapping Python tuples into small arrays

    @@ -5250,7 +5250,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

    -

    32.9.5 Mapping sequences to C arrays

    +

    33.9.5 Mapping sequences to C arrays

    @@ -5339,7 +5339,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

    32.9.6 Pointer handling

    +

    33.9.6 Pointer handling

    @@ -5436,7 +5436,7 @@ that has a this attribute. In addition, class object (if applicable).

    -

    32.9.7 Memory management when returning references to member variables

    +

    33.9.7 Memory management when returning references to member variables

    @@ -5597,7 +5597,7 @@ static PyObject *bike_reference() { -

    32.10 Docstring Features

    +

    33.10 Docstring Features

    @@ -5625,7 +5625,7 @@ of your users much simpler.

    -

    32.10.1 Module docstring

    +

    33.10.1 Module docstring

    @@ -5659,7 +5659,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

    32.10.2 %feature("autodoc")

    +

    33.10.2 %feature("autodoc")

    @@ -5687,7 +5687,7 @@ four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections. -

    32.10.2.1 %feature("autodoc", "0")

    +

    33.10.2.1 %feature("autodoc", "0")

    @@ -5716,7 +5716,7 @@ def function_name(*args, **kwargs): -

    32.10.2.2 %feature("autodoc", "1")

    +

    33.10.2.2 %feature("autodoc", "1")

    @@ -5741,7 +5741,7 @@ def function_name(*args, **kwargs): -

    32.10.2.3 %feature("autodoc", "2")

    +

    33.10.2.3 %feature("autodoc", "2")

    @@ -5803,7 +5803,7 @@ def function_name(*args, **kwargs): -

    32.10.2.4 %feature("autodoc", "3")

    +

    33.10.2.4 %feature("autodoc", "3")

    @@ -5829,7 +5829,7 @@ def function_name(*args, **kwargs): -

    32.10.2.5 %feature("autodoc", "docstring")

    +

    33.10.2.5 %feature("autodoc", "docstring")

    @@ -5848,7 +5848,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

    32.10.3 %feature("docstring")

    +

    33.10.3 %feature("docstring")

    @@ -5880,7 +5880,7 @@ with more than one line. -

    32.11 Python Packages

    +

    33.11 Python Packages

    Python has concepts of modules and packages. Modules are separate units of @@ -5954,7 +5954,7 @@ users may need to use special features such as the package option in th %module directive or import related command line options. These are explained in the following sections.

    -

    32.11.1 Setting the Python package

    +

    33.11.1 Setting the Python package

    @@ -6008,7 +6008,7 @@ pkg1/pkg2/_foo.so # (shared library built from C/C++ code generated by SWI -

    32.11.2 Absolute and relative imports

    +

    33.11.2 Absolute and relative imports

    Suppose, we have the following hierarchy of files:

    @@ -6145,7 +6145,7 @@ uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

    -

    32.11.3 Enforcing absolute import semantics

    +

    33.11.3 Enforcing absolute import semantics

    As you may know, there is an incompatibility in import semantics (for the @@ -6182,7 +6182,7 @@ from __future__ import absolute_import -

    32.11.4 Importing from __init__.py

    +

    33.11.4 Importing from __init__.py

    Imports in __init__.py are handy when you want to populate a @@ -6292,7 +6292,7 @@ class Bar(pkg3.foo.Foo): pass effect (note, that the Python 2 case also needs the -relativeimport workaround).

    -

    32.11.5 Implicit namespace packages

    +

    33.11.5 Implicit namespace packages

    Python 3.3 introduced @@ -6370,7 +6370,7 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

    -

    32.11.6 Location of modules

    +

    33.11.6 Location of modules

    @@ -6406,7 +6406,7 @@ The following sub-sections look more closely at the two default configurations a An input interface file, foo.i, results in the two modules foo.py and _foo.so for each of the configurations.

    -

    32.11.6.1 Both modules in the same package

    +

    33.11.6.1 Both modules in the same package

    @@ -6441,7 +6441,7 @@ from mypackage import foo -

    32.11.6.2 Both modules are global

    +

    33.11.6.2 Both modules are global

    @@ -6473,7 +6473,7 @@ import foo -

    32.11.6.3 Split modules custom configuration

    +

    33.11.6.3 Split modules custom configuration

    In this non-standard 'split module' configuration, the pure Python module is in a package and the low level C/C++ module is global. @@ -6523,7 +6523,7 @@ Using one of the two default configurations is the recommended approach now.

    -

    32.11.6.4 More on customizing the module import code

    +

    33.11.6.4 More on customizing the module import code

    @@ -6643,7 +6643,7 @@ The following will do this for the 32.11.6.5 Statically linked C modules +

    33.11.6.5 Statically linked C modules

    It is strongly recommended to use dynamically linked modules for the C @@ -6715,7 +6715,7 @@ module then you will either need to refer to the Python documentation on how to do this (remember you are now the Python importer) or use dynamic linking.

    -

    32.12 Python 3 Support

    +

    33.12 Python 3 Support

    @@ -6740,7 +6740,7 @@ The following are Python 3 new features that are currently supported by SWIG.

    -

    32.12.1 Function annotation

    +

    33.12.1 Function annotation

    @@ -6773,7 +6773,7 @@ For detailed usage of function annotation, see PEP 3107.

    -

    32.12.2 Buffer interface

    +

    33.12.2 Buffer interface

    @@ -6925,7 +6925,7 @@ modify the buffer. -

    32.12.3 Abstract base classes

    +

    33.12.3 Abstract base classes

    @@ -6975,7 +6975,7 @@ The collections.abc module was introduced in Python 3.3 and hence this requires Python 3.3 or later.

    -

    32.12.4 Byte string output conversion

    +

    33.12.4 Byte string output conversion

    @@ -7156,7 +7156,7 @@ overloads taking both std::string (as Python bytes) and std::wstring (as Python unicode).

    -

    32.12.5 Python 2 Unicode

    +

    33.12.5 Python 2 Unicode

    @@ -7228,7 +7228,7 @@ the first is allowing unicode conversion and the second is explicitly prohibiting it.

    -

    32.13 Support for Multithreaded Applications

    +

    33.13 Support for Multithreaded Applications

    By default, SWIG does not enable support for multithreaded Python applications. More @@ -7243,7 +7243,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai interface for this is described in the next section.

    -

    32.13.1 UI for Enabling Multithreading Support

    +

    33.13.1 UI for Enabling Multithreading Support

    The user interface is as follows:

    @@ -7286,7 +7286,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai -

    32.13.2 Multithread Performance

    +

    33.13.2 Multithread Performance

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 373cd7ed9..6547ab128 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -7,7 +7,7 @@ -

    33 SWIG and R

    +

    34 SWIG and R

      @@ -36,7 +36,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++.

      -

      33.1 Bugs

      +

      34.1 Bugs

      @@ -48,7 +48,7 @@ Currently the following features are not implemented or broken:

    • C Array wrappings
    -

    33.2 Using R and SWIG

    +

    34.2 Using R and SWIG

    @@ -138,7 +138,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

  • Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into -

    33.3 Precompiling large R files

    +

    34.3 Precompiling large R files

    @@ -160,7 +160,7 @@ will save a large amount of loading time. -

    33.4 General policy

    +

    34.4 General policy

    @@ -169,7 +169,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

    -

    33.5 Language conventions

    +

    34.5 Language conventions

    @@ -178,7 +178,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    33.6 C++ classes

    +

    34.6 C++ classes

    @@ -190,7 +190,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

    -

    33.7 Enumerations

    +

    34.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 6939a8a18..5581cc458 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -8,7 +8,7 @@ -

    34 SWIG and Ruby

    +

    35 SWIG and Ruby

      @@ -149,7 +149,7 @@

      This chapter describes SWIG's support of Ruby.

      -

      34.1 Preliminaries

      +

      35.1 Preliminaries

      SWIG 4.0 is known to work with Ruby versions 1.9 and later. @@ -164,7 +164,7 @@ read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

      -

      34.1.1 Running SWIG

      +

      35.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -188,7 +188,7 @@ if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      34.1.2 Getting the right header files

      +

      35.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -202,7 +202,7 @@ the compiler options needed to compile the code is to ask Ruby itself:

    -

    34.1.3 Compiling a dynamic module

    +

    35.1.3 Compiling a dynamic module

    Ruby extension modules are typically compiled into shared @@ -275,7 +275,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.

    -

    34.1.4 Using your module

    +

    35.1.4 Using your module

    Ruby module names must be capitalized, @@ -305,7 +305,7 @@ begins with:

    will result in an extension module using the feature name "example" and Ruby module name "Example".

    -

    34.1.5 Static linking

    +

    35.1.5 Static linking

    An alternative approach to dynamic linking is to rebuild the @@ -320,7 +320,7 @@ finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

    -

    34.1.6 Compilation of C++ extensions

    +

    35.1.6 Compilation of C++ extensions

    On most machines, C++ extension modules should be linked @@ -352,7 +352,7 @@ $libs = append_library($libs, "supc++") create_makefile('example')

  • -

    34.2 Building Ruby Extensions under Windows 95/NT

    +

    35.2 Building Ruby Extensions under Windows 95/NT

    Building a SWIG extension to Ruby under Windows 95/NT is @@ -377,7 +377,7 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

    -

    34.2.1 Running SWIG from Developer Studio

    +

    35.2.1 Running SWIG from Developer Studio

    If you are developing your application within Microsoft @@ -441,13 +441,13 @@ Foo = 3.0 -

    34.3 The Ruby-to-C/C++ Mapping

    +

    35.3 The Ruby-to-C/C++ Mapping

    This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

    -

    34.3.1 Modules

    +

    35.3.1 Modules

    The SWIG %module directive specifies @@ -519,7 +519,7 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

    -

    34.3.2 Functions

    +

    35.3.2 Functions

    Global functions are wrapped as Ruby module methods. For @@ -553,7 +553,7 @@ irb(main):002:0> Example.fact(4) 24 -

    34.3.3 Variable Linking

    +

    35.3.3 Variable Linking

    C/C++ global variables are wrapped as a pair of singleton @@ -633,7 +633,7 @@ irb(main):004:0> $Variable2 41.2 -

    34.3.4 Constants

    +

    35.3.4 Constants

    C/C++ constants are wrapped as module constants initialized @@ -661,7 +661,7 @@ irb(main):002:0> Example::PI 3.14159 -

    34.3.5 Pointers

    +

    35.3.5 Pointers

    "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -685,7 +685,7 @@ returns an instance of an internally generated Ruby class:

    A NULL pointer is always represented by the Ruby nil object.

    -

    34.3.6 Structures

    +

    35.3.6 Structures

    C/C++ structs are wrapped as Ruby classes, with accessor @@ -790,7 +790,7 @@ void Bar_f_set(Bar *b, Foo *val) { } -

    34.3.7 C++ classes

    +

    35.3.7 C++ classes

    Like structs, C++ classes are wrapped by creating a new Ruby @@ -845,7 +845,7 @@ Ale 3 -

    34.3.8 C++ Inheritance

    +

    35.3.8 C++ Inheritance

    The SWIG type-checker is fully aware of C++ inheritance. @@ -998,7 +998,7 @@ inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

    -

    34.3.9 C++ Overloaded Functions

    +

    35.3.9 C++ Overloaded Functions

    C++ overloaded functions, methods, and constructors are @@ -1088,7 +1088,7 @@ arises--in this case, the first declaration takes precedence.

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    34.3.10 C++ Operators

    +

    35.3.10 C++ Operators

    For the most part, overloaded operators are handled @@ -1130,7 +1130,7 @@ c = Example.add_complex(a, b) is discussed in the section on operator overloading.

    -

    34.3.11 C++ namespaces

    +

    35.3.11 C++ namespaces

    SWIG is aware of C++ namespaces, but namespace names do not @@ -1187,7 +1187,7 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    34.3.12 C++ templates

    +

    35.3.12 C++ templates

    C++ templates don't present a huge problem for SWIG. However, @@ -1229,7 +1229,7 @@ irb(main):004:0> p.second 4 -

    34.3.13 C++ Standard Template Library (STL)

    +

    35.3.13 C++ Standard Template Library (STL)

    On a related note, the standard SWIG library contains a @@ -1322,7 +1322,7 @@ puts v shown in these examples. More details can be found in the SWIG and C++ chapter.

    -

    34.3.14 C++ STL Functors

    +

    35.3.14 C++ STL Functors

    Some containers in the STL allow you to modify their default @@ -1383,7 +1383,7 @@ b -

    34.3.15 C++ STL Iterators

    +

    35.3.15 C++ STL Iterators

    The STL is well known for the use of iterators. There @@ -1466,10 +1466,10 @@ i

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    -

    34.3.16 C++ Smart Pointers

    +

    35.3.16 C++ Smart Pointers

    -

    34.3.16.1 The shared_ptr Smart Pointer

    +

    35.3.16.1 The shared_ptr Smart Pointer

    @@ -1480,7 +1480,7 @@ in the shared_ptr smart pointer -

    34.3.16.2 Generic Smart Pointers

    +

    35.3.16.2 Generic Smart Pointers

    In certain C++ programs, it is common to use classes that @@ -1545,7 +1545,7 @@ method. For example:

    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    -

    34.3.17 Cross-Language Polymorphism

    +

    35.3.17 Cross-Language Polymorphism

    SWIG's Ruby module supports cross-language polymorphism @@ -1554,7 +1554,7 @@ module. Rather than duplicate the information presented in the 34.3.17.1 Exception Unrolling +

    35.3.17.1 Exception Unrolling

    Whenever a C++ director class routes one of its virtual @@ -1577,7 +1577,7 @@ method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    -

    34.4 Naming

    +

    35.4 Naming

    Ruby has several common naming conventions. Constants are @@ -1615,7 +1615,7 @@ generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    -

    34.4.1 Defining Aliases

    +

    35.4.1 Defining Aliases

    It's a fairly common practice in the Ruby built-ins and @@ -1685,7 +1685,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.2 Predicate Methods

    +

    35.4.2 Predicate Methods

    Ruby methods that return a boolean value and end in a @@ -1734,7 +1734,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.3 Bang Methods

    +

    35.4.3 Bang Methods

    Ruby methods that modify an object in-place and end in an @@ -1766,7 +1766,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.4 Getters and Setters

    +

    35.4.4 Getters and Setters

    Often times a C++ library will expose properties through @@ -1801,7 +1801,7 @@ irb(main):003:0> puts foo.value %rename("value=") Foo::setValue(int value); -

    34.5 Input and output parameters

    +

    35.5 Input and output parameters

    A common problem in some C programs is handling parameters @@ -1940,10 +1940,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);

    r, c = Example.get_dimensions(m)
    -

    34.6 Exception handling

    +

    35.6 Exception handling

    -

    34.6.1 Using the %exception directive

    +

    35.6.1 Using the %exception directive

    The SWIG %exception directive can be @@ -2052,7 +2052,7 @@ methods and functions named getitem and setitem. limited to C++ exception handling. See the chapter on Customization Features for more examples.

    -

    34.6.2 Handling Ruby Blocks

    +

    35.6.2 Handling Ruby Blocks

    One of the highlights of Ruby and most of its standard library @@ -2119,7 +2119,7 @@ a special in typemap, like:

    For more information on typemaps, see Typemaps.

    -

    34.6.3 Raising exceptions

    +

    35.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to @@ -2276,7 +2276,7 @@ function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    -

    34.6.4 Exception classes

    +

    35.6.4 Exception classes

    Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -2313,7 +2313,7 @@ end

    For another example look at swig/Examples/ruby/exception_class.

    -

    34.7 Typemaps

    +

    35.7 Typemaps

    This section describes how you can modify SWIG's default @@ -2328,7 +2328,7 @@ 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 primitive C-Ruby interface.

    -

    34.7.1 What is a typemap?

    +

    35.7.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is @@ -2485,7 +2485,7 @@ to be used as follows (notice how the length parameter is omitted):

    2 -

    34.7.2 Typemap scope

    +

    35.7.2 Typemap scope

    Once defined, a typemap remains in effect for all of the @@ -2531,7 +2531,7 @@ where the class itself is defined. For example:

    }; -

    34.7.3 Copying a typemap

    +

    35.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    @@ -2573,7 +2573,7 @@ rules as for %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments -

    34.7.4 Deleting a typemap

    +

    35.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For @@ -2598,7 +2598,7 @@ defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    -

    34.7.5 Placement of typemaps

    +

    35.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, @@ -2669,13 +2669,13 @@ In this example, this is done using the class declaration class string .

    -

    34.7.6 Ruby typemaps

    +

    35.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    -

    34.7.6.1 "in" typemap

    +

    35.7.6.1 "in" typemap

    Converts Ruby objects to input @@ -2742,7 +2742,7 @@ arguments to be specified. For example:

    At this time, only zero or one arguments may be converted.

    -

    34.7.6.2 "typecheck" typemap

    +

    35.7.6.2 "typecheck" typemap

    The "typecheck" typemap is used to support overloaded @@ -2764,7 +2764,7 @@ program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    -

    34.7.6.3 "out" typemap

    +

    35.7.6.3 "out" typemap

    Converts return value of a C function @@ -2815,7 +2815,7 @@ version of the C datatype matched by the typemap.

    -

    34.7.6.4 "arginit" typemap

    +

    35.7.6.4 "arginit" typemap

    The "arginit" typemap is used to set the initial value of a @@ -2830,7 +2830,7 @@ applications. For example:

    } -

    34.7.6.5 "default" typemap

    +

    35.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a @@ -2855,7 +2855,7 @@ arguments that follow must have default values. See the 34.7.6.6 "check" typemap +

    35.7.6.6 "check" typemap

    The "check" typemap is used to supply value checking code @@ -2870,7 +2870,7 @@ arguments have been converted. For example:

    } -

    34.7.6.7 "argout" typemap

    +

    35.7.6.7 "argout" typemap

    The "argout" typemap is used to return values from arguments. @@ -2924,7 +2924,7 @@ some function like SWIG_Ruby_AppendOutput.

    See the typemaps.i library for examples.

    -

    34.7.6.8 "freearg" typemap

    +

    35.7.6.8 "freearg" typemap

    The "freearg" typemap is used to cleanup argument data. It is @@ -2951,7 +2951,7 @@ This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    34.7.6.9 "newfree" typemap

    +

    35.7.6.9 "newfree" typemap

    The "newfree" typemap is used in conjunction with the %newobject @@ -2975,7 +2975,7 @@ string *foo();

    See Object ownership and %newobject for further details.

    -

    34.7.6.10 "memberin" typemap

    +

    35.7.6.10 "memberin" typemap

    The "memberin" typemap is used to copy data from an @@ -2993,21 +2993,21 @@ example:

    already provides a default implementation for arrays, strings, and other objects.

    -

    34.7.6.11 "varin" typemap

    +

    35.7.6.11 "varin" typemap

    The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    34.7.6.12 "varout" typemap

    +

    35.7.6.12 "varout" typemap

    The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

    -

    34.7.6.13 "throws" typemap

    +

    35.7.6.13 "throws" typemap

    The "throws" typemap is only used when SWIG parses a C++ @@ -3048,7 +3048,7 @@ specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    -

    34.7.6.14 directorin typemap

    +

    35.7.6.14 directorin typemap

    Converts C++ objects in director @@ -3107,7 +3107,7 @@ referring to the class itself. -

    34.7.6.15 directorout typemap

    +

    35.7.6.15 directorout typemap

    Converts Ruby objects in director @@ -3180,7 +3180,7 @@ exception.

    -

    34.7.6.16 directorargout typemap

    +

    35.7.6.16 directorargout typemap

    Output argument processing in director @@ -3238,19 +3238,19 @@ referring to the instance of the class itself -

    34.7.6.17 ret typemap

    +

    35.7.6.17 ret typemap

    Cleanup of function return values

    -

    34.7.6.18 globalin typemap

    +

    35.7.6.18 globalin typemap

    Setting of C global variables

    -

    34.7.7 Typemap variables

    +

    35.7.7 Typemap variables

    @@ -3300,7 +3300,7 @@ so that their values can be properly assigned.

    The Ruby name of the wrapper function being created.
    -

    34.7.8 Useful Functions

    +

    35.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -3315,7 +3315,7 @@ stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    -

    34.7.8.1 C Datatypes to Ruby Objects

    +

    35.7.8.1 C Datatypes to Ruby Objects

    @@ -3357,7 +3357,7 @@ SWIG_From_float(float)
    -

    34.7.8.2 Ruby Objects to C Datatypes

    +

    35.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -3425,7 +3425,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -

    34.7.8.3 Macros for VALUE

    +

    35.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -3448,7 +3448,7 @@ versions do not, but return a status value to indicate success (SWIG_OK
    pointer to array storage
    -

    34.7.8.4 Exceptions

    +

    35.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -3527,7 +3527,7 @@ message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf(). -

    34.7.8.5 Iterators

    +

    35.7.8.5 Iterators

    void rb_iter_break()

    @@ -3573,14 +3573,14 @@ VALUE), VALUE value)

    Equivalent to Ruby's throw.
    -

    34.7.9 Typemap Examples

    +

    35.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

    -

    34.7.10 Converting a Ruby array to a char **

    +

    35.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -3645,7 +3645,7 @@ array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    -

    34.7.11 Collecting arguments in a hash

    +

    35.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -3859,7 +3859,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:

    program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    -

    34.7.12 Pointer handling

    +

    35.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -3918,7 +3918,7 @@ For example:

    } -

    34.7.12.1 Ruby Datatype Wrapping

    +

    35.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -3945,7 +3945,7 @@ as above. type c-type from the data object obj and assigns that pointer to ptr. -

    34.7.13 Example: STL Vector to Ruby Array

    +

    35.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -4037,7 +4037,7 @@ STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library. -

    34.8 Docstring Features

    +

    35.8 Docstring Features

    @@ -4071,7 +4071,7 @@ generate ri documentation from a c wrap file, you could do:

    $ rdoc -r file_wrap.c -

    34.8.1 Module docstring

    +

    35.8.1 Module docstring

    @@ -4101,7 +4101,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -

    34.8.2 %feature("autodoc")

    +

    35.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -4122,7 +4122,7 @@ several options for autodoc controlled by the value given to the feature, described below.

    -

    34.8.2.1 %feature("autodoc", "0")

    +

    35.8.2.1 %feature("autodoc", "0")

    @@ -4146,7 +4146,7 @@ Then Ruby code like this will be generated: ... -

    34.8.2.2 %feature("autodoc", "1")

    +

    35.8.2.2 %feature("autodoc", "1")

    @@ -4166,7 +4166,7 @@ this: ... -

    34.8.2.3 %feature("autodoc", "2")

    +

    35.8.2.3 %feature("autodoc", "2")

    @@ -4178,7 +4178,7 @@ parameter types with the "2" option will result in Ruby code like this:

    -

    34.8.2.4 %feature("autodoc", "3")

    +

    35.8.2.4 %feature("autodoc", "3")

    @@ -4199,7 +4199,7 @@ Parameters: bar - Bar -

    34.8.2.5 %feature("autodoc", "docstring")

    +

    35.8.2.5 %feature("autodoc", "docstring")

    @@ -4215,7 +4215,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -

    34.8.3 %feature("docstring")

    +

    35.8.3 %feature("docstring")

    @@ -4226,10 +4226,10 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    -

    34.9 Advanced Topics

    +

    35.9 Advanced Topics

    -

    34.9.1 Operator overloading

    +

    35.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -4410,7 +4410,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    -

    34.9.2 Creating Multi-Module Packages

    +

    35.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -4536,7 +4536,7 @@ irb(main):005:0> c.getX() 5.0 -

    34.9.3 Specifying Mixin Modules

    +

    35.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -4603,7 +4603,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.10 Memory Management

    +

    35.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -4626,7 +4626,7 @@ to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    -

    34.10.1 Mark and Sweep Garbage Collector

    +

    35.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -4657,7 +4657,7 @@ any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    -

    34.10.2 Object Ownership

    +

    35.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -4802,7 +4802,7 @@ public:

    This code can be seen in swig/examples/ruby/tracking.

    -

    34.10.3 Object Tracking

    +

    35.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -5028,7 +5028,7 @@ However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    -

    34.10.4 Mark Functions

    +

    35.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -5157,7 +5157,7 @@ irb(main):016:0>

    This code can be seen in swig/examples/ruby/mark_function.

    -

    34.10.5 Free Functions

    +

    35.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -5325,7 +5325,7 @@ been freed, and thus raises a runtime exception.

    This code can be seen in swig/examples/ruby/free_function.

    -

    34.10.6 Embedded Ruby and the C++ Stack

    +

    35.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/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index dc9ae0f7e..0c259e393 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -91,6 +91,7 @@ For additions to the original C++ standard, please read the SWIG and C++11, SWIG and C++14 and SWIG and C++17 chapters. +SWIG and C++20 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ISO C. Support for C++ builds upon ISO C diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 88ab8043e..5c4ef6269 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -9,7 +9,7 @@ -

    35 SWIG and Scilab

    +

    36 SWIG and Scilab

    -

    35.3 A basic tour of C/C++ wrapping

    +

    36.3 A basic tour of C/C++ wrapping

    -

    35.3.1 Overview

    +

    36.3.1 Overview

    @@ -332,7 +332,7 @@ This means that functions, structs, classes, variables, etc... are interfaced th There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    -

    35.3.2 Identifiers

    +

    36.3.2 Identifiers

    @@ -347,7 +347,7 @@ In these cases, the %rename directive Note: truncations can be disabled by specifying the target version 6 of Scilab in the targetversion argument (i.e. -targetversion 6).

    -

    35.3.3 Functions

    +

    36.3.3 Functions

    @@ -378,7 +378,7 @@ ans = 24. -

    35.3.3.1 Argument passing

    +

    36.3.3.1 Argument passing

    @@ -431,7 +431,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are 7. -

    35.3.3.2 Multiple output arguments

    +

    36.3.3.2 Multiple output arguments

    @@ -480,7 +480,7 @@ int divide(int n, int d, int *OUTPUT, int *OUTPUT); -

    35.3.4 Global variables

    +

    36.3.4 Global variables

    @@ -549,10 +549,10 @@ It works the same:

    -

    35.3.5 Constants and enumerations

    +

    36.3.5 Constants and enumerations

    -

    35.3.5.1 Constants

    +

    36.3.5.1 Constants

    @@ -693,7 +693,7 @@ are mapped to Scilab variables, with the same name: 3.14 -

    35.3.5.2 Enumerations

    +

    36.3.5.2 Enumerations

    @@ -758,7 +758,7 @@ typedef enum { RED, BLUE, GREEN } color; -

    35.3.6 Pointers

    +

    36.3.6 Pointers

    @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE". The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    35.3.6.1 Utility functions

    +

    36.3.6.1 Utility functions

    @@ -861,7 +861,7 @@ ans = -

    35.3.6.2 Null pointers:

    +

    36.3.6.2 Null pointers:

    @@ -877,7 +877,7 @@ Using the previous SWIG_this() and SWIG_ptr(), it is possible -

    35.3.7 Structures

    +

    36.3.7 Structures

    @@ -986,7 +986,7 @@ Note: the pointer to the struct works as described in 35.3.8 C++ classes +

    36.3.8 C++ classes

    @@ -1054,7 +1054,7 @@ Note: like structs, class pointers are mapped as described in 35.3.9 C++ inheritance +

    36.3.9 C++ inheritance

    @@ -1129,7 +1129,7 @@ But we can use either use the get_perimeter() function of the parent cl 18.84 -

    35.3.10 C++ overloading

    +

    36.3.10 C++ overloading

    @@ -1169,7 +1169,7 @@ void magnify(Circle *circle, double factor) { -

    35.3.11 Pointers, references, values, and arrays

    +

    36.3.11 Pointers, references, values, and arrays

    @@ -1227,7 +1227,7 @@ All these functions will return a pointer to an instance of Foo. As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.

    -

    35.3.12 C++ templates

    +

    36.3.12 C++ templates

    @@ -1286,7 +1286,7 @@ Then in Scilab: More details on template support can be found in the templates documentation.

    -

    35.3.13 C++ operators

    +

    36.3.13 C++ operators

    @@ -1339,7 +1339,7 @@ private: -

    35.3.14 C++ namespaces

    +

    36.3.14 C++ namespaces

    @@ -1417,7 +1417,7 @@ Note: the nspace feature is not supp

    -

    35.3.15 C++ exceptions

    +

    36.3.15 C++ exceptions

    @@ -1500,17 +1500,17 @@ More complex or custom exception types require specific exception typemaps to be See the SWIG C++ documentation for more details.

    -

    35.3.16 C++ STL

    +

    36.3.16 C++ STL

    The Standard Template Library (STL) is partially supported. See STL for more details.

    -

    35.4 Type mappings and libraries

    +

    36.4 Type mappings and libraries

    -

    35.4.1 Default primitive type mappings

    +

    36.4.1 Default primitive type mappings

    @@ -1561,7 +1561,7 @@ The default behaviour is for SWIG to generate code that will give a runtime erro -

    35.4.2 Arrays

    +

    36.4.2 Arrays

    @@ -1616,7 +1616,7 @@ void printArray(int values[], int len) { [ 0 1 2 3 ] -

    35.4.3 Pointer-to-pointers

    +

    36.4.3 Pointer-to-pointers

    @@ -1689,7 +1689,7 @@ void print_matrix(double **M, int nbRows, int nbCols) { -

    35.4.4 Matrices

    +

    36.4.4 Matrices

    @@ -1782,7 +1782,7 @@ The remarks made earlier for arrays also apply here:

  • There is no control while converting double values to integers, double values are truncated without any checking or warning.
  • -

    35.4.5 STL

    +

    36.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    35.5 Module initialization

    +

    36.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    35.6 Building modes

    +

    36.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    35.6.1 No-builder mode

    +

    36.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    35.6.2 Builder mode

    +

    36.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    35.7 Generated scripts

    +

    36.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    35.7.1 Builder script

    +

    36.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    35.7.2 Loader script

    +

    36.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    35.8 Other resources

    +

    36.8 Other resources

    -

    13.4 Code generation rules

    +

    14.4 Code generation rules

    @@ -1878,7 +1878,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    13.4.1 Scope

    +

    14.4.1 Scope

    @@ -1956,7 +1956,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    13.4.2 Declaring new local variables

    +

    14.4.2 Declaring new local variables

    @@ -2123,7 +2123,7 @@ each type must have its own local variable declaration. -

    13.4.3 Special variables

    +

    14.4.3 Special variables

    @@ -2375,7 +2375,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    13.4.4 Special variable macros

    +

    14.4.4 Special variable macros

    @@ -2387,7 +2387,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    13.4.4.1 $descriptor(type)

    +

    14.4.4.1 $descriptor(type)

    @@ -2398,7 +2398,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    13.4.4.2 $typemap(method, typepattern)

    +

    14.4.4.2 $typemap(method, typepattern)

    @@ -2456,7 +2456,7 @@ The result is the following expansion -

    13.4.5 Special variables and typemap attributes

    +

    14.4.5 Special variables and typemap attributes

    @@ -2483,7 +2483,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    13.4.6 Special variables combined with special variable macros

    +

    14.4.6 Special variables combined with special variable macros

    @@ -2525,7 +2525,7 @@ which then expands to: -

    13.5 Common typemap methods

    +

    14.5 Common typemap methods

    @@ -2533,7 +2533,7 @@ The family of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    13.5.1 "in" typemap

    +

    14.5.1 "in" typemap

    @@ -2593,7 +2593,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    13.5.2 "typecheck" typemap

    +

    14.5.2 "typecheck" typemap

    @@ -2620,7 +2620,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    13.5.3 "out" typemap

    +

    14.5.3 "out" typemap

    @@ -2651,7 +2651,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    13.5.4 "arginit" typemap

    +

    14.5.4 "arginit" typemap

    @@ -2670,7 +2670,7 @@ For example: -

    13.5.5 "default" typemap

    +

    14.5.5 "default" typemap

    @@ -2703,7 +2703,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    13.5.6 "check" typemap

    +

    14.5.6 "check" typemap

    @@ -2722,7 +2722,7 @@ converted. For example: -

    13.5.7 "argout" typemap

    +

    14.5.7 "argout" typemap

    @@ -2768,7 +2768,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    13.5.8 "freearg" typemap

    +

    14.5.8 "freearg" typemap

    @@ -2801,7 +2801,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    13.5.9 "newfree" typemap

    +

    14.5.9 "newfree" typemap

    @@ -2830,7 +2830,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    13.5.10 "ret" typemap

    +

    14.5.10 "ret" typemap

    @@ -2869,7 +2869,7 @@ This approach is an alternative to using the "newfree" typemap and %newobjec is no need to list all the functions that require the memory cleanup, it is purely done on types.

    -

    13.5.11 "memberin" typemap

    +

    14.5.11 "memberin" typemap

    @@ -2891,7 +2891,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    -

    13.5.12 "varin" typemap

    +

    14.5.12 "varin" typemap

    @@ -2899,7 +2899,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    13.5.13 "varout" typemap

    +

    14.5.13 "varout" typemap

    @@ -2907,7 +2907,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    13.5.14 "throws" typemap

    +

    14.5.14 "throws" typemap

    @@ -2957,7 +2957,7 @@ Note that if your methods do not have an exception specification but they do thr Please also see the Exception handling with %exception section for another way to handle exceptions.

    -

    13.6 Some typemap examples

    +

    14.6 Some typemap examples

    @@ -2965,7 +2965,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    13.6.1 Typemaps for arrays

    +

    14.6.1 Typemaps for arrays

    @@ -3224,7 +3224,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    13.6.2 Implementing constraints with typemaps

    +

    14.6.2 Implementing constraints with typemaps

    @@ -3272,7 +3272,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    13.7 Typemaps for multiple target languages

    +

    14.7 Typemaps for multiple target languages

    @@ -3302,7 +3302,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby, in) int "$1 = NUM2INT($input);".

    -

    13.8 Optimal code generation when returning by value

    +

    14.8 Optimal code generation when returning by value

    @@ -3491,7 +3491,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    13.9 Multi-argument typemaps

    +

    14.9 Multi-argument typemaps

    @@ -3768,7 +3768,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    13.10 Typemap warnings

    +

    14.10 Typemap warnings

    @@ -3777,7 +3777,7 @@ See the information in the issuing warnings

    -

    13.11 Typemap fragments

    +

    14.11 Typemap fragments

    @@ -4113,7 +4113,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    13.11.1 Fragment type specialization

    +

    14.11.1 Fragment type specialization

    @@ -4146,7 +4146,7 @@ struct A { -

    13.11.2 Fragments and automatic typemap specialization

    +

    14.11.2 Fragments and automatic typemap specialization

    @@ -4192,7 +4192,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    13.12 The run-time type checker

    +

    14.12 The run-time type checker

    @@ -4218,7 +4218,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    13.12.1 Implementation

    +

    14.12.1 Implementation

    @@ -4412,7 +4412,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    13.12.2 Usage

    +

    14.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4508,7 +4508,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    13.13 Typemaps and overloading

    +

    14.13 Typemaps and overloading

    @@ -4847,7 +4847,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    13.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    +

    14.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    @@ -4949,7 +4949,7 @@ Otherwise both can be wrapped by removing the overloading name ambiguity by rena The 'equivalent' attribute is used in the implementation for the shared_ptr smart pointer library.

    -

    13.14 More about %apply and %clear

    +

    14.14 More about %apply and %clear

    @@ -5054,7 +5054,7 @@ will delete the typemaps for all the typemap methods; namely "in", "check" and " -

    13.15 Passing data between typemaps

    +

    14.15 Passing data between typemaps

    @@ -5091,7 +5091,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    13.16 C++ "this" pointer

    +

    14.16 C++ "this" pointer

    @@ -5151,7 +5151,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    13.17 Where to go for more information?

    +

    14.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 9f20469d2..620f2e5a0 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -7,7 +7,7 @@ -

    16 Variable Length Arguments

    +

    17 Variable Length Arguments

      @@ -43,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      16.1 Introduction

      +

      17.1 Introduction

      @@ -140,7 +140,7 @@ List make_list(const char *s, ...) {

    -

    16.2 The Problem

    +

    17.2 The Problem

    @@ -233,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    16.3 Default varargs support

    +

    17.3 Default varargs support

    @@ -302,7 +302,7 @@ Read on for further solutions.

    -

    16.4 Argument replacement using %varargs

    +

    17.4 Argument replacement using %varargs

    @@ -413,7 +413,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    16.5 Varargs and typemaps

    +

    17.5 Varargs and typemaps

    @@ -593,7 +593,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    16.6 Varargs wrapping with libffi

    +

    17.6 Varargs wrapping with libffi

    @@ -845,7 +845,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    16.7 Wrapping of va_list

    +

    17.7 Wrapping of va_list

    @@ -899,7 +899,7 @@ int my_vprintf(const char *fmt, ...) { -

    16.8 C++ Issues

    +

    17.8 C++ Issues

    @@ -968,7 +968,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    16.9 Discussion

    +

    17.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index c63d7de0c..0cf2a1066 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -7,7 +7,7 @@ -

    18 Warning Messages

    +

    19 Warning Messages

    -

    18.5 Symbolic symbols

    +

    19.5 Symbolic symbols

    @@ -311,7 +311,7 @@ or -

    18.6 Commentary

    +

    19.6 Commentary

    @@ -328,7 +328,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    18.7 Warnings as errors

    +

    19.7 Warnings as errors

    @@ -337,7 +337,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    18.8 Message output format

    +

    19.8 Message output format

    @@ -356,10 +356,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    18.9 Warning number reference

    +

    19.9 Warning number reference

    -

    18.9.1 Deprecated features (100-199)

    +

    19.9.1 Deprecated features (100-199)

      @@ -387,7 +387,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    18.9.2 Preprocessor (200-299)

    +

    19.9.2 Preprocessor (200-299)

      @@ -399,7 +399,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    18.9.3 C/C++ Parser (300-399)

    +

    19.9.3 C/C++ Parser (300-399)

      @@ -476,7 +476,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    18.9.4 Types and typemaps (400-499)

    +

    19.9.4 Types and typemaps (400-499)

      @@ -507,7 +507,7 @@ example.i(4) : Syntax error in input(1). -

      18.9.5 Code generation (500-559)

      +

      19.9.5 Code generation (500-559)

        @@ -538,7 +538,7 @@ example.i(4) : Syntax error in input(1).
      • 525. Destructor declaration is final, name cannot be a director class.
      -

      18.9.6 Doxygen comments (560-599)

      +

      19.9.6 Doxygen comments (560-599)

        @@ -549,7 +549,7 @@ example.i(4) : Syntax error in input(1).
      • 564: Error parsing Doxygen command command: error text. Command ignored."
      -

      18.9.7 Language module specific (700-899)

      +

      19.9.7 Language module specific (700-899)

        @@ -600,14 +600,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      18.9.8 User defined (900-999)

      +

      19.9.8 User defined (900-999)

      These numbers can be used by your own application.

      -

      18.10 History

      +

      19.10 History

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 2cb2b18a3..994b28851 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -7,6 +7,7 @@ SWIGPlus.html CPlusPlus11.html CPlusPlus14.html CPlusPlus17.html +CPlusPlus20.html Preprocessor.html Library.html Arguments.html From 7405bd6a88e0da081f97b29d990a5b662bc815ae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 28 Jan 2020 18:11:07 +0000 Subject: [PATCH 1813/2031] Minor tweak to director_wstring_runme.py test --- Examples/test-suite/python/director_wstring_runme.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py index 242b27582..b7929c0d2 100644 --- a/Examples/test-suite/python/director_wstring_runme.py +++ b/Examples/test-suite/python/director_wstring_runme.py @@ -9,8 +9,8 @@ class B(A): def get_first(self): return A.get_first(self) + u" world!" - def process_text(self, string): - self.smem = u"hello" + def process_text(self, s): + self.smem = s b = B(u"hello") From 58e409dd2b74f9234e6da58ac77dbd7c706af4b8 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Wed, 29 Jan 2020 10:00:22 -0700 Subject: [PATCH 1814/2031] Fix possible refleaks. --- Lib/python/pyhead.swg | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index da8207ad7..9a55d76cf 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -43,12 +43,11 @@ SWIG_Python_str_AsChar(PyObject *str) if (str) { char *cstr; Py_ssize_t len; - if (PyBytes_AsStringAndSize(str, &cstr, &len) == -1) - return NULL; - newstr = (char *) malloc(len+1); - if (!newstr) - return NULL; - memcpy(newstr, cstr, len+1); + if (PyBytes_AsStringAndSize(str, &cstr, &len) != -1) { + newstr = (char *) malloc(len+1); + if (newstr) + memcpy(newstr, cstr, len+1); + } Py_XDECREF(str); } return newstr; From 88ef6e09319a1238832e645eb5117be70536f6c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jan 2020 08:34:07 +0000 Subject: [PATCH 1815/2031] Fix display of template classnames in generated R code --- Source/Modules/r.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 2ad377af1..dc284f82b 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1126,8 +1126,8 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, } Printf(f->code, "}\n"); - - Printf(out, "# Start of accessor method for %s\n", className); + String *classname_str = SwigType_namestr(className); + Printf(out, "# Start of accessor method for %s\n", classname_str); Printf(out, "setMethod('$%s', '_p%s', ", isSet ? "<-" : "", getRClassName(className)); @@ -1143,11 +1143,12 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Printf(out, ");\n"); } + Printf(out, "# end of accessor method for %s\n", classname_str); + + Delete(classname_str); DelWrapper(attr); DelWrapper(f); - Printf(out, "# end of accessor method for %s\n", className); - return SWIG_OK; } From e14532ce52a654768cc4010e9e18e1a0a4d965db Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 25 Jan 2020 17:06:20 +0100 Subject: [PATCH 1816/2031] Fix crash in Python backend when using empty docstrings Due to confusion in build_combined_docstring(), we could call DohDelete() on the "feature:docstring" string, which resulted in a crash when trying to use it later. Fix this and simplify the code at the same time by ensuring that we always use a copy of "feature:docstring" if it's not empty or don't use it at all if it's empty -- like this we don't have to check for its length each time before using it. Closes #1648. --- Examples/test-suite/autodoc.i | 9 +++++++++ Examples/test-suite/python/autodoc_runme.py | 2 ++ Source/Modules/python.cxx | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i index 9f4365ee1..efc720155 100644 --- a/Examples/test-suite/autodoc.i +++ b/Examples/test-suite/autodoc.i @@ -183,3 +183,12 @@ const int PROCESS_DEFAULT_VALUE = 17; typedef long int some_type; int process_complex_defval(int val = PROCESS_DEFAULT_VALUE, int factor = some_type(-1)) { return val*factor; } %} + +// Test for empty docstring, which should be ignored. +%feature("docstring") "" + +%inline %{ +struct a_structure{ + char my_array[1]; +}; +%} diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index 6002d49fe..7bc918644 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -279,3 +279,5 @@ check(inspect.getdoc(process3), "process3(int _from, int _in, int var) -> int") check(inspect.getdoc(process4), "process4(int _from=0, int _in=1, int var=2) -> int") check(inspect.getdoc(process_complex_defval), "process_complex_defval(val=PROCESS_DEFAULT_VALUE, factor=some_type(-1)) -> int") + +check(inspect.getdoc(a_structure.__init__), "__init__(a_structure self) -> a_structure", None, skip) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 1dbedad26..f6b47be24 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1484,8 +1484,15 @@ public: String *build_combined_docstring(Node *n, autodoc_t ad_type, const String *indent = "", bool low_level = false) { String *docstr = Getattr(n, "feature:docstring"); - if (docstr && Len(docstr)) { - docstr = Copy(docstr); + if (docstr) { + // Simplify the code below by just ignoring empty docstrings. + if (!Len(docstr)) + docstr = NULL; + else + docstr = Copy(docstr); + } + + if (docstr) { char *t = Char(docstr); if (*t == '{') { Delitem(docstr, 0); @@ -1496,7 +1503,7 @@ public: if (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) { String *autodoc = make_autodoc(n, ad_type, low_level); if (autodoc && Len(autodoc) > 0) { - if (docstr && Len(docstr)) { + if (docstr) { Append(autodoc, "\n"); Append(autodoc, docstr); } @@ -1509,7 +1516,7 @@ public: Delete(autodoc); } - if (!docstr || !Len(docstr)) { + if (!docstr) { if (doxygen) { docstr = Getattr(n, "python:docstring"); if (!docstr && doxygenTranslator->hasDocumentation(n)) { From f0c922928765b9c1e972f07abec450b11e23dbf5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jan 2020 18:56:59 +0000 Subject: [PATCH 1817/2031] Add changes entry about R attribute fix --- CHANGES.current | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 587d91ee4..2450df0ec 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,15 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-30: richardbeare + #1511 [R] Fix bug wrapping functions. These were previously incorrectly wrapped as if + they were variables. This happened when 'get' or 'set' was in the name of the function + or method, but sometimes also in some other circumstances. If you were using R + attribute syntax to access these methods, you'll need to switch to calling them as R + methods. + + *** POTENTIAL INCOMPATIBILITY *** + 2020-01-24: etse-dignitas, wsfulton #1533 [C#, D, Java] Fix upcasting for shared_ptr's of templated types. From b0ce22625b5374d1e574297cad9104776f1915c3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jan 2020 19:04:32 +0000 Subject: [PATCH 1818/2031] Remove redundant code from r.cxx --- Source/Modules/r.cxx | 117 +------------------------------------------ 1 file changed, 2 insertions(+), 115 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index dc284f82b..84076b92f 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -89,7 +89,6 @@ static String *getRClassName(String *retType, int deRef=0, int upRef=0) { static String * getRClassNameCopyStruct(String *retType, int addRef) { String *tmp = NewString(""); -#if 1 List *l = SwigType_split(retType); int n = Len(l); if(!l || n == 0) { @@ -115,24 +114,6 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) { } } -#else - char *retName = Char(SwigType_manglestr(retType)); - if(!retName) - return(tmp); - - if(addRef) { - while(retName && strlen(retName) > 1 && - strncmp(retName, "_p", 2) == 0) { - retName += 2; - Printf(tmp, "Ref"); - } - } - - if(retName[0] == '_') - retName ++; - Insert(tmp, 0, retName); -#endif - return tmp; } @@ -273,17 +254,7 @@ protected: int generateCopyRoutines(Node *n); int DumpCode(Node *n); - int OutputMemberReferenceMethod(String *className, int isSet, - List *memberList, List *nameList, - List *typeList, File *out); -#if 0 - // not used - int OutputArrayMethod(String *className, List *el, File *out); - int OutputClassMemberTable(Hash *tb, File *out); - int OutputClassMethodsTable(File *out); - int OutputClassAccessInfo(Hash *tb, File *out); -#endif - + int OutputMemberReferenceMethod(String *className, int isSet, List *memberList, List *nameList, List *typeList, File *out); int defineArrayAccessors(SwigType *type); void addNamespaceFunction(String *name) { @@ -369,8 +340,6 @@ protected: String *R_MEMBER_GET; int processing_class_member_function; - // List *class_member_functions; - // List *class_member_set_functions; // Spread out the lists so that they are simpler to process // by storing the type of the method (i.e. set, get or nothing) // and having separate lists for name, membername and wrapper @@ -731,18 +700,6 @@ void R::init() { } - -#if 0 -int R::cDeclaration(Node *n) { - SwigType *t = Getattr(n, "type"); - SwigType *name = Getattr(n, "name"); - if (debugMode) - Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0)); - return Language::cDeclaration(n); -} -#endif - - /* ------------------------------------------------------------- * Method from Language that is called to start the entire * processing off, i.e. the generation of the code. @@ -1152,49 +1109,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, return SWIG_OK; } -#if 0 -// not used -/* ------------------------------------------------------------- - * Write the methods for [ or [<- for accessing a member field in an - * struct or union (or class). - * className - the name of the struct or union (e.g. Bar for struct Bar) - * el - a list of length 2 * # accessible member elements + 1. - * The first element is the name of the class. - * The other pairs are member name and the name of the R function to access it. - * out - the stream where we write the code. - * --------------------------------------------------------------*/ - -int R::OutputArrayMethod(String *className, List *el, File *out) { - int numMems = Len(el), j; - - if(!el || numMems == 0) - return(0); - - Printf(out, "# start of array methods for %s\n", className); - for(j = 0; j < numMems; j+=3) { - String *item = Getitem(el, j); - String *dup = Getitem(el, j + 1); - if (!Strcmp(item, "__getitem__")) { - Printf(out, - "setMethod('[', '_p%s', function(x, i, j, ..., drop =TRUE) ", - getRClassName(className)); - Printf(out, " sapply(i, function (n) %s(x, as.integer(n-1))))\n\n", dup); - } - if (!Strcmp(item, "__setitem__")) { - Printf(out, "setMethod('[<-', '_p%s', function(x, i, j, ..., value)", - getRClassName(className)); - Printf(out, " sapply(1:length(i), function(n) %s(x, as.integer(i[n]-1), value[n])))\n\n", dup); - } - - } - - Printf(out, "# end of array methods for %s\n", className); - - return SWIG_OK; -} - -#endif - /* ------------------------------------------------------------- * Called when a enumeration is to be processed. * We want to call the R function defineEnumeration(). @@ -2118,18 +2032,7 @@ int R::functionWrapper(Node *n) { Replaceall(tm,"$owner", "0"); } -#if 0 - if(addCopyParam) { - Printf(f->code, "if(LOGICAL(s_swig_copy)[0]) {\n"); - Printf(f->code, "/* Deal with returning a reference. */\nr_ans = R_NilValue;\n"); - Printf(f->code, "}\n else {\n"); - } -#endif Printf(f->code, "%s\n", tm); -#if 0 - if(addCopyParam) - Printf(f->code, "}\n"); /* end of if(s_swig_copy) ... else { ... } */ -#endif } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, @@ -2467,14 +2370,6 @@ int R::classDeclaration(Node *n) { opaqueClassDeclaration = NULL; - // OutputArrayMethod(name, class_member_functions, sfile); -#if 0 - // RJB - this bit will need to change - if (class_member_functions) - OutputMemberReferenceMethod(name, 0, class_member_functions, sfile); - if (class_member_set_functions) - OutputMemberReferenceMethod(name, 1, class_member_set_functions, sfile); -#else if (class_member_function_types) { // collect the "set" methods @@ -2507,7 +2402,6 @@ int R::classDeclaration(Node *n) { Delete(class_other_functionnames); Delete(class_other_functiontypes); } -#endif if (class_member_function_types) { Delete(class_member_function_types); @@ -2544,9 +2438,6 @@ int R::classDeclaration(Node *n) { c = nextSibling(c); continue; } -#if 0 - tp = getRType(c); -#else tp = Swig_typemap_lookup("rtype", c, "", 0); if(!tp) { c = nextSibling(c); @@ -2573,7 +2464,7 @@ int R::classDeclaration(Node *n) { // returns "" tp = processType(elType, c, NULL); // Printf(stdout, " elType %p\n", elType); // tp = getRClassNameCopyStruct(Getattr(c, "type"), 1); -#endif + String *elNameT = replaceInitialDash(elName); Printf(def, "%s%s = \"%s\"", tab8, elNameT, tp); firstItem = false; @@ -2934,10 +2825,6 @@ String * R::processType(SwigType *t, Node *n, int *nargs) { return tmp; } -#if 0 - SwigType_isfunction(t) && SwigType_ispointer(t) -#endif - return NULL; } From 3fa5c8c652ba8a8b75a3c9644b8de417740f4958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barre=CC=81?= Date: Thu, 30 Jan 2020 19:52:53 +0000 Subject: [PATCH 1819/2031] Fix R memory leak on exception There is a possible memory leak in case the SWIG_exception_fail macro is called. The problem is related to its definition that call the function Rf_warning. This function (as well as Rf_error) involves a longjmp over C++ destructors on the stack. Thus, all the objects allocated on the heap are not freed. Closes #914 --- Examples/test-suite/r/Makefile.in | 1 + Examples/test-suite/r/r_memory_leak_runme.R | 26 +++++++++++++ Examples/test-suite/r_memory_leak.i | 40 +++++++++++++++++++ Lib/r/rfragments.swg | 4 -- Lib/r/rrun.swg | 43 +++++++++++++++++++++ Source/Modules/r.cxx | 23 +++++++++-- 6 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 Examples/test-suite/r/r_memory_leak_runme.R create mode 100644 Examples/test-suite/r_memory_leak.i diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 33e9d90da..98835b958 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -18,6 +18,7 @@ C_TEST_CASES += \ CPP_TEST_CASES += \ r_double_delete \ + r_memory_leak \ r_overload_array \ r_sexp \ r_overload_comma \ diff --git a/Examples/test-suite/r/r_memory_leak_runme.R b/Examples/test-suite/r/r_memory_leak_runme.R new file mode 100644 index 000000000..ef6533aef --- /dev/null +++ b/Examples/test-suite/r/r_memory_leak_runme.R @@ -0,0 +1,26 @@ +clargs <- commandArgs(trailing=TRUE) +source(file.path(clargs[1], "unittest.R")) + +dyn.load(paste("r_memory_leak", .Platform$dynlib.ext, sep="")) +source("r_memory_leak.R") +cacheMetaData(1) + +a <- Foo(); +unittest(Foo_get_count(), 1); +b <- Foo(); +unittest(Foo_get_count(), 2); + +# Normal behaviour +invisible(trigger_internal_swig_exception("no problem", a)); +unittest(Foo_get_count(), 2); +# SWIG exception introduced +result <- tryCatch({ + trigger_internal_swig_exception("null", b); +}, warning = function(w) { + # print(" Hum... We received a warning, but this should be an error"); + unittest(1,0); +}, error = function(e) { + # print(" Gotcha!"); + unittest(1,1); +}) +unittest(Foo_get_count(), 2); diff --git a/Examples/test-suite/r_memory_leak.i b/Examples/test-suite/r_memory_leak.i new file mode 100644 index 000000000..d490de535 --- /dev/null +++ b/Examples/test-suite/r_memory_leak.i @@ -0,0 +1,40 @@ +%module r_memory_leak + +%include + +%typemap(in) Foo* foo +{ + $1 = new Foo; +} +%typemap(freearg) Foo* foo +{ + printf(" \" Object deleted\"\n"); + delete $1; +} +%typemap(out) Foo* verify_no_memory_leak +{ + if ($1 == NULL) + SWIG_exception_fail(SWIG_RuntimeError, "Let's see how the bindings manage this exception!"); +} +%typemap(scoerceout) Foo* + %{ if (!is.null($result) && !is.logical($result)) {$result <- new("$R_class", ref=$result) ;} %} + +%inline %{ + #include + + class Foo { + static unsigned count; + public: + Foo() { ++count; } + ~Foo() { --count; } + static unsigned get_count() { return count; } + }; + + unsigned Foo::count = 0; + + static Foo* trigger_internal_swig_exception(const std::string& message, Foo* foo) + { + return (message == "null") ? NULL : foo; + }; + +%} diff --git a/Lib/r/rfragments.swg b/Lib/r/rfragments.swg index b89212b05..c3b40a906 100644 --- a/Lib/r/rfragments.swg +++ b/Lib/r/rfragments.swg @@ -1,7 +1,3 @@ -#define SWIG_Error(code, msg) Rf_warning(msg); return Rf_ScalarLogical(NA_LOGICAL) - -#define SWIG_fail return Rf_ScalarLogical(NA_LOGICAL) - /* for raw pointers */ #define SWIG_ConvertPtr(oc, ptr, ty, flags) SWIG_R_ConvertPtr(oc, ptr, ty, flags) #define SWIG_ConvertFunctionPtr(oc, ptr, ty) SWIG_R_ConvertPtr(oc, ptr, ty, 0) diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index c341321a1..a84bb7713 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -1,3 +1,46 @@ +#include // va_list, va_start, va_end +#include // vsnprintf + +/* Last error */ +static int SWIG_lasterror_code = 0; +static char SWIG_lasterror_msg[1024]; +SWIGRUNTIME void SWIG_Error(int code, const char *format, ...) { + va_list arg; + SWIG_lasterror_code = code; + va_start(arg, format); + vsnprintf(SWIG_lasterror_msg, sizeof(SWIG_lasterror_msg), format, arg); + va_end(arg); +} + +SWIGRUNTIME const char* SWIG_ErrorType(int code) { + switch (code) { + case SWIG_MemoryError: + return "SWIG:MemoryError"; + case SWIG_IOError: + return "SWIG:IOError"; + case SWIG_RuntimeError: + return "SWIG:RuntimeError"; + case SWIG_IndexError: + return "SWIG:IndexError"; + case SWIG_TypeError: + return "SWIG:TypeError"; + case SWIG_DivisionByZero: + return "SWIG:DivisionByZero"; + case SWIG_OverflowError: + return "SWIG:OverflowError"; + case SWIG_SyntaxError: + return "SWIG:SyntaxError"; + case SWIG_ValueError: + return "SWIG:ValueError"; + case SWIG_SystemError: + return "SWIG:SystemError"; + case SWIG_AttributeError: + return "SWIG:AttributeError"; + } + return "SWIG:UnknownError"; +} + +#define SWIG_fail goto fail /* Remove global namespace pollution */ #if !defined(SWIG_NO_R_NO_REMAP) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 84076b92f..addcf8b9a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1985,7 +1985,9 @@ int R::functionWrapper(Node *n) { for (p = l; p;) { if ((tm = Getattr(p, "tmap:freearg"))) { Replaceall(tm, "$source", Getattr(p, "lname")); - Printv(cleanup, tm, "\n", NIL); + if (tm && (Len(tm) != 0)) { + Printv(cleanup, tm, "\n", NIL); + } p = Getattr(p, "tmap:freearg:next"); } else { p = nextSibling(p); @@ -2066,8 +2068,10 @@ int R::functionWrapper(Node *n) { } /* Output cleanup code */ - Printv(f->code, cleanup, NIL); - Delete(cleanup); + int need_cleanup = Len(cleanup) != 0; + if (need_cleanup) { + Printv(f->code, cleanup, NIL); + } /* Look to see if there is any newfree cleanup code */ if (GetFlag(n, "feature:new")) { @@ -2124,7 +2128,18 @@ int R::functionWrapper(Node *n) { if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); - Printv(f->code, "return r_ans;\n}\n", NIL); + Printv(f->code, "return r_ans;\n", NIL); + + /* Error handling code */ + Printv(f->code, "fail: SWIGUNUSED;\n", NIL); + if (need_cleanup) { + Printv(f->code, cleanup, NIL); + } + Printv(f->code, " Rf_error(\"%s %s\", SWIG_ErrorType(SWIG_lasterror_code), SWIG_lasterror_msg);\n", NIL); + Printv(f->code, " return R_NilValue;\n", NIL); + Delete(cleanup); + + Printv(f->code, "}\n", NIL); Printv(sfun->code, "\n}", NIL); /* Substitute the function name */ From 995b443948f7c80bb96c734abc46f7094c3aba87 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jan 2020 20:49:01 +0000 Subject: [PATCH 1820/2031] Changes file update --- CHANGES.current | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2450df0ec..73f226c29 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,8 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-30: Alzathar + [R] #910 #914 Fix R memory leak on exception. + 2020-01-30: richardbeare - #1511 [R] Fix bug wrapping functions. These were previously incorrectly wrapped as if + [R] #1511 Fix bug wrapping functions. These were previously incorrectly wrapped as if they were variables. This happened when 'get' or 'set' was in the name of the function or method, but sometimes also in some other circumstances. If you were using R attribute syntax to access these methods, you'll need to switch to calling them as R @@ -17,7 +20,7 @@ Version 4.0.2 (in progress) *** POTENTIAL INCOMPATIBILITY *** 2020-01-24: etse-dignitas, wsfulton - #1533 [C#, D, Java] Fix upcasting for shared_ptr's of templated types. + [C#, D, Java] #1533 Fix upcasting for shared_ptr's of templated types. 2020-01-16: mcfarljm #1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters From a0d42185437965f1ba7d499000afbfdd4d1b1868 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Jan 2020 08:58:09 +0000 Subject: [PATCH 1821/2031] Minor refactor of R error handling code --- Lib/r/rrun.swg | 66 ++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index a84bb7713..798446128 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -1,5 +1,34 @@ -#include // va_list, va_start, va_end -#include // vsnprintf +/* Remove global namespace pollution */ +#if !defined(SWIG_NO_R_NO_REMAP) +# define R_NO_REMAP +#endif +#if !defined(SWIG_NO_STRICT_R_HEADERS) +# define STRICT_R_HEADERS +#endif + +#include +#include + +#ifdef __cplusplus +#include +extern "C" { +#endif + +/* for raw pointer */ +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags) + +#include +#include +#include +#include + +#if R_VERSION >= R_Version(2,6,0) +#define VMAXTYPE void * +#else +#define VMAXTYPE char * +#endif /* Last error */ static int SWIG_lasterror_code = 0; @@ -12,7 +41,7 @@ SWIGRUNTIME void SWIG_Error(int code, const char *format, ...) { va_end(arg); } -SWIGRUNTIME const char* SWIG_ErrorType(int code) { +SWIGRUNTIME const char *SWIG_ErrorType(int code) { switch (code) { case SWIG_MemoryError: return "SWIG:MemoryError"; @@ -42,37 +71,6 @@ SWIGRUNTIME const char* SWIG_ErrorType(int code) { #define SWIG_fail goto fail -/* Remove global namespace pollution */ -#if !defined(SWIG_NO_R_NO_REMAP) -# define R_NO_REMAP -#endif -#if !defined(SWIG_NO_STRICT_R_HEADERS) -# define STRICT_R_HEADERS -#endif - -#include -#include - -#ifdef __cplusplus -#include -extern "C" { -#endif - -/* for raw pointer */ -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_R_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_R_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_R_NewPointerObj(ptr, type, flags) - -#include -#include -#include - -#if R_VERSION >= R_Version(2,6,0) -#define VMAXTYPE void * -#else -#define VMAXTYPE char * -#endif - /* This is mainly a way to avoid having lots of local variables that may conflict with those in the routine. From a5d50729c13a616105d91889b4c02e6d82b4d6c5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Jan 2020 19:02:42 +0000 Subject: [PATCH 1822/2031] Update changes file with python crash fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 73f226c29..99535ae71 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-31: vadz + [Python] #1710 Fix crash parsing empty docstrings. + 2020-01-30: Alzathar [R] #910 #914 Fix R memory leak on exception. From 8c1c01f5e6550121715fdf3e1fb99b870450efc9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Jan 2020 19:18:23 +0000 Subject: [PATCH 1823/2031] Add changes entry for Python string error checking fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 99535ae71..e2a690448 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-31: ZackerySpytz + [Python] #1700 More robust error checking for failures in calls to Python C API: + PyBytes_AsStringAndSize() and PyString_AsStringAndSize(). + 2020-01-31: vadz [Python] #1710 Fix crash parsing empty docstrings. From e321ee30f052ae6bb4d0a5254e8770d16131144e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Jan 2020 22:28:24 +0000 Subject: [PATCH 1824/2031] Changes file correction --- CHANGES | 3 --- CHANGES.current | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 4a38b1fd6..fe8696760 100644 --- a/CHANGES +++ b/CHANGES @@ -8,9 +8,6 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.1 (21 Aug 2019) =========================== -2019-09-09: vadz - [Ruby] Add std::auto_ptr<> typemaps. - 2019-08-20: TekuConcept [Javascript] #1535 Add %native support to Javascript. diff --git a/CHANGES.current b/CHANGES.current index e2a690448..75043b3ea 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-01-31: vadz + [Ruby] Add std::auto_ptr<> typemaps. + 2020-01-31: ZackerySpytz [Python] #1700 More robust error checking for failures in calls to Python C API: PyBytes_AsStringAndSize() and PyString_AsStringAndSize(). From a9731251a4234a390993208098cdcef9c358372d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 31 Jan 2020 22:45:46 +0000 Subject: [PATCH 1825/2031] Disable GC checks for Ruby auto_ptr test --- .../test-suite/ruby/li_std_auto_ptr_runme.rb | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb index a7f3a13ac..cec48a58c 100644 --- a/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb +++ b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb @@ -4,40 +4,24 @@ require 'swig_assert' require 'li_std_auto_ptr' +def gc_check(expected_count) +# GC.start(full_mark: true, immediate_sweep: true) + GC.start +# GC is not reliably run, skip check +# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count()) +end + k1 = Li_std_auto_ptr::makeKlassAutoPtr("first") k2 = Li_std_auto_ptr::makeKlassAutoPtr("second") -swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 2) +swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count()) +gc_check(2) k1 = nil -GC.start - -# GC can need a few runs to actually collect the object. -100.times do || - next if Li_std_auto_ptr::Klass::getTotal_count() == 2 - - swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 1) - break -end +gc_check(1) swig_assert_equal_simple(k2.getLabel(), "second") - -if Li_std_auto_ptr::Klass::getTotal_count() != 1 - STDERR.puts "GC failed to collect the first object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}" - - # Skip the rest of the test as it's not going to work correctly anyhow. - exit -end +gc_check(1) k2 = nil -GC.start +gc_check(0) -100.times do || - next if Li_std_auto_ptr::Klass::getTotal_count() == 1 - - swig_assert_equal_simple(Li_std_auto_ptr::Klass::getTotal_count(), 0) - break -end - -if Li_std_auto_ptr::Klass::getTotal_count() != 0 - STDERR.puts "GC failed to collect the second object, count still #{Li_std_auto_ptr::Klass::getTotal_count()}" -end From f6d97d2338c79490513637a46e2e2d9ec80b8707 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 31 Jan 2020 23:48:32 -0700 Subject: [PATCH 1826/2031] Use PyUnicode_AsUTF8() for Python >= 3.3 --- Lib/python/pyhead.swg | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 9a55d76cf..b3bd39dfc 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -37,7 +37,9 @@ SWIGINTERN char* SWIG_Python_str_AsChar(PyObject *str) { -#if PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03030000 + return (char *)PyUnicode_AsUTF8(str); +#elif PY_VERSION_HEX >= 0x03000000 char *newstr = 0; str = PyUnicode_AsUTF8String(str); if (str) { @@ -56,10 +58,10 @@ SWIG_Python_str_AsChar(PyObject *str) #endif } -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#if PY_VERSION_HEX >= 0x03030000 || PY_VERSION_HEX < 0x03000000 +# define SWIG_Python_str_DelForPy3(x) #else -# define SWIG_Python_str_DelForPy3(x) +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) #endif From 7d2dbe3670f2fd960d290b1304eb374f20fbb4e8 Mon Sep 17 00:00:00 2001 From: Viktor Gal Date: Sat, 1 Feb 2020 11:25:30 +0100 Subject: [PATCH 1827/2031] fix #1199 --- Lib/ruby/rubyrun.swg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 4b2ffe4b4..3b6fd32b0 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -235,6 +235,8 @@ SWIGRUNTIMEINLINE char * SWIG_Ruby_MangleStr(VALUE obj) { VALUE stype = rb_iv_get(obj, "@__swigtype__"); + if (NIL_P(stype)) + return NULL; return StringValuePtr(stype); } From c74507f024a3ac8cc8ae15a78ef741c34d29ed60 Mon Sep 17 00:00:00 2001 From: Richard Beare Date: Mon, 3 Feb 2020 14:37:00 +1100 Subject: [PATCH 1828/2031] documentation about R accessors, with examples --- Doc/Manual/R.html | 135 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 125 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 6547ab128..af9b48c89 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -17,6 +17,9 @@

    • General policy
    • Language conventions
    • C++ classes +
    • Enumerations
    @@ -33,7 +36,11 @@ href="http://www.r-project.org/">www.r-project.org.

    The R bindings are under active development. They have been used to 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++. +with gcc. They are also used to create the SimpleITK R package, which +runs on various linuxes and mac. Swig is used to create all wrapper +interfaces +to SimpleITK. The R +bindings also work on Microsoft Windows using Visual C++.

    34.1 Bugs

    @@ -44,7 +51,9 @@ Currently the following features are not implemented or broken:

      -
    • Garbage collection of created objects +
    • Garbage collection of some created objects. Finalizers are + available for wrapped C++ classes and are called by the + garbage collection system.
    • C Array wrappings
    @@ -158,7 +167,10 @@ This will generate a compiled R file called BigFile.RData that will save a large amount of loading time.

    - +

    +There is no need to precompile large R files if the SWIG-generated code is being included +in an R package. The package infrastructure provides this service during package installation. +

    34.4 General policy

    @@ -173,7 +185,7 @@ to provide R syntax.

    -getitem and setitem use C++ conventions (i.e. zero based indices). [<- +getitem and setitem use C++ conventions (i.e. zero based indices). [<- and [ are overloaded to allow for R syntax (one based indices and slices)

    @@ -182,14 +194,117 @@ slices)

    -C++ objects are implemented as external pointer objects with the class -being the mangled name of the class. The C++ classes are encapsulated -as an SEXP with an external pointer type. The class is the mangled -name of the class. The nice thing about R is that is allows you to -keep track of the pointer object which removes the necessity for a lot -of the proxy class baggage you see in other languages. +Wrapping of C++ classes for R works quite well. R has a special +type, known as an external reference, that can be used as a pointer +to arbitary things, including C++ classes. The proxy layers generated +for other classes are not required.

    +

    + SWIG currently creates a custom hierarchy of R classes derived from the + external reference type and implements +type checking and function overloading in the R code it generates. In +the future we hope to utilise the built in R6 class structures. +

    + +

    +The R interface has the following capabilities: +

      +
    • Destructor methods are registered and called automatically by the R garbage collector. +
    • A range of std::vector types are converted automatically to R equivalents. +
    • The $ operator is used for method access. +
    • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators +
    +

    + +

    34.6.1 Examples

    + + +Consider the following simple example: + +
    +
    +class Vehicle {
    +private:
    +  int m_axles;
    +public:
    +  int Axles() {
    +    return(m_axles);
    +  }
    +  bool Available;
    +
    +  Vehicle() {
    +    Available=false;
    +    m_axles=2;
    +  }
    +
    +  Vehicle(int ax) {
    +    Available=false;
    +    m_axles=ax;
    +  }
    +};
    +
    +
    + +The following options are available in R: + +
    +
    +v1 <- Vehicle()
    +v2 <- Vehicle(4)
    +# access members
    +v1$Axles()
    +[1] 2
    +v2$Axles
    +[1] 4
    +v1$Available
    +[1] FALSE
    +# Set availabilty
    +v1$Available <- TRUE
    +v1$Available
    +[1] TRUE
    +
    +
    + +

    +A useful trick to determine the methods that are available is to +query the R method definition as follows: +

    + +

    +
    +# display the methods for the class
    +getMethod("$", class(v1))
    +    
    +Method Definition:
    +
    +function (x, name) 
    +{
    +    accessorFuns = list(Axles = Vehicle_Axles, Available = Vehicle_Available_get)
    +    vaccessors = c("Available")
    +    idx = pmatch(name, names(accessorFuns))
    +    if (is.na(idx)) 
    +        return(callNextMethod(x, name))
    +    f = accessorFuns[[idx]]
    +    if (is.na(match(name, vaccessors))) 
    +        function(...) {
    +            f(x, ...)
    +        }
    +    else f(x)
    +}
    +
    +
    +Signatures:
    +        x           
    +target  "_p_Vehicle"
    +defined "_p_Vehicle"
    +
    +
    +
    +

    +The names in the accessorFuns list correspond to class methods while names in the vaccessors section +correspond to variables that may be modified. +

    34.7 Enumerations

    From a01e8474f605c5127a512c4ede2b094206db0570 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Feb 2020 06:45:11 +0000 Subject: [PATCH 1829/2031] Fixing setting this in Python when using __slots__ Don't attempt to use the class's __dict__ for setting 'this' when a user has extended a class with: __slots__ = ['this']. Was segfaulting. Now we fall back to a simple PyObject_SetAttr if the usual approach to setting 'this' in __dict__ does not work. Closes #1673 Closes #1674 --- CHANGES.current | 3 +++ .../test-suite/python/python_append_runme.py | 13 ++++++++++ Examples/test-suite/python_append.i | 20 ++++++++++++++- Lib/python/pyrun.swg | 25 ++++++++----------- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 75043b3ea..aba67f451 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-02-06: wsfulton + [Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__. + 2020-01-31: vadz [Ruby] Add std::auto_ptr<> typemaps. diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py index eddda53ff..e5f6b07cf 100644 --- a/Examples/test-suite/python/python_append_runme.py +++ b/Examples/test-suite/python/python_append_runme.py @@ -21,3 +21,16 @@ if grabstaticpath() != None: Test.static_func() if grabstaticpath() != os.path.basename(mypath): raise RuntimeError("grabstaticpath failed") + +# slots test +fs = ForSlots() +if fs.ValidVariable != 99: + raise RuntimeError("ValidVariable failed") +fs.ValidVariable = 11 +if fs.ValidVariable != 11: + raise RuntimeError("ValidVariable failed") +try: + fs.Invalid = 22 + raise RuntimeError("It should not be possible to set a random variable name") +except AttributeError: + pass diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i index 049494319..883097ec6 100644 --- a/Examples/test-suite/python_append.i +++ b/Examples/test-suite/python_append.i @@ -42,13 +42,31 @@ import os.path %} %inline %{ - class Test { public: static void static_func() {}; void funk() {}; }; +%} +// Github issue #1674 +%extend ForSlots { + %pythoncode %{ + __slots__ = ["this"] + %} +} +// While __slots__ does not contain 'ValidVariable' in the list, it is still possible +// to set 'ValidVariable'. A little odd, but the whole attribute setting is bypassed +// for setting C/C++ member variables. +// Not sure how to test the equivalent for -builtin. +%inline %{ +struct ForSlots { + int ValidVariable; + ForSlots() : ValidVariable(99) {} +}; +%} + +%inline %{ #ifdef SWIGPYTHON_BUILTIN bool is_python_builtin() { return true; } #else diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index d6eeda984..66fa67055 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1248,22 +1248,19 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) SWIGRUNTIME void SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { - PyObject *dict; #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } #endif - dict = PyObject_GetAttrString(inst, "__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); + PyObject_SetAttr(inst, SWIG_This(), swig_this); } From 94b4c7dc214d84dfbb695cb59f225e7120268d61 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Feb 2020 07:27:08 +0000 Subject: [PATCH 1830/2031] Better error checking when setting 'this' in Python If python_append.i is modified to use: __slots__ = [] instead of __slots__ = ["this"] then this additional error checking prevents a crash and shows a stack trace and error: AttributeError: 'ForSlots' object has no attribute 'this' Related to issue #1674 --- Lib/python/pyrun.swg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 66fa67055..63ff82ff8 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1245,7 +1245,7 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) return inst; } -SWIGRUNTIME void +SWIGRUNTIME int SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) { #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) @@ -1256,11 +1256,10 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) dict = PyDict_New(); *dictptr = dict; } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; + return PyDict_SetItem(dict, SWIG_This(), swig_this); } #endif - PyObject_SetAttr(inst, SWIG_This(), swig_this); + return PyObject_SetAttr(inst, SWIG_This(), swig_this); } @@ -1274,7 +1273,8 @@ SWIG_Python_InitShadowInstance(PyObject *args) { if (sthis) { SwigPyObject_append((PyObject*) sthis, obj[1]); } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); + if (SWIG_Python_SetSwigThis(obj[0], obj[1]) != 0) + return NULL; } return SWIG_Py_Void(); } From 012d0f7aa58b61ac8dce501076d330c2ca143f52 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 6 Feb 2020 19:09:00 +0000 Subject: [PATCH 1831/2031] Update changes file --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index aba67f451..c12c5eb28 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -11,7 +11,7 @@ Version 4.0.2 (in progress) [Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__. 2020-01-31: vadz - [Ruby] Add std::auto_ptr<> typemaps. + [Ruby] #1651 Add std::auto_ptr<> typemaps. 2020-01-31: ZackerySpytz [Python] #1700 More robust error checking for failures in calls to Python C API: From 63b3fe8d3b3c6a3c2ab634420f11d2697b0f97c3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Feb 2020 07:18:04 +0000 Subject: [PATCH 1832/2031] R documentation minor tweaks --- Doc/Manual/R.html | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index af9b48c89..c02b41264 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -37,7 +37,7 @@ href="http://www.r-project.org/">www.r-project.org. The R bindings are under active development. They have been used to compile and run an R interface to QuantLib running on Mandriva Linux with gcc. They are also used to create the SimpleITK R package, which -runs on various linuxes and mac. Swig is used to create all wrapper +runs on Linux and MacOS. SWIG is used to create all wrapper interfaces to SimpleITK. The R bindings also work on Microsoft Windows using Visual C++. @@ -211,26 +211,30 @@ the future we hope to utilise the built in R6 class structures. The R interface has the following capabilities:
    • Destructor methods are registered and called automatically by the R garbage collector. -
    • A range of std::vector types are converted automatically to R equivalents. +
    • A range of std::vector types are converted automatically to R equivalents via the std_vector.i library.
    • The $ operator is used for method access. -
    • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators +
    • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators.

    34.6.1 Examples

    +

    Consider the following simple example: +

     class Vehicle {
     private:
       int m_axles;
    +
     public:
       int Axles() {
         return(m_axles);
       }
    +
       bool Available;
     
       Vehicle() {
    @@ -246,12 +250,14 @@ public:
     
    +

    The following options are available in R: +

    -
    -v1 <- Vehicle()
    -v2 <- Vehicle(4)
    +
    +v1 <- Vehicle()
    +v2 <- Vehicle(4)
     # access members
     v1$Axles()
     [1] 2
    @@ -260,7 +266,7 @@ v2$Axles
     v1$Available
     [1] FALSE
     # Set availabilty
    -v1$Available <- TRUE
    +v1$Available <- TRUE
     v1$Available
     [1] TRUE
     
    @@ -302,7 +308,7 @@ defined "_p_Vehicle"

    -The names in the accessorFuns list correspond to class methods while names in the vaccessors section +The names in the accessorFuns list correspond to class methods while names in the vaccessors section correspond to variables that may be modified.

    34.7 Enumerations

    From e3524be1646a43af3ae09d1a2f9ddec4b3a550a3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Feb 2020 07:27:49 +0000 Subject: [PATCH 1833/2031] html fixes in documentation --- Doc/Manual/CSharp.html | 3 --- Doc/Manual/Contents.html | 3 +++ Doc/Manual/Doxygen.html | 3 ++- Doc/Manual/R.html | 5 ++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index ca568876a..ef4c0104d 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -75,9 +75,6 @@ There are some minor exceptions, where the minimum required is .NET 4.0. This is when using the std::complex and std::list STL containers.

    -

    -

    -

    To get the most out of this chapter an understanding of interop is required. The Microsoft Developer Network (MSDN) has a good reference guide in a section titled "Interop Marshaling". diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 0d0c977cc..79ffdd50e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1499,6 +1499,9 @@

  • General policy
  • Language conventions
  • C++ classes +
  • Enumerations diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 40faa2014..53238c24d 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -1204,6 +1204,7 @@ Here is the list of all Doxygen tags and the description of how they are transla \b wrapped with '**' + \c wrapped with '``' @@ -1299,7 +1300,7 @@ Here is the list of all Doxygen tags and the description of how they are transla \overload prints 'This is an overloaded ...' according to Doxygen docs - + \p wrapped with '``' diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index c02b41264..e44fe432c 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -209,13 +209,13 @@ the future we hope to utilise the built in R6 class structures.

    The R interface has the following capabilities: +

    • Destructor methods are registered and called automatically by the R garbage collector.
    • A range of std::vector types are converted automatically to R equivalents via the std_vector.i library.
    • The $ operator is used for method access.
    • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators.
    -

    34.6.1 Examples

    @@ -275,7 +275,7 @@ v1$Available

    A useful trick to determine the methods that are available is to query the R method definition as follows: -

    +

    @@ -298,7 +298,6 @@ function (x, name)
             }
         else f(x)
     }
    -
     
     Signatures:
             x           
    
    From 059bb0c0a09f771dc88757446add9928797b22ba Mon Sep 17 00:00:00 2001
    From: Thomas REITMAYR 
    Date: Thu, 13 Feb 2020 16:25:15 +0100
    Subject: [PATCH 1834/2031] Recognize C++ conversion operators with trailing '=
     0' as abstract
    
    This fix is done for all supported variants of user-defined conversion
    operators and fixes swig#1723.
    ---
     Source/CParse/parser.y | 17 ++++++++++++++++-
     1 file changed, 16 insertions(+), 1 deletion(-)
    
    diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
    index 470b7d065..8029dee3d 100644
    --- a/Source/CParse/parser.y
    +++ b/Source/CParse/parser.y
    @@ -4800,6 +4800,9 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
     		 if ($8.qualifier) {
     		   SwigType_push($4,$8.qualifier);
     		 }
    +		 if ($8.val) {
    +		   Setattr($$,"value",$8.val);
    +		 }
     		 Setattr($$,"refqualifier",$8.refqualifier);
     		 Setattr($$,"decl",$4);
     		 Setattr($$,"parms",$6);
    @@ -4818,6 +4821,9 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
     		 if ($8.qualifier) {
     		   SwigType_push(decl,$8.qualifier);
     		 }
    +		 if ($8.val) {
    +		   Setattr($$,"value",$8.val);
    +		 }
     		 Setattr($$,"refqualifier",$8.refqualifier);
     		 Setattr($$,"decl",decl);
     		 Setattr($$,"parms",$6);
    @@ -4836,6 +4842,9 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
     		 if ($8.qualifier) {
     		   SwigType_push(decl,$8.qualifier);
     		 }
    +		 if ($8.val) {
    +		   Setattr($$,"value",$8.val);
    +		 }
     		 Setattr($$,"refqualifier",$8.refqualifier);
     		 Setattr($$,"decl",decl);
     		 Setattr($$,"parms",$6);
    @@ -4856,6 +4865,9 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
     		 if ($9.qualifier) {
     		   SwigType_push(decl,$9.qualifier);
     		 }
    +		 if ($9.val) {
    +		   Setattr($$,"value",$9.val);
    +		 }
     		 Setattr($$,"refqualifier",$9.refqualifier);
     		 Setattr($$,"decl",decl);
     		 Setattr($$,"parms",$7);
    @@ -4873,7 +4885,10 @@ cpp_conversion_operator : storage_class CONVERSIONOPERATOR type pointer LPAREN p
     		if ($7.qualifier) {
     		  SwigType_push(t,$7.qualifier);
     		}
    -		 Setattr($$,"refqualifier",$7.refqualifier);
    +		if ($7.val) {
    +		  Setattr($$,"value",$7.val);
    +		}
    +		Setattr($$,"refqualifier",$7.refqualifier);
     		Setattr($$,"decl",t);
     		Setattr($$,"parms",$5);
     		Setattr($$,"conversion_operator","1");
    
    From eb2be58a1252689fc5f1937834f2f7123d46d13f Mon Sep 17 00:00:00 2001
    From: Thomas REITMAYR 
    Date: Thu, 13 Feb 2020 16:26:30 +0100
    Subject: [PATCH 1835/2031] Add test cases for abstract user-defined conversion
     operators
    
    ---
     Examples/test-suite/common.mk                 |  1 +
     .../director_conversion_operators.i           | 35 +++++++++++++++++++
     2 files changed, 36 insertions(+)
     create mode 100644 Examples/test-suite/director_conversion_operators.i
    
    diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
    index 115747e97..e77f09c86 100644
    --- a/Examples/test-suite/common.mk
    +++ b/Examples/test-suite/common.mk
    @@ -184,6 +184,7 @@ CPP_TEST_CASES += \
     	director_classes \
     	director_classic \
     	director_constructor \
    +	director_conversion_operators \
     	director_default \
     	director_detect \
     	director_enum \
    diff --git a/Examples/test-suite/director_conversion_operators.i b/Examples/test-suite/director_conversion_operators.i
    new file mode 100644
    index 000000000..afcd49d3f
    --- /dev/null
    +++ b/Examples/test-suite/director_conversion_operators.i
    @@ -0,0 +1,35 @@
    +%module(directors="1") director_conversion_operators
    +
    +%feature("director");
    +
    +%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Bar;
    +
    +%rename(toFoo) Bar::operator Foo();
    +%rename(toFooPtr) Bar::operator Foo *();
    +%rename(toFooRef) Bar::operator Foo &();
    +%rename(toFooPtrRef) Bar::operator Foo *&();
    +
    +%rename(toOtherFoo) Bar::operator OtherFoo();
    +%rename(toOtherFooPtr) Bar::operator OtherFoo *();
    +%rename(toOtherFooRef) Bar::operator OtherFoo &();
    +%rename(toOtherFooPtrRef) Bar::operator OtherFoo *&();
    +
    +%inline %{
    +   struct Foo {
    +   };
    +   struct OtherFoo {
    +   };
    +   struct Bar {
    +      Foo myFoo;
    +      Foo *myFooPtr;
    +      virtual ~Bar() { }
    +      virtual operator Foo () { return Foo(); }
    +      virtual operator Foo *() { return &myFoo; }
    +      virtual operator Foo &() { return myFoo; }
    +      virtual operator Foo *&() { return myFooPtr; }
    +      virtual operator OtherFoo () = 0;
    +      virtual operator OtherFoo *() = 0;
    +      virtual operator OtherFoo &() = 0;
    +      virtual operator OtherFoo *&() = 0;
    +   };
    +%}
    
    From fc2f0204ba735ea9374933ff947d48fbec0b2deb Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 13 Feb 2020 19:09:27 +0000
    Subject: [PATCH 1836/2031] Port Ruby test of vector> to Python
    
    This test code tests the upcast code:
      swig_assert_equal_simple(-1, base_num2([Derived(7)]))
    Although there is no explicit memory leak fix test, it does at least run the code.
    
    Handling of None needs fixing in Python (it is working in Ruby)
    Note that the Ruby implementation has a partial template specialization
    for shared_ptr, whereas the Python implementation is in the generic
    code!
    
    Issue #1512
    ---
     .../python/cpp11_shared_ptr_upcast_runme.py   | 63 +++++++++++++++++++
     1 file changed, 63 insertions(+)
     create mode 100644 Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py
    
    diff --git a/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py b/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py
    new file mode 100644
    index 000000000..08546a45e
    --- /dev/null
    +++ b/Examples/test-suite/python/cpp11_shared_ptr_upcast_runme.py
    @@ -0,0 +1,63 @@
    +from cpp11_shared_ptr_upcast import *
    +
    +# This is a port from the Ruby equivalent test and some tests ported from
    +# Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb are not working and commented out with:
    +# not working:
    +
    +def swig_assert_equal_simple(expected, got):
    +    if expected != got:
    +        raise RuntimeError("Expected: {}. Got: {}")
    +
    +# non-overloaded
    +swig_assert_equal_simple(7, derived_num1(Derived(7)))
    +swig_assert_equal_simple(7, derived_num2([Derived(7)]))
    +swig_assert_equal_simple(7, derived_num3({0: Derived(7)}))
    +
    +swig_assert_equal_simple(-1, base_num1(Derived(7)))
    +swig_assert_equal_simple(-1, base_num2([Derived(7)]))
    +swig_assert_equal_simple(-1, base_num3({0: Derived(7)}))
    +
    +swig_assert_equal_simple(999, derived_num1(None))
    +# not working: swig_assert_equal_simple(999, derived_num2([None]))
    +# not working: swig_assert_equal_simple(999, derived_num3({0: None}))
    +
    +swig_assert_equal_simple(999, base_num1(None))
    +# not working: swig_assert_equal_simple(999, base_num2([None]))
    +# not working: swig_assert_equal_simple(999, base_num3({0: None}))
    +
    +# overloaded
    +swig_assert_equal_simple(7, derived_num(Derived(7)))
    +swig_assert_equal_simple(7, derived_num([Derived(7)]))
    +swig_assert_equal_simple(7, derived_num({0: Derived(7)}))
    +
    +swig_assert_equal_simple(-1, base_num(Derived(7)))
    +swig_assert_equal_simple(-1, base_num([Derived(7)]))
    +swig_assert_equal_simple(-1, base_num({0: Derived(7)}))
    +
    +# ptr to shared_ptr
    +swig_assert_equal_simple(7, derived2_num1(Derived2(7)))
    +swig_assert_equal_simple(7, derived2_num2([Derived2(7)]))
    +swig_assert_equal_simple(7, derived2_num3({0: Derived2(7)}))
    +
    +swig_assert_equal_simple(-1, base2_num1(Derived2(7)))
    +
    +# not working: try:
    +# not working:     # Upcast for pointers to shared_ptr in this generic framework has not been implemented
    +# not working:     swig_assert_equal_simple(-1, base2_num2([Derived2(7)]))
    +# not working:     raise RuntimeError, "Failed to catch TypeError"
    +# not working: except TypeError:
    +# not working:     pass
    +# not working: try:
    +# not working:     # Upcast for pointers to shared_ptr in this generic framework has not been implemented
    +# not working:     swig_assert_equal_simple(-1, base2_num3({0: Derived2(7)}))
    +# not working:     raise RuntimeError, "Failed to catch TypeError"
    +# not working: except TypeError:
    +# not working:     pass
    +
    +swig_assert_equal_simple(888, derived2_num1(None))
    +swig_assert_equal_simple(999, derived2_num2([None])) # although 888 would be more consistent
    +swig_assert_equal_simple(999, derived2_num3({0: None})) # although 888 would be more consistent
    +
    +swig_assert_equal_simple(888, base2_num1(None))
    +swig_assert_equal_simple(999, base2_num2([None])) # although 888 would be more consistent
    +swig_assert_equal_simple(999, base2_num3({0: None})) # although 888 would be more consistent
    
    From e631b226ca771a7f3d08d322b9b063c9ea3e66a2 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 13 Feb 2020 19:23:37 +0000
    Subject: [PATCH 1837/2031] Add changes entry for vector> memory
     leak fix
    
    ---
     CHANGES.current | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index c12c5eb28..27945c0c5 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.2 (in progress)
     ===========================
     
    +2020-02-13: ddurham2
    +            [Python] #1512 Fix memleak when using STL containers of shared_ptr objects.
    +
     2020-02-06: wsfulton
                 [Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__.
     
    
    From 67a38589a8164237df82a65dc6f592b423012f87 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 13 Feb 2020 19:28:03 +0000
    Subject: [PATCH 1838/2031] Minor code refactor in Python traits_asptr::asptr
    
    ---
     Lib/python/pystdcommon.swg | 11 +++++------
     1 file changed, 5 insertions(+), 6 deletions(-)
    
    diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
    index 57b26d7e8..afa71350a 100644
    --- a/Lib/python/pystdcommon.swg
    +++ b/Lib/python/pystdcommon.swg
    @@ -45,23 +45,22 @@ namespace swig {
       template 
       struct traits_asptr {   
         static int asptr(PyObject *obj, Type **val) {
    +      int res = SWIG_ERROR;
    +      swig_type_info *descriptor = type_info();
           if (val) {
             Type *p = 0;
    -        swig_type_info *descriptor = type_info();
             int newmem = 0;
    -        int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
    +        res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
             if (SWIG_IsOK(res)) {
               if (newmem & SWIG_CAST_NEW_MEMORY) {
                 res |= SWIG_NEWOBJMASK;
               }
               *val = p;
             }
    -        return res;
           } else {
    -        swig_type_info *descriptor = type_info();
    -        int res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
    -        return res;
    +        res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
           }
    +      return res;
         }
       }; 
     
    
    From 6cec69ef7ba448f0be1ce3a51118bbbfc6f49aef Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 13 Feb 2020 19:46:05 +0000
    Subject: [PATCH 1839/2031] Remove an unnecessary shared_ptr reference count
     increment in Ruby wrappers
    
    When wrapping STL containers, remove a shared_ptr reference count
    increment when an upcast is needed when checking type conversion
    in traits_check::check.
    ---
     Lib/ruby/std_shared_ptr.i | 37 ++++++++++++++++++++-----------------
     1 file changed, 20 insertions(+), 17 deletions(-)
    
    diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i
    index dee35ec03..086e30814 100644
    --- a/Lib/ruby/std_shared_ptr.i
    +++ b/Lib/ruby/std_shared_ptr.i
    @@ -13,24 +13,27 @@ namespace swig {
       template 
       struct traits_asptr > {
         static int asptr(VALUE obj, std::shared_ptr **val) {
    -      std::shared_ptr *p = 0;
    +      int res = SWIG_ERROR;
           swig_type_info *descriptor = type_info >();
    -      swig_ruby_owntype newmem = {0, 0};
    -      int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
    -      if (SWIG_IsOK(res)) {
    -	if (val) {
    -	  if (*val) {
    -	    **val = p ? *p : std::shared_ptr();
    -	  } else {
    -	    *val = p;
    -	    if (newmem.own & SWIG_CAST_NEW_MEMORY) {
    -	      // Upcast for pointers to shared_ptr in this generic framework has not been implemented
    -	      res = SWIG_ERROR;
    -	    }
    -	  }
    -	}
    -	if (newmem.own & SWIG_CAST_NEW_MEMORY)
    -	  delete p;
    +      if (val) {
    +        std::shared_ptr *p = 0;
    +        swig_ruby_owntype newmem = {0, 0};
    +        res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
    +        if (SWIG_IsOK(res)) {
    +          if (*val) {
    +            **val = p ? *p : std::shared_ptr();
    +          } else {
    +            *val = p;
    +            if (newmem.own & SWIG_CAST_NEW_MEMORY) {
    +              // Upcast for pointers to shared_ptr in this generic framework has not been implemented
    +              res = SWIG_ERROR;
    +            }
    +          }
    +          if (newmem.own & SWIG_CAST_NEW_MEMORY)
    +            delete p;
    +        }
    +      } else {
    +        res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
           }
           return res;
         }
    
    From b465531141a95ef29062e219b8683726beacf9a1 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Fri, 14 Feb 2020 07:39:02 +0000
    Subject: [PATCH 1840/2031] Add conversion operator fix to changes file
    
    ---
     CHANGES.current | 3 +++
     1 file changed, 3 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 27945c0c5..27f170eab 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.2 (in progress)
     ===========================
     
    +2020-02-14: treitmayr
    +            #1724 Fix wrapping of abstract user-defined conversion operators.
    +
     2020-02-13: ddurham2
                 [Python] #1512 Fix memleak when using STL containers of shared_ptr objects.
     
    
    From 70f6ee965646b5d9306c47fb61e0cbedcc69934d Mon Sep 17 00:00:00 2001
    From: Daniel Mach 
    Date: Fri, 14 Feb 2020 12:58:49 +0100
    Subject: [PATCH 1841/2031] Catch exceptions by reference rather than by value.
    
    Fixes -Wcatch-value gcc warnings.
    ---
     Lib/ruby/rubycontainer.swg | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
    index 9fa205bf5..5f00ef5ea 100644
    --- a/Lib/ruby/rubycontainer.swg
    +++ b/Lib/ruby/rubycontainer.swg
    @@ -628,7 +628,7 @@ namespace swig
           try {
     	r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
           }
    -      catch( std::out_of_range ) {
    +      catch( std::out_of_range& ) {
           }
           return r;
         }
    @@ -687,7 +687,7 @@ namespace swig
     	r = swig::from< Sequence::value_type >( *(at) );
     	$self->erase(at); 
           }
    -      catch (std::out_of_range)
    +      catch (std::out_of_range&)
     	{
     	}
           return r;
    @@ -757,7 +757,7 @@ namespace swig
           try {
     	r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
           }
    -      catch( std::out_of_range ) {
    +      catch( std::out_of_range& ) {
           }
           return r;
         }
    @@ -780,7 +780,7 @@ namespace swig
           try {
     	r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
           }
    -      catch( std::out_of_range ) {
    +      catch( std::out_of_range& ) {
           }
           return r;
         }
    @@ -790,7 +790,7 @@ namespace swig
           try {
     	r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
           }
    -      catch( std::out_of_range ) {
    +      catch( std::out_of_range& ) {
           }
           return r;
         }
    
    From 45fdcc2feccd45a2ad1c5a60e7edf48ad5e024a1 Mon Sep 17 00:00:00 2001
    From: Vadim Zeitlin 
    Date: Sun, 16 Feb 2020 17:03:14 +0100
    Subject: [PATCH 1842/2031] Fix reading options files on platforms with
     unsigned char
    
    This fixes EOF detection on platforms where char is unsigned, as
    comparing it with EOF could never return true there.
    
    Thanks gcc for the warning "comparison is always true due to limited
    range of data type [-Wtype-limits]".
    ---
     Source/Modules/swigmain.cxx | 5 +++--
     1 file changed, 3 insertions(+), 2 deletions(-)
    
    diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
    index 8d52af194..84ac74294 100644
    --- a/Source/Modules/swigmain.cxx
    +++ b/Source/Modules/swigmain.cxx
    @@ -163,7 +163,7 @@ static void merge_options_files(int *argc, char ***argv) {
       i = 1;
       while (i < new_argc) {
         if (new_argv[i] && new_argv[i][0] == '@' && (f = fopen(&new_argv[i][1], "r"))) {
    -      char c;
    +      int ci;
           char *b;
           char *be = &buffer[BUFFER_SIZE];
           int quote = 0;
    @@ -174,7 +174,8 @@ static void merge_options_files(int *argc, char ***argv) {
           insert = i;
           b = buffer;
     
    -      while ((c = fgetc(f)) != EOF) {
    +      while ((ci = fgetc(f)) != EOF) {
    +        const char c = static_cast(ci);
             if (escape) {
               if (b != be) {
                 *b = c;
    
    From 33c59614fc55d6ef8404b609836dee75db69bd38 Mon Sep 17 00:00:00 2001
    From: Ryan Nevell 
    Date: Mon, 17 Feb 2020 08:45:42 -0800
    Subject: [PATCH 1843/2031] Fix unwrapping of LUA lightuserdata type. Add test
     case.
    
    ---
     Examples/test-suite/lua/Makefile.in              |  1 +
     .../test-suite/lua/lua_lightuserdata_runme.lua   |  7 +++++++
     Examples/test-suite/lua_lightuserdata.i          | 16 ++++++++++++++++
     Lib/lua/luarun.swg                               |  5 +++++
     4 files changed, 29 insertions(+)
     create mode 100644 Examples/test-suite/lua/lua_lightuserdata_runme.lua
     create mode 100644 Examples/test-suite/lua_lightuserdata.i
    
    diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
    index 63b8692b1..92559bb8f 100644
    --- a/Examples/test-suite/lua/Makefile.in
    +++ b/Examples/test-suite/lua/Makefile.in
    @@ -15,6 +15,7 @@ top_builddir = @top_builddir@
     CPP_TEST_CASES += \
     	lua_no_module_global \
     	lua_inherit_getitem  \
    +	lua_lightuserdata  \
     
     
     C_TEST_CASES += \
    diff --git a/Examples/test-suite/lua/lua_lightuserdata_runme.lua b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
    new file mode 100644
    index 000000000..d805c2a74
    --- /dev/null
    +++ b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
    @@ -0,0 +1,7 @@
    +require("import") -- the import fn
    +require("lua_lightuserdata") -- import lib
    +
    +local t = lua_lightuserdata
    +local d = t.get_lightuserdata()
    +local r = t.check_lighuserdata(d)
    +assert(r)
    diff --git a/Examples/test-suite/lua_lightuserdata.i b/Examples/test-suite/lua_lightuserdata.i
    new file mode 100644
    index 000000000..08e15c93c
    --- /dev/null
    +++ b/Examples/test-suite/lua_lightuserdata.i
    @@ -0,0 +1,16 @@
    +%module lua_lightuserdata
    +
    +%native(get_lightuserdata) int get_lightuserdata(lua_State* L);
    +%{
    +int get_lightuserdata(lua_State* L)
    +{
    +  lua_pushlightuserdata(L, reinterpret_cast(0x123456));
    +  return 1;
    +}
    +%}
    +
    +%inline %{
    +bool check_lighuserdata(const void* d) {
    +  return reinterpret_cast(0x123456) == d;
    +}
    +%}
    diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
    index bd764d668..b8ddf000a 100644
    --- a/Lib/lua/luarun.swg
    +++ b/Lib/lua/luarun.swg
    @@ -1765,6 +1765,11 @@ SWIGRUNTIME int  SWIG_Lua_ConvertPtr(lua_State *L,int index,void **ptr,swig_type
         *ptr=0;
         return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
       }
    +  if (lua_islightuserdata(L,index))
    +  {
    +    *ptr=lua_touserdata(L,index);
    +    return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
    +  }
       usr=(swig_lua_userdata*)lua_touserdata(L,index);  /* get data */
       if (usr)
       {
    
    From 18608816db57a675c1041758aebaaefb88fcf2f5 Mon Sep 17 00:00:00 2001
    From: Ryan Nevell 
    Date: Mon, 17 Feb 2020 09:09:58 -0800
    Subject: [PATCH 1844/2031] Clean up test cases
    
    ---
     Examples/test-suite/lua/lua_lightuserdata_runme.lua | 2 +-
     Examples/test-suite/lua_lightuserdata.i             | 5 +++--
     2 files changed, 4 insertions(+), 3 deletions(-)
    
    diff --git a/Examples/test-suite/lua/lua_lightuserdata_runme.lua b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
    index d805c2a74..c1c3c1d73 100644
    --- a/Examples/test-suite/lua/lua_lightuserdata_runme.lua
    +++ b/Examples/test-suite/lua/lua_lightuserdata_runme.lua
    @@ -1,5 +1,5 @@
     require("import") -- the import fn
    -require("lua_lightuserdata") -- import lib
    +import("lua_lightuserdata") -- import lib
     
     local t = lua_lightuserdata
     local d = t.get_lightuserdata()
    diff --git a/Examples/test-suite/lua_lightuserdata.i b/Examples/test-suite/lua_lightuserdata.i
    index 08e15c93c..9069b6ab4 100644
    --- a/Examples/test-suite/lua_lightuserdata.i
    +++ b/Examples/test-suite/lua_lightuserdata.i
    @@ -2,15 +2,16 @@
     
     %native(get_lightuserdata) int get_lightuserdata(lua_State* L);
     %{
    +static int foo;
     int get_lightuserdata(lua_State* L)
     {
    -  lua_pushlightuserdata(L, reinterpret_cast(0x123456));
    +  lua_pushlightuserdata(L, &foo);
       return 1;
     }
     %}
     
     %inline %{
     bool check_lighuserdata(const void* d) {
    -  return reinterpret_cast(0x123456) == d;
    +  return d == &foo;
     }
     %}
    
    From 4ce77ffb772e0c4145b67bf471fdffcf3aed0b40 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 18 Feb 2020 22:06:20 +0000
    Subject: [PATCH 1845/2031] Ruby - catch exceptions by const reference
    
    ---
     Lib/ruby/rubycontainer.swg | 17 ++++++++---------
     1 file changed, 8 insertions(+), 9 deletions(-)
    
    diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
    index 5f00ef5ea..e72330853 100644
    --- a/Lib/ruby/rubycontainer.swg
    +++ b/Lib/ruby/rubycontainer.swg
    @@ -628,7 +628,7 @@ namespace swig
           try {
     	r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
           }
    -      catch( std::out_of_range& ) {
    +      catch( const std::out_of_range& ) {
           }
           return r;
         }
    @@ -687,9 +687,8 @@ namespace swig
     	r = swig::from< Sequence::value_type >( *(at) );
     	$self->erase(at); 
           }
    -      catch (std::out_of_range&)
    -	{
    -	}
    +      catch (const std::out_of_range&) {
    +      }
           return r;
         }
       }
    @@ -757,7 +756,7 @@ namespace swig
           try {
     	r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
           }
    -      catch( std::out_of_range& ) {
    +      catch( const std::out_of_range& ) {
           }
           return r;
         }
    @@ -780,7 +779,7 @@ namespace swig
           try {
     	r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
           }
    -      catch( std::out_of_range& ) {
    +      catch( const std::out_of_range& ) {
           }
           return r;
         }
    @@ -790,7 +789,7 @@ namespace swig
           try {
     	r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
           }
    -      catch( std::out_of_range& ) {
    +      catch( const std::out_of_range& ) {
           }
           return r;
         }
    @@ -1017,7 +1016,7 @@ namespace swig {
     	  } else {
     	    return rubyseq.check() ? SWIG_OK : SWIG_ERROR;
     	  }
    -	} catch (std::exception& e) {
    +	} catch (const std::exception& e) {
     	  if (seq) {
     	    VALUE lastErr = rb_gv_get("$!");
     	    if (lastErr == Qnil) {
    @@ -1057,7 +1056,7 @@ namespace swig {
     	  } else {
     	    return true;
     	  }
    -	} catch (std::exception& e) {
    +	} catch (const std::exception& e) {
     	  if (seq) {
     	    VALUE lastErr = rb_gv_get("$!");
     	    if (lastErr == Qnil) {
    
    From 3a329566f8ae6210a610012ecd60f6455229fe77 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 18 Feb 2020 22:14:21 +0000
    Subject: [PATCH 1846/2031] Update changes file
    
    ---
     CHANGES.current | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/CHANGES.current b/CHANGES.current
    index 27f170eab..5ca41fc3b 100644
    --- a/CHANGES.current
    +++ b/CHANGES.current
    @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
     Version 4.0.2 (in progress)
     ===========================
     
    +2020-02-18: ryannevell
    +            [Lua] #1728 Add support for LUA lightuserdata to SWIG_Lua_ConvertPtr.
    +
    +2020-02-18: dmach
    +            [Ruby] #1725 Fix gcc -Wcatch-value warnings.
    +
     2020-02-14: treitmayr
                 #1724 Fix wrapping of abstract user-defined conversion operators.
     
    
    From 853987e866079e8877a013013da2c8fe1d7992b0 Mon Sep 17 00:00:00 2001
    From: Ryan Mast 
    Date: Fri, 28 Feb 2020 23:56:57 -0800
    Subject: [PATCH 1847/2031] Remove BUILDING_NOTE_EXTENSION from docs
    
    ---
     Doc/Manual/Preprocessor.html | 1 -
     1 file changed, 1 deletion(-)
    
    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
    index f09067b78..b3957982e 100644
    --- a/Doc/Manual/Preprocessor.html
    +++ b/Doc/Manual/Preprocessor.html
    @@ -121,7 +121,6 @@ SWIGJAVA                        Defined when using Java
     SWIGJAVASCRIPT                  Defined when using Javascript
     SWIG_JAVASCRIPT_JSC             Defined when using Javascript for JavascriptCore
     SWIG_JAVASCRIPT_V8              Defined when using Javascript for v8 or node.js
    -BUILDING_NODE_EXTENSION         Defined when using Javascript for node.js
     SWIGLUA                         Defined when using Lua
     SWIGMZSCHEME                    Defined when using Mzscheme
     SWIGOCAML                       Defined when using OCaml
    
    From f97b37a3162c15eca54d2171c36c75125ad3754e Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Tue, 3 Mar 2020 19:23:46 +0000
    Subject: [PATCH 1848/2031] Minor formatting fixes in Lua.html
    
    ---
     Doc/Manual/Lua.html | 20 ++++++++++++++------
     1 file changed, 14 insertions(+), 6 deletions(-)
    
    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
    index 60f7e1775..80807baf4 100644
    --- a/Doc/Manual/Lua.html
    +++ b/Doc/Manual/Lua.html
    @@ -145,7 +145,7 @@ The -elua option puts all the C function wrappers and variable get/set
     The following table list the additional commandline options available for the Lua module. They can also be seen by using: 
     

    -
    +
     swig -lua -help 
     
    @@ -747,7 +747,8 @@ Stout

    Class data members are accessed in the same manner as C structures. Static class members present a special problem for Lua, as Lua doesn't have support for such features. Therefore, SWIG generates wrappers that try to work around some of these issues. To illustrate, suppose you have a class like this:

    -
    class Spam {
    +
    +class Spam {
     public:
       static void foo();
       static int bar;
    @@ -756,7 +757,7 @@ public:
     

    In Lua, C++ static members can be accessed as follows:

    -
    +
     > example.Spam.foo()            -- calling Spam::foo()
     > a=example.Spam.bar            -- reading Spam::bar 
     > example.Spam.bar=b            -- writing to Spam::bar
    @@ -774,7 +775,7 @@ It is not (currently) possible to access static members of an instance:
     Compatibility Note: In versions prior to SWIG-3.0.0 only the following names would work:
     

    -
    +
     > example.Spam_foo()            -- calling Spam::foo()
     > a=example.Spam_bar            -- reading Spam::bar 
     > example.Spam_bar=b            -- writing to Spam::bar
    @@ -964,7 +965,8 @@ When wrapped, it works like you expect:
     

    One restriction with operator overloading support is that SWIG is not able to fully handle operators that aren't defined as part of the class. For example, if you had code like this

    -
    class Complex {
    +
    +class Complex {
     ...
     friend Complex operator+(double, const Complex &c);
     ...
    @@ -973,7 +975,8 @@ friend Complex operator+(double, const Complex &c);
     

    then SWIG doesn't know what to do with the friend function--in fact, it simply ignores it and issues a warning. You can still wrap the operator, but you may have to encapsulate it in a special function. For example:

    -
    %rename(Complex_add_dc) operator+(double, const Complex &);
    +
    +%rename(Complex_add_dc) operator+(double, const Complex &);
     ...
     Complex operator+(double, const Complex &c);
     
    @@ -1446,6 +1449,7 @@ Those names are in a form $classname_$symbolname and are added to the s If %nspace is enabled, then class namespace is taken as scope. If there is no namespace, or %nspace is disabled, then module is considered a class namespace.

    Consider the following C++ code

    +
    %module example
     %nspace MyWorld::Test;
     namespace MyWorld {
    @@ -1486,6 +1490,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not
     
     

    The internal organization of inheritance has changed. Consider the following C++ code:

    +
    %module example
     class Base {
       public:
    @@ -1502,6 +1507,7 @@ were squashed and added to corresponding derived class ST: Everything f
     was copied to .fn table of class Derived and so on. This was a recursive procedure, so in the end the whole
     inheritance tree of derived class was squashed into derived class. 

    That means that any changes done to class Base after module initialization wouldn't affect class Derived:

    +
     base = example.Base()
     der = example.Derived()
    @@ -1516,6 +1522,8 @@ nil
     

    This behaviour was changed. Now unless -squash-bases option is provided, Derived store a list of it's bases and if some symbol is not found in it's own service tables then its bases are searched for it. Option -squash-bases will effectively return old behaviour. +

    +
     > print(der.new_func) -- Now it works
     function
    
    From b81cd1bdab8e36dc8bebe6ce4d23dcf0564caaf3 Mon Sep 17 00:00:00 2001
    From: Vadim Zeitlin 
    Date: Tue, 3 Mar 2020 15:39:37 +0100
    Subject: [PATCH 1849/2031] Fix generated Python code for Doxygen comments
     ending with quote
    
    Single-line Doxygen comments ending with a double quote resulted in
    syntactically-invalid Python docstrings in the output, so use triple
    single quotes as delimiters in this case to avoid it.
    ---
     Examples/test-suite/doxygen_misc_constructs.h |  2 ++
     .../java/doxygen_misc_constructs_runme.java   |  2 ++
     .../python/doxygen_misc_constructs_runme.py   |  4 ++++
     Source/Modules/python.cxx                     | 20 ++++++++++++++++---
     4 files changed, 25 insertions(+), 3 deletions(-)
    
    diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h
    index d677dc3d3..7782b532f 100644
    --- a/Examples/test-suite/doxygen_misc_constructs.h
    +++ b/Examples/test-suite/doxygen_misc_constructs.h
    @@ -91,4 +91,6 @@ void backslashC()
     void cycle(int id, char *fileName)
     {}
     
    +/// This doc comment ends with a quote: "and that's ok"
    +void doc_ends_with_quote() {}
     
    diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    index b1f4e2ef5..ca4b06b55 100644
    --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    @@ -185,6 +185,8 @@ public class doxygen_misc_constructs_runme {
                     "\n" +
                     " @param fileName name of the log file\n");
     
    +    wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_ends_with_quote()",
    +            "This doc comment ends with a quote: \"and that's ok\"");
     
         // and ask the parser to check comments for us
         System.exit(CommentParser.check(wantedComments));
    diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    index c0b5c1620..5655b2cef 100644
    --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    @@ -131,3 +131,7 @@ Spaces at the start of line should be taken into account:
     :type fileName: string
     :param fileName: name of the log file"""
     );
    +
    +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_ends_with_quote),
    +    r'''This doc comment ends with a quote: "and that's ok"'''
    +);
    diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
    index f6b47be24..a4ac11811 100644
    --- a/Source/Modules/python.cxx
    +++ b/Source/Modules/python.cxx
    @@ -1571,7 +1571,8 @@ public:
     
       String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool low_level = false) {
         String *docstr = build_combined_docstring(n, ad_type, indent, low_level);
    -    if (!Len(docstr))
    +    const int len = Len(docstr);
    +    if (!len)
           return docstr;
     
         // Notice that all comments are created as raw strings (prefix "r"),
    @@ -1584,9 +1585,22 @@ public:
         // escape '\x'. '\' may additionally appear in verbatim or htmlonly sections
         // of doxygen doc, Latex expressions, ...
         String *doc = NewString("");
    -    Append(doc, "r\"\"\"");
    +
    +    // Determine which kind of quotes to use as delimiters: for single line
    +    // strings we can avoid problems with having a quote as the last character
    +    // of the docstring by using different kind of quotes as delimiters. For
    +    // multi-line strings this problem doesn't arise, as we always have a new
    +    // line or spaces at the end of it, but it still does no harm to do it for
    +    // them too.
    +    //
    +    // Note: we use double quotes by default, i.e. if there is no reason to
    +    // prefer using single ones, for consistency with the older SWIG versions.
    +    const bool useSingleQuotes = (Char(docstr))[len - 1] == '"';
    +
    +    Append(doc, useSingleQuotes ? "r'''" : "r\"\"\"");
    +
         Append(doc, docstr);
    -    Append(doc, "\"\"\"");
    +    Append(doc, useSingleQuotes ? "'''" : "\"\"\"");
         Delete(docstr);
     
         return doc;
    
    From f57b096c92983758b49c2231fdfd7cb0a75690f5 Mon Sep 17 00:00:00 2001
    From: Vadim Zeitlin 
    Date: Tue, 3 Mar 2020 15:48:42 +0100
    Subject: [PATCH 1850/2031] Fix generated Python code for Doxygen comments with
     triple quotes
    
    In addition to the changes in the previous commit, also avoid syntax
    errors in the generated Python docstrings by splitting them into several
    parts if there are 3 quotes in a row in the input, as it's impossible to
    have them inside triple-quoted strings, generally speaking (i.e. if
    there are occurrences of both """ and ''' inside the string).
    ---
     Examples/test-suite/doxygen_misc_constructs.h          |  6 ++++++
     .../test-suite/java/doxygen_misc_constructs_runme.java |  4 ++++
     .../test-suite/python/doxygen_misc_constructs_runme.py |  6 ++++++
     Source/Modules/python.cxx                              | 10 ++++++++++
     4 files changed, 26 insertions(+)
    
    diff --git a/Examples/test-suite/doxygen_misc_constructs.h b/Examples/test-suite/doxygen_misc_constructs.h
    index 7782b532f..9e81aaf28 100644
    --- a/Examples/test-suite/doxygen_misc_constructs.h
    +++ b/Examples/test-suite/doxygen_misc_constructs.h
    @@ -94,3 +94,9 @@ void cycle(int id, char *fileName)
     /// This doc comment ends with a quote: "and that's ok"
     void doc_ends_with_quote() {}
     
    +/**
    +    This comment contains embedded triple-quoted string:
    +
    +        """How quaint"""
    + */
    +void doc_with_triple_quotes() {}
    diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    index ca4b06b55..cae2b2192 100644
    --- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    +++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
    @@ -188,6 +188,10 @@ public class doxygen_misc_constructs_runme {
         wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_ends_with_quote()",
                 "This doc comment ends with a quote: \"and that's ok\"");
     
    +    wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.doc_with_triple_quotes()",
    +            "This comment contains embedded triple-quoted string:\n" +
    +            "\"\"\"How quaint\"\"\"");
    +
         // and ask the parser to check comments for us
         System.exit(CommentParser.check(wantedComments));
       }
    diff --git a/Examples/test-suite/python/doxygen_misc_constructs_runme.py b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    index 5655b2cef..44f607fee 100644
    --- a/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    +++ b/Examples/test-suite/python/doxygen_misc_constructs_runme.py
    @@ -135,3 +135,9 @@ Spaces at the start of line should be taken into account:
     comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_ends_with_quote),
         r'''This doc comment ends with a quote: "and that's ok"'''
     );
    +
    +comment_verifier.check(inspect.getdoc(doxygen_misc_constructs.doc_with_triple_quotes),
    +    r'''This comment contains embedded triple-quoted string:
    +
    +    """How quaint"""'''
    +);
    diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
    index a4ac11811..c8c45df35 100644
    --- a/Source/Modules/python.cxx
    +++ b/Source/Modules/python.cxx
    @@ -1599,6 +1599,16 @@ public:
     
         Append(doc, useSingleQuotes ? "r'''" : "r\"\"\"");
     
    +    // We also need to avoid having triple quotes of whichever type we use, as
    +    // this would break Python doc string syntax too. Unfortunately there is no
    +    // way to have triple quotes inside of raw-triple-quoted string, so we have
    +    // to break the string in parts and rely on concatenation of the adjacent
    +    // string literals.
    +    if (useSingleQuotes)
    +      Replaceall(docstr, "'''", "''' \"'''\" '''");
    +    else
    +      Replaceall(docstr, "\"\"\"", "\"\"\" '\"\"\"' \"\"\"");
    +
         Append(doc, docstr);
         Append(doc, useSingleQuotes ? "'''" : "\"\"\"");
         Delete(docstr);
    
    From 9727083c6e6c653decf6405dbeb10394131730e3 Mon Sep 17 00:00:00 2001
    From: William S Fulton 
    Date: Thu, 5 Mar 2020 18:56:46 +0000
    Subject: [PATCH 1851/2031] Preprocessor definitions doc update
    
    Move language specific definitions into separate section in docs.
    ---
     Doc/Manual/Preprocessor.html | 25 ++++++++++++++++---------
     1 file changed, 16 insertions(+), 9 deletions(-)
    
    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
    index b3957982e..e45a4354a 100644
    --- a/Doc/Manual/Preprocessor.html
    +++ b/Doc/Manual/Preprocessor.html
    @@ -111,16 +111,12 @@ SWIG_VERSION                    Hexadecimal (binary-coded decimal) number contai
     
     SWIGCSHARP                      Defined when using C#
     SWIGD                           Defined when using D
    -SWIG_D_VERSION                  Unsigned integer target version when using D
     SWIGGO                          Defined when using Go
    -SWIGGO_CGO                      Defined when using Go for cgo
    -SWIGGO_GCCGO                    Defined when using Go for gccgo
    -SWIGGO_INTGO_SIZE               Size of the Go type int when using Go (32 or 64)
     SWIGGUILE                       Defined when using Guile
     SWIGJAVA                        Defined when using Java
     SWIGJAVASCRIPT                  Defined when using Javascript
    -SWIG_JAVASCRIPT_JSC             Defined when using Javascript for JavascriptCore
    -SWIG_JAVASCRIPT_V8              Defined when using Javascript for v8 or node.js
    +SWIG_JAVASCRIPT_JSC             Defined when using Javascript with -jsc
    +SWIG_JAVASCRIPT_V8              Defined when using Javascript with -v8 or -node
     SWIGLUA                         Defined when using Lua
     SWIGMZSCHEME                    Defined when using Mzscheme
     SWIGOCAML                       Defined when using OCaml
    @@ -129,11 +125,8 @@ SWIGPERL                        Defined when using Perl
     SWIGPHP                         Defined when using PHP (any version)
     SWIGPHP7                        Defined when using PHP7
     SWIGPYTHON                      Defined when using Python
    -SWIGPYTHON_PY3                  Defined when using Python with -py3
    -SWIGPYTHON_BUILTIN              Defined when using Python with -builtin
     SWIGR                           Defined when using R
     SWIGRUBY                        Defined when using Ruby
    -SWIG_RUBY_AUTORENAME            Defined when using Ruby with -autorename
     SWIGSCILAB                      Defined when using Scilab
     SWIGTCL                         Defined when using Tcl
     SWIGXML                         Defined when using XML
    @@ -152,6 +145,20 @@ __cplusplus                     Defined when -c++ option used
     
    +

    +The following are language specific symbols that might be defined: +

    + +
    +SWIG_D_VERSION                  Unsigned integer target version when using D
    +SWIGGO_CGO                      Defined when using Go for cgo
    +SWIGGO_GCCGO                    Defined when using Go for gccgo
    +SWIGGO_INTGO_SIZE               Size of the Go type int when using Go (32 or 64)
    +SWIGPYTHON_PY3                  Defined when using Python with -py3
    +SWIGPYTHON_BUILTIN              Defined when using Python with -builtin
    +SWIG_RUBY_AUTORENAME            Defined when using Ruby with -autorename
    +
    +

    Interface files can look at these symbols as necessary to change the way in which an interface is generated or to mix SWIG directives with From 3f3073547804f2e112085429ddfb691beba5a2ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 5 Mar 2020 19:04:55 +0000 Subject: [PATCH 1852/2031] Correct preprocessor docs Blatently incorrect information removed. --- Doc/Manual/Preprocessor.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index e45a4354a..66061a597 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -162,9 +162,7 @@ SWIG_RUBY_AUTORENAME Defined when using Ruby with -autorename

    Interface files can look at these symbols as necessary to change the way in which an interface is generated or to mix SWIG directives with -C code. These symbols are also defined within the C code generated by -SWIG (except for the symbol `SWIG' which is only defined -within the SWIG compiler). +C code.

    10.4 Macro Expansion

    From d58041606ed7dde7084fd1c4f35301fef20e7f97 Mon Sep 17 00:00:00 2001 From: khoran Date: Wed, 25 Mar 2020 11:01:12 -0700 Subject: [PATCH 1853/2031] fixed some missing semicolons. Each one caused a compile error in generated code --- Lib/r/rtype.swg | 10 +++++----- Source/Modules/r.cxx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index bdc48c24e..8fe12230b 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -94,20 +94,20 @@ %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE && - %{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref") %} + %{ if (inherits($input, "ExternalReference")) $input = slot($input,"ref"); %} /* %typemap(scoercein) SWIGTYPE *, SWIGTYPE *const - %{ $input = coerceIfNotSubclass($input, "$R_class") %} + %{ $input = coerceIfNotSubclass($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE & - %{ $input = coerceIfNotSubclass($input, "$R_class") %} + %{ $input = coerceIfNotSubclass($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE && - %{ $input = coerceIfNotSubclass($input, "$R_class") %} + %{ $input = coerceIfNotSubclass($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE - %{ $input = coerceIfNotSubclass($input, "$&R_class") %} + %{ $input = coerceIfNotSubclass($input, "$&R_class"); %} */ %typemap(scoercein) SWIGTYPE[ANY] diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index addcf8b9a..16c4d22d9 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -2120,7 +2120,7 @@ int R::functionWrapper(Node *n) { { String *finalizer = NewString(iname); Replace(finalizer, "new_", "", DOH_REPLACE_FIRST); - Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer); + Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s);\n", finalizer); } Printf(sfun->code, "ans\n"); } From 554aeead56ff7cd826999e307255bd3c92167670 Mon Sep 17 00:00:00 2001 From: Tom Leavy Date: Wed, 25 Mar 2020 17:10:51 -0400 Subject: [PATCH 1854/2031] Introduce macros to support both Handle and Local types The old Node.js versions don't treat v8::Handle and v8::Local as the same types, and the latest versions (v12 and newer) have removed v8::Handle at all. This patch introduces the following macros that use v8::Handle or v8::Local depending on the selected Node.js version: - SWIGV8_ARRAY - SWIGV8_FUNCTION_TEMPLATE - SWIGV8_OBJECT - SWIGV8_OBJECT_TEMPLATE - SWIGV8_VALUE --- Lib/javascript/v8/javascriptrun.swg | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 2452f4040..cf3215334 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -67,6 +67,11 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_NUMBER_NEW(num) v8::Number::New(num) #define SWIGV8_OBJECT_NEW() v8::Object::New() #define SWIGV8_UNDEFINED() v8::Undefined() +#define SWIGV8_ARRAY v8::Handle +#define SWIGV8_FUNCTION_TEMPLATE v8::Handle +#define SWIGV8_OBJECT v8::Handle +#define SWIGV8_OBJECT_TEMPLATE v8::Handle +#define SWIGV8_VALUE v8::Handle #define SWIGV8_NULL() v8::Null() #else #define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent()) @@ -80,6 +85,11 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_NUMBER_NEW(num) v8::Number::New(v8::Isolate::GetCurrent(), num) #define SWIGV8_OBJECT_NEW() v8::Object::New(v8::Isolate::GetCurrent()) #define SWIGV8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent()) +#define SWIGV8_ARRAY v8::Local +#define SWIGV8_FUNCTION_TEMPLATE v8::Local +#define SWIGV8_OBJECT v8::Local +#define SWIGV8_OBJECT_TEMPLATE v8::Local +#define SWIGV8_VALUE v8::Local #define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent()) #endif From 26fc996ad6587d50727b8755ae7126e49cadf180 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Wed, 26 Feb 2020 15:55:18 +0100 Subject: [PATCH 1855/2031] Replace Handle with Local depending on Node.js version Use newly introduced macros like SWIGV8_VALUE to use v8::Handle or v8::Local depending on the selected Node.js version where possible. --- Examples/javascript/native/example.i | 2 +- Examples/test-suite/native_directive.i | 2 +- Lib/javascript/v8/javascriptcode.swg | 24 +++++++----- Lib/javascript/v8/javascriptcomplex.swg | 10 ++--- Lib/javascript/v8/javascripthelpers.swg | 21 +++++----- Lib/javascript/v8/javascriptinit.swg | 6 +-- Lib/javascript/v8/javascriptprimtypes.swg | 29 +++++++------- Lib/javascript/v8/javascriptrun.swg | 48 ++++++++++------------- Lib/javascript/v8/javascriptstrings.swg | 14 +++++-- Lib/javascript/v8/javascripttypemaps.swg | 2 +- 10 files changed, 82 insertions(+), 76 deletions(-) diff --git a/Examples/javascript/native/example.i b/Examples/javascript/native/example.i index 8c6160060..a9ca094a7 100644 --- a/Examples/javascript/native/example.i +++ b/Examples/javascript/native/example.i @@ -15,7 +15,7 @@ int placeholder() { return 0; } static SwigV8ReturnValue JavaScript_do_work(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); const int MY_MAGIC_NUMBER = 5; - v8::Handle jsresult = + SWIGV8_VALUE jsresult = SWIG_From_int(static_cast< int >(MY_MAGIC_NUMBER)); if (args.Length() != 0) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments."); diff --git a/Examples/test-suite/native_directive.i b/Examples/test-suite/native_directive.i index 9ae76e0b7..3d4858032 100644 --- a/Examples/test-suite/native_directive.i +++ b/Examples/test-suite/native_directive.i @@ -53,7 +53,7 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co static SwigV8ReturnValue JavaScript_alpha_count(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; char *arg1 = (char *)0; int res1; char *buf1 = 0; diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index c4aaf3db0..65e0d39d1 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -11,7 +11,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle self = args.Holder(); + SWIGV8_OBJECT self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode @@ -53,7 +53,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); OverloadErrorHandler errorHandler; - v8::Handle self; + SWIGV8_VALUE self; // switch all cases by means of series of if-returns. $jsdispatchcases @@ -78,7 +78,7 @@ fail: static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler &SWIGV8_ErrorHandler) { SWIGV8_HANDLESCOPE(); - v8::Handle self = args.Holder(); + SWIGV8_OBJECT self = args.Holder(); $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); $jscode @@ -226,7 +226,7 @@ static SwigV8ReturnValue $jswrapper(v8::Local property, const SwigV8Pr #endif SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; $jslocals $jscode SWIGV8_RETURN_INFO(jsresult, info); @@ -271,7 +271,7 @@ fail: static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; $jslocals if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper."); @@ -296,7 +296,7 @@ fail: static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; OverloadErrorHandler errorHandler; $jscode @@ -320,7 +320,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args, V8ErrorHandler { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; $jslocals $jscode SWIGV8_RETURN(jsresult); @@ -374,7 +374,7 @@ fail: %fragment("jsv8_define_class_template", "templates") %{ /* Name: $jsmangledname, Type: $jsmangledtype, Dtor: $jsdtor */ - v8::Handle $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname"); + SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname"); SWIGV8_SET_CLASS_TEMPL($jsmangledname_clientData.class_templ, $jsmangledname_class); $jsmangledname_clientData.dtor = $jsdtor; if (SWIGTYPE_$jsmangledtype->clientdata == 0) { @@ -420,11 +420,15 @@ fail: %fragment("jsv8_create_class_instance", "templates") %{ /* Class: $jsname ($jsmangledname) */ - v8::Handle $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); + SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); $jsmangledname_class_0->SetCallHandler($jsctor); $jsmangledname_class_0->Inherit($jsmangledname_class); $jsmangledname_class_0->SetHiddenPrototype(true); +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); +#else + v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); +#endif %} /* ----------------------------------------------------------------------------- @@ -444,7 +448,7 @@ fail: * ----------------------------------------------------------------------------- */ %fragment("jsv8_create_namespace", "templates") %{ - v8::Handle $jsmangledname_obj = SWIGV8_OBJECT_NEW(); + SWIGV8_OBJECT $jsmangledname_obj = SWIGV8_OBJECT_NEW(); %} /* ----------------------------------------------------------------------------- diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index d3b4aaffa..b894d7389 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -12,7 +12,7 @@ %fragment(SWIG_From_frag(Type),"header", fragment=SWIG_From_frag(double)) { -SWIGINTERNINLINE v8::Handle +SWIGINTERNINLINE SWIGV8_VALUE SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) { SWIGV8_HANDLESCOPE_ESC(); @@ -32,12 +32,12 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) fragment=SWIG_AsVal_frag(double)) { SWIGINTERN int -SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) +SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) { SWIGV8_HANDLESCOPE(); if (o->IsArray()) { - v8::Handle array = v8::Handle::Cast(o); + SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; @@ -74,12 +74,12 @@ SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) %fragment(SWIG_AsVal_frag(Type),"header", fragment=SWIG_AsVal_frag(float)) { SWIGINTERN int -SWIG_AsVal_dec(Type) (v8::Handle o, Type* val) +SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) { SWIGV8_HANDLESCOPE(); if (o->IsArray()) { - v8::Handle array = v8::Handle::Cast(o); + SWIGV8_ARRAY array = SWIGV8_ARRAY::Cast(o); if(array->Length() != 2) SWIG_Error(SWIG_TypeError, "Illegal argument for complex: must be array[2]."); double re, im; diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 80fbd7aa1..465d3ee48 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -21,19 +21,19 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfoVoid; /** * Creates a class template for a class with specified initialization function. */ -SWIGRUNTIME v8::Handle SWIGV8_CreateClassTemplate(const char* symbol) { +SWIGRUNTIME SWIGV8_FUNCTION_TEMPLATE SWIGV8_CreateClassTemplate(const char* symbol) { SWIGV8_HANDLESCOPE_ESC(); v8::Local class_templ = SWIGV8_FUNCTEMPLATE_NEW_VOID(); class_templ->SetClassName(SWIGV8_SYMBOL_NEW(symbol)); - v8::Handle inst_templ = class_templ->InstanceTemplate(); + SWIGV8_OBJECT_TEMPLATE inst_templ = class_templ->InstanceTemplate(); inst_templ->SetInternalFieldCount(1); - v8::Handle equals_templ = class_templ->PrototypeTemplate(); + SWIGV8_OBJECT_TEMPLATE equals_templ = class_templ->PrototypeTemplate(); equals_templ->Set(SWIGV8_SYMBOL_NEW("equals"), SWIGV8_FUNCTEMPLATE_NEW(_SWIGV8_wrap_equals)); - v8::Handle cptr_templ = class_templ->PrototypeTemplate(); + SWIGV8_OBJECT_TEMPLATE cptr_templ = class_templ->PrototypeTemplate(); cptr_templ->Set(SWIGV8_SYMBOL_NEW("getCPtr"), SWIGV8_FUNCTEMPLATE_NEW(_wrap_getCPtr)); SWIGV8_ESCAPE(class_templ); @@ -42,33 +42,34 @@ SWIGRUNTIME v8::Handle SWIGV8_CreateClassTemplate(const ch /** * Registers a class method with given name for a given class template. */ -SWIGRUNTIME void SWIGV8_AddMemberFunction(v8::Handle class_templ, const char* symbol, +SWIGRUNTIME void SWIGV8_AddMemberFunction(SWIGV8_FUNCTION_TEMPLATE class_templ, const char* symbol, SwigV8FunctionCallback _func) { - v8::Handle proto_templ = class_templ->PrototypeTemplate(); + SWIGV8_OBJECT_TEMPLATE proto_templ = class_templ->PrototypeTemplate(); proto_templ->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)); } /** * Registers a class property with given name for a given class template. */ -SWIGRUNTIME void SWIGV8_AddMemberVariable(v8::Handle class_templ, const char* symbol, +SWIGRUNTIME void SWIGV8_AddMemberVariable(SWIGV8_FUNCTION_TEMPLATE class_templ, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { - v8::Handle proto_templ = class_templ->InstanceTemplate(); + SWIGV8_OBJECT_TEMPLATE proto_templ = class_templ->InstanceTemplate(); proto_templ->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); } /** * Registers a class method with given name for a given object. */ -SWIGRUNTIME void SWIGV8_AddStaticFunction(v8::Handle obj, const char* symbol, +SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol, const SwigV8FunctionCallback& _func) { +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0705) obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction()); } /** * Registers a class method with given name for a given object. */ -SWIGRUNTIME void SWIGV8_AddStaticVariable(v8::Handle obj, const char* symbol, +SWIGRUNTIME void SWIGV8_AddStaticVariable(SWIGV8_OBJECT obj, const char* symbol, SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback setter) { #if (V8_MAJOR_VERSION-0) < 5 obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg index 8faf2dd8e..401f9ae1f 100644 --- a/Lib/javascript/v8/javascriptinit.swg +++ b/Lib/javascript/v8/javascriptinit.swg @@ -68,16 +68,16 @@ SWIG_V8_GetModule(void *) { // TODO: is it ok to do that? extern "C" #if (NODE_MODULE_VERSION < 0x000C) -void SWIGV8_INIT (v8::Handle exports) +void SWIGV8_INIT (SWIGV8_OBJECT exports) #else -void SWIGV8_INIT (v8::Handle exports, v8::Handle /*module*/) +void SWIGV8_INIT (SWIGV8_OBJECT exports, SWIGV8_OBJECT /*module*/) #endif { SWIG_InitializeModule(static_cast(&exports)); SWIGV8_HANDLESCOPE(); - v8::Handle exports_obj = exports; + SWIGV8_OBJECT exports_obj = exports; %} diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg index f76be983b..a6577ded2 100644 --- a/Lib/javascript/v8/javascriptprimtypes.swg +++ b/Lib/javascript/v8/javascriptprimtypes.swg @@ -6,7 +6,7 @@ %fragment(SWIG_From_frag(bool),"header") { SWIGINTERNINLINE -v8::Handle +SWIGV8_VALUE SWIG_From_dec(bool)(bool value) { return SWIGV8_BOOLEAN_NEW(value); @@ -16,7 +16,7 @@ SWIG_From_dec(bool)(bool value) %fragment(SWIG_AsVal_frag(bool),"header", fragment=SWIG_AsVal_frag(long)) { SWIGINTERN -int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val) +int SWIG_AsVal_dec(bool)(SWIGV8_VALUE obj, bool *val) { if(!obj->IsBoolean()) { return SWIG_ERROR; @@ -31,7 +31,7 @@ int SWIG_AsVal_dec(bool)(v8::Handle obj, bool *val) %fragment(SWIG_From_frag(int),"header") { SWIGINTERNINLINE -v8::Handle SWIG_From_dec(int)(int value) +SWIGV8_VALUE SWIG_From_dec(int)(int value) { return SWIGV8_INT32_NEW(value); } @@ -39,7 +39,7 @@ v8::Handle SWIG_From_dec(int)(int value) %fragment(SWIG_AsVal_frag(int),"header") { SWIGINTERN -int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val) +int SWIG_AsVal_dec(int)(SWIGV8_VALUE valRef, int* val) { if (!valRef->IsNumber()) { return SWIG_TypeError; @@ -54,7 +54,7 @@ int SWIG_AsVal_dec(int)(v8::Handle valRef, int* val) %fragment(SWIG_From_frag(long),"header") { SWIGINTERNINLINE -v8::Handle SWIG_From_dec(long)(long value) +SWIGV8_VALUE SWIG_From_dec(long)(long value) { return SWIGV8_NUMBER_NEW(value); } @@ -63,7 +63,7 @@ v8::Handle SWIG_From_dec(long)(long value) %fragment(SWIG_AsVal_frag(long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN -int SWIG_AsVal_dec(long)(v8::Handle obj, long* val) +int SWIG_AsVal_dec(long)(SWIGV8_VALUE obj, long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; @@ -79,7 +79,7 @@ int SWIG_AsVal_dec(long)(v8::Handle obj, long* val) %fragment(SWIG_From_frag(unsigned long),"header", fragment=SWIG_From_frag(long)) { SWIGINTERNINLINE -v8::Handle SWIG_From_dec(unsigned long)(unsigned long value) +SWIGV8_VALUE SWIG_From_dec(unsigned long)(unsigned long value) { return (value > LONG_MAX) ? SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); @@ -89,7 +89,7 @@ v8::Handle SWIG_From_dec(unsigned long)(unsigned long value) %fragment(SWIG_AsVal_frag(unsigned long),"header", fragment="SWIG_CanCastAsInteger") { SWIGINTERN -int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) +int SWIG_AsVal_dec(unsigned long)(SWIGV8_VALUE obj, unsigned long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; @@ -115,7 +115,7 @@ int SWIG_AsVal_dec(unsigned long)(v8::Handle obj, unsigned long *val) fragment="SWIG_LongLongAvailable") { %#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE -v8::Handle SWIG_From_dec(long long)(long long value) +SWIGV8_VALUE SWIG_From_dec(long long)(long long value) { return SWIGV8_NUMBER_NEW(value); } @@ -128,7 +128,7 @@ v8::Handle SWIG_From_dec(long long)(long long value) fragment="SWIG_LongLongAvailable") { %#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN -int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) +int SWIG_AsVal_dec(long long)(SWIGV8_VALUE obj, long long* val) { if (!obj->IsNumber()) { return SWIG_TypeError; @@ -148,7 +148,7 @@ int SWIG_AsVal_dec(long long)(v8::Handle obj, long long* val) fragment="SWIG_LongLongAvailable") { %#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERNINLINE -v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value) +SWIGV8_VALUE SWIG_From_dec(unsigned long long)(unsigned long long value) { return (value > LONG_MAX) ? SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); @@ -162,7 +162,7 @@ v8::Handle SWIG_From_dec(unsigned long long)(unsigned long long value fragment="SWIG_LongLongAvailable") { %#ifdef SWIG_LONG_LONG_AVAILABLE SWIGINTERN -int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long long *val) +int SWIG_AsVal_dec(unsigned long long)(SWIGV8_VALUE obj, unsigned long long *val) { if(!obj->IsNumber()) { return SWIG_TypeError; @@ -185,7 +185,7 @@ int SWIG_AsVal_dec(unsigned long long)(v8::Handle obj, unsigned long %fragment(SWIG_From_frag(double),"header") { SWIGINTERN -v8::Handle SWIG_From_dec(double) (double val) +SWIGV8_VALUE SWIG_From_dec(double) (double val) { return SWIGV8_NUMBER_NEW(val); } @@ -193,7 +193,7 @@ v8::Handle SWIG_From_dec(double) (double val) %fragment(SWIG_AsVal_frag(double),"header") { SWIGINTERN -int SWIG_AsVal_dec(double)(v8::Handle obj, double *val) +int SWIG_AsVal_dec(double)(SWIGV8_VALUE obj, double *val) { if(!obj->IsNumber()) { return SWIG_TypeError; @@ -203,4 +203,3 @@ int SWIG_AsVal_dec(double)(v8::Handle obj, double *val) return SWIG_OK; } } - diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index cf3215334..1d74e3747 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -173,7 +173,7 @@ public: SWIGV8_THROW_EXCEPTION(err); } } - v8::Handle err; + SWIGV8_VALUE err; }; /* --------------------------------------------------------------------------- @@ -238,7 +238,7 @@ public: SWIGRUNTIME v8::Persistent SWIGV8_SWIGTYPE_Proxy_class_templ; -SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle objRef, void **ptr, swig_type_info *info, int flags) { +SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(SWIGV8_OBJECT objRef, void **ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE(); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; @@ -290,11 +290,11 @@ SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackInfo valRef, void **ptr) { +SWIGRUNTIME int SWIG_V8_GetInstancePtr(SWIGV8_VALUE valRef, void **ptr) { if(!valRef->IsObject()) { return SWIG_TypeError; } - v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); + SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef); if(objRef->InternalFieldCount() < 1) return SWIG_ERROR; @@ -314,7 +314,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle valRef, void **ptr) return SWIG_OK; } -SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, swig_type_info *info, int flags) { +SWIGRUNTIME void SWIGV8_SetPrivateData(SWIGV8_OBJECT obj, void *ptr, swig_type_info *info, int flags) { SWIGV8_Proxy *cdata = new SWIGV8_Proxy(); cdata->swigCObject = ptr; cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0; @@ -377,7 +377,7 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle obj, void *ptr, sw } -SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle valRef, void **ptr, swig_type_info *info, int flags) { +SWIGRUNTIME int SWIG_V8_ConvertPtr(SWIGV8_VALUE valRef, void **ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE(); /* special case: JavaScript null => C NULL pointer */ @@ -388,14 +388,14 @@ SWIGRUNTIME int SWIG_V8_ConvertPtr(v8::Handle valRef, void **ptr, swi if(!valRef->IsObject()) { return SWIG_TypeError; } - v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); + SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef); return SWIG_V8_ConvertInstancePtr(objRef, ptr, info, flags); } -SWIGRUNTIME v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { +SWIGRUNTIME SWIGV8_VALUE SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) { SWIGV8_HANDLESCOPE_ESC(); - v8::Handle class_templ; + SWIGV8_FUNCTION_TEMPLATE class_templ; if (ptr == NULL) { #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) @@ -443,7 +443,7 @@ SWIGRUNTIME v8::Handle SWIG_V8_NewPointerObj(void *ptr, swig_type_inf SWIGRUNTIME SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; void *arg1 = (void *) 0 ; void *arg2 = (void *) 0 ; bool result; @@ -473,7 +473,7 @@ fail: SWIGRUNTIME SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) { SWIGV8_HANDLESCOPE(); - v8::Handle jsresult; + SWIGV8_VALUE jsresult; void *arg1 = (void *) 0 ; long result; int res1; @@ -512,10 +512,10 @@ public: }; SWIGRUNTIMEINLINE -int SwigV8Packed_Check(v8::Handle valRef) { +int SwigV8Packed_Check(SWIGV8_VALUE valRef) { SWIGV8_HANDLESCOPE(); - v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); + SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef); if(objRef->InternalFieldCount() < 1) return false; #if (V8_MAJOR_VERSION-0) < 5 v8::Handle flag = objRef->GetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__")); @@ -529,13 +529,13 @@ int SwigV8Packed_Check(v8::Handle valRef) { } SWIGRUNTIME -swig_type_info *SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, size_t size) { +swig_type_info *SwigV8Packed_UnpackData(SWIGV8_VALUE valRef, void *ptr, size_t size) { if (SwigV8Packed_Check(valRef)) { SWIGV8_HANDLESCOPE(); SwigV8PackedData *sobj; - v8::Handle objRef = SWIGV8_TO_OBJECT(valRef); + SWIGV8_OBJECT objRef = SWIGV8_TO_OBJECT(valRef); #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511) v8::Handle cdataRef = objRef->GetInternalField(0); @@ -552,7 +552,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle valRef, void *ptr, } SWIGRUNTIME -int SWIGV8_ConvertPacked(v8::Handle valRef, void *ptr, size_t sz, swig_type_info *ty) { +int SWIGV8_ConvertPacked(SWIGV8_VALUE valRef, void *ptr, size_t sz, swig_type_info *ty) { swig_type_info *to = SwigV8Packed_UnpackData(valRef, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { @@ -600,7 +600,7 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackInfo SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) { +SWIGV8_VALUE SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) { SWIGV8_HANDLESCOPE_ESC(); SwigV8PackedData *cdata = new SwigV8PackedData(data, size, type); @@ -664,21 +664,15 @@ v8::Handle SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf SWIGRUNTIME -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) -v8::Handle SWIGV8_AppendOutput(v8::Handle result, v8::Handle obj) { -#else -v8::Handle SWIGV8_AppendOutput(v8::Local result, v8::Handle obj) { -#endif +SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { SWIGV8_HANDLESCOPE_ESC(); if (result->IsUndefined()) { result = SWIGV8_ARRAY_NEW(); } -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) - v8::Handle arr = v8::Handle::Cast(result); -#else - v8::Local arr = v8::Local::Cast(result); -#endif + SWIGV8_ARRAY arr = SWIGV8_ARRAY::Cast(result); + +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0706) arr->Set(arr->Length(), obj); SWIGV8_ESCAPE(arr); diff --git a/Lib/javascript/v8/javascriptstrings.swg b/Lib/javascript/v8/javascriptstrings.swg index e767a6d66..9c0919172 100644 --- a/Lib/javascript/v8/javascriptstrings.swg +++ b/Lib/javascript/v8/javascriptstrings.swg @@ -4,10 +4,14 @@ * ------------------------------------------------------------ */ %fragment("SWIG_AsCharPtrAndSize", "header", fragment="SWIG_pchar_descriptor") { SWIGINTERN int -SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, int *alloc) +SWIG_AsCharPtrAndSize(SWIGV8_VALUE valRef, char** cptr, size_t* psize, int *alloc) { if(valRef->IsString()) { +%#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) v8::Handle js_str = SWIGV8_TO_STRING(valRef); +%#else + v8::Local js_str = SWIGV8_TO_STRING(valRef); +%#endif size_t len = SWIGV8_UTF8_LENGTH(js_str) + 1; char* cstr = new char[len]; @@ -20,7 +24,7 @@ SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, return SWIG_OK; } else { if(valRef->IsObject()) { - v8::Handle obj = SWIGV8_TO_OBJECT(valRef); + SWIGV8_OBJECT obj = SWIGV8_TO_OBJECT(valRef); // try if the object is a wrapped char[] swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); if (pchar_descriptor) { @@ -41,7 +45,7 @@ SWIG_AsCharPtrAndSize(v8::Handle valRef, char** cptr, size_t* psize, } %fragment("SWIG_FromCharPtrAndSize","header",fragment="SWIG_pchar_descriptor") { -SWIGINTERNINLINE v8::Handle +SWIGINTERNINLINE SWIGV8_VALUE SWIG_FromCharPtrAndSize(const char* carray, size_t size) { if (carray) { @@ -49,7 +53,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) // TODO: handle extra long strings return SWIGV8_UNDEFINED(); } else { +%#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) v8::Handle js_str = SWIGV8_STRING_NEW2(carray, size); +%#else + v8::Local js_str = SWIGV8_STRING_NEW2(carray, size); +%#endif return js_str; } } else { diff --git a/Lib/javascript/v8/javascripttypemaps.swg b/Lib/javascript/v8/javascripttypemaps.swg index 4601698e0..cb31100c5 100644 --- a/Lib/javascript/v8/javascripttypemaps.swg +++ b/Lib/javascript/v8/javascripttypemaps.swg @@ -25,7 +25,7 @@ /* Javascript types */ -#define SWIG_Object v8::Handle +#define SWIG_Object SWIGV8_VALUE #define VOID_Object SWIGV8_UNDEFINED() /* Overload of the output/constant/exception/dirout handling */ From 113d78a083aa897ffdca4ff6bd9b42e630d16d27 Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Mon, 2 Mar 2020 14:44:04 +0100 Subject: [PATCH 1856/2031] Add support for Node.js v12 --- Lib/javascript/v8/javascriptcode.swg | 16 +++++++-- Lib/javascript/v8/javascripthelpers.swg | 5 +++ Lib/javascript/v8/javascriptrun.swg | 43 ++++++++++++++++++++----- Lib/javascript/v8/javascriptruntime.swg | 5 +++ 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index 65e0d39d1..edcc1fd90 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -423,11 +423,14 @@ fail: SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); $jsmangledname_class_0->SetCallHandler($jsctor); $jsmangledname_class_0->Inherit($jsmangledname_class); - $jsmangledname_class_0->SetHiddenPrototype(true); #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) + $jsmangledname_class_0->SetHiddenPrototype(true); v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); -#else +#elif (SWIG_V8_VERSION < 0x0705) + $jsmangledname_class_0->SetHiddenPrototype(true); v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); +#else + v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked(); #endif %} @@ -439,7 +442,12 @@ fail: * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_class", "templates") %{ +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); +#else + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); +#endif + %} /* ----------------------------------------------------------------------------- @@ -459,7 +467,11 @@ fail: * ----------------------------------------------------------------------------- */ %fragment("jsv8_register_namespace", "templates") %{ +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); +#else + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); +#endif %} /* ----------------------------------------------------------------------------- diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 465d3ee48..cbb43b56d 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -64,6 +64,11 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol, const SwigV8FunctionCallback& _func) { #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0705) obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction()); +#elif (SWIG_V8_VERSION < 0x0706) + obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); +#else + obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); +#endif } /** diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 1d74e3747..8ce8ff567 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -9,8 +9,10 @@ #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len) -#else +#elif (SWIG_V8_VERSION < 0x0706) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len) +#else +#define SWIGV8_STRING_NEW2(cstr, len) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::NewStringType::kNormal, len)).ToLocalChecked() #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) @@ -47,12 +49,18 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err) #define SWIGV8_STRING_NEW(str) v8::String::New(str) #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym) +#elif (SWIG_V8_VERSION < 0x0706) +#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) +#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() +#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) +#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString) +#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString) #else #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) -#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str) -#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym) +#define SWIGV8_STRING_NEW(str) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal)).ToLocalChecked() +#define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked() #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) @@ -117,7 +125,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue() #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len) #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length() -#else +#elif (SWIG_V8_VERSION < 0x0706) #define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() @@ -125,8 +133,17 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len) #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) +#else +#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent()) +#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len) +#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) #endif + /* --------------------------------------------------------------------------- * Error handling * @@ -371,10 +388,11 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(SWIGV8_OBJECT obj, void *ptr, swig_type_i cdata->handle.MarkIndependent(); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); -#else +#elif (SWIG_V8_VERSION < 0x0706) cdata->handle.MarkIndependent(); +// Looks like future versions do not require that anymore: +// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11 #endif - } SWIGRUNTIME int SWIG_V8_ConvertPtr(SWIGV8_VALUE valRef, void **ptr, swig_type_info *info, int flags) { @@ -422,8 +440,12 @@ SWIGRUNTIME SWIGV8_VALUE SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, } #endif -// v8::Handle result = class_templ->InstanceTemplate()->NewInstance(); +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0705) v8::Local result = class_templ->InstanceTemplate()->NewInstance(); +#else + v8::Local result = class_templ->InstanceTemplate()->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked(); +#endif + SWIGV8_SetPrivateData(result, ptr, info, flags); SWIGV8_ESCAPE(result); @@ -646,8 +668,10 @@ SWIGV8_VALUE SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) cdata->handle.MarkIndependent(); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); -#else +#elif (SWIG_V8_VERSION < 0x0706) cdata->handle.MarkIndependent(); +// Looks like future versions do not require that anymore: +// https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11 #endif SWIGV8_ESCAPE(obj); @@ -674,6 +698,9 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0706) arr->Set(arr->Length(), obj); +#else + arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj); +#endif SWIGV8_ESCAPE(arr); } diff --git a/Lib/javascript/v8/javascriptruntime.swg b/Lib/javascript/v8/javascriptruntime.swg index c78e04efb..773014f2a 100644 --- a/Lib/javascript/v8/javascriptruntime.swg +++ b/Lib/javascript/v8/javascriptruntime.swg @@ -56,6 +56,11 @@ %insert(runtime) %{ #include +#if defined(V8_MAJOR_VERSION) && defined(V8_MINOR_VERSION) +#undef SWIG_V8_VERSION +#define SWIG_V8_VERSION (V8_MAJOR_VERSION * 256 + V8_MINOR_VERSION) +#endif + #include #include #include From 0ea6a3bdbf3184d230bf17d2c17704dbc2ec7aac Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Wed, 26 Feb 2020 14:30:15 +0100 Subject: [PATCH 1857/2031] Nodejs: run tests against Node.js v12 --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 32c6656dd..42f0e259f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -112,6 +112,11 @@ matrix: env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1 sudo: required dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=12 CPP11=1 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=jsc From 3b0db10aa43edac4a9d2efb14e79373d51997b58 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 18 Apr 2020 09:57:20 -0600 Subject: [PATCH 1858/2031] Increase DOH_POOL_SIZE Increase DOH_POOL_SIZE to 2^22. Addresses GH-1775. --- Source/DOH/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index e0e4c68bd..4a9494e85 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -15,7 +15,7 @@ #include "dohint.h" #ifndef DOH_POOL_SIZE -#define DOH_POOL_SIZE 16384 +#define DOH_POOL_SIZE 4194304 #endif /* Checks stale DOH object use - will use a lot more memory as pool memory is not re-used. */ From 61dbc4b50ca568dcf087e93cc466ad8e89f9294c Mon Sep 17 00:00:00 2001 From: John McFarland Date: Sat, 2 May 2020 18:34:50 -0500 Subject: [PATCH 1859/2031] Fix for missing space after \endlink in doxygen The "endlink" command is processed in processWordCommands, which by default skips space occuring after the command, which is intended for removing leading space from a command argument. For "end" commands, we don't want to do this. Note that certain end commands such as "endcode" aren't processed by processWordCommands (believe addCommandUnique ends up handling them). Update usage of \link in doxygen_translate_all_tags.i to test handling of space after \endlink. Tweaking some of the usage in doxygen_misc_constructs.i to remove what seems to be an extra space from the input (otherwise we would need to add an extra space to the expected output). --- Examples/test-suite/doxygen_misc_constructs.i | 4 ++-- Examples/test-suite/doxygen_translate_all_tags.i | 2 +- .../test-suite/java/doxygen_translate_all_tags_runme.java | 2 +- .../test-suite/python/doxygen_translate_all_tags_runme.py | 2 +- Source/Doxygen/doxyparser.cxx | 4 ++++ 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i index c1b3eea31..9cf95de39 100644 --- a/Examples/test-suite/doxygen_misc_constructs.i +++ b/Examples/test-suite/doxygen_misc_constructs.i @@ -36,7 +36,7 @@ * @param line line number * @param isGetSize if set, for every object location both address and size are returned * - * @link Connection::getId() @endlink
    + * @link Connection::getId() @endlink
    */ void getAddress(int &fileName, int line, @@ -62,7 +62,7 @@ * used for unspecified parameters. *

    * - * @link advancedWinIDEALaunching.py Python example.@endlink
    + * @link advancedWinIDEALaunching.py Python example.@endlink
    */ class CConnectionConfig { diff --git a/Examples/test-suite/doxygen_translate_all_tags.i b/Examples/test-suite/doxygen_translate_all_tags.i index 6cefd8d4e..b54203d0a 100644 --- a/Examples/test-suite/doxygen_translate_all_tags.i +++ b/Examples/test-suite/doxygen_translate_all_tags.i @@ -210,7 +210,7 @@ void func05(int a) * * \line example * - * \link someMember Some description follows \endlink + * \link someMember Some description follows\endlink with text after * * \mainpage Some title * diff --git a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java index fda1fc3f8..56272bf84 100644 --- a/Examples/test-suite/java/doxygen_translate_all_tags_runme.java +++ b/Examples/test-suite/java/doxygen_translate_all_tags_runme.java @@ -93,7 +93,7 @@ public class doxygen_translate_all_tags_runme { "

  • With lots of items \n" + "
  • lots of lots of items \n" + "
  • \n" + - " {@link someMember Some description follows }\n" + + " {@link someMember Some description follows} with text after\n" + " This will only appear in man\n"); wantedComments.put("doxygen_translate_all_tags.doxygen_translate_all_tags.func07(int, int, int, int)", diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 2b5b3b810..e884cf9ef 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -175,7 +175,7 @@ This will only appear in LATeX -someMember Some description follows +someMember Some description follows with text after diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 6bda9d27c..35d18363f 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -1196,6 +1196,10 @@ void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) { // do it every time.) if (getBaseCommand(cmd) == CMD_CODE) skipLeadingSpace = true; else skipLeadingSpace = false; + } else if (cmd.substr(0,3) == "end") { + // If processing an "end" command such as "endlink", don't skip + // the space before the next string + skipLeadingSpace = false; } if (skipLeadingSpace) { From 48842cb07b9626335f55f7b255578d734562de2a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 21 May 2020 19:39:05 -0400 Subject: [PATCH 1860/2031] configure: fix pkg-config invocation The code was already probing $PKGCONFIG but then still falls back to using the hardcoded `pkg-config` tool. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b4cadefd0..fce5b9ee5 100644 --- a/configure.ac +++ b/configure.ac @@ -1597,7 +1597,7 @@ else if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then AC_MSG_CHECKING(for JavaScriptCore/Webkit library) - if pkg-config javascriptcoregtk-1.0; then + if $PKGCONFIG javascriptcoregtk-1.0; then JSCORELIB=`$PKGCONFIG --libs javascriptcoregtk-1.0` JSCOREVERSION=`$PKGCONFIG --modversion javascriptcoregtk-1.0` fi From ab8ecbc208071e1c2a6cf0b4ee1ee23351ae7ed3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 May 2020 15:58:21 +0200 Subject: [PATCH 1861/2031] Use '\\' instead of "\\" No real changes, just use simpler quoting construct which is sufficient (as we don't need to expand any variables) and also happens not to break Vim 8 syntax highlighting in the entire file, unlike double quotes. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b4cadefd0..ab7de511b 100644 --- a/configure.ac +++ b/configure.ac @@ -622,7 +622,7 @@ else PYEPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)") 2>/dev/null` AC_MSG_RESULT($PYEPREFIX) - if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\"; then + if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\'; then # Windows installations are quite different to posix installations (MinGW path separator is a forward slash) PYPREFIX=`echo "$PYPREFIX" | sed -e 's,\\\\,/,g'` # Forward slashes are easier to use and even work on Windows most of the time PYTHON_SO=.pyd @@ -739,7 +739,7 @@ else PYVER=0 fi if test "x$PY3BIN" = xyes; then - if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\" -a $PYVER -ge 3; then + if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\' -a $PYVER -ge 3; then PYTHON3="$PYTHON" else for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 ""; do @@ -774,7 +774,7 @@ else PYSEPARATOR=`($PYTHON3 -c "import sys, os; sys.stdout.write(os.sep)") 2>/dev/null` AC_MSG_RESULT($PYSEPARATOR) - if test x"$PY3OSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\"; then + if test x"$PY3OSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\'; then # Windows installations are quite different to posix installations # There is no python-config to use AC_MSG_CHECKING(for Python 3.x prefix) From 6c5d00bd0d57e9a9a46ae0f378463f4038e7c42a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 May 2020 16:17:45 +0200 Subject: [PATCH 1862/2031] Ignore ambiguous variable names error from pycodestyle 2.6 This error is given for any use of variable called "l" (and also "I" and "O", but we don't seem to have any of those) and it doesn't seem to be worth changing this variable name in the tests code, as it's really not that meaningful there anyhow, so just disable the warning to let the CI builds, which now use pycodestyle 2.6, instead of 2.5 which didn't have this error and which is still the latest available in Debian Sid, pass. --- Examples/test-suite/python/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index be06f7e51..4c0507cbb 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -11,7 +11,7 @@ endif LANGUAGE = python PYTHON = $(PYBIN) PYCODESTYLE = @PYCODESTYLE@ -PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,W291,W391 +PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391 #*_runme.py for Python 2.x, *_runme3.py for Python 3.x PY2SCRIPTSUFFIX = _runme.py From 6cf36d4cd6bed0519648d2a01ba69cc6b7ec8b3f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 22 May 2020 15:37:33 +0200 Subject: [PATCH 1863/2031] Force using C11 for Guile builds on Travis CI Compiling code including Guile headers with default compiler options doesn't work any more since a recent (~2020-05-05) update to Guile 3.0.2 on Homebrew (2.2.7 was used previously) due to error: redefinition of typedef 'scm_print_state' is a C11 feature in libguile/print.h and scm.h headers. Work around this by enabling C11 for this build by explicitly setting CSTD. Note that we can't just use CPP11=1 for this build, because this would also enable C++11-specific tests that are not currently supported by Guile module. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32c6656dd..cedce513d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -428,7 +428,7 @@ matrix: env: SWIGLANG=go - compiler: clang os: osx - env: SWIGLANG=guile + env: SWIGLANG=guile CSTD=c11 - compiler: clang os: osx env: SWIGLANG=java From 8b572399d72f3d812165e0975498c930ae822a4f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 May 2020 16:06:14 +0200 Subject: [PATCH 1864/2031] Revert "Use '\\' instead of "\\"" This reverts commit ab8ecbc208071e1c2a6cf0b4ee1ee23351ae7ed3 as it broke AppVeyor CI builds. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index fde5a010b..fce5b9ee5 100644 --- a/configure.ac +++ b/configure.ac @@ -622,7 +622,7 @@ else PYEPREFIX=`($PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)") 2>/dev/null` AC_MSG_RESULT($PYEPREFIX) - if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\'; then + if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\"; then # Windows installations are quite different to posix installations (MinGW path separator is a forward slash) PYPREFIX=`echo "$PYPREFIX" | sed -e 's,\\\\,/,g'` # Forward slashes are easier to use and even work on Windows most of the time PYTHON_SO=.pyd @@ -739,7 +739,7 @@ else PYVER=0 fi if test "x$PY3BIN" = xyes; then - if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\' -a $PYVER -ge 3; then + if test x"$PYOSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\" -a $PYVER -ge 3; then PYTHON3="$PYTHON" else for py_ver in 3 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 ""; do @@ -774,7 +774,7 @@ else PYSEPARATOR=`($PYTHON3 -c "import sys, os; sys.stdout.write(os.sep)") 2>/dev/null` AC_MSG_RESULT($PYSEPARATOR) - if test x"$PY3OSNAME" = x"nt" -a x"$PYSEPARATOR" = x'\\'; then + if test x"$PY3OSNAME" = x"nt" -a x"$PYSEPARATOR" = x"\\"; then # Windows installations are quite different to posix installations # There is no python-config to use AC_MSG_CHECKING(for Python 3.x prefix) From c71885d23779f51ccd9d66bce686faaaa44c6ea0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 May 2020 16:12:32 +0200 Subject: [PATCH 1865/2031] Switch one of Travis CI Ruby builds to use s390x arch Check if the tests work correctly in big endian environment. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cedce513d..a71f3e0e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -351,6 +351,7 @@ matrix: sudo: required dist: xenial - os: linux + arch: s390x env: SWIGLANG=ruby CPP11=1 sudo: required dist: xenial From 05b6f07940f6d942afeae58fc024510e054ce585 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 May 2020 23:01:54 +0200 Subject: [PATCH 1866/2031] Don't fail the build if CPU model or memory can't be detected This is purely informative anyhow and there is no reason to stop the build just because this information couldn't be found (as happens when running in s390x VM, for example). Also avoid useless use of cat. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a71f3e0e3..98a1b6319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -495,7 +495,7 @@ matrix: before_install: - date -u - uname -a - - if test "$TRAVIS_OS_NAME" = "linux"; then lscpu && cat /proc/cpuinfo | grep "model name" && cat /proc/meminfo | grep MemTotal; fi + - if test "$TRAVIS_OS_NAME" = "linux"; then lscpu; grep "model name" /proc/cpuinfo || echo 'Unknown CPU model'; grep "MemTotal" /proc/meminfo || echo 'Unknown system memory amount'; fi - if test "$TRAVIS_OS_NAME" = "osx"; then sysctl -a | grep brand_string; fi # Travis overrides CC environment with compiler predefined values - if test -n "$GCC"; then export CC="gcc-$GCC" && export CXX="g++-$GCC"; fi From 7fd9d94a9b6bf5904a042ea75eddeb40c7777cc2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 May 2020 23:07:13 +0200 Subject: [PATCH 1867/2031] Install libpcre3-dev for Linux builds This package contains the required PCRE library development files and may be already installed, as is apparently the case for amd64 systems, but also may not be, as when using s390x architecture. --- Tools/travis-linux-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index c8347d27a..d5157086f 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -13,7 +13,7 @@ if [[ -n "$GCC" ]]; then travis_retry sudo apt-get install -qq g++-$GCC fi -travis_retry sudo apt-get -qq install libboost-dev +travis_retry sudo apt-get -qq install libboost-dev libpcre3-dev WITHLANG=$SWIGLANG From f5e1e689fc583333a870c071c8e4488cf67dc7ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 May 2020 23:53:03 +0100 Subject: [PATCH 1868/2031] changes file update --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 364ec385d..b45fee280 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-05-28: ZackerySpytz + #1776 Quite dramatically decrease run times when generating very large interface files by changing some internal memory pool sizes. + +2020-05-28: mcfarljm + #1788 Fix handling of Doxygen \endlink command. + 2020-05-24: vapier [JS] #1796 Fix pkg-config invocation in configure. From 3c9dd44ff468356913505ccb071119aabe977727 Mon Sep 17 00:00:00 2001 From: Marcel Steinbeck Date: Fri, 24 Jan 2020 18:08:03 +0100 Subject: [PATCH 1869/2031] D: Replace deprecated imports (package std.c). Fixes #1593 --- Lib/d/wrapperloader.swg | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/d/wrapperloader.swg b/Lib/d/wrapperloader.swg index b3c1d0dcf..67e03bfc8 100644 --- a/Lib/d/wrapperloader.swg +++ b/Lib/d/wrapperloader.swg @@ -40,9 +40,10 @@ private { } else { version(D_Version2) { static import std.conv; + } else { + static import std.c.string; } static import std.string; - static import std.c.string; } version(D_Version2) { @@ -112,7 +113,7 @@ private { version(Tango) { import tango.sys.Common; } else version(linux) { - import std.c.linux.linux; + import core.sys.posix.dlfcn; } else { extern(C) { const RTLD_NOW = 2; From e0d85fc939e0c3ea43f645bde0589f4249fd484a Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 30 Apr 2020 23:40:12 +1000 Subject: [PATCH 1870/2031] configure.ac: fix calls to mkoctfile for Octave configuration - As of Octave 5.1.0, mkoctfile no longer works with 'env -' (no environment), so need to pass at least PATH and LD_LIBRARY_PATH for it to work. - Still need to clear environment so that it doesn't override mkoctfile defined variables, e.g. CXXFLAGS. --- configure.ac | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index fce5b9ee5..91c74b8ec 100644 --- a/configure.ac +++ b/configure.ac @@ -1079,6 +1079,7 @@ if test -n "$OCTAVE"; then fi AC_MSG_RESULT([${mkoctfile}]) AC_MSG_CHECKING([if ${mkoctfile} works]) + mkoctfile="env - PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH ${mkoctfile}" AS_IF([test "x`${mkoctfile} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/mkoctfile, version/p'`" != x],[ AC_MSG_RESULT([yes]) ],[ @@ -1093,7 +1094,7 @@ if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave preprocessor flags]) OCTAVE_CPPFLAGS= for var in CPPFLAGS INCFLAGS ALL_CXXFLAGS; do - for flag in `env - ${mkoctfile} -p ${var}`; do + for flag in `${mkoctfile} -p ${var}`; do case ${flag} in -D*|-I*) OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} ${flag}";; *) ;; @@ -1105,7 +1106,7 @@ if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave compiler flags]) OCTAVE_CXXFLAGS= for var in CXX ALL_CXXFLAGS; do - for flag in `env - ${mkoctfile} -p ${var}`; do + for flag in `${mkoctfile} -p ${var}`; do case ${flag} in -std=*|-g*|-W*) OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} ${flag}";; *) ;; @@ -1125,10 +1126,10 @@ if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= for var in OCTLIBDIR; do - OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "-L`env - ${mkoctfile} -p ${var}` + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "-L`${mkoctfile} -p ${var}` done for var in RDYNAMIC_FLAG RLD_FLAG OCTAVE_LIBS LIBS; do - OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`env - ${mkoctfile} -p ${var}` + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p ${var}` done AC_MSG_RESULT([$OCTAVE_LDFLAGS]) From 30132bf77730addafb6150ecd751b855c05394f3 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 1 May 2020 21:29:41 +1000 Subject: [PATCH 1871/2031] octrun.swg: remove octave_value type-id from octave_swig_bound_func - The {DECLARE|DEFINE}_OV_TYPEID_FUNCTIONS_AND_DATA declarations attached to this class cause a seg-fault in the module_load Octave example. Removing these declarations fixes the seg-fault. - While cause of seg-fault is unknown, note that (in Octave 5.1.0) the declaration of octave_function, which is the base class for octave_swig_bound_func, does not use these declarations. So it's possible they simply are not required for this type of subclass. --- Lib/octave/octrun.swg | 4 ---- Lib/octave/octruntime.swg | 7 ------- 2 files changed, 11 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 325a4cca3..162772d98 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -203,11 +203,7 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); std::set dispatch_classes; - private: - - DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; - DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_swig_bound_func, "octave_swig_bound_func", "octave_swig_bound_func"); #else #define SWIG_OCTAVE_BOUND_FUNC(func, args) octave_value(func) #endif diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index f98bf4fe4..6e07aaa70 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -376,7 +376,6 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { string_vector types = typeinfo.installed_type_names(); bool register_octave_swig_ref = true; bool register_octave_swig_packed = true; - bool register_octave_swig_bound_func = true; for (int i = 0; i < types.numel(); ++i) { if (types(i) == octave_swig_ref::static_type_name()) { register_octave_swig_ref = false; @@ -384,9 +383,6 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { if (types(i) == octave_swig_packed::static_type_name()) { register_octave_swig_packed = false; } - if (types(i) == octave_swig_bound_func::static_type_name()) { - register_octave_swig_bound_func = false; - } } if (register_octave_swig_ref) { octave_swig_ref::register_type(); @@ -394,9 +390,6 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { if (register_octave_swig_packed) { octave_swig_packed::register_type(); } - if (register_octave_swig_bound_func) { - octave_swig_bound_func::register_type(); - } } #else octave_swig_ref::register_type(); From 26423d06b3934b5e584beeca62b56e4a861e45a2 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 1 May 2020 21:19:53 +1000 Subject: [PATCH 1872/2031] octruntime.swg: do not use atexit() to quit Octave - This reverts commit 931656bcbe7c2bf37bb5d831b47fab9a38695e91 - Since atexit() does not pass along the desired exit status, __swig_atexit__() always exits with status zero, regardless of whether Octave completed successfully or raised an error. - This means the success/failure of Octave scripts which load SWIG modules cannot be determined by other programs, which makes them unusable. - Instead, provide a Octave function swig_exit() which calls ::_Exit() with a given exit status. This way at least a clean exit from Octave can be guaranteed for future versions if the seg-fault problem is not fixed. --- Lib/octave/octruntime.swg | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 6e07aaa70..2f0cf58aa 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -315,13 +315,29 @@ DEFUN_DLD( swig_octave_prereq, args, nargout, swig_octave_prereq_usage ) { return octave_value(prereq); } +static const char *const swig_exit_usage = "-*- texinfo -*- \n\ +@deftypefn {Loadable Function} {} swig_exit([@var{exit_status}])\n\ +Exit Octave without performing any memory cleanup.\n\ +@end deftypefn"; + +DEFUN_DLD( swig_exit, args, nargout, swig_exit_usage ) { + if (args.length() > 1) { + error("swig_exit: must be called with at most one arguments"); + return octave_value_list(); + } + int exit_status = 0; + if (args.length() == 1) { + exit_status = args(0).int_value(); + } + ::_Exit(exit_status); + return octave_value(); +} + static const char *const SWIG_name_usage = "-*- texinfo -*- \n\ @deftypefn {Loadable Module} {} " SWIG_name_d "\n\ Loads the SWIG-generated module `" SWIG_name_d "'.\n\ @end deftypefn"; -void __swig_atexit__(void) { ::_Exit(0); } - DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { static octave_swig_type* module_ns = 0; @@ -329,14 +345,15 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { // workaround to prevent octave seg-faulting on exit: set Octave exit function // octave_exit to _Exit, which exits immediately without trying to cleanup memory. // definitely affected version 3.2.*, not sure about 3.3.*, seems to be fixed in - // version 3.4.*, but reappeared in 4.2.*, so turn on for all versions after 3.2.*. + // version 3.4.*, reappeared in 4.2.*, hack not possible in 4.4.* or later due to + // removal of octave_exit, so turn on for all versions between 3.2.*. and 4.4.*. // can be turned off with macro definition. #ifndef SWIG_OCTAVE_NO_SEGFAULT_HACK -#if SWIG_OCTAVE_PREREQ(4,4,0) - atexit(__swig_atexit__); -#elif SWIG_OCTAVE_PREREQ(3,2,0) +#if !SWIG_OCTAVE_PREREQ(4,4,0) +#if SWIG_OCTAVE_PREREQ(3,2,0) octave_exit = ::_Exit; #endif +#endif #endif // check for no input and output args @@ -420,6 +437,9 @@ DEFUN_DLD( SWIG_name, args, nargout, SWIG_name_usage ) { if (!SWIG_Octave_InstallFunction(me, "swig_octave_prereq")) { return octave_value_list(); } + if (!SWIG_Octave_InstallFunction(me, "swig_exit")) { + return octave_value_list(); + } octave_swig_type* cvar_ns=0; if (std::string(SWIG_global_name) != ".") { From 66f4f7de8e5a80d48d6b63b47f6fa75a779da35d Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 30 Apr 2020 23:45:39 +1000 Subject: [PATCH 1873/2031] octave.cxx: replace Printf() with Append() for consistency --- Source/Modules/octave.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 1297d2445..4a4e4c956 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -846,7 +846,7 @@ public: Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } Append(setf->code, "fail:\n"); - Printf(setf->code, "return octave_value_list();\n"); + Append(setf->code, "return octave_value_list();\n"); } else { Printf(setf->code, "return octave_set_immutable(args,nargout);"); } From 99bb5dcc70e504d4671a007e5582c72e09d6d77f Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 30 Apr 2020 23:47:29 +1000 Subject: [PATCH 1874/2031] octave.cxx: remote whitespaces --- Source/Modules/octave.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 4a4e4c956..ca57d3686 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -866,10 +866,10 @@ public: } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t, 0)); } - Append(getf->code, " return obj;\n"); + Append(getf->code, "return obj;\n"); if (addfail) { Append(getf->code, "fail:\n"); - Append(getf->code, " return octave_value_list();\n"); + Append(getf->code, "return octave_value_list();\n"); } Append(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); From f6286a1b19cff2144a1803d39374390f6008bc7f Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 30 Apr 2020 23:48:36 +1000 Subject: [PATCH 1875/2031] octave.cxx: this belongs in the code (as opposed to definition) section --- Source/Modules/octave.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index ca57d3686..8c3928285 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -830,7 +830,7 @@ public: String *setwname = Swig_name_wrapper(setname); Octave_begin_function(n, setf->def, setname, setwname, true); - Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname); + Printf(setf->code, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname); if (is_assignable(n)) { Setattr(n, "wrap:name", setname); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { From e67f12558206c0d69d3cfb297248a49e6d5add4c Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Thu, 30 Apr 2020 23:50:02 +1000 Subject: [PATCH 1876/2031] octave.cxx: add missing return statement before "fail:" label --- Source/Modules/octave.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 8c3928285..5c9bd45d5 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -845,6 +845,7 @@ public: } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } + Append(setf->code, "return octave_value_list();\n"); Append(setf->code, "fail:\n"); Append(setf->code, "return octave_value_list();\n"); } else { From d9c94848ec2e6fd1187fd3e11a6eda0aeb20fa85 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 2 May 2020 03:35:05 +1000 Subject: [PATCH 1877/2031] octave.cxx: fix exception raising for newer Octave versions - Since (at least) Octave 5.1.0, the Octave error() function now raises a C++ exception, which if uncaught immediately exits a SWIG wrapper function, bypassing any cleanup code that may appear after a "fail:" label. - This patch adds a "try { ... } catch(...) { }" block around the contents of SWIG wrapper functions to first execute the cleanup code before rethrowing any exception raised. - It is backward compatible with earlier versions of Octave where error() does not raise an exception, which will still branch to the "fail:" block to execute cleanup code if an error is encountered. --- CHANGES.current | 16 ++++++++++++++++ Source/Modules/octave.cxx | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index b45fee280..3bded39e3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -16,6 +16,22 @@ Version 4.0.2 (in progress) 2020-05-24: vapier [JS] #1796 Fix pkg-config invocation in configure. +2020-04-30: kwwette + [Octave] Fix exception raising for newer Octave versions + Since (at least) Octave 5.1.0, the Octave error() function now raises a C++ exception, + which if uncaught immediately exits a SWIG wrapper function, bypassing any cleanup code + that may appear after a "fail:" label. This patch adds a "try { ... } catch(...) { }" + block around the contents of SWIG wrapper functions to first execute the cleanup code + before rethrowing any exception raised. It is backward compatible with earlier versions + of Octave where error() does not raise an exception, which will still branch to the + "fail:" block to execute cleanup code if an error is encountered. + + Note that the new "try { ... } catch(...) { }" block will localise any local variables + used in typemaps that were NOT declared through SWIG's %typemap(...) syntax, so it's + possible this could break existing SWIG wrappers which were implicitly sharing local + variables between typemaps. This can be fixed, however, by declaring local variables + which need to be shared between typemaps through SWIG's %typemap(...) syntax. + 2020-02-18: ryannevell [Lua] #1728 Add support for LUA lightuserdata to SWIG_Lua_ConvertPtr. diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 5c9bd45d5..b1769e42a 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -567,6 +567,10 @@ public: Wrapper *f = NewWrapper(); Octave_begin_function(n, f->def, iname, overname, !overloaded); + // Start default try block to execute + // cleanup code if exception is thrown + Printf(f->code, "try {\n"); + emit_parameter_variables(l, f); emit_attach_parmmaps(l, f); Setattr(n, "wrap:parms", l); @@ -754,9 +758,20 @@ public: } Printf(f->code, "return _out;\n"); - Printf(f->code, "fail:\n"); // we should free locals etc if this happens + + // Execute cleanup code if branched to fail: label + Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); Printf(f->code, "return octave_value_list();\n"); + + // Execute cleanup code if exception was thrown + Printf(f->code, "}\n"); + Printf(f->code, "catch(...) {\n"); + Printv(f->code, cleanup, NIL); + Printf(f->code, "throw;\n"); + Printf(f->code, "}\n"); + + // End wrapper function Printf(f->code, "}\n"); /* Substitute the cleanup code */ From d8d0466e8d18d3845343986cb52b47ac77515f70 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 29 May 2020 19:19:35 +1000 Subject: [PATCH 1878/2031] Tools/travis-osx-install.sh: use Tools/brew-install to install Octave --- Tools/travis-osx-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 393d96e60..99580384c 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -23,7 +23,7 @@ case "$SWIGLANG" in travis_retry brew install lua ;; "octave") - travis_retry brew install octave + travis_retry Tools/brew-install octave ;; "python") WITHLANG=$SWIGLANG$PY3 From df8bb1feeb200caf718b53168c056ad0e61bb8ab Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 31 May 2020 01:52:42 +1000 Subject: [PATCH 1879/2031] Tools/travis-osx-install.sh: disable 'brew cleanup' to save Travis job run time --- Tools/travis-osx-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 99580384c..71d2b2dd0 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -4,6 +4,9 @@ set -e # exit on failure (same as -o errexit) +# Disable 'brew cleanup', just wastes Travis job run time +export HOMEBREW_NO_INSTALL_CLEANUP=1 + sw_vers travis_retry brew update travis_retry brew list From d11e29615d43a5962129724b4097422282ebd8fa Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Fri, 29 May 2020 17:05:01 +1000 Subject: [PATCH 1880/2031] Octave: use pre-compiled headers to speed up test suite, if supported --- .gitignore | 2 + Examples/Makefile.in | 33 ++++++- Examples/octave/example.mk | 12 +-- Examples/test-suite/octave/Makefile.in | 18 ++++ Lib/octave/director.swg | 2 - Lib/octave/extra-install.list | 2 + Lib/octave/octcontainer.swg | 7 -- Lib/octave/octheaders.hpp | 130 +++++++++++++++++++++++++ Lib/octave/octrun.swg | 4 - Lib/octave/octruntime.swg | 111 +-------------------- Lib/octave/std_complex.i | 4 - configure.ac | 33 +++++++ 12 files changed, 225 insertions(+), 133 deletions(-) create mode 100644 Lib/octave/extra-install.list create mode 100644 Lib/octave/octheaders.hpp diff --git a/.gitignore b/.gitignore index 1f1561475..5df510547 100644 --- a/.gitignore +++ b/.gitignore @@ -173,6 +173,8 @@ Examples/ocaml/**/swigp4.ml # Octave swigexample*.oct Examples/test-suite/octave/*.oct +Examples/test-suite/octave/octheaders.hpp +Examples/test-suite/octave/octheaders.hpp.gch # Perl5 Examples/test-suite/perl5/*.pm diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6fbca29db..87386f7eb 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -58,6 +58,7 @@ INTERFACE = INTERFACEDIR = INTERFACEPATH = $(SRCDIR)$(INTERFACEDIR)$(INTERFACE) SWIGOPT = +PCHSUPPORT = @PCHSUPPORT@ # SWIG_LIB_DIR and SWIGEXE must be explicitly set by Makefiles using this Makefile SWIG_LIB_DIR = ./Lib @@ -438,14 +439,37 @@ OCTAVE_SO = @OCTAVE_SO@ OCTAVE_SCRIPT = $(SRCDIR)$(RUNME).m +# ---------------------------------------------------------------- +# Pre-compile Octave headers, if supported +# ---------------------------------------------------------------- + +ifeq (yes,$(PCHSUPPORT)) + +octave_precompile_headers: + echo "precompiling $(OCTHEADERS)" + cp -f $(OCTHEADERSSRC) $(OCTHEADERS) + if $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(OCTAVE_CXX) $(OCTHEADERS); then \ + : ; \ + else \ + rm -f $(OCTHEADERSGCH); \ + exit 1; \ + fi + +else + +octave_precompile_headers: + echo "precompiling Octave headers not supported"; exit 1 + +endif + # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers # ---------------------------------------------------------------- octave: $(SRCDIR_SRCS) - $(SWIG) -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX) + $(SWIG) -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) + $(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CC) -g -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -454,8 +478,8 @@ octave: $(SRCDIR_SRCS) # ----------------------------------------------------------------- octave_cpp: $(SRCDIR_SRCS) - $(SWIG) -c++ -octave $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) - $(CXX) -g -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX) + $(SWIG) -c++ -octave $(SWIGOCTHDROPT) $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH) + $(CXX) -g -c $(IOCTHEADERS) $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CXXSHARED) -g $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- @@ -481,6 +505,7 @@ octave_clean: rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *$(OCTAVE_SO) + rm -f $(OCTHEADERS) $(OCTHEADERSGCH) ################################################################## ##### GUILE ###### diff --git a/Examples/octave/example.mk b/Examples/octave/example.mk index 1ab96f038..88608a12b 100644 --- a/Examples/octave/example.mk +++ b/Examples/octave/example.mk @@ -8,25 +8,25 @@ TARGET = swigexample INTERFACE = example.i check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_run + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_run build: ifneq (,$(SRCS)) - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave else - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave_cpp endif ifneq (,$(TARGET2)$(SWIGOPT2)) ifneq (,$(SRCS)) - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave else - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ SWIGOPT='$(SWIGOPT2)' TARGET='$(TARGET2)' INTERFACE='$(INTERFACE)' octave_cpp endif @@ -34,4 +34,4 @@ endif clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' octave_clean + $(MAKE) -f $(TOP)/Makefile PCHSUPPORT=no SRCDIR='$(SRCDIR)' octave_clean diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 3c8f3b165..1d54a47bb 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -5,6 +5,7 @@ LANGUAGE = octave OCTAVE = @OCTAVE@ SCRIPTSUFFIX = _runme.m +PCHSUPPORT = @PCHSUPPORT@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ @@ -61,6 +62,23 @@ CSRCS = octave_empty.c +$(swig_and_compile_multi_cpp) $(run_testcase) +# Pre-compile Octave headers, if supported + +ifeq (yes,$(PCHSUPPORT)) + +export OCTHEADERSSRC = @top_srcdir@/Lib/octave/octheaders.hpp +export OCTHEADERS = @top_builddir@/Examples/test-suite/octave/octheaders.hpp +export OCTHEADERSGCH = $(OCTHEADERS).gch +export SWIGOCTHDROPT = -DSWIG_OCTAVE_EXTERNAL_OCTHEADERS +export IOCTHEADERS = -I@top_builddir@/Examples/test-suite/octave @PCHINCLUDEARG@ $(OCTHEADERS)@PCHINCLUDEEXT@ + +$(OCTHEADERSGCH): $(OCTHEADERSSRC) + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile octave_precompile_headers + +$(NOT_BROKEN_TEST_CASES) $(BROKEN_TEST_CASES): $(OCTHEADERSGCH) + +endif + # Runs the testcase. A testcase is only run if # a file is found which has _runme.m appended after the testcase name. run_testcase = \ diff --git a/Lib/octave/director.swg b/Lib/octave/director.swg index bf71d18e8..5b9cd86e0 100644 --- a/Lib/octave/director.swg +++ b/Lib/octave/director.swg @@ -7,8 +7,6 @@ # define SWIG_DIRECTOR_CAST(ARG) dynamic_cast(ARG) -#include - namespace Swig { class Director { diff --git a/Lib/octave/extra-install.list b/Lib/octave/extra-install.list new file mode 100644 index 000000000..41ef94778 --- /dev/null +++ b/Lib/octave/extra-install.list @@ -0,0 +1,2 @@ +# see top-level Makefile.in +octheaders.hpp diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index 310a849d9..80d593f4f 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -11,12 +11,6 @@ * be the case. * ----------------------------------------------------------------------------- */ -%{ -#include -#include -%} - - #if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS) # if !defined(SWIG_EXPORT_ITERATOR_METHODS) # define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS @@ -64,7 +58,6 @@ namespace swig { %fragment("OctSequence_Base","header",fragment="") { -%#include namespace std { template <> diff --git a/Lib/octave/octheaders.hpp b/Lib/octave/octheaders.hpp new file mode 100644 index 000000000..abf6428e7 --- /dev/null +++ b/Lib/octave/octheaders.hpp @@ -0,0 +1,130 @@ +// +// This header includes all C++ headers required for generated Octave wrapper code. +// Using a single header file allows pre-compilation of Octave headers, as follows: +// * Check out this header file: +// swig -octave -co octheaders.hpp +// * Pre-compile header file into octheaders.hpp.gch: +// g++ -c ... octheaders.hpp +// * Use pre-compiled header file: +// g++ -c -include octheaders.hpp ... +// + +#if !defined(_SWIG_OCTAVE_OCTHEADERS_HPP) +#define _SWIG_OCTAVE_OCTHEADERS_HPP + +// Required C++ headers +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Minimal headers to define Octave version +#include +#include + +// Macro for enabling features which require Octave version >= major.minor.patch +// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '' (released) and '+' (in development) patch numbers +#define SWIG_OCTAVE_PREREQ(major, minor, patch) \ + ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) ) + +// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1 +#if !defined(OCTAVE_MAJOR_VERSION) + +# if !defined(OCTAVE_API_VERSION_NUMBER) + +// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet +// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER +# include +# if defined(octave_ov_h) +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 8 +# define OCTAVE_PATCH_VERSION 0 +# else + +// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed +# define ComplexLU __ignore +# include +# undef ComplexLU +# if defined(octave_Complex_LU_h) + +// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 1 +# define OCTAVE_PATCH_VERSION 99 + +# else + +// OCTAVE_API_VERSION_NUMBER == 37 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 2 +# define OCTAVE_PATCH_VERSION 0 + +# endif // defined(octave_Complex_LU_h) + +# endif // defined(octave_ov_h) + +// Correlation between Octave API and version numbers extracted from Octave's +// ChangeLogs; version is the *earliest* released Octave with that API number +# elif OCTAVE_API_VERSION_NUMBER >= 48 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 6 +# define OCTAVE_PATCH_VERSION 0 + +# elif OCTAVE_API_VERSION_NUMBER >= 45 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 4 +# define OCTAVE_PATCH_VERSION 1 + +# elif OCTAVE_API_VERSION_NUMBER >= 42 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 3 +# define OCTAVE_PATCH_VERSION 54 + +# elif OCTAVE_API_VERSION_NUMBER >= 41 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 3 +# define OCTAVE_PATCH_VERSION 53 + +# elif OCTAVE_API_VERSION_NUMBER >= 40 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 3 +# define OCTAVE_PATCH_VERSION 52 + +# elif OCTAVE_API_VERSION_NUMBER >= 39 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 3 +# define OCTAVE_PATCH_VERSION 51 + +# else // OCTAVE_API_VERSION_NUMBER == 38 +# define OCTAVE_MAJOR_VERSION 3 +# define OCTAVE_MINOR_VERSION 3 +# define OCTAVE_PATCH_VERSION 50 + +# endif // !defined(OCTAVE_API_VERSION_NUMBER) + +#endif // !defined(OCTAVE_MAJOR_VERSION) + +// Required Octave headers +#include +#include +#include +#include +#include +#include +#include +#if SWIG_OCTAVE_PREREQ(4,2,0) +#include +#else +#include +#endif +#include +#if SWIG_OCTAVE_PREREQ(4,2,0) +#include +#endif + +#endif // !defined(_SWIG_OCTAVE_OCTHEADERS_HPP) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 162772d98..944b72a63 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -89,10 +89,6 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point // Runtime API implementation -#include -#include -#include - typedef octave_value_list(*octave_func) (const octave_value_list &, int); class octave_swig_type; diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 2f0cf58aa..a397fb7c1 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -1,111 +1,10 @@ +#ifdef SWIG_OCTAVE_EXTERNAL_OCTHEADERS %insert(runtime) %{ - -#include -#include - -#include -#include - -// Macro for enabling features which require Octave version >= major.minor.patch -// - Use (OCTAVE_PATCH_VERSION + 0) to handle both '' (released) and '+' (in development) patch numbers -#define SWIG_OCTAVE_PREREQ(major, minor, patch) \ - ( (OCTAVE_MAJOR_VERSION<<16) + (OCTAVE_MINOR_VERSION<<8) + (OCTAVE_PATCH_VERSION + 0) >= ((major)<<16) + ((minor)<<8) + (patch) ) - -// Reconstruct Octave major, minor, and patch versions for releases prior to 3.8.1 -#if !defined(OCTAVE_MAJOR_VERSION) - -# if !defined(OCTAVE_API_VERSION_NUMBER) - -// Hack to distinguish between Octave 3.8.0, which removed OCTAVE_API_VERSION_NUMBER but did not yet -// introduce OCTAVE_MAJOR_VERSION, and Octave <= 3.2, which did not define OCTAVE_API_VERSION_NUMBER -# include -# if defined(octave_ov_h) -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 8 -# define OCTAVE_PATCH_VERSION 0 -# else - -// Hack to distinguish between Octave 3.2 and earlier versions, before OCTAVE_API_VERSION_NUMBER existed -# define ComplexLU __ignore -# include -# undef ComplexLU -# if defined(octave_Complex_LU_h) - -// We know only that this version is prior to Octave 3.2, i.e. OCTAVE_API_VERSION_NUMBER < 37 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 1 -# define OCTAVE_PATCH_VERSION 99 - -# else - -// OCTAVE_API_VERSION_NUMBER == 37 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 2 -# define OCTAVE_PATCH_VERSION 0 - -# endif // defined(octave_Complex_LU_h) - -# endif // defined(octave_ov_h) - -// Correlation between Octave API and version numbers extracted from Octave's -// ChangeLogs; version is the *earliest* released Octave with that API number -# elif OCTAVE_API_VERSION_NUMBER >= 48 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 6 -# define OCTAVE_PATCH_VERSION 0 - -# elif OCTAVE_API_VERSION_NUMBER >= 45 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 4 -# define OCTAVE_PATCH_VERSION 1 - -# elif OCTAVE_API_VERSION_NUMBER >= 42 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 3 -# define OCTAVE_PATCH_VERSION 54 - -# elif OCTAVE_API_VERSION_NUMBER >= 41 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 3 -# define OCTAVE_PATCH_VERSION 53 - -# elif OCTAVE_API_VERSION_NUMBER >= 40 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 3 -# define OCTAVE_PATCH_VERSION 52 - -# elif OCTAVE_API_VERSION_NUMBER >= 39 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 3 -# define OCTAVE_PATCH_VERSION 51 - -# else // OCTAVE_API_VERSION_NUMBER == 38 -# define OCTAVE_MAJOR_VERSION 3 -# define OCTAVE_MINOR_VERSION 3 -# define OCTAVE_PATCH_VERSION 50 - -# endif // !defined(OCTAVE_API_VERSION_NUMBER) - -#endif // !defined(OCTAVE_MAJOR_VERSION) - -#include -#include -#include -#include -#include -#include -#include -#if SWIG_OCTAVE_PREREQ(4,2,0) -#include -#else -#include -#endif -#include -#if SWIG_OCTAVE_PREREQ(4,2,0) -#include -#endif - +#include "octheaders.hpp" %} +#else +%insert(runtime) "octheaders.hpp"; +#endif %insert(runtime) "swigrun.swg"; %insert(runtime) "swigerrors.swg"; diff --git a/Lib/octave/std_complex.i b/Lib/octave/std_complex.i index 30c188244..461e2fdfc 100644 --- a/Lib/octave/std_complex.i +++ b/Lib/octave/std_complex.i @@ -4,10 +4,6 @@ %include -%{ -#include -%} - namespace std { %naturalvar complex; template class complex; diff --git a/configure.ac b/configure.ac index 91c74b8ec..336460889 100644 --- a/configure.ac +++ b/configure.ac @@ -333,6 +333,39 @@ case $host in *) ;; esac +# Check for compiler pre-compiled header support +AC_MSG_CHECKING([if compiler supports pre-compiled headers]) +PCHSUPPORT=no +if test "$CLANGXX" = "yes"; then + PCHINCLUDEARG="-include-pch" + PCHINCLUDEEXT=".gch" +else + PCHINCLUDEARG="-include" + PCHINCLUDEEXT="" +fi +AC_LANG_PUSH([C++]) +echo '#include ' > conftest.hpp +echo '#include "conftest.hpp"' > conftest.cpp +$CXX -c conftest.hpp 2>/dev/null +if test $? -eq 0; then + if test -f conftest.hpp.gch; then + $CXX -H -c -I. ${PCHINCLUDEARG} ./conftest.hpp${PCHINCLUDEEXT} -o conftest.o conftest.cpp >conftest.out 2>&1 + if test $? -eq 0; then + if test "$CLANGXX" = "yes"; then + PCHSUPPORT=yes + elif grep -q '^!.*conftest.hpp.gch$' conftest.out; then + PCHSUPPORT=yes + fi + fi + fi +fi +rm -f conftest.hpp conftest.cpp conftest.out +AC_LANG_POP([C++]) +AC_MSG_RESULT([$PCHSUPPORT]) +AC_SUBST(PCHSUPPORT) +AC_SUBST(PCHINCLUDEARG) +AC_SUBST(PCHINCLUDEEXT) + # Set info about shared libraries. AC_SUBST(SO) AC_SUBST(LDSHARED) From f11e25f3f6ac9a81426f7f7bfb015d3e0ce31d08 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sat, 30 May 2020 18:18:43 +1000 Subject: [PATCH 1881/2031] .travis.yml: add Octave test on Ubuntu Bionic --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cedce513d..e9a0abec3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -146,7 +146,12 @@ matrix: os: linux env: SWIGLANG=octave SWIGJOBS=-j2 sudo: required - dist: xenial + dist: xenial # Octave v4.0.0 + - compiler: gcc + os: linux + env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 + sudo: required + dist: bionic # Octave v4.2.2 - compiler: gcc os: linux env: SWIGLANG=perl5 From 77c0fdaa79629362165cd19660186594b541e32b Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 31 May 2020 10:43:11 +1000 Subject: [PATCH 1882/2031] .travis.yml: require Octave build on OSX to pass --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index e9a0abec3..ee6dfe268 100644 --- a/.travis.yml +++ b/.travis.yml @@ -480,10 +480,6 @@ matrix: env: SWIGLANG=php VER=7.2 sudo: required dist: xenial - # Sometimes hits the Travis 50 minute time limit - - compiler: clang - os: osx - env: SWIGLANG=octave SWIGJOBS=-j2 # Experimental languages - compiler: gcc os: linux From cec09a7e6e6b0d27a7639ef76acea5813f7a70fd Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 31 May 2020 00:34:18 +1000 Subject: [PATCH 1883/2031] .travis.yml: build Octave on OSX with CPP=11 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ee6dfe268..385e7be42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -442,7 +442,7 @@ matrix: env: SWIGLANG=lua - compiler: clang os: osx - env: SWIGLANG=octave SWIGJOBS=-j2 + env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 - compiler: clang os: osx env: SWIGLANG=perl5 From d73ef20475ac77e5f0fe4f641759e4bebcdc2428 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 31 May 2020 10:26:15 +1000 Subject: [PATCH 1884/2031] octrun.swg: ensure type_id() is set correctly --- Lib/octave/octrun.swg | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 944b72a63..1069e0e54 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1058,7 +1058,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); octave_swig_type *ptr; public: octave_swig_ref(octave_swig_type *_ptr = 0) - :ptr(_ptr) { } + :ptr(_ptr) + { + // Ensure type_id() is set correctly + if (t_id == -1) { + t_id = octave_swig_ref::static_type_id(); + } + } ~octave_swig_ref() { if (ptr) ptr->decref(); } @@ -1199,8 +1205,13 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own); public: octave_swig_packed(swig_type_info *_type = 0, const void *_buf = 0, size_t _buf_len = 0) - : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) { - } + : type(_type), buf((const char*)_buf, (const char*)_buf + _buf_len) + { + // Ensure type_id() is set correctly + if (t_id == -1) { + t_id = octave_swig_packed::static_type_id(); + } + } bool copy(swig_type_info *outtype, void *ptr, size_t sz) const { if (outtype && outtype != type) From 6542d848dce1911d33a8640c267554d17645e59f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Jun 2020 10:16:18 +0100 Subject: [PATCH 1885/2031] Fix further missing semicolons in R code. Fixes errors in R code when using -small as this option causes lines to be joined. --- Examples/test-suite/r_memory_leak.i | 2 +- Source/Modules/r.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/r_memory_leak.i b/Examples/test-suite/r_memory_leak.i index d490de535..a240097e3 100644 --- a/Examples/test-suite/r_memory_leak.i +++ b/Examples/test-suite/r_memory_leak.i @@ -17,7 +17,7 @@ SWIG_exception_fail(SWIG_RuntimeError, "Let's see how the bindings manage this exception!"); } %typemap(scoerceout) Foo* - %{ if (!is.null($result) && !is.logical($result)) {$result <- new("$R_class", ref=$result) ;} %} + %{ if (!is.null($result) && !is.logical($result)) {$result <- new("$R_class", ref=$result) ;}; %} %inline %{ #include diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 16c4d22d9..3e3c23e44 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1898,7 +1898,7 @@ int R::functionWrapper(Node *n) { name, " = getNativeSymbolInfo(", name, ");", "\n};\n", "if(is(", name, ", \"NativeSymbolInfo\")) {\n", - name, " = ", name, "$address", ";\n}\n", + name, " = ", name, "$address", ";\n};\n", "if(is(", name, ", \"ExternalReference\")) {\n", name, " = ", name, "@ref;\n}\n", "}; \n", From ac3f668c8322a89720ae277ce03ba2fb9e9a5f65 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 31 May 2020 15:03:20 +0100 Subject: [PATCH 1886/2031] Minor configure.ac output display correction testing for octave --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 336460889..44e715db4 100644 --- a/configure.ac +++ b/configure.ac @@ -1091,7 +1091,7 @@ if test -n "$OCTAVE"; then AS_IF([test "x`${OCTAVE} --version 2>/dev/null | sed -n -e '1p' | sed -n -e '/Octave, version/p'`" != x],[ AC_MSG_RESULT([yes]) ],[ - AC_MSG_NOTICE([no]) + AC_MSG_RESULT([no]) OCTAVE= ]) fi From 3867639897aad9fb2c48dc84ddab47c9c8206689 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Jun 2020 23:24:56 +0100 Subject: [PATCH 1887/2031] Travis ruby s390x (big endian) architecture testing Currently failing on this architecture. Add s390x testing for Ruby c++11 Xenial rather than replace AMD Ruby C++11 Xenial testing. --- .travis.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 98a1b6319..4aac0e773 100644 --- a/.travis.yml +++ b/.travis.yml @@ -351,7 +351,6 @@ matrix: sudo: required dist: xenial - os: linux - arch: s390x env: SWIGLANG=ruby CPP11=1 sudo: required dist: xenial @@ -415,6 +414,11 @@ matrix: env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.8 sudo: required dist: xenial + - os: linux + arch: s390x + env: SWIGLANG=ruby CPP11=1 + sudo: required + dist: xenial - compiler: gcc os: osx env: SWIGLANG= @@ -464,6 +468,12 @@ matrix: osx_image: xcode10.2 allow_failures: + # li_std_wstring failure see https://github.com/swig/swig/pull/1803 + - os: linux + arch: s390x + env: SWIGLANG=ruby CPP11=1 + sudo: required + dist: xenial # Newer version of D not yet working/supported - compiler: gcc os: linux From 9da2e4f5d45e5c92f6c3383dbdf81705a251c2ca Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Mon, 1 Jun 2020 09:24:40 -0700 Subject: [PATCH 1888/2031] Replace `-isystem` compile flag with `-I` Using `-isystem` flag causes compilation errors with GCC10. Replace it with `-I` flag. Fixes #1805 Signed-off-by: Anatol Pomozov --- configure.ac | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 44e715db4..22e3672c3 100644 --- a/configure.ac +++ b/configure.ac @@ -115,15 +115,6 @@ dnl Some test cases require Boost AX_BOOST_BASE(,,,) AC_SUBST(BOOST_CPPFLAGS) -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 - ISYSTEM="-isystem " -else - ISYSTEM="-I" -fi -AC_MSG_NOTICE(ISYSTEM: $ISYSTEM) - dnl Info for building shared libraries ... in order to run the examples # SO is the extension of shared libraries (including the dot!) @@ -484,7 +475,7 @@ AC_ARG_WITH(tcl, [ --with-tcl=path Set location of Tcl package],[ TCLPACKAGE="$withval"], [TCLPACKAGE="$alllang_default"]) AC_ARG_WITH(tclincl,[ --with-tclincl=path Set location of Tcl include directory],[ - TCLINCLUDE="$ISYSTEM$withval"], [TCLINCLUDE=]) + TCLINCLUDE="-I$withval"], [TCLINCLUDE=]) AC_ARG_WITH(tcllib,[ --with-tcllib=path Set location of Tcl library directory],[ TCLLIB="-L$withval"], [TCLLIB=]) @@ -526,7 +517,7 @@ else AC_MSG_RESULT(found $TCLCONFIG/tclConfig.sh) . $TCLCONFIG/tclConfig.sh if test -z "$TCLINCLUDE"; then - TCLINCLUDE=`echo $TCL_INCLUDE_SPEC | sed "s/-I/$ISYSTEM/"` + TCLINCLUDE=`echo $TCL_INCLUDE_SPEC` fi if test -z "$TCLLIB"; then TCLLIB=$TCL_LIB_SPEC @@ -535,7 +526,7 @@ fi if test -z "$TCLINCLUDE"; then if test "x$TCLPACKAGE" != xyes; then - TCLINCLUDE="$ISYSTEM$TCLPACKAGE/include" + TCLINCLUDE="-I$TCLPACKAGE/include" fi fi @@ -553,7 +544,7 @@ if test -z "$TCLINCLUDE"; then for i in $dirs ; do if test -r $i/tcl.h; then AC_MSG_RESULT($i) - TCLINCLUDE="$ISYSTEM$i" + TCLINCLUDE="-I$i" break fi done @@ -1004,7 +995,7 @@ if test -n "$PERL"; then AC_MSG_RESULT($PERL5LIB) fi AC_MSG_CHECKING(for Perl5 ccflags) - PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//" | sed "s/-I/$ISYSTEM/") 2>/dev/null` + PERL5CCFLAGS=`($PERL -e 'use Config; print $Config{ccflags}, "\n"' | sed "s/-Wdeclaration-after-statement//") 2>/dev/null` if test -z "$PERL5CCFLAGS" ; then AC_MSG_RESULT(not found) else @@ -2326,7 +2317,7 @@ if test "$LUABIN"; then # look for the header files & set LUAFLAGS accordingly # will clear LUABIN if not present if test -n "$LUAINCLUDE"; then - AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="$ISYSTEM$LUAINCLUDE"],[LUABIN=]) + AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="-I$LUAINCLUDE"],[LUABIN=]) else LUA_OK="1" CFLAGS_SAVED=$CFLAGS @@ -2350,7 +2341,7 @@ if test "$LUABIN"; then #echo "$i" if test -r $i/lua.h; then AC_MSG_RESULT($i/lua.h) - LUAFLAGS="$ISYSTEM$i" + LUAFLAGS="-I$i" break fi done From 3cc4d76e239997a47753d0250405648d1df75a03 Mon Sep 17 00:00:00 2001 From: Noah Stegmaier Date: Thu, 4 Jun 2020 11:45:52 +0200 Subject: [PATCH 1889/2031] escape filepaths --- Source/Modules/main.cxx | 2 +- Source/Swig/misc.c | 13 +++++++++++++ Source/Swig/swig.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 72b765b40..4dce5d953 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1154,7 +1154,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { use_file = 0; } if (use_file) { - Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + Printf(f_dependencies_file, "\\\n %s ", Swig_filename_escape_space(Getitem(files, i))); if (depend_phony) Append(phony_targets, Getitem(files, i)); } diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 7b818478f..ef6fcc02f 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -249,6 +249,19 @@ String *Swig_filename_escape(String *filename) { return adjusted_filename; } +/* ----------------------------------------------------------------------------- + * Swig_filename_escape() + * + * Escapes spaces in filename - for Makefiles + * ----------------------------------------------------------------------------- */ + +String *Swig_filename_escape_space(String *filename) { + String *adjusted_filename = Copy(filename); + Swig_filename_correct(adjusted_filename); + Replaceall(adjusted_filename, " ", "\\ "); + return adjusted_filename; +} + /* ----------------------------------------------------------------------------- * Swig_filename_unescape() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index e0783dae1..76691269e 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -315,6 +315,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory); extern void Swig_filename_correct(String *filename); extern String *Swig_filename_escape(String *filename); + extern String *Swig_filename_escape_space(String *filename); extern void Swig_filename_unescape(String *filename); extern int Swig_storage_isextern(Node *n); extern int Swig_storage_isexternc(Node *n); From d723f821603afc8201c6a5b306577461c0671a2b Mon Sep 17 00:00:00 2001 From: Noah Stegmaier Date: Thu, 4 Jun 2020 12:01:46 +0200 Subject: [PATCH 1890/2031] escape path of generated file --- Source/Modules/main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 4dce5d953..d15f86942 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1143,7 +1143,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { if (dependencies_target) { Printf(f_dependencies_file, "%s: ", dependencies_target); } else { - Printf(f_dependencies_file, "%s: ", outfile); + Printf(f_dependencies_file, "%s: ", Swig_filename_escape_space(outfile)); } List *files = Preprocessor_depend(); List *phony_targets = NewList(); From e22419473536e803e49cc5f5caa6ba37eb733a4d Mon Sep 17 00:00:00 2001 From: Noah Stegmaier Date: Thu, 4 Jun 2020 12:17:51 +0200 Subject: [PATCH 1891/2031] escape target name --- Source/Modules/main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index d15f86942..273bd3632 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1141,7 +1141,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { } else f_dependencies_file = stdout; if (dependencies_target) { - Printf(f_dependencies_file, "%s: ", dependencies_target); + Printf(f_dependencies_file, "%s: ", Swig_filename_escape_space(dependencies_target)); } else { Printf(f_dependencies_file, "%s: ", Swig_filename_escape_space(outfile)); } From cf7802c5cc058b620b0fcd67a01cd2480a4ee1ba Mon Sep 17 00:00:00 2001 From: Noah Stegmaier Date: Fri, 22 May 2020 16:56:19 +0200 Subject: [PATCH 1892/2031] escape phony targets as well --- Source/Modules/main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 273bd3632..d8f2ab6b4 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1162,7 +1162,7 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { Printf(f_dependencies_file, "\n"); if (depend_phony) { for (int i = 0; i < Len(phony_targets); i++) { - Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i)); + Printf(f_dependencies_file, "\n%s:\n", Swig_filename_escape_space(Getitem(phony_targets, i))); } } From 4e57c5536d165db868a6cb0ba7d1518ca5955f45 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Fri, 5 Jun 2020 10:25:20 -0600 Subject: [PATCH 1893/2031] Fix wrapping of virtual comparison operators with directors Closes #1642. --- Examples/test-suite/common.mk | 1 + .../test-suite/director_comparison_operators.i | 16 ++++++++++++++++ .../director_comparison_operators_runme.py | 11 +++++++++++ Source/Modules/directors.cxx | 4 ---- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/director_comparison_operators.i create mode 100644 Examples/test-suite/python/director_comparison_operators_runme.py diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index e77f09c86..55cbd2cce 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -184,6 +184,7 @@ CPP_TEST_CASES += \ director_classes \ director_classic \ director_constructor \ + director_comparison_operators \ director_conversion_operators \ director_default \ director_detect \ diff --git a/Examples/test-suite/director_comparison_operators.i b/Examples/test-suite/director_comparison_operators.i new file mode 100644 index 000000000..9577847e1 --- /dev/null +++ b/Examples/test-suite/director_comparison_operators.i @@ -0,0 +1,16 @@ +%module(directors="1") director_comparison_operators + +%include "std_string.i" +%feature("director"); + +%inline %{ +class Foo { +public: + virtual ~Foo() { } + virtual bool operator==(const Foo&) const = 0; + virtual bool operator>=(const Foo&) const = 0; + virtual bool operator<=(const Foo&) const = 0; + virtual bool operator!=(const Foo&) const = 0; + virtual std::string test(const char *foo="a=1,b=2") { return foo; } +}; +%} diff --git a/Examples/test-suite/python/director_comparison_operators_runme.py b/Examples/test-suite/python/director_comparison_operators_runme.py new file mode 100644 index 000000000..4fe733098 --- /dev/null +++ b/Examples/test-suite/python/director_comparison_operators_runme.py @@ -0,0 +1,11 @@ +import director_comparison_operators + + +class PyFoo(director_comparison_operators.Foo): + pass + + +a = PyFoo() + +if a.test() != "a=1,b=2": + raise RuntimeError, a.test() diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index a91d5fd9a..3504b2c49 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -175,10 +175,6 @@ String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_Strin if (qualifiers) Printv(result, " ", qualifiers, NIL); - // Reformat result to how it has been historically - Replaceall(result, ",", ", "); - Replaceall(result, "=", " = "); - Delete(args_string); Delete(popped_decl); Delete(qualifiers); From 58ffbe616fca22d815d17099b519097290735c89 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 25 May 2020 10:29:41 +0200 Subject: [PATCH 1894/2031] Ruby wstring - only include endian.h on linux This file is not always available on other systems. See #1801 --- Lib/ruby/std_wstring.i | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/ruby/std_wstring.i b/Lib/ruby/std_wstring.i index 2b633438e..c5d168a0a 100644 --- a/Lib/ruby/std_wstring.i +++ b/Lib/ruby/std_wstring.i @@ -1,4 +1,15 @@ %{ +#if defined(__linux__) +#include +#if BYTE_ORDER == LITTLE_ENDIAN +#define SWIG_RUBY_ENDIAN "LE" +#elif BYTE_ORDER == BIG_ENDIAN +#define SWIG_RUBY_ENDIAN "BE" +#endif +#else +#define SWIG_RUBY_ENDIAN "LE" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -15,9 +26,9 @@ extern "C" { #ifndef SWIG_RUBY_WSTRING_ENCODING #if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff -#define SWIG_RUBY_WSTRING_ENCODING "UTF-16LE" +#define SWIG_RUBY_WSTRING_ENCODING "UTF-16" SWIG_RUBY_ENDIAN #elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff -#define SWIG_RUBY_WSTRING_ENCODING "UTF-32LE" +#define SWIG_RUBY_WSTRING_ENCODING "UTF-32" SWIG_RUBY_ENDIAN #else #error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given. #endif From 6275af60a7586508ccf2a12378a08bfb7c40b26d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Jun 2020 08:46:09 +0100 Subject: [PATCH 1895/2031] Ruby s390x now working on Travis --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d13bd9b5d..b806c85e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -473,12 +473,6 @@ matrix: osx_image: xcode10.2 allow_failures: - # li_std_wstring failure see https://github.com/swig/swig/pull/1803 - - os: linux - arch: s390x - env: SWIGLANG=ruby CPP11=1 - sudo: required - dist: xenial # Newer version of D not yet working/supported - compiler: gcc os: linux From ba0154d90a0e4783675e4ecc582cc345903c323c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Jun 2020 10:29:41 +0100 Subject: [PATCH 1896/2031] Fix node 6 and 8 testing on Travis Later versions of node-gyp (7.0.0) being installed by npm don't seem to work with node 6 and 8. --- Tools/travis-linux-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tools/travis-linux-install.sh b/Tools/travis-linux-install.sh index d5157086f..e25b85f04 100755 --- a/Tools/travis-linux-install.sh +++ b/Tools/travis-linux-install.sh @@ -39,9 +39,11 @@ case "$SWIGLANG" in [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" travis_retry nvm install ${VER} nvm use ${VER} - if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] || [ "$VER" == "4" ] ; then + if [ "$VER" == "0.10" ] || [ "$VER" == "0.12" ] || [ "$VER" == "4" ] || [ "$VER" == "6" ] ; then # travis_retry sudo apt-get install -qq nodejs node-gyp travis_retry npm install -g node-gyp@$VER + elif [ "$VER" == "8" ] ; then + travis_retry npm install -g node-gyp@6 else travis_retry npm install -g node-gyp fi From a70998889be5a69ebd8258147d42fafa2da3da41 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 7 Jun 2020 11:32:16 +0100 Subject: [PATCH 1897/2031] Changes file updates --- CHANGES.current | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 3bded39e3..f64b6e48b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,8 +7,30 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.2 (in progress) =========================== +2020-06-07 vigsterkr + [Ruby] #1717 Nil fix mangling strings + +2020-06-07 vadz + #1748 Fix doxygen comments quoting issue + +2020-06-07 munoah + #1800 Escape spaces in file paths for dependencies (-M -MM etc) + +2020-06-06 andreas-schwab + [Ruby] #1801 Fix encoding on big endian systems when wrapping std::wstring. + +2020-05-31 kwwette + [Octave] #1789 error handling improvements and return error code on exit for SWIG wrapped modules. + +2020-05-30 msteinbeck + [D] #1593 Replace broken imports when using newer versions of D. + +2020-05-29: ZackerySpytz + [Python] #1716 Performance improvements converting strings when using Python >= 3.3. + 2020-05-28: ZackerySpytz - #1776 Quite dramatically decrease run times when generating very large interface files by changing some internal memory pool sizes. + #1776 Quite dramatically decrease run times when generating very large interface files by changing + some internal memory pool sizes. 2020-05-28: mcfarljm #1788 Fix handling of Doxygen \endlink command. From 8041bfdf0956444e72c68fdf8f5b87d6ec5f2925 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 7 Jun 2020 17:59:21 +0100 Subject: [PATCH 1898/2031] Ruby testcase fix Reportedly failing. Failure can be replicated with 2.5.1 by increasing number of loops. Workaround is to disable GC. Closes #1646 --- Examples/test-suite/ruby/newobject2_runme.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/ruby/newobject2_runme.rb b/Examples/test-suite/ruby/newobject2_runme.rb index 04129f4aa..b7ebea097 100644 --- a/Examples/test-suite/ruby/newobject2_runme.rb +++ b/Examples/test-suite/ruby/newobject2_runme.rb @@ -18,10 +18,12 @@ require 'newobject2' include Newobject2 GC.track_class = Foo +GC.disable GC.stats if $VERBOSE 100.times { foo1 = makeFoo } GC.stats if $VERBOSE swig_assert( 'fooCount == 100', nil, "but is #{fooCount}" ) +GC.enable GC.start swig_assert( 'fooCount <= 1', nil, "but is #{fooCount}" ) From b1b13d7d0a5cedf93ceac4d07d7dbad708f4bde3 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 7 Jun 2020 13:56:07 -0600 Subject: [PATCH 1899/2031] Use %rename --- Examples/test-suite/director_comparison_operators.i | 7 +++++++ Examples/test-suite/ocaml/Makefile.in | 1 + 2 files changed, 8 insertions(+) diff --git a/Examples/test-suite/director_comparison_operators.i b/Examples/test-suite/director_comparison_operators.i index 9577847e1..f2251ed6d 100644 --- a/Examples/test-suite/director_comparison_operators.i +++ b/Examples/test-suite/director_comparison_operators.i @@ -3,6 +3,13 @@ %include "std_string.i" %feature("director"); +#if !defined(SWIGLUA) && !defined(SWIGR) +%rename(EqualEqual) operator ==; +%rename(NotEqual) operator !=; +%rename(LessThanEqual) operator <=; +%rename(GreaterThanEqual) operator >=; +#endif + %inline %{ class Foo { public: diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 775b1ea71..3d7230920 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -20,6 +20,7 @@ apply_strings \ cpp_enum \ default_constructor \ director_binary_string \ +director_comparison_operators \ director_enum \ director_primitives \ director_redefined \ From 3c007e81d6b6cb6e580cd18afaa870ef144c8fc8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 7 Jun 2020 23:03:06 +0100 Subject: [PATCH 1900/2031] swig-4.0.2 release notes --- ANNOUNCE | 2 +- CHANGES.current | 6 +++--- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 8 ++++++++ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6709f1182..b99c0c386 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 4.0.2 (in progress) *** +*** ANNOUNCE: SWIG 4.0.2 (8 Jun 2020) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index f64b6e48b..ba71d5556 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,8 +4,8 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.2 (in progress) -=========================== +Version 4.0.2 (8 Jun 2020) +========================== 2020-06-07 vigsterkr [Ruby] #1717 Nil fix mangling strings @@ -36,7 +36,7 @@ Version 4.0.2 (in progress) #1788 Fix handling of Doxygen \endlink command. 2020-05-24: vapier - [JS] #1796 Fix pkg-config invocation in configure. + [Javascript] #1796 Fix pkg-config invocation in configure. 2020-04-30: kwwette [Octave] Fix exception raising for newer Octave versions diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 30b74297c..a23ad7164 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.2 (in progress) +Last update : SWIG-4.0.2 (8 Jun 2020)

    Sections

    diff --git a/README b/README index 1a1cda664..24a0de3e8 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.2 (in progress) +Version: 4.0.2 (8 Jun 2020) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index 8633dadef..cc3ba0712 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -7,6 +7,14 @@ Release Notes Detailed release notes are available with the release and are also published on the SWIG web site at http://swig.org/release.html. +SWIG-4.0.2 summary: +- A few fixes around doxygen comment handling. +- Ruby 2.7 support added. +- Various minor improvements to C#, D, Java, OCaml, Octave, Python, + R, Ruby. +- Considerable performance improvement running SWIG on large + interface files. + SWIG-4.0.1 summary: - SWIG now cleans up on error by removing all generated files. - Add Python 3.8 support. From 772dfd5dcb0e59459a8ff4924ff5cb2383b7c5d3 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 7 Jun 2020 17:47:11 -0600 Subject: [PATCH 1901/2031] Fix the error handling for the PyObject_GetBuffer() calls in pybuffer.i Closes #1640. --- Lib/python/pybuffer.i | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i index 577eb69c8..2fdaa6d6e 100644 --- a/Lib/python/pybuffer.i +++ b/Lib/python/pybuffer.i @@ -17,13 +17,13 @@ int res; Py_ssize_t size = 0; void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); - size = view.len; - buf = view.buf; - PyBuffer_Release(&view); if (res < 0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); $1 = ($1_ltype) buf; $2 = ($2_ltype) (size/sizeof($*1_type)); } @@ -47,12 +47,12 @@ int res; void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_WRITABLE); - buf = view.buf; - PyBuffer_Release(&view); if (res < 0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP)", $symname, $argnum); } + buf = view.buf; + PyBuffer_Release(&view); $1 = ($1_ltype) buf; } %enddef @@ -76,13 +76,13 @@ int res; Py_ssize_t size = 0; const void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); - size = view.len; - buf = view.buf; - PyBuffer_Release(&view); if (res < 0) { PyErr_Clear(); %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum); } + size = view.len; + buf = view.buf; + PyBuffer_Release(&view); $1 = ($1_ltype) buf; $2 = ($2_ltype) (size / sizeof($*1_type)); } @@ -108,14 +108,12 @@ int res; const void *buf = 0; Py_buffer view; res = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO); - buf = view.buf; - PyBuffer_Release(&view); if (res < 0) { + PyErr_Clear(); %argument_fail(res, "(TYPEMAP)", $symname, $argnum); } + buf = view.buf; + PyBuffer_Release(&view); $1 = ($1_ltype) buf; } %enddef - - - From 7070320335c8757219f3e909e3cc559591f9592c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Jun 2020 20:06:55 +0100 Subject: [PATCH 1902/2031] Revert "Add C++20 documentation chapter" This reverts commit 36e8d521de110ab9956f60c3cb296352316e847c. Conflicts: Doc/Manual/R.html --- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Contents.html | 72 +++++------ Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Doxygen.html | 56 ++++----- Doc/Manual/Extending.html | 106 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 44 +++---- Doc/Manual/Introduction.html | 1 - Doc/Manual/Java.html | 220 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 50 ++++---- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 66 +++++----- Doc/Manual/Octave.html | 52 ++++---- Doc/Manual/Perl5.html | 108 ++++++++--------- Doc/Manual/Php.html | 50 ++++---- Doc/Manual/Preprocessor.html | 26 ++-- Doc/Manual/Python.html | 200 +++++++++++++++---------------- Doc/Manual/R.html | 16 +-- Doc/Manual/Ruby.html | 200 +++++++++++++++---------------- Doc/Manual/SWIGPlus.html | 1 - Doc/Manual/Scilab.html | 90 +++++++------- Doc/Manual/Sections.html | 1 - Doc/Manual/Tcl.html | 92 +++++++------- Doc/Manual/Typemaps.html | 132 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 38 +++--- Doc/Manual/chapters | 1 - 35 files changed, 1029 insertions(+), 1045 deletions(-) diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index da475e9a4..944a88d65 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

    22 SWIG and Android

    +

    21 SWIG and Android

    -

    13.1.3 Output parameters

    +

    12.1.3 Output parameters

    @@ -315,7 +315,7 @@ iresult, dresult = foo(3.5, 2) -

    13.1.4 Input/Output parameters

    +

    12.1.4 Input/Output parameters

    @@ -380,7 +380,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    13.1.5 Using different names

    +

    12.1.5 Using different names

    @@ -414,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    13.2 Applying constraints to input values

    +

    12.2 Applying constraints to input values

    @@ -424,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    13.2.1 Simple constraint example

    +

    12.2.1 Simple constraint example

    @@ -450,7 +450,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    13.2.2 Constraint methods

    +

    12.2.2 Constraint methods

    @@ -466,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only). -

    13.2.3 Applying constraints to new datatypes

    +

    12.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index 1a94709ae..edd435fa1 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -7,7 +7,7 @@ -

    21 Using SWIG with ccache - ccache-swig(1) manpage

    +

    20 Using SWIG with ccache - ccache-swig(1) manpage

    -

    21.14 HISTORY

    +

    20.14 HISTORY

    @@ -423,7 +423,7 @@ 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.

    -

    21.15 DIFFERENCES FROM COMPILERCACHE

    +

    20.15 DIFFERENCES FROM COMPILERCACHE

    @@ -441,7 +441,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    21.16 CREDITS

    +

    20.16 CREDITS

    @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    21.17 AUTHOR

    +

    20.17 AUTHOR

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index ef4c0104d..2e6a85147 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

    23 SWIG and C#

    +

    22 SWIG and C#

    -

    23.4 C# Arrays

    +

    22.4 C# Arrays

    @@ -592,7 +592,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

    -

    23.4.1 The SWIG C arrays library

    +

    22.4.1 The SWIG C arrays library

    @@ -629,7 +629,7 @@ example.print_array(c.cast()); // Pass to C

  • -

    23.4.2 Managed arrays using P/Invoke default array marshalling

    +

    22.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -756,7 +756,7 @@ and intermediary class method -

    23.4.3 Managed arrays using pinning

    +

    22.4.3 Managed arrays using pinning

    @@ -851,7 +851,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    23.5 C# Exceptions

    +

    22.5 C# Exceptions

    @@ -948,7 +948,7 @@ set so should only be used when a C# exception is not created.

    -

    23.5.1 C# exception example using "check" typemap

    +

    22.5.1 C# exception example using "check" typemap

    @@ -1130,7 +1130,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.

    -

    23.5.2 C# exception example using %exception

    +

    22.5.2 C# exception example using %exception

    @@ -1195,7 +1195,7 @@ The managed code generated does check for the pending exception as mentioned ear -

    23.5.3 C# exception example using exception specifications

    +

    22.5.3 C# exception example using exception specifications

    @@ -1251,7 +1251,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

    -

    23.5.4 Custom C# ApplicationException example

    +

    22.5.4 Custom C# ApplicationException example

    @@ -1385,7 +1385,7 @@ try { -

    23.6 C# Directors

    +

    22.6 C# Directors

    @@ -1398,7 +1398,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.

    -

    23.6.1 Directors example

    +

    22.6.1 Directors example

    @@ -1519,7 +1519,7 @@ CSharpDerived - UIntMethod(123) -

    23.6.2 Directors implementation

    +

    22.6.2 Directors implementation

    @@ -1727,7 +1727,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    23.6.3 Director caveats

    +

    22.6.3 Director caveats

    @@ -1775,7 +1775,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.

    -

    23.7 Multiple modules

    +

    22.7 Multiple modules

    @@ -1810,7 +1810,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    23.8 C# Typemap examples

    +

    22.8 C# Typemap examples

    This section includes a few examples of typemaps. For more examples, you @@ -1818,7 +1818,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

    23.8.1 Memory management when returning references to member variables

    +

    22.8.1 Memory management when returning references to member variables

    @@ -1942,7 +1942,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

    23.8.2 Memory management for objects passed to the C++ layer

    +

    22.8.2 Memory management for objects passed to the C++ layer

    @@ -2074,7 +2074,7 @@ as mentioned earlier, setElement is actually: -

    23.8.3 Date marshalling using the csin typemap and associated attributes

    +

    22.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2360,7 +2360,7 @@ public class example { -

    23.8.4 A date example demonstrating marshalling of C# properties

    +

    22.8.4 A date example demonstrating marshalling of C# properties

    @@ -2460,7 +2460,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    23.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2522,7 +2522,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    23.8.6 Turning proxy classes into partial classes

    +

    22.8.6 Turning proxy classes into partial classes

    @@ -2622,7 +2622,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.

    -

    23.8.7 Turning proxy classes into sealed classes

    +

    22.8.7 Turning proxy classes into sealed classes

    @@ -2712,7 +2712,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    23.8.8 Extending proxy classes with additional C# code

    +

    22.8.8 Extending proxy classes with additional C# code

    @@ -2751,7 +2751,7 @@ public class ExtendMe : global::System.IDisposable { -

    23.8.9 Underlying type for enums

    +

    22.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 79ffdd50e..8d1c09df2 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -372,19 +372,7 @@ -

    10 SWIG and C++20

    - - - - - -

    11 Preprocessing

    +

    10 Preprocessing

    @@ -407,7 +395,7 @@
    -

    12 SWIG library

    +

    11 SWIG library

    @@ -450,7 +438,7 @@
    -

    13 Argument Handling

    +

    12 Argument Handling

    @@ -473,7 +461,7 @@
    -

    14 Typemaps

    +

    13 Typemaps

    @@ -567,7 +555,7 @@
    -

    15 Customization Features

    +

    14 Customization Features

    @@ -595,7 +583,7 @@
    -

    16 Contracts

    +

    15 Contracts

    @@ -608,7 +596,7 @@
    -

    17 Variable Length Arguments

    +

    16 Variable Length Arguments

    @@ -626,7 +614,7 @@
    -

    18 SWIG and Doxygen Translation

    +

    17 SWIG and Doxygen Translation

    @@ -674,7 +662,7 @@
    -

    19 Warning Messages

    +

    18 Warning Messages

    @@ -703,7 +691,7 @@
    -

    20 Working with Modules

    +

    19 Working with Modules

    @@ -719,7 +707,7 @@
    -

    21 Using SWIG with ccache - ccache-swig(1) manpage

    +

    20 Using SWIG with ccache - ccache-swig(1) manpage

    @@ -745,7 +733,7 @@
    -

    22 SWIG and Android

    +

    21 SWIG and Android

    @@ -763,7 +751,7 @@
    -

    23 SWIG and C#

    +

    22 SWIG and C#

    @@ -811,7 +799,7 @@
    -

    24 SWIG and D

    +

    23 SWIG and D

    @@ -845,7 +833,7 @@
    -

    25 SWIG and Go

    +

    24 SWIG and Go

    @@ -889,7 +877,7 @@
    -

    26 SWIG and Guile

    +

    25 SWIG and Guile

    @@ -925,7 +913,7 @@
    -

    27 SWIG and Java

    +

    26 SWIG and Java

    @@ -1079,7 +1067,7 @@
    -

    28 SWIG and Javascript

    +

    27 SWIG and Javascript

    @@ -1121,7 +1109,7 @@
    -

    29 SWIG and Lua

    +

    28 SWIG and Lua

    @@ -1189,7 +1177,7 @@
    -

    30 SWIG and Octave

    +

    29 SWIG and Octave

    @@ -1229,7 +1217,7 @@
    -

    31 SWIG and Perl5

    +

    30 SWIG and Perl5

    @@ -1305,7 +1293,7 @@
    -

    32 SWIG and PHP

    +

    31 SWIG and PHP

    @@ -1346,7 +1334,7 @@
    -

    33 SWIG and Python

    +

    32 SWIG and Python

    @@ -1488,7 +1476,7 @@
    -

    34 SWIG and R

    +

    33 SWIG and R

    @@ -1507,7 +1495,7 @@
    -

    35 SWIG and Ruby

    +

    34 SWIG and Ruby

    @@ -1645,7 +1633,7 @@
    -

    36 SWIG and Scilab

    +

    35 SWIG and Scilab

    @@ -1714,7 +1702,7 @@
    -

    37 SWIG and Tcl

    +

    36 SWIG and Tcl

    @@ -1780,7 +1768,7 @@
    -

    38 SWIG and MzScheme/Racket

    +

    37 SWIG and MzScheme/Racket

    @@ -1792,7 +1780,7 @@
    -

    39 SWIG and OCaml

    +

    38 SWIG and OCaml

    @@ -1847,7 +1835,7 @@
    -

    40 Extending SWIG to support new languages

    +

    39 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index f7acbba3e..93fb8c003 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -7,7 +7,7 @@ -

    16 Contracts

    +

    15 Contracts

      @@ -39,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      16.1 The %contract directive

      +

      15.1 The %contract directive

      @@ -95,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    16.2 %contract and classes

    +

    15.2 %contract and classes

    @@ -174,7 +174,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    16.3 Constant aggregation and %aggregate_check

    +

    15.3 Constant aggregation and %aggregate_check

    @@ -263,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    16.4 Notes

    +

    15.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 5fe0f5b52..328bc2391 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -7,7 +7,7 @@ -

    15 Customization Features

    +

    14 Customization Features

    -

    15.1.4 Exception handlers for variables

    +

    14.1.4 Exception handlers for variables

    @@ -305,7 +305,7 @@ The %allowexception feature works like any other feature and so can be

    -

    15.1.5 Defining different exception handlers

    +

    14.1.5 Defining different exception handlers

    @@ -442,7 +442,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    15.1.6 Special variables for %exception

    +

    14.1.6 Special variables for %exception

    @@ -545,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    15.1.7 Using The SWIG exception library

    +

    14.1.7 Using The SWIG exception library

    @@ -600,7 +600,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    15.2 Object ownership and %newobject

    +

    14.2 Object ownership and %newobject

    @@ -757,7 +757,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    15.3 Features and the %feature directive

    +

    14.3 Features and the %feature directive

    @@ -839,7 +839,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    15.3.1 Feature attributes

    +

    14.3.1 Feature attributes

    @@ -880,7 +880,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    15.3.2 Feature flags

    +

    14.3.2 Feature flags

    @@ -978,7 +978,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    15.3.3 Clearing features

    +

    14.3.3 Clearing features

    @@ -1071,7 +1071,7 @@ The three macros below show this for the "except" feature: -

    15.3.4 Features and default arguments

    +

    14.3.4 Features and default arguments

    @@ -1146,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    15.3.5 Feature example

    +

    14.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index f9f2d53ca..d97267a5b 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    24 SWIG and D

    +

    23 SWIG and D

      @@ -41,7 +41,7 @@ -

      24.1 Introduction

      +

      23.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      24.2 Command line invocation

      +

      23.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line options as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      24.3 Typemaps

      +

      23.3 Typemaps

      -

      24.3.1 C# <-> D name comparison

      +

      23.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    24.3.2 ctype, imtype, dtype

    +

    23.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    24.3.3 in, out, directorin, directorout

    +

    23.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    24.3.4 din, dout, ddirectorin, ddirectorout

    +

    23.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

    24.3.5 typecheck typemaps

    +

    23.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    24.3.6 Code injection typemaps

    +

    23.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    24.3.7 Special variable macros

    +

    23.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    24.4 D and %feature

    +

    23.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    24.5 Pragmas

    +

    23.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    24.6 D Exceptions

    +

    23.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    24.7 D Directors

    +

    23.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    24.8 Other features

    +

    23.8 Other features

    -

    24.8.1 Extended namespace support (nspace)

    +

    23.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    24.8.2 Native pointer support

    +

    23.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    24.8.3 Operator overloading

    +

    23.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    24.8.4 Running the test-suite

    +

    23.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    24.9 D Typemap examples

    +

    23.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    24.10 Work in progress and planned features

    +

    23.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 53238c24d..75657dc3b 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

    18 SWIG and Doxygen Translation

    +

    17 SWIG and Doxygen Translation

    -

    18.2.2.4 doxygen:nolinktranslate

    +

    17.2.2.4 doxygen:nolinktranslate

    @@ -430,7 +430,7 @@ This is only applicable to Java at the moment.

    -

    18.2.2.5 doxygen:nostripparams

    +

    17.2.2.5 doxygen:nostripparams

    @@ -440,14 +440,14 @@ This is only applicable to Java at the moment.

    -

    18.2.3 Additional command line options

    +

    17.2.3 Additional command line options

    ALSO TO BE ADDED (Javadoc auto brief?)

    -

    18.3 Doxygen to Javadoc

    +

    17.3 Doxygen to Javadoc

    @@ -456,7 +456,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

    -

    18.3.1 Basic example

    +

    17.3.1 Basic example

    @@ -563,7 +563,7 @@ Javadoc translator features summary directives):

    -

    18.3.2 Javadoc tags

    +

    17.3.2 Javadoc tags

    @@ -825,7 +825,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    18.3.3 Unsupported tags

    +

    17.3.3 Unsupported tags

    @@ -992,14 +992,14 @@ comment, the whole comment block is ignored: -

    18.3.4 Further details

    +

    17.3.4 Further details

    TO BE ADDED.

    -

    18.4 Doxygen to Pydoc

    +

    17.4 Doxygen to Pydoc

    @@ -1010,7 +1010,7 @@ Doxygen or Javadoc, so most of Doxygen commands are translated by merely copying the appropriate command text.

    -

    18.4.1 Basic example

    +

    17.4.1 Basic example

    @@ -1173,7 +1173,7 @@ docs), you may want to use some tool like doxypy to do the work.

    -

    18.4.2 Pydoc translator

    +

    17.4.2 Pydoc translator

    @@ -1427,7 +1427,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    18.4.3 Unsupported tags

    +

    17.4.3 Unsupported tags

    @@ -1543,14 +1543,14 @@ Here is the list of these tags: -

    18.4.4 Further details

    +

    17.4.4 Further details

    TO BE ADDED.

    -

    18.5 Troubleshooting

    +

    17.5 Troubleshooting

    @@ -1572,7 +1572,7 @@ include the option and fix problems with Doxygen comments.

    -

    18.5.1 Problem with conditional compilation

    +

    17.5.1 Problem with conditional compilation

    @@ -1612,14 +1612,14 @@ class A { -

    18.6 Developer information

    +

    17.6 Developer information

    This section contains information for developers enhancing the Doxygen translator.

    -

    18.6.1 Doxygen translator design

    +

    17.6.1 Doxygen translator design

    @@ -1645,7 +1645,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

    -

    18.6.2 Debugging the Doxygen parser and translator

    +

    17.6.2 Debugging the Doxygen parser and translator

    @@ -1658,7 +1658,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

    18.6.3 Tests

    +

    17.6.3 Tests

    @@ -1710,7 +1710,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

    -

    18.7 Extending to other languages

    +

    17.7 Extending to other languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 7c2a6c66c..5a640fbdc 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    40 Extending SWIG to support new languages

    +

    39 Extending SWIG to support new languages

    -

    40.4.4 Attribute namespaces

    +

    39.4.4 Attribute namespaces

    @@ -665,7 +665,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    40.4.5 Symbol Tables

    +

    39.4.5 Symbol Tables

    @@ -756,7 +756,7 @@ example.i:5. Previous declaration is foo_i(int ) -

    40.4.6 The %feature directive

    +

    39.4.6 The %feature directive

    @@ -812,7 +812,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    40.4.7 Code Generation

    +

    39.4.7 Code Generation

    @@ -934,7 +934,7 @@ public : The role of these functions is described shortly.

    -

    40.4.8 SWIG and XML

    +

    39.4.8 SWIG and XML

    @@ -947,7 +947,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    40.5 Primitive Data Structures

    +

    39.5 Primitive Data Structures

    @@ -993,7 +993,7 @@ typedef Hash Typetab; -

    40.5.1 Strings

    +

    39.5.1 Strings

    @@ -1134,7 +1134,7 @@ Returns the number of replacements made (if any). -

    40.5.2 Hashes

    +

    39.5.2 Hashes

    @@ -1211,7 +1211,7 @@ Returns the list of hash table keys. -

    40.5.3 Lists

    +

    39.5.3 Lists

    @@ -1300,7 +1300,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    40.5.4 Common operations

    +

    39.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1355,7 +1355,7 @@ objects and report errors. Gets the line number associated with x. -

    40.5.5 Iterating over Lists and Hashes

    +

    39.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1400,7 +1400,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    40.5.6 I/O

    +

    39.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1534,7 +1534,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    40.6 Navigating and manipulating parse trees

    +

    39.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1668,7 +1668,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    40.7 Working with attributes

    +

    39.7 Working with attributes

    @@ -1785,7 +1785,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    40.8 Type system

    +

    39.8 Type system

    @@ -1794,7 +1794,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    40.8.1 String encoding of types

    +

    39.8.1 String encoding of types

    @@ -1895,7 +1895,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    40.8.2 Type construction

    +

    39.8.2 Type construction

    @@ -2064,7 +2064,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    40.8.3 Type tests

    +

    39.8.3 Type tests

    @@ -2151,7 +2151,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    40.8.4 Typedef and inheritance

    +

    39.8.4 Typedef and inheritance

    @@ -2253,7 +2253,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    40.8.5 Lvalues

    +

    39.8.5 Lvalues

    @@ -2290,7 +2290,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    40.8.6 Output functions

    +

    39.8.6 Output functions

    @@ -2352,7 +2352,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    40.9 Parameters

    +

    39.9 Parameters

    @@ -2451,7 +2451,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    40.10 Writing a Language Module

    +

    39.10 Writing a Language Module

    @@ -2466,7 +2466,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    40.10.1 Execution model

    +

    39.10.1 Execution model

    @@ -2476,7 +2476,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.

    -

    40.10.2 Starting out

    +

    39.10.2 Starting out

    @@ -2584,7 +2584,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    40.10.3 Command line options

    +

    39.10.3 Command line options

    @@ -2643,7 +2643,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    40.10.4 Configuration and preprocessing

    +

    39.10.4 Configuration and preprocessing

    @@ -2692,7 +2692,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    40.10.5 Entry point to code generation

    +

    39.10.5 Entry point to code generation

    @@ -2750,7 +2750,7 @@ int Python::top(Node *n) { -

    40.10.6 Module I/O and wrapper skeleton

    +

    39.10.6 Module I/O and wrapper skeleton

    @@ -2898,7 +2898,7 @@ functionWrapper : void Shape_y_set(Shape *self, double y) -

    40.10.7 Low-level code generators

    +

    39.10.7 Low-level code generators

    @@ -3052,7 +3052,7 @@ but without the typemaps, there is still work to do.

    -

    40.10.8 Configuration files

    +

    39.10.8 Configuration files

    @@ -3196,7 +3196,7 @@ politely displays the ignoring language message. -

    40.10.9 Runtime support

    +

    39.10.9 Runtime support

    @@ -3205,7 +3205,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    40.10.10 Standard library files

    +

    39.10.10 Standard library files

    @@ -3224,7 +3224,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    40.10.11 User examples

    +

    39.10.11 User examples

    @@ -3253,7 +3253,7 @@ during this process, see the section on .

    -

    40.10.12 Test driven development and the test-suite

    +

    39.10.12 Test driven development and the test-suite

    @@ -3312,7 +3312,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    40.10.12.1 Running the test-suite

    +

    39.10.12.1 Running the test-suite

    @@ -3504,7 +3504,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    40.10.13 Documentation

    +

    39.10.13 Documentation

    @@ -3536,7 +3536,7 @@ Some topics that you'll want to be sure to address include: if available. -

    40.10.14 Coding style guidelines

    +

    39.10.14 Coding style guidelines

    @@ -3561,7 +3561,7 @@ should be avoided as unlike the SWIG developers, users will never have consisten

    -

    40.10.15 Target language status

    +

    39.10.15 Target language status

    @@ -3570,7 +3570,7 @@ the Target language in This section provides more details on how this status is given.

    -

    40.10.15.1 Supported status

    +

    39.10.15.1 Supported status

    @@ -3617,7 +3617,7 @@ A target language is given the 'Supported' status when

  • -

    40.10.15.2 Experimental status

    +

    39.10.15.2 Experimental status

    @@ -3682,7 +3682,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat -

    40.10.16 Prerequisites for adding a new language module to the SWIG distribution

    +

    39.10.16 Prerequisites for adding a new language module to the SWIG distribution

    @@ -3746,7 +3746,7 @@ the existing tests.

    -

    40.11 Debugging Options

    +

    39.11 Debugging Options

    @@ -3773,7 +3773,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    40.12 Guide to parse tree nodes

    +

    39.12 Guide to parse tree nodes

    @@ -4181,7 +4181,7 @@ extern "X" { ... } declaration. -

    40.13 Further Development Information

    +

    39.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 1a5bb08c7..c28cc03e1 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    25 SWIG and Go

    +

    24 SWIG and Go

    -

    25.3.1 Go-specific Commandline Options

    +

    24.3.1 Go-specific Commandline Options

    @@ -276,7 +276,7 @@ swig -go -help -

    25.3.2 Generated Wrapper Files

    +

    24.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -320,7 +320,7 @@ combined with the compiled MODULE.go using go tool pack. -

    25.4 A tour of basic C/C++ wrapping

    +

    24.4 A tour of basic C/C++ wrapping

    @@ -330,7 +330,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    25.4.1 Go Package Name

    +

    24.4.1 Go Package Name

    @@ -340,7 +340,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    25.4.2 Go Names

    +

    24.4.2 Go Names

    @@ -372,7 +372,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    25.4.3 Go Constants

    +

    24.4.3 Go Constants

    @@ -380,7 +380,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    25.4.4 Go Enumerations

    +

    24.4.4 Go Enumerations

    @@ -390,7 +390,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    25.4.5 Go Classes

    +

    24.4.5 Go Classes

    @@ -468,7 +468,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    25.4.5.1 Go Class Memory Management

    +

    24.4.5.1 Go Class Memory Management

    @@ -590,7 +590,7 @@ func (o *GoClassName) Close() { -

    25.4.5.2 Go Class Inheritance

    +

    24.4.5.2 Go Class Inheritance

    @@ -602,7 +602,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    25.4.6 Go Templates

    +

    24.4.6 Go Templates

    @@ -611,7 +611,7 @@ wrappers for a particular template instantiation. To do this, use the %template directive. -

    25.4.7 Go Director Classes

    +

    24.4.7 Go Director Classes

    @@ -629,7 +629,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    25.4.7.1 Example C++ code

    +

    24.4.7.1 Example C++ code

    @@ -701,7 +701,7 @@ be found in the end of the guide.

    -

    25.4.7.2 Enable director feature

    +

    24.4.7.2 Enable director feature

    @@ -736,7 +736,7 @@ documentation on directors.

    -

    25.4.7.3 Constructor and destructor

    +

    24.4.7.3 Constructor and destructor

    @@ -789,7 +789,7 @@ embedding.

    -

    25.4.7.4 Override virtual methods

    +

    24.4.7.4 Override virtual methods

    @@ -857,7 +857,7 @@ the Go methods.

    -

    25.4.7.5 Call base methods

    +

    24.4.7.5 Call base methods

    @@ -894,7 +894,7 @@ be found in the end of the guide.

    -

    25.4.7.6 Subclass via embedding

    +

    24.4.7.6 Subclass via embedding

    @@ -962,7 +962,7 @@ class.

    -

    25.4.7.7 Memory management with runtime.SetFinalizer

    +

    24.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1027,7 +1027,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    25.4.7.8 Complete FooBarGo example class

    +

    24.4.7.8 Complete FooBarGo example class

    @@ -1156,7 +1156,7 @@ SWIG/Examples/go/director/.

    -

    25.4.8 Default Go primitive type mappings

    +

    24.4.8 Default Go primitive type mappings

    @@ -1263,7 +1263,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    25.4.9 Output arguments

    +

    24.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1316,7 +1316,7 @@ void f(char *output); -

    25.4.10 Adding additional go code

    +

    24.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1411,7 +1411,7 @@ func bar() { -

    25.4.11 Go typemaps

    +

    24.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 9d55b632b..31d822599 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    26 SWIG and Guile

    +

    25 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      26.1 Supported Guile Versions

      +

      25.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      26.2 Meaning of "Module"

      +

      25.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      26.3 Old GH Guile API

      +

      25.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      26.4 Linkage

      +

      25.4 Linkage

      @@ -89,7 +89,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. -

      26.4.1 Simple Linkage

      +

      25.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      26.4.2 Passive Linkage

      +

      25.4.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -204,7 +204,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      26.4.3 Native Guile Module Linkage

      +

      25.4.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -245,7 +245,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    26.4.4 Old Auto-Loading Guile Module Linkage

    +

    25.4.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -271,7 +271,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    26.4.5 Hobbit4D Linkage

    +

    25.4.5 Hobbit4D Linkage

    @@ -296,7 +296,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    26.5 Underscore Folding

    +

    25.5 Underscore Folding

    @@ -308,7 +308,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    26.6 Typemaps

    +

    25.6 Typemaps

    @@ -400,7 +400,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    26.7 Representation of pointers as smobs

    +

    25.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    26.7.1 Smobs

    +

    25.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    26.7.2 Garbage Collection

    +

    25.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 26.8 Native Guile pointers +

    25.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    26.9 Exception Handling

    +

    25.9 Exception Handling

    @@ -487,7 +487,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    26.10 Procedure documentation

    +

    25.10 Procedure documentation

    If invoked with the command-line option -procdoc @@ -522,7 +522,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    26.11 Procedures with setters

    +

    25.11 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -550,7 +550,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    26.12 GOOPS Proxy Classes

    +

    25.12 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -696,7 +696,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    26.12.1 Naming Issues

    +

    25.12.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -733,7 +733,7 @@ guile-modules. For example,

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    26.12.2 Linking

    +

    25.12.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 facfc7dd1..8d161b73d 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -416,7 +416,6 @@ major features include: Most of C++11 is also supported. Details are in the C++11 chapter. C++14 support is covered in the C++14 chapter. C++17 support is covered in the C++17 chapter. -C++20 support is covered in the C++20 chapter.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index b9234b24f..db5f041e4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    27 SWIG and Java

    +

    26 SWIG and Java

    -

    27.3.3 Global variables

    +

    26.3.3 Global variables

    @@ -816,7 +816,7 @@ extern char *path; // Read-only (due to %immutable) -

    27.3.4 Constants

    +

    26.3.4 Constants

    @@ -956,7 +956,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    27.3.5 Enumerations

    +

    26.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    27.3.5.1 Anonymous enums

    +

    26.3.5.1 Anonymous enums

    @@ -1033,7 +1033,7 @@ As in the case of constants, you can access them through either the module class

    -

    27.3.5.2 Typesafe enums

    +

    26.3.5.2 Typesafe enums

    @@ -1126,7 +1126,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.

    -

    27.3.5.3 Proper Java enums

    +

    26.3.5.3 Proper Java enums

    @@ -1179,7 +1179,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    27.3.5.4 Type unsafe enums

    +

    26.3.5.4 Type unsafe enums

    @@ -1227,7 +1227,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.

    -

    27.3.5.5 Simple enums

    +

    26.3.5.5 Simple enums

    @@ -1246,7 +1246,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.

    -

    27.3.6 Pointers

    +

    26.3.6 Pointers

    @@ -1334,7 +1334,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.

    -

    27.3.7 Structures

    +

    26.3.7 Structures

    @@ -1502,7 +1502,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    27.3.8 C++ classes

    +

    26.3.8 C++ classes

    @@ -1565,7 +1565,7 @@ int bar = Spam.getBar(); -

    27.3.9 C++ inheritance

    +

    26.3.9 C++ inheritance

    @@ -1626,7 +1626,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.

    -

    27.3.10 Pointers, references, arrays and pass by value

    +

    26.3.10 Pointers, references, arrays and pass by value

    @@ -1681,7 +1681,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).

    -

    27.3.10.1 Null pointers

    +

    26.3.10.1 Null pointers

    @@ -1705,7 +1705,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.

    -

    27.3.11 C++ overloaded functions

    +

    26.3.11 C++ overloaded functions

    @@ -1820,7 +1820,7 @@ void spam(unsigned short); // Ignored -

    27.3.12 C++ default arguments

    +

    26.3.12 C++ default arguments

    @@ -1863,7 +1863,7 @@ Further details on default arguments and how to restore this approach are given

    -

    27.3.13 C++ namespaces

    +

    26.3.13 C++ namespaces

    @@ -1953,7 +1953,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    27.3.14 C++ templates

    +

    26.3.14 C++ templates

    @@ -2002,10 +2002,10 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    27.3.15 C++ Smart Pointers

    +

    26.3.15 C++ Smart Pointers

    -

    27.3.15.1 The shared_ptr Smart Pointer

    +

    26.3.15.1 The shared_ptr Smart Pointer

    @@ -2016,7 +2016,7 @@ in the shared_ptr smart pointer -

    27.3.15.2 Generic Smart Pointers

    +

    26.3.15.2 Generic Smart Pointers

    @@ -2100,7 +2100,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    27.4 Further details on the generated Java classes

    +

    26.4 Further details on the generated Java classes

    @@ -2115,7 +2115,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    27.4.1 The intermediary JNI class

    +

    26.4.1 The intermediary JNI class

    @@ -2235,7 +2235,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    27.4.1.1 The intermediary JNI class pragmas

    +

    26.4.1.1 The intermediary JNI class pragmas

    @@ -2317,7 +2317,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    27.4.2 The Java module class

    +

    26.4.2 The Java module class

    @@ -2348,7 +2348,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.

    -

    27.4.2.1 The Java module class pragmas

    +

    26.4.2.1 The Java module class pragmas

    @@ -2399,7 +2399,7 @@ See The intermediary JNI class pragmas secti

    -

    27.4.3 Java proxy classes

    +

    26.4.3 Java proxy classes

    @@ -2475,7 +2475,7 @@ int y = f.spam(5, new Foo()); -

    27.4.3.1 Memory management

    +

    26.4.3.1 Memory management

    @@ -2637,7 +2637,7 @@ and

    -

    27.4.3.2 Inheritance

    +

    26.4.3.2 Inheritance

    @@ -2753,7 +2753,7 @@ However, true cross language polymorphism can be achieved using the 27.4.3.3 Proxy classes and garbage collection +

    26.4.3.3 Proxy classes and garbage collection

    @@ -2836,7 +2836,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.

    -

    27.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2958,7 +2958,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    27.4.3.5 Single threaded applications and thread safety

    +

    26.4.3.5 Single threaded applications and thread safety

    @@ -3046,7 +3046,7 @@ for (int i=0; i<100000; i++) { -

    27.4.4 Type wrapper classes

    +

    26.4.4 Type wrapper classes

    @@ -3133,7 +3133,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    27.4.5 Enum classes

    +

    26.4.5 Enum classes

    @@ -3142,7 +3142,7 @@ The Enumerations section discussed these but om The following sub-sections detail the various types of enum classes that can be generated.

    -

    27.4.5.1 Typesafe enum classes

    +

    26.4.5.1 Typesafe enum classes

    @@ -3226,7 +3226,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    27.4.5.2 Proper Java enum classes

    +

    26.4.5.2 Proper Java enum classes

    @@ -3304,7 +3304,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.

    -

    27.4.5.3 Type unsafe enum classes

    +

    26.4.5.3 Type unsafe enum classes

    @@ -3335,7 +3335,7 @@ public final class Beverage { -

    27.4.6 Interfaces

    +

    26.4.6 Interfaces

    @@ -3580,7 +3580,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    27.5 Cross language polymorphism using directors

    +

    26.5 Cross language polymorphism using directors

    @@ -3602,7 +3602,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.

    -

    27.5.1 Enabling directors

    +

    26.5.1 Enabling directors

    @@ -3670,7 +3670,7 @@ public: -

    27.5.2 Director classes

    +

    26.5.2 Director classes

    @@ -3698,7 +3698,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    27.5.3 Overhead and code bloat

    +

    26.5.3 Overhead and code bloat

    @@ -3716,7 +3716,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    27.5.4 Simple directors example

    +

    26.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    27.5.5 Director threading issues

    +

    26.5.5 Director threading issues

    @@ -3799,7 +3799,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    27.5.6 Director performance tuning

    +

    26.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    27.5.7 Java exceptions from directors

    +

    26.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    27.5.7.1 Customizing director exceptions

    +

    26.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    27.6 Accessing protected members

    +

    26.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    27.7 Common customization features

    +

    26.7 Common customization features

    @@ -4562,7 +4562,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    27.7.1 C/C++ helper functions

    +

    26.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    27.7.2 Class extension with %extend

    +

    26.7.2 Class extension with %extend

    @@ -4691,7 +4691,7 @@ Vector(2, 3, 4) in any way---the extensions only show up in the Java interface.

    -

    27.7.3 Class extension with %proxycode

    +

    26.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    27.7.4 Exception handling with %exception and %javaexception

    +

    26.7.4 Exception handling with %exception and %javaexception

    @@ -4987,7 +4987,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    27.7.5 Method access with %javamethodmodifiers

    +

    26.7.5 Method access with %javamethodmodifiers

    @@ -5013,7 +5013,7 @@ protected static void protect_me() { -

    27.8 Tips and techniques

    +

    26.8 Tips and techniques

    @@ -5023,7 +5023,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    27.8.1 Input and output parameters using primitive pointers and references

    +

    26.8.1 Input and output parameters using primitive pointers and references

    @@ -5197,7 +5197,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    27.8.2 Simple pointers

    +

    26.8.2 Simple pointers

    @@ -5263,7 +5263,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    27.8.3 Wrapping C arrays with Java arrays

    +

    26.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    27.8.4 Unbounded C Arrays

    +

    26.8.4 Unbounded C Arrays

    @@ -5475,7 +5475,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    27.8.5 Binary data vs Strings

    +

    26.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    27.8.6 Overriding new and delete to allocate from Java heap

    +

    26.8.6 Overriding new and delete to allocate from Java heap

    @@ -5636,7 +5636,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    27.9 Java typemaps

    +

    26.9 Java typemaps

    @@ -5657,7 +5657,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. -

    27.9.1 Default primitive type mappings

    +

    26.9.1 Default primitive type mappings

    @@ -5809,7 +5809,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    27.9.2 Default typemaps for non-primitive types

    +

    26.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    27.9.3 Sixty four bit JVMs

    +

    26.9.3 Sixty four bit JVMs

    @@ -5837,7 +5837,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    27.9.4 What is a typemap?

    +

    26.9.4 What is a typemap?

    @@ -5960,7 +5960,7 @@ int c = example.count('e', "Hello World"); -

    27.9.5 Typemaps for mapping C/C++ types to Java types

    +

    26.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -6240,7 +6240,7 @@ These are listed below: -

    27.9.6 Java typemap attributes

    +

    26.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    27.9.7 Java special variables

    +

    26.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    27.9.8 Typemaps for both C and C++ compilation

    +

    26.9.8 Typemaps for both C and C++ compilation

    @@ -6505,7 +6505,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    27.9.9 Java code typemaps

    +

    26.9.9 Java code typemaps

    @@ -6803,7 +6803,7 @@ to make the method and constructor public: -

    27.9.10 Director specific typemaps

    +

    26.9.10 Director specific typemaps

    @@ -7080,7 +7080,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    27.10 Typemap Examples

    +

    26.10 Typemap Examples

    @@ -7090,7 +7090,7 @@ the SWIG library.

    -

    27.10.1 Simpler Java enums for enums without initializers

    +

    26.10.1 Simpler Java enums for enums without initializers

    @@ -7169,7 +7169,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    27.10.2 Handling C++ exception specifications as Java exceptions

    +

    26.10.2 Handling C++ exception specifications as Java exceptions

    @@ -7294,7 +7294,7 @@ We could alternatively have used %rename to rename what() into

    -

    27.10.3 NaN Exception - exception handling for a particular type

    +

    26.10.3 NaN Exception - exception handling for a particular type

    @@ -7449,7 +7449,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.

    -

    27.10.4 Converting Java String arrays to char **

    +

    26.10.4 Converting Java String arrays to char **

    @@ -7593,7 +7593,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    27.10.5 Expanding a Java object to multiple arguments

    +

    26.10.5 Expanding a Java object to multiple arguments

    @@ -7675,7 +7675,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    27.10.6 Using typemaps to return arguments

    +

    26.10.6 Using typemaps to return arguments

    @@ -7793,7 +7793,7 @@ $ java runme 1 12.0 340.0 -

    27.10.7 Adding Java downcasts to polymorphic return types

    +

    26.10.7 Adding Java downcasts to polymorphic return types

    @@ -7999,7 +7999,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.

    -

    27.10.8 Adding an equals method to the Java classes

    +

    26.10.8 Adding an equals method to the Java classes

    @@ -8043,7 +8043,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    27.10.9 Void pointers and a common Java base class

    +

    26.10.9 Void pointers and a common Java base class

    @@ -8102,7 +8102,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. -

    27.10.10 Struct pointer to pointer

    +

    26.10.10 Struct pointer to pointer

    @@ -8282,7 +8282,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.

    -

    27.10.11 Memory management when returning references to member variables

    +

    26.10.11 Memory management when returning references to member variables

    @@ -8405,7 +8405,7 @@ public class Bike { Note the addReference call.

    -

    27.10.12 Memory management for objects passed to the C++ layer

    +

    26.10.12 Memory management for objects passed to the C++ layer

    @@ -8533,7 +8533,7 @@ as mentioned earlier, setElement is actually: -

    27.10.13 Date marshalling using the javain typemap and associated attributes

    +

    26.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8710,7 +8710,7 @@ A few things to note: -

    27.11 Living with Java Directors

    +

    26.11 Living with Java Directors

    @@ -8889,10 +8889,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    27.12 Odds and ends

    +

    26.12 Odds and ends

    -

    27.12.1 JavaDoc comments

    +

    26.12.1 JavaDoc comments

    @@ -8948,7 +8948,7 @@ public class Barmy { -

    27.12.2 Functional interface without proxy classes

    +

    26.12.2 Functional interface without proxy classes

    @@ -9009,7 +9009,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    27.12.3 Using your own JNI functions

    +

    26.12.3 Using your own JNI functions

    @@ -9059,7 +9059,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    27.12.4 Performance concerns and hints

    +

    26.12.4 Performance concerns and hints

    @@ -9080,7 +9080,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.

    -

    27.12.5 Debugging

    +

    26.12.5 Debugging

    @@ -9102,7 +9102,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    27.13 Java Examples

    +

    26.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index cce5b5e2e..0b301377c 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    28 SWIG and Javascript

    +

    27 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      28.1 Overview

      +

      27.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      28.2 Preliminaries

      +

      27.2 Preliminaries

      -

      28.2.1 Running SWIG

      +

      27.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      28.2.2 Running Tests and Examples

      +

      27.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    28.2.3 Known Issues

    +

    27.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -169,12 +169,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    28.3 Integration

    +

    27.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    28.3.1 Creating node.js Extensions

    +

    27.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -220,7 +220,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    28.3.1.1 Troubleshooting

    +

    27.3.1.1 Troubleshooting

      @@ -232,12 +232,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      28.3.2 Embedded Webkit

      +

      27.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      28.3.2.1 Mac OS X

      +

      27.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -285,7 +285,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      28.3.2.2 GTK

      +

      27.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -330,7 +330,7 @@ int main(int argc, char* argv[]) } -

      28.3.3 Creating Applications with node-webkit

      +

      27.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -421,12 +421,12 @@ open new windows, and many more things. }; -

      28.4 Examples

      +

      27.4 Examples

      Some basic examples are shown here in more detail.

      -

      28.4.1 Simple

      +

      27.4.1 Simple

      The common example simple looks like this:

      @@ -476,7 +476,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      28.4.2 Class

      +

      27.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -606,12 +606,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      28.5 Implementation

      +

      27.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      28.5.1 Source Code

      +

      27.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -712,7 +712,7 @@ Template::Template(const String *code_) { ... } ... -

      28.5.2 Code Templates

      +

      27.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -751,7 +751,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      28.5.3 Emitter

      +

      27.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -870,7 +870,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      28.5.4 Emitter states

      +

      27.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -914,7 +914,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      28.5.5 Handling Exceptions in JavascriptCore

      +

      27.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 5f72b557d..560859234 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -7,7 +7,7 @@ -

      12 SWIG library

      +

      11 SWIG library

      -

      12.2.4 cdata.i

      +

      11.2.4 cdata.i

      @@ -769,7 +769,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      12.3 C string handling

      +

      11.3 C string handling

      @@ -789,7 +789,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      12.3.1 Default string handling

      +

      11.3.1 Default string handling

      @@ -830,7 +830,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      12.3.2 Passing binary data

      +

      11.3.2 Passing binary data

      @@ -872,7 +872,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      12.3.3 Using %newobject to release memory

      +

      11.3.3 Using %newobject to release memory

      @@ -913,7 +913,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      12.3.4 cstring.i

      +

      11.3.4 cstring.i

      @@ -1373,7 +1373,7 @@ structure or class instead.

    -

    12.4 STL/C++ library

    +

    11.4 STL/C++ library

    @@ -1420,7 +1420,7 @@ Please look for the library files in the appropriate language library directory.

    -

    12.4.1 std::string

    +

    11.4.1 std::string

    @@ -1504,7 +1504,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    12.4.2 std::vector

    +

    11.4.2 std::vector

    @@ -1683,7 +1683,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    12.4.3 STL exceptions

    +

    11.4.3 STL exceptions

    @@ -1733,10 +1733,10 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    12.4.4 shared_ptr smart pointer

    +

    11.4.4 shared_ptr smart pointer

    -

    12.4.4.1 shared_ptr basics

    +

    11.4.4.1 shared_ptr basics

    @@ -1832,7 +1832,7 @@ System.out.println(val1 + " " + val2); -

    12.4.4.2 shared_ptr and inheritance

    +

    11.4.4.2 shared_ptr and inheritance

    @@ -1923,7 +1923,7 @@ Adding the missing %shared_ptr macros will fix this: -

    12.4.4.3 shared_ptr and method overloading

    +

    11.4.4.3 shared_ptr and method overloading

    @@ -1945,7 +1945,7 @@ SWIG will choose to wrap just the first method by default. For the interested reader, SWIG detects that they are equivalent types via the typecheck typemaps in the shared_ptr library.

    -

    12.4.4.4 shared_ptr and templates

    +

    11.4.4.4 shared_ptr and templates

    @@ -1987,7 +1987,7 @@ The SWIG code below shows the required ordering: -

    12.4.4.5 shared_ptr and directors

    +

    11.4.4.5 shared_ptr and directors

    @@ -1995,7 +1995,7 @@ The languages that support shared_ptr also have support for using shared_ptr wit

    -

    12.4.5 auto_ptr smart pointer

    +

    11.4.5 auto_ptr smart pointer

    @@ -2044,10 +2044,10 @@ int value = k.getValue(); -

    12.5 Utility Libraries

    +

    11.5 Utility Libraries

    -

    12.5.1 exception.i

    +

    11.5.1 exception.i

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 80807baf4..431ac1c14 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

    29 SWIG and Lua

    +

    28 SWIG and Lua

      @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      29.1 Preliminaries

      +

      28.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      29.2 Running SWIG

      +

      28.2 Running SWIG

      @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      29.2.1 Additional command line options

      +

      28.2.1 Additional command line options

      @@ -179,7 +179,7 @@ swig -lua -help -

      29.2.2 Compiling and Linking and Interpreter

      +

      28.2.2 Compiling and Linking and Interpreter

      @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      29.2.3 Compiling a dynamic module

      +

      28.2.3 Compiling a dynamic module

      @@ -318,7 +318,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

      29.2.4 Using your module

      +

      28.2.4 Using your module

      @@ -336,19 +336,19 @@ $ ./my_lua >

    -

    29.3 A tour of basic C/C++ wrapping

    +

    28.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.

    -

    29.3.1 Modules

    +

    28.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.

    -

    29.3.2 Functions

    +

    28.3.2 Functions

    @@ -389,7 +389,7 @@ It is also possible to rename the module with an assignment. 24 -

    29.3.3 Global variables

    +

    28.3.3 Global variables

    @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    29.3.4 Constants and enums

    +

    28.3.4 Constants and enums

    @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    29.3.4.1 Constants/enums and classes/structures

    +

    28.3.4.1 Constants/enums and classes/structures

    @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    29.3.5 Pointers

    +

    28.3.5 Pointers

    @@ -606,7 +606,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    29.3.6 Structures

    +

    28.3.6 Structures

    @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    29.3.7 C++ classes

    +

    28.3.7 C++ classes

    @@ -786,7 +786,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    29.3.8 C++ inheritance

    +

    28.3.8 C++ inheritance

    @@ -811,7 +811,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    29.3.9 Pointers, references, values, and arrays

    +

    28.3.9 Pointers, references, values, and arrays

    @@ -842,7 +842,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.

    -

    29.3.10 C++ overloaded functions

    +

    28.3.10 C++ overloaded functions

    @@ -928,7 +928,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.

    -

    29.3.11 C++ operators

    +

    28.3.11 C++ operators

    @@ -1062,7 +1062,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    29.3.12 Class extension with %extend

    +

    28.3.12 Class extension with %extend

    @@ -1119,7 +1119,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).

    -

    29.3.13 Using %newobject to release memory

    +

    28.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1143,7 +1143,7 @@ char *foo();

    This will release the allocated memory.

    -

    29.3.14 C++ templates

    +

    28.3.14 C++ templates

    @@ -1178,7 +1178,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.

    -

    29.3.15 C++ Smart Pointers

    +

    28.3.15 C++ Smart Pointers

    @@ -1230,7 +1230,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    29.3.16 C++ Exceptions

    +

    28.3.16 C++ Exceptions

    @@ -1373,7 +1373,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    29.3.17 Namespaces

    +

    28.3.17 Namespaces

    @@ -1424,7 +1424,7 @@ Now, from Lua usage is as follows: 19 > -

    29.3.17.1 Compatibility Note

    +

    28.3.17.1 Compatibility Note

    @@ -1440,7 +1440,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    29.3.17.2 Names

    +

    28.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1485,7 +1485,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    29.3.17.3 Inheritance

    +

    28.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1530,12 +1530,12 @@ function > -

    29.4 Typemaps

    +

    28.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    29.4.1 What is a typemap?

    +

    28.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:

    @@ -1563,7 +1563,7 @@ Received an integer : 6 720 -

    29.4.2 Using typemaps

    +

    28.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.

    @@ -1616,7 +1616,7 @@ void swap(int *sx, int *sy);

    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).

    -

    29.4.3 Typemaps and arrays

    +

    28.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 @@ -1680,7 +1680,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

    Note: SWIG also can support arrays of pointers in a similar manner.

    -

    29.4.4 Typemaps and pointer-pointer functions

    +

    28.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:

    @@ -1714,7 +1714,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    29.5 Writing typemaps

    +

    28.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.

    @@ -1723,7 +1723,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    29.5.1 Typemaps you can write

    +

    28.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.

    @@ -1736,7 +1736,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    29.5.2 SWIG's Lua-C API

    +

    28.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.

    @@ -1785,7 +1785,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    29.6 Customization of your Bindings

    +

    28.6 Customization of your Bindings

    @@ -1794,7 +1794,7 @@ This section covers adding of some small extra bits to your module to add the la -

    29.6.1 Writing your own custom wrappers

    +

    28.6.1 Writing your own custom wrappers

    @@ -1813,7 +1813,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    29.6.2 Adding additional Lua code

    +

    28.6.2 Adding additional Lua code

    @@ -1851,7 +1851,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.

    -

    29.7 Details on the Lua binding

    +

    28.7 Details on the Lua binding

    @@ -1862,7 +1862,7 @@ See Examples/lua/arrays for an example of this code.

    -

    29.7.1 Binding global data into the module.

    +

    28.7.1 Binding global data into the module.

    @@ -1922,7 +1922,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)'.

    -

    29.7.2 Userdata and Metatables

    +

    28.7.2 Userdata and Metatables

    @@ -2002,7 +2002,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    29.7.3 Memory management

    +

    28.7.3 Memory management

    diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index b9b7b2b94..7efd74e2b 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -7,7 +7,7 @@ -

    20 Working with Modules

    +

    19 Working with Modules

    -

    38.3 External documentation

    +

    37.3 External documentation

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 4ae07e969..92b5260fe 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -7,7 +7,7 @@ -

    39 SWIG and OCaml

    +

    38 SWIG and OCaml

    -

    39.1.3 The camlp4 module

    +

    38.1.3 The camlp4 module

    @@ -242,7 +242,7 @@ let b = C_string (getenv "PATH") -

    39.1.4 Using your module

    +

    38.1.4 Using your module

    @@ -256,7 +256,7 @@ option to build your functions into the primitive list. This option is not needed when you build native code.

    -

    39.1.5 Compilation problems and compiling with C++

    +

    38.1.5 Compilation problems and compiling with C++

    @@ -267,7 +267,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

    -

    39.2 The low-level Ocaml/C interface

    +

    38.2 The low-level Ocaml/C interface

    @@ -367,7 +367,7 @@ value items pass through directly, but you must make your own type signature for a function that uses value in this way.

    -

    39.2.1 The generated module

    +

    38.2.1 The generated module

    @@ -401,7 +401,7 @@ it describes the output SWIG will generate for class definitions. -

    39.2.2 Enums

    +

    38.2.2 Enums

    @@ -464,7 +464,7 @@ val x : Enum_test.c_obj = C_enum `a

    -

    39.2.2.1 Enum typing in Ocaml

    +

    38.2.2.1 Enum typing in Ocaml

    @@ -477,10 +477,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

    -

    39.2.3 Arrays

    +

    38.2.3 Arrays

    -

    39.2.3.1 Simple types of bounded arrays

    +

    38.2.3.1 Simple types of bounded arrays

    @@ -501,7 +501,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

    -

    39.2.3.2 Complex and unbounded arrays

    +

    38.2.3.2 Complex and unbounded arrays

    @@ -514,7 +514,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.

    -

    39.2.3.3 Using an object

    +

    38.2.3.3 Using an object

    @@ -528,7 +528,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

    -

    39.2.3.4 Example typemap for a function taking float * and int

    +

    38.2.3.4 Example typemap for a function taking float * and int

    @@ -579,7 +579,7 @@ void printfloats( float *tab, int len ); -

    39.2.4 C++ Classes

    +

    38.2.4 C++ Classes

    @@ -622,7 +622,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

    -

    39.2.4.1 STL vector and string Example

    +

    38.2.4.1 STL vector and string Example

    @@ -702,7 +702,7 @@ baz # -

    39.2.4.2 C++ Class Example

    +

    38.2.4.2 C++ Class Example

    @@ -732,7 +732,7 @@ public: }; -

    39.2.4.3 Compiling the example

    +

    38.2.4.3 Compiling the example

    @@ -750,7 +750,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
       -L$QTPATH/lib -cclib -lqt
     
    -

    39.2.4.4 Sample Session

    +

    38.2.4.4 Sample Session

    @@ -777,10 +777,10 @@ Assuming you have a working installation of QT, you will see a window
     containing the string "hi" in a button.
     

    -

    39.2.5 Director Classes

    +

    38.2.5 Director Classes

    -

    39.2.5.1 Director Introduction

    +

    38.2.5.1 Director Introduction

    @@ -807,7 +807,7 @@ class foo { };

    -

    39.2.5.2 Overriding Methods in Ocaml

    +

    38.2.5.2 Overriding Methods in Ocaml

    @@ -835,7 +835,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.

    -

    39.2.5.3 Director Usage Example

    +

    38.2.5.3 Director Usage Example

    @@ -896,7 +896,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

    -

    39.2.5.4 Creating director objects

    +

    38.2.5.4 Creating director objects

    @@ -937,7 +937,7 @@ object from causing a core dump, as long as the object is destroyed properly.

    -

    39.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    38.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -948,7 +948,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.

    -

    39.2.5.6 directorin typemap

    +

    38.2.5.6 directorin typemap

    @@ -959,7 +959,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

    -

    39.2.5.7 directorout typemap

    +

    38.2.5.7 directorout typemap

    @@ -970,7 +970,7 @@ for the same type, except when there are special requirements for object ownership, etc.

    -

    39.2.5.8 directorargout typemap

    +

    38.2.5.8 directorargout typemap

    @@ -987,7 +987,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.

    -

    39.2.6 Exceptions

    +

    38.2.6 Exceptions

    @@ -1075,7 +1075,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    39.3 Documentation Features

    +

    38.3 Documentation Features

    @@ -1084,7 +1084,7 @@ comments (colloquially referred to as "docstrings") that can be read by OCamldoc.

    -

    39.3.1 Module docstring

    +

    38.3.1 Module docstring

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index bdef5db7c..bd6b08ff9 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -9,7 +9,7 @@ -

    30 SWIG and Octave

    +

    29 SWIG and Octave

      @@ -60,7 +60,7 @@ This chapter is intended to give an introduction to using the module. You should 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).

      -

      30.1 Preliminaries

      +

      29.1 Preliminaries

      @@ -76,7 +76,7 @@ This cannot be guaranteed however, as in recent times new Octave releases have r The SWIG runtime exports the function swig_octave_prereq() for checking the version of Octave.

      -

      30.2 Running SWIG

      +

      29.2 Running SWIG

      @@ -108,7 +108,7 @@ The -c++ option is also required when wrapping C++ code: This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

      -

      30.2.1 Command-line options

      +

      29.2.1 Command-line options

      @@ -131,7 +131,7 @@ The special name "." loads C global variables into the module namespace, i.e. al The -opprefix options sets the prefix of the names of global/friend operator functions.

      -

      30.2.2 Compiling a dynamic module

      +

      29.2.2 Compiling a dynamic module

      @@ -158,7 +158,7 @@ $ mkoctfile example_wrap.cpp example.c

      octave:1> swigexample
      -

      30.2.3 Using your module

      +

      29.2.3 Using your module

      @@ -176,10 +176,10 @@ octave:4> swigexample.cvar.Foo=4; octave:5> swigexample.cvar.Foo ans = 4

    -

    30.3 A tour of basic C/C++ wrapping

    +

    29.3 A tour of basic C/C++ wrapping

    -

    30.3.1 Modules

    +

    29.3.1 Modules

    @@ -224,7 +224,7 @@ octave:4> swigexample.gcd(4, 6) ans = 2 -

    30.3.2 Functions

    +

    29.3.2 Functions

    @@ -241,7 +241,7 @@ int fact(int n);

    octave:1> swigexample.fact(4)
     24 
    -

    30.3.3 Global variables

    +

    29.3.3 Global variables

    @@ -294,7 +294,7 @@ octave:2> swigexample.PI=3.142; octave:3> swigexample.PI ans = 3.1420 -

    30.3.4 Constants and enums

    +

    29.3.4 Constants and enums

    @@ -316,7 +316,7 @@ swigexample.SCONST="Hello World" swigexample.SUNDAY=0 .... -

    30.3.5 Pointers

    +

    29.3.5 Pointers

    @@ -363,7 +363,7 @@ octave:2> f=swigexample.fopen("not there", "r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

    30.3.6 Structures and C++ classes

    +

    29.3.6 Structures and C++ classes

    @@ -498,7 +498,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.

    -

    30.3.7 C++ inheritance

    +

    29.3.7 C++ inheritance

    @@ -507,7 +507,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.

    -

    30.3.8 C++ overloaded functions

    +

    29.3.8 C++ overloaded functions

    @@ -517,7 +517,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.

    -

    30.3.9 C++ operators

    +

    29.3.9 C++ operators

    @@ -621,7 +621,7 @@ On the C++ side, the default mappings are as follows: Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

    -

    30.3.10 Class extension with %extend

    +

    29.3.10 Class extension with %extend

    @@ -660,7 +660,7 @@ Similarly, Octave can use the __float__ method to convert an object to Octave 3.8.0 and later versions will also map unary functions X() to the corresponding __X__ method, where X includes: abs(), acos(), acosh(), angle(), arg(), asin(), asinh(), atan(), atanh(), cbrt(), ceil(), conj(), cos(), cosh(), dawson(), erf(), erfc(), erfcinv(), erfcx(), erfi(), erfinv(), exp(), expm1(), finite(), fix(), floor(), gamma(), imag(), isalnum(), isalpha(), isascii(), iscntrl(), isdigit(), isgraph(), isinf(), islower(), isna(), isnan(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), lgamma(), log(), log10(), log1p(), log2(), real(), round(), roundb(), signbit(), signum(), sin(), sinh(), sqrt(), tan(), tanh(), toascii(), tolower(), toupper()

    -

    30.3.11 C++ templates

    +

    29.3.11 C++ templates

    @@ -737,10 +737,10 @@ ans = -

    30.3.12 C++ Smart Pointers

    +

    29.3.12 C++ Smart Pointers

    -

    30.3.12.1 The shared_ptr Smart Pointer

    +

    29.3.12.1 The shared_ptr Smart Pointer

    @@ -751,14 +751,14 @@ in the shared_ptr smart pointer -

    30.3.12.2 Generic Smart Pointers

    +

    29.3.12.2 Generic Smart Pointers

    C++ smart pointers are fully supported as in other modules.

    -

    30.3.13 Directors (calling Octave from C++ code)

    +

    29.3.13 Directors (calling Octave from C++ code)

    @@ -839,14 +839,14 @@ c-side routine called octave-side routine called -

    30.3.14 Threads

    +

    29.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.

    -

    30.3.15 Memory management

    +

    29.3.15 Memory management

    @@ -880,14 +880,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).

    -

    30.3.16 STL support

    +

    29.3.16 STL support

    Various STL library files are provided for wrapping STL containers.

    -

    30.3.17 Matrix typemaps

    +

    29.3.17 Matrix typemaps

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 1e7bd9f86..766ccaede 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -7,7 +7,7 @@ -

    31 SWIG and Perl5

    +

    30 SWIG and Perl5

    -

    31.2.2 Compiling a dynamic module

    +

    30.2.2 Compiling a dynamic module

    @@ -208,7 +208,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

    -

    31.2.3 Building a dynamic module with MakeMaker

    +

    30.2.3 Building a dynamic module with MakeMaker

    @@ -242,7 +242,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.

    -

    31.2.4 Building a static version of Perl

    +

    30.2.4 Building a static version of Perl

    @@ -311,7 +311,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

    -

    31.2.5 Using the module

    +

    30.2.5 Using the module

    @@ -464,7 +464,7 @@ system configuration (this requires root access and you will need to read the man pages).

    -

    31.2.6 Compilation problems and compiling with C++

    +

    30.2.6 Compilation problems and compiling with C++

    @@ -607,7 +607,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.

    -

    31.2.7 Compiling for 64-bit platforms

    +

    30.2.7 Compiling for 64-bit platforms

    @@ -634,7 +634,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

    -

    31.3 Building Perl Extensions under Windows

    +

    30.3 Building Perl Extensions under Windows

    @@ -645,7 +645,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

    -

    31.3.1 Running SWIG from Developer Studio

    +

    30.3.1 Running SWIG from Developer Studio

    @@ -708,7 +708,7 @@ print "$a\n"; -

    31.3.2 Using other compilers

    +

    30.3.2 Using other compilers

    @@ -716,7 +716,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.

    -

    31.4 The low-level interface

    +

    30.4 The low-level interface

    @@ -726,7 +726,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.

    -

    31.4.1 Functions

    +

    30.4.1 Functions

    @@ -749,7 +749,7 @@ use example; $a = &example::fact(2); -

    31.4.2 Global variables

    +

    30.4.2 Global variables

    @@ -819,7 +819,7 @@ extern char *path; // Declared later in the input -

    31.4.3 Constants

    +

    30.4.3 Constants

    @@ -859,7 +859,7 @@ print example::FOO, "\n"; -

    31.4.4 Pointers

    +

    30.4.4 Pointers

    @@ -968,7 +968,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

    -

    31.4.5 Structures

    +

    30.4.5 Structures

    @@ -1102,7 +1102,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

    31.4.6 C++ classes

    +

    30.4.6 C++ classes

    @@ -1167,7 +1167,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.

    -

    31.4.7 C++ classes and type-checking

    +

    30.4.7 C++ classes and type-checking

    @@ -1203,7 +1203,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

    -

    31.4.8 C++ overloaded functions

    +

    30.4.8 C++ overloaded functions

    @@ -1247,7 +1247,7 @@ example::Spam_foo_d($s, 3.14); Please refer to the "SWIG Basics" chapter for more information.

    -

    31.4.9 Operators

    +

    30.4.9 Operators

    @@ -1274,7 +1274,7 @@ The following C++ operators are currently supported by the Perl module:

  • operator or
  • -

    31.4.10 Modules and packages

    +

    30.4.10 Modules and packages

    @@ -1369,7 +1369,7 @@ print Foo::fact(4), "\n"; # Call a function in package FooBar --> -

    31.5 Input and output parameters

    +

    30.5 Input and output parameters

    @@ -1588,7 +1588,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

    -

    31.6 Exception handling

    +

    30.6 Exception handling

    @@ -1752,7 +1752,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

    -

    31.7 Remapping datatypes with typemaps

    +

    30.7 Remapping datatypes with typemaps

    @@ -1769,7 +1769,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

    -

    31.7.1 A simple typemap example

    +

    30.7.1 A simple typemap example

    @@ -1873,7 +1873,7 @@ example::count("e", "Hello World"); -

    31.7.2 Perl5 typemaps

    +

    30.7.2 Perl5 typemaps

    @@ -1978,7 +1978,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

    31.7.3 Typemap variables

    +

    30.7.3 Typemap variables

    @@ -2049,7 +2049,7 @@ properly assigned. The Perl name of the wrapper function being created. -

    31.7.4 Useful functions

    +

    30.7.4 Useful functions

    @@ -2118,7 +2118,7 @@ int sv_isa(SV *, char *0; -

    31.8 Typemap Examples

    +

    30.8 Typemap Examples

    @@ -2127,7 +2127,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

    -

    31.8.1 Converting a Perl5 array to a char **

    +

    30.8.1 Converting a Perl5 array to a char **

    @@ -2219,7 +2219,7 @@ print @$b, "\n"; # Print it out -

    31.8.2 Return values

    +

    30.8.2 Return values

    @@ -2248,7 +2248,7 @@ can be done using the EXTEND() macro as in: } -

    31.8.3 Returning values from arguments

    +

    30.8.3 Returning values from arguments

    @@ -2302,7 +2302,7 @@ print "multout(7, 13) = @r\n"; ($x, $y) = multout(7, 13); -

    31.8.4 Accessing array structure members

    +

    30.8.4 Accessing array structure members

    @@ -2365,7 +2365,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

    -

    31.8.5 Turning Perl references into C pointers

    +

    30.8.5 Turning Perl references into C pointers

    @@ -2430,7 +2430,7 @@ print "$c\n"; -

    31.8.6 Pointer handling

    +

    30.8.6 Pointer handling

    @@ -2515,7 +2515,7 @@ For example: -

    31.9 Proxy classes

    +

    30.9 Proxy classes

    @@ -2531,7 +2531,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

    -

    31.9.1 Preliminaries

    +

    30.9.1 Preliminaries

    @@ -2553,7 +2553,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.

    -

    31.9.2 Structure and class wrappers

    +

    30.9.2 Structure and class wrappers

    @@ -2680,7 +2680,7 @@ $v->DESTROY(); -

    31.9.3 Object Ownership

    +

    30.9.3 Object Ownership

    @@ -2767,7 +2767,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

    -

    31.9.4 Nested Objects

    +

    30.9.4 Nested Objects

    @@ -2820,7 +2820,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

    31.9.5 Proxy Functions

    +

    30.9.5 Proxy Functions

    @@ -2854,7 +2854,7 @@ This function replaces the original function, but operates in an identical manner.

    -

    31.9.6 Inheritance

    +

    30.9.6 Inheritance

    @@ -2930,7 +2930,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

    -

    31.9.7 Modifying the proxy methods

    +

    30.9.7 Modifying the proxy methods

    @@ -2958,7 +2958,7 @@ public: }; -

    31.10 Adding additional Perl code

    +

    30.10 Adding additional Perl code

    @@ -3009,7 +3009,7 @@ set_transform($im, $a); -

    31.11 Cross language polymorphism

    +

    30.11 Cross language polymorphism

    @@ -3043,7 +3043,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    31.11.1 Enabling directors

    +

    30.11.1 Enabling directors

    @@ -3133,7 +3133,7 @@ sub one { -

    31.11.2 Director classes

    +

    30.11.2 Director classes

    @@ -3214,7 +3214,7 @@ so there is no need for the extra overhead involved with routing the calls through Perl.

    -

    31.11.3 Ownership and object destruction

    +

    30.11.3 Ownership and object destruction

    @@ -3263,7 +3263,7 @@ sub DESTROY { -

    31.11.4 Exception unrolling

    +

    30.11.4 Exception unrolling

    @@ -3319,7 +3319,7 @@ Swig::DirectorMethodException is thrown, Perl will register the exception as soon as the C wrapper function returns.

    -

    31.11.5 Overhead and code bloat

    +

    30.11.5 Overhead and code bloat

    @@ -3353,7 +3353,7 @@ directive) for only those methods that are likely to be extended in Perl.

    -

    31.11.6 Typemaps

    +

    30.11.6 Typemaps

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 09c514e94..d0ec0df7f 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

    32 SWIG and PHP

    +

    31 SWIG and PHP

    -

    32.1.2 Using PHP Extensions

    +

    31.1.2 Using PHP Extensions

    @@ -182,7 +182,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll almost certainly want to include it anyway.

    -

    32.2 Basic PHP interface

    +

    31.2 Basic PHP interface

    @@ -194,7 +194,7 @@ SWIG doesn't have support for generating wrappers which make use of PHP's namespace feature.

    -

    32.2.1 Constants

    +

    31.2.1 Constants

    @@ -273,7 +273,7 @@ is treated as true by the if test, when the value of the intended constant would be treated as false!

    -

    32.2.2 Global Variables

    +

    31.2.2 Global Variables

    @@ -322,7 +322,7 @@ undefined. At this time SWIG does not support custom accessor methods.

    -

    32.2.3 Functions

    +

    31.2.3 Functions

    @@ -375,7 +375,7 @@ print $s; # The value of $s was not changed. --> -

    32.2.4 Overloading

    +

    31.2.4 Overloading

    @@ -430,7 +430,7 @@ taking the integer argument.

    --> -

    32.2.5 Pointers and References

    +

    31.2.5 Pointers and References

    @@ -568,7 +568,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

    -

    32.2.6 Structures and C++ classes

    +

    31.2.6 Structures and C++ classes

    @@ -629,7 +629,7 @@ Would be used in the following way from PHP: Member variables and methods are accessed using the -> operator.

    -

    32.2.6.1 Using -noproxy

    +

    31.2.6.1 Using -noproxy

    @@ -655,7 +655,7 @@ Complex_im_set($obj, $d); Complex_im_get($obj); -

    32.2.6.2 Constructors and Destructors

    +

    31.2.6.2 Constructors and Destructors

    @@ -696,7 +696,7 @@ the programmer can either reassign the variable or call unset($v)

    -

    32.2.6.3 Static Member Variables

    +

    31.2.6.3 Static Member Variables

    @@ -739,7 +739,7 @@ Ko::threats(10); echo "There have now been " . Ko::threats() . " threats\n"; -

    32.2.6.4 Static Member Functions

    +

    31.2.6.4 Static Member Functions

    @@ -761,7 +761,7 @@ Ko::threats(); -

    32.2.6.5 Specifying Implemented Interfaces

    +

    31.2.6.5 Specifying Implemented Interfaces

    @@ -779,7 +779,7 @@ so: If there are multiple interfaces, just list them separated by commas.

    -

    32.2.7 PHP Pragmas, Startup and Shutdown code

    +

    31.2.7 PHP Pragmas, Startup and Shutdown code

    @@ -876,7 +876,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

    -

    32.3 Cross language polymorphism

    +

    31.3 Cross language polymorphism

    @@ -911,7 +911,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

    -

    32.3.1 Enabling directors

    +

    31.3.1 Enabling directors

    @@ -1000,7 +1000,7 @@ class MyFoo extends Foo { -

    32.3.2 Director classes

    +

    31.3.2 Director classes

    @@ -1081,7 +1081,7 @@ so there is no need for the extra overhead involved with routing the calls through PHP.

    -

    32.3.3 Ownership and object destruction

    +

    31.3.3 Ownership and object destruction

    @@ -1137,7 +1137,7 @@ In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

    -

    32.3.4 Exception unrolling

    +

    31.3.4 Exception unrolling

    @@ -1204,7 +1204,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

    -

    32.3.5 Overhead and code bloat

    +

    31.3.5 Overhead and code bloat

    @@ -1237,7 +1237,7 @@ optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

    -

    32.3.6 Typemaps

    +

    31.3.6 Typemaps

    @@ -1251,7 +1251,7 @@ need to be supported.

    -

    32.3.7 Miscellaneous

    +

    31.3.7 Miscellaneous

    Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 51cc06378..66061a597 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -7,7 +7,7 @@ -

    11 Preprocessing

    +

    10 Preprocessing

      @@ -38,7 +38,7 @@ However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

      -

      11.1 File inclusion

      +

      10.1 File inclusion

      @@ -64,7 +64,7 @@ By default, the #include is ignored unless you run SWIG with the is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files. -

      11.2 File imports

      +

      10.2 File imports

      @@ -93,7 +93,7 @@ The -importall directive tells SWIG to follow all #include sta as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers. -

      11.3 Conditional Compilation

      +

      10.3 Conditional Compilation

      @@ -165,7 +165,7 @@ way in which an interface is generated or to mix SWIG directives with C code.

      -

      11.4 Macro Expansion

      +

      10.4 Macro Expansion

      @@ -220,7 +220,7 @@ like #x. This is a non-standard SWIG extension.

    -

    11.5 SWIG Macros

    +

    10.5 SWIG Macros

    @@ -266,7 +266,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s support).

    -

    11.6 C99 and GNU Extensions

    +

    10.6 C99 and GNU Extensions

    @@ -322,14 +322,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    11.7 Preprocessing and delimiters

    +

    10.7 Preprocessing and delimiters

    The preprocessor handles { }, " " and %{ %} delimiters differently.

    -

    11.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    +

    10.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -354,7 +354,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    11.7.2 Preprocessing and { ... } delimiters

    +

    10.7.2 Preprocessing and { ... } delimiters

    @@ -396,7 +396,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    11.8 Preprocessor and Typemaps

    +

    10.8 Preprocessor and Typemaps

    @@ -467,7 +467,7 @@ would generate

    -

    11.9 Viewing preprocessor output

    +

    10.9 Viewing preprocessor output

    @@ -477,7 +477,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    11.10 The #error and #warning directives

    +

    10.10 The #error and #warning directives

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index fd07301d4..ee443be53 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -7,7 +7,7 @@ -

    33 SWIG and Python

    +

    32 SWIG and Python

    -

    33.3.3 Global variables

    +

    32.3.3 Global variables

    @@ -1158,7 +1158,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

    -

    33.3.4 Constants and enums

    +

    32.3.4 Constants and enums

    @@ -1198,7 +1198,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    33.3.5 Pointers

    +

    32.3.5 Pointers

    @@ -1339,7 +1339,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

    @@ -1549,7 +1549,7 @@ memory and use of it results in a segfault or some sort of other undefined behav

    -

    33.3.7 C++ classes

    +

    32.3.7 C++ classes

    @@ -1637,7 +1637,7 @@ they are accessed through cvar like this: -

    33.3.8 C++ inheritance

    +

    32.3.8 C++ inheritance

    @@ -1692,7 +1692,7 @@ then the function spam() accepts Foo * or a pointer to any cla 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

    @@ -1753,7 +1753,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

    -

    33.3.10 C++ overloaded functions

    +

    32.3.10 C++ overloaded functions

    @@ -1876,7 +1876,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

    @@ -1973,7 +1973,7 @@ instead of raising an exception when the comparison fails, that is, on any kind This follows the guidelines in PEP 207 - Rich Comparisons and NotImplemented Python constant.

    -

    33.3.12 C++ namespaces

    +

    32.3.12 C++ namespaces

    @@ -2040,7 +2040,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

    @@ -2094,10 +2094,10 @@ Some more complicated examples will appear later.

    -

    33.3.14 C++ Smart Pointers

    +

    32.3.14 C++ Smart Pointers

    -

    33.3.14.1 The shared_ptr Smart Pointer

    +

    32.3.14.1 The shared_ptr Smart Pointer

    @@ -2108,7 +2108,7 @@ in the shared_ptr smart pointer -

    33.3.14.2 Generic Smart Pointers

    +

    32.3.14.2 Generic Smart Pointers

    @@ -2192,7 +2192,7 @@ simply use the __deref__() method. For example: -

    33.3.15 C++ reference counted objects

    +

    32.3.15 C++ reference counted objects

    @@ -2201,7 +2201,7 @@ Python examples of memory management using referencing counting.

    -

    33.4 Further details on the Python class interface

    +

    32.4 Further details on the Python class interface

    @@ -2224,7 +2224,7 @@ the -builtin option are in the Built-in section.

    -

    33.4.1 Proxy classes

    +

    32.4.1 Proxy classes

    @@ -2313,7 +2313,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).

    -

    33.4.2 Built-in Types

    +

    32.4.2 Built-in Types

    @@ -2357,7 +2357,7 @@ please refer to the Python documentation:

    https://docs.python.org/3/extending/newtypes.html

    -

    33.4.2.1 Limitations

    +

    32.4.2.1 Limitations

    Use of the -builtin option implies a couple of limitations: @@ -2518,7 +2518,7 @@ assert(issubclass(B.Derived, A.Base)) -

    33.4.2.2 Operator overloads and slots -- use them!

    +

    32.4.2.2 Operator overloads and slots -- use them!

    The entire justification for the -builtin option is improved @@ -2678,7 +2678,7 @@ in the file python/pyopers.swig in the SWIG library.

    -

    33.4.3 Memory management

    +

    32.4.3 Memory management

    NOTE: Although this section refers to proxy objects, everything here also applies @@ -2873,7 +2873,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

    -

    33.5 Cross language polymorphism

    +

    32.5 Cross language polymorphism

    @@ -2907,7 +2907,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    33.5.1 Enabling directors

    +

    32.5.1 Enabling directors

    @@ -2999,7 +2999,7 @@ class MyFoo(mymodule.Foo): -

    33.5.2 Director classes

    +

    32.5.2 Director classes

    @@ -3079,7 +3079,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

    -

    33.5.3 Ownership and object destruction

    +

    32.5.3 Ownership and object destruction

    @@ -3146,7 +3146,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

    -

    33.5.4 Exception unrolling

    +

    32.5.4 Exception unrolling

    @@ -3205,7 +3205,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

    -

    33.5.5 Overhead and code bloat

    +

    32.5.5 Overhead and code bloat

    @@ -3239,7 +3239,7 @@ directive) for only those methods that are likely to be extended in Python.

    -

    33.5.6 Typemaps

    +

    32.5.6 Typemaps

    @@ -3253,7 +3253,7 @@ need to be supported.

    -

    33.5.7 Miscellaneous

    +

    32.5.7 Miscellaneous

    @@ -3300,7 +3300,7 @@ methods that return const references.

    -

    33.6 Common customization features

    +

    32.6 Common customization features

    @@ -3313,7 +3313,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

    -

    33.6.1 C/C++ helper functions

    +

    32.6.1 C/C++ helper functions

    @@ -3394,7 +3394,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

    -

    33.6.2 Adding additional Python code

    +

    32.6.2 Adding additional Python code

    @@ -3650,7 +3650,7 @@ The same applies for overloaded constructors.

    -

    33.6.3 Class extension with %extend

    +

    32.6.3 Class extension with %extend

    @@ -3739,7 +3739,7 @@ Vector(12, 14, 16) in any way---the extensions only show up in the Python interface.

    -

    33.6.4 Exception handling with %exception

    +

    32.6.4 Exception handling with %exception

    @@ -3873,10 +3873,10 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    33.6.5 Optimization options

    +

    32.6.5 Optimization options

    -

    33.6.5.1 -fastproxy

    +

    32.6.5.1 -fastproxy

    @@ -4009,7 +4009,7 @@ While this possibly provides the best of both worlds, the time to import the mod The command line options mentioned above also apply to wrapped C/C++ global functions, not just class methods.

    -

    33.7 Tips and techniques

    +

    32.7 Tips and techniques

    @@ -4019,7 +4019,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

    -

    33.7.1 Input and output parameters

    +

    32.7.1 Input and output parameters

    @@ -4232,7 +4232,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    33.7.2 Simple pointers

    +

    32.7.2 Simple pointers

    @@ -4301,7 +4301,7 @@ If you replace %pointer_functions() by %pointer_class(type, name)SWIG Library chapter for further details.

    -

    33.7.3 Unbounded C Arrays

    +

    32.7.3 Unbounded C Arrays

    @@ -4363,7 +4363,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    33.7.4 String handling

    +

    32.7.4 String handling

    @@ -4433,7 +4433,7 @@ also be used to extra binary data from arbitrary pointers.

    -

    33.7.5 Default arguments

    +

    32.7.5 Default arguments

    @@ -4532,7 +4532,7 @@ Versions of SWIG prior to this varied in their ability to convert C++ default va equivalent Python default argument values.

    -

    33.8 Typemaps

    +

    32.8 Typemaps

    @@ -4549,7 +4549,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.

    -

    33.8.1 What is a typemap?

    +

    32.8.1 What is a typemap?

    @@ -4665,7 +4665,7 @@ parameter is omitted): -

    33.8.2 Python typemaps

    +

    32.8.2 Python typemaps

    @@ -4706,7 +4706,7 @@ a look at the SWIG library version 1.3.20 or so.

    -

    33.8.3 Typemap variables

    +

    32.8.3 Typemap variables

    @@ -4777,7 +4777,7 @@ properly assigned. The Python name of the wrapper function being created. -

    33.8.4 Useful Python Functions

    +

    32.8.4 Useful Python Functions

    @@ -4905,7 +4905,7 @@ write me -

    33.9 Typemap Examples

    +

    32.9 Typemap Examples

    @@ -4914,7 +4914,7 @@ might look at the files "python.swg" and "typemaps.i" in the SWIG library.

    -

    33.9.1 Converting Python list to a char **

    +

    32.9.1 Converting Python list to a char **

    @@ -4994,7 +4994,7 @@ memory allocation is used to allocate memory for the array, the the C function.

    -

    33.9.2 Expanding a Python object into multiple arguments

    +

    32.9.2 Expanding a Python object into multiple arguments

    @@ -5113,7 +5113,7 @@ TypeError: Wrong number or type of arguments for overloaded function 'foo'. -

    33.9.3 Using typemaps to return arguments

    +

    32.9.3 Using typemaps to return arguments

    @@ -5201,7 +5201,7 @@ function can now be used as follows: >>> -

    33.9.4 Mapping Python tuples into small arrays

    +

    32.9.4 Mapping Python tuples into small arrays

    @@ -5250,7 +5250,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

    -

    33.9.5 Mapping sequences to C arrays

    +

    32.9.5 Mapping sequences to C arrays

    @@ -5339,7 +5339,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

    33.9.6 Pointer handling

    +

    32.9.6 Pointer handling

    @@ -5436,7 +5436,7 @@ that has a this attribute. In addition, class object (if applicable).

    -

    33.9.7 Memory management when returning references to member variables

    +

    32.9.7 Memory management when returning references to member variables

    @@ -5597,7 +5597,7 @@ static PyObject *bike_reference() { -

    33.10 Docstring Features

    +

    32.10 Docstring Features

    @@ -5625,7 +5625,7 @@ of your users much simpler.

    -

    33.10.1 Module docstring

    +

    32.10.1 Module docstring

    @@ -5659,7 +5659,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

    33.10.2 %feature("autodoc")

    +

    32.10.2 %feature("autodoc")

    @@ -5687,7 +5687,7 @@ four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections. -

    33.10.2.1 %feature("autodoc", "0")

    +

    32.10.2.1 %feature("autodoc", "0")

    @@ -5716,7 +5716,7 @@ def function_name(*args, **kwargs): -

    33.10.2.2 %feature("autodoc", "1")

    +

    32.10.2.2 %feature("autodoc", "1")

    @@ -5741,7 +5741,7 @@ def function_name(*args, **kwargs): -

    33.10.2.3 %feature("autodoc", "2")

    +

    32.10.2.3 %feature("autodoc", "2")

    @@ -5803,7 +5803,7 @@ def function_name(*args, **kwargs): -

    33.10.2.4 %feature("autodoc", "3")

    +

    32.10.2.4 %feature("autodoc", "3")

    @@ -5829,7 +5829,7 @@ def function_name(*args, **kwargs): -

    33.10.2.5 %feature("autodoc", "docstring")

    +

    32.10.2.5 %feature("autodoc", "docstring")

    @@ -5848,7 +5848,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

    33.10.3 %feature("docstring")

    +

    32.10.3 %feature("docstring")

    @@ -5880,7 +5880,7 @@ with more than one line. -

    33.11 Python Packages

    +

    32.11 Python Packages

    Python has concepts of modules and packages. Modules are separate units of @@ -5954,7 +5954,7 @@ users may need to use special features such as the package option in th %module directive or import related command line options. These are explained in the following sections.

    -

    33.11.1 Setting the Python package

    +

    32.11.1 Setting the Python package

    @@ -6008,7 +6008,7 @@ pkg1/pkg2/_foo.so # (shared library built from C/C++ code generated by SWI -

    33.11.2 Absolute and relative imports

    +

    32.11.2 Absolute and relative imports

    Suppose, we have the following hierarchy of files:

    @@ -6145,7 +6145,7 @@ uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

    -

    33.11.3 Enforcing absolute import semantics

    +

    32.11.3 Enforcing absolute import semantics

    As you may know, there is an incompatibility in import semantics (for the @@ -6182,7 +6182,7 @@ from __future__ import absolute_import -

    33.11.4 Importing from __init__.py

    +

    32.11.4 Importing from __init__.py

    Imports in __init__.py are handy when you want to populate a @@ -6292,7 +6292,7 @@ class Bar(pkg3.foo.Foo): pass effect (note, that the Python 2 case also needs the -relativeimport workaround).

    -

    33.11.5 Implicit namespace packages

    +

    32.11.5 Implicit namespace packages

    Python 3.3 introduced @@ -6370,7 +6370,7 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

    -

    33.11.6 Location of modules

    +

    32.11.6 Location of modules

    @@ -6406,7 +6406,7 @@ The following sub-sections look more closely at the two default configurations a An input interface file, foo.i, results in the two modules foo.py and _foo.so for each of the configurations.

    -

    33.11.6.1 Both modules in the same package

    +

    32.11.6.1 Both modules in the same package

    @@ -6441,7 +6441,7 @@ from mypackage import foo -

    33.11.6.2 Both modules are global

    +

    32.11.6.2 Both modules are global

    @@ -6473,7 +6473,7 @@ import foo -

    33.11.6.3 Split modules custom configuration

    +

    32.11.6.3 Split modules custom configuration

    In this non-standard 'split module' configuration, the pure Python module is in a package and the low level C/C++ module is global. @@ -6523,7 +6523,7 @@ Using one of the two default configurations is the recommended approach now.

    -

    33.11.6.4 More on customizing the module import code

    +

    32.11.6.4 More on customizing the module import code

    @@ -6643,7 +6643,7 @@ The following will do this for the 33.11.6.5 Statically linked C modules +

    32.11.6.5 Statically linked C modules

    It is strongly recommended to use dynamically linked modules for the C @@ -6715,7 +6715,7 @@ module then you will either need to refer to the Python documentation on how to do this (remember you are now the Python importer) or use dynamic linking.

    -

    33.12 Python 3 Support

    +

    32.12 Python 3 Support

    @@ -6740,7 +6740,7 @@ The following are Python 3 new features that are currently supported by SWIG.

    -

    33.12.1 Function annotation

    +

    32.12.1 Function annotation

    @@ -6773,7 +6773,7 @@ For detailed usage of function annotation, see PEP 3107.

    -

    33.12.2 Buffer interface

    +

    32.12.2 Buffer interface

    @@ -6925,7 +6925,7 @@ modify the buffer. -

    33.12.3 Abstract base classes

    +

    32.12.3 Abstract base classes

    @@ -6975,7 +6975,7 @@ The collections.abc module was introduced in Python 3.3 and hence this requires Python 3.3 or later.

    -

    33.12.4 Byte string output conversion

    +

    32.12.4 Byte string output conversion

    @@ -7156,7 +7156,7 @@ overloads taking both std::string (as Python bytes) and std::wstring (as Python unicode).

    -

    33.12.5 Python 2 Unicode

    +

    32.12.5 Python 2 Unicode

    @@ -7228,7 +7228,7 @@ the first is allowing unicode conversion and the second is explicitly prohibiting it.

    -

    33.13 Support for Multithreaded Applications

    +

    32.13 Support for Multithreaded Applications

    By default, SWIG does not enable support for multithreaded Python applications. More @@ -7243,7 +7243,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai interface for this is described in the next section.

    -

    33.13.1 UI for Enabling Multithreading Support

    +

    32.13.1 UI for Enabling Multithreading Support

    The user interface is as follows:

    @@ -7286,7 +7286,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai -

    33.13.2 Multithread Performance

    +

    32.13.2 Multithread Performance

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index e44fe432c..9ea2d827d 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -7,7 +7,7 @@ -

    34 SWIG and R

    +

    33 SWIG and R

      @@ -43,7 +43,7 @@ to SimpleITK. The R bindings also work on Microsoft Windows using Visual C++.

      -

      34.1 Bugs

      +

      33.1 Bugs

      @@ -57,7 +57,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

    @@ -147,7 +147,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

  • Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into -

    34.3 Precompiling large R files

    +

    33.3 Precompiling large R files

    @@ -172,7 +172,7 @@ There is no need to precompile large R files if the SWIG-generated code is being in an R package. The package infrastructure provides this service during package installation.

    -

    34.4 General policy

    +

    33.4 General policy

    @@ -181,7 +181,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

    @@ -190,7 +190,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    34.6 C++ classes

    +

    33.6 C++ classes

    @@ -310,7 +310,7 @@ defined "_p_Vehicle" The names in the accessorFuns list correspond to class methods while names in the vaccessors section correspond to variables that may be modified.

    -

    34.7 Enumerations

    +

    33.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 5581cc458..6939a8a18 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -8,7 +8,7 @@ -

    35 SWIG and Ruby

    +

    34 SWIG and Ruby

      @@ -149,7 +149,7 @@

      This chapter describes SWIG's support of Ruby.

      -

      35.1 Preliminaries

      +

      34.1 Preliminaries

      SWIG 4.0 is known to work with Ruby versions 1.9 and later. @@ -164,7 +164,7 @@ read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

      -

      35.1.1 Running SWIG

      +

      34.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -188,7 +188,7 @@ if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      35.1.2 Getting the right header files

      +

      34.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -202,7 +202,7 @@ the compiler options needed to compile the code is to ask Ruby itself:

    -

    35.1.3 Compiling a dynamic module

    +

    34.1.3 Compiling a dynamic module

    Ruby extension modules are typically compiled into shared @@ -275,7 +275,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.

    -

    35.1.4 Using your module

    +

    34.1.4 Using your module

    Ruby module names must be capitalized, @@ -305,7 +305,7 @@ begins with:

    will result in an extension module using the feature name "example" and Ruby module name "Example".

    -

    35.1.5 Static linking

    +

    34.1.5 Static linking

    An alternative approach to dynamic linking is to rebuild the @@ -320,7 +320,7 @@ finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

    -

    35.1.6 Compilation of C++ extensions

    +

    34.1.6 Compilation of C++ extensions

    On most machines, C++ extension modules should be linked @@ -352,7 +352,7 @@ $libs = append_library($libs, "supc++") create_makefile('example')

  • -

    35.2 Building Ruby Extensions under Windows 95/NT

    +

    34.2 Building Ruby Extensions under Windows 95/NT

    Building a SWIG extension to Ruby under Windows 95/NT is @@ -377,7 +377,7 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

    -

    35.2.1 Running SWIG from Developer Studio

    +

    34.2.1 Running SWIG from Developer Studio

    If you are developing your application within Microsoft @@ -441,13 +441,13 @@ Foo = 3.0 -

    35.3 The Ruby-to-C/C++ Mapping

    +

    34.3 The Ruby-to-C/C++ Mapping

    This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

    -

    35.3.1 Modules

    +

    34.3.1 Modules

    The SWIG %module directive specifies @@ -519,7 +519,7 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

    -

    35.3.2 Functions

    +

    34.3.2 Functions

    Global functions are wrapped as Ruby module methods. For @@ -553,7 +553,7 @@ irb(main):002:0> Example.fact(4) 24 -

    35.3.3 Variable Linking

    +

    34.3.3 Variable Linking

    C/C++ global variables are wrapped as a pair of singleton @@ -633,7 +633,7 @@ irb(main):004:0> $Variable2 41.2 -

    35.3.4 Constants

    +

    34.3.4 Constants

    C/C++ constants are wrapped as module constants initialized @@ -661,7 +661,7 @@ irb(main):002:0> Example::PI 3.14159 -

    35.3.5 Pointers

    +

    34.3.5 Pointers

    "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -685,7 +685,7 @@ returns an instance of an internally generated Ruby class:

    A NULL pointer is always represented by the Ruby nil object.

    -

    35.3.6 Structures

    +

    34.3.6 Structures

    C/C++ structs are wrapped as Ruby classes, with accessor @@ -790,7 +790,7 @@ void Bar_f_set(Bar *b, Foo *val) { } -

    35.3.7 C++ classes

    +

    34.3.7 C++ classes

    Like structs, C++ classes are wrapped by creating a new Ruby @@ -845,7 +845,7 @@ Ale 3 -

    35.3.8 C++ Inheritance

    +

    34.3.8 C++ Inheritance

    The SWIG type-checker is fully aware of C++ inheritance. @@ -998,7 +998,7 @@ inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

    -

    35.3.9 C++ Overloaded Functions

    +

    34.3.9 C++ Overloaded Functions

    C++ overloaded functions, methods, and constructors are @@ -1088,7 +1088,7 @@ arises--in this case, the first declaration takes precedence.

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    35.3.10 C++ Operators

    +

    34.3.10 C++ Operators

    For the most part, overloaded operators are handled @@ -1130,7 +1130,7 @@ c = Example.add_complex(a, b) is discussed in the section on operator overloading.

    -

    35.3.11 C++ namespaces

    +

    34.3.11 C++ namespaces

    SWIG is aware of C++ namespaces, but namespace names do not @@ -1187,7 +1187,7 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    35.3.12 C++ templates

    +

    34.3.12 C++ templates

    C++ templates don't present a huge problem for SWIG. However, @@ -1229,7 +1229,7 @@ irb(main):004:0> p.second 4 -

    35.3.13 C++ Standard Template Library (STL)

    +

    34.3.13 C++ Standard Template Library (STL)

    On a related note, the standard SWIG library contains a @@ -1322,7 +1322,7 @@ puts v shown in these examples. More details can be found in the SWIG and C++ chapter.

    -

    35.3.14 C++ STL Functors

    +

    34.3.14 C++ STL Functors

    Some containers in the STL allow you to modify their default @@ -1383,7 +1383,7 @@ b -

    35.3.15 C++ STL Iterators

    +

    34.3.15 C++ STL Iterators

    The STL is well known for the use of iterators. There @@ -1466,10 +1466,10 @@ i

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    -

    35.3.16 C++ Smart Pointers

    +

    34.3.16 C++ Smart Pointers

    -

    35.3.16.1 The shared_ptr Smart Pointer

    +

    34.3.16.1 The shared_ptr Smart Pointer

    @@ -1480,7 +1480,7 @@ in the shared_ptr smart pointer -

    35.3.16.2 Generic Smart Pointers

    +

    34.3.16.2 Generic Smart Pointers

    In certain C++ programs, it is common to use classes that @@ -1545,7 +1545,7 @@ method. For example:

    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    -

    35.3.17 Cross-Language Polymorphism

    +

    34.3.17 Cross-Language Polymorphism

    SWIG's Ruby module supports cross-language polymorphism @@ -1554,7 +1554,7 @@ module. Rather than duplicate the information presented in the 35.3.17.1 Exception Unrolling +

    34.3.17.1 Exception Unrolling

    Whenever a C++ director class routes one of its virtual @@ -1577,7 +1577,7 @@ method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    -

    35.4 Naming

    +

    34.4 Naming

    Ruby has several common naming conventions. Constants are @@ -1615,7 +1615,7 @@ generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    -

    35.4.1 Defining Aliases

    +

    34.4.1 Defining Aliases

    It's a fairly common practice in the Ruby built-ins and @@ -1685,7 +1685,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    35.4.2 Predicate Methods

    +

    34.4.2 Predicate Methods

    Ruby methods that return a boolean value and end in a @@ -1734,7 +1734,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    35.4.3 Bang Methods

    +

    34.4.3 Bang Methods

    Ruby methods that modify an object in-place and end in an @@ -1766,7 +1766,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    35.4.4 Getters and Setters

    +

    34.4.4 Getters and Setters

    Often times a C++ library will expose properties through @@ -1801,7 +1801,7 @@ irb(main):003:0> puts foo.value %rename("value=") Foo::setValue(int value); -

    35.5 Input and output parameters

    +

    34.5 Input and output parameters

    A common problem in some C programs is handling parameters @@ -1940,10 +1940,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);

    r, c = Example.get_dimensions(m)
    -

    35.6 Exception handling

    +

    34.6 Exception handling

    -

    35.6.1 Using the %exception directive

    +

    34.6.1 Using the %exception directive

    The SWIG %exception directive can be @@ -2052,7 +2052,7 @@ methods and functions named getitem and setitem. limited to C++ exception handling. See the chapter on Customization Features for more examples.

    -

    35.6.2 Handling Ruby Blocks

    +

    34.6.2 Handling Ruby Blocks

    One of the highlights of Ruby and most of its standard library @@ -2119,7 +2119,7 @@ a special in typemap, like:

    For more information on typemaps, see Typemaps.

    -

    35.6.3 Raising exceptions

    +

    34.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to @@ -2276,7 +2276,7 @@ function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    -

    35.6.4 Exception classes

    +

    34.6.4 Exception classes

    Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -2313,7 +2313,7 @@ end

    For another example look at swig/Examples/ruby/exception_class.

    -

    35.7 Typemaps

    +

    34.7 Typemaps

    This section describes how you can modify SWIG's default @@ -2328,7 +2328,7 @@ 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 primitive C-Ruby interface.

    -

    35.7.1 What is a typemap?

    +

    34.7.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is @@ -2485,7 +2485,7 @@ to be used as follows (notice how the length parameter is omitted):

    2 -

    35.7.2 Typemap scope

    +

    34.7.2 Typemap scope

    Once defined, a typemap remains in effect for all of the @@ -2531,7 +2531,7 @@ where the class itself is defined. For example:

    }; -

    35.7.3 Copying a typemap

    +

    34.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    @@ -2573,7 +2573,7 @@ rules as for %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments -

    35.7.4 Deleting a typemap

    +

    34.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For @@ -2598,7 +2598,7 @@ defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    -

    35.7.5 Placement of typemaps

    +

    34.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, @@ -2669,13 +2669,13 @@ In this example, this is done using the class declaration class string .

    -

    35.7.6 Ruby typemaps

    +

    34.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    -

    35.7.6.1 "in" typemap

    +

    34.7.6.1 "in" typemap

    Converts Ruby objects to input @@ -2742,7 +2742,7 @@ arguments to be specified. For example:

    At this time, only zero or one arguments may be converted.

    -

    35.7.6.2 "typecheck" typemap

    +

    34.7.6.2 "typecheck" typemap

    The "typecheck" typemap is used to support overloaded @@ -2764,7 +2764,7 @@ program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    -

    35.7.6.3 "out" typemap

    +

    34.7.6.3 "out" typemap

    Converts return value of a C function @@ -2815,7 +2815,7 @@ version of the C datatype matched by the typemap.

    -

    35.7.6.4 "arginit" typemap

    +

    34.7.6.4 "arginit" typemap

    The "arginit" typemap is used to set the initial value of a @@ -2830,7 +2830,7 @@ applications. For example:

    } -

    35.7.6.5 "default" typemap

    +

    34.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a @@ -2855,7 +2855,7 @@ arguments that follow must have default values. See the 35.7.6.6 "check" typemap +

    34.7.6.6 "check" typemap

    The "check" typemap is used to supply value checking code @@ -2870,7 +2870,7 @@ arguments have been converted. For example:

    } -

    35.7.6.7 "argout" typemap

    +

    34.7.6.7 "argout" typemap

    The "argout" typemap is used to return values from arguments. @@ -2924,7 +2924,7 @@ some function like SWIG_Ruby_AppendOutput.

    See the typemaps.i library for examples.

    -

    35.7.6.8 "freearg" typemap

    +

    34.7.6.8 "freearg" typemap

    The "freearg" typemap is used to cleanup argument data. It is @@ -2951,7 +2951,7 @@ This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    35.7.6.9 "newfree" typemap

    +

    34.7.6.9 "newfree" typemap

    The "newfree" typemap is used in conjunction with the %newobject @@ -2975,7 +2975,7 @@ string *foo();

    See Object ownership and %newobject for further details.

    -

    35.7.6.10 "memberin" typemap

    +

    34.7.6.10 "memberin" typemap

    The "memberin" typemap is used to copy data from an @@ -2993,21 +2993,21 @@ example:

    already provides a default implementation for arrays, strings, and other objects.

    -

    35.7.6.11 "varin" typemap

    +

    34.7.6.11 "varin" typemap

    The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    35.7.6.12 "varout" typemap

    +

    34.7.6.12 "varout" typemap

    The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

    -

    35.7.6.13 "throws" typemap

    +

    34.7.6.13 "throws" typemap

    The "throws" typemap is only used when SWIG parses a C++ @@ -3048,7 +3048,7 @@ specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    -

    35.7.6.14 directorin typemap

    +

    34.7.6.14 directorin typemap

    Converts C++ objects in director @@ -3107,7 +3107,7 @@ referring to the class itself. -

    35.7.6.15 directorout typemap

    +

    34.7.6.15 directorout typemap

    Converts Ruby objects in director @@ -3180,7 +3180,7 @@ exception.

    -

    35.7.6.16 directorargout typemap

    +

    34.7.6.16 directorargout typemap

    Output argument processing in director @@ -3238,19 +3238,19 @@ referring to the instance of the class itself -

    35.7.6.17 ret typemap

    +

    34.7.6.17 ret typemap

    Cleanup of function return values

    -

    35.7.6.18 globalin typemap

    +

    34.7.6.18 globalin typemap

    Setting of C global variables

    -

    35.7.7 Typemap variables

    +

    34.7.7 Typemap variables

    @@ -3300,7 +3300,7 @@ so that their values can be properly assigned.

    The Ruby name of the wrapper function being created.
    -

    35.7.8 Useful Functions

    +

    34.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -3315,7 +3315,7 @@ stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    -

    35.7.8.1 C Datatypes to Ruby Objects

    +

    34.7.8.1 C Datatypes to Ruby Objects

    @@ -3357,7 +3357,7 @@ SWIG_From_float(float)
    -

    35.7.8.2 Ruby Objects to C Datatypes

    +

    34.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -3425,7 +3425,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -

    35.7.8.3 Macros for VALUE

    +

    34.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -3448,7 +3448,7 @@ versions do not, but return a status value to indicate success (SWIG_OK
    pointer to array storage
    -

    35.7.8.4 Exceptions

    +

    34.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -3527,7 +3527,7 @@ message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf(). -

    35.7.8.5 Iterators

    +

    34.7.8.5 Iterators

    void rb_iter_break()

    @@ -3573,14 +3573,14 @@ VALUE), VALUE value)

    Equivalent to Ruby's throw.
    -

    35.7.9 Typemap Examples

    +

    34.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

    -

    35.7.10 Converting a Ruby array to a char **

    +

    34.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -3645,7 +3645,7 @@ array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    -

    35.7.11 Collecting arguments in a hash

    +

    34.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -3859,7 +3859,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:

    program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    -

    35.7.12 Pointer handling

    +

    34.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -3918,7 +3918,7 @@ For example:

    } -

    35.7.12.1 Ruby Datatype Wrapping

    +

    34.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -3945,7 +3945,7 @@ as above. type c-type from the data object obj and assigns that pointer to ptr. -

    35.7.13 Example: STL Vector to Ruby Array

    +

    34.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -4037,7 +4037,7 @@ STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library. -

    35.8 Docstring Features

    +

    34.8 Docstring Features

    @@ -4071,7 +4071,7 @@ generate ri documentation from a c wrap file, you could do:

    $ rdoc -r file_wrap.c -

    35.8.1 Module docstring

    +

    34.8.1 Module docstring

    @@ -4101,7 +4101,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -

    35.8.2 %feature("autodoc")

    +

    34.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -4122,7 +4122,7 @@ several options for autodoc controlled by the value given to the feature, described below.

    -

    35.8.2.1 %feature("autodoc", "0")

    +

    34.8.2.1 %feature("autodoc", "0")

    @@ -4146,7 +4146,7 @@ Then Ruby code like this will be generated: ... -

    35.8.2.2 %feature("autodoc", "1")

    +

    34.8.2.2 %feature("autodoc", "1")

    @@ -4166,7 +4166,7 @@ this: ... -

    35.8.2.3 %feature("autodoc", "2")

    +

    34.8.2.3 %feature("autodoc", "2")

    @@ -4178,7 +4178,7 @@ parameter types with the "2" option will result in Ruby code like this:

    -

    35.8.2.4 %feature("autodoc", "3")

    +

    34.8.2.4 %feature("autodoc", "3")

    @@ -4199,7 +4199,7 @@ Parameters: bar - Bar -

    35.8.2.5 %feature("autodoc", "docstring")

    +

    34.8.2.5 %feature("autodoc", "docstring")

    @@ -4215,7 +4215,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -

    35.8.3 %feature("docstring")

    +

    34.8.3 %feature("docstring")

    @@ -4226,10 +4226,10 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    -

    35.9 Advanced Topics

    +

    34.9 Advanced Topics

    -

    35.9.1 Operator overloading

    +

    34.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -4410,7 +4410,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    -

    35.9.2 Creating Multi-Module Packages

    +

    34.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -4536,7 +4536,7 @@ irb(main):005:0> c.getX() 5.0 -

    35.9.3 Specifying Mixin Modules

    +

    34.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -4603,7 +4603,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    35.10 Memory Management

    +

    34.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -4626,7 +4626,7 @@ to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    -

    35.10.1 Mark and Sweep Garbage Collector

    +

    34.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -4657,7 +4657,7 @@ any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    -

    35.10.2 Object Ownership

    +

    34.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -4802,7 +4802,7 @@ public:

    This code can be seen in swig/examples/ruby/tracking.

    -

    35.10.3 Object Tracking

    +

    34.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -5028,7 +5028,7 @@ However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    -

    35.10.4 Mark Functions

    +

    34.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -5157,7 +5157,7 @@ irb(main):016:0>

    This code can be seen in swig/examples/ruby/mark_function.

    -

    35.10.5 Free Functions

    +

    34.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -5325,7 +5325,7 @@ been freed, and thus raises a runtime exception.

    This code can be seen in swig/examples/ruby/free_function.

    -

    35.10.6 Embedded Ruby and the C++ Stack

    +

    34.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/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 0c259e393..dc9ae0f7e 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -91,7 +91,6 @@ For additions to the original C++ standard, please read the SWIG and C++11, SWIG and C++14 and SWIG and C++17 chapters. -SWIG and C++20 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ISO C. Support for C++ builds upon ISO C diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 5c4ef6269..88ab8043e 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -9,7 +9,7 @@ -

    36 SWIG and Scilab

    +

    35 SWIG and Scilab

    -

    36.3 A basic tour of C/C++ wrapping

    +

    35.3 A basic tour of C/C++ wrapping

    -

    36.3.1 Overview

    +

    35.3.1 Overview

    @@ -332,7 +332,7 @@ This means that functions, structs, classes, variables, etc... are interfaced th There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    -

    36.3.2 Identifiers

    +

    35.3.2 Identifiers

    @@ -347,7 +347,7 @@ In these cases, the %rename directive Note: truncations can be disabled by specifying the target version 6 of Scilab in the targetversion argument (i.e. -targetversion 6).

    -

    36.3.3 Functions

    +

    35.3.3 Functions

    @@ -378,7 +378,7 @@ ans = 24. -

    36.3.3.1 Argument passing

    +

    35.3.3.1 Argument passing

    @@ -431,7 +431,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are 7. -

    36.3.3.2 Multiple output arguments

    +

    35.3.3.2 Multiple output arguments

    @@ -480,7 +480,7 @@ int divide(int n, int d, int *OUTPUT, int *OUTPUT); -

    36.3.4 Global variables

    +

    35.3.4 Global variables

    @@ -549,10 +549,10 @@ It works the same:

    -

    36.3.5 Constants and enumerations

    +

    35.3.5 Constants and enumerations

    -

    36.3.5.1 Constants

    +

    35.3.5.1 Constants

    @@ -693,7 +693,7 @@ are mapped to Scilab variables, with the same name: 3.14 -

    36.3.5.2 Enumerations

    +

    35.3.5.2 Enumerations

    @@ -758,7 +758,7 @@ typedef enum { RED, BLUE, GREEN } color; -

    36.3.6 Pointers

    +

    35.3.6 Pointers

    @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE". The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    36.3.6.1 Utility functions

    +

    35.3.6.1 Utility functions

    @@ -861,7 +861,7 @@ ans = -

    36.3.6.2 Null pointers:

    +

    35.3.6.2 Null pointers:

    @@ -877,7 +877,7 @@ Using the previous SWIG_this() and SWIG_ptr(), it is possible -

    36.3.7 Structures

    +

    35.3.7 Structures

    @@ -986,7 +986,7 @@ Note: the pointer to the struct works as described in 36.3.8 C++ classes +

    35.3.8 C++ classes

    @@ -1054,7 +1054,7 @@ Note: like structs, class pointers are mapped as described in 36.3.9 C++ inheritance +

    35.3.9 C++ inheritance

    @@ -1129,7 +1129,7 @@ But we can use either use the get_perimeter() function of the parent cl 18.84 -

    36.3.10 C++ overloading

    +

    35.3.10 C++ overloading

    @@ -1169,7 +1169,7 @@ void magnify(Circle *circle, double factor) { -

    36.3.11 Pointers, references, values, and arrays

    +

    35.3.11 Pointers, references, values, and arrays

    @@ -1227,7 +1227,7 @@ All these functions will return a pointer to an instance of Foo. As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.

    -

    36.3.12 C++ templates

    +

    35.3.12 C++ templates

    @@ -1286,7 +1286,7 @@ Then in Scilab: More details on template support can be found in the templates documentation.

    -

    36.3.13 C++ operators

    +

    35.3.13 C++ operators

    @@ -1339,7 +1339,7 @@ private: -

    36.3.14 C++ namespaces

    +

    35.3.14 C++ namespaces

    @@ -1417,7 +1417,7 @@ Note: the nspace feature is not supp

    -

    36.3.15 C++ exceptions

    +

    35.3.15 C++ exceptions

    @@ -1500,17 +1500,17 @@ More complex or custom exception types require specific exception typemaps to be See the SWIG C++ documentation for more details.

    -

    36.3.16 C++ STL

    +

    35.3.16 C++ STL

    The Standard Template Library (STL) is partially supported. See STL for more details.

    -

    36.4 Type mappings and libraries

    +

    35.4 Type mappings and libraries

    -

    36.4.1 Default primitive type mappings

    +

    35.4.1 Default primitive type mappings

    @@ -1561,7 +1561,7 @@ The default behaviour is for SWIG to generate code that will give a runtime erro -

    36.4.2 Arrays

    +

    35.4.2 Arrays

    @@ -1616,7 +1616,7 @@ void printArray(int values[], int len) { [ 0 1 2 3 ] -

    36.4.3 Pointer-to-pointers

    +

    35.4.3 Pointer-to-pointers

    @@ -1689,7 +1689,7 @@ void print_matrix(double **M, int nbRows, int nbCols) { -

    36.4.4 Matrices

    +

    35.4.4 Matrices

    @@ -1782,7 +1782,7 @@ The remarks made earlier for arrays also apply here:

  • There is no control while converting double values to integers, double values are truncated without any checking or warning.
  • -

    36.4.5 STL

    +

    35.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    36.5 Module initialization

    +

    35.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    36.6 Building modes

    +

    35.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    36.6.1 No-builder mode

    +

    35.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    36.6.2 Builder mode

    +

    35.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    36.7 Generated scripts

    +

    35.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    36.7.1 Builder script

    +

    35.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    36.7.2 Loader script

    +

    35.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    36.8 Other resources

    +

    35.8 Other resources

    -

    14.4 Code generation rules

    +

    13.4 Code generation rules

    @@ -1878,7 +1878,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    14.4.1 Scope

    +

    13.4.1 Scope

    @@ -1956,7 +1956,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    14.4.2 Declaring new local variables

    +

    13.4.2 Declaring new local variables

    @@ -2123,7 +2123,7 @@ each type must have its own local variable declaration. -

    14.4.3 Special variables

    +

    13.4.3 Special variables

    @@ -2375,7 +2375,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    14.4.4 Special variable macros

    +

    13.4.4 Special variable macros

    @@ -2387,7 +2387,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    14.4.4.1 $descriptor(type)

    +

    13.4.4.1 $descriptor(type)

    @@ -2398,7 +2398,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    14.4.4.2 $typemap(method, typepattern)

    +

    13.4.4.2 $typemap(method, typepattern)

    @@ -2456,7 +2456,7 @@ The result is the following expansion -

    14.4.5 Special variables and typemap attributes

    +

    13.4.5 Special variables and typemap attributes

    @@ -2483,7 +2483,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    14.4.6 Special variables combined with special variable macros

    +

    13.4.6 Special variables combined with special variable macros

    @@ -2525,7 +2525,7 @@ which then expands to: -

    14.5 Common typemap methods

    +

    13.5 Common typemap methods

    @@ -2533,7 +2533,7 @@ The family of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    14.5.1 "in" typemap

    +

    13.5.1 "in" typemap

    @@ -2593,7 +2593,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    14.5.2 "typecheck" typemap

    +

    13.5.2 "typecheck" typemap

    @@ -2620,7 +2620,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    14.5.3 "out" typemap

    +

    13.5.3 "out" typemap

    @@ -2651,7 +2651,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    14.5.4 "arginit" typemap

    +

    13.5.4 "arginit" typemap

    @@ -2670,7 +2670,7 @@ For example: -

    14.5.5 "default" typemap

    +

    13.5.5 "default" typemap

    @@ -2703,7 +2703,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    14.5.6 "check" typemap

    +

    13.5.6 "check" typemap

    @@ -2722,7 +2722,7 @@ converted. For example: -

    14.5.7 "argout" typemap

    +

    13.5.7 "argout" typemap

    @@ -2768,7 +2768,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    14.5.8 "freearg" typemap

    +

    13.5.8 "freearg" typemap

    @@ -2801,7 +2801,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    14.5.9 "newfree" typemap

    +

    13.5.9 "newfree" typemap

    @@ -2830,7 +2830,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    14.5.10 "ret" typemap

    +

    13.5.10 "ret" typemap

    @@ -2869,7 +2869,7 @@ This approach is an alternative to using the "newfree" typemap and %newobjec is no need to list all the functions that require the memory cleanup, it is purely done on types.

    -

    14.5.11 "memberin" typemap

    +

    13.5.11 "memberin" typemap

    @@ -2891,7 +2891,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    -

    14.5.12 "varin" typemap

    +

    13.5.12 "varin" typemap

    @@ -2899,7 +2899,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    14.5.13 "varout" typemap

    +

    13.5.13 "varout" typemap

    @@ -2907,7 +2907,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    14.5.14 "throws" typemap

    +

    13.5.14 "throws" typemap

    @@ -2957,7 +2957,7 @@ Note that if your methods do not have an exception specification but they do thr Please also see the Exception handling with %exception section for another way to handle exceptions.

    -

    14.6 Some typemap examples

    +

    13.6 Some typemap examples

    @@ -2965,7 +2965,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    14.6.1 Typemaps for arrays

    +

    13.6.1 Typemaps for arrays

    @@ -3224,7 +3224,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    14.6.2 Implementing constraints with typemaps

    +

    13.6.2 Implementing constraints with typemaps

    @@ -3272,7 +3272,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    14.7 Typemaps for multiple target languages

    +

    13.7 Typemaps for multiple target languages

    @@ -3302,7 +3302,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby, in) int "$1 = NUM2INT($input);".

    -

    14.8 Optimal code generation when returning by value

    +

    13.8 Optimal code generation when returning by value

    @@ -3491,7 +3491,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    14.9 Multi-argument typemaps

    +

    13.9 Multi-argument typemaps

    @@ -3768,7 +3768,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    14.10 Typemap warnings

    +

    13.10 Typemap warnings

    @@ -3777,7 +3777,7 @@ See the information in the issuing warnings

    -

    14.11 Typemap fragments

    +

    13.11 Typemap fragments

    @@ -4113,7 +4113,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    14.11.1 Fragment type specialization

    +

    13.11.1 Fragment type specialization

    @@ -4146,7 +4146,7 @@ struct A { -

    14.11.2 Fragments and automatic typemap specialization

    +

    13.11.2 Fragments and automatic typemap specialization

    @@ -4192,7 +4192,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    14.12 The run-time type checker

    +

    13.12 The run-time type checker

    @@ -4218,7 +4218,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    14.12.1 Implementation

    +

    13.12.1 Implementation

    @@ -4412,7 +4412,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    14.12.2 Usage

    +

    13.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4508,7 +4508,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    14.13 Typemaps and overloading

    +

    13.13 Typemaps and overloading

    @@ -4847,7 +4847,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    14.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    +

    13.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    @@ -4949,7 +4949,7 @@ Otherwise both can be wrapped by removing the overloading name ambiguity by rena The 'equivalent' attribute is used in the implementation for the shared_ptr smart pointer library.

    -

    14.14 More about %apply and %clear

    +

    13.14 More about %apply and %clear

    @@ -5054,7 +5054,7 @@ will delete the typemaps for all the typemap methods; namely "in", "check" and " -

    14.15 Passing data between typemaps

    +

    13.15 Passing data between typemaps

    @@ -5091,7 +5091,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    14.16 C++ "this" pointer

    +

    13.16 C++ "this" pointer

    @@ -5151,7 +5151,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    14.17 Where to go for more information?

    +

    13.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 620f2e5a0..9f20469d2 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -7,7 +7,7 @@ -

    17 Variable Length Arguments

    +

    16 Variable Length Arguments

      @@ -43,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      17.1 Introduction

      +

      16.1 Introduction

      @@ -140,7 +140,7 @@ List make_list(const char *s, ...) {

    -

    17.2 The Problem

    +

    16.2 The Problem

    @@ -233,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    17.3 Default varargs support

    +

    16.3 Default varargs support

    @@ -302,7 +302,7 @@ Read on for further solutions.

    -

    17.4 Argument replacement using %varargs

    +

    16.4 Argument replacement using %varargs

    @@ -413,7 +413,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    17.5 Varargs and typemaps

    +

    16.5 Varargs and typemaps

    @@ -593,7 +593,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    17.6 Varargs wrapping with libffi

    +

    16.6 Varargs wrapping with libffi

    @@ -845,7 +845,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    17.7 Wrapping of va_list

    +

    16.7 Wrapping of va_list

    @@ -899,7 +899,7 @@ int my_vprintf(const char *fmt, ...) { -

    17.8 C++ Issues

    +

    16.8 C++ Issues

    @@ -968,7 +968,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    17.9 Discussion

    +

    16.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 0cf2a1066..c63d7de0c 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -7,7 +7,7 @@ -

    19 Warning Messages

    +

    18 Warning Messages

    -

    19.5 Symbolic symbols

    +

    18.5 Symbolic symbols

    @@ -311,7 +311,7 @@ or -

    19.6 Commentary

    +

    18.6 Commentary

    @@ -328,7 +328,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    19.7 Warnings as errors

    +

    18.7 Warnings as errors

    @@ -337,7 +337,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    19.8 Message output format

    +

    18.8 Message output format

    @@ -356,10 +356,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    19.9 Warning number reference

    +

    18.9 Warning number reference

    -

    19.9.1 Deprecated features (100-199)

    +

    18.9.1 Deprecated features (100-199)

      @@ -387,7 +387,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    19.9.2 Preprocessor (200-299)

    +

    18.9.2 Preprocessor (200-299)

      @@ -399,7 +399,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    19.9.3 C/C++ Parser (300-399)

    +

    18.9.3 C/C++ Parser (300-399)

      @@ -476,7 +476,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    19.9.4 Types and typemaps (400-499)

    +

    18.9.4 Types and typemaps (400-499)

      @@ -507,7 +507,7 @@ example.i(4) : Syntax error in input(1). -

      19.9.5 Code generation (500-559)

      +

      18.9.5 Code generation (500-559)

        @@ -538,7 +538,7 @@ example.i(4) : Syntax error in input(1).
      • 525. Destructor declaration is final, name cannot be a director class.
      -

      19.9.6 Doxygen comments (560-599)

      +

      18.9.6 Doxygen comments (560-599)

        @@ -549,7 +549,7 @@ example.i(4) : Syntax error in input(1).
      • 564: Error parsing Doxygen command command: error text. Command ignored."
      -

      19.9.7 Language module specific (700-899)

      +

      18.9.7 Language module specific (700-899)

        @@ -600,14 +600,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      19.9.8 User defined (900-999)

      +

      18.9.8 User defined (900-999)

      These numbers can be used by your own application.

      -

      19.10 History

      +

      18.10 History

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 994b28851..2cb2b18a3 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -7,7 +7,6 @@ SWIGPlus.html CPlusPlus11.html CPlusPlus14.html CPlusPlus17.html -CPlusPlus20.html Preprocessor.html Library.html Arguments.html From efe5f181cf69975cf2fa1dcddefc29b93e4a6196 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Jun 2020 20:19:47 +0100 Subject: [PATCH 1903/2031] html fixes --- Doc/Manual/R.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 9ea2d827d..d0713cade 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -217,7 +217,7 @@ The R interface has the following capabilities:

    • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators.
    -

    34.6.1 Examples

    +

    33.6.1 Examples

    From 470d1926f80b3734034f296f7a9e9c73ed6db854 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Jun 2020 20:47:47 +0100 Subject: [PATCH 1904/2031] Bump version to 4.1.0 --- ANNOUNCE | 8 +-- CHANGES | 145 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 145 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.ac | 2 +- 6 files changed, 154 insertions(+), 150 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b99c0c386..e50bcd463 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 4.0.2 (8 Jun 2020) *** +*** ANNOUNCE: SWIG 4.1.0 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-4.0.2, the latest SWIG release. +We're pleased to announce SWIG-4.1.0, the latest SWIG release. What is SWIG? ============= @@ -25,11 +25,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-4.0.2.tar.gz + http://prdownloads.sourceforge.net/swig/swig-4.1.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-4.0.2.zip + http://prdownloads.sourceforge.net/swig/swigwin-4.1.0.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index fe8696760..05834910a 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,151 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ +Version 4.0.2 (8 Jun 2020) +========================== + +2020-06-07 vigsterkr + [Ruby] #1717 Nil fix mangling strings + +2020-06-07 vadz + #1748 Fix doxygen comments quoting issue + +2020-06-07 munoah + #1800 Escape spaces in file paths for dependencies (-M -MM etc) + +2020-06-06 andreas-schwab + [Ruby] #1801 Fix encoding on big endian systems when wrapping std::wstring. + +2020-05-31 kwwette + [Octave] #1789 error handling improvements and return error code on exit for SWIG wrapped modules. + +2020-05-30 msteinbeck + [D] #1593 Replace broken imports when using newer versions of D. + +2020-05-29: ZackerySpytz + [Python] #1716 Performance improvements converting strings when using Python >= 3.3. + +2020-05-28: ZackerySpytz + #1776 Quite dramatically decrease run times when generating very large interface files by changing + some internal memory pool sizes. + +2020-05-28: mcfarljm + #1788 Fix handling of Doxygen \endlink command. + +2020-05-24: vapier + [Javascript] #1796 Fix pkg-config invocation in configure. + +2020-04-30: kwwette + [Octave] Fix exception raising for newer Octave versions + Since (at least) Octave 5.1.0, the Octave error() function now raises a C++ exception, + which if uncaught immediately exits a SWIG wrapper function, bypassing any cleanup code + that may appear after a "fail:" label. This patch adds a "try { ... } catch(...) { }" + block around the contents of SWIG wrapper functions to first execute the cleanup code + before rethrowing any exception raised. It is backward compatible with earlier versions + of Octave where error() does not raise an exception, which will still branch to the + "fail:" block to execute cleanup code if an error is encountered. + + Note that the new "try { ... } catch(...) { }" block will localise any local variables + used in typemaps that were NOT declared through SWIG's %typemap(...) syntax, so it's + possible this could break existing SWIG wrappers which were implicitly sharing local + variables between typemaps. This can be fixed, however, by declaring local variables + which need to be shared between typemaps through SWIG's %typemap(...) syntax. + +2020-02-18: ryannevell + [Lua] #1728 Add support for LUA lightuserdata to SWIG_Lua_ConvertPtr. + +2020-02-18: dmach + [Ruby] #1725 Fix gcc -Wcatch-value warnings. + +2020-02-14: treitmayr + #1724 Fix wrapping of abstract user-defined conversion operators. + +2020-02-13: ddurham2 + [Python] #1512 Fix memleak when using STL containers of shared_ptr objects. + +2020-02-06: wsfulton + [Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__. + +2020-01-31: vadz + [Ruby] #1651 Add std::auto_ptr<> typemaps. + +2020-01-31: ZackerySpytz + [Python] #1700 More robust error checking for failures in calls to Python C API: + PyBytes_AsStringAndSize() and PyString_AsStringAndSize(). + +2020-01-31: vadz + [Python] #1710 Fix crash parsing empty docstrings. + +2020-01-30: Alzathar + [R] #910 #914 Fix R memory leak on exception. + +2020-01-30: richardbeare + [R] #1511 Fix bug wrapping functions. These were previously incorrectly wrapped as if + they were variables. This happened when 'get' or 'set' was in the name of the function + or method, but sometimes also in some other circumstances. If you were using R + attribute syntax to access these methods, you'll need to switch to calling them as R + methods. + + *** POTENTIAL INCOMPATIBILITY *** + +2020-01-24: etse-dignitas, wsfulton + [C#, D, Java] #1533 Fix upcasting for shared_ptr's of templated types. + +2020-01-16: mcfarljm + #1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters + are used. + +2020-01-16: mcfarljm + #1632 #1659 Fix newline handling for doxygen "///" comments. + +2020-01-14: mcfarljm + #1647 #1656 Fix crash handling empty doxygen comments. + +2020-01-14: mcfarljm + #1608 Improve doxygen support. + - Add support for \param[] commands such as: \param[in]. + - Optional arguments are marked as 'optional' in pydoc. + - Improve support for \code commands so that other languages are supported as code blocks. + Support added for java, c and py. For example Python: \code{.py} ... \endcode + - Fix doxygen handling of \em and \p tags for Python. + +2020-01-13: wsfulton + [Python] #1595 Python -builtin constructors silently ignored keyword arguments. + Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" + exception is thrown if keyword arguments are used. Hence constructors and normal methods/ + functions behave in the same way. Note, -keyword should be used with -builtin to obtain + keyword argument support. + +2020-01-05: jschueller shadchin + [Python] #1670 #1696 Add missing field initializers introduced in python 3.8: + tp_vectorcall and tp_print. + +2020-01-05: friedrichatgc + [Octave] #1688 Change swig_this() to use size_t instead of long for compatibility + with Windows 64 bit. + +2020-01-05: treitmayr + [Ruby] #1692 #1689 Add support for Ruby 2.7 + +2019-12-30: treitmayr + [Ruby] #1653 #1668 Fix code generated when using -globalmodule option. + +2019-12-29: ZackerySpytz + [OCaml] #1686 Fix compilation errors with OCaml 4.09.0. + +2019-12-10: wsfulton + #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when + they are used as part of the scope name of an identifier, such as a namespace name. + +2019-11-26: wsfulton + [C#] #1628 'out' or 'ref' used in a cstype typemap was not always stripped out in parts + of director code generation. + +2019-11-01: wsfulton + [Python] #1595 Fix bug in support for keyword arguments (kwargs feature or -keyword) + when using -builtin. The fix is in the argument error checking when wrapping zero + argument constructors only. + Version 4.0.1 (21 Aug 2019) =========================== diff --git a/CHANGES.current b/CHANGES.current index ba71d5556..a82db8b04 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -4,147 +4,6 @@ See the RELEASENOTES file for a summary of changes in each release. Issue # numbers mentioned below can be found on Github. For more details, add the issue number to the end of the URL: https://github.com/swig/swig/issues/ -Version 4.0.2 (8 Jun 2020) -========================== +Version 4.1.0 (in progress) +=========================== -2020-06-07 vigsterkr - [Ruby] #1717 Nil fix mangling strings - -2020-06-07 vadz - #1748 Fix doxygen comments quoting issue - -2020-06-07 munoah - #1800 Escape spaces in file paths for dependencies (-M -MM etc) - -2020-06-06 andreas-schwab - [Ruby] #1801 Fix encoding on big endian systems when wrapping std::wstring. - -2020-05-31 kwwette - [Octave] #1789 error handling improvements and return error code on exit for SWIG wrapped modules. - -2020-05-30 msteinbeck - [D] #1593 Replace broken imports when using newer versions of D. - -2020-05-29: ZackerySpytz - [Python] #1716 Performance improvements converting strings when using Python >= 3.3. - -2020-05-28: ZackerySpytz - #1776 Quite dramatically decrease run times when generating very large interface files by changing - some internal memory pool sizes. - -2020-05-28: mcfarljm - #1788 Fix handling of Doxygen \endlink command. - -2020-05-24: vapier - [Javascript] #1796 Fix pkg-config invocation in configure. - -2020-04-30: kwwette - [Octave] Fix exception raising for newer Octave versions - Since (at least) Octave 5.1.0, the Octave error() function now raises a C++ exception, - which if uncaught immediately exits a SWIG wrapper function, bypassing any cleanup code - that may appear after a "fail:" label. This patch adds a "try { ... } catch(...) { }" - block around the contents of SWIG wrapper functions to first execute the cleanup code - before rethrowing any exception raised. It is backward compatible with earlier versions - of Octave where error() does not raise an exception, which will still branch to the - "fail:" block to execute cleanup code if an error is encountered. - - Note that the new "try { ... } catch(...) { }" block will localise any local variables - used in typemaps that were NOT declared through SWIG's %typemap(...) syntax, so it's - possible this could break existing SWIG wrappers which were implicitly sharing local - variables between typemaps. This can be fixed, however, by declaring local variables - which need to be shared between typemaps through SWIG's %typemap(...) syntax. - -2020-02-18: ryannevell - [Lua] #1728 Add support for LUA lightuserdata to SWIG_Lua_ConvertPtr. - -2020-02-18: dmach - [Ruby] #1725 Fix gcc -Wcatch-value warnings. - -2020-02-14: treitmayr - #1724 Fix wrapping of abstract user-defined conversion operators. - -2020-02-13: ddurham2 - [Python] #1512 Fix memleak when using STL containers of shared_ptr objects. - -2020-02-06: wsfulton - [Python] #1673 #1674 Fix setting 'this' when extending a proxy class with __slots__. - -2020-01-31: vadz - [Ruby] #1651 Add std::auto_ptr<> typemaps. - -2020-01-31: ZackerySpytz - [Python] #1700 More robust error checking for failures in calls to Python C API: - PyBytes_AsStringAndSize() and PyString_AsStringAndSize(). - -2020-01-31: vadz - [Python] #1710 Fix crash parsing empty docstrings. - -2020-01-30: Alzathar - [R] #910 #914 Fix R memory leak on exception. - -2020-01-30: richardbeare - [R] #1511 Fix bug wrapping functions. These were previously incorrectly wrapped as if - they were variables. This happened when 'get' or 'set' was in the name of the function - or method, but sometimes also in some other circumstances. If you were using R - attribute syntax to access these methods, you'll need to switch to calling them as R - methods. - - *** POTENTIAL INCOMPATIBILITY *** - -2020-01-24: etse-dignitas, wsfulton - [C#, D, Java] #1533 Fix upcasting for shared_ptr's of templated types. - -2020-01-16: mcfarljm - #1643 #1654 When using -doxygen, fix segfault when nameless parameters or vararg parameters - are used. - -2020-01-16: mcfarljm - #1632 #1659 Fix newline handling for doxygen "///" comments. - -2020-01-14: mcfarljm - #1647 #1656 Fix crash handling empty doxygen comments. - -2020-01-14: mcfarljm - #1608 Improve doxygen support. - - Add support for \param[] commands such as: \param[in]. - - Optional arguments are marked as 'optional' in pydoc. - - Improve support for \code commands so that other languages are supported as code blocks. - Support added for java, c and py. For example Python: \code{.py} ... \endcode - - Fix doxygen handling of \em and \p tags for Python. - -2020-01-13: wsfulton - [Python] #1595 Python -builtin constructors silently ignored keyword arguments. - Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments" - exception is thrown if keyword arguments are used. Hence constructors and normal methods/ - functions behave in the same way. Note, -keyword should be used with -builtin to obtain - keyword argument support. - -2020-01-05: jschueller shadchin - [Python] #1670 #1696 Add missing field initializers introduced in python 3.8: - tp_vectorcall and tp_print. - -2020-01-05: friedrichatgc - [Octave] #1688 Change swig_this() to use size_t instead of long for compatibility - with Windows 64 bit. - -2020-01-05: treitmayr - [Ruby] #1692 #1689 Add support for Ruby 2.7 - -2019-12-30: treitmayr - [Ruby] #1653 #1668 Fix code generated when using -globalmodule option. - -2019-12-29: ZackerySpytz - [OCaml] #1686 Fix compilation errors with OCaml 4.09.0. - -2019-12-10: wsfulton - #1679 Fix parsing of C++11 identifiers with special meaning (final and override) when - they are used as part of the scope name of an identifier, such as a namespace name. - -2019-11-26: wsfulton - [C#] #1628 'out' or 'ref' used in a cstype typemap was not always stripped out in parts - of director code generation. - -2019-11-01: wsfulton - [Python] #1595 Fix bug in support for keyword arguments (kwargs feature or -keyword) - when using -builtin. The fix is in the argument error checking when wrapping zero - argument constructors only. diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index c851b0847..f02754a7e 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -8,7 +8,7 @@

    SWIG-4.0 Documentation

    -Last update : SWIG-4.0.2 (8 Jun 2020) +Last update : SWIG-4.1.0 (in progress)

    Sections

    diff --git a/README b/README index 24a0de3e8..ba8ded0d5 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 4.0.2 (8 Jun 2020) +Version: 4.1.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua, diff --git a/configure.ac b/configure.ac index 22e3672c3..23c59deea 100644 --- a/configure.ac +++ b/configure.ac @@ -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],[4.0.2],[http://www.swig.org]) +AC_INIT([swig],[4.1.0],[http://www.swig.org]) AC_PREREQ(2.60) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) From dbb88876e61e090ffd5278f9a93b4f8b85558b26 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Jun 2020 20:52:10 +0100 Subject: [PATCH 1905/2031] Allow cygwin to fail on Appveyor --- appveyor.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f87cefd0f..004dee321 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: global: MAKEJOBS: 2 - matrix: +matrix: - SWIGLANG: csharp VSVER: 12 - SWIGLANG: csharp @@ -20,8 +20,6 @@ environment: # VSVER: 14 # VER: 36 # PY3: 3 - - SWIGLANG: python - OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw VER: 27 @@ -31,6 +29,11 @@ environment: VER: 37 PY3: 3 +allow_failures: +# Currently failing due to not detecting header files/include paths + - swiglang: python + osvariant: cygwin + install: - date /T & time /T - ps: >- From b7bcb338cfddcd6e5a294f9e83111e2001732620 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Jun 2020 20:52:57 +0100 Subject: [PATCH 1906/2031] Add C++20 documentation chapter --- Doc/Manual/Android.html | 16 +-- Doc/Manual/Arguments.html | 22 ++-- Doc/Manual/CCache.html | 36 +++--- Doc/Manual/CPlusPlus20.html | 42 +++++++ Doc/Manual/CSharp.html | 60 +++++----- Doc/Manual/Contents.html | 72 ++++++----- Doc/Manual/Contract.html | 10 +- Doc/Manual/Customization.html | 32 ++--- Doc/Manual/D.html | 44 +++---- Doc/Manual/Doxygen.html | 56 ++++----- Doc/Manual/Extending.html | 106 ++++++++-------- Doc/Manual/Go.html | 56 ++++----- Doc/Manual/Guile.html | 44 +++---- Doc/Manual/Introduction.html | 1 + Doc/Manual/Java.html | 220 +++++++++++++++++----------------- Doc/Manual/Javascript.html | 44 +++---- Doc/Manual/Library.html | 50 ++++---- Doc/Manual/Lua.html | 88 +++++++------- Doc/Manual/Modules.html | 16 +-- Doc/Manual/Mzscheme.html | 8 +- Doc/Manual/Ocaml.html | 66 +++++----- Doc/Manual/Octave.html | 52 ++++---- Doc/Manual/Perl5.html | 108 ++++++++--------- Doc/Manual/Php.html | 50 ++++---- Doc/Manual/Preprocessor.html | 26 ++-- Doc/Manual/Python.html | 200 +++++++++++++++---------------- Doc/Manual/R.html | 18 +-- Doc/Manual/Ruby.html | 200 +++++++++++++++---------------- Doc/Manual/SWIGPlus.html | 1 + Doc/Manual/Scilab.html | 90 +++++++------- Doc/Manual/Sections.html | 1 + Doc/Manual/Tcl.html | 92 +++++++------- Doc/Manual/Typemaps.html | 132 ++++++++++---------- Doc/Manual/Varargs.html | 20 ++-- Doc/Manual/Warnings.html | 38 +++--- Doc/Manual/chapters | 1 + 36 files changed, 1088 insertions(+), 1030 deletions(-) create mode 100644 Doc/Manual/CPlusPlus20.html diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 944a88d65..da475e9a4 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -6,7 +6,7 @@ -

    21 SWIG and Android

    +

    22 SWIG and Android

    -

    12.1.3 Output parameters

    +

    13.1.3 Output parameters

    @@ -315,7 +315,7 @@ iresult, dresult = foo(3.5, 2) -

    12.1.4 Input/Output parameters

    +

    13.1.4 Input/Output parameters

    @@ -380,7 +380,7 @@ rather than directly overwriting the value of the original input object. SWIG. Backwards compatibility is preserved, but deprecated.

    -

    12.1.5 Using different names

    +

    13.1.5 Using different names

    @@ -414,7 +414,7 @@ Typemap declarations are lexically scoped so a typemap takes effect from the poi file or a matching %clear declaration.

    -

    12.2 Applying constraints to input values

    +

    13.2 Applying constraints to input values

    @@ -424,7 +424,7 @@ insure that a value is positive, or that a pointer is non-NULL. This can be accomplished including the constraints.i library file.

    -

    12.2.1 Simple constraint example

    +

    13.2.1 Simple constraint example

    @@ -450,7 +450,7 @@ the arguments violate the constraint condition, a scripting language exception will be raised. As a result, it is possible to catch bad values, prevent mysterious program crashes and so on.

    -

    12.2.2 Constraint methods

    +

    13.2.2 Constraint methods

    @@ -466,7 +466,7 @@ NONNULL Non-NULL pointer (pointers only). -

    12.2.3 Applying constraints to new datatypes

    +

    13.2.3 Applying constraints to new datatypes

    diff --git a/Doc/Manual/CCache.html b/Doc/Manual/CCache.html index edd435fa1..1a94709ae 100644 --- a/Doc/Manual/CCache.html +++ b/Doc/Manual/CCache.html @@ -7,7 +7,7 @@ -

    20 Using SWIG with ccache - ccache-swig(1) manpage

    +

    21 Using SWIG with ccache - ccache-swig(1) manpage

    -

    20.14 HISTORY

    +

    21.14 HISTORY

    @@ -423,7 +423,7 @@ 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.

    -

    20.15 DIFFERENCES FROM COMPILERCACHE

    +

    21.15 DIFFERENCES FROM COMPILERCACHE

    @@ -441,7 +441,7 @@ are:

  • ccache avoids a double call to cpp on a cache miss

    -

    20.16 CREDITS

    +

    21.16 CREDITS

    @@ -453,7 +453,7 @@ Thanks to the following people for their contributions to ccache

  • Paul Russell for many suggestions and the debian packaging

    -

    20.17 AUTHOR

    +

    21.17 AUTHOR

    diff --git a/Doc/Manual/CPlusPlus20.html b/Doc/Manual/CPlusPlus20.html new file mode 100644 index 000000000..0a8b0027f --- /dev/null +++ b/Doc/Manual/CPlusPlus20.html @@ -0,0 +1,42 @@ + + + +SWIG and C++20 + + + + + +

    10 SWIG and C++20

    + + + + + + +

    10.1 Introduction

    + + +

    This chapter gives you a brief overview about the SWIG +implementation of the C++20 standard. +Work has only just begun on adding C++20 support. +

    + +

    +Compatibility note: SWIG-4.1.0 is the first version to support any C++20 features. +

    + +

    10.2 Core language changes

    + + +

    10.3 Standard library changes

    + + + + diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 2e6a85147..ef4c0104d 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -6,7 +6,7 @@ -

    22 SWIG and C#

    +

    23 SWIG and C#

    -

    22.4 C# Arrays

    +

    23.4 C# Arrays

    @@ -592,7 +592,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/ pinned arrays.

    -

    22.4.1 The SWIG C arrays library

    +

    23.4.1 The SWIG C arrays library

    @@ -629,7 +629,7 @@ example.print_array(c.cast()); // Pass to C

  • -

    22.4.2 Managed arrays using P/Invoke default array marshalling

    +

    23.4.2 Managed arrays using P/Invoke default array marshalling

    @@ -756,7 +756,7 @@ and intermediary class method -

    22.4.3 Managed arrays using pinning

    +

    23.4.3 Managed arrays using pinning

    @@ -851,7 +851,7 @@ public static extern void myArrayCopy(global::System.IntPtr jarg1, global::Syste -

    22.5 C# Exceptions

    +

    23.5 C# Exceptions

    @@ -948,7 +948,7 @@ set so should only be used when a C# exception is not created.

    -

    22.5.1 C# exception example using "check" typemap

    +

    23.5.1 C# exception example using "check" typemap

    @@ -1130,7 +1130,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.

    -

    22.5.2 C# exception example using %exception

    +

    23.5.2 C# exception example using %exception

    @@ -1195,7 +1195,7 @@ The managed code generated does check for the pending exception as mentioned ear -

    22.5.3 C# exception example using exception specifications

    +

    23.5.3 C# exception example using exception specifications

    @@ -1251,7 +1251,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

    -

    22.5.4 Custom C# ApplicationException example

    +

    23.5.4 Custom C# ApplicationException example

    @@ -1385,7 +1385,7 @@ try { -

    22.6 C# Directors

    +

    23.6 C# Directors

    @@ -1398,7 +1398,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.

    -

    22.6.1 Directors example

    +

    23.6.1 Directors example

    @@ -1519,7 +1519,7 @@ CSharpDerived - UIntMethod(123) -

    22.6.2 Directors implementation

    +

    23.6.2 Directors implementation

    @@ -1727,7 +1727,7 @@ before SWIG parses the Base class will change all the delegates to internal< -

    22.6.3 Director caveats

    +

    23.6.3 Director caveats

    @@ -1775,7 +1775,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.

    -

    22.7 Multiple modules

    +

    23.7 Multiple modules

    @@ -1810,7 +1810,7 @@ the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrows if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.

    -

    22.8 C# Typemap examples

    +

    23.8 C# Typemap examples

    This section includes a few examples of typemaps. For more examples, you @@ -1818,7 +1818,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

    22.8.1 Memory management when returning references to member variables

    +

    23.8.1 Memory management when returning references to member variables

    @@ -1942,7 +1942,7 @@ public class Bike : global::System.IDisposable { Note the addReference call.

    -

    22.8.2 Memory management for objects passed to the C++ layer

    +

    23.8.2 Memory management for objects passed to the C++ layer

    @@ -2074,7 +2074,7 @@ as mentioned earlier, setElement is actually: -

    22.8.3 Date marshalling using the csin typemap and associated attributes

    +

    23.8.3 Date marshalling using the csin typemap and associated attributes

    @@ -2360,7 +2360,7 @@ public class example { -

    22.8.4 A date example demonstrating marshalling of C# properties

    +

    23.8.4 A date example demonstrating marshalling of C# properties

    @@ -2460,7 +2460,7 @@ Some points to note:

  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. -

    22.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    +

    23.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    @@ -2522,7 +2522,7 @@ Pay special attention to the memory management issues, using these attributes.

    -

    22.8.6 Turning proxy classes into partial classes

    +

    23.8.6 Turning proxy classes into partial classes

    @@ -2622,7 +2622,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.

    -

    22.8.7 Turning proxy classes into sealed classes

    +

    23.8.7 Turning proxy classes into sealed classes

    @@ -2712,7 +2712,7 @@ Either suppress the warning or modify the generated code by copying and tweaking 'csbody' typemap code in csharp.swg by modifying swigCMemOwn to not be protected.

    -

    22.8.8 Extending proxy classes with additional C# code

    +

    23.8.8 Extending proxy classes with additional C# code

    @@ -2751,7 +2751,7 @@ public class ExtendMe : global::System.IDisposable { -

    22.8.9 Underlying type for enums

    +

    23.8.9 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 8d1c09df2..79ffdd50e 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -372,7 +372,19 @@ -

    10 Preprocessing

    +

    10 SWIG and C++20

    + + + + + +

    11 Preprocessing

    @@ -395,7 +407,7 @@
    -

    11 SWIG library

    +

    12 SWIG library

    @@ -438,7 +450,7 @@
    -

    12 Argument Handling

    +

    13 Argument Handling

    @@ -461,7 +473,7 @@
    -

    13 Typemaps

    +

    14 Typemaps

    @@ -555,7 +567,7 @@
    -

    14 Customization Features

    +

    15 Customization Features

    @@ -583,7 +595,7 @@
    -

    15 Contracts

    +

    16 Contracts

    @@ -596,7 +608,7 @@
    -

    16 Variable Length Arguments

    +

    17 Variable Length Arguments

    @@ -614,7 +626,7 @@
    -

    17 SWIG and Doxygen Translation

    +

    18 SWIG and Doxygen Translation

    @@ -662,7 +674,7 @@
    -

    18 Warning Messages

    +

    19 Warning Messages

    @@ -691,7 +703,7 @@
    -

    19 Working with Modules

    +

    20 Working with Modules

    @@ -707,7 +719,7 @@
    -

    20 Using SWIG with ccache - ccache-swig(1) manpage

    +

    21 Using SWIG with ccache - ccache-swig(1) manpage

    @@ -733,7 +745,7 @@
    -

    21 SWIG and Android

    +

    22 SWIG and Android

    @@ -751,7 +763,7 @@
    -

    22 SWIG and C#

    +

    23 SWIG and C#

    @@ -799,7 +811,7 @@
    -

    23 SWIG and D

    +

    24 SWIG and D

    @@ -833,7 +845,7 @@
    -

    24 SWIG and Go

    +

    25 SWIG and Go

    @@ -877,7 +889,7 @@
    -

    25 SWIG and Guile

    +

    26 SWIG and Guile

    @@ -913,7 +925,7 @@
    -

    26 SWIG and Java

    +

    27 SWIG and Java

    @@ -1067,7 +1079,7 @@
    -

    27 SWIG and Javascript

    +

    28 SWIG and Javascript

    @@ -1109,7 +1121,7 @@
    -

    28 SWIG and Lua

    +

    29 SWIG and Lua

    @@ -1177,7 +1189,7 @@
    -

    29 SWIG and Octave

    +

    30 SWIG and Octave

    @@ -1217,7 +1229,7 @@
    -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

    @@ -1293,7 +1305,7 @@
    -

    31 SWIG and PHP

    +

    32 SWIG and PHP

    @@ -1334,7 +1346,7 @@
    -

    32 SWIG and Python

    +

    33 SWIG and Python

    @@ -1476,7 +1488,7 @@
    -

    33 SWIG and R

    +

    34 SWIG and R

    @@ -1495,7 +1507,7 @@
    -

    34 SWIG and Ruby

    +

    35 SWIG and Ruby

    @@ -1633,7 +1645,7 @@
    -

    35 SWIG and Scilab

    +

    36 SWIG and Scilab

    @@ -1702,7 +1714,7 @@
    -

    36 SWIG and Tcl

    +

    37 SWIG and Tcl

    @@ -1768,7 +1780,7 @@
    -

    37 SWIG and MzScheme/Racket

    +

    38 SWIG and MzScheme/Racket

    @@ -1780,7 +1792,7 @@
    -

    38 SWIG and OCaml

    +

    39 SWIG and OCaml

    @@ -1835,7 +1847,7 @@
    -

    39 Extending SWIG to support new languages

    +

    40 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Contract.html b/Doc/Manual/Contract.html index 93fb8c003..f7acbba3e 100644 --- a/Doc/Manual/Contract.html +++ b/Doc/Manual/Contract.html @@ -7,7 +7,7 @@ -

    15 Contracts

    +

    16 Contracts

      @@ -39,7 +39,7 @@ When one of the rules is violated by a script, a runtime exception is generated rather than having the program continue to execute.

      -

      15.1 The %contract directive

      +

      16.1 The %contract directive

      @@ -95,7 +95,7 @@ RuntimeError: Contract violation: require: (arg1>=0)

    -

    15.2 %contract and classes

    +

    16.2 %contract and classes

    @@ -174,7 +174,7 @@ specified for the derived class all must hold. In the above example, this means that both the arguments to Spam::bar must be positive.

    -

    15.3 Constant aggregation and %aggregate_check

    +

    16.3 Constant aggregation and %aggregate_check

    @@ -263,7 +263,7 @@ Regrettably, there is no automatic way to perform similar checks with enums valu release.

    -

    15.4 Notes

    +

    16.4 Notes

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index 328bc2391..5fe0f5b52 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -7,7 +7,7 @@ -

    14 Customization Features

    +

    15 Customization Features

    -

    14.1.4 Exception handlers for variables

    +

    15.1.4 Exception handlers for variables

    @@ -305,7 +305,7 @@ The %allowexception feature works like any other feature and so can be

    -

    14.1.5 Defining different exception handlers

    +

    15.1.5 Defining different exception handlers

    @@ -442,7 +442,7 @@ declarations. However, it never really worked that well and the new %exception directive is much better.

    -

    14.1.6 Special variables for %exception

    +

    15.1.6 Special variables for %exception

    @@ -545,7 +545,7 @@ Below shows the expansions for the 1st of the overloaded something wrap -

    14.1.7 Using The SWIG exception library

    +

    15.1.7 Using The SWIG exception library

    @@ -600,7 +600,7 @@ SWIG_NullReferenceError The SWIG_exception() function can also be used in typemaps.

    -

    14.2 Object ownership and %newobject

    +

    15.2 Object ownership and %newobject

    @@ -757,7 +757,7 @@ char *strdup(const char *s); The results might not be what you expect.

    -

    14.3 Features and the %feature directive

    +

    15.3 Features and the %feature directive

    @@ -839,7 +839,7 @@ The following are all equivalent: The syntax in the first variation will generate the { } delimiters used whereas the other variations will not.

    -

    14.3.1 Feature attributes

    +

    15.3.1 Feature attributes

    @@ -880,7 +880,7 @@ In the following example, MyExceptionClass is the name of the Java clas Further details can be obtained from the Java exception handling section.

    -

    14.3.2 Feature flags

    +

    15.3.2 Feature flags

    @@ -978,7 +978,7 @@ in the swig.swg Library file. The following shows the alternative synta The concept of clearing features is discussed next.

    -

    14.3.3 Clearing features

    +

    15.3.3 Clearing features

    @@ -1071,7 +1071,7 @@ The three macros below show this for the "except" feature: -

    14.3.4 Features and default arguments

    +

    15.3.4 Features and default arguments

    @@ -1146,7 +1146,7 @@ specifying or not specifying default arguments in a feature is not applicable as in SWIG-1.3.23 when the approach to wrapping methods with default arguments was changed.

    -

    14.3.5 Feature example

    +

    15.3.5 Feature example

    diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index d97267a5b..f9f2d53ca 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -6,7 +6,7 @@ -

    23 SWIG and D

    +

    24 SWIG and D

      @@ -41,7 +41,7 @@ -

      23.1 Introduction

      +

      24.1 Introduction

      From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?

      @@ -53,7 +53,7 @@

      To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).

      -

      23.2 Command line invocation

      +

      24.2 Command line invocation

      To activate the D module, pass the -d option to SWIG at the command line. The same standard command line options as with any other language module are available, plus the following D specific ones:

      @@ -83,10 +83,10 @@ -

      23.3 Typemaps

      +

      24.3 Typemaps

      -

      23.3.1 C# <-> D name comparison

      +

      24.3.1 C# <-> D name comparison

      If you already know the SWIG C# module, you might find the following name comparison table useful:

      @@ -112,7 +112,7 @@
    -

    23.3.2 ctype, imtype, dtype

    +

    24.3.2 ctype, imtype, dtype

    Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.

    @@ -120,7 +120,7 @@

    The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.

    -

    23.3.3 in, out, directorin, directorout

    +

    24.3.3 in, out, directorin, directorout

    Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).

    @@ -130,7 +130,7 @@

    The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).

    -

    23.3.4 din, dout, ddirectorin, ddirectorout

    +

    24.3.4 din, dout, ddirectorin, ddirectorout

    Typemaps for code generation in D proxy and type wrapper classes.

    @@ -157,13 +157,13 @@ dtype DClass.method(dtype a) -

    23.3.5 typecheck typemaps

    +

    24.3.5 typecheck typemaps

    Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).

    -

    23.3.6 Code injection typemaps

    +

    24.3.6 Code injection typemaps

    These typemaps are used for generating the skeleton of proxy classes for C++ types.

    @@ -178,7 +178,7 @@ Code can also be injected into the D proxy class using %proxycode.

    -

    23.3.7 Special variable macros

    +

    24.3.7 Special variable macros

    The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.

    @@ -299,7 +299,7 @@ $importtype(AnotherInterface) -

    23.4 D and %feature

    +

    24.4 D and %feature

    The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:

    @@ -329,7 +329,7 @@ struct A { -

    23.5 Pragmas

    +

    24.5 Pragmas

    There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:

    @@ -368,7 +368,7 @@ struct A { -

    23.6 D Exceptions

    +

    24.6 D Exceptions

    Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.

    @@ -378,7 +378,7 @@ struct A {

    As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.

    -

    23.7 D Directors

    +

    24.7 D Directors

    When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.

    @@ -387,16 +387,16 @@ struct A {

    -

    23.8 Other features

    +

    24.8 Other features

    -

    23.8.1 Extended namespace support (nspace)

    +

    24.8.1 Extended namespace support (nspace)

    By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.

    -

    23.8.2 Native pointer support

    +

    24.8.2 Native pointer support

    Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a primitive type below.

    @@ -408,7 +408,7 @@ struct A {

    To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).

    -

    23.8.3 Operator overloading

    +

    24.8.3 Operator overloading

    The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:

    @@ -420,7 +420,7 @@ struct A {

    There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.

    -

    23.8.4 Running the test-suite

    +

    24.8.4 Running the test-suite

    As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.

    @@ -428,14 +428,14 @@ struct A {

    Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib, ...) statement.

    -

    23.9 D Typemap examples

    +

    24.9 D Typemap examples

    There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.

    -

    23.10 Work in progress and planned features

    +

    24.10 Work in progress and planned features

    There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:

    diff --git a/Doc/Manual/Doxygen.html b/Doc/Manual/Doxygen.html index 75657dc3b..53238c24d 100644 --- a/Doc/Manual/Doxygen.html +++ b/Doc/Manual/Doxygen.html @@ -5,7 +5,7 @@ -

    17 SWIG and Doxygen Translation

    +

    18 SWIG and Doxygen Translation

    -

    17.2.2.4 doxygen:nolinktranslate

    +

    18.2.2.4 doxygen:nolinktranslate

    @@ -430,7 +430,7 @@ This is only applicable to Java at the moment.

    -

    17.2.2.5 doxygen:nostripparams

    +

    18.2.2.5 doxygen:nostripparams

    @@ -440,14 +440,14 @@ This is only applicable to Java at the moment.

    -

    17.2.3 Additional command line options

    +

    18.2.3 Additional command line options

    ALSO TO BE ADDED (Javadoc auto brief?)

    -

    17.3 Doxygen to Javadoc

    +

    18.3 Doxygen to Javadoc

    @@ -456,7 +456,7 @@ automatically placed in the correct locations in the resulting module and proxy files.

    -

    17.3.1 Basic example

    +

    18.3.1 Basic example

    @@ -563,7 +563,7 @@ Javadoc translator features summary directives):

    -

    17.3.2 Javadoc tags

    +

    18.3.2 Javadoc tags

    @@ -825,7 +825,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    17.3.3 Unsupported tags

    +

    18.3.3 Unsupported tags

    @@ -992,14 +992,14 @@ comment, the whole comment block is ignored: -

    17.3.4 Further details

    +

    18.3.4 Further details

    TO BE ADDED.

    -

    17.4 Doxygen to Pydoc

    +

    18.4 Doxygen to Pydoc

    @@ -1010,7 +1010,7 @@ Doxygen or Javadoc, so most of Doxygen commands are translated by merely copying the appropriate command text.

    -

    17.4.1 Basic example

    +

    18.4.1 Basic example

    @@ -1173,7 +1173,7 @@ docs), you may want to use some tool like doxypy to do the work.

    -

    17.4.2 Pydoc translator

    +

    18.4.2 Pydoc translator

    @@ -1427,7 +1427,7 @@ Here is the list of all Doxygen tags and the description of how they are transla -

    17.4.3 Unsupported tags

    +

    18.4.3 Unsupported tags

    @@ -1543,14 +1543,14 @@ Here is the list of these tags: -

    17.4.4 Further details

    +

    18.4.4 Further details

    TO BE ADDED.

    -

    17.5 Troubleshooting

    +

    18.5 Troubleshooting

    @@ -1572,7 +1572,7 @@ include the option and fix problems with Doxygen comments.

    -

    17.5.1 Problem with conditional compilation

    +

    18.5.1 Problem with conditional compilation

    @@ -1612,14 +1612,14 @@ class A { -

    17.6 Developer information

    +

    18.6 Developer information

    This section contains information for developers enhancing the Doxygen translator.

    -

    17.6.1 Doxygen translator design

    +

    18.6.1 Doxygen translator design

    @@ -1645,7 +1645,7 @@ class for translation into the target documentation language. For example, JavaDocConverter is the Javadoc module class.

    -

    17.6.2 Debugging the Doxygen parser and translator

    +

    18.6.2 Debugging the Doxygen parser and translator

    @@ -1658,7 +1658,7 @@ detailed debug information printing. -debug-doxygen-translator - Display Doxygen translator module debugging information -

    17.6.3 Tests

    +

    18.6.3 Tests

    @@ -1710,7 +1710,7 @@ Runtime tests in Python are just plain string comparisons of the __doc__ properties.

    -

    17.7 Extending to other languages

    +

    18.7 Extending to other languages

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 5a640fbdc..7c2a6c66c 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -7,7 +7,7 @@ -

    39 Extending SWIG to support new languages

    +

    40 Extending SWIG to support new languages

    -

    39.4.4 Attribute namespaces

    +

    40.4.4 Attribute namespaces

    @@ -665,7 +665,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    39.4.5 Symbol Tables

    +

    40.4.5 Symbol Tables

    @@ -756,7 +756,7 @@ example.i:5. Previous declaration is foo_i(int ) -

    39.4.6 The %feature directive

    +

    40.4.6 The %feature directive

    @@ -812,7 +812,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    39.4.7 Code Generation

    +

    40.4.7 Code Generation

    @@ -934,7 +934,7 @@ public : The role of these functions is described shortly.

    -

    39.4.8 SWIG and XML

    +

    40.4.8 SWIG and XML

    @@ -947,7 +947,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    39.5 Primitive Data Structures

    +

    40.5 Primitive Data Structures

    @@ -993,7 +993,7 @@ typedef Hash Typetab; -

    39.5.1 Strings

    +

    40.5.1 Strings

    @@ -1134,7 +1134,7 @@ Returns the number of replacements made (if any). -

    39.5.2 Hashes

    +

    40.5.2 Hashes

    @@ -1211,7 +1211,7 @@ Returns the list of hash table keys. -

    39.5.3 Lists

    +

    40.5.3 Lists

    @@ -1300,7 +1300,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    39.5.4 Common operations

    +

    40.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1355,7 +1355,7 @@ objects and report errors. Gets the line number associated with x. -

    39.5.5 Iterating over Lists and Hashes

    +

    40.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1400,7 +1400,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    39.5.6 I/O

    +

    40.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1534,7 +1534,7 @@ Printf(f, "%s\n", s); Similarly, the preprocessor and parser all operate on string-files.

    -

    39.6 Navigating and manipulating parse trees

    +

    40.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1668,7 +1668,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    39.7 Working with attributes

    +

    40.7 Working with attributes

    @@ -1785,7 +1785,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    39.8 Type system

    +

    40.8 Type system

    @@ -1794,7 +1794,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    39.8.1 String encoding of types

    +

    40.8.1 String encoding of types

    @@ -1895,7 +1895,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    39.8.2 Type construction

    +

    40.8.2 Type construction

    @@ -2064,7 +2064,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    39.8.3 Type tests

    +

    40.8.3 Type tests

    @@ -2151,7 +2151,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    39.8.4 Typedef and inheritance

    +

    40.8.4 Typedef and inheritance

    @@ -2253,7 +2253,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    39.8.5 Lvalues

    +

    40.8.5 Lvalues

    @@ -2290,7 +2290,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    39.8.6 Output functions

    +

    40.8.6 Output functions

    @@ -2352,7 +2352,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    39.9 Parameters

    +

    40.9 Parameters

    @@ -2451,7 +2451,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    39.10 Writing a Language Module

    +

    40.10 Writing a Language Module

    @@ -2466,7 +2466,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    39.10.1 Execution model

    +

    40.10.1 Execution model

    @@ -2476,7 +2476,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.

    -

    39.10.2 Starting out

    +

    40.10.2 Starting out

    @@ -2584,7 +2584,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    39.10.3 Command line options

    +

    40.10.3 Command line options

    @@ -2643,7 +2643,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    39.10.4 Configuration and preprocessing

    +

    40.10.4 Configuration and preprocessing

    @@ -2692,7 +2692,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    39.10.5 Entry point to code generation

    +

    40.10.5 Entry point to code generation

    @@ -2750,7 +2750,7 @@ int Python::top(Node *n) { -

    39.10.6 Module I/O and wrapper skeleton

    +

    40.10.6 Module I/O and wrapper skeleton

    @@ -2898,7 +2898,7 @@ functionWrapper : void Shape_y_set(Shape *self, double y) -

    39.10.7 Low-level code generators

    +

    40.10.7 Low-level code generators

    @@ -3052,7 +3052,7 @@ but without the typemaps, there is still work to do.

    -

    39.10.8 Configuration files

    +

    40.10.8 Configuration files

    @@ -3196,7 +3196,7 @@ politely displays the ignoring language message. -

    39.10.9 Runtime support

    +

    40.10.9 Runtime support

    @@ -3205,7 +3205,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    39.10.10 Standard library files

    +

    40.10.10 Standard library files

    @@ -3224,7 +3224,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    39.10.11 User examples

    +

    40.10.11 User examples

    @@ -3253,7 +3253,7 @@ during this process, see the section on .

    -

    39.10.12 Test driven development and the test-suite

    +

    40.10.12 Test driven development and the test-suite

    @@ -3312,7 +3312,7 @@ It is therefore essential that the runtime tests are written in a manner that di but error/exception out with an error message on stderr on failure.

    -

    39.10.12.1 Running the test-suite

    +

    40.10.12.1 Running the test-suite

    @@ -3504,7 +3504,7 @@ It can be run in the same way as the other language test-suites, replacing [lang The test cases used and the way it works is described in Examples/test-suite/errors/Makefile.in.

    -

    39.10.13 Documentation

    +

    40.10.13 Documentation

    @@ -3536,7 +3536,7 @@ Some topics that you'll want to be sure to address include: if available. -

    39.10.14 Coding style guidelines

    +

    40.10.14 Coding style guidelines

    @@ -3561,7 +3561,7 @@ should be avoided as unlike the SWIG developers, users will never have consisten

    -

    39.10.15 Target language status

    +

    40.10.15 Target language status

    @@ -3570,7 +3570,7 @@ the Target language in This section provides more details on how this status is given.

    -

    39.10.15.1 Supported status

    +

    40.10.15.1 Supported status

    @@ -3617,7 +3617,7 @@ A target language is given the 'Supported' status when

  • -

    39.10.15.2 Experimental status

    +

    40.10.15.2 Experimental status

    @@ -3682,7 +3682,7 @@ Some minimum requirements and notes about languages with the 'Experimental' stat -

    39.10.16 Prerequisites for adding a new language module to the SWIG distribution

    +

    40.10.16 Prerequisites for adding a new language module to the SWIG distribution

    @@ -3746,7 +3746,7 @@ the existing tests.

    -

    39.11 Debugging Options

    +

    40.11 Debugging Options

    @@ -3773,7 +3773,7 @@ There are various command line options which can aid debugging a SWIG interface The complete list of command line options for SWIG are available by running swig -help.

    -

    39.12 Guide to parse tree nodes

    +

    40.12 Guide to parse tree nodes

    @@ -4181,7 +4181,7 @@ extern "X" { ... } declaration. -

    39.13 Further Development Information

    +

    40.13 Further Development Information

    diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index c28cc03e1..1a5bb08c7 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -6,7 +6,7 @@ -

    24 SWIG and Go

    +

    25 SWIG and Go

    -

    24.3.1 Go-specific Commandline Options

    +

    25.3.1 Go-specific Commandline Options

    @@ -276,7 +276,7 @@ swig -go -help -

    24.3.2 Generated Wrapper Files

    +

    25.3.2 Generated Wrapper Files

    There are two different approaches to generating wrapper files, @@ -320,7 +320,7 @@ combined with the compiled MODULE.go using go tool pack. -

    24.4 A tour of basic C/C++ wrapping

    +

    25.4 A tour of basic C/C++ wrapping

    @@ -330,7 +330,7 @@ modifications have to occur. This section briefly covers the essential aspects of this wrapping.

    -

    24.4.1 Go Package Name

    +

    25.4.1 Go Package Name

    @@ -340,7 +340,7 @@ directive. You may override this by using SWIG's -package command line option.

    -

    24.4.2 Go Names

    +

    25.4.2 Go Names

    @@ -372,7 +372,7 @@ followed by that name, and the destructor will be named Delete followed by that name.

    -

    24.4.3 Go Constants

    +

    25.4.3 Go Constants

    @@ -380,7 +380,7 @@ C/C++ constants created via #define or the %constant directive become Go constants, declared with a const declaration. -

    24.4.4 Go Enumerations

    +

    25.4.4 Go Enumerations

    @@ -390,7 +390,7 @@ usual). The values of the enumeration will become variables in Go; code should avoid modifying those variables.

    -

    24.4.5 Go Classes

    +

    25.4.5 Go Classes

    @@ -468,7 +468,7 @@ returns a go interface. If the returned pointer can be null, you can check for this by calling the Swigcptr() method.

    -

    24.4.5.1 Go Class Memory Management

    +

    25.4.5.1 Go Class Memory Management

    @@ -590,7 +590,7 @@ func (o *GoClassName) Close() { -

    24.4.5.2 Go Class Inheritance

    +

    25.4.5.2 Go Class Inheritance

    @@ -602,7 +602,7 @@ Doing the reverse will require an explicit type assertion, which will be checked dynamically.

    -

    24.4.6 Go Templates

    +

    25.4.6 Go Templates

    @@ -611,7 +611,7 @@ wrappers for a particular template instantiation. To do this, use the %template directive. -

    24.4.7 Go Director Classes

    +

    25.4.7 Go Director Classes

    @@ -629,7 +629,7 @@ completely to avoid common pitfalls with directors in Go.

    -

    24.4.7.1 Example C++ code

    +

    25.4.7.1 Example C++ code

    @@ -701,7 +701,7 @@ be found in the end of the guide.

    -

    24.4.7.2 Enable director feature

    +

    25.4.7.2 Enable director feature

    @@ -736,7 +736,7 @@ documentation on directors.

    -

    24.4.7.3 Constructor and destructor

    +

    25.4.7.3 Constructor and destructor

    @@ -789,7 +789,7 @@ embedding.

    -

    24.4.7.4 Override virtual methods

    +

    25.4.7.4 Override virtual methods

    @@ -857,7 +857,7 @@ the Go methods.

    -

    24.4.7.5 Call base methods

    +

    25.4.7.5 Call base methods

    @@ -894,7 +894,7 @@ be found in the end of the guide.

    -

    24.4.7.6 Subclass via embedding

    +

    25.4.7.6 Subclass via embedding

    @@ -962,7 +962,7 @@ class.

    -

    24.4.7.7 Memory management with runtime.SetFinalizer

    +

    25.4.7.7 Memory management with runtime.SetFinalizer

    @@ -1027,7 +1027,7 @@ before using runtime.SetFinalizer to know all of its gotchas.

    -

    24.4.7.8 Complete FooBarGo example class

    +

    25.4.7.8 Complete FooBarGo example class

    @@ -1156,7 +1156,7 @@ SWIG/Examples/go/director/.

    -

    24.4.8 Default Go primitive type mappings

    +

    25.4.8 Default Go primitive type mappings

    @@ -1263,7 +1263,7 @@ that typemap, or add new values, to control how C/C++ types are mapped into Go types.

    -

    24.4.9 Output arguments

    +

    25.4.9 Output arguments

    Because of limitations in the way output arguments are processed in swig, @@ -1316,7 +1316,7 @@ void f(char *output); -

    24.4.10 Adding additional go code

    +

    25.4.10 Adding additional go code

    Often the APIs generated by swig are not very natural in go, especially if @@ -1411,7 +1411,7 @@ func bar() { -

    24.4.11 Go typemaps

    +

    25.4.11 Go typemaps

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 31d822599..9d55b632b 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    25 SWIG and Guile

    +

    26 SWIG and Guile

      @@ -48,7 +48,7 @@

      This section details guile-specific support in SWIG. -

      25.1 Supported Guile Versions

      +

      26.1 Supported Guile Versions

      @@ -62,7 +62,7 @@ improved performance. This is currently not tested with swig so your mileage may vary. To be safe set environment variable GUILE_AUTO_COMPILE to 0 when using swig generated guile code. -

      25.2 Meaning of "Module"

      +

      26.2 Meaning of "Module"

      @@ -70,7 +70,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". -

      25.3 Old GH Guile API

      +

      26.3 Old GH Guile API

      Guile 1.8 and older could be interfaced using two different api's, the SCM @@ -81,7 +81,7 @@ or the GH API. The GH interface to guile is deprecated. Read more about why in version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please use that version if you really need the GH wrapper code. -

      25.4 Linkage

      +

      26.4 Linkage

      @@ -89,7 +89,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. -

      25.4.1 Simple Linkage

      +

      26.4.1 Simple Linkage

      @@ -194,7 +194,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. -

      25.4.2 Passive Linkage

      +

      26.4.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -204,7 +204,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      25.4.3 Native Guile Module Linkage

      +

      26.4.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -245,7 +245,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    25.4.4 Old Auto-Loading Guile Module Linkage

    +

    26.4.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -271,7 +271,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    25.4.5 Hobbit4D Linkage

    +

    26.4.5 Hobbit4D Linkage

    @@ -296,7 +296,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    25.5 Underscore Folding

    +

    26.5 Underscore Folding

    @@ -308,7 +308,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    25.6 Typemaps

    +

    26.6 Typemaps

    @@ -400,7 +400,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    25.7 Representation of pointers as smobs

    +

    26.7 Representation of pointers as smobs

    @@ -421,7 +421,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. -

    25.7.1 Smobs

    +

    26.7.1 Smobs

    @@ -440,7 +440,7 @@ structure describing this type. If a generated GOOPS module has been loaded, sm the corresponding GOOPS class.

    -

    25.7.2 Garbage Collection

    +

    26.7.2 Garbage Collection

    Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, @@ -454,14 +454,14 @@ is exactly like described in 25.8 Native Guile pointers +

    26.8 Native Guile pointers

    In addition to SWIG smob pointers, Guile's native pointer type are accepted as arguments to wrapped SWIG functions. This can be useful for passing pointers to bytevector data to wrapped functions.

    -

    25.9 Exception Handling

    +

    26.9 Exception Handling

    @@ -487,7 +487,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    25.10 Procedure documentation

    +

    26.10 Procedure documentation

    If invoked with the command-line option -procdoc @@ -522,7 +522,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    25.11 Procedures with setters

    +

    26.11 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -550,7 +550,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    25.12 GOOPS Proxy Classes

    +

    26.12 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -696,7 +696,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    25.12.1 Naming Issues

    +

    26.12.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -733,7 +733,7 @@ guile-modules. For example,

    (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:))) -

    25.12.2 Linking

    +

    26.12.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 8d161b73d..facfc7dd1 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -416,6 +416,7 @@ major features include: Most of C++11 is also supported. Details are in the C++11 chapter. C++14 support is covered in the C++14 chapter. C++17 support is covered in the C++17 chapter. +C++20 support is covered in the C++20 chapter.

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index db5f041e4..b9234b24f 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6,7 +6,7 @@ -

    26 SWIG and Java

    +

    27 SWIG and Java

    -

    26.3.3 Global variables

    +

    27.3.3 Global variables

    @@ -816,7 +816,7 @@ extern char *path; // Read-only (due to %immutable) -

    26.3.4 Constants

    +

    27.3.4 Constants

    @@ -956,7 +956,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    26.3.5 Enumerations

    +

    27.3.5 Enumerations

    @@ -970,7 +970,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.

    -

    26.3.5.1 Anonymous enums

    +

    27.3.5.1 Anonymous enums

    @@ -1033,7 +1033,7 @@ As in the case of constants, you can access them through either the module class

    -

    26.3.5.2 Typesafe enums

    +

    27.3.5.2 Typesafe enums

    @@ -1126,7 +1126,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.

    -

    26.3.5.3 Proper Java enums

    +

    27.3.5.3 Proper Java enums

    @@ -1179,7 +1179,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    26.3.5.4 Type unsafe enums

    +

    27.3.5.4 Type unsafe enums

    @@ -1227,7 +1227,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.

    -

    26.3.5.5 Simple enums

    +

    27.3.5.5 Simple enums

    @@ -1246,7 +1246,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.

    -

    26.3.6 Pointers

    +

    27.3.6 Pointers

    @@ -1334,7 +1334,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.

    -

    26.3.7 Structures

    +

    27.3.7 Structures

    @@ -1502,7 +1502,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    26.3.8 C++ classes

    +

    27.3.8 C++ classes

    @@ -1565,7 +1565,7 @@ int bar = Spam.getBar(); -

    26.3.9 C++ inheritance

    +

    27.3.9 C++ inheritance

    @@ -1626,7 +1626,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.

    -

    26.3.10 Pointers, references, arrays and pass by value

    +

    27.3.10 Pointers, references, arrays and pass by value

    @@ -1681,7 +1681,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).

    -

    26.3.10.1 Null pointers

    +

    27.3.10.1 Null pointers

    @@ -1705,7 +1705,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.

    -

    26.3.11 C++ overloaded functions

    +

    27.3.11 C++ overloaded functions

    @@ -1820,7 +1820,7 @@ void spam(unsigned short); // Ignored -

    26.3.12 C++ default arguments

    +

    27.3.12 C++ default arguments

    @@ -1863,7 +1863,7 @@ Further details on default arguments and how to restore this approach are given

    -

    26.3.13 C++ namespaces

    +

    27.3.13 C++ namespaces

    @@ -1953,7 +1953,7 @@ If the resulting use of the nspace feature and hence packages results in a proxy you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.

    -

    26.3.14 C++ templates

    +

    27.3.14 C++ templates

    @@ -2002,10 +2002,10 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    26.3.15 C++ Smart Pointers

    +

    27.3.15 C++ Smart Pointers

    -

    26.3.15.1 The shared_ptr Smart Pointer

    +

    27.3.15.1 The shared_ptr Smart Pointer

    @@ -2016,7 +2016,7 @@ in the shared_ptr smart pointer -

    26.3.15.2 Generic Smart Pointers

    +

    27.3.15.2 Generic Smart Pointers

    @@ -2100,7 +2100,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    26.4 Further details on the generated Java classes

    +

    27.4 Further details on the generated Java classes

    @@ -2115,7 +2115,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    26.4.1 The intermediary JNI class

    +

    27.4.1 The intermediary JNI class

    @@ -2235,7 +2235,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    26.4.1.1 The intermediary JNI class pragmas

    +

    27.4.1.1 The intermediary JNI class pragmas

    @@ -2317,7 +2317,7 @@ For example, let's change the intermediary JNI class access to just the default All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.

    -

    26.4.2 The Java module class

    +

    27.4.2 The Java module class

    @@ -2348,7 +2348,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.

    -

    26.4.2.1 The Java module class pragmas

    +

    27.4.2.1 The Java module class pragmas

    @@ -2399,7 +2399,7 @@ See The intermediary JNI class pragmas secti

    -

    26.4.3 Java proxy classes

    +

    27.4.3 Java proxy classes

    @@ -2475,7 +2475,7 @@ int y = f.spam(5, new Foo()); -

    26.4.3.1 Memory management

    +

    27.4.3.1 Memory management

    @@ -2637,7 +2637,7 @@ and

    -

    26.4.3.2 Inheritance

    +

    27.4.3.2 Inheritance

    @@ -2753,7 +2753,7 @@ However, true cross language polymorphism can be achieved using the 26.4.3.3 Proxy classes and garbage collection +

    27.4.3.3 Proxy classes and garbage collection

    @@ -2836,7 +2836,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.

    -

    26.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    27.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2958,7 +2958,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    26.4.3.5 Single threaded applications and thread safety

    +

    27.4.3.5 Single threaded applications and thread safety

    @@ -3046,7 +3046,7 @@ for (int i=0; i<100000; i++) { -

    26.4.4 Type wrapper classes

    +

    27.4.4 Type wrapper classes

    @@ -3133,7 +3133,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    26.4.5 Enum classes

    +

    27.4.5 Enum classes

    @@ -3142,7 +3142,7 @@ The Enumerations section discussed these but om The following sub-sections detail the various types of enum classes that can be generated.

    -

    26.4.5.1 Typesafe enum classes

    +

    27.4.5.1 Typesafe enum classes

    @@ -3226,7 +3226,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    26.4.5.2 Proper Java enum classes

    +

    27.4.5.2 Proper Java enum classes

    @@ -3304,7 +3304,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.

    -

    26.4.5.3 Type unsafe enum classes

    +

    27.4.5.3 Type unsafe enum classes

    @@ -3335,7 +3335,7 @@ public final class Beverage { -

    26.4.6 Interfaces

    +

    27.4.6 Interfaces

    @@ -3580,7 +3580,7 @@ typemap which is only used when a class is marked with the interface fe See Java code typemaps for details.

    -

    26.5 Cross language polymorphism using directors

    +

    27.5 Cross language polymorphism using directors

    @@ -3602,7 +3602,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.

    -

    26.5.1 Enabling directors

    +

    27.5.1 Enabling directors

    @@ -3670,7 +3670,7 @@ public: -

    26.5.2 Director classes

    +

    27.5.2 Director classes

    @@ -3698,7 +3698,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    26.5.3 Overhead and code bloat

    +

    27.5.3 Overhead and code bloat

    @@ -3716,7 +3716,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    26.5.4 Simple directors example

    +

    27.5.4 Simple directors example

    @@ -3779,7 +3779,7 @@ DirectorDerived.upcall_method() invoked. -

    26.5.5 Director threading issues

    +

    27.5.5 Director threading issues

    @@ -3799,7 +3799,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    26.5.6 Director performance tuning

    +

    27.5.6 Director performance tuning

    @@ -3820,7 +3820,7 @@ However, if all director methods are expected to usually be overridden by Java s The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical.

    -

    26.5.7 Java exceptions from directors

    +

    27.5.7 Java exceptions from directors

    @@ -3896,7 +3896,7 @@ Exception in thread "main" java.lang.RuntimeException: There was a problem! More on the Swig::DirectorException class can be found in the next section which details how to customize the handling of director exceptions.

    -

    26.5.7.1 Customizing director exceptions

    +

    27.5.7.1 Customizing director exceptions

    @@ -4454,7 +4454,7 @@ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index is negativ -

    26.6 Accessing protected members

    +

    27.6 Accessing protected members

    @@ -4550,7 +4550,7 @@ class MyProtectedBase extends ProtectedBase -

    26.7 Common customization features

    +

    27.7 Common customization features

    @@ -4562,7 +4562,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    26.7.1 C/C++ helper functions

    +

    27.7.1 C/C++ helper functions

    @@ -4628,7 +4628,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.

    -

    26.7.2 Class extension with %extend

    +

    27.7.2 Class extension with %extend

    @@ -4691,7 +4691,7 @@ Vector(2, 3, 4) in any way---the extensions only show up in the Java interface.

    -

    26.7.3 Class extension with %proxycode

    +

    27.7.3 Class extension with %proxycode

    @@ -4828,7 +4828,7 @@ public class ValueUnsignedInt { -

    26.7.4 Exception handling with %exception and %javaexception

    +

    27.7.4 Exception handling with %exception and %javaexception

    @@ -4987,7 +4987,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    26.7.5 Method access with %javamethodmodifiers

    +

    27.7.5 Method access with %javamethodmodifiers

    @@ -5013,7 +5013,7 @@ protected static void protect_me() { -

    26.8 Tips and techniques

    +

    27.8 Tips and techniques

    @@ -5023,7 +5023,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    26.8.1 Input and output parameters using primitive pointers and references

    +

    27.8.1 Input and output parameters using primitive pointers and references

    @@ -5197,7 +5197,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    26.8.2 Simple pointers

    +

    27.8.2 Simple pointers

    @@ -5263,7 +5263,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    26.8.3 Wrapping C arrays with Java arrays

    +

    27.8.3 Wrapping C arrays with Java arrays

    @@ -5330,7 +5330,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.

    -

    26.8.4 Unbounded C Arrays

    +

    27.8.4 Unbounded C Arrays

    @@ -5475,7 +5475,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    26.8.5 Binary data vs Strings

    +

    27.8.5 Binary data vs Strings

    @@ -5519,7 +5519,7 @@ len: 5 data: 68 69 0 6a 6b -

    26.8.6 Overriding new and delete to allocate from Java heap

    +

    27.8.6 Overriding new and delete to allocate from Java heap

    @@ -5636,7 +5636,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    26.9 Java typemaps

    +

    27.9 Java typemaps

    @@ -5657,7 +5657,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. -

    26.9.1 Default primitive type mappings

    +

    27.9.1 Default primitive type mappings

    @@ -5809,7 +5809,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    26.9.2 Default typemaps for non-primitive types

    +

    27.9.2 Default typemaps for non-primitive types

    @@ -5824,7 +5824,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.

    -

    26.9.3 Sixty four bit JVMs

    +

    27.9.3 Sixty four bit JVMs

    @@ -5837,7 +5837,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    26.9.4 What is a typemap?

    +

    27.9.4 What is a typemap?

    @@ -5960,7 +5960,7 @@ int c = example.count('e', "Hello World"); -

    26.9.5 Typemaps for mapping C/C++ types to Java types

    +

    27.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -6240,7 +6240,7 @@ These are listed below: -

    26.9.6 Java typemap attributes

    +

    27.9.6 Java typemap attributes

    @@ -6286,7 +6286,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.

    -

    26.9.7 Java special variables

    +

    27.9.7 Java special variables

    @@ -6468,7 +6468,7 @@ in that it is not fully qualified with the package name when using the nspace feature.

    -

    26.9.8 Typemaps for both C and C++ compilation

    +

    27.9.8 Typemaps for both C and C++ compilation

    @@ -6505,7 +6505,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    26.9.9 Java code typemaps

    +

    27.9.9 Java code typemaps

    @@ -6803,7 +6803,7 @@ to make the method and constructor public: -

    26.9.10 Director specific typemaps

    +

    27.9.10 Director specific typemaps

    @@ -7080,7 +7080,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    26.10 Typemap Examples

    +

    27.10 Typemap Examples

    @@ -7090,7 +7090,7 @@ the SWIG library.

    -

    26.10.1 Simpler Java enums for enums without initializers

    +

    27.10.1 Simpler Java enums for enums without initializers

    @@ -7169,7 +7169,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    26.10.2 Handling C++ exception specifications as Java exceptions

    +

    27.10.2 Handling C++ exception specifications as Java exceptions

    @@ -7294,7 +7294,7 @@ We could alternatively have used %rename to rename what() into

    -

    26.10.3 NaN Exception - exception handling for a particular type

    +

    27.10.3 NaN Exception - exception handling for a particular type

    @@ -7449,7 +7449,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.

    -

    26.10.4 Converting Java String arrays to char **

    +

    27.10.4 Converting Java String arrays to char **

    @@ -7593,7 +7593,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify what Java types to use.

    -

    26.10.5 Expanding a Java object to multiple arguments

    +

    27.10.5 Expanding a Java object to multiple arguments

    @@ -7675,7 +7675,7 @@ example.foo(new String[]{"red", "green", "blue", "white"}); -

    26.10.6 Using typemaps to return arguments

    +

    27.10.6 Using typemaps to return arguments

    @@ -7793,7 +7793,7 @@ $ java runme 1 12.0 340.0 -

    26.10.7 Adding Java downcasts to polymorphic return types

    +

    27.10.7 Adding Java downcasts to polymorphic return types

    @@ -7999,7 +7999,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.

    -

    26.10.8 Adding an equals method to the Java classes

    +

    27.10.8 Adding an equals method to the Java classes

    @@ -8043,7 +8043,7 @@ System.out.println("foo1? " + foo1.equals(foo2)); -

    26.10.9 Void pointers and a common Java base class

    +

    27.10.9 Void pointers and a common Java base class

    @@ -8102,7 +8102,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. -

    26.10.10 Struct pointer to pointer

    +

    27.10.10 Struct pointer to pointer

    @@ -8282,7 +8282,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.

    -

    26.10.11 Memory management when returning references to member variables

    +

    27.10.11 Memory management when returning references to member variables

    @@ -8405,7 +8405,7 @@ public class Bike { Note the addReference call.

    -

    26.10.12 Memory management for objects passed to the C++ layer

    +

    27.10.12 Memory management for objects passed to the C++ layer

    @@ -8533,7 +8533,7 @@ as mentioned earlier, setElement is actually: -

    26.10.13 Date marshalling using the javain typemap and associated attributes

    +

    27.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -8710,7 +8710,7 @@ A few things to note: -

    26.11 Living with Java Directors

    +

    27.11 Living with Java Directors

    @@ -8889,10 +8889,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    26.12 Odds and ends

    +

    27.12 Odds and ends

    -

    26.12.1 JavaDoc comments

    +

    27.12.1 JavaDoc comments

    @@ -8948,7 +8948,7 @@ public class Barmy { -

    26.12.2 Functional interface without proxy classes

    +

    27.12.2 Functional interface without proxy classes

    @@ -9009,7 +9009,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    26.12.3 Using your own JNI functions

    +

    27.12.3 Using your own JNI functions

    @@ -9059,7 +9059,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    26.12.4 Performance concerns and hints

    +

    27.12.4 Performance concerns and hints

    @@ -9080,7 +9080,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.

    -

    26.12.5 Debugging

    +

    27.12.5 Debugging

    @@ -9102,7 +9102,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    26.13 Java Examples

    +

    27.13 Java Examples

    diff --git a/Doc/Manual/Javascript.html b/Doc/Manual/Javascript.html index 0b301377c..cce5b5e2e 100644 --- a/Doc/Manual/Javascript.html +++ b/Doc/Manual/Javascript.html @@ -7,7 +7,7 @@ -

    27 SWIG and Javascript

    +

    28 SWIG and Javascript

      @@ -52,7 +52,7 @@

      This chapter describes SWIG's support of Javascript. It does not cover SWIG basics, but only information that is specific to this module.

      -

      27.1 Overview

      +

      28.1 Overview

      Javascript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. Its arguably the most popular language for web development. @@ -63,10 +63,10 @@ Javascript has gone beyond being a browser-based scripting language and with node-webkit there is a platform which uses Google's Chromium as Web-Browser widget and node.js for javascript extensions.

      -

      27.2 Preliminaries

      +

      28.2 Preliminaries

      -

      27.2.1 Running SWIG

      +

      28.2.1 Running SWIG

      Suppose that you defined a SWIG module such as the following:

      @@ -121,7 +121,7 @@ void example_initialize(v8::Handle<v8::Object> exports) Note: be aware that v8 has a C++ API, and thus, the generated modules must be compiled as C++.

      -

      27.2.2 Running Tests and Examples

      +

      28.2.2 Running Tests and Examples

      The configuration for tests and examples currently supports Linux and Mac only and not MinGW (Windows) yet.

      @@ -153,7 +153,7 @@ $ make check-javascript-test-suite ENGINE=jsc $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8
    -

    27.2.3 Known Issues

    +

    28.2.3 Known Issues

    At the moment, the Javascript generators pass all tests syntactically, i.e., the generated source code compiles. However, there are still remaining runtime issues.

    @@ -169,12 +169,12 @@ $ make check-javascript-examples V8_VERSION=0x032530 ENGINE=v8

    The primary development environment has been Linux (Ubuntu 12.04). Windows and Mac OS X have been tested sporadically. Therefore, the generators might have more issues on those platforms. Please report back any problem you observe to help us improving this module quickly.

    -

    27.3 Integration

    +

    28.3 Integration

    This chapter gives a short introduction how to use a native Javascript extension: as a node.js module, and as an extension for an embedded Webkit.

    -

    27.3.1 Creating node.js Extensions

    +

    28.3.1 Creating node.js Extensions

    To install node.js you can download an installer from their web-site for Mac OS X and Windows. For Linux you can either build the source yourself and run sudo checkinstall or keep to the (probably stone-age) packaged version. For Ubuntu there is a PPA available.

    @@ -220,7 +220,7 @@ require("./build/Release/example")

    A more detailed explanation is given in the Examples section.

    -

    27.3.1.1 Troubleshooting

    +

    28.3.1.1 Troubleshooting

      @@ -232,12 +232,12 @@ require("./build/Release/example") $ sudo apt-get remove gyp -

      27.3.2 Embedded Webkit

      +

      28.3.2 Embedded Webkit

      Webkit is pre-installed on Mac OS X and available as a library for GTK.

      -

      27.3.2.1 Mac OS X

      +

      28.3.2.1 Mac OS X

      There is general information about programming with WebKit on Apple Developer Documentation. Details about Cocoa programming are not covered here.

      @@ -285,7 +285,7 @@ extern bool example_initialize(JSGlobalContextRef context, JSObjectRef* exports) @end -

      27.3.2.2 GTK

      +

      28.3.2.2 GTK

      There is general information about programming GTK at GTK documentation and in the GTK tutorial, and for Webkit there is a Webkit GTK+ API Reference.

      @@ -330,7 +330,7 @@ int main(int argc, char* argv[]) } -

      27.3.3 Creating Applications with node-webkit

      +

      28.3.3 Creating Applications with node-webkit

      To get started with node-webkit there is a very informative set of wiki pages.

      @@ -421,12 +421,12 @@ open new windows, and many more things. }; -

      27.4 Examples

      +

      28.4 Examples

      Some basic examples are shown here in more detail.

      -

      27.4.1 Simple

      +

      28.4.1 Simple

      The common example simple looks like this:

      @@ -476,7 +476,7 @@ example.Foo = 3.1415926;

      Note: ECMAScript 5, the currently implemented Javascript standard, does not have modules. node.js and other implementations provide this mechanism defined by the CommonJS group. For browsers this is provided by Browserify, for instance.

      -

      27.4.2 Class

      +

      28.4.2 Class

      The common example class defines three classes, Shape, Circle, and Square:

      @@ -606,12 +606,12 @@ at emitKey (readline.js:1095:12) Note: In ECMAScript 5 there is no concept for classes. Instead each function can be used as a constructor function which is executed by the 'new' operator. Furthermore, during construction the key property prototype of the constructor function is used to attach a prototype instance to the created object. A prototype is essentially an object itself that is the first-class delegate of a class used whenever the access to a property of an object fails. The very same prototype instance is shared among all instances of one type. Prototypal inheritance is explained in more detail on in Inheritance and the prototype chain, for instance.

      -

      27.5 Implementation

      +

      28.5 Implementation

      The Javascript Module implementation has taken a very different approach compared to other language modules in order to support different Javascript interpreters.

      -

      27.5.1 Source Code

      +

      28.5.1 Source Code

      The Javascript module is implemented in Source/Modules/javascript.cxx. It dispatches the code generation to a JSEmitter instance, V8Emitter or JSCEmitter. Additionally there are some helpers: Template, for templated code generation, and JSEmitterState, which is used to manage state information during AST traversal. This rough map shall make it easier to find a way through this huge source file:

      @@ -712,7 +712,7 @@ Template::Template(const String *code_) { ... } ... -

      27.5.2 Code Templates

      +

      28.5.2 Code Templates

      All generated code is created on the basis of code templates. The templates for JavascriptCore can be found in Lib/javascript/jsc/javascriptcode.swg, for v8 in Lib/javascript/v8/javascriptcode.swg.

      @@ -751,7 +751,7 @@ t_register.replace("$jsparent", state.clazz(NAME_MANGLED))

      Template creates a copy of that string and Template::replace uses Swig's Replaceall to replace variables in the template. Template::trim can be used to eliminate leading and trailing whitespaces. Template::print is used to write the final template string to a Swig DOH (based on Printv). All methods allow chaining.

      -

      27.5.3 Emitter

      +

      28.5.3 Emitter

      The Javascript module delegates code generation to a JSEmitter instance. The following extract shows the essential interface:

      @@ -870,7 +870,7 @@ int JAVASCRIPT::classHandler(Node *n) {

      In enterClass the emitter stores state information that is necessary when processing class members. In exitClass the wrapper code for the whole class is generated.

      -

      27.5.4 Emitter states

      +

      28.5.4 Emitter states

      For storing information during the AST traversal the emitter provides a JSEmitterState with different slots to store data representing the scopes global, class, function, and variable.

      @@ -914,7 +914,7 @@ state.clazz(NAME, Getattr(n, "sym:name"));

      State information can be retrieved using state.clazz(NAME) or with Getattr on state.clazz() which actually returns a Hash instance.

      -

      27.5.5 Handling Exceptions in JavascriptCore

      +

      28.5.5 Handling Exceptions in JavascriptCore

      Applications with an embedded JavascriptCore should be able to present detailed exception messages that occur in the Javascript engine. Below is an example derived from code provided by Brian Barnes on how these exception details can be extracted.

      diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 560859234..5f72b557d 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -7,7 +7,7 @@ -

      11 SWIG library

      +

      12 SWIG library

      -

      11.2.4 cdata.i

      +

      12.2.4 cdata.i

      @@ -769,7 +769,7 @@ char *cdata_name(type* ptr, int nitems) Clearly they are unsafe.

      -

      11.3 C string handling

      +

      12.3 C string handling

      @@ -789,7 +789,7 @@ morality. The modules in this section provide basic functionality for manipulating raw C strings.

      -

      11.3.1 Default string handling

      +

      12.3.1 Default string handling

      @@ -830,7 +830,7 @@ interpreter and lead to a crash). Furthermore, the default behavior does not work well with binary data. Instead, strings are assumed to be NULL-terminated.

      -

      11.3.2 Passing binary data

      +

      12.3.2 Passing binary data

      @@ -872,7 +872,7 @@ In the wrapper function, the passed string will be expanded to a pointer and len The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).

      -

      11.3.3 Using %newobject to release memory

      +

      12.3.3 Using %newobject to release memory

      @@ -913,7 +913,7 @@ however, you may need to provide your own "newfree" typemap for other types. See Object ownership and %newobject for more details.

      -

      11.3.4 cstring.i

      +

      12.3.4 cstring.i

      @@ -1373,7 +1373,7 @@ structure or class instead.

    -

    11.4 STL/C++ library

    +

    12.4 STL/C++ library

    @@ -1420,7 +1420,7 @@ Please look for the library files in the appropriate language library directory.

    -

    11.4.1 std::string

    +

    12.4.1 std::string

    @@ -1504,7 +1504,7 @@ void foo(string s, const String &t); // std_string typemaps still applie -

    11.4.2 std::vector

    +

    12.4.2 std::vector

    @@ -1683,7 +1683,7 @@ if you want to make their head explode. details and the public API exposed to the interpreter vary.

    -

    11.4.3 STL exceptions

    +

    12.4.3 STL exceptions

    @@ -1733,10 +1733,10 @@ The %exception directive can be used by placing the following code befo Any thrown STL exceptions will then be gracefully handled instead of causing a crash.

    -

    11.4.4 shared_ptr smart pointer

    +

    12.4.4 shared_ptr smart pointer

    -

    11.4.4.1 shared_ptr basics

    +

    12.4.4.1 shared_ptr basics

    @@ -1832,7 +1832,7 @@ System.out.println(val1 + " " + val2); -

    11.4.4.2 shared_ptr and inheritance

    +

    12.4.4.2 shared_ptr and inheritance

    @@ -1923,7 +1923,7 @@ Adding the missing %shared_ptr macros will fix this: -

    11.4.4.3 shared_ptr and method overloading

    +

    12.4.4.3 shared_ptr and method overloading

    @@ -1945,7 +1945,7 @@ SWIG will choose to wrap just the first method by default. For the interested reader, SWIG detects that they are equivalent types via the typecheck typemaps in the shared_ptr library.

    -

    11.4.4.4 shared_ptr and templates

    +

    12.4.4.4 shared_ptr and templates

    @@ -1987,7 +1987,7 @@ The SWIG code below shows the required ordering: -

    11.4.4.5 shared_ptr and directors

    +

    12.4.4.5 shared_ptr and directors

    @@ -1995,7 +1995,7 @@ The languages that support shared_ptr also have support for using shared_ptr wit

    -

    11.4.5 auto_ptr smart pointer

    +

    12.4.5 auto_ptr smart pointer

    @@ -2044,10 +2044,10 @@ int value = k.getValue(); -

    11.5 Utility Libraries

    +

    12.5 Utility Libraries

    -

    11.5.1 exception.i

    +

    12.5.1 exception.i

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 431ac1c14..80807baf4 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -7,7 +7,7 @@ -

    28 SWIG and Lua

    +

    29 SWIG and Lua

      @@ -83,14 +83,14 @@ Lua is an extension programming language designed to support general procedural eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net

      -

      28.1 Preliminaries

      +

      29.1 Preliminaries

      The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. 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). SWIG also has support for eLua starting from eLua 0.8. Due to substantial changes between SWIG 2.x and SWIG 3.0 and unavailability of testing platform, eLua status was downgraded to 'experimental'.

      -

      28.2 Running SWIG

      +

      29.2 Running SWIG

      @@ -138,7 +138,7 @@ $ swig -lua -eluac example.i The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.

      -

      28.2.1 Additional command line options

      +

      29.2.1 Additional command line options

      @@ -179,7 +179,7 @@ swig -lua -help -

      28.2.2 Compiling and Linking and Interpreter

      +

      29.2.2 Compiling and Linking and Interpreter

      @@ -250,7 +250,7 @@ LUALIB_API int ( luaopen_mod )(lua_State *L ); More information on building and configuring eLua can be found here: http://www.eluaproject.net/doc/v0.8/en_building.html

      -

      28.2.3 Compiling a dynamic module

      +

      29.2.3 Compiling a dynamic module

      @@ -318,7 +318,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

      28.2.4 Using your module

      +

      29.2.4 Using your module

      @@ -336,19 +336,19 @@ $ ./my_lua >

    -

    28.3 A tour of basic C/C++ wrapping

    +

    29.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.

    -

    28.3.1 Modules

    +

    29.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.

    -

    28.3.2 Functions

    +

    29.3.2 Functions

    @@ -389,7 +389,7 @@ It is also possible to rename the module with an assignment. 24 -

    28.3.3 Global variables

    +

    29.3.3 Global variables

    @@ -477,7 +477,7 @@ If you have used the -eluac option for your eLua module, you will have In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.

    -

    28.3.4 Constants and enums

    +

    29.3.4 Constants and enums

    @@ -512,7 +512,7 @@ If you're using eLua and have used -elua or -eluac to generate Hello World -

    28.3.4.1 Constants/enums and classes/structures

    +

    29.3.4.1 Constants/enums and classes/structures

    @@ -568,7 +568,7 @@ If the -no-old-metatable-bindings option is used, then these old-style It is worth mentioning, that example.Test.TEST1 and example.Test_TEST1 are different entities and changing one does not change the other. Given the fact that these are constantes and they are not supposed to be changed, it is up to you to avoid such issues.

    -

    28.3.5 Pointers

    +

    29.3.5 Pointers

    @@ -606,7 +606,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    28.3.6 Structures

    +

    29.3.6 Structures

    @@ -710,7 +710,7 @@ For eLua with the -eluac option, structure manipulation has to be perfo In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)

    -

    28.3.7 C++ classes

    +

    29.3.7 C++ classes

    @@ -786,7 +786,7 @@ Both style names are generated by default now. However, if the -no-old-metatable-bindings option is used, then the backward compatible names are not generated in addition to ordinary ones.

    -

    28.3.8 C++ inheritance

    +

    29.3.8 C++ inheritance

    @@ -811,7 +811,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    28.3.9 Pointers, references, values, and arrays

    +

    29.3.9 Pointers, references, values, and arrays

    @@ -842,7 +842,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.

    -

    28.3.10 C++ overloaded functions

    +

    29.3.10 C++ overloaded functions

    @@ -928,7 +928,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.

    -

    28.3.11 C++ operators

    +

    29.3.11 C++ operators

    @@ -1062,7 +1062,7 @@ operators and pseudo-operators):

    No other lua metafunction is inherited. For example, __gc is not inherited and must be redefined in every class. __tostring is subject to a special handling. If absent in class and in class bases, a default one will be provided by SWIG.

    -

    28.3.12 Class extension with %extend

    +

    29.3.12 Class extension with %extend

    @@ -1119,7 +1119,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).

    -

    28.3.13 Using %newobject to release memory

    +

    29.3.13 Using %newobject to release memory

    If you have a function that allocates memory like this,

    @@ -1143,7 +1143,7 @@ char *foo();

    This will release the allocated memory.

    -

    28.3.14 C++ templates

    +

    29.3.14 C++ templates

    @@ -1178,7 +1178,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.

    -

    28.3.15 C++ Smart Pointers

    +

    29.3.15 C++ Smart Pointers

    @@ -1230,7 +1230,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    28.3.16 C++ Exceptions

    +

    29.3.16 C++ Exceptions

    @@ -1373,7 +1373,7 @@ and the "Exception handling add exception specification to functions or globally (respectively).

    -

    28.3.17 Namespaces

    +

    29.3.17 Namespaces

    @@ -1424,7 +1424,7 @@ Now, from Lua usage is as follows: 19 > -

    28.3.17.1 Compatibility Note

    +

    29.3.17.1 Compatibility Note

    @@ -1440,7 +1440,7 @@ If SWIG is running in a backwards compatible way, i.e. without the -no-old-m -

    28.3.17.2 Names

    +

    29.3.17.2 Names

    If SWIG is launched without -no-old-metatable-bindings option, then it enters backward-compatible mode. While in this mode, it tries @@ -1485,7 +1485,7 @@ surrounding scope without any prefixing. Pretending that Test2 is a struct, not > -

    28.3.17.3 Inheritance

    +

    29.3.17.3 Inheritance

    The internal organization of inheritance has changed. @@ -1530,12 +1530,12 @@ function > -

    28.4 Typemaps

    +

    29.4 Typemaps

    This section explains what typemaps are and how to use them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect

    -

    28.4.1 What is a typemap?

    +

    29.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:

    @@ -1563,7 +1563,7 @@ Received an integer : 6 720 -

    28.4.2 Using typemaps

    +

    29.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.

    @@ -1616,7 +1616,7 @@ void swap(int *sx, int *sy);

    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).

    -

    28.4.3 Typemaps and arrays

    +

    29.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 @@ -1680,7 +1680,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In

    Note: SWIG also can support arrays of pointers in a similar manner.

    -

    28.4.4 Typemaps and pointer-pointer functions

    +

    29.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:

    @@ -1714,7 +1714,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs) ptr=nil -- the iMath* will be GC'ed as normal -

    28.5 Writing typemaps

    +

    29.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.

    @@ -1723,7 +1723,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

    Before proceeding, you should read the previous section on using typemaps, and look at the existing 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 an idea to base your work on).

    -

    28.5.1 Typemaps you can write

    +

    29.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.

    @@ -1736,7 +1736,7 @@ ptr=nil -- the iMath* will be GC'ed as normal (the syntax for the typecheck is different from the typemap, see typemaps for details). -

    28.5.2 SWIG's Lua-C API

    +

    29.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.

    @@ -1785,7 +1785,7 @@ This macro, when called within the context of a SWIG wrapped function, will disp
    Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    -

    28.6 Customization of your Bindings

    +

    29.6 Customization of your Bindings

    @@ -1794,7 +1794,7 @@ This section covers adding of some small extra bits to your module to add the la -

    28.6.1 Writing your own custom wrappers

    +

    29.6.1 Writing your own custom wrappers

    @@ -1813,7 +1813,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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    28.6.2 Adding additional Lua code

    +

    29.6.2 Adding additional Lua code

    @@ -1851,7 +1851,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.

    -

    28.7 Details on the Lua binding

    +

    29.7 Details on the Lua binding

    @@ -1862,7 +1862,7 @@ See Examples/lua/arrays for an example of this code.

    -

    28.7.1 Binding global data into the module.

    +

    29.7.1 Binding global data into the module.

    @@ -1922,7 +1922,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)'.

    -

    28.7.2 Userdata and Metatables

    +

    29.7.2 Userdata and Metatables

    @@ -2002,7 +2002,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrapped classes/str

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' 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.

    -

    28.7.3 Memory management

    +

    29.7.3 Memory management

    diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 7efd74e2b..b9b7b2b94 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -7,7 +7,7 @@ -

    19 Working with Modules

    +

    20 Working with Modules

    -

    37.3 External documentation

    +

    38.3 External documentation

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 92b5260fe..4ae07e969 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -7,7 +7,7 @@ -

    38 SWIG and OCaml

    +

    39 SWIG and OCaml

    -

    38.1.3 The camlp4 module

    +

    39.1.3 The camlp4 module

    @@ -242,7 +242,7 @@ let b = C_string (getenv "PATH") -

    38.1.4 Using your module

    +

    39.1.4 Using your module

    @@ -256,7 +256,7 @@ option to build your functions into the primitive list. This option is not needed when you build native code.

    -

    38.1.5 Compilation problems and compiling with C++

    +

    39.1.5 Compilation problems and compiling with C++

    @@ -267,7 +267,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

    -

    38.2 The low-level Ocaml/C interface

    +

    39.2 The low-level Ocaml/C interface

    @@ -367,7 +367,7 @@ value items pass through directly, but you must make your own type signature for a function that uses value in this way.

    -

    38.2.1 The generated module

    +

    39.2.1 The generated module

    @@ -401,7 +401,7 @@ it describes the output SWIG will generate for class definitions. -

    38.2.2 Enums

    +

    39.2.2 Enums

    @@ -464,7 +464,7 @@ val x : Enum_test.c_obj = C_enum `a

    -

    38.2.2.1 Enum typing in Ocaml

    +

    39.2.2.1 Enum typing in Ocaml

    @@ -477,10 +477,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

    -

    38.2.3 Arrays

    +

    39.2.3 Arrays

    -

    38.2.3.1 Simple types of bounded arrays

    +

    39.2.3.1 Simple types of bounded arrays

    @@ -501,7 +501,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

    -

    38.2.3.2 Complex and unbounded arrays

    +

    39.2.3.2 Complex and unbounded arrays

    @@ -514,7 +514,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.

    -

    38.2.3.3 Using an object

    +

    39.2.3.3 Using an object

    @@ -528,7 +528,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

    -

    38.2.3.4 Example typemap for a function taking float * and int

    +

    39.2.3.4 Example typemap for a function taking float * and int

    @@ -579,7 +579,7 @@ void printfloats( float *tab, int len ); -

    38.2.4 C++ Classes

    +

    39.2.4 C++ Classes

    @@ -622,7 +622,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

    -

    38.2.4.1 STL vector and string Example

    +

    39.2.4.1 STL vector and string Example

    @@ -702,7 +702,7 @@ baz # -

    38.2.4.2 C++ Class Example

    +

    39.2.4.2 C++ Class Example

    @@ -732,7 +732,7 @@ public: }; -

    38.2.4.3 Compiling the example

    +

    39.2.4.3 Compiling the example

    @@ -750,7 +750,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
       -L$QTPATH/lib -cclib -lqt
     
    -

    38.2.4.4 Sample Session

    +

    39.2.4.4 Sample Session

    @@ -777,10 +777,10 @@ Assuming you have a working installation of QT, you will see a window
     containing the string "hi" in a button.
     

    -

    38.2.5 Director Classes

    +

    39.2.5 Director Classes

    -

    38.2.5.1 Director Introduction

    +

    39.2.5.1 Director Introduction

    @@ -807,7 +807,7 @@ class foo { };

    -

    38.2.5.2 Overriding Methods in Ocaml

    +

    39.2.5.2 Overriding Methods in Ocaml

    @@ -835,7 +835,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.

    -

    38.2.5.3 Director Usage Example

    +

    39.2.5.3 Director Usage Example

    @@ -896,7 +896,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

    -

    38.2.5.4 Creating director objects

    +

    39.2.5.4 Creating director objects

    @@ -937,7 +937,7 @@ object from causing a core dump, as long as the object is destroyed properly.

    -

    38.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    +

    39.2.5.5 Typemaps for directors, directorin, directorout, directorargout

    @@ -948,7 +948,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.

    -

    38.2.5.6 directorin typemap

    +

    39.2.5.6 directorin typemap

    @@ -959,7 +959,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

    -

    38.2.5.7 directorout typemap

    +

    39.2.5.7 directorout typemap

    @@ -970,7 +970,7 @@ for the same type, except when there are special requirements for object ownership, etc.

    -

    38.2.5.8 directorargout typemap

    +

    39.2.5.8 directorargout typemap

    @@ -987,7 +987,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.

    -

    38.2.6 Exceptions

    +

    39.2.6 Exceptions

    @@ -1075,7 +1075,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    38.3 Documentation Features

    +

    39.3 Documentation Features

    @@ -1084,7 +1084,7 @@ comments (colloquially referred to as "docstrings") that can be read by OCamldoc.

    -

    38.3.1 Module docstring

    +

    39.3.1 Module docstring

    diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index bd6b08ff9..bdef5db7c 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -9,7 +9,7 @@ -

    29 SWIG and Octave

    +

    30 SWIG and Octave

      @@ -60,7 +60,7 @@ This chapter is intended to give an introduction to using the module. You should 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).

      -

      29.1 Preliminaries

      +

      30.1 Preliminaries

      @@ -76,7 +76,7 @@ This cannot be guaranteed however, as in recent times new Octave releases have r The SWIG runtime exports the function swig_octave_prereq() for checking the version of Octave.

      -

      29.2 Running SWIG

      +

      30.2 Running SWIG

      @@ -108,7 +108,7 @@ The -c++ option is also required when wrapping C++ code: This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

      -

      29.2.1 Command-line options

      +

      30.2.1 Command-line options

      @@ -131,7 +131,7 @@ The special name "." loads C global variables into the module namespace, i.e. al The -opprefix options sets the prefix of the names of global/friend operator functions.

      -

      29.2.2 Compiling a dynamic module

      +

      30.2.2 Compiling a dynamic module

      @@ -158,7 +158,7 @@ $ mkoctfile example_wrap.cpp example.c

      octave:1> swigexample
      -

      29.2.3 Using your module

      +

      30.2.3 Using your module

      @@ -176,10 +176,10 @@ octave:4> swigexample.cvar.Foo=4; octave:5> swigexample.cvar.Foo ans = 4

    -

    29.3 A tour of basic C/C++ wrapping

    +

    30.3 A tour of basic C/C++ wrapping

    -

    29.3.1 Modules

    +

    30.3.1 Modules

    @@ -224,7 +224,7 @@ octave:4> swigexample.gcd(4, 6) ans = 2 -

    29.3.2 Functions

    +

    30.3.2 Functions

    @@ -241,7 +241,7 @@ int fact(int n);

    octave:1> swigexample.fact(4)
     24 
    -

    29.3.3 Global variables

    +

    30.3.3 Global variables

    @@ -294,7 +294,7 @@ octave:2> swigexample.PI=3.142; octave:3> swigexample.PI ans = 3.1420 -

    29.3.4 Constants and enums

    +

    30.3.4 Constants and enums

    @@ -316,7 +316,7 @@ swigexample.SCONST="Hello World" swigexample.SUNDAY=0 .... -

    29.3.5 Pointers

    +

    30.3.5 Pointers

    @@ -363,7 +363,7 @@ octave:2> f=swigexample.fopen("not there", "r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

    29.3.6 Structures and C++ classes

    +

    30.3.6 Structures and C++ classes

    @@ -498,7 +498,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.

    -

    29.3.7 C++ inheritance

    +

    30.3.7 C++ inheritance

    @@ -507,7 +507,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.

    -

    29.3.8 C++ overloaded functions

    +

    30.3.8 C++ overloaded functions

    @@ -517,7 +517,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.

    -

    29.3.9 C++ operators

    +

    30.3.9 C++ operators

    @@ -621,7 +621,7 @@ On the C++ side, the default mappings are as follows: Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.

    -

    29.3.10 Class extension with %extend

    +

    30.3.10 Class extension with %extend

    @@ -660,7 +660,7 @@ Similarly, Octave can use the __float__ method to convert an object to Octave 3.8.0 and later versions will also map unary functions X() to the corresponding __X__ method, where X includes: abs(), acos(), acosh(), angle(), arg(), asin(), asinh(), atan(), atanh(), cbrt(), ceil(), conj(), cos(), cosh(), dawson(), erf(), erfc(), erfcinv(), erfcx(), erfi(), erfinv(), exp(), expm1(), finite(), fix(), floor(), gamma(), imag(), isalnum(), isalpha(), isascii(), iscntrl(), isdigit(), isgraph(), isinf(), islower(), isna(), isnan(), isprint(), ispunct(), isspace(), isupper(), isxdigit(), lgamma(), log(), log10(), log1p(), log2(), real(), round(), roundb(), signbit(), signum(), sin(), sinh(), sqrt(), tan(), tanh(), toascii(), tolower(), toupper()

    -

    29.3.11 C++ templates

    +

    30.3.11 C++ templates

    @@ -737,10 +737,10 @@ ans = -

    29.3.12 C++ Smart Pointers

    +

    30.3.12 C++ Smart Pointers

    -

    29.3.12.1 The shared_ptr Smart Pointer

    +

    30.3.12.1 The shared_ptr Smart Pointer

    @@ -751,14 +751,14 @@ in the shared_ptr smart pointer -

    29.3.12.2 Generic Smart Pointers

    +

    30.3.12.2 Generic Smart Pointers

    C++ smart pointers are fully supported as in other modules.

    -

    29.3.13 Directors (calling Octave from C++ code)

    +

    30.3.13 Directors (calling Octave from C++ code)

    @@ -839,14 +839,14 @@ c-side routine called octave-side routine called -

    29.3.14 Threads

    +

    30.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.

    -

    29.3.15 Memory management

    +

    30.3.15 Memory management

    @@ -880,14 +880,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).

    -

    29.3.16 STL support

    +

    30.3.16 STL support

    Various STL library files are provided for wrapping STL containers.

    -

    29.3.17 Matrix typemaps

    +

    30.3.17 Matrix typemaps

    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 766ccaede..1e7bd9f86 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -7,7 +7,7 @@ -

    30 SWIG and Perl5

    +

    31 SWIG and Perl5

    -

    30.2.2 Compiling a dynamic module

    +

    31.2.2 Compiling a dynamic module

    @@ -208,7 +208,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

    -

    30.2.3 Building a dynamic module with MakeMaker

    +

    31.2.3 Building a dynamic module with MakeMaker

    @@ -242,7 +242,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.

    -

    30.2.4 Building a static version of Perl

    +

    31.2.4 Building a static version of Perl

    @@ -311,7 +311,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

    -

    30.2.5 Using the module

    +

    31.2.5 Using the module

    @@ -464,7 +464,7 @@ system configuration (this requires root access and you will need to read the man pages).

    -

    30.2.6 Compilation problems and compiling with C++

    +

    31.2.6 Compilation problems and compiling with C++

    @@ -607,7 +607,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.

    -

    30.2.7 Compiling for 64-bit platforms

    +

    31.2.7 Compiling for 64-bit platforms

    @@ -634,7 +634,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

    -

    30.3 Building Perl Extensions under Windows

    +

    31.3 Building Perl Extensions under Windows

    @@ -645,7 +645,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

    -

    30.3.1 Running SWIG from Developer Studio

    +

    31.3.1 Running SWIG from Developer Studio

    @@ -708,7 +708,7 @@ print "$a\n"; -

    30.3.2 Using other compilers

    +

    31.3.2 Using other compilers

    @@ -716,7 +716,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.

    -

    30.4 The low-level interface

    +

    31.4 The low-level interface

    @@ -726,7 +726,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.

    -

    30.4.1 Functions

    +

    31.4.1 Functions

    @@ -749,7 +749,7 @@ use example; $a = &example::fact(2); -

    30.4.2 Global variables

    +

    31.4.2 Global variables

    @@ -819,7 +819,7 @@ extern char *path; // Declared later in the input -

    30.4.3 Constants

    +

    31.4.3 Constants

    @@ -859,7 +859,7 @@ print example::FOO, "\n"; -

    30.4.4 Pointers

    +

    31.4.4 Pointers

    @@ -968,7 +968,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

    -

    30.4.5 Structures

    +

    31.4.5 Structures

    @@ -1102,7 +1102,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

    30.4.6 C++ classes

    +

    31.4.6 C++ classes

    @@ -1167,7 +1167,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.

    -

    30.4.7 C++ classes and type-checking

    +

    31.4.7 C++ classes and type-checking

    @@ -1203,7 +1203,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

    -

    30.4.8 C++ overloaded functions

    +

    31.4.8 C++ overloaded functions

    @@ -1247,7 +1247,7 @@ example::Spam_foo_d($s, 3.14); Please refer to the "SWIG Basics" chapter for more information.

    -

    30.4.9 Operators

    +

    31.4.9 Operators

    @@ -1274,7 +1274,7 @@ The following C++ operators are currently supported by the Perl module:

  • operator or
  • -

    30.4.10 Modules and packages

    +

    31.4.10 Modules and packages

    @@ -1369,7 +1369,7 @@ print Foo::fact(4), "\n"; # Call a function in package FooBar --> -

    30.5 Input and output parameters

    +

    31.5 Input and output parameters

    @@ -1588,7 +1588,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

    -

    30.6 Exception handling

    +

    31.6 Exception handling

    @@ -1752,7 +1752,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

    -

    30.7 Remapping datatypes with typemaps

    +

    31.7 Remapping datatypes with typemaps

    @@ -1769,7 +1769,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

    -

    30.7.1 A simple typemap example

    +

    31.7.1 A simple typemap example

    @@ -1873,7 +1873,7 @@ example::count("e", "Hello World"); -

    30.7.2 Perl5 typemaps

    +

    31.7.2 Perl5 typemaps

    @@ -1978,7 +1978,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

    30.7.3 Typemap variables

    +

    31.7.3 Typemap variables

    @@ -2049,7 +2049,7 @@ properly assigned. The Perl name of the wrapper function being created. -

    30.7.4 Useful functions

    +

    31.7.4 Useful functions

    @@ -2118,7 +2118,7 @@ int sv_isa(SV *, char *0; -

    30.8 Typemap Examples

    +

    31.8 Typemap Examples

    @@ -2127,7 +2127,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

    -

    30.8.1 Converting a Perl5 array to a char **

    +

    31.8.1 Converting a Perl5 array to a char **

    @@ -2219,7 +2219,7 @@ print @$b, "\n"; # Print it out -

    30.8.2 Return values

    +

    31.8.2 Return values

    @@ -2248,7 +2248,7 @@ can be done using the EXTEND() macro as in: } -

    30.8.3 Returning values from arguments

    +

    31.8.3 Returning values from arguments

    @@ -2302,7 +2302,7 @@ print "multout(7, 13) = @r\n"; ($x, $y) = multout(7, 13); -

    30.8.4 Accessing array structure members

    +

    31.8.4 Accessing array structure members

    @@ -2365,7 +2365,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

    -

    30.8.5 Turning Perl references into C pointers

    +

    31.8.5 Turning Perl references into C pointers

    @@ -2430,7 +2430,7 @@ print "$c\n"; -

    30.8.6 Pointer handling

    +

    31.8.6 Pointer handling

    @@ -2515,7 +2515,7 @@ For example: -

    30.9 Proxy classes

    +

    31.9 Proxy classes

    @@ -2531,7 +2531,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

    -

    30.9.1 Preliminaries

    +

    31.9.1 Preliminaries

    @@ -2553,7 +2553,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.

    -

    30.9.2 Structure and class wrappers

    +

    31.9.2 Structure and class wrappers

    @@ -2680,7 +2680,7 @@ $v->DESTROY(); -

    30.9.3 Object Ownership

    +

    31.9.3 Object Ownership

    @@ -2767,7 +2767,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

    -

    30.9.4 Nested Objects

    +

    31.9.4 Nested Objects

    @@ -2820,7 +2820,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

    30.9.5 Proxy Functions

    +

    31.9.5 Proxy Functions

    @@ -2854,7 +2854,7 @@ This function replaces the original function, but operates in an identical manner.

    -

    30.9.6 Inheritance

    +

    31.9.6 Inheritance

    @@ -2930,7 +2930,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

    -

    30.9.7 Modifying the proxy methods

    +

    31.9.7 Modifying the proxy methods

    @@ -2958,7 +2958,7 @@ public: }; -

    30.10 Adding additional Perl code

    +

    31.10 Adding additional Perl code

    @@ -3009,7 +3009,7 @@ set_transform($im, $a); -

    30.11 Cross language polymorphism

    +

    31.11 Cross language polymorphism

    @@ -3043,7 +3043,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    30.11.1 Enabling directors

    +

    31.11.1 Enabling directors

    @@ -3133,7 +3133,7 @@ sub one { -

    30.11.2 Director classes

    +

    31.11.2 Director classes

    @@ -3214,7 +3214,7 @@ so there is no need for the extra overhead involved with routing the calls through Perl.

    -

    30.11.3 Ownership and object destruction

    +

    31.11.3 Ownership and object destruction

    @@ -3263,7 +3263,7 @@ sub DESTROY { -

    30.11.4 Exception unrolling

    +

    31.11.4 Exception unrolling

    @@ -3319,7 +3319,7 @@ Swig::DirectorMethodException is thrown, Perl will register the exception as soon as the C wrapper function returns.

    -

    30.11.5 Overhead and code bloat

    +

    31.11.5 Overhead and code bloat

    @@ -3353,7 +3353,7 @@ directive) for only those methods that are likely to be extended in Perl.

    -

    30.11.6 Typemaps

    +

    31.11.6 Typemaps

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index d0ec0df7f..09c514e94 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,7 +7,7 @@ -

    31 SWIG and PHP

    +

    32 SWIG and PHP

    -

    31.1.2 Using PHP Extensions

    +

    32.1.2 Using PHP Extensions

    @@ -182,7 +182,7 @@ This PHP module also defines the PHP classes for the wrapped API, so you'll almost certainly want to include it anyway.

    -

    31.2 Basic PHP interface

    +

    32.2 Basic PHP interface

    @@ -194,7 +194,7 @@ SWIG doesn't have support for generating wrappers which make use of PHP's namespace feature.

    -

    31.2.1 Constants

    +

    32.2.1 Constants

    @@ -273,7 +273,7 @@ is treated as true by the if test, when the value of the intended constant would be treated as false!

    -

    31.2.2 Global Variables

    +

    32.2.2 Global Variables

    @@ -322,7 +322,7 @@ undefined. At this time SWIG does not support custom accessor methods.

    -

    31.2.3 Functions

    +

    32.2.3 Functions

    @@ -375,7 +375,7 @@ print $s; # The value of $s was not changed. --> -

    31.2.4 Overloading

    +

    32.2.4 Overloading

    @@ -430,7 +430,7 @@ taking the integer argument.

    --> -

    31.2.5 Pointers and References

    +

    32.2.5 Pointers and References

    @@ -568,7 +568,7 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

    -

    31.2.6 Structures and C++ classes

    +

    32.2.6 Structures and C++ classes

    @@ -629,7 +629,7 @@ Would be used in the following way from PHP: Member variables and methods are accessed using the -> operator.

    -

    31.2.6.1 Using -noproxy

    +

    32.2.6.1 Using -noproxy

    @@ -655,7 +655,7 @@ Complex_im_set($obj, $d); Complex_im_get($obj); -

    31.2.6.2 Constructors and Destructors

    +

    32.2.6.2 Constructors and Destructors

    @@ -696,7 +696,7 @@ the programmer can either reassign the variable or call unset($v)

    -

    31.2.6.3 Static Member Variables

    +

    32.2.6.3 Static Member Variables

    @@ -739,7 +739,7 @@ Ko::threats(10); echo "There have now been " . Ko::threats() . " threats\n"; -

    31.2.6.4 Static Member Functions

    +

    32.2.6.4 Static Member Functions

    @@ -761,7 +761,7 @@ Ko::threats(); -

    31.2.6.5 Specifying Implemented Interfaces

    +

    32.2.6.5 Specifying Implemented Interfaces

    @@ -779,7 +779,7 @@ so: If there are multiple interfaces, just list them separated by commas.

    -

    31.2.7 PHP Pragmas, Startup and Shutdown code

    +

    32.2.7 PHP Pragmas, Startup and Shutdown code

    @@ -876,7 +876,7 @@ The %rinit and %rshutdown statements are very similar but inse into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.

    -

    31.3 Cross language polymorphism

    +

    32.3 Cross language polymorphism

    @@ -911,7 +911,7 @@ wrapper functions takes care of all the cross-language method routing transparently.

    -

    31.3.1 Enabling directors

    +

    32.3.1 Enabling directors

    @@ -1000,7 +1000,7 @@ class MyFoo extends Foo { -

    31.3.2 Director classes

    +

    32.3.2 Director classes

    @@ -1081,7 +1081,7 @@ so there is no need for the extra overhead involved with routing the calls through PHP.

    -

    31.3.3 Ownership and object destruction

    +

    32.3.3 Ownership and object destruction

    @@ -1137,7 +1137,7 @@ In this example, we are assuming that FooContainer will take care of deleting all the Foo pointers it contains at some point.

    -

    31.3.4 Exception unrolling

    +

    32.3.4 Exception unrolling

    @@ -1204,7 +1204,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception as soon as the C wrapper function returns.

    -

    31.3.5 Overhead and code bloat

    +

    32.3.5 Overhead and code bloat

    @@ -1237,7 +1237,7 @@ optimized by selectively enabling director methods (using the %feature directive) for only those methods that are likely to be extended in PHP.

    -

    31.3.6 Typemaps

    +

    32.3.6 Typemaps

    @@ -1251,7 +1251,7 @@ need to be supported.

    -

    31.3.7 Miscellaneous

    +

    32.3.7 Miscellaneous

    Director typemaps for STL classes are mostly in place, and hence you diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 66061a597..51cc06378 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -7,7 +7,7 @@ -

    10 Preprocessing

    +

    11 Preprocessing

      @@ -38,7 +38,7 @@ However, a number of modifications and enhancements have been made. This chapter describes some of these modifications.

      -

      10.1 File inclusion

      +

      11.1 File inclusion

      @@ -64,7 +64,7 @@ By default, the #include is ignored unless you run SWIG with the is that you often don't want SWIG to try and wrap everything included in standard header system headers and auxiliary files. -

      10.2 File imports

      +

      11.2 File imports

      @@ -93,7 +93,7 @@ The -importall directive tells SWIG to follow all #include sta as imports. This might be useful if you want to extract type definitions from system header files without generating any wrappers. -

      10.3 Conditional Compilation

      +

      11.3 Conditional Compilation

      @@ -165,7 +165,7 @@ way in which an interface is generated or to mix SWIG directives with C code.

      -

      10.4 Macro Expansion

      +

      11.4 Macro Expansion

      @@ -220,7 +220,7 @@ like #x. This is a non-standard SWIG extension.

    -

    10.5 SWIG Macros

    +

    11.5 SWIG Macros

    @@ -266,7 +266,7 @@ many of SWIG's advanced features and libraries are built using this mechanism (s support).

    -

    10.6 C99 and GNU Extensions

    +

    11.6 C99 and GNU Extensions

    @@ -322,14 +322,14 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

    -

    10.7 Preprocessing and delimiters

    +

    11.7 Preprocessing and delimiters

    The preprocessor handles { }, " " and %{ %} delimiters differently.

    -

    10.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    +

    11.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -354,7 +354,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    10.7.2 Preprocessing and { ... } delimiters

    +

    11.7.2 Preprocessing and { ... } delimiters

    @@ -396,7 +396,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    10.8 Preprocessor and Typemaps

    +

    11.8 Preprocessor and Typemaps

    @@ -467,7 +467,7 @@ would generate

    -

    10.9 Viewing preprocessor output

    +

    11.9 Viewing preprocessor output

    @@ -477,7 +477,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    10.10 The #error and #warning directives

    +

    11.10 The #error and #warning directives

    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index ee443be53..fd07301d4 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -7,7 +7,7 @@ -

    32 SWIG and Python

    +

    33 SWIG and Python

    -

    32.3.3 Global variables

    +

    33.3.3 Global variables

    @@ -1158,7 +1158,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

    -

    32.3.4 Constants and enums

    +

    33.3.4 Constants and enums

    @@ -1198,7 +1198,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    32.3.5 Pointers

    +

    33.3.5 Pointers

    @@ -1339,7 +1339,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.

    -

    32.3.6 Structures

    +

    33.3.6 Structures

    @@ -1549,7 +1549,7 @@ memory and use of it results in a segfault or some sort of other undefined behav

    -

    32.3.7 C++ classes

    +

    33.3.7 C++ classes

    @@ -1637,7 +1637,7 @@ they are accessed through cvar like this: -

    32.3.8 C++ inheritance

    +

    33.3.8 C++ inheritance

    @@ -1692,7 +1692,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

    -

    32.3.9 Pointers, references, values, and arrays

    +

    33.3.9 Pointers, references, values, and arrays

    @@ -1753,7 +1753,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

    -

    32.3.10 C++ overloaded functions

    +

    33.3.10 C++ overloaded functions

    @@ -1876,7 +1876,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    32.3.11 C++ operators

    +

    33.3.11 C++ operators

    @@ -1973,7 +1973,7 @@ instead of raising an exception when the comparison fails, that is, on any kind This follows the guidelines in PEP 207 - Rich Comparisons and NotImplemented Python constant.

    -

    32.3.12 C++ namespaces

    +

    33.3.12 C++ namespaces

    @@ -2040,7 +2040,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    32.3.13 C++ templates

    +

    33.3.13 C++ templates

    @@ -2094,10 +2094,10 @@ Some more complicated examples will appear later.

    -

    32.3.14 C++ Smart Pointers

    +

    33.3.14 C++ Smart Pointers

    -

    32.3.14.1 The shared_ptr Smart Pointer

    +

    33.3.14.1 The shared_ptr Smart Pointer

    @@ -2108,7 +2108,7 @@ in the shared_ptr smart pointer -

    32.3.14.2 Generic Smart Pointers

    +

    33.3.14.2 Generic Smart Pointers

    @@ -2192,7 +2192,7 @@ simply use the __deref__() method. For example: -

    32.3.15 C++ reference counted objects

    +

    33.3.15 C++ reference counted objects

    @@ -2201,7 +2201,7 @@ Python examples of memory management using referencing counting.

    -

    32.4 Further details on the Python class interface

    +

    33.4 Further details on the Python class interface

    @@ -2224,7 +2224,7 @@ the -builtin option are in the Built-in section.

    -

    32.4.1 Proxy classes

    +

    33.4.1 Proxy classes

    @@ -2313,7 +2313,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).

    -

    32.4.2 Built-in Types

    +

    33.4.2 Built-in Types

    @@ -2357,7 +2357,7 @@ please refer to the Python documentation:

    https://docs.python.org/3/extending/newtypes.html

    -

    32.4.2.1 Limitations

    +

    33.4.2.1 Limitations

    Use of the -builtin option implies a couple of limitations: @@ -2518,7 +2518,7 @@ assert(issubclass(B.Derived, A.Base)) -

    32.4.2.2 Operator overloads and slots -- use them!

    +

    33.4.2.2 Operator overloads and slots -- use them!

    The entire justification for the -builtin option is improved @@ -2678,7 +2678,7 @@ in the file python/pyopers.swig in the SWIG library.

    -

    32.4.3 Memory management

    +

    33.4.3 Memory management

    NOTE: Although this section refers to proxy objects, everything here also applies @@ -2873,7 +2873,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

    -

    32.5 Cross language polymorphism

    +

    33.5 Cross language polymorphism

    @@ -2907,7 +2907,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

    -

    32.5.1 Enabling directors

    +

    33.5.1 Enabling directors

    @@ -2999,7 +2999,7 @@ class MyFoo(mymodule.Foo): -

    32.5.2 Director classes

    +

    33.5.2 Director classes

    @@ -3079,7 +3079,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

    -

    32.5.3 Ownership and object destruction

    +

    33.5.3 Ownership and object destruction

    @@ -3146,7 +3146,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

    -

    32.5.4 Exception unrolling

    +

    33.5.4 Exception unrolling

    @@ -3205,7 +3205,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

    -

    32.5.5 Overhead and code bloat

    +

    33.5.5 Overhead and code bloat

    @@ -3239,7 +3239,7 @@ directive) for only those methods that are likely to be extended in Python.

    -

    32.5.6 Typemaps

    +

    33.5.6 Typemaps

    @@ -3253,7 +3253,7 @@ need to be supported.

    -

    32.5.7 Miscellaneous

    +

    33.5.7 Miscellaneous

    @@ -3300,7 +3300,7 @@ methods that return const references.

    -

    32.6 Common customization features

    +

    33.6 Common customization features

    @@ -3313,7 +3313,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

    -

    32.6.1 C/C++ helper functions

    +

    33.6.1 C/C++ helper functions

    @@ -3394,7 +3394,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

    -

    32.6.2 Adding additional Python code

    +

    33.6.2 Adding additional Python code

    @@ -3650,7 +3650,7 @@ The same applies for overloaded constructors.

    -

    32.6.3 Class extension with %extend

    +

    33.6.3 Class extension with %extend

    @@ -3739,7 +3739,7 @@ Vector(12, 14, 16) in any way---the extensions only show up in the Python interface.

    -

    32.6.4 Exception handling with %exception

    +

    33.6.4 Exception handling with %exception

    @@ -3873,10 +3873,10 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

    -

    32.6.5 Optimization options

    +

    33.6.5 Optimization options

    -

    32.6.5.1 -fastproxy

    +

    33.6.5.1 -fastproxy

    @@ -4009,7 +4009,7 @@ While this possibly provides the best of both worlds, the time to import the mod The command line options mentioned above also apply to wrapped C/C++ global functions, not just class methods.

    -

    32.7 Tips and techniques

    +

    33.7 Tips and techniques

    @@ -4019,7 +4019,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

    -

    32.7.1 Input and output parameters

    +

    33.7.1 Input and output parameters

    @@ -4232,7 +4232,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    32.7.2 Simple pointers

    +

    33.7.2 Simple pointers

    @@ -4301,7 +4301,7 @@ If you replace %pointer_functions() by %pointer_class(type, name)SWIG Library chapter for further details.

    -

    32.7.3 Unbounded C Arrays

    +

    33.7.3 Unbounded C Arrays

    @@ -4363,7 +4363,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    32.7.4 String handling

    +

    33.7.4 String handling

    @@ -4433,7 +4433,7 @@ also be used to extra binary data from arbitrary pointers.

    -

    32.7.5 Default arguments

    +

    33.7.5 Default arguments

    @@ -4532,7 +4532,7 @@ Versions of SWIG prior to this varied in their ability to convert C++ default va equivalent Python default argument values.

    -

    32.8 Typemaps

    +

    33.8 Typemaps

    @@ -4549,7 +4549,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.

    -

    32.8.1 What is a typemap?

    +

    33.8.1 What is a typemap?

    @@ -4665,7 +4665,7 @@ parameter is omitted): -

    32.8.2 Python typemaps

    +

    33.8.2 Python typemaps

    @@ -4706,7 +4706,7 @@ a look at the SWIG library version 1.3.20 or so.

    -

    32.8.3 Typemap variables

    +

    33.8.3 Typemap variables

    @@ -4777,7 +4777,7 @@ properly assigned. The Python name of the wrapper function being created. -

    32.8.4 Useful Python Functions

    +

    33.8.4 Useful Python Functions

    @@ -4905,7 +4905,7 @@ write me -

    32.9 Typemap Examples

    +

    33.9 Typemap Examples

    @@ -4914,7 +4914,7 @@ might look at the files "python.swg" and "typemaps.i" in the SWIG library.

    -

    32.9.1 Converting Python list to a char **

    +

    33.9.1 Converting Python list to a char **

    @@ -4994,7 +4994,7 @@ memory allocation is used to allocate memory for the array, the the C function.

    -

    32.9.2 Expanding a Python object into multiple arguments

    +

    33.9.2 Expanding a Python object into multiple arguments

    @@ -5113,7 +5113,7 @@ TypeError: Wrong number or type of arguments for overloaded function 'foo'. -

    32.9.3 Using typemaps to return arguments

    +

    33.9.3 Using typemaps to return arguments

    @@ -5201,7 +5201,7 @@ function can now be used as follows: >>> -

    32.9.4 Mapping Python tuples into small arrays

    +

    33.9.4 Mapping Python tuples into small arrays

    @@ -5250,7 +5250,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

    -

    32.9.5 Mapping sequences to C arrays

    +

    33.9.5 Mapping sequences to C arrays

    @@ -5339,7 +5339,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

    32.9.6 Pointer handling

    +

    33.9.6 Pointer handling

    @@ -5436,7 +5436,7 @@ that has a this attribute. In addition, class object (if applicable).

    -

    32.9.7 Memory management when returning references to member variables

    +

    33.9.7 Memory management when returning references to member variables

    @@ -5597,7 +5597,7 @@ static PyObject *bike_reference() { -

    32.10 Docstring Features

    +

    33.10 Docstring Features

    @@ -5625,7 +5625,7 @@ of your users much simpler.

    -

    32.10.1 Module docstring

    +

    33.10.1 Module docstring

    @@ -5659,7 +5659,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

    32.10.2 %feature("autodoc")

    +

    33.10.2 %feature("autodoc")

    @@ -5687,7 +5687,7 @@ four levels for autodoc controlled by the value given to the feature, %feature("autodoc", "level"). The four values for level are covered in the following sub-sections. -

    32.10.2.1 %feature("autodoc", "0")

    +

    33.10.2.1 %feature("autodoc", "0")

    @@ -5716,7 +5716,7 @@ def function_name(*args, **kwargs): -

    32.10.2.2 %feature("autodoc", "1")

    +

    33.10.2.2 %feature("autodoc", "1")

    @@ -5741,7 +5741,7 @@ def function_name(*args, **kwargs): -

    32.10.2.3 %feature("autodoc", "2")

    +

    33.10.2.3 %feature("autodoc", "2")

    @@ -5803,7 +5803,7 @@ def function_name(*args, **kwargs): -

    32.10.2.4 %feature("autodoc", "3")

    +

    33.10.2.4 %feature("autodoc", "3")

    @@ -5829,7 +5829,7 @@ def function_name(*args, **kwargs): -

    32.10.2.5 %feature("autodoc", "docstring")

    +

    33.10.2.5 %feature("autodoc", "docstring")

    @@ -5848,7 +5848,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

    32.10.3 %feature("docstring")

    +

    33.10.3 %feature("docstring")

    @@ -5880,7 +5880,7 @@ with more than one line. -

    32.11 Python Packages

    +

    33.11 Python Packages

    Python has concepts of modules and packages. Modules are separate units of @@ -5954,7 +5954,7 @@ users may need to use special features such as the package option in th %module directive or import related command line options. These are explained in the following sections.

    -

    32.11.1 Setting the Python package

    +

    33.11.1 Setting the Python package

    @@ -6008,7 +6008,7 @@ pkg1/pkg2/_foo.so # (shared library built from C/C++ code generated by SWI -

    32.11.2 Absolute and relative imports

    +

    33.11.2 Absolute and relative imports

    Suppose, we have the following hierarchy of files:

    @@ -6145,7 +6145,7 @@ uses relative imports. Second case is, when one puts import directives in __init__.py to import symbols from submodules or subpackages and the submodule depends on other submodules (discussed later).

    -

    32.11.3 Enforcing absolute import semantics

    +

    33.11.3 Enforcing absolute import semantics

    As you may know, there is an incompatibility in import semantics (for the @@ -6182,7 +6182,7 @@ from __future__ import absolute_import -

    32.11.4 Importing from __init__.py

    +

    33.11.4 Importing from __init__.py

    Imports in __init__.py are handy when you want to populate a @@ -6292,7 +6292,7 @@ class Bar(pkg3.foo.Foo): pass effect (note, that the Python 2 case also needs the -relativeimport workaround).

    -

    32.11.5 Implicit namespace packages

    +

    33.11.5 Implicit namespace packages

    Python 3.3 introduced @@ -6370,7 +6370,7 @@ zipimporter requires python-3.5.1 or newer to work with subpackages.

    -

    32.11.6 Location of modules

    +

    33.11.6 Location of modules

    @@ -6406,7 +6406,7 @@ The following sub-sections look more closely at the two default configurations a An input interface file, foo.i, results in the two modules foo.py and _foo.so for each of the configurations.

    -

    32.11.6.1 Both modules in the same package

    +

    33.11.6.1 Both modules in the same package

    @@ -6441,7 +6441,7 @@ from mypackage import foo -

    32.11.6.2 Both modules are global

    +

    33.11.6.2 Both modules are global

    @@ -6473,7 +6473,7 @@ import foo -

    32.11.6.3 Split modules custom configuration

    +

    33.11.6.3 Split modules custom configuration

    In this non-standard 'split module' configuration, the pure Python module is in a package and the low level C/C++ module is global. @@ -6523,7 +6523,7 @@ Using one of the two default configurations is the recommended approach now.

    -

    32.11.6.4 More on customizing the module import code

    +

    33.11.6.4 More on customizing the module import code

    @@ -6643,7 +6643,7 @@ The following will do this for the 32.11.6.5 Statically linked C modules +

    33.11.6.5 Statically linked C modules

    It is strongly recommended to use dynamically linked modules for the C @@ -6715,7 +6715,7 @@ module then you will either need to refer to the Python documentation on how to do this (remember you are now the Python importer) or use dynamic linking.

    -

    32.12 Python 3 Support

    +

    33.12 Python 3 Support

    @@ -6740,7 +6740,7 @@ The following are Python 3 new features that are currently supported by SWIG.

    -

    32.12.1 Function annotation

    +

    33.12.1 Function annotation

    @@ -6773,7 +6773,7 @@ For detailed usage of function annotation, see PEP 3107.

    -

    32.12.2 Buffer interface

    +

    33.12.2 Buffer interface

    @@ -6925,7 +6925,7 @@ modify the buffer. -

    32.12.3 Abstract base classes

    +

    33.12.3 Abstract base classes

    @@ -6975,7 +6975,7 @@ The collections.abc module was introduced in Python 3.3 and hence this requires Python 3.3 or later.

    -

    32.12.4 Byte string output conversion

    +

    33.12.4 Byte string output conversion

    @@ -7156,7 +7156,7 @@ overloads taking both std::string (as Python bytes) and std::wstring (as Python unicode).

    -

    32.12.5 Python 2 Unicode

    +

    33.12.5 Python 2 Unicode

    @@ -7228,7 +7228,7 @@ the first is allowing unicode conversion and the second is explicitly prohibiting it.

    -

    32.13 Support for Multithreaded Applications

    +

    33.13 Support for Multithreaded Applications

    By default, SWIG does not enable support for multithreaded Python applications. More @@ -7243,7 +7243,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai interface for this is described in the next section.

    -

    32.13.1 UI for Enabling Multithreading Support

    +

    33.13.1 UI for Enabling Multithreading Support

    The user interface is as follows:

    @@ -7286,7 +7286,7 @@ will not be able to run any other threads, even if the wrapped C/C++ code is wai -

    32.13.2 Multithread Performance

    +

    33.13.2 Multithread Performance

    diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index d0713cade..e44fe432c 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -7,7 +7,7 @@ -

    33 SWIG and R

    +

    34 SWIG and R

      @@ -43,7 +43,7 @@ to SimpleITK. The R bindings also work on Microsoft Windows using Visual C++.

      -

      33.1 Bugs

      +

      34.1 Bugs

      @@ -57,7 +57,7 @@ Currently the following features are not implemented or broken:

    • C Array wrappings
    -

    33.2 Using R and SWIG

    +

    34.2 Using R and SWIG

    @@ -147,7 +147,7 @@ Error in .Call("R_swig_fact", s_arg1, as.logical(.copy), PACKAGE = "example") :

  • Make sure the architecture of the shared library(x64 for instance), matches the architecture of the R program you want to load your shared library into -

    33.3 Precompiling large R files

    +

    34.3 Precompiling large R files

    @@ -172,7 +172,7 @@ There is no need to precompile large R files if the SWIG-generated code is being in an R package. The package infrastructure provides this service during package installation.

    -

    33.4 General policy

    +

    34.4 General policy

    @@ -181,7 +181,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

    -

    33.5 Language conventions

    +

    34.5 Language conventions

    @@ -190,7 +190,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

    -

    33.6 C++ classes

    +

    34.6 C++ classes

    @@ -217,7 +217,7 @@ The R interface has the following capabilities:

  • Variable accessors are automatically generated and called via the $, [, [[, $<-, [<-, [[<- operators. -

    33.6.1 Examples

    +

    34.6.1 Examples

    @@ -310,7 +310,7 @@ defined "_p_Vehicle" The names in the accessorFuns list correspond to class methods while names in the vaccessors section correspond to variables that may be modified.

    -

    33.7 Enumerations

    +

    34.7 Enumerations

    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 6939a8a18..5581cc458 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -8,7 +8,7 @@ -

    34 SWIG and Ruby

    +

    35 SWIG and Ruby

      @@ -149,7 +149,7 @@

      This chapter describes SWIG's support of Ruby.

      -

      34.1 Preliminaries

      +

      35.1 Preliminaries

      SWIG 4.0 is known to work with Ruby versions 1.9 and later. @@ -164,7 +164,7 @@ read the "SWIG Basics" chapter. It is also assumed that the reader has a basic understanding of Ruby.

      -

      34.1.1 Running SWIG

      +

      35.1.1 Running SWIG

      To build a Ruby module, run SWIG using the -ruby @@ -188,7 +188,7 @@ if compiling a C++ extension) that contains all of the code needed to build a Ruby extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

      -

      34.1.2 Getting the right header files

      +

      35.1.2 Getting the right header files

      In order to compile the wrapper code, the compiler needs the ruby.h @@ -202,7 +202,7 @@ the compiler options needed to compile the code is to ask Ruby itself:

    -

    34.1.3 Compiling a dynamic module

    +

    35.1.3 Compiling a dynamic module

    Ruby extension modules are typically compiled into shared @@ -275,7 +275,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.

    -

    34.1.4 Using your module

    +

    35.1.4 Using your module

    Ruby module names must be capitalized, @@ -305,7 +305,7 @@ begins with:

    will result in an extension module using the feature name "example" and Ruby module name "Example".

    -

    34.1.5 Static linking

    +

    35.1.5 Static linking

    An alternative approach to dynamic linking is to rebuild the @@ -320,7 +320,7 @@ finding the Ruby source, adding an entry to the ext/Setup file, adding your directory to the list of extensions in the file, and finally rebuilding Ruby.

    -

    34.1.6 Compilation of C++ extensions

    +

    35.1.6 Compilation of C++ extensions

    On most machines, C++ extension modules should be linked @@ -352,7 +352,7 @@ $libs = append_library($libs, "supc++") create_makefile('example')

  • -

    34.2 Building Ruby Extensions under Windows 95/NT

    +

    35.2 Building Ruby Extensions under Windows 95/NT

    Building a SWIG extension to Ruby under Windows 95/NT is @@ -377,7 +377,7 @@ order to build extensions, you may need to download the source distribution to the Ruby package, as you will need the Ruby header files.

    -

    34.2.1 Running SWIG from Developer Studio

    +

    35.2.1 Running SWIG from Developer Studio

    If you are developing your application within Microsoft @@ -441,13 +441,13 @@ Foo = 3.0 -

    34.3 The Ruby-to-C/C++ Mapping

    +

    35.3 The Ruby-to-C/C++ Mapping

    This section describes the basics of how SWIG maps C or C++ declarations in your SWIG interface files to Ruby constructs.

    -

    34.3.1 Modules

    +

    35.3.1 Modules

    The SWIG %module directive specifies @@ -519,7 +519,7 @@ option to wrap everything into the global module, take care that the names of your constants, classes and methods don't conflict with any of Ruby's built-in names.

    -

    34.3.2 Functions

    +

    35.3.2 Functions

    Global functions are wrapped as Ruby module methods. For @@ -553,7 +553,7 @@ irb(main):002:0> Example.fact(4) 24 -

    34.3.3 Variable Linking

    +

    35.3.3 Variable Linking

    C/C++ global variables are wrapped as a pair of singleton @@ -633,7 +633,7 @@ irb(main):004:0> $Variable2 41.2 -

    34.3.4 Constants

    +

    35.3.4 Constants

    C/C++ constants are wrapped as module constants initialized @@ -661,7 +661,7 @@ irb(main):002:0> Example::PI 3.14159 -

    34.3.5 Pointers

    +

    35.3.5 Pointers

    "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -685,7 +685,7 @@ returns an instance of an internally generated Ruby class:

    A NULL pointer is always represented by the Ruby nil object.

    -

    34.3.6 Structures

    +

    35.3.6 Structures

    C/C++ structs are wrapped as Ruby classes, with accessor @@ -790,7 +790,7 @@ void Bar_f_set(Bar *b, Foo *val) { } -

    34.3.7 C++ classes

    +

    35.3.7 C++ classes

    Like structs, C++ classes are wrapped by creating a new Ruby @@ -845,7 +845,7 @@ Ale 3 -

    34.3.8 C++ Inheritance

    +

    35.3.8 C++ Inheritance

    The SWIG type-checker is fully aware of C++ inheritance. @@ -998,7 +998,7 @@ inherit from both Base1 and Base2 (i.e. they exhibit "Duck Typing").

    -

    34.3.9 C++ Overloaded Functions

    +

    35.3.9 C++ Overloaded Functions

    C++ overloaded functions, methods, and constructors are @@ -1088,7 +1088,7 @@ arises--in this case, the first declaration takes precedence.

    Please refer to the "SWIG and C++" chapter for more information about overloading.

    -

    34.3.10 C++ Operators

    +

    35.3.10 C++ Operators

    For the most part, overloaded operators are handled @@ -1130,7 +1130,7 @@ c = Example.add_complex(a, b) is discussed in the section on operator overloading.

    -

    34.3.11 C++ namespaces

    +

    35.3.11 C++ namespaces

    SWIG is aware of C++ namespaces, but namespace names do not @@ -1187,7 +1187,7 @@ and create extension modules for each namespace separately. If your program utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

    -

    34.3.12 C++ templates

    +

    35.3.12 C++ templates

    C++ templates don't present a huge problem for SWIG. However, @@ -1229,7 +1229,7 @@ irb(main):004:0> p.second 4 -

    34.3.13 C++ Standard Template Library (STL)

    +

    35.3.13 C++ Standard Template Library (STL)

    On a related note, the standard SWIG library contains a @@ -1322,7 +1322,7 @@ puts v shown in these examples. More details can be found in the SWIG and C++ chapter.

    -

    34.3.14 C++ STL Functors

    +

    35.3.14 C++ STL Functors

    Some containers in the STL allow you to modify their default @@ -1383,7 +1383,7 @@ b -

    34.3.15 C++ STL Iterators

    +

    35.3.15 C++ STL Iterators

    The STL is well known for the use of iterators. There @@ -1466,10 +1466,10 @@ i

    If you'd rather have STL classes without any iterators, you should define -DSWIG_NO_EXPORT_ITERATOR_METHODS when running swig.

    -

    34.3.16 C++ Smart Pointers

    +

    35.3.16 C++ Smart Pointers

    -

    34.3.16.1 The shared_ptr Smart Pointer

    +

    35.3.16.1 The shared_ptr Smart Pointer

    @@ -1480,7 +1480,7 @@ in the shared_ptr smart pointer -

    34.3.16.2 Generic Smart Pointers

    +

    35.3.16.2 Generic Smart Pointers

    In certain C++ programs, it is common to use classes that @@ -1545,7 +1545,7 @@ method. For example:

    irb(main):004:0> f = p.__deref__() # Returns underlying Foo *
    -

    34.3.17 Cross-Language Polymorphism

    +

    35.3.17 Cross-Language Polymorphism

    SWIG's Ruby module supports cross-language polymorphism @@ -1554,7 +1554,7 @@ module. Rather than duplicate the information presented in the 34.3.17.1 Exception Unrolling +

    35.3.17.1 Exception Unrolling

    Whenever a C++ director class routes one of its virtual @@ -1577,7 +1577,7 @@ method is "wrapped" using the rb_rescue2() function from Ruby's C API. If any Ruby exception is raised, it will be caught here and a C++ exception is raised in its place.

    -

    34.4 Naming

    +

    35.4 Naming

    Ruby has several common naming conventions. Constants are @@ -1615,7 +1615,7 @@ generated by SWIG, it is turned off by default in SWIG 1.3.28. However, it is planned to become the default option in future releases.

    -

    34.4.1 Defining Aliases

    +

    35.4.1 Defining Aliases

    It's a fairly common practice in the Ruby built-ins and @@ -1685,7 +1685,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.2 Predicate Methods

    +

    35.4.2 Predicate Methods

    Ruby methods that return a boolean value and end in a @@ -1734,7 +1734,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.3 Bang Methods

    +

    35.4.3 Bang Methods

    Ruby methods that modify an object in-place and end in an @@ -1766,7 +1766,7 @@ using SWIG's "features" mechanism and so the same name matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.4.4 Getters and Setters

    +

    35.4.4 Getters and Setters

    Often times a C++ library will expose properties through @@ -1801,7 +1801,7 @@ irb(main):003:0> puts foo.value %rename("value=") Foo::setValue(int value); -

    34.5 Input and output parameters

    +

    35.5 Input and output parameters

    A common problem in some C programs is handling parameters @@ -1940,10 +1940,10 @@ void get_dimensions(Matrix *m, int *rows, int*columns);

    r, c = Example.get_dimensions(m)
    -

    34.6 Exception handling

    +

    35.6 Exception handling

    -

    34.6.1 Using the %exception directive

    +

    35.6.1 Using the %exception directive

    The SWIG %exception directive can be @@ -2052,7 +2052,7 @@ methods and functions named getitem and setitem. limited to C++ exception handling. See the chapter on Customization Features for more examples.

    -

    34.6.2 Handling Ruby Blocks

    +

    35.6.2 Handling Ruby Blocks

    One of the highlights of Ruby and most of its standard library @@ -2119,7 +2119,7 @@ a special in typemap, like:

    For more information on typemaps, see Typemaps.

    -

    34.6.3 Raising exceptions

    +

    35.6.3 Raising exceptions

    There are three ways to raise exceptions from C++ code to @@ -2276,7 +2276,7 @@ function. The first argument passed to rb_raise() is the exception type. You can raise a custom exception type or one of the built-in Ruby exception types.

    -

    34.6.4 Exception classes

    +

    35.6.4 Exception classes

    Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -2313,7 +2313,7 @@ end

    For another example look at swig/Examples/ruby/exception_class.

    -

    34.7 Typemaps

    +

    35.7 Typemaps

    This section describes how you can modify SWIG's default @@ -2328,7 +2328,7 @@ 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 primitive C-Ruby interface.

    -

    34.7.1 What is a typemap?

    +

    35.7.1 What is a typemap?

    A typemap is nothing more than a code generation rule that is @@ -2485,7 +2485,7 @@ to be used as follows (notice how the length parameter is omitted):

    2 -

    34.7.2 Typemap scope

    +

    35.7.2 Typemap scope

    Once defined, a typemap remains in effect for all of the @@ -2531,7 +2531,7 @@ where the class itself is defined. For example:

    }; -

    34.7.3 Copying a typemap

    +

    35.7.3 Copying a typemap

    A typemap is copied by using assignment. For example:

    @@ -2573,7 +2573,7 @@ rules as for %apply (char *buf, int len) { (char *buffer, int size) }; // Multiple arguments -

    34.7.4 Deleting a typemap

    +

    35.7.4 Deleting a typemap

    A typemap can be deleted by simply defining no code. For @@ -2598,7 +2598,7 @@ defined by typemaps, clearing a fundamental type like int will make that type unusable unless you also define a new set of typemaps immediately after the clear operation.

    -

    34.7.5 Placement of typemaps

    +

    35.7.5 Placement of typemaps

    Typemap declarations can be declared in the global scope, @@ -2669,13 +2669,13 @@ In this example, this is done using the class declaration class string .

    -

    34.7.6 Ruby typemaps

    +

    35.7.6 Ruby typemaps

    The following list details all of the typemap methods that can be used by the Ruby module:

    -

    34.7.6.1 "in" typemap

    +

    35.7.6.1 "in" typemap

    Converts Ruby objects to input @@ -2742,7 +2742,7 @@ arguments to be specified. For example:

    At this time, only zero or one arguments may be converted.

    -

    34.7.6.2 "typecheck" typemap

    +

    35.7.6.2 "typecheck" typemap

    The "typecheck" typemap is used to support overloaded @@ -2764,7 +2764,7 @@ program uses overloaded methods, you should also define a collection of "typecheck" typemaps. More details about this follow in a later section on "Typemaps and Overloading."

    -

    34.7.6.3 "out" typemap

    +

    35.7.6.3 "out" typemap

    Converts return value of a C function @@ -2815,7 +2815,7 @@ version of the C datatype matched by the typemap.

    -

    34.7.6.4 "arginit" typemap

    +

    35.7.6.4 "arginit" typemap

    The "arginit" typemap is used to set the initial value of a @@ -2830,7 +2830,7 @@ applications. For example:

    } -

    34.7.6.5 "default" typemap

    +

    35.7.6.5 "default" typemap

    The "default" typemap is used to turn an argument into a @@ -2855,7 +2855,7 @@ arguments that follow must have default values. See the 34.7.6.6 "check" typemap +

    35.7.6.6 "check" typemap

    The "check" typemap is used to supply value checking code @@ -2870,7 +2870,7 @@ arguments have been converted. For example:

    } -

    34.7.6.7 "argout" typemap

    +

    35.7.6.7 "argout" typemap

    The "argout" typemap is used to return values from arguments. @@ -2924,7 +2924,7 @@ some function like SWIG_Ruby_AppendOutput.

    See the typemaps.i library for examples.

    -

    34.7.6.8 "freearg" typemap

    +

    35.7.6.8 "freearg" typemap

    The "freearg" typemap is used to cleanup argument data. It is @@ -2951,7 +2951,7 @@ This code is also placed into a special variable $cleanup that may be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    34.7.6.9 "newfree" typemap

    +

    35.7.6.9 "newfree" typemap

    The "newfree" typemap is used in conjunction with the %newobject @@ -2975,7 +2975,7 @@ string *foo();

    See Object ownership and %newobject for further details.

    -

    34.7.6.10 "memberin" typemap

    +

    35.7.6.10 "memberin" typemap

    The "memberin" typemap is used to copy data from an @@ -2993,21 +2993,21 @@ example:

    already provides a default implementation for arrays, strings, and other objects.

    -

    34.7.6.11 "varin" typemap

    +

    35.7.6.11 "varin" typemap

    The "varin" typemap is used to convert objects in the target language to C for the purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    34.7.6.12 "varout" typemap

    +

    35.7.6.12 "varout" typemap

    The "varout" typemap is used to convert a C/C++ object to an object in the target language when reading a C/C++ global variable. This is implementation specific.

    -

    34.7.6.13 "throws" typemap

    +

    35.7.6.13 "throws" typemap

    The "throws" typemap is only used when SWIG parses a C++ @@ -3048,7 +3048,7 @@ specification yet they do throw exceptions, SWIG cannot know how to deal with them. For a neat way to handle these, see the Exception handling with %exception section.

    -

    34.7.6.14 directorin typemap

    +

    35.7.6.14 directorin typemap

    Converts C++ objects in director @@ -3107,7 +3107,7 @@ referring to the class itself. -

    34.7.6.15 directorout typemap

    +

    35.7.6.15 directorout typemap

    Converts Ruby objects in director @@ -3180,7 +3180,7 @@ exception.

    -

    34.7.6.16 directorargout typemap

    +

    35.7.6.16 directorargout typemap

    Output argument processing in director @@ -3238,19 +3238,19 @@ referring to the instance of the class itself -

    34.7.6.17 ret typemap

    +

    35.7.6.17 ret typemap

    Cleanup of function return values

    -

    34.7.6.18 globalin typemap

    +

    35.7.6.18 globalin typemap

    Setting of C global variables

    -

    34.7.7 Typemap variables

    +

    35.7.7 Typemap variables

    @@ -3300,7 +3300,7 @@ so that their values can be properly assigned.

    The Ruby name of the wrapper function being created.
    -

    34.7.8 Useful Functions

    +

    35.7.8 Useful Functions

    When you write a typemap, you usually have to work directly @@ -3315,7 +3315,7 @@ stick to the swig functions instead of the native Ruby functions. That should help you avoid having to rewrite a lot of typemaps across multiple languages.

    -

    34.7.8.1 C Datatypes to Ruby Objects

    +

    35.7.8.1 C Datatypes to Ruby Objects

    @@ -3357,7 +3357,7 @@ SWIG_From_float(float)
    -

    34.7.8.2 Ruby Objects to C Datatypes

    +

    35.7.8.2 Ruby Objects to C Datatypes

    Here, while the Ruby versions return the value directly, the SWIG @@ -3425,7 +3425,7 @@ versions do not, but return a status value to indicate success (SWIG_OK -

    34.7.8.3 Macros for VALUE

    +

    35.7.8.3 Macros for VALUE

    RSTRING_LEN(str)

    @@ -3448,7 +3448,7 @@ versions do not, but return a status value to indicate success (SWIG_OK
    pointer to array storage
    -

    34.7.8.4 Exceptions

    +

    35.7.8.4 Exceptions

    void rb_raise(VALUE exception, const char *fmt, @@ -3527,7 +3527,7 @@ message to standard error if Ruby was invoked with the -w flag. The given format string fmt and remaining arguments are interpreted as with printf(). -

    34.7.8.5 Iterators

    +

    35.7.8.5 Iterators

    void rb_iter_break()

    @@ -3573,14 +3573,14 @@ VALUE), VALUE value)

    Equivalent to Ruby's throw.
    -

    34.7.9 Typemap Examples

    +

    35.7.9 Typemap Examples

    This section includes a few examples of typemaps. For more examples, you might look at the examples in the Example/ruby directory.

    -

    34.7.10 Converting a Ruby array to a char **

    +

    35.7.10 Converting a Ruby array to a char **

    A common problem in many C programs is the processing of @@ -3645,7 +3645,7 @@ array. Since dynamic memory allocation is used to allocate memory for the array, the "freearg" typemap is used to later release this memory after the execution of the C function.

    -

    34.7.11 Collecting arguments in a hash

    +

    35.7.11 Collecting arguments in a hash

    Ruby's solution to the "keyword arguments" capability of some @@ -3859,7 +3859,7 @@ memory leak. Fortunately, this typemap is a lot easier to write:

    program that uses the extension, can be found in the Examples/ruby/hashargs directory of the SWIG distribution.

    -

    34.7.12 Pointer handling

    +

    35.7.12 Pointer handling

    Occasionally, it might be necessary to convert pointer values @@ -3918,7 +3918,7 @@ For example:

    } -

    34.7.12.1 Ruby Datatype Wrapping

    +

    35.7.12.1 Ruby Datatype Wrapping

    VALUE Data_Wrap_Struct(VALUE class, void @@ -3945,7 +3945,7 @@ as above. type c-type from the data object obj and assigns that pointer to ptr. -

    34.7.13 Example: STL Vector to Ruby Array

    +

    35.7.13 Example: STL Vector to Ruby Array

    Another use for macros and type maps is to create a Ruby array @@ -4037,7 +4037,7 @@ STL with ruby, you are advised to use the standard swig STL library, which does much more than this. Refer to the section called the C++ Standard Template Library. -

    34.8 Docstring Features

    +

    35.8 Docstring Features

    @@ -4071,7 +4071,7 @@ generate ri documentation from a c wrap file, you could do:

    $ rdoc -r file_wrap.c -

    34.8.1 Module docstring

    +

    35.8.1 Module docstring

    @@ -4101,7 +4101,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." %module(docstring=DOCSTRING) xrc -

    34.8.2 %feature("autodoc")

    +

    35.8.2 %feature("autodoc")

    Since SWIG does know everything about the function it wraps, @@ -4122,7 +4122,7 @@ several options for autodoc controlled by the value given to the feature, described below.

    -

    34.8.2.1 %feature("autodoc", "0")

    +

    35.8.2.1 %feature("autodoc", "0")

    @@ -4146,7 +4146,7 @@ Then Ruby code like this will be generated: ... -

    34.8.2.2 %feature("autodoc", "1")

    +

    35.8.2.2 %feature("autodoc", "1")

    @@ -4166,7 +4166,7 @@ this: ... -

    34.8.2.3 %feature("autodoc", "2")

    +

    35.8.2.3 %feature("autodoc", "2")

    @@ -4178,7 +4178,7 @@ parameter types with the "2" option will result in Ruby code like this:

    -

    34.8.2.4 %feature("autodoc", "3")

    +

    35.8.2.4 %feature("autodoc", "3")

    @@ -4199,7 +4199,7 @@ Parameters: bar - Bar -

    34.8.2.5 %feature("autodoc", "docstring")

    +

    35.8.2.5 %feature("autodoc", "docstring")

    @@ -4215,7 +4215,7 @@ generated string. For example: void GetPosition(int* OUTPUT, int* OUTPUT); -

    34.8.3 %feature("docstring")

    +

    35.8.3 %feature("docstring")

    @@ -4226,10 +4226,10 @@ docstring associated with classes, function or methods are output. If an item already has an autodoc string then it is combined with the docstring and they are output together.

    -

    34.9 Advanced Topics

    +

    35.9 Advanced Topics

    -

    34.9.1 Operator overloading

    +

    35.9.1 Operator overloading

    SWIG allows operator overloading with, by using the %extend @@ -4410,7 +4410,7 @@ separate method for handling inequality since Ruby parses the expression a != b as !(a == b).

    -

    34.9.2 Creating Multi-Module Packages

    +

    35.9.2 Creating Multi-Module Packages

    The chapter on Working @@ -4536,7 +4536,7 @@ irb(main):005:0> c.getX() 5.0 -

    34.9.3 Specifying Mixin Modules

    +

    35.9.3 Specifying Mixin Modules

    The Ruby language doesn't support multiple inheritance, but @@ -4603,7 +4603,7 @@ matching rules used for other kinds of features apply (see the chapter on "Customization Features") for more details).

    -

    34.10 Memory Management

    +

    35.10 Memory Management

    One of the most common issues in generating SWIG bindings for @@ -4626,7 +4626,7 @@ to C++ (or vice versa) depending on what function or methods are invoked. Clearly, developing a SWIG wrapper requires a thorough understanding of how the underlying library manages memory.

    -

    34.10.1 Mark and Sweep Garbage Collector

    +

    35.10.1 Mark and Sweep Garbage Collector

    Ruby uses a mark and sweep garbage collector. When the garbage @@ -4657,7 +4657,7 @@ any memory has been allocated in creating the underlying C struct or C++ struct, then a "free" function must be defined that deallocates this memory.

    -

    34.10.2 Object Ownership

    +

    35.10.2 Object Ownership

    As described above, memory management depends on clearly @@ -4802,7 +4802,7 @@ public:

    This code can be seen in swig/examples/ruby/tracking.

    -

    34.10.3 Object Tracking

    +

    35.10.3 Object Tracking

    The remaining parts of this section will use the class library @@ -5028,7 +5028,7 @@ However, if you implement your own free functions (see below) you may also have to call the SWIG_RubyRemoveTracking and RubyUnlinkObjects methods.

    -

    34.10.4 Mark Functions

    +

    35.10.4 Mark Functions

    With a bit more testing, we see that our class library still @@ -5157,7 +5157,7 @@ irb(main):016:0>

    This code can be seen in swig/examples/ruby/mark_function.

    -

    34.10.5 Free Functions

    +

    35.10.5 Free Functions

    By default, SWIG creates a "free" function that is called when @@ -5325,7 +5325,7 @@ been freed, and thus raises a runtime exception.

    This code can be seen in swig/examples/ruby/free_function.

    -

    34.10.6 Embedded Ruby and the C++ Stack

    +

    35.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/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index dc9ae0f7e..0c259e393 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -91,6 +91,7 @@ For additions to the original C++ standard, please read the SWIG and C++11, SWIG and C++14 and SWIG and C++17 chapters. +SWIG and C++20 chapters. As a prerequisite, you should first read the chapter SWIG Basics to see how SWIG wraps ISO C. Support for C++ builds upon ISO C diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html index 88ab8043e..5c4ef6269 100644 --- a/Doc/Manual/Scilab.html +++ b/Doc/Manual/Scilab.html @@ -9,7 +9,7 @@ -

    35 SWIG and Scilab

    +

    36 SWIG and Scilab

    -

    35.3 A basic tour of C/C++ wrapping

    +

    36.3 A basic tour of C/C++ wrapping

    -

    35.3.1 Overview

    +

    36.3.1 Overview

    @@ -332,7 +332,7 @@ This means that functions, structs, classes, variables, etc... are interfaced th There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.

    -

    35.3.2 Identifiers

    +

    36.3.2 Identifiers

    @@ -347,7 +347,7 @@ In these cases, the %rename directive Note: truncations can be disabled by specifying the target version 6 of Scilab in the targetversion argument (i.e. -targetversion 6).

    -

    35.3.3 Functions

    +

    36.3.3 Functions

    @@ -378,7 +378,7 @@ ans = 24. -

    35.3.3.1 Argument passing

    +

    36.3.3.1 Argument passing

    @@ -431,7 +431,7 @@ In Scilab, parameters are passed by value. The output (and inout) parameters are 7. -

    35.3.3.2 Multiple output arguments

    +

    36.3.3.2 Multiple output arguments

    @@ -480,7 +480,7 @@ int divide(int n, int d, int *OUTPUT, int *OUTPUT); -

    35.3.4 Global variables

    +

    36.3.4 Global variables

    @@ -549,10 +549,10 @@ It works the same:

    -

    35.3.5 Constants and enumerations

    +

    36.3.5 Constants and enumerations

    -

    35.3.5.1 Constants

    +

    36.3.5.1 Constants

    @@ -693,7 +693,7 @@ are mapped to Scilab variables, with the same name: 3.14 -

    35.3.5.2 Enumerations

    +

    36.3.5.2 Enumerations

    @@ -758,7 +758,7 @@ typedef enum { RED, BLUE, GREEN } color; -

    35.3.6 Pointers

    +

    36.3.6 Pointers

    @@ -820,7 +820,7 @@ Note: the type name _p_FILE which means "pointer to FILE". The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).

    -

    35.3.6.1 Utility functions

    +

    36.3.6.1 Utility functions

    @@ -861,7 +861,7 @@ ans = -

    35.3.6.2 Null pointers:

    +

    36.3.6.2 Null pointers:

    @@ -877,7 +877,7 @@ Using the previous SWIG_this() and SWIG_ptr(), it is possible -

    35.3.7 Structures

    +

    36.3.7 Structures

    @@ -986,7 +986,7 @@ Note: the pointer to the struct works as described in 35.3.8 C++ classes +

    36.3.8 C++ classes

    @@ -1054,7 +1054,7 @@ Note: like structs, class pointers are mapped as described in 35.3.9 C++ inheritance +

    36.3.9 C++ inheritance

    @@ -1129,7 +1129,7 @@ But we can use either use the get_perimeter() function of the parent cl 18.84 -

    35.3.10 C++ overloading

    +

    36.3.10 C++ overloading

    @@ -1169,7 +1169,7 @@ void magnify(Circle *circle, double factor) { -

    35.3.11 Pointers, references, values, and arrays

    +

    36.3.11 Pointers, references, values, and arrays

    @@ -1227,7 +1227,7 @@ All these functions will return a pointer to an instance of Foo. As the function spam7 returns a value, new instance of Foo has to be allocated, and a pointer on this instance is returned.

    -

    35.3.12 C++ templates

    +

    36.3.12 C++ templates

    @@ -1286,7 +1286,7 @@ Then in Scilab: More details on template support can be found in the templates documentation.

    -

    35.3.13 C++ operators

    +

    36.3.13 C++ operators

    @@ -1339,7 +1339,7 @@ private: -

    35.3.14 C++ namespaces

    +

    36.3.14 C++ namespaces

    @@ -1417,7 +1417,7 @@ Note: the nspace feature is not supp

    -

    35.3.15 C++ exceptions

    +

    36.3.15 C++ exceptions

    @@ -1500,17 +1500,17 @@ More complex or custom exception types require specific exception typemaps to be See the SWIG C++ documentation for more details.

    -

    35.3.16 C++ STL

    +

    36.3.16 C++ STL

    The Standard Template Library (STL) is partially supported. See STL for more details.

    -

    35.4 Type mappings and libraries

    +

    36.4 Type mappings and libraries

    -

    35.4.1 Default primitive type mappings

    +

    36.4.1 Default primitive type mappings

    @@ -1561,7 +1561,7 @@ The default behaviour is for SWIG to generate code that will give a runtime erro -

    35.4.2 Arrays

    +

    36.4.2 Arrays

    @@ -1616,7 +1616,7 @@ void printArray(int values[], int len) { [ 0 1 2 3 ] -

    35.4.3 Pointer-to-pointers

    +

    36.4.3 Pointer-to-pointers

    @@ -1689,7 +1689,7 @@ void print_matrix(double **M, int nbRows, int nbCols) { -

    35.4.4 Matrices

    +

    36.4.4 Matrices

    @@ -1782,7 +1782,7 @@ The remarks made earlier for arrays also apply here:

  • There is no control while converting double values to integers, double values are truncated without any checking or warning.
  • -

    35.4.5 STL

    +

    36.4.5 STL

    @@ -1982,7 +1982,7 @@ ans = --> delete_PersonPtrSet(p); -

    35.5 Module initialization

    +

    36.5 Module initialization

    @@ -2006,7 +2006,7 @@ For example, to initialize the module example: --> example_Init(); -

    35.6 Building modes

    +

    36.6 Building modes

    @@ -2021,7 +2021,7 @@ To produce a dynamic module, when generating the wrapper, there are two possibil

  • the builder mode. In this mode, Scilab is responsible of building. -

    35.6.1 No-builder mode

    +

    36.6.1 No-builder mode

    @@ -2034,7 +2034,7 @@ This mode is the best option to use when you have to integrate the module build

    -

    35.6.2 Builder mode

    +

    36.6.2 Builder mode

    @@ -2074,14 +2074,14 @@ The command is: $ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx, baa2.cxx example.i -

    35.7 Generated scripts

    +

    36.7 Generated scripts

    In this part we give some details about the generated Scilab scripts.

    -

    35.7.1 Builder script

    +

    36.7.1 Builder script

    @@ -2106,7 +2106,7 @@ ilib_build(ilib_name, table, files, libs);

  • table: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.
  • -

    35.7.2 Loader script

    +

    36.7.2 Loader script

    @@ -2145,7 +2145,7 @@ clear get_file_path; -

    35.8 Other resources

    +

    36.8 Other resources

    -

    13.4 Code generation rules

    +

    14.4 Code generation rules

    @@ -1878,7 +1878,7 @@ This section describes rules by which typemap code is inserted into the generated wrapper code.

    -

    13.4.1 Scope

    +

    14.4.1 Scope

    @@ -1956,7 +1956,7 @@ a block scope when it is emitted. This sometimes results in a less complicated Note that only the third of the three typemaps have the typemap code passed through the SWIG preprocessor.

    -

    13.4.2 Declaring new local variables

    +

    14.4.2 Declaring new local variables

    @@ -2123,7 +2123,7 @@ each type must have its own local variable declaration. -

    13.4.3 Special variables

    +

    14.4.3 Special variables

    @@ -2375,7 +2375,7 @@ Another approach, which only works for arrays is to use the $1_basetype -

    13.4.4 Special variable macros

    +

    14.4.4 Special variable macros

    @@ -2387,7 +2387,7 @@ it is done during the SWIG parsing/compilation stages. The following special variable macros are available across all language modules.

    -

    13.4.4.1 $descriptor(type)

    +

    14.4.4.1 $descriptor(type)

    @@ -2398,7 +2398,7 @@ For example, $descriptor(std::vector<int> *) will expand into Run-time type checker usage section.

    -

    13.4.4.2 $typemap(method, typepattern)

    +

    14.4.4.2 $typemap(method, typepattern)

    @@ -2456,7 +2456,7 @@ The result is the following expansion -

    13.4.5 Special variables and typemap attributes

    +

    14.4.5 Special variables and typemap attributes

    @@ -2483,7 +2483,7 @@ is equivalent to the following as $*1_ltype expands to unsigned int -

    13.4.6 Special variables combined with special variable macros

    +

    14.4.6 Special variables combined with special variable macros

    @@ -2525,7 +2525,7 @@ which then expands to: -

    13.5 Common typemap methods

    +

    14.5 Common typemap methods

    @@ -2533,7 +2533,7 @@ The family of typemaps recognized by a language module may vary. However, the following typemap methods are nearly universal:

    -

    13.5.1 "in" typemap

    +

    14.5.1 "in" typemap

    @@ -2593,7 +2593,7 @@ Usually numinputs is not specified, whereupon the default value is 1, t is the same as the old "ignore" typemap.

    -

    13.5.2 "typecheck" typemap

    +

    14.5.2 "typecheck" typemap

    @@ -2620,7 +2620,7 @@ If you define new "in" typemaps and your program uses overloaded method "typecheck" typemaps. More details about this follow in the Typemaps and overloading section.

    -

    13.5.3 "out" typemap

    +

    14.5.3 "out" typemap

    @@ -2651,7 +2651,7 @@ $symname - Name of function/method being wrapped The "out" typemap supports an optional attribute flag called "optimal". This is for code optimisation and is detailed in the Optimal code generation when returning by value section.

    -

    13.5.4 "arginit" typemap

    +

    14.5.4 "arginit" typemap

    @@ -2670,7 +2670,7 @@ For example: -

    13.5.5 "default" typemap

    +

    14.5.5 "default" typemap

    @@ -2703,7 +2703,7 @@ See the Default/optional arguments sec for further information on default argument wrapping.

    -

    13.5.6 "check" typemap

    +

    14.5.6 "check" typemap

    @@ -2722,7 +2722,7 @@ converted. For example: -

    13.5.7 "argout" typemap

    +

    14.5.7 "argout" typemap

    @@ -2768,7 +2768,7 @@ return values are often appended to return value of the function. See the typemaps.i library file for examples.

    -

    13.5.8 "freearg" typemap

    +

    14.5.8 "freearg" typemap

    @@ -2801,7 +2801,7 @@ be used in other typemaps whenever a wrapper function needs to abort prematurely.

    -

    13.5.9 "newfree" typemap

    +

    14.5.9 "newfree" typemap

    @@ -2830,7 +2830,7 @@ string *foo(); See Object ownership and %newobject for further details.

    -

    13.5.10 "ret" typemap

    +

    14.5.10 "ret" typemap

    @@ -2869,7 +2869,7 @@ This approach is an alternative to using the "newfree" typemap and %newobjec is no need to list all the functions that require the memory cleanup, it is purely done on types.

    -

    13.5.11 "memberin" typemap

    +

    14.5.11 "memberin" typemap

    @@ -2891,7 +2891,7 @@ It is rarely necessary to write "memberin" typemaps---SWIG already provides a default implementation for arrays, strings, and other objects.

    -

    13.5.12 "varin" typemap

    +

    14.5.12 "varin" typemap

    @@ -2899,7 +2899,7 @@ The "varin" typemap is used to convert objects in the target language to C for t purposes of assigning to a C/C++ global variable. This is implementation specific.

    -

    13.5.13 "varout" typemap

    +

    14.5.13 "varout" typemap

    @@ -2907,7 +2907,7 @@ The "varout" typemap is used to convert a C/C++ object to an object in the targe language when reading a C/C++ global variable. This is implementation specific.

    -

    13.5.14 "throws" typemap

    +

    14.5.14 "throws" typemap

    @@ -2957,7 +2957,7 @@ Note that if your methods do not have an exception specification but they do thr Please also see the Exception handling with %exception section for another way to handle exceptions.

    -

    13.6 Some typemap examples

    +

    14.6 Some typemap examples

    @@ -2965,7 +2965,7 @@ This section contains a few examples. Consult language module documentation for more examples.

    -

    13.6.1 Typemaps for arrays

    +

    14.6.1 Typemaps for arrays

    @@ -3224,7 +3224,7 @@ Now, you will find that member access is quite nice: useless and has since been eliminated. To return structure members, simply use the "out" typemap.

    -

    13.6.2 Implementing constraints with typemaps

    +

    14.6.2 Implementing constraints with typemaps

    @@ -3272,7 +3272,7 @@ a NULL pointer. As a result, SWIG can often prevent a potential segmentation faults or other run-time problems by raising an exception rather than blindly passing values to the underlying C/C++ program.

    -

    13.7 Typemaps for multiple target languages

    +

    14.7 Typemaps for multiple target languages

    @@ -3302,7 +3302,7 @@ The example above also shows a common approach of issuing a warning for an as ye %typemap(ruby, in) int "$1 = NUM2INT($input);".

    -

    13.8 Optimal code generation when returning by value

    +

    14.8 Optimal code generation when returning by value

    @@ -3491,7 +3491,7 @@ example.i:7: Warning 475: optimal attribute usage in the out typemap. However, it doesn't always get it right, for example when $1 is within some commented out code.

    -

    13.9 Multi-argument typemaps

    +

    14.9 Multi-argument typemaps

    @@ -3768,7 +3768,7 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re- the arguments to make them consecutive will need to be written.

    -

    13.10 Typemap warnings

    +

    14.10 Typemap warnings

    @@ -3777,7 +3777,7 @@ See the information in the issuing warnings

    -

    13.11 Typemap fragments

    +

    14.11 Typemap fragments

    @@ -4113,7 +4113,7 @@ fragment usage unless a desire to really get to grips with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.

    -

    13.11.1 Fragment type specialization

    +

    14.11.1 Fragment type specialization

    @@ -4146,7 +4146,7 @@ struct A { -

    13.11.2 Fragments and automatic typemap specialization

    +

    14.11.2 Fragments and automatic typemap specialization

    @@ -4192,7 +4192,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file

    -

    13.12 The run-time type checker

    +

    14.12 The run-time type checker

    @@ -4218,7 +4218,7 @@ language modules.

  • Modules can be unloaded from the type system.
  • -

    13.12.1 Implementation

    +

    14.12.1 Implementation

    @@ -4412,7 +4412,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

    -

    13.12.2 Usage

    +

    14.12.2 Usage

    This section covers how to use these functions from typemaps. To learn how to @@ -4508,7 +4508,7 @@ probably just look at the output of SWIG to get a better sense for how types are managed.

    -

    13.13 Typemaps and overloading

    +

    14.13 Typemaps and overloading

    @@ -4847,7 +4847,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking. -

    13.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    +

    14.13.1 SWIG_TYPECHECK_POINTER precedence level and the typecheck typemap

    @@ -4949,7 +4949,7 @@ Otherwise both can be wrapped by removing the overloading name ambiguity by rena The 'equivalent' attribute is used in the implementation for the shared_ptr smart pointer library.

    -

    13.14 More about %apply and %clear

    +

    14.14 More about %apply and %clear

    @@ -5054,7 +5054,7 @@ will delete the typemaps for all the typemap methods; namely "in", "check" and " -

    13.15 Passing data between typemaps

    +

    14.15 Passing data between typemaps

    @@ -5091,7 +5091,7 @@ sure that the typemaps sharing information have exactly the same types and names

    -

    13.16 C++ "this" pointer

    +

    14.16 C++ "this" pointer

    @@ -5151,7 +5151,7 @@ will also match the typemap. One work around is to create an interface file tha the method, but gives the argument a name other than self.

    -

    13.17 Where to go for more information?

    +

    14.17 Where to go for more information?

    diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index 9f20469d2..620f2e5a0 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -7,7 +7,7 @@ -

    16 Variable Length Arguments

    +

    17 Variable Length Arguments

      @@ -43,7 +43,7 @@ added in SWIG-1.3.12. Most other wrapper generation tools have wisely chosen to avoid this issue.

      -

      16.1 Introduction

      +

      17.1 Introduction

      @@ -140,7 +140,7 @@ List make_list(const char *s, ...) {

    -

    16.2 The Problem

    +

    17.2 The Problem

    @@ -233,7 +233,7 @@ can also support real varargs wrapping (with stack-frame manipulation) if you are willing to get hands dirty. Keep reading.

    -

    16.3 Default varargs support

    +

    17.3 Default varargs support

    @@ -302,7 +302,7 @@ Read on for further solutions.

    -

    16.4 Argument replacement using %varargs

    +

    17.4 Argument replacement using %varargs

    @@ -413,7 +413,7 @@ mixed argument types such as printf(). Providing general purpose wrappers to such functions presents special problems (covered shortly).

    -

    16.5 Varargs and typemaps

    +

    17.5 Varargs and typemaps

    @@ -593,7 +593,7 @@ really want to elevate your guru status and increase your job security, continue to the next section.

    -

    16.6 Varargs wrapping with libffi

    +

    17.6 Varargs wrapping with libffi

    @@ -845,7 +845,7 @@ provide an argument number for the first extra argument. This can be used to in values. Please consult the chapter on each language module for more details.

    -

    16.7 Wrapping of va_list

    +

    17.7 Wrapping of va_list

    @@ -899,7 +899,7 @@ int my_vprintf(const char *fmt, ...) { -

    16.8 C++ Issues

    +

    17.8 C++ Issues

    @@ -968,7 +968,7 @@ design or to provide an alternative interface using a helper function than it is fully general wrapper to a varargs C++ member function.

    -

    16.9 Discussion

    +

    17.9 Discussion

    diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index c63d7de0c..0cf2a1066 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -7,7 +7,7 @@ -

    18 Warning Messages

    +

    19 Warning Messages

    -

    18.5 Symbolic symbols

    +

    19.5 Symbolic symbols

    @@ -311,7 +311,7 @@ or -

    18.6 Commentary

    +

    19.6 Commentary

    @@ -328,7 +328,7 @@ no obvious recovery. There is no mechanism for suppressing error messages.

    -

    18.7 Warnings as errors

    +

    19.7 Warnings as errors

    @@ -337,7 +337,7 @@ option. This will cause SWIG to exit with a non successful exit code if a warning is encountered.

    -

    18.8 Message output format

    +

    19.8 Message output format

    @@ -356,10 +356,10 @@ $ swig -python -Fmicrosoft example.i example.i(4) : Syntax error in input(1). -

    18.9 Warning number reference

    +

    19.9 Warning number reference

    -

    18.9.1 Deprecated features (100-199)

    +

    19.9.1 Deprecated features (100-199)

      @@ -387,7 +387,7 @@ example.i(4) : Syntax error in input(1).
    • 126. The 'nestedworkaround' feature is deprecated.
    -

    18.9.2 Preprocessor (200-299)

    +

    19.9.2 Preprocessor (200-299)

      @@ -399,7 +399,7 @@ example.i(4) : Syntax error in input(1).
    • 206. Unexpected tokens after #directive directive.
    -

    18.9.3 C/C++ Parser (300-399)

    +

    19.9.3 C/C++ Parser (300-399)

      @@ -476,7 +476,7 @@ example.i(4) : Syntax error in input(1).
    • 395. operator delete[] ignored.
    -

    18.9.4 Types and typemaps (400-499)

    +

    19.9.4 Types and typemaps (400-499)

      @@ -507,7 +507,7 @@ example.i(4) : Syntax error in input(1). -

      18.9.5 Code generation (500-559)

      +

      19.9.5 Code generation (500-559)

        @@ -538,7 +538,7 @@ example.i(4) : Syntax error in input(1).
      • 525. Destructor declaration is final, name cannot be a director class.
      -

      18.9.6 Doxygen comments (560-599)

      +

      19.9.6 Doxygen comments (560-599)

        @@ -549,7 +549,7 @@ example.i(4) : Syntax error in input(1).
      • 564: Error parsing Doxygen command command: error text. Command ignored."
      -

      18.9.7 Language module specific (700-899)

      +

      19.9.7 Language module specific (700-899)

        @@ -600,14 +600,14 @@ example.i(4) : Syntax error in input(1).
      • 871. Unrecognized pragma pragma. (Php).
      -

      18.9.8 User defined (900-999)

      +

      19.9.8 User defined (900-999)

      These numbers can be used by your own application.

      -

      18.10 History

      +

      19.10 History

      diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index 2cb2b18a3..994b28851 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -7,6 +7,7 @@ SWIGPlus.html CPlusPlus11.html CPlusPlus14.html CPlusPlus17.html +CPlusPlus20.html Preprocessor.html Library.html Arguments.html From 8f795a422050a76125d82c88e34ec106f48c3e4d Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 9 Jun 2020 17:42:46 -0600 Subject: [PATCH 1907/2031] Fix references to pyopers.swg in the Python docs [skip ci] --- Doc/Manual/Python.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index fd07301d4..c132afc8a 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2568,7 +2568,7 @@ but the line that uses the '+' operator is much faster. (operator==, operator<, etc.) are also converted to Python slot operators. For a complete list of C++ operators that are automatically converted to Python slot operators, refer to the file -python/pyopers.swig in the SWIG library. +python/pyopers.swg in the SWIG library.

      @@ -2674,7 +2674,7 @@ the chosen closure function.

      There is further information on %feature("python:slot") -in the file python/pyopers.swig in the SWIG library. +in the file python/pyopers.swg in the SWIG library.

      From 24945669fd9238f5fea8d48281ec694640ce645f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Jun 2020 17:52:52 -0400 Subject: [PATCH 1908/2031] configure: change $PKGCONFIG to $PKG_CONFIG The PKG_CONFIG variable name aligns with the standard upstream value that the pkg-config project itself uses. --- configure.ac | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 23c59deea..d61ecbf42 100644 --- a/configure.ac +++ b/configure.ac @@ -459,7 +459,7 @@ else alllang_default=yes fi -AC_CHECK_PROGS(PKGCONFIG, [pkg-config]) +AC_CHECK_PROGS([PKG_CONFIG], [pkg-config]) #-------------------------------------------------------------------- # Look for Tcl @@ -1235,8 +1235,8 @@ else AC_MSG_CHECKING(for Scilab header files) if test "$SCILABINCDIR" != ""; then dirs="$SCILABINCDIR" - elif test -n "$PKGCONFIG"; then - dirs=`$PKGCONFIG scilab --cflags-only-I | sed -e 's/-I//g'` + elif test -n "$PKG_CONFIG "; then + dirs=`$PKG_CONFIG scilab --cflags-only-I | sed -e 's/-I//g'` else dirs="" fi @@ -1620,11 +1620,11 @@ else # check for JavaScriptCore/Webkit libraries AC_ARG_WITH(jscorelib,[ --with-jscorelib=path Set location of the JavaScriptCore/Webkit library directory],[JSCORELIB="-L$withval"], [JSCORELIB=]) - if test -z "$JSCORELIB" -a -n "$PKGCONFIG"; then + if test -z "$JSCORELIB" -a -n "$PKG_CONFIG "; then AC_MSG_CHECKING(for JavaScriptCore/Webkit library) - if $PKGCONFIG javascriptcoregtk-1.0; then - JSCORELIB=`$PKGCONFIG --libs javascriptcoregtk-1.0` - JSCOREVERSION=`$PKGCONFIG --modversion javascriptcoregtk-1.0` + if $PKG_CONFIG javascriptcoregtk-1.0; then + JSCORELIB=`$PKG_CONFIG --libs javascriptcoregtk-1.0` + JSCOREVERSION=`$PKG_CONFIG --modversion javascriptcoregtk-1.0` fi if test -z "$JSCORELIB"; then AC_MSG_RESULT(not found) From 8bf2f473f478a2f4b1e09a3d86592c160abb4f0e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jun 2020 23:06:40 +0100 Subject: [PATCH 1909/2031] Revert "Allow cygwin to fail on Appveyor" This reverts commit dbb88876e61e090ffd5278f9a93b4f8b85558b26. --- appveyor.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 004dee321..f87cefd0f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,7 +6,7 @@ environment: global: MAKEJOBS: 2 -matrix: + matrix: - SWIGLANG: csharp VSVER: 12 - SWIGLANG: csharp @@ -20,6 +20,8 @@ matrix: # VSVER: 14 # VER: 36 # PY3: 3 + - SWIGLANG: python + OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw VER: 27 @@ -29,11 +31,6 @@ matrix: VER: 37 PY3: 3 -allow_failures: -# Currently failing due to not detecting header files/include paths - - swiglang: python - osvariant: cygwin - install: - date /T & time /T - ps: >- From d3fa519a9c83f817d565899f915fde323a490195 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Jun 2020 23:08:00 +0100 Subject: [PATCH 1910/2031] Stop running cygwin python test on Appveyor Currently broken, unable to find header files. --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f87cefd0f..487c06623 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,8 +20,8 @@ environment: # VSVER: 14 # VER: 36 # PY3: 3 - - SWIGLANG: python - OSVARIANT: cygwin +# - SWIGLANG: python +# OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw VER: 27 From e9a21197ecb9f2f63290320e9152f71b54af48ea Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 12 Jun 2020 19:08:29 -0400 Subject: [PATCH 1911/2031] configure: use AC_PATH_TOOL for pkg-config AC_CHECK_PROGS will find the tool using exactly the name given: it only searches for "pkg-config". When doing native builds, this is generally fine. However, when cross-compiling, this is not ideal as `pkg-config` is often configured for the build system, not the system we want to cross-compile for. Switch to using the AC_PATH_TOOL tool instead. This will look for "pkg-config" with a $host- prefix first before falling back to the plain "pkg-config". When doing native builds, things should still behave the same, but now things work better out of the box when we cross-compile. For example, `./configure --host=aarch64-linux-gnu` will first look for "aarch64-linux-gnu-pkg-config" before falling back to the plain "pkg-config". --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d61ecbf42..726a3bac2 100644 --- a/configure.ac +++ b/configure.ac @@ -459,7 +459,7 @@ else alllang_default=yes fi -AC_CHECK_PROGS([PKG_CONFIG], [pkg-config]) +AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) #-------------------------------------------------------------------- # Look for Tcl From 148f6b48fc3200ae09428240f4e838c98f0a2084 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Jun 2020 13:56:28 +0100 Subject: [PATCH 1912/2031] Move python cygwin to Appveyor allow_failure list. --- appveyor.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 487c06623..cabc675e4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,8 +20,6 @@ environment: # VSVER: 14 # VER: 36 # PY3: 3 -# - SWIGLANG: python -# OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw VER: 27 @@ -31,6 +29,12 @@ environment: VER: 37 PY3: 3 +matrix: + allow_failures: + # Currently failing due to not detecting header files/include paths + - SWIGLANG: python + OSVARIANT: cygwin + install: - date /T & time /T - ps: >- From 4546aae41da060a9c77c24858168aee1d39219a0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Jun 2020 14:04:50 +0100 Subject: [PATCH 1913/2031] Add missing python cygwin build in appveyor.yml --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index cabc675e4..8624cd697 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -20,6 +20,8 @@ environment: # VSVER: 14 # VER: 36 # PY3: 3 + - SWIGLANG: python + OSVARIANT: cygwin - SWIGLANG: python OSVARIANT: mingw VER: 27 From ce4164b66d11bc7a4e58065d3f7196295caad48a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 14 Jun 2020 23:09:11 +0100 Subject: [PATCH 1914/2031] Add director comparison operator fix to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a82db8b04..01186095f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,3 +7,6 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-06-14: ZackerySpytz + #1642 #1809 Fix virtual comparison operators in director classes - remove incorrect + space in the function name, for example, operator= = is now operator==. From c4c8751892b9f50a45d724e7785e4659aeeb4cf7 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 15 Jun 2020 01:33:59 -0600 Subject: [PATCH 1915/2031] Add tests. --- .../python/python_pybuffer_runme.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py index 8ecdb523b..be73b0bad 100644 --- a/Examples/test-suite/python/python_pybuffer_runme.py +++ b/Examples/test-suite/python/python_pybuffer_runme.py @@ -44,3 +44,27 @@ else: buf3 = bytearray(b"hello") python_pybuffer.title1(buf3) check(buf3 == b"Hello") + + try: + python_pybuffer.func1(1) + raise RuntimeError, "should throw TypeError" + except TypeError, e: + check("(char *buf1, int len)" in str(e)) + + try: + python_pybuffer.func2(1) + raise RuntimeError, "should throw TypeError" + except TypeError, e: + check("(char *buf2)" in str(e)) + + try: + python_pybuffer.func3(1) + raise RuntimeError, "should throw TypeError" + except TypeError, e: + check("(const char *buf3, int len)" in str(e)) + + try: + python_pybuffer.func4(1) + raise RuntimeError, "should throw TypeError" + except TypeError, e: + check("(const char *buf4)" in str(e)) From c2597023149353cf67797fbb55ba75b861eca85f Mon Sep 17 00:00:00 2001 From: Thomas Reitmayr Date: Sun, 14 Jun 2020 14:46:03 +0200 Subject: [PATCH 1916/2031] Perform proper spacing in director method declarations If a director method returns a const pointer, eg. 'int *const', then in its method declaration a space has to be inserted between 'const' and the method name. This fixes swig#1810. --- Examples/test-suite/director_basic.i | 17 +++++++++++++++-- Examples/test-suite/javascript/Makefile.in | 1 + Source/Modules/directors.cxx | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 07d627589..23d910324 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -5,6 +5,7 @@ #endif %warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) MyClass::pmethod; +%warnfilter(SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) ConstPtrClass::getConstPtr; %{ #include @@ -174,7 +175,19 @@ public: } }; - -%} + %} %template(MyClassT_i) MyClassT; + + %feature("director") ConstPtrClass; + + %inline %{ + +class ConstPtrClass { +public: + virtual ~ConstPtrClass() {} + virtual int *const getConstPtr() = 0; +}; + + %} + diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index 8127415f1..4dc02e3bf 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -52,6 +52,7 @@ ifeq (node,$(JSENGINE)) apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" + director_basic.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\" setup_node = \ test -d $* || mkdir $* && \ diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index a91d5fd9a..056842cb6 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -160,7 +160,7 @@ String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_Strin SwigType *rettype_stripped = SwigType_strip_qualifiers(rettype); String *rtype = SwigType_str(rettype, 0); Append(result, rtype); - if (SwigType_issimple(rettype_stripped) && return_base_type) + if ((SwigType_issimple(rettype_stripped) && return_base_type) || SwigType_isqualifier(rettype)) Append(result, " "); Delete(rtype); Delete(rettype_stripped); From d967e4c8b8c9b243c472c359fb70bba2136a7d84 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Jun 2020 19:18:58 +0100 Subject: [PATCH 1917/2031] Use conventional 'v' prefix for release tagging See semantic versioning: https://semver.org/spec/v2.0.0.html Closes #1825 --- Tools/mkdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 47cf8e765..7116144a0 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -73,9 +73,9 @@ if not skip_checks: sys.exit(3) print("Tagging release") -tag = "'rel-" + version + "'" +tag = "'v" + version + "'" force = "-f " if force_tag else "" -os.system("git tag -a -m " + tag + " " + force + tag) == 0 or failed() +os.system("git tag -a -m 'Release version " + version + "' " + force + tag) == 0 or failed() outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/" print("Grabbing tagged release git repository using 'git archive' into " + outdir) From 13260f95b0d35def50f2f4dc9bfe5b04f670fbdd Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Thu, 2 Apr 2020 15:08:08 -0400 Subject: [PATCH 1918/2031] Properly handle C99 complex types even in C++ mode Use the `_Complex` keyword rather than the `complex` macro. Fixes #1487. --- Lib/javascript/jsc/ccomplex.i | 8 ++++---- Lib/javascript/v8/ccomplex.i | 8 ++++---- Lib/python/ccomplex.i | 8 ++++---- Source/CParse/cscanner.c | 4 ++++ Source/CParse/parser.y | 12 ++++++------ Source/Swig/typesys.c | 4 ++-- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Lib/javascript/jsc/ccomplex.i b/Lib/javascript/jsc/ccomplex.i index 50f0f95fe..64fe00ec9 100644 --- a/Lib/javascript/jsc/ccomplex.i +++ b/Lib/javascript/jsc/ccomplex.i @@ -16,11 +16,11 @@ /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) -%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); +%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ -%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i index 8eda920bb..b1e766354 100644 --- a/Lib/javascript/v8/ccomplex.i +++ b/Lib/javascript/v8/ccomplex.i @@ -16,11 +16,11 @@ /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) -%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); +%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ -%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index 28872b985..17163506b 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -16,11 +16,11 @@ /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) -%swig_cplxflt_convn(float complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(double complex, CCplxConst, creal, cimag); +%swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ -%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 19a013803..6de66845c 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -912,6 +912,10 @@ int yylex(void) { yylval.type = NewSwigType(T_COMPLEX); return (TYPE_COMPLEX); } + if (strcmp(yytext, "_Complex") == 0) { + yylval.type = NewSwigType(T_COMPLEX); + return (TYPE_COMPLEX); + } if (strcmp(yytext, "restrict") == 0) return (yylex()); } diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 8029dee3d..682e317d4 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6232,19 +6232,19 @@ primitive_type_list : type_specifier { } else if (Cmp($1.type,"double") == 0) { if (Cmp($2.type,"long") == 0) { $$.type = NewString("long double"); - } else if (Cmp($2.type,"complex") == 0) { - $$.type = NewString("double complex"); + } else if (Cmp($2.type,"complex") == 0 || Cmp($2.type,"_Complex") == 0) { + $$.type = NewString("double _Complex"); } else { err = 1; } } else if (Cmp($1.type,"float") == 0) { - if (Cmp($2.type,"complex") == 0) { - $$.type = NewString("float complex"); + if (Cmp($2.type,"complex") == 0 || Cmp($2.type,"_Complex") == 0) { + $$.type = NewString("float _Complex"); } else { err = 1; } - } else if (Cmp($1.type,"complex") == 0) { - $$.type = NewStringf("%s complex", $2.type); + } else if (Cmp($1.type,"complex") == 0 || Cmp($1.type,"_Complex") == 0) { + $$.type = NewStringf("%s _Complex", $2.type); } else { err = 1; } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 7564db1a6..e48b80ce2 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1453,9 +1453,9 @@ int SwigType_type(const SwigType *t) { return T_DOUBLE; if (strcmp(c, "long double") == 0) return T_LONGDOUBLE; - if (!cparse_cplusplus && (strcmp(c, "float complex") == 0)) + if (!cparse_cplusplus && (strcmp(c, "float _Complex") == 0)) return T_FLTCPLX; - if (!cparse_cplusplus && (strcmp(c, "double complex") == 0)) + if (!cparse_cplusplus && (strcmp(c, "double _Complex") == 0)) return T_DBLCPLX; if (!cparse_cplusplus && (strcmp(c, "complex") == 0)) return T_COMPLEX; From 1adc7dac5db7455264d590340573c3aff253c624 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Tue, 16 Jun 2020 19:55:50 -0400 Subject: [PATCH 1919/2031] Small corrections for handling C99 _Complex --- Examples/test-suite/complextest.i | 6 +++--- Lib/javascript/jsc/ccomplex.i | 2 -- Lib/javascript/v8/ccomplex.i | 2 -- Lib/python/ccomplex.i | 2 -- Source/CParse/cscanner.c | 4 ---- Source/CParse/parser.y | 6 +++--- Source/Swig/typesys.c | 2 -- 7 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i index 592512b45..57d00a946 100644 --- a/Examples/test-suite/complextest.i +++ b/Examples/test-suite/complextest.i @@ -72,15 +72,15 @@ %inline { - complex Conj(complex a) + double complex Conj(complex a) { return conj(a); } - complex float Conjf(float complex a) + float complex Conjf(float complex a) { - return conj(a); + return conjf(a); } } diff --git a/Lib/javascript/jsc/ccomplex.i b/Lib/javascript/jsc/ccomplex.i index 64fe00ec9..9c3080b60 100644 --- a/Lib/javascript/jsc/ccomplex.i +++ b/Lib/javascript/jsc/ccomplex.i @@ -18,9 +18,7 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i index b1e766354..7669cb86a 100644 --- a/Lib/javascript/v8/ccomplex.i +++ b/Lib/javascript/v8/ccomplex.i @@ -18,9 +18,7 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index 17163506b..eba278905 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -18,9 +18,7 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); -%swig_cplxdbl_convn(complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); -%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, complex); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 6de66845c..a3702704e 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -908,10 +908,6 @@ int yylex(void) { if (strcmp(yytext, "class") == 0) { Swig_warning(WARN_PARSE_CLASS_KEYWORD, cparse_file, cparse_line, "class keyword used, but not in C++ mode.\n"); } - if (strcmp(yytext, "complex") == 0) { - yylval.type = NewSwigType(T_COMPLEX); - return (TYPE_COMPLEX); - } if (strcmp(yytext, "_Complex") == 0) { yylval.type = NewSwigType(T_COMPLEX); return (TYPE_COMPLEX); diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 682e317d4..cccd613fe 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6232,18 +6232,18 @@ primitive_type_list : type_specifier { } else if (Cmp($1.type,"double") == 0) { if (Cmp($2.type,"long") == 0) { $$.type = NewString("long double"); - } else if (Cmp($2.type,"complex") == 0 || Cmp($2.type,"_Complex") == 0) { + } else if (Cmp($2.type,"_Complex") == 0) { $$.type = NewString("double _Complex"); } else { err = 1; } } else if (Cmp($1.type,"float") == 0) { - if (Cmp($2.type,"complex") == 0 || Cmp($2.type,"_Complex") == 0) { + if (Cmp($2.type,"_Complex") == 0) { $$.type = NewString("float _Complex"); } else { err = 1; } - } else if (Cmp($1.type,"complex") == 0 || Cmp($1.type,"_Complex") == 0) { + } else if (Cmp($1.type,"_Complex") == 0) { $$.type = NewStringf("%s _Complex", $2.type); } else { err = 1; diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index e48b80ce2..b306c95e8 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1457,8 +1457,6 @@ int SwigType_type(const SwigType *t) { return T_FLTCPLX; if (!cparse_cplusplus && (strcmp(c, "double _Complex") == 0)) return T_DBLCPLX; - if (!cparse_cplusplus && (strcmp(c, "complex") == 0)) - return T_COMPLEX; if (strcmp(c, "void") == 0) return T_VOID; if (strcmp(c, "bool") == 0) From 07b4b274e5048c23be73a9a85b53461d369dc2a2 Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Wed, 17 Jun 2020 10:14:07 -0400 Subject: [PATCH 1920/2031] Restore _Complex as standalone type --- Lib/javascript/jsc/ccomplex.i | 2 ++ Lib/javascript/v8/ccomplex.i | 2 ++ Lib/python/ccomplex.i | 2 ++ Source/Swig/typesys.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/Lib/javascript/jsc/ccomplex.i b/Lib/javascript/jsc/ccomplex.i index 9c3080b60..00680d3b4 100644 --- a/Lib/javascript/jsc/ccomplex.i +++ b/Lib/javascript/jsc/ccomplex.i @@ -18,7 +18,9 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex); diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i index 7669cb86a..a753ae180 100644 --- a/Lib/javascript/v8/ccomplex.i +++ b/Lib/javascript/v8/ccomplex.i @@ -18,7 +18,9 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex); diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index eba278905..1652816ca 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -18,7 +18,9 @@ %swig_cplxflt_convn(float _Complex, CCplxConst, creal, cimag); %swig_cplxdbl_convn(double _Complex, CCplxConst, creal, cimag); +%swig_cplxdbl_convn(_Complex, CCplxConst, creal, cimag); /* declaring the typemaps */ %typemaps_primitive(SWIG_TYPECHECK_CPLXFLT, float _Complex); %typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, double _Complex); +%typemaps_primitive(SWIG_TYPECHECK_CPLXDBL, _Complex); diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index b306c95e8..d6d6bcc88 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1457,6 +1457,8 @@ int SwigType_type(const SwigType *t) { return T_FLTCPLX; if (!cparse_cplusplus && (strcmp(c, "double _Complex") == 0)) return T_DBLCPLX; + if (!cparse_cplusplus && (strcmp(c, "_Complex") == 0)) + return T_COMPLEX; if (strcmp(c, "void") == 0) return T_VOID; if (strcmp(c, "bool") == 0) From 511df0e6428ae86696ac44e381ba0c736a3742fc Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Wed, 17 Jun 2020 13:03:17 -0400 Subject: [PATCH 1921/2031] More C99 complex fixes, plus Python tests --- Examples/test-suite/complextest.i | 53 ++++++++++++++++++- Examples/test-suite/python/Makefile.in | 1 + .../test-suite/python/complextest_runme.py | 37 +++++++++---- Lib/javascript/jsc/ccomplex.i | 1 + Lib/javascript/v8/ccomplex.i | 1 + Lib/python/ccomplex.i | 1 + Source/CParse/parser.y | 2 +- 7 files changed, 83 insertions(+), 13 deletions(-) diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i index 57d00a946..4d40bc524 100644 --- a/Examples/test-suite/complextest.i +++ b/Examples/test-suite/complextest.i @@ -68,20 +68,69 @@ %{ +#include %} %inline { - double complex Conj(complex a) + complex double Conj(complex double a) { return conj(a); } - float complex Conjf(float complex a) + complex float Conjf(complex float a) { return conjf(a); } + + + double complex Conj1(double complex a) + { + return conj(a); + } + + + float complex Conjf1(float complex a) + { + return conjf(a); + } + + + _Complex double Conj2(_Complex double a) + { + return conj(a); + } + + + _Complex float Conjf2(_Complex float a) + { + return conjf(a); + } + + + double _Complex Conj3(double _Complex a) + { + return conj(a); + } + + + float _Complex Conjf3(float _Complex a) + { + return conjf(a); + } + + + complex Conj4(complex a) + { + return conj(a); + } + + + _Complex Conj5(_Complex a) + { + return conj(a); + } } diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4c0507cbb..86d5e37f2 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -92,6 +92,7 @@ CPP11_TEST_CASES = \ cpp11_std_unordered_set \ C_TEST_CASES += \ + complextest \ file_test \ li_cstring \ li_cwstring \ diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py index 5cfc7ccab..2b3d6fda9 100644 --- a/Examples/test-suite/python/complextest_runme.py +++ b/Examples/test-suite/python/complextest_runme.py @@ -14,17 +14,34 @@ if complextest.Conj2(a) != a.conjugate(): if complextest.Conjf2(a) != a.conjugate(): raise RuntimeError, "bad complex mapping" +if 'Conj3' in dir(complextest): + if complextest.Conj3(a) != a.conjugate(): + raise RuntimeError, "bad complex mapping" -v = (complex(1, 2), complex(2, 3), complex(4, 3), 1) +if 'Conjf3' in dir(complextest): + if complextest.Conjf3(a) != a.conjugate(): + raise RuntimeError, "bad complex mapping" -if len(complextest.CopyHalf(v)) != 2: - raise RuntimeError("CopyHalf failed") +if 'Conj4' in dir(complextest): + if complextest.Conj4(a) != a.conjugate(): + raise RuntimeError, "bad complex mapping" -if len(complextest.CopyHalfRef(v)) != 2: - raise RuntimeError("CopyHalfRef failed") +if 'Conj5' in dir(complextest): + if complextest.Conj5(a) != a.conjugate(): + raise RuntimeError, "bad complex mapping" -p = complextest.ComplexPair() -p.z1 = complex(0, 1) -p.z2 = complex(0, -1) -if complextest.Conj(p.z2) != p.z1: - raise RuntimeError, "bad complex mapping" +if 'CopyHalf' in dir(complextest): + + v = (complex(1, 2), complex(2, 3), complex(4, 3), 1) + + if len(complextest.CopyHalf(v)) != 2: + raise RuntimeError("CopyHalf failed") + + if len(complextest.CopyHalfRef(v)) != 2: + raise RuntimeError("CopyHalfRef failed") + + p = complextest.ComplexPair() + p.z1 = complex(0, 1) + p.z2 = complex(0, -1) + if complextest.Conj(p.z2) != p.z1: + raise RuntimeError, "bad complex mapping" diff --git a/Lib/javascript/jsc/ccomplex.i b/Lib/javascript/jsc/ccomplex.i index 00680d3b4..e58dbf719 100644 --- a/Lib/javascript/jsc/ccomplex.i +++ b/Lib/javascript/jsc/ccomplex.i @@ -12,6 +12,7 @@ #include %} +#define complex _Complex /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i index a753ae180..b4b925da7 100644 --- a/Lib/javascript/v8/ccomplex.i +++ b/Lib/javascript/v8/ccomplex.i @@ -12,6 +12,7 @@ #include %} +#define complex _Complex /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index 1652816ca..b99f96a48 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -12,6 +12,7 @@ #include %} +#define complex _Complex /* C complex constructor */ #define CCplxConst(r, i) ((r) + I*(i)) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index cccd613fe..c48d3a6f2 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -6294,7 +6294,7 @@ type_specifier : TYPE_INT { $$.type = 0; } | TYPE_COMPLEX { - $$.type = NewString("complex"); + $$.type = NewString("_Complex"); $$.us = 0; } | TYPE_NON_ISO_INT8 { From 8245277ad3acd9308ce28c40508b999e9496b27e Mon Sep 17 00:00:00 2001 From: Leo Singer Date: Sun, 21 Jun 2020 12:29:42 -0400 Subject: [PATCH 1922/2031] Remove test for unsupported complex or _Complex by itself --- Examples/test-suite/complextest.i | 12 ------------ Examples/test-suite/python/complextest_runme.py | 8 -------- 2 files changed, 20 deletions(-) diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i index 4d40bc524..622b38058 100644 --- a/Examples/test-suite/complextest.i +++ b/Examples/test-suite/complextest.i @@ -119,18 +119,6 @@ { return conjf(a); } - - - complex Conj4(complex a) - { - return conj(a); - } - - - _Complex Conj5(_Complex a) - { - return conj(a); - } } diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py index 2b3d6fda9..53b2b8d6b 100644 --- a/Examples/test-suite/python/complextest_runme.py +++ b/Examples/test-suite/python/complextest_runme.py @@ -22,14 +22,6 @@ if 'Conjf3' in dir(complextest): if complextest.Conjf3(a) != a.conjugate(): raise RuntimeError, "bad complex mapping" -if 'Conj4' in dir(complextest): - if complextest.Conj4(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" - -if 'Conj5' in dir(complextest): - if complextest.Conj5(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" - if 'CopyHalf' in dir(complextest): v = (complex(1, 2), complex(2, 3), complex(4, 3), 1) From 917110212e0820220ec28f651572fa9020372772 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Fri, 17 Jul 2020 12:15:54 +0200 Subject: [PATCH 1923/2031] PyTypeObject::ob_base isn't available in PyPy --- Lib/python/builtin.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 5308748b7..3360b1320 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -414,7 +414,7 @@ SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { SWIGINTERN void SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) { -#if PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION) type->ob_base.ob_base.ob_type = metatype; #else type->ob_type = metatype; From eafe1e2daa9b712b29379fcd195c2ef22435b8e0 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Tue, 28 Jul 2020 08:11:02 +0200 Subject: [PATCH 1924/2031] Use Py_TYPE in SwigPyBuiltin_SetMetaType --- Lib/python/builtin.swg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 3360b1320..4f31a8d54 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -414,11 +414,7 @@ SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) { SWIGINTERN void SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype) { -#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION) - type->ob_base.ob_base.ob_type = metatype; -#else - type->ob_type = metatype; -#endif + Py_TYPE(type) = metatype; } From 4d844a8dc2ac7f1a256af6ceedc51040892babd3 Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Wed, 5 Aug 2020 10:28:09 -0700 Subject: [PATCH 1925/2031] javascript: replace exceptions with SWIG_exit When building SWIG for Android, there is no support for C++ exceptions. In the cases there is "Illegal state", it seems more like an internal error, so we can replace the throw calls with a debug print and exit immediately. Closes #1858 --- Source/Modules/javascript.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index d2b33b1b4..31576bd93 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -1575,7 +1575,8 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma Printf(arg, "argv[%d]", i); break; default: - throw "Illegal state."; + Printf(stdout, "Illegal state."); + SWIG_exit(EXIT_FAILURE); } tm = emitInputTypemap(n, p, wrapper, arg); Delete(arg); @@ -2212,7 +2213,8 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar Printf(arg, "args[%d]", i); break; default: - throw "Illegal state."; + Printf(stdout, "Illegal state."); + SWIG_exit(EXIT_FAILURE); } tm = emitInputTypemap(n, p, wrapper, arg); From a38f30a19475603f0b97ad4d1db9a1e1e2c02b54 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 13:41:09 +0100 Subject: [PATCH 1926/2031] Add basic std::pair Python testing Based on Ruby's li_std_pair_runme.rb --- .../test-suite/python/li_std_pair_runme.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Examples/test-suite/python/li_std_pair_runme.py 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..4150e5cc8 --- /dev/null +++ b/Examples/test-suite/python/li_std_pair_runme.py @@ -0,0 +1,47 @@ +from li_std_pair import * + +def check(flag): + if not flag: + raise RuntimeError("Check failed") + +intPair = makeIntPair(7, 6) +check(isinstance(intPair, tuple)) +check(len(intPair) == 2) +check(intPair[0] == 7) +check(intPair[1] == 6) + +intPairConstRef = makeIntPairConstRef(7, 6) +check(isinstance(intPairConstRef, tuple)) +check(intPairConstRef[0] == 7) +check(intPairConstRef[1] == 6) + +# +# Each of these should return a reference to a wrapped +# std::pair object (i.e. an IntPair instance). +# +intPairPtr = makeIntPairPtr(7, 6) +check(isinstance(intPairPtr, IntPair)) +check(intPairPtr[0] == 7) +check(intPairPtr[1] == 6) + +intPairRef = makeIntPairRef(7, 6) +check(isinstance(intPairRef, IntPair)) +check(intPairRef[0] == 7) +check(intPairRef[1] == 6) +# +# Now test various input typemaps. Each of the wrapped C++ functions +# (product1, product2 and product3) is expecting an argument of a +# different type (see li_std_pair.i). Typemaps should be in place to +# convert this tuple into the expected argument type. +# +check(product1(intPair) == 42) +check(product2(intPair) == 42) +# check(product3(intPair) == 42) # TODO, if desirable to match Ruby wrappers behaviour. Requires equivalent to typemap(in) std::pair* in Lib/ruby/std_pair.i and further fixes to stop recursive calls to swig::asptr which this testcase shows. Plus further changes for any type of sequence type (including other STL containers) to be accepted by all methods taking an STL container to match Ruby behaviour. + +# +# Similarly, each of the input typemaps should know what to do +# with an IntPair instance. +# +check(product1(intPairPtr) == 42) +check(product2(intPairPtr) == 42) +check(product3(intPairPtr) == 42) From bfddc50a6a38193acabaf8d895c5e472718a9a4d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 16:04:10 +0100 Subject: [PATCH 1927/2031] Add C# support for void *VOID_INT_PTR member variables Issue reported by Carlos Frederico Biscaya on swig-user mailing list. --- Examples/test-suite/csharp/director_void_runme.cs | 6 ++++++ Examples/test-suite/director_void.i | 4 ++++ Lib/csharp/csharp.swg | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/Examples/test-suite/csharp/director_void_runme.cs b/Examples/test-suite/csharp/director_void_runme.cs index 24b470f11..ef440a76a 100644 --- a/Examples/test-suite/csharp/director_void_runme.cs +++ b/Examples/test-suite/csharp/director_void_runme.cs @@ -67,6 +67,12 @@ public class runme if (x != 1334) throw new Exception("Bad4 should be 1334, got " + x); } + { + MemberVoid mv = new MemberVoid(); + global::System.IntPtr zero = global::System.IntPtr.Zero; + mv.memberVariable = zero; + zero = mv.memberVariable; + } } } diff --git a/Examples/test-suite/director_void.i b/Examples/test-suite/director_void.i index 40f53b6e2..d9d99aaac 100644 --- a/Examples/test-suite/director_void.i +++ b/Examples/test-suite/director_void.i @@ -43,5 +43,9 @@ struct Caller { return *(int *)p; } }; + +struct MemberVoid { + void *memberVariable; +}; %} diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 832206386..ecc1983a7 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -875,6 +875,15 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { global::System.IntPtr ret = $imcall;$excode return ret; } +%typemap(csvarin, excode=SWIGEXCODE2) void *VOID_INT_PTR %{ + set { + $imcall;$excode + } %} +%typemap(csvarout, excode=SWIGEXCODE2) void *VOID_INT_PTR %{ + get { + global::System.IntPtr ret = $imcall;$excode + return ret; + } %} %typemap(csdirectorin) void *VOID_INT_PTR "$iminput" %typemap(csdirectorout) void *VOID_INT_PTR "$cscall" From 143837ddf162ef9e07e0a5e89a656df3d83ed7ed Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 16:26:50 +0100 Subject: [PATCH 1928/2031] Update changes file --- CHANGES.current | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 01186095f..a2c288c87 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-08-13: wsfulton + [C#] Add support for void *VOID_INT_PTR for member variables. + +2020-07-29: chrisburr + #1843 [Python] Compilation error fix in SwigPyBuiltin_SetMetaType when using PyPy. + 2020-06-14: ZackerySpytz #1642 #1809 Fix virtual comparison operators in director classes - remove incorrect space in the function name, for example, operator= = is now operator==. From baf2fbb98fbc7fa9da895f687d855dbeda7a422b Mon Sep 17 00:00:00 2001 From: Alistair Delva Date: Wed, 5 Aug 2020 10:32:17 -0700 Subject: [PATCH 1929/2031] naming: Add unreachable return to !HAVE_PCRE path Android builds all host tools with -Werror=no-return, which generates a false positive in name_regexmatch_value() if HAVE_PCRE is not present. Fix this by adding a return code to the !HAVE_PCRE path. This return will not be reached but will suppress the compiler warning. If/when SWIG can require C++11 compilers, a better fix would be to make SWIG_exit() [[noreturn]]. Closes #1860 --- Source/Swig/naming.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 6689ceb7a..1d78e7a47 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1132,6 +1132,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) { Swig_error("SWIG", Getline(n), "PCRE regex matching is not available in this SWIG build.\n"); SWIG_exit(EXIT_FAILURE); + return 0; } #endif /* HAVE_PCRE/!HAVE_PCRE */ From f3830958517cfad8709fb531a441dfa9fee87d6b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Jun 2020 11:13:16 +0100 Subject: [PATCH 1930/2031] Alphabetise testing of examples --- Examples/guile/check.list | 8 ++++---- Examples/octave/check.list | 2 +- Examples/python/check.list | 4 ++-- Examples/scilab/check.list | 1 - 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Examples/guile/check.list b/Examples/guile/check.list index 726e6ab75..1f22adf78 100644 --- a/Examples/guile/check.list +++ b/Examples/guile/check.list @@ -1,9 +1,9 @@ # see top-level Makefile.in -constants class -port -simple -std_vector +constants matrix multimap multivalue +port +simple +std_vector diff --git a/Examples/octave/check.list b/Examples/octave/check.list index e9c719231..54a591042 100644 --- a/Examples/octave/check.list +++ b/Examples/octave/check.list @@ -8,8 +8,8 @@ extend funcptr funcptr2 functor -operator module_load +operator pointer reference simple diff --git a/Examples/python/check.list b/Examples/python/check.list index 0798b5f7e..025278f89 100644 --- a/Examples/python/check.list +++ b/Examples/python/check.list @@ -13,8 +13,8 @@ funcptr funcptr2 functor import -import_template import_packages +import_template #libffi multimap operator @@ -22,8 +22,8 @@ pointer reference simple smartptr -std_vector std_map +std_vector template varargs variables diff --git a/Examples/scilab/check.list b/Examples/scilab/check.list index 0bcf457c2..d57cfab64 100644 --- a/Examples/scilab/check.list +++ b/Examples/scilab/check.list @@ -13,4 +13,3 @@ std_vector struct template variables - From e535190c34636113de375fcaf7b897ec1738c00f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 6 Jul 2020 10:57:35 +0100 Subject: [PATCH 1931/2031] Update Visual C++ instructions in Windows.html --- Doc/Manual/Windows.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 800e2e420..f6f0d16df 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -77,10 +77,10 @@ If you want to build your own swig.exe have a look at examples using Cygwin. @@ -95,9 +95,11 @@ More information on each of the examples is available with the examples distribu Ensure the SWIG executable is as supplied in the SWIG root directory in order for the examples to work. Most languages require some environment variables to be set before running Visual C++. Note that Visual C++ must be re-started to pick up any changes in environment variables. -Open up an example .dsp file, Visual C++ will create a workspace for you (.dsw file). -Ensure the Release build is selected then do a Rebuild All from the Build menu. -The required environment variables are displayed with their current values. +Open up an example .dsp file, Visual C++ will prompt you to upgrade the project and convert +it into an MSBuild project (.vcxproj file) and Solution (.sln file). +Note that older versions of Visual C++ will simply create a workspace for you (.dsw file). +Ensure the Release build is selected then do a Rebuild Solution from the Build menu. +The required environment variables are displayed with their current values during the build.

      The list of required environment variables for each module language is also listed below. @@ -111,7 +113,7 @@ If you are interested in how the project files are set up there is explanatory i

      The C# examples do not require any environment variables to be set as a C# project file is included. -Just open up the .sln solution file in Visual Studio .NET 2003 or later, select Release Build, and do a Rebuild All from the Build menu. +Just open up the .sln solution file in Visual Studio 2005 or later, select Release Build, and do a Rebuild Solution from the Build menu. The accompanying C# and C++ project files are automatically used by the solution file.

      From 365d4961d485df0fde081e6f05e75ab23b124ea9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 21:22:47 +0100 Subject: [PATCH 1932/2031] Remove print statements from Python tests Use exceptions instead of printing to stdout. Part of an effort to convert Python tests to python 3 syntax. --- .../test-suite/python/argcargvtest_runme.py | 1 - .../test-suite/python/char_binary_runme.py | 9 ++--- Examples/test-suite/python/constover_runme.py | 19 +++------ Examples/test-suite/python/cpp_enum_runme.py | 12 ++---- .../test-suite/python/default_args_runme.py | 34 +++++----------- .../python/director_exception_runme.py | 38 +++++------------- .../python/director_profile_runme.py | 2 +- .../python/director_string_runme.py | 6 +-- .../python/director_thread_runme.py | 3 +- .../python/director_unroll_runme.py | 3 +- .../python/director_wstring_runme.py | 6 +-- .../test-suite/python/dynamic_cast_runme.py | 2 +- .../python/exception_order_runme.py | 3 +- Examples/test-suite/python/inctest_runme.py | 18 ++------- .../python/inherit_missing_runme.py | 6 +-- .../test-suite/python/inplaceadd_runme.py | 3 +- .../test-suite/python/li_attribute_runme.py | 6 +-- .../python/li_attribute_template_runme.py | 3 +- .../test-suite/python/li_cstring_runme.py | 6 +-- .../test-suite/python/li_std_map_runme.py | 3 +- .../test-suite/python/li_std_stream_runme.py | 3 +- .../python/li_std_string_extra_runme.py | 9 ++--- .../test-suite/python/li_std_wstream_runme.py | 3 +- .../python/li_std_wstring_inherit_runme.py | 3 +- .../python/primitive_types_runme.py | 24 ++++-------- .../python/python_nondynamic_runme.py | 8 +--- .../test-suite/python/python_pickle_runme.py | 8 ++-- .../python/python_pybuffer_runme.py | 4 +- .../python/return_const_value_runme.py | 6 +-- .../python/smart_pointer_member_runme.py | 4 +- .../test-suite/python/std_containers_runme.py | 3 +- .../test-suite/python/swigobject_runme.py | 3 +- .../python/template_typedef_cplx2_runme.py | 39 +++++++------------ .../python/template_typedef_cplx_runme.py | 36 ++++++----------- .../python/template_typedef_runme.py | 9 ++--- .../template_typemaps_typedef2_runme.py | 2 +- .../python/template_typemaps_typedef_runme.py | 2 +- .../python/typedef_inherit_runme.py | 8 ++-- .../test-suite/python/typedef_scope_runme.py | 4 +- Examples/test-suite/python/unions_runme.py | 16 +++----- 40 files changed, 123 insertions(+), 254 deletions(-) diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py index b0345746f..eb57f79ea 100644 --- a/Examples/test-suite/python/argcargvtest_runme.py +++ b/Examples/test-suite/python/argcargvtest_runme.py @@ -6,7 +6,6 @@ if mainc(largs) != 3: targs = ("hi", "hola") if mainv(targs, 1) != "hola": - print(mainv(targs, 1)) raise RuntimeError("bad main typemap") targs = ("hi", "hola") diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py index 0425fe1c9..83ae9f0ec 100644 --- a/Examples/test-suite/python/char_binary_runme.py +++ b/Examples/test-suite/python/char_binary_runme.py @@ -2,11 +2,9 @@ from char_binary import * t = Test() if t.strlen("hile") != 4: - print t.strlen("hile") - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap {}".format(t.strlen("hile"))) if t.ustrlen("hile") != 4: - print t.ustrlen("hile") - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap {}".format(t.ustrlen("hile"))) if t.strlen("hil\0") != 4: raise RuntimeError, "bad multi-arg typemap" @@ -31,8 +29,7 @@ if t.ustrlen(pc) != 4: cvar.var_pchar = pc if cvar.var_pchar != "hola": - print cvar.var_pchar - raise RuntimeError, "bad pointer case" + raise RuntimeError("bad pointer case {}".format(cvar.var_pchar)) cvar.var_namet = pc # if cvar.var_namet != "hola\0": diff --git a/Examples/test-suite/python/constover_runme.py b/Examples/test-suite/python/constover_runme.py index 2d28a55cc..0c03967f6 100644 --- a/Examples/test-suite/python/constover_runme.py +++ b/Examples/test-suite/python/constover_runme.py @@ -4,33 +4,26 @@ error = 0 p = constover.test("test") if p != "test": - print "test failed!" - error = 1 + raise RuntimeError("test failed!") p = constover.test_pconst("test") if p != "test_pconst": - print "test_pconst failed!" - error = 1 + raise RuntimeError("test_pconst failed!") f = constover.Foo() p = f.test("test") if p != "test": - print "member-test failed!" - error = 1 + raise RuntimeError("member-test failed!") p = f.test_pconst("test") if p != "test_pconst": - print "member-test_pconst failed!" - error = 1 + raise RuntimeError("member-test_pconst failed!") p = f.test_constm("test") if p != "test_constmethod": - print "member-test_constm failed!" - error = 1 + raise RuntimeError("member-test_constm failed!") p = f.test_pconstm("test") if p != "test_pconstmethod": - print "member-test_pconstm failed!" - error = 1 + raise RuntimeError("member-test_pconstm failed!") -sys.exit(error) diff --git a/Examples/test-suite/python/cpp_enum_runme.py b/Examples/test-suite/python/cpp_enum_runme.py index 5f1e91c97..910d378e4 100644 --- a/Examples/test-suite/python/cpp_enum_runme.py +++ b/Examples/test-suite/python/cpp_enum_runme.py @@ -3,21 +3,17 @@ import cpp_enum f = cpp_enum.Foo() if f.hola != f.Hello: - print f.hola - raise RuntimeError + raise RuntimeError("f.hola: {}".format(f.hola)) f.hola = f.Hi if f.hola != f.Hi: - print f.hola - raise RuntimeError + raise RuntimeError("f.hola: {}".format(f.hola)) f.hola = f.Hello if f.hola != f.Hello: - print f.hola - raise RuntimeError + raise RuntimeError("f.hola: {}".format(f.hola)) cpp_enum.cvar.hi = cpp_enum.Hello if cpp_enum.cvar.hi != cpp_enum.Hello: - print cpp_enum.cvar.hi - raise RuntimeError + raise RuntimeError("cpp_enum.cvar.hi: {}".format(cpp_enum.cvar.hi)) diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py index 14ef8c594..0ce47ab79 100644 --- a/Examples/test-suite/python/default_args_runme.py +++ b/Examples/test-suite/python/default_args_runme.py @@ -108,48 +108,34 @@ def run(module_name): if Klass_inc().val != 0: raise RuntimeError("Klass::inc failed") - tricky_failure = False tricky = default_args.TrickyInPython() if tricky.value_m1(10) != -1: - print "trickyvalue_m1 failed" - tricky_failure = True + raise RuntimeError("trickyvalue_m1 failed") if tricky.value_m1(10, 10) != 10: - print "trickyvalue_m1 failed" - tricky_failure = True + raise RuntimeError("trickyvalue_m1 failed") if tricky.value_0xabcdef(10) != 0xabcdef: - print "trickyvalue_0xabcdef failed" - tricky_failure = True + raise RuntimeError("trickyvalue_0xabcdef failed") if tricky.value_0644(10) != 420: - print "trickyvalue_0644 failed" - tricky_failure = True + raise RuntimeError("trickyvalue_0644 failed") if tricky.value_perm(10) != 420: - print "trickyvalue_perm failed" - tricky_failure = True + raise RuntimeError("trickyvalue_perm failed") if tricky.value_m01(10) != -1: - print "trickyvalue_m01 failed" - tricky_failure = True + raise RuntimeError("trickyvalue_m01 failed") if not tricky.booltest2(): - print "booltest2 failed" - tricky_failure = True + raise RuntimeError("booltest2 failed") if tricky.max_32bit_int1() != 0x7FFFFFFF: - print "max_32bit_int1 failed" - tricky_failure = True + raise RuntimeError("max_32bit_int1 failed") if tricky.min_32bit_int1() != -2147483648: - print "min_32bit_int1 failed" - tricky_failure = True + raise RuntimeError("min_32bit_int1 failed") if tricky.max_32bit_int2() != 0x7FFFFFFF: - print "max_32bit_int2 failed" - tricky_failure = True + raise RuntimeError("max_32bit_int2 failed") tricky.too_big_32bit_int1() tricky.too_small_32bit_int1() tricky.too_big_32bit_int2() tricky.too_small_32bit_int2() - if tricky_failure: - raise RuntimeError - default_args.seek() default_args.seek(10) diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 06856f30a..5b715bae6 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -34,68 +34,48 @@ class MyFoo4(Foo): # 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) -except: + if not str(e) == "MyFoo::ping() EXCEPTION": + raise RuntimeError("Unexpected error message: %s" % str(e)) +except TypeError: 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: # fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists - if str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"): - ok = 1 - else: - print "Unexpected error message: %s" % str(e) -if not ok: - raise RuntimeError + if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"): + raise RuntimeError("Unexpected error message: %s" % str(e)) # 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 + if e.msg != "foobar": + raise RuntimeError("Unexpected error message: %s" % str(e)) # Check that the director returns the appropriate TypeError thrown in a director method -ok = 0 a = MyFoo4() b = launder(a) try: b.pong() except TypeError as e: - if str(e).startswith("type() takes 1 or 3 arguments"): - ok = 1 - else: - print "Unexpected error message: %s" % str(e) -if not ok: - raise RuntimeError + if not str(e).startswith("type() takes 1 or 3 arguments"): + raise RuntimeError("Unexpected error message: %s" % str(e)) # This is expected to fail with -builtin option diff --git a/Examples/test-suite/python/director_profile_runme.py b/Examples/test-suite/python/director_profile_runme.py index 035007c61..7c269c3f7 100644 --- a/Examples/test-suite/python/director_profile_runme.py +++ b/Examples/test-suite/python/director_profile_runme.py @@ -38,4 +38,4 @@ while i: a = fi(a) # 20 i -= 1 -print a +print("a: {}".format(a)) diff --git a/Examples/test-suite/python/director_string_runme.py b/Examples/test-suite/python/director_string_runme.py index dcd47d647..c6d4c8121 100644 --- a/Examples/test-suite/python/director_string_runme.py +++ b/Examples/test-suite/python/director_string_runme.py @@ -18,12 +18,10 @@ b = B("hello") b.get(0) if b.get_first() != "hello world!": - print b.get_first() - raise RuntimeError + raise RuntimeError("b.get_first(): {}".format(b.get_first())) b.call_process_func() if b.smem != "hello": - print smem - raise RuntimeError + raise RuntimeError("smem: {}".format(smem)) diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py index 4fcf3bfd1..21a8ce1b0 100644 --- a/Examples/test-suite/python/director_thread_runme.py +++ b/Examples/test-suite/python/director_thread_runme.py @@ -14,7 +14,6 @@ d = Derived() d.run() if d.val >= 0: - print d.val - raise RuntimeError + raise RuntimeError("d.val: {}".format(d.val)) d.stop() diff --git a/Examples/test-suite/python/director_unroll_runme.py b/Examples/test-suite/python/director_unroll_runme.py index 60bc05585..ea602d8e2 100644 --- a/Examples/test-suite/python/director_unroll_runme.py +++ b/Examples/test-suite/python/director_unroll_runme.py @@ -16,5 +16,4 @@ c = b.get() if not (a.this == c.this): - print a, c - raise RuntimeError + raise RuntimeError("{} {}".format(a, c)) diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py index b7929c0d2..b6e25f4d5 100644 --- a/Examples/test-suite/python/director_wstring_runme.py +++ b/Examples/test-suite/python/director_wstring_runme.py @@ -17,12 +17,10 @@ b = B(u"hello") b.get(0) if b.get_first() != u"hello world!": - print b.get_first() - raise RuntimeError + raise RuntimeError("b.get_first(): {}".format(b.get_first())) b.call_process_func() if b.smem != u"hello": - print smem - raise RuntimeError + raise RuntimeError("smem: {}".format(smem)) diff --git a/Examples/test-suite/python/dynamic_cast_runme.py b/Examples/test-suite/python/dynamic_cast_runme.py index 59e86d34c..ae080833b 100644 --- a/Examples/test-suite/python/dynamic_cast_runme.py +++ b/Examples/test-suite/python/dynamic_cast_runme.py @@ -8,4 +8,4 @@ y = b.blah() a = dynamic_cast.do_test(y) if a != "Bar::test": - print "Failed!!" + raise RuntimeError("Failed!!") diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py index c53521e3e..aa97e26e6 100644 --- a/Examples/test-suite/python/exception_order_runme.py +++ b/Examples/test-suite/python/exception_order_runme.py @@ -25,8 +25,7 @@ try: a.foobar() except RuntimeError, e: if e.args[0] != "postcatch unknown": - print "bad exception order", - raise RuntimeError, e.args + raise RuntimeError("bad exception order {}".format(e.args)) try: diff --git a/Examples/test-suite/python/inctest_runme.py b/Examples/test-suite/python/inctest_runme.py index fa3492932..c2746560d 100644 --- a/Examples/test-suite/python/inctest_runme.py +++ b/Examples/test-suite/python/inctest_runme.py @@ -1,31 +1,21 @@ import inctest -error = 0 try: a = inctest.A() except: - print "didn't find A" - print "therefore, I didn't include 'testdir/subdir1/hello.i'" - error = 1 + raise RuntimeError("didn't find A, therefore, I didn't include 'testdir/subdir1/hello.i'") pass try: b = inctest.B() except: - print "didn't find B" - print "therefore, I didn't include 'testdir/subdir2/hello.i'" - error = 1 + raise RuntimeError("didn't find B, therefore, I didn't include 'testdir/subdir2/hello.i'") pass -if error == 1: - raise RuntimeError - # Check the import in subdirectory worked if inctest.importtest1(5) != 15: - print "import test 1 failed" - raise RuntimeError + raise RuntimeError("import test 1 failed") if inctest.importtest2("black") != "white": - print "import test 2 failed" - raise RuntimeError + raise RuntimeError("import test 2 failed") diff --git a/Examples/test-suite/python/inherit_missing_runme.py b/Examples/test-suite/python/inherit_missing_runme.py index 044c166fb..57a245e44 100644 --- a/Examples/test-suite/python/inherit_missing_runme.py +++ b/Examples/test-suite/python/inherit_missing_runme.py @@ -6,14 +6,14 @@ c = inherit_missing.Spam() x = inherit_missing.do_blah(a) if x != "Foo::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) x = inherit_missing.do_blah(b) if x != "Bar::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) x = inherit_missing.do_blah(c) if x != "Spam::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) inherit_missing.delete_Foo(a) diff --git a/Examples/test-suite/python/inplaceadd_runme.py b/Examples/test-suite/python/inplaceadd_runme.py index 7f292cbb5..3d5a1fd40 100644 --- a/Examples/test-suite/python/inplaceadd_runme.py +++ b/Examples/test-suite/python/inplaceadd_runme.py @@ -3,8 +3,7 @@ a = inplaceadd.A(7) a += 5 if a.val != 12: - print a.val - raise RuntimeError + raise RuntimeError("a.val: {}".format(a.val)) a -= 5 if a.val != 7: diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index 80e793618..764bcdb55 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -8,12 +8,10 @@ if aa.a != 1: raise RuntimeError aa.a = 3 if aa.a != 3: - print aa.a - raise RuntimeError + raise RuntimeError("aa.a: {}".format(aa.a)) if aa.b != 2: - print aa.b - raise RuntimeError + raise RuntimeError("aa.b: {}".format(aa.b)) aa.b = 5 if aa.b != 5: raise RuntimeError diff --git a/Examples/test-suite/python/li_attribute_template_runme.py b/Examples/test-suite/python/li_attribute_template_runme.py index d33b12309..f0a774995 100644 --- a/Examples/test-suite/python/li_attribute_template_runme.py +++ b/Examples/test-suite/python/li_attribute_template_runme.py @@ -7,8 +7,7 @@ chell = li_attribute_template.Cintint(1, 2, 3) def rassert(what, master): if what != master: - print what - raise RuntimeError + raise RuntimeError("what: {}".format(what)) # Testing primitive by value attribute rassert(chell.a, 1) diff --git a/Examples/test-suite/python/li_cstring_runme.py b/Examples/test-suite/python/li_cstring_runme.py index b718f1352..d22fc261b 100644 --- a/Examples/test-suite/python/li_cstring_runme.py +++ b/Examples/test-suite/python/li_cstring_runme.py @@ -11,12 +11,10 @@ if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ raise RuntimeError if test3("hello") != "hello-suffix": - print test3("hello") - raise RuntimeError + raise RuntimeError("test3(\"hello\")") if test4("hello") != "hello-suffix": - print test4("hello") - raise RuntimeError + raise RuntimeError("test4(\"hello\")") if test5(4) != "xxxx": raise RuntimeError diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index ac214dd45..f53d3f56b 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -25,8 +25,7 @@ for k in m: for k in m: if pm[k].this != m[k].this: - print pm[k], m[k] - raise RuntimeError + raise RuntimeError("Not equal {} {}".format(pm[k], m[k])) m = {} diff --git a/Examples/test-suite/python/li_std_stream_runme.py b/Examples/test-suite/python/li_std_stream_runme.py index 08c308856..a4526f07b 100644 --- a/Examples/test-suite/python/li_std_stream_runme.py +++ b/Examples/test-suite/python/li_std_stream_runme.py @@ -9,5 +9,4 @@ o << a << " " << 2345 << " " << 1.435 if o.str() != "A class 2345 1.435": - print "\"%s\"" % (o.str(),) - raise RuntimeError + raise RuntimeError("str failed: \"%s\"".format(o.str())) diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index 087d92b19..9d3bad03a 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -10,8 +10,7 @@ if li_std_string_extra.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) - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping {} {}".format(x, li_std_string_extra.test_value(x))) if li_std_string_extra.test_const_reference(x) != x: raise RuntimeError, "bad string mapping" @@ -23,8 +22,7 @@ s = li_std_string_extra.string("he") s = s + "llo" if s != x: - print s, x - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping {} {}".format(s, x)) if s[1:4] != x[1:4]: raise RuntimeError, "bad string mapping" @@ -47,8 +45,7 @@ b = li_std_string_extra.string(" world") s = a + b if a + b != "hello world": - print a + b - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping {}".format(a + b)) if a + " world" != "hello world": raise RuntimeError, "bad string mapping" diff --git a/Examples/test-suite/python/li_std_wstream_runme.py b/Examples/test-suite/python/li_std_wstream_runme.py index 045645b61..a83561a84 100644 --- a/Examples/test-suite/python/li_std_wstream_runme.py +++ b/Examples/test-suite/python/li_std_wstream_runme.py @@ -8,5 +8,4 @@ o = wostringstream() o << a << u" " << 2345 << u" " << 1.435 << wends if o.str() != "A class 2345 1.435\0": - print "\"%s\"" % (o.str(),) - raise RuntimeError + raise RuntimeError("str failed: \"%s\"".format(o.str())) diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py index 558914e7e..5a8569a6f 100644 --- a/Examples/test-suite/python/li_std_wstring_inherit_runme.py +++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py @@ -7,8 +7,7 @@ s = li_std_wstring_inherit.wstring(u"he") s = s + u"llo" if s != x: - print s, x - raise RuntimeError("bad string mapping") + raise RuntimeError("bad string mapping {} {}".format(s, x)) if s[1:4] != x[1:4]: raise RuntimeError("bad string mapping") diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 04588ddf2..729b450a6 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -31,8 +31,7 @@ v_check() def pyerror(name, val, cte): - print "bad val/cte", name, val, cte - raise RuntimeError + raise RuntimeError("bad val/cte {} {} {}".format(name, val, cte)) pass if cvar.var_bool != cct_bool: @@ -228,26 +227,22 @@ t.v_check() # this value contains a '0' char! if def_namet != "hola": - print "bad namet", def_namet - raise RuntimeError + raise RuntimeError("bad namet {}".format(def_namet)) t.var_namet = def_namet if t.var_namet != def_namet: - print "bad namet", t.var_namet, def_namet - raise RuntimeError + raise RuntimeError("bad namet {} {}".format(t.var_namet, def_namet)) t.var_namet = "hola" if t.var_namet != "hola": - print "bad namet", t.var_namet - raise RuntimeError + raise RuntimeError("bad namet {}".format(t.var_namet)) t.var_namet = "hol" if t.var_namet != "hol": # if t.var_namet != "hol\0\0": - print "bad namet", t.var_namet - raise RuntimeError + raise RuntimeError("bad namet {}".format(t.var_namet)) cvar.var_char = "\0" @@ -261,8 +256,7 @@ if cvar.var_char != "\0": cvar.var_namet = "\0" # if cvar.var_namet != "\0\0\0\0\0": if cvar.var_namet != "": - print "hola", "", cvar.var_namet - raise RuntimeError, "bad char '\0' case" + raise RuntimeError("bad char '\0' case hola {}".format(cvar.var_namet)) cvar.var_namet = "" # if cvar.var_namet != "\0\0\0\0\0": @@ -275,8 +269,7 @@ if cvar.var_pchar != None: cvar.var_pchar = "" if cvar.var_pchar != "": - print "%c" % (cvar.var_pchar[0],) - raise RuntimeError, "bad char empty case" + raise RuntimeError("bad char empty case %c" % (cvar.var_pchar[0],)) cvar.var_pcharc = None if cvar.var_pcharc != None: @@ -300,8 +293,7 @@ pchar_setitem(pc, 4, 0) cvar.var_pchar = pc if cvar.var_pchar != "hola": - print cvar.var_pchar - raise RuntimeError, "bad pointer case" + raise RuntimeError("bad pointer case {}".format(cvar.var_pchar)) cvar.var_namet = pc # if cvar.var_namet != "hola\0": diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py index fbb60ad36..524f4d1c4 100644 --- a/Examples/test-suite/python/python_nondynamic_runme.py +++ b/Examples/test-suite/python/python_nondynamic_runme.py @@ -51,9 +51,7 @@ if python_nondynamic.retrieve_A_b(bb) != 5: raise RuntimeError("b not set correc try: bb.c = 3 - print("bb.c = {}".format(bb.c)) - print("B.c = {}".format(B.c)) - raise RuntimeError("B.c class variable messes up nondynamic-ness of B") + raise RuntimeError("B.c class variable messes up nondynamic-ness of B bb.c={} B.c={}".format(bb.c, B.c)) except AttributeError as e: debug_print(e) pass @@ -99,9 +97,7 @@ if is_python_modern() and not python_nondynamic.is_python_builtin(): if not python_nondynamic.is_python_builtin(): try: bb.cc = 3 - print("bb.cc = {}".format(bb.cc)) - print("B.cc = {}".format(B.cc)) - raise RuntimeError("B.cc class variable messes up nondynamic-ness of B") + raise RuntimeError("B.cc class variable messes up nondynamic-ness of B bb.cc={} B.cc={}".format(bb.cc, B.cc)) except AttributeError as e: debug_print(e) pass diff --git a/Examples/test-suite/python/python_pickle_runme.py b/Examples/test-suite/python/python_pickle_runme.py index 27c67ae10..cbe425fa2 100644 --- a/Examples/test-suite/python/python_pickle_runme.py +++ b/Examples/test-suite/python/python_pickle_runme.py @@ -15,15 +15,15 @@ check(p) r = p.__reduce__() if python_pickle.cvar.debug: - print "__reduce__ returned:", r + print("__reduce__ returned: {}".format(r)) pickle_string = pickle.dumps(p) newp = pickle.loads(pickle_string) check(newp) # Not yet working... some crash and others are not producing a sensible "can't be pickled" error #nfp = python_pickle.NotForPickling("no no") -#print nfp.__reduce__() +#print("{}".format(nfp.__reduce__())) #pickle_string = pickle.dumps(nfp) -#print pickle_string +#print("{}".format(pickle_string)) #newp = pickle.loads(pickle_string) -#print newp.msg +#print("{}".format(newp.msg)) diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py index 8ecdb523b..86f43b608 100644 --- a/Examples/test-suite/python/python_pybuffer_runme.py +++ b/Examples/test-suite/python/python_pybuffer_runme.py @@ -17,13 +17,13 @@ if len(sys.argv) >= 2 and sys.argv[1] == "benchmark": a = bytearray(b"hello world") for i in range(k): python_pybuffer.title1(a) - print "Time used by bytearray:", time.time() - t + print("Time used by bytearray: {}".format(time.time() - t)) t = time.time() b = "hello world" for i in range(k): python_pybuffer.title2(b) - print "Time used by string:", time.time() - t + print("Time used by string: {}".format(time.time() - t)) else: # run the test case buf1 = bytearray(10) diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py index ff3bd5f02..809eed97a 100644 --- a/Examples/test-suite/python/return_const_value_runme.py +++ b/Examples/test-suite/python/return_const_value_runme.py @@ -3,10 +3,8 @@ import sys p = return_const_value.Foo_ptr_getPtr() if (p.getVal() != 17): - print "Runtime test1 failed. p.getVal()=", p.getVal() - sys.exit(1) + raise RuntimeError("Runtime test1 failed. p.getVal()={}".format(p.getVal())) p = return_const_value.Foo_ptr_getConstPtr() if (p.getVal() != 17): - print "Runtime test2 failed. p.getVal()=", p.getVal() - sys.exit(1) + raise RuntimeError("Runtime test2 failed. p.getVal()={}".format(p.getVal())) diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py index d2ed87e79..9758b0ba4 100644 --- a/Examples/test-suite/python/smart_pointer_member_runme.py +++ b/Examples/test-suite/python/smart_pointer_member_runme.py @@ -11,9 +11,7 @@ b = Bar(f) b.y = 2 if f.y != 2: - print f.y - print b.y - raise RuntimeError + raise RuntimeError("Failed {} {}".format(f.y, b.y)) if b.x != f.x: raise RuntimeError diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py index 7404cd5f4..51bd2a7b8 100644 --- a/Examples/test-suite/python/std_containers_runme.py +++ b/Examples/test-suite/python/std_containers_runme.py @@ -33,8 +33,7 @@ if vu[2] != std_containers.videntu(vu)[2]: if v[0:3][1] != vu[0:3][1]: - print v[0:3][1], vu[0:3][1] - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice {} {}".format(v[0:3][1], vu[0:3][1])) m = ((1, 2, 3), (2, 3), (3, 4)) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index de232f580..3b18a6b74 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -23,8 +23,7 @@ xstr2 = str.lstrip(xstr2, "0") xstr2 = str.upper(xstr2) if xstr1 != xstr2: - print xstr1, xstr2 - raise RuntimeError + raise RuntimeError("Not equal failed {} {}".format(xstr1, xstr2)) s = str(a.this) r = repr(a.this) diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 161bd51fc..23f19efb9 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -8,25 +8,21 @@ try: d = make_Identity_double() a = d.this except: - print d, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(d)) s = "%s" % d if str.find(s, "ArithUnaryFunction") == -1: - print d, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(d)) try: e = make_Multiplies_double_double_double_double(d, d) a = e.this except: - print e, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(e)) s = "%s" % e if str.find(s, "ArithUnaryFunction") == -1: - print e, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(e)) # @@ -37,25 +33,21 @@ try: c = make_Identity_complex() a = c.this except: - print c, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(c)) s = "%s" % c if str.find(s, "ArithUnaryFunction") == -1: - print c, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(c)) try: f = make_Multiplies_complex_complex_complex_complex(c, c) a = f.this except: - print f, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(f)) s = "%s" % f if str.find(s, "ArithUnaryFunction") == -1: - print f, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(f)) # # Mix case @@ -65,29 +57,24 @@ try: g = make_Multiplies_double_double_complex_complex(d, c) a = g.this except: - print g, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(g)) s = "%s" % g if str.find(s, "ArithUnaryFunction") == -1: - print g, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(g)) try: h = make_Multiplies_complex_complex_double_double(c, d) a = h.this except: - print h, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(h)) s = "%s" % h if str.find(s, "ArithUnaryFunction") == -1: - print h, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(h)) try: a = g.get_value() except: - print g, "has not get_value() method" - raise RuntimeError + raise RuntimeError("{}, has not get_value() method".format(g)) diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py index 1846739eb..69d5642d6 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -8,25 +8,21 @@ try: d = make_Identity_double() a = d.this except: - print d, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(d)) s = "%s" % d if str.find(s, "ArithUnaryFunction") == -1: - print d, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(d)) try: e = make_Multiplies_double_double_double_double(d, d) a = e.this except: - print e, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(e)) s = "%s" % e if str.find(s, "ArithUnaryFunction") == -1: - print e, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(e)) # @@ -37,25 +33,21 @@ try: c = make_Identity_complex() a = c.this except: - print c, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(c)) s = "%s" % c if str.find(s, "ArithUnaryFunction") == -1: - print c, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(c)) try: f = make_Multiplies_complex_complex_complex_complex(c, c) a = f.this except: - print f, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(f)) s = "%s" % f if str.find(s, "ArithUnaryFunction") == -1: - print f, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(f)) # # Mix case @@ -65,23 +57,19 @@ try: g = make_Multiplies_double_double_complex_complex(d, c) a = g.this except: - print g, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(g)) s = "%s" % g if str.find(s, "ArithUnaryFunction") == -1: - print g, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(g)) try: h = make_Multiplies_complex_complex_double_double(c, d) a = h.this except: - print h, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(h)) s = "%s" % h if str.find(s, "ArithUnaryFunction") == -1: - print h, "is not an ArithUnaryFunction" - raise RuntimeError + raise RuntimeError("{} is not an ArithUnaryFunction".format(h)) diff --git a/Examples/test-suite/python/template_typedef_runme.py b/Examples/test-suite/python/template_typedef_runme.py index 16695bada..5723e4f59 100644 --- a/Examples/test-suite/python/template_typedef_runme.py +++ b/Examples/test-suite/python/template_typedef_runme.py @@ -14,22 +14,19 @@ try: e = make_Multiplies_float_float_float_float(d, d) a = e.this except: - print e, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(e)) try: f = make_Multiplies_reald_reald_reald_reald(c, c) a = f.this except: - print f, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(f)) try: g = make_Multiplies_float_float_reald_reald(d, c) a = g.this except: - print g, "is not an instance" - raise RuntimeError + raise RuntimeError("{} is not an instance".format(g)) # the old large format diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py index 258f44366..2b8bd5631 100644 --- a/Examples/test-suite/python/template_typemaps_typedef2_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py @@ -13,7 +13,7 @@ m2 = MultimapAInt() #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) -# print val +# print("{}".format(val)) # if val != 4321: # raise RuntimeError, "typemaps not working" diff --git a/Examples/test-suite/python/template_typemaps_typedef_runme.py b/Examples/test-suite/python/template_typemaps_typedef_runme.py index 1ca3f835c..d84be64ff 100644 --- a/Examples/test-suite/python/template_typemaps_typedef_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py @@ -13,7 +13,7 @@ m2 = MultimapAInt() #dummy_pair = m2.make_dummy_pair() #val = m2.typemap_test(dummy_pair) -# print val +# print("{}".format(val)) # if val != 4321: # raise RuntimeError, "typemaps not working" diff --git a/Examples/test-suite/python/typedef_inherit_runme.py b/Examples/test-suite/python/typedef_inherit_runme.py index 6b7f2d872..3c552ec65 100644 --- a/Examples/test-suite/python/typedef_inherit_runme.py +++ b/Examples/test-suite/python/typedef_inherit_runme.py @@ -5,19 +5,19 @@ b = typedef_inherit.Bar() x = typedef_inherit.do_blah(a) if x != "Foo::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) x = typedef_inherit.do_blah(b) if x != "Bar::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) c = typedef_inherit.Spam() d = typedef_inherit.Grok() x = typedef_inherit.do_blah2(c) if x != "Spam::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) x = typedef_inherit.do_blah2(d) if x != "Grok::blah": - print "Whoa! Bad return", x + raise RuntimeError("Whoa! Bad return {}".format(x)) diff --git a/Examples/test-suite/python/typedef_scope_runme.py b/Examples/test-suite/python/typedef_scope_runme.py index edd3e9f3a..0294c4a07 100644 --- a/Examples/test-suite/python/typedef_scope_runme.py +++ b/Examples/test-suite/python/typedef_scope_runme.py @@ -3,8 +3,8 @@ import typedef_scope b = typedef_scope.Bar() x = b.test1(42, "hello") if x != 42: - print "Failed!!" + raise RuntimeError("Failed!!") x = b.test2(42, "hello") if x != "hello": - print "Failed!!" + raise RuntimeError("Failed!!") diff --git a/Examples/test-suite/python/unions_runme.py b/Examples/test-suite/python/unions_runme.py index 387a048c8..5a3ee3b5c 100644 --- a/Examples/test-suite/python/unions_runme.py +++ b/Examples/test-suite/python/unions_runme.py @@ -3,7 +3,6 @@ # union embedded within a struct can be set and read correctly. import unions -import sys import string # Create new instances of SmallStruct and BigStruct for later use @@ -23,28 +22,23 @@ eut.number = 1 eut.uni.small = small Jill1 = eut.uni.small.jill if (Jill1 != 200): - print "Runtime test1 failed. eut.uni.small.jill=", Jill1 - sys.exit(1) + raise RuntimeError("Runtime test1 failed. eut.uni.small.jill={}".format(Jill1)) Num1 = eut.number if (Num1 != 1): - print "Runtime test2 failed. eut.number=", Num1 - sys.exit(1) + raise RuntimeError("Runtime test2 failed. eut.number=".format(Num1)) # Secondly check the BigStruct in EmbeddedUnionTest eut.number = 2 eut.uni.big = big Jack1 = eut.uni.big.jack if (Jack1 != 300): - print "Runtime test3 failed. eut.uni.big.jack=", Jack1 - sys.exit(1) + raise RuntimeError("Runtime test3 failed. eut.uni.big.jack={}".format(Jack1)) Jill2 = eut.uni.big.smallstruct.jill if (Jill2 != 200): - print "Runtime test4 failed. eut.uni.big.smallstruct.jill=", Jill2 - sys.exit(1) + raise RuntimeError("Runtime test4 failed. eut.uni.big.smallstruct.jill={}".format(Jill2)) Num2 = eut.number if (Num2 != 2): - print "Runtime test5 failed. eut.number=", Num2 - sys.exit(1) + raise RuntimeError("Runtime test5 failed. eut.number={}".format(Num2)) From 7c34d3828fc013fcf2e5d2a4ebc4c7bd2f8f4517 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 21:31:56 +0100 Subject: [PATCH 1933/2031] Improve contract Python testcase testing Catch expected exceptions only - fix bug in test --- Examples/test-suite/python/contract_runme.py | 46 ++++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index cd75a51d2..8bfda8930 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -2,16 +2,16 @@ import contract contract.test_preassert(1, 2) try: - contract.test_preassert(-1) + contract.test_preassert(-1, 3) print "Failed! Preassertions are broken" -except: +except RuntimeError: pass contract.test_postassert(3) try: contract.test_postassert(-3) print "Failed! Postassertions are broken" -except: +except RuntimeError: pass contract.test_prepost(2, 3) @@ -19,14 +19,14 @@ contract.test_prepost(5, -4) try: contract.test_prepost(-3, 4) print "Failed! Preassertions are broken" -except: +except RuntimeError: pass try: contract.test_prepost(4, -10) print "Failed! Postassertions are broken" -except: +except RuntimeError: pass f = contract.Foo() @@ -34,14 +34,14 @@ f.test_preassert(4, 5) try: f.test_preassert(-2, 3) print "Failed! Method preassertion." -except: +except RuntimeError: pass f.test_postassert(4) try: f.test_postassert(-4) print "Failed! Method postassertion" -except: +except RuntimeError: pass f.test_prepost(3, 4) @@ -49,33 +49,33 @@ f.test_prepost(4, -3) try: f.test_prepost(-4, 2) print "Failed! Method preassertion." -except: +except RuntimeError: pass try: f.test_prepost(4, -10) print "Failed! Method postassertion." -except: +except RuntimeError: pass contract.Foo_stest_prepost(4, 0) try: contract.Foo_stest_prepost(-4, 2) print "Failed! Static method preassertion" -except: +except RuntimeError: pass try: contract.Foo_stest_prepost(4, -10) print "Failed! Static method posteassertion" -except: +except RuntimeError: pass b = contract.Bar() try: b.test_prepost(2, -4) print "Failed! Inherited preassertion." -except: +except RuntimeError: pass @@ -83,54 +83,54 @@ d = contract.D() try: d.foo(-1, 1, 1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.foo(1, -1, 1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.foo(1, 1, -1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.foo(1, 1, 1, -1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.foo(1, 1, 1, 1, -1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.bar(-1, 1, 1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.bar(1, -1, 1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.bar(1, 1, -1, 1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.bar(1, 1, 1, -1, 1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass try: d.bar(1, 1, 1, 1, -1) print "Failed! Inherited preassertion (D)." -except: +except RuntimeError: pass # Namespace @@ -138,5 +138,5 @@ my = contract.myClass(1) try: my = contract.myClass(0) print "Failed! constructor preassertion" -except: +except RuntimeError: pass From 64d3617b3c354dcaa243cc0a864ab729e75dbfab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 21:40:11 +0100 Subject: [PATCH 1934/2031] Improve Python testing catching exceptions Catch expected exceptions only --- Examples/test-suite/python/contract_runme.py | 44 +++++++++---------- .../python/default_constructor_runme.py | 14 +++--- .../python/smart_pointer_not_runme.py | 12 ++--- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index 8bfda8930..b6bab3a09 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -3,14 +3,14 @@ import contract contract.test_preassert(1, 2) try: contract.test_preassert(-1, 3) - print "Failed! Preassertions are broken" + raise Exception("Failed! Preassertions are broken") except RuntimeError: pass contract.test_postassert(3) try: contract.test_postassert(-3) - print "Failed! Postassertions are broken" + raise Exception("Failed! Postassertions are broken") except RuntimeError: pass @@ -18,13 +18,13 @@ contract.test_prepost(2, 3) contract.test_prepost(5, -4) try: contract.test_prepost(-3, 4) - print "Failed! Preassertions are broken" + raise Exception("Failed! Preassertions are broken") except RuntimeError: pass try: contract.test_prepost(4, -10) - print "Failed! Postassertions are broken" + raise Exception("Failed! Postassertions are broken") except RuntimeError: pass @@ -33,14 +33,14 @@ f = contract.Foo() f.test_preassert(4, 5) try: f.test_preassert(-2, 3) - print "Failed! Method preassertion." + raise Exception("Failed! Method preassertion.") except RuntimeError: pass f.test_postassert(4) try: f.test_postassert(-4) - print "Failed! Method postassertion" + raise Exception("Failed! Method postassertion") except RuntimeError: pass @@ -48,33 +48,33 @@ f.test_prepost(3, 4) f.test_prepost(4, -3) try: f.test_prepost(-4, 2) - print "Failed! Method preassertion." + raise Exception("Failed! Method preassertion.") except RuntimeError: pass try: f.test_prepost(4, -10) - print "Failed! Method postassertion." + raise Exception("Failed! Method postassertion.") except RuntimeError: pass contract.Foo_stest_prepost(4, 0) try: contract.Foo_stest_prepost(-4, 2) - print "Failed! Static method preassertion" + raise Exception("Failed! Static method preassertion") except RuntimeError: pass try: contract.Foo_stest_prepost(4, -10) - print "Failed! Static method posteassertion" + raise Exception("Failed! Static method posteassertion") except RuntimeError: pass b = contract.Bar() try: b.test_prepost(2, -4) - print "Failed! Inherited preassertion." + raise Exception("Failed! Inherited preassertion.") except RuntimeError: pass @@ -82,54 +82,54 @@ except RuntimeError: d = contract.D() try: d.foo(-1, 1, 1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.foo(1, -1, 1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.foo(1, 1, -1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.foo(1, 1, 1, -1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.foo(1, 1, 1, 1, -1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.bar(-1, 1, 1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.bar(1, -1, 1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.bar(1, 1, -1, 1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.bar(1, 1, 1, -1, 1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass try: d.bar(1, 1, 1, 1, -1) - print "Failed! Inherited preassertion (D)." + raise Exception("Failed! Inherited preassertion (D).") except RuntimeError: pass @@ -137,6 +137,6 @@ except RuntimeError: my = contract.myClass(1) try: my = contract.myClass(0) - print "Failed! constructor preassertion" + raise Exception("Failed! constructor preassertion") except RuntimeError: pass diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py index 1e877adda..301f422cf 100644 --- a/Examples/test-suite/python/default_constructor_runme.py +++ b/Examples/test-suite/python/default_constructor_runme.py @@ -17,7 +17,7 @@ dc.delete_AA(aa) try: b = dc.new_B() print "Whoa. new_BB created." -except: +except TypeError: pass del_b = dc.delete_B @@ -25,7 +25,7 @@ del_b = dc.delete_B try: bb = dc.new_BB() print "Whoa. new_BB created." -except: +except AttributeError: pass del_bb = dc.delete_BB @@ -33,7 +33,7 @@ del_bb = dc.delete_BB try: c = dc.new_C() print "Whoa. new_C created." -except: +except AttributeError: pass del_c = dc.delete_C @@ -44,7 +44,7 @@ dc.delete_CC(cc) try: d = dc.new_D() print "Whoa. new_D created" -except: +except AttributeError: pass del_d = dc.delete_D @@ -52,7 +52,7 @@ del_d = dc.delete_D try: dd = dc.new_DD() print "Whoa. new_DD created" -except: +except AttributeError: pass dd = dc.delete_DD @@ -60,7 +60,7 @@ dd = dc.delete_DD try: ad = dc.new_AD() print "Whoa. new_AD created" -except: +except AttributeError: pass del_ad = dc.delete_AD @@ -74,7 +74,7 @@ dc.delete_EE(ee) try: eb = dc.new_EB() print "Whoa. new_EB created" -except: +except AttributeError: pass del_eb = dc.delete_EB diff --git a/Examples/test-suite/python/smart_pointer_not_runme.py b/Examples/test-suite/python/smart_pointer_not_runme.py index 69704c4ef..53006bce4 100644 --- a/Examples/test-suite/python/smart_pointer_not_runme.py +++ b/Examples/test-suite/python/smart_pointer_not_runme.py @@ -8,35 +8,35 @@ g = Grok(f) try: x = b.x print "Error! b.x" -except: +except AttributeError: pass try: x = s.x print "Error! s.x" -except: +except AttributeError: pass try: x = g.x print "Error! g.x" -except: +except AttributeError: pass try: x = b.getx() print "Error! b.getx()" -except: +except AttributeError: pass try: x = s.getx() print "Error! s.getx()" -except: +except AttributeError: pass try: x = g.getx() print "Error! g.getx()" -except: +except AttributeError: pass From 916955562870476171777b177562e6edc8c283d3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 21:47:20 +0100 Subject: [PATCH 1935/2031] Remove further print statements from Python tests Use exceptions instead of printing to stdout. Part of an effort to convert Python tests to python 3 syntax. --- .../python/default_constructor_runme.py | 18 +++++++++--------- .../python/smart_pointer_not_runme.py | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py index 301f422cf..2943dc960 100644 --- a/Examples/test-suite/python/default_constructor_runme.py +++ b/Examples/test-suite/python/default_constructor_runme.py @@ -16,7 +16,7 @@ dc.delete_AA(aa) try: b = dc.new_B() - print "Whoa. new_BB created." + raise RuntimeError("Whoa. new_BB created.") except TypeError: pass @@ -24,7 +24,7 @@ del_b = dc.delete_B try: bb = dc.new_BB() - print "Whoa. new_BB created." + raise RuntimeError("Whoa. new_BB created.") except AttributeError: pass @@ -32,7 +32,7 @@ del_bb = dc.delete_BB try: c = dc.new_C() - print "Whoa. new_C created." + raise RuntimeError("Whoa. new_C created.") except AttributeError: pass @@ -43,7 +43,7 @@ dc.delete_CC(cc) try: d = dc.new_D() - print "Whoa. new_D created" + raise RuntimeError("Whoa. new_D created") except AttributeError: pass @@ -51,7 +51,7 @@ del_d = dc.delete_D try: dd = dc.new_DD() - print "Whoa. new_DD created" + raise RuntimeError("Whoa. new_DD created") except AttributeError: pass @@ -59,7 +59,7 @@ dd = dc.delete_DD try: ad = dc.new_AD() - print "Whoa. new_AD created" + raise RuntimeError("Whoa. new_AD created") except AttributeError: pass @@ -73,7 +73,7 @@ dc.delete_EE(ee) try: eb = dc.new_EB() - print "Whoa. new_EB created" + raise RuntimeError("Whoa. new_EB created") except AttributeError: pass @@ -83,7 +83,7 @@ f = dc.new_F() try: del_f = dc.delete_F - print "Whoa. delete_F created" + raise RuntimeError("Whoa. delete_F created") except AttributeError: pass @@ -93,7 +93,7 @@ g = dc.new_G() try: del_g = dc.delete_G - print "Whoa. delete_G created" + raise RuntimeError("Whoa. delete_G created") except AttributeError: pass diff --git a/Examples/test-suite/python/smart_pointer_not_runme.py b/Examples/test-suite/python/smart_pointer_not_runme.py index 53006bce4..8cd9f11f3 100644 --- a/Examples/test-suite/python/smart_pointer_not_runme.py +++ b/Examples/test-suite/python/smart_pointer_not_runme.py @@ -7,36 +7,36 @@ g = Grok(f) try: x = b.x - print "Error! b.x" + raise RuntimeError("Error! b.x") except AttributeError: pass try: x = s.x - print "Error! s.x" + raise RuntimeError("Error! s.x") except AttributeError: pass try: x = g.x - print "Error! g.x" + raise RuntimeError("Error! g.x") except AttributeError: pass try: x = b.getx() - print "Error! b.getx()" + raise RuntimeError("Error! b.getx()") except AttributeError: pass try: x = s.getx() - print "Error! s.getx()" + raise RuntimeError("Error! s.getx()") except AttributeError: pass try: x = g.getx() - print "Error! g.getx()" + raise RuntimeError("Error! g.getx()") except AttributeError: pass From d82004533606327b340af483d7d5838539f65b83 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 22:00:01 +0100 Subject: [PATCH 1936/2031] Improve director_exception Python test Add code to handle missed exceptons. Remove print statement. --- Examples/test-suite/python/director_exception_runme.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 5b715bae6..77abd25a9 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -28,7 +28,7 @@ class MyFoo3(Foo): class MyFoo4(Foo): def ping(self, *args): - print(type("bad", "call")) # throws TypeError message: type() takes 1 or 3 arguments + t = type("bad", "call") # throws TypeError message: type() takes 1 or 3 arguments return "Foo4.ping" @@ -38,6 +38,7 @@ a = MyFoo() b = launder(a) try: b.pong() + raise RuntimeError("Exception was not thrown") except NotImplementedError, e: if not str(e) == "MyFoo::ping() EXCEPTION": raise RuntimeError("Unexpected error message: %s" % str(e)) @@ -51,6 +52,7 @@ a = MyFoo2() b = launder(a) try: b.pong() + raise RuntimeError("Exception was not thrown") except TypeError, e: # fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"): @@ -63,6 +65,7 @@ a = MyFoo3() b = launder(a) try: b.pong() + raise RuntimeError("Exception was not thrown") except MyException, e: if e.msg != "foobar": raise RuntimeError("Unexpected error message: %s" % str(e)) @@ -73,6 +76,7 @@ a = MyFoo4() b = launder(a) try: b.pong() + raise RuntimeError("Exception was not thrown") except TypeError as e: if not str(e).startswith("type() takes 1 or 3 arguments"): raise RuntimeError("Unexpected error message: %s" % str(e)) From 982b08dcedc4002c8cf4a5b1d19dfb930e6fa6b1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2020 23:34:28 +0100 Subject: [PATCH 1937/2031] Convert two tests to work with both Python 2 and 3 Now these two tests work without having to use 2to3 --- .../python_destructor_exception_runme.py | 10 +++++++--- .../python/python_strict_unicode_runme.py | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/python/python_destructor_exception_runme.py b/Examples/test-suite/python/python_destructor_exception_runme.py index ee71ab33b..47659531b 100644 --- a/Examples/test-suite/python/python_destructor_exception_runme.py +++ b/Examples/test-suite/python/python_destructor_exception_runme.py @@ -1,7 +1,11 @@ import python_destructor_exception -from StringIO import StringIO import sys +if sys.version_info[0:2] < (3, 0): + import StringIO as io +else: + import io + def error_function(): python_destructor_exception.ClassWithThrowingDestructor().GetBlah() @@ -9,13 +13,13 @@ def runtest(): attributeErrorOccurred = False try: error_function() - except AttributeError, e: + except AttributeError: attributeErrorOccurred = True return attributeErrorOccurred def test1(): stderr_saved = sys.stderr - buffer = StringIO() + buffer = io.StringIO() attributeErrorOccurred = False try: # Suppress stderr while making this call to suppress the output shown by PyErr_WriteUnraisable diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py index e7fae2556..ba0e7d965 100644 --- a/Examples/test-suite/python/python_strict_unicode_runme.py +++ b/Examples/test-suite/python/python_strict_unicode_runme.py @@ -1,8 +1,17 @@ import python_strict_unicode +import sys test_bytes = b"hello \x01world\x99" BYTES = b"BYTES" -test_unicode = u"h\udce9llo w\u00f6rld" + +if sys.version_info[0:2] < (3, 0): + test_unicode = u"h\udce9llo w\u00f6rld" + UNICODE = u"UNICODE" + type_unicode_string = type(u"") +else: + test_unicode = "h\udce9llo w\u00f6rld" + UNICODE = "UNICODE" + type_unicode_string = type("") # Test that byte string inputs and outputs work as expected bdbl = python_strict_unicode.double_str(test_bytes) @@ -20,12 +29,12 @@ if type(bout) != type(BYTES): udbl = python_strict_unicode.double_wstr(test_unicode) if udbl != test_unicode + test_unicode: raise RuntimeError("Failed to double wide string") -if type(udbl) != type(u""): +if type(udbl) != type_unicode_string: raise RuntimeError("Wrong type output for wide string") uout = python_strict_unicode.same_wstr(test_unicode) if uout != test_unicode: raise RuntimeError("Failed to copy wchar_t*") -if type(uout) != type(u""): +if type(uout) != type_unicode_string: raise RuntimeError("Wrong type output for wchar_t*") # Test that overloading is handled properly @@ -35,9 +44,9 @@ if bovr != BYTES: if type(bovr) != type(BYTES): raise RuntimeError("Wrong type output from overload") uovr = python_strict_unicode.overload(test_unicode) -if uovr != u"UNICODE": +if uovr != UNICODE: raise RuntimeError("Failed to return unicode from overload") -if type(uovr) != type(u""): +if type(uovr) != type_unicode_string: raise RuntimeERror("Wrong type output from overload") # Test that bytes aren't accepted as wide strings and unicode isn't accepted as narrow strings From 36bb54f01d0b5a0fef4c3843b366b5d78b8c04bb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2020 23:27:35 +0100 Subject: [PATCH 1938/2031] Convert swigobject python test to be python 2 and 3 compatible --- Examples/test-suite/python/swigobject_runme.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 3b18a6b74..e28e187c9 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -1,5 +1,5 @@ - from swigobject import * +import sys a = A() @@ -11,7 +11,11 @@ if a1.this != a2.this: raise RuntimeError -lthis = long(a.this) +if sys.version_info[0:2] < (3, 0): + lthis = long(a.this) +else: + lthis = int(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,) @@ -30,5 +34,10 @@ r = repr(a.this) v1 = v_ptr(a) v2 = v_ptr(a) -if long(v1) != long(v2): - raise RuntimeError + +if sys.version_info[0:2] < (3, 0): + if long(v1) != long(v2): + raise RuntimeError +else: + if int(v1) != int(v2): + raise RuntimeError From 66df0bd2242b04125bc008142de749b962991675 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 00:09:31 +0100 Subject: [PATCH 1939/2031] Convert python test scripts to be Python 2 and 3 compatible Unicode testing --- .../python/director_wstring_runme.py | 8 ++++---- .../test-suite/python/li_cwstring_runme.py | 18 +++++++++--------- .../test-suite/python/li_std_wstream_runme.py | 2 +- .../python/li_std_wstring_inherit_runme.py | 10 +++++----- .../test-suite/python/li_std_wstring_runme.py | 6 +++--- .../test-suite/python/unicode_strings_runme.py | 14 ++++++-------- 6 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Examples/test-suite/python/director_wstring_runme.py b/Examples/test-suite/python/director_wstring_runme.py index b6e25f4d5..5facc1f1d 100644 --- a/Examples/test-suite/python/director_wstring_runme.py +++ b/Examples/test-suite/python/director_wstring_runme.py @@ -7,20 +7,20 @@ class B(A): A.__init__(self, string) def get_first(self): - return A.get_first(self) + u" world!" + return A.get_first(self) + " world!" def process_text(self, s): self.smem = s -b = B(u"hello") +b = B("hello") b.get(0) -if b.get_first() != u"hello world!": +if b.get_first() != "hello world!": raise RuntimeError("b.get_first(): {}".format(b.get_first())) b.call_process_func() -if b.smem != u"hello": +if b.smem != "hello": raise RuntimeError("smem: {}".format(smem)) diff --git a/Examples/test-suite/python/li_cwstring_runme.py b/Examples/test-suite/python/li_cwstring_runme.py index 5dd7b9b20..9216445c6 100644 --- a/Examples/test-suite/python/li_cwstring_runme.py +++ b/Examples/test-suite/python/li_cwstring_runme.py @@ -1,28 +1,28 @@ from li_cwstring import * -if count(u"ab\0ab\0ab\0", 0) != 3: +if count("ab\0ab\0ab\0", 0) != 3: raise RuntimeError -if test1() != u"Hello World": +if test1() != "Hello World": raise RuntimeError -if test2() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": +if test2() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError -if test3("hello") != u"hello-suffix": +if test3("hello") != "hello-suffix": raise RuntimeError -if test4("hello") != u"hello-suffix": +if test4("hello") != "hello-suffix": raise RuntimeError -if test5(4) != u"xxxx": +if test5(4) != "xxxx": raise RuntimeError -if test6(10) != u"xxxxx": +if test6(10) != "xxxxx": raise RuntimeError -if test7() != u"Hello world!": +if test7() != "Hello world!": raise RuntimeError -if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": +if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_": raise RuntimeError diff --git a/Examples/test-suite/python/li_std_wstream_runme.py b/Examples/test-suite/python/li_std_wstream_runme.py index a83561a84..0ecdddbf8 100644 --- a/Examples/test-suite/python/li_std_wstream_runme.py +++ b/Examples/test-suite/python/li_std_wstream_runme.py @@ -5,7 +5,7 @@ a = A() o = wostringstream() -o << a << u" " << 2345 << u" " << 1.435 << wends +o << a << " " << 2345 << " " << 1.435 << wends if o.str() != "A class 2345 1.435\0": raise RuntimeError("str failed: \"%s\"".format(o.str())) diff --git a/Examples/test-suite/python/li_std_wstring_inherit_runme.py b/Examples/test-suite/python/li_std_wstring_inherit_runme.py index 5a8569a6f..bd585890c 100644 --- a/Examples/test-suite/python/li_std_wstring_inherit_runme.py +++ b/Examples/test-suite/python/li_std_wstring_inherit_runme.py @@ -1,10 +1,10 @@ import li_std_wstring_inherit import sys -x = u"hello" +x = "hello" -s = li_std_wstring_inherit.wstring(u"he") -s = s + u"llo" +s = li_std_wstring_inherit.wstring("he") +s = s + "llo" if s != x: raise RuntimeError("bad string mapping {} {}".format(s, x)) @@ -33,12 +33,12 @@ if not li_std_wstring_inherit.is_python_builtin(): b = li_std_wstring_inherit.B("hi") -b.name = li_std_wstring_inherit.wstring(u"hello") +b.name = li_std_wstring_inherit.wstring("hello") if b.name != "hello": raise RuntimeError("bad string mapping") b.a = li_std_wstring_inherit.A("hello") -if b.a != u"hello": +if b.a != "hello": raise RuntimeError("bad string mapping") diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index c6210e2de..ef2085c66 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -5,10 +5,10 @@ def check_equal(a, b): if a != b: raise RuntimeError("failed {} {}".format(a, b)) -h = u"h" +h = "h" check_equal(li_std_wstring.test_wcvalue(h), h) -x = u"abc" +x = "abc" check_equal(li_std_wstring.test_ccvalue(x), x) check_equal(li_std_wstring.test_cvalue(x), x) @@ -72,7 +72,7 @@ except TypeError: # Check surrogateescape if sys.version_info[0:2] > (3, 1): - x = u"h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo" + x = "h\udce9llo" # surrogate escaped representation of C char*: "h\xe9llo" if li_std_wstring.non_utf8_c_str() != x: raise RuntimeError("surrogateescape not working") if li_std_wstring.size_wstring(x) != 5 and len(x) != 5: diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 4e661f00e..108d0d2c9 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -2,12 +2,8 @@ import sys import unicode_strings -# The 'u' string prefix isn't valid in Python 3.0 - 3.2 and is redundant -# in 3.3+. Since this file is run through 2to3 before testing, though, -# mark this as a unicode string in 2.x so it'll become a str in 3.x. -test_string = u"h\udce9llo w\u00f6rld" - if sys.version_info[0:2] >= (3, 1): + test_string = "h\udce9llo w\u00f6rld" if unicode_strings.non_utf8_c_str() != test_string: raise ValueError("Test comparison mismatch") if unicode_strings.non_utf8_std_string() != test_string: @@ -22,15 +18,17 @@ if sys.version_info[0:2] < (3, 0): check(unicode_strings.charstring("hello1"), "hello1") check(unicode_strings.charstring(str(u"hello2")), "hello2") check(unicode_strings.charstring(u"hello3"), "hello3") - check(unicode_strings.charstring(unicode("hello4")), "hello4") + check(unicode_strings.charstring(str("hello4")), "hello4") unicode_strings.charstring(u"hell\xb05") unicode_strings.charstring(u"hell\u00f66") + low_surrogate_string = u"\udcff" +else: + low_surrogate_string = "\udcff" -low_surrogate_string = u"\udcff" try: unicode_strings.instring(low_surrogate_string) # Will succeed with Python 2 -except TypeError, e: +except TypeError as e: # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError. # The real error is actually: # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed From d4ffa46f4168b85524ec26c07426fe97dfcb3a38 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 00:16:04 +0100 Subject: [PATCH 1940/2031] Convert python tests using 2to3 These tests were converted using 2to3 and should be valid using Python 2.7 and Python 3+. --- .../test-suite/python/array_member_runme.py | 4 +- .../test-suite/python/char_binary_runme.py | 10 +- .../test-suite/python/complextest_runme.py | 10 +- .../cpp11_alternate_function_syntax_runme.py | 10 +- .../test-suite/python/cpp11_decltype_runme.py | 8 +- .../python/cpp11_hash_tables_runme.py | 16 ++-- .../cpp11_null_pointer_constant_runme.py | 8 +- .../python/cpp11_raw_string_literals_runme.py | 10 +- .../python/cpp11_result_of_runme.py | 8 +- .../python/cpp11_rvalue_reference_runme.py | 8 +- .../python/cpp11_std_array_runme.py | 14 +-- .../cpp11_uniform_initialization_runme.py | 8 +- .../python/director_abstract_runme.py | 4 +- .../python/director_alternating_runme.py | 2 +- .../test-suite/python/director_basic_runme.py | 8 +- .../director_comparison_operators_runme.py | 2 +- .../python/director_detect_runme.py | 2 +- .../python/director_exception_runme.py | 8 +- .../python/director_extend_runme.py | 4 +- .../test-suite/python/director_frob_runme.py | 2 +- .../python/director_nested_runme.py | 4 +- .../python/director_protected_runme.py | 30 +++--- .../python/director_smartptr_runme.py | 2 +- .../python/exception_order_runme.py | 18 ++-- Examples/test-suite/python/fvirtual_runme.py | 2 +- .../python/global_functions_runme.py | 10 +- .../test-suite/python/global_vars_runme.py | 4 +- .../test-suite/python/import_stl_runme.py | 2 +- .../test-suite/python/li_attribute_runme.py | 2 +- .../python/li_boost_shared_ptr_runme.py | 4 +- .../test-suite/python/li_implicit_runme.py | 6 +- .../python/li_std_containers_int_runme.py | 40 ++++---- .../test-suite/python/li_std_map_runme.py | 16 ++-- .../test-suite/python/li_std_set_runme.py | 20 ++-- .../python/li_std_string_extra_runme.py | 58 ++++++------ .../python/li_std_vector_enum_runme.py | 2 +- .../python/li_std_vector_extra_runme.py | 30 +++--- Examples/test-suite/python/minherit_runme.py | 40 ++++---- .../python/namespace_class_runme.py | 4 +- .../python/overload_complicated_runme.py | 22 ++--- .../python/overload_simple_runme.py | 50 +++++----- .../python/overload_subtype_runme.py | 4 +- .../python/overload_template_fast_runme.py | 78 +++++++-------- .../python/overload_template_runme.py | 78 +++++++-------- .../python/pointer_reference_runme.py | 8 +- .../python/primitive_types_runme.py | 78 +++++++-------- .../test-suite/python/python_builtin_runme.py | 2 +- .../python_overload_simple_cast_runme.py | 94 +++++++++---------- .../python/python_richcompare_runme.py | 8 +- .../test-suite/python/std_containers_runme.py | 18 ++-- .../test-suite/python/struct_value_runme.py | 4 +- .../python/template_classes_runme.py | 8 +- .../python/template_default_arg_runme.py | 40 ++++---- .../template_typemaps_typedef2_runme.py | 14 +-- .../python/template_typemaps_typedef_runme.py | 14 +-- .../python/threads_exception_runme.py | 16 ++-- .../test-suite/python/typemap_arrays_runme.py | 2 +- Examples/test-suite/python/typename_runme.py | 8 +- .../python/using_composition_runme.py | 18 ++-- .../test-suite/python/using_extend_runme.py | 12 +-- .../test-suite/python/using_inherit_runme.py | 24 ++--- .../test-suite/python/using_private_runme.py | 6 +- .../python/using_protected_runme.py | 2 +- .../python/varargs_overload_runme.py | 36 +++---- Examples/test-suite/python/varargs_runme.py | 16 ++-- .../python/virtual_derivation_runme.py | 2 +- 66 files changed, 551 insertions(+), 551 deletions(-) diff --git a/Examples/test-suite/python/array_member_runme.py b/Examples/test-suite/python/array_member_runme.py index de6e0f3e7..2708a6f37 100644 --- a/Examples/test-suite/python/array_member_runme.py +++ b/Examples/test-suite/python/array_member_runme.py @@ -5,7 +5,7 @@ f.data = cvar.global_data for i in range(0, 8): if get_value(f.data, i) != get_value(cvar.global_data, i): - raise RuntimeError, "Bad array assignment" + raise RuntimeError("Bad array assignment") for i in range(0, 8): @@ -15,4 +15,4 @@ cvar.global_data = f.data for i in range(0, 8): if get_value(f.data, i) != get_value(cvar.global_data, i): - raise RuntimeError, "Bad array assignment" + raise RuntimeError("Bad array assignment") diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py index 83ae9f0ec..39c0b2447 100644 --- a/Examples/test-suite/python/char_binary_runme.py +++ b/Examples/test-suite/python/char_binary_runme.py @@ -7,9 +7,9 @@ if t.ustrlen("hile") != 4: raise RuntimeError("bad multi-arg typemap {}".format(t.ustrlen("hile"))) if t.strlen("hil\0") != 4: - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap") if t.ustrlen("hil\0") != 4: - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap") # # creating a raw char* @@ -23,9 +23,9 @@ pchar_setitem(pc, 4, 0) if t.strlen(pc) != 4: - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap") if t.ustrlen(pc) != 4: - raise RuntimeError, "bad multi-arg typemap" + raise RuntimeError("bad multi-arg typemap") cvar.var_pchar = pc if cvar.var_pchar != "hola": @@ -34,6 +34,6 @@ if cvar.var_pchar != "hola": cvar.var_namet = pc # if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": - raise RuntimeError, "bad pointer case" + raise RuntimeError("bad pointer case") delete_pchar(pc) diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py index 5cfc7ccab..4257cb3b0 100644 --- a/Examples/test-suite/python/complextest_runme.py +++ b/Examples/test-suite/python/complextest_runme.py @@ -3,16 +3,16 @@ import complextest a = complex(-1, 2) if complextest.Conj(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" + raise RuntimeError("bad complex mapping") if complextest.Conjf(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" + raise RuntimeError("bad complex mapping") if complextest.Conj2(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" + raise RuntimeError("bad complex mapping") if complextest.Conjf2(a) != a.conjugate(): - raise RuntimeError, "bad complex mapping" + raise RuntimeError("bad complex mapping") v = (complex(1, 2), complex(2, 3), complex(4, 3), 1) @@ -27,4 +27,4 @@ p = complextest.ComplexPair() p.z1 = complex(0, 1) p.z2 = complex(0, -1) if complextest.Conj(p.z2) != p.z1: - raise RuntimeError, "bad complex mapping" + raise RuntimeError("bad complex mapping") diff --git a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py index cc7b5cd91..e46a4772f 100644 --- a/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py +++ b/Examples/test-suite/python/cpp11_alternate_function_syntax_runme.py @@ -4,20 +4,20 @@ a = cpp11_alternate_function_syntax.SomeStruct() res = a.addNormal(4, 5) if res != 9: - raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.") + raise RuntimeError("SomeStruct::addNormal(4,5) returns ", res, " should be 9.") res = a.addAlternate(4, 5) if res != 9: - raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.") + raise RuntimeError("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.") res = a.addAlternateConst(4, 5) if res != 9: - raise RuntimeError, ("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.") + raise RuntimeError("SomeStruct::addAlternateConst(4,5) returns ", res, " should be 9.") res = a.addAlternateNoExcept(4, 5) if res != 9: - raise RuntimeError, ("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.") + raise RuntimeError("SomeStruct::addAlternateNoExcept(4,5) returns ", res, " should be 9.") res = a.addAlternateConstNoExcept(4, 5) if res != 9: - raise RuntimeError, ("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.") + raise RuntimeError("SomeStruct::addAlternateConstNoExcept(4,5) returns ", res, " should be 9.") diff --git a/Examples/test-suite/python/cpp11_decltype_runme.py b/Examples/test-suite/python/cpp11_decltype_runme.py index 1650d9004..a18f334dc 100644 --- a/Examples/test-suite/python/cpp11_decltype_runme.py +++ b/Examples/test-suite/python/cpp11_decltype_runme.py @@ -3,16 +3,16 @@ import cpp11_decltype a = cpp11_decltype.A() a.i = 5 if a.i != 5: - raise RuntimeError, "Assignment to a.i failed." + raise RuntimeError("Assignment to a.i failed.") a.j = 10 if a.j != 10: - raise RuntimeError, "Assignment to a.j failed." + raise RuntimeError("Assignment to a.j failed.") b = a.foo(5) if b != 10: - raise RuntimeError, "foo(5) should return 10." + raise RuntimeError("foo(5) should return 10.") b = a.foo(6) if b != 0: - raise RuntimeError, "foo(6) should return 0." + raise RuntimeError("foo(6) should return 0.") diff --git a/Examples/test-suite/python/cpp11_hash_tables_runme.py b/Examples/test-suite/python/cpp11_hash_tables_runme.py index 7b772ff9a..3e7be49d0 100644 --- a/Examples/test-suite/python/cpp11_hash_tables_runme.py +++ b/Examples/test-suite/python/cpp11_hash_tables_runme.py @@ -10,14 +10,14 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7}) ]: - swig_assert_equal([(k, v) for k, v in x.iteritems()], [(1, 7)]) - swig_assert_equal(x.keys(), [1]) - swig_assert_equal(x.values(), [7]) - swig_assert_equal(x.items(), [(1, 7)]) + swig_assert_equal([(k, v) for k, v in x.items()], [(1, 7)]) + swig_assert_equal(list(x.keys()), [1]) + swig_assert_equal(list(x.values()), [7]) + swig_assert_equal(list(x.items()), [(1, 7)]) swig_assert_equal([k for k in x], [1]) - swig_assert_equal([i for i in x.iterkeys()], [1]) - swig_assert_equal([i for i in x.itervalues()], [7]) - swig_assert_equal([i for i in x.iteritems()], [(1, 7)]) + swig_assert_equal([i for i in x.keys()], [1]) + swig_assert_equal([i for i in x.values()], [7]) + swig_assert_equal([i for i in x.items()], [(1, 7)]) swig_assert_equal(x[1], 7) swig_assert_equal(2 in x, False) @@ -33,7 +33,7 @@ for x in [cpp11_hash_tables.MapIntInt({1:7}), for x in [cpp11_hash_tables.MultiMapIntInt({1:7}), cpp11_hash_tables.UnorderedMultiMapIntInt({1:7})]: x[1] = 9 - swig_assert_equal(sorted([v for k, v in x.iteritems()]), [7, 9]) + swig_assert_equal(sorted([v for k, v in x.items()]), [7, 9]) swig_assert_equal(len(x), 2) for x in [cpp11_hash_tables.SetInt([1]), diff --git a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py index 54a8fe0eb..c39760344 100644 --- a/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py +++ b/Examples/test-suite/python/cpp11_null_pointer_constant_runme.py @@ -3,15 +3,15 @@ import cpp11_null_pointer_constant a = cpp11_null_pointer_constant.A() if a._myA != None: - raise RuntimeError, ( + raise RuntimeError( "cpp11_null_pointer_constant: _myA should be None, but is ", a._myA) b = cpp11_null_pointer_constant.A() if a._myA != b._myA: - raise RuntimeError, ( + raise RuntimeError( "cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA) a._myA = cpp11_null_pointer_constant.A() if a._myA == None: - raise RuntimeError, ( - "cpp11_null_pointer_constant: _myA should be object, but is None") + raise RuntimeError(( + "cpp11_null_pointer_constant: _myA should be object, but is None")) diff --git a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py index 6a587b860..90e450f8b 100644 --- a/Examples/test-suite/python/cpp11_raw_string_literals_runme.py +++ b/Examples/test-suite/python/cpp11_raw_string_literals_runme.py @@ -34,19 +34,19 @@ if cvar.aa != "Wide string": raise RuntimeError if cvar.bb != "UTF-8 string": - raise RuntimeError, cvar.wide + raise RuntimeError(cvar.wide) if cvar.xx != ")I'm an \"ascii\" \\ string.": - raise RuntimeError, cvar.xx + raise RuntimeError(cvar.xx) if cvar.ee != ")I'm an \"ascii\" \\ string.": - raise RuntimeError, cvar.ee + raise RuntimeError(cvar.ee) if cvar.ff != "I'm a \"raw wide\" \\ string.": - raise RuntimeError, cvar.ff + raise RuntimeError(cvar.ff) if cvar.gg != "I'm a \"raw UTF-8\" \\ string.": - raise RuntimeError, cvar.gg + raise RuntimeError(cvar.gg) def check(got, expected): diff --git a/Examples/test-suite/python/cpp11_result_of_runme.py b/Examples/test-suite/python/cpp11_result_of_runme.py index 4469efd81..691d2a2d8 100644 --- a/Examples/test-suite/python/cpp11_result_of_runme.py +++ b/Examples/test-suite/python/cpp11_result_of_runme.py @@ -2,10 +2,10 @@ import cpp11_result_of result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0) if result != 9.0: - raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str( - result) + raise RuntimeError("test_result(square, 3.0) is not 9.0. Got: " + str( + result)) result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0) if result != 9.0: - raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str( - result) + raise RuntimeError("test_result_alternative1(square, 3.0) is not 9.0. Got: " + str( + result)) diff --git a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py index c1cd3bf26..85d64a581 100644 --- a/Examples/test-suite/python/cpp11_rvalue_reference_runme.py +++ b/Examples/test-suite/python/cpp11_rvalue_reference_runme.py @@ -4,24 +4,24 @@ a = cpp11_rvalue_reference.A() a.setAcopy(5) if a.getAcopy() != 5: - raise RunTimeError, ("int A::getAcopy() value is ", + raise RunTimeError("int A::getAcopy() value is ", a.getAcopy(), " should be 5") ptr = a.getAptr() a.setAptr(ptr) if a.getAcopy() != 5: - raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy( + raise RunTimeError("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy( ), " should be 5") a.setAref(ptr) if a.getAcopy() != 5: - raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy( + raise RunTimeError("after A::setAref(): int A::getAcopy() value is ", a.getAcopy( ), " should be 5") rvalueref = a.getAmove() a.setAmove(rvalueref) if a.getAcopy() != 5: - raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy( + raise RunTimeError("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy( ), " should be 5") diff --git a/Examples/test-suite/python/cpp11_std_array_runme.py b/Examples/test-suite/python/cpp11_std_array_runme.py index e5e7373dd..9e11a3e5b 100644 --- a/Examples/test-suite/python/cpp11_std_array_runme.py +++ b/Examples/test-suite/python/cpp11_std_array_runme.py @@ -3,7 +3,7 @@ import sys def failed(a, b, msg): - raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) + raise RuntimeError(msg + " " + str(list(a)) + " " + str(list(b))) def compare_sequences(a, b): @@ -26,8 +26,8 @@ def steps_exception(swigarray, i, j, step): a = swigarray[i::step] else: a = swigarray[i:j:step] - raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray)) - except ValueError, e: + raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray))) + except ValueError as e: # print("exception: {}".format(e)) pass @@ -43,16 +43,16 @@ def del_exception(swigarray, i, j, step): del swigarray[i::step] else: del swigarray[i:j:step] - raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray)) - except ValueError, e: + raise RuntimeError("swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray))) + except ValueError as e: # print("exception: {}".format(e)) pass def setslice_exception(swigarray, newval): try: swigarray[::] = newval - raise RuntimeError, "swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray)) - except TypeError, e: + raise RuntimeError("swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray))) + except TypeError as e: # print("exception: {}".format(e)) pass diff --git a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py index ecb468ccb..b01557a6f 100644 --- a/Examples/test-suite/python/cpp11_uniform_initialization_runme.py +++ b/Examples/test-suite/python/cpp11_uniform_initialization_runme.py @@ -9,13 +9,13 @@ if var2.getX() != 2: m = cpp11_uniform_initialization.MoreInit() if m.charptr != None: - raise RuntimeError, m.charptr + raise RuntimeError(m.charptr) m.charptr = "hello sir" if m.charptr != "hello sir": - raise RuntimeError, m.charptr + raise RuntimeError(m.charptr) if m.more1(m.vi) != 15: - raise RuntimeError, m.vi + raise RuntimeError(m.vi) if m.more1([-1, 1, 2]) != 2: - raise RuntimeError, m.vi + raise RuntimeError(m.vi) if m.more1() != 10: raise RuntimeError diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py index 333b75fe5..c8c4b36dc 100644 --- a/Examples/test-suite/python/director_abstract_runme.py +++ b/Examples/test-suite/python/director_abstract_runme.py @@ -13,10 +13,10 @@ class MyFoo(director_abstract.Foo): a = MyFoo() if a.ping() != "MyFoo::ping()": - raise RuntimeError, a.ping() + raise RuntimeError(a.ping()) if a.pong() != "Foo::pong();MyFoo::ping()": - raise RuntimeError, a.pong() + raise RuntimeError(a.pong()) class MyExample1(director_abstract.Example1): diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py index a93ffec34..dc85351b5 100644 --- a/Examples/test-suite/python/director_alternating_runme.py +++ b/Examples/test-suite/python/director_alternating_runme.py @@ -2,4 +2,4 @@ from director_alternating import * id = getBar().id() if id != idFromGetBar(): - raise RuntimeError, "Got wrong id: " + str(id) + raise RuntimeError("Got wrong id: " + str(id)) diff --git a/Examples/test-suite/python/director_basic_runme.py b/Examples/test-suite/python/director_basic_runme.py index 6564c95a2..79cd0e2eb 100644 --- a/Examples/test-suite/python/director_basic_runme.py +++ b/Examples/test-suite/python/director_basic_runme.py @@ -10,18 +10,18 @@ class PyFoo(director_basic.Foo): a = PyFoo() if a.ping() != "PyFoo::ping()": - raise RuntimeError, a.ping() + raise RuntimeError(a.ping()) if a.pong() != "Foo::pong();PyFoo::ping()": - raise RuntimeError, a.pong() + raise RuntimeError(a.pong()) b = director_basic.Foo() if b.ping() != "Foo::ping()": - raise RuntimeError, b.ping() + raise RuntimeError(b.ping()) if b.pong() != "Foo::pong();Foo::ping()": - raise RuntimeError, b.pong() + raise RuntimeError(b.pong()) a = director_basic.A1(1) diff --git a/Examples/test-suite/python/director_comparison_operators_runme.py b/Examples/test-suite/python/director_comparison_operators_runme.py index 4fe733098..e9bf9438d 100644 --- a/Examples/test-suite/python/director_comparison_operators_runme.py +++ b/Examples/test-suite/python/director_comparison_operators_runme.py @@ -8,4 +8,4 @@ class PyFoo(director_comparison_operators.Foo): a = PyFoo() if a.test() != "a=1,b=2": - raise RuntimeError, a.test() + raise RuntimeError(a.test()) diff --git a/Examples/test-suite/python/director_detect_runme.py b/Examples/test-suite/python/director_detect_runme.py index 345051982..b9c73eb45 100644 --- a/Examples/test-suite/python/director_detect_runme.py +++ b/Examples/test-suite/python/director_detect_runme.py @@ -35,4 +35,4 @@ c = b.clone() vc = c.get_value() if (v != 3) or (b.val != 5) or (vc != 6): - raise RuntimeError, "Bad virtual detection" + raise RuntimeError("Bad virtual detection") diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 77abd25a9..458983c6a 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -10,7 +10,7 @@ class MyException(Exception): class MyFoo(Foo): def ping(self): - raise NotImplementedError, "MyFoo::ping() EXCEPTION" + raise NotImplementedError("MyFoo::ping() EXCEPTION") class MyFoo2(Foo): @@ -39,7 +39,7 @@ b = launder(a) try: b.pong() raise RuntimeError("Exception was not thrown") -except NotImplementedError, e: +except NotImplementedError as e: if not str(e) == "MyFoo::ping() EXCEPTION": raise RuntimeError("Unexpected error message: %s" % str(e)) except TypeError: @@ -53,7 +53,7 @@ b = launder(a) try: b.pong() raise RuntimeError("Exception was not thrown") -except TypeError, e: +except TypeError as e: # fastdispatch mode adds on Additional Information to the exception message - just check the main exception message exists if not str(e).startswith("SWIG director type mismatch in output value of type 'std::string'"): raise RuntimeError("Unexpected error message: %s" % str(e)) @@ -66,7 +66,7 @@ b = launder(a) try: b.pong() raise RuntimeError("Exception was not thrown") -except MyException, e: +except MyException as e: if e.msg != "foobar": raise RuntimeError("Unexpected error message: %s" % str(e)) diff --git a/Examples/test-suite/python/director_extend_runme.py b/Examples/test-suite/python/director_extend_runme.py index a5aad8245..870443d1f 100644 --- a/Examples/test-suite/python/director_extend_runme.py +++ b/Examples/test-suite/python/director_extend_runme.py @@ -17,6 +17,6 @@ class MyObject(SpObject): m = MyObject() if m.dummy() != 666: - raise RuntimeError, "1st call" + raise RuntimeError("1st call") if m.dummy() != 666: # Locked system - raise RuntimeError, "2nd call" + raise RuntimeError("2nd call") diff --git a/Examples/test-suite/python/director_frob_runme.py b/Examples/test-suite/python/director_frob_runme.py index 0ef4ad900..6c8fcad06 100644 --- a/Examples/test-suite/python/director_frob_runme.py +++ b/Examples/test-suite/python/director_frob_runme.py @@ -4,4 +4,4 @@ foo = Bravo() s = foo.abs_method() if s != "Bravo::abs_method()": - raise RuntimeError, s + raise RuntimeError(s) diff --git a/Examples/test-suite/python/director_nested_runme.py b/Examples/test-suite/python/director_nested_runme.py index f3d973630..b2c4b0d40 100644 --- a/Examples/test-suite/python/director_nested_runme.py +++ b/Examples/test-suite/python/director_nested_runme.py @@ -14,7 +14,7 @@ class A(FooBar_int): a = A() if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;": - raise RuntimeError, "Bad A virtual resolution" + raise RuntimeError("Bad A virtual resolution") class B(FooBar_int): @@ -34,7 +34,7 @@ class B(FooBar_int): b = B() if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;": - raise RuntimeError, "Bad B virtual resolution" + raise RuntimeError("Bad B virtual resolution") class C(FooBar_int): diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py index c3118a7c0..94eab69a6 100644 --- a/Examples/test-suite/python/director_protected_runme.py +++ b/Examples/test-suite/python/director_protected_runme.py @@ -35,7 +35,7 @@ try: raise RuntimeError pass except: - raise RuntimeError, "bad FooBar::used" + raise RuntimeError("bad FooBar::used") try: s = fb2.used() @@ -43,7 +43,7 @@ try: raise RuntimeError pass except: - raise RuntimeError, "bad FooBar2::used" + raise RuntimeError("bad FooBar2::used") try: s = b.pong() @@ -51,7 +51,7 @@ try: raise RuntimeError pass except: - raise RuntimeError, "bad Bar::pong" + raise RuntimeError("bad Bar::pong") try: s = f.pong() @@ -59,7 +59,7 @@ try: raise RuntimeError pass except: - raise RuntimeError, " bad Foo::pong" + raise RuntimeError(" bad Foo::pong") try: s = fb.pong() @@ -67,7 +67,7 @@ try: raise RuntimeError pass except: - raise RuntimeError, " bad FooBar::pong" + raise RuntimeError(" bad FooBar::pong") protected = 1 try: @@ -76,7 +76,7 @@ try: except: pass if not protected: - raise RuntimeError, "Foo::ping is protected" + raise RuntimeError("Foo::ping is protected") protected = 1 try: @@ -85,7 +85,7 @@ try: except: pass if not protected: - raise RuntimeError, "Foo::ping is protected" + raise RuntimeError("Foo::ping is protected") protected = 1 @@ -95,7 +95,7 @@ try: except: pass if not protected: - raise RuntimeError, "FooBar::pang is protected" + raise RuntimeError("FooBar::pang is protected") protected = 1 @@ -105,7 +105,7 @@ try: except: pass if not protected: - raise RuntimeError, "Bar::cheer is protected" + raise RuntimeError("Bar::cheer is protected") protected = 1 try: @@ -114,19 +114,19 @@ try: except: pass if not protected: - raise RuntimeError, "Foo::cheer is protected" + raise RuntimeError("Foo::cheer is protected") if fb3.cheer() != "FooBar3::cheer();": - raise RuntimeError, "bad fb3::cheer" + raise RuntimeError("bad fb3::cheer") if fb2.callping() != "FooBar2::ping();": - raise RuntimeError, "bad fb2.callping" + raise RuntimeError("bad fb2.callping") if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();": - raise RuntimeError, "bad fb2.callcheer" + raise RuntimeError("bad fb2.callcheer") if fb3.callping() != "Bar::ping();": - raise RuntimeError, "bad fb3.callping" + raise RuntimeError("bad fb3.callping") if fb3.callcheer() != "FooBar3::cheer();": - raise RuntimeError, "bad fb3.callcheer" + raise RuntimeError("bad fb3.callcheer") diff --git a/Examples/test-suite/python/director_smartptr_runme.py b/Examples/test-suite/python/director_smartptr_runme.py index 23e22d0fb..b4cbafe32 100644 --- a/Examples/test-suite/python/director_smartptr_runme.py +++ b/Examples/test-suite/python/director_smartptr_runme.py @@ -31,7 +31,7 @@ class director_smartptr_MyBarFooDerived(FooDerived): def check(got, expected): if (got != expected): - raise RuntimeError, "Failed, got: " + got + " expected: " + expected + raise RuntimeError("Failed, got: " + got + " expected: " + expected) fooBar = FooBar() diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py index aa97e26e6..5c1529999 100644 --- a/Examples/test-suite/python/exception_order_runme.py +++ b/Examples/test-suite/python/exception_order_runme.py @@ -9,35 +9,35 @@ a = A() try: a.foo() -except E1, e: +except E1 as e: pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError("bad exception order") try: a.bar() -except E2, e: +except E2 as e: pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError("bad exception order") try: a.foobar() -except RuntimeError, e: +except RuntimeError as e: if e.args[0] != "postcatch unknown": raise RuntimeError("bad exception order {}".format(e.args)) try: a.barfoo(1) -except E1, e: +except E1 as e: pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError("bad exception order") try: a.barfoo(2) -except E2, e: +except E2 as e: pass except: - raise RuntimeError, "bad exception order" + raise RuntimeError("bad exception order") diff --git a/Examples/test-suite/python/fvirtual_runme.py b/Examples/test-suite/python/fvirtual_runme.py index 99f5dc6b0..fe211b441 100644 --- a/Examples/test-suite/python/fvirtual_runme.py +++ b/Examples/test-suite/python/fvirtual_runme.py @@ -5,4 +5,4 @@ n = Node() i = sw.addChild(n) if i != 2: - raise RuntimeError, "addChild" + raise RuntimeError("addChild") diff --git a/Examples/test-suite/python/global_functions_runme.py b/Examples/test-suite/python/global_functions_runme.py index f411261b6..4aab1b082 100644 --- a/Examples/test-suite/python/global_functions_runme.py +++ b/Examples/test-suite/python/global_functions_runme.py @@ -11,7 +11,7 @@ check(global_two(2, 2), 4) fail = True try: global_void(1) -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") @@ -19,7 +19,7 @@ if fail: fail = True try: global_one() -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") @@ -27,7 +27,7 @@ if fail: fail = True try: global_one(2, 2) -except TypeError, e: +except TypeError as e: fail = False if fail: @@ -36,7 +36,7 @@ if fail: fail = True try: global_two(1) -except TypeError, e: +except TypeError as e: fail = False if fail: @@ -45,7 +45,7 @@ if fail: fail = True try: global_two(3, 3, 3) -except TypeError, e: +except TypeError as e: fail = False if fail: diff --git a/Examples/test-suite/python/global_vars_runme.py b/Examples/test-suite/python/global_vars_runme.py index 3ef0b494f..015519ec8 100644 --- a/Examples/test-suite/python/global_vars_runme.py +++ b/Examples/test-suite/python/global_vars_runme.py @@ -20,7 +20,7 @@ if x != 9876: fail = True try: global_vars.cvar.notexist = "something" -except AttributeError, e: +except AttributeError as e: fail = False if fail: raise RuntimeError("AttributeError should have been thrown") @@ -28,7 +28,7 @@ if fail: fail = True try: g = global_vars.cvar.notexist -except AttributeError, e: +except AttributeError as e: fail = False if fail: raise RuntimeError("AttributeError should have been thrown") diff --git a/Examples/test-suite/python/import_stl_runme.py b/Examples/test-suite/python/import_stl_runme.py index 69fe812b9..d0efbd083 100644 --- a/Examples/test-suite/python/import_stl_runme.py +++ b/Examples/test-suite/python/import_stl_runme.py @@ -3,4 +3,4 @@ import import_stl_a v_new = import_stl_b.process_vector([1, 2, 3]) if v_new != (1, 2, 3, 4): - raise RuntimeError, v_new + raise RuntimeError(v_new) diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index 764bcdb55..a5a6914cd 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -75,7 +75,7 @@ if myStringyClass.ReadOnlyString != "changed string": try: x = myFoo.does_not_exist raise RuntimeError -except AttributeError, e: +except AttributeError as e: if str(e).find("does_not_exist") == -1: 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 c960625ad..ecda7fdb1 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -10,7 +10,7 @@ class li_boost_shared_ptr_runme: def main(self): if (debug): - print "Started" + print("Started") li_boost_shared_ptr.cvar.debug_shared = debug @@ -32,7 +32,7 @@ class li_boost_shared_ptr_runme: "shared_ptr wrapper count=%s" % wrapper_count) if (debug): - print "Finished" + print("Finished") def runtest(self): # simple shared_ptr usage - created in C++ diff --git a/Examples/test-suite/python/li_implicit_runme.py b/Examples/test-suite/python/li_implicit_runme.py index d8dd0fdcc..5d5c6caa0 100644 --- a/Examples/test-suite/python/li_implicit_runme.py +++ b/Examples/test-suite/python/li_implicit_runme.py @@ -9,8 +9,8 @@ ad, get(ad) ab, get(ab) if get(ai) != get(1): - raise RuntimeError, "bad implicit type" + raise RuntimeError("bad implicit type") if get(ad) != get(2.0): - raise RuntimeError, "bad implicit type" + raise RuntimeError("bad implicit type") if get(ab) != get(b): - raise RuntimeError, "bad implicit type" + raise RuntimeError("bad implicit type") diff --git a/Examples/test-suite/python/li_std_containers_int_runme.py b/Examples/test-suite/python/li_std_containers_int_runme.py index 941838a5f..f346de220 100644 --- a/Examples/test-suite/python/li_std_containers_int_runme.py +++ b/Examples/test-suite/python/li_std_containers_int_runme.py @@ -6,7 +6,7 @@ import sys def failed(a, b, msg): - raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b)) + raise RuntimeError(msg + " " + str(list(a)) + " " + str(list(b))) def compare_sequences(a, b): @@ -26,7 +26,7 @@ def compare_containers(pythonlist, swigvector, swiglist): def container_insert_step(i, j, step, newval): - ps = range(6) + ps = list(range(6)) iv = vector_int(ps) il = list_int(ps) @@ -43,9 +43,9 @@ def container_insert_step(i, j, step, newval): else: ps[i:j:step] = newval ps_error = None - except ValueError, e: + except ValueError as e: ps_error = e - except IndexError, e: + except IndexError as e: ps_error = e # std::vector @@ -61,9 +61,9 @@ def container_insert_step(i, j, step, newval): else: iv[i:j:step] = newval iv_error = None - except ValueError, e: + except ValueError as e: iv_error = e - except IndexError, e: + except IndexError as e: iv_error = e # std::list @@ -79,14 +79,14 @@ def container_insert_step(i, j, step, newval): else: il[i:j:step] = newval il_error = None - except ValueError, e: + except ValueError as e: il_error = e - except IndexError, e: + except IndexError as e: il_error = e if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + \ - str(ps_error) + " " + str(iv_error) + " " + str(il_error) + raise RuntimeError("ValueError exception not consistently thrown: " + \ + str(ps_error) + " " + str(iv_error) + " " + str(il_error)) compare_containers(ps, iv, il) @@ -94,7 +94,7 @@ def container_insert_step(i, j, step, newval): # Check std::vector and std::list delete behaves same as Python list # delete including exceptions def container_delete_step(i, j, step): - ps = range(6) + ps = list(range(6)) iv = vector_int(ps) il = list_int(ps) @@ -111,9 +111,9 @@ def container_delete_step(i, j, step): else: del ps[i:j:step] ps_error = None - except ValueError, e: + except ValueError as e: ps_error = e - except IndexError, e: + except IndexError as e: ps_error = e # std::vector @@ -129,9 +129,9 @@ def container_delete_step(i, j, step): else: del iv[i:j:step] iv_error = None - except ValueError, e: + except ValueError as e: iv_error = e - except IndexError, e: + except IndexError as e: iv_error = e # std::list @@ -147,14 +147,14 @@ def container_delete_step(i, j, step): else: del il[i:j:step] il_error = None - except ValueError, e: + except ValueError as e: il_error = e - except IndexError, e: + except IndexError as e: il_error = e if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))): - raise RuntimeError, "ValueError exception not consistently thrown: " + \ - str(ps_error) + " " + str(iv_error) + " " + str(il_error) + raise RuntimeError("ValueError exception not consistently thrown: " + \ + str(ps_error) + " " + str(iv_error) + " " + str(il_error)) compare_containers(ps, iv, il) @@ -252,7 +252,7 @@ for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 10 for step in range(-7, 7): container_delete_step(start, end, step) -ps = range(6) +ps = list(range(6)) iv = vector_int(ps) il = list_int(ps) del ps[:] diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index f53d3f56b..765527ea4 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -50,31 +50,31 @@ mii[1] = 2 if mii[1] != 2: raise RuntimeError -if mii.keys() != [1]: +if list(mii.keys()) != [1]: raise RuntimeError("keys") -if mii.values() != [2]: +if list(mii.values()) != [2]: raise RuntimeError("values") -if mii.items() != [(1, 2)]: +if list(mii.items()) != [(1, 2)]: raise RuntimeError("items") if [k for k in mii] != [1]: raise RuntimeError("iteration") -if [i for i in mii.iterkeys()] != [1]: +if [i for i in mii.keys()] != [1]: raise RuntimeError("iterkeys") -if [i for i in mii.itervalues()] != [2]: +if [i for i in mii.values()] != [2]: raise RuntimeError("itervalues") -if [i for i in mii.iteritems()] != [(1, 2)]: +if [i for i in mii.items()] != [(1, 2)]: raise RuntimeError("iteritems") slmap = li_std_map.StringLengthNumberMap() li_std_map.populate(slmap) -keys = " ".join([k for k in slmap.keys()]) +keys = " ".join([k for k in list(slmap.keys())]) if keys != "a aa zzz xxxx aaaaa": raise RuntimeError("Keys are wrong or in wrong order: " + keys) -values = " ".join([str(v) for v in slmap.values()]) +values = " ".join([str(v) for v in list(slmap.values())]) if values != "1 2 3 4 5": raise RuntimeError("Values are wrong or in wrong order: " + values) diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py index 5e5b72442..34a1eb19c 100644 --- a/Examples/test-suite/python/li_std_set_runme.py +++ b/Examples/test-suite/python/li_std_set_runme.py @@ -14,11 +14,11 @@ if sum != "abc": raise RuntimeError i = s.__iter__() -if i.next() != "a": +if next(i) != "a": raise RuntimeError -if i.next() != "b": +if next(i) != "b": raise RuntimeError -if i.next() != "c": +if next(i) != "c": raise RuntimeError @@ -26,7 +26,7 @@ b = s.begin() e = s.end() sum = "" while (b != e): - sum = sum + b.next() + sum = sum + next(b) if sum != "abc": raise RuntimeError @@ -34,7 +34,7 @@ b = s.rbegin() e = s.rend() sum = "" while (b != e): - sum = sum + b.next() + sum = sum + next(b) if sum != "cba": raise RuntimeError @@ -47,25 +47,25 @@ si.append(2) si.append(3) i = si.__iter__() -if i.next() != 1: +if next(i) != 1: raise RuntimeError -if i.next() != 2: +if next(i) != 2: raise RuntimeError -if i.next() != 3: +if next(i) != 3: raise RuntimeError if si[0] != 1: raise RuntimeError i = s.begin() -i.next() +next(i) s.erase(i) b = s.begin() e = s.end() sum = "" while (b != e): - sum = sum + b.next() + sum = sum + next(b) if sum != "ac": raise RuntimeError diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index 9d3bad03a..96c64163d 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -4,16 +4,16 @@ x = "hello" if li_std_string_extra.test_ccvalue(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_cvalue(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value(x) != x: raise RuntimeError("bad string mapping {} {}".format(x, li_std_string_extra.test_value(x))) if li_std_string_extra.test_const_reference(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") s = li_std_string_extra.string("he") @@ -25,21 +25,21 @@ if s != x: raise RuntimeError("bad string mapping {} {}".format(s, x)) if s[1:4] != x[1:4]: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value(s) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_const_reference(s) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") a = li_std_string_extra.A(s) if li_std_string_extra.test_value(a) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_const_reference(a) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") b = li_std_string_extra.string(" world") @@ -48,17 +48,17 @@ if a + b != "hello world": raise RuntimeError("bad string mapping {}".format(a + b)) if a + " world" != "hello world": - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") # This is expected to fail with -builtin option # Reverse operators not supported in builtin types if not li_std_string_extra.is_python_builtin(): if "hello" + b != "hello world": - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") c = "hello" + b if c.find_last_of("l") != 9: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") s = "hello world" @@ -66,33 +66,33 @@ b = li_std_string_extra.B("hi") b.name = li_std_string_extra.string("hello") if b.name != "hello": - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") b.a = li_std_string_extra.A("hello") if b.a != "hello": - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value_basic1(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value_basic2(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value_basic3(x) != x: - raise RuntimeError, "bad string mapping" + raise RuntimeError("bad string mapping") if li_std_string_extra.test_value_basic_overload(x) != x: - raise RuntimeError, "bad overload string" + raise RuntimeError("bad overload string") if li_std_string_extra.test_value_basic_overload(123) != "int": - raise RuntimeError, "bad overload int" + raise RuntimeError("bad overload int") try: li_std_string_extra.test_value_basic_overload([x]) - raise RuntimeError, "should throw TypeError" + raise RuntimeError("should throw TypeError") except TypeError as e: if str(e).find("Possible C/C++ prototypes are:") == -1: raise RuntimeError("Incorrect error message text:\n{}".format(e)) @@ -100,7 +100,7 @@ except TypeError as e: try: li_std_string_extra.test_value_basic_overload([123]) - raise RuntimeError, "should throw TypeError" + raise RuntimeError("should throw TypeError") except TypeError as e: if str(e).find("Possible C/C++ prototypes are:") == -1: raise RuntimeError("Incorrect error message text:\n{}".format(e)) @@ -109,30 +109,30 @@ except TypeError as e: # Global variables s = "initial string" if li_std_string_extra.cvar.GlobalString2 != "global string 2": - raise RuntimeError, "GlobalString2 test 1" + raise RuntimeError("GlobalString2 test 1") li_std_string_extra.cvar.GlobalString2 = s if li_std_string_extra.cvar.GlobalString2 != s: - raise RuntimeError, "GlobalString2 test 2" + raise RuntimeError("GlobalString2 test 2") if li_std_string_extra.cvar.ConstGlobalString != "const global string": - raise RuntimeError, "ConstGlobalString test" + raise RuntimeError("ConstGlobalString test") # Member variables myStructure = li_std_string_extra.Structure() if myStructure.MemberString2 != "member string 2": - raise RuntimeError, "MemberString2 test 1" + raise RuntimeError("MemberString2 test 1") myStructure.MemberString2 = s if myStructure.MemberString2 != s: - raise RuntimeError, "MemberString2 test 2" + raise RuntimeError("MemberString2 test 2") if myStructure.ConstMemberString != "const member string": - raise RuntimeError, "ConstMemberString test" + raise RuntimeError("ConstMemberString test") if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": - raise RuntimeError, "StaticMemberString2 test 1" + raise RuntimeError("StaticMemberString2 test 1") li_std_string_extra.cvar.Structure_StaticMemberString2 = s if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: - raise RuntimeError, "StaticMemberString2 test 2" + raise RuntimeError("StaticMemberString2 test 2") if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": - raise RuntimeError, "ConstStaticMemberString test" + raise RuntimeError("ConstStaticMemberString test") if li_std_string_extra.test_reference_input("hello") != "hello": diff --git a/Examples/test-suite/python/li_std_vector_enum_runme.py b/Examples/test-suite/python/li_std_vector_enum_runme.py index 318d1bff6..587f20b37 100644 --- a/Examples/test-suite/python/li_std_vector_enum_runme.py +++ b/Examples/test-suite/python/li_std_vector_enum_runme.py @@ -14,7 +14,7 @@ check(ev.nums[2], 30) it = ev.nums.iterator() v = it.value() check(v, 10) -it.next() +next(it) v = it.value() check(v, 20) diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index 59e729a27..40444552b 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -23,20 +23,20 @@ bv[2] = bool(4) bv[3] = bool(0) if bv[0] != bv[2]: - raise RuntimeError, "bad std::vector mapping" + raise RuntimeError("bad std::vector mapping") b = B(5) va = VecA([b, None, b, b]) if va[0].f(1) != 6: - raise RuntimeError, "bad std::vector mapping" + raise RuntimeError("bad std::vector mapping") if vecAptr(va) != 6: - raise RuntimeError, "bad std::vector mapping" + raise RuntimeError("bad std::vector mapping") b.val = 7 if va[3].f(1) != 8: - raise RuntimeError, "bad std::vector mapping" + raise RuntimeError("bad std::vector mapping") ip = PtrInt() @@ -47,7 +47,7 @@ ArrInt_setitem(ap, 2, 123) vi = IntPtrVector((ip, ap, None)) if ArrInt_getitem(vi[0], 0) != ArrInt_getitem(vi[1], 2): - raise RuntimeError, "bad std::vector mapping" + raise RuntimeError("bad std::vector mapping") delete_ArrInt(ap) @@ -57,42 +57,42 @@ a = halfs([10, 8, 4, 3]) v = IntVector() v[0:2] = [1, 2] if v[0] != 1 or v[1] != 2: - raise RuntimeError, "bad setslice" + raise RuntimeError("bad setslice") if v[0:-1][0] != 1: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") if v[0:-2].size() != 0: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") v[0:1] = [2] if v[0] != 2: - raise RuntimeError, "bad setslice" + raise RuntimeError("bad setslice") v[1:] = [3] if v[1] != 3: - raise RuntimeError, "bad setslice" + raise RuntimeError("bad setslice") v[2:] = [3] if v[2] != 3: - raise RuntimeError, "bad setslice" + raise RuntimeError("bad setslice") if v[0:][0] != v[0]: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") del v[:] if v.size() != 0: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") del v[:] if v.size() != 0: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") v = vecStr(["hello ", "world"]) if v[0] != "hello world": - raise RuntimeError, "bad std::string+std::vector" + raise RuntimeError("bad std::string+std::vector") pv = pyvector([1, "hello", (1, 2)]) diff --git a/Examples/test-suite/python/minherit_runme.py b/Examples/test-suite/python/minherit_runme.py index b7e7d019c..8638d2357 100644 --- a/Examples/test-suite/python/minherit_runme.py +++ b/Examples/test-suite/python/minherit_runme.py @@ -7,31 +7,31 @@ c = minherit.FooBar() d = minherit.Spam() if a.xget() != 1: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if b.yget() != 2: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if c.xget() != 1 or c.yget() != 2 or c.zget() != 3: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if minherit.xget(a) != 1: - raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a)) + raise RuntimeError("Bad attribute value %d" % (minherit.xget(a))) if minherit.yget(b) != 2: - raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b)) + raise RuntimeError("Bad attribute value %d" % (minherit.yget(b))) if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3: - raise RuntimeError, "Bad attribute value %d %d %d" % ( - minherit.xget(c), minherit.yget(c), minherit.zget(c)) + raise RuntimeError("Bad attribute value %d %d %d" % ( + minherit.xget(c), minherit.yget(c), minherit.zget(c))) if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4: - raise RuntimeError, "Bad attribute value %d %d %d %d" % ( - minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d)) + raise RuntimeError("Bad attribute value %d %d %d %d" % ( + minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d))) # Cleanse all of the pointers and see what happens @@ -41,27 +41,27 @@ cc = minherit.toFooBarPtr(c) dd = minherit.toSpamPtr(d) if aa.xget() != 1: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if bb.yget() != 2: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4: - raise RuntimeError, "Bad attribute value" + raise RuntimeError("Bad attribute value") if minherit.xget(aa) != 1: - raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa)) + raise RuntimeError("Bad attribute value %d" % (minherit.xget(aa))) if minherit.yget(bb) != 2: - raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb)) + raise RuntimeError("Bad attribute value %d" % (minherit.yget(bb))) if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3: - raise RuntimeError, "Bad attribute value %d %d %d" % ( - minherit.xget(cc), minherit.yget(cc), minherit.zget(cc)) + raise RuntimeError("Bad attribute value %d %d %d" % ( + minherit.xget(cc), minherit.yget(cc), minherit.zget(cc))) if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4: - raise RuntimeError, "Bad attribute value %d %d %d %d" % ( - minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd)) + raise RuntimeError("Bad attribute value %d %d %d %d" % ( + minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd))) diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py index aa5165562..9349f2430 100644 --- a/Examples/test-suite/python/namespace_class_runme.py +++ b/Examples/test-suite/python/namespace_class_runme.py @@ -7,7 +7,7 @@ except: error = 0 if (error): - raise RuntimeError, "Private1 is private" + raise RuntimeError("Private1 is private") try: p = Private2() @@ -16,7 +16,7 @@ except: error = 0 if (error): - raise RuntimeError, "Private2 is private" + raise RuntimeError("Private2 is private") EulerT3D.toFrame(1, 1, 1) diff --git a/Examples/test-suite/python/overload_complicated_runme.py b/Examples/test-suite/python/overload_complicated_runme.py index 2593c4f16..8794da12b 100644 --- a/Examples/test-suite/python/overload_complicated_runme.py +++ b/Examples/test-suite/python/overload_complicated_runme.py @@ -10,38 +10,38 @@ p = Pop(pInt, False) # Check overloaded in const only and pointers/references which target # languages cannot disambiguate if p.hip(False) != 701: - raise RuntimeError, "Test 1 failed" + raise RuntimeError("Test 1 failed") if p.hip(pInt) != 702: - raise RuntimeError, "Test 2 failed" + raise RuntimeError("Test 2 failed") # Reverse the order for the above if p.hop(pInt) != 805: - raise RuntimeError, "Test 3 failed" + raise RuntimeError("Test 3 failed") if p.hop(False) != 801: - raise RuntimeError, "Test 4 failed" + raise RuntimeError("Test 4 failed") # Few more variations and order shuffled if p.pop(False) != 901: - raise RuntimeError, "Test 5 failed" + raise RuntimeError("Test 5 failed") if p.pop(pInt) != 904: - raise RuntimeError, "Test 6 failed" + raise RuntimeError("Test 6 failed") if p.pop() != 905: - raise RuntimeError, "Test 7 failed" + raise RuntimeError("Test 7 failed") # Overload on const only if p.bop(pInt) != 1001: - raise RuntimeError, "Test 8 failed" + raise RuntimeError("Test 8 failed") if p.bip(pInt) != 2002: - raise RuntimeError, "Test 9 failed" + raise RuntimeError("Test 9 failed") # Globals if muzak(False) != 3001: - raise RuntimeError, "Test 10 failed" + raise RuntimeError("Test 10 failed") if muzak(pInt) != 3002: - raise RuntimeError, "Test 11 failed" + raise RuntimeError("Test 11 failed") diff --git a/Examples/test-suite/python/overload_simple_runme.py b/Examples/test-suite/python/overload_simple_runme.py index 6d72ec081..8ad813b86 100644 --- a/Examples/test-suite/python/overload_simple_runme.py +++ b/Examples/test-suite/python/overload_simple_runme.py @@ -1,95 +1,95 @@ from overload_simple import * if foo(3) != "foo:int": - raise RuntimeError, "foo(int)" + raise RuntimeError("foo(int)") if foo(3.0) != "foo:double": - raise RuntimeError, "foo(double)" + raise RuntimeError("foo(double)") if foo("hello") != "foo:char *": - raise RuntimeError, "foo(char *)" + raise RuntimeError("foo(char *)") f = Foo() b = Bar() if foo(f) != "foo:Foo *": - raise RuntimeError, "foo(Foo *)" + raise RuntimeError("foo(Foo *)") if foo(b) != "foo:Bar *": - raise RuntimeError, "foo(Bar *)" + raise RuntimeError("foo(Bar *)") v = malloc_void(32) if foo(v) != "foo:void *": - raise RuntimeError, "foo(void *)" + raise RuntimeError("foo(void *)") s = Spam() if s.foo(3) != "foo:int": - raise RuntimeError, "Spam::foo(int)" + raise RuntimeError("Spam::foo(int)") if s.foo(3.0) != "foo:double": - raise RuntimeError, "Spam::foo(double)" + raise RuntimeError("Spam::foo(double)") if s.foo("hello") != "foo:char *": - raise RuntimeError, "Spam::foo(char *)" + raise RuntimeError("Spam::foo(char *)") if s.foo(f) != "foo:Foo *": - raise RuntimeError, "Spam::foo(Foo *)" + raise RuntimeError("Spam::foo(Foo *)") if s.foo(b) != "foo:Bar *": - raise RuntimeError, "Spam::foo(Bar *)" + raise RuntimeError("Spam::foo(Bar *)") if s.foo(v) != "foo:void *": - raise RuntimeError, "Spam::foo(void *)" + raise RuntimeError("Spam::foo(void *)") if Spam_bar(3) != "bar:int": - raise RuntimeError, "Spam::bar(int)" + raise RuntimeError("Spam::bar(int)") if Spam_bar(3.0) != "bar:double": - raise RuntimeError, "Spam::bar(double)" + raise RuntimeError("Spam::bar(double)") if Spam_bar("hello") != "bar:char *": - raise RuntimeError, "Spam::bar(char *)" + raise RuntimeError("Spam::bar(char *)") if Spam_bar(f) != "bar:Foo *": - raise RuntimeError, "Spam::bar(Foo *)" + raise RuntimeError("Spam::bar(Foo *)") if Spam_bar(b) != "bar:Bar *": - raise RuntimeError, "Spam::bar(Bar *)" + raise RuntimeError("Spam::bar(Bar *)") if Spam_bar(v) != "bar:void *": - raise RuntimeError, "Spam::bar(void *)" + raise RuntimeError("Spam::bar(void *)") # Test constructors s = Spam() if s.type != "none": - raise RuntimeError, "Spam()" + raise RuntimeError("Spam()") s = Spam(3) if s.type != "int": - raise RuntimeError, "Spam(int)" + raise RuntimeError("Spam(int)") s = Spam(3.4) if s.type != "double": - raise RuntimeError, "Spam(double)" + raise RuntimeError("Spam(double)") s = Spam("hello") if s.type != "char *": - raise RuntimeError, "Spam(char *)" + raise RuntimeError("Spam(char *)") s = Spam(f) if s.type != "Foo *": - raise RuntimeError, "Spam(Foo *)" + raise RuntimeError("Spam(Foo *)") s = Spam(b) if s.type != "Bar *": - raise RuntimeError, "Spam(Bar *)" + raise RuntimeError("Spam(Bar *)") s = Spam(v) if s.type != "void *": - raise RuntimeError, "Spam(void *)" + raise RuntimeError("Spam(void *)") free_void(v) diff --git a/Examples/test-suite/python/overload_subtype_runme.py b/Examples/test-suite/python/overload_subtype_runme.py index 3f32a5583..b02e62ff3 100644 --- a/Examples/test-suite/python/overload_subtype_runme.py +++ b/Examples/test-suite/python/overload_subtype_runme.py @@ -4,7 +4,7 @@ f = Foo() b = Bar() if spam(f) != 1: - raise RuntimeError, "foo" + raise RuntimeError("foo") if spam(b) != 2: - raise RuntimeError, "bar" + raise RuntimeError("bar") diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py index ca3cac9b5..e4eb33288 100644 --- a/Examples/test-suite/python/overload_template_fast_runme.py +++ b/Examples/test-suite/python/overload_template_fast_runme.py @@ -7,74 +7,74 @@ b = maximum(3.4, 5.2) # mix 1 if (mix1("hi") != 101): - raise RuntimeError, ("mix1(const char*)") + raise RuntimeError(("mix1(const char*)")) if (mix1(1.0, 1.0) != 102): - raise RuntimeError, ("mix1(double, const double &)") + raise RuntimeError(("mix1(double, const double &)")) if (mix1(1.0) != 103): - raise RuntimeError, ("mix1(double)") + raise RuntimeError(("mix1(double)")) # mix 2 if (mix2("hi") != 101): - raise RuntimeError, ("mix2(const char*)") + raise RuntimeError(("mix2(const char*)")) if (mix2(1.0, 1.0) != 102): - raise RuntimeError, ("mix2(double, const double &)") + raise RuntimeError(("mix2(double, const double &)")) if (mix2(1.0) != 103): - raise RuntimeError, ("mix2(double)") + raise RuntimeError(("mix2(double)")) # mix 3 if (mix3("hi") != 101): - raise RuntimeError, ("mix3(const char*)") + raise RuntimeError(("mix3(const char*)")) if (mix3(1.0, 1.0) != 102): - raise RuntimeError, ("mix3(double, const double &)") + raise RuntimeError(("mix3(double, const double &)")) if (mix3(1.0) != 103): - raise RuntimeError, ("mix3(double)") + raise RuntimeError(("mix3(double)")) # Combination 1 if (overtparams1(100) != 10): - raise RuntimeError, ("overtparams1(int)") + raise RuntimeError(("overtparams1(int)")) if (overtparams1(100.0, 100) != 20): - raise RuntimeError, ("overtparams1(double, int)") + raise RuntimeError(("overtparams1(double, int)")) # Combination 2 if (overtparams2(100.0, 100) != 40): - raise RuntimeError, ("overtparams2(double, int)") + raise RuntimeError(("overtparams2(double, int)")) # Combination 3 if (overloaded() != 60): - raise RuntimeError, ("overloaded()") + raise RuntimeError(("overloaded()")) if (overloaded(100.0, 100) != 70): - raise RuntimeError, ("overloaded(double, int)") + raise RuntimeError(("overloaded(double, int)")) # Combination 4 if (overloadedagain("hello") != 80): - raise RuntimeError, ("overloadedagain(const char *)") + raise RuntimeError(("overloadedagain(const char *)")) if (overloadedagain() != 90): - raise RuntimeError, ("overloadedagain(double)") + raise RuntimeError(("overloadedagain(double)")) # specializations if (specialization(10) != 202): - raise RuntimeError, ("specialization(int)") + raise RuntimeError(("specialization(int)")) if (specialization(10.0) != 203): - raise RuntimeError, ("specialization(double)") + raise RuntimeError(("specialization(double)")) if (specialization(10, 10) != 204): - raise RuntimeError, ("specialization(int, int)") + raise RuntimeError(("specialization(int, int)")) if (specialization(10.0, 10.0) != 205): - raise RuntimeError, ("specialization(double, double)") + raise RuntimeError(("specialization(double, double)")) if (specialization("hi", "hi") != 201): - raise RuntimeError, ("specialization(const char *, const char *)") + raise RuntimeError(("specialization(const char *, const char *)")) # simple specialization @@ -84,61 +84,61 @@ xyz_double() # a bit of everything if (overload("hi") != 0): - raise RuntimeError, ("overload()") + raise RuntimeError(("overload()")) if (overload(1) != 10): - raise RuntimeError, ("overload(int t)") + raise RuntimeError(("overload(int t)")) if (overload(1, 1) != 20): - raise RuntimeError, ("overload(int t, const int &)") + raise RuntimeError(("overload(int t, const int &)")) if (overload(1, "hello") != 30): - raise RuntimeError, ("overload(int t, const char *)") + raise RuntimeError(("overload(int t, const char *)")) k = Klass() if (overload(k) != 10): - raise RuntimeError, ("overload(Klass t)") + raise RuntimeError(("overload(Klass t)")) if (overload(k, k) != 20): - raise RuntimeError, ("overload(Klass t, const Klass &)") + raise RuntimeError(("overload(Klass t, const Klass &)")) if (overload(k, "hello") != 30): - raise RuntimeError, ("overload(Klass t, const char *)") + raise RuntimeError(("overload(Klass t, const char *)")) if (overload(10.0, "hi") != 40): - raise RuntimeError, ("overload(double t, const char *)") + raise RuntimeError(("overload(double t, const char *)")) if (overload() != 50): - raise RuntimeError, ("overload(const char *)") + raise RuntimeError(("overload(const char *)")) # everything put in a namespace if (nsoverload("hi") != 1000): - raise RuntimeError, ("nsoverload()") + raise RuntimeError(("nsoverload()")) if (nsoverload(1) != 1010): - raise RuntimeError, ("nsoverload(int t)") + raise RuntimeError(("nsoverload(int t)")) if (nsoverload(1, 1) != 1020): - raise RuntimeError, ("nsoverload(int t, const int &)") + raise RuntimeError(("nsoverload(int t, const int &)")) if (nsoverload(1, "hello") != 1030): - raise RuntimeError, ("nsoverload(int t, const char *)") + raise RuntimeError(("nsoverload(int t, const char *)")) if (nsoverload(k) != 1010): - raise RuntimeError, ("nsoverload(Klass t)") + raise RuntimeError(("nsoverload(Klass t)")) if (nsoverload(k, k) != 1020): - raise RuntimeError, ("nsoverload(Klass t, const Klass &)") + raise RuntimeError(("nsoverload(Klass t, const Klass &)")) if (nsoverload(k, "hello") != 1030): - raise RuntimeError, ("nsoverload(Klass t, const char *)") + raise RuntimeError(("nsoverload(Klass t, const char *)")) if (nsoverload(10.0, "hi") != 1040): - raise RuntimeError, ("nsoverload(double t, const char *)") + raise RuntimeError(("nsoverload(double t, const char *)")) if (nsoverload() != 1050): - raise RuntimeError, ("nsoverload(const char *)") + raise RuntimeError(("nsoverload(const char *)")) A.foo(1) diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py index 014ec71cb..a484d8f0e 100644 --- a/Examples/test-suite/python/overload_template_runme.py +++ b/Examples/test-suite/python/overload_template_runme.py @@ -6,74 +6,74 @@ b = maximum(3.4, 5.2) # mix 1 if (mix1("hi") != 101): - raise RuntimeError, ("mix1(const char*)") + raise RuntimeError(("mix1(const char*)")) if (mix1(1.0, 1.0) != 102): - raise RuntimeError, ("mix1(double, const double &)") + raise RuntimeError(("mix1(double, const double &)")) if (mix1(1.0) != 103): - raise RuntimeError, ("mix1(double)") + raise RuntimeError(("mix1(double)")) # mix 2 if (mix2("hi") != 101): - raise RuntimeError, ("mix2(const char*)") + raise RuntimeError(("mix2(const char*)")) if (mix2(1.0, 1.0) != 102): - raise RuntimeError, ("mix2(double, const double &)") + raise RuntimeError(("mix2(double, const double &)")) if (mix2(1.0) != 103): - raise RuntimeError, ("mix2(double)") + raise RuntimeError(("mix2(double)")) # mix 3 if (mix3("hi") != 101): - raise RuntimeError, ("mix3(const char*)") + raise RuntimeError(("mix3(const char*)")) if (mix3(1.0, 1.0) != 102): - raise RuntimeError, ("mix3(double, const double &)") + raise RuntimeError(("mix3(double, const double &)")) if (mix3(1.0) != 103): - raise RuntimeError, ("mix3(double)") + raise RuntimeError(("mix3(double)")) # Combination 1 if (overtparams1(100) != 10): - raise RuntimeError, ("overtparams1(int)") + raise RuntimeError(("overtparams1(int)")) if (overtparams1(100.0, 100) != 20): - raise RuntimeError, ("overtparams1(double, int)") + raise RuntimeError(("overtparams1(double, int)")) # Combination 2 if (overtparams2(100.0, 100) != 40): - raise RuntimeError, ("overtparams2(double, int)") + raise RuntimeError(("overtparams2(double, int)")) # Combination 3 if (overloaded() != 60): - raise RuntimeError, ("overloaded()") + raise RuntimeError(("overloaded()")) if (overloaded(100.0, 100) != 70): - raise RuntimeError, ("overloaded(double, int)") + raise RuntimeError(("overloaded(double, int)")) # Combination 4 if (overloadedagain("hello") != 80): - raise RuntimeError, ("overloadedagain(const char *)") + raise RuntimeError(("overloadedagain(const char *)")) if (overloadedagain() != 90): - raise RuntimeError, ("overloadedagain(double)") + raise RuntimeError(("overloadedagain(double)")) # specializations if (specialization(10) != 202): - raise RuntimeError, ("specialization(int)") + raise RuntimeError(("specialization(int)")) if (specialization(10.0) != 203): - raise RuntimeError, ("specialization(double)") + raise RuntimeError(("specialization(double)")) if (specialization(10, 10) != 204): - raise RuntimeError, ("specialization(int, int)") + raise RuntimeError(("specialization(int, int)")) if (specialization(10.0, 10.0) != 205): - raise RuntimeError, ("specialization(double, double)") + raise RuntimeError(("specialization(double, double)")) if (specialization("hi", "hi") != 201): - raise RuntimeError, ("specialization(const char *, const char *)") + raise RuntimeError(("specialization(const char *, const char *)")) # simple specialization @@ -83,61 +83,61 @@ xyz_double() # a bit of everything if (overload("hi") != 0): - raise RuntimeError, ("overload()") + raise RuntimeError(("overload()")) if (overload(1) != 10): - raise RuntimeError, ("overload(int t)") + raise RuntimeError(("overload(int t)")) if (overload(1, 1) != 20): - raise RuntimeError, ("overload(int t, const int &)") + raise RuntimeError(("overload(int t, const int &)")) if (overload(1, "hello") != 30): - raise RuntimeError, ("overload(int t, const char *)") + raise RuntimeError(("overload(int t, const char *)")) k = Klass() if (overload(k) != 10): - raise RuntimeError, ("overload(Klass t)") + raise RuntimeError(("overload(Klass t)")) if (overload(k, k) != 20): - raise RuntimeError, ("overload(Klass t, const Klass &)") + raise RuntimeError(("overload(Klass t, const Klass &)")) if (overload(k, "hello") != 30): - raise RuntimeError, ("overload(Klass t, const char *)") + raise RuntimeError(("overload(Klass t, const char *)")) if (overload(10.0, "hi") != 40): - raise RuntimeError, ("overload(double t, const char *)") + raise RuntimeError(("overload(double t, const char *)")) if (overload() != 50): - raise RuntimeError, ("overload(const char *)") + raise RuntimeError(("overload(const char *)")) # everything put in a namespace if (nsoverload("hi") != 1000): - raise RuntimeError, ("nsoverload()") + raise RuntimeError(("nsoverload()")) if (nsoverload(1) != 1010): - raise RuntimeError, ("nsoverload(int t)") + raise RuntimeError(("nsoverload(int t)")) if (nsoverload(1, 1) != 1020): - raise RuntimeError, ("nsoverload(int t, const int &)") + raise RuntimeError(("nsoverload(int t, const int &)")) if (nsoverload(1, "hello") != 1030): - raise RuntimeError, ("nsoverload(int t, const char *)") + raise RuntimeError(("nsoverload(int t, const char *)")) if (nsoverload(k) != 1010): - raise RuntimeError, ("nsoverload(Klass t)") + raise RuntimeError(("nsoverload(Klass t)")) if (nsoverload(k, k) != 1020): - raise RuntimeError, ("nsoverload(Klass t, const Klass &)") + raise RuntimeError(("nsoverload(Klass t, const Klass &)")) if (nsoverload(k, "hello") != 1030): - raise RuntimeError, ("nsoverload(Klass t, const char *)") + raise RuntimeError(("nsoverload(Klass t, const char *)")) if (nsoverload(10.0, "hi") != 1040): - raise RuntimeError, ("nsoverload(double t, const char *)") + raise RuntimeError(("nsoverload(double t, const char *)")) if (nsoverload() != 1050): - raise RuntimeError, ("nsoverload(const char *)") + raise RuntimeError(("nsoverload(const char *)")) A_foo(1) diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py index b9b47881d..f12648696 100644 --- a/Examples/test-suite/python/pointer_reference_runme.py +++ b/Examples/test-suite/python/pointer_reference_runme.py @@ -2,15 +2,15 @@ import pointer_reference s = pointer_reference.get() if s.value != 10: - raise RuntimeError, "get test failed" + raise RuntimeError("get test failed") ss = pointer_reference.Struct(20) pointer_reference.set(ss) if pointer_reference.cvar.Struct_instance.value != 20: - raise RuntimeError, "set test failed" + raise RuntimeError("set test failed") if pointer_reference.overloading(1) != 111: - raise RuntimeError, "overload test 1 failed" + raise RuntimeError("overload test 1 failed") if pointer_reference.overloading(ss) != 222: - raise RuntimeError, "overload test 2 failed" + raise RuntimeError("overload test 2 failed") diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index 729b450a6..f550fc2ab 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -172,7 +172,7 @@ p = PyTest() # internal call check if t.c_check() != p.c_check(): - raise RuntimeError, "bad director" + raise RuntimeError("bad director") p.var_bool = p.stc_bool p.var_schar = p.stc_schar @@ -247,11 +247,11 @@ if t.var_namet != "hol": cvar.var_char = "\0" if cvar.var_char != "\0": - raise RuntimeError, "bad char '0' case" + raise RuntimeError("bad char '0' case") cvar.var_char = 0 if cvar.var_char != "\0": - raise RuntimeError, "bad char '0' case" + raise RuntimeError("bad char '0' case") cvar.var_namet = "\0" # if cvar.var_namet != "\0\0\0\0\0": @@ -261,11 +261,11 @@ if cvar.var_namet != "": cvar.var_namet = "" # if cvar.var_namet != "\0\0\0\0\0": if cvar.var_namet != "": - raise RuntimeError, "bad char empty case" + raise RuntimeError("bad char empty case") cvar.var_pchar = None if cvar.var_pchar != None: - raise RuntimeError, "bad None case" + raise RuntimeError("bad None case") cvar.var_pchar = "" if cvar.var_pchar != "": @@ -273,11 +273,11 @@ if cvar.var_pchar != "": cvar.var_pcharc = None if cvar.var_pcharc != None: - raise RuntimeError, "bad None case" + raise RuntimeError("bad None case") cvar.var_pcharc = "" if cvar.var_pcharc != "": - raise RuntimeError, "bad char empty case" + raise RuntimeError("bad char empty case") # @@ -298,7 +298,7 @@ if cvar.var_pchar != "hola": cvar.var_namet = pc # if cvar.var_namet != "hola\0": if cvar.var_namet != "hola": - raise RuntimeError, "bad pointer case" + raise RuntimeError("bad pointer case") delete_pchar(pc) @@ -317,7 +317,7 @@ except OverflowError: error = 1 pass if error: - raise RuntimeError, "bad uchar typemap" + raise RuntimeError("bad uchar typemap") try: @@ -330,7 +330,7 @@ except TypeError: error = 1 pass if error: - raise RuntimeError, "bad char typemap" + raise RuntimeError("bad char typemap") try: error = 0 @@ -342,7 +342,7 @@ except OverflowError: error = 1 pass if error: - raise RuntimeError, "bad ushort typemap" + raise RuntimeError("bad ushort typemap") try: error = 0 @@ -354,7 +354,7 @@ except OverflowError: error = 1 pass if error: - raise RuntimeError, "bad uint typemap" + raise RuntimeError("bad uint typemap") try: error = 0 @@ -366,7 +366,7 @@ except OverflowError: error = 1 pass if error: - raise RuntimeError, "bad sizet typemap" + raise RuntimeError("bad sizet typemap") try: error = 0 @@ -378,7 +378,7 @@ except OverflowError: error = 1 pass if error: - raise RuntimeError, "bad ulong typemap" + raise RuntimeError("bad ulong typemap") # # @@ -392,43 +392,43 @@ except TypeError: error = 1 pass if error: - raise RuntimeError, "bad namet typemap" + raise RuntimeError("bad namet typemap") # # # t2 = p.vtest(t) if t.var_namet != t2.var_namet: - raise RuntimeError, "bad SWIGTYPE* typemap" + raise RuntimeError("bad SWIGTYPE* typemap") if cvar.fixsize != "ho\0la\0\0\0": - raise RuntimeError, "bad FIXSIZE typemap" + raise RuntimeError("bad FIXSIZE typemap") cvar.fixsize = "ho" if cvar.fixsize != "ho\0\0\0\0\0\0": - raise RuntimeError, "bad FIXSIZE typemap" + raise RuntimeError("bad FIXSIZE typemap") f = Foo(3) f1 = fptr_val(f) f2 = fptr_ref(f) if f1._a != f2._a: - raise RuntimeError, "bad const ptr& typemap" + raise RuntimeError("bad const ptr& typemap") v = char_foo(1, 3) if v != 3: - raise RuntimeError, "bad int typemap" + raise RuntimeError("bad int typemap") s = char_foo(1, "hello") if s != "hello": - raise RuntimeError, "bad char* typemap" + raise RuntimeError("bad char* typemap") v = SetPos(1, 3) if v != 4: - raise RuntimeError, "bad int typemap" + raise RuntimeError("bad int typemap") # # Check the bounds for converting various types @@ -472,8 +472,8 @@ maxllong = overllong - 1 maxullong = 2 * maxllong + 1 # Make sure Python 2's sys.maxint is the same as the maxlong we calculated -if sys.version_info[0] <= 2 and maxlong != sys.maxint: - raise RuntimeError, "sys.maxint is not the maximum value of a signed long" +if sys.version_info[0] <= 2 and maxlong != sys.maxsize: + raise RuntimeError("sys.maxint is not the maximum value of a signed long") def checkType(t, e, val, delta): """t = Test object, e = type name (e.g. ulong), val = max or min allowed value, delta = +1 for max, -1 for min""" @@ -503,7 +503,7 @@ def checkType(t, e, val, delta): except OverflowError: pass if error: - raise RuntimeError, "bad " + e + " typemap" + raise RuntimeError("bad " + e + " typemap") def checkFull(t, e, maxval, minval): """Check the maximum and minimum bounds for the type given by e""" @@ -535,17 +535,17 @@ def checkOverload(t, name, val, delta, prevval, limit): if val != prevval: # Make sure the most extreme value of this type gives the name of this type if t.ovr_str(val) != name: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") # Make sure a more extreme value doesn't give the name of this type try: if t.ovr_str(val + delta) == name: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") if val == limit: # Should raise TypeError here since this is the largest integral type - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") except TypeError: if val != limit: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") # Check that overloading works: uchar > schar > ushort > short > uint > int > ulong > long > ullong > llong checkOverload(t, "uchar", maxuchar, +1, 0, maxullong) @@ -560,22 +560,22 @@ checkOverload(t, "long", minlong, -1, minint, minllong) checkOverload(t, "llong", minllong, -1, minlong, minllong) # Make sure that large ints can be converted to doubles properly -if val_double(sys.maxint + 1) != float(sys.maxint + 1): - raise RuntimeError, "bad double typemap" -if val_double(-sys.maxint - 2) != float(-sys.maxint - 2): - raise RuntimeError, "bad double typemap" +if val_double(sys.maxsize + 1) != float(sys.maxsize + 1): + raise RuntimeError("bad double typemap") +if val_double(-sys.maxsize - 2) != float(-sys.maxsize - 2): + raise RuntimeError("bad double typemap") # Check the minimum and maximum values that fit in ptrdiff_t and size_t def checkType(name, maxfunc, maxval, minfunc, minval, echofunc): if maxfunc() != maxval: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") if minfunc() != minval: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") if echofunc(maxval) != maxval: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") if echofunc(minval) != minval: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") error = 0 try: echofunc(maxval + 1) @@ -583,14 +583,14 @@ def checkType(name, maxfunc, maxval, minfunc, minval, echofunc): except OverflowError: pass if error == 1: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") try: echofunc(minval - 1) error = 1 except OverflowError: pass if error == 1: - raise RuntimeError, "bad " + name + " typemap" + raise RuntimeError("bad " + name + " typemap") # sys.maxsize is the largest value supported by Py_ssize_t, which should be the same as ptrdiff_t if sys.version_info[0:2] >= (2, 6): diff --git a/Examples/test-suite/python/python_builtin_runme.py b/Examples/test-suite/python/python_builtin_runme.py index 26e757ca7..8a42a2607 100644 --- a/Examples/test-suite/python/python_builtin_runme.py +++ b/Examples/test-suite/python/python_builtin_runme.py @@ -32,7 +32,7 @@ if is_python_builtin(): passed = False try: h = hash(ExceptionHashFunction()) - except RuntimeError, e: + except RuntimeError as e: passed = str(e).find("oops") != -1 pass diff --git a/Examples/test-suite/python/python_overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py index d4cb8a37a..fc398ab29 100644 --- a/Examples/test-suite/python/python_overload_simple_cast_runme.py +++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py @@ -30,136 +30,136 @@ except: good = 1 if not good: - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fint(ad) != "fint:int": - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fdouble(ad) != "fdouble:double": - raise RuntimeError, "fdouble(double)" + raise RuntimeError("fdouble(double)") if fint(ai) != "fint:int": - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fint(5.0) != "fint:int": - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fint(3) != "fint:int": - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fint(3.0) != "fint:int": - raise RuntimeError, "fint(int)" + raise RuntimeError("fint(int)") if fdouble(ad) != "fdouble:double": - raise RuntimeError, "fdouble(double)" + raise RuntimeError("fdouble(double)") if fdouble(3) != "fdouble:double": - raise RuntimeError, "fdouble(double)" + raise RuntimeError("fdouble(double)") if fdouble(3.0) != "fdouble:double": - raise RuntimeError, "fdouble(double)" + raise RuntimeError("fdouble(double)") if fid(3, 3.0) != "fid:intdouble": - raise RuntimeError, "fid:intdouble" + raise RuntimeError("fid:intdouble") if fid(3.0, 3) != "fid:doubleint": - raise RuntimeError, "fid:doubleint" + raise RuntimeError("fid:doubleint") if fid(ad, ai) != "fid:doubleint": - raise RuntimeError, "fid:doubleint" + raise RuntimeError("fid:doubleint") if fid(ai, ad) != "fid:intdouble": - raise RuntimeError, "fid:intdouble" + raise RuntimeError("fid:intdouble") if foo(3) != "foo:int": - raise RuntimeError, "foo(int)" + raise RuntimeError("foo(int)") if foo(3.0) != "foo:double": - raise RuntimeError, "foo(double)" + raise RuntimeError("foo(double)") if foo("hello") != "foo:char *": - raise RuntimeError, "foo(char *)" + raise RuntimeError("foo(char *)") f = Foo() b = Bar() if foo(f) != "foo:Foo *": - raise RuntimeError, "foo(Foo *)" + raise RuntimeError("foo(Foo *)") if foo(b) != "foo:Bar *": - raise RuntimeError, "foo(Bar *)" + raise RuntimeError("foo(Bar *)") v = malloc_void(32) if foo(v) != "foo:void *": - raise RuntimeError, "foo(void *)" + raise RuntimeError("foo(void *)") s = Spam() if s.foo(3) != "foo:int": - raise RuntimeError, "Spam::foo(int)" + raise RuntimeError("Spam::foo(int)") if s.foo(3.0) != "foo:double": - raise RuntimeError, "Spam::foo(double)" + raise RuntimeError("Spam::foo(double)") if s.foo("hello") != "foo:char *": - raise RuntimeError, "Spam::foo(char *)" + raise RuntimeError("Spam::foo(char *)") if s.foo(f) != "foo:Foo *": - raise RuntimeError, "Spam::foo(Foo *)" + raise RuntimeError("Spam::foo(Foo *)") if s.foo(b) != "foo:Bar *": - raise RuntimeError, "Spam::foo(Bar *)" + raise RuntimeError("Spam::foo(Bar *)") if s.foo(v) != "foo:void *": - raise RuntimeError, "Spam::foo(void *)" + raise RuntimeError("Spam::foo(void *)") if Spam_bar(3) != "bar:int": - raise RuntimeError, "Spam::bar(int)" + raise RuntimeError("Spam::bar(int)") if Spam_bar(3.0) != "bar:double": - raise RuntimeError, "Spam::bar(double)" + raise RuntimeError("Spam::bar(double)") if Spam_bar("hello") != "bar:char *": - raise RuntimeError, "Spam::bar(char *)" + raise RuntimeError("Spam::bar(char *)") if Spam_bar(f) != "bar:Foo *": - raise RuntimeError, "Spam::bar(Foo *)" + raise RuntimeError("Spam::bar(Foo *)") if Spam_bar(b) != "bar:Bar *": - raise RuntimeError, "Spam::bar(Bar *)" + raise RuntimeError("Spam::bar(Bar *)") if Spam_bar(v) != "bar:void *": - raise RuntimeError, "Spam::bar(void *)" + raise RuntimeError("Spam::bar(void *)") # Test constructors s = Spam() if s.type != "none": - raise RuntimeError, "Spam()" + raise RuntimeError("Spam()") s = Spam(3) if s.type != "int": - raise RuntimeError, "Spam(int)" + raise RuntimeError("Spam(int)") s = Spam(3.4) if s.type != "double": - raise RuntimeError, "Spam(double)" + raise RuntimeError("Spam(double)") s = Spam("hello") if s.type != "char *": - raise RuntimeError, "Spam(char *)" + raise RuntimeError("Spam(char *)") s = Spam(f) if s.type != "Foo *": - raise RuntimeError, "Spam(Foo *)" + raise RuntimeError("Spam(Foo *)") s = Spam(b) if s.type != "Bar *": - raise RuntimeError, "Spam(Bar *)" + raise RuntimeError("Spam(Bar *)") s = Spam(v) if s.type != "void *": - raise RuntimeError, "Spam(void *)" + raise RuntimeError("Spam(void *)") # unsigned long long @@ -168,13 +168,13 @@ ullmaxd = 9007199254740992.0 ullmin = 0 ullmind = 0.0 if ull(ullmin) != ullmin: - raise RuntimeError, "ull(ullmin)" + raise RuntimeError("ull(ullmin)") if ull(ullmax) != ullmax: - raise RuntimeError, "ull(ullmax)" + raise RuntimeError("ull(ullmax)") if ull(ullmind) != ullmind: - raise RuntimeError, "ull(ullmind)" + raise RuntimeError("ull(ullmind)") if ull(ullmaxd) != ullmaxd: - raise RuntimeError, "ull(ullmaxd)" + raise RuntimeError("ull(ullmaxd)") # long long llmax = 9223372036854775807 # 0x7fffffffffffffff @@ -183,13 +183,13 @@ llmin = -9223372036854775808 llmaxd = 9007199254740992.0 llmind = -9007199254740992.0 if ll(llmin) != llmin: - raise RuntimeError, "ll(llmin)" + raise RuntimeError("ll(llmin)") if ll(llmax) != llmax: - raise RuntimeError, "ll(llmax)" + raise RuntimeError("ll(llmax)") if ll(llmind) != llmind: - raise RuntimeError, "ll(llmind)" + raise RuntimeError("ll(llmind)") if ll(llmaxd) != llmaxd: - raise RuntimeError, "ll(llmaxd)" + raise RuntimeError("ll(llmaxd)") free_void(v) diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py index 724d1d73c..988a3f91f 100644 --- a/Examples/test-suite/python/python_richcompare_runme.py +++ b/Examples/test-suite/python/python_richcompare_runme.py @@ -114,22 +114,22 @@ else: try: res = base1 < 42 raise RuntimeError("Failed to throw") - except TypeError,e: + except TypeError as e: check_unorderable_types(e) try: res = base1 <= 42 raise RuntimeError("Failed to throw") - except TypeError,e: + except TypeError as e: check_unorderable_types(e) try: res = base1 > 42 raise RuntimeError("Failed to throw") - except TypeError,e: + except TypeError as e: check_unorderable_types(e) try: res = base1 >= 42 raise RuntimeError("Failed to throw") - except TypeError,e: + except TypeError as e: check_unorderable_types(e) # Check inequalities used for ordering diff --git a/Examples/test-suite/python/std_containers_runme.py b/Examples/test-suite/python/std_containers_runme.py index 51bd2a7b8..820c8f454 100644 --- a/Examples/test-suite/python/std_containers_runme.py +++ b/Examples/test-suite/python/std_containers_runme.py @@ -7,29 +7,29 @@ cube = (((1, 2), (3, 4)), ((5, 6), (7, 8))) icube = std_containers.cident(cube) for i in range(0, len(cube)): if cube[i] != icube[i]: - raise RuntimeError, "bad cident" + raise RuntimeError("bad cident") p = (1, 2) if p != std_containers.pident(p): - raise RuntimeError, "bad pident" + raise RuntimeError("bad pident") v = (1, 2, 3, 4, 5, 6) iv = std_containers.vident(v) for i in range(0, len(v)): if v[i] != iv[i]: - raise RuntimeError, "bad vident" + raise RuntimeError("bad vident") iv = std_containers.videntu(v) for i in range(0, len(v)): if v[i] != iv[i]: - raise RuntimeError, "bad videntu" + raise RuntimeError("bad videntu") vu = std_containers.vector_ui(v) if vu[2] != std_containers.videntu(vu)[2]: - raise RuntimeError, "bad videntu" + raise RuntimeError("bad videntu") if v[0:3][1] != vu[0:3][1]: @@ -42,20 +42,20 @@ im = std_containers.midenti(m) for i in range(0, len(m)): for j in range(0, len(m[i])): if m[i][j] != im[i][j]: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") m = ((True, False, True), (True, True), (True, True)) im = std_containers.midentb(m) for i in range(0, len(m)): for j in range(0, len(m[i])): if m[i][j] != im[i][j]: - raise RuntimeError, "bad getslice" + raise RuntimeError("bad getslice") mi = std_containers.imatrix(m) mc = std_containers.cmatrix(m) if mi[0][1] != mc[0][1]: - raise RuntimeError, "bad matrix" + raise RuntimeError("bad matrix") map = {} @@ -66,7 +66,7 @@ map["3"] = 2 imap = std_containers.mapident(map) for k in map: if map[k] != imap[k]: - raise RuntimeError, "bad map" + raise RuntimeError("bad map") # Test __contains__ (required for 'x in y' to work) if not imap.__contains__("hello"): diff --git a/Examples/test-suite/python/struct_value_runme.py b/Examples/test-suite/python/struct_value_runme.py index aa3ece38c..9fe5c815c 100644 --- a/Examples/test-suite/python/struct_value_runme.py +++ b/Examples/test-suite/python/struct_value_runme.py @@ -17,7 +17,7 @@ b.added = 123 if b.added != 123: raise RuntimeError("Wrong attribute value") -if not b.__dict__.has_key("added"): +if "added" not in b.__dict__: raise RuntimeError("Missing added attribute in __dict__") @@ -28,7 +28,7 @@ class PyBar(struct_value.Bar): struct_value.Bar.__init__(self) pybar = PyBar() -if not pybar.__dict__.has_key("extra"): +if "extra" not in pybar.__dict__: raise RuntimeError("Missing extra attribute in __dict__") if pybar.extra != "hi": raise RuntimeError("Incorrect attribute value for extra") diff --git a/Examples/test-suite/python/template_classes_runme.py b/Examples/test-suite/python/template_classes_runme.py index 38b2d7a62..1bd133975 100644 --- a/Examples/test-suite/python/template_classes_runme.py +++ b/Examples/test-suite/python/template_classes_runme.py @@ -13,7 +13,7 @@ RectangleInt.static_onearg(1) fail = True try: rectangle.setPoint() -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") @@ -22,7 +22,7 @@ if fail: fail = True try: rectangle.getPoint(0) -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") @@ -30,7 +30,7 @@ if fail: fail = True try: RectangleInt.static_noargs(0) -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") @@ -38,7 +38,7 @@ if fail: fail = True try: RectangleInt.static_onearg() -except TypeError, e: +except TypeError as e: fail = False if fail: raise RuntimeError("argument count check failed") diff --git a/Examples/test-suite/python/template_default_arg_runme.py b/Examples/test-suite/python/template_default_arg_runme.py index 91b1e0e8c..e9ef00f99 100644 --- a/Examples/test-suite/python/template_default_arg_runme.py +++ b/Examples/test-suite/python/template_default_arg_runme.py @@ -7,25 +7,25 @@ helloInt.foo(template_default_arg.Hello_int.hi) x = template_default_arg.X_int() if (x.meth(20.0, 200) != 200): - raise RuntimeError, ("X_int test 1 failed") + raise RuntimeError(("X_int test 1 failed")) if (x.meth(20) != 20): - raise RuntimeError, ("X_int test 2 failed") + raise RuntimeError(("X_int test 2 failed")) if (x.meth() != 0): - raise RuntimeError, ("X_int test 3 failed") + raise RuntimeError(("X_int test 3 failed")) y = template_default_arg.Y_unsigned() if (y.meth(20.0, 200) != 200): - raise RuntimeError, ("Y_unsigned test 1 failed") + raise RuntimeError(("Y_unsigned test 1 failed")) if (y.meth(20) != 20): - raise RuntimeError, ("Y_unsigned test 2 failed") + raise RuntimeError(("Y_unsigned test 2 failed")) if (y.meth() != 0): - raise RuntimeError, ("Y_unsigned test 3 failed") + raise RuntimeError(("Y_unsigned test 3 failed")) x = template_default_arg.X_longlong() x = template_default_arg.X_longlong(20.0) -x = template_default_arg.X_longlong(20.0, 200L) +x = template_default_arg.X_longlong(20.0, 200) x = template_default_arg.X_int() @@ -54,40 +54,40 @@ fzc = x.meth(fz) # plain function: int ott(Foo) if (template_default_arg.ott(template_default_arg.Foo_int()) != 30): - raise RuntimeError, ("ott test 1 failed") + raise RuntimeError(("ott test 1 failed")) # %template(ott) ott if (template_default_arg.ott() != 10): - raise RuntimeError, ("ott test 2 failed") + raise RuntimeError(("ott test 2 failed")) if (template_default_arg.ott(1) != 10): - raise RuntimeError, ("ott test 3 failed") + raise RuntimeError(("ott test 3 failed")) if (template_default_arg.ott(1, 1) != 10): - raise RuntimeError, ("ott test 4 failed") + raise RuntimeError(("ott test 4 failed")) if (template_default_arg.ott("hi") != 20): - raise RuntimeError, ("ott test 5 failed") + raise RuntimeError(("ott test 5 failed")) if (template_default_arg.ott("hi", 1) != 20): - raise RuntimeError, ("ott test 6 failed") + raise RuntimeError(("ott test 6 failed")) if (template_default_arg.ott("hi", 1, 1) != 20): - raise RuntimeError, ("ott test 7 failed") + raise RuntimeError(("ott test 7 failed")) # %template(ott) ott if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40): - raise RuntimeError, ("ott test 8 failed") + raise RuntimeError(("ott test 8 failed")) if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40): - raise RuntimeError, ("ott test 9 failed") + raise RuntimeError(("ott test 9 failed")) # %template(ott) ott if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50): - raise RuntimeError, ("ott test 10 failed") + raise RuntimeError(("ott test 10 failed")) if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50): - raise RuntimeError, ("ott test 11 failed") + raise RuntimeError(("ott test 11 failed")) # %template(ott) ott if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60): - raise RuntimeError, ("ott test 12 failed") + raise RuntimeError(("ott test 12 failed")) if (template_default_arg.ott(template_default_arg.Hello_int()) != 60): - raise RuntimeError, ("ott test 13 failed") + raise RuntimeError(("ott test 13 failed")) diff --git a/Examples/test-suite/python/template_typemaps_typedef2_runme.py b/Examples/test-suite/python/template_typemaps_typedef2_runme.py index 2b8bd5631..da26a9f76 100644 --- a/Examples/test-suite/python/template_typemaps_typedef2_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef2_runme.py @@ -5,7 +5,7 @@ m1 = MultimapIntA() dummy_pair = m1.make_dummy_pair() val = m1.typemap_test(dummy_pair).val if val != 1234: - raise RuntimeError, "typemaps not working" + raise RuntimeError("typemaps not working") m2 = MultimapAInt() @@ -18,19 +18,19 @@ m2 = MultimapAInt() # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test1 not working" + raise RuntimeError("typedef_test1 not working") if typedef_test2(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test2 not working" + raise RuntimeError("typedef_test2 not working") if typedef_test3(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test3 not working" + raise RuntimeError("typedef_test3 not working") if typedef_test4(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test4 not working" + raise RuntimeError("typedef_test4 not working") if typedef_test5(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test5 not working" + raise RuntimeError("typedef_test5 not working") if typedef_test6(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test6 not working" + raise RuntimeError("typedef_test6 not working") diff --git a/Examples/test-suite/python/template_typemaps_typedef_runme.py b/Examples/test-suite/python/template_typemaps_typedef_runme.py index d84be64ff..a5209b71f 100644 --- a/Examples/test-suite/python/template_typemaps_typedef_runme.py +++ b/Examples/test-suite/python/template_typemaps_typedef_runme.py @@ -5,7 +5,7 @@ m1 = MultimapIntA() dummy_pair = m1.make_dummy_pair() val = m1.typemap_test(dummy_pair).val if val != 1234: - raise RuntimeError, "typemaps not working" + raise RuntimeError("typemaps not working") m2 = MultimapAInt() @@ -18,19 +18,19 @@ m2 = MultimapAInt() # raise RuntimeError, "typemaps not working" if typedef_test1(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test1 not working" + raise RuntimeError("typedef_test1 not working") if typedef_test2(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test2 not working" + raise RuntimeError("typedef_test2 not working") if typedef_test3(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test3 not working" + raise RuntimeError("typedef_test3 not working") if typedef_test4(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test4 not working" + raise RuntimeError("typedef_test4 not working") if typedef_test5(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test5 not working" + raise RuntimeError("typedef_test5 not working") if typedef_test6(dummy_pair).val != 1234: - raise RuntimeError, "typedef_test6 not working" + raise RuntimeError("typedef_test6 not working") diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py index 056bd849b..e3f6299e7 100644 --- a/Examples/test-suite/python/threads_exception_runme.py +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -3,18 +3,18 @@ import threads_exception t = threads_exception.Test() try: t.unknown() -except RuntimeError, e: +except RuntimeError as e: pass try: t.simple() -except RuntimeError, e: +except RuntimeError as e: if e.args[0] != 37: raise RuntimeError try: t.message() -except RuntimeError, e: +except RuntimeError as e: if e.args[0] != "I died.": raise RuntimeError @@ -23,18 +23,18 @@ except RuntimeError, e: if not threads_exception.is_python_builtin(): try: t.hosed() - except threads_exception.Exc, e: + except threads_exception.Exc as e: code = e.code if code != 42: - raise RuntimeError, "bad... code: %d" % code + raise RuntimeError("bad... code: %d" % code) msg = e.msg if msg != "Hosed": - raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg)) + raise RuntimeError("bad... msg: '%s' len: %d" % (msg, len(msg))) for i in range(1, 4): try: t.multi(i) - except RuntimeError, e: + except RuntimeError as e: pass - except threads_exception.Exc, e: + except threads_exception.Exc as e: pass diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py index ea0f08d6b..7bc45f908 100644 --- a/Examples/test-suite/python/typemap_arrays_runme.py +++ b/Examples/test-suite/python/typemap_arrays_runme.py @@ -1,4 +1,4 @@ from typemap_arrays import * if sumA(None) != 60: - raise RuntimeError, "Sum is wrong" + raise RuntimeError("Sum is wrong") diff --git a/Examples/test-suite/python/typename_runme.py b/Examples/test-suite/python/typename_runme.py index aac936fde..a4f76fc36 100644 --- a/Examples/test-suite/python/typename_runme.py +++ b/Examples/test-suite/python/typename_runme.py @@ -4,8 +4,8 @@ f = typename.Foo() b = typename.Bar() x = typename.twoFoo(f) -if not isinstance(x, types.FloatType): - raise RuntimeError, "Wrong return type (FloatType) !" +if not isinstance(x, float): + raise RuntimeError("Wrong return type (FloatType) !") y = typename.twoBar(b) -if not isinstance(y, types.IntType): - raise RuntimeError, "Wrong return type (IntType)!" +if not isinstance(y, int): + raise RuntimeError("Wrong return type (IntType)!") diff --git a/Examples/test-suite/python/using_composition_runme.py b/Examples/test-suite/python/using_composition_runme.py index c4f339095..67f72bc2f 100644 --- a/Examples/test-suite/python/using_composition_runme.py +++ b/Examples/test-suite/python/using_composition_runme.py @@ -2,32 +2,32 @@ from using_composition import * f = FooBar() if f.blah(3) != 3: - raise RuntimeError, "FooBar::blah(int)" + raise RuntimeError("FooBar::blah(int)") if f.blah(3.5) != 3.5: - raise RuntimeError, "FooBar::blah(double)" + raise RuntimeError("FooBar::blah(double)") if f.blah("hello") != "hello": - raise RuntimeError, "FooBar::blah(char *)" + raise RuntimeError("FooBar::blah(char *)") f = FooBar2() if f.blah(3) != 3: - raise RuntimeError, "FooBar2::blah(int)" + raise RuntimeError("FooBar2::blah(int)") if f.blah(3.5) != 3.5: - raise RuntimeError, "FooBar2::blah(double)" + raise RuntimeError("FooBar2::blah(double)") if f.blah("hello") != "hello": - raise RuntimeError, "FooBar2::blah(char *)" + raise RuntimeError("FooBar2::blah(char *)") f = FooBar3() if f.blah(3) != 3: - raise RuntimeError, "FooBar3::blah(int)" + raise RuntimeError("FooBar3::blah(int)") if f.blah(3.5) != 3.5: - raise RuntimeError, "FooBar3::blah(double)" + raise RuntimeError("FooBar3::blah(double)") if f.blah("hello") != "hello": - raise RuntimeError, "FooBar3::blah(char *)" + raise RuntimeError("FooBar3::blah(char *)") diff --git a/Examples/test-suite/python/using_extend_runme.py b/Examples/test-suite/python/using_extend_runme.py index 038a1686a..7e0912926 100644 --- a/Examples/test-suite/python/using_extend_runme.py +++ b/Examples/test-suite/python/using_extend_runme.py @@ -2,20 +2,20 @@ from using_extend import * f = FooBar() if f.blah(3) != 3: - raise RuntimeError, "blah(int)" + raise RuntimeError("blah(int)") if f.blah(3.5) != 3.5: - raise RuntimeError, "blah(double)" + raise RuntimeError("blah(double)") if f.blah("hello") != "hello": - raise RuntimeError, "blah(char *)" + raise RuntimeError("blah(char *)") if f.blah(3, 4) != 7: - raise RuntimeError, "blah(int,int)" + raise RuntimeError("blah(int,int)") if f.blah(3.5, 7.5) != (3.5 + 7.5): - raise RuntimeError, "blah(double,double)" + raise RuntimeError("blah(double,double)") if f.duh(3) != 3: - raise RuntimeError, "duh(int)" + raise RuntimeError("duh(int)") diff --git a/Examples/test-suite/python/using_inherit_runme.py b/Examples/test-suite/python/using_inherit_runme.py index 4fd595968..ccdeece8d 100644 --- a/Examples/test-suite/python/using_inherit_runme.py +++ b/Examples/test-suite/python/using_inherit_runme.py @@ -2,47 +2,47 @@ from using_inherit import * b = Bar() if b.test(3) != 3: - raise RuntimeError, "Bar::test(int)" + raise RuntimeError("Bar::test(int)") if b.test(3.5) != 3.5: - raise RuntimeError, "Bar::test(double)" + raise RuntimeError("Bar::test(double)") b = Bar2() if b.test(3) != 6: - raise RuntimeError, "Bar2::test(int)" + raise RuntimeError("Bar2::test(int)") if b.test(3.5) != 7.0: - raise RuntimeError, "Bar2::test(double)" + raise RuntimeError("Bar2::test(double)") b = Bar3() if b.test(3) != 6: - raise RuntimeError, "Bar3::test(int)" + raise RuntimeError("Bar3::test(int)") if b.test(3.5) != 7.0: - raise RuntimeError, "Bar3::test(double)" + raise RuntimeError("Bar3::test(double)") b = Bar4() if b.test(3) != 6: - raise RuntimeError, "Bar4::test(int)" + raise RuntimeError("Bar4::test(int)") if b.test(3.5) != 7.0: - raise RuntimeError, "Bar4::test(double)" + raise RuntimeError("Bar4::test(double)") b = Fred1() if b.test(3) != 3: - raise RuntimeError, "Fred1::test(int)" + raise RuntimeError("Fred1::test(int)") if b.test(3.5) != 7.0: - raise RuntimeError, "Fred1::test(double)" + raise RuntimeError("Fred1::test(double)") b = Fred2() if b.test(3) != 3: - raise RuntimeError, "Fred2::test(int)" + raise RuntimeError("Fred2::test(int)") if b.test(3.5) != 7.0: - raise RuntimeError, "Fred2::test(double)" + raise RuntimeError("Fred2::test(double)") diff --git a/Examples/test-suite/python/using_private_runme.py b/Examples/test-suite/python/using_private_runme.py index 00c9a8d25..9e0a15f12 100644 --- a/Examples/test-suite/python/using_private_runme.py +++ b/Examples/test-suite/python/using_private_runme.py @@ -4,10 +4,10 @@ f = FooBar() f.x = 3 if f.blah(4) != 4: - raise RuntimeError, "blah(int)" + raise RuntimeError("blah(int)") if f.defaulted() != -1: - raise RuntimeError, "defaulted()" + raise RuntimeError("defaulted()") if f.defaulted(222) != 222: - raise RuntimeError, "defaulted(222)" + raise RuntimeError("defaulted(222)") diff --git a/Examples/test-suite/python/using_protected_runme.py b/Examples/test-suite/python/using_protected_runme.py index 525a1cde4..dd477237e 100644 --- a/Examples/test-suite/python/using_protected_runme.py +++ b/Examples/test-suite/python/using_protected_runme.py @@ -4,4 +4,4 @@ f = FooBar() f.x = 3 if f.blah(4) != 4: - raise RuntimeError, "blah(int)" + raise RuntimeError("blah(int)") diff --git a/Examples/test-suite/python/varargs_overload_runme.py b/Examples/test-suite/python/varargs_overload_runme.py index 6f5a70222..ffa763450 100644 --- a/Examples/test-suite/python/varargs_overload_runme.py +++ b/Examples/test-suite/python/varargs_overload_runme.py @@ -1,62 +1,62 @@ import varargs_overload if varargs_overload.vararg_over1("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over1(2) != "2": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over2("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over2(2, 2.2) != "2 2.2": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over3("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over3(2, 2.2, "hey") != "2 2.2 hey": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over4("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over4(123) != "123": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over4("Hello", 123) != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") # Same as above but non-vararg function declared first if varargs_overload.vararg_over6("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over6(2) != "2": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over7("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over7(2, 2.2) != "2 2.2": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over8("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over8(2, 2.2, "hey") != "2 2.2 hey": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over9("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over9(123) != "123": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs_overload.vararg_over9("Hello", 123) != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") diff --git a/Examples/test-suite/python/varargs_runme.py b/Examples/test-suite/python/varargs_runme.py index 277ea757a..8f90d5cde 100644 --- a/Examples/test-suite/python/varargs_runme.py +++ b/Examples/test-suite/python/varargs_runme.py @@ -1,31 +1,31 @@ import varargs if varargs.test("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") f = varargs.Foo("Greetings") if f.str != "Greetings": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if f.test("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs.test_def("Hello", 1) != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs.test_def("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") ### if varargs.test_plenty("Hello") != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs.test_plenty("Hello", 1) != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") if varargs.test_plenty("Hello", 1, 2) != "Hello": - raise RuntimeError, "Failed" + raise RuntimeError("Failed") try: varargs.test_plenty("Hello", 1, 2, 3) diff --git a/Examples/test-suite/python/virtual_derivation_runme.py b/Examples/test-suite/python/virtual_derivation_runme.py index 68546c6eb..21014bd02 100644 --- a/Examples/test-suite/python/virtual_derivation_runme.py +++ b/Examples/test-suite/python/virtual_derivation_runme.py @@ -4,4 +4,4 @@ from virtual_derivation import * # b = B(3) if b.get_a() != b.get_b(): - raise RuntimeError, "something is really wrong" + raise RuntimeError("something is really wrong") From 2af35cb4ff80f352aa2f8f2b02bfd31000db4188 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 12:20:23 +0100 Subject: [PATCH 1941/2031] Remove python3 specific runme3.py test files This file can be run using Python 2, the test is just ignored --- ...python_abstractbase_runme3.py => python_abstractbase_runme.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Examples/test-suite/python/{python_abstractbase_runme3.py => python_abstractbase_runme.py} (100%) diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme.py similarity index 100% rename from Examples/test-suite/python/python_abstractbase_runme3.py rename to Examples/test-suite/python/python_abstractbase_runme.py From bc7a06758728608bb75f3334a9734ed52e938646 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 12:26:21 +0100 Subject: [PATCH 1942/2031] Remove Examples/contract This set of examples was never tested/documented There is an equivalent testcase in Examples/test-suite/contract.i --- Examples/contract/simple_c/example.c | 11 ----- Examples/contract/simple_c/example.i | 19 -------- Examples/contract/simple_c/runme1.py | 17 ------- Examples/contract/simple_c/runme2.py | 20 --------- Examples/contract/simple_cxx/example.cxx | 30 ------------- Examples/contract/simple_cxx/example.h | 34 -------------- Examples/contract/simple_cxx/example.i | 28 ------------ Examples/contract/simple_cxx/runme1.py | 33 -------------- Examples/contract/simple_cxx/runme2.py | 44 ------------------ Examples/contract/simple_cxx/runme3.py | 57 ------------------------ 10 files changed, 293 deletions(-) delete mode 100644 Examples/contract/simple_c/example.c delete mode 100644 Examples/contract/simple_c/example.i delete mode 100644 Examples/contract/simple_c/runme1.py delete mode 100644 Examples/contract/simple_c/runme2.py delete mode 100644 Examples/contract/simple_cxx/example.cxx delete mode 100644 Examples/contract/simple_cxx/example.h delete mode 100644 Examples/contract/simple_cxx/example.i delete mode 100644 Examples/contract/simple_cxx/runme1.py delete mode 100644 Examples/contract/simple_cxx/runme2.py delete mode 100644 Examples/contract/simple_cxx/runme3.py diff --git a/Examples/contract/simple_c/example.c b/Examples/contract/simple_c/example.c deleted file mode 100644 index 85a3e1417..000000000 --- a/Examples/contract/simple_c/example.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -int Circle (int x, int y, int radius) { - /* Draw Circle */ - printf("Drawing the circle...\n"); - /* Return -1 to test contract post assertion */ - if (radius == 2) - return -1; - else - return 1; -} diff --git a/Examples/contract/simple_c/example.i b/Examples/contract/simple_c/example.i deleted file mode 100644 index 49df09af6..000000000 --- a/Examples/contract/simple_c/example.i +++ /dev/null @@ -1,19 +0,0 @@ -/* File : example.i */ - -/* Basic C example for swig contract */ -/* Tiger, University of Chicago, 2003 */ - -%module example - -%contract Circle (int x, int y, int radius) { -require: - x >= 0; - y >= 0; - radius > x; -ensure: - Circle >= 0; -} - -%inline %{ -extern int Circle (int x, int y, int radius); -%} diff --git a/Examples/contract/simple_c/runme1.py b/Examples/contract/simple_c/runme1.py deleted file mode 100644 index abd8df62f..000000000 --- a/Examples/contract/simple_c/runme1.py +++ /dev/null @@ -1,17 +0,0 @@ -import example -# Call the Circle() function correctly - -x = 1; -y = 1; -r = 3; - -c = example.Circle(x, y, r) - -# test post-assertion -x = 1; -y = 1; -r = 2; - -c = example.Circle(x, y, r) - -print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) diff --git a/Examples/contract/simple_c/runme2.py b/Examples/contract/simple_c/runme2.py deleted file mode 100644 index 48d4a3f10..000000000 --- a/Examples/contract/simple_c/runme2.py +++ /dev/null @@ -1,20 +0,0 @@ -import example - -# Call the Circle() function correctly - -x = 1; -y = 1; -r = 3; - -c = example.Circle(x, y, r) - -print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) - -# test pre-assertion -x = 1; -y = -1; -r = 3; - -c = example.Circle(x, y, r) - -print "The return value of Circle(%d, %d, %d) is %d" % (x,y,r,c) diff --git a/Examples/contract/simple_cxx/example.cxx b/Examples/contract/simple_cxx/example.cxx deleted file mode 100644 index e3dd2ca7a..000000000 --- a/Examples/contract/simple_cxx/example.cxx +++ /dev/null @@ -1,30 +0,0 @@ -#include "example.h" - -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area(void) { - /* return -1 is to test post-assertion */ - if (radius == 1) - return -1; - return M_PI*radius*radius; -} - -double Circle::perimeter(void) { - return 2*M_PI*radius; -} - -double Square::area(void) { - return width*width; -} - -double Square::perimeter(void) { - return 4*width; -} diff --git a/Examples/contract/simple_cxx/example.h b/Examples/contract/simple_cxx/example.h deleted file mode 100644 index de708bb7b..000000000 --- a/Examples/contract/simple_cxx/example.h +++ /dev/null @@ -1,34 +0,0 @@ -/* File : example.h */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area(void) = 0; - virtual double perimeter(void) = 0; - static int nshapes; -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - virtual double area(void); - virtual double perimeter(void); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - virtual double area(void); - virtual double perimeter(void); -}; diff --git a/Examples/contract/simple_cxx/example.i b/Examples/contract/simple_cxx/example.i deleted file mode 100644 index 9b47409d0..000000000 --- a/Examples/contract/simple_cxx/example.i +++ /dev/null @@ -1,28 +0,0 @@ -%module example - -%contract Circle::Circle(double radius) { -require: - radius > 0; -} - -%contract Circle::area(void) { -ensure: - area > 0; -} - -%contract Shape::move(double dx, double dy) { -require: - dx > 0; -} - -/* should be no effect, since there is no move() for class Circle */ -%contract Circle::move(double dx, double dy) { -require: - dy > 1; -} - -# include must be after contracts -%{ -#include "example.h" -%} -%include "example.h" diff --git a/Examples/contract/simple_cxx/runme1.py b/Examples/contract/simple_cxx/runme1.py deleted file mode 100644 index 9028d02d9..000000000 --- a/Examples/contract/simple_cxx/runme1.py +++ /dev/null @@ -1,33 +0,0 @@ -import example - -# Create the Circle object - -r = 2; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) - -# Set the location of the object - -c.x = 20 -c.y = 30 -print " Here is its current position:" -print " Circle = (%f, %f)" % (c.x,c.y) - -# ----- Call some methods ----- - -print "\n Here are some properties of the Circle:" -print " area = ", c.area() -print " perimeter = ", c.perimeter() -dx = 1; -dy = 1; -print " Moving with (%d, %d)..." % (dx, dy) -c.move(dx, dy) - -del c - -print "===================================" - -# test construction */ -r = -1; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) diff --git a/Examples/contract/simple_cxx/runme2.py b/Examples/contract/simple_cxx/runme2.py deleted file mode 100644 index 5f9c0df5b..000000000 --- a/Examples/contract/simple_cxx/runme2.py +++ /dev/null @@ -1,44 +0,0 @@ -import example - -# Create the Circle object - -r = 2; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) - -# Set the location of the object - -c.x = 20 -c.y = 30 -print " Here is its current position:" -print " Circle = (%f, %f)" % (c.x,c.y) - -# ----- Call some methods ----- - -print "\n Here are some properties of the Circle:" -print " area = ", c.area() -print " perimeter = ", c.perimeter() -dx = 1; -dy = 1; -print " Moving with (%d, %d)..." % (dx, dy) -c.move(dx, dy) - -del c - -print "===================================" - -# test area function */ -r = 1; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) -# Set the location of the object - -c.x = 20 -c.y = 30 -print " Here is its current position:" -print " Circle = (%f, %f)" % (c.x,c.y) - -# ----- Call some methods ----- - -print "\n Here are some properties of the Circle:" -print " area = ", c.area() diff --git a/Examples/contract/simple_cxx/runme3.py b/Examples/contract/simple_cxx/runme3.py deleted file mode 100644 index a663732b1..000000000 --- a/Examples/contract/simple_cxx/runme3.py +++ /dev/null @@ -1,57 +0,0 @@ -import example - -# Create the Circle object - -r = 2; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) - -# Set the location of the object - -c.x = 20 -c.y = 30 -print " Here is its current position:" -print " Circle = (%f, %f)" % (c.x,c.y) - -# ----- Call some methods ----- - -print "\n Here are some properties of the Circle:" -print " area = ", c.area() -print " perimeter = ", c.perimeter() -dx = 1; -dy = 1; -print " Moving with (%d, %d)..." % (dx, dy) -c.move(dx, dy) - -del c - -print "===================================" - -# test move function */ -r = 2; -print " Creating circle (radium: %d) :" % r -c = example.Circle(r) -# Set the location of the object - -c.x = 20 -c.y = 30 -print " Here is its current position:" -print " Circle = (%f, %f)" % (c.x,c.y) - -# ----- Call some methods ----- - -print "\n Here are some properties of the Circle:" -print " area = ", c.area() -print " perimeter = ", c.perimeter() - -# no error for Circle's pre-assertion -dx = 1; -dy = -1; -print " Moving with (%d, %d)..." % (dx, dy) -c.move(dx, dy) - -# error with Shape's pre-assertion -dx = -1; -dy = 1; -print " Moving with (%d, %d)..." % (dx, dy) -c.move(dx, dy) From 89bee6a7fa2236da8f10bf200abdc4892d4085b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 16:46:01 +0100 Subject: [PATCH 1943/2031] Modify examples to be both Python 2 and 3 compatible For removing dependency on 2to3 --- Examples/python/callback/runme.py | 22 +++--- Examples/python/class/runme.py | 28 +++---- Examples/python/constants/runme.py | 28 +++---- Examples/python/contract/runme.py | 6 +- Examples/python/docstrings/runme.py | 2 +- Examples/python/doxygen/runme.py | 20 ++--- Examples/python/enum/runme.py | 20 ++--- Examples/python/exception/runme.py | 28 +++---- Examples/python/exceptproxy/runme.py | 28 +++---- Examples/python/extend/runme.py | 24 +++--- Examples/python/funcptr/runme.py | 20 ++--- Examples/python/funcptr2/runme.py | 26 +++---- Examples/python/functor/runme.py | 4 +- Examples/python/import/runme.py | 78 ++++++++----------- .../import_packages/from_init1/runme.py | 10 +-- .../import_packages/from_init2/runme.py | 10 +-- .../import_packages/from_init3/runme.py | 10 +-- .../import_packages/module_is_init/runme.py | 8 +- .../import_packages/namespace_pkg/runme.py | 6 +- .../import_packages/relativeimport1/runme.py | 10 +-- .../import_packages/relativeimport2/runme.py | 10 +-- .../import_packages/relativeimport3/runme.py | 10 +-- .../import_packages/same_modnames1/runme.py | 8 +- .../import_packages/same_modnames2/runme.py | 8 +- .../split_modules/vanilla/runme.py | 6 +- .../split_modules/vanilla_split/runme.py | 6 +- Examples/python/import_template/runme.py | 78 ++++++++----------- Examples/python/multimap/runme.py | 6 +- Examples/python/operator/runme.py | 14 ++-- Examples/python/pointer/runme.py | 18 ++--- Examples/python/reference/runme.py | 24 +++--- Examples/python/simple/runme.py | 6 +- Examples/python/smartptr/runme.py | 28 +++---- Examples/python/std_map/runme.py | 68 ++++++++-------- Examples/python/std_vector/runme.py | 12 ++- Examples/python/template/runme.py | 8 +- Examples/python/variables/runme.py | 58 +++++++------- 37 files changed, 368 insertions(+), 388 deletions(-) diff --git a/Examples/python/callback/runme.py b/Examples/python/callback/runme.py index 345a3eb6e..41deb8386 100644 --- a/Examples/python/callback/runme.py +++ b/Examples/python/callback/runme.py @@ -11,7 +11,7 @@ class PyCallback(example.Callback): example.Callback.__init__(self) def run(self): - print "PyCallback.run()" + print("PyCallback.run()") # Create an Caller instance @@ -20,8 +20,8 @@ caller = example.Caller() # Add a simple C++ callback (caller owns the callback, so # we disown it first by clearing the .thisown flag). -print "Adding and calling a normal C++ callback" -print "----------------------------------------" +print("Adding and calling a normal C++ callback") +print("----------------------------------------") callback = example.Callback() callback.thisown = 0 @@ -29,9 +29,9 @@ caller.setCallback(callback) caller.call() caller.delCallback() -print -print "Adding and calling a Python callback" -print "------------------------------------" +print("") +print("Adding and calling a Python callback") +print("------------------------------------") # Add a Python callback (caller owns the callback, so we # disown it first by calling __disown__). @@ -40,9 +40,9 @@ caller.setCallback(PyCallback().__disown__()) caller.call() caller.delCallback() -print -print "Adding and calling another Python callback" -print "------------------------------------------" +print("") +print("Adding and calling another Python callback") +print("------------------------------------------") # Let's do the same but use the weak reference this time. @@ -53,5 +53,5 @@ caller.delCallback() # All done. -print -print "python exit" +print("") +print("python exit") diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py index 34d21505c..adade7468 100644 --- a/Examples/python/class/runme.py +++ b/Examples/python/class/runme.py @@ -7,15 +7,15 @@ import example # ----- Object creation ----- -print "Creating some objects:" +print("Creating some objects:") c = example.Circle(10) -print " Created circle", c +print(" Created circle %s" % c) s = example.Square(10) -print " Created square", s +print(" Created square %s" % s) # ----- Access a static member ----- -print "\nA total of", example.cvar.Shape_nshapes, "shapes were created" +print("\nA total of %d shapes were created" % example.cvar.Shape_nshapes) # ----- Member data access ----- @@ -27,25 +27,25 @@ c.y = 30 s.x = -10 s.y = 5 -print "\nHere is their current position:" -print " Circle = (%f, %f)" % (c.x, c.y) -print " Square = (%f, %f)" % (s.x, s.y) +print("\nHere is their current position:") +print(" Circle = (%f, %f)" % (c.x, c.y)) +print(" Square = (%f, %f)" % (s.x, s.y)) # ----- Call some methods ----- -print "\nHere are some properties of the shapes:" +print("\nHere are some properties of the shapes:") for o in [c, s]: - print " ", o - print " area = ", o.area() - print " perimeter = ", o.perimeter() + print(" %s" % o) + print(" area = %s" % o.area()) + print(" perimeter = %s" % o.perimeter()) # prevent o from holding a reference to the last object looked at o = None -print "\nGuess I'll clean up now" +print("\nGuess I'll clean up now") # Note: this invokes the virtual destructor del c del s -print example.cvar.Shape_nshapes, "shapes remain" -print "Goodbye" +print("%d shapes remain" % example.cvar.Shape_nshapes) +print("Goodbye") diff --git a/Examples/python/constants/runme.py b/Examples/python/constants/runme.py index 415d1adc4..808bf1fe6 100644 --- a/Examples/python/constants/runme.py +++ b/Examples/python/constants/runme.py @@ -2,22 +2,24 @@ import example -print "ICONST =", example.ICONST, "(should be 42)" -print "FCONST =", example.FCONST, "(should be 2.1828)" -print "CCONST =", example.CCONST, "(should be 'x')" -print "CCONST2 =", example.CCONST2, "(this should be on a new line)" -print "SCONST =", example.SCONST, "(should be 'Hello World')" -print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')" -print "EXPR =", example.EXPR, "(should be 48.5484)" -print "iconst =", example.iconst, "(should be 37)" -print "fconst =", example.fconst, "(should be 3.14)" +print("ICONST = %s (should be 42)" % example.ICONST) +print("FCONST = %s (should be 2.1828)" % example.FCONST) +print("CCONST = %s (should be 'x')" % example.CCONST) +print("CCONST2 = %s (this should be on a new line)" % example.CCONST2) +print("SCONST = %s (should be 'Hello World')" % example.SCONST) +print("SCONST2 = %s (should be '\"Hello World\"')" % example.SCONST2) +print("EXPR = %s (should be 48.5484)" % example.EXPR) +print("iconst = %s (should be 37)" % example.iconst) +print("fconst = %s (should be 3.14)" % example.fconst) try: - print "EXTERN = ", example.EXTERN, "(Arg! This shouldn't print anything)" + x = example.EXTERN + print("%s (Arg! This shouldn't print anything)" % x) except AttributeError: - print "EXTERN isn't defined (good)" + print("EXTERN isn't defined (good)") try: - print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)" + x = example.FOO + print("%s (Arg! This shouldn't print anything)" % x) except AttributeError: - print "FOO isn't defined (good)" + print("FOO isn't defined (good)") diff --git a/Examples/python/contract/runme.py b/Examples/python/contract/runme.py index ce01e5a1d..ec0aceb45 100644 --- a/Examples/python/contract/runme.py +++ b/Examples/python/contract/runme.py @@ -7,15 +7,15 @@ import example x = 42 y = 105 g = example.gcd(x, y) -print "The gcd of %d and %d is %d" % (x, y, g) +print("The gcd of %d and %d is %d" % (x, y, g)) # Manipulate the Foo global variable # Output its current value -print "Foo = ", example.cvar.Foo +print("Foo = %s" % example.cvar.Foo) # Change its value example.cvar.Foo = 3.1415926 # See if the change took effect -print "Foo = ", example.cvar.Foo +print("Foo = %s" % example.cvar.Foo) diff --git a/Examples/python/docstrings/runme.py b/Examples/python/docstrings/runme.py index c25d291b6..76386d214 100644 --- a/Examples/python/docstrings/runme.py +++ b/Examples/python/docstrings/runme.py @@ -2,4 +2,4 @@ import example -print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')" +print("example.Foo.bar.__doc__ = %s (Should be 'No comment')" % repr(example.Foo.bar.__doc__)) diff --git a/Examples/python/doxygen/runme.py b/Examples/python/doxygen/runme.py index e23528874..657535cc2 100644 --- a/Examples/python/doxygen/runme.py +++ b/Examples/python/doxygen/runme.py @@ -5,24 +5,24 @@ import example -print "Creating some objects:" +print("Creating some objects:") c = example.MakeCircle(10) -print " Created circle", c +print(" Created circle %s" % c) s = example.MakeSquare(10) -print " Created square", s +print(" Created square %s" % s) r = example.MakeRectangleInt(10, 20) -print " Created rectangle", r +print(" Created rectangle %s" % r) -print "\nHere are some properties of the shapes:" +print("\nHere are some properties of the shapes:") for o in [c, s, r]: - print " ", o - print " area = ", o.area() - print " perimeter = ", o.perimeter() + print(" %s" % o) + print(" area = %s" % o.area()) + print(" perimeter = %s" % o.perimeter()) -print "\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py" +print("\nRunning pydoc, this is the equivalent to executing: pydoc -w ./example.py") import pydoc pydoc.writedoc("example") -print "Open example.html in your browser to view the generated python docs" +print("Open example.html in your browser to view the generated python docs") diff --git a/Examples/python/enum/runme.py b/Examples/python/enum/runme.py index def01b147..4920c1dcf 100644 --- a/Examples/python/enum/runme.py +++ b/Examples/python/enum/runme.py @@ -5,24 +5,24 @@ import example # ----- Object creation ----- # Print out the value of some enums -print "*** color ***" -print " RED =", example.RED -print " BLUE =", example.BLUE -print " GREEN =", example.GREEN +print("*** color ***") +print(" RED = %s" % example.RED) +print(" BLUE = %s" % example.BLUE) +print(" GREEN = %s" % example.GREEN) -print "\n*** Foo::speed ***" -print " Foo_IMPULSE =", example.Foo.IMPULSE -print " Foo_WARP =", example.Foo.WARP -print " Foo_LUDICROUS =", example.Foo.LUDICROUS +print("\n*** Foo::speed ***") +print(" Foo_IMPULSE = %s" % example.Foo.IMPULSE) +print(" Foo_WARP = %s" % example.Foo.WARP) +print(" Foo_LUDICROUS = %s" % example.Foo.LUDICROUS) -print "\nTesting use of enums with functions\n" +print("\nTesting use of enums with functions\n") example.enum_test(example.RED, example.Foo.IMPULSE) example.enum_test(example.BLUE, example.Foo.WARP) example.enum_test(example.GREEN, example.Foo.LUDICROUS) example.enum_test(1234, 5678) -print "\nTesting use of enum with class method" +print("\nTesting use of enum with class method") f = example.Foo() f.enum_test(example.Foo.IMPULSE) diff --git a/Examples/python/exception/runme.py b/Examples/python/exception/runme.py index 7fae49030..7b5c10d19 100644 --- a/Examples/python/exception/runme.py +++ b/Examples/python/exception/runme.py @@ -7,36 +7,36 @@ import example t = example.Test() try: t.unknown() -except RuntimeError, e: - print "incomplete type", e.args[0] +except RuntimeError as e: + print("incomplete type %s" % e.args[0]) try: t.simple() -except RuntimeError, e: - print e.args[0] +except RuntimeError as e: + print(e.args[0]) try: t.message() -except RuntimeError, e: - print e.args[0] +except RuntimeError as e: + print(e.args[0]) if not example.is_python_builtin(): try: t.hosed() - except example.Exc, e: - print e.code, e.msg + except example.Exc as e: + print("%s %s" % (e.code, e.msg)) else: try: t.hosed() - except BaseException, e: + except BaseException as e: # Throwing builtin classes as exceptions not supported (-builtin # option) - print e + print(e) for i in range(1, 4): try: t.multi(i) - except RuntimeError, e: - print e.args[0] - except example.Exc, e: - print e.code, e.msg + except RuntimeError as e: + print(e.args[0]) + except example.Exc as e: + print("%s %s" % (e.code, e.msg)) diff --git a/Examples/python/exceptproxy/runme.py b/Examples/python/exceptproxy/runme.py index 970d6201d..d25fb6de6 100644 --- a/Examples/python/exceptproxy/runme.py +++ b/Examples/python/exceptproxy/runme.py @@ -2,44 +2,44 @@ import example if example.is_python_builtin(): - print "Skipping example: -builtin option does not support %exceptionclass" + print("Skipping example: -builtin option does not support %exceptionclass") exit(0) q = example.intQueue(10) -print "Inserting items into intQueue" +print("Inserting items into intQueue") -print type(example.FullError) +print(type(example.FullError)) try: for i in range(0, 100): q.enqueue(i) -except example.FullError, e: - print "Maxsize is", e.maxsize +except example.FullError as e: + print("Maxsize is %s" % e.maxsize) -print "Removing items" +print("Removing items") try: - while 1: + while True: q.dequeue() -except example.EmptyError, e: +except example.EmptyError as e: pass q = example.doubleQueue(1000) -print "Inserting items into doubleQueue" +print("Inserting items into doubleQueue") try: for i in range(0, 10000): q.enqueue(i * 1.5) -except example.FullError, e: - print "Maxsize is", e.maxsize +except example.FullError as e: + print("Maxsize is %s" % e.maxsize) -print "Removing items" +print("Removing items") try: - while 1: + while True: q.dequeue() -except example.EmptyError, e: +except example.EmptyError as e: pass diff --git a/Examples/python/extend/runme.py b/Examples/python/extend/runme.py index e97358b99..d7e626ec2 100644 --- a/Examples/python/extend/runme.py +++ b/Examples/python/extend/runme.py @@ -21,9 +21,9 @@ class CEO(example.Manager): # the director wrappers to call CEO.getPosition. e = CEO("Alice") -print e.getName(), "is a", e.getPosition() -print "Just call her \"%s\"" % e.getTitle() -print "----------------------" +print("%s is a %s" % (e.getName(), e.getPosition())) +print("Just call her \"%s\"" % e.getTitle()) +print("----------------------") # Create a new EmployeeList instance. This class does not have a C++ @@ -40,7 +40,7 @@ list = example.EmployeeList() e = e.__disown__() list.addEmployee(e) -print "----------------------" +print("----------------------") # Now we access the first four items in list (three are C++ objects that # EmployeeList's constructor adds, the last is our CEO). The virtual @@ -59,13 +59,13 @@ print "----------------------" # passes down through the C++ director class to the Python implementation # in CEO. All this routing takes place transparently. -print "(position, title) for items 0-3:" +print("(position, title) for items 0-3:") -print " %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle()) -print " %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle()) -print " %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle()) -print " %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle()) -print "----------------------" +print(" %s, \"%s\"" % (list.get_item(0).getPosition(), list.get_item(0).getTitle())) +print(" %s, \"%s\"" % (list.get_item(1).getPosition(), list.get_item(1).getTitle())) +print(" %s, \"%s\"" % (list.get_item(2).getPosition(), list.get_item(2).getTitle())) +print(" %s, \"%s\"" % (list.get_item(3).getPosition(), list.get_item(3).getTitle())) +print("----------------------") # Time to delete the EmployeeList, which will delete all the Employee* # items it contains. The last item is our CEO, which gets destroyed as its @@ -75,8 +75,8 @@ print "----------------------" # usual to destroy the object. del list -print "----------------------" +print("----------------------") # All done. -print "python exit" +print("python exit") diff --git a/Examples/python/funcptr/runme.py b/Examples/python/funcptr/runme.py index bf0c6e1ac..4248f928d 100644 --- a/Examples/python/funcptr/runme.py +++ b/Examples/python/funcptr/runme.py @@ -7,14 +7,14 @@ b = 42 # Now call our C function with a bunch of callbacks -print "Trying some C callback functions" -print " a =", a -print " b =", b -print " ADD(a,b) =", example.do_op(a, b, example.ADD) -print " SUB(a,b) =", example.do_op(a, b, example.SUB) -print " MUL(a,b) =", example.do_op(a, b, example.MUL) +print("Trying some C callback functions") +print(" a = %s" % a) +print(" b = %s" % b) +print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD)) +print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB)) +print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL)) -print "Here is what the C callback function objects look like in Python" -print " ADD =", example.ADD -print " SUB =", example.SUB -print " MUL =", example.MUL +print("Here is what the C callback function objects look like in Python") +print(" ADD = %s" % example.ADD) +print(" SUB = %s" % example.SUB) +print(" MUL = %s" % example.MUL) diff --git a/Examples/python/funcptr2/runme.py b/Examples/python/funcptr2/runme.py index a4405d9d9..afa2e2db6 100644 --- a/Examples/python/funcptr2/runme.py +++ b/Examples/python/funcptr2/runme.py @@ -7,18 +7,18 @@ b = 42 # Now call our C function with a bunch of callbacks -print "Trying some C callback functions" -print " a =", a -print " b =", b -print " ADD(a,b) =", example.do_op(a, b, example.ADD) -print " SUB(a,b) =", example.do_op(a, b, example.SUB) -print " MUL(a,b) =", example.do_op(a, b, example.MUL) +print("Trying some C callback functions") +print(" a = %s" % a) +print(" b = %s" % b) +print(" ADD(a,b) = %s" % example.do_op(a, b, example.ADD)) +print(" SUB(a,b) = %s" % example.do_op(a, b, example.SUB)) +print(" MUL(a,b) = %s" % example.do_op(a, b, example.MUL)) -print "Here is what the C callback function objects look like in Python" -print " ADD =", example.ADD -print " SUB =", example.SUB -print " MUL =", example.MUL +print("Here is what the C callback function objects look like in Python") +print(" ADD = %s" % example.ADD) +print(" SUB = %s" % example.SUB) +print(" MUL = %s" % example.MUL) -print "Call the functions directly..." -print " add(a,b) =", example.add(a, b) -print " sub(a,b) =", example.sub(a, b) +print("Call the functions directly...") +print(" add(a,b) = %s" % example.add(a, b)) +print(" sub(a,b) = %s" % example.sub(a, b)) diff --git a/Examples/python/functor/runme.py b/Examples/python/functor/runme.py index 7f6f2b649..69289a78b 100644 --- a/Examples/python/functor/runme.py +++ b/Examples/python/functor/runme.py @@ -12,5 +12,5 @@ for i in range(0, 100): a(i) # Note: function call b(math.sqrt(i)) # Note: function call -print a.result() -print b.result() +print(a.result()) +print(b.result()) diff --git a/Examples/python/import/runme.py b/Examples/python/import/runme.py index 0e83acad0..afa21a2b3 100644 --- a/Examples/python/import/runme.py +++ b/Examples/python/import/runme.py @@ -1,15 +1,22 @@ # file: runme.py # Test various properties of classes defined in separate modules +import sys + +print("Testing the %import directive") -print "Testing the %import directive" import base import foo import bar import spam +def write_flush(s): + # Python 2/3 compatible write and flush + sys.stdout.write(s) + sys.stdout.flush() + # Create some objects -print "Creating some objects" +print("Creating some objects") a = base.Base() b = foo.Foo() @@ -17,91 +24,74 @@ c = bar.Bar() d = spam.Spam() # Try calling some methods -print "Testing some methods" -print "", -print "Should see 'Base::A' ---> ", +print("Testing some methods") + +write_flush(" Should see 'Base::A' ---> ") a.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") a.B() -print "Should see 'Foo::A' ---> ", +write_flush(" Should see 'Foo::A' ---> ") b.A() -print "Should see 'Foo::B' ---> ", +write_flush(" Should see 'Foo::B' ---> ") b.B() -print "Should see 'Bar::A' ---> ", +write_flush(" Should see 'Bar::A' ---> ") c.A() -print "Should see 'Bar::B' ---> ", +write_flush(" Should see 'Bar::B' ---> ") c.B() -print "Should see 'Spam::A' ---> ", +write_flush(" Should see 'Spam::A' ---> ") d.A() -print "Should see 'Spam::B' ---> ", +write_flush(" Should see 'Spam::B' ---> ") d.B() # Try some casts -print "\nTesting some casts\n" -print "", +print("\nTesting some casts\n") x = a.toBase() -print "Should see 'Base::A' ---> ", +write_flush(" Should see 'Base::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = b.toBase() -print "Should see 'Foo::A' ---> ", +write_flush(" Should see 'Foo::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = c.toBase() -print "Should see 'Bar::A' ---> ", +write_flush(" Should see 'Bar::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = d.toBase() -print "Should see 'Spam::A' ---> ", +write_flush(" Should see 'Spam::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = d.toBar() -print "Should see 'Bar::B' ---> ", +write_flush(" Should see 'Bar::B' ---> ") x.B() -print "\nTesting some dynamic casts\n" +print("\nTesting some dynamic casts\n") x = d.toBase() -print " Spam -> Base -> Foo : ", y = foo.Foo_fromBase(x) -if y: - print "bad swig" -else: - print "good swig" +print(" Spam -> Base -> Foo : {} swig".format("bad" if y else "good")) -print " Spam -> Base -> Bar : ", y = bar.Bar_fromBase(x) -if y: - print "good swig" -else: - print "bad swig" +print(" Spam -> Base -> Bar : {} swig".format("good" if y else "bad")) -print " Spam -> Base -> Spam : ", y = spam.Spam_fromBase(x) -if y: - print "good swig" -else: - print "bad swig" +print(" Spam -> Base -> Spam : {} swig".format("good" if y else "bad")) -print " Foo -> Spam : ", y = spam.Spam_fromBase(b) -if y: - print "bad swig" -else: - print "good swig" +print(" Foo -> Spam : {} swig".format("bad" if y else "good")) diff --git a/Examples/python/import_packages/from_init1/runme.py b/Examples/python/import_packages/from_init1/runme.py index a663a136b..c76716f16 100644 --- a/Examples/python/import_packages/from_init1/runme.py +++ b/Examples/python/import_packages/from_init1/runme.py @@ -6,26 +6,26 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2 - print " Finished importing py2.pkg2" + print(" Finished importing py2.pkg2") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.foo" run_except_on_windows(commandline) else: import py3.pkg2 - print " Finished importing py3.pkg2" + print(" Finished importing py3.pkg2") # commandline = sys.executable + " -m py3.pkg2.bar" # run_except_on_windows(commandline) # commandline = sys.executable + " -m py3.pkg2.foo" diff --git a/Examples/python/import_packages/from_init2/runme.py b/Examples/python/import_packages/from_init2/runme.py index 3c7b12693..c9c46a4da 100644 --- a/Examples/python/import_packages/from_init2/runme.py +++ b/Examples/python/import_packages/from_init2/runme.py @@ -6,24 +6,24 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2 - print " Finished importing py2.pkg2" + print(" Finished importing py2.pkg2") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) else: import py3.pkg2 - print " Finished importing py3.pkg2" + print(" Finished importing py3.pkg2") # commandline = sys.executable + " -m py3.pkg2.bar" # run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/from_init3/runme.py b/Examples/python/import_packages/from_init3/runme.py index 3c7b12693..c9c46a4da 100644 --- a/Examples/python/import_packages/from_init3/runme.py +++ b/Examples/python/import_packages/from_init3/runme.py @@ -6,24 +6,24 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2 - print " Finished importing py2.pkg2" + print(" Finished importing py2.pkg2") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) else: import py3.pkg2 - print " Finished importing py3.pkg2" + print(" Finished importing py3.pkg2") # commandline = sys.executable + " -m py3.pkg2.bar" # run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/module_is_init/runme.py b/Examples/python/import_packages/module_is_init/runme.py index b5e646e85..c4806cdf8 100644 --- a/Examples/python/import_packages/module_is_init/runme.py +++ b/Examples/python/import_packages/module_is_init/runme.py @@ -3,10 +3,10 @@ import sys # Test import of a SWIG generated module renamed as the package's __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - module renamed as __init__.py" +print("Testing " + testname + " - module renamed as __init__.py") if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0): - print " Not importing as Python version is >= 3.0 and < 3.3" + print(" Not importing as Python version is >= 3.0 and < 3.3") # Package detection does not work in these versions. # Can be fixed by using this in the interface file: # %module(moduleimport="from . import $module") foo # without -builtin @@ -14,7 +14,7 @@ if sys.version_info >= (3, 0, 0) and sys.version_info < (3, 3, 0): sys.exit(0) import pkg1 -print " Finished importing pkg1" +print(" Finished importing pkg1") if pkg1.foofunction(123) != 1230: raise RuntimeError("foofunction failed") @@ -23,4 +23,4 @@ fc = pkg1.FooClass() if fc.foomethod(1) != 6: raise RuntimeError("foomethod failed") -print " Finished testing pkg1" +print(" Finished testing pkg1") diff --git a/Examples/python/import_packages/namespace_pkg/runme.py b/Examples/python/import_packages/namespace_pkg/runme.py index d2af05619..54a8e4ee6 100644 --- a/Examples/python/import_packages/namespace_pkg/runme.py +++ b/Examples/python/import_packages/namespace_pkg/runme.py @@ -5,14 +5,14 @@ import subprocess import sys testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - namespace packages" +print("Testing " + testname + " - namespace packages") if sys.version_info < (3, 3, 0): - print " Not importing nstest as Python version is < 3.3" + print(" Not importing nstest as Python version is < 3.3") sys.exit(0) import nstest -print " Finished importing nstest" +print(" Finished importing nstest") nstest.main() diff --git a/Examples/python/import_packages/relativeimport1/runme.py b/Examples/python/import_packages/relativeimport1/runme.py index 87101ea46..3073cb5a7 100644 --- a/Examples/python/import_packages/relativeimport1/runme.py +++ b/Examples/python/import_packages/relativeimport1/runme.py @@ -6,26 +6,26 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) with -relativeimport" +print("Testing " + testname + " - %module(package=...) with -relativeimport") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2.bar - print " Finished importing py2.pkg2.bar" + print(" Finished importing py2.pkg2.bar") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.foo" run_except_on_windows(commandline) else: import py3.pkg2.bar - print " Finished importing py3.pkg2.bar" + print(" Finished importing py3.pkg2.bar") commandline = sys.executable + " -m py3.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.foo" diff --git a/Examples/python/import_packages/relativeimport2/runme.py b/Examples/python/import_packages/relativeimport2/runme.py index f5b55782f..9ab8d9471 100644 --- a/Examples/python/import_packages/relativeimport2/runme.py +++ b/Examples/python/import_packages/relativeimport2/runme.py @@ -6,26 +6,26 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2.bar - print " Finished importing py2.pkg2.bar" + print(" Finished importing py2.pkg2.bar") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.pkg4.foo" run_except_on_windows(commandline) else: import py3.pkg2.bar - print " Finished importing py3.pkg2.bar" + print(" Finished importing py3.pkg2.bar") commandline = sys.executable + " -m py3.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.pkg4.foo" diff --git a/Examples/python/import_packages/relativeimport3/runme.py b/Examples/python/import_packages/relativeimport3/runme.py index 87101ea46..3073cb5a7 100644 --- a/Examples/python/import_packages/relativeimport3/runme.py +++ b/Examples/python/import_packages/relativeimport3/runme.py @@ -6,26 +6,26 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of modules content from within __init__.py testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) with -relativeimport" +print("Testing " + testname + " - %module(package=...) with -relativeimport") if sys.version_info < (2, 5): - print " Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'" + print(" Skipping test as Python version is < 2.5 and does not support relative import syntax: 'from . import x'") sys.exit(0) if sys.version_info < (3, 0): import py2.pkg2.bar - print " Finished importing py2.pkg2.bar" + print(" Finished importing py2.pkg2.bar") commandline = sys.executable + " -m py2.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py2.pkg2.pkg3.foo" run_except_on_windows(commandline) else: import py3.pkg2.bar - print " Finished importing py3.pkg2.bar" + print(" Finished importing py3.pkg2.bar") commandline = sys.executable + " -m py3.pkg2.bar" run_except_on_windows(commandline) commandline = sys.executable + " -m py3.pkg2.pkg3.foo" diff --git a/Examples/python/import_packages/same_modnames1/runme.py b/Examples/python/import_packages/same_modnames1/runme.py index a64551bfd..05846ed9d 100644 --- a/Examples/python/import_packages/same_modnames1/runme.py +++ b/Examples/python/import_packages/same_modnames1/runme.py @@ -6,21 +6,21 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) # Test import of same modules from different packages testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") import pkg2.foo -print " Finished importing pkg2.foo" +print(" Finished importing pkg2.foo") var2 = pkg2.foo.Pkg2_Foo() classname = str(type(var2)) if classname.find("pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) -print " Successfully created object pkg2.foo.Pkg2_Foo" +print(" Successfully created object pkg2.foo.Pkg2_Foo") commandline = sys.executable + " -m pkg2.foo" run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/same_modnames2/runme.py b/Examples/python/import_packages/same_modnames2/runme.py index c2cf2744c..190dadc77 100644 --- a/Examples/python/import_packages/same_modnames2/runme.py +++ b/Examples/python/import_packages/same_modnames2/runme.py @@ -6,20 +6,20 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py" +print("Testing " + testname + " - %module(package=...) + python 'import' in __init__.py") import pkg1.pkg2.foo -print " Finished importing pkg1.pkg2.foo" +print(" Finished importing pkg1.pkg2.foo") var2 = pkg1.pkg2.foo.Pkg2_Foo() classname = str(type(var2)) if classname.find("pkg1.pkg2.foo.Pkg2_Foo") == -1: raise RuntimeError("failed type checking: " + classname) -print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" +print(" Successfully created object pkg1.pkg2.foo.Pkg2_Foo") commandline = sys.executable + " -m pkg1.pkg2.foo" run_except_on_windows(commandline) diff --git a/Examples/python/import_packages/split_modules/vanilla/runme.py b/Examples/python/import_packages/split_modules/vanilla/runme.py index 79d79b4c3..0f7b8806b 100644 --- a/Examples/python/import_packages/split_modules/vanilla/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla/runme.py @@ -6,14 +6,14 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - split modules" +print("Testing " + testname + " - split modules") import pkg1.foo -print " Finished importing pkg1.foo" +print(" Finished importing pkg1.foo") if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") diff --git a/Examples/python/import_packages/split_modules/vanilla_split/runme.py b/Examples/python/import_packages/split_modules/vanilla_split/runme.py index 79d79b4c3..0f7b8806b 100644 --- a/Examples/python/import_packages/split_modules/vanilla_split/runme.py +++ b/Examples/python/import_packages/split_modules/vanilla_split/runme.py @@ -6,14 +6,14 @@ def run_except_on_windows(commandline, env=None): if os.name != "nt" and sys.platform != "cygwin": # Strange failures on windows/cygin/mingw subprocess.check_call(commandline, env=env, shell=True) - print(" Finished running: " + commandline) + print((" Finished running: " + commandline)) testname = os.path.basename(os.path.dirname(os.path.abspath(__file__))) -print "Testing " + testname + " - split modules" +print("Testing " + testname + " - split modules") import pkg1.foo -print " Finished importing pkg1.foo" +print(" Finished importing pkg1.foo") if not(pkg1.foo.count() == 3): raise RuntimeError("test failed") diff --git a/Examples/python/import_template/runme.py b/Examples/python/import_template/runme.py index 35f8924c1..b14f8d35e 100644 --- a/Examples/python/import_template/runme.py +++ b/Examples/python/import_template/runme.py @@ -1,15 +1,22 @@ # file: runme.py # Test various properties of classes defined in separate modules +import sys + +print("Testing the %import directive with templates") -print "Testing the %import directive with templates" import base import foo import bar import spam +def write_flush(s): + # Python 2/3 compatible write and flush + sys.stdout.write(s) + sys.stdout.flush() + # Create some objects -print "Creating some objects" +print("Creating some objects") a = base.intBase() b = foo.intFoo() @@ -17,91 +24,74 @@ c = bar.intBar() d = spam.intSpam() # Try calling some methods -print "Testing some methods" -print "", -print "Should see 'Base::A' ---> ", +print("Testing some methods") + +write_flush(" Should see 'Base::A' ---> ") a.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") a.B() -print "Should see 'Foo::A' ---> ", +write_flush(" Should see 'Foo::A' ---> ") b.A() -print "Should see 'Foo::B' ---> ", +write_flush(" Should see 'Foo::B' ---> ") b.B() -print "Should see 'Bar::A' ---> ", +write_flush(" Should see 'Bar::A' ---> ") c.A() -print "Should see 'Bar::B' ---> ", +write_flush(" Should see 'Bar::B' ---> ") c.B() -print "Should see 'Spam::A' ---> ", +write_flush(" Should see 'Spam::A' ---> ") d.A() -print "Should see 'Spam::B' ---> ", +write_flush(" Should see 'Spam::B' ---> ") d.B() # Try some casts -print "\nTesting some casts\n" -print "", +print("\nTesting some casts\n") x = a.toBase() -print "Should see 'Base::A' ---> ", +write_flush(" Should see 'Base::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = b.toBase() -print "Should see 'Foo::A' ---> ", +write_flush(" Should see 'Foo::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = c.toBase() -print "Should see 'Bar::A' ---> ", +write_flush(" Should see 'Bar::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = d.toBase() -print "Should see 'Spam::A' ---> ", +write_flush(" Should see 'Spam::A' ---> ") x.A() -print "Should see 'Base::B' ---> ", +write_flush(" Should see 'Base::B' ---> ") x.B() x = d.toBar() -print "Should see 'Bar::B' ---> ", +write_flush(" Should see 'Bar::B' ---> ") x.B() -print "\nTesting some dynamic casts\n" +print("\nTesting some dynamic casts\n") x = d.toBase() -print " Spam -> Base -> Foo : ", y = foo.intFoo_fromBase(x) -if y: - print "bad swig" -else: - print "good swig" +print(" Spam -> Base -> Foo : {} swig".format("bad" if y else "good")) -print " Spam -> Base -> Bar : ", y = bar.intBar_fromBase(x) -if y: - print "good swig" -else: - print "bad swig" +print(" Spam -> Base -> Bar : {} swig".format("good" if y else "bad")) -print " Spam -> Base -> Spam : ", y = spam.intSpam_fromBase(x) -if y: - print "good swig" -else: - print "bad swig" +print(" Spam -> Base -> Spam : {} swig".format("good" if y else "bad")) -print " Foo -> Spam : ", y = spam.intSpam_fromBase(b) -if y: - print "bad swig" -else: - print "good swig" +print(" Foo -> Spam : {} swig".format("bad" if y else "good")) diff --git a/Examples/python/multimap/runme.py b/Examples/python/multimap/runme.py index ad693b73a..e24f54ee1 100644 --- a/Examples/python/multimap/runme.py +++ b/Examples/python/multimap/runme.py @@ -7,14 +7,14 @@ import example x = 42 y = 105 g = example.gcd(x, y) -print "The gcd of %d and %d is %d" % (x, y, g) +print("The gcd of %d and %d is %d" % (x, y, g)) # Call the gcdmain() function example.gcdmain(["gcdmain", "42", "105"]) # Call the count function -print example.count("Hello World", "l") +print(example.count("Hello World", "l")) # Call the capitalize function -print example.capitalize("hello world") +print(example.capitalize("hello world")) diff --git a/Examples/python/operator/runme.py b/Examples/python/operator/runme.py index ac48f2676..ee479f0b5 100644 --- a/Examples/python/operator/runme.py +++ b/Examples/python/operator/runme.py @@ -4,17 +4,17 @@ import example a = example.Complex(2, 3) b = example.Complex(-5, 10) -print "a =", a -print "b =", b +print("a = %s" % a) +print("b = %s" % b) c = a + b -print "c =", c -print "a*b =", a * b -print "a-c =", a - c +print("c = %s" % c) +print("a*b = %s" % (a * b)) +print("a-c = %s" % (a - c)) e = example.ComplexCopy(a - c) -print "e =", e +print("e = %s" % e) # Big expression f = ((a + b) * (c + b * e)) + (-a) -print "f =", f +print("f = %s" % f) diff --git a/Examples/python/pointer/runme.py b/Examples/python/pointer/runme.py index 5b5f16bc2..46371b89a 100644 --- a/Examples/python/pointer/runme.py +++ b/Examples/python/pointer/runme.py @@ -3,23 +3,23 @@ import example # First create some objects using the pointer library. -print "Testing the pointer library" +print("Testing the pointer library") a = example.new_intp() b = example.new_intp() c = example.new_intp() example.intp_assign(a, 37) example.intp_assign(b, 42) -print " a =", a -print " b =", b -print " c =", c +print(" a = %s" % a) +print(" b = %s" % b) +print(" c = %s" % c) # Call the add() function with some pointers example.add(a, b, c) # Now get the result r = example.intp_value(c) -print " 37 + 42 =", r +print(" 37 + 42 = %s" % r) # Clean up the pointers example.delete_intp(a) @@ -30,12 +30,12 @@ example.delete_intp(c) # This should be much easier. Now how it is no longer # necessary to manufacture pointers. -print "Trying the typemap library" +print("Trying the typemap library") r = example.sub(37, 42) -print " 37 - 42 =", r +print(" 37 - 42 = %s" % r) # Now try the version with multiple return values -print "Testing multiple return values" +print("Testing multiple return values") q, r = example.divide(42, 37) -print " 42/37 = %d remainder %d" % (q, r) +print(" 42/37 = %d remainder %d" % (q, r)) diff --git a/Examples/python/reference/runme.py b/Examples/python/reference/runme.py index 0ff217b02..8a96e03a7 100644 --- a/Examples/python/reference/runme.py +++ b/Examples/python/reference/runme.py @@ -6,12 +6,12 @@ import example # ----- Object creation ----- -print "Creating some objects:" +print("Creating some objects:") a = example.Vector(3, 4, 5) b = example.Vector(10, 11, 12) -print " Created", a.cprint() -print " Created", b.cprint() +print(" Created %s" % a.cprint()) +print(" Created %s" % b.cprint()) # ----- Call an overloaded operator ----- @@ -21,9 +21,9 @@ print " Created", b.cprint() # # It returns a new allocated object. -print "Adding a+b" +print("Adding a+b") c = example.addv(a, b) -print " a+b =", c.cprint() +print(" a+b = %s" % c.cprint()) # Note: Unless we free the result, a memory leak will occur del c @@ -31,9 +31,9 @@ del c # ----- Create a vector array ----- # Note: Using the high-level interface here -print "Creating an array of vectors" +print("Creating an array of vectors") va = example.VectorArray(10) -print " va = ", va +print(" va = %s" % va) # ----- Set some values in the array ----- @@ -45,17 +45,17 @@ va.set(2, example.addv(a, b)) # Get some values from the array -print "Getting some array values" +print("Getting some array values") for i in range(0, 5): - print " va(%d) = %s" % (i, va.get(i).cprint()) + print(" va(%d) = %s" % (i, va.get(i).cprint())) # Watch under resource meter to check on this -print "Making sure we don't leak memory." -for i in xrange(0, 1000000): +print("Making sure we don't leak memory.") +for i in range(0, 1000000): c = va.get(i % 10) # ----- Clean up ----- -print "Cleaning up" +print("Cleaning up") del va del a diff --git a/Examples/python/simple/runme.py b/Examples/python/simple/runme.py index ce01e5a1d..ec0aceb45 100644 --- a/Examples/python/simple/runme.py +++ b/Examples/python/simple/runme.py @@ -7,15 +7,15 @@ import example x = 42 y = 105 g = example.gcd(x, y) -print "The gcd of %d and %d is %d" % (x, y, g) +print("The gcd of %d and %d is %d" % (x, y, g)) # Manipulate the Foo global variable # Output its current value -print "Foo = ", example.cvar.Foo +print("Foo = %s" % example.cvar.Foo) # Change its value example.cvar.Foo = 3.1415926 # See if the change took effect -print "Foo = ", example.cvar.Foo +print("Foo = %s" % example.cvar.Foo) diff --git a/Examples/python/smartptr/runme.py b/Examples/python/smartptr/runme.py index 5f8b73476..f01636ad6 100644 --- a/Examples/python/smartptr/runme.py +++ b/Examples/python/smartptr/runme.py @@ -7,17 +7,17 @@ import example # ----- Object creation ----- -print "Creating some objects:" +print("Creating some objects:") cc = example.Circle(10) c = example.ShapePtr(cc) -print " Created circle", c +print(" Created circle %s" % c) ss = example.Square(10) s = example.ShapePtr(ss) -print " Created square", s +print(" Created square %s" % s) # ----- Access a static member ----- -print "\nA total of", example.cvar.Shape_nshapes, "shapes were created" +print("\nA total of %s shapes were created" % example.cvar.Shape_nshapes) # ----- Member data access ----- @@ -29,19 +29,19 @@ c.y = 30 s.x = -10 s.y = 5 -print "\nHere is their current position:" -print " Circle = (%f, %f)" % (c.x, c.y) -print " Square = (%f, %f)" % (s.x, s.y) +print("\nHere is their current position:") +print(" Circle = (%f, %f)" % (c.x, c.y)) +print(" Square = (%f, %f)" % (s.x, s.y)) # ----- Call some methods ----- -print "\nHere are some properties of the shapes:" +print("\nHere are some properties of the shapes:") for o in [c, s]: - print " ", o - print " area = ", o.area() - print " perimeter = ", o.perimeter() + print(" %s" % o) + print(" area = %s" % o.area()) + print(" perimeter = %s" % o.perimeter()) -print "\nGuess I'll clean up now" +print("\nGuess I'll clean up now") # Note: this invokes the virtual destructor del c @@ -50,5 +50,5 @@ del cc del ss s = 3 -print example.cvar.Shape_nshapes, "shapes remain" -print "Goodbye" +print("%d shapes remain" % example.cvar.Shape_nshapes) +print("Goodbye") diff --git a/Examples/python/std_map/runme.py b/Examples/python/std_map/runme.py index 26031f3f4..e86f613fa 100644 --- a/Examples/python/std_map/runme.py +++ b/Examples/python/std_map/runme.py @@ -11,45 +11,45 @@ dmap = {} dmap["hello"] = 1.0 dmap["hi"] = 2.0 -print dmap.items() -print dmap.keys() -print dmap.values() +print(list(dmap.items())) +print(list(dmap.keys())) +print(list(dmap.values())) -print dmap +print(dmap) hmap = example.halfd(dmap) dmap = hmap -print dmap -for i in dmap.iterkeys(): - print "key", i +print(dmap) +for i in dmap.keys(): + print("key %s" % i) -for i in dmap.itervalues(): - print "val", i +for i in dmap.values(): + print("val %s" % i) -for k, v in dmap.iteritems(): - print "item", k, v +for k, v in dmap.items(): + print("item %s %s" % (k, v)) dmap = example.DoubleMap() dmap["hello"] = 1.0 dmap["hi"] = 2.0 -for i in dmap.iterkeys(): - print "key", i +for i in dmap.keys(): + print("key %s" % i) -for i in dmap.itervalues(): - print "val", i +for i in dmap.values(): + print("val %s" % i) -for k, v in dmap.iteritems(): - print "item", k, v +for k, v in dmap.items(): + print("item %s %s" % (k, v)) -print dmap.items() -print dmap.keys() -print dmap.values() +print(list(dmap.items())) +print(list(dmap.keys())) +print(list(dmap.values())) hmap = example.halfd(dmap) -print hmap.keys() -print hmap.values() +print(list(hmap.keys())) +print(list(hmap.values())) dmap = {} @@ -57,23 +57,23 @@ dmap["hello"] = 2 dmap["hi"] = 4 hmap = example.halfi(dmap) -print hmap -print hmap.keys() -print hmap.values() +print(hmap) +print(list(hmap.keys())) +print(list(hmap.values())) dmap = hmap -for i in dmap.iterkeys(): - print "key", i +for i in dmap.keys(): + print("key %s" % i) -for i in dmap.itervalues(): - print "val", i +for i in dmap.values(): + print("val %s" % i) -for i in dmap.iteritems(): - print "item", i +for i in dmap.items(): + print("item %s" % str(i)) -for k, v in dmap.iteritems(): - print "item", k, v +for k, v in dmap.items(): + print("item %s %s" % (k, v)) -print dmap +print(dmap) diff --git a/Examples/python/std_vector/runme.py b/Examples/python/std_vector/runme.py index d7d3c2ea4..3f1106d59 100644 --- a/Examples/python/std_vector/runme.py +++ b/Examples/python/std_vector/runme.py @@ -4,32 +4,30 @@ import example # Call average with a Python list... -print example.average([1, 2, 3, 4]) +print(example.average([1, 2, 3, 4])) # ... or a wrapped std::vector v = example.IntVector(4) for i in range(len(v)): v[i] = i + 1 -print example.average(v) +print(example.average(v)) # half will return a Python list. # Call it with a Python tuple... -print example.half((1.0, 1.5, 2.0, 2.5, 3.0)) +print(example.half((1.0, 1.5, 2.0, 2.5, 3.0))) # ... or a wrapped std::vector v = example.DoubleVector() for i in [1, 2, 3, 4]: v.append(i) -print example.half(v) +print(example.half(v)) # now halve a wrapped std::vector in place example.halve_in_place(v) -for i in range(len(v)): - print v[i], "; ", -print +print([i for i in v]) diff --git a/Examples/python/template/runme.py b/Examples/python/template/runme.py index e408e15f9..85b1ba937 100644 --- a/Examples/python/template/runme.py +++ b/Examples/python/template/runme.py @@ -3,8 +3,8 @@ import example # Call some templated functions -print example.maxint(3, 7) -print example.maxdouble(3.14, 2.18) +print(example.maxint(3, 7)) +print(example.maxdouble(3.14, 2.18)) # Create some class @@ -21,12 +21,12 @@ sum = 0 for i in range(0, 100): sum = sum + iv.getitem(i) -print sum +print(sum) sum = 0.0 for i in range(0, 1000): sum = sum + dv.getitem(i) -print sum +print(sum) del iv del dv diff --git a/Examples/python/variables/runme.py b/Examples/python/variables/runme.py index 4d34e92dd..d59e0aa3e 100644 --- a/Examples/python/variables/runme.py +++ b/Examples/python/variables/runme.py @@ -22,51 +22,51 @@ example.cvar.name = "Bill" # Now print out the values of the variables -print "Variables (values printed from Python)" +print("Variables (values printed from Python)") -print "ivar =", example.cvar.ivar -print "svar =", example.cvar.svar -print "lvar =", example.cvar.lvar -print "uivar =", example.cvar.uivar -print "usvar =", example.cvar.usvar -print "ulvar =", example.cvar.ulvar -print "scvar =", example.cvar.scvar -print "ucvar =", example.cvar.ucvar -print "fvar =", example.cvar.fvar -print "dvar =", example.cvar.dvar -print "cvar =", example.cvar.cvar -print "strvar =", example.cvar.strvar -print "cstrvar =", example.cvar.cstrvar -print "iptrvar =", example.cvar.iptrvar -print "name =", example.cvar.name -print "ptptr =", example.cvar.ptptr, example.Point_print(example.cvar.ptptr) -print "pt =", example.cvar.pt, example.Point_print(example.cvar.pt) +print("ivar = %s" % example.cvar.ivar) +print("svar = %s" % example.cvar.svar) +print("lvar = %s" % example.cvar.lvar) +print("uivar = %s" % example.cvar.uivar) +print("usvar = %s" % example.cvar.usvar) +print("ulvar = %s" % example.cvar.ulvar) +print("scvar = %s" % example.cvar.scvar) +print("ucvar = %s" % example.cvar.ucvar) +print("fvar = %s" % example.cvar.fvar) +print("dvar = %s" % example.cvar.dvar) +print("cvar = %s" % example.cvar.cvar) +print("strvar = %s" % example.cvar.strvar) +print("cstrvar = %s" % example.cvar.cstrvar) +print("iptrvar = %s" % example.cvar.iptrvar) +print("name = %s" % example.cvar.name) +print("ptptr = %s %s" % (example.cvar.ptptr, example.Point_print(example.cvar.ptptr))) +print("pt = %s %s" % (example.cvar.pt, example.Point_print(example.cvar.pt))) -print "\nVariables (values printed from C)" +print("\nVariables (values printed from C)") example.print_vars() -print "\nNow I'm going to try and modify some read only variables" +print("\nNow I'm going to try and modify some read only variables") -print " Trying to set 'path'" +print(" Trying to set 'path'") try: example.cvar.path = "Whoa!" - print "Hey, what's going on?!?! This shouldn't work" + print("Hey, what's going on?!?! This shouldn't work") except Exception: - print "Good." + print("Good.") -print " Trying to set 'status'" +print(" Trying to set 'status'") try: example.cvar.status = 0 - print "Hey, what's going on?!?! This shouldn't work" + print("Hey, what's going on?!?! This shouldn't work") except Exception: - print "Good." + print("Good.") -print "\nI'm going to try and update a structure variable.\n" +print("\nI'm going to try and update a structure variable.\n") example.cvar.pt = example.cvar.ptptr -print "The new value is" +print("The new value is") example.pt_print() -print "You should see the value", example.Point_print(example.cvar.ptptr) +print("You should see the value %s" % example.Point_print(example.cvar.ptptr)) From ec2b47ef2a4e5c879dde9eac8872db479ac55e74 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 18:04:58 +0100 Subject: [PATCH 1944/2031] Remove need for Python 2to3 All Python examples and tests have been written to be both Python 2 and Python 3 compatible, removing the need for 2to3 to run the examples or test-suite. The 2to3 executable is not always available and even when available does not always work, e.g. with pyenv. An alternative would be to use the lib2to3 Python module instead, but this isn't available in some older versions of Python 3. I had this problem on Ubuntu Bionic on Travis: checking Examples/python/callback pyenv: 2to3-3.8: command not found The `2to3-3.8' command exists in these Python versions: 3.8 3.8.1 Reference issues: https://github.com/pypa/virtualenv/issues/1399 https://travis-ci.community/t/2to3-command-not-found-in-venv-in-bionic/4495 --- CHANGES.current | 4 ++ Examples/Makefile.in | 13 +--- Examples/python/index.html | 1 - Examples/test-suite/python/Makefile.in | 87 ++------------------------ configure.ac | 24 ------- 5 files changed, 11 insertions(+), 118 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index a2c288c87..2d8037197 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-08-15: wsfulton + [Python] All Python examples and tests are written to be Python 2 and Python 3 + compatible, removing the need for 2to3 to run the examples or test-suite. + 2020-08-13: wsfulton [C#] Add support for void *VOID_INT_PTR for member variables. diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 87386f7eb..3f6140b5e 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -381,13 +381,7 @@ python_static_cpp: $(SRCDIR_SRCS) # Running a Python example # ----------------------------------------------------------------- -ifeq (,$(PY3)) - PYSCRIPT = $(RUNME).py -else - PYSCRIPT = $(RUNME)3.py -endif - -PY2TO3 = @PY2TO3@ `@PY2TO3@ -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` +PYSCRIPT = $(RUNME).py python_run: $(PYSCRIPT) ifneq (,$(PYCODESTYLE)) @@ -400,10 +394,6 @@ $(RUNME).py: $(SRCDIR)$(RUNME).py cp $< $@ endif -$(RUNME)3.py: $(SRCDIR)$(RUNME).py - cp $< $@ - $(PY2TO3) -w $@ >/dev/null 2>&1 - # ----------------------------------------------------------------- # Version display # ----------------------------------------------------------------- @@ -421,7 +411,6 @@ python_clean: rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *$(PYTHON_SO) rm -f $(TARGET).py - if test -f $(SRCDIR)$(RUNME).py; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi case "x$(SRCDIR)" in x|x./);; *) rm -f $(RUNME).py;; esac diff --git a/Examples/python/index.html b/Examples/python/index.html index 3bbdd66e8..750c0f04a 100644 --- a/Examples/python/index.html +++ b/Examples/python/index.html @@ -89,7 +89,6 @@ to look at the distutils

      Compatibility

      For Python 3, set the environment variable PY3=1. -This will ensure the 2to3 program is run prior to running any example.

      Your mileage may vary. If you experience a problem, please let us know by diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4c0507cbb..a340251eb 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -10,20 +10,10 @@ endif LANGUAGE = python PYTHON = $(PYBIN) +SCRIPTSUFFIX = _runme.py PYCODESTYLE = @PYCODESTYLE@ PYCODESTYLE_FLAGS = --ignore=E252,E30,E402,E501,E731,E741,W291,W391 -#*_runme.py for Python 2.x, *_runme3.py for Python 3.x -PY2SCRIPTSUFFIX = _runme.py -PY3SCRIPTSUFFIX = _runme3.py -PY2TO3 = @PY2TO3@ -x import - -ifeq (,$(PY3)) - SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) -else - SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) -endif - srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ @@ -107,7 +97,6 @@ C_TEST_CASES += \ include $(srcdir)/../common.mk # Overridden variables here -SCRIPTDIR = . LIBS = -L. VALGRIND_OPT += --suppressions=pythonswig.supp @@ -116,35 +105,25 @@ VALGRIND_OPT += --suppressions=pythonswig.supp # Rules for the different types of tests %.cpptest: - +$(convert_testcase) $(setup) +$(swig_and_compile_cpp) $(check_pep8) $(run_testcase) %.ctest: - +$(convert_testcase) $(setup) +$(swig_and_compile_c) $(check_pep8) $(run_testcase) %.multicpptest: - +$(convert_testcase) $(setup) +$(swig_and_compile_multi_cpp) $(check_pep8_multi_cpp) $(run_testcase) - -# 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. - -py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) -py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) - +# Python code style checking ifneq (,$(PYCODESTYLE)) check_pep8 = $(COMPILETOOL) $(PYCODESTYLE) $(PYCODESTYLE_FLAGS) $(SCRIPTPREFIX)$*.py @@ -154,70 +133,16 @@ check_pep8_multi_cpp = \ done endif -run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme) - +# Runs the testcase. A testcase is only run if +# a file is found which has _runme.py appended after the testcase name. run_testcase = \ - if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \ - $(run_python);\ + if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi -# Grab runme file ready for running: copied for out of source tree builds, and/or run 2to3 -# Note terminal (double colon) rules creating runme files to fix possible infinite recursion, -# see https://github.com/swig/swig/pull/688 -ifeq ($(SCRIPTDIR),$(srcdir)) - # in source tree build - ifeq (,$(PY3)) - convert_testcase = - else - convert_testcase = \ - if [ -f $(srcdir)/$(py2_runme) ]; then \ - $(MAKE) $(SCRIPTDIR)/$(py_runme); \ - fi - -# For converting python 2 tests into Python 3 tests -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) - cp $< $@ - $(PY2TO3) -w $@ >/dev/null 2>&1 - - endif -else - # out of source tree build - ifeq (,$(PY3)) - convert_testcase = \ - if [ -f $(srcdir)/$(py2_runme) ]; then \ - $(MAKE) $(SCRIPTDIR)/$(py_runme); \ - fi - -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) - cp $< $@ - - else - convert_testcase = \ - if [ -f $(srcdir)/$(py2_runme) ]; then \ - $(MAKE) $(SCRIPTDIR)/$(py_runme); \ - elif [ -f $(srcdir)/$(py3_runme) ]; then \ - $(MAKE) $(SCRIPTDIR)/$(py3_runme); \ - fi - -# For when there is a _runme3.py instead of a _runme.py, ie a Python 3 only run test -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY3SCRIPTSUFFIX) - cp $< $@ - -# For converting python 2 tests into Python 3 tests -$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX):: $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX) - cp $< $@ - $(PY2TO3) -w $@ >/dev/null 2>&1 - - endif - -endif - # Clean: remove the generated .py file -# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py. %.clean: @rm -f $*.py - @if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi - @if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py_runme); fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean diff --git a/configure.ac b/configure.ac index 726a3bac2..af4c89414 100644 --- a/configure.ac +++ b/configure.ac @@ -919,30 +919,6 @@ if test -n "$PYINCLUDE" || test -n "$PY3INCLUDE" ; then fi fi -AC_ARG_WITH(2to3, AS_HELP_STRING([--with-2to3=path], [Set location of Python 2to3 tool]), [PY2TO3BIN="$withval"], [PY2TO3BIN="yes"]) -if test -n "$PYTHON3"; then - if test "x$PY2TO3BIN" = xyes; then - py3to2=`echo $PYTHON3 | sed -e "s/python/2to3-/"` - AC_CHECK_PROGS(PY2TO3, $py3to2 2to3) - if test -z "$PY2TO3"; then - # Windows distributions don't always have the 2to3 executable - AC_MSG_CHECKING(for 2to3.py) - py2to3script="$PY3PREFIX/Tools/scripts/2to3.py" - if test -f "$py2to3script"; then - AC_MSG_RESULT($py2to3script) - PY2TO3="$PYTHON3 $py2to3script" - else - AC_MSG_RESULT(Not found) - fi - fi - else - PY2TO3="$PY2TO3BIN" - fi - if test -z "$PY2TO3"; then - PYTHON3= - fi -fi - #---------------------------------------------------------------- # Look for Perl5 #---------------------------------------------------------------- From cc94e5168f0853fcb7d95ea04cb93388df7d2b4d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 19:02:52 +0100 Subject: [PATCH 1945/2031] Add missing test to python test-suite --- Examples/test-suite/python/Makefile.in | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4c0507cbb..1ba1bb3f5 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -85,6 +85,7 @@ CPP11_TEST_CASES = \ cpp11_shared_ptr_const \ cpp11_shared_ptr_nullptr_in_containers \ cpp11_shared_ptr_overload \ + cpp11_shared_ptr_template_upcast \ cpp11_shared_ptr_upcast \ cpp11_std_unordered_map \ cpp11_std_unordered_multimap \ From c5e078c4374dc019966fd023d6ec296ac478d169 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 23:50:31 +0100 Subject: [PATCH 1946/2031] Revert 2to3 modification Use sys.maxint still for Python 2 --- Examples/test-suite/python/primitive_types_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py index f550fc2ab..7ed4b52d1 100644 --- a/Examples/test-suite/python/primitive_types_runme.py +++ b/Examples/test-suite/python/primitive_types_runme.py @@ -472,7 +472,7 @@ maxllong = overllong - 1 maxullong = 2 * maxllong + 1 # Make sure Python 2's sys.maxint is the same as the maxlong we calculated -if sys.version_info[0] <= 2 and maxlong != sys.maxsize: +if sys.version_info[0] <= 2 and maxlong != sys.maxint: raise RuntimeError("sys.maxint is not the maximum value of a signed long") def checkType(t, e, val, delta): From b1c0145fd3d5e899552e8e4f83194f2dd365eb42 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2020 23:51:40 +0100 Subject: [PATCH 1947/2031] Python 3.2 syntax error fixes in tests --- .../python/python_strict_unicode_runme.py | 11 ++++--- .../python/unicode_strings_runme.py | 31 ++++++++++--------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Examples/test-suite/python/python_strict_unicode_runme.py b/Examples/test-suite/python/python_strict_unicode_runme.py index ba0e7d965..79c768de1 100644 --- a/Examples/test-suite/python/python_strict_unicode_runme.py +++ b/Examples/test-suite/python/python_strict_unicode_runme.py @@ -5,13 +5,16 @@ test_bytes = b"hello \x01world\x99" BYTES = b"BYTES" if sys.version_info[0:2] < (3, 0): - test_unicode = u"h\udce9llo w\u00f6rld" - UNICODE = u"UNICODE" - type_unicode_string = type(u"") + # Python 3.0-3.2 results in a SyntaxError when using u"" string literals, so we use a + # convoluted unicode string construction using unicode() and unichr(). + # Conventional Python 2 syntax shown in comments. + test_unicode = unicode("h" + unichr(0xdce9) + "llo w" + unichr(0x00f6) + "rld") # u"h\udce9llo w\u00f6rld" + UNICODE = unicode("UNICODE") + type_unicode_string = type(UNICODE) else: test_unicode = "h\udce9llo w\u00f6rld" UNICODE = "UNICODE" - type_unicode_string = type("") + type_unicode_string = type(UNICODE) # Test that byte string inputs and outputs work as expected bdbl = python_strict_unicode.double_str(test_bytes) diff --git a/Examples/test-suite/python/unicode_strings_runme.py b/Examples/test-suite/python/unicode_strings_runme.py index 108d0d2c9..57bd7abca 100644 --- a/Examples/test-suite/python/unicode_strings_runme.py +++ b/Examples/test-suite/python/unicode_strings_runme.py @@ -15,21 +15,24 @@ def check(s1, s2): # Testing SWIG_PYTHON_2_UNICODE flag which allows unicode strings to be passed to C if sys.version_info[0:2] < (3, 0): + # Python 3.0-3.2 results in a SyntaxError when using u"" string literals, so we use a + # convoluted unicode string construction using unicode() and unichr(). + # Conventional Python 2 syntax shown in comments. check(unicode_strings.charstring("hello1"), "hello1") - check(unicode_strings.charstring(str(u"hello2")), "hello2") - check(unicode_strings.charstring(u"hello3"), "hello3") + check(unicode_strings.charstring(str(unicode("hello2"))), "hello2") # u"hello2" + check(unicode_strings.charstring(unicode("hello3")), "hello3") # u"hello3" check(unicode_strings.charstring(str("hello4")), "hello4") - unicode_strings.charstring(u"hell\xb05") - unicode_strings.charstring(u"hell\u00f66") - low_surrogate_string = u"\udcff" + unicode_strings.charstring(unicode("hell" + unichr(0xb0) + "5")) # u"hell\xb05" + unicode_strings.charstring(unicode("hell" + unichr(0x00f6) +"6")) # u"hell\u00f66" + low_surrogate_string = unichr(0xdcff) # u"\udcff" + unicode_strings.instring(low_surrogate_string) else: low_surrogate_string = "\udcff" - -try: - unicode_strings.instring(low_surrogate_string) - # Will succeed with Python 2 -except TypeError as e: - # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError. - # The real error is actually: - # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed - pass + try: + unicode_strings.instring(low_surrogate_string) + raise RuntimeError("Exception should have been thrown") + except TypeError as e: + # Python 3 will fail the PyUnicode_AsUTF8String conversion resulting in a TypeError. + # The real error is actually: + # UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 0: surrogates not allowed + pass From 251ab662bfab0231a477e8965f6993e3e47f92fb Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Mon, 8 Jun 2020 03:18:37 +1000 Subject: [PATCH 1948/2031] Octave: error() must be called with an argument --- .../test-suite/octave/abstract_access_runme.m | 2 +- .../octave/abstract_typedef_runme.m | 2 +- Examples/test-suite/octave/callback_runme.m | 18 +++---- .../test-suite/octave/class_ignore_runme.m | 2 +- .../octave/class_scope_weird_runme.m | 2 +- .../octave/compactdefaultargs_runme.m | 8 +-- .../octave/constructor_copy_runme.m | 8 +-- .../test-suite/octave/default_args_runme.m | 8 +-- .../octave/director_abstract_runme.m | 6 +-- .../test-suite/octave/director_basic_runme.m | 8 +-- .../test-suite/octave/director_enum_runme.m | 2 +- .../test-suite/octave/director_nested_runme.m | 4 +- .../test-suite/octave/director_unroll_runme.m | 2 +- .../test-suite/octave/enum_template_runme.m | 4 +- Examples/test-suite/octave/enums_runme.m | 8 +-- .../octave/extend_template_ns_runme.m | 4 +- .../test-suite/octave/extend_template_runme.m | 4 +- .../test-suite/octave/extend_variable_runme.m | 2 +- Examples/test-suite/octave/friends_runme.m | 18 +++---- Examples/test-suite/octave/grouping_runme.m | 4 +- Examples/test-suite/octave/iadd_runme.m | 2 +- Examples/test-suite/octave/inout_runme.m | 10 ++-- Examples/test-suite/octave/inplaceadd_runme.m | 8 +-- Examples/test-suite/octave/input_runme.m | 8 +-- .../test-suite/octave/li_attribute_runme.m | 32 ++++++------ .../test-suite/octave/li_carrays_cpp_runme.m | 2 +- Examples/test-suite/octave/li_carrays_runme.m | 2 +- Examples/test-suite/octave/li_cmalloc_runme.m | 2 +- .../test-suite/octave/li_cpointer_cpp_runme.m | 2 +- .../test-suite/octave/li_cpointer_runme.m | 2 +- Examples/test-suite/octave/li_cstring_runme.m | 14 +++--- .../test-suite/octave/li_cwstring_runme.m | 18 +++---- Examples/test-suite/octave/li_factory_runme.m | 4 +- .../test-suite/octave/li_std_carray_runme.m | 6 +-- Examples/test-suite/octave/li_std_set_runme.m | 26 +++++----- .../test-suite/octave/li_std_stream_runme.m | 2 +- .../octave/li_std_string_extra_runme.m | 10 ++-- .../test-suite/octave/li_std_wstream_runme.m | 2 +- .../test-suite/octave/multi_import_runme.m | 10 ++-- .../octave/namespace_typemap_runme.m | 50 +++++++++---------- Examples/test-suite/octave/naturalvar_runme.m | 2 +- .../octave/overload_extend2_runme.m | 16 +++--- .../octave/overload_extend_c_runme.m | 10 ++-- .../test-suite/octave/overload_extend_runme.m | 10 ++-- Examples/test-suite/octave/preproc_runme.m | 8 +-- .../test-suite/octave/primitive_ref_runme.m | 26 +++++----- .../octave/reference_global_vars_runme.m | 34 ++++++------- .../test-suite/octave/rename_scope_runme.m | 4 +- .../test-suite/octave/ret_by_value_runme.m | 4 +- .../octave/smart_pointer_extend_runme.m | 12 ++--- .../octave/smart_pointer_member_runme.m | 10 ++-- .../octave/smart_pointer_multi_runme.m | 4 +- .../smart_pointer_multi_typedef_runme.m | 4 +- .../octave/smart_pointer_overload_runme.m | 12 ++--- .../octave/smart_pointer_rename_runme.m | 6 +-- .../octave/smart_pointer_simple_runme.m | 4 +- .../smart_pointer_templatevariables_runme.m | 8 +-- .../octave/smart_pointer_typedef_runme.m | 4 +- .../octave/static_const_member_2_runme.m | 2 +- .../test-suite/octave/std_containers_runme.m | 2 +- .../test-suite/octave/struct_value_runme.m | 4 +- Examples/test-suite/octave/swigobject_runme.m | 6 +-- .../octave/template_extend1_runme.m | 4 +- .../octave/template_extend2_runme.m | 4 +- .../octave/template_inherit_runme.m | 30 +++++------ .../test-suite/octave/template_ns4_runme.m | 2 +- .../test-suite/octave/template_ns_runme.m | 8 +-- .../octave/template_tbase_template_runme.m | 2 +- .../octave/template_typedef_cplx2_runme.m | 6 +-- .../octave/template_typedef_runme.m | 8 +-- .../octave/typemap_namespace_runme.m | 4 +- .../octave/typemap_ns_using_runme.m | 2 +- .../test-suite/octave/types_directive_runme.m | 4 +- Examples/test-suite/octave/using1_runme.m | 2 +- Examples/test-suite/octave/using2_runme.m | 2 +- .../test-suite/octave/virtual_poly_runme.m | 12 ++--- Examples/test-suite/octave/voidtest_runme.m | 6 +-- 77 files changed, 308 insertions(+), 308 deletions(-) diff --git a/Examples/test-suite/octave/abstract_access_runme.m b/Examples/test-suite/octave/abstract_access_runme.m index e49343a92..e47223c47 100644 --- a/Examples/test-suite/octave/abstract_access_runme.m +++ b/Examples/test-suite/octave/abstract_access_runme.m @@ -2,6 +2,6 @@ abstract_access d = abstract_access.D(); if (d.do_x() != 1) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/abstract_typedef_runme.m b/Examples/test-suite/octave/abstract_typedef_runme.m index e57f71504..6f90b8159 100644 --- a/Examples/test-suite/octave/abstract_typedef_runme.m +++ b/Examples/test-suite/octave/abstract_typedef_runme.m @@ -10,7 +10,7 @@ a = A(); if (a.write(e) != 1) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/callback_runme.m b/Examples/test-suite/octave/callback_runme.m index db9f7888d..95df598f1 100644 --- a/Examples/test-suite/octave/callback_runme.m +++ b/Examples/test-suite/octave/callback_runme.m @@ -2,39 +2,39 @@ _callback callback if (foo(2) != 2) - error + error("failed"); endif if (A_bar(2) != 4) - error + error("failed"); endif if (foobar(3, _callback.foo) != foo(3)) - error + error("failed"); endif if (foobar(3, foo) != foo(3)) - error + error("failed"); endif if (foobar(3, A_bar) != A_bar(3)) - error + error("failed"); endif if (foobar(3, foof) != foof(3)) - error + error("failed"); endif if (foobar_i(3, foo_i) != foo_i(3)) - error + error("failed"); endif if (foobar_d(3.5, foo_d) != foo_d(3.5)) - error + error("failed"); endif a = A(); if (foobarm(3, a, A.foom_cb_ptr) != a.foom(3)) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/class_ignore_runme.m b/Examples/test-suite/octave/class_ignore_runme.m index 3e52047c2..53cad9570 100644 --- a/Examples/test-suite/octave/class_ignore_runme.m +++ b/Examples/test-suite/octave/class_ignore_runme.m @@ -8,5 +8,5 @@ class_ignore a = class_ignore.Bar(); if (!strcmp(class_ignore.do_blah(a),"Bar::blah")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/class_scope_weird_runme.m b/Examples/test-suite/octave/class_scope_weird_runme.m index 2fc857808..b0e975359 100644 --- a/Examples/test-suite/octave/class_scope_weird_runme.m +++ b/Examples/test-suite/octave/class_scope_weird_runme.m @@ -3,5 +3,5 @@ class_scope_weird f = class_scope_weird.Foo(); g = class_scope_weird.Foo(3); if (f.bar(3) != 3) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/compactdefaultargs_runme.m b/Examples/test-suite/octave/compactdefaultargs_runme.m index 08e872724..ada60dcbe 100644 --- a/Examples/test-suite/octave/compactdefaultargs_runme.m +++ b/Examples/test-suite/octave/compactdefaultargs_runme.m @@ -4,21 +4,21 @@ defaults1 = Defaults1(1000); defaults1 = Defaults1(); if (defaults1.ret(10.0) != 10.0) - error + error("failed"); endif if (defaults1.ret() != -1.0) - error + error("failed"); endif defaults2 = Defaults2(1000); defaults2 = Defaults2(); if (defaults2.ret(10.0) != 10.0) - error + error("failed"); endif if (defaults2.ret() != -1.0) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/constructor_copy_runme.m b/Examples/test-suite/octave/constructor_copy_runme.m index e450214c6..b6d3c3b6a 100644 --- a/Examples/test-suite/octave/constructor_copy_runme.m +++ b/Examples/test-suite/octave/constructor_copy_runme.m @@ -10,7 +10,7 @@ f11 = Foo1(f1); if (f1.x != f11.x) - error + error("failed"); endif @@ -23,7 +23,7 @@ catch end_try_catch if (!good) - error + error("failed"); endif @@ -31,7 +31,7 @@ bi = Bari(5); bc = Bari(bi); if (bi.x != bc.x) - error + error("failed"); endif @@ -44,6 +44,6 @@ catch end_try_catch if (!good) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/default_args_runme.m b/Examples/test-suite/octave/default_args_runme.m index 3d00f63e0..d2c6b4a6f 100644 --- a/Examples/test-suite/octave/default_args_runme.m +++ b/Examples/test-suite/octave/default_args_runme.m @@ -7,19 +7,19 @@ default_args if (default_args.Statics.staticmethod() != 60) - error + error("failed"); endif if (default_args.cfunc1(1) != 2) - error + error("failed"); endif if (default_args.cfunc2(1) != 3) - error + error("failed"); endif if (default_args.cfunc3(1) != 4) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/director_abstract_runme.m b/Examples/test-suite/octave/director_abstract_runme.m index 657e2e1d9..c96cf7554 100644 --- a/Examples/test-suite/octave/director_abstract_runme.m +++ b/Examples/test-suite/octave/director_abstract_runme.m @@ -28,17 +28,17 @@ MyExample3=@() subclass(director_abstract.Example3_i(),'Color',@(self,r,g,b) b); me1 = MyExample1(); if (director_abstract.Example1.get_color(me1, 1,2,3) != 1) - error + error("failed"); endif me2 = MyExample2(1,2); if (me2.get_color(me2, 1,2,3) != 2) - error + error("failed"); endif me3 = MyExample3(); if (me3.get_color(me3, 1,2,3) != 3) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/director_basic_runme.m b/Examples/test-suite/octave/director_basic_runme.m index 9de54a385..9a411a703 100644 --- a/Examples/test-suite/octave/director_basic_runme.m +++ b/Examples/test-suite/octave/director_basic_runme.m @@ -33,7 +33,7 @@ endif a = director_basic.A1(1); if (a.rg(2) != 2) - error + error("failed"); endif function self=OctClass() @@ -62,16 +62,16 @@ bd = dd.cmethod(b); cc.method(b); if (c.cmethod != 7) - error + error("failed"); endif if (bc.x != 34) - error + error("failed"); endif if (bd.x != 16) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/director_enum_runme.m b/Examples/test-suite/octave/director_enum_runme.m index 96f158d39..59a5ccf8b 100644 --- a/Examples/test-suite/octave/director_enum_runme.m +++ b/Examples/test-suite/octave/director_enum_runme.m @@ -6,5 +6,5 @@ b = director_enum.Foo(); a = MyFoo(); if (a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi)) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/director_nested_runme.m b/Examples/test-suite/octave/director_nested_runme.m index 6e1d0ded9..614af0c60 100644 --- a/Examples/test-suite/octave/director_nested_runme.m +++ b/Examples/test-suite/octave/director_nested_runme.m @@ -31,9 +31,9 @@ c = FooBar_int_get_self(cc); c.advance(); if (!strcmp(c.get_name(),"FooBar::get_name hello")) - error + error("failed"); endif if (!strcmp(c.name(),"FooBar::get_name hello")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/director_unroll_runme.m b/Examples/test-suite/octave/director_unroll_runme.m index 6ca213c4c..607b9d5ef 100644 --- a/Examples/test-suite/octave/director_unroll_runme.m +++ b/Examples/test-suite/octave/director_unroll_runme.m @@ -11,6 +11,6 @@ c = b.get(); if (swig_this(a) != swig_this(c)) a,c - error + error("failed"); endif diff --git a/Examples/test-suite/octave/enum_template_runme.m b/Examples/test-suite/octave/enum_template_runme.m index a9f940a9f..1474ce1cc 100644 --- a/Examples/test-suite/octave/enum_template_runme.m +++ b/Examples/test-suite/octave/enum_template_runme.m @@ -6,13 +6,13 @@ endif enum_template if (enum_template.MakeETest() != 1) - error + error("failed"); endif enum_template.TakeETest(0); try a=enum_template.TakeETest(0); - error + error("failed"); catch end_try_catch diff --git a/Examples/test-suite/octave/enums_runme.m b/Examples/test-suite/octave/enums_runme.m index b654d9d04..5f6bd6951 100644 --- a/Examples/test-suite/octave/enums_runme.m +++ b/Examples/test-suite/octave/enums_runme.m @@ -6,18 +6,18 @@ enums.bar3(1) enums.bar1(1) if (enums.cvar.enumInstance != 2) - error + error("failed"); endif if (enums.cvar.Slap != 10) - error + error("failed"); endif if (enums.cvar.Mine != 11) - error + error("failed"); endif if (enums.cvar.Thigh != 12) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/extend_template_ns_runme.m b/Examples/test-suite/octave/extend_template_ns_runme.m index e79a00dda..7196fac73 100644 --- a/Examples/test-suite/octave/extend_template_ns_runme.m +++ b/Examples/test-suite/octave/extend_template_ns_runme.m @@ -7,9 +7,9 @@ extend_template_ns f = Foo_One(); if (f.test1(37) != 37) - error + error("failed"); endif if (f.test2(42) != 42) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/extend_template_runme.m b/Examples/test-suite/octave/extend_template_runme.m index 1cad7bfc9..125bd4a5a 100644 --- a/Examples/test-suite/octave/extend_template_runme.m +++ b/Examples/test-suite/octave/extend_template_runme.m @@ -2,9 +2,9 @@ extend_template f = extend_template.Foo_0(); if (f.test1(37) != 37) - error + error("failed"); endif if (f.test2(42) != 42) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/extend_variable_runme.m b/Examples/test-suite/octave/extend_variable_runme.m index c55b6c55c..89af26c9d 100644 --- a/Examples/test-suite/octave/extend_variable_runme.m +++ b/Examples/test-suite/octave/extend_variable_runme.m @@ -1,6 +1,6 @@ extend_variable if (Foo.Bar != 42) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/friends_runme.m b/Examples/test-suite/octave/friends_runme.m index 31211567f..50a5b20ef 100644 --- a/Examples/test-suite/octave/friends_runme.m +++ b/Examples/test-suite/octave/friends_runme.m @@ -8,25 +8,25 @@ friends a = friends.A(2); if (friends.get_val1(a) != 2) - error + error("failed"); endif if (friends.get_val2(a) != 4) - error + error("failed"); endif if (friends.get_val3(a) != 6) - error + error("failed"); endif # nice overload working fine if (friends.get_val1(1,2,3) != 1) - error + error("failed"); endif b = friends.B(3); # David's case if (friends.mix(a,b) != 5) - error + error("failed"); endif di = friends.D_d(2); @@ -34,18 +34,18 @@ dd = friends.D_d(3.3); # incredible template overloading working just fine if (friends.get_val1(di) != 2) - error + error("failed"); endif if (friends.get_val1(dd) != 3.3) - error + error("failed"); endif friends.set(di, 4); friends.set(dd, 1.3); if (friends.get_val1(di) != 4) - error + error("failed"); endif if (friends.get_val1(dd) != 1.3) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/grouping_runme.m b/Examples/test-suite/octave/grouping_runme.m index 6d1a2d673..4e2c9ea2d 100644 --- a/Examples/test-suite/octave/grouping_runme.m +++ b/Examples/test-suite/octave/grouping_runme.m @@ -7,14 +7,14 @@ grouping x = grouping.test1(42); if (x != 42) - error + error("failed"); endif grouping.test2(42); x = (grouping.do_unary(37, grouping.NEGATE)); if (x != -37) - error + error("failed"); endif grouping.cvar.test3 = 42; diff --git a/Examples/test-suite/octave/iadd_runme.m b/Examples/test-suite/octave/iadd_runme.m index c386c669e..70cd75dae 100644 --- a/Examples/test-suite/octave/iadd_runme.m +++ b/Examples/test-suite/octave/iadd_runme.m @@ -6,5 +6,5 @@ f.AsA.x = 3; f.AsA += f.AsA; if (f.AsA.x != 6) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/inout_runme.m b/Examples/test-suite/octave/inout_runme.m index 74caaff46..c5d293eb6 100644 --- a/Examples/test-suite/octave/inout_runme.m +++ b/Examples/test-suite/octave/inout_runme.m @@ -2,26 +2,26 @@ inout a = inout.AddOne1(1); if (a != 2) - error + error("failed"); endif a = inout.AddOne3(1,1,1); if (a != [2,2,2]) - error + error("failed"); endif a = inout.AddOne1p((1,1)); if (a != (2,2)) - error + error("failed"); endif a = inout.AddOne2p((1,1),1); if (a != [(2,2),2]) - error + error("failed"); endif a = inout.AddOne3p(1,(1,1),1); if (a != [2,(2,2),2]) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/inplaceadd_runme.m b/Examples/test-suite/octave/inplaceadd_runme.m index 2bc193793..50b680aba 100644 --- a/Examples/test-suite/octave/inplaceadd_runme.m +++ b/Examples/test-suite/octave/inplaceadd_runme.m @@ -3,22 +3,22 @@ a = inplaceadd.A(7); a += 5; if (a.val != 12) - error + error("failed"); endif a -= 5; if a.val != 7: - error + error("failed"); endif a *= 2; if (a.val != 14) - error + error("failed"); endif a += a; if (a.val != 28) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/input_runme.m b/Examples/test-suite/octave/input_runme.m index 1a92d032b..477ffaac1 100644 --- a/Examples/test-suite/octave/input_runme.m +++ b/Examples/test-suite/octave/input_runme.m @@ -7,21 +7,21 @@ input f = Foo(); if (f.foo(2) != 4) - error + error("failed"); endif try a=f.foo(); - error + error("failed"); catch end_try_catch if (!strcmp(sfoo("Hello"),"Hello world")) - error + error("failed"); endif try a=sfoo(); - error + error("failed"); catch end_try_catch diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m index ed051d9df..5e239045f 100644 --- a/Examples/test-suite/octave/li_attribute_runme.m +++ b/Examples/test-suite/octave/li_attribute_runme.m @@ -8,7 +8,7 @@ li_attribute aa = li_attribute.A(1,2,3); if (aa.a != 1) - error + error("failed"); endif aa.a = 3; if (aa.a != 3) @@ -20,31 +20,31 @@ if (aa.b != 2) endif aa.b = 5; if (aa.b != 5) - error + error("failed"); endif if (aa.d != aa.b) - error + error("failed"); endif if (aa.c != 3) - error + error("failed"); endif pi = li_attribute.Param_i(7); if (pi.value != 7) - error + error("failed"); endif pi.value=3; if (pi.value != 3) - error + error("failed"); endif b = li_attribute.B(aa); if (b.a.c != 3) - error + error("failed"); endif # class/struct attribute with get/set methods using return/pass by reference @@ -53,38 +53,38 @@ myFoo.x = 8; myClass = li_attribute.MyClass(); myClass.Foo = myFoo; if (myClass.Foo.x != 8) - error + error("failed"); endif # class/struct attribute with get/set methods using return/pass by value myClassVal = li_attribute.MyClassVal(); if (myClassVal.ReadWriteFoo.x != -1) - error + error("failed"); endif if (myClassVal.ReadOnlyFoo.x != -1) - error + error("failed"); endif myClassVal.ReadWriteFoo = myFoo; if (myClassVal.ReadWriteFoo.x != 8) - error + error("failed"); endif if (myClassVal.ReadOnlyFoo.x != 8) - error + error("failed"); endif # string attribute with get/set methods using return/pass by value myStringyClass = li_attribute.MyStringyClass("initial string"); if (myStringyClass.ReadWriteString != "initial string") - error + error("failed"); endif if (myStringyClass.ReadOnlyString != "initial string") - error + error("failed"); endif myStringyClass.ReadWriteString = "changed string"; if (myStringyClass.ReadWriteString != "changed string") - error + error("failed"); endif if (myStringyClass.ReadOnlyString != "changed string") - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_carrays_cpp_runme.m b/Examples/test-suite/octave/li_carrays_cpp_runme.m index b3b520920..57e3e9a87 100644 --- a/Examples/test-suite/octave/li_carrays_cpp_runme.m +++ b/Examples/test-suite/octave/li_carrays_cpp_runme.m @@ -11,5 +11,5 @@ d(0) = 7; d(5) = d(0) + 3; if (d(5) + d(0) != 17) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_carrays_runme.m b/Examples/test-suite/octave/li_carrays_runme.m index c6b5f1619..5f180cce3 100644 --- a/Examples/test-suite/octave/li_carrays_runme.m +++ b/Examples/test-suite/octave/li_carrays_runme.m @@ -11,5 +11,5 @@ d(0) = 7; d(5) = d(0) + 3; if (d(5) + d(0) != 17) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_cmalloc_runme.m b/Examples/test-suite/octave/li_cmalloc_runme.m index 92bcd9515..5daea2cb9 100644 --- a/Examples/test-suite/octave/li_cmalloc_runme.m +++ b/Examples/test-suite/octave/li_cmalloc_runme.m @@ -17,6 +17,6 @@ catch end_try_catch if (ok != 1) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_cpointer_cpp_runme.m b/Examples/test-suite/octave/li_cpointer_cpp_runme.m index 463cf44f8..3551a17a9 100644 --- a/Examples/test-suite/octave/li_cpointer_cpp_runme.m +++ b/Examples/test-suite/octave/li_cpointer_cpp_runme.m @@ -5,7 +5,7 @@ p = new_intp(); intp_assign(p,3); if (intp_value(p) != 3) - error + error("failed"); endif delete_intp(p); diff --git a/Examples/test-suite/octave/li_cpointer_runme.m b/Examples/test-suite/octave/li_cpointer_runme.m index ce055cddd..995cc2abf 100644 --- a/Examples/test-suite/octave/li_cpointer_runme.m +++ b/Examples/test-suite/octave/li_cpointer_runme.m @@ -10,7 +10,7 @@ p = new_intp(); intp_assign(p,3); if (intp_value(p) != 3) - error + error("failed"); endif delete_intp(p); diff --git a/Examples/test-suite/octave/li_cstring_runme.m b/Examples/test-suite/octave/li_cstring_runme.m index 8aea6b709..4a706d33f 100644 --- a/Examples/test-suite/octave/li_cstring_runme.m +++ b/Examples/test-suite/octave/li_cstring_runme.m @@ -7,15 +7,15 @@ li_cstring if (count("ab\0ab\0ab\0", 0) != 3) - error + error("failed"); endif if (!strcmp(test1(),"Hello World")) - error + error("failed"); endif if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) - error + error("failed"); endif if (!strcmp(test3("hello"),"hello-suffix")) @@ -27,18 +27,18 @@ if (!strcmp(test4("hello"),"hello-suffix")) endif if (!strcmp(test5(4),'xxxx')) - error + error("failed"); endif if (!strcmp(test6(10),'xxxxx')) - error + error("failed"); endif if (!strcmp(test7(),"Hello world!")) - error + error("failed"); endif if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_cwstring_runme.m b/Examples/test-suite/octave/li_cwstring_runme.m index 1fb0962e7..5b9055110 100644 --- a/Examples/test-suite/octave/li_cwstring_runme.m +++ b/Examples/test-suite/octave/li_cwstring_runme.m @@ -6,38 +6,38 @@ endif li_cwstring if (count("ab\0ab\0ab\0", 0) != 3) - error + error("failed"); endif if (!strcmp(test1(),"Hello World")) - error + error("failed"); endif if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) - error + error("failed"); endif if (!strcmp(test3("hello"),"hello-suffix")) - error + error("failed"); endif if (!strcmp(test4("hello"),"hello-suffix")) - error + error("failed"); endif if (!strcmp(test5(4),'xxxx')) - error + error("failed"); endif if (!strcmp(test6(10),'xxxxx')) - error + error("failed"); endif if (!strcmp(test7(),"Hello world!")) - error + error("failed"); endif if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_factory_runme.m b/Examples/test-suite/octave/li_factory_runme.m index 5ea9b779f..7c07825f4 100644 --- a/Examples/test-suite/octave/li_factory_runme.m +++ b/Examples/test-suite/octave/li_factory_runme.m @@ -8,11 +8,11 @@ li_factory circle = Geometry_create(Geometry.CIRCLE); r = circle.radius(); if (r != 1.5) - error + error("failed"); endif point = Geometry_create(Geometry.POINT); w = point.width(); if (w != 1.0) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_std_carray_runme.m b/Examples/test-suite/octave/li_std_carray_runme.m index 4943fa8a2..f7212dc9a 100644 --- a/Examples/test-suite/octave/li_std_carray_runme.m +++ b/Examples/test-suite/octave/li_std_carray_runme.m @@ -9,7 +9,7 @@ endfor i = 0; for d in v3, if (d != i) - error + error("failed"); endif i = i + 1; endfor @@ -29,7 +29,7 @@ for v3 in m3, j = 0; for d in v3, if (d != i + j) - error + error("failed"); endif j = j + 1; endfor @@ -39,7 +39,7 @@ endfor for i=0:len(m3), for j=0:len(m3), if (m3(i,j) != i + j) - error + error("failed"); endif endfor endfor diff --git a/Examples/test-suite/octave/li_std_set_runme.m b/Examples/test-suite/octave/li_std_set_runme.m index 9bd4f152c..7f43f2f13 100644 --- a/Examples/test-suite/octave/li_std_set_runme.m +++ b/Examples/test-suite/octave/li_std_set_runme.m @@ -11,15 +11,15 @@ for i in s: sum = sum + i if (sum != "abc") - error + error("failed"); i = s.__iter__() if i.next() != "a": - error + error("failed"); if i.next() != "b": - error + error("failed"); if i.next() != "c": - error + error("failed"); b = s.begin() @@ -28,7 +28,7 @@ sum = "" while (b != e): sum = sum + b.next() if sum != "abc": - error + error("failed"); b = s.rbegin() e = s.rend() @@ -37,7 +37,7 @@ while (b != e): sum = sum + b.next() if sum != "cba": - error + error("failed"); @@ -49,11 +49,11 @@ si.append(3) i = si.__iter__() if i.next() != 1: - error + error("failed"); if i.next() != 2: - error + error("failed"); if i.next() != 3: - error + error("failed"); @@ -68,17 +68,17 @@ sum = "" while (b != e): sum = sum + b.next() if sum != "ac": - error + error("failed"); b = s.begin() e = s.end() if e - b != 2: - error + error("failed"); m = b + 1 if m.value() != "c": - error + error("failed"); @@ -93,4 +93,4 @@ for i in s: sum = sum + (i,) if sum != (1, 'hello', (1, 2)): - error + error("failed"); diff --git a/Examples/test-suite/octave/li_std_stream_runme.m b/Examples/test-suite/octave/li_std_stream_runme.m index bf9402e16..cedc8e59c 100644 --- a/Examples/test-suite/octave/li_std_stream_runme.m +++ b/Examples/test-suite/octave/li_std_stream_runme.m @@ -8,6 +8,6 @@ o << a << " " << 2345 << " " << 1.435; if (o.str() != "A class 2345 1.435") - error + error("failed"); endif diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m index 8d506af8a..15e18eec7 100644 --- a/Examples/test-suite/octave/li_std_string_extra_runme.m +++ b/Examples/test-suite/octave/li_std_string_extra_runme.m @@ -140,23 +140,23 @@ endif if (li_std_string_extra.test_reference_input("hello") != "hello") - error + error("failed"); endif s = li_std_string_extra.test_reference_inout("hello"); if (s != "hellohello") - error + error("failed"); endif if (li_std_string_extra.stdstring_empty() != "") - error + error("failed"); endif if (li_std_string_extra.c_empty() != "") - error + error("failed"); endif #if (li_std_string_extra.c_null() != None) -# error +# error("failed"); #endif diff --git a/Examples/test-suite/octave/li_std_wstream_runme.m b/Examples/test-suite/octave/li_std_wstream_runme.m index a017e8acd..4f1c62166 100644 --- a/Examples/test-suite/octave/li_std_wstream_runme.m +++ b/Examples/test-suite/octave/li_std_wstream_runme.m @@ -9,6 +9,6 @@ o = wostringstream(); o << a << u" " << 2345 << u" " << 1.435 << wends; if (o.str() != "A class 2345 1.435\0") - error + error("failed"); endif diff --git a/Examples/test-suite/octave/multi_import_runme.m b/Examples/test-suite/octave/multi_import_runme.m index 2b7a610d4..d22ff5c81 100644 --- a/Examples/test-suite/octave/multi_import_runme.m +++ b/Examples/test-suite/octave/multi_import_runme.m @@ -8,22 +8,22 @@ multi_import_b; x = multi_import_b.XXX(); if (x.testx() != 0) - error + error("failed"); endif y = multi_import_b.YYY(); if (y.testx() != 0) - error + error("failed"); endif if (y.testy() != 1) - error + error("failed"); endif z = multi_import_a.ZZZ(); if (z.testx() != 0) - error + error("failed"); endif if (z.testz() != 2) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/namespace_typemap_runme.m b/Examples/test-suite/octave/namespace_typemap_runme.m index ca3730773..d7e338104 100644 --- a/Examples/test-suite/octave/namespace_typemap_runme.m +++ b/Examples/test-suite/octave/namespace_typemap_runme.m @@ -1,106 +1,106 @@ namespace_typemap if (!strcmp(stest1("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest2("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest3("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest4("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest5("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest6("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest7("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest8("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest9("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest10("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest11("hello"),"hello")) - error + error("failed"); endif if (!strcmp(stest12("hello"),"hello")) - error + error("failed"); endif c = complex(2,3); r = real(c); if (ctest1(c) != r) - error + error("failed"); endif if (ctest2(c) != r) - error + error("failed"); endif if (ctest3(c) != r) - error + error("failed"); endif if (ctest4(c) != r) - error + error("failed"); endif if (ctest5(c) != r) - error + error("failed"); endif if (ctest6(c) != r) - error + error("failed"); endif if (ctest7(c) != r) - error + error("failed"); endif if (ctest8(c) != r) - error + error("failed"); endif if (ctest9(c) != r) - error + error("failed"); endif if (ctest10(c) != r) - error + error("failed"); endif if (ctest11(c) != r) - error + error("failed"); endif if (ctest12(c) != r) - error + error("failed"); endif try ttest1(-14) - error + error("failed"); catch end_try_catch diff --git a/Examples/test-suite/octave/naturalvar_runme.m b/Examples/test-suite/octave/naturalvar_runme.m index 6059b0273..40546f26c 100644 --- a/Examples/test-suite/octave/naturalvar_runme.m +++ b/Examples/test-suite/octave/naturalvar_runme.m @@ -14,6 +14,6 @@ cvar.s = "hello"; b.s = "hello"; if (b.s != cvar.s) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/overload_extend2_runme.m b/Examples/test-suite/octave/overload_extend2_runme.m index 6db6b66bb..e4611948e 100644 --- a/Examples/test-suite/octave/overload_extend2_runme.m +++ b/Examples/test-suite/octave/overload_extend2_runme.m @@ -2,29 +2,29 @@ overload_extend2 f = overload_extend2.Foo(); if (f.test(3) != 1) - error + error("failed"); endif if (f.test("hello") != 2) - error + error("failed"); endif if (f.test(3.5,2.5) != 3) - error + error("failed"); endif if (f.test("hello",20) != 1020) - error + error("failed"); endif if (f.test("hello",20,100) != 120) - error + error("failed"); endif # C default args if (f.test(f) != 30) - error + error("failed"); endif if (f.test(f,100) != 120) - error + error("failed"); endif if (f.test(f,100,200) != 300) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/overload_extend_c_runme.m b/Examples/test-suite/octave/overload_extend_c_runme.m index 79b92ca47..2a6c5c21e 100644 --- a/Examples/test-suite/octave/overload_extend_c_runme.m +++ b/Examples/test-suite/octave/overload_extend_c_runme.m @@ -7,18 +7,18 @@ overload_extend_c f = overload_extend_c.Foo(); if (f.test() != 0) - error + error("failed"); endif if (f.test(3) != 1) - error + error("failed"); endif if (f.test("hello") != 2) - error + error("failed"); endif if (f.test(3,2) != 5) - error + error("failed"); endif if (f.test(3.1)-.1 != 1003) # :) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/overload_extend_runme.m b/Examples/test-suite/octave/overload_extend_runme.m index d9959804f..a29f1910e 100644 --- a/Examples/test-suite/octave/overload_extend_runme.m +++ b/Examples/test-suite/octave/overload_extend_runme.m @@ -7,18 +7,18 @@ overload_extend f = overload_extend.Foo(); if (f.test() != 0) - error + error("failed"); endif if (f.test(3) != 1) - error + error("failed"); endif if (f.test("hello") != 2) - error + error("failed"); endif if (f.test(3,2) != 5) - error + error("failed"); endif if (f.test(3.1)-.1 != 1003) # :) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/preproc_runme.m b/Examples/test-suite/octave/preproc_runme.m index e9af66e78..80f1d32ba 100644 --- a/Examples/test-suite/octave/preproc_runme.m +++ b/Examples/test-suite/octave/preproc_runme.m @@ -6,18 +6,18 @@ endif preproc if (preproc.cvar.endif != 1) - error + error("failed"); endif if (preproc.cvar.define != 1) - error + error("failed"); endif if (preproc.cvar.defined != 1) - error + error("failed"); endif if (2*preproc.one != preproc.two) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/primitive_ref_runme.m b/Examples/test-suite/octave/primitive_ref_runme.m index 68a5750c3..799b6db17 100644 --- a/Examples/test-suite/octave/primitive_ref_runme.m +++ b/Examples/test-suite/octave/primitive_ref_runme.m @@ -1,53 +1,53 @@ primitive_ref if (ref_int(3) != 3) - error + error("failed"); endif if (ref_uint(3) != 3) - error + error("failed"); endif if (ref_short(3) != 3) - error + error("failed"); endif if (ref_ushort(3) != 3) - error + error("failed"); endif if (ref_long(3) != 3) - error + error("failed"); endif if (ref_ulong(3) != 3) - error + error("failed"); endif if (ref_schar(3) != 3) - error + error("failed"); endif if (ref_uchar(3) != 3) - error + error("failed"); endif if (ref_float(3.5) != 3.5) - error + error("failed"); endif if (ref_double(3.5) != 3.5) - error + error("failed"); endif if (ref_bool(true) != true) - error + error("failed"); endif if (!strcmp(ref_char('x'),'x')) - error + error("failed"); endif if (ref_over(0) != 0) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/reference_global_vars_runme.m b/Examples/test-suite/octave/reference_global_vars_runme.m index 67ad9c514..c7f4f56b7 100644 --- a/Examples/test-suite/octave/reference_global_vars_runme.m +++ b/Examples/test-suite/octave/reference_global_vars_runme.m @@ -2,90 +2,90 @@ reference_global_vars # const class reference variable if (getconstTC().num != 33) - error + error("failed"); endif # primitive reference variables cvar.var_bool = createref_bool(false); if (value_bool(cvar.var_bool) != 0) - error + error("failed"); endif cvar.var_bool = createref_bool(true); if (value_bool(cvar.var_bool) != 1) - error + error("failed"); endif cvar.var_char = createref_char('w'); if (!strcmp(value_char(cvar.var_char),'w')) - error + error("failed"); endif cvar.var_unsigned_char = createref_unsigned_char(10); if (value_unsigned_char(cvar.var_unsigned_char) != 10) - error + error("failed"); endif cvar.var_signed_char = createref_signed_char(10); if (value_signed_char(cvar.var_signed_char) != 10) - error + error("failed"); endif cvar.var_short = createref_short(10); if (value_short(cvar.var_short) != 10) - error + error("failed"); endif cvar.var_unsigned_short = createref_unsigned_short(10); if (value_unsigned_short(cvar.var_unsigned_short) != 10) - error + error("failed"); endif cvar.var_int = createref_int(10); if (value_int(cvar.var_int) != 10) - error + error("failed"); endif cvar.var_unsigned_int = createref_unsigned_int(10); if (value_unsigned_int(cvar.var_unsigned_int) != 10) - error + error("failed"); endif cvar.var_long = createref_long(10); if (value_long(cvar.var_long) != 10) - error + error("failed"); endif cvar.var_unsigned_long = createref_unsigned_long(10); if (value_unsigned_long(cvar.var_unsigned_long) != 10) - error + error("failed"); endif cvar.var_long_long = createref_long_long(int64(0x6FFFFFFFFFFFFFF8)); if (value_long_long(cvar.var_long_long) != int64(0x6FFFFFFFFFFFFFF8)) - error + error("failed"); endif #ull = abs(0xFFFFFFF2FFFFFFF0) ull = uint64(55834574864); cvar.var_unsigned_long_long = createref_unsigned_long_long(ull); if (value_unsigned_long_long(cvar.var_unsigned_long_long) != ull) - error + error("failed"); endif cvar.var_float = createref_float(10.5); if (value_float(cvar.var_float) != 10.5) - error + error("failed"); endif cvar.var_double = createref_double(10.5); if (value_double(cvar.var_double) != 10.5) - error + error("failed"); endif # class reference variable cvar.var_TestClass = createref_TestClass(TestClass(20)); if (value_TestClass(cvar.var_TestClass).num != 20) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/rename_scope_runme.m b/Examples/test-suite/octave/rename_scope_runme.m index 154f99dfe..776d218c5 100644 --- a/Examples/test-suite/octave/rename_scope_runme.m +++ b/Examples/test-suite/octave/rename_scope_runme.m @@ -4,11 +4,11 @@ a = Natural_UP(); b = Natural_BP(); if (a.rtest() != 1) - error + error("failed"); endif if (b.rtest() != 1) - error + error("failed"); endif f = @equals; diff --git a/Examples/test-suite/octave/ret_by_value_runme.m b/Examples/test-suite/octave/ret_by_value_runme.m index 67f80aae2..c1c508353 100644 --- a/Examples/test-suite/octave/ret_by_value_runme.m +++ b/Examples/test-suite/octave/ret_by_value_runme.m @@ -7,9 +7,9 @@ ret_by_value a = ret_by_value.get_test(); if (a.myInt != 100) - error + error("failed"); endif if (a.myShort != 200) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_extend_runme.m b/Examples/test-suite/octave/smart_pointer_extend_runme.m index 6c9258e6d..cf82f7350 100644 --- a/Examples/test-suite/octave/smart_pointer_extend_runme.m +++ b/Examples/test-suite/octave/smart_pointer_extend_runme.m @@ -9,7 +9,7 @@ f = Foo(); b = Bar(f); if (b.extension() != f.extension()) - error + error("failed"); endif @@ -18,15 +18,15 @@ d = CDerived(); p = CPtr(); if (b.bar() != p.bar()) - error + error("failed"); endif if (d.foo() != p.foo()) - error + error("failed"); endif if (b.hello() != p.hello()) - error + error("failed"); endif @@ -36,11 +36,11 @@ d = DFoo(); dp = DPtrFoo(d); if (d.SExt(1) != dp.SExt(1)) - error + error("failed"); endif if (d.Ext(1) != dp.Ext(1)) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_member_runme.m b/Examples/test-suite/octave/smart_pointer_member_runme.m index 30251c3a8..1c2d0e9ed 100644 --- a/Examples/test-suite/octave/smart_pointer_member_runme.m +++ b/Examples/test-suite/octave/smart_pointer_member_runme.m @@ -4,7 +4,7 @@ f = Foo(); f.y = 1; if (f.y != 1) - error + error("failed"); endif b = Bar(f); @@ -15,18 +15,18 @@ if (f.y != 2) endif if (swig_this(b.x) != swig_this(f.x)) - error + error("failed"); endif if (b.z != f.z) - error + error("failed"); endif try if (Foo.z == Bar.z) - error + error("failed"); endif - error + error("failed"); catch end_try_catch diff --git a/Examples/test-suite/octave/smart_pointer_multi_runme.m b/Examples/test-suite/octave/smart_pointer_multi_runme.m index 71ef9109a..ea15d04b9 100644 --- a/Examples/test-suite/octave/smart_pointer_multi_runme.m +++ b/Examples/test-suite/octave/smart_pointer_multi_runme.m @@ -7,11 +7,11 @@ g = Grok(b); s.x = 3; if (s.getx() != 3) - error + error("failed"); endif g.x = 4; if (g.getx() != 4) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m b/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m index 4b77e0eea..c2ab78714 100644 --- a/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m +++ b/Examples/test-suite/octave/smart_pointer_multi_typedef_runme.m @@ -7,12 +7,12 @@ g = Grok(b); s.x = 3; if (s.getx() != 3) - error + error("failed"); endif g.x = 4; if (g.getx() != 4) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_overload_runme.m b/Examples/test-suite/octave/smart_pointer_overload_runme.m index a5df0ded4..1bfb68354 100644 --- a/Examples/test-suite/octave/smart_pointer_overload_runme.m +++ b/Examples/test-suite/octave/smart_pointer_overload_runme.m @@ -10,23 +10,23 @@ b = Bar(f); if (f.test(3) != 1) - error + error("failed"); endif if (f.test(3.5) != 2) - error + error("failed"); endif if (f.test("hello") != 3) - error + error("failed"); endif if (b.test(3) != 1) - error + error("failed"); endif if (b.test(3.5) != 2) - error + error("failed"); endif if (b.test("hello") != 3) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_rename_runme.m b/Examples/test-suite/octave/smart_pointer_rename_runme.m index 5eb6d4c3c..307bd8f95 100644 --- a/Examples/test-suite/octave/smart_pointer_rename_runme.m +++ b/Examples/test-suite/octave/smart_pointer_rename_runme.m @@ -9,14 +9,14 @@ f = Foo(); b = Bar(f); if (b.test() != 3) - error + error("failed"); endif if (b.ftest1(1) != 1) - error + error("failed"); endif if (b.ftest2(2,3) != 2) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_simple_runme.m b/Examples/test-suite/octave/smart_pointer_simple_runme.m index 30b1387c4..c15c43ca9 100644 --- a/Examples/test-suite/octave/smart_pointer_simple_runme.m +++ b/Examples/test-suite/octave/smart_pointer_simple_runme.m @@ -10,11 +10,11 @@ b = Bar(f); b.x = 3; if (b.getx() != 3) - error + error("failed"); endif fp = b.__deref__(); fp.x = 4; if (fp.getx() != 4) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m b/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m index 4884fa24b..ee45f68f9 100644 --- a/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m +++ b/Examples/test-suite/octave/smart_pointer_templatevariables_runme.m @@ -3,17 +3,17 @@ smart_pointer_templatevariables d = DiffImContainerPtr_D(create(1234, 5678)); if (d.id != 1234) - error + error("failed"); endif #if (d.xyz != 5678): -# error +# error("failed"); d.id = 4321; #d.xyz = 8765 if (d.id != 4321) - error + error("failed"); endif #if (d.xyz != 8765): -# error +# error("failed"); diff --git a/Examples/test-suite/octave/smart_pointer_typedef_runme.m b/Examples/test-suite/octave/smart_pointer_typedef_runme.m index 0e1c8a61e..3a094670f 100644 --- a/Examples/test-suite/octave/smart_pointer_typedef_runme.m +++ b/Examples/test-suite/octave/smart_pointer_typedef_runme.m @@ -10,11 +10,11 @@ b = Bar(f); b.x = 3; if (b.getx() != 3) - error + error("failed"); endif fp = b.__deref__(); fp.x = 4; if (fp.getx() != 4) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/static_const_member_2_runme.m b/Examples/test-suite/octave/static_const_member_2_runme.m index 73260bae7..8619fd1eb 100644 --- a/Examples/test-suite/octave/static_const_member_2_runme.m +++ b/Examples/test-suite/octave/static_const_member_2_runme.m @@ -18,6 +18,6 @@ end_try_catch if (Foo.BAZ.val != 2*Foo.BAR.val) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/std_containers_runme.m b/Examples/test-suite/octave/std_containers_runme.m index eae3d5d9f..d069b585c 100644 --- a/Examples/test-suite/octave/std_containers_runme.m +++ b/Examples/test-suite/octave/std_containers_runme.m @@ -132,7 +132,7 @@ s.append(3); j=1; for i in s, if (i != j) - error + error("failed"); endif j = j + 1; endfor diff --git a/Examples/test-suite/octave/struct_value_runme.m b/Examples/test-suite/octave/struct_value_runme.m index ff344047e..7f7448bb6 100644 --- a/Examples/test-suite/octave/struct_value_runme.m +++ b/Examples/test-suite/octave/struct_value_runme.m @@ -9,10 +9,10 @@ b = struct_value.Bar(); b.a.x = 3; if (b.a.x != 3) - error + error("failed"); endif b.b.x = 3; if (b.b.x != 3) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/swigobject_runme.m b/Examples/test-suite/octave/swigobject_runme.m index 73167e497..9ab3aa8c6 100644 --- a/Examples/test-suite/octave/swigobject_runme.m +++ b/Examples/test-suite/octave/swigobject_runme.m @@ -11,7 +11,7 @@ a1 = a_ptr(a); a2 = a_ptr(a); if (swig_this(a1) != swig_this(a2)) - error + error("failed"); endif @@ -20,7 +20,7 @@ xstr1 = printf("0x%x",lthis); xstr2 = pointer_str(a); if (xstr1 != xstr2) - error + error("failed"); endif s = str(a.this); @@ -29,5 +29,5 @@ r = repr(a.this); v1 = v_ptr(a); v2 = v_ptr(a); if (uint64(v1) != uint64(v2)) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_extend1_runme.m b/Examples/test-suite/octave/template_extend1_runme.m index 5035debf5..05e534107 100644 --- a/Examples/test-suite/octave/template_extend1_runme.m +++ b/Examples/test-suite/octave/template_extend1_runme.m @@ -9,9 +9,9 @@ a = template_extend1.lBaz(); b = template_extend1.dBaz(); if (!strcmp(a.foo(),"lBaz::foo")) - error + error("failed"); endif if (!strcmp(b.foo(),"dBaz::foo")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_extend2_runme.m b/Examples/test-suite/octave/template_extend2_runme.m index 24472a9ed..e9b5fb799 100644 --- a/Examples/test-suite/octave/template_extend2_runme.m +++ b/Examples/test-suite/octave/template_extend2_runme.m @@ -9,9 +9,9 @@ a = template_extend2.lBaz(); b = template_extend2.dBaz(); if (!strcmp(a.foo(),"lBaz::foo")) - error + error("failed"); endif if (!strcmp(b.foo(),"dBaz::foo")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_inherit_runme.m b/Examples/test-suite/octave/template_inherit_runme.m index 368cce227..72d7e7511 100644 --- a/Examples/test-suite/octave/template_inherit_runme.m +++ b/Examples/test-suite/octave/template_inherit_runme.m @@ -12,62 +12,62 @@ e = FooUInt(); f = BarUInt(); if (!strcmp(a.blah(),"Foo")) - error + error("failed"); endif if (!strcmp(b.blah(),"Foo")) - error + error("failed"); endif if (!strcmp(e.blah(),"Foo")) - error + error("failed"); endif if (!strcmp(c.blah(),"Bar")) - error + error("failed"); endif if (!strcmp(d.blah(),"Bar")) - error + error("failed"); endif if (!strcmp(f.blah(),"Bar")) - error + error("failed"); endif if (!strcmp(c.foomethod(),"foomethod")) - error + error("failed"); endif if (!strcmp(d.foomethod(),"foomethod")) - error + error("failed"); endif if (!strcmp(f.foomethod(),"foomethod")) - error + error("failed"); endif if (!strcmp(invoke_blah_int(a),"Foo")) - error + error("failed"); endif if (!strcmp(invoke_blah_int(c),"Bar")) - error + error("failed"); endif if (!strcmp(invoke_blah_double(b),"Foo")) - error + error("failed"); endif if (!strcmp(invoke_blah_double(d),"Bar")) - error + error("failed"); endif if (!strcmp(invoke_blah_uint(e),"Foo")) - error + error("failed"); endif if (!strcmp(invoke_blah_uint(f),"Bar")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_ns4_runme.m b/Examples/test-suite/octave/template_ns4_runme.m index b5746427b..6dff55694 100644 --- a/Examples/test-suite/octave/template_ns4_runme.m +++ b/Examples/test-suite/octave/template_ns4_runme.m @@ -7,5 +7,5 @@ template_ns4 d = make_Class_DD(); if (!strcmp(d.test(),"test")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_ns_runme.m b/Examples/test-suite/octave/template_ns_runme.m index 29a2f53f6..44b13e62c 100644 --- a/Examples/test-suite/octave/template_ns_runme.m +++ b/Examples/test-suite/octave/template_ns_runme.m @@ -3,19 +3,19 @@ p1 = pairii(2,3); p2 = pairii(p1); if (p2.first != 2) - error + error("failed"); endif if (p2.second != 3) - error + error("failed"); endif p3 = pairdd(3.5,2.5); p4 = pairdd(p3); if (p4.first != 3.5) - error + error("failed"); endif if (p4.second != 2.5) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_tbase_template_runme.m b/Examples/test-suite/octave/template_tbase_template_runme.m index da8ec4c69..b1bfd8f7d 100644 --- a/Examples/test-suite/octave/template_tbase_template_runme.m +++ b/Examples/test-suite/octave/template_tbase_template_runme.m @@ -2,5 +2,5 @@ template_tbase_template a = make_Class_dd(); if (!strcmp(a.test(),"test")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/template_typedef_cplx2_runme.m b/Examples/test-suite/octave/template_typedef_cplx2_runme.m index a72e0f1e0..eb783fe81 100644 --- a/Examples/test-suite/octave/template_typedef_cplx2_runme.m +++ b/Examples/test-suite/octave/template_typedef_cplx2_runme.m @@ -15,7 +15,7 @@ end_try_catch if (strfind('ArithUnaryFunction',swig_type(d)) != 1) d error("is not an ArithUnaryFunction") - error + error("failed"); endif try @@ -77,7 +77,7 @@ end_try_catch if (strfind('ArithUnaryFunction',swig_type(g)) != 1) g error("is not an ArithUnaryFunction") - error + error("failed"); endif @@ -98,6 +98,6 @@ try a = g.get_value(); catch error(g, "has not get_value() method") - error + error("failed"); end_try_catch diff --git a/Examples/test-suite/octave/template_typedef_runme.m b/Examples/test-suite/octave/template_typedef_runme.m index 8d8af795b..2a734e207 100644 --- a/Examples/test-suite/octave/template_typedef_runme.m +++ b/Examples/test-suite/octave/template_typedef_runme.m @@ -8,7 +8,7 @@ try a = swig_this(d); a = swig_this(c); catch - error + error("failed"); end_try_catch try @@ -37,15 +37,15 @@ end_try_catch # the old large format if (strcmp("",swig_typequery("vfncs::ArithUnaryFunction::argument_type,vfncs::arith_traits::result_type > *"))) - error + error("failed"); endif # the reduced format if (strcmp("",swig_typequery("vfncs::ArithUnaryFunction *"))) - error + error("failed"); endif # this is a bad name if (!strcmp("",swig_typequery("vfncs::ArithUnaryFunction *"))) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/typemap_namespace_runme.m b/Examples/test-suite/octave/typemap_namespace_runme.m index ec62a3910..e67781c66 100644 --- a/Examples/test-suite/octave/typemap_namespace_runme.m +++ b/Examples/test-suite/octave/typemap_namespace_runme.m @@ -1,10 +1,10 @@ typemap_namespace if (!strcmp(test1("hello"),"hello")) - error + error("failed"); endif if (!strcmp(test2("hello"),"hello")) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/typemap_ns_using_runme.m b/Examples/test-suite/octave/typemap_ns_using_runme.m index dd3f657f0..d94241b9c 100644 --- a/Examples/test-suite/octave/typemap_ns_using_runme.m +++ b/Examples/test-suite/octave/typemap_ns_using_runme.m @@ -1,5 +1,5 @@ typemap_ns_using if (typemap_ns_using.spam(37) != 37) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/types_directive_runme.m b/Examples/test-suite/octave/types_directive_runme.m index 0757c6c39..5ad4af1bb 100644 --- a/Examples/test-suite/octave/types_directive_runme.m +++ b/Examples/test-suite/octave/types_directive_runme.m @@ -3,13 +3,13 @@ types_directive d1 = Time1(2001, 2, 3, 60); newDate = add(d1, 7); # check that a Time1 instance is accepted where Date is expected if (newDate.day != 10) - error + error("failed"); endif d2 = Time2(1999, 8, 7, 60); newDate = add(d2, 7); # check that a Time2 instance is accepted where Date is expected if (newDate.day != 14) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/using1_runme.m b/Examples/test-suite/octave/using1_runme.m index 9253a1d35..e25128ec7 100644 --- a/Examples/test-suite/octave/using1_runme.m +++ b/Examples/test-suite/octave/using1_runme.m @@ -6,5 +6,5 @@ endif using1 if (using1.spam(37) != 37) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/using2_runme.m b/Examples/test-suite/octave/using2_runme.m index 7cc668940..0213ee7c6 100644 --- a/Examples/test-suite/octave/using2_runme.m +++ b/Examples/test-suite/octave/using2_runme.m @@ -6,5 +6,5 @@ endif using2 if (using2.spam(37) != 37) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/virtual_poly_runme.m b/Examples/test-suite/octave/virtual_poly_runme.m index 0c7c95153..363f86798 100644 --- a/Examples/test-suite/octave/virtual_poly_runme.m +++ b/Examples/test-suite/octave/virtual_poly_runme.m @@ -10,23 +10,23 @@ dc = d.copy(); ic = i.copy(); if (d.get() != dc.get()) - error + error("failed"); endif if (i.get() != ic.get()) - error + error("failed"); endif virtual_poly.incr(ic); if ((i.get() + 1) != ic.get()) - error + error("failed"); endif dr = d.ref_this(); if (d.get() != dr.get()) - error + error("failed"); endif @@ -35,10 +35,10 @@ endif # ddc = virtual_poly.NDouble_narrow(d.nnumber()); if (d.get() != ddc.get()) - error + error("failed"); endif dic = virtual_poly.NInt_narrow(i.nnumber()); if (i.get() != dic.get()) - error + error("failed"); endif diff --git a/Examples/test-suite/octave/voidtest_runme.m b/Examples/test-suite/octave/voidtest_runme.m index fb411ee4e..c4815a597 100644 --- a/Examples/test-suite/octave/voidtest_runme.m +++ b/Examples/test-suite/octave/voidtest_runme.m @@ -27,16 +27,16 @@ end_try_catch v1 = voidtest.vfunc1(f); v2 = voidtest.vfunc2(f); if (swig_this(v1) != swig_this(v2)) - error + error("failed"); endif v3 = voidtest.vfunc3(v1); if (swig_this(v3) != swig_this(f)) - error + error("failed"); endif v4 = voidtest.vfunc1(f); if (swig_this(v4) != swig_this(v1)) - error + error("failed"); endif From 9c50887daa2b44251e77be8123c63df238034cf5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2020 10:07:45 +0100 Subject: [PATCH 1949/2031] Python 3.9 support Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls it automatically now. This removes a deprecation warning when using Python 3.9. https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads --- CHANGES.current | 4 ++++ Lib/python/pythreads.swg | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2d8037197..c1bac0667 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-08-16: wsfulton + [Python] Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls + it automatically now. This removes a deprecation warning when using Python 3.9. + 2020-08-15: wsfulton [Python] All Python examples and tests are written to be Python 2 and Python 3 compatible, removing the need for 2to3 to run the examples or test-suite. diff --git a/Lib/python/pythreads.swg b/Lib/python/pythreads.swg index d8797e659..8d6c5ab49 100644 --- a/Lib/python/pythreads.swg +++ b/Lib/python/pythreads.swg @@ -8,8 +8,12 @@ # define SWIG_PYTHON_USE_GIL # endif # if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# if PY_VERSION_HEX < 0x03070000 +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# else +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif # endif # ifdef __cplusplus /* C++ code */ class SWIG_Python_Thread_Block { From e774fe5cfd564df8542545830213859de2f676c4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2020 13:52:32 +0100 Subject: [PATCH 1950/2031] Python 3.9 support for -builtin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing initializer for member ‘_heaptypeobject::ht_module’ to complete Python 3.9 support. --- CHANGES.current | 4 ++++ Source/Modules/python.cxx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index c1bac0667..2eb67c929 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-08-16: wsfulton + [Python] Add missing initializer for member ‘_heaptypeobject::ht_module’ when using + -builtin to complete Python 3.9 support. + 2020-08-16: wsfulton [Python] Remove PyEval_InitThreads() call for Python 3.7 and later as Python calls it automatically now. This removes a deprecation warning when using Python 3.9. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index c8c45df35..b437d2f6f 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -4308,6 +4308,10 @@ public: // struct _dictkeysobject *ht_cached_keys; printSlot(f, getSlot(n, "feature:python:ht_cached_keys"), "ht_cached_keys"); Printv(f, "#endif\n", NIL); + + Printv(f, "#if PY_VERSION_HEX >= 0x03090000\n", NIL); + printSlot(f, getSlot(n, "feature:python:ht_module"), "ht_module", "PyObject *"); + Printv(f, "#endif\n", NIL); Printf(f, "};\n\n"); String *clientdata = NewString(""); From 70e78d41256be5524f2dfb166abbcb7abdc97b6e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2020 10:16:50 +0100 Subject: [PATCH 1951/2031] Travis testing of Python 3.9 --- .travis.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b806c85e0..43936b5cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -217,6 +217,11 @@ matrix: env: SWIGLANG=python PY3=3 VER=3.8 sudo: required dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=python PY3=3 VER=3.9 + sudo: required + dist: xenial - compiler: gcc os: linux env: SWIGLANG=python SWIG_FEATURES=-builtin @@ -232,7 +237,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.8 + env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.9 sudo: required dist: xenial - compiler: gcc @@ -257,12 +262,17 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.8 + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9 sudo: required dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.8 SWIGOPTPY3= + env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.9 + sudo: required + dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9 SWIGOPTPY3= sudo: required dist: xenial - compiler: gcc @@ -272,7 +282,7 @@ matrix: dist: xenial - compiler: gcc os: linux - env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.8 + env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.9 sudo: required dist: xenial - compiler: gcc @@ -404,7 +414,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.8 + env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.9 sudo: required dist: xenial - os: linux @@ -416,7 +426,7 @@ matrix: sudo: required dist: xenial - os: linux - env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.8 + env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.9 sudo: required dist: xenial - os: linux From b018c32f9d0ba963560fa08da84802c23c41d89d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 28 Aug 2020 18:23:47 +0100 Subject: [PATCH 1952/2031] Fix crashes in swig_connect_director during director class construction. Occurs when using the director class from multiple threads - a race condition initialising block scope static variables. Block scope static variables are guaranteed to be thread safe in C++11, so the fix is guaranteed when using C++11. However, most modern compilers also fix it when using C++03/C++98. Closes #1862 --- CHANGES.current | 6 ++++++ Lib/java/director.swg | 14 ++++++++++++++ Source/Modules/java.cxx | 31 ++++++++++--------------------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2eb67c929..e557ec9ad 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-08-28: wsfulton + [Java] #1862 Fix crashes in swig_connect_director during director class construction + when using the director class from multiple threads - a race condition initialising + block scope static variables. The fix is guaranteed when using C++11, but most + compilers also fix it when using C++03/C++98. + 2020-08-16: wsfulton [Python] Add missing initializer for member ‘_heaptypeobject::ht_module’ when using -builtin to complete Python 3.9 support. diff --git a/Lib/java/director.swg b/Lib/java/director.swg index d3bd162ec..e911a3da7 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -215,6 +215,15 @@ namespace Swig { } }; + struct SwigDirectorMethod { + const char *name; + const char *desc; + jmethodID methid; + SwigDirectorMethod(JNIEnv *jenv, jclass baseclass, const char *name, const char *desc) : name(name), desc(desc) { + methid = jenv->GetMethodID(baseclass, name, desc); + } + }; + /* Java object wrapper */ JObjectWrapper swig_self_; @@ -238,6 +247,11 @@ namespace Swig { } } + jclass swig_new_global_ref(JNIEnv *jenv, const char *classname) { + jclass clz = jenv->FindClass(classname); + return clz ? (jclass)jenv->NewGlobalRef(clz) : 0; + } + public: Director(JNIEnv *jenv) : swig_jvm_((JavaVM *) NULL), swig_self_() { /* Acquire the Java VM pointer */ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7734c6471..231c6c0cb 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4835,34 +4835,27 @@ public: // .'s to delimit namespaces, so we need to replace those with /'s Replace(internal_classname, NSPACE_SEPARATOR, "/", DOH_REPLACE_ANY); - Wrapper_add_localv(w, "baseclass", "static jclass baseclass", "= 0", NIL); Printf(w->def, "void %s::swig_connect_director(JNIEnv *jenv, jobject jself, jclass jcls, bool swig_mem_own, bool weak_global) {", director_classname); + Printf(w->def, "static jclass baseclass = swig_new_global_ref(jenv, \"%s\");\n", internal_classname); + Printf(w->def, "if (!baseclass) return;\n"); + if (first_class_dmethod != curr_class_dmethod) { - Printf(w->def, "static struct {\n"); - Printf(w->def, "const char *mname;\n"); - Printf(w->def, "const char *mdesc;\n"); - Printf(w->def, "jmethodID base_methid;\n"); - Printf(w->def, "} methods[] = {\n"); + Printf(w->def, "static SwigDirectorMethod methods[] = {\n"); for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) { UpcallData *udata = Getitem(dmethods_seq, i); - Printf(w->def, "{ \"%s\", \"%s\", NULL }", Getattr(udata, "method"), Getattr(udata, "fdesc")); + Printf(w->def, "SwigDirectorMethod(jenv, baseclass, \"%s\", \"%s\")", Getattr(udata, "method"), Getattr(udata, "fdesc")); if (i != curr_class_dmethod - 1) Putc(',', w->def); Putc('\n', w->def); } - Printf(w->def, "};\n"); + Printf(w->def, "};"); } Printf(w->code, "if (swig_set_self(jenv, jself, swig_mem_own, weak_global)) {\n"); - Printf(w->code, "if (!baseclass) {\n"); - Printf(w->code, "baseclass = jenv->FindClass(\"%s\");\n", internal_classname); - Printf(w->code, "if (!baseclass) return;\n"); - Printf(w->code, "baseclass = (jclass) jenv->NewGlobalRef(baseclass);\n"); - Printf(w->code, "}\n"); int n_methods = curr_class_dmethod - first_class_dmethod; @@ -4877,12 +4870,8 @@ public: /* Emit the code to look up the class's methods, initialize the override array */ - Printf(w->code, "bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);\n"); - Printf(w->code, "for (int i = 0; i < %d; ++i) {\n", n_methods); - Printf(w->code, " if (!methods[i].base_methid) {\n"); - Printf(w->code, " methods[i].base_methid = jenv->GetMethodID(baseclass, methods[i].mname, methods[i].mdesc);\n"); - Printf(w->code, " if (!methods[i].base_methid) return;\n"); - Printf(w->code, " }\n"); + Printf(w->code, " bool derived = (jenv->IsSameObject(baseclass, jcls) ? false : true);\n"); + Printf(w->code, " for (int i = 0; i < %d; ++i) {\n", n_methods); // Generally, derived classes have a mix of overridden and // non-overridden methods and it is worth making a GetMethodID // check during initialization to determine if each method is @@ -4902,8 +4891,8 @@ public: } else { Printf(w->code, " swig_override[i] = false;\n"); Printf(w->code, " if (derived) {\n"); - Printf(w->code, " jmethodID methid = jenv->GetMethodID(jcls, methods[i].mname, methods[i].mdesc);\n"); - Printf(w->code, " swig_override[i] = (methid != methods[i].base_methid);\n"); + Printf(w->code, " jmethodID methid = jenv->GetMethodID(jcls, methods[i].name, methods[i].desc);\n"); + Printf(w->code, " swig_override[i] = methods[i].methid && (methid != methods[i].methid);\n"); Printf(w->code, " jenv->ExceptionClear();\n"); Printf(w->code, " }\n"); } From 975f8fcfdba56294bb190d745cdd449a52e633f4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Sep 2020 10:44:49 +1200 Subject: [PATCH 1953/2031] Avoid undefined behaviour in DOH Replace() function If the source and replacement strings were the same length, the code was performing undefined pointer arithmetic involving a NULL pointer. I'm not aware of any observable effects of this in practice, but it's potentially problematic. It's detected by ubsan, for example when running `make check-python-test-suite`: DOH/string.c:839:4: runtime error: applying non-zero offset to non-null pointer 0x602000001558 produced null pointer SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DOH/string.c:839:4 in --- Source/DOH/string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 3689f4ffe..093330b89 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -836,7 +836,9 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co memmove(t, s, (str->str + str->len) - s + 1); } } else { - t += (c - s); + if (c) { + t += (c - s); + } } s = c; ic--; From beb1d8498d4927bcf203e8ba564d9cbe7569fde1 Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Sat, 5 Sep 2020 17:03:34 +0100 Subject: [PATCH 1954/2031] Fix C# wchar_t* csvarout to be same as csout --- Lib/csharp/wchar.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index 798194114..1ece767da 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -92,7 +92,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStri } %} %typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{ get { - string ret = $imcall;$excode + string ret = global::System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode return ret; } %} From 6db3ab0d050397e57bff654ca183b92d67b1b704 Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Sat, 12 Sep 2020 16:57:44 +0100 Subject: [PATCH 1955/2031] Add test for wchar_t members to li_std_string.i --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 7 +++++++ Examples/test-suite/li_std_wstring.i | 5 +++++ Examples/test-suite/python/li_std_wstring_runme.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index 8b7ba1b30..c96c8c723 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -75,6 +75,13 @@ public class runme check_equal(li_std_wstring.test_ccvalue(x), "abc"); check_equal(li_std_wstring.test_wchar_overload(x), "abc"); + // Member variables + var s = new wchar_test_struct(); + s.wchar_t_member = h; + check_equal(s.wchar_t_member, h); + s.wchar_t_ptr_member = x; + check_equal(s.wchar_t_ptr_member, "abc"); + { // Unicode strings string[] test_strings = { diff --git a/Examples/test-suite/li_std_wstring.i b/Examples/test-suite/li_std_wstring.i index 55d45383e..a790ca7e0 100644 --- a/Examples/test-suite/li_std_wstring.i +++ b/Examples/test-suite/li_std_wstring.i @@ -70,6 +70,11 @@ size_t size_wstring(const std::wstring& s) { return s.size(); } +struct wchar_test_struct { + wchar_t wchar_t_member; + wchar_t* wchar_t_ptr_member; +}; + %} #endif diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py index ef2085c66..ca8dc3184 100644 --- a/Examples/test-suite/python/li_std_wstring_runme.py +++ b/Examples/test-suite/python/li_std_wstring_runme.py @@ -54,6 +54,12 @@ check_equal(li_std_wstring.test_value(x), x) check_equal(li_std_wstring.test_ccvalue(x), "abc") check_equal(li_std_wstring.test_wchar_overload(x), "abc") +ts = li_std_wstring.wchar_test_struct() +ts.wchar_t_member = h +check_equal(ts.wchar_t_member, h) +ts.wchar_t_ptr_member = s +check_equal(ts.wchar_t_ptr_member, s) + ################### Python specific # Byte strings only converted in Python 2 From 33765e5025d3585d2c6fefdb743a7c25efc3303e Mon Sep 17 00:00:00 2001 From: Gareth Francis Date: Sat, 12 Sep 2020 17:19:15 +0100 Subject: [PATCH 1956/2031] Extend C# wchar_t member test to pass unicode strings --- Examples/test-suite/csharp/li_std_wstring_runme.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index c96c8c723..d2927287f 100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs @@ -106,6 +106,13 @@ public class runme check_equal(received, expected); } + foreach (string expected in test_strings) + { + s.wchar_t_ptr_member = expected; + string received = s.wchar_t_ptr_member; + check_equal(received, expected); + } + /* Not working for Japanese and Russian characters on Windows, okay on Linux * Is fixed by adding CharSet=CharSet.Unicode to the DllImport, so change to: * [global::System.Runtime.InteropServices.DllImport("li_std_wstring", CharSet=global::System.Runtime.InteropServices.CharSet.Unicode, EntryPoint="CSharp_li_std_wstringNamespace_test_wcvalue")] From 71d48228605b0dcf97cc6baf4e4124355e821273 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Sep 2020 22:36:32 +0100 Subject: [PATCH 1957/2031] Add Ruby test for wchar_t members in li_std_string testcase --- Examples/test-suite/ruby/li_std_wstring_runme.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Examples/test-suite/ruby/li_std_wstring_runme.rb b/Examples/test-suite/ruby/li_std_wstring_runme.rb index 4922d8d90..170f80ebf 100644 --- a/Examples/test-suite/ruby/li_std_wstring_runme.rb +++ b/Examples/test-suite/ruby/li_std_wstring_runme.rb @@ -50,3 +50,10 @@ x = "abc\0def" swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding) swig_assert_equal("Li_std_wstring.test_ccvalue(x)", '"abc"', binding) swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", '"abc"', binding) + +ts = Li_std_wstring::Wchar_test_struct.new +ts.wchar_t_member = h +swig_assert_equal("ts.wchar_t_member", "h", binding) +ts.wchar_t_ptr_member = s +swig_assert_equal("ts.wchar_t_ptr_member", "s", binding) + From c8ac73513bb1e59a1f2a4ae1e48aba2244644fec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Sep 2020 22:39:01 +0100 Subject: [PATCH 1958/2031] changes file entry for C# wchar_t csvarout fix --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e557ec9ad..5386a7d36 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-09-24: geefr + [C#] #1868 Fix wchar_t* csvarout typemap for member variable wrappers. + 2020-08-28: wsfulton [Java] #1862 Fix crashes in swig_connect_director during director class construction when using the director class from multiple threads - a race condition initialising From c1b004f4fa62b1b15e047fd9462ddf3b46e55357 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 25 Sep 2020 18:54:25 +0100 Subject: [PATCH 1959/2031] Add access modifier support for interface feature Add ability to change the modifiers for the C# and Java interface generated when using the %interface macros. For C# use the 'csinterfacemodifiers' typemap. For Java use the 'javainterfacemodifiers' typemap. For example: %typemap(csinterfacemodifiers) X "internal interface" Closes #1874 --- CHANGES.current | 12 ++++++++ Doc/Manual/CSharp.html | 1 + Doc/Manual/Java.html | 11 +++++++- .../multiple_inheritance_interfaces.i | 28 +++++++++++++++++++ Lib/csharp/csharp.swg | 1 + Lib/java/java.swg | 1 + Source/Include/swigwarn.h | 2 ++ Source/Modules/csharp.cxx | 3 +- Source/Modules/java.cxx | 3 +- 9 files changed, 59 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 5386a7d36..1e88a89d4 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,18 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-09-25: wsfulton + [C#, Java] #1874 Add ability to change the modifiers for the interface + generated when using the %interface macros. + + For C# use the 'csinterfacemodifiers' typemap. + For Java use the 'javainterfacemodifiers' typemap. + + For example: + + %typemap(csinterfacemodifiers) X "internal interface" + + 2020-09-24: geefr [C#] #1868 Fix wchar_t* csvarout typemap for member variable wrappers. diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index ef4c0104d..fe8f7c4bd 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -240,6 +240,7 @@ javabody -> csbody javafinalize -> csfinalize javadestruct -> csdisposing and csdispose javadestruct_derived -> csdisposing_derived and csdispose_derived +javainterfacemodifiers -> csinterfacemodifiers javainterfacecode -> csinterfacecode diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index b9234b24f..2f55f5b04 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6610,6 +6610,15 @@ Below shows an example modifying the finalizer, assuming the delete met +

      %typemap(javainterfacemodifiers)

      +
      +Interface modifiers for the Java interface generated when using the interface feature, see Java interfaces section. The default is "public interface". +

      +Compatibility note: This typemap was added in SWIG-4.1.0. +

      + +
      +

      %typemap(javainterfacecode, declaration="...", cptrmethod="...")

      @@ -6709,7 +6718,7 @@ The "javaimports" typemap is ignored if the enum class is wrapped by an inner Ja

       [ javaimports typemap ]
      -public interface [ javainterfacename ] {
      +[ javainterfacemodifiers typemap ] [ javainterfacename ] {
       [ javainterfacecode:cptrmethod typemap attribute ]
       ... interface declarations ...
       }
      diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
      index 2972922fb..b7069647b 100644
      --- a/Examples/test-suite/multiple_inheritance_interfaces.i
      +++ b/Examples/test-suite/multiple_inheritance_interfaces.i
      @@ -64,3 +64,31 @@ struct DerivedOverloaded : public BaseOverloaded {
         virtual void identical_overload(int i, const PTypedef &p = PTypedef()) {}
       };
       %}
      +
      +
      +#if defined(SWIGJAVA) || defined(SWIGCSHARP)
      +%interface(Space::X)
      +#endif
      +
      +// Test the csinterfacemodifiers and javainterfacemodifiers typemaps.
      +#if defined(SWIGCSHARP)
      +/* change access from default "public class" to "internal class" */
      +%typemap(csclassmodifiers) InternalAccess "internal class"
      +/* The following modifiers are also needed with the above access modifier change */
      +%typemap(csclassmodifiers) Space::X "internal class"
      +%typemap(csinterfacemodifiers) Space::X "internal interface"
      +#elif defined(SWIGJAVA)
      +%typemap(javaclassmodifiers) InternalAccess "final /*notpublic*/ class"
      +%typemap(javaclassmodifiers) Space::X "final class"
      +%typemap(javainterfacemodifiers) Space::X "/*notpublic*/ interface"
      +#endif
      +
      +%inline %{
      +struct InternalAccess {};
      +namespace Space {
      +  class X {
      +  public:
      +    virtual void x(const InternalAccess& date) const = 0;
      +  };
      +}
      +%}
      diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
      index ecc1983a7..0e180f576 100644
      --- a/Lib/csharp/csharp.swg
      +++ b/Lib/csharp/csharp.swg
      @@ -894,6 +894,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
       %typemap(csinterfaces)                SWIGTYPE "global::System.IDisposable"
       %typemap(csinterfaces)                          SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
       %typemap(csinterfaces_derived)        SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
      +%typemap(csinterfacemodifiers)        SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
       
       
       // csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.
      diff --git a/Lib/java/java.swg b/Lib/java/java.swg
      index e9309331a..8f95f3a3b 100644
      --- a/Lib/java/java.swg
      +++ b/Lib/java/java.swg
      @@ -1196,6 +1196,7 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
       %typemap(javacode)             SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
       %typemap(javaimports)          SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
       %typemap(javainterfaces)       SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
      +%typemap(javainterfacemodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public interface"
       
       /* javabody typemaps */
       
      diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
      index a08693ac8..8362cc08e 100644
      --- a/Source/Include/swigwarn.h
      +++ b/Source/Include/swigwarn.h
      @@ -277,6 +277,7 @@
       #define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC   824
       #define WARN_JAVA_NO_DIRECTORCONNECT_ATTR     825
       #define WARN_JAVA_NSPACE_WITHOUT_PACKAGE      826
      +#define WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847
       
       /* please leave 810-829 free for Java */
       
      @@ -297,6 +298,7 @@
       #define WARN_CSHARP_EXCODE                    844
       #define WARN_CSHARP_CANTHROW                  845
       #define WARN_CSHARP_NO_DIRECTORCONNECT_ATTR   846
      +#define WARN_CSHARP_TYPEMAP_INTERFACEMODIFIERS_UNDEF 847
       
       /* please leave 830-849 free for C# */
       
      diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
      index 27cc65b32..5fef4caef 100644
      --- a/Source/Modules/csharp.cxx
      +++ b/Source/Modules/csharp.cxx
      @@ -2050,7 +2050,8 @@ public:
       
         void emitInterfaceDeclaration(Node *n, String *interface_name, File *f_interface) {
           Printv(f_interface, typemapLookup(n, "csimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
      -    Printf(f_interface, "public interface %s", interface_name);
      +    Printv(f_interface, typemapLookup(n, "csinterfacemodifiers", Getattr(n, "classtypeobj"), WARN_CSHARP_TYPEMAP_INTERFACEMODIFIERS_UNDEF), NIL);
      +    Printf(f_interface, " %s", interface_name);
           if (List *baselist = Getattr(n, "bases")) {
             String *bases = 0;
             for (Iterator base = First(baselist); base.item; base = Next(base)) {
      diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
      index 231c6c0cb..7c8bed480 100644
      --- a/Source/Modules/java.cxx
      +++ b/Source/Modules/java.cxx
      @@ -2145,7 +2145,8 @@ public:
           }
       
           Printv(f_interface, typemapLookup(n, "javaimports", Getattr(n, "classtypeobj"), WARN_NONE), "\n", NIL);
      -    Printf(f_interface, "public interface %s", interface_name);
      +    Printv(f_interface, typemapLookup(n, "javainterfacemodifiers", Getattr(n, "classtypeobj"), WARN_JAVA_TYPEMAP_INTERFACEMODIFIERS_UNDEF), NIL);
      +    Printf(f_interface, " %s", interface_name);
           if (List *baselist = Getattr(n, "bases")) {
             String *bases = 0;
             for (Iterator base = First(baselist); base.item; base = Next(base)) {
      
      From 61ea3c05decb295e072ec4d42ec34a512b0000f9 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Mon, 28 Sep 2020 09:57:51 +0100
      Subject: [PATCH 1960/2031] Add missing virtual destructor to testcase
      
      ---
       Examples/test-suite/multiple_inheritance_interfaces.i | 1 +
       1 file changed, 1 insertion(+)
      
      diff --git a/Examples/test-suite/multiple_inheritance_interfaces.i b/Examples/test-suite/multiple_inheritance_interfaces.i
      index b7069647b..98ec37b4f 100644
      --- a/Examples/test-suite/multiple_inheritance_interfaces.i
      +++ b/Examples/test-suite/multiple_inheritance_interfaces.i
      @@ -89,6 +89,7 @@ namespace Space {
         class X {
         public:
           virtual void x(const InternalAccess& date) const = 0;
      +    virtual ~X() {}
         };
       }
       %}
      
      From e71f781140df4265208d13d415822e8969bfc20e Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 7 Oct 2020 22:06:47 +0100
      Subject: [PATCH 1961/2031] Apply suggestions from code review
      
      Print errors to stderr instead of stdout
      ---
       Source/Modules/javascript.cxx | 4 ++--
       1 file changed, 2 insertions(+), 2 deletions(-)
      
      diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
      index 31576bd93..98f6d801f 100644
      --- a/Source/Modules/javascript.cxx
      +++ b/Source/Modules/javascript.cxx
      @@ -1575,7 +1575,7 @@ void JSCEmitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Ma
             Printf(arg, "argv[%d]", i);
             break;
           default:
      -      Printf(stdout, "Illegal state.");
      +      Printf(stderr, "Illegal MarshallingMode.");
             SWIG_exit(EXIT_FAILURE);
           }
           tm = emitInputTypemap(n, p, wrapper, arg);
      @@ -2213,7 +2213,7 @@ void V8Emitter::marshalInputArgs(Node *n, ParmList *parms, Wrapper *wrapper, Mar
             Printf(arg, "args[%d]", i);
             break;
           default:
      -      Printf(stdout, "Illegal state.");
      +      Printf(stderr, "Illegal MarshallingMode.");
             SWIG_exit(EXIT_FAILURE);
           }
       
      
      From 339377410b4e1b474eb505a6d68dedde26e1eae4 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 7 Oct 2020 22:21:37 +0100
      Subject: [PATCH 1962/2031] Put test in alphabetical order
      
      ---
       Examples/test-suite/javascript/Makefile.in | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
      index 4dc02e3bf..4fab31206 100644
      --- a/Examples/test-suite/javascript/Makefile.in
      +++ b/Examples/test-suite/javascript/Makefile.in
      @@ -51,8 +51,8 @@ ifeq (node,$(JSENGINE))
         # dunno... ignoring generously
         apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
         constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
      -  enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
         director_basic.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
      +  enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
       
       	setup_node = \
       		test -d $* || mkdir $* && \
      
      From b84cd9c53eb3944b00151f99d526bc92f3394875 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 7 Oct 2020 22:29:56 +0100
      Subject: [PATCH 1963/2031] Update changes file
      
      ---
       CHANGES.current | 7 +++++++
       1 file changed, 7 insertions(+)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 1e88a89d4..1a093e716 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
       Version 4.1.0 (in progress)
       ===========================
       
      +2020-10-07: treitmayr
      +            #1824 Add missing space in director method declaration returning
      +            const pointer.
      +
      +2020-10-07: adelva1984
      +            #1859 Remove all (two) exceptions from SWIG executable.
      +
       2020-09-25: wsfulton
                   [C#, Java] #1874 Add ability to change the modifiers for the interface
                   generated when using the %interface macros.
      
      From b4564499403242caa2c3ac5667fb9e099077f341 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 7 Oct 2020 22:41:04 +0100
      Subject: [PATCH 1964/2031] Update python_pybuffer_runme.py syntax for working
       under both python 2 and 3
      
      ---
       .../test-suite/python/python_pybuffer_runme.py   | 16 ++++++++--------
       1 file changed, 8 insertions(+), 8 deletions(-)
      
      diff --git a/Examples/test-suite/python/python_pybuffer_runme.py b/Examples/test-suite/python/python_pybuffer_runme.py
      index 7703cac12..65079200b 100644
      --- a/Examples/test-suite/python/python_pybuffer_runme.py
      +++ b/Examples/test-suite/python/python_pybuffer_runme.py
      @@ -47,24 +47,24 @@ else:
       
           try:
               python_pybuffer.func1(1)
      -        raise RuntimeError, "should throw TypeError"
      -    except TypeError, e:
      +        raise RuntimeError("should throw TypeError")
      +    except TypeError as e:
               check("(char *buf1, int len)" in str(e))
       
           try:
               python_pybuffer.func2(1)
      -        raise RuntimeError, "should throw TypeError"
      -    except TypeError, e:
      +        raise RuntimeError("should throw TypeError")
      +    except TypeError as e:
               check("(char *buf2)" in str(e))
       
           try:
               python_pybuffer.func3(1)
      -        raise RuntimeError, "should throw TypeError"
      -    except TypeError, e:
      +        raise RuntimeError("should throw TypeError")
      +    except TypeError as e:
               check("(const char *buf3, int len)" in str(e))
       
           try:
               python_pybuffer.func4(1)
      -        raise RuntimeError, "should throw TypeError"
      -    except TypeError, e:
      +        raise RuntimeError("should throw TypeError")
      +    except TypeError as e:
               check("(const char *buf4)" in str(e))
      
      From 0034b3572efbcd7de9c5a05dc68e7fa5f62e963e Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 7 Oct 2020 22:42:56 +0100
      Subject: [PATCH 1965/2031] Update changes file
      
      ---
       CHANGES.current | 3 +++
       1 file changed, 3 insertions(+)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 1a093e716..63548c672 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
       Version 4.1.0 (in progress)
       ===========================
       
      +2020-10-07: treitmayr
      +            [Python] #1812 Fix error handling in pybuffer.i PyObject_GetBuffer().
      +
       2020-10-07: treitmayr
                   #1824 Add missing space in director method declaration returning
                   const pointer.
      
      From 2cbf7d725a66fc13596a4a1b18117edc108237fe Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Fri, 9 Oct 2020 18:34:32 +0100
      Subject: [PATCH 1966/2031] Remove Remove runtime test for unsupported complex
       or _Complex by itself
      
      ---
       Examples/test-suite/python/complextest_runme.py | 8 --------
       1 file changed, 8 deletions(-)
      
      diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py
      index 4e7d08ffc..3eef2b2bc 100644
      --- a/Examples/test-suite/python/complextest_runme.py
      +++ b/Examples/test-suite/python/complextest_runme.py
      @@ -22,14 +22,6 @@ if 'Conjf3' in dir(complextest):
           if complextest.Conjf3(a) != a.conjugate():
               raise RuntimeError("bad complex mapping")
       
      -if 'Conj4' in dir(complextest):
      -    if complextest.Conj4(a) != a.conjugate():
      -        raise RuntimeError("bad complex mapping")
      -
      -if 'Conj5' in dir(complextest):
      -    if complextest.Conj5(a) != a.conjugate():
      -        raise RuntimeError("bad complex mapping")
      -
       if 'CopyHalf' in dir(complextest):
       
           v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
      
      From 57957787b71f7f25d9b7c8ae07223d33d29357e0 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 09:00:26 +0100
      Subject: [PATCH 1967/2031] Convert C++ comment to C comment
      
      ---
       Lib/python/pyhead.swg | 3 +--
       1 file changed, 1 insertion(+), 2 deletions(-)
      
      diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
      index b3bd39dfc..4ae8bbe2e 100644
      --- a/Lib/python/pyhead.swg
      +++ b/Lib/python/pyhead.swg
      @@ -79,8 +79,7 @@ SWIG_Python_str_FromChar(const char *c)
       # define PyObject_DEL PyObject_Del
       #endif
       
      -// SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user
      -// interface files check for it.
      +/* SWIGPY_USE_CAPSULE is no longer used within SWIG itself, but some user interface files check for it. */
       # define SWIGPY_USE_CAPSULE
       # define SWIGPY_CAPSULE_NAME ("swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
       
      
      From 9a2513bf8532e7375ecb1c2dc2949dddb22063d1 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 09:11:26 +0100
      Subject: [PATCH 1968/2031] Javascript v8 C complex wrappers fix
      
      ---
       Lib/javascript/v8/ccomplex.i | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Lib/javascript/v8/ccomplex.i b/Lib/javascript/v8/ccomplex.i
      index b4b925da7..e58dbf719 100644
      --- a/Lib/javascript/v8/ccomplex.i
      +++ b/Lib/javascript/v8/ccomplex.i
      @@ -6,7 +6,7 @@
        * ----------------------------------------------------------------------------- */
       
       
      -%include 
      +%include 
       
       %{
       #include 
      
      From fd592fdc3b01791eba19ed8eace26b7196d567c8 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 09:11:43 +0100
      Subject: [PATCH 1969/2031] Split C complex.h from C++ complex testing
      
      ---
       Examples/test-suite/ccomplextest.i            | 79 +++++++++++++++++++
       Examples/test-suite/complextest.i             | 63 ---------------
       Examples/test-suite/javascript/Makefile.in    |  3 +
       Examples/test-suite/octave/Makefile.in        |  8 --
       Examples/test-suite/python/Makefile.in        |  8 +-
       .../test-suite/python/ccomplextest_runme.py   | 24 ++++++
       .../test-suite/python/complextest_runme.py    | 30 +++----
       7 files changed, 117 insertions(+), 98 deletions(-)
       create mode 100644 Examples/test-suite/ccomplextest.i
       create mode 100644 Examples/test-suite/python/ccomplextest_runme.py
      
      diff --git a/Examples/test-suite/ccomplextest.i b/Examples/test-suite/ccomplextest.i
      new file mode 100644
      index 000000000..4a2f68ff6
      --- /dev/null
      +++ b/Examples/test-suite/ccomplextest.i
      @@ -0,0 +1,79 @@
      +%module ccomplextest
      +
      +%include 
      +
      +%{
      +#include 
      +
      +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199001L
      +#define HAS_C99_COMPLEX_FOR_TESTING 1
      +#else
      +/* complex not supported - hack tests to just test plain floating point numbers */
      +/* some pre c99 compilers (gcc-4.x) don't define _Complex but do define complex */
      +#define _Complex
      +#if !defined(complex)
      +#  define complex
      +#endif
      +#define conj
      +#define conjf
      +#if defined(I)
      +#  undef I
      +#  define I 1
      +#endif
      +#define HAS_C99_COMPLEX_FOR_TESTING 0
      +#endif
      +%}
      +
      +%inline
      +{
      +  int has_c99_complex(void) {
      +    return HAS_C99_COMPLEX_FOR_TESTING;
      +  }
      +
      +  complex double Conj(complex double a)
      +  {
      +    return conj(a);
      +  }
      +
      +
      +  complex float Conjf(complex float a)
      +  {
      +    return conjf(a);
      +  }
      +
      +
      +  double complex Conj1(double complex a)
      +  {
      +    return conj(a);
      +  }
      +
      +
      +  float complex Conjf1(float complex a)
      +  {
      +    return conjf(a);
      +  }
      +
      +
      +  _Complex double Conj2(_Complex double a)
      +  {
      +    return conj(a);
      +  }
      +
      +
      +  _Complex float Conjf2(_Complex float a)
      +  {
      +    return conjf(a);
      +  }
      +
      +
      +  double _Complex Conj3(double _Complex a)
      +  {
      +    return conj(a);
      +  }
      +
      +
      +  float _Complex Conjf3(float _Complex a)
      +  {
      +    return conjf(a);
      +  }
      +}
      diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/complextest.i
      index 622b38058..6c7b1f44a 100644
      --- a/Examples/test-suite/complextest.i
      +++ b/Examples/test-suite/complextest.i
      @@ -2,7 +2,6 @@
       
       %include 
       
      -#ifdef __cplusplus
       %{
       #include 
       #include 
      @@ -10,9 +9,7 @@
       %}
       %include 
       
      -#if 1
       %template(VectorStdCplx) std::vector >;
      -#endif
       
       %inline
       {
      @@ -63,63 +60,3 @@
         }
       }
       
      -
      -#else
      -
      -
      -%{
      -#include 
      -%}
      -
      -%inline
      -{
      -  complex double Conj(complex double a)
      -  {
      -    return conj(a);
      -  }
      -
      -
      -  complex float Conjf(complex float a)
      -  {
      -    return conjf(a);
      -  }
      -
      -
      -  double complex Conj1(double complex a)
      -  {
      -    return conj(a);
      -  }
      -
      -
      -  float complex Conjf1(float complex a)
      -  {
      -    return conjf(a);
      -  }
      -
      -
      -  _Complex double Conj2(_Complex double a)
      -  {
      -    return conj(a);
      -  }
      -
      -
      -  _Complex float Conjf2(_Complex float a)
      -  {
      -    return conjf(a);
      -  }
      -
      -
      -  double _Complex Conj3(double _Complex a)
      -  {
      -    return conj(a);
      -  }
      -
      -
      -  float _Complex Conjf3(float _Complex a)
      -  {
      -    return conjf(a);
      -  }
      -}
      -
      -
      -#endif
      diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
      index 4fab31206..d42ffec5a 100644
      --- a/Examples/test-suite/javascript/Makefile.in
      +++ b/Examples/test-suite/javascript/Makefile.in
      @@ -13,6 +13,9 @@ srcdir       = @srcdir@
       top_srcdir   = @top_srcdir@
       top_builddir = @top_builddir@
       
      +C_TEST_CASES += \
      +	ccomplextest \
      +
       SWIGEXE   = $(top_builddir)/swig
       SWIG_LIB_DIR = $(top_srcdir)/Lib
       
      diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
      index 1d54a47bb..9602d85f5 100644
      --- a/Examples/test-suite/octave/Makefile.in
      +++ b/Examples/test-suite/octave/Makefile.in
      @@ -29,14 +29,6 @@ CPP_TEST_BROKEN += \
       	li_std_set \
       	li_std_stream
       
      -#C_TEST_CASES +=
      -
      -#
      -# This test only works with modern C compilers
      -#
      -#C_TEST_CASES += \
      -#	complextest
      -
       include $(srcdir)/../common.mk
       
       # Overridden variables here
      diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
      index 7ca98b3bc..c2528eb49 100644
      --- a/Examples/test-suite/python/Makefile.in
      +++ b/Examples/test-suite/python/Makefile.in
      @@ -83,19 +83,13 @@ CPP11_TEST_CASES = \
       	cpp11_std_unordered_set \
       
       C_TEST_CASES += \
      -	complextest \
      +	ccomplextest \
       	file_test \
       	li_cstring \
       	li_cwstring \
       	python_nondynamic \
       	python_varargs_typemap \
       
      -#
      -# This test only works with modern C compilers
      -#
      -#C_TEST_CASES += \
      -#	complextest
      -
       include $(srcdir)/../common.mk
       
       # Overridden variables here
      diff --git a/Examples/test-suite/python/ccomplextest_runme.py b/Examples/test-suite/python/ccomplextest_runme.py
      new file mode 100644
      index 000000000..60b95458d
      --- /dev/null
      +++ b/Examples/test-suite/python/ccomplextest_runme.py
      @@ -0,0 +1,24 @@
      +import ccomplextest
      +
      +a = complex(-1, 2)
      +
      +if ccomplextest.has_c99_complex():
      +    if ccomplextest.Conj(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +
      +    if ccomplextest.Conjf(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +
      +    if ccomplextest.Conj2(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +
      +    if ccomplextest.Conjf2(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +
      +    if ccomplextest.Conj3(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +
      +    if ccomplextest.Conjf3(a) != a.conjugate():
      +        raise RuntimeError("bad complex mapping")
      +else:
      +    print("Not a c99 compiler")
      diff --git a/Examples/test-suite/python/complextest_runme.py b/Examples/test-suite/python/complextest_runme.py
      index 3eef2b2bc..1b9ad6629 100644
      --- a/Examples/test-suite/python/complextest_runme.py
      +++ b/Examples/test-suite/python/complextest_runme.py
      @@ -14,26 +14,16 @@ if complextest.Conj2(a) != a.conjugate():
       if complextest.Conjf2(a) != a.conjugate():
           raise RuntimeError("bad complex mapping")
       
      -if 'Conj3' in dir(complextest):
      -    if complextest.Conj3(a) != a.conjugate():
      -        raise RuntimeError("bad complex mapping")
      +v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
       
      -if 'Conjf3' in dir(complextest):
      -    if complextest.Conjf3(a) != a.conjugate():
      -        raise RuntimeError("bad complex mapping")
      +if len(complextest.CopyHalf(v)) != 2:
      +    raise RuntimeError("CopyHalf failed")
       
      -if 'CopyHalf' in dir(complextest):
      +if len(complextest.CopyHalfRef(v)) != 2:
      +    raise RuntimeError("CopyHalfRef failed")
       
      -    v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
      -
      -    if len(complextest.CopyHalf(v)) != 2:
      -        raise RuntimeError("CopyHalf failed")
      -
      -    if len(complextest.CopyHalfRef(v)) != 2:
      -        raise RuntimeError("CopyHalfRef failed")
      -
      -    p = complextest.ComplexPair()
      -    p.z1 = complex(0, 1)
      -    p.z2 = complex(0, -1)
      -    if complextest.Conj(p.z2) != p.z1:
      -        raise RuntimeError("bad complex mapping")
      +p = complextest.ComplexPair()
      +p.z1 = complex(0, 1)
      +p.z2 = complex(0, -1)
      +if complextest.Conj(p.z2) != p.z1:
      +    raise RuntimeError("bad complex mapping")
      
      From 04e49b174be7b917695f33568082cca76f79f83c Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 11:10:29 +0100
      Subject: [PATCH 1970/2031] Further ccomplextest hacks
      
      For visual c++ compilation when using creal and cimag.
      ---
       Examples/test-suite/ccomplextest.i | 4 +++-
       1 file changed, 3 insertions(+), 1 deletion(-)
      
      diff --git a/Examples/test-suite/ccomplextest.i b/Examples/test-suite/ccomplextest.i
      index 4a2f68ff6..c631dc02e 100644
      --- a/Examples/test-suite/ccomplextest.i
      +++ b/Examples/test-suite/ccomplextest.i
      @@ -8,7 +8,7 @@
       #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199001L
       #define HAS_C99_COMPLEX_FOR_TESTING 1
       #else
      -/* complex not supported - hack tests to just test plain floating point numbers */
      +/* c99 complex not supported - super hack tests to just test plain floating point numbers */
       /* some pre c99 compilers (gcc-4.x) don't define _Complex but do define complex */
       #define _Complex
       #if !defined(complex)
      @@ -16,6 +16,8 @@
       #endif
       #define conj
       #define conjf
      +#define creal
      +#define cimag
       #if defined(I)
       #  undef I
       #  define I 1
      
      From f318bb828667e8cd71c6ee1d62dad038e96c6c71 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 11:44:51 +0100
      Subject: [PATCH 1971/2031] Add missing clean targets
      
      template_typedef_cplx2 files are generated by the template_typedef_import.multicpptest
      but can also be cleaned by the template_typedef_cplx2.cpptest target.
      ---
       Examples/test-suite/go/Makefile.in         | 11 ++++++-----
       Examples/test-suite/javascript/Makefile.in |  1 +
       Examples/test-suite/ocaml/Makefile.in      | 10 +++++++---
       Examples/test-suite/php/Makefile.in        |  1 +
       Examples/test-suite/python/Makefile.in     |  3 ++-
       5 files changed, 17 insertions(+), 9 deletions(-)
      
      diff --git a/Examples/test-suite/go/Makefile.in b/Examples/test-suite/go/Makefile.in
      index 8283327d6..75debc538 100644
      --- a/Examples/test-suite/go/Makefile.in
      +++ b/Examples/test-suite/go/Makefile.in
      @@ -173,16 +173,17 @@ run_multi_testcase = \
       
       clean:
       	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' go_clean
      -	rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
      -	rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
       	rm -f clientdata_prop_a.go clientdata_prop_a.gox
       	rm -f clientdata_prop_b.go clientdata_prop_b.gox
      +	rm -f import_stl_a.go import_stl_a.gox
      +	rm -f import_stl_b.go import_stl_b.gox
      +	rm -f imports_a.go imports_a.gox imports_b.go imports_b.gox
      +	rm -f mod_a.go mod_a.gox mod_b.go mod_b.gox
       	rm -f multi_import_a.go multi_import_a.gox
       	rm -f multi_import_b.go multi_import_b.gox
      -	rm -rf go_subdir_import_a.go go_subdir_import_a.gox testdir
       	rm -f packageoption_a.go packageoption_a.gox
       	rm -f packageoption_b.go packageoption_b.gox
       	rm -f packageoption_c.go packageoption_c.gox
      -	rm -f import_stl_a.go import_stl_a.gox
      -	rm -f import_stl_b.go import_stl_b.gox
      +	rm -f template_typedef_cplx2.go template_typedef_cplx2.gox
      +	rm -rf go_subdir_import_a.go go_subdir_import_a.gox testdir
       	rm -rf gopath
      diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
      index d42ffec5a..fed028388 100644
      --- a/Examples/test-suite/javascript/Makefile.in
      +++ b/Examples/test-suite/javascript/Makefile.in
      @@ -137,4 +137,5 @@ clean:
       		rm -f mod_a$${ext} mod_b$${ext}; \
       		rm -f multi_import_a$${ext} multi_import_b$${ext}; \
       		rm -f packageoption_a$${ext} packageoption_b$${ext} packageoption_c$${ext}; \
      +		rm -f template_typedef_cplx2$${ext}; \
       	done
      diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
      index 3d7230920..c44f02a72 100644
      --- a/Examples/test-suite/ocaml/Makefile.in
      +++ b/Examples/test-suite/ocaml/Makefile.in
      @@ -102,6 +102,10 @@ $(MULTI_CPP_TEST_CASES:=.multicpptest): extra_objects
       
       clean:
       	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' ocaml_clean
      -	rm -f clientdata_prop_a.ml clientdata_prop_b.ml import_stl_a.ml import_stl_b.ml
      -	rm -f imports_a.ml imports_b.ml mod_a.ml mod_b.ml multi_import_a.ml
      -	rm -f multi_import_b.ml packageoption_a.ml packageoption_b.ml packageoption_c.ml
      +	rm -f clientdata_prop_a.ml clientdata_prop_b.ml
      +	rm -f import_stl_a.ml import_stl_b.ml
      +	rm -f imports_a.ml imports_b.ml
      +	rm -f mod_a.ml mod_b.ml
      +	rm -f multi_import_a.ml multi_import_b.ml
      +	rm -f packageoption_a.ml packageoption_b.ml packageoption_c.ml
      +	rm -f template_typedef_cplx2.ml
      diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
      index 64f0d1f9d..693615bc6 100644
      --- a/Examples/test-suite/php/Makefile.in
      +++ b/Examples/test-suite/php/Makefile.in
      @@ -79,3 +79,4 @@ clean:
       	rm -f mod_a.php mod_b.php php_mod_a.h php_mod_b.h
       	rm -f multi_import_a.php multi_import_b.php php_multi_import_a.h php_multi_import_b.h
       	rm -f packageoption_a.php packageoption_b.php packageoption_c.php php_packageoption_a.h php_packageoption_b.h php_packageoption_c.h
      +	rm -f template_typedef_cplx2.php php_template_typedef_cplx2.h
      diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
      index c2528eb49..0bdbad51e 100644
      --- a/Examples/test-suite/python/Makefile.in
      +++ b/Examples/test-suite/python/Makefile.in
      @@ -142,10 +142,11 @@ run_testcase = \
       
       clean:
       	$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
      -	rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
       	rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
      +	rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
       	rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
       	rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
      +	rm -f template_typedef_cplx2.py
       
       hugemod_runme = hugemod$(SCRIPTPREFIX)
       
      
      From 4b5baf0a601c23061b6606426619ac7a13851ce6 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 12:36:39 +0100
      Subject: [PATCH 1972/2031] 0.0 float warning fix
      
      ---
       Lib/javascript/jsc/javascriptcomplex.swg | 2 +-
       Lib/octave/octcomplex.swg                | 2 +-
       Lib/python/pycomplex.swg                 | 2 +-
       Lib/ruby/rubycomplex.swg                 | 2 +-
       4 files changed, 4 insertions(+), 4 deletions(-)
      
      diff --git a/Lib/javascript/jsc/javascriptcomplex.swg b/Lib/javascript/jsc/javascriptcomplex.swg
      index 7be120b3b..dcc205dbd 100644
      --- a/Lib/javascript/jsc/javascriptcomplex.swg
      +++ b/Lib/javascript/jsc/javascriptcomplex.swg
      @@ -127,7 +127,7 @@ SWIG_AsVal_dec(Type)(JSValueRef o, Type *val)
           float re;
           int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
           if (SWIG_IsOK(res)) {
      -      if (val) *val = Constructor(re, 0.0);
      +      if (val) *val = Constructor(re, 0.0f);
             return res;
           }
         }
      diff --git a/Lib/octave/octcomplex.swg b/Lib/octave/octcomplex.swg
      index a3e9ebf77..87e77a62e 100644
      --- a/Lib/octave/octcomplex.swg
      +++ b/Lib/octave/octcomplex.swg
      @@ -73,7 +73,7 @@
       	int res = SWIG_AddCast(SWIG_AsVal(float)(ov, &d));
       	if (SWIG_IsOK(res)) {
       	  if (val)
      -	    *val = Constructor(d, 0.0);
      +	    *val = Constructor(d, 0.0f);
       	  return res;
       	}
             }
      diff --git a/Lib/python/pycomplex.swg b/Lib/python/pycomplex.swg
      index 087c50f90..28c963617 100644
      --- a/Lib/python/pycomplex.swg
      +++ b/Lib/python/pycomplex.swg
      @@ -65,7 +65,7 @@ SWIG_AsVal(Type)(PyObject *o, Type *val)
           float re;
           int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
           if (SWIG_IsOK(res)) {
      -      if (val) *val = Constructor(re, 0.0);
      +      if (val) *val = Constructor(re, 0.0f);
             return res;
           }
         }
      diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg
      index 4e249c71f..a62bfe531 100644
      --- a/Lib/ruby/rubycomplex.swg
      +++ b/Lib/ruby/rubycomplex.swg
      @@ -127,7 +127,7 @@ SWIG_AsVal(Type)(VALUE o, Type *val)
           float re;
           int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
           if (SWIG_IsOK(res)) {
      -      if (val) *val = Constructor(re, 0.0);
      +      if (val) *val = Constructor(re, 0.0f);
             return res;
           }
         }
      
      From 71a13e60ded68d1c595bab986a66857596a38166 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 15:21:13 +0100
      Subject: [PATCH 1973/2031] Quieten ccomplextest
      
      ---
       Examples/test-suite/python/ccomplextest_runme.py | 2 --
       1 file changed, 2 deletions(-)
      
      diff --git a/Examples/test-suite/python/ccomplextest_runme.py b/Examples/test-suite/python/ccomplextest_runme.py
      index 60b95458d..63a663f50 100644
      --- a/Examples/test-suite/python/ccomplextest_runme.py
      +++ b/Examples/test-suite/python/ccomplextest_runme.py
      @@ -20,5 +20,3 @@ if ccomplextest.has_c99_complex():
       
           if ccomplextest.Conjf3(a) != a.conjugate():
               raise RuntimeError("bad complex mapping")
      -else:
      -    print("Not a c99 compiler")
      
      From 8edb04778556aeedf0006691e55100ad16ea7599 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 15:27:22 +0100
      Subject: [PATCH 1974/2031] Update changes file with complex fixes
      
      ---
       CHANGES.current | 6 ++++++
       1 file changed, 6 insertions(+)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 63548c672..9e6a04cc3 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
       Version 4.1.0 (in progress)
       ===========================
       
      +2020-10-10: lpsinger
      +            #1770 Correct C complex support.
      +            _Complex is now parsed as a keyword rather than complex as per the C99 standard.
      +            The complex macro is available in the ccomplex.i library file along with other
      +            complex number handling provided by the complex.h header.
      +
       2020-10-07: treitmayr
                   [Python] #1812 Fix error handling in pybuffer.i PyObject_GetBuffer().
       
      
      From 638ca8152d4ff68540d74a2a173a81a96ffbaeaa Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 16:07:55 +0100
      Subject: [PATCH 1975/2031] complex can now be used as an identifier
      
      Remove final vestiges of 'complex' keyword.
      
      Closes #252
      ---
       CHANGES.current                                    |  3 +++
       Examples/test-suite/common.mk                      |  1 +
       Examples/test-suite/not_c_keywords.i               | 13 +++++++++++++
       Examples/test-suite/python/not_c_keywords_runme.py |  7 +++++++
       Source/Swig/stype.c                                |  2 +-
       5 files changed, 25 insertions(+), 1 deletion(-)
       create mode 100644 Examples/test-suite/not_c_keywords.i
       create mode 100644 Examples/test-suite/python/not_c_keywords_runme.py
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 9e6a04cc3..2cf0bc497 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
       Version 4.1.0 (in progress)
       ===========================
       
      +2020-10-10: wsfulton
      +            #252 complex can now be used as a C identifier and doesn't give a syntax error.
      +
       2020-10-10: lpsinger
                   #1770 Correct C complex support.
                   _Complex is now parsed as a keyword rather than complex as per the C99 standard.
      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
      index 55cbd2cce..bddae4b2f 100644
      --- a/Examples/test-suite/common.mk
      +++ b/Examples/test-suite/common.mk
      @@ -718,6 +718,7 @@ C_TEST_CASES += \
       	nested_extend_c \
       	nested_structs \
       	newobject2 \
      +	not_ckeywords \
       	overload_extend_c \
       	overload_extend2 \
       	preproc \
      diff --git a/Examples/test-suite/not_c_keywords.i b/Examples/test-suite/not_c_keywords.i
      new file mode 100644
      index 000000000..013575bc6
      --- /dev/null
      +++ b/Examples/test-suite/not_c_keywords.i
      @@ -0,0 +1,13 @@
      +%module not_c_keywords
      +
      +%extend ComplexStruct {
      +void init() {
      +  $self->complex = 123;
      +}
      +}
      +
      +%inline %{
      +struct ComplexStruct {
      +  int complex; /* complex as variable name */
      +};
      +%}
      diff --git a/Examples/test-suite/python/not_c_keywords_runme.py b/Examples/test-suite/python/not_c_keywords_runme.py
      new file mode 100644
      index 000000000..7f0772407
      --- /dev/null
      +++ b/Examples/test-suite/python/not_c_keywords_runme.py
      @@ -0,0 +1,7 @@
      +from not_c_keywords import *
      +
      +cs = ComplexStruct()
      +cs.init()
      +if cs.complex != 123:
      +    raise RuntimeError("complex not correct")
      +cs.complex = 456
      diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
      index 66518f50c..fbf02bb1f 100644
      --- a/Source/Swig/stype.c
      +++ b/Source/Swig/stype.c
      @@ -134,7 +134,7 @@ SwigType *NewSwigType(int t) {
           return NewString("double");
           break;
         case T_COMPLEX:
      -    return NewString("complex");
      +    return NewString("_Complex");
           break;
         case T_CHAR:
           return NewString("char");
      
      From bc09d05174aebe4c97ff0d7ae6955fa2fe9e3d71 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 10 Oct 2020 17:59:17 +0100
      Subject: [PATCH 1976/2031] testname typo fix
      
      ---
       Examples/test-suite/common.mk | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
      index bddae4b2f..be3453df7 100644
      --- a/Examples/test-suite/common.mk
      +++ b/Examples/test-suite/common.mk
      @@ -718,7 +718,7 @@ C_TEST_CASES += \
       	nested_extend_c \
       	nested_structs \
       	newobject2 \
      -	not_ckeywords \
      +	not_c_keywords \
       	overload_extend_c \
       	overload_extend2 \
       	preproc \
      
      From 8a4672edd1ac6727f2ba9e159ba6a6669ecdd6d3 Mon Sep 17 00:00:00 2001
      From: Julien Schueller 
      Date: Wed, 14 Oct 2020 12:12:53 +0200
      Subject: [PATCH 1977/2031] Travis: sudo is useless now
      
      ---
       .travis.yml | 97 -----------------------------------------------------
       1 file changed, 97 deletions(-)
      
      diff --git a/.travis.yml b/.travis.yml
      index 43936b5cf..093a1e98e 100644
      --- a/.travis.yml
      +++ b/.travis.yml
      @@ -4,435 +4,342 @@ matrix:
           - compiler: clang
             os: linux
             env: SWIGLANG=
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=4.4
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=4.6
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=4.7
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=4.8
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=4.9
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=6
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=7
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=8
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG= GCC=9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=csharp
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=d VER=2.066.0
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=d VER=2.086.1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=go VER=1.3
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=go VER=1.8
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=go VER=1.12
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=guile
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=java
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=node VER=0.10
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=node VER=8 CPP11=1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=node VER=10 CPP11=1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=jsc
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=javascript ENGINE=v8
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=lua
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=lua VER=5.3
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=mzscheme
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ocaml
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=octave SWIGJOBS=-j2
      -      sudo: required
             dist: xenial   # Octave v4.0.0
           - compiler: gcc
             os: linux
             env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1
      -      sudo: required
             dist: bionic   # Octave v4.2.2
           - compiler: gcc
             os: linux
             env: SWIGLANG=perl5
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=php VER=7.0
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=php VER=7.1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=php VER=7.2
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=php VER=7.3
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python # 2.7
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.2
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.3
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.4
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.5
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.6
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.7
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.8
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES="-builtin -O"
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin GCC=6 CPP11=1 PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.4
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.5
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.7
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.8
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES="-builtin -O" PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3 VER=3.9 SWIGOPTPY3=
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-O
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=python SWIG_FEATURES=-O PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=r
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=1.9
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.0
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.2
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.3
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.4
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.5
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.6
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ruby VER=2.7
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=scilab
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=tcl
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=csharp CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=go VER=1.6 CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=java CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=r CPP11=1 # Note: making 'R CMD SHLIB' use a different compiler is non-trivial
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=ruby CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=tcl CPP11=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=csharp GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=go VER=1.6 GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=java GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=ruby GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=tcl GCC=6 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=java GCC=7 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python GCC=7 CPP14=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=csharp GCC=8 CPP17=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=java GCC=8 CPP17=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python GCC=8 CPP17=1 PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=csharp GCC=9 CPP17=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=java GCC=9 CPP17=1
      -      sudo: required
             dist: xenial
           - os: linux
             env: SWIGLANG=python GCC=9 CPP17=1 PY3=3 VER=3.9
      -      sudo: required
             dist: xenial
           - os: linux
             arch: s390x
             env: SWIGLANG=ruby CPP11=1
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: osx
      @@ -487,24 +394,20 @@ matrix:
           - compiler: gcc
             os: linux
             env: SWIGLANG=d VER=2.086.1
      -      sudo: required
             dist: xenial
           # seg fault in director_basic testcase
           - compiler: gcc
             os: linux
             env: SWIGLANG=php VER=7.2
      -      sudo: required
             dist: xenial
           # Experimental languages
           - compiler: gcc
             os: linux
             env: SWIGLANG=mzscheme
      -      sudo: required
             dist: xenial
           - compiler: gcc
             os: linux
             env: SWIGLANG=ocaml
      -      sudo: required
             dist: xenial
       
       before_install:
      
      From 9ed60ac7a042768bcf13a1f6bd2ffdebb5afa6f1 Mon Sep 17 00:00:00 2001
      From: Julien Schueller 
      Date: Wed, 14 Oct 2020 11:07:07 +0200
      Subject: [PATCH 1978/2031] Drop deprecated PyEval_CallObject method
      
      see https://docs.python.org/3.9/whatsnew/3.9.html
      ---
       Lib/python/defarg.swg | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
      
      diff --git a/Lib/python/defarg.swg b/Lib/python/defarg.swg
      index 59450bd82..ba5ff43d4 100644
      --- a/Lib/python/defarg.swg
      +++ b/Lib/python/defarg.swg
      @@ -33,5 +33,5 @@ SWIGINTERN PyObject *swig_call_defargs(PyObject *self, PyObject *args) {
           SWIG_PYTHON_THREAD_END_BLOCK;
           return NULL;
         }
      -  return PyEval_CallObject(func,parms);
      +  return PyObject_Call(func, parms, NULL);
       }
      
      From 4ce34742a777a85397404ec49938f624e4636849 Mon Sep 17 00:00:00 2001
      From: TungPham51D 
      Date: Thu, 14 Jan 2021 13:48:19 +0000
      Subject: [PATCH 1979/2031] OPTIM: Restructured the code where it checks for V8
       version, removing duplicate code and potentially improving the readability.
      
      ---
       Lib/javascript/v8/javascriptcode.swg |  7 ++++---
       Lib/javascript/v8/javascriptrun.swg  | 25 ++++++++++---------------
       2 files changed, 14 insertions(+), 18 deletions(-)
      
      diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg
      index edcc1fd90..07fa2dca7 100644
      --- a/Lib/javascript/v8/javascriptcode.swg
      +++ b/Lib/javascript/v8/javascriptcode.swg
      @@ -423,12 +423,13 @@ fail:
         SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname");
         $jsmangledname_class_0->SetCallHandler($jsctor);
         $jsmangledname_class_0->Inherit($jsmangledname_class);
      +#if (SWIG_V8_VERSION < 0x0705)
      +$jsmangledname_class_0->SetHiddenPrototype(true);
       #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
      -  $jsmangledname_class_0->SetHiddenPrototype(true);
         v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
      -#elif (SWIG_V8_VERSION < 0x0705)
      -  $jsmangledname_class_0->SetHiddenPrototype(true);
      +#else
         v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction();
      +#endif
       #else
         v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked();
       #endif
      diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg
      index 8ce8ff567..9f2e194c1 100644
      --- a/Lib/javascript/v8/javascriptrun.swg
      +++ b/Lib/javascript/v8/javascriptrun.swg
      @@ -49,19 +49,18 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo;
       #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err)
       #define SWIGV8_STRING_NEW(str) v8::String::New(str)
       #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym)
      -#elif (SWIG_V8_VERSION < 0x0706)
      -#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
      -#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
      -#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
      -#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString)
      -#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString)
       #else
       #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size)
       #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext()
       #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err)
      +#if (SWIG_V8_VERSION < 0x0706)
      +#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString)
      +#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString)
      +#else
       #define SWIGV8_STRING_NEW(str) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal)).ToLocalChecked()
       #define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked()
       #endif
      +#endif
       
       #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
       #define SWIGV8_ARRAY_NEW() v8::Array::New()
      @@ -125,22 +124,18 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo;
       #define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue()
       #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len)
       #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length()
      -#elif (SWIG_V8_VERSION < 0x0706)
      -#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
      -#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
      -#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
      -#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
      -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
      -#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
      -#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
       #else
       #define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
       #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()
       #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
       #define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
      -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent())
       #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len)
       #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent())
      +#if (SWIG_V8_VERSION < 0x0706)
      +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked()
      +#else
      +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent())
      +#endif
       #endif
       
       
      
      From 280b82c8acacfce7be90b108685dd62e080ce53d Mon Sep 17 00:00:00 2001
      From: James Gerity 
      Date: Mon, 18 Jan 2021 14:36:22 -0500
      Subject: [PATCH 1980/2031] Document lack of support for `auto` for C++
       variables (#1125)
      
      ---
       Doc/Manual/CPlusPlus11.html | 4 ++++
       1 file changed, 4 insertions(+)
      
      diff --git a/Doc/Manual/CPlusPlus11.html b/Doc/Manual/CPlusPlus11.html
      index 11335a251..e5d7fbc2d 100644
      --- a/Doc/Manual/CPlusPlus11.html
      +++ b/Doc/Manual/CPlusPlus11.html
      @@ -336,6 +336,10 @@ int i; int j;
       decltype(i+j) k;  // syntax error
       
      +

      SWIG does not support auto as a type specifier for variables, only +for specifying the return type of lambdas +and functions.

      +

      7.2.7 Range-based for-loop

      From 36960396bac5c54f2b008eb8ee4354e82725acef Mon Sep 17 00:00:00 2001 From: tungpham25 Date: Thu, 28 Jan 2021 21:48:45 +0000 Subject: [PATCH 1981/2031] Revert "Merge pull request #3 from tungntpham/new-node-fixes-refactor" This reverts commit 35f05bd54182f9db9d2aed599ff9cf227bda0457, reversing changes made to 0ea6a3bdbf3184d230bf17d2c17704dbc2ec7aac. --- Lib/javascript/v8/javascriptcode.swg | 7 +++---- Lib/javascript/v8/javascriptrun.swg | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index 07fa2dca7..edcc1fd90 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -423,13 +423,12 @@ fail: SWIGV8_FUNCTION_TEMPLATE $jsmangledname_class_0 = SWIGV8_CreateClassTemplate("$jsname"); $jsmangledname_class_0->SetCallHandler($jsctor); $jsmangledname_class_0->Inherit($jsmangledname_class); -#if (SWIG_V8_VERSION < 0x0705) -$jsmangledname_class_0->SetHiddenPrototype(true); #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) + $jsmangledname_class_0->SetHiddenPrototype(true); v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); -#else +#elif (SWIG_V8_VERSION < 0x0705) + $jsmangledname_class_0->SetHiddenPrototype(true); v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); -#endif #else v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked(); #endif diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 9f2e194c1..8ce8ff567 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -49,18 +49,19 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err) #define SWIGV8_STRING_NEW(str) v8::String::New(str) #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym) +#elif (SWIG_V8_VERSION < 0x0706) +#define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) +#define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() +#define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) +#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString) +#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString) #else #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) -#if (SWIG_V8_VERSION < 0x0706) -#define SWIGV8_STRING_NEW(str) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::String::kNormalString) -#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::String::kNormalString) -#else #define SWIGV8_STRING_NEW(str) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), str, v8::NewStringType::kNormal)).ToLocalChecked() #define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked() #endif -#endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) #define SWIGV8_ARRAY_NEW() v8::Array::New() @@ -124,18 +125,22 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue() #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len) #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length() +#elif (SWIG_V8_VERSION < 0x0706) +#define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() +#define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len) +#define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) #else #define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() #define SWIGV8_INTEGER_VALUE(handle) (handle)->IntegerValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() +#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent()) #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(v8::Isolate::GetCurrent(), buffer, len) #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) -#if (SWIG_V8_VERSION < 0x0706) -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() -#else -#define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue(v8::Isolate::GetCurrent()) -#endif #endif From c12ab1f012bba6b59be77715942b296a75143620 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sat, 30 Jan 2021 15:10:34 -0700 Subject: [PATCH 1982/2031] Fix attribution error for Python buffers fix in CHANGES.current [skip ci] Closes #1940. --- CHANGES.current | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2cf0bc497..dafe7077b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -16,8 +16,9 @@ Version 4.1.0 (in progress) The complex macro is available in the ccomplex.i library file along with other complex number handling provided by the complex.h header. -2020-10-07: treitmayr - [Python] #1812 Fix error handling in pybuffer.i PyObject_GetBuffer(). +2020-10-07: ZackerySpytz + [Python] #1812 Fix the error handling for the PyObject_GetBuffer() calls in + pybuffer.i. 2020-10-07: treitmayr #1824 Add missing space in director method declaration returning From bcfa9272980cdb99b04125f0077d9f44565bca79 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Tue, 9 Feb 2021 09:21:14 -0700 Subject: [PATCH 1983/2031] Fix typos in attribute2ref() in Lib/typemaps/attribute.swg AccessorName was being used instead of AttributeName. Closes #1872. --- Examples/test-suite/li_attribute.i | 3 +++ Examples/test-suite/python/li_attribute_runme.py | 3 +++ Lib/typemaps/attribute.swg | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i index 4f9497afb..95389b2b6 100644 --- a/Examples/test-suite/li_attribute.i +++ b/Examples/test-suite/li_attribute.i @@ -95,6 +95,7 @@ struct MyFoo; // %attribute2 does not work with templates // class/struct attribute with get/set methods using return/pass by reference %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); +%attribute2ref(MyClass, MyFoo, Foo2); %inline %{ struct MyFoo { MyFoo() : x(-1) {} @@ -102,9 +103,11 @@ struct MyFoo; // %attribute2 does not work with templates }; class MyClass { MyFoo foo; + MyFoo foo2; public: MyFoo& GetFoo() { return foo; } void SetFoo(const MyFoo& other) { foo = other; } + MyFoo& Foo2() { return foo2; } }; %} diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index a5a6914cd..d26bf0b68 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -45,6 +45,9 @@ myClass = li_attribute.MyClass() myClass.Foo = myFoo if myClass.Foo.x != 8: raise RuntimeError +myClass.Foo2 = myFoo +if myClass.Foo2.x != 8: + raise RuntimeError # class/struct attribute with get/set methods using return/pass by value myClassVal = li_attribute.MyClassVal() diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 988113991..37c3340cf 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -224,7 +224,7 @@ #if #AccessorMethod != "" %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AccessorMethod, AccessorMethod, &self_->AccessorMethod(), self_->AccessorMethod() = *val_) #else - %attribute_custom(%arg(Class), %arg(AttributeType), AccessorName, AccessorName, AccessorName, &self_->AccessorName(), self_->AccessorName() = *val_) + %attribute_custom(%arg(Class), %arg(AttributeType), AttributeName, AttributeName, AttributeName, &self_->AttributeName(), self_->AttributeName() = *val_) #endif %enddef From 6358510c57d772ab2ece053109a4c09951b7e036 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 21:50:43 +0000 Subject: [PATCH 1984/2031] Travis: disable MinGW testing MinGW server seems to be offline --- appveyor.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 8624cd697..3dc08a0de 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,14 +22,14 @@ environment: # PY3: 3 - SWIGLANG: python OSVARIANT: cygwin - - SWIGLANG: python - OSVARIANT: mingw - VER: 27 - - SWIGLANG: python - OSVARIANT: mingw - WITHLANG: python - VER: 37 - PY3: 3 +# - SWIGLANG: python +# OSVARIANT: mingw +# VER: 27 +# - SWIGLANG: python +# OSVARIANT: mingw +# WITHLANG: python +# VER: 37 +# PY3: 3 matrix: allow_failures: From b65ec5c3697c957032b70082c847d6b8f0687d33 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 18:23:47 +0000 Subject: [PATCH 1985/2031] Travis update to use newer macOS 10.15.7 xcode12.2 --- .travis.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 093a1e98e..735882e73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -343,51 +343,64 @@ matrix: dist: xenial - compiler: gcc os: osx + osx_image: xcode12.2 env: SWIGLANG= - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG= - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=csharp - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=go - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=guile CSTD=c11 - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=java - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=lua - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=perl5 - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=python - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=python PY3=3 - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=ruby - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=tcl - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=java CPP17=1 - osx_image: xcode10.2 - compiler: clang os: osx + osx_image: xcode12.2 env: SWIGLANG=python PY3=3 CPP17=1 - osx_image: xcode10.2 allow_failures: # Newer version of D not yet working/supported From 3716e7348ee2bacc11500f30f5fb4202cb257d32 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 20:21:55 +0000 Subject: [PATCH 1986/2031] Travis: brew list versions --- Tools/travis-osx-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 71d2b2dd0..38167183f 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -9,7 +9,8 @@ export HOMEBREW_NO_INSTALL_CLEANUP=1 sw_vers travis_retry brew update -travis_retry brew list +echo "Installed packages..." +travis_retry brew list --versions # travis_retry brew install pcre # Travis Xcode-7.3 has pcre # travis_retry brew install boost From 33c547d0799e2d92d7dbeffe9e36f3e8da099be3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 20:32:37 +0000 Subject: [PATCH 1987/2031] Travis osx - guile is now pre-installed --- Tools/travis-osx-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 38167183f..6e4d4e4b0 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -20,9 +20,6 @@ case "$SWIGLANG" in "csharp") travis_retry brew install mono ;; - "guile") - travis_retry Tools/brew-install guile - ;; "lua") travis_retry brew install lua ;; From 7d85efbf3c8cd0524bf92cec74f73b4484411da7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 20:59:51 +0000 Subject: [PATCH 1988/2031] Lua example fix for newer osx --- Examples/lua/owner/example.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/lua/owner/example.cxx b/Examples/lua/owner/example.cxx index c2c073d79..a4dcc68a1 100644 --- a/Examples/lua/owner/example.cxx +++ b/Examples/lua/owner/example.cxx @@ -3,7 +3,9 @@ #include "example.h" #include +#ifndef M_PI #define M_PI 3.14159265358979323846 +#endif /* Move the shape to a new location */ void Shape::move(double dx, double dy) { From ad3f3b6ed5b3ad04ddbdb759eede2ce2de67280c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 21:06:38 +0000 Subject: [PATCH 1989/2031] Travis osx: perl needs installing now --- Tools/travis-osx-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index 6e4d4e4b0..b717b44a4 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -26,6 +26,9 @@ case "$SWIGLANG" in "octave") travis_retry Tools/brew-install octave ;; + "perl5") + travis_retry Tools/brew-install perl + ;; "python") WITHLANG=$SWIGLANG$PY3 ;; From f7b5fea09f7fc9376dcb4774d8e36f5e370cad69 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 21:16:33 +0000 Subject: [PATCH 1990/2031] Travis osx: Disable octave testing Octave 6.1 is installed and has a new non-backwards compatible API --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 735882e73..c282768f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -369,10 +369,11 @@ matrix: os: osx osx_image: xcode12.2 env: SWIGLANG=lua - - compiler: clang - os: osx - osx_image: xcode12.2 - env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 +# octave-6.1 not working +# - compiler: clang +# os: osx +# osx_image: xcode12.2 +# env: SWIGLANG=octave SWIGJOBS=-j2 CPP11=1 - compiler: clang os: osx osx_image: xcode12.2 From b58e44700a1b41365fe2829879143fd5c9f9e29d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Feb 2021 10:22:15 +0000 Subject: [PATCH 1991/2031] Travis: skip make check-maintainer-clean on osx Often fails with: rm: Resource temporarily unavailable --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c282768f4..95a98d41e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -459,5 +459,6 @@ script: - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi - echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r' - - make check-maintainer-clean && ../../configure $CONFIGOPTS + # Skip on osx as often fails with: rm: Resource temporarily unavailable + - if test "$TRAVIS_OS_NAME" != "osx"; then make check-maintainer-clean && ../../configure $CONFIGOPTS; fi - echo -en 'travis_fold:end:script.3\\r' From 38530af0281a6bb3d5e8c6c73e324ab785073eb4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Feb 2021 10:49:01 +0000 Subject: [PATCH 1992/2031] brew-install now handles more than one argument --- Tools/brew-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/brew-install b/Tools/brew-install index 408ae13bb..39fe22bc2 100755 --- a/Tools/brew-install +++ b/Tools/brew-install @@ -6,7 +6,7 @@ seconds=0 minutes=0 -brew install $1 & +brew install "$@" & while true; do ps -p$! 2>& 1>/dev/null if [ $? = 0 ]; then From d344698934e867770a625fba3a790884812d5490 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 19 Feb 2021 21:25:14 +0000 Subject: [PATCH 1993/2031] Travis osx: install tcl --- Tools/travis-osx-install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tools/travis-osx-install.sh b/Tools/travis-osx-install.sh index b717b44a4..71545ad5c 100755 --- a/Tools/travis-osx-install.sh +++ b/Tools/travis-osx-install.sh @@ -32,6 +32,9 @@ case "$SWIGLANG" in "python") WITHLANG=$SWIGLANG$PY3 ;; + "tcl") + travis_retry Tools/brew-install --cask tcl + ;; esac # Workaround for https://github.com/travis-ci/travis-ci/issues/6522 From ac8de714af1d7fbd755597b0f51792212f552ef7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Feb 2021 13:43:47 +0000 Subject: [PATCH 1994/2031] Travis testing tcl for MacOSX10.14 and later Used suggestion from https://www.postgresql-archive.org/PG-vs-macOS-Mojave-td6047357.html#a6056680 to add in sysroot. Note that the examples failed at runtime unless tcl was installed from homebrew: brew install --cask tcl --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index af4c89414..8f19c2471 100644 --- a/configure.ac +++ b/configure.ac @@ -496,7 +496,9 @@ fi dirs="/usr/lib*/ /usr/lib*/tcl*/ /usr/local/lib*/ /usr/local/lib*/tcl*/" case $host in *-*-darwin*) - dirs="/System/Library/Frameworks/Tcl.framework/ $dirs" + tcl_framework="/System/Library/Frameworks/Tcl.framework/" + macos_sysroot="$(xcodebuild -version -sdk macosx Path 2>/dev/null)" # For MacOSX10.14 and later + dirs="$macos_sysroot$tcl_framework $tcl_framework $dirs" ;; *) ;; From 8cbeb084c4f426ac6177070d07b90f4a3af8c0e6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 22 Feb 2021 21:15:03 +0100 Subject: [PATCH 1995/2031] Don't use invalid iterators in Doxygen command parsing code Check that the string is non-empty before dereferencing its begin() iterator and avoid calling addDoxyCommand() with an empty string in the first place. --- Source/Doxygen/doxyparser.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Doxygen/doxyparser.cxx b/Source/Doxygen/doxyparser.cxx index 35d18363f..d5a0a15eb 100644 --- a/Source/Doxygen/doxyparser.cxx +++ b/Source/Doxygen/doxyparser.cxx @@ -1081,6 +1081,13 @@ bool DoxygenParser::addDoxyCommand(DoxygenParser::TokenList &tokList, const std: tokList.push_back(Token(COMMAND, cmd)); return true; } else { + if (cmd.empty()) { + // This actually indicates a bug in the code in this file, as this + // function shouldn't be called at all in this case. + printListError(WARN_DOXYGEN_UNKNOWN_COMMAND, "Unexpected empty Doxygen command."); + return false; + } + // This function is called for the special Doxygen commands, but also for // HTML commands (or anything that looks like them, actually) and entities. // We don't recognize all of those, so just ignore them and pass them @@ -1181,6 +1188,11 @@ void DoxygenParser::processWordCommands(size_t &pos, const std::string &line) { size_t endOfWordPos = getEndOfWordCommand(line, pos); string cmd = line.substr(pos, endOfWordPos - pos); + if (cmd.empty()) { + // This was a bare backslash, just ignore it. + return; + } + addDoxyCommand(m_tokenList, cmd); // A flag for whether we want to skip leading spaces after the command From 896e8d8654694f6e6225fd9a9757652484775ada Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 00:34:55 +0100 Subject: [PATCH 1996/2031] Add CMake build steps on Windows --- Doc/Manual/Windows.html | 86 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index f6f0d16df..1991e7fab 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -1,4 +1,4 @@ - + Getting started on Windows @@ -36,6 +36,7 @@
    • Building swig.exe using MinGW and MSYS
    • Building swig.exe using Cygwin
    • Building swig.exe alternatives +
    • Building swig.exe using CMake
  • Running the examples on Windows using Cygwin @@ -364,6 +365,89 @@ SWIG. For example, all the source code files can be added to a Visual C++ projec file in order to build swig.exe from the Visual C++ IDE.

    +

    3.3.1.2 Building swig.exe using Cygwin

    + + +

    +Note that SWIG can also be built using Cygwin. +However, SWIG will then require the Cygwin DLL when executing. +Follow the Unix instructions in the README file in the SWIG root directory. +Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. +These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system. +

    + +

    3.3.1.3 Building swig.exe alternatives

    + + +

    +If you don't want to install Cygwin or MinGW, use a different compiler to build +SWIG. For example, all the source code files can be added to a Visual C++ project +file in order to build swig.exe from the Visual C++ IDE. +

    + +

    3.3.1.4 Building swig.exe using CMake

    + + +

    +SWIG can also be built using CMake and Visual Studio rather than autotools. As with the other approaches to +building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW. +For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file. +

    + +
      +
    1. + Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it + to C:\Tools\cmake-3.19.4-win64-x64 +
    2. +
    3. + Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
    4. +
    5. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager + for .NET, but allows us to easily install PCRE required by SWIG. +
    6. +
    7. + Install PCRE using Nuget using the following command:
      C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
      +
    8. +
    9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
      git clone https://github.com/swig/swig.git
      + In this example we are assuming the source code is available at C:\swig +
    10. +
    + +

    +Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then +build a Release version of SWIG. +

    + +
    +
    +cd C:\swig
    +SET PATH=C:\Tools\cmake-3.19.4-win64-x64\bin;C:\Tools\Bison\bin;%PATH%
    +PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native
    +SET PCRE_PLATFORM=x64
    +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include 
    +-DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/Tools/Bison/bin/bison.exe .
    +cmake --build . --config Release
    +
    +
    + +

    + If all runs successfully a new swig.exe should be generated in a /Release folder. + In addition to Release builds you can create a Debug build using: +

    +
    +
    cmake --build . --config Debug
    +
    +

    + A Visual Studio solution file should be generated - swig.sln. This can be opened and debugged by running the swig project and setting the + Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following: +

    +
    +
    -python -py3 -shadow -o C:\Temp\doxygen_parsing.c C:\swig\Examples\test-suite\doxygen_parsing.i
    +

    3.3.2 Running the examples on Windows using Cygwin

    From da33383ea26991cde94cc2d2a1afee61008c0547 Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 00:38:41 +0100 Subject: [PATCH 1997/2031] Add link on main Contents page --- Doc/Manual/Contents.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 79ffdd50e..59378c50b 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1,4 +1,4 @@ - + @@ -98,6 +98,7 @@
  • Building swig.exe using MinGW and MSYS
  • Building swig.exe using Cygwin
  • Building swig.exe alternatives +
  • Building swig.exe using CMake
  • Running the examples on Windows using Cygwin From a1fdfe7d657cdc343868beaf6ea9f15a0311fe93 Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 12:49:30 +0100 Subject: [PATCH 1998/2031] Remove duplicate section --- Doc/Manual/Windows.html | 51 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 1991e7fab..e23af9e75 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -356,15 +356,6 @@ Note that the Cygwin environment will also allow one to regenerate the autotool These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system.

    -

    3.3.1.3 Building swig.exe alternatives

    - - -

    -If you don't want to install Cygwin or MinGW, use a different compiler to build -SWIG. For example, all the source code files can be added to a Visual C++ project -file in order to build swig.exe from the Visual C++ IDE. -

    -

    3.3.1.2 Building swig.exe using Cygwin

    @@ -394,27 +385,27 @@ building SWIG the dependencies need to be installed. The steps below are one of For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file.

    -
      -
    1. - Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it - to C:\Tools\cmake-3.19.4-win64-x64 -
    2. -
    3. - Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) - and save to a folder e.g. C:\Tools\Bison -
    4. -
    5. - Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager - for .NET, but allows us to easily install PCRE required by SWIG. -
    6. -
    7. - Install PCRE using Nuget using the following command:
      C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
      -
    8. -
    9. - We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase - using
      git clone https://github.com/swig/swig.git
      - In this example we are assuming the source code is available at C:\swig -
    10. +
        +
      1. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager + for .NET, but allows us to easily install PCRE required by SWIG. +
      2. +
      3. + Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it + to C:\Tools\cmake-3.19.4-win64-x64 +
      4. +
      5. + Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
      6. +
      7. + Install PCRE using Nuget using the following command:
        C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
        +
      8. +
      9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
        git clone https://github.com/swig/swig.git
        + In this example we are assuming the source code is available at C:\swig +

      From f0bf789db098f3730e859a778be3ec29fb4b7f7e Mon Sep 17 00:00:00 2001 From: sethg Date: Tue, 23 Feb 2021 13:16:07 +0100 Subject: [PATCH 1999/2031] Remove duplicate and update to nuget installs --- Doc/Manual/Windows.html | 76 +++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index e23af9e75..065da215d 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -348,17 +348,6 @@ make

      3.3.1.2 Building swig.exe using Cygwin

      -

      -Note that SWIG can also be built using Cygwin. -However, SWIG will then require the Cygwin DLL when executing. -Follow the Unix instructions in the README file in the SWIG root directory. -Note that the Cygwin environment will also allow one to regenerate the autotool generated files which are supplied with the release distribution. -These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system. -

      - -

      3.3.1.2 Building swig.exe using Cygwin

      - -

      Note that SWIG can also be built using Cygwin. However, SWIG will then require the Cygwin DLL when executing. @@ -385,55 +374,60 @@ building SWIG the dependencies need to be installed. The steps below are one of For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file.

      -
        -
      1. - Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example). Nuget is the package manager - for .NET, but allows us to easily install PCRE required by SWIG. -
      2. -
      3. - Download CMake from https://cmake.org/download/. In this example we are using 3.19 and unzipping it - to C:\Tools\cmake-3.19.4-win64-x64 -
      4. -
      5. - Download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) - and save to a folder e.g. C:\Tools\Bison -
      6. -
      7. - Install PCRE using Nuget using the following command:
        C:\Tools\nuget install pcre -Verbosity quiet -Version 8.33.0.1 -OutputDirectory C:\pcre
        -
      8. -
      9. - We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase - using
        git clone https://github.com/swig/swig.git
        - In this example we are assuming the source code is available at C:\swig -
      10. +
          +
        1. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example, and installed to C:\Tools). Nuget is the package manager + for .NET, but allows us to easily install PCRE and other dependencies required by SWIG. +
        2. +
        3. + Install CMake using the following command:
          C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake
          + Alternatively you can download CMake from https://cmake.org/download/. +
        4. +
        5. + Install Bison using the following command:
          C:\Tools\nuget install bison-win32 -Version 2.4.1.1 -OutputDirectory C:\Tools\bison
          + Alternatively download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
        6. +
        7. + Install PCRE using Nuget using the following command:
          C:\Tools\nuget install pcre -Version 8.33.0.1 -OutputDirectory C:\Tools\pcre
          +
        8. +
        9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
          git clone https://github.com/swig/swig.git
          + In this example we are assuming the source code is available at C:\swig +

        -Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then -build a Release version of SWIG. + We are assuming Visual Studio 2017 is installed. For other versions of Visual Studio change "Visual Studio 15 2017 Win64" to the relevant + Visual Studio Generator. + Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then + build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in a /Release folder.

        -
        +    
         cd C:\swig
        -SET PATH=C:\Tools\cmake-3.19.4-win64-x64\bin;C:\Tools\Bison\bin;%PATH%
        -PCRE_ROOT=C:/pcre/pcre.8.33.0.1/build/native
        +SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH%
        +SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native
         SET PCRE_PLATFORM=x64
        -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include 
        --DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/Tools/Bison/bin/bison.exe .
        +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib .
         cmake --build . --config Release
        +
        +REM to test the exe
        +cd /Release
        +swig.exe -help
         

        - If all runs successfully a new swig.exe should be generated in a /Release folder. In addition to Release builds you can create a Debug build using:

        cmake --build . --config Debug

        - A Visual Studio solution file should be generated - swig.sln. This can be opened and debugged by running the swig project and setting the + A Visual Studio solution file should be generated named swig.sln. This can be opened and debugged by running the swig project and setting the Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following:

        From c3c4ec1e88c3838d4cd3ffc127bfce569e6ae383 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Feb 2021 22:07:36 +0000 Subject: [PATCH 2000/2031] html link corrections --- Doc/Manual/Java.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 2f55f5b04..dc403a98c 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -4030,7 +4030,7 @@ repetitive duplication of the director:except feature code for each director method. To mitigate this, a second approach is provided via typemaps in a fashion analogous to -the "throws" typemap. +the "throws" typemap. The "throws" typemap provides a way to map all the C++ exceptions listed in a method's defined exceptions (either from a C++ exception specification or a %catches @@ -4081,7 +4081,7 @@ has the $directorthrowshandlers special variable replaced with the the relevant "directorthrows" typemaps, for each and every exception defined for the method. The relevant exceptions can be defined either with a C++ exception specification or %catches as described for the -"throws" typemap. +"throws" typemap.

        From 1edc58d8fe14b9c0128b815625fd8b123afa2a7e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Feb 2021 22:11:10 +0000 Subject: [PATCH 2001/2031] Travis testing: Node 12 support not fully working yet --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 42f0e259f..fe7742dcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -474,6 +474,12 @@ matrix: env: SWIGLANG=d VER=2.086.1 sudo: required dist: xenial + # New node support, wip + - compiler: gcc + os: linux + env: SWIGLANG=javascript ENGINE=node VER=12 CPP11=1 + sudo: required + dist: xenial # seg fault in director_basic testcase - compiler: gcc os: linux From 7ba19e758632c8aeddcf82ddf48a05f34e218bc9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Feb 2021 22:22:36 +0000 Subject: [PATCH 2002/2031] Document node v12 support and minimum is now v6 Code to remove support for node v0.10 upto v6 is still to be removed. --- .travis.yml | 8 -------- CHANGES.current | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 432be8291..6572bb74b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,14 +68,6 @@ matrix: os: linux env: SWIGLANG=java dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=0.10 - dist: xenial - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=4 CPP11=1 - dist: xenial - compiler: gcc os: linux env: SWIGLANG=javascript ENGINE=node VER=6 CPP11=1 diff --git a/CHANGES.current b/CHANGES.current index dafe7077b..5611a764c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-02-24: tomleavy, yegorich, tungntpham + #1746 [Javascript] Add support for Node v12. + SWIG support is now for Node v6 and later only. + 2020-10-10: wsfulton #252 complex can now be used as a C identifier and doesn't give a syntax error. From 2981eda00da91b7992d669a93d186efb9e28d48e Mon Sep 17 00:00:00 2001 From: Oliver Buchtala Date: Mon, 31 Mar 2014 01:49:17 +0200 Subject: [PATCH 2003/2031] Initial CMake configuration. Needs to be tested under OSX and Windows. --- CMakeLists.txt | 165 ++++++++++++++++++++++++++++++++++++ Tools/cmake/FindPCRE.cmake | 37 ++++++++ Tools/cmake/swigconfig.h.in | 95 +++++++++++++++++++++ 3 files changed, 297 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Tools/cmake/FindPCRE.cmake create mode 100644 Tools/cmake/swigconfig.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..fe2f0ccdc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,165 @@ +cmake_minimum_required (VERSION 3.2) + +if (NOT DEFINED CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") +endif () + +project (swig) + +file (STRINGS configure.ac line LIMIT_COUNT 1 REGEX "AC_INIT\\(.*\\)" ) +if (line MATCHES "AC_INIT\\(\\[(.*)\\],[ \t]*\\[(.*)\\],[ \t]*\\[(.*)\\]\\)" ) + set (SWIG_VERSION ${CMAKE_MATCH_2}) + set (PACKAGE_BUGREPORT ${CMAKE_MATCH_3}) +else () + message (SEND_ERROR "Could not parse version from configure.ac") +endif () + +set(SWIG_ROOT ${PROJECT_SOURCE_DIR}) + +set (SWIG_LIB share/swig/${SWIG_VERSION}) + +# Project wide configuration variables +# ------------------------------------ + +set(SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) + +set ( PACKAGE_NAME swig ) +set ( PACKAGE_VERSION ${SWIG_VERSION} ) + +# Options +# ------- + +# TODO... + + +# Configure +# --------- + +list (APPEND CMAKE_MODULE_PATH ${SWIG_ROOT}/Tools/cmake) + +include(CheckIncludeFiles) +include(CheckIncludeFile) +include(CheckTypeSize) +include(CheckSymbolExists) +include(CheckLibraryExists) +include(CheckCSourceCompiles) + +# HACK: didn't get the bool check working for Visual Studio 2008 +if(MSVC) +set(HAVE_BOOL 1) +else() +set(CMAKE_EXTRA_INCLUDE_FILES stdbool.h) +check_type_size("bool" HAVE_BOOL) +set(CMAKE_EXTRA_INCLUDE_FILES) +endif() + +check_include_file("inttypes.h" HAVE_INTTYPES_H) +check_include_file("memory.h" HAVE_MEMORY_H) +check_include_file("stddef.h" HAVE_STDDEF_H) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("stdlib.h" HAVE_STDLIB_H) +check_include_file("string.h" HAVE_STRING_H) +check_include_file("strings.h" HAVE_STRINGS_H) +check_include_file("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file("unistd.h" HAVE_UNISTD_H) +check_include_files( "stdlib.h;stdarg.h;string.h;float.h" HAVE_STDC_HEADERS ) + +check_library_exists(dl dlopen "" HAVE_LIBDL) + +find_package (PCRE REQUIRED) +if (PCRE_FOUND) + add_definitions (-DHAVE_PCRE) + include_directories (${PCRE_INCLUDE_DIRS}) +endif() + +configure_file (${SWIG_ROOT}/Tools/cmake/swigconfig.h.in + ${CMAKE_CURRENT_BINARY_DIR}/Source/Include/swigconfig.h) + +find_package (BISON REQUIRED) + + +# Compiler flags +# -------------- + +include_directories( + ${SWIG_SOURCE_DIR}/CParse + ${SWIG_SOURCE_DIR}/Include + ${SWIG_SOURCE_DIR}/DOH + ${SWIG_SOURCE_DIR}/Swig + ${SWIG_SOURCE_DIR}/Preprocessor + ${SWIG_SOURCE_DIR}/Modules + ${PROJECT_BINARY_DIR}/Source/Include + ${PROJECT_BINARY_DIR}/Source/CParse + ${PROJECT_SOURCE_DIR}/Source/Doxygen +) + +# generate the parser source code (depends on bison) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) + +BISON_TARGET(swig_parser + ${SWIG_SOURCE_DIR}/CParse/parser.y + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c +) + +# generate swigwarn.swg +file(READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) +string(REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) +set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) + +# install lib +install (DIRECTORY ${SWIG_ROOT}/Lib/ DESTINATION ${SWIG_LIB}) +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg DESTINATION ${SWIG_LIB}) + +# Libraries +# --------- + +file (GLOB CPARSE_SOURCES ${SWIG_SOURCE_DIR}/CParse/*.c) +add_library (cparse ${CPARSE_SOURCES} + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c + ${PROJECT_BINARY_DIR}/Source/CParse/parser.h +) + +file (GLOB PREPROCESSOR_SOURCES ${SWIG_SOURCE_DIR}/Preprocessor/*.c) +add_library (preprocessor ${PREPROCESSOR_SOURCES}) + +file (GLOB DOH_SOURCES ${SWIG_SOURCE_DIR}/DOH/*.c) +add_library (doh ${DOH_SOURCES}) + +file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) +add_library (doxygen ${DOXYGEN_SOURCES}) + +file (GLOB CORE_SOURCES ${SWIG_SOURCE_DIR}/Swig/*.c) +add_library (core ${CORE_SOURCES}) +if (PCRE_FOUND) + target_link_libraries (core ${PCRE_LIBRARIES}) +endif () + +file (GLOB MODULES_SOURCES ${SWIG_SOURCE_DIR}/Modules/*.cxx) +add_library (modules ${MODULES_SOURCES} + ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h + ${SWIG_SOURCE_DIR}/Include/swigwarn.h +) +target_link_libraries(modules doxygen) + +add_executable(swig + ${SWIG_SOURCE_DIR}/Modules/main.cxx + ${SWIG_SOURCE_DIR}/Modules/swigmain.cxx +) + +target_link_libraries (swig cparse preprocessor doh core modules) +install (TARGETS swig DESTINATION bin) + + +# 'make package-source' creates tarballs +set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} ) +set ( CPACK_SOURCE_GENERATOR "TGZ;TBZ2" ) +set ( CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}" ) +set ( CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION} ) +include ( CPack ) + +enable_testing() +add_test (NAME cmd_version COMMAND swig -version) +add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) +set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") diff --git a/Tools/cmake/FindPCRE.cmake b/Tools/cmake/FindPCRE.cmake new file mode 100644 index 000000000..dbbd60ada --- /dev/null +++ b/Tools/cmake/FindPCRE.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2007-2009 LuaDist. +# Created by Peter Kapec +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Note: +# Searching headers and libraries is very simple and is NOT as powerful as scripts +# distributed with CMake, because LuaDist defines directories to search for. +# Everyone is encouraged to contact the author with improvements. Maybe this file +# becomes part of CMake distribution sometimes. + +# - Find pcre +# Find the native PCRE headers and libraries. +# +# PCRE_INCLUDE_DIRS - where to find pcre.h, etc. +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + +# Look for the header file. +FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h) + +# Look for the library. +FIND_LIBRARY(PCRE_LIBRARY NAMES pcre) + +# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) + +# Copy the results to the output variables. +IF(PCRE_FOUND) + SET(PCRE_LIBRARIES ${PCRE_LIBRARY}) + SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) +ELSE(PCRE_FOUND) + SET(PCRE_LIBRARIES) + SET(PCRE_INCLUDE_DIRS) +ENDIF(PCRE_FOUND) + +MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) diff --git a/Tools/cmake/swigconfig.h.in b/Tools/cmake/swigconfig.h.in new file mode 100644 index 000000000..3f72818f0 --- /dev/null +++ b/Tools/cmake/swigconfig.h.in @@ -0,0 +1,95 @@ +/* Tools/cmake/swigconfig.h.in Generated by cmake. */ + +/* define if the Boost library is available */ +#cmakedefine HAVE_BOOST + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#cmakedefine HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +#cmakedefine HAVE_LIBDLD 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H 1 + +/* Define if pcre is available */ +#cmakedefine HAVE_PCRE 1 + +/* Define if popen is available */ +#cmakedefine HAVE_POPEN 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Name of package */ +#define PACKAGE "swig" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "http://www.swig.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "swig" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "swig @SWIG_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "swig" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.swig.org" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@SWIG_VERSION@" + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@ + +/* Define to 1 if you have the ANSI C header files. */ +#cmakedefine STDC_HEADERS 1 + +/* Compiler that built SWIG */ +#define SWIG_CXX "@SWIG_CXX@" + +/* Directory for SWIG system-independent libraries */ +#define SWIG_LIB "@CMAKE_INSTALL_PREFIX@/@SWIG_LIB@" + +/* Directory for SWIG system-independent libraries (Unix install on native + Windows) */ +#define SWIG_LIB_WIN_UNIX "C:/cygwin/usr/local/@SWIG_LIB@" + +/* Platform that SWIG is built for */ +#define SWIG_PLATFORM "i686-pc-cygwin" + +/* Version number of package */ +#define VERSION "@SWIG_VERSION@" + +/* Default language */ +#define SWIG_LANG "-tcl" + +/* Deal with attempt by Microsoft to deprecate C standard runtime functions */ +#if defined(_MSC_VER) +# define _CRT_SECURE_NO_DEPRECATE +#endif + From 72aefd2207b677a794f8129eeaeca944ce204487 Mon Sep 17 00:00:00 2001 From: Michel Zou Date: Thu, 12 Oct 2017 17:23:07 +0200 Subject: [PATCH 2004/2031] Enable cmake build in CI --- .travis.yml | 15 +++++++++++++++ appveyor.yml | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/.travis.yml b/.travis.yml index 6572bb74b..e8b65d0d4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,18 @@ matrix: os: linux env: SWIGLANG= dist: xenial + - compiler: clang + os: linux + env: SWIGLANG= BUILDSYSTEM=cmake + dist: xenial - compiler: gcc os: linux env: SWIGLANG= dist: xenial + - compiler: gcc + os: linux + env: SWIGLANG= BUILDSYSTEM=cmake + dist: xenial - os: linux env: SWIGLANG= GCC=4.4 dist: xenial @@ -342,6 +350,12 @@ matrix: os: osx osx_image: xcode12.2 env: SWIGLANG= + - compiler: gcc + os: osx + env: SWIGLANG= BUILDSYSTEM=cmake + - compiler: clang + os: osx + env: SWIGLANG= BUILDSYSTEM=cmake - compiler: clang os: osx osx_image: xcode12.2 @@ -439,6 +453,7 @@ install: - if test "$TRAVIS_OS_NAME" = "osx"; then source Tools/travis-osx-install.sh; fi - ls -la $(which $CC) $(which $CXX) && $CC --version && $CXX --version script: + - if test "$BUILDSYSTEM" = "cmake"; then mkdir -p build/build && cd build/build && cmake -DCMAKE_INSTALL_PREFIX=~/.local ../.. && make install && ctest --output-on-failure -V && exit 0; fi - echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r' - if test -n "$CPP11"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++11 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++11; fi - if test -n "$CPP14"; then CONFIGOPTS+=(--enable-cpp11-testing --without-maximum-compile-warnings "CXXFLAGS=-std=c++14 -Wall -Wextra" "CFLAGS=-std=c11 -Wall -Wextra") && export CSTD=c11 && export CPPSTD=c++14; fi diff --git a/appveyor.yml b/appveyor.yml index 3dc08a0de..cf84dd1ea 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,6 +30,8 @@ environment: # WITHLANG: python # VER: 37 # PY3: 3 + - BUILDSYSTEM: cmake + VSVER: 14 matrix: allow_failures: @@ -51,6 +53,7 @@ install: $env:MINGWBIN="C:\msys64\mingw32\bin" $env:MBITS="32" $env:MARCH="i686" + $env:VSARCH="" } else { $env:PCRE_PLATFORM="x64" $env:JAVA_HOME="C:/Program Files/Java/jdk1.8.0" @@ -62,6 +65,7 @@ install: $env:MINGWBIN="C:\msys64\mingw64\bin" $env:MBITS="64" $env:MARCH="x86_64" + $env:VSARCH=" Win64" } - ps: >- if (!$env:OSVARIANT) { @@ -114,6 +118,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor +- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Mon, 22 Feb 2021 09:24:15 +0100 Subject: [PATCH 2005/2031] Misc fixes --- CMakeLists.txt | 155 +++++++++++++++++------------------- Tools/cmake/swigconfig.h.in | 28 +++---- appveyor.yml | 2 +- 3 files changed, 90 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe2f0ccdc..fbe8023dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ endif () project (swig) +if (POLICY CMP0074) + cmake_policy (SET CMP0074 NEW) +endif() + file (STRINGS configure.ac line LIMIT_COUNT 1 REGEX "AC_INIT\\(.*\\)" ) if (line MATCHES "AC_INIT\\(\\[(.*)\\],[ \t]*\\[(.*)\\],[ \t]*\\[(.*)\\]\\)" ) set (SWIG_VERSION ${CMAKE_MATCH_2}) @@ -14,65 +18,67 @@ else () message (SEND_ERROR "Could not parse version from configure.ac") endif () -set(SWIG_ROOT ${PROJECT_SOURCE_DIR}) +set (SWIG_ROOT ${PROJECT_SOURCE_DIR}) set (SWIG_LIB share/swig/${SWIG_VERSION}) # Project wide configuration variables # ------------------------------------ -set(SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) - -set ( PACKAGE_NAME swig ) -set ( PACKAGE_VERSION ${SWIG_VERSION} ) - -# Options -# ------- - -# TODO... +set (SWIG_SOURCE_DIR ${SWIG_ROOT}/Source CACHE INTERNAL "Path of swig sources" FORCE) +set (PACKAGE_NAME swig) +set (PACKAGE_VERSION ${SWIG_VERSION}) # Configure # --------- list (APPEND CMAKE_MODULE_PATH ${SWIG_ROOT}/Tools/cmake) -include(CheckIncludeFiles) -include(CheckIncludeFile) -include(CheckTypeSize) -include(CheckSymbolExists) -include(CheckLibraryExists) -include(CheckCSourceCompiles) +include (CheckIncludeFiles) +include (CheckIncludeFile) +include (CheckIncludeFileCXX) +include (CheckTypeSize) +include (CheckSymbolExists) +include (CheckFunctionExists) +include (CheckLibraryExists) +include (CheckCSourceCompiles) # HACK: didn't get the bool check working for Visual Studio 2008 -if(MSVC) -set(HAVE_BOOL 1) +if (MSVC) + set(HAVE_BOOL 1) else() -set(CMAKE_EXTRA_INCLUDE_FILES stdbool.h) -check_type_size("bool" HAVE_BOOL) -set(CMAKE_EXTRA_INCLUDE_FILES) + set (CMAKE_EXTRA_INCLUDE_FILES stdbool.h) + check_type_size ("bool" HAVE_BOOL) + set (CMAKE_EXTRA_INCLUDE_FILES) endif() -check_include_file("inttypes.h" HAVE_INTTYPES_H) -check_include_file("memory.h" HAVE_MEMORY_H) -check_include_file("stddef.h" HAVE_STDDEF_H) -check_include_file("stdint.h" HAVE_STDINT_H) -check_include_file("stdlib.h" HAVE_STDLIB_H) -check_include_file("string.h" HAVE_STRING_H) -check_include_file("strings.h" HAVE_STRINGS_H) -check_include_file("sys/stat.h" HAVE_SYS_STAT_H) -check_include_file("sys/types.h" HAVE_SYS_TYPES_H) -check_include_file("unistd.h" HAVE_UNISTD_H) -check_include_files( "stdlib.h;stdarg.h;string.h;float.h" HAVE_STDC_HEADERS ) +check_include_file ("inttypes.h" HAVE_INTTYPES_H) +check_include_file ("stddef.h" HAVE_STDDEF_H) +check_include_file ("stdint.h" HAVE_STDINT_H) +check_include_file ("stdio.h" HAVE_STDIO_H) +check_include_file ("stdlib.h" HAVE_STDLIB_H) +check_include_file ("string.h" HAVE_STRING_H) +check_include_file ("strings.h" HAVE_STRINGS_H) +check_include_file ("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file ("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file ("unistd.h" HAVE_UNISTD_H) +check_include_files ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) -check_library_exists(dl dlopen "" HAVE_LIBDL) +check_include_file_cxx ("boost/shared_ptr.hpp" HAVE_BOOST) +check_library_exists (dl dlopen "" HAVE_LIBDL) +check_function_exists (popen HAVE_POPEN) -find_package (PCRE REQUIRED) +set (PCRE_REQUIRED_ARG "REQUIRED" CACHE STRING "required arg") +find_package (PCRE ${PCRE_REQUIRED_ARG}) if (PCRE_FOUND) - add_definitions (-DHAVE_PCRE) + set (HAVE_PCRE 1) include_directories (${PCRE_INCLUDE_DIRS}) endif() +if (WIN32) + file (TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${SWIG_LIB} SWIG_LIB_WIN_UNIX) +endif () configure_file (${SWIG_ROOT}/Tools/cmake/swigconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/Source/Include/swigconfig.h) @@ -82,7 +88,7 @@ find_package (BISON REQUIRED) # Compiler flags # -------------- -include_directories( +include_directories ( ${SWIG_SOURCE_DIR}/CParse ${SWIG_SOURCE_DIR}/Include ${SWIG_SOURCE_DIR}/DOH @@ -95,71 +101,60 @@ include_directories( ) # generate the parser source code (depends on bison) -file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) +file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/Source/CParse) -BISON_TARGET(swig_parser +BISON_TARGET (swig_parser ${SWIG_SOURCE_DIR}/CParse/parser.y ${PROJECT_BINARY_DIR}/Source/CParse/parser.c ) # generate swigwarn.swg -file(READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) -string(REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) -file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) -set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) +file (READ ${SWIG_SOURCE_DIR}/Include/swigwarn.h SWIG_WARN_H) +string (REGEX REPLACE "#define WARN([^ \\t]*)[ \\t]*([0-9]+)" "%define SWIGWARN\\1 \\2 %enddef" SWIG_WARN_SWG ${SWIG_WARN_H}) +file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg ${SWIG_WARN_SWG}) +set_property (SOURCE ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg PROPERTY GENERATED 1) # install lib install (DIRECTORY ${SWIG_ROOT}/Lib/ DESTINATION ${SWIG_LIB}) install (FILES ${CMAKE_CURRENT_BINARY_DIR}/swigwarn.swg DESTINATION ${SWIG_LIB}) -# Libraries +# sources # --------- - -file (GLOB CPARSE_SOURCES ${SWIG_SOURCE_DIR}/CParse/*.c) -add_library (cparse ${CPARSE_SOURCES} - ${PROJECT_BINARY_DIR}/Source/CParse/parser.c - ${PROJECT_BINARY_DIR}/Source/CParse/parser.h -) - -file (GLOB PREPROCESSOR_SOURCES ${SWIG_SOURCE_DIR}/Preprocessor/*.c) -add_library (preprocessor ${PREPROCESSOR_SOURCES}) - file (GLOB DOH_SOURCES ${SWIG_SOURCE_DIR}/DOH/*.c) -add_library (doh ${DOH_SOURCES}) - -file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) -add_library (doxygen ${DOXYGEN_SOURCES}) - +file (GLOB CPARSE_SOURCES ${SWIG_SOURCE_DIR}/CParse/*.c) +list (APPEND CPARSE_SOURCES) +file (GLOB PREPROCESSOR_SOURCES ${SWIG_SOURCE_DIR}/Preprocessor/*.c) file (GLOB CORE_SOURCES ${SWIG_SOURCE_DIR}/Swig/*.c) -add_library (core ${CORE_SOURCES}) -if (PCRE_FOUND) - target_link_libraries (core ${PCRE_LIBRARIES}) -endif () - +file (GLOB DOXYGEN_SOURCES ${SWIG_SOURCE_DIR}/Doxygen/*.cxx) file (GLOB MODULES_SOURCES ${SWIG_SOURCE_DIR}/Modules/*.cxx) -add_library (modules ${MODULES_SOURCES} - ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h - ${SWIG_SOURCE_DIR}/Include/swigwarn.h -) -target_link_libraries(modules doxygen) -add_executable(swig - ${SWIG_SOURCE_DIR}/Modules/main.cxx - ${SWIG_SOURCE_DIR}/Modules/swigmain.cxx +add_executable (swig + ${CPARSE_SOURCES} + ${DOH_SOURCES} + ${DOXYGEN_SOURCES} + ${MODULES_SOURCES} + ${CORE_SOURCES} + ${PREPROCESSOR_SOURCES} + ${PROJECT_BINARY_DIR}/Source/Include/swigconfig.h + ${SWIG_SOURCE_DIR}/Include/swigwarn.h + ${PROJECT_BINARY_DIR}/Source/CParse/parser.c + ${PROJECT_BINARY_DIR}/Source/CParse/parser.h ) - -target_link_libraries (swig cparse preprocessor doh core modules) +if (PCRE_FOUND) + target_link_libraries (swig ${PCRE_LIBRARIES}) +endif () install (TARGETS swig DESTINATION bin) - # 'make package-source' creates tarballs -set ( CPACK_PACKAGE_NAME ${PACKAGE_NAME} ) -set ( CPACK_SOURCE_GENERATOR "TGZ;TBZ2" ) -set ( CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}" ) -set ( CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION} ) -include ( CPack ) +set (CPACK_PACKAGE_NAME ${PACKAGE_NAME}) +set (CPACK_SOURCE_GENERATOR "TGZ;TBZ2") +set (CPACK_SOURCE_IGNORE_FILES "/.git;/build;.*~;${CPACK_SOURCE_IGNORE_FILES}") +set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION}) +include (CPack) -enable_testing() +# few tests +enable_testing () add_test (NAME cmd_version COMMAND swig -version) add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") + diff --git a/Tools/cmake/swigconfig.h.in b/Tools/cmake/swigconfig.h.in index 3f72818f0..94cee1646 100644 --- a/Tools/cmake/swigconfig.h.in +++ b/Tools/cmake/swigconfig.h.in @@ -1,7 +1,7 @@ -/* Tools/cmake/swigconfig.h.in Generated by cmake. */ +/* swigconfig.h. Generated by cmake from Tools/cmake/swigconfig.h.in */ /* define if the Boost library is available */ -#cmakedefine HAVE_BOOST +#cmakedefine HAVE_BOOST 1 /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 @@ -12,10 +12,7 @@ /* Define to 1 if you have the `dld' library (-ldld). */ #cmakedefine HAVE_LIBDLD 1 -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H 1 - -/* Define if pcre is available */ +/* Define if you have PCRE library */ #cmakedefine HAVE_PCRE 1 /* Define if popen is available */ @@ -24,6 +21,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDINT_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDIO_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_STDLIB_H 1 @@ -58,35 +58,35 @@ #define PACKAGE_TARNAME "swig" /* Define to the home page for this package. */ -#define PACKAGE_URL "http://www.swig.org" +#define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "@SWIG_VERSION@" /* The size of `void *', as computed by sizeof. */ -#define SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@ +/* #undef SIZEOF_VOID_P */ -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #cmakedefine STDC_HEADERS 1 /* Compiler that built SWIG */ -#define SWIG_CXX "@SWIG_CXX@" +#define SWIG_CXX "@CMAKE_CXX_COMPILER@" /* Directory for SWIG system-independent libraries */ #define SWIG_LIB "@CMAKE_INSTALL_PREFIX@/@SWIG_LIB@" /* Directory for SWIG system-independent libraries (Unix install on native Windows) */ -#define SWIG_LIB_WIN_UNIX "C:/cygwin/usr/local/@SWIG_LIB@" +#define SWIG_LIB_WIN_UNIX "@SWIG_LIB_WIN_UNIX@" /* Platform that SWIG is built for */ -#define SWIG_PLATFORM "i686-pc-cygwin" +#define SWIG_PLATFORM "@CMAKE_SYSTEM_NAME@" /* Version number of package */ #define VERSION "@SWIG_VERSION@" -/* Default language */ -#define SWIG_LANG "-tcl" /* Deal with attempt by Microsoft to deprecate C standard runtime functions */ #if defined(_MSC_VER) diff --git a/appveyor.yml b/appveyor.yml index cf84dd1ea..47cf893bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -118,7 +118,7 @@ build_script: - set CCCL_OPTIONS=--cccl-muffle /W3 /EHsc - set CHECK_OPTIONS=CSHARPOPTIONS=-platform:%Platform% # Open dummy file descriptor to fix error on cygwin: ./configure: line 560: 0: Bad file descriptor -- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit +- if "%BUILDSYSTEM%"=="cmake" cmake -G "Visual Studio 14 2015%VSARCH%" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DCMAKE_CXX_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib -DBISON_EXECUTABLE=C:/cygwin/bin/bison.exe . && cmake --build . --config Release --target install && ctest --output-on-failure -V -C Release && appveyor exit - if "%OSVARIANT%"=="" bash -c "exec 0 Date: Fri, 26 Feb 2021 21:52:05 +0000 Subject: [PATCH 2006/2031] Javascript: Stop using deprecated Array::Get method --- Lib/javascript/v8/javascriptcomplex.swg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index b894d7389..d1cbe7642 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -43,12 +43,12 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) double re, im; int res; - res = SWIG_AsVal(double)(array->Get(0), &re); + res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 0).ToLocalChecked(), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } - res = SWIG_AsVal(double)(array->Get(1), &im); + res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 1).ToLocalChecked(), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } @@ -85,12 +85,12 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) double re, im; int res; - res = SWIG_AsVal(double)(array->Get(0), &re); + res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 0).ToLocalChecked(), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } - res = SWIG_AsVal(double)(array->Get(1), &im); + res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 1).ToLocalChecked(), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } From 0533fc26ca6922eee55e8dc400bd6a1532a351a6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Feb 2021 22:23:57 +0000 Subject: [PATCH 2007/2031] Fix -Wunused-result warnings in node wrappers --- Lib/javascript/v8/javascriptcode.swg | 4 ++-- Lib/javascript/v8/javascripthelpers.swg | 4 ++-- Lib/javascript/v8/javascriptrun.swg | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index edcc1fd90..79bcaa0a6 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -445,7 +445,7 @@ fail: #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); #else - $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj).Check(); #endif %} @@ -470,7 +470,7 @@ fail: #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); #else - $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); + $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj).Check(); #endif %} diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index cbb43b56d..37a794f92 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -67,7 +67,7 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol, #elif (SWIG_V8_VERSION < 0x0706) obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); #else - obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); + obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()).Check(); #endif } @@ -79,7 +79,7 @@ SWIGRUNTIME void SWIGV8_AddStaticVariable(SWIGV8_OBJECT obj, const char* symbol, #if (V8_MAJOR_VERSION-0) < 5 obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); #else - obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter); + obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter).Check(); #endif } diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 8ce8ff567..5c0a2ff78 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -699,7 +699,7 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0706) arr->Set(arr->Length(), obj); #else - arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj); + arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj).Check(); #endif SWIGV8_ESCAPE(arr); From e6315eedd0f2b65d04df44c0be831d2c43d7d363 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Feb 2021 22:38:28 +0000 Subject: [PATCH 2008/2031] Fix -Wunused-result warnings in node wrappers --- Lib/javascript/v8/javascriptcomplex.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index d1cbe7642..52a554905 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -19,8 +19,8 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) v8::Local vals = SWIGV8_ARRAY_NEW(); - vals->Set(0, SWIG_From(double)(Real(c))); - vals->Set(1, SWIG_From(double)(Imag(c))); + vals->Set(SWIGV8_CURRENT_CONTEXT(), 0, SWIG_From(double)(Real(c))).Check(); + vals->Set(SWIGV8_CURRENT_CONTEXT(), 1, SWIG_From(double)(Imag(c))).Check(); SWIGV8_ESCAPE(vals); } } From 5f76f7e3187a68e65b81326ade37eea3d29d2dd2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Feb 2021 22:45:06 +0000 Subject: [PATCH 2009/2031] Travis testing node 12 now working --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6572bb74b..90a59eb2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -406,12 +406,6 @@ matrix: os: linux env: SWIGLANG=d VER=2.086.1 dist: xenial - # New node support, wip - - compiler: gcc - os: linux - env: SWIGLANG=javascript ENGINE=node VER=12 CPP11=1 - sudo: required - dist: xenial # seg fault in director_basic testcase - compiler: gcc os: linux From 355ef40bc15f2e18372fa749622ee25e849f8d1d Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Wed, 6 Jun 2018 17:20:33 +0200 Subject: [PATCH 2010/2031] Use SWIGV8_INTEGER_NEW_UNS always for unsigned values --- Lib/javascript/v8/javascriptprimtypes.swg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg index a6577ded2..235d8313c 100644 --- a/Lib/javascript/v8/javascriptprimtypes.swg +++ b/Lib/javascript/v8/javascriptprimtypes.swg @@ -81,8 +81,7 @@ int SWIG_AsVal_dec(long)(SWIGV8_VALUE obj, long* val) SWIGINTERNINLINE SWIGV8_VALUE SWIG_From_dec(unsigned long)(unsigned long value) { - return (value > LONG_MAX) ? - SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); + return SWIGV8_INTEGER_NEW_UNS(value); } } From bcc0b6b6164bc867d503a3609c6784ea13d94c42 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Feb 2021 23:24:49 +0000 Subject: [PATCH 2011/2031] Use SWIGV8_INTEGER_NEW_UNS always for unsigned long long --- Lib/javascript/v8/javascriptprimtypes.swg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Lib/javascript/v8/javascriptprimtypes.swg b/Lib/javascript/v8/javascriptprimtypes.swg index 235d8313c..0af406b90 100644 --- a/Lib/javascript/v8/javascriptprimtypes.swg +++ b/Lib/javascript/v8/javascriptprimtypes.swg @@ -149,8 +149,7 @@ int SWIG_AsVal_dec(long long)(SWIGV8_VALUE obj, long long* val) SWIGINTERNINLINE SWIGV8_VALUE SWIG_From_dec(unsigned long long)(unsigned long long value) { - return (value > LONG_MAX) ? - SWIGV8_INTEGER_NEW_UNS(value) : SWIGV8_INTEGER_NEW(%numeric_cast(value,long)); + return SWIGV8_INTEGER_NEW_UNS(value); } %#endif } From 1d4ef62466b7cc67080610b1fd8a91ef9c8a5b92 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Feb 2021 23:29:03 +0000 Subject: [PATCH 2012/2031] Node: Fix handling of large unsigned values Closes #1269 --- CHANGES.current | 4 ++++ .../test-suite/javascript/integers_runme.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Examples/test-suite/javascript/integers_runme.js diff --git a/CHANGES.current b/CHANGES.current index 5611a764c..b4450c943 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-02-26: murillo128, wsfulton + #1269 [Javascript] Fix handling of large positive unsigned long and + unsigned long long values. + 2021-02-24: tomleavy, yegorich, tungntpham #1746 [Javascript] Add support for Node v12. SWIG support is now for Node v6 and later only. diff --git a/Examples/test-suite/javascript/integers_runme.js b/Examples/test-suite/javascript/integers_runme.js new file mode 100644 index 000000000..0356176ad --- /dev/null +++ b/Examples/test-suite/javascript/integers_runme.js @@ -0,0 +1,18 @@ +var integers = require("integers"); + +var val = 3902408827 +ret = integers.signed_long_identity(val) +if (ret != val) + throw "Incorrect value: " + ret + +ret = integers.unsigned_long_identity(val) +if (ret != val) + throw "Incorrect value: " + ret + +ret = integers.signed_long_long_identity(val) +if (ret != val) + throw "Incorrect value: " + ret + +ret = integers.unsigned_long_long_identity(val) +if (ret != val) + throw "Incorrect value: " + ret From 7cb719ee6734cf235f7d9d43cc50ba910a9518eb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2021 13:00:07 +0000 Subject: [PATCH 2013/2031] -Wunused-result fixes for Node < 12 Fix 0533fc26c which adds in calls to Check(), which was added in Node 12. Also fix e6315eedd which calls the new Set() and Check() method. --- Lib/javascript/v8/javascriptcode.swg | 4 ++-- Lib/javascript/v8/javascriptcomplex.swg | 4 ++-- Lib/javascript/v8/javascripthelpers.swg | 4 ++-- Lib/javascript/v8/javascriptrun.swg | 7 ++++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index 79bcaa0a6..8e49101de 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -445,7 +445,7 @@ fail: #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); #else - $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj).Check(); + SWIGV8_MAYBE_CHECK($jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj)); #endif %} @@ -470,7 +470,7 @@ fail: #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsparent_obj->Set(SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj); #else - $jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj).Check(); + SWIGV8_MAYBE_CHECK($jsparent_obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW("$jsname"), $jsmangledname_obj)); #endif %} diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index 52a554905..102f60ca0 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -19,8 +19,8 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) v8::Local vals = SWIGV8_ARRAY_NEW(); - vals->Set(SWIGV8_CURRENT_CONTEXT(), 0, SWIG_From(double)(Real(c))).Check(); - vals->Set(SWIGV8_CURRENT_CONTEXT(), 1, SWIG_From(double)(Imag(c))).Check(); + SWIGV8_MAYBE_CHECK(vals->Set(SWIGV8_CURRENT_CONTEXT(), 0, SWIG_From(double)(Real(c)))); + SWIGV8_MAYBE_CHECK(vals->Set(SWIGV8_CURRENT_CONTEXT(), 1, SWIG_From(double)(Imag(c)))); SWIGV8_ESCAPE(vals); } } diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 37a794f92..0209ab378 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -67,7 +67,7 @@ SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol, #elif (SWIG_V8_VERSION < 0x0706) obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); #else - obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()).Check(); + SWIGV8_MAYBE_CHECK(obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked())); #endif } @@ -79,7 +79,7 @@ SWIGRUNTIME void SWIGV8_AddStaticVariable(SWIGV8_OBJECT obj, const char* symbol, #if (V8_MAJOR_VERSION-0) < 5 obj->SetAccessor(SWIGV8_SYMBOL_NEW(symbol), getter, setter); #else - obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter).Check(); + SWIGV8_MAYBE_CHECK(obj->SetAccessor(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), getter, setter)); #endif } diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 5c0a2ff78..21b0a2a6e 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -143,6 +143,11 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) #endif +#if (SWIG_V8_VERSION < 0x0704) +#define SWIGV8_MAYBE_CHECK(maybe) maybe.FromJust() +#else +#define SWIGV8_MAYBE_CHECK(maybe) maybe.Check() +#endif /* --------------------------------------------------------------------------- * Error handling @@ -699,7 +704,7 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0706) arr->Set(arr->Length(), obj); #else - arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj).Check(); + SWIGV8_MAYBE_CHECK(arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj)); #endif SWIGV8_ESCAPE(arr); From 0e36b5d6fd0dd2ed91d8b042d5951050ce13a09c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2021 14:25:11 +0000 Subject: [PATCH 2014/2031] Fixes for node v12.0-12.5 --- Lib/javascript/v8/javascriptcode.swg | 2 +- Lib/javascript/v8/javascripthelpers.swg | 4 +--- Lib/javascript/v8/javascriptrun.swg | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Lib/javascript/v8/javascriptcode.swg b/Lib/javascript/v8/javascriptcode.swg index 8e49101de..fb41f33ba 100644 --- a/Lib/javascript/v8/javascriptcode.swg +++ b/Lib/javascript/v8/javascriptcode.swg @@ -426,7 +426,7 @@ fail: #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) $jsmangledname_class_0->SetHiddenPrototype(true); v8::Handle $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); -#elif (SWIG_V8_VERSION < 0x0705) +#elif (SWIG_V8_VERSION < 0x0704) $jsmangledname_class_0->SetHiddenPrototype(true); v8::Local $jsmangledname_obj = $jsmangledname_class_0->GetFunction(); #else diff --git a/Lib/javascript/v8/javascripthelpers.swg b/Lib/javascript/v8/javascripthelpers.swg index 0209ab378..9da3ad639 100644 --- a/Lib/javascript/v8/javascripthelpers.swg +++ b/Lib/javascript/v8/javascripthelpers.swg @@ -62,10 +62,8 @@ SWIGRUNTIME void SWIGV8_AddMemberVariable(SWIGV8_FUNCTION_TEMPLATE class_templ, */ SWIGRUNTIME void SWIGV8_AddStaticFunction(SWIGV8_OBJECT obj, const char* symbol, const SwigV8FunctionCallback& _func) { -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0705) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704) obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction()); -#elif (SWIG_V8_VERSION < 0x0706) - obj->Set(SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked()); #else SWIGV8_MAYBE_CHECK(obj->Set(SWIGV8_CURRENT_CONTEXT(), SWIGV8_SYMBOL_NEW(symbol), SWIGV8_FUNCTEMPLATE_NEW(_func)->GetFunction(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked())); #endif diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 21b0a2a6e..92206f3aa 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -9,7 +9,7 @@ #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len) -#elif (SWIG_V8_VERSION < 0x0706) +#elif (SWIG_V8_VERSION < 0x0704) #define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len) #else #define SWIGV8_STRING_NEW2(cstr, len) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::NewStringType::kNormal, len)).ToLocalChecked() @@ -49,7 +49,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err) #define SWIGV8_STRING_NEW(str) v8::String::New(str) #define SWIGV8_SYMBOL_NEW(sym) v8::String::NewSymbol(sym) -#elif (SWIG_V8_VERSION < 0x0706) +#elif (SWIG_V8_VERSION < 0x0704) #define SWIGV8_ADJUST_MEMORY(size) v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(size) #define SWIGV8_CURRENT_CONTEXT() v8::Isolate::GetCurrent()->GetCurrentContext() #define SWIGV8_THROW_EXCEPTION(err) v8::Isolate::GetCurrent()->ThrowException(err) @@ -125,7 +125,7 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_BOOLEAN_VALUE(handle) (handle)->BooleanValue() #define SWIGV8_WRITE_UTF8(handle, buffer, len) (handle)->WriteUtf8(buffer, len) #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length() -#elif (SWIG_V8_VERSION < 0x0706) +#elif (SWIG_V8_VERSION < 0x0704) #define SWIGV8_TO_OBJECT(handle) (handle)->ToObject(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_TO_STRING(handle) (handle)->ToString(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked() #define SWIGV8_NUMBER_VALUE(handle) (handle)->NumberValue(SWIGV8_CURRENT_CONTEXT()).ToChecked() @@ -393,7 +393,7 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(SWIGV8_OBJECT obj, void *ptr, swig_type_i cdata->handle.MarkIndependent(); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); -#elif (SWIG_V8_VERSION < 0x0706) +#elif (SWIG_V8_VERSION < 0x0704) cdata->handle.MarkIndependent(); // Looks like future versions do not require that anymore: // https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11 @@ -445,7 +445,7 @@ SWIGRUNTIME SWIGV8_VALUE SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, } #endif -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0705) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704) v8::Local result = class_templ->InstanceTemplate()->NewInstance(); #else v8::Local result = class_templ->InstanceTemplate()->NewInstance(SWIGV8_CURRENT_CONTEXT()).ToLocalChecked(); @@ -673,7 +673,7 @@ SWIGV8_VALUE SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) cdata->handle.MarkIndependent(); #elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100) cdata->handle.MarkIndependent(v8::Isolate::GetCurrent()); -#elif (SWIG_V8_VERSION < 0x0706) +#elif (SWIG_V8_VERSION < 0x0704) cdata->handle.MarkIndependent(); // Looks like future versions do not require that anymore: // https://monorail-prod.appspot.com/p/chromium/issues/detail?id=923361#c11 @@ -701,7 +701,7 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { } SWIGV8_ARRAY arr = SWIGV8_ARRAY::Cast(result); -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0706) +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704) arr->Set(arr->Length(), obj); #else SWIGV8_MAYBE_CHECK(arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj)); From 11deb82354a47bb291c4e2d43751fe847d71ee58 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2021 16:41:56 +0000 Subject: [PATCH 2015/2031] Restore complex number support for ancient v8 versions --- Lib/javascript/v8/javascriptcomplex.swg | 12 ++++++------ Lib/javascript/v8/javascriptrun.swg | 16 ++++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Lib/javascript/v8/javascriptcomplex.swg b/Lib/javascript/v8/javascriptcomplex.swg index 102f60ca0..b73d5e2dd 100644 --- a/Lib/javascript/v8/javascriptcomplex.swg +++ b/Lib/javascript/v8/javascriptcomplex.swg @@ -19,8 +19,8 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c) v8::Local vals = SWIGV8_ARRAY_NEW(); - SWIGV8_MAYBE_CHECK(vals->Set(SWIGV8_CURRENT_CONTEXT(), 0, SWIG_From(double)(Real(c)))); - SWIGV8_MAYBE_CHECK(vals->Set(SWIGV8_CURRENT_CONTEXT(), 1, SWIG_From(double)(Imag(c)))); + SWIGV8_ARRAY_SET(vals, 0, SWIG_From(double)(Real(c))); + SWIGV8_ARRAY_SET(vals, 1, SWIG_From(double)(Imag(c))); SWIGV8_ESCAPE(vals); } } @@ -43,12 +43,12 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) double re, im; int res; - res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 0).ToLocalChecked(), &re); + res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } - res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 1).ToLocalChecked(), &im); + res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } @@ -85,12 +85,12 @@ SWIG_AsVal_dec(Type) (SWIGV8_VALUE o, Type* val) double re, im; int res; - res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 0).ToLocalChecked(), &re); + res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 0), &re); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } - res = SWIG_AsVal(double)(array->Get(SWIGV8_CURRENT_CONTEXT(), 1).ToLocalChecked(), &im); + res = SWIG_AsVal(double)(SWIGV8_ARRAY_GET(array, 1), &im); if(!SWIG_IsOK(res)) { return SWIG_TypeError; } diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 92206f3aa..f35329acd 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -63,6 +63,12 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_SYMBOL_NEW(sym) (v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym, v8::NewStringType::kNormal)).ToLocalChecked() #endif +#if (SWIG_V8_VERSION < 0x0704) +#define SWIGV8_MAYBE_CHECK(maybe) maybe.FromJust() +#else +#define SWIGV8_MAYBE_CHECK(maybe) maybe.Check() +#endif + #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318) #define SWIGV8_ARRAY_NEW() v8::Array::New() #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool) @@ -81,6 +87,8 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_OBJECT_TEMPLATE v8::Handle #define SWIGV8_VALUE v8::Handle #define SWIGV8_NULL() v8::Null() +#define SWIGV8_ARRAY_GET(array, index) (array)->Get(index) +#define SWIGV8_ARRAY_SET(array, index, value) (array)->Set(index, value) #else #define SWIGV8_ARRAY_NEW() v8::Array::New(v8::Isolate::GetCurrent()) #define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(v8::Isolate::GetCurrent(), bool) @@ -99,6 +107,8 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_OBJECT_TEMPLATE v8::Local #define SWIGV8_VALUE v8::Local #define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent()) +#define SWIGV8_ARRAY_GET(array, index) (array)->Get(SWIGV8_CURRENT_CONTEXT(), index).ToLocalChecked() +#define SWIGV8_ARRAY_SET(array, index, value) SWIGV8_MAYBE_CHECK((array)->Set(SWIGV8_CURRENT_CONTEXT(), index, value)) #endif #if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710) @@ -143,12 +153,6 @@ typedef v8::PropertyCallbackInfo SwigV8PropertyCallbackInfo; #define SWIGV8_UTF8_LENGTH(handle) (handle)->Utf8Length(v8::Isolate::GetCurrent()) #endif -#if (SWIG_V8_VERSION < 0x0704) -#define SWIGV8_MAYBE_CHECK(maybe) maybe.FromJust() -#else -#define SWIGV8_MAYBE_CHECK(maybe) maybe.Check() -#endif - /* --------------------------------------------------------------------------- * Error handling * From 59b780efed9ec3257e7494822609d9518f5a04bc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 20:26:03 +0000 Subject: [PATCH 2016/2031] Cosmetic whitespace --- Lib/javascript/v8/typemaps.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/javascript/v8/typemaps.i b/Lib/javascript/v8/typemaps.i index d3d8afb19..e68b6654a 100644 --- a/Lib/javascript/v8/typemaps.i +++ b/Lib/javascript/v8/typemaps.i @@ -18,7 +18,7 @@ you would use a real value instead. int *INPUT short *INPUT long *INPUT - long long *INPUT + long long *INPUT unsigned int *INPUT unsigned short *INPUT unsigned long *INPUT From f7756be391944444252261e88b4a8d754f6250e3 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Sun, 8 Oct 2017 12:59:53 +0300 Subject: [PATCH 2017/2031] Fix SWIGV8_AppendOutput for OUTPUT typemaps Create array to append to if the existing return type is not void. Closes #405 Closes #1121 --- Lib/javascript/v8/javascriptrun.swg | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index f35329acd..6dd32f49e 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -702,6 +702,14 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { if (result->IsUndefined()) { result = SWIGV8_ARRAY_NEW(); + } else if (!result->IsArray()) { +#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) + v8::Handle tmparr = SWIGV8_ARRAY_NEW(); +#else + v8::Local tmparr = SWIGV8_ARRAY_NEW(); +#endif + tmparr->Set(0, result); + result = tmparr; } SWIGV8_ARRAY arr = SWIGV8_ARRAY::Cast(result); From 7005b156ccd536776a66831117f3d2cf64dfc088 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 20:59:46 +0000 Subject: [PATCH 2018/2031] Modify SWIGV8_AppendOutput to work with newer versions of node --- Lib/javascript/v8/javascriptrun.swg | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index 6dd32f49e..b0064d05e 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -684,6 +684,7 @@ SWIGV8_VALUE SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) #endif SWIGV8_ESCAPE(obj); + } #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIGV8_ConvertPacked(obj, ptr, sz, ty) @@ -703,21 +704,12 @@ SWIGV8_VALUE SWIGV8_AppendOutput(SWIGV8_VALUE result, SWIGV8_VALUE obj) { if (result->IsUndefined()) { result = SWIGV8_ARRAY_NEW(); } else if (!result->IsArray()) { -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) - v8::Handle tmparr = SWIGV8_ARRAY_NEW(); -#else - v8::Local tmparr = SWIGV8_ARRAY_NEW(); -#endif - tmparr->Set(0, result); + SWIGV8_ARRAY tmparr = SWIGV8_ARRAY_NEW(); + SWIGV8_ARRAY_SET(tmparr, 0, result); result = tmparr; } + SWIGV8_ARRAY arr = SWIGV8_ARRAY::Cast(result); - -#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903) || (SWIG_V8_VERSION < 0x0704) - arr->Set(arr->Length(), obj); -#else - SWIGV8_MAYBE_CHECK(arr->Set(SWIGV8_CURRENT_CONTEXT(), arr->Length(), obj)); -#endif - + SWIGV8_ARRAY_SET(arr, arr->Length(), obj); SWIGV8_ESCAPE(arr); } From 769dc27bcd4fdd28771e345f2f2a879ad1465968 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 21:01:41 +0000 Subject: [PATCH 2019/2031] Javascript: Add runtime tests for typemaps.i Tests fix in previous couple of commits. --- .../javascript/li_typemaps_runme.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Examples/test-suite/javascript/li_typemaps_runme.js diff --git a/Examples/test-suite/javascript/li_typemaps_runme.js b/Examples/test-suite/javascript/li_typemaps_runme.js new file mode 100644 index 000000000..987606030 --- /dev/null +++ b/Examples/test-suite/javascript/li_typemaps_runme.js @@ -0,0 +1,49 @@ +var li_typemaps = require("li_typemaps"); + +function check(a, b) { + if (a !== b) { + throw new Error("Not equal: " + a + " " + b) + } +} + +function check_array(a, b) { + if (a.length != b.length) + throw new Error("Array length mismatch " + a.length + " " + b.length) + if (!a.every(function(element, index) { return element === b[index]; })) + throw new Error("Arrays don't match a: " + a + " b:" + b) +} + +// Check double INPUT typemaps +check(li_typemaps.in_double(22.22), 22.22) +check(li_typemaps.inr_double(22.22), 22.22) + +// Check double OUTPUT typemaps +check_array(li_typemaps.out_double(22.22), [22.22]) +check_array(li_typemaps.outr_double(22.22), [22.22]) + +// Check double INOUT typemaps +check_array(li_typemaps.inout_double(22.22), [22.22]) +check_array(li_typemaps.inoutr_double(22.22), [22.22]) + +// check long long +check(li_typemaps.in_ulonglong(20), 20) +check(li_typemaps.inr_ulonglong(20), 20) +check_array(li_typemaps.out_ulonglong(20), [20]) +check_array(li_typemaps.outr_ulonglong(20), [20]) +check_array(li_typemaps.inout_ulonglong(20), [20]) +check_array(li_typemaps.inoutr_ulonglong(20), [20]) + +// check bools +check(li_typemaps.in_bool(true), true) +check(li_typemaps.inr_bool(false), false) +check_array(li_typemaps.out_bool(true), [true]) +check_array(li_typemaps.outr_bool(false), [false]) +check_array(li_typemaps.inout_bool(true), [true]) +check_array(li_typemaps.inoutr_bool(false), [false]) + +// the others +check_array(li_typemaps.inoutr_int2(1,2), [1, 2]) + +fi = li_typemaps.out_foo(10) +check(fi[0].a, 10) +check(fi[1], 20) From 00e64d7a49e0f3ad24574144095d2442313e8877 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 21:58:45 +0000 Subject: [PATCH 2020/2031] Document Javascript OUTPUT typemap fix --- CHANGES.current | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b4450c943..823d4754e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-02-28: alecmev + #405 #1121 [Javascript] Fix OUTPUT typemaps on methods that don't return void. + The output value is appended to the return value. + 2021-02-26: murillo128, wsfulton #1269 [Javascript] Fix handling of large positive unsigned long and unsigned long long values. From 1de4a3a8f6e536175bf7a14125ca2bf214bd28ba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 21:48:12 +0000 Subject: [PATCH 2021/2031] Add Javascript test for missing new in constructor call Testcase for issue #969 and issue #626 --- .../test-suite/javascript/class_scope_weird_runme.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js index 73c118d61..ca18c1b4d 100644 --- a/Examples/test-suite/javascript/class_scope_weird_runme.js +++ b/Examples/test-suite/javascript/class_scope_weird_runme.js @@ -4,3 +4,14 @@ f = new class_scope_weird.Foo(); g = new class_scope_weird.Foo(3); if (f.bar(3) != 3) throw RuntimeError; + +// Test missing new keyword during constructor call +var caughtException = false; +try { + g = class_scope_weird.Foo(4); +} catch (err) { + caughtException = true; +} +if (!caughtException) { + throw new Error("Instantiation exception not thrown"); +} From 5ed74fd19b7771ffa564c970fa5e1d496abad0a4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 28 Feb 2021 22:05:03 +0000 Subject: [PATCH 2022/2031] Add fix for bad constructor call crash to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 823d4754e..c5400b381 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-02-28: p2k + #969 [Javascript] v8/node - prevent crash calling a constructor without new keyword. + 2021-02-28: alecmev #405 #1121 [Javascript] Fix OUTPUT typemaps on methods that don't return void. The output value is appended to the return value. From 4b64becbbb6fa86afe3aa00ce89ac26dafad45ab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Mar 2021 14:20:18 +0000 Subject: [PATCH 2023/2031] OUTPUT typemaps on methods that don't return void SWIGJSC_ValueIsArray could be implemented by JSValueIsArray in later versions of Javascript webkit, similar fix to previous commits for v8. Enhance testing of OUTPUT typemaps to test more than one output. --- .../javascript/li_typemaps_runme.js | 3 ++- Examples/test-suite/li_typemaps.i | 6 ++++- Examples/test-suite/lua/li_typemaps_runme.lua | 4 +-- .../test-suite/perl5/li_typemaps_runme.pl | 5 ++-- Lib/javascript/jsc/javascriptrun.swg | 26 +++++++++++++++++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/javascript/li_typemaps_runme.js b/Examples/test-suite/javascript/li_typemaps_runme.js index 987606030..c0b1b43b0 100644 --- a/Examples/test-suite/javascript/li_typemaps_runme.js +++ b/Examples/test-suite/javascript/li_typemaps_runme.js @@ -10,7 +10,7 @@ function check_array(a, b) { if (a.length != b.length) throw new Error("Array length mismatch " + a.length + " " + b.length) if (!a.every(function(element, index) { return element === b[index]; })) - throw new Error("Arrays don't match a: " + a + " b:" + b) + throw new Error("Arrays don't match a:" + a + " b:" + b) } // Check double INPUT typemaps @@ -47,3 +47,4 @@ check_array(li_typemaps.inoutr_int2(1,2), [1, 2]) fi = li_typemaps.out_foo(10) check(fi[0].a, 10) check(fi[1], 20) +check(fi[2], 30) diff --git a/Examples/test-suite/li_typemaps.i b/Examples/test-suite/li_typemaps.i index a53c1c74a..d508c1c84 100644 --- a/Examples/test-suite/li_typemaps.i +++ b/Examples/test-suite/li_typemaps.i @@ -2,6 +2,7 @@ %include "typemaps.i" +%apply int *OUTPUT { int *OUTPUT2 }; %apply int &INOUT { int &INOUT2 }; %newobject out_foo; %inline %{ @@ -51,10 +52,13 @@ void out_longlong(long long x, long long *OUTPUT) { *OUTPUT = x; } void out_ulonglong(unsigned long long x, unsigned long long *OUTPUT) { *OUTPUT = x; } /* Tests a returning a wrapped pointer and an output argument */ -struct Foo *out_foo(int a, int *OUTPUT) { +struct Foo *out_foo(int a, int *OUTPUT, int *OUTPUT2) { struct Foo *f = new struct Foo(); f->a = a; *OUTPUT = a * 2; + struct Foo *f2 = new struct Foo(); + f2->a = a; + *OUTPUT2 = a * 3; return f; } diff --git a/Examples/test-suite/lua/li_typemaps_runme.lua b/Examples/test-suite/lua/li_typemaps_runme.lua index 7456d8245..342634a5b 100644 --- a/Examples/test-suite/lua/li_typemaps_runme.lua +++ b/Examples/test-suite/lua/li_typemaps_runme.lua @@ -38,5 +38,5 @@ assert(li_typemaps.inoutr_bool(false)==false) a,b=li_typemaps.inoutr_int2(1,2) assert(a==1 and b==2) -f,i=li_typemaps.out_foo(10) -assert(f.a==10 and i==20) +f,i,i2=li_typemaps.out_foo(10) +assert(f.a==10 and i==20 and i2==30) diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl index a573b89a0..2755862a2 100644 --- a/Examples/test-suite/perl5/li_typemaps_runme.pl +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 415; +use Test::More tests => 416; BEGIN { use_ok('li_typemaps') } require_ok('li_typemaps'); @@ -75,10 +75,11 @@ SKIP: { batch('ulonglong', $c); } -my($foo, $int) = li_typemaps::out_foo(10); +my($foo, $int, $int2) = li_typemaps::out_foo(10); isa_ok($foo, 'li_typemaps::Foo'); is($foo->{a}, 10); is($int, 20); +is($int2, 30); my($a, $b) = li_typemaps::inoutr_int2(13, 31); is($a, 13); diff --git a/Lib/javascript/jsc/javascriptrun.swg b/Lib/javascript/jsc/javascriptrun.swg index 4a8fc5be5..26c440244 100644 --- a/Lib/javascript/jsc/javascriptrun.swg +++ b/Lib/javascript/jsc/javascriptrun.swg @@ -317,6 +317,30 @@ unsigned int SWIGJSC_ArrayLength(JSContextRef context, JSObjectRef arr) { } } +SWIGRUNTIME +bool SWIGJSC_ValueIsArray(JSContextRef context, JSValueRef value) { + if (JSValueIsObject(context, value)) { + static JSStringRef ArrayString = NULL; + static JSStringRef isArrayString = NULL; + JSObjectRef array = NULL; + JSObjectRef isArray = NULL; + JSValueRef retval = NULL; + + if (!ArrayString) + ArrayString = JSStringCreateWithUTF8CString("Array"); + if (!isArrayString) + isArrayString = JSStringCreateWithUTF8CString("isArray"); + + array = (JSObjectRef)JSObjectGetProperty(context, JSContextGetGlobalObject(context), ArrayString, NULL); + isArray = (JSObjectRef)JSObjectGetProperty(context, array, isArrayString, NULL); + retval = JSObjectCallAsFunction(context, isArray, NULL, 1, &value, NULL); + + if (JSValueIsBoolean(context, retval)) + return JSValueToBoolean(context, retval); + } + return false; +} + SWIGRUNTIME JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueRef obj) { JSObjectRef arr; @@ -324,6 +348,8 @@ JSValueRef SWIGJSC_AppendOutput(JSContextRef context, JSValueRef value, JSValueR if (JSValueIsUndefined(context, value)) { arr = JSObjectMakeArray(context, 0, 0, 0); + } else if (!SWIGJSC_ValueIsArray(context, value)) { + arr = JSObjectMakeArray(context, 1, &value, 0); } else { arr = JSValueToObject(context, value, 0); } From 1abb726d69c3a84070e56e9f7af46f3a5a544ab2 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 28 Feb 2021 22:41:55 +0100 Subject: [PATCH 2024/2031] configure.ac: pick up javascriptcoregtk-4.0,3.0 if available. Ubuntu 20 doesn't have libwebkitgtk-dev/libjavascriptcoregtk-1.0-dev, but it has 4.0. Ubuntu 18 provides 3.0 as option. --- Tools/javascript/jsc_shell.cxx | 2 +- configure.ac | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Tools/javascript/jsc_shell.cxx b/Tools/javascript/jsc_shell.cxx index 292c4042b..c173c147f 100644 --- a/Tools/javascript/jsc_shell.cxx +++ b/Tools/javascript/jsc_shell.cxx @@ -18,7 +18,7 @@ typedef int (*JSCIntializer)(JSGlobalContextRef context, JSObjectRef *module); public: - JSCShell() {}; + JSCShell() { context = 0; }; virtual ~JSCShell(); diff --git a/configure.ac b/configure.ac index 8f19c2471..77c94a696 100644 --- a/configure.ac +++ b/configure.ac @@ -1600,7 +1600,15 @@ else if test -z "$JSCORELIB" -a -n "$PKG_CONFIG "; then AC_MSG_CHECKING(for JavaScriptCore/Webkit library) - if $PKG_CONFIG javascriptcoregtk-1.0; then + if $PKG_CONFIG javascriptcoregtk-4.0; then + JSCORELIB=`$PKG_CONFIG --libs javascriptcoregtk-4.0` + JSCOREINC=`$PKG_CONFIG --cflags-only-I javascriptcoregtk-4.0` + JSCOREVERSION=`$PKG_CONFIG --modversion javascriptcoregtk-4.0` + elif $PKG_CONFIG javascriptcoregtk-3.0; then + JSCORELIB=`$PKG_CONFIG --libs javascriptcoregtk-3.0` + JSCOREINC=`$PKG_CONFIG --cflags-only-I javascriptcoregtk-3.0` + JSCOREVERSION=`$PKG_CONFIG --modversion javascriptcoregtk-3.0` + elif $PKG_CONFIG javascriptcoregtk-1.0; then JSCORELIB=`$PKG_CONFIG --libs javascriptcoregtk-1.0` JSCOREVERSION=`$PKG_CONFIG --modversion javascriptcoregtk-1.0` fi From e74876f1b828b6c883ef9f6a6088eed8651cf840 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Mar 2021 22:07:55 +0000 Subject: [PATCH 2025/2031] Add table of v8/node versions --- Lib/javascript/v8/javascriptrun.swg | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/javascript/v8/javascriptrun.swg b/Lib/javascript/v8/javascriptrun.swg index b0064d05e..62c7bf829 100644 --- a/Lib/javascript/v8/javascriptrun.swg +++ b/Lib/javascript/v8/javascriptrun.swg @@ -1,6 +1,7 @@ /* --------------------------------------------------------------------------- * These typedefs and defines are used to deal with v8 API changes * + * Useful table of versions: https://nodejs.org/en/download/releases/ * ---------------------------------------------------------------------------*/ // First v8 version that uses "SetWeak" and not "MakeWeak" From 69f9509c2bb973071a97af3cb21fda2866848cd0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Mar 2021 22:51:01 +0000 Subject: [PATCH 2026/2031] Fix incorrect warning "Unknown Doxygen command: ." --- CHANGES.current | 3 +++ Examples/test-suite/doxygen_parsing.i | 1 + Examples/test-suite/java/doxygen_parsing_runme.java | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index dafe7077b..7e99c7490 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-03-01: vadz + #1952 Fix incorrect warning "Unknown Doxygen command: ." + 2020-10-10: wsfulton #252 complex can now be used as a C identifier and doesn't give a syntax error. diff --git a/Examples/test-suite/doxygen_parsing.i b/Examples/test-suite/doxygen_parsing.i index 40f37a4c2..3a559053d 100644 --- a/Examples/test-suite/doxygen_parsing.i +++ b/Examples/test-suite/doxygen_parsing.i @@ -29,6 +29,7 @@ enum SomeEnum */ struct SomeStruct { + int width; ///< \**immutable** image width in pixels }; /** diff --git a/Examples/test-suite/java/doxygen_parsing_runme.java b/Examples/test-suite/java/doxygen_parsing_runme.java index 10d65fca8..29e524f78 100644 --- a/Examples/test-suite/java/doxygen_parsing_runme.java +++ b/Examples/test-suite/java/doxygen_parsing_runme.java @@ -45,6 +45,12 @@ public class doxygen_parsing_runme { " The struct comment \n" + " \n" + ""); + wantedComments.put("doxygen_parsing.SomeStruct.setWidth(int)", + "**immutable** image width in pixels \n" + + ""); + wantedComments.put("doxygen_parsing.SomeStruct.getWidth()", + "**immutable** image width in pixels \n" + + ""); wantedComments.put("doxygen_parsing.doxygen_parsing.setSomeVar(int)", " The var comment \n" + " \n" + From 4ba9d9a8ec69d69832155ad599066eed13b97e09 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Mar 2021 23:42:52 +0000 Subject: [PATCH 2027/2031] CMake test, run -swiglib --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbe8023dd..b36f441fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,7 @@ include (CPack) # few tests enable_testing () add_test (NAME cmd_version COMMAND swig -version) +add_test (NAME cmd_swiglib COMMAND swig -swiglib) add_test (NAME cmd_external_runtime COMMAND swig -external-runtime ext_rt.h) set_tests_properties(cmd_external_runtime PROPERTIES ENVIRONMENT "SWIG_LIB=${PROJECT_SOURCE_DIR}/Lib") From 3f63848940c992cdc91bf5591394250f6b5cff70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Mar 2021 23:55:28 +0000 Subject: [PATCH 2028/2031] Move CMake chapter --- Doc/Manual/Windows.html | 140 ++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 065da215d..28413f1e5 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -33,10 +33,10 @@

        @@ -227,6 +227,75 @@ This information is provided for those that want to modify the SWIG source code Normally this is not needed, so most people will want to ignore this section.

        +

        3.3.1.4 Building swig.exe using CMake

        + + +

        +SWIG can also be built using CMake and Visual Studio rather than autotools. As with the other approaches to +building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW. +For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file. +

        + +
          +
        1. + Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example, and installed to C:\Tools). Nuget is the package manager + for .NET, but allows us to easily install PCRE and other dependencies required by SWIG. +
        2. +
        3. + Install CMake using the following command:
          C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake
          + Alternatively you can download CMake from https://cmake.org/download/. +
        4. +
        5. + Install Bison using the following command:
          C:\Tools\nuget install bison-win32 -Version 2.4.1.1 -OutputDirectory C:\Tools\bison
          + Alternatively download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) + and save to a folder e.g. C:\Tools\Bison +
        6. +
        7. + Install PCRE using Nuget using the following command:
          C:\Tools\nuget install pcre -Version 8.33.0.1 -OutputDirectory C:\Tools\pcre
          +
        8. +
        9. + We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase + using
          git clone https://github.com/swig/swig.git
          + In this example we are assuming the source code is available at C:\swig +
        10. +
        + +

        + We are assuming Visual Studio 2017 is installed. For other versions of Visual Studio change "Visual Studio 15 2017 Win64" to the relevant + Visual Studio Generator. + Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then + build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in a /Release folder. +

        + +
        +
        +cd C:\swig
        +SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH%
        +SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native
        +SET PCRE_PLATFORM=x64
        +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib .
        +cmake --build . --config Release
        +
        +REM to test the exe
        +cd /Release
        +swig.exe -help
        +
        +
        + +

        + In addition to Release builds you can create a Debug build using: +

        +
        +
        cmake --build . --config Debug
        +
        +

        + A Visual Studio solution file should be generated named swig.sln. This can be opened and debugged by running the swig project and setting the + Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following: +

        +
        +
        -python -py3 -shadow -o C:\Temp\doxygen_parsing.c C:\swig\Examples\test-suite\doxygen_parsing.i
        +
        +

        3.3.1.1 Building swig.exe using MinGW and MSYS

        @@ -365,75 +434,6 @@ SWIG. For example, all the source code files can be added to a Visual C++ projec file in order to build swig.exe from the Visual C++ IDE.

        -

        3.3.1.4 Building swig.exe using CMake

        - - -

        -SWIG can also be built using CMake and Visual Studio rather than autotools. As with the other approaches to -building SWIG the dependencies need to be installed. The steps below are one of a number of ways of installing the dependencies without requiring Cygwin or MinGW. -For fully working build steps always check the Continuous Integration setups currently detailed in the Appveyor YAML file. -

        - -
          -
        1. - Install Nuget from https://www.nuget.org/downloads (v5.8.1 is used in this example, and installed to C:\Tools). Nuget is the package manager - for .NET, but allows us to easily install PCRE and other dependencies required by SWIG. -
        2. -
        3. - Install CMake using the following command:
          C:\Tools\nuget install CMake-win64 -Version 3.15.5 -OutputDirectory C:\Tools\CMake
          - Alternatively you can download CMake from https://cmake.org/download/. -
        4. -
        5. - Install Bison using the following command:
          C:\Tools\nuget install bison-win32 -Version 2.4.1.1 -OutputDirectory C:\Tools\bison
          - Alternatively download Bison from https://sourceforge.net/projects/gnuwin32/files/bison/ (2.4.1 is used in this example) - and save to a folder e.g. C:\Tools\Bison -
        6. -
        7. - Install PCRE using Nuget using the following command:
          C:\Tools\nuget install pcre -Version 8.33.0.1 -OutputDirectory C:\Tools\pcre
          -
        8. -
        9. - We will also need the SWIG source code. Either download a zipped archive from GitHub, or if git is installed clone the latest codebase - using
          git clone https://github.com/swig/swig.git
          - In this example we are assuming the source code is available at C:\swig -
        10. -
        - -

        - We are assuming Visual Studio 2017 is installed. For other versions of Visual Studio change "Visual Studio 15 2017 Win64" to the relevant - Visual Studio Generator. - Now we have all the required dependencies we can build SWIG using the commands below. We add the required build tools to the system PATH, and then - build a Release version of SWIG. If all runs successfully a new swig.exe should be generated in a /Release folder. -

        - -
        -
        -cd C:\swig
        -SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH%
        -SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native
        -SET PCRE_PLATFORM=x64
        -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib .
        -cmake --build . --config Release
        -
        -REM to test the exe
        -cd /Release
        -swig.exe -help
        -
        -
        - -

        - In addition to Release builds you can create a Debug build using: -

        -
        -
        cmake --build . --config Debug
        -
        -

        - A Visual Studio solution file should be generated named swig.sln. This can be opened and debugged by running the swig project and setting the - Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following: -

        -
        -
        -python -py3 -shadow -o C:\Temp\doxygen_parsing.c C:\swig\Examples\test-suite\doxygen_parsing.i
        -
        -

        3.3.2 Running the examples on Windows using Cygwin

        From 27f29aef2cf00735172c28d331536d0069b0f1f4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Mar 2021 00:12:46 +0000 Subject: [PATCH 2029/2031] CMake documentation tweaks --- Doc/Manual/Windows.html | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 28413f1e5..5fdd5f5cb 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -36,7 +36,6 @@
      11. Building swig.exe using CMake
      12. Building swig.exe using MinGW and MSYS
      13. Building swig.exe using Cygwin -
      14. Building swig.exe alternatives
      15. Running the examples on Windows using Cygwin @@ -273,7 +272,8 @@ cd C:\swig SET PATH=C:\Tools\CMake\CMake-win64.3.15.5\bin;C:\Tools\bison\bison-win32.2.4.1.1\tools\native\bin;%PATH% SET PCRE_ROOT=C:\Tools\pcre\pcre.8.33.0.1\build\native SET PCRE_PLATFORM=x64 -cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib . +cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_INSTALL_PREFIX="%CD:\=/%/install2" -DCMAKE_C_FLAGS="/DPCRE_STATIC" ^ + -DPCRE_INCLUDE_DIR=%PCRE_ROOT%/include -DPCRE_LIBRARY=%PCRE_ROOT%/lib/v110/%PCRE_PLATFORM%/Release/static/utf8/pcre8.lib . cmake --build . --config Release REM to test the exe @@ -290,10 +290,10 @@ swig.exe -help
      16. A Visual Studio solution file should be generated named swig.sln. This can be opened and debugged by running the swig project and setting the - Debugging Command Arguments. For example to step through one of the sample .i files included with the SWIG source use the following: + Debugging Command Arguments. For example to debug one of the test-suite .i files included with the SWIG source use the following:

        -
        -python -py3 -shadow -o C:\Temp\doxygen_parsing.c C:\swig\Examples\test-suite\doxygen_parsing.i
        +
        -python -c++ -o C:\Temp\doxygen_parsing.cpp C:\swig\Examples\test-suite\doxygen_parsing.i

        3.3.1.1 Building swig.exe using MinGW and MSYS

        @@ -425,14 +425,6 @@ Note that the Cygwin environment will also allow one to regenerate the autotool These files are generated using the autogen.sh script and will only need regenerating in circumstances such as changing the build system.

        -

        3.3.1.3 Building swig.exe alternatives

        - - -

        -If you don't want to install Cygwin or MinGW, use a different compiler to build -SWIG. For example, all the source code files can be added to a Visual C++ project -file in order to build swig.exe from the Visual C++ IDE. -

        3.3.2 Running the examples on Windows using Cygwin

        From e0be0f75178483e70c31aae6071f000706819fe4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Mar 2021 00:13:56 +0000 Subject: [PATCH 2030/2031] html chapter numbering fix --- Doc/Manual/Contents.html | 5 ++--- Doc/Manual/Windows.html | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 59378c50b..0370d4724 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1,4 +1,4 @@ - + @@ -95,10 +95,9 @@ diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 5fdd5f5cb..001d0ef46 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -226,7 +226,7 @@ This information is provided for those that want to modify the SWIG source code Normally this is not needed, so most people will want to ignore this section.

        -

        3.3.1.4 Building swig.exe using CMake

        +

        3.3.1.1 Building swig.exe using CMake

        @@ -296,7 +296,7 @@ swig.exe -help

        -python -c++ -o C:\Temp\doxygen_parsing.cpp C:\swig\Examples\test-suite\doxygen_parsing.i
        -

        3.3.1.1 Building swig.exe using MinGW and MSYS

        +

        3.3.1.2 Building swig.exe using MinGW and MSYS

        @@ -414,7 +414,7 @@ make

      -

      3.3.1.2 Building swig.exe using Cygwin

      +

      3.3.1.3 Building swig.exe using Cygwin

      From 5c602b0dcf2a03882293ec0cf30091809a1c9b70 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 2 Mar 2021 00:15:04 +0000 Subject: [PATCH 2031/2031] CMake added to changes file --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index cf0fcd142..0f69796f2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2021-03-01: xantares, Oliver Buchtala, geographika + #1040 Add support for building SWIG with CMake. See documentation in Windows.html. + 2021-03-01: vadz #1952 Fix incorrect warning "Unknown Doxygen command: ."